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

Side by Side Diff: third_party/libaddressinput/chromium/storage_test_runner.cc

Issue 1911823002: Convert //third_party from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update crashpad's README.chromium 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 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 "third_party/libaddressinput/chromium/storage_test_runner.h" 5 #include "third_party/libaddressinput/chromium/storage_test_runner.h"
6 6
7 #include <cassert> 7 #include <cassert>
8 #include <cstddef> 8 #include <cstddef>
9 #include <string> 9 #include <string>
10 10
(...skipping 17 matching lines...) Expand all
28 EXPECT_NO_FATAL_FAILURE(GetReturnsWhatWasPut()); 28 EXPECT_NO_FATAL_FAILURE(GetReturnsWhatWasPut());
29 EXPECT_NO_FATAL_FAILURE(SecondPutOverwritesData()); 29 EXPECT_NO_FATAL_FAILURE(SecondPutOverwritesData());
30 } 30 }
31 31
32 void StorageTestRunner::ClearValues() { 32 void StorageTestRunner::ClearValues() {
33 success_ = false; 33 success_ = false;
34 key_.clear(); 34 key_.clear();
35 data_.clear(); 35 data_.clear();
36 } 36 }
37 37
38 scoped_ptr<Storage::Callback> StorageTestRunner::BuildCallback() { 38 std::unique_ptr<Storage::Callback> StorageTestRunner::BuildCallback() {
39 return scoped_ptr<Storage::Callback>(::i18n::addressinput::BuildCallback( 39 return std::unique_ptr<Storage::Callback>(::i18n::addressinput::BuildCallback(
40 this, &StorageTestRunner::OnDataReady)); 40 this, &StorageTestRunner::OnDataReady));
41 } 41 }
42 42
43 void StorageTestRunner::OnDataReady(bool success, 43 void StorageTestRunner::OnDataReady(bool success,
44 const std::string& key, 44 const std::string& key,
45 std::string* data) { 45 std::string* data) {
46 assert(!success || data != NULL); 46 assert(!success || data != NULL);
47 success_ = success; 47 success_ = success;
48 key_ = key; 48 key_ = key;
49 if (data != NULL) { 49 if (data != NULL) {
50 data_ = *data; 50 data_ = *data;
51 delete data; 51 delete data;
52 } 52 }
53 } 53 }
54 54
55 void StorageTestRunner::GetWithoutPutReturnsEmptyData() { 55 void StorageTestRunner::GetWithoutPutReturnsEmptyData() {
56 ClearValues(); 56 ClearValues();
57 scoped_ptr<Storage::Callback> callback(BuildCallback()); 57 std::unique_ptr<Storage::Callback> callback(BuildCallback());
58 storage_->Get("key", *callback); 58 storage_->Get("key", *callback);
59 59
60 EXPECT_FALSE(success_); 60 EXPECT_FALSE(success_);
61 EXPECT_EQ("key", key_); 61 EXPECT_EQ("key", key_);
62 EXPECT_TRUE(data_.empty()); 62 EXPECT_TRUE(data_.empty());
63 } 63 }
64 64
65 void StorageTestRunner::GetReturnsWhatWasPut() { 65 void StorageTestRunner::GetReturnsWhatWasPut() {
66 ClearValues(); 66 ClearValues();
67 storage_->Put("key", new std::string("value")); 67 storage_->Put("key", new std::string("value"));
68 scoped_ptr<Storage::Callback> callback(BuildCallback()); 68 std::unique_ptr<Storage::Callback> callback(BuildCallback());
69 storage_->Get("key", *callback); 69 storage_->Get("key", *callback);
70 70
71 EXPECT_TRUE(success_); 71 EXPECT_TRUE(success_);
72 EXPECT_EQ("key", key_); 72 EXPECT_EQ("key", key_);
73 EXPECT_EQ("value", data_); 73 EXPECT_EQ("value", data_);
74 } 74 }
75 75
76 void StorageTestRunner::SecondPutOverwritesData() { 76 void StorageTestRunner::SecondPutOverwritesData() {
77 ClearValues(); 77 ClearValues();
78 storage_->Put("key", new std::string("bad-value")); 78 storage_->Put("key", new std::string("bad-value"));
79 storage_->Put("key", new std::string("good-value")); 79 storage_->Put("key", new std::string("good-value"));
80 scoped_ptr<Storage::Callback> callback(BuildCallback()); 80 std::unique_ptr<Storage::Callback> callback(BuildCallback());
81 storage_->Get("key", *callback); 81 storage_->Get("key", *callback);
82 82
83 EXPECT_TRUE(success_); 83 EXPECT_TRUE(success_);
84 EXPECT_EQ("key", key_); 84 EXPECT_EQ("key", key_);
85 EXPECT_EQ("good-value", data_); 85 EXPECT_EQ("good-value", data_);
86 } 86 }
87 87
88 } // namespace autofill 88 } // namespace autofill
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/storage_test_runner.h ('k') | third_party/libaddressinput/chromium/string_compare.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698