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

Side by Side Diff: chrome/browser/extensions/extension_keybinding_apitest.cc

Issue 576413002: Reland Track the active ExtensionKeybindingRegistry and make it available to EventRewriter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/extensions/active_tab_permission_granter.h" 6 #include "chrome/browser/extensions/active_tab_permission_granter.h"
7 #include "chrome/browser/extensions/api/commands/command_service.h" 7 #include "chrome/browser/extensions/api/commands/command_service.h"
8 #include "chrome/browser/extensions/browser_action_test_util.h" 8 #include "chrome/browser/extensions/browser_action_test_util.h"
9 #include "chrome/browser/extensions/extension_action.h" 9 #include "chrome/browser/extensions/extension_action.h"
10 #include "chrome/browser/extensions/extension_action_manager.h" 10 #include "chrome/browser/extensions/extension_action_manager.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 protected: 47 protected:
48 BrowserActionTestUtil GetBrowserActionsBar() { 48 BrowserActionTestUtil GetBrowserActionsBar() {
49 return BrowserActionTestUtil(browser()); 49 return BrowserActionTestUtil(browser());
50 } 50 }
51 51
52 bool IsGrantedForTab(const Extension* extension, 52 bool IsGrantedForTab(const Extension* extension,
53 const content::WebContents* web_contents) { 53 const content::WebContents* web_contents) {
54 return extension->permissions_data()->HasAPIPermissionForTab( 54 return extension->permissions_data()->HasAPIPermissionForTab(
55 SessionTabHelper::IdForTab(web_contents), APIPermission::kTab); 55 SessionTabHelper::IdForTab(web_contents), APIPermission::kTab);
56 } 56 }
57
58 #if defined(OS_CHROMEOS)
59 void RunChromeOSConversionTest(const std::string& extension_path) {
60 // Setup the environment.
61 ASSERT_TRUE(test_server()->Start());
62 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
63 ASSERT_TRUE(RunExtensionTest(extension_path)) << message_;
64 ui_test_utils::NavigateToURL(
65 browser(), test_server()->GetURL("files/extensions/test_file.txt"));
66
67 ResultCatcher catcher;
68
69 // Send all expected keys (Search+Shift+{Left, Up, Right, Down}).
70 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
71 browser(), ui::VKEY_LEFT, false, true, false, true));
72 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
73 browser(), ui::VKEY_UP, false, true, false, true));
74 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
75 browser(), ui::VKEY_RIGHT, false, true, false, true));
76 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
77 browser(), ui::VKEY_DOWN, false, true, false, true));
78
79 ASSERT_TRUE(catcher.GetNextResult());
80 }
81 #endif // OS_CHROMEOS
57 }; 82 };
58 83
59 // Test the basic functionality of the Keybinding API: 84 // Test the basic functionality of the Keybinding API:
60 // - That pressing the shortcut keys should perform actions (activate the 85 // - That pressing the shortcut keys should perform actions (activate the
61 // browser action or send an event). 86 // browser action or send an event).
62 // - Note: Page action keybindings are tested in PageAction test below. 87 // - Note: Page action keybindings are tested in PageAction test below.
63 // - The shortcut keys taken by one extension are not overwritten by the last 88 // - The shortcut keys taken by one extension are not overwritten by the last
64 // installed extension. 89 // installed extension.
65 IN_PROC_BROWSER_TEST_F(CommandsApiTest, Basic) { 90 IN_PROC_BROWSER_TEST_F(CommandsApiTest, Basic) {
66 ASSERT_TRUE(test_server()->Start()); 91 ASSERT_TRUE(test_server()->Start());
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 browser(), ui::VKEY_F, true, true, false, false)); 758 browser(), ui::VKEY_F, true, true, false, false));
734 ASSERT_TRUE(catcher.GetNextResult()); 759 ASSERT_TRUE(catcher.GetNextResult());
735 760
736 // The extension should now have removed its |onCommand| event listener. 761 // The extension should now have removed its |onCommand| event listener.
737 // Finally, the page should again receive the key. 762 // Finally, the page should again receive the key.
738 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 763 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
739 browser(), ui::VKEY_F, true, true, false, false)); 764 browser(), ui::VKEY_F, true, true, false, false));
740 ASSERT_TRUE(catcher.GetNextResult()); 765 ASSERT_TRUE(catcher.GetNextResult());
741 } 766 }
742 767
768 // Test is only applicable on Chrome OS.
769 #if defined(OS_CHROMEOS)
770 // http://crbug.com/410534
771 #if defined(USE_OZONE)
772 #define MAYBE_ChromeOSConversions DISABLED_ChromeOSConversions
773 #else
774 #define MAYBE_ChromeOSConversions ChromeOSConversions
775 #endif
776 IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_ChromeOSConversions) {
777 RunChromeOSConversionTest("keybinding/chromeos_conversions");
778 }
779 #endif // OS_CHROMEOS
780
743 } // namespace extensions 781 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698