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

Side by Side Diff: components/invalidation/impl/sync_system_resources_unittest.cc

Issue 2082333002: Remove calls to deprecated MessageLoop methods in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/invalidation/impl/sync_system_resources.h" 5 #include "components/invalidation/impl/sync_system_resources.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h"
15 #include "components/invalidation/impl/push_client_channel.h" 16 #include "components/invalidation/impl/push_client_channel.h"
16 #include "components/invalidation/impl/state_writer.h" 17 #include "components/invalidation/impl/state_writer.h"
17 #include "google/cacheinvalidation/include/types.h" 18 #include "google/cacheinvalidation/include/types.h"
18 #include "jingle/notifier/listener/fake_push_client.h" 19 #include "jingle/notifier/listener/fake_push_client.h"
19 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace syncer { 23 namespace syncer {
23 namespace { 24 namespace {
24 25
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 sync_system_resources_.Start(); 129 sync_system_resources_.Start();
129 ScheduleShouldNotRun(); 130 ScheduleShouldNotRun();
130 } 131 }
131 132
132 TEST_F(SyncSystemResourcesTest, ScheduleImmediately) { 133 TEST_F(SyncSystemResourcesTest, ScheduleImmediately) {
133 sync_system_resources_.Start(); 134 sync_system_resources_.Start();
134 MockClosure mock_closure; 135 MockClosure mock_closure;
135 EXPECT_CALL(mock_closure, Run()); 136 EXPECT_CALL(mock_closure, Run());
136 sync_system_resources_.internal_scheduler()->Schedule( 137 sync_system_resources_.internal_scheduler()->Schedule(
137 invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure()); 138 invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure());
138 message_loop_.RunUntilIdle(); 139 base::RunLoop().RunUntilIdle();
139 } 140 }
140 141
141 TEST_F(SyncSystemResourcesTest, ScheduleOnListenerThread) { 142 TEST_F(SyncSystemResourcesTest, ScheduleOnListenerThread) {
142 sync_system_resources_.Start(); 143 sync_system_resources_.Start();
143 MockClosure mock_closure; 144 MockClosure mock_closure;
144 EXPECT_CALL(mock_closure, Run()); 145 EXPECT_CALL(mock_closure, Run());
145 sync_system_resources_.listener_scheduler()->Schedule( 146 sync_system_resources_.listener_scheduler()->Schedule(
146 invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure()); 147 invalidation::Scheduler::NoDelay(), mock_closure.CreateClosure());
147 EXPECT_TRUE( 148 EXPECT_TRUE(
148 sync_system_resources_.internal_scheduler()->IsRunningOnThread()); 149 sync_system_resources_.internal_scheduler()->IsRunningOnThread());
149 message_loop_.RunUntilIdle(); 150 base::RunLoop().RunUntilIdle();
150 } 151 }
151 152
152 TEST_F(SyncSystemResourcesTest, ScheduleWithZeroDelay) { 153 TEST_F(SyncSystemResourcesTest, ScheduleWithZeroDelay) {
153 sync_system_resources_.Start(); 154 sync_system_resources_.Start();
154 MockClosure mock_closure; 155 MockClosure mock_closure;
155 EXPECT_CALL(mock_closure, Run()); 156 EXPECT_CALL(mock_closure, Run());
156 sync_system_resources_.internal_scheduler()->Schedule( 157 sync_system_resources_.internal_scheduler()->Schedule(
157 invalidation::TimeDelta::FromSeconds(0), mock_closure.CreateClosure()); 158 invalidation::TimeDelta::FromSeconds(0), mock_closure.CreateClosure());
158 message_loop_.RunUntilIdle(); 159 base::RunLoop().RunUntilIdle();
159 } 160 }
160 161
161 // TODO(akalin): Figure out how to test with a non-zero delay. 162 // TODO(akalin): Figure out how to test with a non-zero delay.
162 163
163 TEST_F(SyncSystemResourcesTest, WriteState) { 164 TEST_F(SyncSystemResourcesTest, WriteState) {
164 sync_system_resources_.Start(); 165 sync_system_resources_.Start();
165 EXPECT_CALL(mock_state_writer_, WriteState(_)); 166 EXPECT_CALL(mock_state_writer_, WriteState(_));
166 // Owned by WriteState. 167 // Owned by WriteState.
167 MockStorageCallback mock_storage_callback; 168 MockStorageCallback mock_storage_callback;
168 invalidation::Status results(invalidation::Status::PERMANENT_FAILURE, 169 invalidation::Status results(invalidation::Status::PERMANENT_FAILURE,
169 "fake-failure"); 170 "fake-failure");
170 EXPECT_CALL(mock_storage_callback, Run(_)) 171 EXPECT_CALL(mock_storage_callback, Run(_))
171 .WillOnce(SaveArg<0>(&results)); 172 .WillOnce(SaveArg<0>(&results));
172 sync_system_resources_.storage()->WriteKey( 173 sync_system_resources_.storage()->WriteKey(
173 std::string(), "state", mock_storage_callback.CreateCallback()); 174 std::string(), "state", mock_storage_callback.CreateCallback());
174 message_loop_.RunUntilIdle(); 175 base::RunLoop().RunUntilIdle();
175 EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, std::string()), 176 EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, std::string()),
176 results); 177 results);
177 } 178 }
178 179
179 class TestSyncNetworkChannel : public SyncNetworkChannel { 180 class TestSyncNetworkChannel : public SyncNetworkChannel {
180 public: 181 public:
181 TestSyncNetworkChannel() {} 182 TestSyncNetworkChannel() {}
182 ~TestSyncNetworkChannel() override {} 183 ~TestSyncNetworkChannel() override {}
183 184
184 using SyncNetworkChannel::NotifyNetworkStatusChange; 185 using SyncNetworkChannel::NotifyNetworkStatusChange;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 TEST_F(SyncNetworkChannelTest, NetworkStateChange) { 242 TEST_F(SyncNetworkChannelTest, NetworkStateChange) {
242 EXPECT_FALSE(connected_); 243 EXPECT_FALSE(connected_);
243 network_channel_.NotifyNetworkStatusChange(true); 244 network_channel_.NotifyNetworkStatusChange(true);
244 EXPECT_TRUE(connected_); 245 EXPECT_TRUE(connected_);
245 network_channel_.NotifyNetworkStatusChange(false); 246 network_channel_.NotifyNetworkStatusChange(false);
246 EXPECT_FALSE(connected_); 247 EXPECT_FALSE(connected_);
247 } 248 }
248 249
249 } // namespace 250 } // namespace
250 } // namespace syncer 251 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698