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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa_browser_test.mm

Issue 1905273002: Fix positioning of Mac permission prompts when fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 4 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 #include "chrome/browser/ui/browser_window.h" 6 #include "chrome/browser/ui/browser_commands_mac.h"
7 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
8 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" 7 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
9 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h " 8 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h "
9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/website_settings/permission_bubble_browser_test_util .h" 11 #include "chrome/browser/ui/website_settings/permission_bubble_browser_test_util .h"
12 #include "chrome/common/pref_names.h"
13 #include "components/prefs/pref_service.h"
11 #import "testing/gtest_mac.h" 14 #import "testing/gtest_mac.h"
12 #import "ui/base/cocoa/fullscreen_window_manager.h" 15 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
13 16
14 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) { 17 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
15 PermissionBubbleCocoa bubble(browser()); 18 PermissionBubbleCocoa bubble(browser());
16 bubble.SetDelegate(test_delegate()); 19 bubble.SetDelegate(test_delegate());
17 bubble.Show(requests(), accept_states()); 20 bubble.Show(requests(), accept_states());
18 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 21 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
19 bubble.Hide(); 22 bubble.Hide();
20 } 23 }
21 24
22 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) { 25 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
26 BrowserFullscreenHasLocationBar) {
27 ui::test::ScopedFakeNSWindowFullscreen faker;
28
23 PermissionBubbleCocoa bubble(browser()); 29 PermissionBubbleCocoa bubble(browser());
24 bubble.SetDelegate(test_delegate()); 30 bubble.SetDelegate(test_delegate());
25 bubble.Show(requests(), accept_states()); 31 bubble.Show(requests(), accept_states());
32 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
26 33
27 NSWindow* window = browser()->window()->GetNativeWindow(); 34 FullscreenController* controller =
28 base::scoped_nsobject<FullscreenWindowManager> manager( 35 browser()->exclusive_access_manager()->fullscreen_controller();
29 [[FullscreenWindowManager alloc] initWithWindow:window 36 controller->ToggleBrowserFullscreenMode();
30 desiredScreen:[NSScreen mainScreen]]); 37 faker.FinishTransition();
31 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 38
32 [manager enterFullscreenMode]; 39 // The location bar should be visible if the toolbar is set to be visible in
33 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 40 // fullscreen mode.
34 [manager exitFullscreenMode]; 41 PrefService* prefs = browser()->profile()->GetPrefs();
35 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 42 bool show_toolbar = prefs->GetBoolean(prefs::kShowFullscreenToolbar);
43 EXPECT_EQ(show_toolbar, [bubble.bubbleController_ hasVisibleLocationBar]);
44
45 // Toggle the value of the preference.
46 chrome::ToggleFullscreenToolbar(browser());
47 EXPECT_EQ(!show_toolbar, [bubble.bubbleController_ hasVisibleLocationBar]);
48
49 // Put the setting back the way it started.
50 chrome::ToggleFullscreenToolbar(browser());
51 controller->ToggleBrowserFullscreenMode();
52 faker.FinishTransition();
53
54 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
36 bubble.Hide(); 55 bubble.Hide();
37 } 56 }
38 57
58 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
59 TabFullscreenHasLocationBar) {
60 ui::test::ScopedFakeNSWindowFullscreen faker;
61
62 PermissionBubbleCocoa bubble(browser());
63 bubble.SetDelegate(test_delegate());
64 bubble.Show(requests(), accept_states());
65 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
66
67 FullscreenController* controller =
68 browser()->exclusive_access_manager()->fullscreen_controller();
69 controller->EnterFullscreenModeForTab(
70 browser()->tab_strip_model()->GetActiveWebContents(), GURL());
71 faker.FinishTransition();
72
73 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
74 controller->ExitFullscreenModeForTab(
75 browser()->tab_strip_model()->GetActiveWebContents());
76 faker.FinishTransition();
77
78 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
79 bubble.Hide();
80 }
81
39 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, AppHasNoLocationBar) { 82 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, AppHasNoLocationBar) {
40 Browser* app_browser = OpenExtensionAppWindow(); 83 Browser* app_browser = OpenExtensionAppWindow();
41 PermissionBubbleCocoa bubble(app_browser); 84 PermissionBubbleCocoa bubble(app_browser);
42 bubble.SetDelegate(test_delegate()); 85 bubble.SetDelegate(test_delegate());
43 bubble.Show(requests(), accept_states()); 86 bubble.Show(requests(), accept_states());
44 EXPECT_FALSE([bubble.bubbleController_ hasLocationBar]); 87 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
45 bubble.Hide(); 88 bubble.Hide();
46 } 89 }
47 90
48 // http://crbug.com/470724 91 // http://crbug.com/470724
49 // Kiosk mode on Mac has a location bar but it shouldn't. 92 // Kiosk mode on Mac has a location bar but it shouldn't.
50 IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest, 93 IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
51 DISABLED_KioskHasNoLocationBar) { 94 DISABLED_KioskHasNoLocationBar) {
52 PermissionBubbleCocoa bubble(browser()); 95 PermissionBubbleCocoa bubble(browser());
53 bubble.SetDelegate(test_delegate()); 96 bubble.SetDelegate(test_delegate());
54 bubble.Show(requests(), accept_states()); 97 bubble.Show(requests(), accept_states());
55 EXPECT_FALSE([bubble.bubbleController_ hasLocationBar]); 98 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
56 bubble.Hide(); 99 bubble.Hide();
57 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698