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

Side by Side Diff: sync/internal_api/sync_encryption_handler_impl_unittest.cc

Issue 1866243002: Convert //sync from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "sync/internal_api/sync_encryption_handler_impl.h" 5 #include "sync/internal_api/sync_encryption_handler_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory>
9 #include <string> 10 #include <string>
10 11
11 #include "base/base64.h" 12 #include "base/base64.h"
12 #include "base/json/json_string_value_serializer.h" 13 #include "base/json/json_string_value_serializer.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/tracked_objects.h" 15 #include "base/tracked_objects.h"
16 #include "sync/internal_api/public/base/model_type_test_util.h" 16 #include "sync/internal_api/public/base/model_type_test_util.h"
17 #include "sync/internal_api/public/read_node.h" 17 #include "sync/internal_api/public/read_node.h"
18 #include "sync/internal_api/public/read_transaction.h" 18 #include "sync/internal_api/public/read_transaction.h"
19 #include "sync/internal_api/public/test/test_user_share.h" 19 #include "sync/internal_api/public/test/test_user_share.h"
20 #include "sync/internal_api/public/write_node.h" 20 #include "sync/internal_api/public/write_node.h"
21 #include "sync/internal_api/public/write_transaction.h" 21 #include "sync/internal_api/public/write_transaction.h"
22 #include "sync/protocol/nigori_specifics.pb.h" 22 #include "sync/protocol/nigori_specifics.pb.h"
23 #include "sync/protocol/sync.pb.h" 23 #include "sync/protocol/sync.pb.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 encryption_handler()->RestoreNigori(nigori_state); 361 encryption_handler()->RestoreNigori(nigori_state);
362 encryption_handler()->Init(); 362 encryption_handler()->Init();
363 Mock::VerifyAndClearExpectations(observer()); 363 Mock::VerifyAndClearExpectations(observer());
364 VerifyMigratedNigoriWithTimestamp(migration_time, passphrase_type, 364 VerifyMigratedNigoriWithTimestamp(migration_time, passphrase_type,
365 passphrase); 365 passphrase);
366 } 366 }
367 367
368 protected: 368 protected:
369 TestUserShare test_user_share_; 369 TestUserShare test_user_share_;
370 FakeEncryptor encryptor_; 370 FakeEncryptor encryptor_;
371 scoped_ptr<SyncEncryptionHandlerImpl> encryption_handler_; 371 std::unique_ptr<SyncEncryptionHandlerImpl> encryption_handler_;
372 StrictMock<SyncEncryptionHandlerObserverMock> observer_; 372 StrictMock<SyncEncryptionHandlerObserverMock> observer_;
373 TestIdFactory ids_; 373 TestIdFactory ids_;
374 base::MessageLoop message_loop_; 374 base::MessageLoop message_loop_;
375 }; 375 };
376 376
377 // Verify that the encrypted types are being written to and read from the 377 // Verify that the encrypted types are being written to and read from the
378 // nigori node properly. 378 // nigori node properly.
379 TEST_F(SyncEncryptionHandlerImplTest, NigoriEncryptionTypes) { 379 TEST_F(SyncEncryptionHandlerImplTest, NigoriEncryptionTypes) {
380 sync_pb::NigoriSpecifics nigori; 380 sync_pb::NigoriSpecifics nigori;
381 381
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 // Ensure the bootstrap is encoded properly (a base64 encoded encrypted blob 693 // Ensure the bootstrap is encoded properly (a base64 encoded encrypted blob
694 // of list values containing the keystore keys). 694 // of list values containing the keystore keys).
695 std::string decoded_bootstrap; 695 std::string decoded_bootstrap;
696 ASSERT_TRUE(base::Base64Decode(keystore_bootstrap, &decoded_bootstrap)); 696 ASSERT_TRUE(base::Base64Decode(keystore_bootstrap, &decoded_bootstrap));
697 std::string decrypted_bootstrap; 697 std::string decrypted_bootstrap;
698 ASSERT_TRUE( 698 ASSERT_TRUE(
699 GetCryptographer()->encryptor()->DecryptString(decoded_bootstrap, 699 GetCryptographer()->encryptor()->DecryptString(decoded_bootstrap,
700 &decrypted_bootstrap)); 700 &decrypted_bootstrap));
701 JSONStringValueDeserializer json(decrypted_bootstrap); 701 JSONStringValueDeserializer json(decrypted_bootstrap);
702 scoped_ptr<base::Value> deserialized_keystore_keys( 702 std::unique_ptr<base::Value> deserialized_keystore_keys(
703 json.Deserialize(NULL, NULL)); 703 json.Deserialize(NULL, NULL));
704 ASSERT_TRUE(deserialized_keystore_keys.get()); 704 ASSERT_TRUE(deserialized_keystore_keys.get());
705 base::ListValue* keystore_list = NULL; 705 base::ListValue* keystore_list = NULL;
706 deserialized_keystore_keys->GetAsList(&keystore_list); 706 deserialized_keystore_keys->GetAsList(&keystore_list);
707 ASSERT_TRUE(keystore_list); 707 ASSERT_TRUE(keystore_list);
708 ASSERT_EQ(2U, keystore_list->GetSize()); 708 ASSERT_EQ(2U, keystore_list->GetSize());
709 std::string test_string; 709 std::string test_string;
710 keystore_list->GetString(0, &test_string); 710 keystore_list->GetString(0, &test_string);
711 ASSERT_EQ(old_keystore_key, test_string); 711 ASSERT_EQ(old_keystore_key, test_string);
712 keystore_list->GetString(1, &test_string); 712 keystore_list->GetString(1, &test_string);
(...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN)); 2495 OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN));
2496 { 2496 {
2497 ReadTransaction trans(FROM_HERE, user_share()); 2497 ReadTransaction trans(FROM_HERE, user_share());
2498 encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto( 2498 encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto(
2499 kRawKeystoreKey), 2499 kRawKeystoreKey),
2500 trans.GetWrappedTrans()); 2500 trans.GetWrappedTrans());
2501 } 2501 }
2502 } 2502 }
2503 2503
2504 } // namespace syncer 2504 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698