Bug 837318: Update testVkbOverlap to account for tablet behavior; r=wesj

This commit is contained in:
Geoff Brown 2013-02-19 12:02:15 -07:00
parent 139ae58c04
commit 8fa6b4f565
3 changed files with 36 additions and 31 deletions

View File

@ -546,7 +546,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
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;
@ -560,12 +560,10 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
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";
}
}
@ -577,19 +575,24 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
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);
}
}
@ -605,47 +608,42 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
}
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$");
}
}
}

View File

@ -29,12 +29,17 @@ public class testTabHistory extends PixelTest {
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();
@ -48,6 +53,7 @@ public class testTabHistory extends PixelTest {
// Reload page
nav.reload();
mSolo.waitForText("Browser Blank Page 02");
verifyPageTitle("Browser Blank Page 02");
}
}

View File

@ -22,10 +22,11 @@ public class testVkbOverlap extends PixelTest {
}
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) {