OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/notifications/desktop_notifications_unittest.h
" | 5 #include "chrome/browser/chromeos/notifications/desktop_notifications_unittest.h
" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.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/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // DesktopNotificationsTest | 105 // DesktopNotificationsTest |
106 | 106 |
107 DesktopNotificationsTest::DesktopNotificationsTest() | 107 DesktopNotificationsTest::DesktopNotificationsTest() |
108 : ui_thread_(BrowserThread::UI, &message_loop_) { | 108 : ui_thread_(BrowserThread::UI, &message_loop_) { |
109 } | 109 } |
110 | 110 |
111 DesktopNotificationsTest::~DesktopNotificationsTest() { | 111 DesktopNotificationsTest::~DesktopNotificationsTest() { |
112 } | 112 } |
113 | 113 |
114 void DesktopNotificationsTest::SetUp() { | 114 void DesktopNotificationsTest::SetUp() { |
115 #if defined(USE_AURA) | 115 #if defined(USE_ASH) |
116 // Make sure a root window has been instantiated. | 116 // Make sure a root window has been instantiated. |
117 ash::Shell::GetRootWindow(); | 117 ash::Shell::CreateInstance(NULL); |
118 #endif | 118 #endif |
119 browser::RegisterLocalState(&local_state_); | 119 browser::RegisterLocalState(&local_state_); |
120 profile_.reset(new TestingProfile()); | 120 profile_.reset(new TestingProfile()); |
121 balloon_collection_ = new MockBalloonCollection(); | 121 balloon_collection_ = new MockBalloonCollection(); |
122 ui_manager_.reset(NotificationUIManager::Create(&local_state_, | 122 ui_manager_.reset(NotificationUIManager::Create(&local_state_, |
123 balloon_collection_)); | 123 balloon_collection_)); |
124 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); | 124 service_.reset(new DesktopNotificationService(profile(), ui_manager_.get())); |
125 log_output_.clear(); | 125 log_output_.clear(); |
126 } | 126 } |
127 | 127 |
128 void DesktopNotificationsTest::TearDown() { | 128 void DesktopNotificationsTest::TearDown() { |
129 service_.reset(NULL); | 129 service_.reset(NULL); |
130 ui_manager_.reset(NULL); | 130 ui_manager_.reset(NULL); |
131 profile_.reset(NULL); | 131 profile_.reset(NULL); |
| 132 #if defined(USE_ASH) |
| 133 ash::Shell::DeleteInstance(); |
| 134 #endif |
132 } | 135 } |
133 | 136 |
134 content::ShowDesktopNotificationHostMsgParams | 137 content::ShowDesktopNotificationHostMsgParams |
135 DesktopNotificationsTest::StandardTestNotification() { | 138 DesktopNotificationsTest::StandardTestNotification() { |
136 content::ShowDesktopNotificationHostMsgParams params; | 139 content::ShowDesktopNotificationHostMsgParams params; |
137 params.notification_id = 0; | 140 params.notification_id = 0; |
138 params.origin = GURL("http://www.google.com"); | 141 params.origin = GURL("http://www.google.com"); |
139 params.is_html = false; | 142 params.is_html = false; |
140 params.icon_url = GURL("/icon.png"); | 143 params.icon_url = GURL("/icon.png"); |
141 params.title = ASCIIToUTF16("Title"); | 144 params.title = ASCIIToUTF16("Title"); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 314 |
312 MessageLoopForUI::current()->RunAllPending(); | 315 MessageLoopForUI::current()->RunAllPending(); |
313 EXPECT_EQ(1, balloon_collection_->count()); | 316 EXPECT_EQ(1, balloon_collection_->count()); |
314 Balloon* balloon = (*balloon_collection_->balloons().begin()); | 317 Balloon* balloon = (*balloon_collection_->balloons().begin()); |
315 GURL data_url = balloon->notification().content_url(); | 318 GURL data_url = balloon->notification().content_url(); |
316 EXPECT_EQ(std::string::npos, data_url.spec().find("<script>")); | 319 EXPECT_EQ(std::string::npos, data_url.spec().find("<script>")); |
317 EXPECT_EQ(std::string::npos, data_url.spec().find("<i>")); | 320 EXPECT_EQ(std::string::npos, data_url.spec().find("<i>")); |
318 } | 321 } |
319 | 322 |
320 } // namespace chromeos | 323 } // namespace chromeos |
OLD | NEW |