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

Side by Side Diff: google_apis/gcm/engine/gcm_store_impl_unittest.cc

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch to land Created 5 years, 6 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
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 "google_apis/gcm/engine/gcm_store_impl.h" 5 #include "google_apis/gcm/engine/gcm_store_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 226
227 TEST_F(GCMStoreImplTest, Registrations) { 227 TEST_F(GCMStoreImplTest, Registrations) {
228 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); 228 scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
229 scoped_ptr<GCMStore::LoadResult> load_result; 229 scoped_ptr<GCMStore::LoadResult> load_result;
230 gcm_store->Load(base::Bind( 230 gcm_store->Load(base::Bind(
231 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 231 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
232 PumpLoop(); 232 PumpLoop();
233 233
234 // Add one registration with one sender. 234 // Add one registration with one sender.
235 linked_ptr<RegistrationInfo> registration1(new RegistrationInfo); 235 std::string registration = "sender1=registration1";
236 registration1->sender_ids.push_back("sender1");
237 registration1->registration_id = "registration1";
238 gcm_store->AddRegistration( 236 gcm_store->AddRegistration(
239 "app1", 237 kAppName,
240 registration1, 238 registration,
241 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); 239 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
242 PumpLoop(); 240 PumpLoop();
243 241
244 // Add one registration with multiple senders. 242 // Add one registration with multiple senders.
245 linked_ptr<RegistrationInfo> registration2(new RegistrationInfo); 243 std::string registration2 = "sender1,sender2=registration2";
246 registration2->sender_ids.push_back("sender2_1");
247 registration2->sender_ids.push_back("sender2_2");
248 registration2->registration_id = "registration2";
249 gcm_store->AddRegistration( 244 gcm_store->AddRegistration(
250 "app2", 245 kAppName2,
251 registration2, 246 registration2,
252 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); 247 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
253 PumpLoop(); 248 PumpLoop();
254 249
255 gcm_store = BuildGCMStore().Pass(); 250 gcm_store = BuildGCMStore().Pass();
256 gcm_store->Load(base::Bind( 251 gcm_store->Load(base::Bind(
257 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 252 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
258 PumpLoop(); 253 PumpLoop();
259 254
260 ASSERT_EQ(2u, load_result->registrations.size()); 255 ASSERT_EQ(2u, load_result->registrations.size());
261 ASSERT_TRUE(load_result->registrations.find("app1") != 256 ASSERT_TRUE(load_result->registrations.find(kAppName) !=
262 load_result->registrations.end()); 257 load_result->registrations.end());
263 EXPECT_EQ(registration1->registration_id, 258 EXPECT_EQ(registration, load_result->registrations[kAppName]);
264 load_result->registrations["app1"]->registration_id); 259 ASSERT_TRUE(load_result->registrations.find(kAppName2) !=
265 ASSERT_EQ(1u, load_result->registrations["app1"]->sender_ids.size());
266 EXPECT_EQ(registration1->sender_ids[0],
267 load_result->registrations["app1"]->sender_ids[0]);
268 ASSERT_TRUE(load_result->registrations.find("app2") !=
269 load_result->registrations.end()); 260 load_result->registrations.end());
270 EXPECT_EQ(registration2->registration_id, 261 EXPECT_EQ(registration2, load_result->registrations[kAppName2]);
271 load_result->registrations["app2"]->registration_id);
272 ASSERT_EQ(2u, load_result->registrations["app2"]->sender_ids.size());
273 EXPECT_EQ(registration2->sender_ids[0],
274 load_result->registrations["app2"]->sender_ids[0]);
275 EXPECT_EQ(registration2->sender_ids[1],
276 load_result->registrations["app2"]->sender_ids[1]);
277 262
278 gcm_store->RemoveRegistration( 263 gcm_store->RemoveRegistration(
279 "app2", 264 kAppName2,
280 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); 265 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
281 PumpLoop(); 266 PumpLoop();
282 267
283 gcm_store = BuildGCMStore().Pass(); 268 gcm_store = BuildGCMStore().Pass();
284 gcm_store->Load(base::Bind( 269 gcm_store->Load(base::Bind(
285 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 270 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
286 PumpLoop(); 271 PumpLoop();
287 272
288 ASSERT_EQ(1u, load_result->registrations.size()); 273 ASSERT_EQ(1u, load_result->registrations.size());
289 ASSERT_TRUE(load_result->registrations.find("app1") != 274 ASSERT_TRUE(load_result->registrations.find(kAppName) !=
290 load_result->registrations.end()); 275 load_result->registrations.end());
291 EXPECT_EQ(registration1->registration_id, 276 EXPECT_EQ(registration, load_result->registrations[kAppName]);
292 load_result->registrations["app1"]->registration_id);
293 ASSERT_EQ(1u, load_result->registrations["app1"]->sender_ids.size());
294 EXPECT_EQ(registration1->sender_ids[0],
295 load_result->registrations["app1"]->sender_ids[0]);
296 } 277 }
297 278
298 // Verify saving some incoming messages, reopening the directory, and then 279 // Verify saving some incoming messages, reopening the directory, and then
299 // removing those incoming messages. 280 // removing those incoming messages.
300 TEST_F(GCMStoreImplTest, IncomingMessages) { 281 TEST_F(GCMStoreImplTest, IncomingMessages) {
301 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); 282 scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
302 scoped_ptr<GCMStore::LoadResult> load_result; 283 scoped_ptr<GCMStore::LoadResult> load_result;
303 gcm_store->Load(base::Bind( 284 gcm_store->Load(base::Bind(
304 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 285 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
305 PumpLoop(); 286 PumpLoop();
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 769
789 ASSERT_EQ(1u, load_result->instance_id_data.size()); 770 ASSERT_EQ(1u, load_result->instance_id_data.size());
790 ASSERT_TRUE(load_result->instance_id_data.find(kAppName2) != 771 ASSERT_TRUE(load_result->instance_id_data.find(kAppName2) !=
791 load_result->instance_id_data.end()); 772 load_result->instance_id_data.end());
792 EXPECT_EQ(instance_id_data2, load_result->instance_id_data[kAppName2]); 773 EXPECT_EQ(instance_id_data2, load_result->instance_id_data[kAppName2]);
793 } 774 }
794 775
795 } // namespace 776 } // namespace
796 777
797 } // namespace gcm 778 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | google_apis/gcm/engine/gcm_unregistration_request_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698