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

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

Issue 11111022: Remove TabContents from constrained windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unrelated gtk code Created 8 years, 2 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 | Annotate | Revision Log
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/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_window.h" 8 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 9 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
(...skipping 14 matching lines...) Expand all
25 sheet_.reset([[NSWindow alloc] 25 sheet_.reset([[NSWindow alloc]
26 initWithContentRect:NSMakeRect(0, 0, 30, 30) 26 initWithContentRect:NSMakeRect(0, 0, 30, 30)
27 styleMask:NSTitledWindowMask 27 styleMask:NSTitledWindowMask
28 backing:NSBackingStoreBuffered 28 backing:NSBackingStoreBuffered
29 defer:NO]); 29 defer:NO]);
30 [sheet_ setReleasedWhenClosed:NO]; 30 [sheet_ setReleasedWhenClosed:NO];
31 } 31 }
32 32
33 virtual void SetUpOnMainThread() OVERRIDE { 33 virtual void SetUpOnMainThread() OVERRIDE {
34 AddTabAtIndex(1, GURL("about:blank"), content::PAGE_TRANSITION_LINK); 34 AddTabAtIndex(1, GURL("about:blank"), content::PAGE_TRANSITION_LINK);
35 tab0_ = browser()->tab_strip_model()->GetTabContentsAt(0); 35 tab0_ = browser()->tab_strip_model()->GetWebContentsAt(0);
36 tab1_ = browser()->tab_strip_model()->GetTabContentsAt(1); 36 tab1_ = browser()->tab_strip_model()->GetWebContentsAt(1);
37 EXPECT_EQ(tab1_, browser()->tab_strip_model()->GetActiveTabContents()); 37 EXPECT_EQ(tab1_, browser()->tab_strip_model()->GetActiveWebContents());
38 38
39 controller_ = [BrowserWindowController browserWindowControllerForWindow: 39 controller_ = [BrowserWindowController browserWindowControllerForWindow:
40 browser()->window()->GetNativeWindow()]; 40 browser()->window()->GetNativeWindow()];
41 EXPECT_TRUE(controller_); 41 EXPECT_TRUE(controller_);
42 tab_view0_ = [[controller_ tabStripController] viewAtIndex:0]; 42 tab_view0_ = [[controller_ tabStripController] viewAtIndex:0];
43 EXPECT_TRUE(tab_view0_); 43 EXPECT_TRUE(tab_view0_);
44 tab_view1_ = [[controller_ tabStripController] viewAtIndex:1]; 44 tab_view1_ = [[controller_ tabStripController] viewAtIndex:1];
45 EXPECT_TRUE(tab_view1_); 45 EXPECT_TRUE(tab_view1_);
46 } 46 }
47 47
48 protected: 48 protected:
49 scoped_nsobject<NSWindow> sheet_; 49 scoped_nsobject<NSWindow> sheet_;
50 TabContents* tab0_; 50 content::WebContents* tab0_;
51 TabContents* tab1_; 51 content::WebContents* tab1_;
52 BrowserWindowController* controller_; 52 BrowserWindowController* controller_;
53 NSView* tab_view0_; 53 NSView* tab_view0_;
54 NSView* tab_view1_; 54 NSView* tab_view1_;
55 }; 55 };
56 56
57 // Test that a sheet added to a inactive tab is not shown until the 57 // Test that a sheet added to a inactive tab is not shown until the
58 // tab is activated. 58 // tab is activated.
59 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) { 59 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) {
60 // Show dialog in non active tab. 60 // Show dialog in non active tab.
61 // Dialog will delete it self when closed. 61 // Dialog will delete itself when closed.
62 ConstrainedWindowMac2* dialog = new ConstrainedWindowMac2(tab0_, sheet_); 62 ConstrainedWindowMac2* dialog = new ConstrainedWindowMac2(tab0_, sheet_);
63 EXPECT_EQ(0.0, [sheet_ alphaValue]); 63 EXPECT_EQ(0.0, [sheet_ alphaValue]);
64 64
65 // Switch to inactive tab. 65 // Switch to inactive tab.
66 browser()->tab_strip_model()->ActivateTabAt(0, true); 66 browser()->tab_strip_model()->ActivateTabAt(0, true);
67 EXPECT_EQ(1.0, [sheet_ alphaValue]); 67 EXPECT_EQ(1.0, [sheet_ alphaValue]);
68 68
69 dialog->CloseConstrainedWindow(); 69 dialog->CloseConstrainedWindow();
70 } 70 }
71 71
72 // Test that adding a sheet disables tab dragging. 72 // Test that adding a sheet disables tab dragging.
73 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) { 73 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) {
74 // Dialog will delete it self when closed. 74 // Dialog will delete itself when closed.
75 ConstrainedWindowMac2* dialog = new ConstrainedWindowMac2(tab1_, sheet_); 75 ConstrainedWindowMac2* dialog = new ConstrainedWindowMac2(tab1_, sheet_);
76 76
77 // Verify that the dialog disables dragging. 77 // Verify that the dialog disables dragging.
78 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]); 78 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]);
79 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]); 79 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]);
80 80
81 dialog->CloseConstrainedWindow(); 81 dialog->CloseConstrainedWindow();
82 } 82 }
83 83
84 // Test that closing a browser window with a sheet works. 84 // Test that closing a browser window with a sheet works.
85 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowClose) { 85 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowClose) {
86 // Dialog will delete it self when closed. 86 // Dialog will delete itself when closed.
87 new ConstrainedWindowMac2(tab1_, sheet_); 87 new ConstrainedWindowMac2(tab1_, sheet_);
88 EXPECT_EQ(1.0, [sheet_ alphaValue]); 88 EXPECT_EQ(1.0, [sheet_ alphaValue]);
89 89
90 // Close the browser window. 90 // Close the browser window.
91 scoped_nsobject<NSWindow> browser_window( 91 scoped_nsobject<NSWindow> browser_window(
92 [browser()->window()->GetNativeWindow() retain]); 92 [browser()->window()->GetNativeWindow() retain]);
93 EXPECT_TRUE([browser_window isVisible]); 93 EXPECT_TRUE([browser_window isVisible]);
94 [browser()->window()->GetNativeWindow() performClose:nil]; 94 [browser()->window()->GetNativeWindow() performClose:nil];
95 EXPECT_FALSE([browser_window isVisible]); 95 EXPECT_FALSE([browser_window isVisible]);
96 } 96 }
97 97
98 // Test that closing a tab with a sheet works. 98 // Test that closing a tab with a sheet works.
99 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabClose) { 99 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabClose) {
100 // Dialog will delete it self when closed. 100 // Dialog will delete itself when closed.
101 new ConstrainedWindowMac2(tab1_, sheet_); 101 new ConstrainedWindowMac2(tab1_, sheet_);
102 EXPECT_EQ(1.0, [sheet_ alphaValue]); 102 EXPECT_EQ(1.0, [sheet_ alphaValue]);
103 103
104 // Close the tab. 104 // Close the tab.
105 EXPECT_EQ(2, browser()->tab_count()); 105 EXPECT_EQ(2, browser()->tab_count());
106 EXPECT_TRUE(browser()->tab_strip_model()->CloseTabContentsAt( 106 EXPECT_TRUE(browser()->tab_strip_model()->CloseTabContentsAt(
107 1, TabStripModel::CLOSE_USER_GESTURE)); 107 1, TabStripModel::CLOSE_USER_GESTURE));
108 EXPECT_EQ(1, browser()->tab_count()); 108 EXPECT_EQ(1, browser()->tab_count());
109 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698