| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/extensions/api/commands/command_service.h" | 5 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 9 #include "content/public/test/browser_test.h" | 8 #include "content/public/test/browser_test.h" |
| 10 #include "content/public/test/test_utils.h" | 9 #include "content/public/test/test_utils.h" |
| 10 #include "extensions/common/manifest_constants.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 typedef ExtensionApiTest CommandServiceTest; | 14 typedef ExtensionApiTest CommandServiceTest; |
| 15 | 15 |
| 16 IN_PROC_BROWSER_TEST_F(CommandServiceTest, RemoveShortcutSurvivesUpdate) { | 16 IN_PROC_BROWSER_TEST_F(CommandServiceTest, RemoveShortcutSurvivesUpdate) { |
| 17 base::ScopedTempDir scoped_temp_dir; | 17 base::ScopedTempDir scoped_temp_dir; |
| 18 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); | 18 EXPECT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); |
| 19 base::FilePath pem_path = test_data_dir_. | 19 base::FilePath pem_path = test_data_dir_. |
| 20 AppendASCII("keybinding").AppendASCII("keybinding.pem"); | 20 AppendASCII("keybinding").AppendASCII("keybinding.pem"); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 const char kId[] = "pgoakhfeplldmjheffidklpoklkppipp"; | 38 const char kId[] = "pgoakhfeplldmjheffidklpoklkppipp"; |
| 39 | 39 |
| 40 // Install v1 of the extension. | 40 // Install v1 of the extension. |
| 41 ASSERT_TRUE(InstallExtension(path_v1, 1)); | 41 ASSERT_TRUE(InstallExtension(path_v1, 1)); |
| 42 EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL); | 42 EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL); |
| 43 | 43 |
| 44 // Verify it has a command of Alt+Shift+F. | 44 // Verify it has a command of Alt+Shift+F. |
| 45 ui::Accelerator accelerator = | 45 ui::Accelerator accelerator = |
| 46 command_service->FindShortcutForCommand( | 46 command_service->FindShortcutForCommand( |
| 47 kId, extension_manifest_values::kBrowserActionCommandEvent); | 47 kId, manifest_values::kBrowserActionCommandEvent); |
| 48 EXPECT_EQ(ui::VKEY_F, accelerator.key_code()); | 48 EXPECT_EQ(ui::VKEY_F, accelerator.key_code()); |
| 49 EXPECT_FALSE(accelerator.IsCtrlDown()); | 49 EXPECT_FALSE(accelerator.IsCtrlDown()); |
| 50 EXPECT_TRUE(accelerator.IsShiftDown()); | 50 EXPECT_TRUE(accelerator.IsShiftDown()); |
| 51 EXPECT_TRUE(accelerator.IsAltDown()); | 51 EXPECT_TRUE(accelerator.IsAltDown()); |
| 52 | 52 |
| 53 // Remove the keybinding. | 53 // Remove the keybinding. |
| 54 command_service->RemoveKeybindingPrefs( | 54 command_service->RemoveKeybindingPrefs( |
| 55 kId, extension_manifest_values::kBrowserActionCommandEvent); | 55 kId, manifest_values::kBrowserActionCommandEvent); |
| 56 | 56 |
| 57 // Verify it got removed. | 57 // Verify it got removed. |
| 58 accelerator = command_service->FindShortcutForCommand( | 58 accelerator = command_service->FindShortcutForCommand( |
| 59 kId, extension_manifest_values::kBrowserActionCommandEvent); | 59 kId, manifest_values::kBrowserActionCommandEvent); |
| 60 EXPECT_EQ(ui::VKEY_UNKNOWN, accelerator.key_code()); | 60 EXPECT_EQ(ui::VKEY_UNKNOWN, accelerator.key_code()); |
| 61 | 61 |
| 62 // Update to version 2. | 62 // Update to version 2. |
| 63 EXPECT_TRUE(UpdateExtension(kId, path_v2, 0)); | 63 EXPECT_TRUE(UpdateExtension(kId, path_v2, 0)); |
| 64 EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL); | 64 EXPECT_TRUE(service->GetExtensionById(kId, false) != NULL); |
| 65 | 65 |
| 66 // Verify it is still set to nothing. | 66 // Verify it is still set to nothing. |
| 67 accelerator = command_service->FindShortcutForCommand( | 67 accelerator = command_service->FindShortcutForCommand( |
| 68 kId, extension_manifest_values::kBrowserActionCommandEvent); | 68 kId, manifest_values::kBrowserActionCommandEvent); |
| 69 EXPECT_EQ(ui::VKEY_UNKNOWN, accelerator.key_code()); | 69 EXPECT_EQ(ui::VKEY_UNKNOWN, accelerator.key_code()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace extensions | 72 } // namespace extensions |
| OLD | NEW |