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

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

Issue 11098030: Revert 160959 - [android_webview] Use AwContents loadUrl method instead of ContentViewCore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
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;
13 import org.chromium.base.test.util.Feature; 12 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 AwContents mAwContents; 18 private ContentViewCore mContentViewCore;
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 mAwContents = createAwTestContainerViewOnMainSync(mContentsClient).getAw Contents(); 24 mContentViewCore =
25 createAwTestContainerViewOnMainSync(mContentsClient).getContentV iewCore();
25 } 26 }
26 27
27 /** 28 /**
28 * Test for b/6404375. Verify that the UA string doesn't contain 29 * Test for b/6404375. Verify that the UA string doesn't contain
29 * two spaces before the Android build name. 30 * two spaces before the Android build name.
30 */ 31 */
31 @SmallTest 32 @SmallTest
32 @Feature({"Android-WebView"}) 33 @Feature({"Android-WebView"})
33 public void testNoExtraSpaceBeforeBuildName() throws Throwable { 34 public void testNoExtraSpaceBeforeBuildName() throws Throwable {
34 getContentSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true); 35 getContentSettingsOnUiThread(mContentViewCore).setJavaScriptEnabled(true );
35 loadDataSync( 36 loadDataSync(
36 mAwContents, 37 mContentViewCore,
37 mContentsClient.getOnPageFinishedHelper(), 38 mContentsClient.getOnPageFinishedHelper(),
38 // Spaces are replaced with underscores to avoid consecutive spaces compression. 39 // Spaces are replaced with underscores to avoid consecutive spaces compression.
39 "<html>" + 40 "<html>" +
40 "<body onload='document.title=navigator.userAgent.replace(/ /g, \"_\ ")'></body>" + 41 "<body onload='document.title=navigator.userAgent.replace(/ /g, \"_\ ")'></body>" +
41 "</html>", 42 "</html>",
42 "text/html", false); 43 "text/html", false);
43 final String ua = getTitleOnUiThread(mAwContents); 44 final String ua = getTitleOnUiThread(mContentViewCore);
44 Matcher matcher = Pattern.compile("Android_[^;]+;_[^_]").matcher(ua); 45 Matcher matcher = Pattern.compile("Android_[^;]+;_[^_]").matcher(ua);
45 assertTrue(matcher.find()); 46 assertTrue(matcher.find());
46 } 47 }
47 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698