| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 EXPECT_TRUE(IsVisible()); | 134 EXPECT_TRUE(IsVisible()); |
| 135 EXPECT_TRUE([GetURLText() isEqualToString:@"http:"]); | 135 EXPECT_TRUE([GetURLText() isEqualToString:@"http:"]); |
| 136 bubble_->SetURL(GURL("about:blank"), L""); | 136 bubble_->SetURL(GURL("about:blank"), L""); |
| 137 EXPECT_TRUE(IsVisible()); | 137 EXPECT_TRUE(IsVisible()); |
| 138 EXPECT_TRUE([GetURLText() isEqualToString:@"about:blank"]); | 138 EXPECT_TRUE([GetURLText() isEqualToString:@"about:blank"]); |
| 139 bubble_->SetURL(GURL("foopy://"), L""); | 139 bubble_->SetURL(GURL("foopy://"), L""); |
| 140 EXPECT_TRUE(IsVisible()); | 140 EXPECT_TRUE(IsVisible()); |
| 141 EXPECT_TRUE([GetURLText() isEqualToString:@"foopy://"]); | 141 EXPECT_TRUE([GetURLText() isEqualToString:@"foopy://"]); |
| 142 bubble_->SetURL(GURL("http://www.cnn.com"), L""); | 142 bubble_->SetURL(GURL("http://www.cnn.com"), L""); |
| 143 EXPECT_TRUE(IsVisible()); | 143 EXPECT_TRUE(IsVisible()); |
| 144 EXPECT_TRUE([GetURLText() isEqualToString:@"http://www.cnn.com/"]); | 144 EXPECT_TRUE([GetURLText() isEqualToString:@"www.cnn.com/"]); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Test hiding bubble that's already hidden. | 147 // Test hiding bubble that's already hidden. |
| 148 TEST_F(StatusBubbleMacTest, Hides) { | 148 TEST_F(StatusBubbleMacTest, Hides) { |
| 149 bubble_->SetStatus(L"Showing"); | 149 bubble_->SetStatus(L"Showing"); |
| 150 EXPECT_TRUE(IsVisible()); | 150 EXPECT_TRUE(IsVisible()); |
| 151 bubble_->Hide(); | 151 bubble_->Hide(); |
| 152 EXPECT_FALSE(IsVisible()); | 152 EXPECT_FALSE(IsVisible()); |
| 153 bubble_->Hide(); | 153 bubble_->Hide(); |
| 154 EXPECT_FALSE(IsVisible()); | 154 EXPECT_FALSE(IsVisible()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Test the "main"/"backup" behavior in StatusBubbleMac::SetText(). | 157 // Test the "main"/"backup" behavior in StatusBubbleMac::SetText(). |
| 158 TEST_F(StatusBubbleMacTest, SetStatusAndURL) { | 158 TEST_F(StatusBubbleMacTest, SetStatusAndURL) { |
| 159 EXPECT_FALSE(IsVisible()); | 159 EXPECT_FALSE(IsVisible()); |
| 160 bubble_->SetStatus(L"Status"); | 160 bubble_->SetStatus(L"Status"); |
| 161 EXPECT_TRUE(IsVisible()); | 161 EXPECT_TRUE(IsVisible()); |
| 162 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]); | 162 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]); |
| 163 bubble_->SetURL(GURL("http://www.nytimes.com/"), L""); | 163 bubble_->SetURL(GURL("http://www.nytimes.com/"), L""); |
| 164 EXPECT_TRUE(IsVisible()); | 164 EXPECT_TRUE(IsVisible()); |
| 165 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"http://www.nytimes.com/"]); | 165 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"www.nytimes.com/"]); |
| 166 bubble_->SetURL(GURL(), L""); | 166 bubble_->SetURL(GURL(), L""); |
| 167 EXPECT_TRUE(IsVisible()); | 167 EXPECT_TRUE(IsVisible()); |
| 168 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]); | 168 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]); |
| 169 bubble_->SetStatus(L""); | 169 bubble_->SetStatus(L""); |
| 170 EXPECT_FALSE(IsVisible()); | 170 EXPECT_FALSE(IsVisible()); |
| 171 bubble_->SetURL(GURL("http://www.nytimes.com/"), L""); | 171 bubble_->SetURL(GURL("http://www.nytimes.com/"), L""); |
| 172 EXPECT_TRUE(IsVisible()); | 172 EXPECT_TRUE(IsVisible()); |
| 173 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"http://www.nytimes.com/"]); | 173 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"www.nytimes.com/"]); |
| 174 bubble_->SetStatus(L"Status"); | 174 bubble_->SetStatus(L"Status"); |
| 175 EXPECT_TRUE(IsVisible()); | 175 EXPECT_TRUE(IsVisible()); |
| 176 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]); | 176 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]); |
| 177 bubble_->SetStatus(L""); | 177 bubble_->SetStatus(L""); |
| 178 EXPECT_TRUE(IsVisible()); | 178 EXPECT_TRUE(IsVisible()); |
| 179 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"http://www.nytimes.com/"]); | 179 EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"www.nytimes.com/"]); |
| 180 bubble_->SetURL(GURL(), L""); | 180 bubble_->SetURL(GURL(), L""); |
| 181 EXPECT_FALSE(IsVisible()); | 181 EXPECT_FALSE(IsVisible()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Test that the status bubble goes through the correct delay and fade states. | 184 // Test that the status bubble goes through the correct delay and fade states. |
| 185 // The delay and fade duration are simulated and not actually experienced | 185 // The delay and fade duration are simulated and not actually experienced |
| 186 // during the test because StatusBubbleMacTest sets immediate_ mode. | 186 // during the test because StatusBubbleMacTest sets immediate_ mode. |
| 187 TEST_F(StatusBubbleMacTest, StateTransitions) { | 187 TEST_F(StatusBubbleMacTest, StateTransitions) { |
| 188 // First, some sanity | 188 // First, some sanity |
| 189 | 189 |
| (...skipping 261 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 } |
| OLD | NEW |