Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/apps/app_browsertest_util.h" | 15 #include "chrome/browser/apps/app_browsertest_util.h" |
| 16 #include "chrome/browser/chrome_content_browser_client.h" | 16 #include "chrome/browser/chrome_content_browser_client.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h" | 18 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h" |
| 19 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" | 19 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" |
| 20 #include "chrome/test/base/interactive_test_utils.h" | 20 #include "chrome/test/base/interactive_test_utils.h" |
| 21 #include "chrome/test/base/test_launcher_utils.h" | 21 #include "chrome/test/base/test_launcher_utils.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "components/guest_view/browser/guest_view_base.h" | 23 #include "components/guest_view/browser/guest_view_base.h" |
| 24 #include "components/guest_view/browser/guest_view_manager.h" | 24 #include "components/guest_view/browser/guest_view_manager.h" |
| 25 #include "components/guest_view/browser/guest_view_manager_delegate.h" | 25 #include "components/guest_view/browser/guest_view_manager_delegate.h" |
| 26 #include "components/guest_view/browser/guest_view_manager_factory.h" | 26 #include "components/guest_view/browser/guest_view_manager_factory.h" |
| 27 #include "components/guest_view/browser/test_guest_view_manager.h" | 27 #include "components/guest_view/browser/test_guest_view_manager.h" |
| 28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/render_frame_host.h" | |
| 29 #include "content/public/browser/render_process_host.h" | 30 #include "content/public/browser/render_process_host.h" |
| 30 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
| 31 #include "content/public/browser/render_widget_host.h" | 32 #include "content/public/browser/render_widget_host.h" |
| 32 #include "content/public/browser/render_widget_host_iterator.h" | 33 #include "content/public/browser/render_widget_host_iterator.h" |
| 33 #include "content/public/browser/render_widget_host_view.h" | 34 #include "content/public/browser/render_widget_host_view.h" |
| 34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 36 #include "content/public/test/browser_test_utils.h" | 37 #include "content/public/test/browser_test_utils.h" |
| 37 #include "extensions/browser/api/extensions_api_client.h" | 38 #include "extensions/browser/api/extensions_api_client.h" |
| 38 #include "extensions/browser/app_window/app_window.h" | 39 #include "extensions/browser/app_window/app_window.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 void TestHelper(const std::string& test_name, | 221 void TestHelper(const std::string& test_name, |
| 221 const std::string& app_location, | 222 const std::string& app_location, |
| 222 TestServer test_server) { | 223 TestServer test_server) { |
| 223 content::WebContents* embedder_web_contents = NULL; | 224 content::WebContents* embedder_web_contents = NULL; |
| 224 std::unique_ptr<ExtensionTestMessageListener> done_listener(RunAppHelper( | 225 std::unique_ptr<ExtensionTestMessageListener> done_listener(RunAppHelper( |
| 225 test_name, app_location, test_server, &embedder_web_contents)); | 226 test_name, app_location, test_server, &embedder_web_contents)); |
| 226 | 227 |
| 227 ASSERT_TRUE(done_listener); | 228 ASSERT_TRUE(done_listener); |
| 228 ASSERT_TRUE(done_listener->WaitUntilSatisfied()); | 229 ASSERT_TRUE(done_listener->WaitUntilSatisfied()); |
| 229 | 230 |
| 231 embedder_web_contents_ = embedder_web_contents; | |
| 230 guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated(); | 232 guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated(); |
| 231 } | 233 } |
| 232 | 234 |
| 233 void SendMessageToEmbedder(const std::string& message) { | 235 void SendMessageToEmbedder(const std::string& message) { |
| 234 ASSERT_TRUE(content::ExecuteScript( | 236 ASSERT_TRUE(content::ExecuteScript( |
| 235 GetFirstAppWindowWebContents(), | 237 GetFirstAppWindowWebContents(), |
| 236 base::StringPrintf("onAppMessage('%s');", message.c_str()))); | 238 base::StringPrintf("onAppMessage('%s');", message.c_str()))); |
| 237 } | 239 } |
| 238 | 240 |
| 239 void SetupTest(const std::string& app_name, | 241 void SetupTest(const std::string& app_name, |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1340 // this time. | 1342 // this time. |
| 1341 for (size_t i = 0; i < 4; ++i) | 1343 for (size_t i = 0; i < 4; ++i) |
| 1342 SendKeyPressToPlatformApp(ui::VKEY_TAB); | 1344 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 1343 ExtensionTestMessageListener webview_button_not_focused_listener( | 1345 ExtensionTestMessageListener webview_button_not_focused_listener( |
| 1344 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); | 1346 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); |
| 1345 webview_button_not_focused_listener.set_failure_message( | 1347 webview_button_not_focused_listener.set_failure_message( |
| 1346 "WebViewInteractiveTest.WebViewButtonWasFocused"); | 1348 "WebViewInteractiveTest.WebViewButtonWasFocused"); |
| 1347 SendMessageToEmbedder("verify"); | 1349 SendMessageToEmbedder("verify"); |
| 1348 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); | 1350 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); |
| 1349 } | 1351 } |
| 1352 | |
| 1353 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) { | |
| 1354 TestHelper("testKeyboardFocus", "web_view/focus", NO_TEST_SERVER); | |
| 1355 | |
| 1356 EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), | |
| 1357 embedder_web_contents()->GetMainFrame()); | |
| 1358 content::FrameFocusedObserver focus_observer( | |
| 1359 guest_web_contents()->GetMainFrame()); | |
| 1360 { | |
| 1361 gfx::Rect offset = embedder_web_contents()->GetContainerBounds(); | |
| 1362 // Click the <input> element inside the <webview>. | |
| 1363 // If we wanted, we could ask the embedder to compute an appropriate point. | |
| 1364 MoveMouseInsideWindow(gfx::Point(offset.x() + 40, offset.y() + 40)); | |
| 1365 SendMouseClick(ui_controls::LEFT); | |
| 1366 } | |
| 1367 focus_observer.Wait(); | |
| 1368 if (GetParam()) { | |
|
alexmos
2016/06/24 01:38:49
nit: { not necessary
avallee
2016/07/25 19:02:05
Done.
| |
| 1369 EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), nullptr); | |
| 1370 } | |
| 1371 | |
| 1372 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
| 1373 GetPlatformAppWindow(), ui::VKEY_A, false, false, false, false)); | |
| 1374 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
| 1375 GetPlatformAppWindow(), ui::VKEY_B, false, true, false, false)); | |
| 1376 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | |
| 1377 GetPlatformAppWindow(), ui::VKEY_C, false, false, false, false)); | |
| 1378 | |
| 1379 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); | |
| 1380 next_step_listener.set_failure_message("TEST_STEP_FAILED"); | |
| 1381 EXPECT_TRUE(content::ExecuteScript( | |
| 1382 embedder_web_contents(), | |
| 1383 "window.runCommand('testKeyboardFocusRunNextStep', 'aBc');")); | |
| 1384 | |
| 1385 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); | |
| 1386 } | |
| OLD | NEW |