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 "chrome/browser/notifications/desktop_notifications_unittest.h" | 5 #include "chrome/browser/notifications/desktop_notifications_unittest.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // balloon collection. | 28 // balloon collection. |
29 Notification test_notification( | 29 Notification test_notification( |
30 notification.origin_url(), | 30 notification.origin_url(), |
31 notification.content_url(), | 31 notification.content_url(), |
32 notification.display_source(), | 32 notification.display_source(), |
33 notification.replace_id(), | 33 notification.replace_id(), |
34 new LoggingNotificationProxy(notification.notification_id())); | 34 new LoggingNotificationProxy(notification.notification_id())); |
35 BalloonCollectionImpl::Add(test_notification, profile); | 35 BalloonCollectionImpl::Add(test_notification, profile); |
36 } | 36 } |
37 | 37 |
| 38 bool MockBalloonCollection::HasSpace() const { |
| 39 return count() < kMockBalloonSpace; |
| 40 } |
| 41 |
38 Balloon* MockBalloonCollection::MakeBalloon(const Notification& notification, | 42 Balloon* MockBalloonCollection::MakeBalloon(const Notification& notification, |
39 Profile* profile) { | 43 Profile* profile) { |
40 // Start with a normal balloon but mock out the view. | 44 // Start with a normal balloon but mock out the view. |
41 Balloon* balloon = BalloonCollectionImpl::MakeBalloon(notification, profile); | 45 Balloon* balloon = BalloonCollectionImpl::MakeBalloon(notification, profile); |
42 balloon->set_view(new MockBalloonView(balloon)); | 46 balloon->set_view(new MockBalloonView(balloon)); |
43 balloons_.push_back(balloon); | 47 balloons_.push_back(balloon); |
44 return balloon; | 48 return balloon; |
45 } | 49 } |
46 | 50 |
47 void MockBalloonCollection::OnBalloonClosed(Balloon* source) { | 51 void MockBalloonCollection::OnBalloonClosed(Balloon* source) { |
48 std::deque<Balloon*>::iterator it; | 52 std::deque<Balloon*>::iterator it; |
49 for (it = balloons_.begin(); it != balloons_.end(); ++it) { | 53 for (it = balloons_.begin(); it != balloons_.end(); ++it) { |
50 if (*it == source) { | 54 if (*it == source) { |
51 balloons_.erase(it); | 55 balloons_.erase(it); |
52 BalloonCollectionImpl::OnBalloonClosed(source); | 56 BalloonCollectionImpl::OnBalloonClosed(source); |
53 break; | 57 break; |
54 } | 58 } |
55 } | 59 } |
56 } | 60 } |
57 | 61 |
| 62 const BalloonCollection::Balloons& MockBalloonCollection::GetActiveBalloons() { |
| 63 return balloons_; |
| 64 } |
| 65 |
58 int MockBalloonCollection::UppermostVerticalPosition() { | 66 int MockBalloonCollection::UppermostVerticalPosition() { |
59 int min = 0; | 67 int min = 0; |
60 std::deque<Balloon*>::iterator iter; | 68 std::deque<Balloon*>::iterator iter; |
61 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { | 69 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { |
62 int pos = (*iter)->GetPosition().y(); | 70 int pos = (*iter)->GetPosition().y(); |
63 if (iter == balloons_.begin() || pos < min) | 71 if (iter == balloons_.begin() || pos < min) |
64 min = pos; | 72 min = pos; |
65 } | 73 } |
66 return min; | 74 return min; |
67 } | 75 } |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 436 } |
429 | 437 |
430 // Now change the position to upper left. Confirm that the X value for the | 438 // Now change the position to upper left. Confirm that the X value for the |
431 // balloons gets smaller. | 439 // balloons gets smaller. |
432 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, | 440 profile_->GetPrefs()->SetInteger(prefs::kDesktopNotificationPosition, |
433 BalloonCollection::UPPER_LEFT); | 441 BalloonCollection::UPPER_LEFT); |
434 | 442 |
435 int current_x = (*balloons.begin())->GetPosition().x(); | 443 int current_x = (*balloons.begin())->GetPosition().x(); |
436 EXPECT_LT(current_x, last_x); | 444 EXPECT_LT(current_x, last_x); |
437 } | 445 } |
OLD | NEW |