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

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/ContentViewMiscTest.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.content.BroadcastReceiver; 7 import android.content.BroadcastReceiver;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.IntentFilter; 10 import android.content.IntentFilter;
11 import android.graphics.Bitmap; 11 import android.graphics.Bitmap;
12 import android.graphics.Color; 12 import android.graphics.Color;
13 import android.net.Proxy; 13 import android.net.Proxy;
14 import android.test.mock.MockContext; 14 import android.test.mock.MockContext;
15 import android.test.suitebuilder.annotation.SmallTest; 15 import android.test.suitebuilder.annotation.SmallTest;
16 16
17 import org.chromium.android_webview.AwContents;
17 import org.chromium.base.test.util.DisabledTest; 18 import org.chromium.base.test.util.DisabledTest;
18 import org.chromium.base.test.util.Feature; 19 import org.chromium.base.test.util.Feature;
19 import org.chromium.base.ThreadUtils; 20 import org.chromium.base.ThreadUtils;
20 import org.chromium.content.browser.ContentViewCore; 21 import org.chromium.content.browser.ContentViewCore;
21 import org.chromium.content.browser.ContentViewStatics; 22 import org.chromium.content.browser.ContentViewStatics;
22 import org.chromium.net.ProxyChangeListener; 23 import org.chromium.net.ProxyChangeListener;
23 24
24 import java.util.concurrent.atomic.AtomicBoolean; 25 import java.util.concurrent.atomic.AtomicBoolean;
25 import java.util.concurrent.atomic.AtomicReference; 26 import java.util.concurrent.atomic.AtomicReference;
26 import java.util.concurrent.Callable; 27 import java.util.concurrent.Callable;
27 28
28 /** 29 /**
29 * Tests for ContentView methods that don't fall into any other category. 30 * Tests for ContentView methods that don't fall into any other category.
30 */ 31 */
31 public class ContentViewMiscTest extends AndroidWebViewTestBase { 32 public class ContentViewMiscTest extends AndroidWebViewTestBase {
32 33
33 private TestAwContentsClient mContentsClient; 34 private TestAwContentsClient mContentsClient;
35 private AwContents mAwContents;
34 private ContentViewCore mContentViewCore; 36 private ContentViewCore mContentViewCore;
35 37
36 @Override 38 @Override
37 public void setUp() throws Exception { 39 public void setUp() throws Exception {
38 super.setUp(); 40 super.setUp();
39 mContentsClient = new TestAwContentsClient(); 41 mContentsClient = new TestAwContentsClient();
40 mContentViewCore = 42 final AwTestContainerView testContainerView =
41 createAwTestContainerViewOnMainSync(mContentsClient).getContentV iewCore(); 43 createAwTestContainerViewOnMainSync(mContentsClient);
44 mAwContents = testContainerView.getAwContents();
45 mContentViewCore = testContainerView.getContentViewCore();
42 } 46 }
43 47
44 /** 48 /**
45 * @SmallTest 49 * @SmallTest
46 * @Feature({"Android-WebView"}) 50 * @Feature({"Android-WebView"})
47 * crbug.com/147721 51 * crbug.com/147721
48 */ 52 */
49 @DisabledTest 53 @DisabledTest
50 public void testFlingScroll() throws Throwable { 54 public void testFlingScroll() throws Throwable {
51 StringBuffer testPage = new StringBuffer().append("data:text/html;utf-8, ") 55 StringBuffer testPage = new StringBuffer().append("data:text/html;utf-8, ")
52 .append("<html><head><style>body { width: 5000px; height: 5000px ; }</head><body>") 56 .append("<html><head><style>body { width: 5000px; height: 5000px ; }</head><body>")
53 .append("</body></html>"); 57 .append("</body></html>");
54 58
55 // Test flinging in the y axis 59 // Test flinging in the y axis
56 loadUrlSync(mContentViewCore, mContentsClient.getOnPageFinishedHelper(), 60 loadUrlSync(mAwContents , mContentsClient.getOnPageFinishedHelper(),
57 testPage.toString()); 61 testPage.toString());
58 assertEquals(0, mContentViewCore.getNativeScrollYForTest()); 62 assertEquals(0, mContentViewCore.getNativeScrollYForTest());
59 ThreadUtils.runOnUiThread(new Runnable() { 63 ThreadUtils.runOnUiThread(new Runnable() {
60 @Override 64 @Override
61 public void run() { 65 public void run() {
62 mContentViewCore.flingScroll(0, 2000); 66 mContentViewCore.flingScroll(0, 2000);
63 } 67 }
64 }); 68 });
65 Thread.sleep(1000); 69 Thread.sleep(1000);
66 assertNotSame(0, mContentViewCore.getNativeScrollYForTest()); 70 assertNotSame(0, mContentViewCore.getNativeScrollYForTest());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 assertEquals(true, proxyChanged.get()); 148 assertEquals(true, proxyChanged.get());
145 } 149 }
146 150
147 /** 151 /**
148 * @SmallTest 152 * @SmallTest
149 * @Feature({"Android-WebView"}) 153 * @Feature({"Android-WebView"})
150 * Bug 6931901 154 * Bug 6931901
151 */ 155 */
152 @DisabledTest 156 @DisabledTest
153 public void testSetGetBackgroundColor() throws Throwable { 157 public void testSetGetBackgroundColor() throws Throwable {
154 loadUrlSync(mContentViewCore, mContentsClient.getOnPageFinishedHelper(), "about:blank"); 158 loadUrlSync(mAwContents , mContentsClient.getOnPageFinishedHelper(), "ab out:blank");
155 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 159 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
156 @Override 160 @Override
157 public void run() { 161 public void run() {
158 mContentViewCore.setBackgroundColor(Color.MAGENTA); 162 mContentViewCore.setBackgroundColor(Color.MAGENTA);
159 } 163 }
160 }); 164 });
161 int backgroundColor = ThreadUtils.runOnUiThreadBlocking(new Callable<Int eger>() { 165 int backgroundColor = ThreadUtils.runOnUiThreadBlocking(new Callable<Int eger>() {
162 @Override 166 @Override
163 public Integer call() { 167 public Integer call() {
164 Bitmap map = mContentViewCore.getBitmap(1, 1); 168 Bitmap map = mContentViewCore.getBitmap(1, 1);
165 return map.getPixel(0,0); 169 return map.getPixel(0,0);
166 } 170 }
167 }); 171 });
168 assertEquals(Color.MAGENTA, backgroundColor); 172 assertEquals(Color.MAGENTA, backgroundColor);
169 } 173 }
170 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698