| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/hats/hats_notification_controller.h" | 5 #include "chrome/browser/chromeos/hats/hats_notification_controller.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" |
| 7 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 8 #include "chrome/browser/notifications/message_center_notification_manager.h" | 9 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 9 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
| 10 #include "chrome/browser/notifications/notification_ui_manager.h" | 11 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 12 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
| 13 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 15 #include "chrome/test/base/testing_profile_manager.h" | 16 #include "chrome/test/base/testing_profile_manager.h" |
| 16 #include "chromeos/network/network_state.h" | 17 #include "chromeos/network/network_state.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 manager->SetMessageCenterTrayDelegateForTest( | 107 manager->SetMessageCenterTrayDelegateForTest( |
| 107 new message_center::FakeMessageCenterTrayDelegate( | 108 new message_center::FakeMessageCenterTrayDelegate( |
| 108 message_center::MessageCenter::Get())); | 109 message_center::MessageCenter::Get())); |
| 109 | 110 |
| 110 network_portal_detector::InitializeForTesting( | 111 network_portal_detector::InitializeForTesting( |
| 111 &mock_network_portal_detector_); | 112 &mock_network_portal_detector_); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void TearDown() override { | 115 void TearDown() override { |
| 115 g_browser_process->notification_ui_manager()->StartShutdown(); | 116 g_browser_process->notification_ui_manager()->StartShutdown(); |
| 117 // The notifications may be deleted async. |
| 118 base::RunLoop loop; |
| 119 loop.RunUntilIdle(); |
| 116 profile_manager_.reset(); | 120 profile_manager_.reset(); |
| 117 network_portal_detector::InitializeForTesting(nullptr); | 121 network_portal_detector::InitializeForTesting(nullptr); |
| 118 BrowserWithTestWindowTest::TearDown(); | 122 BrowserWithTestWindowTest::TearDown(); |
| 119 } | 123 } |
| 120 | 124 |
| 121 scoped_refptr<HatsNotificationController> InstantiateHatsController() { | 125 scoped_refptr<HatsNotificationController> InstantiateHatsController() { |
| 122 MockImageFetcher* mock_image_fetcher_ = new MockImageFetcher; | 126 MockImageFetcher* mock_image_fetcher_ = new MockImageFetcher; |
| 123 // The initialization will fail since the function IsNewDevice() will return | 127 // The initialization will fail since the function IsNewDevice() will return |
| 124 // true. | 128 // true. |
| 125 scoped_refptr<HatsNotificationController> hats_notification_controller = | 129 scoped_refptr<HatsNotificationController> hats_notification_controller = |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > | 284 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > |
| 281 base::Time::FromInternalValue(now_timestamp)); | 285 base::Time::FromInternalValue(now_timestamp)); |
| 282 | 286 |
| 283 // Destructor for HatsController removes self from observer list. | 287 // Destructor for HatsController removes self from observer list. |
| 284 EXPECT_CALL(mock_network_portal_detector_, | 288 EXPECT_CALL(mock_network_portal_detector_, |
| 285 RemoveObserver(hats_notification_controller.get())) | 289 RemoveObserver(hats_notification_controller.get())) |
| 286 .Times(1); | 290 .Times(1); |
| 287 } | 291 } |
| 288 | 292 |
| 289 } // namespace chromeos | 293 } // namespace chromeos |
| OLD | NEW |