diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 01:56:06 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 01:56:06 +0000 |
commit | 67b086baf1d59bc9847f5467d88b38964fec94da (patch) | |
tree | 2dabbcf933698cfc880fdb8578971a67bc10573a /android_webview | |
parent | 579d260bb8a4636d3ac8a91d340e1822ace23e08 (diff) | |
download | chromium_src-67b086baf1d59bc9847f5467d88b38964fec94da.zip chromium_src-67b086baf1d59bc9847f5467d88b38964fec94da.tar.gz chromium_src-67b086baf1d59bc9847f5467d88b38964fec94da.tar.bz2 |
Add aw test to check UA is actually set by ContentSettings.
The magic code that this is currently testing is at the end of
RenderViewImpl::willSendRequest, which sets the UA override (if there is
one). The network stack will only ask UrlRequestContext for a user agent
if it is not already set.
BUG=
Java test change. Ran through android java trybot
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/11227059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java index e5a5479..3275597 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java @@ -8,6 +8,8 @@ import android.content.Context; import android.os.Build; import android.test.suitebuilder.annotation.SmallTest; +import org.apache.http.Header; +import org.apache.http.HttpRequest; import org.chromium.android_webview.AndroidProtocolHandler; import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwSettings; @@ -1262,6 +1264,41 @@ public class AwSettingsTest extends AndroidWebViewTestBase { @SmallTest @Feature({"Android-WebView", "Preferences"}) + public void testUserAgentWithTestServer() throws Throwable { + final TestAwContentsClient contentClient = new TestAwContentsClient(); + final AwTestContainerView testContainerView = + createAwTestContainerViewOnMainSync(contentClient); + AwContents awContents = testContainerView.getAwContents(); + ContentSettings settings = getContentSettingsOnUiThread(awContents); + final String customUserAgentString = + "testUserAgentWithTestServerUserAgent"; + + TestWebServer webServer = null; + String fileName = null; + try { + webServer = new TestWebServer(false); + final String httpPath = "/testUserAgentWithTestServer.html"; + final String url = webServer.setResponse(httpPath, "foo", null); + + settings.setUserAgentString(customUserAgentString); + loadUrlSync(awContents, + contentClient.getOnPageFinishedHelper(), + url); + + assertEquals(1, webServer.getRequestCount(httpPath)); + HttpRequest request = webServer.getLastRequest(httpPath); + Header[] matchingHeaders = request.getHeaders("User-Agent"); + assertEquals(1, matchingHeaders.length); + + Header header = matchingHeaders[0]; + assertEquals(customUserAgentString, header.getValue()); + } finally { + if (webServer != null) webServer.shutdown(); + } + } + + @SmallTest + @Feature({"Android-WebView", "Preferences"}) public void testDomStorageEnabledNormal() throws Throwable { ViewPair views = createViews(NORMAL_VIEW, NORMAL_VIEW); runPerViewSettingsTest( |