Bug 1391421 - Part 9 - Add a basic Robocop test for IDN domain support. r=gbrown

MozReview-Commit-ID: HAT9Imh9YVf

--HG--
extra : rebase_source : c29f9cf4c62377896081644006692f395a6755ec
This commit is contained in:
Jan Henning 2017-09-15 23:29:01 +02:00
Родитель 6cddaccbac
Коммит 78e7a75171
3 изменённых файлов: 40 добавлений и 1 удалений

Просмотреть файл

@ -46,6 +46,7 @@ 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]

Просмотреть файл

@ -17,6 +17,7 @@ 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;
@ -26,6 +27,8 @@ 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.
*/
@ -256,8 +259,11 @@ public class ToolbarComponent extends BaseComponent {
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;
}
@ -339,4 +345,11 @@ public class ToolbarComponent extends BaseComponent {
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();
}
}

Просмотреть файл

@ -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);
}
}