Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/UserAgentTest.java

Issue 11028094: [android_webview] Use AwContents loadUrl method instead of ContentViewCore. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase yet again Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.test.suitebuilder.annotation.SmallTest; 7 import android.test.suitebuilder.annotation.SmallTest;
8 8
9 import java.util.regex.Matcher; 9 import java.util.regex.Matcher;
10 import java.util.regex.Pattern; 10 import java.util.regex.Pattern;
11 11
12 import org.chromium.android_webview.AwContents;
12 import org.chromium.base.test.util.Feature; 13 import org.chromium.base.test.util.Feature;
13 import org.chromium.content.browser.ContentViewCore;
14 14
15 public class UserAgentTest extends AndroidWebViewTestBase { 15 public class UserAgentTest extends AndroidWebViewTestBase {
16 16
17 private TestAwContentsClient mContentsClient; 17 private TestAwContentsClient mContentsClient;
18 private ContentViewCore mContentViewCore; 18 private AwContents mAwContents;
19 19
20 @Override 20 @Override
21 public void setUp() throws Exception { 21 public void setUp() throws Exception {
22 super.setUp(); 22 super.setUp();
23 mContentsClient = new TestAwContentsClient(); 23 mContentsClient = new TestAwContentsClient();
24 mContentViewCore = 24 mAwContents = createAwTestContainerViewOnMainSync(mContentsClient).getAw Contents();
25 createAwTestContainerViewOnMainSync(mContentsClient).getContentV iewCore();
26 } 25 }
27 26
28 /** 27 /**
29 * Test for b/6404375. Verify that the UA string doesn't contain 28 * Test for b/6404375. Verify that the UA string doesn't contain
30 * two spaces before the Android build name. 29 * two spaces before the Android build name.
31 */ 30 */
32 @SmallTest 31 @SmallTest
33 @Feature({"Android-WebView"}) 32 @Feature({"Android-WebView"})
34 public void testNoExtraSpaceBeforeBuildName() throws Throwable { 33 public void testNoExtraSpaceBeforeBuildName() throws Throwable {
35 getContentSettingsOnUiThread(mContentViewCore).setJavaScriptEnabled(true ); 34 getContentSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
36 loadDataSync( 35 loadDataSync(
37 mContentViewCore, 36 mAwContents,
38 mContentsClient.getOnPageFinishedHelper(), 37 mContentsClient.getOnPageFinishedHelper(),
39 // Spaces are replaced with underscores to avoid consecutive spaces compression. 38 // Spaces are replaced with underscores to avoid consecutive spaces compression.
40 "<html>" + 39 "<html>" +
41 "<body onload='document.title=navigator.userAgent.replace(/ /g, \"_\ ")'></body>" + 40 "<body onload='document.title=navigator.userAgent.replace(/ /g, \"_\ ")'></body>" +
42 "</html>", 41 "</html>",
43 "text/html", false); 42 "text/html", false);
44 final String ua = getTitleOnUiThread(mContentViewCore); 43 final String ua = getTitleOnUiThread(mAwContents);
45 Matcher matcher = Pattern.compile("Android_[^;]+;_[^_]").matcher(ua); 44 Matcher matcher = Pattern.compile("Android_[^;]+;_[^_]").matcher(ua);
46 assertTrue(matcher.find()); 45 assertTrue(matcher.find());
47 } 46 }
48 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698