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/android/data_usage/data_use_ui_tab_model.h" | 5 #include "chrome/browser/android/data_usage/data_use_ui_tab_model.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Mock observer to track the calls to start and end tracking events. | 59 // Mock observer to track the calls to start and end tracking events. |
60 class MockTabDataUseObserver : public DataUseTabModel::TabDataUseObserver { | 60 class MockTabDataUseObserver : public DataUseTabModel::TabDataUseObserver { |
61 public: | 61 public: |
62 MOCK_METHOD1(NotifyTrackingStarting, void(SessionID::id_type tab_id)); | 62 MOCK_METHOD1(NotifyTrackingStarting, void(SessionID::id_type tab_id)); |
63 MOCK_METHOD1(NotifyTrackingEnding, void(SessionID::id_type tab_id)); | 63 MOCK_METHOD1(NotifyTrackingEnding, void(SessionID::id_type tab_id)); |
64 MOCK_METHOD0(OnDataUseTabModelReady, void()); | 64 MOCK_METHOD0(OnDataUseTabModelReady, void()); |
65 }; | 65 }; |
66 | 66 |
67 class TestDataUseTabModel : public DataUseTabModel { | 67 class TestDataUseTabModel : public DataUseTabModel { |
68 public: | 68 public: |
69 TestDataUseTabModel() {} | 69 TestDataUseTabModel() |
| 70 : DataUseTabModel(base::Bind(&TestDataUseTabModel::FetchMatchingRules, |
| 71 base::Unretained(this)), |
| 72 base::Bind(&TestDataUseTabModel::OnMatchingRulesFetched, |
| 73 base::Unretained(this))) {} |
70 ~TestDataUseTabModel() override {} | 74 ~TestDataUseTabModel() override {} |
71 | 75 |
| 76 void FetchMatchingRules() {} |
| 77 |
| 78 void OnMatchingRulesFetched(bool is_valid) {} |
| 79 |
72 using DataUseTabModel::NotifyObserversOfTrackingStarting; | 80 using DataUseTabModel::NotifyObserversOfTrackingStarting; |
73 using DataUseTabModel::NotifyObserversOfTrackingEnding; | 81 using DataUseTabModel::NotifyObserversOfTrackingEnding; |
74 }; | 82 }; |
75 | 83 |
76 class DataUseUITabModelTest : public testing::Test { | 84 class DataUseUITabModelTest : public testing::Test { |
77 public: | 85 public: |
78 DataUseUITabModelTest() | 86 DataUseUITabModelTest() |
79 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} | 87 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} |
80 DataUseUITabModel* data_use_ui_tab_model() { return &data_use_ui_tab_model_; } | 88 DataUseUITabModel* data_use_ui_tab_model() { return &data_use_ui_tab_model_; } |
81 | 89 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 121 |
114 data_use_aggregator_.reset( | 122 data_use_aggregator_.reset( |
115 new data_usage::DataUseAggregator(nullptr, nullptr)); | 123 new data_usage::DataUseAggregator(nullptr, nullptr)); |
116 | 124 |
117 external_data_use_observer_.reset(new ExternalDataUseObserver( | 125 external_data_use_observer_.reset(new ExternalDataUseObserver( |
118 data_use_aggregator_.get(), io_task_runner_, ui_task_runner_)); | 126 data_use_aggregator_.get(), io_task_runner_, ui_task_runner_)); |
119 // Wait for |external_data_use_observer_| to create the Java object. | 127 // Wait for |external_data_use_observer_| to create the Java object. |
120 base::RunLoop().RunUntilIdle(); | 128 base::RunLoop().RunUntilIdle(); |
121 | 129 |
122 data_use_tab_model_.reset(new TestDataUseTabModel()); | 130 data_use_tab_model_.reset(new TestDataUseTabModel()); |
123 data_use_tab_model_->InitOnUIThread( | |
124 external_data_use_observer_->external_data_use_observer_bridge_); | |
125 } | 131 } |
126 | 132 |
127 void SetUpDataUseUITabModel() { | 133 void SetUpDataUseUITabModel() { |
128 data_use_ui_tab_model_.SetDataUseTabModel(data_use_tab_model_.get()); | 134 data_use_ui_tab_model_.SetDataUseTabModel(data_use_tab_model_.get()); |
129 data_use_tab_model_->OnControlAppInstallStateChange(true); | 135 data_use_tab_model_->OnControlAppInstallStateChange(true); |
130 } | 136 } |
131 | 137 |
132 private: | 138 private: |
133 content::TestBrowserThreadBundle thread_bundle_; | 139 content::TestBrowserThreadBundle thread_bundle_; |
134 DataUseUITabModel data_use_ui_tab_model_; | 140 DataUseUITabModel data_use_ui_tab_model_; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 base::RunLoop().RunUntilIdle(); | 607 base::RunLoop().RunUntilIdle(); |
602 RegisterURLRegexes(std::vector<std::string>(url_regexes.size(), kFooPackage), | 608 RegisterURLRegexes(std::vector<std::string>(url_regexes.size(), kFooPackage), |
603 url_regexes, | 609 url_regexes, |
604 std::vector<std::string>(url_regexes.size(), kFooLabel)); | 610 std::vector<std::string>(url_regexes.size(), kFooLabel)); |
605 base::RunLoop().RunUntilIdle(); | 611 base::RunLoop().RunUntilIdle(); |
606 } | 612 } |
607 | 613 |
608 } // namespace android | 614 } // namespace android |
609 | 615 |
610 } // namespace chrome | 616 } // namespace chrome |
OLD | NEW |