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/memory/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.h" | 9 #include "base/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 "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #import "testing/gtest_mac.h" | 16 #import "testing/gtest_mac.h" |
17 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 // Test helper for moving the fake mouse location, and checking that | 169 // Test helper for moving the fake mouse location, and checking that |
170 // the bubble avoids that location. | 170 // the bubble avoids that location. |
171 // For convenience & clarity, coordinates are relative to the main window. | 171 // For convenience & clarity, coordinates are relative to the main window. |
172 bool CheckAvoidsMouse(int relative_x, int relative_y) { | 172 bool CheckAvoidsMouse(int relative_x, int relative_y) { |
173 SetMouseLocation(relative_x, relative_y); | 173 SetMouseLocation(relative_x, relative_y); |
174 return !IsPointInBubble(relative_x, relative_y); | 174 return !IsPointInBubble(relative_x, relative_y); |
175 } | 175 } |
176 | 176 |
177 base::MessageLoop message_loop_; | 177 base::MessageLoop message_loop_; |
178 scoped_nsobject<StatusBubbleMacTestDelegate> delegate_; | 178 base::scoped_nsobject<StatusBubbleMacTestDelegate> delegate_; |
179 StatusBubbleMac* bubble_; // Strong. | 179 StatusBubbleMac* bubble_; // Strong. |
180 }; | 180 }; |
181 | 181 |
182 TEST_F(StatusBubbleMacTest, SetStatus) { | 182 TEST_F(StatusBubbleMacTest, SetStatus) { |
183 bubble_->SetStatus(string16()); | 183 bubble_->SetStatus(string16()); |
184 bubble_->SetStatus(UTF8ToUTF16("This is a test")); | 184 bubble_->SetStatus(UTF8ToUTF16("This is a test")); |
185 EXPECT_NSEQ(@"This is a test", GetText()); | 185 EXPECT_NSEQ(@"This is a test", GetText()); |
186 EXPECT_TRUE(IsVisible()); | 186 EXPECT_TRUE(IsVisible()); |
187 | 187 |
188 // Set the status to the exact same thing again | 188 // Set the status to the exact same thing again |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 int windowWidth = NSWidth([window frame]); | 654 int windowWidth = NSWidth([window frame]); |
655 for (int x = 0; x < windowWidth; x += smallValue) { | 655 for (int x = 0; x < windowWidth; x += smallValue) { |
656 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); | 656 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); |
657 } | 657 } |
658 | 658 |
659 // Simulate moving the mouse from right to left. | 659 // Simulate moving the mouse from right to left. |
660 for (int x = windowWidth; x >= 0; x -= smallValue) { | 660 for (int x = windowWidth; x >= 0; x -= smallValue) { |
661 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); | 661 ASSERT_TRUE(CheckAvoidsMouse(x, smallValue)); |
662 } | 662 } |
663 } | 663 } |
OLD | NEW |