From 5b439a3f444aaf4cc1c43c76fef1319c9e610572 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Tue, 12 Sep 2023 21:50:14 +0800 Subject: [PATCH] Fix DevelopmentSettingsTest And MoreWirelessSettingsTests.testVPNMenuLoad Bug: 290684887 Test: ui test Change-Id: I37ef70d1f6f75cd1721ab9ba0763f7ec20be80d0 --- .../android/settings/ui/DevelopmentSettingsTest.kt | 11 ++++++++--- .../settings/ui/MoreWirelessSettingsTests.java | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/uitests/src/com/android/settings/ui/DevelopmentSettingsTest.kt b/tests/uitests/src/com/android/settings/ui/DevelopmentSettingsTest.kt index 1afa3ab6945..12153839618 100644 --- a/tests/uitests/src/com/android/settings/ui/DevelopmentSettingsTest.kt +++ b/tests/uitests/src/com/android/settings/ui/DevelopmentSettingsTest.kt @@ -16,13 +16,14 @@ package com.android.settings.ui -import android.os.SystemClock import android.provider.Settings import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice import com.android.settings.ui.testutils.SettingsTestUtils.assertHasTexts +import com.android.settings.ui.testutils.SettingsTestUtils.clickObject import com.android.settings.ui.testutils.SettingsTestUtils.startMainActivityFromHomeScreen import org.junit.Before import org.junit.Test @@ -35,8 +36,11 @@ class DevelopmentSettingsTest { @Before fun setUp() { - device.executeShellCommand("settings put global development_settings_enabled 1") - SystemClock.sleep(1000) + device.startMainActivityFromHomeScreen(Settings.ACTION_DEVICE_INFO_SETTINGS) + device.assertHasTexts(listOf(BUILD_NUMBER)) + repeat(7) { // Enable development mode + device.clickObject(By.text(BUILD_NUMBER)) + } device.startMainActivityFromHomeScreen(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS) } @@ -46,6 +50,7 @@ class DevelopmentSettingsTest { } private companion object { + private const val BUILD_NUMBER = "Build number" val ON_SCREEN_TEXTS = listOf( "Use developer options", "Memory", diff --git a/tests/uitests/src/com/android/settings/ui/MoreWirelessSettingsTests.java b/tests/uitests/src/com/android/settings/ui/MoreWirelessSettingsTests.java index 5bfc59df337..25b47673e30 100644 --- a/tests/uitests/src/com/android/settings/ui/MoreWirelessSettingsTests.java +++ b/tests/uitests/src/com/android/settings/ui/MoreWirelessSettingsTests.java @@ -24,6 +24,7 @@ import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.MediumTest; import androidx.test.uiautomator.By; +import androidx.test.uiautomator.Direction; import androidx.test.uiautomator.UiDevice; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; @@ -86,8 +87,8 @@ public class MoreWirelessSettingsTests extends InstrumentationTestCase { public void testVPNMenuLoad() throws Exception { SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), Settings.ACTION_WIRELESS_SETTINGS); - mDevice.wait(Until - .findObject(By.text("VPN")), TIMEOUT) + mDevice.findObject(By.res(SETTINGS_PACKAGE, "main_content")) + .scrollUntil(Direction.DOWN, Until.findObject(By.text("VPN"))) .click(); Thread.sleep(TIMEOUT); UiObject2 usbTethering = mDevice.wait(Until