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

Side by Side Diff: chrome/common/extensions/command_unittest.cc

Issue 10387224: Rename ExtensionCommand* to Command* within the extension namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/command.cc ('k') | chrome/common/extensions/extension.h » ('j') | 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/extension_commands.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/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 class ExtensionCommandsTest : public testing::Test { 14 class CommandTest : public testing::Test {
15 }; 15 };
16 16
17 TEST(ExtensionCommandsTest, ExtensionCommandParsing) { 17 TEST(CommandTest, ExtensionCommandParsing) {
18 const ui::Accelerator none = ui::Accelerator(); 18 const ui::Accelerator none = ui::Accelerator();
19 const ui::Accelerator shift_f = ui::Accelerator(ui::VKEY_F, 19 const ui::Accelerator shift_f = ui::Accelerator(ui::VKEY_F,
20 ui::EF_SHIFT_DOWN); 20 ui::EF_SHIFT_DOWN);
21 const ui::Accelerator ctrl_f = ui::Accelerator(ui::VKEY_F, 21 const ui::Accelerator ctrl_f = ui::Accelerator(ui::VKEY_F,
22 ui::EF_CONTROL_DOWN); 22 ui::EF_CONTROL_DOWN);
23 const ui::Accelerator alt_f = ui::Accelerator(ui::VKEY_F, ui::EF_ALT_DOWN); 23 const ui::Accelerator alt_f = ui::Accelerator(ui::VKEY_F, ui::EF_ALT_DOWN);
24 const ui::Accelerator ctrl_shift_f = 24 const ui::Accelerator ctrl_shift_f =
25 ui::Accelerator(ui::VKEY_F, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN); 25 ui::Accelerator(ui::VKEY_F, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN);
26 const ui::Accelerator alt_shift_f = 26 const ui::Accelerator alt_shift_f =
27 ui::Accelerator(ui::VKEY_F, ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN); 27 ui::Accelerator(ui::VKEY_F, ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 EXPECT_EQ(kTests[i].expected_result, result); 109 EXPECT_EQ(kTests[i].expected_result, result);
110 if (result) { 110 if (result) {
111 EXPECT_STREQ(kTests[i].description, 111 EXPECT_STREQ(kTests[i].description,
112 UTF16ToASCII(command.description()).c_str()); 112 UTF16ToASCII(command.description()).c_str());
113 EXPECT_STREQ(kTests[i].command_name, command.command_name().c_str()); 113 EXPECT_STREQ(kTests[i].command_name, command.command_name().c_str());
114 EXPECT_EQ(kTests[i].accelerator, command.accelerator()); 114 EXPECT_EQ(kTests[i].accelerator, command.accelerator());
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 TEST(ExtensionCommandsTest, ExtensionCommandParsingFallback) { 119 TEST(CommandTest, ExtensionCommandParsingFallback) {
120 std::string description = "desc"; 120 std::string description = "desc";
121 std::string command_name = "foo"; 121 std::string command_name = "foo";
122 122
123 // Test that platform specific keys are honored on each platform, despite 123 // Test that platform specific keys are honored on each platform, despite
124 // fallback being given. 124 // fallback being given.
125 scoped_ptr<DictionaryValue> input(new DictionaryValue); 125 scoped_ptr<DictionaryValue> input(new DictionaryValue);
126 DictionaryValue* key_dict = new DictionaryValue(); 126 DictionaryValue* key_dict = new DictionaryValue();
127 key_dict->SetString("default", "Ctrl+Shift+D"); 127 key_dict->SetString("default", "Ctrl+Shift+D");
128 key_dict->SetString("windows", "Ctrl+Shift+W"); 128 key_dict->SetString("windows", "Ctrl+Shift+W");
129 key_dict->SetString("mac", "Ctrl+Shift+M"); 129 key_dict->SetString("mac", "Ctrl+Shift+M");
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); 186 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error));
187 187
188 // Make sure Mac specific keys are not processed on other platforms. 188 // Make sure Mac specific keys are not processed on other platforms.
189 #if !defined(OS_MACOSX) 189 #if !defined(OS_MACOSX)
190 key_dict->SetString("windows", "Command+Shift+M"); 190 key_dict->SetString("windows", "Command+Shift+M");
191 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); 191 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error));
192 key_dict->SetString("windows", "Options+Shift+M"); 192 key_dict->SetString("windows", "Options+Shift+M");
193 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); 193 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error));
194 #endif 194 #endif
195 } 195 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/command.cc ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698