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

Unified Diff: components/webcrypto/algorithms/aes_cbc_unittest.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 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 side-by-side diff with in-line comments
Download patch
Index: components/webcrypto/algorithms/aes_cbc_unittest.cc
diff --git a/components/webcrypto/algorithms/aes_cbc_unittest.cc b/components/webcrypto/algorithms/aes_cbc_unittest.cc
index 86c67db984276db22e328cf65a8fae8777fa57e3..88204984a125f0b0bbb45ec627b5b70f37a08d43 100644
--- a/components/webcrypto/algorithms/aes_cbc_unittest.cc
+++ b/components/webcrypto/algorithms/aes_cbc_unittest.cc
@@ -6,7 +6,10 @@
#include <stddef.h>
#include <stdint.h>
+#include <utility>
+
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "components/webcrypto/algorithm_dispatch.h"
#include "components/webcrypto/algorithms/test_helpers.h"
@@ -219,7 +222,7 @@ TEST_F(WebCryptoAesCbcTest, ImportKeyJwkEmptyKeyOps) {
dict.SetString("kty", "oct");
dict.SetBoolean("ext", false);
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg");
- dict.Set("key_ops", new base::ListValue); // Takes ownership.
+ dict.Set("key_ops", base::MakeUnique<base::ListValue>());
// The JWK does not contain encrypt usages.
EXPECT_EQ(Status::ErrorJwkKeyopsInconsistent(),
@@ -260,8 +263,8 @@ TEST_F(WebCryptoAesCbcTest, ImportKeyJwkKeyOpsEncryptDecrypt) {
base::DictionaryValue dict;
dict.SetString("kty", "oct");
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg");
- base::ListValue* key_ops = new base::ListValue;
- dict.Set("key_ops", key_ops); // Takes ownership.
+ base::ListValue* key_ops =
+ dict.SetList("key_ops", base::MakeUnique<base::ListValue>());
key_ops->AppendString("encrypt");
@@ -298,10 +301,9 @@ TEST_F(WebCryptoAesCbcTest, ImportKeyJwkKeyOpsNotSuperset) {
base::DictionaryValue dict;
dict.SetString("kty", "oct");
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg");
- base::ListValue* key_ops = new base::ListValue;
- dict.Set("key_ops", key_ops); // Takes ownership.
-
+ auto key_ops = base::MakeUnique<base::ListValue>();
key_ops->AppendString("encrypt");
+ dict.Set("key_ops", std::move(key_ops));
EXPECT_EQ(
Status::ErrorJwkKeyopsInconsistent(),
@@ -364,10 +366,9 @@ TEST_F(WebCryptoAesCbcTest, ImportJwkKeyOpsLacksUsages) {
dict.SetString("kty", "oct");
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg");
- base::ListValue* key_ops = new base::ListValue;
- // Note: the following call makes dict assume ownership of key_ops.
- dict.Set("key_ops", key_ops);
+ auto key_ops = base::MakeUnique<base::ListValue>();
key_ops->AppendString("foo");
+ dict.Set("key_ops", std::move(key_ops));
EXPECT_EQ(Status::ErrorJwkKeyopsInconsistent(),
ImportKeyJwkFromDict(
dict, CreateAlgorithm(blink::kWebCryptoAlgorithmIdAesCbc),
« no previous file with comments | « components/url_matcher/url_matcher_factory_unittest.cc ('k') | components/webcrypto/algorithms/aes_kw_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698