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

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

Issue 2474323002: Implement WebContentsViewChildFrame::TakeFocus. (Closed)
Patch Set: remove logging and move pant kickcing out of loop Created 3 years, 11 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 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Flaky on MacOS builders. https://crbug.com/670008
1360 #if defined(OS_MACOSX) 1360 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, FocusAndVisibility) {
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()); 1361 ASSERT_TRUE(StartEmbeddedTestServer());
1368 LoadAndLaunchPlatformApp("web_view/focus_visibility", 1362 LoadAndLaunchPlatformApp("web_view/focus_visibility",
1369 "WebViewInteractiveTest.LOADED"); 1363 "WebViewInteractiveTest.LOADED");
1364 if (GetParam())
1365 SendMessageToEmbedder("setOopif");
1366
1370 ExtensionTestMessageListener test_init_listener( 1367 ExtensionTestMessageListener test_init_listener(
1371 "WebViewInteractiveTest.WebViewInitialized", false); 1368 "WebViewInteractiveTest.WebViewInitialized", false);
1372 SendMessageToEmbedder("init"); 1369 SendMessageToEmbedder("init");
1373 test_init_listener.WaitUntilSatisfied(); 1370 test_init_listener.WaitUntilSatisfied();
1374 1371
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 1372 // Send several tab-keys. The button inside webview should receive focus at
1384 // least once. 1373 // least once.
1385 for (size_t i = 0; i < 2; ++i) 1374 ExtensionTestMessageListener key_processed_listener(
1375 "WebViewInteractiveTest.KeyUp", false);
1376 #if defined(OS_MACOSX)
1377 // Mac needs a kick in the pants before wait doesn't deadlock.
1378 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1379 #endif
1380 for (size_t i = 0; i < 4; ++i) {
1381 key_processed_listener.Reset();
1386 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1382 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1387 if (frame_focus_observer) { 1383 EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied());
1388 frame_focus_observer->Wait();
1389 frame_focus_observer.reset();
1390 } 1384 }
1391 for (size_t i = 0; i < 2; ++i)
1392 SendKeyPressToPlatformApp(ui::VKEY_TAB);
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 // Now make the <webview> invisible.
1400 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset", 1392 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset",
1401 false); 1393 false);
1402 SendMessageToEmbedder("reset"); 1394 SendMessageToEmbedder("reset");
1403 reset_listener.WaitUntilSatisfied(); 1395 reset_listener.WaitUntilSatisfied();
1404 ExtensionTestMessageListener did_hide_webview_listener( 1396 ExtensionTestMessageListener did_hide_webview_listener(
1405 "WebViewInteractiveTest.DidHideWebView", false); 1397 "WebViewInteractiveTest.DidHideWebView", false);
1406 SendMessageToEmbedder("hide-webview"); 1398 SendMessageToEmbedder("hide-webview");
1407 did_hide_webview_listener.WaitUntilSatisfied(); 1399 did_hide_webview_listener.WaitUntilSatisfied();
1408 // Send the same number of keys and verify that the webview button was not 1400 // Send the same number of keys and verify that the webview button was not
1409 // this time. 1401 // this time.
1410 for (size_t i = 0; i < 4; ++i) 1402 for (size_t i = 0; i < 4; ++i) {
1403 key_processed_listener.Reset();
1411 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1404 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1405 EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied());
1406 }
1412 ExtensionTestMessageListener webview_button_not_focused_listener( 1407 ExtensionTestMessageListener webview_button_not_focused_listener(
1413 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); 1408 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false);
1414 webview_button_not_focused_listener.set_failure_message( 1409 webview_button_not_focused_listener.set_failure_message(
1415 "WebViewInteractiveTest.WebViewButtonWasFocused"); 1410 "WebViewInteractiveTest.WebViewButtonWasFocused");
1416 SendMessageToEmbedder("verify"); 1411 SendMessageToEmbedder("verify");
1417 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); 1412 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied());
1418 } 1413 }
1419 1414
1420 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusSimple) { 1415 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusSimple) {
1421 TestHelper("testKeyboardFocusSimple", "web_view/focus", NO_TEST_SERVER); 1416 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( 1505 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
1511 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false)); 1506 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false));
1512 1507
1513 next_step_listener.Reset(); 1508 next_step_listener.Reset();
1514 EXPECT_TRUE(content::ExecuteScript( 1509 EXPECT_TRUE(content::ExecuteScript(
1515 embedder_web_contents(), 1510 embedder_web_contents(),
1516 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');")); 1511 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');"));
1517 1512
1518 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1513 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1519 } 1514 }
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