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

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: Created 4 years, 8 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"
14 #include "content/public/test/test_utils.h"
11 #import "testing/gtest_mac.h" 15 #import "testing/gtest_mac.h"
12 #import "ui/base/cocoa/fullscreen_window_manager.h" 16 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
13 17
14 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) { 18 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
15 PermissionBubbleCocoa bubble(browser()); 19 PermissionBubbleCocoa bubble(browser());
16 bubble.SetDelegate(test_delegate()); 20 bubble.SetDelegate(test_delegate());
17 bubble.Show(requests(), accept_states()); 21 bubble.Show(requests(), accept_states());
18 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 22 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
19 bubble.Hide(); 23 bubble.Hide();
20 } 24 }
21 25
22 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, FullscreenHasLocationBar) { 26 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
27 BrowserFullscreenHasLocationBar) {
28 ui::test::ScopedFakeNSWindowFullscreen faker;
29
23 PermissionBubbleCocoa bubble(browser()); 30 PermissionBubbleCocoa bubble(browser());
24 bubble.SetDelegate(test_delegate()); 31 bubble.SetDelegate(test_delegate());
25 bubble.Show(requests(), accept_states()); 32 bubble.Show(requests(), accept_states());
33 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
26 34
27 NSWindow* window = browser()->window()->GetNativeWindow(); 35 FullscreenController* controller =
28 base::scoped_nsobject<FullscreenWindowManager> manager( 36 browser()->exclusive_access_manager()->fullscreen_controller();
29 [[FullscreenWindowManager alloc] initWithWindow:window 37 controller->ToggleBrowserFullscreenMode();
30 desiredScreen:[NSScreen mainScreen]]); 38 while (faker.IsInTransition())
tapted 2016/04/22 05:27:40 This looks like it would spin on the CPU - I don't
benwells 2016/04/28 07:32:43 Done.
31 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 39 content::RunAllPendingInMessageLoop();
32 [manager enterFullscreenMode]; 40
33 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 41 // The location bar should be visible if the toolbar is set to be visible in
34 [manager exitFullscreenMode]; 42 // fullscreen mode.
35 EXPECT_TRUE([bubble.bubbleController_ hasLocationBar]); 43 PrefService* prefs = browser()->profile()->GetPrefs();
44 bool show_toolbar = prefs->GetBoolean(prefs::kShowFullscreenToolbar);
45 EXPECT_EQ(show_toolbar, [bubble.bubbleController_ hasVisibleLocationBar]);
46
47 // Toggle the value of the preference.
48 chrome::ToggleFullscreenToolbar(browser());
49 EXPECT_EQ(!show_toolbar, [bubble.bubbleController_ hasVisibleLocationBar]);
50
51 // Put the setting back the way it started.
52 chrome::ToggleFullscreenToolbar(browser());
53 controller->ToggleBrowserFullscreenMode();
54 while (faker.IsInTransition())
55 content::RunAllPendingInMessageLoop();
56
57 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
36 bubble.Hide(); 58 bubble.Hide();
37 } 59 }
38 60
61 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
62 TabFullscreenHasLocationBar) {
63 ui::test::ScopedFakeNSWindowFullscreen faker;
64
65 PermissionBubbleCocoa bubble(browser());
66 bubble.SetDelegate(test_delegate());
67 bubble.Show(requests(), accept_states());
68 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
69
70 FullscreenController* controller =
71 browser()->exclusive_access_manager()->fullscreen_controller();
72 controller->EnterFullscreenModeForTab(
73 browser()->tab_strip_model()->GetActiveWebContents(), GURL());
74 while (faker.IsInTransition())
75 content::RunAllPendingInMessageLoop();
76
77 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
78 controller->ExitFullscreenModeForTab(
79 browser()->tab_strip_model()->GetActiveWebContents());
80 while (faker.IsInTransition())
81 content::RunAllPendingInMessageLoop();
82
83 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
84 bubble.Hide();
85 }
86
39 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, AppHasNoLocationBar) { 87 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, AppHasNoLocationBar) {
40 Browser* app_browser = OpenExtensionAppWindow(); 88 Browser* app_browser = OpenExtensionAppWindow();
41 PermissionBubbleCocoa bubble(app_browser); 89 PermissionBubbleCocoa bubble(app_browser);
42 bubble.SetDelegate(test_delegate()); 90 bubble.SetDelegate(test_delegate());
43 bubble.Show(requests(), accept_states()); 91 bubble.Show(requests(), accept_states());
44 EXPECT_FALSE([bubble.bubbleController_ hasLocationBar]); 92 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
45 bubble.Hide(); 93 bubble.Hide();
46 } 94 }
47 95
48 // http://crbug.com/470724 96 // http://crbug.com/470724
49 // Kiosk mode on Mac has a location bar but it shouldn't. 97 // Kiosk mode on Mac has a location bar but it shouldn't.
50 IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest, 98 IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
51 DISABLED_KioskHasNoLocationBar) { 99 DISABLED_KioskHasNoLocationBar) {
52 PermissionBubbleCocoa bubble(browser()); 100 PermissionBubbleCocoa bubble(browser());
53 bubble.SetDelegate(test_delegate()); 101 bubble.SetDelegate(test_delegate());
54 bubble.Show(requests(), accept_states()); 102 bubble.Show(requests(), accept_states());
55 EXPECT_FALSE([bubble.bubbleController_ hasLocationBar]); 103 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
56 bubble.Hide(); 104 bubble.Hide();
57 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698