OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 scoped_ptr<base::DictionaryValue> input(new base::DictionaryValue); | 123 scoped_ptr<base::DictionaryValue> input(new base::DictionaryValue); |
124 input->SetString("suggested_key", kTests[i].key); | 124 input->SetString("suggested_key", kTests[i].key); |
125 input->SetString("description", kTests[i].description); | 125 input->SetString("description", kTests[i].description); |
126 | 126 |
127 SCOPED_TRACE(std::string("Command name: |") + kTests[i].command_name + | 127 SCOPED_TRACE(std::string("Command name: |") + kTests[i].command_name + |
128 "| key: |" + kTests[i].key + | 128 "| key: |" + kTests[i].key + |
129 "| description: |" + kTests[i].description + | 129 "| description: |" + kTests[i].description + |
130 "| index: " + base::IntToString(i)); | 130 "| index: " + base::IntToString(i)); |
131 | 131 |
132 extensions::Command command; | 132 extensions::Command command; |
133 string16 error; | 133 base::string16 error; |
134 bool result = | 134 bool result = |
135 command.Parse(input.get(), kTests[i].command_name, i, &error); | 135 command.Parse(input.get(), kTests[i].command_name, i, &error); |
136 | 136 |
137 EXPECT_EQ(kTests[i].expected_result, result); | 137 EXPECT_EQ(kTests[i].expected_result, result); |
138 if (result) { | 138 if (result) { |
139 EXPECT_STREQ(kTests[i].description, | 139 EXPECT_STREQ(kTests[i].description, |
140 UTF16ToASCII(command.description()).c_str()); | 140 UTF16ToASCII(command.description()).c_str()); |
141 EXPECT_STREQ(kTests[i].command_name, command.command_name().c_str()); | 141 EXPECT_STREQ(kTests[i].command_name, command.command_name().c_str()); |
142 EXPECT_EQ(kTests[i].accelerator, command.accelerator()); | 142 EXPECT_EQ(kTests[i].accelerator, command.accelerator()); |
143 } | 143 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 base::DictionaryValue* key_dict = new base::DictionaryValue(); | 175 base::DictionaryValue* key_dict = new base::DictionaryValue(); |
176 key_dict->SetString("default", "Ctrl+Shift+D"); | 176 key_dict->SetString("default", "Ctrl+Shift+D"); |
177 key_dict->SetString("windows", "Ctrl+Shift+W"); | 177 key_dict->SetString("windows", "Ctrl+Shift+W"); |
178 key_dict->SetString("mac", "Ctrl+Shift+M"); | 178 key_dict->SetString("mac", "Ctrl+Shift+M"); |
179 key_dict->SetString("linux", "Ctrl+Shift+L"); | 179 key_dict->SetString("linux", "Ctrl+Shift+L"); |
180 key_dict->SetString("chromeos", "Ctrl+Shift+C"); | 180 key_dict->SetString("chromeos", "Ctrl+Shift+C"); |
181 input->Set("suggested_key", key_dict); | 181 input->Set("suggested_key", key_dict); |
182 input->SetString("description", description); | 182 input->SetString("description", description); |
183 | 183 |
184 extensions::Command command; | 184 extensions::Command command; |
185 string16 error; | 185 base::string16 error; |
186 EXPECT_TRUE(command.Parse(input.get(), command_name, 0, &error)); | 186 EXPECT_TRUE(command.Parse(input.get(), command_name, 0, &error)); |
187 EXPECT_STREQ(description.c_str(), | 187 EXPECT_STREQ(description.c_str(), |
188 UTF16ToASCII(command.description()).c_str()); | 188 UTF16ToASCII(command.description()).c_str()); |
189 EXPECT_STREQ(command_name.c_str(), command.command_name().c_str()); | 189 EXPECT_STREQ(command_name.c_str(), command.command_name().c_str()); |
190 | 190 |
191 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
192 ui::Accelerator accelerator(ui::VKEY_W, | 192 ui::Accelerator accelerator(ui::VKEY_W, |
193 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); | 193 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
194 #elif defined(OS_MACOSX) | 194 #elif defined(OS_MACOSX) |
195 ui::Accelerator accelerator(ui::VKEY_M, | 195 ui::Accelerator accelerator(ui::VKEY_M, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 key_dict->SetString("windows", "Ctrl+Shift+W"); | 241 key_dict->SetString("windows", "Ctrl+Shift+W"); |
242 #endif | 242 #endif |
243 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); | 243 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); |
244 | 244 |
245 // Make sure Mac specific keys are not processed on other platforms. | 245 // Make sure Mac specific keys are not processed on other platforms. |
246 #if !defined(OS_MACOSX) | 246 #if !defined(OS_MACOSX) |
247 key_dict->SetString("windows", "Command+Shift+M"); | 247 key_dict->SetString("windows", "Command+Shift+M"); |
248 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); | 248 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); |
249 #endif | 249 #endif |
250 } | 250 } |
OLD | NEW |