Bug 730941 - Add testcase for "view image" context menu entry. r=wesj, r=mcomella
☠☠ backed out by d26a2463dc6b ☠ ☠
authorAnuj Sahai <sahai.anuj16@gmail.com>
Tue, 15 Apr 2014 00:26:29 +0530
changeset 180424 bb54e487c53ed820ab0a128ef30a1bf34bbc4a9c
parent 180423 882b5ddfc023fd9518c87f33e8ea19bfce5f85f9
child 180425 bbcb7f37b1760fe56bff7906cdf3cbc84972e90f
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerswesj, mcomella
bugs730941
milestone31.0a1
Bug 730941 - Add testcase for "view image" context menu entry. r=wesj, r=mcomella
mobile/android/base/tests/ContentContextMenuTest.java
mobile/android/base/tests/testPictureLinkContextMenu.java
--- a/mobile/android/base/tests/ContentContextMenuTest.java
+++ b/mobile/android/base/tests/ContentContextMenuTest.java
@@ -1,15 +1,18 @@
 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
  */
 abstract class ContentContextMenuTest extends PixelTest {
     private static final int MAX_TEST_TIMEOUT = 10000;
 
     // This method opens the context menu of any web content. It assumes that the page is already loaded
@@ -60,16 +63,32 @@ abstract class ContentContextMenuTest ex
 
     protected void switchTabs(String tab) {
         if (!mSolo.searchText(tab)) {
             openWebContentContextMenu(tab);
         }
         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)) {
             openWebContentContextMenu(copyOption); // Open the context menu if it is not already
         }
         mSolo.clickOnText(copyOption);
         boolean correctText = waitForTest(new BooleanTest() {
             @Override
--- a/mobile/android/base/tests/testPictureLinkContextMenu.java
+++ b/mobile/android/base/tests/testPictureLinkContextMenu.java
@@ -1,37 +1,40 @@
 package org.mozilla.gecko.tests;
 
 
 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$";
 
     public void testPictureLinkContextMenu() {
         blockForGeckoReady();
 
         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);
 
         switchTabs(imageTitle);
         verifyContextMenuItems(photoMenuItems);
         verifyTabs(tabs);
         switchTabs(imageTitle);
         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
         openTabFromContextMenu(linkMenuItems[1],2); // Test the "Open in Private Tab" option - expecting only 2 tabs in normal mode
         verifyCopyOption(linkMenuItems[2], BLANK_PAGE_URL); // Test the "Copy Link" option
         verifyShareOption(linkMenuItems[3], PICTURE_PAGE_TITLE); // Test the "Share Link" option
         verifyBookmarkLinkOption(linkMenuItems[4],BLANK_PAGE_URL); // Test the "Bookmark Link" option
     }