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

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

Issue 16268017: GTTF: convert some tests in chrome to use EmbeddedTestServer patch nr 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/extensions/extension_test_message_listener.h" 7 #include "chrome/browser/extensions/extension_test_message_listener.h"
8 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 8 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
9 #include "chrome/browser/extensions/shell_window_registry.h" 9 #include "chrome/browser/extensions/shell_window_registry.h"
10 #include "chrome/browser/ui/extensions/shell_window.h" 10 #include "chrome/browser/ui/extensions/shell_window.h"
11 #include "chrome/test/base/interactive_test_utils.h" 11 #include "chrome/test/base/interactive_test_utils.h"
12 #include "chrome/test/base/test_launcher_utils.h" 12 #include "chrome/test/base/test_launcher_utils.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/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 17 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_view.h" 19 #include "content/public/browser/web_contents_view.h"
20 #include "content/public/test/browser_test_utils.h" 20 #include "content/public/test/browser_test_utils.h"
21 #include "net/test/embedded_test_server/embedded_test_server.h"
21 #include "ui/base/keycodes/keyboard_codes.h" 22 #include "ui/base/keycodes/keyboard_codes.h"
22 #include "ui/base/test/ui_controls.h" 23 #include "ui/base/test/ui_controls.h"
23 24
24 class WebViewInteractiveTest 25 class WebViewInteractiveTest
25 : public extensions::PlatformAppBrowserTest { 26 : public extensions::PlatformAppBrowserTest {
26 public: 27 public:
27 WebViewInteractiveTest() 28 WebViewInteractiveTest()
28 : corner_(gfx::Point()), 29 : corner_(gfx::Point()),
29 mouse_click_result_(false), 30 mouse_click_result_(false),
30 first_click_(true) {} 31 first_click_(true) {}
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 state); 95 state);
95 first_click_ = false; 96 first_click_ = false;
96 } else { 97 } else {
97 ASSERT_EQ(mouse_click_result_, ui_test_utils::SendMouseEventsSync( 98 ASSERT_EQ(mouse_click_result_, ui_test_utils::SendMouseEventsSync(
98 button, state)); 99 button, state));
99 } 100 }
100 } 101 }
101 102
102 void NewWindowTestHelper(const std::string& test_name, 103 void NewWindowTestHelper(const std::string& test_name,
103 const std::string& app_location) { 104 const std::string& app_location) {
104 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 105 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
105 ExtensionTestMessageListener launched_listener("Launched", false); 106 ExtensionTestMessageListener launched_listener("Launched", false);
106 LoadAndLaunchPlatformApp(app_location.c_str()); 107 LoadAndLaunchPlatformApp(app_location.c_str());
107 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 108 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
108 109
109 content::WebContents* embedder_web_contents = 110 content::WebContents* embedder_web_contents =
110 GetFirstShellWindowWebContents(); 111 GetFirstShellWindowWebContents();
111 ASSERT_TRUE(embedder_web_contents); 112 ASSERT_TRUE(embedder_web_contents);
112 113
113 ExtensionTestMessageListener done_listener("DoneNewWindowTest.PASSED", 114 ExtensionTestMessageListener done_listener("DoneNewWindowTest.PASSED",
114 false); 115 false);
115 done_listener.AlsoListenForFailureMessage("DoneNewWindowTest.FAILED"); 116 done_listener.AlsoListenForFailureMessage("DoneNewWindowTest.FAILED");
116 EXPECT_TRUE(content::ExecuteScript( 117 EXPECT_TRUE(content::ExecuteScript(
117 embedder_web_contents, 118 embedder_web_contents,
118 base::StringPrintf("runNewWindowTest('%s')", 119 base::StringPrintf("runNewWindowTest('%s')",
119 test_name.c_str()))); 120 test_name.c_str())));
120 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 121 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
121 } 122 }
122 123
123 void SetupTest(const std::string& app_name, 124 void SetupTest(const std::string& app_name,
124 const std::string& guest_url_spec) { 125 const std::string& guest_url_spec) {
125 ASSERT_TRUE(StartTestServer()); 126 ASSERT_TRUE(StartEmbeddedTestServer());
126 GURL::Replacements replace_host; 127 GURL::Replacements replace_host;
127 std::string host_str("localhost"); // Must stay in scope with replace_host. 128 std::string host_str("localhost"); // Must stay in scope with replace_host.
128 replace_host.SetHostStr(host_str); 129 replace_host.SetHostStr(host_str);
129 130
130 GURL guest_url = test_server()->GetURL(guest_url_spec); 131 GURL guest_url = embedded_test_server()->GetURL(guest_url_spec);
131 guest_url = guest_url.ReplaceComponents(replace_host); 132 guest_url = guest_url.ReplaceComponents(replace_host);
132 133
133 ui_test_utils::UrlLoadObserver guest_observer( 134 ui_test_utils::UrlLoadObserver guest_observer(
134 guest_url, content::NotificationService::AllSources()); 135 guest_url, content::NotificationService::AllSources());
135 136
136 ExtensionTestMessageListener guest_connected_listener("connected", false); 137 ExtensionTestMessageListener guest_connected_listener("connected", false);
137 LoadAndLaunchPlatformApp(app_name.c_str()); 138 LoadAndLaunchPlatformApp(app_name.c_str());
138 139
139 guest_observer.Wait(); 140 guest_observer.Wait();
140 141
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 bool first_click_; 284 bool first_click_;
284 }; 285 };
285 286
286 // ui_test_utils::SendMouseMoveSync doesn't seem to work on OS_MACOSX, and 287 // ui_test_utils::SendMouseMoveSync doesn't seem to work on OS_MACOSX, and
287 // likely won't work on many other platforms as well, so for now this test 288 // likely won't work on many other platforms as well, so for now this test
288 // is for Windows and Linux only. 289 // is for Windows and Linux only.
289 #if (defined(OS_WIN) || defined(OS_LINUX)) 290 #if (defined(OS_WIN) || defined(OS_LINUX))
290 291
291 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PointerLock) { 292 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PointerLock) {
292 SetupTest("web_view/pointer_lock", 293 SetupTest("web_view/pointer_lock",
293 "files/extensions/platform_apps/web_view/pointer_lock/guest.html"); 294 "/extensions/platform_apps/web_view/pointer_lock/guest.html");
294 295
295 // Move the mouse over the Lock Pointer button. 296 // Move the mouse over the Lock Pointer button.
296 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( 297 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(
297 gfx::Point(corner().x() + 75, corner().y() + 25))); 298 gfx::Point(corner().x() + 75, corner().y() + 25)));
298 299
299 // Click the Lock Pointer button. The first two times the button is clicked 300 // Click the Lock Pointer button. The first two times the button is clicked
300 // the permission API will deny the request (intentional). 301 // the permission API will deny the request (intentional).
301 ExtensionTestMessageListener exception_listener("request exception", false); 302 ExtensionTestMessageListener exception_listener("request exception", false);
302 SendMouseClickWithListener(ui_controls::LEFT, "lock error"); 303 SendMouseClickWithListener(ui_controls::LEFT, "lock error");
303 ASSERT_TRUE(exception_listener.WaitUntilSatisfied()); 304 ASSERT_TRUE(exception_listener.WaitUntilSatisfied());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( 358 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(
358 gfx::Point(corner().x() + 51, corner().y() + 11))); 359 gfx::Point(corner().x() + 51, corner().y() + 11)));
359 ASSERT_TRUE(move_listener2.WaitUntilSatisfied()); 360 ASSERT_TRUE(move_listener2.WaitUntilSatisfied());
360 } 361 }
361 } 362 }
362 363
363 #endif // (defined(OS_WIN) || defined(OS_LINUX)) 364 #endif // (defined(OS_WIN) || defined(OS_LINUX))
364 365
365 // Tests that setting focus on the <webview> sets focus on the guest. 366 // Tests that setting focus on the <webview> sets focus on the guest.
366 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_Focus) { 367 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_Focus) {
367 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 368 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
368 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/focus")) 369 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/focus"))
369 << message_; 370 << message_;
370 } 371 }
371 372
372 // Tests that guests receive edit commands and respond appropriately. 373 // Tests that guests receive edit commands and respond appropriately.
373 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommands) { 374 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommands) {
374 SetupTest("web_view/edit_commands", 375 SetupTest("web_view/edit_commands",
375 "files/extensions/platform_apps/web_view/edit_commands/guest.html"); 376 "/extensions/platform_apps/web_view/edit_commands/guest.html");
376 377
377 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( 378 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
378 GetPlatformAppWindow())); 379 GetPlatformAppWindow()));
379 380
380 // Flush any pending events to make sure we start with a clean slate. 381 // Flush any pending events to make sure we start with a clean slate.
381 content::RunAllPendingInMessageLoop(); 382 content::RunAllPendingInMessageLoop();
382 383
383 ExtensionTestMessageListener copy_listener("copy", false); 384 ExtensionTestMessageListener copy_listener("copy", false);
384 SendCopyKeyPressToPlatformApp(); 385 SendCopyKeyPressToPlatformApp();
385 386
386 // Wait for the guest to receive a 'copy' edit command. 387 // Wait for the guest to receive a 'copy' edit command.
387 ASSERT_TRUE(copy_listener.WaitUntilSatisfied()); 388 ASSERT_TRUE(copy_listener.WaitUntilSatisfied());
388 } 389 }
389 390
390 // Tests that guests receive edit commands and respond appropriately. 391 // Tests that guests receive edit commands and respond appropriately.
391 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommandsNoMenu) { 392 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommandsNoMenu) {
392 SetupTest("web_view/edit_commands_no_menu", 393 SetupTest("web_view/edit_commands_no_menu",
393 "files/extensions/platform_apps/web_view/edit_commands_no_menu/" 394 "/extensions/platform_apps/web_view/edit_commands_no_menu/"
394 "guest.html"); 395 "guest.html");
395 396
396 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( 397 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
397 GetPlatformAppWindow())); 398 GetPlatformAppWindow()));
398 399
399 // Flush any pending events to make sure we start with a clean slate. 400 // Flush any pending events to make sure we start with a clean slate.
400 content::RunAllPendingInMessageLoop(); 401 content::RunAllPendingInMessageLoop();
401 402
402 ExtensionTestMessageListener start_of_line_listener("StartOfLine", false); 403 ExtensionTestMessageListener start_of_line_listener("StartOfLine", false);
403 SendStartOfLineKeyPressToPlatformApp(); 404 SendStartOfLineKeyPressToPlatformApp();
(...skipping 25 matching lines...) Expand all
429 430
430 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, NewWindow_ExecuteScript) { 431 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, NewWindow_ExecuteScript) {
431 NewWindowTestHelper("testNewWindowExecuteScript", "web_view/newwindow"); 432 NewWindowTestHelper("testNewWindowExecuteScript", "web_view/newwindow");
432 } 433 }
433 434
434 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, NewWindow_WebRequest) { 435 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, NewWindow_WebRequest) {
435 NewWindowTestHelper("testNewWindowWebRequest", "web_view/newwindow"); 436 NewWindowTestHelper("testNewWindowWebRequest", "web_view/newwindow");
436 } 437 }
437 438
438 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) { 439 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) {
439 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 440 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
440 ASSERT_TRUE(RunPlatformAppTestWithArg( 441 ASSERT_TRUE(RunPlatformAppTestWithArg(
441 "platform_apps/web_view/common", "execute_code")) << message_; 442 "platform_apps/web_view/common", "execute_code")) << message_;
442 } 443 }
443 444
444 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PopupPositioning) { 445 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PopupPositioning) {
445 SetupTest( 446 SetupTest(
446 "web_view/popup_positioning", 447 "web_view/popup_positioning",
447 "files/extensions/platform_apps/web_view/popup_positioning/guest.html"); 448 "/extensions/platform_apps/web_view/popup_positioning/guest.html");
448 ASSERT_TRUE(guest_web_contents()); 449 ASSERT_TRUE(guest_web_contents());
449 450
450 PopupTestHelper(gfx::Point()); 451 PopupTestHelper(gfx::Point());
451 452
452 // moveTo a random location and run the steps again. 453 // moveTo a random location and run the steps again.
453 EXPECT_TRUE(content::ExecuteScript(embedder_web_contents(), 454 EXPECT_TRUE(content::ExecuteScript(embedder_web_contents(),
454 "window.moveTo(16, 20);")); 455 "window.moveTo(16, 20);"));
455 PopupTestHelper(gfx::Point()); 456 PopupTestHelper(gfx::Point());
456 } 457 }
457 458
458 // Tests that moving browser plugin (without resize/UpdateRects) correctly 459 // Tests that moving browser plugin (without resize/UpdateRects) correctly
459 // repositions popup. 460 // repositions popup.
460 // Started flakily failing after a Blink roll: http://crbug.com/245332 461 // Started flakily failing after a Blink roll: http://crbug.com/245332
461 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_PopupPositioningMoved) { 462 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_PopupPositioningMoved) {
462 SetupTest( 463 SetupTest(
463 "web_view/popup_positioning_moved", 464 "web_view/popup_positioning_moved",
464 "files/extensions/platform_apps/web_view/popup_positioning_moved" 465 "/extensions/platform_apps/web_view/popup_positioning_moved"
465 "/guest.html"); 466 "/guest.html");
466 ASSERT_TRUE(guest_web_contents()); 467 ASSERT_TRUE(guest_web_contents());
467 468
468 PopupTestHelper(gfx::Point(20, 0)); 469 PopupTestHelper(gfx::Point(20, 0));
469 } 470 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/web_view_browsertest.cc ('k') | chrome/browser/extensions/window_open_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698