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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_webrequest_api.h" 8 #include "chrome/browser/extensions/extension_webrequest_api.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/login/login_prompt.h" 11 #include "chrome/browser/ui/login/login_prompt.h"
12 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/renderer_host/render_view_host.h" 15 #include "content/browser/renderer_host/render_view_host.h"
16 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/web_contents.h"
19 #include "net/base/mock_host_resolver.h" 19 #include "net/base/mock_host_resolver.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
21 21
22 using content::WebContents;
23
22 namespace { 24 namespace {
23 25
24 class CancelLoginDialog : public content::NotificationObserver { 26 class CancelLoginDialog : public content::NotificationObserver {
25 public: 27 public:
26 CancelLoginDialog() { 28 CancelLoginDialog() {
27 registrar_.Add(this, 29 registrar_.Add(this,
28 chrome::NOTIFICATION_AUTH_NEEDED, 30 chrome::NOTIFICATION_AUTH_NEEDED,
29 content::NotificationService::AllSources()); 31 content::NotificationService::AllSources());
30 } 32 }
31 33
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 WebRequestBlocking) { 83 WebRequestBlocking) {
82 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << 84 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) <<
83 message_; 85 message_;
84 } 86 }
85 87
86 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) { 88 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) {
87 // Wait for the extension to set itself up and return control to us. 89 // Wait for the extension to set itself up and return control to us.
88 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html")) 90 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html"))
89 << message_; 91 << message_;
90 92
91 TabContents* tab = browser()->GetSelectedTabContents(); 93 WebContents* tab = browser()->GetSelectedWebContents();
92 ui_test_utils::WaitForLoadStop(tab); 94 ui_test_utils::WaitForLoadStop(tab);
93 95
94 ResultCatcher catcher; 96 ResultCatcher catcher;
95 97
96 ExtensionService* service = browser()->profile()->GetExtensionService(); 98 ExtensionService* service = browser()->profile()->GetExtensionService();
97 const Extension* extension = 99 const Extension* extension =
98 service->GetExtensionById(last_loaded_extension_id_, false); 100 service->GetExtensionById(last_loaded_extension_id_, false);
99 GURL url = extension->GetResourceURL("newTab/a.html"); 101 GURL url = extension->GetResourceURL("newTab/a.html");
100 102
101 ui_test_utils::NavigateToURL(browser(), url); 103 ui_test_utils::NavigateToURL(browser(), url);
102 104
103 // There's a link on a.html with target=_blank. Click on it to open it in a 105 // There's a link on a.html with target=_blank. Click on it to open it in a
104 // new tab. 106 // new tab.
105 WebKit::WebMouseEvent mouse_event; 107 WebKit::WebMouseEvent mouse_event;
106 mouse_event.type = WebKit::WebInputEvent::MouseDown; 108 mouse_event.type = WebKit::WebInputEvent::MouseDown;
107 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 109 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
108 mouse_event.x = 7; 110 mouse_event.x = 7;
109 mouse_event.y = 7; 111 mouse_event.y = 7;
110 mouse_event.clickCount = 1; 112 mouse_event.clickCount = 1;
111 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 113 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
112 mouse_event.type = WebKit::WebInputEvent::MouseUp; 114 mouse_event.type = WebKit::WebInputEvent::MouseUp;
113 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 115 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
114 116
115 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 117 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
116 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698