Bug 944144 - Implement NavigationHelper.reload. r=mcomella
authorVivek Balakrishnan <vivekb.balakrishnan@gmail.com>
Wed, 07 May 2014 16:24:00 -0400
changeset 182807 567c1b6a0988401165b5af111d15c5b34fe6e98a
parent 182806 32acf0cd2a166635f070e6f5abaf7ddb1620d0d4
child 182808 5fd2e583adc0909a098c9294cf761ea75d788d23
push id26770
push usercbook@mozilla.com
push dateTue, 13 May 2014 10:31:28 +0000
treeherdermozilla-central@2cd3bedf26b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs944144
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 944144 - Implement NavigationHelper.reload. r=mcomella
mobile/android/base/tests/components/AppMenuComponent.java
mobile/android/base/tests/components/ToolbarComponent.java
mobile/android/base/tests/helpers/NavigationHelper.java
mobile/android/base/tests/testSessionHistory.java
--- a/mobile/android/base/tests/components/AppMenuComponent.java
+++ b/mobile/android/base/tests/components/AppMenuComponent.java
@@ -24,17 +24,18 @@ import com.jayway.android.robotium.solo.
 import com.jayway.android.robotium.solo.Solo;
 
 /**
  * A class representing any interactions that take place on the app menu.
  */
 public class AppMenuComponent extends BaseComponent {
     public enum MenuItem {
         FORWARD(R.string.forward),
-        NEW_TAB(R.string.new_tab);
+        NEW_TAB(R.string.new_tab),
+        RELOAD(R.string.reload);
 
         private final int resourceID;
         private String stringResource;
 
         MenuItem(final int resourceID) {
             this.resourceID = resourceID;
         }
 
--- a/mobile/android/base/tests/components/ToolbarComponent.java
+++ b/mobile/android/base/tests/components/ToolbarComponent.java
@@ -75,16 +75,20 @@ public class ToolbarComponent extends Ba
         return (ImageButton) getToolbarView().findViewById(R.id.back);
     }
 
     private ImageButton getForwardButton() {
         DeviceHelper.assertIsTablet();
         return (ImageButton) getToolbarView().findViewById(R.id.forward);
     }
 
+    private ImageButton getReloadButton() {
+        DeviceHelper.assertIsTablet();
+        return (ImageButton) getToolbarView().findViewById(R.id.reload);
+    }
     /**
      * Returns the View for the edit cancel button in the browser toolbar.
      */
     private ImageButton getEditCancelButton() {
         return (ImageButton) getToolbarView().findViewById(R.id.edit_cancel);
     }
 
     private CharSequence getTitle() {
@@ -185,16 +189,21 @@ public class ToolbarComponent extends Ba
         return pressButton(backButton, "back");
     }
 
     public ToolbarComponent pressForwardButton() {
         final ImageButton forwardButton = getForwardButton();
         return pressButton(forwardButton, "forward");
     }
 
+    public ToolbarComponent pressReloadButton() {
+        final ImageButton reloadButton = getReloadButton();
+        return pressButton(reloadButton, "reload");
+    }
+
     private ToolbarComponent pressButton(final View view, final String buttonName) {
         fAssertNotNull("The " + buttonName + " button View is not null", view);
         fAssertTrue("The " + buttonName + " button is enabled", view.isEnabled());
         fAssertEquals("The " + buttonName + " button is visible",
                 View.VISIBLE, view.getVisibility());
         assertIsNotEditing();
 
         WaitHelper.waitForPageLoad(new Runnable() {
--- a/mobile/android/base/tests/helpers/NavigationHelper.java
+++ b/mobile/android/base/tests/helpers/NavigationHelper.java
@@ -83,14 +83,22 @@ final public class NavigationHelper {
             @Override
             public void run() {
                 sAppMenu.pressMenuItem(AppMenuComponent.MenuItem.FORWARD);
             }
         });
     }
 
     public static void reload() {
-        // TODO: On tablets, press reload in TOOLBAR. Note that this is technically
-        // an app menu item so tread carefully.
-        //       On phones, press reload in APPMENU.
-        throw new UnsupportedOperationException("Not yet implemented.");
+        if (DeviceHelper.isTablet()) {
+            sToolbar.pressReloadButton(); // Waits for page load & asserts isNotEditing.
+            return;
+        }
+
+        sToolbar.assertIsNotEditing();
+        WaitHelper.waitForPageLoad(new Runnable() {
+            @Override
+            public void run() {
+                sAppMenu.pressMenuItem(AppMenuComponent.MenuItem.RELOAD);
+            }
+        });
     }
 }
--- a/mobile/android/base/tests/testSessionHistory.java
+++ b/mobile/android/base/tests/testSessionHistory.java
@@ -23,15 +23,12 @@ public class testSessionHistory extends 
         mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
 
         NavigationHelper.goBack();
         mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_01_TITLE);
 
         NavigationHelper.goForward();
         mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
 
-        // TODO: Implement this functionality and uncomment.
-        /*
         NavigationHelper.reload();
         mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
-        */
     }
 }