Bug 1391421 - Part 9 - Add a basic Robocop test for IDN domain support. r=gbrown
authorJan Henning <jh+bugzilla@buttercookie.de>
Fri, 15 Sep 2017 23:29:01 +0200
changeset 431577 65537efd1f7262c7c43aa552fc2660a3e9960c81
parent 431576 3cb0b289475c028cc9c532ed277e74d09946f906
child 431578 cdaeacba2c3215d8f52445126de93e5e9282236e
push id7785
push userryanvm@gmail.com
push dateThu, 21 Sep 2017 13:39:55 +0000
treeherdermozilla-beta@06d4034a8a03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1391421
milestone57.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 1391421 - Part 9 - Add a basic Robocop test for IDN domain support. r=gbrown MozReview-Commit-ID: HAT9Imh9YVf
mobile/android/tests/browser/robocop/robocop.ini
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/ToolbarComponent.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testIdnSupport.java
--- a/mobile/android/tests/browser/robocop/robocop.ini
+++ b/mobile/android/tests/browser/robocop/robocop.ini
@@ -41,16 +41,17 @@ disabled=bug 1128287
 skip-if = true # Bug 1390059
 [src/org/mozilla/gecko/tests/testFormHistory.java]
 [src/org/mozilla/gecko/tests/testGetUserMedia.java]
 # failures across the board, bug 1092202 & bug 1144926
 skip-if = true
 [src/org/mozilla/gecko/tests/testHistory.java]
 disabled=see bug 915350
 [src/org/mozilla/gecko/tests/testHomeBanner.java]
+[src/org/mozilla/gecko/tests/testIdnSupport.java]
 [src/org/mozilla/gecko/tests/testInputUrlBar.java]
 [src/org/mozilla/gecko/tests/testJarReader.java]
 [src/org/mozilla/gecko/tests/testLinkContextMenu.java]
 [src/org/mozilla/gecko/tests/testHomeListsProvider.java]
 disabled=see bug 952310
 [src/org/mozilla/gecko/tests/testLoad.java]
 skip-if = true # Bug 1390059
 [src/org/mozilla/gecko/tests/testMailToContextMenu.java]
--- 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
@@ -12,25 +12,28 @@ import static org.mozilla.gecko.tests.he
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.tests.UITestContext;
 import org.mozilla.gecko.tests.helpers.DeviceHelper;
 import org.mozilla.gecko.tests.helpers.NavigationHelper;
 import org.mozilla.gecko.tests.helpers.WaitHelper;
 import org.mozilla.gecko.toolbar.PageActionLayout;
 import org.mozilla.gecko.toolbar.TabCounter;
 
+import android.net.Uri;
 import android.view.View;
 import android.widget.EditText;
 import android.widget.ImageButton;
 import android.widget.TextSwitcher;
 import android.widget.TextView;
 
 import com.robotium.solo.Condition;
 import com.robotium.solo.Solo;
 
+import java.net.IDN;
+
 /**
  * A class representing any interactions that take place on the Toolbar.
  */
 public class ToolbarComponent extends BaseComponent {
     public static final String URL_HTTP_PREFIX = "http://";
 
     // We are waiting up to 30 seconds instead of the default waiting time because reader mode
     // parsing can take quite some time on slower devices (Bug 1142699)
@@ -251,18 +254,21 @@ public class ToolbarComponent extends Ba
         fAssertNotNull("url is not null", url);
 
         assertIsEditing();
 
         final EditText urlEditText = getUrlEditText();
         fAssertTrue("The UrlEditText is the input method target",
                 urlEditText.isInputMethodTarget());
 
+        // Solo doesn't handle typing text with Unicode characters, so if the input looks like a
+        // genuine URL, we work around this by converting it to Punycode beforehand.
+        final String textToType = url.contains("://") ? convertUrlToPunycode(url) : url;
         mSolo.clearEditText(urlEditText);
-        mSolo.typeText(urlEditText, url);
+        mSolo.typeText(urlEditText, textToType);
 
         return this;
     }
 
     public ToolbarComponent pressBackButton() {
         final ImageButton backButton = getBackButton();
         return pressButton(backButton, "back");
     }
@@ -334,9 +340,16 @@ public class ToolbarComponent extends Ba
 
     private boolean isUrlEditTextSelected() {
         return getUrlEditText().isSelected();
     }
 
     private boolean isBackButtonEnabled() {
         return getBackButton().isEnabled();
     }
+
+    private String convertUrlToPunycode(final String url) {
+        final Uri uri = Uri.parse(url);
+        final Uri.Builder uriBuilder = uri.buildUpon();
+        uriBuilder.encodedAuthority(IDN.toASCII(uri.getAuthority()));
+        return uriBuilder.toString();
+    }
 }
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testIdnSupport.java
@@ -0,0 +1,25 @@
+package org.mozilla.gecko.tests;
+
+import org.mozilla.gecko.tests.helpers.GeckoHelper;
+import org.mozilla.gecko.tests.helpers.NavigationHelper;
+
+public class testIdnSupport extends UITest {
+    public void testToolbarIdnSupport() {
+        GeckoHelper.blockForReady();
+
+        mBaseHostnameUrl = "http://exämple.test/tests";
+        String url = mStringHelper.ROBOCOP_BLANK_PAGE_01_URL;
+        NavigationHelper.enterAndLoadUrl(url);
+        mToolbar.assertTitle(url);
+
+        mBaseHostnameUrl = "http://παράδειγμα.δοκιμή/tests";
+        url = mStringHelper.ROBOCOP_BLANK_PAGE_02_URL;
+        NavigationHelper.enterAndLoadUrl(url);
+        mToolbar.assertTitle(url);
+
+        mBaseHostnameUrl = "http://天気の良い日.w3c-test.org/tests";
+        url = mStringHelper.ROBOCOP_BLANK_PAGE_03_URL;
+        NavigationHelper.enterAndLoadUrl(url);
+        mToolbar.assertTitle(url);
+    }
+}