| 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 #if defined(OS_MACOSX) |
| 78 // Send Cmd+Left on MacOSX. |
| 79 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 80 GetPlatformAppWindow(), ui::VKEY_LEFT, false, false, false, true)); |
| 81 #else |
| 82 // Send Ctrl+Left on Windows and Linux/ChromeOS. |
| 83 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 84 GetPlatformAppWindow(), ui::VKEY_LEFT, true, false, false, false)); |
| 85 #endif |
| 86 } |
| 87 |
| 76 void SendMouseEvent(ui_controls::MouseButton button, | 88 void SendMouseEvent(ui_controls::MouseButton button, |
| 77 ui_controls::MouseButtonState state) { | 89 ui_controls::MouseButtonState state) { |
| 78 if (first_click_) { | 90 if (first_click_) { |
| 79 mouse_click_result_ = ui_test_utils::SendMouseEventsSync(button, | 91 mouse_click_result_ = ui_test_utils::SendMouseEventsSync(button, |
| 80 state); | 92 state); |
| 81 first_click_ = false; | 93 first_click_ = false; |
| 82 } else { | 94 } else { |
| 83 ASSERT_EQ(mouse_click_result_, ui_test_utils::SendMouseEventsSync( | 95 ASSERT_EQ(mouse_click_result_, ui_test_utils::SendMouseEventsSync( |
| 84 button, state)); | 96 button, state)); |
| 85 } | 97 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 "files/extensions/platform_apps/web_view/edit_commands/guest.html"); | 352 "files/extensions/platform_apps/web_view/edit_commands/guest.html"); |
| 341 | 353 |
| 342 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( | 354 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 343 GetPlatformAppWindow())); | 355 GetPlatformAppWindow())); |
| 344 | 356 |
| 345 // Flush any pending events to make sure we start with a clean slate. | 357 // Flush any pending events to make sure we start with a clean slate. |
| 346 content::RunAllPendingInMessageLoop(); | 358 content::RunAllPendingInMessageLoop(); |
| 347 | 359 |
| 348 ExtensionTestMessageListener copy_listener("copy", false); | 360 ExtensionTestMessageListener copy_listener("copy", false); |
| 349 SendCopyKeyPressToPlatformApp(); | 361 SendCopyKeyPressToPlatformApp(); |
| 362 |
| 350 // Wait for the guest to receive a 'copy' edit command. | 363 // Wait for the guest to receive a 'copy' edit command. |
| 351 ASSERT_TRUE(copy_listener.WaitUntilSatisfied()); | 364 ASSERT_TRUE(copy_listener.WaitUntilSatisfied()); |
| 352 } | 365 } |
| 353 | 366 |
| 367 // Tests that guests receive edit commands and respond appropriately. |
| 368 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommandsNoMenu) { |
| 369 SetupTest("web_view/edit_commands_no_menu", |
| 370 "files/extensions/platform_apps/web_view/edit_commands_no_menu/" |
| 371 "guest.html"); |
| 372 |
| 373 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 374 GetPlatformAppWindow())); |
| 375 |
| 376 // Flush any pending events to make sure we start with a clean slate. |
| 377 content::RunAllPendingInMessageLoop(); |
| 378 |
| 379 ExtensionTestMessageListener start_of_line_listener("StartOfLine", false); |
| 380 SendStartOfLineKeyPressToPlatformApp(); |
| 381 // Wait for the guest to receive a 'copy' edit command. |
| 382 ASSERT_TRUE(start_of_line_listener.WaitUntilSatisfied()); |
| 383 } |
| 384 |
| 354 // Disabled due to timeouts/crashing on several platforms. crbug.com/241912 | 385 // Disabled due to timeouts/crashing on several platforms. crbug.com/241912 |
| 355 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_NewWindow) { | 386 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_NewWindow) { |
| 356 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 387 ASSERT_TRUE(StartTestServer()); // For serving guest pages. |
| 357 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/newwindow")) | 388 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/newwindow")) |
| 358 << message_; | 389 << message_; |
| 359 } | 390 } |
| 360 | 391 |
| 361 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) { | 392 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) { |
| 362 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 393 ASSERT_TRUE(StartTestServer()); // For serving guest pages. |
| 363 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/execute_code")) | 394 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/execute_code")) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 383 // Started flakily failing after a Blink roll: http://crbug.com/245332 | 414 // Started flakily failing after a Blink roll: http://crbug.com/245332 |
| 384 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_PopupPositioningMoved) { | 415 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_PopupPositioningMoved) { |
| 385 SetupTest( | 416 SetupTest( |
| 386 "web_view/popup_positioning_moved", | 417 "web_view/popup_positioning_moved", |
| 387 "files/extensions/platform_apps/web_view/popup_positioning_moved" | 418 "files/extensions/platform_apps/web_view/popup_positioning_moved" |
| 388 "/guest.html"); | 419 "/guest.html"); |
| 389 ASSERT_TRUE(guest_web_contents()); | 420 ASSERT_TRUE(guest_web_contents()); |
| 390 | 421 |
| 391 PopupTestHelper(gfx::Point(20, 0)); | 422 PopupTestHelper(gfx::Point(20, 0)); |
| 392 } | 423 } |
| OLD | NEW |