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/extension_commands.h" | 5 #include "chrome/common/extensions/extension_commands.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/values.h" | 9 #include "base/values.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 input->Set("suggested_key", key_dict); | 128 input->Set("suggested_key", key_dict); |
129 input->SetString("description", description); | 129 input->SetString("description", description); |
130 | 130 |
131 extensions::Command command; | 131 extensions::Command command; |
132 string16 error; | 132 string16 error; |
133 EXPECT_TRUE(command.Parse(input.get(), command_name, 0, &error)); | 133 EXPECT_TRUE(command.Parse(input.get(), command_name, 0, &error)); |
134 EXPECT_STREQ(description.c_str(), command.description().c_str()); | 134 EXPECT_STREQ(description.c_str(), command.description().c_str()); |
135 EXPECT_STREQ(command_name.c_str(), command.command_name().c_str()); | 135 EXPECT_STREQ(command_name.c_str(), command.command_name().c_str()); |
136 | 136 |
137 #if defined(OS_WIN) | 137 #if defined(OS_WIN) |
138 ui::Accelerator accelerator(ui::VKEY_W, true, true, false); | 138 ui::Accelerator accelerator(ui::VKEY_W, |
| 139 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
139 #elif defined(OS_MACOSX) | 140 #elif defined(OS_MACOSX) |
140 ui::Accelerator accelerator(ui::VKEY_M, true, true, false); | 141 ui::Accelerator accelerator(ui::VKEY_M, |
| 142 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
141 #elif defined(OS_CHROMEOS) | 143 #elif defined(OS_CHROMEOS) |
142 ui::Accelerator accelerator(ui::VKEY_C, true, true, false); | 144 ui::Accelerator accelerator(ui::VKEY_C, |
| 145 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
143 #elif defined(OS_LINUX) | 146 #elif defined(OS_LINUX) |
144 ui::Accelerator accelerator(ui::VKEY_L, true, true, false); | 147 ui::Accelerator accelerator(ui::VKEY_L, |
| 148 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
145 #else | 149 #else |
146 ui::Accelerator accelerator(ui::VKEY_D, true, true, false); | 150 ui::Accelerator accelerator(ui::VKEY_D, |
| 151 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
147 #endif | 152 #endif |
148 EXPECT_EQ(accelerator, command.accelerator()); | 153 EXPECT_EQ(accelerator, command.accelerator()); |
149 | 154 |
150 // Misspell a platform. | 155 // Misspell a platform. |
151 key_dict->SetString("windosw", "Ctrl+M"); | 156 key_dict->SetString("windosw", "Ctrl+M"); |
152 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); | 157 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); |
153 EXPECT_TRUE(key_dict->Remove("windosw", NULL)); | 158 EXPECT_TRUE(key_dict->Remove("windosw", NULL)); |
154 | 159 |
155 // Now remove platform specific keys (leaving just "default") and make sure | 160 // Now remove platform specific keys (leaving just "default") and make sure |
156 // every platform falls back to the default. | 161 // every platform falls back to the default. |
(...skipping 19 matching lines...) Expand all Loading... |
176 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); | 181 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); |
177 | 182 |
178 // Make sure Mac specific keys are not processed on other platforms. | 183 // Make sure Mac specific keys are not processed on other platforms. |
179 #if !defined(OS_MACOSX) | 184 #if !defined(OS_MACOSX) |
180 key_dict->SetString("windows", "Command+Shift+M"); | 185 key_dict->SetString("windows", "Command+Shift+M"); |
181 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); | 186 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); |
182 key_dict->SetString("windows", "Options+Shift+M"); | 187 key_dict->SetString("windows", "Options+Shift+M"); |
183 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); | 188 EXPECT_FALSE(command.Parse(input.get(), command_name, 0, &error)); |
184 #endif | 189 #endif |
185 } | 190 } |
OLD | NEW |