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

Side by Side Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc

Issue 2841623003: Remove base::Value::Get{Buffer,Size} (Closed)
Patch Set: std::vector::assign instead of std::vector::operator= Created 3 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 "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h" 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return ""; 162 return "";
163 } 163 }
164 164
165 const base::Value* result_binary_value; 165 const base::Value* result_binary_value;
166 if (!result_list->GetBinary(0, &result_binary_value) || 166 if (!result_list->GetBinary(0, &result_binary_value) ||
167 !result_binary_value) { 167 !result_binary_value) {
168 LOG(ERROR) << "Result not a binary value."; 168 LOG(ERROR) << "Result not a binary value.";
169 return ""; 169 return "";
170 } 170 }
171 171
172 return std::string(result_binary_value->GetBuffer(), 172 return std::string(result_binary_value->GetBlob().data(),
173 result_binary_value->GetSize()); 173 result_binary_value->GetBlob().size());
174 } 174 }
175 175
176 chromeos::EasyUnlockClient* client_; 176 chromeos::EasyUnlockClient* client_;
177 }; 177 };
178 178
179 TEST_F(EasyUnlockPrivateApiTest, GenerateEcP256KeyPair) { 179 TEST_F(EasyUnlockPrivateApiTest, GenerateEcP256KeyPair) {
180 scoped_refptr<EasyUnlockPrivateGenerateEcP256KeyPairFunction> function( 180 scoped_refptr<EasyUnlockPrivateGenerateEcP256KeyPairFunction> function(
181 new EasyUnlockPrivateGenerateEcP256KeyPairFunction()); 181 new EasyUnlockPrivateGenerateEcP256KeyPairFunction());
182 function->set_has_callback(true); 182 function->set_has_callback(true);
183 183
184 ASSERT_TRUE(extension_function_test_utils::RunFunction( 184 ASSERT_TRUE(extension_function_test_utils::RunFunction(
185 function.get(), 185 function.get(),
186 "[]", 186 "[]",
187 browser(), 187 browser(),
188 extension_function_test_utils::NONE)); 188 extension_function_test_utils::NONE));
189 189
190 const base::ListValue* result_list = function->GetResultList(); 190 const base::ListValue* result_list = function->GetResultList();
191 ASSERT_TRUE(result_list); 191 ASSERT_TRUE(result_list);
192 ASSERT_EQ(2u, result_list->GetSize()); 192 ASSERT_EQ(2u, result_list->GetSize());
193 193
194 const base::Value* public_key; 194 const base::Value* public_key;
195 ASSERT_TRUE(result_list->GetBinary(0, &public_key)); 195 ASSERT_TRUE(result_list->GetBinary(0, &public_key));
196 ASSERT_TRUE(public_key); 196 ASSERT_TRUE(public_key);
197 197
198 const base::Value* private_key; 198 const base::Value* private_key;
199 ASSERT_TRUE(result_list->GetBinary(1, &private_key)); 199 ASSERT_TRUE(result_list->GetBinary(1, &private_key));
200 ASSERT_TRUE(private_key); 200 ASSERT_TRUE(private_key);
201 201
202 EXPECT_TRUE(chromeos::FakeEasyUnlockClient::IsEcP256KeyPair( 202 EXPECT_TRUE(chromeos::FakeEasyUnlockClient::IsEcP256KeyPair(
203 std::string(private_key->GetBuffer(), private_key->GetSize()), 203 std::string(private_key->GetBlob().data(), private_key->GetBlob().size()),
204 std::string(public_key->GetBuffer(), public_key->GetSize()))); 204 std::string(public_key->GetBlob().data(), public_key->GetBlob().size())));
205 } 205 }
206 206
207 TEST_F(EasyUnlockPrivateApiTest, PerformECDHKeyAgreement) { 207 TEST_F(EasyUnlockPrivateApiTest, PerformECDHKeyAgreement) {
208 scoped_refptr<EasyUnlockPrivatePerformECDHKeyAgreementFunction> function( 208 scoped_refptr<EasyUnlockPrivatePerformECDHKeyAgreementFunction> function(
209 new EasyUnlockPrivatePerformECDHKeyAgreementFunction()); 209 new EasyUnlockPrivatePerformECDHKeyAgreementFunction());
210 function->set_has_callback(true); 210 function->set_has_callback(true);
211 211
212 std::string private_key_1; 212 std::string private_key_1;
213 std::string public_key_1_unused; 213 std::string public_key_1_unused;
214 client_->GenerateEcP256KeyPair( 214 client_->GenerateEcP256KeyPair(
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 651
652 scoped_refptr<TestableGetPermitAccessFunction> function( 652 scoped_refptr<TestableGetPermitAccessFunction> function(
653 new TestableGetPermitAccessFunction()); 653 new TestableGetPermitAccessFunction());
654 std::unique_ptr<base::Value> value( 654 std::unique_ptr<base::Value> value(
655 extensions::api_test_utils::RunFunctionAndReturnSingleResult( 655 extensions::api_test_utils::RunFunctionAndReturnSingleResult(
656 function.get(), "[]", profile())); 656 function.get(), "[]", profile()));
657 EXPECT_FALSE(value); 657 EXPECT_FALSE(value);
658 } 658 }
659 659
660 } // namespace 660 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698