From 2ce38abbf4de486c247f97c5ea35304532eb8bfb Mon Sep 17 00:00:00 2001 From: nikhil kumar Date: Thu, 25 Jul 2024 21:24:15 +0530 Subject: [PATCH] TP-74933 | Dismiss NUX while running macrobenchmark tests (#11905) --- .github/workflows/macrobenchmark.yml | 2 +- .../benchmark/home/HomePageScrollBenchmark.kt | 12 ++++++++++-- .../naviapp/benchmark/startup/StartupBenchmark.kt | 7 ++++++- .../com/naviapp/benchmark/utils/HomePageActions.kt | 10 ++++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/macrobenchmark.yml b/.github/workflows/macrobenchmark.yml index 376cc5309b..d3a076a5df 100644 --- a/.github/workflows/macrobenchmark.yml +++ b/.github/workflows/macrobenchmark.yml @@ -58,7 +58,7 @@ jobs: --type instrumentation \ --app ${{ github.workspace }}/android/app/build/outputs/apk_from_bundle/qaRelease/app-qa-release-universal.apk \ --test ${{ github.workspace }}/android/benchmark/build/outputs/apk/qa/benchmark/benchmark-qa-benchmark.apk \ - --test-targets "class com.naviapp.benchmark.baselineprofile.HomePageScrollBaselineProfile, class com.naviapp.benchmark.startup.StartupBenchmark#startupPrecompiledWithBaselineProfile, class com.naviapp.benchmark.home.HomePageScrollBenchmark#scrollHomeCompilationBaselineProfile" \ + --test-targets "class com.naviapp.benchmark.baselineprofile.NaviBaselineProfile, class com.naviapp.benchmark.startup.StartupBenchmark#startupPrecompiledWithBaselineProfile, class com.naviapp.benchmark.home.HomePageScrollBenchmark#scrollHomeCompilationBaselineProfile" \ --device model=akita,version=34,locale=en,orientation=portrait \ --directories-to-pull /sdcard/Download \ --results-bucket navi-android-super-app-benchmark-results-qa \ diff --git a/android/benchmark/src/main/java/com/naviapp/benchmark/home/HomePageScrollBenchmark.kt b/android/benchmark/src/main/java/com/naviapp/benchmark/home/HomePageScrollBenchmark.kt index 364255fd5c..a77dc9ea75 100644 --- a/android/benchmark/src/main/java/com/naviapp/benchmark/home/HomePageScrollBenchmark.kt +++ b/android/benchmark/src/main/java/com/naviapp/benchmark/home/HomePageScrollBenchmark.kt @@ -7,6 +7,9 @@ package com.naviapp.benchmark.home +import android.os.Build +import androidx.annotation.RequiresApi +import androidx.benchmark.macro.BaselineProfileMode.Require import androidx.benchmark.macro.CompilationMode import androidx.benchmark.macro.FrameTimingMetric import androidx.benchmark.macro.StartupMode @@ -25,9 +28,14 @@ import org.junit.runner.RunWith class HomePageScrollBenchmark { @get:Rule val benchmarkRule = MacrobenchmarkRule() - @Test fun scrollHomeCompilationNone() = scrollHomePage(CompilationMode.None()) + @RequiresApi(Build.VERSION_CODES.N) + @Test + fun scrollHomeCompilationNone() = scrollHomePage(CompilationMode.None()) - @Test fun scrollHomeCompilationBaselineProfile() = scrollHomePage(CompilationMode.Partial()) + @RequiresApi(Build.VERSION_CODES.N) + @Test + fun scrollHomeCompilationBaselineProfile() = + scrollHomePage(CompilationMode.Partial(baselineProfileMode = Require)) @Test fun scrollHomeCompilationFull() = scrollHomePage(CompilationMode.Full()) diff --git a/android/benchmark/src/main/java/com/naviapp/benchmark/startup/StartupBenchmark.kt b/android/benchmark/src/main/java/com/naviapp/benchmark/startup/StartupBenchmark.kt index c063089b80..d87141ac8a 100644 --- a/android/benchmark/src/main/java/com/naviapp/benchmark/startup/StartupBenchmark.kt +++ b/android/benchmark/src/main/java/com/naviapp/benchmark/startup/StartupBenchmark.kt @@ -7,6 +7,8 @@ package com.naviapp.benchmark.startup +import android.os.Build +import androidx.annotation.RequiresApi import androidx.benchmark.macro.BaselineProfileMode.Require import androidx.benchmark.macro.CompilationMode import androidx.benchmark.macro.StartupMode @@ -25,8 +27,11 @@ import org.junit.runner.RunWith class StartupBenchmark { @get:Rule val benchmarkRule = MacrobenchmarkRule() - @Test fun startupWithoutPreCompilation() = startup(CompilationMode.None()) + @RequiresApi(Build.VERSION_CODES.N) + @Test + fun startupWithoutPreCompilation() = startup(CompilationMode.None()) + @RequiresApi(Build.VERSION_CODES.N) @Test fun startupPrecompiledWithBaselineProfile() = startup(CompilationMode.Partial(baselineProfileMode = Require)) diff --git a/android/benchmark/src/main/java/com/naviapp/benchmark/utils/HomePageActions.kt b/android/benchmark/src/main/java/com/naviapp/benchmark/utils/HomePageActions.kt index 441706e14e..cf59c88a85 100644 --- a/android/benchmark/src/main/java/com/naviapp/benchmark/utils/HomePageActions.kt +++ b/android/benchmark/src/main/java/com/naviapp/benchmark/utils/HomePageActions.kt @@ -16,17 +16,23 @@ import java.util.concurrent.TimeUnit fun MacrobenchmarkScope.waitForHomePage() { val okButton = By.text("OK") - val dialog = device.wait(Until.findObject(okButton), TimeUnit.SECONDS.toMillis(20)) + val dialog = device.wait(Until.findObject(okButton), TimeUnit.SECONDS.toMillis(5)) dialog?.let { it.click() device.wait(Until.gone(okButton), TimeUnit.SECONDS.toMillis(5)) } // Sometime location popup coming two times so adding one more check - val dialog2 = device.wait(Until.findObject(okButton), TimeUnit.SECONDS.toMillis(20)) + val dialog2 = device.wait(Until.findObject(okButton), TimeUnit.SECONDS.toMillis(5)) dialog2?.let { it.click() device.wait(Until.gone(okButton), TimeUnit.SECONDS.toMillis(5)) } + val nux = + device.wait( + Until.findObject(By.text("Make your first payment")), + TimeUnit.SECONDS.toMillis(10) + ) + nux?.let { device.pressBack() } device.wait(Until.hasObject(By.clazz(HOME_PAGE_CLASS_NAME)), TimeUnit.SECONDS.toMillis(10)) }