Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1049)

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service_unittest.cc

Issue 285623002: Rename GCMClient::Load to GCMClient::Start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/services/gcm/gcm_profile_service.h" 5 #include "chrome/browser/services/gcm/gcm_profile_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 TestingProfile::Builder builder; 89 TestingProfile::Builder builder;
90 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), 90 builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
91 FakeSigninManager::Build); 91 FakeSigninManager::Build);
92 profile_ = builder.Build(); 92 profile_ = builder.Build();
93 93
94 gcm_profile_service_ = static_cast<GCMProfileService*>( 94 gcm_profile_service_ = static_cast<GCMProfileService*>(
95 GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse( 95 GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse(
96 profile_.get(), 96 profile_.get(),
97 &BuildGCMProfileService)); 97 &BuildGCMProfileService));
98 gcm_profile_service_->Initialize(scoped_ptr<GCMClientFactory>( 98 gcm_profile_service_->Initialize(scoped_ptr<GCMClientFactory>(
99 new FakeGCMClientFactory(GCMClientMock::NO_DELAY_LOADING))); 99 new FakeGCMClientFactory(GCMClientMock::NO_DELAY_START)));
100 100
101 FakeSigninManager* signin_manager = static_cast<FakeSigninManager*>( 101 FakeSigninManager* signin_manager = static_cast<FakeSigninManager*>(
102 SigninManagerFactory::GetInstance()->GetForProfile(profile_.get())); 102 SigninManagerFactory::GetInstance()->GetForProfile(profile_.get()));
103 signin_manager->SignIn(kTestAccountID); 103 signin_manager->SignIn(kTestAccountID);
104 base::RunLoop().RunUntilIdle(); 104 base::RunLoop().RunUntilIdle();
105 } 105 }
106 106
107 void GCMProfileServiceTest::RegisterAndWaitForCompletion( 107 void GCMProfileServiceTest::RegisterAndWaitForCompletion(
108 const std::vector<std::string>& sender_ids) { 108 const std::vector<std::string>& sender_ids) {
109 base::RunLoop run_loop; 109 base::RunLoop run_loop;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EXPECT_FALSE(gcm_profile_service_->IsGCMClientReady()); 151 EXPECT_FALSE(gcm_profile_service_->IsGCMClientReady());
152 EXPECT_EQ(GCMClientMock::UNINITIALIZED, GetGCMClient()->status()); 152 EXPECT_EQ(GCMClientMock::UNINITIALIZED, GetGCMClient()->status());
153 153
154 // Invoking register will make GCMClient checked in. 154 // Invoking register will make GCMClient checked in.
155 std::vector<std::string> sender_ids; 155 std::vector<std::string> sender_ids;
156 sender_ids.push_back("sender"); 156 sender_ids.push_back("sender");
157 RegisterAndWaitForCompletion(sender_ids); 157 RegisterAndWaitForCompletion(sender_ids);
158 158
159 // GCMClient should be checked in. 159 // GCMClient should be checked in.
160 EXPECT_TRUE(gcm_profile_service_->IsGCMClientReady()); 160 EXPECT_TRUE(gcm_profile_service_->IsGCMClientReady());
161 EXPECT_EQ(GCMClientMock::LOADED, GetGCMClient()->status()); 161 EXPECT_EQ(GCMClientMock::STARTED, GetGCMClient()->status());
162 162
163 // Registration should succeed. 163 // Registration should succeed.
164 std::string expected_registration_id = 164 std::string expected_registration_id =
165 GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids); 165 GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
166 EXPECT_EQ(expected_registration_id, registration_id_); 166 EXPECT_EQ(expected_registration_id, registration_id_);
167 EXPECT_EQ(GCMClient::SUCCESS, registration_result_); 167 EXPECT_EQ(GCMClient::SUCCESS, registration_result_);
168 } 168 }
169 169
170 TEST_F(GCMProfileServiceTest, SendUnderNeutralChannelSignal) { 170 TEST_F(GCMProfileServiceTest, SendUnderNeutralChannelSignal) {
171 // GCMClient should not be checked in. 171 // GCMClient should not be checked in.
172 EXPECT_FALSE(gcm_profile_service_->IsGCMClientReady()); 172 EXPECT_FALSE(gcm_profile_service_->IsGCMClientReady());
173 EXPECT_EQ(GCMClientMock::UNINITIALIZED, GetGCMClient()->status()); 173 EXPECT_EQ(GCMClientMock::UNINITIALIZED, GetGCMClient()->status());
174 174
175 // Invoking send will make GCMClient checked in. 175 // Invoking send will make GCMClient checked in.
176 GCMClient::OutgoingMessage message; 176 GCMClient::OutgoingMessage message;
177 message.id = "1"; 177 message.id = "1";
178 message.data["key1"] = "value1"; 178 message.data["key1"] = "value1";
179 SendAndWaitForCompletion( message); 179 SendAndWaitForCompletion( message);
180 180
181 // GCMClient should be checked in. 181 // GCMClient should be checked in.
182 EXPECT_TRUE(gcm_profile_service_->IsGCMClientReady()); 182 EXPECT_TRUE(gcm_profile_service_->IsGCMClientReady());
183 EXPECT_EQ(GCMClientMock::LOADED, GetGCMClient()->status()); 183 EXPECT_EQ(GCMClientMock::STARTED, GetGCMClient()->status());
184 184
185 // Sending should succeed. 185 // Sending should succeed.
186 EXPECT_EQ(message.id, send_message_id_); 186 EXPECT_EQ(message.id, send_message_id_);
187 EXPECT_EQ(GCMClient::SUCCESS, send_result_); 187 EXPECT_EQ(GCMClient::SUCCESS, send_result_);
188 } 188 }
189 189
190 } // namespace gcm 190 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_client_mock.cc ('k') | chrome/browser/services/gcm/gcm_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698