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

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm

Issue 11419277: Fix showing constrained window for uninitialized tabs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « chrome/browser/ui/cocoa/constrained_window/constrained_window_mac2.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cocoa/constrained_window/constrained_window_mac2.h" 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac2.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/browser_tabstrip.h"
10 #include "chrome/browser/ui/browser_window.h" 12 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 13 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
15 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
16 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 #include "ipc/ipc_message.h"
17 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
18 21
19 using ::testing::NiceMock; 22 using ::testing::NiceMock;
20 23
21 namespace { 24 namespace {
22 25
23 class ConstrainedWindowDelegateMock : public ConstrainedWindowMacDelegate2 { 26 class ConstrainedWindowDelegateMock : public ConstrainedWindowMacDelegate2 {
24 public: 27 public:
25 MOCK_METHOD1(OnConstrainedWindowClosed, void(ConstrainedWindowMac2*)); 28 MOCK_METHOD1(OnConstrainedWindowClosed, void(ConstrainedWindowMac2*));
26 }; 29 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ConstrainedWindowMac2 dialog(&delegate, tab0_, sheet_); 79 ConstrainedWindowMac2 dialog(&delegate, tab0_, sheet_);
77 EXPECT_EQ(0.0, [sheet_ alphaValue]); 80 EXPECT_EQ(0.0, [sheet_ alphaValue]);
78 81
79 // Switch to inactive tab. 82 // Switch to inactive tab.
80 browser()->tab_strip_model()->ActivateTabAt(0, true); 83 browser()->tab_strip_model()->ActivateTabAt(0, true);
81 EXPECT_EQ(1.0, [sheet_ alphaValue]); 84 EXPECT_EQ(1.0, [sheet_ alphaValue]);
82 85
83 dialog.CloseConstrainedWindow(); 86 dialog.CloseConstrainedWindow();
84 } 87 }
85 88
89 // If a tab has never been shown then the associated tab view for the web
90 // content will not be created. Verify that adding a constrained window to such
91 // a tab works correctly.
92 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) {
93 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create(
94 browser()->profile(), NULL, MSG_ROUTING_NONE, NULL));
95 bool was_blocked = false;
96 chrome::AddWebContents(browser(), NULL, web_contents.release(),
97 NEW_BACKGROUND_TAB, gfx::Rect(), false, &was_blocked);
98 content::WebContents* tab2 =
99 browser()->tab_strip_model()->GetWebContentsAt(2);
100 ASSERT_TRUE(tab2);
101 EXPECT_FALSE([tab2->GetNativeView() superview]);
102
103 // Show dialog and verify that it's not visible yet.
104 NiceMock<ConstrainedWindowDelegateMock> delegate;
105 ConstrainedWindowMac2 dialog(&delegate, tab2, sheet_);
106 EXPECT_FALSE([sheet_ isVisible]);
107
108 // Activate the tab and verify that the constrained window is shown.
109 browser()->tab_strip_model()->ActivateTabAt(2, true);
110 EXPECT_TRUE([tab2->GetNativeView() superview]);
111 EXPECT_TRUE([sheet_ isVisible]);
112 EXPECT_EQ(1.0, [sheet_ alphaValue]);
113
114 dialog.CloseConstrainedWindow();
115 }
116
86 // Test that adding a sheet disables tab dragging. 117 // Test that adding a sheet disables tab dragging.
87 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) { 118 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) {
88 NiceMock<ConstrainedWindowDelegateMock> delegate; 119 NiceMock<ConstrainedWindowDelegateMock> delegate;
89 ConstrainedWindowMac2 dialog(&delegate, tab1_, sheet_); 120 ConstrainedWindowMac2 dialog(&delegate, tab1_, sheet_);
90 121
91 // Verify that the dialog disables dragging. 122 // Verify that the dialog disables dragging.
92 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]); 123 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]);
93 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]); 124 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]);
94 125
95 dialog.CloseConstrainedWindow(); 126 dialog.CloseConstrainedWindow();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 158 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
128 159
129 // Dialog will delete it self when closed. 160 // Dialog will delete it self when closed.
130 NiceMock<ConstrainedWindowDelegateMock> delegate; 161 NiceMock<ConstrainedWindowDelegateMock> delegate;
131 ConstrainedWindowMac2 dialog(&delegate, tab1_, sheet_); 162 ConstrainedWindowMac2 dialog(&delegate, tab1_, sheet_);
132 163
133 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 164 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
134 165
135 dialog.CloseConstrainedWindow(); 166 dialog.CloseConstrainedWindow();
136 } 167 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/constrained_window/constrained_window_mac2.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698