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

Unified Diff: chrome/browser/extensions/api/commands/command_service_browsertest.cc

Issue 14990002: Make sure keybindings removed don't come back during extension update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moving API calls out of ExtensionPrefs class Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/commands/command_service_browsertest.cc
diff --git a/chrome/browser/extensions/api/commands/command_service_browsertest.cc b/chrome/browser/extensions/api/commands/command_service_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..21c8f0e5ffae26115b1c3dd8241afd58cf04bea6
--- /dev/null
+++ b/chrome/browser/extensions/api/commands/command_service_browsertest.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/commands/command_service.h"
+#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "content/public/test/browser_test.h"
+#include "content/public/test/test_utils.h"
+
+namespace extensions {
+
+typedef ExtensionApiTest CommandServiceTest;
+
+IN_PROC_BROWSER_TEST_F(CommandServiceTest, RemoveShortcutSurvivesUpdate) {
+ base::ScopedTempDir scoped_temp_dir;
+ EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
+ base::FilePath pem_path = test_data_dir_.
+ AppendASCII("keybinding").AppendASCII("keybinding.pem");
+ base::FilePath path_v1 = PackExtensionWithOptions(
+ test_data_dir_.AppendASCII("keybinding").AppendASCII("update")
+ .AppendASCII("v1"),
+ scoped_temp_dir.path().AppendASCII("v1.crx"),
+ pem_path,
+ base::FilePath());
+ base::FilePath path_v2 = PackExtensionWithOptions(
+ test_data_dir_.AppendASCII("keybinding").AppendASCII("update")
+ .AppendASCII("v2"),
+ scoped_temp_dir.path().AppendASCII("v2.crx"),
+ pem_path,
+ base::FilePath());
+
+ ExtensionService* service = ExtensionSystem::Get(browser()->profile())->
+ extension_service();
+ CommandService* command_service = CommandService::Get(browser()->profile());
+
+ const char kId[] = "pgoakhfeplldmjheffidklpoklkppipp";
+
+ // Install v1 of the extension.
+ ASSERT_TRUE(InstallExtension(path_v1, 1));
+ EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL);
+
+ // Verify it has a command of Alt+Shift+F.
+ ui::Accelerator accelerator =
+ command_service->FindShortcutForCommand(
+ kId, extension_manifest_values::kBrowserActionCommandEvent);
+ EXPECT_EQ(ui::VKEY_F, accelerator.key_code());
+ EXPECT_FALSE(accelerator.IsCtrlDown());
+ EXPECT_TRUE(accelerator.IsShiftDown());
+ EXPECT_TRUE(accelerator.IsAltDown());
+
+ // Remove the keybinding.
+ command_service->RemoveKeybindingPrefs(
+ kId, extension_manifest_values::kBrowserActionCommandEvent);
+
+ // Verify it got removed.
+ accelerator = command_service->FindShortcutForCommand(
+ kId, extension_manifest_values::kBrowserActionCommandEvent);
+ EXPECT_EQ(ui::VKEY_UNKNOWN, accelerator.key_code());
+
+ // Update to version 2.
+ EXPECT_TRUE(UpdateExtension(kId, path_v2, 0));
+ EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL);
+
+ // Verify it is still set to nothing.
+ accelerator = command_service->FindShortcutForCommand(
+ kId, extension_manifest_values::kBrowserActionCommandEvent);
+ EXPECT_EQ(ui::VKEY_UNKNOWN, accelerator.key_code());
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/commands/command_service.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698