Bug 896571 - Update testInputAwesomeBar for new about:home (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Thu, 15 Aug 2013 12:16:19 +0100
changeset 143538 9dfb38fba3a8227e4f6be06c1f2d680f2d4a1f96
parent 143537 8a36903511fd744beebe2bb41d358090e4c31760
child 143539 a7454660ca732db8744db69c6cf95943e3c38025
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs896571
milestone26.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 896571 - Update testInputAwesomeBar for new about:home (r=margaret)
mobile/android/base/tests/robocop.ini
mobile/android/base/tests/testInputAwesomeBar.java.in
mobile/android/base/tests/testInputUrlBar.java.in
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -30,17 +30,17 @@
 [testShareLink]
 # [testClearPrivateData] # disabled on fig - bug 880060
 [testSettingsMenuItems]
 [testSystemPages]
 # [testPermissions] # see bug 757475
 [testJarReader]
 [testDistribution]
 [testFindInPage]
-# [testInputAwesomeBar] # disabled on fig - bug 880060
+[testInputUrlBar]
 # [testAddSearchEngine] # disabled on fig - bug 880060
 [testImportFromAndroid]
 [testMasterPassword]
 [testDeviceSearchEngine]
 
 # Used for Talos, please don't use in mochitest
 #[testPan]
 #[testCheck]
rename from mobile/android/base/tests/testInputAwesomeBar.java.in
rename to mobile/android/base/tests/testInputUrlBar.java.in
--- a/mobile/android/base/tests/testInputAwesomeBar.java.in
+++ b/mobile/android/base/tests/testInputUrlBar.java.in
@@ -3,118 +3,130 @@ package @ANDROID_PACKAGE_NAME@.tests;
 
 import @ANDROID_PACKAGE_NAME@.*;
 
 import android.app.Activity;
 import android.view.View;
 import android.widget.EditText;
 
 /**
- * Basic test of text editing within the AwesomeBar.
+ * Basic test of text editing within the editing mode.
  * - Enter some text, move the cursor around, and modifying some text.
- * - Check that all AwesomeBar text is selected after switching AwesomeScreen tabs.
+ * - Check that all edit entry text is selected after switching about:home tabs.
  */
-public final class testInputAwesomeBar extends BaseTest {
-    private Element     mAwesomeBarTextElement;
-    private EditText    mAwesomeBarEditText;
+public final class testInputUrlBar extends BaseTest {
+    private Element mUrlBarEditElement;
+    private EditText mUrlBarEditView;
 
-    public void testInputAwesomeBar() {
+    public void testInputUrlBar() {
         blockForGeckoReady();
 
-        openAwesomeScreen();
-        assertAwesomeBarText("about:home");
+        startEditingMode();
+        assertUrlBarText("about:home");
 
         mActions.sendKeys("ab");
-        assertAwesomeBarText("ab");
+        assertUrlBarText("ab");
 
         mActions.sendKeys("cd");
-        assertAwesomeBarText("abcd");
+        assertUrlBarText("abcd");
 
         mActions.sendSpecialKey(Actions.SpecialKey.LEFT);
         mActions.sendSpecialKey(Actions.SpecialKey.LEFT);
+
         // Inserting "" should not do anything.
         mActions.sendKeys("");
-        assertAwesomeBarText("abcd");
+        assertUrlBarText("abcd");
 
         mActions.sendKeys("ef");
-        assertAwesomeBarText("abefcd");
+        assertUrlBarText("abefcd");
 
         mActions.sendSpecialKey(Actions.SpecialKey.RIGHT);
         mActions.sendKeys("gh");
-        assertAwesomeBarText("abefcghd");
+        assertUrlBarText("abefcghd");
 
-        final EditText editText = mAwesomeBarEditText;
-        runOnUiThreadSync(new Runnable() { public void run() {
-            // Select "ef"
-            editText.setSelection(2);
-        }});
+        final EditText editText = mUrlBarEditView;
+        runOnUiThreadSync(new Runnable() {
+            public void run() {
+                // Select "ef"
+                editText.setSelection(2);
+            }
+        });
         mActions.sendKeys("op");
-        assertAwesomeBarText("abopefcghd");
+        assertUrlBarText("abopefcghd");
 
-        runOnUiThreadSync(new Runnable() { public void run() {
-            // Select "cg"
-            editText.setSelection(6,8);
-        }});
+        runOnUiThreadSync(new Runnable() {
+            public void run() {
+                // Select "cg"
+                editText.setSelection(6, 8);
+            }
+        });
         mActions.sendKeys("qr");
-        assertAwesomeBarText("abopefqrhd");
+        assertUrlBarText("abopefqrhd");
 
-        runOnUiThreadSync(new Runnable() { public void run() {
-            // Select "op"
-            editText.setSelection(4,2);
-        }});
+        runOnUiThreadSync(new Runnable() {
+            public void run() {
+                // Select "op"
+                editText.setSelection(4,2);
+            }
+        });
         mActions.sendKeys("st");
-        assertAwesomeBarText("abstefqrhd");
+        assertUrlBarText("abstefqrhd");
 
-        runOnUiThreadSync(new Runnable() { public void run() {
-            editText.selectAll();
-        }});
+        runOnUiThreadSync(new Runnable() {
+            public void run() {
+                editText.selectAll();
+            }
+        });
         mActions.sendKeys("uv");
-        assertAwesomeBarText("uv");
+        assertUrlBarText("uv");
 
-        // BACK key should close the VKB, so typing should no longer affect the AwesomeBar text.
+        // Dismiss the VKB
         mActions.sendSpecialKey(Actions.SpecialKey.BACK);
 
-        // Wait for about:home page to load.
-        waitForText("Add-ons for your");
+        // Dismiss editing mode
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK);
 
-        // AwesomeBar should have forgotten about "uv" text.
-        openAwesomeScreen();
-        assertAwesomeBarText("about:home");
+        waitForText("Enter Search or Address");
+
+        // URL bar should have forgotten about "uv" text.
+        startEditingMode();
+        assertUrlBarText("about:home");
 
-        // Switch tabs so address bar loses input focus.
-        mSolo.clickOnText("Top Sites");
-        mSolo.clickOnText("Bookmarks");
-        mSolo.clickOnText("History");
+        int width = mDriver.getGeckoWidth() / 2;
+        int y = mDriver.getGeckoHeight() / 2;
 
-        mSolo.clickOnView(mAwesomeBarEditText);
+        // Slide to the right, force URL bar entry to lose input focus
+        mActions.drag(width, 0, y, y);
+
+        // Select text and replace the content
+        mSolo.clickOnView(mUrlBarEditView);
         mActions.sendKeys("yz");
 
-        // FIXME BUG 855134: Clicking back to the AwesomeBar after the VKB has closed should
-        // select all URL text. Instead it deselects the URL text and positions the cursor.
-        String yz = getAwesomeBarText();
-        mAsserter.ok("yz".equals(yz) || "about:homeyz".equals(yz),
-                     "Is AwesomeBar text \"yz\" or \"about:homeyz\"?", yz);
+        String yz = getUrlBarText();
+        mAsserter.ok("yz".equals(yz), "Is the URL bar text \"yz\"?", yz);
     }
 
     @Override
     protected int getTestType() {
         return TEST_MOCHITEST;
     }
 
-    private void openAwesomeScreen() {
+    private void startEditingMode() {
         focusUrlBar();
-        mAwesomeBarTextElement = mDriver.findElement(getActivity(), URL_EDIT_TEXT_ID);
-        int id = mAwesomeBarTextElement.getId();
-        mAwesomeBarEditText = (EditText) getActivity().findViewById(id);
+
+        mUrlBarEditElement = mDriver.findElement(getActivity(), URL_EDIT_TEXT_ID);
+        final int id = mUrlBarEditElement.getId();
+        mUrlBarEditView = (EditText) getActivity().findViewById(id);
     }
 
-    private String getAwesomeBarText() {
-        String elementText = mAwesomeBarTextElement.getText();
-        String editText = mAwesomeBarEditText.getText().toString();
-        mAsserter.is(editText, elementText, "Does AwesomeBar editText == elementText?");
+    private String getUrlBarText() {
+        final String elementText = mUrlBarEditElement.getText();
+        final String editText = mUrlBarEditView.getText().toString();
+        mAsserter.is(editText, elementText, "Does URL bar editText == elementText?");
+
         return editText;
     }
 
-    private void assertAwesomeBarText(String expectedText) {
-        String actualText = getAwesomeBarText();
-        mAsserter.is(actualText, expectedText, "Does AwesomeBar actualText == expectedText?");
+    private void assertUrlBarText(String expectedText) {
+        String actualText = getUrlBarText();
+        mAsserter.is(actualText, expectedText, "Does URL bar actualText == expectedText?");
     }
 }