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

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

Issue 2335623002: Use WebContents instead of Browser to construct PermissionPrompt (Closed)
Patch Set: Created 4 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
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_commands_mac.h" 6 #include "chrome/browser/ui/browser_commands_mac.h"
7 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" 7 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
8 #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" 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/tabs/tab_strip_model.h"
11 #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" 12 #include "chrome/common/pref_names.h"
13 #include "components/prefs/pref_service.h" 13 #include "components/prefs/pref_service.h"
14 #import "testing/gtest_mac.h" 14 #import "testing/gtest_mac.h"
15 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h" 15 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
16 16
17 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) { 17 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
18 PermissionBubbleCocoa bubble(browser()); 18 content::WebContents* web_contents =
19 browser()->tab_strip_model()->GetActiveWebContents();
20 PermissionBubbleCocoa bubble(web_contents);
19 bubble.SetDelegate(test_delegate()); 21 bubble.SetDelegate(test_delegate());
20 bubble.Show(requests(), accept_states()); 22 bubble.Show(requests(), accept_states());
21 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]); 23 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
22 bubble.Hide(); 24 bubble.Hide();
23 } 25 }
24 26
25 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, 27 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
26 BrowserFullscreenHasLocationBar) { 28 BrowserFullscreenHasLocationBar) {
27 ui::test::ScopedFakeNSWindowFullscreen faker; 29 ui::test::ScopedFakeNSWindowFullscreen faker;
28 30
29 PermissionBubbleCocoa bubble(browser()); 31 content::WebContents* web_contents =
32 browser()->tab_strip_model()->GetActiveWebContents();
33 PermissionBubbleCocoa bubble(web_contents);
30 bubble.SetDelegate(test_delegate()); 34 bubble.SetDelegate(test_delegate());
31 bubble.Show(requests(), accept_states()); 35 bubble.Show(requests(), accept_states());
32 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]); 36 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
33 37
34 FullscreenController* controller = 38 FullscreenController* controller =
35 browser()->exclusive_access_manager()->fullscreen_controller(); 39 browser()->exclusive_access_manager()->fullscreen_controller();
36 controller->ToggleBrowserFullscreenMode(); 40 controller->ToggleBrowserFullscreenMode();
37 faker.FinishTransition(); 41 faker.FinishTransition();
38 42
39 // The location bar should be visible if the toolbar is set to be visible in 43 // The location bar should be visible if the toolbar is set to be visible in
(...skipping 12 matching lines...) Expand all
52 faker.FinishTransition(); 56 faker.FinishTransition();
53 57
54 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]); 58 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
55 bubble.Hide(); 59 bubble.Hide();
56 } 60 }
57 61
58 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, 62 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
59 TabFullscreenHasLocationBar) { 63 TabFullscreenHasLocationBar) {
60 ui::test::ScopedFakeNSWindowFullscreen faker; 64 ui::test::ScopedFakeNSWindowFullscreen faker;
61 65
62 PermissionBubbleCocoa bubble(browser()); 66 content::WebContents* web_contents =
67 browser()->tab_strip_model()->GetActiveWebContents();
68 PermissionBubbleCocoa bubble(web_contents);
63 bubble.SetDelegate(test_delegate()); 69 bubble.SetDelegate(test_delegate());
64 bubble.Show(requests(), accept_states()); 70 bubble.Show(requests(), accept_states());
65 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]); 71 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
66 72
67 FullscreenController* controller = 73 FullscreenController* controller =
68 browser()->exclusive_access_manager()->fullscreen_controller(); 74 browser()->exclusive_access_manager()->fullscreen_controller();
69 controller->EnterFullscreenModeForTab( 75 controller->EnterFullscreenModeForTab(
70 browser()->tab_strip_model()->GetActiveWebContents(), GURL()); 76 browser()->tab_strip_model()->GetActiveWebContents(), GURL());
71 faker.FinishTransition(); 77 faker.FinishTransition();
72 78
73 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]); 79 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
74 controller->ExitFullscreenModeForTab( 80 controller->ExitFullscreenModeForTab(
75 browser()->tab_strip_model()->GetActiveWebContents()); 81 browser()->tab_strip_model()->GetActiveWebContents());
76 faker.FinishTransition(); 82 faker.FinishTransition();
77 83
78 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]); 84 EXPECT_TRUE([bubble.bubbleController_ hasVisibleLocationBar]);
79 bubble.Hide(); 85 bubble.Hide();
80 } 86 }
81 87
82 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, AppHasNoLocationBar) { 88 IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, AppHasNoLocationBar) {
83 Browser* app_browser = OpenExtensionAppWindow(); 89 Browser* app_browser = OpenExtensionAppWindow();
84 PermissionBubbleCocoa bubble(app_browser); 90 content::WebContents* web_contents =
91 app_browser->tab_strip_model()->GetActiveWebContents();
92 PermissionBubbleCocoa bubble(web_contents);
85 bubble.SetDelegate(test_delegate()); 93 bubble.SetDelegate(test_delegate());
86 bubble.Show(requests(), accept_states()); 94 bubble.Show(requests(), accept_states());
87 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]); 95 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
88 bubble.Hide(); 96 bubble.Hide();
89 } 97 }
90 98
91 // http://crbug.com/470724 99 // http://crbug.com/470724
92 // Kiosk mode on Mac has a location bar but it shouldn't. 100 // Kiosk mode on Mac has a location bar but it shouldn't.
93 IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest, 101 IN_PROC_BROWSER_TEST_F(PermissionBubbleKioskBrowserTest,
94 DISABLED_KioskHasNoLocationBar) { 102 DISABLED_KioskHasNoLocationBar) {
95 PermissionBubbleCocoa bubble(browser()); 103 content::WebContents* web_contents =
104 browser()->tab_strip_model()->GetActiveWebContents();
105 PermissionBubbleCocoa bubble(web_contents);
96 bubble.SetDelegate(test_delegate()); 106 bubble.SetDelegate(test_delegate());
97 bubble.Show(requests(), accept_states()); 107 bubble.Show(requests(), accept_states());
98 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]); 108 EXPECT_FALSE([bubble.bubbleController_ hasVisibleLocationBar]);
99 bubble.Hide(); 109 bubble.Hide();
100 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698