From efca963a956217410148de7b16ed29e52f16566a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Tue, 4 Jun 2024 08:37:09 +0000 Subject: [PATCH] Trying to rule things out Change-Id: I7176201b8e7edf4261cb019ec58c2ca19c79907a --- .../apps/nowinandroid/ui/EdgeToEdgeTest.kt | 147 +++++++++--------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt index 2bc90cea9..5bec93f71 100644 --- a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt +++ b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt @@ -80,70 +80,71 @@ class EdgeToEdgeTest { @get:Rule(order = 3) val activityScenarioRule = ActivityScenarioRule(MainActivity::class.java) - @get:Rule(order = 4) - val dropshots = Dropshots() +// @get:Rule(order = 4) +// val dropshots = Dropshots() @Before fun setup() = hiltRule.inject() - - @Before - fun enableDemoMode() { - UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply { - executeShellCommand("settings put global sysui_demo_allowed 1") - executeShellCommand( - "am broadcast -a com.android.systemui.demo -e command " + - "enter", - ) - executeShellCommand( - "am broadcast -a com.android.systemui.demo -e command " + - "notifications -e visible false", - ) - executeShellCommand( - "am broadcast -a com.android.systemui.demo -e command " + - "clock -e hhmm 1234", - ) - executeShellCommand( - "am broadcast -a com.android.systemui.demo -e command " + - "network -e wifi hide", - ) - executeShellCommand( - "am broadcast -a com.android.systemui.demo -e command " + - "network -e mobile hide", - ) - } - } - - companion object { - @JvmStatic - @AfterClass - fun resetDemoMode() { - executeShellCommand("am broadcast -a com.android.systemui.demo -e command exit") - } - } - - @RequiresDisplay(WidthSizeClassEnum.COMPACT, HeightSizeClassEnum.MEDIUM) - @SdkSuppress(minSdkVersion = 27, maxSdkVersion = 27) - @Test - fun edgeToEdge_Phone_Api27() { - screenshotSystemBar("edgeToEdge_Phone_systemBar_Api27") - screenshotNavigationBar("edgeToEdge_Phone_navBar_Api27") - } +// +// @Before +// fun enableDemoMode() { +// UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply { +// executeShellCommand("settings put global sysui_demo_allowed 1") +// executeShellCommand( +// "am broadcast -a com.android.systemui.demo -e command " + +// "enter", +// ) +// executeShellCommand( +// "am broadcast -a com.android.systemui.demo -e command " + +// "notifications -e visible false", +// ) +// executeShellCommand( +// "am broadcast -a com.android.systemui.demo -e command " + +// "clock -e hhmm 1234", +// ) +// executeShellCommand( +// "am broadcast -a com.android.systemui.demo -e command " + +// "network -e wifi hide", +// ) +// executeShellCommand( +// "am broadcast -a com.android.systemui.demo -e command " + +// "network -e mobile hide", +// ) +// } +// } +// +// companion object { +// @JvmStatic +// @AfterClass +// fun resetDemoMode() { +// executeShellCommand("am broadcast -a com.android.systemui.demo -e command exit") +// } +// } +// +// @RequiresDisplay(WidthSizeClassEnum.COMPACT, HeightSizeClassEnum.MEDIUM) +// @SdkSuppress(minSdkVersion = 27, maxSdkVersion = 27) +// @Test +// fun edgeToEdge_Phone_Api27() { +// screenshotSystemBar("edgeToEdge_Phone_systemBar_Api27") +// screenshotNavigationBar("edgeToEdge_Phone_navBar_Api27") +// } @RequiresDeviceMode(mode = FLAT) @RequiresDeviceMode(mode = CLOSED) @SdkSuppress(minSdkVersion = 33, maxSdkVersion = 33) @Test fun edgeToEdge_Foldable_api33() { - runFoldableTests(apiName = "api33") - } - - @RequiresDeviceMode(mode = FLAT) - @RequiresDeviceMode(mode = CLOSED) - @SdkSuppress(minSdkVersion = 35, codeName = "VanillaIceCream") - @Test - fun edgeToEdge_Foldable_api35() { - runFoldableTests(apiName = "api35") + assert(true) + //runFoldableTests(apiName = "api33") } +// +// @RequiresDeviceMode(mode = FLAT) +// @RequiresDeviceMode(mode = CLOSED) +// @SdkSuppress(minSdkVersion = 35, codeName = "VanillaIceCream") +// @Test +// fun edgeToEdge_Foldable_api35() { +// runFoldableTests(apiName = "api35") +// } // Very flaky:DeviceControllerOperationException: Device could not be set to the // requested screen orientation. @@ -167,7 +168,7 @@ class EdgeToEdgeTest { screenshotNavigationBar("edgeToEdge_Foldable_closed_navGesture_$apiName") //onDevice().setFlatMode() - enableDemoMode() // Flat mode resets demo mode! + //enableDemoMode() // Flat mode resets demo mode! screenshotSystemBar("edgeToEdge_Foldable_flat_system_$apiName") forceThreeButtonNavigation() screenshotNavigationBar("edgeToEdge_Foldable_flat_nav3button_$apiName") @@ -236,22 +237,22 @@ class EdgeToEdgeTest { ) } - fun assertSnapshot( - bitmap: Bitmap, - name: String, - filePath: String? = null, - ) { - // Try to assert 3 times - var count = 2 - while (true) { - try { - dropshots.assertSnapshot(bitmap, name, filePath) - } catch (e: AssertionError) { - if (count == 0) throw e - count -= 1 - Log.i("EdgeToEdgeTest", "Test failed, retrying (count=$count)") - waitForWindowUpdate() - } - } - } +// fun assertSnapshot( +// bitmap: Bitmap, +// name: String, +// filePath: String? = null, +// ) { +// // Try to assert 3 times +// var count = 2 +// while (true) { +// try { +// dropshots.assertSnapshot(bitmap, name, filePath) +// } catch (e: AssertionError) { +// if (count == 0) throw e +// count -= 1 +// Log.i("EdgeToEdgeTest", "Test failed, retrying (count=$count)") +// waitForWindowUpdate() +// } +// } +// } }