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 "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 Loading... | |
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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
697 accelerator = command_service->FindCommandByName( | 722 accelerator = command_service->FindCommandByName( |
698 kId, manifest_values::kBrowserActionCommandEvent).accelerator(); | 723 kId, manifest_values::kBrowserActionCommandEvent).accelerator(); |
699 EXPECT_EQ(ui::VKEY_G, accelerator.key_code()); | 724 EXPECT_EQ(ui::VKEY_G, accelerator.key_code()); |
700 EXPECT_FALSE(accelerator.IsCtrlDown()); | 725 EXPECT_FALSE(accelerator.IsCtrlDown()); |
701 EXPECT_TRUE(accelerator.IsShiftDown()); | 726 EXPECT_TRUE(accelerator.IsShiftDown()); |
702 EXPECT_TRUE(accelerator.IsAltDown()); | 727 EXPECT_TRUE(accelerator.IsAltDown()); |
703 } | 728 } |
704 | 729 |
705 // | 730 // |
706 #if defined(OS_CHROMEOS) && !defined(NDEBUG) | 731 #if defined(OS_CHROMEOS) && !defined(NDEBUG) |
707 // TODO(dtseng): Test times out on Chrome OS debug. See http://crbug.com/412456. | 732 // TODO(dtseng): Test times out on Chrome OS debug. See http://crbug.com/412456. |
Finnur
2014/09/16 10:29:14
I presume this isn't directly because of this chan
| |
708 #define MAYBE_ContinuePropagation DISABLED_ContinuePropagation | 733 #define MAYBE_ContinuePropagation DISABLED_ContinuePropagation |
709 #else | 734 #else |
710 #define MAYBE_ContinuePropagation ContinuePropagation | 735 #define MAYBE_ContinuePropagation ContinuePropagation |
711 #endif | 736 #endif |
712 | 737 |
713 IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_ContinuePropagation) { | 738 IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_ContinuePropagation) { |
714 // Setup the environment. | 739 // Setup the environment. |
715 ASSERT_TRUE(test_server()->Start()); | 740 ASSERT_TRUE(test_server()->Start()); |
716 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 741 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
717 ASSERT_TRUE(RunExtensionTest("keybinding/continue_propagation")) << message_; | 742 ASSERT_TRUE(RunExtensionTest("keybinding/continue_propagation")) << message_; |
(...skipping 15 matching lines...) Expand all Loading... | |
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 IN_PROC_BROWSER_TEST_F(CommandsApiTest, ChromeOSConversions) { | |
771 RunChromeOSConversionTest("keybinding/chromeos_conversions"); | |
772 } | |
773 #endif // OS_CHROMEOS | |
774 | |
743 } // namespace extensions | 775 } // namespace extensions |
OLD | NEW |