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 "base/location.h" |
5 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/thread_task_runner_handle.h" |
6 #include "chrome/browser/signin/account_tracker_service_factory.h" | 9 #include "chrome/browser/signin/account_tracker_service_factory.h" |
7 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 10 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
8 #include "chrome/browser/signin/fake_account_tracker_service.h" | 11 #include "chrome/browser/signin/fake_account_tracker_service.h" |
9 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
10 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
12 #include "chrome/browser/signin/test_signin_client_builder.h" | 15 #include "chrome/browser/signin/test_signin_client_builder.h" |
13 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
14 #include "components/gcm_driver/fake_gcm_driver.h" | 17 #include "components/gcm_driver/fake_gcm_driver.h" |
15 #include "components/gcm_driver/gcm_driver.h" | 18 #include "components/gcm_driver/gcm_driver.h" |
(...skipping 11 matching lines...) Expand all Loading... |
27 // registrationId. | 30 // registrationId. |
28 class CustomFakeGCMDriver : public gcm::FakeGCMDriver { | 31 class CustomFakeGCMDriver : public gcm::FakeGCMDriver { |
29 public: | 32 public: |
30 CustomFakeGCMDriver() {} | 33 CustomFakeGCMDriver() {} |
31 ~CustomFakeGCMDriver() override {} | 34 ~CustomFakeGCMDriver() override {} |
32 | 35 |
33 protected: | 36 protected: |
34 // FakeGCMDriver override: | 37 // FakeGCMDriver override: |
35 void RegisterImpl(const std::string& app_id, | 38 void RegisterImpl(const std::string& app_id, |
36 const std::vector<std::string>& sender_ids) override { | 39 const std::vector<std::string>& sender_ids) override { |
37 base::MessageLoop::current()->PostTask( | 40 base::ThreadTaskRunnerHandle::Get()->PostTask( |
38 FROM_HERE, | 41 FROM_HERE, |
39 base::Bind(&CustomFakeGCMDriver::RegisterFinished, | 42 base::Bind(&CustomFakeGCMDriver::RegisterFinished, |
40 base::Unretained(this), | 43 base::Unretained(this), app_id, |
41 app_id, | 44 std::string("registration.id"), gcm::GCMClient::SUCCESS)); |
42 std::string("registration.id"), | |
43 gcm::GCMClient::SUCCESS)); | |
44 } | 45 } |
45 | 46 |
46 private: | 47 private: |
47 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); | 48 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); |
48 }; | 49 }; |
49 | 50 |
50 class GCMInvalidationBridgeTest : public ::testing::Test { | 51 class GCMInvalidationBridgeTest : public ::testing::Test { |
51 protected: | 52 protected: |
52 GCMInvalidationBridgeTest() | 53 GCMInvalidationBridgeTest() |
53 : connection_online_(false) {} | 54 : connection_online_(false) {} |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bridge_->OnConnected(net::IPEndPoint()); | 164 bridge_->OnConnected(net::IPEndPoint()); |
164 RunLoop(); | 165 RunLoop(); |
165 EXPECT_TRUE(connection_online_); | 166 EXPECT_TRUE(connection_online_); |
166 bridge_->OnDisconnected(); | 167 bridge_->OnDisconnected(); |
167 RunLoop(); | 168 RunLoop(); |
168 EXPECT_FALSE(connection_online_); | 169 EXPECT_FALSE(connection_online_); |
169 } | 170 } |
170 | 171 |
171 } // namespace | 172 } // namespace |
172 } // namespace invalidation | 173 } // namespace invalidation |
OLD | NEW |