OLD | NEW |
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 #include "build/build_config.h" | 5 #include "build/build_config.h" |
6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/ui/browser_tabstrip.h" | 7 #include "chrome/browser/ui/browser_tabstrip.h" |
8 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 8 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
9 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h" | 9 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h" |
10 #include "chrome/test/base/browser_with_test_window_test.h" | 10 #include "chrome/test/base/browser_with_test_window_test.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 window_->set_reentrant(reentrant); | 310 window_->set_reentrant(reentrant); |
311 FullscreenControllerStateTest::TestStateAndEvent(state, event, reentrant); | 311 FullscreenControllerStateTest::TestStateAndEvent(state, event, reentrant); |
312 } | 312 } |
313 | 313 |
314 Browser* FullscreenControllerStateUnitTest::GetBrowser() { | 314 Browser* FullscreenControllerStateUnitTest::GetBrowser() { |
315 return BrowserWithTestWindowTest::browser(); | 315 return BrowserWithTestWindowTest::browser(); |
316 } | 316 } |
317 | 317 |
318 // Tests ----------------------------------------------------------------------- | 318 // Tests ----------------------------------------------------------------------- |
319 | 319 |
320 // Soak tests: | |
321 | |
322 // Tests all states with all permutations of multiple events to detect lingering | |
323 // state issues that would bleed over to other states. | |
324 // I.E. for each state test all combinations of events E1, E2, E3. | |
325 // | |
326 // This produces coverage for event sequences that may happen normally but | |
327 // would not be exposed by traversing to each state via TransitionToState(). | |
328 // TransitionToState() always takes the same path even when multiple paths | |
329 // exist. | |
330 TEST_F(FullscreenControllerStateUnitTest, TransitionsForEachState) { | |
331 // A tab is needed for tab fullscreen. | |
332 AddTab(browser(), GURL(chrome::kAboutBlankURL)); | |
333 TestTransitionsForEachState(); | |
334 // Progress of test can be examined via LOG(INFO) << GetAndClearDebugLog(); | |
335 } | |
336 | |
337 | |
338 // Individual tests for each pair of state and event: | |
339 | |
340 #define TEST_EVENT_INNER(state, event, reentrant, reentrant_id) \ | 320 #define TEST_EVENT_INNER(state, event, reentrant, reentrant_id) \ |
341 TEST_F(FullscreenControllerStateUnitTest, \ | 321 TEST_F(FullscreenControllerStateUnitTest, \ |
342 state##__##event##reentrant_id) { \ | 322 state##__##event##reentrant_id) { \ |
343 AddTab(browser(), GURL(chrome::kAboutBlankURL)); \ | 323 AddTab(browser(), GURL(chrome::kAboutBlankURL)); \ |
344 ASSERT_NO_FATAL_FAILURE(TestStateAndEvent(state, event, reentrant)) \ | 324 ASSERT_NO_FATAL_FAILURE(TestStateAndEvent(state, event, reentrant)) \ |
345 << GetAndClearDebugLog(); \ | 325 << GetAndClearDebugLog(); \ |
346 } | 326 } |
347 // Progress of tests can be examined by inserting the following line: | 327 // Progress of tests can be examined by inserting the following line: |
348 // LOG(INFO) << GetAndClearDebugLog(); } | 328 // LOG(INFO) << GetAndClearDebugLog(); } |
349 | 329 |
350 #define TEST_EVENT(state, event) \ | 330 #define TEST_EVENT(state, event) \ |
351 TEST_EVENT_INNER(state, event, false, ); \ | 331 TEST_EVENT_INNER(state, event, false, ); \ |
352 TEST_EVENT_INNER(state, event, true, _Reentrant); | 332 TEST_EVENT_INNER(state, event, true, _Reentrant); |
353 | 333 |
| 334 // Individual tests for each pair of state and event: |
| 335 |
354 TEST_EVENT(STATE_NORMAL, TOGGLE_FULLSCREEN); | 336 TEST_EVENT(STATE_NORMAL, TOGGLE_FULLSCREEN); |
355 TEST_EVENT(STATE_NORMAL, TAB_FULLSCREEN_TRUE); | 337 TEST_EVENT(STATE_NORMAL, TAB_FULLSCREEN_TRUE); |
356 TEST_EVENT(STATE_NORMAL, TAB_FULLSCREEN_FALSE); | 338 TEST_EVENT(STATE_NORMAL, TAB_FULLSCREEN_FALSE); |
357 #if defined(OS_WIN) | 339 #if defined(OS_WIN) |
358 TEST_EVENT(STATE_NORMAL, METRO_SNAP_TRUE); | 340 TEST_EVENT(STATE_NORMAL, METRO_SNAP_TRUE); |
359 TEST_EVENT(STATE_NORMAL, METRO_SNAP_FALSE); | 341 TEST_EVENT(STATE_NORMAL, METRO_SNAP_FALSE); |
360 #endif | 342 #endif |
361 TEST_EVENT(STATE_NORMAL, BUBBLE_EXIT_LINK); | 343 TEST_EVENT(STATE_NORMAL, BUBBLE_EXIT_LINK); |
362 TEST_EVENT(STATE_NORMAL, BUBBLE_ALLOW); | 344 TEST_EVENT(STATE_NORMAL, BUBBLE_ALLOW); |
363 TEST_EVENT(STATE_NORMAL, BUBBLE_DENY); | 345 TEST_EVENT(STATE_NORMAL, BUBBLE_DENY); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, TAB_FULLSCREEN_FALSE); | 422 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, TAB_FULLSCREEN_FALSE); |
441 #if defined(OS_WIN) | 423 #if defined(OS_WIN) |
442 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, METRO_SNAP_TRUE); | 424 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, METRO_SNAP_TRUE); |
443 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, METRO_SNAP_FALSE); | 425 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, METRO_SNAP_FALSE); |
444 #endif | 426 #endif |
445 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, BUBBLE_EXIT_LINK); | 427 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, BUBBLE_EXIT_LINK); |
446 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, BUBBLE_ALLOW); | 428 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, BUBBLE_ALLOW); |
447 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, BUBBLE_DENY); | 429 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, BUBBLE_DENY); |
448 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, WINDOW_CHANGE); | 430 TEST_EVENT(STATE_TO_TAB_FULLSCREEN, WINDOW_CHANGE); |
449 | 431 |
450 | |
451 // Specific one-off tests for known issues: | 432 // Specific one-off tests for known issues: |
452 | 433 |
453 // TODO(scheib) Toggling Tab fullscreen while pending Tab or | 434 // TODO(scheib) Toggling Tab fullscreen while pending Tab or |
454 // Browser fullscreen is broken currently http://crbug.com/154196 | 435 // Browser fullscreen is broken currently http://crbug.com/154196 |
455 TEST_F(FullscreenControllerStateUnitTest, | 436 TEST_F(FullscreenControllerStateUnitTest, |
456 DISABLED_ToggleTabWhenPendingBrowser) { | 437 DISABLED_ToggleTabWhenPendingBrowser) { |
457 #if !defined(OS_WIN) // Only possible without reentrancy | 438 #if !defined(OS_WIN) // Only possible without reentrancy |
458 AddTab(browser(), GURL(chrome::kAboutBlankURL)); | 439 AddTab(browser(), GURL(chrome::kAboutBlankURL)); |
459 ASSERT_NO_FATAL_FAILURE( | 440 ASSERT_NO_FATAL_FAILURE( |
460 TransitionToState(STATE_TO_BROWSER_FULLSCREEN_NO_CHROME)) | 441 TransitionToState(STATE_TO_BROWSER_FULLSCREEN_NO_CHROME)) |
(...skipping 13 matching lines...) Expand all Loading... |
474 ASSERT_NO_FATAL_FAILURE( | 455 ASSERT_NO_FATAL_FAILURE( |
475 TransitionToState(STATE_TO_TAB_FULLSCREEN)) | 456 TransitionToState(STATE_TO_TAB_FULLSCREEN)) |
476 << GetAndClearDebugLog(); | 457 << GetAndClearDebugLog(); |
477 | 458 |
478 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)) << GetAndClearDebugLog(); | 459 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)) << GetAndClearDebugLog(); |
479 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE)) << GetAndClearDebugLog(); | 460 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE)) << GetAndClearDebugLog(); |
480 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)) << GetAndClearDebugLog(); | 461 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)) << GetAndClearDebugLog(); |
481 #endif | 462 #endif |
482 } | 463 } |
483 | 464 |
| 465 // Soak tests: |
| 466 |
| 467 // Tests all states with all permutations of multiple events to detect lingering |
| 468 // state issues that would bleed over to other states. |
| 469 // I.E. for each state test all combinations of events E1, E2, E3. |
| 470 // |
| 471 // This produces coverage for event sequences that may happen normally but |
| 472 // would not be exposed by traversing to each state via TransitionToState(). |
| 473 // TransitionToState() always takes the same path even when multiple paths |
| 474 // exist. |
| 475 TEST_F(FullscreenControllerStateUnitTest, TransitionsForEachState) { |
| 476 // A tab is needed for tab fullscreen. |
| 477 AddTab(browser(), GURL(chrome::kAboutBlankURL)); |
| 478 TestTransitionsForEachState(); |
| 479 // Progress of test can be examined via LOG(INFO) << GetAndClearDebugLog(); |
| 480 } |
| 481 |
OLD | NEW |