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

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewLocationTest.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, 4 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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.test.suitebuilder.annotation.MediumTest; 7 import android.test.suitebuilder.annotation.MediumTest;
8 8
9 import org.chromium.base.test.util.Feature; 9 import org.chromium.base.test.util.Feature;
10 import org.chromium.content.browser.test.util.Criteria; 10 import org.chromium.content.browser.test.util.Criteria;
(...skipping 27 matching lines...) Expand all
38 private void showContentViewOnUiThread() { 38 private void showContentViewOnUiThread() {
39 getInstrumentation().runOnMainSync(new Runnable() { 39 getInstrumentation().runOnMainSync(new Runnable() {
40 @Override 40 @Override
41 public void run() { 41 public void run() {
42 getContentViewCore().onShow(); 42 getContentViewCore().onShow();
43 } 43 }
44 }); 44 });
45 } 45 }
46 46
47 private void pollForPositionCallback() throws Throwable { 47 private void pollForPositionCallback() throws Throwable {
48 mJavascriptHelper.evaluateJavaScriptForTests(getWebContents(), 48 mJavascriptHelper.evaluateJavaScript(getWebContents(),
49 "positionCount = 0"); 49 "positionCount = 0");
50 mJavascriptHelper.waitUntilHasValue(); 50 mJavascriptHelper.waitUntilHasValue();
51 assertEquals(0, Integer.parseInt(mJavascriptHelper.getJsonResultAndClear ())); 51 assertEquals(0, Integer.parseInt(mJavascriptHelper.getJsonResultAndClear ()));
52 52
53 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { 53 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
54 @Override 54 @Override
55 public boolean isSatisfied() { 55 public boolean isSatisfied() {
56 mJavascriptHelper.evaluateJavaScriptForTests(getWebContents( ), "positionCount"); 56 mJavascriptHelper.evaluateJavaScript(getWebContents(), "posi tionCount");
57 try { 57 try {
58 mJavascriptHelper.waitUntilHasValue(); 58 mJavascriptHelper.waitUntilHasValue();
59 } catch (Exception e) { 59 } catch (Exception e) {
60 fail(); 60 fail();
61 } 61 }
62 return Integer.parseInt(mJavascriptHelper.getJsonResultAndCl ear()) > 0; 62 return Integer.parseInt(mJavascriptHelper.getJsonResultAndCl ear()) > 0;
63 } 63 }
64 })); 64 }));
65 } 65 }
66 66
67 private void startGeolocationWatchPosition() throws Throwable { 67 private void startGeolocationWatchPosition() throws Throwable {
68 mJavascriptHelper.evaluateJavaScriptForTests(getWebContents(), 68 mJavascriptHelper.evaluateJavaScript(getWebContents(),
69 "initiate_watchPosition();"); 69 "initiate_watchPosition();");
70 mJavascriptHelper.waitUntilHasValue(); 70 mJavascriptHelper.waitUntilHasValue();
71 } 71 }
72 72
73 private void ensureGeolocationRunning(final boolean running) throws Exceptio n { 73 private void ensureGeolocationRunning(final boolean running) throws Exceptio n {
74 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { 74 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
75 @Override 75 @Override
76 public boolean isSatisfied() { 76 public boolean isSatisfied() {
77 return mMockLocationProvider.isRunning() == running; 77 return mMockLocationProvider.isRunning() == running;
78 } 78 }
(...skipping 30 matching lines...) Expand all
109 public void testWatchHideShowStop() throws Throwable { 109 public void testWatchHideShowStop() throws Throwable {
110 110
111 startGeolocationWatchPosition(); 111 startGeolocationWatchPosition();
112 pollForPositionCallback(); 112 pollForPositionCallback();
113 ensureGeolocationRunning(true); 113 ensureGeolocationRunning(true);
114 114
115 // Now hide the ContentView and ensure that geolocation stops. 115 // Now hide the ContentView and ensure that geolocation stops.
116 hideContentViewOnUiThread(); 116 hideContentViewOnUiThread();
117 ensureGeolocationRunning(false); 117 ensureGeolocationRunning(false);
118 118
119 mJavascriptHelper.evaluateJavaScriptForTests(getWebContents(), 119 mJavascriptHelper.evaluateJavaScript(getWebContents(),
120 "positionCount = 0"); 120 "positionCount = 0");
121 mJavascriptHelper.waitUntilHasValue(); 121 mJavascriptHelper.waitUntilHasValue();
122 122
123 // Show the ContentView again and ensure that geolocation starts again. 123 // Show the ContentView again and ensure that geolocation starts again.
124 showContentViewOnUiThread(); 124 showContentViewOnUiThread();
125 pollForPositionCallback(); 125 pollForPositionCallback();
126 ensureGeolocationRunning(true); 126 ensureGeolocationRunning(true);
127 127
128 // Navigate away and ensure that geolocation stops. 128 // Navigate away and ensure that geolocation stops.
129 loadUrl(getContentViewCore().getWebContents().getNavigationController(), 129 loadUrl(getContentViewCore().getWebContents().getNavigationController(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 hideContentViewOnUiThread(); 168 hideContentViewOnUiThread();
169 startGeolocationWatchPosition(); 169 startGeolocationWatchPosition();
170 ensureGeolocationRunning(false); 170 ensureGeolocationRunning(false);
171 171
172 loadUrl(getContentViewCore().getWebContents().getNavigationController(), 172 loadUrl(getContentViewCore().getWebContents().getNavigationController(),
173 mTestCallbackHelperContainer, new LoadUrlParams("about:blank")); 173 mTestCallbackHelperContainer, new LoadUrlParams("about:blank"));
174 showContentViewOnUiThread(); 174 showContentViewOnUiThread();
175 ensureGeolocationRunning(false); 175 ensureGeolocationRunning(false);
176 } 176 }
177 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698