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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/browser_action_test_util.h" | 6 #include "chrome/browser/extensions/browser_action_test_util.h" |
7 #include "chrome/browser/sessions/restore_tab_helper.h" | 7 #include "chrome/browser/sessions/restore_tab_helper.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #if !defined(OS_MACOSX) | 33 #if !defined(OS_MACOSX) |
34 // Test the basic functionality of the Keybinding API: | 34 // Test the basic functionality of the Keybinding API: |
35 // - That pressing the shortcut keys should perform actions (activate the | 35 // - That pressing the shortcut keys should perform actions (activate the |
36 // browser action or send an event). | 36 // browser action or send an event). |
37 // - Note: Page action keybindings are tested in PageAction test below. | 37 // - Note: Page action keybindings are tested in PageAction test below. |
38 // - The shortcut keys taken by one extension are not overwritten by the last | 38 // - The shortcut keys taken by one extension are not overwritten by the last |
39 // installed extension. | 39 // installed extension. |
40 IN_PROC_BROWSER_TEST_F(KeybindingApiTest, Basic) { | 40 IN_PROC_BROWSER_TEST_F(KeybindingApiTest, Basic) { |
41 ASSERT_TRUE(test_server()->Start()); | 41 ASSERT_TRUE(test_server()->Start()); |
42 ASSERT_TRUE(RunExtensionTest("keybinding/basics")) << message_; | 42 ASSERT_TRUE(RunExtensionTest("keybinding/basics")) << message_; |
43 const Extension* extension = GetSingleLoadedExtension(); | 43 const extensions::Extension* extension = GetSingleLoadedExtension(); |
44 ASSERT_TRUE(extension) << message_; | 44 ASSERT_TRUE(extension) << message_; |
45 | 45 |
46 // Load this extension, which uses the same keybindings but sets the page | 46 // Load this extension, which uses the same keybindings but sets the page |
47 // to different colors. This is so we can see that it doesn't interfere. We | 47 // to different colors. This is so we can see that it doesn't interfere. We |
48 // don't test this extension in any other way (it should otherwise be | 48 // don't test this extension in any other way (it should otherwise be |
49 // immaterial to this test). | 49 // immaterial to this test). |
50 ASSERT_TRUE(RunExtensionTest("keybinding/conflicting")) << message_; | 50 ASSERT_TRUE(RunExtensionTest("keybinding/conflicting")) << message_; |
51 | 51 |
52 // Test that there are two browser actions in the toolbar. | 52 // Test that there are two browser actions in the toolbar. |
53 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); | 53 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); |
(...skipping 26 matching lines...) Expand all Loading... |
80 L"setInterval(function(){" | 80 L"setInterval(function(){" |
81 L" if(document.body.bgColor == 'blue'){" | 81 L" if(document.body.bgColor == 'blue'){" |
82 L" window.domAutomationController.send(true)}}, 100)", | 82 L" window.domAutomationController.send(true)}}, 100)", |
83 &result)); | 83 &result)); |
84 ASSERT_TRUE(result); | 84 ASSERT_TRUE(result); |
85 } | 85 } |
86 | 86 |
87 IN_PROC_BROWSER_TEST_F(KeybindingApiTest, PageAction) { | 87 IN_PROC_BROWSER_TEST_F(KeybindingApiTest, PageAction) { |
88 ASSERT_TRUE(test_server()->Start()); | 88 ASSERT_TRUE(test_server()->Start()); |
89 ASSERT_TRUE(RunExtensionTest("keybinding/page_action")) << message_; | 89 ASSERT_TRUE(RunExtensionTest("keybinding/page_action")) << message_; |
90 const Extension* extension = GetSingleLoadedExtension(); | 90 const extensions::Extension* extension = GetSingleLoadedExtension(); |
91 ASSERT_TRUE(extension) << message_; | 91 ASSERT_TRUE(extension) << message_; |
92 | 92 |
93 { | 93 { |
94 // Load a page, the extension will detect the navigation and request to show | 94 // Load a page, the extension will detect the navigation and request to show |
95 // the page action icon. | 95 // the page action icon. |
96 ResultCatcher catcher; | 96 ResultCatcher catcher; |
97 ui_test_utils::NavigateToURL(browser(), | 97 ui_test_utils::NavigateToURL(browser(), |
98 test_server()->GetURL("files/extensions/test_file.txt")); | 98 test_server()->GetURL("files/extensions/test_file.txt")); |
99 ASSERT_TRUE(catcher.GetNextResult()); | 99 ASSERT_TRUE(catcher.GetNextResult()); |
100 } | 100 } |
(...skipping 16 matching lines...) Expand all Loading... |
117 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 117 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
118 tab->GetRenderViewHost(), L"", | 118 tab->GetRenderViewHost(), L"", |
119 L"setInterval(function(){" | 119 L"setInterval(function(){" |
120 L" if(document.body.bgColor == 'red'){" | 120 L" if(document.body.bgColor == 'red'){" |
121 L" window.domAutomationController.send(true)}}, 100)", | 121 L" window.domAutomationController.send(true)}}, 100)", |
122 &result)); | 122 &result)); |
123 ASSERT_TRUE(result); | 123 ASSERT_TRUE(result); |
124 } | 124 } |
125 | 125 |
126 #endif // !OS_MACOSX | 126 #endif // !OS_MACOSX |
OLD | NEW |