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 "net/traffic_annotation/network_traffic_annotation_test_helper.h" | 26 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/gfx/image/image_unittest_util.h" | 29 #include "ui/gfx/image/image_unittest_util.h" |
29 #include "ui/message_center/fake_message_center_tray_delegate.h" | 30 #include "ui/message_center/fake_message_center_tray_delegate.h" |
30 #include "ui/message_center/message_center.h" | 31 #include "ui/message_center/message_center.h" |
31 | 32 |
32 using testing::_; | 33 using testing::_; |
33 using testing::AtLeast; | 34 using testing::AtLeast; |
34 using testing::Invoke; | 35 using testing::Invoke; |
35 using testing::Return; | 36 using testing::Return; |
36 using testing::SaveArg; | 37 using testing::SaveArg; |
37 using testing::StrictMock; | 38 using testing::StrictMock; |
38 | 39 |
39 using image_fetcher::ImageFetcher; | 40 using image_fetcher::ImageFetcher; |
40 using image_fetcher::ImageFetcherDelegate; | 41 using image_fetcher::ImageFetcherDelegate; |
41 | 42 |
42 namespace chromeos { | 43 namespace chromeos { |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 class MockNetworkPortalDetector : public NetworkPortalDetector { | |
47 public: | |
48 MockNetworkPortalDetector() {} | |
49 ~MockNetworkPortalDetector() override {} | |
50 | |
51 MOCK_METHOD1(AddObserver, | |
52 void(chromeos::NetworkPortalDetector::Observer* observer)); | |
53 MOCK_METHOD1(RemoveObserver, | |
54 void(chromeos::NetworkPortalDetector::Observer* observer)); | |
55 MOCK_METHOD1(AddAndFireObserver, | |
56 void(chromeos::NetworkPortalDetector::Observer* observer)); | |
57 MOCK_METHOD1(GetCaptivePortalState, | |
58 chromeos::NetworkPortalDetector::CaptivePortalState( | |
59 const std::string& service_path)); | |
60 MOCK_METHOD0(IsEnabled, bool()); | |
61 MOCK_METHOD1(Enable, void(bool start_detection)); | |
62 MOCK_METHOD0(StartDetectionIfIdle, bool()); | |
63 MOCK_METHOD1(SetStrategy, | |
64 void(chromeos::PortalDetectorStrategy::StrategyId id)); | |
65 MOCK_METHOD0(OnLockScreenRequest, void()); | |
66 | |
67 private: | |
68 DISALLOW_COPY_AND_ASSIGN(MockNetworkPortalDetector); | |
69 }; | |
70 | |
71 class MockImageFetcher : public image_fetcher::ImageFetcher { | 47 class MockImageFetcher : public image_fetcher::ImageFetcher { |
72 public: | 48 public: |
73 MockImageFetcher() {} | 49 MockImageFetcher() {} |
74 ~MockImageFetcher() override {} | 50 ~MockImageFetcher() override {} |
75 | 51 |
76 MOCK_METHOD4(StartOrQueueNetworkRequest, | 52 MOCK_METHOD4(StartOrQueueNetworkRequest, |
77 void(const std::string&, | 53 void(const std::string&, |
78 const GURL&, | 54 const GURL&, |
79 const ImageFetcher::ImageFetcherCallback&, | 55 const ImageFetcher::ImageFetcherCallback&, |
80 const net::NetworkTrafficAnnotationTag&)); | 56 const net::NetworkTrafficAnnotationTag&)); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > | 276 ASSERT_TRUE(base::Time::FromInternalValue(new_timestamp) > |
301 base::Time::FromInternalValue(now_timestamp)); | 277 base::Time::FromInternalValue(now_timestamp)); |
302 | 278 |
303 // Destructor for HatsController removes self from observer list. | 279 // Destructor for HatsController removes self from observer list. |
304 EXPECT_CALL(mock_network_portal_detector_, | 280 EXPECT_CALL(mock_network_portal_detector_, |
305 RemoveObserver(hats_notification_controller.get())) | 281 RemoveObserver(hats_notification_controller.get())) |
306 .Times(1); | 282 .Times(1); |
307 } | 283 } |
308 | 284 |
309 } // namespace chromeos | 285 } // namespace chromeos |
OLD | NEW |