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

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

Issue 10201016: Conflict detection for Extension Keybinding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed comments Created 8 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 unified diff | Download patch | Annotate | Revision Log
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 "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 13 matching lines...) Expand all
24 } 24 }
25 virtual ~KeybindingApiTest() {} 25 virtual ~KeybindingApiTest() {}
26 26
27 protected: 27 protected:
28 BrowserActionTestUtil GetBrowserActionsBar() { 28 BrowserActionTestUtil GetBrowserActionsBar() {
29 return BrowserActionTestUtil(browser()); 29 return BrowserActionTestUtil(browser());
30 } 30 }
31 }; 31 };
32 32
33 #if !defined(OS_MACOSX) 33 #if !defined(OS_MACOSX)
34 // Test the basic functionality of the Keybinding API:
35 // - That pressing the shortcut keys should perform actions (activate the
36 // browser action or send an event).
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
39 // installed extension.
34 IN_PROC_BROWSER_TEST_F(KeybindingApiTest, Basic) { 40 IN_PROC_BROWSER_TEST_F(KeybindingApiTest, Basic) {
35 ASSERT_TRUE(test_server()->Start()); 41 ASSERT_TRUE(test_server()->Start());
36 ASSERT_TRUE(RunExtensionTest("keybinding/basics")) << message_; 42 ASSERT_TRUE(RunExtensionTest("keybinding/basics")) << message_;
37 const Extension* extension = GetSingleLoadedExtension(); 43 const Extension* extension = GetSingleLoadedExtension();
38 ASSERT_TRUE(extension) << message_; 44 ASSERT_TRUE(extension) << message_;
39 45
40 // Test that there is a browser action in the toolbar. 46 // Load this extension, which uses the same keybindings but sets the page
41 ASSERT_EQ(1, GetBrowserActionsBar().NumberOfBrowserActions()); 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
49 // immaterial to this test).
50 ASSERT_TRUE(RunExtensionTest("keybinding/conflicting")) << message_;
51
52 // Test that there are two browser actions in the toolbar.
53 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions());
42 54
43 ui_test_utils::NavigateToURL(browser(), 55 ui_test_utils::NavigateToURL(browser(),
44 test_server()->GetURL("files/extensions/test_file.txt")); 56 test_server()->GetURL("files/extensions/test_file.txt"));
45 57
46 // Activate the shortcut (Ctrl+Shift+F). 58 // Activate the shortcut (Ctrl+Shift+F).
47 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 59 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
48 browser(), ui::VKEY_F, true, true, false, false)); 60 browser(), ui::VKEY_F, true, true, false, false));
49 61
50 // Verify the command worked. 62 // Verify the command worked.
51 WebContents* tab = browser()->GetSelectedWebContents(); 63 WebContents* tab = browser()->GetSelectedWebContents();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 117 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
106 tab->GetRenderViewHost(), L"", 118 tab->GetRenderViewHost(), L"",
107 L"setInterval(function(){" 119 L"setInterval(function(){"
108 L" if(document.body.bgColor == 'red'){" 120 L" if(document.body.bgColor == 'red'){"
109 L" window.domAutomationController.send(true)}}, 100)", 121 L" window.domAutomationController.send(true)}}, 100)",
110 &result)); 122 &result));
111 ASSERT_TRUE(result); 123 ASSERT_TRUE(result);
112 } 124 }
113 125
114 #endif // !OS_MACOSX 126 #endif // !OS_MACOSX
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_command_service_factory.cc ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698