зеркало из https://github.com/mozilla/gecko-dev.git
Bug 846257 - Robocop: Extend 'Web Content Context Menu' test to cover the context menu options for images. r=jmaher
This commit is contained in:
Родитель
9c1859f03b
Коммит
4f8816d618
|
@ -36,6 +36,7 @@ _JAVA_TESTS = $(patsubst $(TESTPATH)/%.in,%,$(wildcard $(TESTPATH)/*.java.in))
|
|||
|
||||
_TEST_FILES = \
|
||||
$(wildcard $(TESTPATH)/*.html) \
|
||||
$(wildcard $(TESTPATH)/*.jpg) \
|
||||
$(wildcard $(TESTPATH)/*.sjs) \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -665,5 +665,30 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void bookmark() {
|
||||
if (devType.equals("tablet")) {
|
||||
if (!osVersion.equals("4.x")){
|
||||
Element bookmarkBtn = mDriver.findElement(getActivity(), "bookmark");
|
||||
bookmarkBtn.click();
|
||||
}
|
||||
else {
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.MENU);
|
||||
mSolo.waitForText("^New Tab$");
|
||||
mSolo.clickOnText("^Bookmark$");
|
||||
}
|
||||
}
|
||||
else {
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.MENU);
|
||||
mSolo.waitForText("^New Tab$");
|
||||
if (!osVersion.equals("2.x")) {
|
||||
Element bookmarkBtn = mDriver.findElement(getActivity(), "bookmark");
|
||||
bookmarkBtn.click();
|
||||
}
|
||||
else {
|
||||
mSolo.clickOnText("^Bookmark$");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 9.5 KiB |
|
@ -0,0 +1,13 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Picture Link</title>
|
||||
<link rel="shortcut icon" href="data:image/gif;base64,R0lGODlhCwALAIAAAAAA3pn/ZiH5BAEAAAEALAAAAAALAAsAAAIUhA+hkcuO4lmNVindo7qyrIXiGBYAOw==" />
|
||||
<meta name="viewport" content="initial-scale=1.0"/>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0">
|
||||
<div style="text-align: center; margin: 0; padding: 0">
|
||||
<a style="font-size: 60px" href="robocop_blank_02.html"><img src="Firefox.jpg"></img></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -8,15 +8,30 @@ import android.util.DisplayMetrics;
|
|||
* verify that the context menu is shown and verify that some
|
||||
* of the menu actions work.
|
||||
*/
|
||||
|
||||
public class testWebContentContextMenu extends PixelTest {
|
||||
|
||||
@Override
|
||||
protected int getTestType() {
|
||||
return TEST_MOCHITEST;
|
||||
|
||||
}
|
||||
|
||||
public void testWebContentContextMenu() {
|
||||
blockForGeckoReady();
|
||||
|
||||
String urls [] = { "/robocop/robocop_big_link.html", "/robocop/robocop_big_mailto.html", "/robocop/robocop_picture_link.html"};
|
||||
String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
|
||||
String mailtoMenuItems [] = { "Open With an App", "Copy Email Address", "Share Email Address"};
|
||||
String photoMenuItems [] = { "Copy Image Location", "Share Image", "Set as Wallpaper", "Save Image"};
|
||||
|
||||
verfyLinkContextMenu(linkMenuItems, urls);
|
||||
verfyMailtoContextMenu(mailtoMenuItems, urls);
|
||||
verfyPhotoContextMenu(photoMenuItems, urls);
|
||||
|
||||
}
|
||||
|
||||
public void openContextMenu(int i, String urls []) {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
|
||||
|
@ -24,77 +39,171 @@ public class testWebContentContextMenu extends PixelTest {
|
|||
float top = mDriver.getGeckoTop() + 30 * dm.density;
|
||||
float left = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() / 2;
|
||||
|
||||
// Load the test page and check for 'Open Link'
|
||||
String url = getAbsoluteUrl("/robocop/robocop_big_link.html");
|
||||
String url = getAbsoluteUrl(urls [i]);
|
||||
getInstrumentation().waitForIdleSync();
|
||||
loadAndPaint(url);
|
||||
|
||||
mAsserter.dumpLog("long-clicking at "+left+", "+top);
|
||||
mSolo.clickLongOnScreen(left, top);
|
||||
}
|
||||
|
||||
mAsserter.ok(mSolo.waitForText("^Open Link in New Tab$"), "looking for context menu action", "found 'Open Link in New Tab'");
|
||||
public void accessSection(int i, String opt, String urls []) {
|
||||
openContextMenu(i, urls);
|
||||
mAsserter.ok(mSolo.waitForText(opt), "Waiting for " + opt + " option", "The " + opt + " option is present");
|
||||
mSolo.clickOnText(opt);
|
||||
}
|
||||
|
||||
Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
|
||||
Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
|
||||
mSolo.clickOnText("Open Link");
|
||||
public void verfyLinkContextMenu(String items [], String urls []) {
|
||||
for (String opt:items) {
|
||||
if (opt.equals("Open Link in New Tab")) {
|
||||
openContextMenu(0, urls);
|
||||
mAsserter.ok(mSolo.waitForText(opt), "Waiting for " + opt + " option", "The " + opt + " option is present");
|
||||
Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
|
||||
Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
|
||||
mSolo.clickOnText(opt);
|
||||
|
||||
// Wait for the new tab and page to load
|
||||
tabEventExpecter.blockForEvent();
|
||||
contentEventExpecter.blockForEvent();
|
||||
// Wait for the new tab and page to load
|
||||
tabEventExpecter.blockForEvent();
|
||||
contentEventExpecter.blockForEvent();
|
||||
|
||||
// See tab count
|
||||
Element tabCount = mDriver.findElement(getActivity(), "tabs_count");
|
||||
String tabCountText = null;
|
||||
if (tabCount != null) {
|
||||
tabCountText = tabCount.getText();
|
||||
// See tab count
|
||||
Element tabCount = mDriver.findElement(getActivity(), "tabs_count");
|
||||
String tabCountText = null;
|
||||
if (tabCount != null) {
|
||||
tabCountText = tabCount.getText();
|
||||
}
|
||||
mAsserter.is(tabCountText, "2", "Number of tabs has increased");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Open Link in Private Tab")) {
|
||||
accessSection(2, opt, urls);
|
||||
mAsserter.ok(mSolo.waitForText("New private tab opened"), "Waiting for private tab to open", "The private tab is opened");
|
||||
|
||||
// Verifying if the private data is not listed in Awesomescreen
|
||||
clickOnAwesomeBar();
|
||||
mSolo.clickOnText("History");
|
||||
mAsserter.ok(mSolo.waitForText("Browser Blank Page 01"), "Looking in History for the page loaded in the normal tab", "Fount it");
|
||||
mAsserter.ok(mSolo.waitForText("Browser Blank Page 02") == false, "Looking in History for the page loaded in the private tab", "Page is not present in History");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Copy Link")) {
|
||||
accessSection(0, opt, urls);
|
||||
|
||||
// Verifying if the link was copied
|
||||
mSolo.clickLongOnText("Big Link");
|
||||
mAsserter.ok(mSolo.waitForText("^Paste$"), "Verify if the 'Paste' option is present", "The 'Paste' option is present");
|
||||
mSolo.clickOnText("^Paste$");
|
||||
mAsserter.ok(mSolo.waitForText("robocop_blank_01.html"), "Verify link", "The link was properly copied");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Share Link")) {
|
||||
accessSection(0, opt, urls);
|
||||
|
||||
// Verifying if the Share Link option menu is opened
|
||||
mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the Share Link option menu to open", "The Share Link option menu is opened");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Share Link option menu
|
||||
mSolo.waitForText("Big Link");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Bookmark Link")) {
|
||||
Device mDevice = new Device();
|
||||
Navigation nav = new Navigation(mDevice);
|
||||
|
||||
accessSection(0, opt, urls);
|
||||
mAsserter.is(mSolo.waitForText("Bookmark added"), true, "Bookmark added verified");
|
||||
|
||||
// This waitForIdleSync improves reliability of the following loadUrl.
|
||||
// TODO: understand why!
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
// We know that the link test page points to robocop_blank_01.html, so lets
|
||||
// load it and see if the page is bookmarked
|
||||
String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
loadAndPaint(url);
|
||||
|
||||
// Pause briefly, to ensure that the bookmark addition, above, updates database tables and
|
||||
// completes before checking that the bookmark exists.
|
||||
// TODO: Find a better way to wait for completion of bookmark operations.
|
||||
try { Thread.sleep(2000); } catch(Exception e) {}
|
||||
|
||||
// TODO: This doesn't work for some reason. We got a 'Bookmark added' and
|
||||
// will check for 'Bookmark removed'
|
||||
mAsserter.todo_is(mSolo.isTextChecked("Bookmark"), true, "Page is bookmarked");
|
||||
|
||||
nav.bookmark();
|
||||
mAsserter.is(mSolo.waitForText("Bookmark removed"), true, "Bookmark removal verified");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mAsserter.is(tabCountText, "2", "Number of tabs has increased");
|
||||
}
|
||||
|
||||
// Load the test page again and test for 'Share Link' and 'Bookmark Link'
|
||||
loadAndPaint(url);
|
||||
public void verfyMailtoContextMenu(String items [], String urls []) {
|
||||
for (String opt:items) {
|
||||
if (opt.equals("Copy Email Address")) {
|
||||
openContextMenu(1, urls);
|
||||
mAsserter.ok(mSolo.waitForText(opt), "Waiting for " + opt + " option", "The " + opt + " option is present");
|
||||
mSolo.clickOnText(opt);
|
||||
|
||||
mSolo.clickLongOnScreen(left, top);
|
||||
// Verifying if the email address was copied
|
||||
mSolo.clickLongOnText("Big Mailto");
|
||||
mAsserter.ok(mSolo.waitForText("^Paste$"), "Verify if the 'Paste' option is present", "The 'Paste' option is present");
|
||||
mSolo.clickOnText("^Paste$");
|
||||
mAsserter.ok(mSolo.waitForText("foo.bar@example.com"), "Verify email address", "The email address was properly copied");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Share Email Address")) {
|
||||
accessSection(1, opt, urls);
|
||||
|
||||
mAsserter.ok(mSolo.waitForText("^Share Link$"), "looking for context menu action", "found 'Share Link'");
|
||||
mAsserter.ok(mSolo.waitForText("^Bookmark Link$"), "looking for context menu action", "found 'Bookmark Link'");
|
||||
mSolo.clickOnText("Bookmark");
|
||||
mAsserter.is(mSolo.waitForText("Bookmark added"), true, "Bookmark added verified");
|
||||
// Verifying if the Share email address option menu is opened
|
||||
mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the Share email address option menu to open", "The Share email address option menu is opened");
|
||||
}
|
||||
}
|
||||
}
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the Share email address option menu
|
||||
mSolo.waitForText("Big Mailto");
|
||||
}
|
||||
|
||||
// This waitForIdleSync improves reliability of the following loadUrl.
|
||||
// TODO: understand why!
|
||||
getInstrumentation().waitForIdleSync();
|
||||
// Load a picture test page and test for allowed menu actions
|
||||
public void verfyPhotoContextMenu(String items [], String urls []) {
|
||||
for (String opt:items) {
|
||||
if (opt.equals("Copy Image Location")) {
|
||||
|
||||
// We know that the link test page points to robocop_blank_01.html, so lets
|
||||
// load it and see if the page is bookmarked
|
||||
url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
|
||||
loadAndPaint(url);
|
||||
// This waitForIdleSync improves reliability of the following loadUrl.
|
||||
// TODO: understand why!
|
||||
getInstrumentation().waitForIdleSync();
|
||||
accessSection(2, opt, urls);
|
||||
|
||||
// Pause briefly, to ensure that the bookmark addition, above, updates database tables and
|
||||
// completes before checking that the bookmark exists.
|
||||
// TODO: Find a better way to wait for completion of bookmark operations.
|
||||
try { Thread.sleep(2000); } catch(Exception e) {}
|
||||
// Verifying if the photo's link was copied
|
||||
mSolo.clickLongOnText("Picture Link");
|
||||
mAsserter.ok(mSolo.waitForText("^Paste$"), "Verify if the 'Paste' option is present", "The 'Paste' option is present");
|
||||
mSolo.clickOnText("^Paste$");
|
||||
mAsserter.ok(mSolo.waitForText("Firefox.jpg"), "Verify link", "The photo's link was properly copied");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Share Image")) {
|
||||
accessSection(2, opt, urls);
|
||||
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.MENU);
|
||||
waitForText("Bookmark");
|
||||
|
||||
// TODO: This doesn't work for some reason. We got a 'Bookmark added' and
|
||||
// will check for 'Bookmark removed'
|
||||
mAsserter.todo_is(mSolo.isTextChecked("Bookmark"), true, "Page is bookmarked");
|
||||
|
||||
mSolo.clickOnText("Bookmark");
|
||||
mAsserter.is(mSolo.waitForText("Bookmark removed"), true, "Bookmark removal verified");
|
||||
|
||||
// This waitForIdleSync improves reliability of the following loadUrl.
|
||||
// TODO: understand why!
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
// Load the mailto test page again and test for allowed menu actions
|
||||
url = getAbsoluteUrl("/robocop/robocop_big_mailto.html");
|
||||
loadAndPaint(url);
|
||||
|
||||
mSolo.clickLongOnScreen(left, top);
|
||||
|
||||
mAsserter.ok(mSolo.waitForText("Share"), "looking for context menu action", "found 'Share'");
|
||||
mAsserter.ok(!mSolo.waitForText("^Open Link in New Tab$", 0, 1000, false), "looking for context menu action", "did not find 'Open Link in New Tab'");
|
||||
mAsserter.ok(!mSolo.waitForText("^Bookmark Link$", 0, 1000, false), "looking for context menu action", "did not find 'Bookmark Link'");
|
||||
// Verifying if the Share Image option menu is opened
|
||||
mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the Share Image option menu to open", "The Share Image option menu is opened");
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the Share Image option menu
|
||||
mSolo.waitForText("Picture Link");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Set as Wallpaper")) {
|
||||
openContextMenu(2, urls);
|
||||
mAsserter.ok(mSolo.waitForText(opt), "Waiting for " + opt + " option", "The " + opt + " option is present");
|
||||
}
|
||||
else {
|
||||
if (opt.equals("Save Image")) {
|
||||
mSolo.clickOnText(opt);
|
||||
mAsserter.ok(mSolo.waitForText("Download started"), "Verify that the download started", "The download started");
|
||||
mSolo.waitForText("Picture Link");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче