OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/download/notification/download_notification_item.h" | 5 #include "chrome/browser/download/notification/download_notification_item.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/test/base/testing_browser_process.h" | |
11 #include "chrome/test/base/testing_profile.h" | |
12 #include "chrome/test/base/testing_profile_manager.h" | |
10 #include "content/public/test/mock_download_item.h" | 13 #include "content/public/test/mock_download_item.h" |
11 #include "content/public/test/mock_download_manager.h" | 14 #include "content/public/test/mock_download_manager.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/message_center/fake_message_center.h" | 17 #include "ui/message_center/fake_message_center.h" |
15 | 18 |
16 using testing::NiceMock; | 19 using testing::NiceMock; |
17 using testing::Return; | 20 using testing::Return; |
18 using testing::_; | 21 using testing::_; |
19 | 22 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 message_center()->GetPopupNotifications(); | 117 message_center()->GetPopupNotifications(); |
115 for (auto it = popups.begin(); it != popups.end(); it++) { | 118 for (auto it = popups.begin(); it != popups.end(); it++) { |
116 if ((*it)->id() == notification_id) { | 119 if ((*it)->id() == notification_id) { |
117 return true; | 120 return true; |
118 } | 121 } |
119 } | 122 } |
120 return false; | 123 return false; |
121 } | 124 } |
122 | 125 |
123 void CreateDownloadNotificationItem() { | 126 void CreateDownloadNotificationItem() { |
124 download_notification_item_.reset( | 127 TestingProfileManager profile_manager(TestingBrowserProcess::GetGlobal()); |
125 new DownloadNotificationItem(download_item_.get(), &delegate_)); | 128 ASSERT_TRUE(profile_manager.SetUp()); |
asanka
2015/03/24 18:36:15
Move the TestingProfileManager construction and Se
yoshiki
2015/03/25 05:30:25
Done. I moved the construction of Profile as well.
| |
129 Profile* profile = profile_manager.CreateTestingProfile("test-user"); | |
asanka
2015/03/24 18:36:15
Can't we at least test whether two notifications c
yoshiki
2015/03/25 05:30:25
That's good idea. But I think the multi-user test
asanka
2015/03/25 21:04:48
It would be great if such a test was part of this
| |
130 | |
131 download_notification_item_.reset(new DownloadNotificationItem( | |
132 download_item_.get(), profile, &delegate_)); | |
126 } | 133 } |
127 | 134 |
128 scoped_refptr<base::TestSimpleTaskRunner> runner_; | 135 scoped_refptr<base::TestSimpleTaskRunner> runner_; |
129 base::ThreadTaskRunnerHandle runner_handler_; | 136 base::ThreadTaskRunnerHandle runner_handler_; |
130 | 137 |
131 MockDownloadNotificationItemDelegate delegate_; | 138 MockDownloadNotificationItemDelegate delegate_; |
132 scoped_ptr<NiceMock<content::MockDownloadItem>> download_item_; | 139 scoped_ptr<NiceMock<content::MockDownloadItem>> download_item_; |
133 scoped_ptr<DownloadNotificationItem> download_notification_item_; | 140 scoped_ptr<DownloadNotificationItem> download_notification_item_; |
134 }; | 141 }; |
135 | 142 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 | 267 |
261 // Checks OnDownloadRemoved(). | 268 // Checks OnDownloadRemoved(). |
262 EXPECT_EQ(0u, delegate_.GetOnDownloadRemovedCallCount()); | 269 EXPECT_EQ(0u, delegate_.GetOnDownloadRemovedCallCount()); |
263 download_item_->NotifyObserversDownloadRemoved(); | 270 download_item_->NotifyObserversDownloadRemoved(); |
264 EXPECT_EQ(1u, delegate_.GetOnDownloadRemovedCallCount()); | 271 EXPECT_EQ(1u, delegate_.GetOnDownloadRemovedCallCount()); |
265 | 272 |
266 download_item_.reset(); | 273 download_item_.reset(); |
267 } | 274 } |
268 | 275 |
269 } // namespace test | 276 } // namespace test |
OLD | NEW |