OLD | NEW |
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/gcm_network_channel.h" | 5 #include "components/invalidation/impl/gcm_network_channel.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64url.h" | 10 #include "base/base64url.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/test/scoped_task_environment.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
17 #include "net/url_request/test_url_fetcher_factory.h" | 18 #include "net/url_request/test_url_fetcher_factory.h" |
18 #include "net/url_request/url_request_test_util.h" | 19 #include "net/url_request/url_request_test_util.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace syncer { | 22 namespace syncer { |
22 | 23 |
23 class TestGCMNetworkChannelDelegate : public GCMNetworkChannelDelegate { | 24 class TestGCMNetworkChannelDelegate : public GCMNetworkChannelDelegate { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 InvalidatorState get_last_invalidator_state() { | 207 InvalidatorState get_last_invalidator_state() { |
207 return last_invalidator_state_; | 208 return last_invalidator_state_; |
208 } | 209 } |
209 | 210 |
210 void RunLoopUntilIdle() { | 211 void RunLoopUntilIdle() { |
211 base::RunLoop run_loop; | 212 base::RunLoop run_loop; |
212 run_loop.RunUntilIdle(); | 213 run_loop.RunUntilIdle(); |
213 } | 214 } |
214 | 215 |
215 private: | 216 private: |
216 base::MessageLoop message_loop_; | 217 base::test::ScopedTaskEnvironment scoped_task_environment_; |
217 TestGCMNetworkChannelDelegate* delegate_; | 218 TestGCMNetworkChannelDelegate* delegate_; |
218 std::unique_ptr<GCMNetworkChannel> gcm_network_channel_; | 219 std::unique_ptr<GCMNetworkChannel> gcm_network_channel_; |
219 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 220 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
220 std::unique_ptr<net::FakeURLFetcherFactory> url_fetcher_factory_; | 221 std::unique_ptr<net::FakeURLFetcherFactory> url_fetcher_factory_; |
221 int url_fetchers_created_count_; | 222 int url_fetchers_created_count_; |
222 std::string last_echo_token_; | 223 std::string last_echo_token_; |
223 InvalidatorState last_invalidator_state_; | 224 InvalidatorState last_invalidator_state_; |
224 }; | 225 }; |
225 | 226 |
226 void TestNetworkChannelURLFetcher::AddExtraRequestHeader( | 227 void TestNetworkChannelURLFetcher::AddExtraRequestHeader( |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 delegate()->request_token_callback.Run( | 476 delegate()->request_token_callback.Run( |
476 GoogleServiceAuthError::AuthErrorNone(), "access.token"); | 477 GoogleServiceAuthError::AuthErrorNone(), "access.token"); |
477 RunLoopUntilIdle(); | 478 RunLoopUntilIdle(); |
478 EXPECT_EQ(url_fetchers_created_count(), 3); | 479 EXPECT_EQ(url_fetchers_created_count(), 3); |
479 // Echo_token should be from second message. | 480 // Echo_token should be from second message. |
480 EXPECT_EQ("echo.token", get_last_echo_token()); | 481 EXPECT_EQ("echo.token", get_last_echo_token()); |
481 } | 482 } |
482 #endif | 483 #endif |
483 | 484 |
484 } // namespace syncer | 485 } // namespace syncer |
OLD | NEW |