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

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

Issue 222913004: [GCM] Minimum change for periodic checkin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applying a final comments. Created 6 years, 8 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
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | google_apis/gcm/gcm_client_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); 101 scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
102 scoped_ptr<GCMStore::LoadResult> load_result; 102 scoped_ptr<GCMStore::LoadResult> load_result;
103 gcm_store->Load(base::Bind( 103 gcm_store->Load(base::Bind(
104 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 104 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
105 PumpLoop(); 105 PumpLoop();
106 106
107 EXPECT_EQ(0U, load_result->device_android_id); 107 EXPECT_EQ(0U, load_result->device_android_id);
108 EXPECT_EQ(0U, load_result->device_security_token); 108 EXPECT_EQ(0U, load_result->device_security_token);
109 EXPECT_TRUE(load_result->incoming_messages.empty()); 109 EXPECT_TRUE(load_result->incoming_messages.empty());
110 EXPECT_TRUE(load_result->outgoing_messages.empty()); 110 EXPECT_TRUE(load_result->outgoing_messages.empty());
111 EXPECT_EQ(base::Time::FromInternalValue(0LL), load_result->last_checkin_time);
111 } 112 }
112 113
113 TEST_F(GCMStoreImplTest, DeviceCredentials) { 114 TEST_F(GCMStoreImplTest, DeviceCredentials) {
114 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); 115 scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
115 scoped_ptr<GCMStore::LoadResult> load_result; 116 scoped_ptr<GCMStore::LoadResult> load_result;
116 gcm_store->Load(base::Bind( 117 gcm_store->Load(base::Bind(
117 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 118 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
118 PumpLoop(); 119 PumpLoop();
119 120
120 gcm_store->SetDeviceCredentials( 121 gcm_store->SetDeviceCredentials(
121 kDeviceId, 122 kDeviceId,
122 kDeviceToken, 123 kDeviceToken,
123 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); 124 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
124 PumpLoop(); 125 PumpLoop();
125 126
126 gcm_store = BuildGCMStore().Pass(); 127 gcm_store = BuildGCMStore().Pass();
127 gcm_store->Load(base::Bind( 128 gcm_store->Load(base::Bind(
128 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 129 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
129 PumpLoop(); 130 PumpLoop();
130 131
131 ASSERT_EQ(kDeviceId, load_result->device_android_id); 132 ASSERT_EQ(kDeviceId, load_result->device_android_id);
132 ASSERT_EQ(kDeviceToken, load_result->device_security_token); 133 ASSERT_EQ(kDeviceToken, load_result->device_security_token);
133 } 134 }
134 135
136 TEST_F(GCMStoreImplTest, LastCheckinTime) {
137 scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
138 scoped_ptr<GCMStore::LoadResult> load_result;
139 gcm_store->Load(base::Bind(
140 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
141 PumpLoop();
142
143 base::Time last_checkin_time = base::Time::Now();
144
145 gcm_store->SetLastCheckinTime(
146 last_checkin_time,
147 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
148 PumpLoop();
149
150 gcm_store = BuildGCMStore().Pass();
151 gcm_store->Load(base::Bind(
152 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
153 PumpLoop();
154
155 ASSERT_EQ(last_checkin_time, load_result->last_checkin_time);
156 }
157
135 TEST_F(GCMStoreImplTest, Registrations) { 158 TEST_F(GCMStoreImplTest, Registrations) {
136 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); 159 scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
137 scoped_ptr<GCMStore::LoadResult> load_result; 160 scoped_ptr<GCMStore::LoadResult> load_result;
138 gcm_store->Load(base::Bind( 161 gcm_store->Load(base::Bind(
139 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); 162 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
140 PumpLoop(); 163 PumpLoop();
141 164
142 // Add one registration with one sender. 165 // Add one registration with one sender.
143 linked_ptr<RegistrationInfo> registration1(new RegistrationInfo); 166 linked_ptr<RegistrationInfo> registration1(new RegistrationInfo);
144 registration1->sender_ids.push_back("sender1"); 167 registration1->sender_ids.push_back("sender1");
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 487
465 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, 488 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback,
466 base::Unretained(this), 489 base::Unretained(this),
467 &load_result)); 490 &load_result));
468 PumpLoop(); 491 PumpLoop();
469 } 492 }
470 493
471 } // namespace 494 } // namespace
472 495
473 } // namespace gcm 496 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | google_apis/gcm/gcm_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698