| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/sync/sync_ui_util.h" | 9 #include "chrome/browser/sync/sync_ui_util.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 BrowserWindowController* controller = | 125 BrowserWindowController* controller = |
| 126 static_cast<BrowserWindowController*>([cocoaWindow windowController]); | 126 static_cast<BrowserWindowController*>([cocoaWindow windowController]); |
| 127 ASSERT_TRUE([controller isKindOfClass:[BrowserWindowController class]]); | 127 ASSERT_TRUE([controller isKindOfClass:[BrowserWindowController class]]); |
| 128 EXPECT_FALSE([controller isTabbedWindow]); | 128 EXPECT_FALSE([controller isTabbedWindow]); |
| 129 EXPECT_FALSE([controller hasTabStrip]); | 129 EXPECT_FALSE([controller hasTabStrip]); |
| 130 EXPECT_TRUE([controller hasTitleBar]); | 130 EXPECT_TRUE([controller hasTitleBar]); |
| 131 EXPECT_FALSE([controller isBookmarkBarVisible]); | 131 EXPECT_FALSE([controller isBookmarkBarVisible]); |
| 132 [controller close]; | 132 [controller close]; |
| 133 } | 133 } |
| 134 | 134 |
| 135 TEST_F(BrowserWindowControllerTest, TestSetBounds) { |
| 136 // Create a normal browser with bounds smaller than the minimum. |
| 137 Browser::CreateParams params(Browser::TYPE_TABBED, browser_helper_.profile()); |
| 138 params.initial_bounds = gfx::Rect(0, 0, 50, 50); |
| 139 Browser* browser = Browser::CreateWithParams(params); |
| 140 NSWindow *cocoaWindow = browser->window()->GetNativeHandle(); |
| 141 BrowserWindowController* controller = |
| 142 static_cast<BrowserWindowController*>([cocoaWindow windowController]); |
| 143 |
| 144 ASSERT_TRUE([controller isTabbedWindow]); |
| 145 BrowserWindow* browser_window = [controller browserWindow]; |
| 146 EXPECT_EQ(browser_window, browser->window()); |
| 147 gfx::Rect bounds = browser_window->GetBounds(); |
| 148 EXPECT_EQ(400, bounds.width()); |
| 149 EXPECT_EQ(272, bounds.height()); |
| 150 |
| 151 // Try to set the bounds smaller than the minimum. |
| 152 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| 153 bounds = browser_window->GetBounds(); |
| 154 EXPECT_EQ(400, bounds.width()); |
| 155 EXPECT_EQ(272, bounds.height()); |
| 156 |
| 157 [controller close]; |
| 158 } |
| 159 |
| 160 TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) { |
| 161 // Create a popup with bounds smaller than the minimum. |
| 162 Browser::CreateParams params(Browser::TYPE_POPUP, browser_helper_.profile()); |
| 163 params.initial_bounds = gfx::Rect(0, 0, 50, 50); |
| 164 Browser* browser = Browser::CreateWithParams(params); |
| 165 NSWindow *cocoaWindow = browser->window()->GetNativeHandle(); |
| 166 BrowserWindowController* controller = |
| 167 static_cast<BrowserWindowController*>([cocoaWindow windowController]); |
| 168 |
| 169 ASSERT_FALSE([controller isTabbedWindow]); |
| 170 BrowserWindow* browser_window = [controller browserWindow]; |
| 171 EXPECT_EQ(browser_window, browser->window()); |
| 172 gfx::Rect bounds = browser_window->GetBounds(); |
| 173 EXPECT_EQ(100, bounds.width()); |
| 174 EXPECT_EQ(122, bounds.height()); |
| 175 |
| 176 // Try to set the bounds smaller than the minimum. |
| 177 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| 178 bounds = browser_window->GetBounds(); |
| 179 EXPECT_EQ(100, bounds.width()); |
| 180 EXPECT_EQ(122, bounds.height()); |
| 181 |
| 182 [controller close]; |
| 183 } |
| 184 |
| 135 TEST_F(BrowserWindowControllerTest, TestTheme) { | 185 TEST_F(BrowserWindowControllerTest, TestTheme) { |
| 136 [controller_ userChangedTheme]; | 186 [controller_ userChangedTheme]; |
| 137 } | 187 } |
| 138 | 188 |
| 139 TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) { | 189 TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) { |
| 140 EXPECT_FALSE([controller_ isBookmarkBarVisible]); | 190 EXPECT_FALSE([controller_ isBookmarkBarVisible]); |
| 141 | 191 |
| 142 // Explicitly show the bar. Can't use bookmark_utils::ToggleWhenVisible() | 192 // Explicitly show the bar. Can't use bookmark_utils::ToggleWhenVisible() |
| 143 // because of the notification issues. | 193 // because of the notification issues. |
| 144 browser_helper_.profile()->GetPrefs()-> | 194 browser_helper_.profile()->GetPrefs()-> |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 fullscreenWindow_.reset( | 719 fullscreenWindow_.reset( |
| 670 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) | 720 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) |
| 671 styleMask:NSBorderlessWindowMask | 721 styleMask:NSBorderlessWindowMask |
| 672 backing:NSBackingStoreBuffered | 722 backing:NSBackingStoreBuffered |
| 673 defer:NO]); | 723 defer:NO]); |
| 674 return fullscreenWindow_.get(); | 724 return fullscreenWindow_.get(); |
| 675 } | 725 } |
| 676 @end | 726 @end |
| 677 | 727 |
| 678 /* TODO(???): test other methods of BrowserWindowController */ | 728 /* TODO(???): test other methods of BrowserWindowController */ |
| OLD | NEW |