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

Unified Diff: chrome/common/extensions/api/commands/commands_manifest_unittest.cc

Issue 11662013: Move Commands from Extension to CommandsHandler (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_script_badge
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/api/commands/commands_manifest_unittest.cc
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_command_unittest.cc b/chrome/common/extensions/api/commands/commands_manifest_unittest.cc
similarity index 66%
rename from chrome/common/extensions/manifest_tests/extension_manifests_command_unittest.cc
rename to chrome/common/extensions/api/commands/commands_manifest_unittest.cc
index a9e4ffb0d7540486ebf969fd1a6487c06ad2f64a..38c32a06d0acaadda3ebb81e76e76549d7d169e9 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_command_unittest.cc
+++ b/chrome/common/extensions/api/commands/commands_manifest_unittest.cc
@@ -7,12 +7,24 @@
#include "base/command_line.h"
#include "base/string_util.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/api/commands/commands_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace errors = extension_manifest_errors;
-TEST_F(ExtensionManifestTest, CommandManifestSimple) {
+namespace extensions {
+
+class CommandsManifestTest : public ExtensionManifestTest {
+ protected:
+ virtual void SetUp() OVERRIDE {
+ ManifestHandler::Register(extension_manifest_keys::kCommands,
+ new CommandsHandler);
+ }
+};
+
+TEST_F(CommandsManifestTest, CommandManifestSimple) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
@@ -28,29 +40,29 @@ TEST_F(ExtensionManifestTest, CommandManifestSimple) {
const ui::Accelerator alt_shift_f =
ui::Accelerator(ui::VKEY_F, ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN);
- scoped_refptr<extensions::Extension> extension =
+ scoped_refptr<Extension> extension =
LoadAndExpectSuccess("command_simple.json");
ASSERT_TRUE(extension);
- const extensions::CommandMap& commands = extension->named_commands();
- ASSERT_EQ(1u, commands.size());
- extensions::CommandMap::const_iterator iter = commands.begin();
- ASSERT_TRUE(commands.end() != iter);
- const extensions::Command* named_command = &(*iter).second;
+ const CommandMap* commands = CommandsInfo::GetNamedCommands(extension);
+ ASSERT_TRUE(commands);
+ ASSERT_EQ(1u, commands->size());
+ CommandMap::const_iterator iter = commands->begin();
+ ASSERT_TRUE(commands->end() != iter);
+ const Command* named_command = &(*iter).second;
ASSERT_STREQ("feature1", named_command->command_name().c_str());
ASSERT_STREQ("desc", UTF16ToASCII(named_command->description()).c_str());
ASSERT_EQ(ctrl_shift_f, named_command->accelerator());
- const extensions::Command* browser_action =
- extension->browser_action_command();
+ const Command* browser_action =
+ CommandsInfo::GetBrowserActionCommand(extension);
ASSERT_TRUE(NULL != browser_action);
ASSERT_STREQ("_execute_browser_action",
browser_action->command_name().c_str());
ASSERT_STREQ("", UTF16ToASCII(browser_action->description()).c_str());
ASSERT_EQ(alt_shift_f, browser_action->accelerator());
- const extensions::Command* page_action =
- extension->page_action_command();
+ const Command* page_action = CommandsInfo::GetPageActionCommand(extension);
ASSERT_TRUE(NULL != page_action);
ASSERT_STREQ("_execute_page_action",
page_action->command_name().c_str());
@@ -58,7 +70,7 @@ TEST_F(ExtensionManifestTest, CommandManifestSimple) {
ASSERT_EQ(ctrl_f, page_action->accelerator());
}
-TEST_F(ExtensionManifestTest, CommandManifestTooMany) {
+TEST_F(CommandsManifestTest, CommandManifestTooMany) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
@@ -66,18 +78,20 @@ TEST_F(ExtensionManifestTest, CommandManifestTooMany) {
errors::kInvalidKeyBindingTooMany);
}
-TEST_F(ExtensionManifestTest, CommandManifestAllowNumbers) {
+TEST_F(CommandsManifestTest, CommandManifestAllowNumbers) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
- scoped_refptr<extensions::Extension> extension =
+ scoped_refptr<Extension> extension =
LoadAndExpectSuccess("command_allow_numbers.json");
}
-TEST_F(ExtensionManifestTest, CommandManifestRejectJustShift) {
+TEST_F(CommandsManifestTest, CommandManifestRejectJustShift) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
LoadAndExpectError("command_reject_just_shift.json",
errors::kInvalidKeyBinding);
}
+
+} // namespace extensions
« no previous file with comments | « chrome/common/extensions/api/commands/commands_handler.cc ('k') | chrome/common/extensions/api/omnibox/omnibox_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698