| OLD | NEW |
| 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/extensions/extension_test_message_listener.h" | 6 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 7 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 7 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 8 #include "chrome/browser/extensions/shell_window_registry.h" | 8 #include "chrome/browser/extensions/shell_window_registry.h" |
| 9 #include "chrome/browser/ui/extensions/shell_window.h" | 9 #include "chrome/browser/ui/extensions/shell_window.h" |
| 10 #include "chrome/test/base/interactive_test_utils.h" | 10 #include "chrome/test/base/interactive_test_utils.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Send Cmd+C on MacOSX. | 66 // Send Cmd+C on MacOSX. |
| 67 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 67 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 68 GetPlatformAppWindow(), ui::VKEY_C, false, false, false, true)); | 68 GetPlatformAppWindow(), ui::VKEY_C, false, false, false, true)); |
| 69 #else | 69 #else |
| 70 // Send Ctrl+C on Windows and Linux/ChromeOS. | 70 // Send Ctrl+C on Windows and Linux/ChromeOS. |
| 71 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 71 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 72 GetPlatformAppWindow(), ui::VKEY_C, true, false, false, false)); | 72 GetPlatformAppWindow(), ui::VKEY_C, true, false, false, false)); |
| 73 #endif | 73 #endif |
| 74 } | 74 } |
| 75 | 75 |
| 76 void SendStartOfLineKeyPressToPlatformApp() { |
| 77 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 78 GetPlatformAppWindow(), ui::VKEY_LEFT, false, false, false, true)); |
| 79 } |
| 80 |
| 76 void SendMouseEvent(ui_controls::MouseButton button, | 81 void SendMouseEvent(ui_controls::MouseButton button, |
| 77 ui_controls::MouseButtonState state) { | 82 ui_controls::MouseButtonState state) { |
| 78 if (first_click_) { | 83 if (first_click_) { |
| 79 mouse_click_result_ = ui_test_utils::SendMouseEventsSync(button, | 84 mouse_click_result_ = ui_test_utils::SendMouseEventsSync(button, |
| 80 state); | 85 state); |
| 81 first_click_ = false; | 86 first_click_ = false; |
| 82 } else { | 87 } else { |
| 83 ASSERT_EQ(mouse_click_result_, ui_test_utils::SendMouseEventsSync( | 88 ASSERT_EQ(mouse_click_result_, ui_test_utils::SendMouseEventsSync( |
| 84 button, state)); | 89 button, state)); |
| 85 } | 90 } |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 "files/extensions/platform_apps/web_view/edit_commands/guest.html"); | 346 "files/extensions/platform_apps/web_view/edit_commands/guest.html"); |
| 342 | 347 |
| 343 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( | 348 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 344 GetPlatformAppWindow())); | 349 GetPlatformAppWindow())); |
| 345 | 350 |
| 346 // Flush any pending events to make sure we start with a clean slate. | 351 // Flush any pending events to make sure we start with a clean slate. |
| 347 content::RunAllPendingInMessageLoop(); | 352 content::RunAllPendingInMessageLoop(); |
| 348 | 353 |
| 349 ExtensionTestMessageListener copy_listener("copy", false); | 354 ExtensionTestMessageListener copy_listener("copy", false); |
| 350 SendCopyKeyPressToPlatformApp(); | 355 SendCopyKeyPressToPlatformApp(); |
| 356 |
| 351 // Wait for the guest to receive a 'copy' edit command. | 357 // Wait for the guest to receive a 'copy' edit command. |
| 352 ASSERT_TRUE(copy_listener.WaitUntilSatisfied()); | 358 ASSERT_TRUE(copy_listener.WaitUntilSatisfied()); |
| 353 } | 359 } |
| 354 | 360 |
| 361 // Tests that guests receive edit commands and respond appropriately. |
| 362 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommandsNoMenu) { |
| 363 SetupTest("web_view/edit_commands_no_menu", |
| 364 "files/extensions/platform_apps/web_view/edit_commands_no_menu/" |
| 365 "guest.html"); |
| 366 |
| 367 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 368 GetPlatformAppWindow())); |
| 369 |
| 370 // Flush any pending events to make sure we start with a clean slate. |
| 371 content::RunAllPendingInMessageLoop(); |
| 372 |
| 373 ExtensionTestMessageListener start_of_line_listener("StartOfLine", false); |
| 374 SendStartOfLineKeyPressToPlatformApp(); |
| 375 // Wait for the guest to receive a 'copy' edit command. |
| 376 ASSERT_TRUE(start_of_line_listener.WaitUntilSatisfied()); |
| 377 } |
| 378 |
| 355 // Disabled due to timeouts/crashing on several platforms. crbug.com/241912 | 379 // Disabled due to timeouts/crashing on several platforms. crbug.com/241912 |
| 356 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_NewWindow) { | 380 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_NewWindow) { |
| 357 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 381 ASSERT_TRUE(StartTestServer()); // For serving guest pages. |
| 358 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/newwindow")) | 382 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/newwindow")) |
| 359 << message_; | 383 << message_; |
| 360 } | 384 } |
| 361 | 385 |
| 362 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) { | 386 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) { |
| 363 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 387 ASSERT_TRUE(StartTestServer()); // For serving guest pages. |
| 364 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/execute_code")) | 388 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/execute_code")) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 383 // repositions popup. | 407 // repositions popup. |
| 384 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PopupPositioningMoved) { | 408 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PopupPositioningMoved) { |
| 385 SetupTest( | 409 SetupTest( |
| 386 "web_view/popup_positioning_moved", | 410 "web_view/popup_positioning_moved", |
| 387 "files/extensions/platform_apps/web_view/popup_positioning_moved" | 411 "files/extensions/platform_apps/web_view/popup_positioning_moved" |
| 388 "/guest.html"); | 412 "/guest.html"); |
| 389 ASSERT_TRUE(guest_web_contents()); | 413 ASSERT_TRUE(guest_web_contents()); |
| 390 | 414 |
| 391 PopupTestHelper(gfx::Point(20, 0)); | 415 PopupTestHelper(gfx::Point(20, 0)); |
| 392 } | 416 } |
| OLD | NEW |