Fix Abvt Tests

Bug: 30898195
Bug: 31244390
Bug: 31244663
Bug: 31244388
Change-Id: I3725af51ccd447f8513d3d882a8ee1956298a051
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java b/tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java
index cce964c..26d2e07 100644
--- a/tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java
+++ b/tests/androidbvt/src/com/android/androidbvt/SysSettingTests.java
@@ -36,6 +36,7 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.regex.Pattern;
+
 import junit.framework.TestCase;
 /**
  * Contain following tests for setting tests:
@@ -82,8 +83,8 @@
 
     private HashMap<String, String> mSecureSettings = new HashMap<String, String>();
     {
-        // By default screensaver is enabled
-        mSecureSettings.put("screensaver_enabled", "1");
+        // By default screensaver is disabled
+        mSecureSettings.put("screensaver_enabled", "0");
     }
 
     private Map<SettingType, HashMap<String, String>> mSettings =
@@ -216,7 +217,8 @@
         mABvtHelper.launchQuickSettingsAndWait();;
         mDevice.wait(Until.findObject(By.descContains("Open settings.")), mABvtHelper.LONG_TIMEOUT)
                 .click();
-        UiObject2 settingHeading = mDevice.wait(Until.findObject(By.text("Settings")),
+        Pattern pattern = Pattern.compile("Settings", Pattern.CASE_INSENSITIVE);
+        UiObject2 settingHeading = mDevice.wait(Until.findObject(By.text(pattern)),
                 mABvtHelper.LONG_TIMEOUT);
         assertNotNull("Setting menu has not loaded correctly", settingHeading);
     }
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java b/tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java
index 07e4af9..fcf4924 100644
--- a/tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java
+++ b/tests/androidbvt/src/com/android/androidbvt/SysUILauncherTests.java
@@ -55,7 +55,7 @@
     private ILauncherStrategy mLauncherStrategy = null;
     private AndroidBvtHelper mABvtHelper = null;
     private SettingsHelperImpl mHelper;
-    private boolean mIsMr1Device = false;
+    private boolean mIsNexusDevice = false;
 
     @Override
     public void setUp() throws Exception {
@@ -66,7 +66,7 @@
         mLauncherStrategy = LauncherStrategyFactory.getInstance(mDevice).getLauncherStrategy();
         mABvtHelper = AndroidBvtHelper.getInstance(mDevice, mContext,
                 InstrumentationRegistry.getInstrumentation().getUiAutomation());
-        mIsMr1Device = mABvtHelper.isNexusExperienceDevice();
+        mIsNexusDevice = mABvtHelper.isNexusExperienceDevice();
         mHelper =  new SettingsHelperImpl(InstrumentationRegistry.getInstrumentation());
     }
 
@@ -120,7 +120,7 @@
             mDevice.wait(Until.findObject(By.clazz(WIDGET_TEXT_VIEW)
                     .text("WALLPAPERS")), LONG_TIMEOUT).click();
             Thread.sleep(LONG_TIMEOUT);
-            testWallPaper(mIsMr1Device);
+            testWallPaper(mIsNexusDevice);
             Thread.sleep(LONG_TIMEOUT);
             WallpaperManager wallpaperManagerPost = WallpaperManager.getInstance(mContext);
             Drawable wallPaperPost = wallpaperManagerPost.getDrawable().getCurrent();
@@ -155,15 +155,20 @@
      */
     private void removeObject(UiObject2 app) throws InterruptedException {
         // Drag shortcut/widget icon to Remove button which behinds Google Search bar
-        String remove = mIsMr1Device ? "Search" : "Google Search";
+        String remove = mIsNexusDevice ? "Search" : "Google Search";
         UiObject2 removeButton = mDevice.wait(Until.findObject(By.desc(remove)),
                 LONG_TIMEOUT);
-        app.drag(new Point(mDevice.getDisplayWidth() / 2, removeButton.getVisibleCenter().y),
-                1000);
+        if (mIsNexusDevice){
+            app.drag(new Point(removeButton.getVisibleCenter().x, removeButton.getVisibleCenter().y),
+                    1000);
+        }else{
+            app.drag(new Point(mDevice.getDisplayWidth() / 2, removeButton.getVisibleCenter().y),
+                    1000);
+        }
     }
 
-    private void testWallPaper(boolean mIsMr1Device)  throws InterruptedException {
-        if (mIsMr1Device){ //test marlin and sailfish
+    private void testWallPaper(boolean mIsNexusDevice)  throws InterruptedException {
+        if (mIsNexusDevice){ //test marlin and sailfish
             UiObject2 viewScroll = mDevice.wait(Until.findObject(By.clazz("android.support.v7.widget.RecyclerView")), LONG_TIMEOUT);
             while(viewScroll.scroll(Direction.DOWN, 1.0f));
             UiObject2 wallpaperSets = mDevice.wait(Until.findObject(By.res(WALLPAPER_PKG,"tile")), LONG_TIMEOUT);
diff --git a/tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java b/tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java
index c766498..8cb6a58 100644
--- a/tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java
+++ b/tests/androidbvt/src/com/android/androidbvt/SysUILockScreenTests.java
@@ -48,7 +48,7 @@
     private AndroidBvtHelper mABvtHelper = null;
     private UiDevice mDevice = null;
     private Context mContext;
-    private boolean mIsMr1Device = false;
+    private boolean mIsNexusDevice = false;
     private GoogleCameraHelperImpl mCameraHelper;
 
     @Override
@@ -61,7 +61,7 @@
                 InstrumentationRegistry.getInstrumentation().getUiAutomation());
         mDevice.wakeUp();
         mDevice.pressHome();
-        mIsMr1Device = mABvtHelper.isNexusExperienceDevice();
+        mIsNexusDevice = mABvtHelper.isNexusExperienceDevice();
         mCameraHelper = new GoogleCameraHelperImpl(InstrumentationRegistry.getInstrumentation());
     }
 
@@ -378,7 +378,7 @@
         navigateToScreenLock();
         mDevice.wait(Until.findObject(By.text(mode)), mABvtHelper.LONG_TIMEOUT).click();
         // set up Secure start-up page
-        if (!mIsMr1Device) {
+        if (!mIsNexusDevice) {
             mDevice.wait(Until.findObject(By.text("No thanks")), mABvtHelper.LONG_TIMEOUT).click();
         }
         UiObject2 pinField = mDevice.wait(Until.findObject(By.clazz(EDIT_TEXT_CLASS_NAME)),