Bug 730941 - Add testcase for "view image" context menu entry. r=wesj, r=mcomella

This commit is contained in:
Anuj Sahai 2014-04-15 00:26:29 +05:30
parent 55ba67a65d
commit 684d18af11
2 changed files with 23 additions and 1 deletions

View File

@ -1,10 +1,13 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.Actions;
import org.mozilla.gecko.Element;
import org.mozilla.gecko.R;
import org.mozilla.gecko.util.Clipboard;
import android.util.DisplayMetrics;
import com.jayway.android.robotium.solo.Condition;
/**
* This class covers interactions with the context menu opened from web content
@ -65,6 +68,22 @@ abstract class ContentContextMenuTest extends PixelTest {
mSolo.clickOnText(tab);
}
protected void verifyViewImageOption(final String viewImageOption, final String imageUrl) {
if (!mSolo.searchText(viewImageOption)) {
openWebContentContextMenu(viewImageOption);
}
mSolo.clickOnText(viewImageOption);
boolean viewedImage = waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
final Element urlBarElement = mDriver.findElement(getActivity(), R.id.url_edit_text);
final String loadedUrl = urlBarElement.getText();
return loadedUrl.contentEquals(imageUrl);
}
}, MAX_TEST_TIMEOUT);
mAsserter.ok(viewedImage, "Checking if the image is correctly viewed", "The image was correctly viewed");
mSolo.goBack();
}
protected void verifyCopyOption(String copyOption, final String copiedText) {
if (!mSolo.searchText(copyOption)) {

View File

@ -6,9 +6,10 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
// Test website strings
private static String PICTURE_PAGE_URL;
private static String BLANK_PAGE_URL;
private static String PICTURE_URL;
private static final String PICTURE_PAGE_TITLE = "Picture Link";
private static final String tabs [] = { "Image", "Link" };
private static final String photoMenuItems [] = { "Copy Image Location", "Share Image", "Set Image As", "Save Image" };
private static final String photoMenuItems [] = { "Copy Image Location", "Share Image", "View Image", "Set Image As", "Save Image" };
private static final String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
private static final String imageTitle = "^Image$";
@ -17,6 +18,7 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
PICTURE_PAGE_URL=getAbsoluteUrl("/robocop/robocop_picture_link.html");
BLANK_PAGE_URL=getAbsoluteUrl("/robocop/robocop_blank_02.html");
PICTURE_URL=getAbsoluteUrl("/robocop/Firefox.jpg");
loadAndPaint(PICTURE_PAGE_URL);
verifyPageTitle(PICTURE_PAGE_TITLE);
@ -27,6 +29,7 @@ public class testPictureLinkContextMenu extends ContentContextMenuTest {
verifyCopyOption(photoMenuItems[0], "Firefox.jpg"); // Test the "Copy Image Location" option
switchTabs(imageTitle);
verifyShareOption(photoMenuItems[1], PICTURE_PAGE_TITLE); // Test the "Share Image" option
verifyViewImageOption(photoMenuItems[2], PICTURE_URL); // Test the "View Image" option
verifyContextMenuItems(linkMenuItems);
openTabFromContextMenu(linkMenuItems[0],2); // Test the "Open in New Tab" option - expecting 2 tabs: the original and the new one