OLD | NEW |
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/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 virtual void SetUpOnMainThread() OVERRIDE { | 78 virtual void SetUpOnMainThread() OVERRIDE { |
79 FilePath path = ui_test_utils::GetTestFilePath(FilePath(), FilePath()); | 79 FilePath path = ui_test_utils::GetTestFilePath(FilePath(), FilePath()); |
80 BrowserThread::PostTask( | 80 BrowserThread::PostTask( |
81 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); | 81 BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); |
82 } | 82 } |
83 | 83 |
84 void LoadAndWait(const GURL& url) { | 84 void LoadAndWait(const GURL& url) { |
85 string16 expected_title(ASCIIToUTF16("OK")); | 85 string16 expected_title(ASCIIToUTF16("OK")); |
86 ui_test_utils::TitleWatcher title_watcher( | 86 ui_test_utils::TitleWatcher title_watcher( |
87 browser()->GetSelectedWebContents(), expected_title); | 87 browser()->GetActiveWebContents(), expected_title); |
88 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 88 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
89 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); | 89 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); |
90 ui_test_utils::NavigateToURL(browser(), url); | 90 ui_test_utils::NavigateToURL(browser(), url); |
91 string16 title = title_watcher.WaitAndGetTitle(); | 91 string16 title = title_watcher.WaitAndGetTitle(); |
92 if (title == ASCIIToUTF16("plugin_not_found")) { | 92 if (title == ASCIIToUTF16("plugin_not_found")) { |
93 const testing::TestInfo* const test_info = | 93 const testing::TestInfo* const test_info = |
94 testing::UnitTest::GetInstance()->current_test_info(); | 94 testing::UnitTest::GetInstance()->current_test_info(); |
95 LOG(INFO) << "PluginTest." << test_info->name() << | 95 LOG(INFO) << "PluginTest." << test_info->name() << |
96 " not running because plugin not installed."; | 96 " not running because plugin not installed."; |
97 } else { | 97 } else { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // This was never ported to Mac. The only thing remaining is to make | 168 // This was never ported to Mac. The only thing remaining is to make |
169 // ui_test_utils::SimulateMouseClick get to Mac plugins, currently it doesn't | 169 // ui_test_utils::SimulateMouseClick get to Mac plugins, currently it doesn't |
170 // work. | 170 // work. |
171 IN_PROC_BROWSER_TEST_F(PluginTest, | 171 IN_PROC_BROWSER_TEST_F(PluginTest, |
172 SelfDeletePluginInvokeInSynchronousMouseUp) { | 172 SelfDeletePluginInvokeInSynchronousMouseUp) { |
173 ui_test_utils::NavigateToURL( | 173 ui_test_utils::NavigateToURL( |
174 browser(), GetURL("execute_script_delete_in_mouse_up.html")); | 174 browser(), GetURL("execute_script_delete_in_mouse_up.html")); |
175 | 175 |
176 string16 expected_title(ASCIIToUTF16("OK")); | 176 string16 expected_title(ASCIIToUTF16("OK")); |
177 ui_test_utils::TitleWatcher title_watcher( | 177 ui_test_utils::TitleWatcher title_watcher( |
178 browser()->GetSelectedWebContents(), expected_title); | 178 browser()->GetActiveWebContents(), expected_title); |
179 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 179 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
180 ui_test_utils::SimulateMouseClick(browser()->GetSelectedWebContents()); | 180 ui_test_utils::SimulateMouseClick(browser()->GetActiveWebContents()); |
181 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 181 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
182 } | 182 } |
183 #endif | 183 #endif |
184 | 184 |
185 // Flaky, http://crbug.com/60071. | 185 // Flaky, http://crbug.com/60071. |
186 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequest404Response) { | 186 IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRequest404Response) { |
187 GURL url(URLRequestMockHTTPJob::GetMockUrl( | 187 GURL url(URLRequestMockHTTPJob::GetMockUrl( |
188 FilePath().AppendASCII("npapi"). | 188 FilePath().AppendASCII("npapi"). |
189 AppendASCII("plugin_url_request_404.html"))); | 189 AppendASCII("plugin_url_request_404.html"))); |
190 LoadAndWait(url); | 190 LoadAndWait(url); |
191 } | 191 } |
192 | 192 |
193 // Tests if a plugin executing a self deleting script using Invoke with | 193 // Tests if a plugin executing a self deleting script using Invoke with |
194 // a modal dialog showing works without crashing or hanging | 194 // a modal dialog showing works without crashing or hanging |
195 // Disabled, flakily exceeds timeout, http://crbug.com/46257. | 195 // Disabled, flakily exceeds timeout, http://crbug.com/46257. |
196 IN_PROC_BROWSER_TEST_F(PluginTest, SelfDeletePluginInvokeAlert) { | 196 IN_PROC_BROWSER_TEST_F(PluginTest, SelfDeletePluginInvokeAlert) { |
197 // Navigate asynchronously because if we waitd until it completes, there's a | 197 // Navigate asynchronously because if we waitd until it completes, there's a |
198 // race condition where the alert can come up before we start watching for it. | 198 // race condition where the alert can come up before we start watching for it. |
199 ui_test_utils::NavigateToURLWithDisposition( | 199 ui_test_utils::NavigateToURLWithDisposition( |
200 browser(), GetURL("self_delete_plugin_invoke_alert.html"), CURRENT_TAB, | 200 browser(), GetURL("self_delete_plugin_invoke_alert.html"), CURRENT_TAB, |
201 0); | 201 0); |
202 | 202 |
203 string16 expected_title(ASCIIToUTF16("OK")); | 203 string16 expected_title(ASCIIToUTF16("OK")); |
204 ui_test_utils::TitleWatcher title_watcher( | 204 ui_test_utils::TitleWatcher title_watcher( |
205 browser()->GetSelectedWebContents(), expected_title); | 205 browser()->GetActiveWebContents(), expected_title); |
206 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 206 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
207 | 207 |
208 ui_test_utils::WaitForAppModalDialogAndCloseIt(); | 208 ui_test_utils::WaitForAppModalDialogAndCloseIt(); |
209 | 209 |
210 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 210 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
211 } | 211 } |
212 | 212 |
213 // Test passing arguments to a plugin. | 213 // Test passing arguments to a plugin. |
214 IN_PROC_BROWSER_TEST_F(PluginTest, Arguments) { | 214 IN_PROC_BROWSER_TEST_F(PluginTest, Arguments) { |
215 LoadAndWait(GetURL("arguments.html")); | 215 LoadAndWait(GetURL("arguments.html")); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 IN_PROC_BROWSER_TEST_F(PluginTest, PluginConvertPointTest) { | 392 IN_PROC_BROWSER_TEST_F(PluginTest, PluginConvertPointTest) { |
393 gfx::NativeWindow window = NULL; | 393 gfx::NativeWindow window = NULL; |
394 gfx::Rect bounds(50, 50, 400, 400); | 394 gfx::Rect bounds(50, 50, 400, 400); |
395 ui_test_utils::GetNativeWindow(browser(), &window); | 395 ui_test_utils::GetNativeWindow(browser(), &window); |
396 ui_test_utils::SetWindowBounds(window, bounds); | 396 ui_test_utils::SetWindowBounds(window, bounds); |
397 | 397 |
398 ui_test_utils::NavigateToURL(browser(), GetURL("convert_point.html")); | 398 ui_test_utils::NavigateToURL(browser(), GetURL("convert_point.html")); |
399 | 399 |
400 string16 expected_title(ASCIIToUTF16("OK")); | 400 string16 expected_title(ASCIIToUTF16("OK")); |
401 ui_test_utils::TitleWatcher title_watcher( | 401 ui_test_utils::TitleWatcher title_watcher( |
402 browser()->GetSelectedWebContents(), expected_title); | 402 browser()->GetActiveWebContents(), expected_title); |
403 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 403 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
404 // TODO(stuartmorgan): When the automation system supports sending clicks, | 404 // TODO(stuartmorgan): When the automation system supports sending clicks, |
405 // change the test to trigger on mouse-down rather than window focus. | 405 // change the test to trigger on mouse-down rather than window focus. |
406 static_cast<content::WebContentsDelegate*>(browser())-> | 406 static_cast<content::WebContentsDelegate*>(browser())-> |
407 ActivateContents(browser()->GetSelectedWebContents()); | 407 ActivateContents(browser()->GetActiveWebContents()); |
408 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 408 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
409 } | 409 } |
410 #endif | 410 #endif |
411 | 411 |
412 IN_PROC_BROWSER_TEST_F(PluginTest, Flash) { | 412 IN_PROC_BROWSER_TEST_F(PluginTest, Flash) { |
413 TestPlugin("flash.html"); | 413 TestPlugin("flash.html"); |
414 } | 414 } |
415 | 415 |
416 #if defined(OS_WIN) | 416 #if defined(OS_WIN) |
417 // Windows only test | 417 // Windows only test |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 458 |
459 // http://crbug.com/8690 | 459 // http://crbug.com/8690 |
460 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) { | 460 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) { |
461 TestPlugin("Java.html"); | 461 TestPlugin("Java.html"); |
462 } | 462 } |
463 | 463 |
464 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) { | 464 IN_PROC_BROWSER_TEST_F(PluginTest, Silverlight) { |
465 TestPlugin("silverlight.html"); | 465 TestPlugin("silverlight.html"); |
466 } | 466 } |
467 #endif // defined(OS_WIN) | 467 #endif // defined(OS_WIN) |
OLD | NEW |