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 #import "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 5 #import "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel()); | 244 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel()); |
245 PanelTitlebarViewCocoa* titlebar = [native_window->controller_ titlebarView]; | 245 PanelTitlebarViewCocoa* titlebar = [native_window->controller_ titlebarView]; |
246 | 246 |
247 NSView* contentView = [[native_window->controller_ window] contentView]; | 247 NSView* contentView = [[native_window->controller_ window] contentView]; |
248 VerifyTitlebarLocation(contentView, titlebar); | 248 VerifyTitlebarLocation(contentView, titlebar); |
249 | 249 |
250 // In local coordinate system, width of titlebar should match width of | 250 // In local coordinate system, width of titlebar should match width of |
251 // content view of the window. They both use the same scale factor. | 251 // content view of the window. They both use the same scale factor. |
252 EXPECT_EQ(NSWidth([contentView bounds]), NSWidth([titlebar bounds])); | 252 EXPECT_EQ(NSWidth([contentView bounds]), NSWidth([titlebar bounds])); |
253 | 253 |
| 254 NSRect oldTitleFrame = [[titlebar title] frame]; |
| 255 NSRect oldIconFrame = [[titlebar icon] frame]; |
| 256 |
254 // Now resize the Panel, see that titlebar follows. | 257 // Now resize the Panel, see that titlebar follows. |
255 const int kDelta = 153; // random number | 258 const int kDelta = 153; // random number |
256 gfx::Rect bounds = panel->GetBounds(); | 259 gfx::Rect bounds = panel->GetBounds(); |
257 // Grow panel in a way so that its titlebar moves and grows. | 260 // Grow panel in a way so that its titlebar moves and grows. |
258 bounds.set_x(bounds.x() - kDelta); | 261 bounds.set_x(bounds.x() - kDelta); |
259 bounds.set_y(bounds.y() - kDelta); | 262 bounds.set_y(bounds.y() - kDelta); |
260 bounds.set_width(bounds.width() + kDelta); | 263 bounds.set_width(bounds.width() + kDelta); |
261 bounds.set_height(bounds.height() + kDelta); | 264 bounds.set_height(bounds.height() + kDelta); |
262 | 265 |
263 PanelAnimatedBoundsObserver bounds_observer(panel); | 266 PanelAnimatedBoundsObserver bounds_observer(panel); |
264 native_window->SetPanelBounds(bounds); | 267 native_window->SetPanelBounds(bounds); |
265 bounds_observer.Wait(); | 268 bounds_observer.Wait(); |
266 | 269 |
267 // Verify the panel resized. | 270 // Verify the panel resized. |
268 NSRect window_frame = [[native_window->controller_ window] frame]; | 271 NSRect window_frame = [[native_window->controller_ window] frame]; |
269 EXPECT_EQ(NSWidth(window_frame), bounds.width()); | 272 EXPECT_EQ(NSWidth(window_frame), bounds.width()); |
270 EXPECT_EQ(NSHeight(window_frame), bounds.height()); | 273 EXPECT_EQ(NSHeight(window_frame), bounds.height()); |
271 | 274 |
272 // Verify the titlebar is still on top of regular titlebar. | 275 // Verify the titlebar is still on top of regular titlebar. |
273 VerifyTitlebarLocation(contentView, titlebar); | 276 VerifyTitlebarLocation(contentView, titlebar); |
274 | 277 |
| 278 // Verify that the title/icon frames were updated. |
| 279 NSRect newTitleFrame = [[titlebar title] frame]; |
| 280 NSRect newIconFrame = [[titlebar icon] frame]; |
| 281 |
| 282 EXPECT_EQ(newTitleFrame.origin.x - newIconFrame.origin.x, |
| 283 oldTitleFrame.origin.x - oldIconFrame.origin.x); |
| 284 EXPECT_NE(newTitleFrame.origin.x, oldTitleFrame.origin.x); |
| 285 EXPECT_NE(newIconFrame.origin.x, oldIconFrame.origin.x); |
| 286 |
275 ClosePanelAndWait(panel->browser()); | 287 ClosePanelAndWait(panel->browser()); |
276 } | 288 } |
277 | 289 |
278 // Verify closing behavior of titlebar close button. | 290 // Verify closing behavior of titlebar close button. |
279 TEST_F(PanelBrowserWindowCocoaTest, TitlebarViewClose) { | 291 TEST_F(PanelBrowserWindowCocoaTest, TitlebarViewClose) { |
280 Panel* panel = CreateTestPanel("Test Panel"); | 292 Panel* panel = CreateTestPanel("Test Panel"); |
281 | 293 |
282 PanelBrowserWindowCocoa* native_window = | 294 PanelBrowserWindowCocoa* native_window = |
283 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel()); | 295 static_cast<PanelBrowserWindowCocoa*>(panel->native_panel()); |
284 | 296 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; | 408 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; |
397 EXPECT_NSEQ(frontmostWindow, [native_window->controller_ window]); | 409 EXPECT_NSEQ(frontmostWindow, [native_window->controller_ window]); |
398 | 410 |
399 native_window2->ActivatePanel(); | 411 native_window2->ActivatePanel(); |
400 frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; | 412 frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; |
401 EXPECT_NSEQ(frontmostWindow, [native_window2->controller_ window]); | 413 EXPECT_NSEQ(frontmostWindow, [native_window2->controller_ window]); |
402 | 414 |
403 ClosePanelAndWait(panel->browser()); | 415 ClosePanelAndWait(panel->browser()); |
404 ClosePanelAndWait(panel2->browser()); | 416 ClosePanelAndWait(panel2->browser()); |
405 } | 417 } |
OLD | NEW |