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

Side by Side Diff: chrome/browser/ui/fullscreen/fullscreen_controller_test.cc

Issue 10919113: Move fullscreen_controller browser tests to interactive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cross platform safe include of mac specific header Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" 5 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_tabstrip.h" 10 #include "chrome/browser/ui/browser_tabstrip.h"
11 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 12 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/test_navigation_observer.h" 15 #include "content/public/test/test_navigation_observer.h"
16 16
17 using content::WebContents; 17 using content::WebContents;
18 18
19 const char FullscreenControllerTest::kFullscreenMouseLockHTML[] = 19 const char FullscreenControllerTest::kFullscreenMouseLockHTML[] =
20 "files/fullscreen_mouselock/fullscreen_mouselock.html"; 20 "files/fullscreen_mouselock/fullscreen_mouselock.html";
21 21
22 void FullscreenControllerTest::SetUpCommandLine(CommandLine* command_line) { 22 void FullscreenControllerTest::SetUpCommandLine(CommandLine* command_line) {
23 command_line->AppendSwitch(switches::kEnablePointerLock); 23 command_line->AppendSwitch(switches::kEnablePointerLock);
24 } 24 }
25 25
26 void FullscreenControllerTest::ToggleTabFullscreen(bool enter_fullscreen) {
27 ToggleTabFullscreen_Internal(enter_fullscreen, true);
28 }
29
30 // |ToggleTabFullscreen| should not need to tolerate the transition failing.
31 // Most fullscreen tests run sharded in fullscreen_controller_browsertest.cc
32 // and some flakiness has occurred when calling |ToggleTabFullscreen|, so that
33 // method has been made robust by retrying if the transition fails.
34 // The root cause of that flakiness should still be tracked down, see
35 // http://crbug.com/133831. In the mean time, this method
36 // allows a fullscreen_controller_interactive_browsertest.cc test to verify
37 // that when running serially there is no flakiness in the transition.
38 void FullscreenControllerTest::ToggleTabFullscreenNoRetries(
39 bool enter_fullscreen) {
40 ToggleTabFullscreen_Internal(enter_fullscreen, false);
41 }
42
43 void FullscreenControllerTest::ToggleBrowserFullscreen(bool enter_fullscreen) {
44 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen);
45 FullscreenNotificationObserver fullscreen_observer;
46
47 chrome::ToggleFullscreenMode(browser());
48
49 fullscreen_observer.Wait();
50 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
51 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen);
52 }
53
54 void FullscreenControllerTest::RequestToLockMouse( 26 void FullscreenControllerTest::RequestToLockMouse(
55 bool user_gesture, 27 bool user_gesture,
56 bool last_unlocked_by_target) { 28 bool last_unlocked_by_target) {
57 WebContents* tab = chrome::GetActiveWebContents(browser()); 29 WebContents* tab = chrome::GetActiveWebContents(browser());
58 browser()->RequestToLockMouse(tab, user_gesture, 30 browser()->RequestToLockMouse(tab, user_gesture,
59 last_unlocked_by_target); 31 last_unlocked_by_target);
60 } 32 }
61 33
62 void FullscreenControllerTest::LostMouseLock() { 34 void FullscreenControllerTest::LostMouseLock() {
63 browser()->LostMouseLock(); 35 browser()->LostMouseLock();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 115
144 void FullscreenControllerTest::Reload() { 116 void FullscreenControllerTest::Reload() {
145 content::TestNavigationObserver observer( 117 content::TestNavigationObserver observer(
146 content::NotificationService::AllSources(), NULL, 1); 118 content::NotificationService::AllSources(), NULL, 1);
147 119
148 chrome::Reload(browser(), CURRENT_TAB); 120 chrome::Reload(browser(), CURRENT_TAB);
149 121
150 observer.Wait(); 122 observer.Wait();
151 } 123 }
152 124
153 void FullscreenControllerTest::ToggleTabFullscreen_Internal(
154 bool enter_fullscreen, bool retry_until_success) {
155 WebContents* tab = chrome::GetActiveWebContents(browser());
156 if (IsFullscreenForBrowser()) {
157 // Changing tab fullscreen state will not actually change the window
158 // when browser fullscreen is in effect.
159 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
160 } else { // Not in browser fullscreen, expect window to actually change.
161 ASSERT_NE(browser()->window()->IsFullscreen(), enter_fullscreen);
162 do {
163 FullscreenNotificationObserver fullscreen_observer;
164 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
165 fullscreen_observer.Wait();
166 // Repeat ToggleFullscreenModeForTab until the correct state is entered.
167 // This addresses flakiness on test bots running many fullscreen
168 // tests in parallel.
169 } while (retry_until_success &&
170 browser()->window()->IsFullscreen() != enter_fullscreen);
171 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
172 }
173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698