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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/browser_tabstrip.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
10 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_action.h" 13 #include "chrome/common/extensions/extension_action.h"
13 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 17
17 using content::WebContents; 18 using content::WebContents;
18 19
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); 54 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions());
54 55
55 ui_test_utils::NavigateToURL(browser(), 56 ui_test_utils::NavigateToURL(browser(),
56 test_server()->GetURL("files/extensions/test_file.txt")); 57 test_server()->GetURL("files/extensions/test_file.txt"));
57 58
58 // Activate the shortcut (Ctrl+Shift+F). 59 // Activate the shortcut (Ctrl+Shift+F).
59 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 60 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
60 browser(), ui::VKEY_F, true, true, false, false)); 61 browser(), ui::VKEY_F, true, true, false, false));
61 62
62 // Verify the command worked. 63 // Verify the command worked.
63 WebContents* tab = browser()->GetActiveWebContents(); 64 WebContents* tab = chrome::GetActiveWebContents(browser());
64 bool result = false; 65 bool result = false;
65 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 66 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
66 tab->GetRenderViewHost(), L"", 67 tab->GetRenderViewHost(), L"",
67 L"setInterval(function(){" 68 L"setInterval(function(){"
68 L" if(document.body.bgColor == 'red'){" 69 L" if(document.body.bgColor == 'red'){"
69 L" window.domAutomationController.send(true)}}, 100)", 70 L" window.domAutomationController.send(true)}}, 100)",
70 &result)); 71 &result));
71 ASSERT_TRUE(result); 72 ASSERT_TRUE(result);
72 73
73 // Activate the shortcut (Ctrl+Shift+Y). 74 // Activate the shortcut (Ctrl+Shift+Y).
(...skipping 20 matching lines...) Expand all
94 // Load a page, the extension will detect the navigation and request to show 95 // Load a page, the extension will detect the navigation and request to show
95 // the page action icon. 96 // the page action icon.
96 ResultCatcher catcher; 97 ResultCatcher catcher;
97 ui_test_utils::NavigateToURL(browser(), 98 ui_test_utils::NavigateToURL(browser(),
98 test_server()->GetURL("files/extensions/test_file.txt")); 99 test_server()->GetURL("files/extensions/test_file.txt"));
99 ASSERT_TRUE(catcher.GetNextResult()); 100 ASSERT_TRUE(catcher.GetNextResult());
100 } 101 }
101 102
102 // Make sure it appears and is the right one. 103 // Make sure it appears and is the right one.
103 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 104 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
104 int tab_id = browser()->GetActiveTabContents()-> 105 int tab_id = chrome::GetActiveTabContents(browser())->restore_tab_helper()->
105 restore_tab_helper()->session_id().id(); 106 session_id().id();
106 ExtensionAction* action = extension->page_action(); 107 ExtensionAction* action = extension->page_action();
107 ASSERT_TRUE(action); 108 ASSERT_TRUE(action);
108 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); 109 EXPECT_EQ("Make this page red", action->GetTitle(tab_id));
109 110
110 // Activate the shortcut (Ctrl+Shift+F). 111 // Activate the shortcut (Ctrl+Shift+F).
111 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 112 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
112 browser(), ui::VKEY_F, true, true, false, false)); 113 browser(), ui::VKEY_F, true, true, false, false));
113 114
114 // Verify the command worked (the page action turns the page red). 115 // Verify the command worked (the page action turns the page red).
115 WebContents* tab = browser()->GetActiveWebContents(); 116 WebContents* tab = chrome::GetActiveWebContents(browser());
116 bool result = false; 117 bool result = false;
117 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 118 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
118 tab->GetRenderViewHost(), L"", 119 tab->GetRenderViewHost(), L"",
119 L"setInterval(function(){" 120 L"setInterval(function(){"
120 L" if(document.body.bgColor == 'red'){" 121 L" if(document.body.bgColor == 'red'){"
121 L" window.domAutomationController.send(true)}}, 100)", 122 L" window.domAutomationController.send(true)}}, 100)",
122 &result)); 123 &result));
123 ASSERT_TRUE(result); 124 ASSERT_TRUE(result);
124 } 125 }
125 126
126 #endif // !OS_MACOSX 127 #endif // !OS_MACOSX
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_default.cc ('k') | chrome/browser/extensions/extension_nacl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698