| 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" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 void TestHelper(const std::string& test_name, | 220 void TestHelper(const std::string& test_name, |
| 221 const std::string& app_location, | 221 const std::string& app_location, |
| 222 TestServer test_server) { | 222 TestServer test_server) { |
| 223 content::WebContents* embedder_web_contents = NULL; | 223 content::WebContents* embedder_web_contents = NULL; |
| 224 std::unique_ptr<ExtensionTestMessageListener> done_listener(RunAppHelper( | 224 std::unique_ptr<ExtensionTestMessageListener> done_listener(RunAppHelper( |
| 225 test_name, app_location, test_server, &embedder_web_contents)); | 225 test_name, app_location, test_server, &embedder_web_contents)); |
| 226 | 226 |
| 227 ASSERT_TRUE(done_listener); | 227 ASSERT_TRUE(done_listener); |
| 228 ASSERT_TRUE(done_listener->WaitUntilSatisfied()); | 228 ASSERT_TRUE(done_listener->WaitUntilSatisfied()); |
| 229 | 229 |
| 230 embedder_web_contents_ = embedder_web_contents; |
| 230 guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated(); | 231 guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated(); |
| 231 } | 232 } |
| 232 | 233 |
| 233 void SendMessageToEmbedder(const std::string& message) { | 234 void SendMessageToEmbedder(const std::string& message) { |
| 234 ASSERT_TRUE(content::ExecuteScript( | 235 ASSERT_TRUE(content::ExecuteScript( |
| 235 GetFirstAppWindowWebContents(), | 236 GetFirstAppWindowWebContents(), |
| 236 base::StringPrintf("onAppMessage('%s');", message.c_str()))); | 237 base::StringPrintf("onAppMessage('%s');", message.c_str()))); |
| 237 } | 238 } |
| 238 | 239 |
| 239 void SetupTest(const std::string& app_name, | 240 void SetupTest(const std::string& app_name, |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 // this time. | 1341 // this time. |
| 1341 for (size_t i = 0; i < 4; ++i) | 1342 for (size_t i = 0; i < 4; ++i) |
| 1342 SendKeyPressToPlatformApp(ui::VKEY_TAB); | 1343 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 1343 ExtensionTestMessageListener webview_button_not_focused_listener( | 1344 ExtensionTestMessageListener webview_button_not_focused_listener( |
| 1344 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); | 1345 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); |
| 1345 webview_button_not_focused_listener.set_failure_message( | 1346 webview_button_not_focused_listener.set_failure_message( |
| 1346 "WebViewInteractiveTest.WebViewButtonWasFocused"); | 1347 "WebViewInteractiveTest.WebViewButtonWasFocused"); |
| 1347 SendMessageToEmbedder("verify"); | 1348 SendMessageToEmbedder("verify"); |
| 1348 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); | 1349 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); |
| 1349 } | 1350 } |
| 1351 |
| 1352 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) { |
| 1353 TestHelper("testKeyboardFocus", "web_view/focus", NO_TEST_SERVER); |
| 1354 |
| 1355 EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), |
| 1356 embedder_web_contents()->GetMainFrame()); |
| 1357 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); |
| 1358 next_step_listener.set_failure_message("TEST_STEP_FAILED"); |
| 1359 { |
| 1360 content::SimulateMouseClickAt(embedder_web_contents(), 0, |
| 1361 blink::WebMouseEvent::ButtonLeft, |
| 1362 gfx::Point(40, 40)); |
| 1363 } |
| 1364 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); |
| 1365 if (GetParam()) { |
| 1366 EXPECT_NE(embedder_web_contents()->GetFocusedFrame(), |
| 1367 embedder_web_contents()->GetMainFrame()); |
| 1368 } |
| 1369 |
| 1370 content::SimulateKeyPress(embedder_web_contents(), ui::VKEY_A, false, false, |
| 1371 false, false); |
| 1372 content::SimulateKeyPress(embedder_web_contents(), ui::VKEY_B, false, false, |
| 1373 false, false); |
| 1374 content::SimulateKeyPress(embedder_web_contents(), ui::VKEY_C, false, true, |
| 1375 false, false); |
| 1376 |
| 1377 next_step_listener.Reset(); |
| 1378 EXPECT_TRUE(content::ExecuteScript( |
| 1379 embedder_web_contents(), |
| 1380 "window.runCommand('testKeyboardFocusRunNextStep', 'ABC');")); |
| 1381 |
| 1382 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); |
| 1383 } |
| OLD | NEW |