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: chrome/common/extensions/command_unittest.cc

Issue 493903003: Fix a leak in a test from r291170. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/common/extensions/command.h" 5 #include "chrome/common/extensions/command.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 if (result) { 49 if (result) {
50 EXPECT_STREQ(data.description, 50 EXPECT_STREQ(data.description,
51 base::UTF16ToASCII(command.description()).c_str()); 51 base::UTF16ToASCII(command.description()).c_str());
52 EXPECT_STREQ(data.command_name, command.command_name().c_str()); 52 EXPECT_STREQ(data.command_name, command.command_name().c_str());
53 EXPECT_EQ(data.accelerator, command.accelerator()); 53 EXPECT_EQ(data.accelerator, command.accelerator());
54 } 54 }
55 } 55 }
56 56
57 // Now, test the parse of a platform dictionary suggested_key value. 57 // Now, test the parse of a platform dictionary suggested_key value.
58 if (data.key[0] != '\0') { 58 if (data.key[0] != '\0') {
59 input.reset(new base::DictionaryValue);
60 base::DictionaryValue* key_dict = new base::DictionaryValue();
61
62 for (size_t j = 0; j < platforms.size(); ++j)
63 key_dict->SetString(platforms[j], data.key);
64
65 std::string current_platform = extensions::Command::CommandPlatform(); 59 std::string current_platform = extensions::Command::CommandPlatform();
66 if (platform_specific_only && 60 if (platform_specific_only &&
67 std::find(platforms.begin(), platforms.end(), current_platform) == 61 std::find(platforms.begin(), platforms.end(), current_platform) ==
68 platforms.end()) { 62 platforms.end()) {
69 // Given a |current_platform| without a |suggested_key|, |default| is 63 // Given a |current_platform| without a |suggested_key|, |default| is
70 // used. However, some keys, such as Search on Chrome OS, are only valid 64 // used. However, some keys, such as Search on Chrome OS, are only valid
71 // for platform specific entries. Skip the test in this case. 65 // for platform specific entries. Skip the test in this case.
72 return; 66 return;
73 } 67 }
74 68
69 input.reset(new base::DictionaryValue);
70 base::DictionaryValue* key_dict = new base::DictionaryValue();
71
72 for (size_t j = 0; j < platforms.size(); ++j)
73 key_dict->SetString(platforms[j], data.key);
74
75 input->Set("suggested_key", key_dict); 75 input->Set("suggested_key", key_dict);
76 input->SetString("description", data.description); 76 input->SetString("description", data.description);
77 77
78 bool result = command.Parse(input.get(), data.command_name, i, &error); 78 bool result = command.Parse(input.get(), data.command_name, i, &error);
79 EXPECT_EQ(data.expected_result, result); 79 EXPECT_EQ(data.expected_result, result);
80 80
81 if (result) { 81 if (result) {
82 EXPECT_STREQ(data.description, 82 EXPECT_STREQ(data.description,
83 base::UTF16ToASCII(command.description()).c_str()); 83 base::UTF16ToASCII(command.description()).c_str());
84 EXPECT_STREQ(data.command_name, command.command_name().c_str()); 84 EXPECT_STREQ(data.command_name, command.command_name().c_str());
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 }; 301 };
302 std::vector<std::string> non_chromeos; 302 std::vector<std::string> non_chromeos;
303 non_chromeos.push_back("default"); 303 non_chromeos.push_back("default");
304 non_chromeos.push_back("windows"); 304 non_chromeos.push_back("windows");
305 non_chromeos.push_back("mac"); 305 non_chromeos.push_back("mac");
306 non_chromeos.push_back("linux"); 306 non_chromeos.push_back("linux");
307 307
308 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kNonChromeOsSearchTests); ++i) 308 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kNonChromeOsSearchTests); ++i)
309 CheckParse(kNonChromeOsSearchTests[i], i, true, non_chromeos); 309 CheckParse(kNonChromeOsSearchTests[i], i, true, non_chromeos);
310 } 310 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698