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 "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/browser/prefs/browser_prefs.h" | 9 #include "chrome/browser/prefs/browser_prefs.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
11 #include "chrome/test/base/testing_pref_service.h" | 11 #include "chrome/test/base/testing_pref_service.h" |
12 #include "content/public/common/show_desktop_notification_params.h" | 12 #include "content/public/common/show_desktop_notification_params.h" |
13 | 13 |
| 14 #if defined(USE_AURA) |
| 15 #include "ui/aura/desktop.h" |
| 16 #endif |
| 17 |
14 using content::BrowserThread; | 18 using content::BrowserThread; |
15 | 19 |
16 // static | 20 // static |
17 const int MockBalloonCollection::kMockBalloonSpace = 5; | 21 const int MockBalloonCollection::kMockBalloonSpace = 5; |
18 | 22 |
19 // static | 23 // static |
20 std::string DesktopNotificationsTest::log_output_; | 24 std::string DesktopNotificationsTest::log_output_; |
21 | 25 |
22 MockBalloonCollection::MockBalloonCollection() {} | 26 MockBalloonCollection::MockBalloonCollection() {} |
23 | 27 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 81 } |
78 | 82 |
79 DesktopNotificationsTest::DesktopNotificationsTest() | 83 DesktopNotificationsTest::DesktopNotificationsTest() |
80 : ui_thread_(BrowserThread::UI, &message_loop_) { | 84 : ui_thread_(BrowserThread::UI, &message_loop_) { |
81 } | 85 } |
82 | 86 |
83 DesktopNotificationsTest::~DesktopNotificationsTest() { | 87 DesktopNotificationsTest::~DesktopNotificationsTest() { |
84 } | 88 } |
85 | 89 |
86 void DesktopNotificationsTest::SetUp() { | 90 void DesktopNotificationsTest::SetUp() { |
| 91 #if defined(USE_AURA) |
| 92 // MockBalloonCollection retrieves information about the screen on creation. |
| 93 // So it is necessary to make sure the desktop gets created first. |
| 94 aura::Desktop::GetInstance(); |
| 95 #endif |
| 96 |
87 browser::RegisterLocalState(&local_state_); | 97 browser::RegisterLocalState(&local_state_); |
88 profile_.reset(new TestingProfile()); | 98 profile_.reset(new TestingProfile()); |
89 balloon_collection_ = new MockBalloonCollection(); | 99 balloon_collection_ = new MockBalloonCollection(); |
90 ui_manager_.reset(NotificationUIManager::Create(&local_state_, | 100 ui_manager_.reset(NotificationUIManager::Create(&local_state_, |
91 balloon_collection_)); | 101 balloon_collection_)); |
92 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 102 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
93 log_output_.clear(); | 103 log_output_.clear(); |
94 } | 104 } |
95 | 105 |
96 void DesktopNotificationsTest::TearDown() { | 106 void DesktopNotificationsTest::TearDown() { |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 456 } |
447 | 457 |
448 // Now change the position to upper left. Confirm that the X value for the | 458 // Now change the position to upper left. Confirm that the X value for the |
449 // balloons gets smaller. | 459 // balloons gets smaller. |
450 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 460 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
451 BalloonCollection::UPPER_LEFT); | 461 BalloonCollection::UPPER_LEFT); |
452 | 462 |
453 int current_x = (*balloons.begin())->GetPosition().x(); | 463 int current_x = (*balloons.begin())->GetPosition().x(); |
454 EXPECT_LT(current_x, last_x); | 464 EXPECT_LT(current_x, last_x); |
455 } | 465 } |
OLD | NEW |