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" |
(...skipping 12 matching lines...) Expand all Loading... |
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 virtual ~CustomFakeGCMDriver() {} |
28 | 28 |
29 protected: | 29 protected: |
30 // FakeGCMDriver override: | 30 // FakeGCMDriver override: |
31 virtual void RegisterImpl( | 31 virtual void RegisterImpl( |
32 const std::string& app_id, | 32 const std::string& app_id, |
33 const std::vector<std::string>& sender_ids) OVERRIDE { | 33 const std::vector<std::string>& sender_ids) override { |
34 base::MessageLoop::current()->PostTask( | 34 base::MessageLoop::current()->PostTask( |
35 FROM_HERE, | 35 FROM_HERE, |
36 base::Bind(&CustomFakeGCMDriver::RegisterFinished, | 36 base::Bind(&CustomFakeGCMDriver::RegisterFinished, |
37 base::Unretained(this), | 37 base::Unretained(this), |
38 app_id, | 38 app_id, |
39 std::string("registration.id"), | 39 std::string("registration.id"), |
40 gcm::GCMClient::SUCCESS)); | 40 gcm::GCMClient::SUCCESS)); |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); | 44 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); |
45 }; | 45 }; |
46 | 46 |
47 class GCMInvalidationBridgeTest : public ::testing::Test { | 47 class GCMInvalidationBridgeTest : public ::testing::Test { |
48 protected: | 48 protected: |
49 GCMInvalidationBridgeTest() | 49 GCMInvalidationBridgeTest() |
50 : connection_online_(false) {} | 50 : connection_online_(false) {} |
51 | 51 |
52 virtual ~GCMInvalidationBridgeTest() {} | 52 virtual ~GCMInvalidationBridgeTest() {} |
53 | 53 |
54 virtual void SetUp() OVERRIDE { | 54 virtual void SetUp() override { |
55 TestingProfile::Builder builder; | 55 TestingProfile::Builder builder; |
56 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 56 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
57 &BuildAutoIssuingFakeProfileOAuth2TokenService); | 57 &BuildAutoIssuingFakeProfileOAuth2TokenService); |
58 profile_ = builder.Build(); | 58 profile_ = builder.Build(); |
59 | 59 |
60 FakeProfileOAuth2TokenService* token_service = | 60 FakeProfileOAuth2TokenService* token_service = |
61 (FakeProfileOAuth2TokenService*) | 61 (FakeProfileOAuth2TokenService*) |
62 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 62 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); |
63 token_service->IssueRefreshTokenForUser("", "fake_refresh_token"); | 63 token_service->IssueRefreshTokenForUser("", "fake_refresh_token"); |
64 gcm_driver_.reset(new CustomFakeGCMDriver()); | 64 gcm_driver_.reset(new CustomFakeGCMDriver()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 bridge_->OnConnected(net::IPEndPoint()); | 156 bridge_->OnConnected(net::IPEndPoint()); |
157 RunLoop(); | 157 RunLoop(); |
158 EXPECT_TRUE(connection_online_); | 158 EXPECT_TRUE(connection_online_); |
159 bridge_->OnDisconnected(); | 159 bridge_->OnDisconnected(); |
160 RunLoop(); | 160 RunLoop(); |
161 EXPECT_FALSE(connection_online_); | 161 EXPECT_FALSE(connection_online_); |
162 } | 162 } |
163 | 163 |
164 } // namespace | 164 } // namespace |
165 } // namespace invalidation | 165 } // namespace invalidation |
OLD | NEW |