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

Side by Side Diff: chrome/browser/ui/cocoa/status_bubble_mac_unittest.mm

Issue 164333006: Fix the Mac status bubble. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: hit it with a larger hammer Created 6 years, 10 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
OLDNEW
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"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 NSString* GetText() { 128 NSString* GetText() {
129 return bubble_->status_text_; 129 return bubble_->status_text_;
130 } 130 }
131 NSString* GetURLText() { 131 NSString* GetURLText() {
132 return bubble_->url_text_; 132 return bubble_->url_text_;
133 } 133 }
134 NSString* GetBubbleViewText() { 134 NSString* GetBubbleViewText() {
135 BubbleView* bubbleView = [bubble_->window_ contentView]; 135 BubbleView* bubbleView = [bubble_->window_ contentView];
136 return [bubbleView content]; 136 return [bubbleView content];
137 } 137 }
138 NSWindow* GetWindow() { 138 StatusBubbleWindow* GetWindow() {
139 return bubble_->window_; 139 return bubble_->window_;
140 } 140 }
141 NSWindow* parent() { 141 NSWindow* parent() {
142 return bubble_->parent_; 142 return bubble_->parent_;
143 } 143 }
144 StatusBubbleMac::StatusBubbleState GetState() { 144 StatusBubbleMac::StatusBubbleState GetState() {
145 return bubble_->state_; 145 return bubble_->state_;
146 } 146 }
147 void SetState(StatusBubbleMac::StatusBubbleState state) { 147 void SetState(StatusBubbleMac::StatusBubbleState state) {
148 bubble_->SetState(state); 148 bubble_->SetState(state);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 EXPECT_EQ(rect_before.origin.y, rect_after.origin.y); 530 EXPECT_EQ(rect_before.origin.y, rect_after.origin.y);
531 EXPECT_NE(rect_before.size.width, rect_after.size.width); 531 EXPECT_NE(rect_before.size.width, rect_after.size.width);
532 EXPECT_EQ(rect_before.size.height, rect_after.size.height); 532 EXPECT_EQ(rect_before.size.height, rect_after.size.height);
533 } 533 }
534 534
535 TEST_F(StatusBubbleMacTest, MovingWindowUpdatesPosition) { 535 TEST_F(StatusBubbleMacTest, MovingWindowUpdatesPosition) {
536 NSWindow* window = test_window(); 536 NSWindow* window = test_window();
537 537
538 // Show the bubble and make sure it has the same origin as |window|. 538 // Show the bubble and make sure it has the same origin as |window|.
539 bubble_->SetStatus(UTF8ToUTF16("Showing")); 539 bubble_->SetStatus(UTF8ToUTF16("Showing"));
540 NSWindow* child = GetWindow(); 540 StatusBubbleWindow* child = GetWindow();
541 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); 541 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin));
542 542
543 // Hide the bubble, move the window, and show it again. 543 // Hide the bubble, move the window, and show it again.
544 bubble_->Hide(); 544 bubble_->Hide();
545 NSRect frame = [window frame]; 545 NSRect frame = [window frame];
546 frame.origin.x += 50; 546 frame.origin.x += 50;
547 [window setFrame:frame display:YES]; 547 [window setFrame:frame display:YES];
548 bubble_->SetStatus(UTF8ToUTF16("Reshowing")); 548 bubble_->SetStatus(UTF8ToUTF16("Reshowing"));
549 549
550 // The bubble should reattach in the correct location. 550 // The bubble should reattach in the correct location.
551 child = GetWindow(); 551 child = GetWindow();
552 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); 552 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin));
553 } 553 }
554 554
555 TEST_F(StatusBubbleMacTest, StatuBubbleRespectsBaseFrameLimits) { 555 TEST_F(StatusBubbleMacTest, StatuBubbleRespectsBaseFrameLimits) {
556 NSWindow* window = test_window(); 556 NSWindow* window = test_window();
557 557
558 // Show the bubble and make sure it has the same origin as |window|. 558 // Show the bubble and make sure it has the same origin as |window|.
559 bubble_->SetStatus(UTF8ToUTF16("Showing")); 559 bubble_->SetStatus(UTF8ToUTF16("Showing"));
560 NSWindow* child = GetWindow(); 560 StatusBubbleWindow* child = GetWindow();
561 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); 561 EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin));
562 562
563 // Hide the bubble, change base frame offset, and show it again. 563 // Hide the bubble, change base frame offset, and show it again.
564 bubble_->Hide(); 564 bubble_->Hide();
565 565
566 NSPoint baseFrameOffset = NSMakePoint(0, [window frame].size.height / 3); 566 NSPoint baseFrameOffset = NSMakePoint(0, [window frame].size.height / 3);
567 EXPECT_GT(baseFrameOffset.y, 0); 567 EXPECT_GT(baseFrameOffset.y, 0);
568 [delegate_ forceBaseFrameOffset:baseFrameOffset]; 568 [delegate_ forceBaseFrameOffset:baseFrameOffset];
569 569
570 bubble_->SetStatus(UTF8ToUTF16("Reshowing")); 570 bubble_->SetStatus(UTF8ToUTF16("Reshowing"));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 int windowWidth = NSWidth([window frame]); 656 int windowWidth = NSWidth([window frame]);
657 for (int x = 0; x < windowWidth; x += smallValue) { 657 for (int x = 0; x < windowWidth; x += smallValue) {
658 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); 658 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue));
659 } 659 }
660 660
661 // Simulate moving the mouse from right to left. 661 // Simulate moving the mouse from right to left.
662 for (int x = windowWidth; x >= 0; x -= smallValue) { 662 for (int x = windowWidth; x >= 0; x -= smallValue) {
663 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); 663 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue));
664 } 664 }
665 } 665 }
OLDNEW
« chrome/browser/ui/cocoa/status_bubble_mac.mm ('K') | « chrome/browser/ui/cocoa/status_bubble_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698