Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/browser/android/data_usage/data_use_tab_model_unittest.cc

Issue 2158913002: Make DataUseTabModel and DataUseMatcher more independent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bind_helpers.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
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()))));
121 126
122 tick_clock_ = new base::SimpleTestTickClock(); 127 tick_clock_ = new base::SimpleTestTickClock();
123 128
124 // Advance to non nil time. 129 // Advance to non nil time.
125 tick_clock_->Advance(base::TimeDelta::FromSeconds(1)); 130 tick_clock_->Advance(base::TimeDelta::FromSeconds(1));
126 131
127 // |tick_clock_| will be owned by |data_use_tab_model_|. 132 // |tick_clock_| will be owned by |data_use_tab_model_|.
128 data_use_tab_model_->tick_clock_.reset(tick_clock_); 133 data_use_tab_model_->tick_clock_.reset(tick_clock_);
129 data_use_tab_model_->OnControlAppInstallStateChange(true); 134 data_use_tab_model_->OnControlAppInstallStateChange(true);
130 } 135 }
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 RegisterURLRegexes(app_package_names, domain_regexes, labels); 1139 RegisterURLRegexes(app_package_names, domain_regexes, labels);
1135 data_use_tab_model_->OnControlAppInstallStateChange(false); 1140 data_use_tab_model_->OnControlAppInstallStateChange(false);
1136 data_use_tab_model_->OnControlAppInstallStateChange(true); 1141 data_use_tab_model_->OnControlAppInstallStateChange(true);
1137 testing::Mock::VerifyAndClearExpectations(&mock_observer); 1142 testing::Mock::VerifyAndClearExpectations(&mock_observer);
1138 EXPECT_TRUE(data_use_tab_model_->is_ready_for_navigation_event()); 1143 EXPECT_TRUE(data_use_tab_model_->is_ready_for_navigation_event());
1139 } 1144 }
1140 1145
1141 } // namespace android 1146 } // namespace android
1142 1147
1143 } // namespace chrome 1148 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698