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/run_loop.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "chrome/browser/notifications/message_center_notification_manager.h" | 9 #include "chrome/browser/notifications/message_center_notification_manager.h" |
10 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
11 #include "chrome/browser/notifications/notification_ui_manager.h" | 11 #include "chrome/browser/notifications/notification_ui_manager.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
14 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "chrome/test/base/testing_profile_manager.h" | 16 #include "chrome/test/base/testing_profile_manager.h" |
17 #include "chromeos/network/network_state.h" | 17 #include "chromeos/network/network_state.h" |
18 #include "chromeos/network/portal_detector/mock_network_portal_detector.h" | |
19 #include "chromeos/network/portal_detector/network_portal_detector.h" | 18 #include "chromeos/network/portal_detector/network_portal_detector.h" |
20 #include "components/image_fetcher/core/image_fetcher.h" | 19 #include "components/image_fetcher/core/image_fetcher.h" |
21 #include "components/image_fetcher/core/image_fetcher_delegate.h" | 20 #include "components/image_fetcher/core/image_fetcher_delegate.h" |
22 #include "components/image_fetcher/core/request_metadata.h" | 21 #include "components/image_fetcher/core/request_metadata.h" |
23 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
24 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
25 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/gfx/image/image_unittest_util.h" | 27 #include "ui/gfx/image/image_unittest_util.h" |
29 #include "ui/message_center/fake_message_center_tray_delegate.h" | 28 #include "ui/message_center/fake_message_center_tray_delegate.h" |
30 #include "ui/message_center/message_center.h" | 29 #include "ui/message_center/message_center.h" |
31 | 30 |
32 using testing::_; | 31 using testing::_; |
33 using testing::AtLeast; | 32 using testing::AtLeast; |
34 using testing::Invoke; | 33 using testing::Invoke; |
35 using testing::Return; | 34 using testing::Return; |
36 using testing::SaveArg; | 35 using testing::SaveArg; |
37 using testing::StrictMock; | 36 using testing::StrictMock; |
38 | 37 |
39 using image_fetcher::ImageFetcher; | 38 using image_fetcher::ImageFetcher; |
40 using image_fetcher::ImageFetcherDelegate; | 39 using image_fetcher::ImageFetcherDelegate; |
41 | 40 |
42 namespace chromeos { | 41 namespace chromeos { |
43 | 42 |
44 namespace { | 43 namespace { |
45 | 44 |
| 45 class MockNetworkPortalDetector : public NetworkPortalDetector { |
| 46 public: |
| 47 MockNetworkPortalDetector() {} |
| 48 ~MockNetworkPortalDetector() override {} |
| 49 |
| 50 MOCK_METHOD1(AddObserver, |
| 51 void(chromeos::NetworkPortalDetector::Observer* observer)); |
| 52 MOCK_METHOD1(RemoveObserver, |
| 53 void(chromeos::NetworkPortalDetector::Observer* observer)); |
| 54 MOCK_METHOD1(AddAndFireObserver, |
| 55 void(chromeos::NetworkPortalDetector::Observer* observer)); |
| 56 MOCK_METHOD1(GetCaptivePortalState, |
| 57 chromeos::NetworkPortalDetector::CaptivePortalState( |
| 58 const std::string& service_path)); |
| 59 MOCK_METHOD0(IsEnabled, bool()); |
| 60 MOCK_METHOD1(Enable, void(bool start_detection)); |
| 61 MOCK_METHOD0(StartDetectionIfIdle, bool()); |
| 62 MOCK_METHOD1(SetStrategy, |
| 63 void(chromeos::PortalDetectorStrategy::StrategyId id)); |
| 64 MOCK_METHOD0(OnLockScreenRequest, void()); |
| 65 |
| 66 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(MockNetworkPortalDetector); |
| 68 }; |
| 69 |
46 class MockImageFetcher : public image_fetcher::ImageFetcher { | 70 class MockImageFetcher : public image_fetcher::ImageFetcher { |
47 public: | 71 public: |
48 MockImageFetcher() {} | 72 MockImageFetcher() {} |
49 ~MockImageFetcher() override {} | 73 ~MockImageFetcher() override {} |
50 | 74 |
51 MOCK_METHOD3(StartOrQueueNetworkRequest, | 75 MOCK_METHOD3(StartOrQueueNetworkRequest, |
52 void(const std::string&, | 76 void(const std::string&, |
53 const GURL&, | 77 const GURL&, |
54 const ImageFetcher::ImageFetcherCallback&)); | 78 const ImageFetcher::ImageFetcherCallback&)); |
55 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); | 79 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > | 296 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > |
273 base::Time::FromInternalValue(now_timestamp)); | 297 base::Time::FromInternalValue(now_timestamp)); |
274 | 298 |
275 // Destructor for HatsController removes self from observer list. | 299 // Destructor for HatsController removes self from observer list. |
276 EXPECT_CALL(mock_network_portal_detector_, | 300 EXPECT_CALL(mock_network_portal_detector_, |
277 RemoveObserver(hats_notification_controller.get())) | 301 RemoveObserver(hats_notification_controller.get())) |
278 .Times(1); | 302 .Times(1); |
279 } | 303 } |
280 | 304 |
281 } // namespace chromeos | 305 } // namespace chromeos |
OLD | NEW |