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) | 14 #if defined(USE_AURA) |
| 15 #if defined(USE_WEBKIT_COMPOSITOR) |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 17 #endif |
15 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
16 #endif | 19 #endif |
17 | 20 |
18 using content::BrowserThread; | 21 using content::BrowserThread; |
19 | 22 |
20 // static | 23 // static |
21 const int MockBalloonCollection::kMockBalloonSpace = 5; | 24 const int MockBalloonCollection::kMockBalloonSpace = 5; |
22 | 25 |
23 // static | 26 // static |
24 std::string DesktopNotificationsTest::log_output_; | 27 std::string DesktopNotificationsTest::log_output_; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 85 |
83 DesktopNotificationsTest::DesktopNotificationsTest() | 86 DesktopNotificationsTest::DesktopNotificationsTest() |
84 : ui_thread_(BrowserThread::UI, &message_loop_) { | 87 : ui_thread_(BrowserThread::UI, &message_loop_) { |
85 } | 88 } |
86 | 89 |
87 DesktopNotificationsTest::~DesktopNotificationsTest() { | 90 DesktopNotificationsTest::~DesktopNotificationsTest() { |
88 } | 91 } |
89 | 92 |
90 void DesktopNotificationsTest::SetUp() { | 93 void DesktopNotificationsTest::SetUp() { |
91 #if defined(USE_AURA) | 94 #if defined(USE_AURA) |
| 95 #if defined(USE_WEBKIT_COMPOSITOR) |
| 96 WebKit::initialize(&webkit_platform_support_); |
| 97 #endif |
92 // MockBalloonCollection retrieves information about the screen on creation. | 98 // MockBalloonCollection retrieves information about the screen on creation. |
93 // So it is necessary to make sure the desktop gets created first. | 99 // So it is necessary to make sure the desktop gets created first. |
94 aura::RootWindow::GetInstance(); | 100 aura::RootWindow::GetInstance(); |
95 #endif | 101 #endif |
96 | 102 |
97 browser::RegisterLocalState(&local_state_); | 103 browser::RegisterLocalState(&local_state_); |
98 profile_.reset(new TestingProfile()); | 104 profile_.reset(new TestingProfile()); |
99 balloon_collection_ = new MockBalloonCollection(); | 105 balloon_collection_ = new MockBalloonCollection(); |
100 ui_manager_.reset(NotificationUIManager::Create(&local_state_, | 106 ui_manager_.reset(NotificationUIManager::Create(&local_state_, |
101 balloon_collection_)); | 107 balloon_collection_)); |
102 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 108 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
103 log_output_.clear(); | 109 log_output_.clear(); |
104 } | 110 } |
105 | 111 |
106 void DesktopNotificationsTest::TearDown() { | 112 void DesktopNotificationsTest::TearDown() { |
107 service_.reset(NULL); | 113 service_.reset(NULL); |
108 ui_manager_.reset(NULL); | 114 ui_manager_.reset(NULL); |
109 profile_.reset(NULL); | 115 profile_.reset(NULL); |
| 116 #if defined(USE_AURA) |
| 117 aura::RootWindow::DeleteInstance(); |
| 118 #if defined(USE_WEBKIT_COMPOSITOR) |
| 119 WebKit::shutdown(); |
| 120 #endif |
| 121 #endif |
110 } | 122 } |
111 | 123 |
112 content::ShowDesktopNotificationHostMsgParams | 124 content::ShowDesktopNotificationHostMsgParams |
113 DesktopNotificationsTest::StandardTestNotification() { | 125 DesktopNotificationsTest::StandardTestNotification() { |
114 content::ShowDesktopNotificationHostMsgParams params; | 126 content::ShowDesktopNotificationHostMsgParams params; |
115 params.notification_id = 0; | 127 params.notification_id = 0; |
116 params.origin = GURL("http://www.google.com"); | 128 params.origin = GURL("http://www.google.com"); |
117 params.is_html = false; | 129 params.is_html = false; |
118 params.icon_url = GURL("/icon.png"); | 130 params.icon_url = GURL("/icon.png"); |
119 params.title = ASCIIToUTF16("Title"); | 131 params.title = ASCIIToUTF16("Title"); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 468 } |
457 | 469 |
458 // Now change the position to upper left. Confirm that the X value for the | 470 // Now change the position to upper left. Confirm that the X value for the |
459 // balloons gets smaller. | 471 // balloons gets smaller. |
460 local_state_.SetInteger(prefs::kDesktopNotificationPosition, | 472 local_state_.SetInteger(prefs::kDesktopNotificationPosition, |
461 BalloonCollection::UPPER_LEFT); | 473 BalloonCollection::UPPER_LEFT); |
462 | 474 |
463 int current_x = (*balloons.begin())->GetPosition().x(); | 475 int current_x = (*balloons.begin())->GetPosition().x(); |
464 EXPECT_LT(current_x, last_x); | 476 EXPECT_LT(current_x, last_x); |
465 } | 477 } |
OLD | NEW |