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 3 // found in the LICENSE file. 4 5 #include "build/build_config.h" 6 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser_tabstrip.h" 8 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h" 11 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" 12 #include "chrome/test/base/in_process_browser_test.h" 13 #include "content/public/browser/web_contents.h" 14 #include "content/public/common/url_constants.h" 15 #include "content/public/test/test_utils.h" 16 #include "testing/gtest/include/gtest/gtest.h" 17 18 19 // FullscreenControllerStateInteractiveTest ------------------------------------ 20 21 // Interactive test fixture testing Fullscreen Controller through its states. 22 // 23 // Used to verify that the FullscreenControllerTestWindow models the behavior 24 // of actual windows accurately. The interactive tests are too flaky to run 25 // on infrastructure, and so those tests are disabled. Run them with: 26 // interactive_ui_tests 27 // --gtest_filter="FullscreenControllerStateInteractiveTest.*" 28 // --gtest_also_run_disabled_tests 29 // 30 // More context atop fullscreen_controller_state_test.h. 31 class FullscreenControllerStateInteractiveTest 32 : public InProcessBrowserTest, 33 public FullscreenControllerStateTest { 34 private: 35 // FullscreenControllerStateTest override: 36 virtual Browser* GetBrowser() OVERRIDE; 37 }; 38 39 Browser* FullscreenControllerStateInteractiveTest::GetBrowser() { 40 return InProcessBrowserTest::browser(); 41 } 42 43 44 // Soak tests ------------------------------------------------------------------ 45 46 // Tests all states with all permutations of multiple events to detect lingering 47 // state issues that would bleed over to other states. 48 // I.E. for each state test all combinations of events E1, E2, E3. 49 // 50 // This produces coverage for event sequences that may happen normally but 51 // would not be exposed by traversing to each state via TransitionToState(). 52 // TransitionToState() always takes the same path even when multiple paths 53 // exist. 54 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest, 55 DISABLED_TransitionsForEachState) { 56 // A tab is needed for tab fullscreen. 57 AddTabAtIndex(0, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED); 58 TestTransitionsForEachState(); 59 // Progress of test can be examined via LOG(INFO) << GetAndClearDebugLog(); 60 } 61 62 63 // Individual tests for each pair of state and event --------------------------- 64 65 // An "empty" test is included as part of each "TEST_EVENT" because it makes 66 // running the entire test suite less flaky on MacOS. All of the tests pass 67 // when run individually. 68 #define TEST_EVENT(state, event) \ 69 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest, \ 70 DISABLED_##state##__##event##__Empty) {} \ 71 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest, \ 72 DISABLED_##state##__##event) { \ 73 AddTabAtIndex( \ 74 0, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED); \ 75 ASSERT_NO_FATAL_FAILURE(TestStateAndEvent(state, event)) \ 76 << GetAndClearDebugLog(); \ 77 } 78 // Progress of tests can be examined by inserting the following line: 79 // LOG(INFO) << GetAndClearDebugLog(); } 80 81 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_tests.h" 82 83 84 // Specific one-off tests for known issues ------------------------------------- 85 86 // Used manually to determine what happens on a platform. 87 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest, 88 DISABLED_ManualTest) { 89 // A tab is needed for tab fullscreen. 90 AddTabAtIndex(0, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED); 91 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN)) << GetAndClearDebugLog(); 92 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)) << GetAndClearDebugLog(); 93 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)) << GetAndClearDebugLog(); 94 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN)) << GetAndClearDebugLog(); 95 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)) << GetAndClearDebugLog(); 96 97 // Wait, allowing human operator to observe the result. 98 scoped_refptr<content::MessageLoopRunner> message_loop 99 = new content::MessageLoopRunner(); 100 message_loop->Run(); 101 } 102 103