| 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_tab_model.h" | 5 #include "chrome/browser/android/data_usage/data_use_tab_model.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/bind.h" |
| 13 #include "base/callback.h" |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 18 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/test/histogram_tester.h" | 22 #include "base/test/histogram_tester.h" |
| 21 #include "base/test/simple_test_tick_clock.h" | 23 #include "base/test/simple_test_tick_clock.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 class DataUseTabModelTest : public testing::Test { | 110 class DataUseTabModelTest : public testing::Test { |
| 109 public: | 111 public: |
| 110 DataUseTabModelTest() | 112 DataUseTabModelTest() |
| 111 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 113 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 112 external_data_use_observer_bridge_( | 114 external_data_use_observer_bridge_( |
| 113 new TestExternalDataUseObserverBridge()) {} | 115 new TestExternalDataUseObserverBridge()) {} |
| 114 | 116 |
| 115 protected: | 117 protected: |
| 116 void SetUp() override { | 118 void SetUp() override { |
| 117 base::RunLoop().RunUntilIdle(); | 119 base::RunLoop().RunUntilIdle(); |
| 118 data_use_tab_model_.reset(new DataUseTabModel()); | 120 data_use_tab_model_.reset(new DataUseTabModel( |
| 119 data_use_tab_model_->InitOnUIThread( | 121 base::Bind(&ExternalDataUseObserverBridge::FetchMatchingRules, |
| 120 external_data_use_observer_bridge_.get()); | 122 base::Unretained(external_data_use_observer_bridge_.get())), |
| 123 base::Bind( |
| 124 &ExternalDataUseObserverBridge::ShouldRegisterAsDataUseObserver, |
| 125 base::Unretained(external_data_use_observer_bridge_.get())))); |
| 126 data_use_tab_model_->InitOnUIThread(); |
| 121 | 127 |
| 122 tick_clock_ = new base::SimpleTestTickClock(); | 128 tick_clock_ = new base::SimpleTestTickClock(); |
| 123 | 129 |
| 124 // Advance to non nil time. | 130 // Advance to non nil time. |
| 125 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); | 131 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); |
| 126 | 132 |
| 127 // |tick_clock_| will be owned by |data_use_tab_model_|. | 133 // |tick_clock_| will be owned by |data_use_tab_model_|. |
| 128 data_use_tab_model_->tick_clock_.reset(tick_clock_); | 134 data_use_tab_model_->tick_clock_.reset(tick_clock_); |
| 129 data_use_tab_model_->OnControlAppInstallStateChange(true); | 135 data_use_tab_model_->OnControlAppInstallStateChange(true); |
| 130 } | 136 } |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 RegisterURLRegexes(app_package_names, domain_regexes, labels); | 1140 RegisterURLRegexes(app_package_names, domain_regexes, labels); |
| 1135 data_use_tab_model_->OnControlAppInstallStateChange(false); | 1141 data_use_tab_model_->OnControlAppInstallStateChange(false); |
| 1136 data_use_tab_model_->OnControlAppInstallStateChange(true); | 1142 data_use_tab_model_->OnControlAppInstallStateChange(true); |
| 1137 testing::Mock::VerifyAndClearExpectations(&mock_observer); | 1143 testing::Mock::VerifyAndClearExpectations(&mock_observer); |
| 1138 EXPECT_TRUE(data_use_tab_model_->is_ready_for_navigation_event()); | 1144 EXPECT_TRUE(data_use_tab_model_->is_ready_for_navigation_event()); |
| 1139 } | 1145 } |
| 1140 | 1146 |
| 1141 } // namespace android | 1147 } // namespace android |
| 1142 | 1148 |
| 1143 } // namespace chrome | 1149 } // namespace chrome |
| OLD | NEW |