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/manifest_tests/extension_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/extensions/api/commands/commands_handler.h" | 10 #include "chrome/common/extensions/api/commands/commands_handler.h" |
11 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" | |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 | 12 |
14 namespace errors = extension_manifest_errors; | 13 namespace errors = extension_manifest_errors; |
15 | 14 |
16 namespace extensions { | 15 namespace extensions { |
17 | 16 |
18 class CommandsManifestTest : public ExtensionManifestTest { | 17 class CommandsManifestTest : public ExtensionManifestTest { |
19 protected: | |
20 virtual void SetUp() OVERRIDE { | |
21 (new CommandsHandler)->Register(); | |
22 } | |
23 }; | 18 }; |
24 | 19 |
25 TEST_F(CommandsManifestTest, CommandManifestSimple) { | 20 TEST_F(CommandsManifestTest, CommandManifestSimple) { |
26 #if defined(OS_MACOSX) | 21 #if defined(OS_MACOSX) |
27 int ctrl = ui::EF_COMMAND_DOWN; | 22 int ctrl = ui::EF_COMMAND_DOWN; |
28 #else | 23 #else |
29 int ctrl = ui::EF_CONTROL_DOWN; | 24 int ctrl = ui::EF_CONTROL_DOWN; |
30 #endif | 25 #endif |
31 | 26 |
32 const ui::Accelerator ctrl_f = ui::Accelerator(ui::VKEY_F, ctrl); | 27 const ui::Accelerator ctrl_f = ui::Accelerator(ui::VKEY_F, ctrl); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 scoped_refptr<Extension> extension = | 74 scoped_refptr<Extension> extension = |
80 LoadAndExpectSuccess("command_allow_numbers.json"); | 75 LoadAndExpectSuccess("command_allow_numbers.json"); |
81 } | 76 } |
82 | 77 |
83 TEST_F(CommandsManifestTest, CommandManifestRejectJustShift) { | 78 TEST_F(CommandsManifestTest, CommandManifestRejectJustShift) { |
84 LoadAndExpectError("command_reject_just_shift.json", | 79 LoadAndExpectError("command_reject_just_shift.json", |
85 errors::kInvalidKeyBinding); | 80 errors::kInvalidKeyBinding); |
86 } | 81 } |
87 | 82 |
88 TEST_F(CommandsManifestTest, BrowserActionSynthesizesCommand) { | 83 TEST_F(CommandsManifestTest, BrowserActionSynthesizesCommand) { |
89 (new BrowserActionHandler)->Register(); | |
90 scoped_refptr<Extension> extension = | 84 scoped_refptr<Extension> extension = |
91 LoadAndExpectSuccess("browser_action_synthesizes_command.json"); | 85 LoadAndExpectSuccess("browser_action_synthesizes_command.json"); |
92 // An extension with a browser action but no extension command specified | 86 // An extension with a browser action but no extension command specified |
93 // should get a command assigned to it. | 87 // should get a command assigned to it. |
94 const extensions::Command* command = | 88 const extensions::Command* command = |
95 CommandsInfo::GetBrowserActionCommand(extension); | 89 CommandsInfo::GetBrowserActionCommand(extension); |
96 ASSERT_TRUE(command != NULL); | 90 ASSERT_TRUE(command != NULL); |
97 ASSERT_EQ(ui::VKEY_UNKNOWN, command->accelerator().key_code()); | 91 ASSERT_EQ(ui::VKEY_UNKNOWN, command->accelerator().key_code()); |
98 } | 92 } |
99 | 93 |
100 } // namespace extensions | 94 } // namespace extensions |
OLD | NEW |