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 <Cocoa/Cocoa.h> | 5 #include <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #import "chrome/browser/ui/cocoa/bubble_view.h" | 11 #import "chrome/browser/ui/cocoa/bubble_view.h" |
12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
13 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" | 13 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #import "testing/gtest_mac.h" | 15 #import "testing/gtest_mac.h" |
16 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
| 17 #import "third_party/ocmock/OCMock/OCMock.h" |
17 #include "ui/gfx/point.h" | 18 #include "ui/gfx/point.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 using base::UTF8ToUTF16; | 21 using base::UTF8ToUTF16; |
21 | 22 |
22 // The test delegate records all of the status bubble object's state | 23 // The test delegate records all of the status bubble object's state |
23 // transitions. | 24 // transitions. |
24 @interface StatusBubbleMacTestDelegate : NSObject { | 25 @interface StatusBubbleMacTestDelegate : NSObject { |
25 @private | 26 @private |
26 NSWindow* window_; // Weak. | 27 NSWindow* window_; // Weak. |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // The bubble should reattach in the correct location. | 573 // The bubble should reattach in the correct location. |
573 child = GetWindow(); | 574 child = GetWindow(); |
574 NSPoint expectedOrigin = [window frame].origin; | 575 NSPoint expectedOrigin = [window frame].origin; |
575 expectedOrigin.x += baseFrameOffset.x; | 576 expectedOrigin.x += baseFrameOffset.x; |
576 expectedOrigin.y += baseFrameOffset.y; | 577 expectedOrigin.y += baseFrameOffset.y; |
577 EXPECT_TRUE(NSEqualPoints(expectedOrigin, [child frame].origin)); | 578 EXPECT_TRUE(NSEqualPoints(expectedOrigin, [child frame].origin)); |
578 } | 579 } |
579 | 580 |
580 TEST_F(StatusBubbleMacTest, ExpandBubble) { | 581 TEST_F(StatusBubbleMacTest, ExpandBubble) { |
581 NSWindow* window = test_window(); | 582 NSWindow* window = test_window(); |
| 583 |
| 584 // The system font changes between OSX 10.9 and OSX 10.10. Use the system |
| 585 // font from OSX 10.9 for this test. |
| 586 id mockContentView = |
| 587 [OCMockObject partialMockForObject:[GetWindow() contentView]]; |
| 588 [[[mockContentView stub] |
| 589 andReturn:[NSFont fontWithName:@"Lucida Grande" size:11]] font]; |
| 590 |
582 ASSERT_TRUE(window); | 591 ASSERT_TRUE(window); |
583 NSRect window_frame = [window frame]; | 592 NSRect window_frame = [window frame]; |
584 window_frame.size.width = 600.0; | 593 window_frame.size.width = 600.0; |
585 [window setFrame:window_frame display:YES]; | 594 [window setFrame:window_frame display:YES]; |
586 | 595 |
587 // Check basic expansion | 596 // Check basic expansion |
588 bubble_->SetStatus(UTF8ToUTF16("Showing")); | 597 bubble_->SetStatus(UTF8ToUTF16("Showing")); |
589 EXPECT_TRUE(IsVisible()); | 598 EXPECT_TRUE(IsVisible()); |
590 bubble_->SetURL(GURL("http://www.battersbox.com/peter_paul_and_mary.html"), | 599 bubble_->SetURL(GURL("http://www.battersbox.com/peter_paul_and_mary.html"), |
591 std::string()); | 600 std::string()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 int windowWidth = NSWidth([window frame]); | 665 int windowWidth = NSWidth([window frame]); |
657 for (int x = 0; x < windowWidth; x += smallValue) { | 666 for (int x = 0; x < windowWidth; x += smallValue) { |
658 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); | 667 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); |
659 } | 668 } |
660 | 669 |
661 // Simulate moving the mouse from right to left. | 670 // Simulate moving the mouse from right to left. |
662 for (int x = windowWidth; x >= 0; x -= smallValue) { | 671 for (int x = windowWidth; x >= 0; x -= smallValue) { |
663 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); | 672 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); |
664 } | 673 } |
665 } | 674 } |
OLD | NEW |