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

Unified Diff: chrome/common/extensions/command_unittest.cc

Issue 2888073002: Remove raw DictionaryValue::Set in //chrome (Closed)
Patch Set: Fix Tests 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: chrome/common/extensions/command_unittest.cc
diff --git a/chrome/common/extensions/command_unittest.cc b/chrome/common/extensions/command_unittest.cc
index 5edc4ce21233c082323e69d3da67d63b4389e360..b4f4a2ad721e16f9fe42b25e9ef6f896bf4ecefc 100644
--- a/chrome/common/extensions/command_unittest.cc
+++ b/chrome/common/extensions/command_unittest.cc
@@ -7,8 +7,10 @@
#include <stddef.h>
#include <memory>
+#include <utility>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -72,12 +74,12 @@ void CheckParse(const ConstCommandsTestData& data,
}
input.reset(new base::DictionaryValue);
- base::DictionaryValue* key_dict = new base::DictionaryValue();
+ auto key_dict = base::MakeUnique<base::DictionaryValue>();
for (size_t j = 0; j < platforms.size(); ++j)
key_dict->SetString(platforms[j], data.key);
- input->Set("suggested_key", key_dict);
+ input->Set("suggested_key", std::move(key_dict));
input->SetString("description", data.description);
bool result = command.Parse(input.get(), data.command_name, i, &error);
@@ -207,14 +209,14 @@ TEST(CommandTest, ExtensionCommandParsingFallback) {
// Test that platform specific keys are honored on each platform, despite
// fallback being given.
std::unique_ptr<base::DictionaryValue> input(new base::DictionaryValue);
- base::DictionaryValue* key_dict = new base::DictionaryValue();
- key_dict->SetString("default", "Ctrl+Shift+D");
- key_dict->SetString("windows", "Ctrl+Shift+W");
- key_dict->SetString("mac", "Ctrl+Shift+M");
- key_dict->SetString("linux", "Ctrl+Shift+L");
- key_dict->SetString("chromeos", "Ctrl+Shift+C");
- input->Set("suggested_key", key_dict);
input->SetString("description", description);
+ base::DictionaryValue* key_dict = input->SetDictionary(
+ "suggested_key", base::MakeUnique<base::DictionaryValue>());
+ key_dict->SetString("default", "Ctrl+Shift+D");
+ key_dict->SetString("windows", "Ctrl+Shift+W");
+ key_dict->SetString("mac", "Ctrl+Shift+M");
+ key_dict->SetString("linux", "Ctrl+Shift+L");
+ key_dict->SetString("chromeos", "Ctrl+Shift+C");
extensions::Command command;
base::string16 error;

Powered by Google App Engine
This is Rietveld 408576698