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.
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"
19 // FullscreenControllerStateInteractiveTest ------------------------------------
21 // Interactive test fixture testing Fullscreen Controller through its states.
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
30 // More context atop fullscreen_controller_state_test.h.
31 class FullscreenControllerStateInteractiveTest
32 : public InProcessBrowserTest
,
33 public FullscreenControllerStateTest
{
35 // FullscreenControllerStateTest override:
36 virtual Browser
* GetBrowser() OVERRIDE
;
39 Browser
* FullscreenControllerStateInteractiveTest::GetBrowser() {
40 return InProcessBrowserTest::browser();
44 // Soak tests ------------------------------------------------------------------
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.
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
54 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest
,
55 DISABLED_TransitionsForEachState
) {
56 // A tab is needed for tab fullscreen.
57 AddTabAtIndex(0, GURL(content::kAboutBlankURL
),
58 content::PAGE_TRANSITION_TYPED
);
59 TestTransitionsForEachState();
60 // Progress of test can be examined via LOG(INFO) << GetAndClearDebugLog();
64 // Individual tests for each pair of state and event ---------------------------
66 // An "empty" test is included as part of each "TEST_EVENT" because it makes
67 // running the entire test suite less flaky on MacOS. All of the tests pass
68 // when run individually.
69 #define TEST_EVENT(state, event) \
70 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest, \
71 DISABLED_##state##__##event##__Empty) { \
73 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest, \
74 DISABLED_##state##__##event) { \
75 AddTabAtIndex(0, GURL(content::kAboutBlankURL), \
76 content::PAGE_TRANSITION_TYPED); \
77 ASSERT_NO_FATAL_FAILURE(TestStateAndEvent(state, event)) \
78 << GetAndClearDebugLog(); \
80 // Progress of tests can be examined by inserting the following line:
81 // LOG(INFO) << GetAndClearDebugLog(); }
83 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_tests.h"
86 // Specific one-off tests for known issues -------------------------------------
88 // Used manually to determine what happens on a platform.
89 IN_PROC_BROWSER_TEST_F(FullscreenControllerStateInteractiveTest
,
90 DISABLED_ManualTest
) {
91 // A tab is needed for tab fullscreen.
92 AddTabAtIndex(0, GURL(content::kAboutBlankURL
),
93 content::PAGE_TRANSITION_TYPED
);
94 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN
)) << GetAndClearDebugLog();
95 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE
)) << GetAndClearDebugLog();
96 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE
)) << GetAndClearDebugLog();
97 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN
)) << GetAndClearDebugLog();
98 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE
)) << GetAndClearDebugLog();
100 // Wait, allowing human operator to observe the result.
101 scoped_refptr
<content::MessageLoopRunner
> message_loop
102 = new content::MessageLoopRunner();