| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <Cocoa/Cocoa.h> | 5 #include <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #import "chrome/browser/cocoa/bubble_view.h" | 9 #import "chrome/browser/cocoa/bubble_view.h" |
| 10 #import "chrome/browser/cocoa/browser_test_helper.h" | 10 #import "chrome/browser/cocoa/browser_test_helper.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 frame.size.width += 50.0; // (fairly arbitrary nonzero value) | 451 frame.size.width += 50.0; // (fairly arbitrary nonzero value) |
| 452 frame.size.height += 50.0; // (fairly arbitrary nonzero value) | 452 frame.size.height += 50.0; // (fairly arbitrary nonzero value) |
| 453 [window setFrame:frame display:YES]; | 453 [window setFrame:frame display:YES]; |
| 454 bubble_->UpdateSizeAndPosition(); | 454 bubble_->UpdateSizeAndPosition(); |
| 455 rect_after = [GetWindow() frame]; | 455 rect_after = [GetWindow() frame]; |
| 456 EXPECT_EQ(rect_before.origin.x, rect_after.origin.x); | 456 EXPECT_EQ(rect_before.origin.x, rect_after.origin.x); |
| 457 EXPECT_EQ(rect_before.origin.y, rect_after.origin.y); | 457 EXPECT_EQ(rect_before.origin.y, rect_after.origin.y); |
| 458 EXPECT_NE(rect_before.size.width, rect_after.size.width); | 458 EXPECT_NE(rect_before.size.width, rect_after.size.width); |
| 459 EXPECT_EQ(rect_before.size.height, rect_after.size.height); | 459 EXPECT_EQ(rect_before.size.height, rect_after.size.height); |
| 460 } | 460 } |
| 461 |
| 462 TEST_F(StatusBubbleMacTest, MovingWindowUpdatesPosition) { |
| 463 NSWindow* window = test_window(); |
| 464 |
| 465 // Show the bubble and make sure it has the same origin as |window|. |
| 466 bubble_->SetStatus(L"Showing"); |
| 467 NSWindow* child = GetWindow(); |
| 468 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); |
| 469 |
| 470 // Hide the bubble, move the window, and show it again. |
| 471 bubble_->Hide(); |
| 472 NSRect frame = [window frame]; |
| 473 frame.origin.x += 50; |
| 474 [window setFrame:frame display:YES]; |
| 475 bubble_->SetStatus(L"Reshowing"); |
| 476 |
| 477 // The bubble should reattach in the correct location. |
| 478 child = GetWindow(); |
| 479 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); |
| 480 } |
| OLD | NEW |