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

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

Issue 10535077: TabContentsWrapper -> TabContents, part 12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 6 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.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_action.h" 12 #include "chrome/common/extensions/extension_action.h"
13 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 16
17 using content::WebContents; 17 using content::WebContents;
18 18
19 class KeybindingApiTest : public ExtensionApiTest { 19 class KeybindingApiTest : public ExtensionApiTest {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); 53 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions());
54 54
55 ui_test_utils::NavigateToURL(browser(), 55 ui_test_utils::NavigateToURL(browser(),
56 test_server()->GetURL("files/extensions/test_file.txt")); 56 test_server()->GetURL("files/extensions/test_file.txt"));
57 57
58 // Activate the shortcut (Ctrl+Shift+F). 58 // Activate the shortcut (Ctrl+Shift+F).
59 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 59 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
60 browser(), ui::VKEY_F, true, true, false, false)); 60 browser(), ui::VKEY_F, true, true, false, false));
61 61
62 // Verify the command worked. 62 // Verify the command worked.
63 WebContents* tab = browser()->GetSelectedWebContents(); 63 WebContents* tab = browser()->GetActiveWebContents();
64 bool result = false; 64 bool result = false;
65 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 65 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
66 tab->GetRenderViewHost(), L"", 66 tab->GetRenderViewHost(), L"",
67 L"setInterval(function(){" 67 L"setInterval(function(){"
68 L" if(document.body.bgColor == 'red'){" 68 L" if(document.body.bgColor == 'red'){"
69 L" window.domAutomationController.send(true)}}, 100)", 69 L" window.domAutomationController.send(true)}}, 100)",
70 &result)); 70 &result));
71 ASSERT_TRUE(result); 71 ASSERT_TRUE(result);
72 72
73 // Activate the shortcut (Ctrl+Shift+Y). 73 // 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 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 }
101 101
102 // Make sure it appears and is the right one. 102 // Make sure it appears and is the right one.
103 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 103 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
104 int tab_id = browser()->GetSelectedTabContentsWrapper()-> 104 int tab_id = browser()->GetActiveTabContents()->
105 restore_tab_helper()->session_id().id(); 105 restore_tab_helper()->session_id().id();
106 ExtensionAction* action = extension->page_action(); 106 ExtensionAction* action = extension->page_action();
107 ASSERT_TRUE(action); 107 ASSERT_TRUE(action);
108 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); 108 EXPECT_EQ("Make this page red", action->GetTitle(tab_id));
109 109
110 // Activate the shortcut (Ctrl+Shift+F). 110 // Activate the shortcut (Ctrl+Shift+F).
111 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 111 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
112 browser(), ui::VKEY_F, true, true, false, false)); 112 browser(), ui::VKEY_F, true, true, false, false));
113 113
114 // Verify the command worked (the page action turns the page red). 114 // Verify the command worked (the page action turns the page red).
115 WebContents* tab = browser()->GetSelectedWebContents(); 115 WebContents* tab = browser()->GetActiveWebContents();
116 bool result = false; 116 bool result = false;
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698