This source file includes following definitions.
- setUp
- Feature
- testNoExtraSpaceBeforeBuildName
package org.chromium.android_webview.test;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.android_webview.AwContents;
import org.chromium.base.test.util.Feature;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class UserAgentTest extends AwTestBase {
private TestAwContentsClient mContentsClient;
private AwContents mAwContents;
@Override
public void setUp() throws Exception {
super.setUp();
mContentsClient = new TestAwContentsClient();
mAwContents = createAwTestContainerViewOnMainSync(mContentsClient).getAwContents();
}
@SmallTest
@Feature({"AndroidWebView"})
public void testNoExtraSpaceBeforeBuildName() throws Throwable {
getAwSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
loadDataSync(
mAwContents,
mContentsClient.getOnPageFinishedHelper(),
"<html>" +
"<body onload='document.title=navigator.userAgent.replace(/ /g, \"_\")'></body>" +
"</html>",
"text/html", false);
final String ua = getTitleOnUiThread(mAwContents);
Matcher matcher = Pattern.compile("Android_[^;]+;_[^_]").matcher(ua);
assertTrue(matcher.find());
}
}