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

Side by Side Diff: content/browser/device_sensors/device_sensor_browsertest.cc

Issue 2160913005: Use a ThreadChecker in DeviceSensorHost instead of DCHECK_CURRENTLY_ON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | content/browser/device_sensors/device_sensor_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/threading/platform_thread.h" 8 #include "base/threading/platform_thread.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" 10 #include "content/browser/device_sensors/data_fetcher_shared_memory.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 if (!cmd_line->HasSwitch(switches::kEnableExperimentalWebPlatformFeatures)) 219 if (!cmd_line->HasSwitch(switches::kEnableExperimentalWebPlatformFeatures))
220 cmd_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); 220 cmd_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures);
221 } 221 }
222 222
223 FakeDataFetcher* fetcher_; 223 FakeDataFetcher* fetcher_;
224 224
225 private: 225 private:
226 base::WaitableEvent io_loop_finished_event_; 226 base::WaitableEvent io_loop_finished_event_;
227 }; 227 };
228 228
229 // Flaky test. See http://crbug.com/628527. 229 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, OrientationTest) {
230 #if defined(ADDRESS_SANITIZER) && defined(OS_LINUX)
231 #define MAYBE_OrientationTest DISABLED_OrientationTest
232 #else
233 #define MAYBE_OrientationTest OrientationTest
234 #endif
235 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest,
236 MAYBE_OrientationTest) {
237 // The test page will register an event handler for orientation events, 230 // The test page will register an event handler for orientation events,
238 // expects to get an event with fake values, then removes the event 231 // expects to get an event with fake values, then removes the event
239 // handler and navigates to #pass. 232 // handler and navigates to #pass.
240 GURL test_url = GetTestUrl("device_sensors", "device_orientation_test.html"); 233 GURL test_url = GetTestUrl("device_sensors", "device_orientation_test.html");
241 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); 234 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
242 235
243 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 236 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
244 fetcher_->started_orientation_.Wait(); 237 fetcher_->started_orientation_.Wait();
245 fetcher_->stopped_orientation_.Wait(); 238 fetcher_->stopped_orientation_.Wait();
246 } 239 }
247 240
248 // Flaky test. See http://crbug.com/628527. 241 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, LightTest) {
249 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, DISABLED_LightTest) {
250 // The test page will register an event handler for light events, 242 // The test page will register an event handler for light events,
251 // expects to get an event with fake values, then removes the event 243 // expects to get an event with fake values, then removes the event
252 // handler and navigates to #pass. 244 // handler and navigates to #pass.
253 EnableExperimentalFeatures(); 245 EnableExperimentalFeatures();
254 GURL test_url = GetTestUrl("device_sensors", "device_light_test.html"); 246 GURL test_url = GetTestUrl("device_sensors", "device_light_test.html");
255 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); 247 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
256 248
257 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 249 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
258 fetcher_->started_light_.Wait(); 250 fetcher_->started_light_.Wait();
259 fetcher_->stopped_light_.Wait(); 251 fetcher_->stopped_light_.Wait();
260 } 252 }
261 253
262 // Flaky test. See http://crbug.com/628527. 254 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, MotionTest) {
263 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, DISABLED_MotionTest) {
264 // The test page will register an event handler for motion events, 255 // The test page will register an event handler for motion events,
265 // expects to get an event with fake values, then removes the event 256 // expects to get an event with fake values, then removes the event
266 // handler and navigates to #pass. 257 // handler and navigates to #pass.
267 GURL test_url = GetTestUrl("device_sensors", "device_motion_test.html"); 258 GURL test_url = GetTestUrl("device_sensors", "device_motion_test.html");
268 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); 259 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
269 260
270 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 261 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
271 fetcher_->started_motion_.Wait(); 262 fetcher_->started_motion_.Wait();
272 fetcher_->stopped_motion_.Wait(); 263 fetcher_->stopped_motion_.Wait();
273 } 264 }
274 265
275 // Flaky test. See http://crbug.com/628527. 266 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, LightOneOffInfintyTest) {
276 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest,
277 DISABLED_LightOneOffInfintyTest) {
278 // The test page registers an event handler for light events and expects 267 // The test page registers an event handler for light events and expects
279 // to get an event with value equal to infinity, because no sensor data can 268 // to get an event with value equal to infinity, because no sensor data can
280 // be provided. 269 // be provided.
281 EnableExperimentalFeatures(); 270 EnableExperimentalFeatures();
282 fetcher_->SetSensorDataAvailable(false); 271 fetcher_->SetSensorDataAvailable(false);
283 GURL test_url = 272 GURL test_url =
284 GetTestUrl("device_sensors", "device_light_infinity_test.html"); 273 GetTestUrl("device_sensors", "device_light_infinity_test.html");
285 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); 274 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
286 275
287 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 276 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
288 fetcher_->started_light_.Wait(); 277 fetcher_->started_light_.Wait();
289 fetcher_->stopped_light_.Wait(); 278 fetcher_->stopped_light_.Wait();
290 } 279 }
291 280
292 // Flaky test. See http://crbug.com/628527. 281 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, OrientationNullTest) {
293 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, DISABLED_OrientationNullTest) {
294 // The test page registers an event handler for orientation events and 282 // The test page registers an event handler for orientation events and
295 // expects to get an event with null values, because no sensor data can be 283 // expects to get an event with null values, because no sensor data can be
296 // provided. 284 // provided.
297 fetcher_->SetSensorDataAvailable(false); 285 fetcher_->SetSensorDataAvailable(false);
298 GURL test_url = 286 GURL test_url =
299 GetTestUrl("device_sensors", "device_orientation_null_test.html"); 287 GetTestUrl("device_sensors", "device_orientation_null_test.html");
300 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); 288 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
301 289
302 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 290 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
303 fetcher_->started_orientation_.Wait(); 291 fetcher_->started_orientation_.Wait();
304 fetcher_->stopped_orientation_.Wait(); 292 fetcher_->stopped_orientation_.Wait();
305 } 293 }
306 294
307 // Flaky test. See http://crbug.com/628527. 295 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, MotionNullTest) {
308 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, DISABLED_MotionNullTest) {
309 // The test page registers an event handler for motion events and 296 // The test page registers an event handler for motion events and
310 // expects to get an event with null values, because no sensor data can be 297 // expects to get an event with null values, because no sensor data can be
311 // provided. 298 // provided.
312 fetcher_->SetSensorDataAvailable(false); 299 fetcher_->SetSensorDataAvailable(false);
313 GURL test_url = GetTestUrl("device_sensors", "device_motion_null_test.html"); 300 GURL test_url = GetTestUrl("device_sensors", "device_motion_null_test.html");
314 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2); 301 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 2);
315 302
316 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 303 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
317 fetcher_->started_motion_.Wait(); 304 fetcher_->started_motion_.Wait();
318 fetcher_->stopped_motion_.Wait(); 305 fetcher_->stopped_motion_.Wait();
319 } 306 }
320 307
321 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, DISABLED_NullTestWithAlert) { 308 IN_PROC_BROWSER_TEST_F(DeviceSensorBrowserTest, NullTestWithAlert) {
322 // The test page registers an event handlers for motion/orientation events 309 // The test page registers an event handlers for motion/orientation events
323 // and expects to get events with null values. The test raises a modal alert 310 // and expects to get events with null values. The test raises a modal alert
324 // dialog with a delay to test that the one-off null-events still propagate 311 // dialog with a delay to test that the one-off null-events still propagate
325 // to window after the alert is dismissed and the callbacks are invoked which 312 // to window after the alert is dismissed and the callbacks are invoked which
326 // eventually navigate to #pass. 313 // eventually navigate to #pass.
327 fetcher_->SetSensorDataAvailable(false); 314 fetcher_->SetSensorDataAvailable(false);
328 TestNavigationObserver same_tab_observer(shell()->web_contents(), 2); 315 TestNavigationObserver same_tab_observer(shell()->web_contents(), 2);
329 316
330 GURL test_url = 317 GURL test_url =
331 GetTestUrl("device_sensors", "device_sensors_null_test_with_alert.html"); 318 GetTestUrl("device_sensors", "device_sensors_null_test_with_alert.html");
332 shell()->LoadURL(test_url); 319 shell()->LoadURL(test_url);
333 320
334 // TODO(timvolodine): investigate if it is possible to test this without 321 // TODO(timvolodine): investigate if it is possible to test this without
335 // delay, crbug.com/360044. 322 // delay, crbug.com/360044.
336 WaitForAlertDialogAndQuitAfterDelay(base::TimeDelta::FromMilliseconds(500)); 323 WaitForAlertDialogAndQuitAfterDelay(base::TimeDelta::FromMilliseconds(500));
337 324
338 fetcher_->started_motion_.Wait(); 325 fetcher_->started_motion_.Wait();
339 fetcher_->stopped_motion_.Wait(); 326 fetcher_->stopped_motion_.Wait();
340 fetcher_->started_orientation_.Wait(); 327 fetcher_->started_orientation_.Wait();
341 fetcher_->stopped_orientation_.Wait(); 328 fetcher_->stopped_orientation_.Wait();
342 same_tab_observer.Wait(); 329 same_tab_observer.Wait();
343 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 330 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
344 } 331 }
345 332
346 } // namespace 333 } // namespace
347 334
348 } // namespace content 335 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/device_sensors/device_sensor_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698