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" |
18 #include "chromeos/network/portal_detector/network_portal_detector.h" | 19 #include "chromeos/network/portal_detector/network_portal_detector.h" |
19 #include "components/image_fetcher/core/image_fetcher.h" | 20 #include "components/image_fetcher/core/image_fetcher.h" |
20 #include "components/image_fetcher/core/image_fetcher_delegate.h" | 21 #include "components/image_fetcher/core/image_fetcher_delegate.h" |
21 #include "components/image_fetcher/core/request_metadata.h" | 22 #include "components/image_fetcher/core/request_metadata.h" |
22 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
23 #include "content/public/test/test_browser_thread_bundle.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "ui/gfx/image/image_unittest_util.h" | 28 #include "ui/gfx/image/image_unittest_util.h" |
28 #include "ui/message_center/fake_message_center_tray_delegate.h" | 29 #include "ui/message_center/fake_message_center_tray_delegate.h" |
29 #include "ui/message_center/message_center.h" | 30 #include "ui/message_center/message_center.h" |
30 | 31 |
31 using testing::_; | 32 using testing::_; |
32 using testing::AtLeast; | 33 using testing::AtLeast; |
33 using testing::Invoke; | 34 using testing::Invoke; |
34 using testing::Return; | 35 using testing::Return; |
35 using testing::SaveArg; | 36 using testing::SaveArg; |
36 using testing::StrictMock; | 37 using testing::StrictMock; |
37 | 38 |
38 using image_fetcher::ImageFetcher; | 39 using image_fetcher::ImageFetcher; |
39 using image_fetcher::ImageFetcherDelegate; | 40 using image_fetcher::ImageFetcherDelegate; |
40 | 41 |
41 namespace chromeos { | 42 namespace chromeos { |
42 | 43 |
43 namespace { | 44 namespace { |
44 | 45 |
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 | |
70 class MockImageFetcher : public image_fetcher::ImageFetcher { | 46 class MockImageFetcher : public image_fetcher::ImageFetcher { |
71 public: | 47 public: |
72 MockImageFetcher() {} | 48 MockImageFetcher() {} |
73 ~MockImageFetcher() override {} | 49 ~MockImageFetcher() override {} |
74 | 50 |
75 MOCK_METHOD3(StartOrQueueNetworkRequest, | 51 MOCK_METHOD3(StartOrQueueNetworkRequest, |
76 void(const std::string&, | 52 void(const std::string&, |
77 const GURL&, | 53 const GURL&, |
78 const ImageFetcher::ImageFetcherCallback&)); | 54 const ImageFetcher::ImageFetcherCallback&)); |
79 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); | 55 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > | 272 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > |
297 base::Time::FromInternalValue(now_timestamp)); | 273 base::Time::FromInternalValue(now_timestamp)); |
298 | 274 |
299 // Destructor for HatsController removes self from observer list. | 275 // Destructor for HatsController removes self from observer list. |
300 EXPECT_CALL(mock_network_portal_detector_, | 276 EXPECT_CALL(mock_network_portal_detector_, |
301 RemoveObserver(hats_notification_controller.get())) | 277 RemoveObserver(hats_notification_controller.get())) |
302 .Times(1); | 278 .Times(1); |
303 } | 279 } |
304 | 280 |
305 } // namespace chromeos | 281 } // namespace chromeos |
OLD | NEW |