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/strings/string_util.h" | 8 #include "base/strings/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/features/feature_channel.h" |
11 #include "extensions/common/manifest_constants.h" | 12 #include "extensions/common/manifest_constants.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace extensions { | 15 namespace extensions { |
15 | 16 |
16 namespace errors = manifest_errors; | 17 namespace errors = manifest_errors; |
17 | 18 |
18 class CommandsManifestTest : public ExtensionManifestTest { | 19 class CommandsManifestTest : public ExtensionManifestTest { |
19 }; | 20 }; |
20 | 21 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 scoped_refptr<Extension> extension = | 87 scoped_refptr<Extension> extension = |
87 LoadAndExpectSuccess("browser_action_synthesizes_command.json"); | 88 LoadAndExpectSuccess("browser_action_synthesizes_command.json"); |
88 // An extension with a browser action but no extension command specified | 89 // An extension with a browser action but no extension command specified |
89 // should get a command assigned to it. | 90 // should get a command assigned to it. |
90 const extensions::Command* command = | 91 const extensions::Command* command = |
91 CommandsInfo::GetBrowserActionCommand(extension.get()); | 92 CommandsInfo::GetBrowserActionCommand(extension.get()); |
92 ASSERT_TRUE(command != NULL); | 93 ASSERT_TRUE(command != NULL); |
93 ASSERT_EQ(ui::VKEY_UNKNOWN, command->accelerator().key_code()); | 94 ASSERT_EQ(ui::VKEY_UNKNOWN, command->accelerator().key_code()); |
94 } | 95 } |
95 | 96 |
| 97 // This test makes sure that the "commands" feature and the "commands.global" |
| 98 // property behave as expected on dev and stable (enabled and working on dev, |
| 99 // not working on stable). |
| 100 TEST_F(CommandsManifestTest, ChannelTests) { |
| 101 // This tests the following combinations. |
| 102 // Ext+Command Stable : OK. |
| 103 // Ext+Command+Global Stable : Property is silently ignored (expect success). |
| 104 // App+Command Stable : NOT OK. |
| 105 // App+Command+Global Stable : NOT OK. |
| 106 { |
| 107 std::string warning = "'commands' requires Google Chrome dev channel or " |
| 108 "newer, but this is the stable channel."; |
| 109 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_STABLE); |
| 110 scoped_refptr<Extension> extension1 = |
| 111 LoadAndExpectSuccess("command_ext.json"); |
| 112 scoped_refptr<Extension> extension2 = |
| 113 LoadAndExpectSuccess("command_ext_global.json"); |
| 114 LoadAndExpectWarning("command_app.json", warning); |
| 115 LoadAndExpectWarning("command_app_global.json", warning); |
| 116 } |
| 117 |
| 118 // Ext+Command Dev : OK. |
| 119 // App+Command Dev : OK. |
| 120 // Ext+Command+Global Dev : OK. |
| 121 // App+Command+Global Dev : OK. |
| 122 { |
| 123 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); |
| 124 scoped_refptr<Extension> extension1 = |
| 125 LoadAndExpectSuccess("command_ext.json"); |
| 126 scoped_refptr<Extension> extension2 = |
| 127 LoadAndExpectSuccess("command_app.json"); |
| 128 scoped_refptr<Extension> extension3 = |
| 129 LoadAndExpectSuccess("command_ext_global.json"); |
| 130 scoped_refptr<Extension> extension4 = |
| 131 LoadAndExpectSuccess("command_app_global.json"); |
| 132 } |
| 133 } |
| 134 |
96 } // namespace extensions | 135 } // namespace extensions |
OLD | NEW |