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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc

Issue 1934703002: Fix keyboard focus for OOPIF-<webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test and addressed comments. Created 4 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
OLDNEW
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
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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 // this time. 1339 // this time.
1339 for (size_t i = 0; i < 4; ++i) 1340 for (size_t i = 0; i < 4; ++i)
1340 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1341 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1341 ExtensionTestMessageListener webview_button_not_focused_listener( 1342 ExtensionTestMessageListener webview_button_not_focused_listener(
1342 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); 1343 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false);
1343 webview_button_not_focused_listener.set_failure_message( 1344 webview_button_not_focused_listener.set_failure_message(
1344 "WebViewInteractiveTest.WebViewButtonWasFocused"); 1345 "WebViewInteractiveTest.WebViewButtonWasFocused");
1345 SendMessageToEmbedder("verify"); 1346 SendMessageToEmbedder("verify");
1346 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); 1347 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied());
1347 } 1348 }
1349
1350 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) {
1351 TestHelper("testKeyboardFocus", "web_view/focus", NO_TEST_SERVER);
1352
1353 EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(),
1354 embedder_web_contents()->GetMainFrame());
1355 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false);
1356 next_step_listener.set_failure_message("TEST_STEP_FAILED");
1357 {
1358 content::SimulateMouseClickAt(embedder_web_contents(), 0,
1359 blink::WebMouseEvent::ButtonLeft,
1360 gfx::Point(40, 40));
alexmos 2016/06/07 22:03:43 This expected to land on the <input> field created
avallee 2016/06/15 13:32:10 1. Comment added. 2. Looking at it, I think you're
1361 }
1362 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1363 if (GetParam()) {
1364 EXPECT_NE(embedder_web_contents()->GetFocusedFrame(),
alexmos 2016/06/07 22:03:43 embedder_web_contents()->GetFocusedFrame() should
avallee 2016/06/15 13:32:10 Done.
1365 embedder_web_contents()->GetMainFrame());
1366 }
1367
1368 content::SimulateKeyPress(embedder_web_contents(), ui::VKEY_A, false, false,
1369 false, false);
1370 content::SimulateKeyPress(embedder_web_contents(), ui::VKEY_B, false, false,
1371 false, false);
1372 content::SimulateKeyPress(embedder_web_contents(), ui::VKEY_C, false, true,
1373 false, false);
1374
1375 next_step_listener.Reset();
1376 EXPECT_TRUE(content::ExecuteScript(
1377 embedder_web_contents(),
1378 "window.runCommand('testKeyboardFocusRunNextStep', 'ABC');"));
1379
1380 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1381 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698