由于Ext.ready引起的tree重复显示和不显示问题解决办法

bug:

点击保存后会加载慢导致tree出不来、或是加载多个tree。

 

这两个问题都是因为一个原因造成的,使用两处Ext的onReady造成了加载延迟。Ext.onReady需要页面全部加载完后才能在客户端的代码中使用,而test.jsp页面有两处使用了onReady方法,这样,在一个onReady方法还没执行完就又开了一个线程去执行onReady,所以会出现,还没加载完的不显示,还有都加载完的显示多个的tree。

 

 

点击“发起任务”时执行了遍onReady,执行“发起同级任务”的保存时(”loadMy”函数),又写了个onReady函数。所以导致了发起任务--新增同级任务多次点击保存时,会因为onReady等待加载html内容而不显示tree。

 

 

解决办法:

去掉一个onReady,发起任务时的,或者是发起同级任务时的保存中的。

plugins { id &#39;com.android.application&#39; } apply from: &#39;jacoco-report.gradle&#39; def cfg = rootProject.ext.configuration android { compileSdk cfg.targetSdk defaultConfig { applicationId cfg.applicationId minSdk cfg.minSdk targetSdk cfg.targetSdk versionCode cfg.versionCode versionName cfg.versionName } signingConfigs { release { storeFile file("$rootDir/platform.jks") storePassword = "123456" keyPassword = "123456" keyAlias = "ktplatfrom" } debug { storeFile file("$rootDir/platform.jks") storePassword = "123456" keyPassword = "123456" keyAlias = "ktplatfrom" } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(&#39;proguard-android-optimize.txt&#39;), &#39;proguard-rules.pro&#39; } debugCoverage { minifyEnabled false testCoverageEnabled false } } // buildTypes { // release { // minifyEnabled false // signingConfig signingConfigs.release // } // debug { // minifyEnabled false // signingConfig signingConfigs.debug // debuggable true // testCoverageEnabled false // } // } applicationVariants.all { variant -> variant.outputs.all { output -> def newName = "ktLauncher.apk" outputFileName = newName } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } dataBinding { enabled = true } buildFeatures { aidl true } //儿童模式 flavorDimensions "default" productFlavors { _NORMAL_MODE { buildConfigField("int", "user_model", "0") } _CHILD_MODE { buildConfigField("int", "user_model", &#39;1&#39;) } } testOptions { unitTests { includeAndroidResources = true returnDefaultValues = true } } } gradle.projectsEvaluated { tasks.withType(JavaCompile) { Set<File> fileSet = options.bootstrapClasspath.getFiles() List<File> newFileList = new ArrayList<>(); //将framework.jar插入到最前面 newFileList.add(new File("libs/framework.jar")) //最后将原始的数据插入 newFileList.addAll(fileSet) options.bootstrapClasspath = files( newFileList.toArray() ) } } dependencies { // api fileTree(include: [&#39;*.jar&#39;], dir: &#39;libs&#39;) implementation rootProject.ext.dependencies["appcompat"] implementation rootProject.ext.dependencies["material"] implementation rootProject.ext.dependencies["constraintlayout"] implementation rootProject.ext.dependencies["lifecycle-extensions"] implementation rootProject.ext.dependencies["gson"] implementation project(&#39;:base&#39;) compileOnly files(&#39;libs/framework.jar&#39;) implementation &#39;com.github.bumptech.glide:glide:4.12.0&#39; implementation &#39;com.android.support:design:28.0.0&#39; implementation "androidx.constraintlayout:constraintlayout:2.1.3" annotationProcessor &#39;com.github.bumptech.glide:compiler:4.12.0&#39; // test testImplementation &#39;org.powermock:powermock-module-junit4:2.0.7&#39; testImplementation &#39;org.powermock:powermock-module-junit4-rule:1.7.4&#39; testImplementation &#39;org.powermock:powermock-api-mockito2:2.0.7&#39; testImplementation &#39;org.mockito:mockito-core:3.3.3&#39; testImplementation &#39;android.arch.core:core-testing:1.1.1&#39; testImplementation &#39;org.mockito:mockito-inline:3.11.2&#39; } -----build.gradle----------- apply plugin: &#39;jacoco&#39; //gradlew clean & gradlew createOfflineTestCoverageReport & gradlew jacocoTestReport tasks.withType(Test) { jacoco.includeNoLocationClasses = true jacoco.excludes = [&#39;jdk.internal.*&#39;] } configurations { jacocoAnt jacocoRuntime } jacoco { toolVersion = "0.8.5" } def offline_instrumented_outputDir = "$buildDir.path/intermediates/classes-instrumented/debugCoverage" tasks.withType(Test) { jacoco.includeNoLocationClasses = true jacoco.excludes = [&#39;jdk.internal.*&#39;] } def coverageSourceDirs = [ &#39;src/main/java&#39; ] task jacocoTestReport(type: JacocoReport, dependsOn: "test") { group = "Reporting" description = "Generate Jacoco coverage reports" classDirectories.from = fileTree( dir: &#39;./build/intermediates/javac/debugCoverage/classes/&#39;, excludes: [ &#39;**/R.class&#39;, &#39;**/R$*.class&#39;, &#39;**/Manifest*.*&#39;, &#39;**/*Test*.*&#39;, &#39;android/**/*.*&#39;, &#39;**/BuildConfig.*&#39;, &#39;**/**Bean.class&#39;, &#39;**/inputmethod/*&#39;, &#39;**/config/*.*&#39;, &#39;**/flex/*.*&#39;, &#39;**/AssetsUtils.class&#39; ] ) getSourceDirectories().setFrom(files(coverageSourceDirs)) getExecutionData().setFrom(files(&#39;./build/jacoco/testDebugUnitTest.exec&#39;)) } jacocoTestReport { reports { xml.enabled true html.enabled true html.destination file("build/test-results/jacocoHtml") } } /* This task is used to create offline instrumentation of classes for on-the-fly instrumentation coverage tool like Jacoco. See jacoco classId * and Offline Instrumentation from the jacoco site for more info. * * In this case, some classes mocked using PowerMock were reported as 0% coverage on jacoco & Sonarqube. The issue between PowerMock and jacoco * is well documented, and a possible solution is offline Instrumentation (not so well documented for gradle). * * In a nutshell, this task: * - Pre-instruments the original *.class files * - Puts the instrumented classes path at the beginning of the task&#39;s classpath (for report purposes) * - Runs test & generates a new exec file based on the pre-instrumented classes -- as opposed to on-the-fly instrumented class files generated by jacoco. * * It is currently not implemented to run prior to any other existing tasks (like test, jacocoTestReport, etc...), therefore, it should be called * explicitly if Offline Instrumentation report is needed. * * Usage: gradle clean & gradle createOfflineInstrTestCoverageReport & gradle jacocoTestReport * - gradle clean //To prevent influence from any previous task execution * - gradle createOfflineInstrTestCoverageReport //To generate *.exec file from offline instrumented class * - gradle jacocoTestReport //To generate html report from newly created *.exec task */ task createOfflineTestCoverageReport(dependsOn: [&#39;instrument&#39;, &#39;testDebugCoverageUnitTest&#39;]) { group = "reporting" doLast { ant.taskdef(name: &#39;report&#39;, classname: &#39;org.jacoco.ant.ReportTask&#39;, classpath: configur3+ations.jacocoAnt.asPath) ant.report() { executiondata { ant.file(file: "$buildDir.path/jacoco/testDebugCoverageUnitTest.exec") } structure(name: &#39;Example&#39;) { classfiles { fileset(dir: "$project.buildDir/intermediates/javac/debugCoverage") } sourcefiles { fileset(dir: &#39;src/main/java&#39;) } } //Uncomment if we want the task to generate jacoco html reports. However, the current script does not exclude files. //An alternative is to used jacocoTestReport after this task finishes //html(destdir: "$buildDir.path/reports/jacocoHtml") } } } createOfflineTestCoverageReport.dependsOn(clean) /* * Part of the Offline Instrumentation process is to add the jacoco runtime to the class path along with the path of the instrumented files. */ gradle.taskGraph.whenReady { graph -> if (graph.hasTask(instrument)) { tasks.withType(Test) { doFirst { systemProperty &#39;jacoco-agent.destfile&#39;, buildDir.path + &#39;/jacoco/testDebugCoverageUnitTest.exec&#39; classpath = files(offline_instrumented_outputDir) + classpath + configurations.jacocoRuntime } } } } /* * Instruments the classes per se */ task instrument(dependsOn:&#39;compileDebugUnitTestSources&#39;) { doLast { println &#39;Instrumenting classes&#39; ant.taskdef(name: &#39;instrument&#39;, classname: &#39;org.jacoco.ant.InstrumentTask&#39;, classpath: configurations.jacocoAnt.asPath) ant.instrument(destdir: offline_instrumented_outputDir) { fileset(dir: "$buildDir.path/intermediates/javac/debugCoverage") } } } -----jacoco-report.gradle--------------- jacoco-report.gradle 在同一个项目中的base模块可以正常生成jacoco单元测试覆盖率报告,但是在app模块无法生成,build文件夹中,都没有jacoco test-results文件夹。上述的jacoco-report.gradlebuild.gradle是app模块的内容 请问应该如何解决app模块无法显示jacoco报告的问题i
最新发布
07-23
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值