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

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

Issue 1257603003: Revert of Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.os.Build; 7 import android.os.Build;
8 import android.test.suitebuilder.annotation.MediumTest; 8 import android.test.suitebuilder.annotation.MediumTest;
9 import android.webkit.GeolocationPermissions; 9 import android.webkit.GeolocationPermissions;
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 /** 107 /**
108 * Ensure that a call to navigator.getCurrentPosition works in WebView. 108 * Ensure that a call to navigator.getCurrentPosition works in WebView.
109 */ 109 */
110 @MediumTest 110 @MediumTest
111 @Feature({"AndroidWebView"}) 111 @Feature({"AndroidWebView"})
112 public void testGetPosition() throws Throwable { 112 public void testGetPosition() throws Throwable {
113 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), 113 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
114 RAW_HTML, "text/html", false); 114 RAW_HTML, "text/html", false);
115 115
116 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null); 116 mAwContents.evaluateJavaScript("initiate_getCurrentPosition();", null);
117 117
118 poll(new Callable<Boolean>() { 118 poll(new Callable<Boolean>() {
119 @Override 119 @Override
120 public Boolean call() throws Exception { 120 public Boolean call() throws Exception {
121 return getPositionCountFromJS() == 1; 121 return getPositionCountFromJS() == 1;
122 } 122 }
123 }); 123 });
124 124
125 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null); 125 mAwContents.evaluateJavaScript("initiate_getCurrentPosition();", null);
126 poll(new Callable<Boolean>() { 126 poll(new Callable<Boolean>() {
127 @Override 127 @Override
128 public Boolean call() throws Exception { 128 public Boolean call() throws Exception {
129 return getPositionCountFromJS() == 2; 129 return getPositionCountFromJS() == 2;
130 } 130 }
131 }); 131 });
132 } 132 }
133 133
134 /** 134 /**
135 * Ensure that a call to navigator.watchPosition works in WebView. 135 * Ensure that a call to navigator.watchPosition works in WebView.
136 */ 136 */
137 @MediumTest 137 @MediumTest
138 @Feature({"AndroidWebView"}) 138 @Feature({"AndroidWebView"})
139 public void testWatchPosition() throws Throwable { 139 public void testWatchPosition() throws Throwable {
140 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), 140 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
141 RAW_HTML, "text/html", false); 141 RAW_HTML, "text/html", false);
142 142
143 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null ); 143 mAwContents.evaluateJavaScript("initiate_watchPosition();", null);
144 144
145 poll(new Callable<Boolean>() { 145 poll(new Callable<Boolean>() {
146 @Override 146 @Override
147 public Boolean call() throws Exception { 147 public Boolean call() throws Exception {
148 return getPositionCountFromJS() > 1; 148 return getPositionCountFromJS() > 1;
149 } 149 }
150 }); 150 });
151 } 151 }
152 152
153 @MediumTest 153 @MediumTest
154 @Feature({"AndroidWebView"}) 154 @Feature({"AndroidWebView"})
155 public void testPauseGeolocationOnPause() throws Throwable { 155 public void testPauseGeolocationOnPause() throws Throwable {
156 // Start a watch going. 156 // Start a watch going.
157 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), 157 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
158 RAW_HTML, "text/html", false); 158 RAW_HTML, "text/html", false);
159 159
160 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null ); 160 mAwContents.evaluateJavaScript("initiate_watchPosition();", null);
161 161
162 poll(new Callable<Boolean>() { 162 poll(new Callable<Boolean>() {
163 @Override 163 @Override
164 public Boolean call() throws Exception { 164 public Boolean call() throws Exception {
165 return getPositionCountFromJS() > 1; 165 return getPositionCountFromJS() > 1;
166 } 166 }
167 }); 167 });
168 168
169 ensureGeolocationRunning(true); 169 ensureGeolocationRunning(true);
170 170
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 @Override 208 @Override
209 public void run() { 209 public void run() {
210 mAwContents.onPause(); 210 mAwContents.onPause();
211 } 211 }
212 }); 212 });
213 213
214 // Start a watch going. 214 // Start a watch going.
215 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), 215 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
216 RAW_HTML, "text/html", false); 216 RAW_HTML, "text/html", false);
217 217
218 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null ); 218 mAwContents.evaluateJavaScript("initiate_watchPosition();", null);
219 219
220 assertEquals(0, getPositionCountFromJS()); 220 assertEquals(0, getPositionCountFromJS());
221 221
222 ensureGeolocationRunning(false); 222 ensureGeolocationRunning(false);
223 223
224 getInstrumentation().runOnMainSync(new Runnable() { 224 getInstrumentation().runOnMainSync(new Runnable() {
225 @Override 225 @Override
226 public void run() { 226 public void run() {
227 mAwContents.onResume(); 227 mAwContents.onResume();
228 } 228 }
(...skipping 26 matching lines...) Expand all
255 @Override 255 @Override
256 public void run() { 256 public void run() {
257 mAwContents.onResume(); 257 mAwContents.onResume();
258 } 258 }
259 }); 259 });
260 260
261 ensureGeolocationRunning(false); 261 ensureGeolocationRunning(false);
262 } 262 }
263 263
264 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698