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

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

Issue 2648263006: <webview>: Synchronize WebViewFocusInteractiveTest.FocusAndVisibility (Closed)
Patch Set: Address ehsank's comments. Created 3 years, 10 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/focus_visibility/guest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 // Now verify that the selection text propagates properly to RWHV. 1349 // Now verify that the selection text propagates properly to RWHV.
1350 content::RenderWidgetHostView* guest_rwhv = 1350 content::RenderWidgetHostView* guest_rwhv =
1351 guest_web_contents()->GetRenderWidgetHostView(); 1351 guest_web_contents()->GetRenderWidgetHostView();
1352 ASSERT_TRUE(guest_rwhv); 1352 ASSERT_TRUE(guest_rwhv);
1353 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); 1353 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText());
1354 ASSERT_TRUE(selected_text.size() >= 10u); 1354 ASSERT_TRUE(selected_text.size() >= 10u);
1355 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); 1355 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10));
1356 } 1356 }
1357 #endif 1357 #endif
1358 1358
1359 // Flaky on MacOS builders. https://crbug.com/670008 1359 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, FocusAndVisibility) {
1360 #if defined(OS_MACOSX)
1361 #define MAYBE_FocusAndVisibility DISABLED_FocusAndVisibility
1362 #else
1363 #define MAYBE_FocusAndVisibility FocusAndVisibility
1364 #endif
1365
1366 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
1367 ASSERT_TRUE(StartEmbeddedTestServer()); 1360 ASSERT_TRUE(StartEmbeddedTestServer());
1368 LoadAndLaunchPlatformApp("web_view/focus_visibility", 1361 LoadAndLaunchPlatformApp("web_view/focus_visibility",
1369 "WebViewInteractiveTest.LOADED"); 1362 "WebViewInteractiveTest.LOADED");
1370 ExtensionTestMessageListener test_init_listener( 1363 ExtensionTestMessageListener test_init_listener(
1371 "WebViewInteractiveTest.WebViewInitialized", false); 1364 "WebViewInteractiveTest.WebViewInitialized", false);
1372 SendMessageToEmbedder("init"); 1365 SendMessageToEmbedder(GetParam() ? "init-oopif" : "init");
1373 test_init_listener.WaitUntilSatisfied(); 1366 test_init_listener.WaitUntilSatisfied();
1374 1367
1375 // In oopif-webview, wait until the tab key triggers a focus change.
1376 std::unique_ptr<content::FrameFocusedObserver> frame_focus_observer =
1377 GetParam() ? base::MakeUnique<content::FrameFocusedObserver>(
1378 GetGuestViewManager()
1379 ->WaitForSingleGuestCreated()
1380 ->GetMainFrame())
1381 : nullptr;
1382
1383 // Send several tab-keys. The button inside webview should receive focus at 1368 // Send several tab-keys. The button inside webview should receive focus at
1384 // least once. 1369 // least once.
1385 for (size_t i = 0; i < 2; ++i) 1370 ExtensionTestMessageListener key_processed_listener(
1371 "WebViewInteractiveTest.KeyUp", false);
1372 #if defined(OS_MACOSX)
1373 // On mac, the event listener seems one key event behind and deadlocks. Send
1374 // an extra tab to get things unblocked. See http://crbug.com/685281 when
1375 // fixed, this can be removed.
1376 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1377 #endif
1378 for (size_t i = 0; i < 4; ++i) {
1379 key_processed_listener.Reset();
1386 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1380 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1387 if (frame_focus_observer) { 1381 EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied());
1388 frame_focus_observer->Wait();
1389 frame_focus_observer.reset();
1390 } 1382 }
1391 for (size_t i = 0; i < 2; ++i) 1383
1392 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1384 // Verify that the button in the guest receives focus.
1393 ExtensionTestMessageListener webview_button_focused_listener( 1385 ExtensionTestMessageListener webview_button_focused_listener(
1394 "WebViewInteractiveTest.WebViewButtonWasFocused", false); 1386 "WebViewInteractiveTest.WebViewButtonWasFocused", false);
1395 webview_button_focused_listener.set_failure_message( 1387 webview_button_focused_listener.set_failure_message(
1396 "WebViewInteractiveTest.WebViewButtonWasNotFocused"); 1388 "WebViewInteractiveTest.WebViewButtonWasNotFocused");
1397 SendMessageToEmbedder("verify"); 1389 SendMessageToEmbedder("verify");
1398 EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied()); 1390 EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied());
1399 // Now make the <webview> invisible. 1391
1392 // Reset the test and now make the <webview> invisible.
1400 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset", 1393 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset",
1401 false); 1394 false);
1402 SendMessageToEmbedder("reset"); 1395 SendMessageToEmbedder("reset");
1403 reset_listener.WaitUntilSatisfied(); 1396 reset_listener.WaitUntilSatisfied();
1404 ExtensionTestMessageListener did_hide_webview_listener( 1397 ExtensionTestMessageListener did_hide_webview_listener(
1405 "WebViewInteractiveTest.DidHideWebView", false); 1398 "WebViewInteractiveTest.DidHideWebView", false);
1406 SendMessageToEmbedder("hide-webview"); 1399 SendMessageToEmbedder("hide-webview");
1407 did_hide_webview_listener.WaitUntilSatisfied(); 1400 did_hide_webview_listener.WaitUntilSatisfied();
1401
1402
1408 // Send the same number of keys and verify that the webview button was not 1403 // Send the same number of keys and verify that the webview button was not
1409 // this time. 1404 // this time.
1410 for (size_t i = 0; i < 4; ++i) 1405 for (size_t i = 0; i < 4; ++i) {
1406 key_processed_listener.Reset();
1411 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1407 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1408 EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied());
1409 }
1412 ExtensionTestMessageListener webview_button_not_focused_listener( 1410 ExtensionTestMessageListener webview_button_not_focused_listener(
1413 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); 1411 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false);
1414 webview_button_not_focused_listener.set_failure_message( 1412 webview_button_not_focused_listener.set_failure_message(
1415 "WebViewInteractiveTest.WebViewButtonWasFocused"); 1413 "WebViewInteractiveTest.WebViewButtonWasFocused");
1416 SendMessageToEmbedder("verify"); 1414 SendMessageToEmbedder("verify");
1417 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); 1415 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied());
1418 } 1416 }
1419 1417
1420 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusSimple) { 1418 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusSimple) {
1421 TestHelper("testKeyboardFocusSimple", "web_view/focus", NO_TEST_SERVER); 1419 TestHelper("testKeyboardFocusSimple", "web_view/focus", NO_TEST_SERVER);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( 1508 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
1511 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false)); 1509 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false));
1512 1510
1513 next_step_listener.Reset(); 1511 next_step_listener.Reset();
1514 EXPECT_TRUE(content::ExecuteScript( 1512 EXPECT_TRUE(content::ExecuteScript(
1515 embedder_web_contents(), 1513 embedder_web_contents(),
1516 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');")); 1514 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');"));
1517 1515
1518 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1516 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1519 } 1517 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/focus_visibility/guest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698