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

Side by Side Diff: components/gcm_driver/crypto/gcm_key_store_unittest.cc

Issue 1948133003: Fix GCMKeyStore interleaved request handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid5default
Patch Set: Address review comments Created 4 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
« no previous file with comments | « components/gcm_driver/crypto/gcm_key_store.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/gcm_driver/crypto/gcm_key_store.h" 5 #include "components/gcm_driver/crypto/gcm_key_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 gcm_key_store()->GetKeys(kFakeAppId, 204 gcm_key_store()->GetKeys(kFakeAppId,
205 base::Bind(&GCMKeyStoreTest::GotKeys, 205 base::Bind(&GCMKeyStoreTest::GotKeys,
206 base::Unretained(this), &read_pair, 206 base::Unretained(this), &read_pair,
207 &read_auth_secret)); 207 &read_auth_secret));
208 208
209 base::RunLoop().RunUntilIdle(); 209 base::RunLoop().RunUntilIdle();
210 210
211 ASSERT_FALSE(read_pair.IsInitialized()); 211 ASSERT_FALSE(read_pair.IsInitialized());
212 } 212 }
213 213
214 TEST_F(GCMKeyStoreTest, CreateAndRemoveKeysSynchronously) {
215 KeyPair pair;
216 std::string auth_secret;
217 gcm_key_store()->CreateKeys(kFakeAppId,
218 base::Bind(&GCMKeyStoreTest::GotKeys,
219 base::Unretained(this), &pair,
220 &auth_secret));
221
222 // Continue synchronously, without running RunUntilIdle first.
223 gcm_key_store()->RemoveKeys(kFakeAppId, base::Bind(&base::DoNothing));
224
225 base::RunLoop().RunUntilIdle();
226
227 ASSERT_TRUE(pair.IsInitialized());
228 EXPECT_TRUE(pair.has_type());
229
230 histogram_tester()->ExpectBucketCount(
231 "GCM.Crypto.RemoveKeySuccessRate", 1, 1); // success
232
233 KeyPair read_pair;
234 std::string read_auth_secret;
235 gcm_key_store()->GetKeys(kFakeAppId,
236 base::Bind(&GCMKeyStoreTest::GotKeys,
237 base::Unretained(this), &read_pair,
238 &read_auth_secret));
239
240 base::RunLoop().RunUntilIdle();
241
242 ASSERT_FALSE(read_pair.IsInitialized());
243 }
244
214 TEST_F(GCMKeyStoreTest, GetKeysMultipleAppIds) { 245 TEST_F(GCMKeyStoreTest, GetKeysMultipleAppIds) {
215 KeyPair pair; 246 KeyPair pair;
216 std::string auth_secret; 247 std::string auth_secret;
217 gcm_key_store()->CreateKeys(kFakeAppId, 248 gcm_key_store()->CreateKeys(kFakeAppId,
218 base::Bind(&GCMKeyStoreTest::GotKeys, 249 base::Bind(&GCMKeyStoreTest::GotKeys,
219 base::Unretained(this), &pair, 250 base::Unretained(this), &pair,
220 &auth_secret)); 251 &auth_secret));
221 252
222 base::RunLoop().RunUntilIdle(); 253 base::RunLoop().RunUntilIdle();
223 254
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // to the asynchronous nature of operations, however, we can't rely on the 301 // to the asynchronous nature of operations, however, we can't rely on the
271 // write to have finished before the read begins. 302 // write to have finished before the read begins.
272 base::RunLoop().RunUntilIdle(); 303 base::RunLoop().RunUntilIdle();
273 304
274 EXPECT_TRUE(pair.IsInitialized()); 305 EXPECT_TRUE(pair.IsInitialized());
275 } 306 }
276 307
277 } // namespace 308 } // namespace
278 309
279 } // namespace gcm 310 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/crypto/gcm_key_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698