OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.location.Location; | 7 import android.location.Location; |
8 import android.test.FlakyTest; | 8 import android.test.FlakyTest; |
9 | 9 |
10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 */ | 85 */ |
86 @FlakyTest | 86 @FlakyTest |
87 public void testGeolocationPlumbing() throws Exception { | 87 public void testGeolocationPlumbing() throws Exception { |
88 final String url = TestHttpServerClient.getUrl( | 88 final String url = TestHttpServerClient.getUrl( |
89 "chrome/test/data/geolocation/geolocation_on_load.html"); | 89 "chrome/test/data/geolocation/geolocation_on_load.html"); |
90 | 90 |
91 Tab tab = getActivity().getActivityTab(); | 91 Tab tab = getActivity().getActivityTab(); |
92 final CallbackHelper loadCallback = new CallbackHelper(); | 92 final CallbackHelper loadCallback = new CallbackHelper(); |
93 TabObserver observer = new EmptyTabObserver() { | 93 TabObserver observer = new EmptyTabObserver() { |
94 @Override | 94 @Override |
95 public void onLoadStopped(Tab tab) { | 95 public void onLoadStopped(Tab tab, boolean toDifferentDocument) { |
96 // If the device has a cached non-mock location, we won't get ba
ck our | 96 // If the device has a cached non-mock location, we won't get ba
ck our |
97 // lat/long, so checking that it has "#pass" is sufficient. | 97 // lat/long, so checking that it has "#pass" is sufficient. |
98 if (tab.getUrl().startsWith(url + "#pass|")) { | 98 if (tab.getUrl().startsWith(url + "#pass|")) { |
99 loadCallback.notifyCalled(); | 99 loadCallback.notifyCalled(); |
100 } | 100 } |
101 } | 101 } |
102 }; | 102 }; |
103 tab.addObserver(observer); | 103 tab.addObserver(observer); |
104 loadUrl(url); | 104 loadUrl(url); |
105 assertTrue("InfoBar not added.", mListener.addInfoBarAnimationFinished()
); | 105 assertTrue("InfoBar not added.", mListener.addInfoBarAnimationFinished()
); |
(...skipping 16 matching lines...) Expand all Loading... |
122 */ | 122 */ |
123 @FlakyTest | 123 @FlakyTest |
124 public void testGeolocationWatch() throws Exception { | 124 public void testGeolocationWatch() throws Exception { |
125 final String url = TestHttpServerClient.getUrl( | 125 final String url = TestHttpServerClient.getUrl( |
126 "chrome/test/data/geolocation/geolocation_on_load.html"); | 126 "chrome/test/data/geolocation/geolocation_on_load.html"); |
127 | 127 |
128 Tab tab = getActivity().getActivityTab(); | 128 Tab tab = getActivity().getActivityTab(); |
129 final CallbackHelper loadCallback0 = new CallbackHelper(); | 129 final CallbackHelper loadCallback0 = new CallbackHelper(); |
130 TabObserver observer = new EmptyTabObserver() { | 130 TabObserver observer = new EmptyTabObserver() { |
131 @Override | 131 @Override |
132 public void onLoadStopped(Tab tab) { | 132 public void onLoadStopped(Tab tab, boolean toDifferentDocument) { |
133 // If the device has a cached non-mock location, we won't get ba
ck our | 133 // If the device has a cached non-mock location, we won't get ba
ck our |
134 // lat/long, so checking that it has "#pass" is sufficient. | 134 // lat/long, so checking that it has "#pass" is sufficient. |
135 if (tab.getUrl().startsWith(url + "#pass|0|")) { | 135 if (tab.getUrl().startsWith(url + "#pass|0|")) { |
136 loadCallback0.notifyCalled(); | 136 loadCallback0.notifyCalled(); |
137 } | 137 } |
138 } | 138 } |
139 }; | 139 }; |
140 tab.addObserver(observer); | 140 tab.addObserver(observer); |
141 loadUrl(url); | 141 loadUrl(url); |
142 assertTrue("InfoBar not added.", mListener.addInfoBarAnimationFinished()
); | 142 assertTrue("InfoBar not added.", mListener.addInfoBarAnimationFinished()
); |
143 | 143 |
144 List<InfoBar> infoBars = getActivity().getActivityTab().getInfoBarContai
ner().getInfoBars(); | 144 List<InfoBar> infoBars = getActivity().getActivityTab().getInfoBarContai
ner().getInfoBars(); |
145 assertTrue("OK button wasn't found", InfoBarUtil.clickPrimaryButton(info
Bars.get(0))); | 145 assertTrue("OK button wasn't found", InfoBarUtil.clickPrimaryButton(info
Bars.get(0))); |
146 | 146 |
147 sendLocation(createMockLocation(LATITUDE, LONGITUDE, ACCURACY)); | 147 sendLocation(createMockLocation(LATITUDE, LONGITUDE, ACCURACY)); |
148 | 148 |
149 loadCallback0.waitForCallback(0); | 149 loadCallback0.waitForCallback(0); |
150 tab.removeObserver(observer); | 150 tab.removeObserver(observer); |
151 | 151 |
152 // Send another location: it'll update the URL again, so increase the co
unt. | 152 // Send another location: it'll update the URL again, so increase the co
unt. |
153 final CallbackHelper loadCallback1 = new CallbackHelper(); | 153 final CallbackHelper loadCallback1 = new CallbackHelper(); |
154 observer = new EmptyTabObserver() { | 154 observer = new EmptyTabObserver() { |
155 @Override | 155 @Override |
156 public void onLoadStopped(Tab tab) { | 156 public void onLoadStopped(Tab tab, boolean toDifferentDocument) { |
157 // If the device has a cached non-mock location, we won't get ba
ck our | 157 // If the device has a cached non-mock location, we won't get ba
ck our |
158 // lat/long, so checking that it has "#pass" is sufficient. | 158 // lat/long, so checking that it has "#pass" is sufficient. |
159 if (tab.getUrl().startsWith(url + "#pass|1|")) { | 159 if (tab.getUrl().startsWith(url + "#pass|1|")) { |
160 loadCallback1.notifyCalled(); | 160 loadCallback1.notifyCalled(); |
161 } | 161 } |
162 } | 162 } |
163 }; | 163 }; |
164 tab.addObserver(observer); | 164 tab.addObserver(observer); |
165 sendLocation(createMockLocation(LATITUDE + 1, LONGITUDE - 1, ACCURACY -
1)); | 165 sendLocation(createMockLocation(LATITUDE + 1, LONGITUDE - 1, ACCURACY -
1)); |
166 loadCallback1.waitForCallback(0); | 166 loadCallback1.waitForCallback(0); |
(...skipping 22 matching lines...) Expand all Loading... |
189 location.getLatitude(), location.getLongitude(), | 189 location.getLatitude(), location.getLongitude(), |
190 location.getTime() / 1000.0, | 190 location.getTime() / 1000.0, |
191 location.hasAltitude(), location.getAltitude(), | 191 location.hasAltitude(), location.getAltitude(), |
192 location.hasAccuracy(), location.getAccuracy(), | 192 location.hasAccuracy(), location.getAccuracy(), |
193 location.hasBearing(), location.getBearing(), | 193 location.hasBearing(), location.getBearing(), |
194 location.hasSpeed(), location.getSpeed()); | 194 location.hasSpeed(), location.getSpeed()); |
195 } | 195 } |
196 }); | 196 }); |
197 } | 197 } |
198 } | 198 } |
OLD | NEW |