Bug 837318: Update testVkbOverlap to account for tablet behavior; r=wesj
authorGeoff Brown <gbrown@mozilla.com>
Tue, 19 Feb 2013 12:02:15 -0700
changeset 122353 16c9ccf0e50b856a1033e6cca670abe4b1b5eeb2
parent 122352 6b7d9acf0d5bae954491108b06113c5a7607d28a
child 122354 8619eb3bdee1abd6a8e456af8834a3b44390fdb8
push id24336
push userryanvm@gmail.com
push dateWed, 20 Feb 2013 12:07:46 +0000
treeherdermozilla-central@1bcc3c56b011 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs837318
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 837318: Update testVkbOverlap to account for tablet behavior; r=wesj
mobile/android/base/tests/BaseTest.java.in
mobile/android/base/tests/testTabHistory.java.in
mobile/android/base/tests/testVkbOverlap.java.in
--- a/mobile/android/base/tests/BaseTest.java.in
+++ b/mobile/android/base/tests/BaseTest.java.in
@@ -541,113 +541,111 @@ abstract class BaseTest extends Activity
         // cannot use loadUrl(): getText fails because we are using a different urlbar
         mActions.sendKeys(url);
         hitEnterAndWait();
     }
 
     class Device {
         Build.VERSION mBuildVersion;
         public String version; // 2.x or 3.x or 4.x
-        public String type; // tablet or phone
+        public String type; // "tablet" or "phone"
         public int width;
         public int height;
 
         public Device() {
             detectDevice();
         }
 
         private void detectDevice() {
             // Determine device version
             mBuildVersion = new Build.VERSION();
             int mSDK = mBuildVersion.SDK_INT;
             if (mSDK < Build.VERSION_CODES.HONEYCOMB) {
                 version = "2.x";
-            }
-            else {
+            } else {
                 if (mSDK > Build.VERSION_CODES.HONEYCOMB_MR2) {
                     version = "4.x";
-                }
-                else {
+                } else {
                     version = "3.x";
                 }
             }
 
             // Determine with and height
             DisplayMetrics dm = new DisplayMetrics();
             getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
             height = dm.heightPixels;
             width = dm.widthPixels;
 
             // Determine device type
-            if (width > 480 && height > 480) {
-                type = "tablet";
-            }
-            else {
-                type = "phone";
+            type = "phone";
+            try {
+                ClassLoader classLoader = getActivity().getClassLoader();
+                Class appsCls = classLoader.loadClass("org.mozilla.gecko.GeckoAppShell");
+                Method isTabletMethod = appsCls.getMethod("isTablet", (Class[]) null);
+                boolean isTablet = (Boolean)isTabletMethod.invoke(null);
+                if (isTablet) {
+                    type = "tablet";
+                }
+            } catch (Exception e) {
+                mAsserter.dumpLog("Exception in detectDevice", e);
             }
         }
 
         public void rotate() {
             if (getActivity().getRequestedOrientation () == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                 mSolo.setActivityOrientation(Solo.PORTRAIT);
-            }
-            else {
+            } else {
                 mSolo.setActivityOrientation(Solo.LANDSCAPE);
             }
         }
     }
 
     class Navigation {
         private String devType;
         private String osVersion;
 
         public Navigation(Device mDevice) {
             devType = mDevice.type;
             osVersion = mDevice.version;
         }
 
         public void back() {
-            if (devType == "tablet"){
+            if (devType.equals("tablet")) {
                 Element backBtn = mDriver.findElement(getActivity(), "back");
                 backBtn.click();
-            }
-            else {
+            } else {
                 mActions.sendSpecialKey(Actions.SpecialKey.BACK);
             }
         }
 
         public void forward() {
-            if (devType == "tablet"){
+            if (devType.equals("tablet")) {
                 Element fwdBtn = mDriver.findElement(getActivity(), "forward");
                 fwdBtn.click();
-            }
-            else {
+            } else {
                 mActions.sendSpecialKey(Actions.SpecialKey.MENU);
                 mSolo.waitForText("^New Tab$");
-                if (osVersion != "2.x") {
+                if (!osVersion.equals("2.x")) {
                     Element fwdBtn = mDriver.findElement(getActivity(), "forward");
                     fwdBtn.click();
-                }
-                else {
+                } else {
                     mSolo.clickOnText("^Forward$");
                 }
             }
         }
 
         public void reload() {
-            if (devType == "tablet"){
+            if (devType.equals("tablet")) {
                 Element reloadBtn = mDriver.findElement(getActivity(), "reload");
                 reloadBtn.click();
-            }
-            else {
+            } else {
                 mActions.sendSpecialKey(Actions.SpecialKey.MENU);
                 mSolo.waitForText("^New Tab$");
-                if (osVersion != "2.x") {
+                if (!osVersion.equals("2.x")) {
                     Element reloadBtn = mDriver.findElement(getActivity(), "reload");
                     reloadBtn.click();
-                }
-                else {
-                    mSolo.clickOnText("^Forward$");
+                } else {
+                    mSolo.clickOnText("^Reload$");
                 }
             }
         }
     }
 }
--- a/mobile/android/base/tests/testTabHistory.java.in
+++ b/mobile/android/base/tests/testTabHistory.java.in
@@ -24,30 +24,36 @@ public class testTabHistory extends Pixe
         String url3 = getAbsoluteUrl("/robocop/robocop_blank_03.html");
 
         // Create tab history
         loadAndPaint(url);
         loadAndPaint(url2);
         loadAndPaint(url3);
 
         // Get the device information and create the navigation for it
-        Device mDevice = new Device();
-        Navigation nav = new Navigation(mDevice);
+        Device device = new Device();
+        Navigation nav = new Navigation(device);
+        mAsserter.dumpLog("device type: "+device.type);
+        mAsserter.dumpLog("device version: "+device.version);
+        mAsserter.dumpLog("device width: "+device.width);
+        mAsserter.dumpLog("device height: "+device.height);
 
         // Go to the 2nd page
         nav.back();
         mSolo.waitForText("Browser Blank Page 02");
+        verifyPageTitle("Browser Blank Page 02");
 
         // Go to the first page
         nav.back();
         mSolo.waitForText("Browser Blank Page 01");
         verifyPageTitle("Browser Blank Page 01");
 
         // Go forward to the second page
         nav.forward();
         mSolo.waitForText("Browser Blank Page 02");
         verifyPageTitle("Browser Blank Page 02");
 
         // Reload page
         nav.reload();
+        mSolo.waitForText("Browser Blank Page 02");
         verifyPageTitle("Browser Blank Page 02");
     }
 }
--- a/mobile/android/base/tests/testVkbOverlap.java.in
+++ b/mobile/android/base/tests/testVkbOverlap.java.in
@@ -17,20 +17,21 @@ public class testVkbOverlap extends Pixe
     private static final int PAGE_SETTLE_TIME = 5000;
 
     @Override
     protected int getTestType() {
         return TEST_MOCHITEST;
     }
 
     public void testVkbOverlap() {
+        Device device = new Device();
         blockForGeckoReady();
         testSetup("initial-scale=1.0, user-scalable=no", false);
         testSetup("initial-scale=1.0", false);
-        testSetup("", true);
+        testSetup("", "phone".equals(device.type));
     }
 
     private void testSetup(String viewport, boolean shouldZoom) {
         loadAndPaint(getAbsoluteUrl("/robocop/test_viewport.sjs?metadata=" + Uri.encode(viewport)));
 
         // scroll to the bottom of the page and let it settle
         Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
         MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());