Marlin and Sailfish test fixes for Sys UI Part One
Change-Id: I6cc324b941071c1b506359348a6561be122fa861
diff --git a/tests/functional/launchertests/src/com/android/launcher/functional/HomeScreenTests.java b/tests/functional/launchertests/src/com/android/launcher/functional/HomeScreenTests.java
index 9f31232..32653c8 100644
--- a/tests/functional/launchertests/src/com/android/launcher/functional/HomeScreenTests.java
+++ b/tests/functional/launchertests/src/com/android/launcher/functional/HomeScreenTests.java
@@ -186,7 +186,7 @@
public void testCreateRenameRemoveFolderOnHome() throws Exception {
// Create two shortcuts on the home screen
createShortcutOnHome("Calculator");
- createShortcutOnHome("Clock");
+ createShortcutOnHome("Gmail");
mDevice.pressHome();
mDevice.waitForIdle();
@@ -195,7 +195,7 @@
UiObject2 calculatorIcon = mDevice.wait
(Until.findObject(By.text("Calculator")), TIMEOUT);
UiObject2 clockIcon = mDevice.wait
- (Until.findObject(By.text("Clock")), TIMEOUT);
+ (Until.findObject(By.text("Gmail")), TIMEOUT);
calculatorIcon.drag(clockIcon.getVisibleCenter(), 1000);
// Verify that there is a new unnamed folder at this point
@@ -206,7 +206,7 @@
(Until.findObject(By.text("Unnamed Folder")), TIMEOUT);
assertNotNull("Custom folder not created", unnamedFolder);
- // Rename the unnamed folder to 'Snowflake'
+ // Rename the unnamed folder to Snowflake.
unnamedFolder.click();
unnamedFolder.setText("Snowflake");
@@ -221,29 +221,20 @@
UiObject2 snowflakeFolder = mDevice.wait
(Until.findObject(By.text("Snowflake")), TIMEOUT);
assertNotNull("Custom folder not created", snowflakeFolder);
+ snowflakeFolder.click();
+ UiObject2 calculatorButton = mDevice.wait
+ (Until.findObject(By.text("Calculator")), TIMEOUT);
+ calculatorButton.click();
+ assertTrue("Calculator wasn't opened from the Google folder",
+ mDevice.wait(Until.hasObject
+ (By.pkg("com.google.android.calculator")), TIMEOUT));
+ mDevice.pressHome();
+ mDevice.waitForIdle();
// Verify that the Snowflake folder can be removed
removeObjectFromHomeScreen(snowflakeFolder, "text", "Snowflake");
}
- // Folders - opening an app from folder
- @MediumTest
- public void testOpenAppFromFolderOnHome() {
- mDevice.pressHome();
- mDevice.waitForIdle();
- UiObject2 googleFolder = mDevice.wait
- (Until.findObject(By.desc("Folder: Google")), TIMEOUT);
- googleFolder.click();
- UiObject2 youTubeButton = mDevice.wait
- (Until.findObject(By.text("YouTube")), TIMEOUT);
- youTubeButton.click();
- assertTrue("Youtube wasn't opened from the Google folder",
- mDevice.wait(Until.hasObject
- (By.pkg("com.google.android.youtube")), TIMEOUT));
- mDevice.pressHome();
- mDevice.waitForIdle();
- }
-
/* This method takes in an object to be drag/dropped onto the
* Remove button hiding behind the search bar
*
@@ -261,14 +252,30 @@
// because today, UIAutomator doesn't allow us to search for an element
// while a touchdown has been executed, but before the touch up.
// FYI: A click is a combination of a touch down and a touch up motion.
- UiObject2 removeButton = mDevice.wait(Until.findObject(By.desc("Google Search")),
- TIMEOUT);
- // Drag the calculator icon to the 'Remove' button to remove it
+ UiObject2 removeButton = null;
+ int removeButtonCenterYCoordinate = 0;
+ String deviceName = mDevice.getProductName();
+ if (deviceName.equals("marlin") || deviceName.equals("sailfish")) {
+ mDevice.wait(Until.findObject(By.res
+ ("com.google.android.apps.nexuslauncher:id/g_icon")),
+ TIMEOUT).click();
+ removeButton = mDevice.wait(Until.findObject
+ (By.res("com.google.android.googlequicksearchbox:id/search_plate")),
+ TIMEOUT);
+ removeButtonCenterYCoordinate = removeButton.getVisibleCenter().y;
+ // Hit back to go back to the regular Home screen
+ mDevice.pressBack();
+ mDevice.waitForIdle();
+ }
+ else {
+ removeButton = mDevice.wait(Until.findObject(By.desc("Google Search")),
+ TIMEOUT);
+ removeButtonCenterYCoordinate = removeButton.getVisibleCenter().y;
+ }
objectToRemove.drag(new Point(mDevice.getDisplayWidth() / 2,
- removeButton.getVisibleCenter().y), 1000);
-
+ removeButtonCenterYCoordinate), 1000);
UiObject2 checkForObject = null;
- // Refetch the calculator icon
+ // Refetch the icon
if (searchCategory.equals("text")) {
checkForObject = mDevice.findObject(By.text(searchContent));
}
@@ -292,8 +299,7 @@
private void createShortcutOnHome(String appName) throws Exception {
// Navigate to All Apps
mDevice.pressHome();
- UiObject2 allApps = mDevice.findObject(By.desc("Apps"));
- allApps.click();
+ mDevice.findObject(mLauncherStrategy.getAllAppsButtonSelector()).click();
mDevice.waitForIdle();
// Long press on the Calculator app for two seconds and release on home screen
diff --git a/tests/functional/launchertests/src/com/android/launcher/functional/PhoneHotseatTests.java b/tests/functional/launchertests/src/com/android/launcher/functional/PhoneHotseatTests.java
index 9a987f3..ad78fdb 100644
--- a/tests/functional/launchertests/src/com/android/launcher/functional/PhoneHotseatTests.java
+++ b/tests/functional/launchertests/src/com/android/launcher/functional/PhoneHotseatTests.java
@@ -20,6 +20,8 @@
import android.content.Intent;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.support.test.launcherhelper.ILauncherStrategy;
+import android.support.test.launcherhelper.LauncherStrategyFactory;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
@@ -34,6 +36,7 @@
private static final String HOTSEAT = "hotseat";
private UiDevice mDevice;
private HotseatHelper hotseatHelper = null;
+ private ILauncherStrategy mLauncherStrategy = null;
@Override
public void setUp() throws Exception {
@@ -44,6 +47,7 @@
} catch (RemoteException e) {
throw new RuntimeException("failed to freeze device orientaion", e);
}
+ mLauncherStrategy = LauncherStrategyFactory.getInstance(mDevice).getLauncherStrategy();
hotseatHelper = HotseatHelper.getInstance(mDevice, getInstrumentation().getContext());
}
@@ -79,7 +83,7 @@
@MediumTest
public void testHomeToAllAppsNavigation() {
- hotseatHelper.launchAppFromHotseat("Apps", getLauncherPackage());
+ mDevice.findObject(mLauncherStrategy.getAllAppsButtonSelector()).click();
assertNotNull("All apps page not found when navigating from hotseat",
mDevice.wait(Until.hasObject(By.res(getLauncherPackage(), "apps_view")), TIMEOUT));
}
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java
index 2d6171b..1a6a795 100644
--- a/tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java
+++ b/tests/functional/settingstests/src/com/android/settings/functional/AboutPhoneSettingsTests.java
@@ -46,7 +46,7 @@
private static final String[] sResourceTexts = {
"Status",
"Legal information",
- "Regulatory information",
+ "Regulatory labels",
"Model number",
"Android version",
"Android security patch level",
@@ -56,7 +56,7 @@
};
private static final String[] sClickableResourceTexts = {
- "Status", "Legal information", "Regulatory information",
+ "Status", "Legal information", "Regulatory labels",
};
@Override
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java b/tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java
index ee4952c..254a825 100644
--- a/tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java
+++ b/tests/functional/settingstests/src/com/android/settings/functional/SoundSettingsTest.java
@@ -45,6 +45,9 @@
@Override
public void tearDown() throws Exception {
+ mDevice.pressBack();
+ mDevice.pressHome();
+ mDevice.waitForIdle();
mDevice.unfreezeRotation();
super.tearDown();
}
@@ -185,7 +188,14 @@
public void testPhoneRingtoneUmbriel() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.clickSetting("Phone ringtone");
- verifyRingtone(new RingtoneSetting("Umbriel", "49"),
+ String ringtone = "Umbriel";
+ String ringtoneSettingValue = "49";
+ if (mDevice.getProductName().equals("marlin")
+ || mDevice.getProductName().equals("sailfish")) {
+ ringtone = "Spaceship";
+ ringtoneSettingValue = "32";
+ }
+ verifyRingtone(new RingtoneSetting(ringtone, ringtoneSettingValue),
Settings.System.RINGTONE, ScrollDir.DOWN);
}
@@ -210,7 +220,14 @@
public void testNotificationRingtoneTitan() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.clickSetting("Default notification ringtone");
- verifyRingtone(new RingtoneSetting("Titan", "35"),
+ String notificationRingtone = "Titan";
+ String notificationSettingValue = "35";
+ if (mDevice.getProductName().equals("marlin")
+ || mDevice.getProductName().equals("sailfish")) {
+ notificationRingtone = "Trill";
+ notificationSettingValue = "24";
+ }
+ verifyRingtone(new RingtoneSetting(notificationRingtone, notificationSettingValue),
Settings.System.NOTIFICATION_SOUND, ScrollDir.DOWN);
}
@@ -226,7 +243,14 @@
public void testAlarmRingtoneXenon() throws Exception {
SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), PAGE);
mHelper.clickSetting("Default alarm ringtone");
- verifyRingtone(new RingtoneSetting("Xenon", "22"),
+ String alarmRingtone = "Xenon";
+ String alarmSettingValue = "22";
+ if (mDevice.getProductName().equals("marlin")
+ || mDevice.getProductName().equals("sailfish")) {
+ alarmRingtone = "Wag";
+ alarmSettingValue = "15";
+ }
+ verifyRingtone(new RingtoneSetting(alarmRingtone, alarmSettingValue),
Settings.System.ALARM_ALERT, ScrollDir.DOWN);
}
@@ -234,6 +258,19 @@
verifyRingtone(r, settingName, ScrollDir.NOSCROLL);
}
+ /*
+ * This method verifies that setting a custom ringtone changes the
+ * ringtone code setting on the system. Each ringtone sound corresponds
+ * to an arbitrary code. To see which ringtone code this is on your device, run
+ * adb shell settings get system ringtone
+ * The number you see at the end of the file path is the one you need.
+ * To see alarms and notifications ringtone codes, run the following:
+ * adb shell settings get system alarm_alert
+ * adb shell settings get system notification_sound
+ * @param r Ringtone setting - the name of the ringtone as displayed on device
+ * @param settingName - the code of the ringtone as explained above
+ * @param dir - the direction in which to scroll
+ */
private void verifyRingtone(RingtoneSetting r, String settingName, ScrollDir dir) {
if (dir != ScrollDir.NOSCROLL) {
mHelper.scrollVert(dir == ScrollDir.UP);
diff --git a/tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java b/tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java
index fca0149..f1ee737 100644
--- a/tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java
+++ b/tests/functional/settingstests/src/com/android/settings/functional/WirelessNetworkSettingsTests.java
@@ -192,7 +192,7 @@
// Check that the SSID field is defaults to the hint.
assertEquals("Enter the SSID", mDevice.wait(Until.findObject(By
.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SSID_RES_ID)
- .clazz(EDIT_TEXT_CLASS)), TIMEOUT)
+ .clazz(EDIT_TEXT_CLASS)), TIMEOUT*2)
.getText());
// Check Security defaults to None.
@@ -657,10 +657,7 @@
continue;
}
// If we get here, we successfully clicked on the Add network button, so we are done.
- // Adding a sleep and a back press to dismiss the IME, as a workaround for
- // b/28862652
Thread.sleep(SLEEP_TIME*5);
- mDevice.pressBack();
return;
}