mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 747835: Back, Forward and Reload buttons test. r=jmaher
This commit is contained in:
parent
42e9f5bddc
commit
718c2a6f10
@ -5,6 +5,7 @@ import com.jayway.android.robotium.solo.Solo;
|
|||||||
import @ANDROID_PACKAGE_NAME@.*;
|
import @ANDROID_PACKAGE_NAME@.*;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -18,6 +19,8 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenient base class suitable for most Robocop tests.
|
* A convenient base class suitable for most Robocop tests.
|
||||||
@ -349,8 +352,30 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|||||||
|
|
||||||
public final void verifyPageTitle(String title) {
|
public final void verifyPageTitle(String title) {
|
||||||
Element awesomebar = mDriver.findElement(getActivity(), "awesome_bar_title");
|
Element awesomebar = mDriver.findElement(getActivity(), "awesome_bar_title");
|
||||||
mAsserter.isnot(awesomebar, null, "Got the awesomebar");
|
String pageTitle = null;
|
||||||
assertMatches(awesomebar.getText(), title, "Page title match");
|
if (awesomebar != null) {
|
||||||
|
// Wait for the title to make sure it has been displayed in case the view
|
||||||
|
// does not update fast enough
|
||||||
|
waitForTest(new VerifyTitle(awesomebar, title), MAX_WAIT_MS);
|
||||||
|
pageTitle = awesomebar.getText();
|
||||||
|
}
|
||||||
|
mAsserter.is(pageTitle, title, "Page title is correct");
|
||||||
|
}
|
||||||
|
|
||||||
|
class VerifyTitle implements BooleanTest {
|
||||||
|
private Element mAwesomebar;
|
||||||
|
private String mTitle;
|
||||||
|
public VerifyTitle(Element awesomebar, String title) {
|
||||||
|
mAwesomebar = awesomebar;
|
||||||
|
mTitle = title;
|
||||||
|
}
|
||||||
|
public boolean test() {
|
||||||
|
String pageTitle = mAwesomebar.getText();
|
||||||
|
if (pageTitle.equals(mTitle)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void verifyTabCount(int expectedTabCount) {
|
public final void verifyTabCount(int expectedTabCount) {
|
||||||
@ -392,4 +417,112 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|||||||
mActions.sendKeys(url);
|
mActions.sendKeys(url);
|
||||||
hitEnterAndWait();
|
hitEnterAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Device {
|
||||||
|
Build.VERSION mBuildVersion;
|
||||||
|
public String version; // 2.x or 3.x or 4.x
|
||||||
|
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 {
|
||||||
|
if (mSDK > Build.VERSION_CODES.HONEYCOMB_MR2) {
|
||||||
|
version = "4.x";
|
||||||
|
}
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate() {
|
||||||
|
if (getActivity().getRequestedOrientation () == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
||||||
|
mSolo.setActivityOrientation(Solo.PORTRAIT);
|
||||||
|
}
|
||||||
|
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"){
|
||||||
|
Element backBtn = mDriver.findElement(getActivity(), "back");
|
||||||
|
backBtn.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forward() {
|
||||||
|
if (devType == "tablet"){
|
||||||
|
Element fwdBtn = mDriver.findElement(getActivity(), "forward");
|
||||||
|
fwdBtn.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mActions.sendSpecialKey(Actions.SpecialKey.MENU);
|
||||||
|
mSolo.waitForText("^New Tab$");
|
||||||
|
if (osVersion != "2.x") {
|
||||||
|
Element fwdBtn = mDriver.findElement(getActivity(), "forward");
|
||||||
|
fwdBtn.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mSolo.clickOnText("^Forward$");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
if (devType == "tablet"){
|
||||||
|
Element reloadBtn = mDriver.findElement(getActivity(), "reload");
|
||||||
|
reloadBtn.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mActions.sendSpecialKey(Actions.SpecialKey.MENU);
|
||||||
|
mSolo.waitForText("^New Tab$");
|
||||||
|
if (osVersion != "2.x") {
|
||||||
|
Element reloadBtn = mDriver.findElement(getActivity(), "reload");
|
||||||
|
reloadBtn.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mSolo.clickOnText("^Forward$");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
[testHistory]
|
[testHistory]
|
||||||
[testVkbOverlap]
|
[testVkbOverlap]
|
||||||
[testDoorHanger]
|
[testDoorHanger]
|
||||||
|
[testTabHistory]
|
||||||
# [testPermissions] # see bug 757475
|
# [testPermissions] # see bug 757475
|
||||||
# [testJarReader] # see bug 738890
|
# [testJarReader] # see bug 738890
|
||||||
|
|
||||||
|
53
mobile/android/base/tests/testTabHistory.java.in
Executable file
53
mobile/android/base/tests/testTabHistory.java.in
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
#filter substitution
|
||||||
|
package @ANDROID_PACKAGE_NAME@.tests;
|
||||||
|
|
||||||
|
import @ANDROID_PACKAGE_NAME@.*;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class testTabHistory extends PixelTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getTestType() {
|
||||||
|
return TEST_MOCHITEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This test will check the functionality of the Back, Forward and Reload buttons.
|
||||||
|
First it will determine the Device and the OS.
|
||||||
|
Then it will create the appropriate navigation mechanisms for back, forward and reload depending on device type and OS.
|
||||||
|
Finally it will run the tests */
|
||||||
|
|
||||||
|
public void testTabHistory() {
|
||||||
|
blockForGeckoReady();
|
||||||
|
|
||||||
|
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||||
|
String url2 = getAbsoluteUrl("/robocop/robocop_blank_02.html");
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Go to the 2nd page
|
||||||
|
nav.back();
|
||||||
|
mSolo.waitForText("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();
|
||||||
|
verifyPageTitle("Browser Blank Page 02");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user