| 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/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 6 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 7 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 7 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "components/gcm_driver/fake_gcm_driver.h" | 10 #include "components/gcm_driver/fake_gcm_driver.h" |
| 11 #include "components/gcm_driver/gcm_driver.h" | 11 #include "components/gcm_driver/gcm_driver.h" |
| 12 #include "components/invalidation/gcm_invalidation_bridge.h" | 12 #include "components/invalidation/gcm_invalidation_bridge.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "google_apis/gaia/fake_identity_provider.h" | 14 #include "google_apis/gaia/fake_identity_provider.h" |
| 15 #include "google_apis/gaia/google_service_auth_error.h" | 15 #include "google_apis/gaia/google_service_auth_error.h" |
| 16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace invalidation { | 19 namespace invalidation { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Implementation of GCMDriver::Register that always succeeds with the same | 22 // Implementation of GCMDriver::Register that always succeeds with the same |
| 23 // registrationId. | 23 // registrationId. |
| 24 class CustomFakeGCMDriver : public gcm::FakeGCMDriver { | 24 class CustomFakeGCMDriver : public gcm::FakeGCMDriver { |
| 25 public: | 25 public: |
| 26 CustomFakeGCMDriver() {} | 26 CustomFakeGCMDriver() {} |
| 27 virtual ~CustomFakeGCMDriver() {} | 27 ~CustomFakeGCMDriver() override {} |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 // FakeGCMDriver override: | 30 // FakeGCMDriver override: |
| 31 virtual void RegisterImpl( | 31 void RegisterImpl(const std::string& app_id, |
| 32 const std::string& app_id, | 32 const std::vector<std::string>& sender_ids) override { |
| 33 const std::vector<std::string>& sender_ids) override { | |
| 34 base::MessageLoop::current()->PostTask( | 33 base::MessageLoop::current()->PostTask( |
| 35 FROM_HERE, | 34 FROM_HERE, |
| 36 base::Bind(&CustomFakeGCMDriver::RegisterFinished, | 35 base::Bind(&CustomFakeGCMDriver::RegisterFinished, |
| 37 base::Unretained(this), | 36 base::Unretained(this), |
| 38 app_id, | 37 app_id, |
| 39 std::string("registration.id"), | 38 std::string("registration.id"), |
| 40 gcm::GCMClient::SUCCESS)); | 39 gcm::GCMClient::SUCCESS)); |
| 41 } | 40 } |
| 42 | 41 |
| 43 private: | 42 private: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 bridge_->OnConnected(net::IPEndPoint()); | 155 bridge_->OnConnected(net::IPEndPoint()); |
| 157 RunLoop(); | 156 RunLoop(); |
| 158 EXPECT_TRUE(connection_online_); | 157 EXPECT_TRUE(connection_online_); |
| 159 bridge_->OnDisconnected(); | 158 bridge_->OnDisconnected(); |
| 160 RunLoop(); | 159 RunLoop(); |
| 161 EXPECT_FALSE(connection_online_); | 160 EXPECT_FALSE(connection_online_); |
| 162 } | 161 } |
| 163 | 162 |
| 164 } // namespace | 163 } // namespace |
| 165 } // namespace invalidation | 164 } // namespace invalidation |
| OLD | NEW |