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

Side by Side Diff: content/browser/plugin_browsertest.cc

Issue 10815025: Move TitleWatcher from ui_test_utils.h to browser_test_utils.h so it can be reused by content_brows… (Closed) Base URL: svn://chrome-svn/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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.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/browser_tabstrip.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/test/browser_test_utils.h"
14 #include "content/test/net/url_request_mock_http_job.h" 15 #include "content/test/net/url_request_mock_http_job.h"
15 #include "webkit/plugins/plugin_switches.h" 16 #include "webkit/plugins/plugin_switches.h"
16 17
17 #if defined(OS_WIN) 18 #if defined(OS_WIN)
18 #include "base/win/registry.h" 19 #include "base/win/registry.h"
19 #endif 20 #endif
20 21
21 using content::BrowserThread; 22 using content::BrowserThread;
22 23
23 namespace { 24 namespace {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 78 }
78 79
79 virtual void SetUpOnMainThread() OVERRIDE { 80 virtual void SetUpOnMainThread() OVERRIDE {
80 FilePath path = ui_test_utils::GetTestFilePath(FilePath(), FilePath()); 81 FilePath path = ui_test_utils::GetTestFilePath(FilePath(), FilePath());
81 BrowserThread::PostTask( 82 BrowserThread::PostTask(
82 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); 83 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path));
83 } 84 }
84 85
85 void LoadAndWait(const GURL& url) { 86 void LoadAndWait(const GURL& url) {
86 string16 expected_title(ASCIIToUTF16("OK")); 87 string16 expected_title(ASCIIToUTF16("OK"));
87 ui_test_utils::TitleWatcher title_watcher( 88 content::TitleWatcher title_watcher(
88 chrome::GetActiveWebContents(browser()), expected_title); 89 chrome::GetActiveWebContents(browser()), expected_title);
89 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 90 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
90 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); 91 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found"));
91 ui_test_utils::NavigateToURL(browser(), url); 92 ui_test_utils::NavigateToURL(browser(), url);
92 string16 title = title_watcher.WaitAndGetTitle(); 93 string16 title = title_watcher.WaitAndGetTitle();
93 if (title == ASCIIToUTF16("plugin_not_found")) { 94 if (title == ASCIIToUTF16("plugin_not_found")) {
94 const testing::TestInfo* const test_info = 95 const testing::TestInfo* const test_info =
95 testing::UnitTest::GetInstance()->current_test_info(); 96 testing::UnitTest::GetInstance()->current_test_info();
96 LOG(INFO) << "PluginTest." << test_info->name() << 97 LOG(INFO) << "PluginTest." << test_info->name() <<
97 " not running because plugin not installed."; 98 " not running because plugin not installed.";
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // a synchronous mouseup works correctly. 169 // a synchronous mouseup works correctly.
169 // This was never ported to Mac. The only thing remaining is to make 170 // This was never ported to Mac. The only thing remaining is to make
170 // ui_test_utils::SimulateMouseClick get to Mac plugins, currently it doesn't 171 // ui_test_utils::SimulateMouseClick get to Mac plugins, currently it doesn't
171 // work. 172 // work.
172 IN_PROC_BROWSER_TEST_F(PluginTest, 173 IN_PROC_BROWSER_TEST_F(PluginTest,
173 SelfDeletePluginInvokeInSynchronousMouseUp) { 174 SelfDeletePluginInvokeInSynchronousMouseUp) {
174 ui_test_utils::NavigateToURL( 175 ui_test_utils::NavigateToURL(
175 browser(), GetURL("execute_script_delete_in_mouse_up.html")); 176 browser(), GetURL("execute_script_delete_in_mouse_up.html"));
176 177
177 string16 expected_title(ASCIIToUTF16("OK")); 178 string16 expected_title(ASCIIToUTF16("OK"));
178 ui_test_utils::TitleWatcher title_watcher( 179 content::TitleWatcher title_watcher(
179 chrome::GetActiveWebContents(browser()), expected_title); 180 chrome::GetActiveWebContents(browser()), expected_title);
180 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 181 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
181 ui_test_utils::SimulateMouseClick(chrome::GetActiveWebContents(browser())); 182 ui_test_utils::SimulateMouseClick(chrome::GetActiveWebContents(browser()));
182 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 183 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
183 } 184 }
184 #endif 185 #endif
185 186
186 // Flaky, http://crbug.com/60071. 187 // Flaky, http://crbug.com/60071.
187 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequest404Response) { 188 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequest404Response) {
188 GURL url(URLRequestMockHTTPJob::GetMockUrl( 189 GURL url(URLRequestMockHTTPJob::GetMockUrl(
189 FilePath().AppendASCII("npapi"). 190 FilePath().AppendASCII("npapi").
190 AppendASCII("plugin_url_request_404.html"))); 191 AppendASCII("plugin_url_request_404.html")));
191 LoadAndWait(url); 192 LoadAndWait(url);
192 } 193 }
193 194
194 // Tests if a plugin executing a self deleting script using Invoke with 195 // Tests if a plugin executing a self deleting script using Invoke with
195 // a modal dialog showing works without crashing or hanging 196 // a modal dialog showing works without crashing or hanging
196 // Disabled, flakily exceeds timeout, http://crbug.com/46257. 197 // Disabled, flakily exceeds timeout, http://crbug.com/46257.
197 IN_PROC_BROWSER_TEST_F(PluginTest, SelfDeletePluginInvokeAlert) { 198 IN_PROC_BROWSER_TEST_F(PluginTest, SelfDeletePluginInvokeAlert) {
198 // Navigate asynchronously because if we waitd until it completes, there's a 199 // Navigate asynchronously because if we waitd until it completes, there's a
199 // race condition where the alert can come up before we start watching for it. 200 // race condition where the alert can come up before we start watching for it.
200 ui_test_utils::NavigateToURLWithDisposition( 201 ui_test_utils::NavigateToURLWithDisposition(
201 browser(), GetURL("self_delete_plugin_invoke_alert.html"), CURRENT_TAB, 202 browser(), GetURL("self_delete_plugin_invoke_alert.html"), CURRENT_TAB,
202 0); 203 0);
203 204
204 string16 expected_title(ASCIIToUTF16("OK")); 205 string16 expected_title(ASCIIToUTF16("OK"));
205 ui_test_utils::TitleWatcher title_watcher( 206 content::TitleWatcher title_watcher(
206 chrome::GetActiveWebContents(browser()), expected_title); 207 chrome::GetActiveWebContents(browser()), expected_title);
207 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 208 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
208 209
209 ui_test_utils::WaitForAppModalDialogAndCloseIt(); 210 ui_test_utils::WaitForAppModalDialogAndCloseIt();
210 211
211 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 212 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
212 } 213 }
213 214
214 // Test passing arguments to a plugin. 215 // Test passing arguments to a plugin.
215 IN_PROC_BROWSER_TEST_F(PluginTest, Arguments) { 216 IN_PROC_BROWSER_TEST_F(PluginTest, Arguments) {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // Test is flaky, see http://crbug.com/134515. 394 // Test is flaky, see http://crbug.com/134515.
394 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) { 395 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) {
395 gfx::NativeWindow window = NULL; 396 gfx::NativeWindow window = NULL;
396 gfx::Rect bounds(50, 50, 400, 400); 397 gfx::Rect bounds(50, 50, 400, 400);
397 ui_test_utils::GetNativeWindow(browser(), &window); 398 ui_test_utils::GetNativeWindow(browser(), &window);
398 ui_test_utils::SetWindowBounds(window, bounds); 399 ui_test_utils::SetWindowBounds(window, bounds);
399 400
400 ui_test_utils::NavigateToURL(browser(), GetURL("convert_point.html")); 401 ui_test_utils::NavigateToURL(browser(), GetURL("convert_point.html"));
401 402
402 string16 expected_title(ASCIIToUTF16("OK")); 403 string16 expected_title(ASCIIToUTF16("OK"));
403 ui_test_utils::TitleWatcher title_watcher( 404 content::TitleWatcher title_watcher(
404 chrome::GetActiveWebContents(browser()), expected_title); 405 chrome::GetActiveWebContents(browser()), expected_title);
405 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 406 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
406 // TODO(stuartmorgan): When the automation system supports sending clicks, 407 // TODO(stuartmorgan): When the automation system supports sending clicks,
407 // change the test to trigger on mouse-down rather than window focus. 408 // change the test to trigger on mouse-down rather than window focus.
408 static_cast<content::WebContentsDelegate*>(browser())-> 409 static_cast<content::WebContentsDelegate*>(browser())->
409 ActivateContents(chrome::GetActiveWebContents(browser())); 410 ActivateContents(chrome::GetActiveWebContents(browser()));
410 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 411 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
411 } 412 }
412 #endif 413 #endif
413 414
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 461
461 // http://crbug.com/8690 462 // http://crbug.com/8690
462 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) { 463 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) {
463 TestPlugin("Java.html"); 464 TestPlugin("Java.html");
464 } 465 }
465 466
466 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) { 467 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) {
467 TestPlugin("silverlight.html"); 468 TestPlugin("silverlight.html");
468 } 469 }
469 #endif // defined(OS_WIN) 470 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « content/browser/mouseleave_browsertest.cc ('k') | content/browser/renderer_host/resource_dispatcher_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698