Bug 1413739 - Part 2 - Simple test for handling of an ACTION_ASSIST intent. r=nechen
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 03 Dec 2017 21:03:47 +0100
changeset 394922 92d7837be2dbb28c5648282fb61843c43d2b00bd
parent 394921 151826976a7d1cc0773017bdbd1eaa8554fc247e
child 394923 baada68cad47311154f570973c53ccf8db177efc
push id33025
push usershindli@mozilla.com
push dateTue, 05 Dec 2017 09:57:50 +0000
treeherdermozilla-central@390c1aad9d4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnechen
bugs1413739
milestone59.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 1413739 - Part 2 - Simple test for handling of an ACTION_ASSIST intent. r=nechen assertUrl wasn't used before and getUrlEditText().getText() returns a SpannableStringBuilder, so we need to add a toString() conversion there in order to successfully use it. MozReview-Commit-ID: 9BtZWDRstdD
mobile/android/tests/browser/robocop/robocop.ini
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/AssistIntentTest.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/ToolbarComponent.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAssistIntentNewIntent.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAssistIntentStartup.java
--- a/mobile/android/tests/browser/robocop/robocop.ini
+++ b/mobile/android/tests/browser/robocop/robocop.ini
@@ -6,16 +6,18 @@ subsuite = robocop
 [src/org/mozilla/gecko/tests/testActivityStreamContextMenu.java]
 [src/org/mozilla/gecko/tests/testAddonManager.java]
 # disabled on 4.3, bug 1144918
 skip-if = android_version == "18"
 [src/org/mozilla/gecko/tests/testAddSearchEngine.java]
 # disabled on 4.3, bug 1120759
 skip-if = android_version == "18"
 [src/org/mozilla/gecko/tests/testANRReporter.java]
+[src/org/mozilla/gecko/tests/testAssistIntentNewIntent.java]
+[src/org/mozilla/gecko/tests/testAssistIntentStartup.java]
 [src/org/mozilla/gecko/tests/testAudioFocus.java]
 [src/org/mozilla/gecko/tests/testMediaControl.java]
 skip-if = android_version < "23"
 [src/org/mozilla/gecko/tests/testAxisLocking.java]
 skip-if = true # Bug 1390059
 [src/org/mozilla/gecko/tests/testBookmark.java]
 disabled=see bug 915350
 [src/org/mozilla/gecko/tests/testBookmarksPanel.java]
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/AssistIntentTest.java
@@ -0,0 +1,29 @@
+package org.mozilla.gecko.tests;
+
+import android.content.Intent;
+
+import org.mozilla.gecko.tests.helpers.GeckoHelper;
+
+public class AssistIntentTest extends SessionTest {
+    @Override
+    public void setActivityIntent(Intent intent) {
+        // We want to make sure that we have opened a new tab, so we're creating a session
+        // where the default selected tab will *not* be about:home.
+        Session session = createTestSession(/*selected tab*/ 1);
+        injectSessionToRestore(intent, session);
+
+        super.setActivityIntent(intent);
+    }
+
+    protected void verifyAssistIntentHandling() {
+        // After an ACTION_ASSIST intent, we should be in editing mode...
+        mToolbar.assertIsEditing();
+
+        // ... the input field should be empty in readiness for the user to type...
+        mToolbar.assertUrl("");
+
+        // ... and we should have opened a new tab in addition to those from the "restored" session.
+        mToolbar.dismissEditingMode();
+        mToolbar.assertTitle(mStringHelper.ABOUT_HOME_URL);
+    }
+}
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/ToolbarComponent.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/ToolbarComponent.java
@@ -70,17 +70,17 @@ public class ToolbarComponent extends Ba
         // Since we only display a shortened "base domain" (See bug 1236431) we use the content
         // description to obtain the full URL.
         fAssertEquals("The Toolbar title is " + expected, expected, getUrlFromContentDescription());
         return this;
     }
 
     public ToolbarComponent assertUrl(final String expected) {
         assertIsEditing();
-        fAssertEquals("The Toolbar url is " + expected, expected, getUrlEditText().getText());
+        fAssertEquals("The Toolbar url is " + expected, expected, getUrlEditText().getText().toString());
         return this;
     }
 
     public ToolbarComponent assertIsUrlEditTextSelected() {
         fAssertTrue("The edit text is selected", isUrlEditTextSelected());
         return this;
     }
 
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAssistIntentNewIntent.java
@@ -0,0 +1,28 @@
+package org.mozilla.gecko.tests;
+
+import android.content.Context;
+import android.content.Intent;
+
+import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.tests.helpers.GeckoHelper;
+import org.mozilla.gecko.tests.helpers.WaitHelper;
+
+public class testAssistIntentNewIntent extends AssistIntentTest {
+    public void testAssistIntentNewIntent() {
+        GeckoHelper.blockForReady();
+
+        final Context testContext = getInstrumentation().getContext();
+        final Intent assistIntent = new Intent(Intent.ACTION_ASSIST);
+        assistIntent.setPackage(AppConstants.ANDROID_PACKAGE_NAME);
+        assistIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+        WaitHelper.waitForPageLoad(new Runnable() {
+            @Override
+            public void run() {
+                testContext.startActivity(assistIntent);
+            }
+        });
+
+        verifyAssistIntentHandling();
+    }
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAssistIntentStartup.java
@@ -0,0 +1,20 @@
+package org.mozilla.gecko.tests;
+
+import android.content.Intent;
+
+import org.mozilla.gecko.tests.helpers.GeckoHelper;
+
+public class testAssistIntentStartup extends AssistIntentTest {
+    @Override
+    public void setActivityIntent(Intent intent) {
+        intent.setAction(Intent.ACTION_ASSIST);
+
+        super.setActivityIntent(intent);
+    }
+
+    public void testAssistIntentStartup() {
+        GeckoHelper.blockForReady();
+
+        verifyAssistIntentHandling();
+    }
+}