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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 1650713003: Preference for Presentation Mode/Fullscreen Toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 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
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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 9
10 #include "base/mac/sdk_forward_declarations.h" 10 #include "base/mac/sdk_forward_declarations.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/devtools/devtools_window_testing.h" 16 #include "chrome/browser/devtools/devtools_window_testing.h"
17 #include "chrome/browser/fullscreen.h"
17 #include "chrome/browser/infobars/infobar_service.h" 18 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 21 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
23 #include "chrome/browser/ui/browser_list.h" 24 #include "chrome/browser/ui/browser_list.h"
24 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" 26 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
26 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 27 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
27 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 28 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
28 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" 29 #import "chrome/browser/ui/cocoa/history_overlay_controller.h"
29 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" 30 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
30 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 31 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
31 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 32 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
32 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 33 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
34 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
33 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" 35 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
34 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" 36 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
35 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 37 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
36 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 38 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
37 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" 39 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h"
38 #include "chrome/browser/ui/extensions/application_launch.h" 40 #include "chrome/browser/ui/extensions/application_launch.h"
39 #include "chrome/browser/ui/find_bar/find_bar.h" 41 #include "chrome/browser/ui/find_bar/find_bar.h"
40 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 42 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
41 #include "chrome/browser/ui/infobar_container_delegate.h" 43 #include "chrome/browser/ui/infobar_container_delegate.h"
42 #include "chrome/browser/ui/tabs/tab_strip_model.h" 44 #include "chrome/browser/ui/tabs/tab_strip_model.h"
45 #include "chrome/common/pref_names.h"
43 #include "chrome/test/base/in_process_browser_test.h" 46 #include "chrome/test/base/in_process_browser_test.h"
44 #include "chrome/test/base/testing_profile.h" 47 #include "chrome/test/base/testing_profile.h"
45 #include "components/infobars/core/infobar_delegate.h" 48 #include "components/infobars/core/infobar_delegate.h"
46 #include "components/infobars/core/simple_alert_infobar_delegate.h" 49 #include "components/infobars/core/simple_alert_infobar_delegate.h"
47 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
48 #include "content/public/test/test_utils.h" 51 #include "content/public/test/test_utils.h"
49 #import "testing/gtest_mac.h" 52 #import "testing/gtest_mac.h"
50 #import "third_party/ocmock/OCMock/OCMock.h" 53 #import "third_party/ocmock/OCMock/OCMock.h"
51 #import "ui/base/cocoa/nsview_additions.h" 54 #import "ui/base/cocoa/nsview_additions.h"
52 #include "ui/gfx/animation/slide_animation.h" 55 #include "ui/gfx/animation/slide_animation.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 base::Timer timer(false, true); 312 base::Timer timer(false, true);
310 timer.Start( 313 timer.Start(
311 FROM_HERE, 314 FROM_HERE,
312 base::TimeDelta::FromMilliseconds(15), 315 base::TimeDelta::FromMilliseconds(15),
313 base::Bind(&CheckBookmarkBarAnimation, 316 base::Bind(&CheckBookmarkBarAnimation,
314 [controller() bookmarkBarController], 317 [controller() bookmarkBarController],
315 runner->QuitClosure())); 318 runner->QuitClosure()));
316 runner->Run(); 319 runner->Run();
317 } 320 }
318 321
322 void VerifyFullscreenToolbarVisibility(fullscreen_mac::SlidingStyle style) {
323 EXPECT_EQ([[controller() presentationModeController] slidingStyle], style);
324
325 NSRect toolbarFrame = [[[controller() toolbarController] view] frame];
326 NSRect screenFrame = [[[controller() window] screen] frame];
327 if (style == fullscreen_mac::OMNIBOX_TABS_PRESENT)
328 EXPECT_LE(NSMaxY(toolbarFrame), NSMaxY(screenFrame));
329 else
330 EXPECT_GE(NSMinY(toolbarFrame), NSMaxY(screenFrame));
331 }
332
319 NSInteger GetExpectedTopInfoBarTipHeight() { 333 NSInteger GetExpectedTopInfoBarTipHeight() {
320 InfoBarContainerController* info_bar_container_controller = 334 InfoBarContainerController* info_bar_container_controller =
321 [controller() infoBarContainerController]; 335 [controller() infoBarContainerController];
322 CGFloat overlapping_tip_height = 336 CGFloat overlapping_tip_height =
323 [info_bar_container_controller overlappingTipHeight]; 337 [info_bar_container_controller overlappingTipHeight];
324 LocationBarViewMac* location_bar_view = [controller() locationBarBridge]; 338 LocationBarViewMac* location_bar_view = [controller() locationBarBridge];
325 NSPoint icon_bottom = location_bar_view->GetPageInfoBubblePoint(); 339 NSPoint icon_bottom = location_bar_view->GetPageInfoBubblePoint();
326 340
327 NSPoint info_bar_top = NSMakePoint(0, 341 NSPoint info_bar_top = NSMakePoint(0,
328 NSHeight([info_bar_container_controller view].frame) - 342 NSHeight([info_bar_container_controller view].frame) -
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // are reset correctly after the transition. 680 // are reset correctly after the transition.
667 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, FullscreenResizeFlags) { 681 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, FullscreenResizeFlags) {
668 // Enter fullscreen and verify the flags. 682 // Enter fullscreen and verify the flags.
669 ToggleFullscreenAndWaitForNotification(); 683 ToggleFullscreenAndWaitForNotification();
670 VerifyFullscreenResizeFlagsAfterTransition(); 684 VerifyFullscreenResizeFlagsAfterTransition();
671 685
672 // Exit fullscreen and verify the flags. 686 // Exit fullscreen and verify the flags.
673 ToggleFullscreenAndWaitForNotification(); 687 ToggleFullscreenAndWaitForNotification();
674 VerifyFullscreenResizeFlagsAfterTransition(); 688 VerifyFullscreenResizeFlagsAfterTransition();
675 } 689 }
690
691 // Tests that the omnibox and tabs are hidden/visible in fullscreen mode.
692 // Ensure that when the user toggles this setting, the omnibox, tabs and
693 // preferences are updated correctly.
694 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
695 FullscreenToolbarIsVisibleAccordingToPrefs) {
696 // This feature is only available on SystemFullscreen.
697 if (!chrome::mac::SupportsSystemFullscreen())
698 return;
699
700 // Tests that the preference is set to false by default.
701 PrefService* prefs = browser()->profile()->GetPrefs();
702 EXPECT_FALSE(prefs->GetBoolean(prefs::kHideFullscreenToolbar));
703
704 // Toggle fullscreen and check if the toolbar is shown.
705 ToggleFullscreenAndWaitForNotification();
706 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_PRESENT);
707
708 // Toggle the visibility of the fullscreen toolbar. Verify that the toolbar
709 // is hidden and the preference is correctly updated.
710 [[controller() presentationModeController] setToolbarFraction:0.0];
711 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR);
712 EXPECT_TRUE(prefs->GetBoolean(prefs::kHideFullscreenToolbar));
713 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN);
714
715 // Toggle out and back into fullscreen and verify that the toolbar is still
716 // hidden.
717 ToggleFullscreenAndWaitForNotification();
718 ToggleFullscreenAndWaitForNotification();
719 VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN);
720
721 chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR);
722 EXPECT_FALSE(prefs->GetBoolean(prefs::kHideFullscreenToolbar));
723 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698