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/invalidation/gcm_invalidation_bridge.h" | 6 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h" |
7 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 7 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
8 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 8 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
9 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 9 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
10 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 explicit FakeGCMProfileService(Profile* profile) | 30 explicit FakeGCMProfileService(Profile* profile) |
31 : gcm::GCMProfileService(profile) {} | 31 : gcm::GCMProfileService(profile) {} |
32 | 32 |
33 virtual void Register(const std::string& app_id, | 33 virtual void Register(const std::string& app_id, |
34 const std::vector<std::string>& sender_ids, | 34 const std::vector<std::string>& sender_ids, |
35 RegisterCallback callback) OVERRIDE { | 35 RegisterCallback callback) OVERRIDE { |
36 base::MessageLoop::current()->PostTask( | 36 base::MessageLoop::current()->PostTask( |
37 FROM_HERE, | 37 FROM_HERE, |
38 base::Bind( | 38 base::Bind( |
39 callback, std::string("registration.id"), gcm::GCMClient::SUCCESS)); | 39 callback, std::string("registration.id"), gcm::RESULT_SUCCESS)); |
40 } | 40 } |
41 | 41 |
42 private: | 42 private: |
43 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); | 43 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); |
44 }; | 44 }; |
45 | 45 |
46 class GCMInvalidationBridgeTest : public ::testing::Test { | 46 class GCMInvalidationBridgeTest : public ::testing::Test { |
47 protected: | 47 protected: |
48 GCMInvalidationBridgeTest() {} | 48 GCMInvalidationBridgeTest() {} |
49 | 49 |
(...skipping 20 matching lines...) Expand all Loading... |
70 identity_provider_.get())); | 70 identity_provider_.get())); |
71 | 71 |
72 delegate_ = bridge_->CreateDelegate(); | 72 delegate_ = bridge_->CreateDelegate(); |
73 delegate_->Initialize(); | 73 delegate_->Initialize(); |
74 base::RunLoop run_loop; | 74 base::RunLoop run_loop; |
75 run_loop.RunUntilIdle(); | 75 run_loop.RunUntilIdle(); |
76 } | 76 } |
77 | 77 |
78 public: | 78 public: |
79 void RegisterFinished(const std::string& registration_id, | 79 void RegisterFinished(const std::string& registration_id, |
80 gcm::GCMClient::Result result) { | 80 gcm::Result result) { |
81 registration_id_ = registration_id; | 81 registration_id_ = registration_id; |
82 } | 82 } |
83 | 83 |
84 void RequestTokenFinished(const GoogleServiceAuthError& error, | 84 void RequestTokenFinished(const GoogleServiceAuthError& error, |
85 const std::string& token) { | 85 const std::string& token) { |
86 issued_tokens_.push_back(token); | 86 issued_tokens_.push_back(token); |
87 request_token_errors_.push_back(error); | 87 request_token_errors_.push_back(error); |
88 } | 88 } |
89 | 89 |
90 content::TestBrowserThreadBundle thread_bundle_; | 90 content::TestBrowserThreadBundle thread_bundle_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 delegate_->Register(base::Bind(&GCMInvalidationBridgeTest::RegisterFinished, | 140 delegate_->Register(base::Bind(&GCMInvalidationBridgeTest::RegisterFinished, |
141 base::Unretained(this))); | 141 base::Unretained(this))); |
142 base::RunLoop run_loop; | 142 base::RunLoop run_loop; |
143 run_loop.RunUntilIdle(); | 143 run_loop.RunUntilIdle(); |
144 | 144 |
145 EXPECT_FALSE(registration_id_.empty()); | 145 EXPECT_FALSE(registration_id_.empty()); |
146 } | 146 } |
147 | 147 |
148 } // namespace | 148 } // namespace |
149 } // namespace invalidation | 149 } // namespace invalidation |
OLD | NEW |