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

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

Issue 2227563003: Refactoring button field and its type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix new instances Created 4 years, 4 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 content::WebContents* embedder_web_contents = 468 content::WebContents* embedder_web_contents =
469 GetFirstAppWindowWebContents(); 469 GetFirstAppWindowWebContents();
470 ASSERT_TRUE(embedder_web_contents); 470 ASSERT_TRUE(embedder_web_contents);
471 ASSERT_TRUE(guest_web_contents()); 471 ASSERT_TRUE(guest_web_contents());
472 // Click the guest to request fullscreen. 472 // Click the guest to request fullscreen.
473 ExtensionTestMessageListener passed_listener( 473 ExtensionTestMessageListener passed_listener(
474 "FULLSCREEN_STEP_PASSED", false); 474 "FULLSCREEN_STEP_PASSED", false);
475 passed_listener.set_failure_message("TEST_FAILED"); 475 passed_listener.set_failure_message("TEST_FAILED");
476 content::SimulateMouseClickAt(guest_web_contents(), 476 content::SimulateMouseClickAt(guest_web_contents(),
477 0, 477 0,
478 blink::WebMouseEvent::ButtonLeft, 478 blink::WebMouseEvent::Button::Left,
479 gfx::Point(20, 20)); 479 gfx::Point(20, 20));
480 ASSERT_TRUE(passed_listener.WaitUntilSatisfied()); 480 ASSERT_TRUE(passed_listener.WaitUntilSatisfied());
481 } 481 }
482 482
483 protected: 483 protected:
484 TestGuestViewManagerFactory factory_; 484 TestGuestViewManagerFactory factory_;
485 content::WebContents* guest_web_contents_; 485 content::WebContents* guest_web_contents_;
486 content::WebContents* embedder_web_contents_; 486 content::WebContents* embedder_web_contents_;
487 gfx::Point corner_; 487 gfx::Point corner_;
488 bool mouse_click_result_; 488 bool mouse_click_result_;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 RunAppHelper("testAdvanceFocus", "web_view/focus", NO_TEST_SERVER, 674 RunAppHelper("testAdvanceFocus", "web_view/focus", NO_TEST_SERVER,
675 &embedder_web_contents)); 675 &embedder_web_contents));
676 done_listener->WaitUntilSatisfied(); 676 done_listener->WaitUntilSatisfied();
677 } 677 }
678 678
679 { 679 {
680 ExtensionTestMessageListener listener("button1-focused", false); 680 ExtensionTestMessageListener listener("button1-focused", false);
681 listener.set_failure_message("TEST_FAILED"); 681 listener.set_failure_message("TEST_FAILED");
682 SimulateRWHMouseClick( 682 SimulateRWHMouseClick(
683 embedder_web_contents->GetRenderViewHost()->GetWidget(), 683 embedder_web_contents->GetRenderViewHost()->GetWidget(),
684 blink::WebMouseEvent::ButtonLeft, 200, 20); 684 blink::WebMouseEvent::Button::Left, 200, 20);
685 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, 685 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB,
686 ui::DomCode::TAB, ui::VKEY_TAB, false, false, 686 ui::DomCode::TAB, ui::VKEY_TAB, false, false,
687 false, false); 687 false, false);
688 ASSERT_TRUE(listener.WaitUntilSatisfied()); 688 ASSERT_TRUE(listener.WaitUntilSatisfied());
689 } 689 }
690 690
691 { 691 {
692 // Wait for button1 to be focused again, this means we were asked to 692 // Wait for button1 to be focused again, this means we were asked to
693 // move the focus to the next focusable element. 693 // move the focus to the next focusable element.
694 ExtensionTestMessageListener listener("button1-advance-focus", false); 694 ExtensionTestMessageListener listener("button1-advance-focus", false);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 // <webview> sees transformed coordinates, the point is transformed in 913 // <webview> sees transformed coordinates, the point is transformed in
914 // CrossProcessFrameConnector::TransformPointToRootCoordSpace. 914 // CrossProcessFrameConnector::TransformPointToRootCoordSpace.
915 IN_PROC_BROWSER_TEST_F(WebViewContextMenuInteractiveTest, 915 IN_PROC_BROWSER_TEST_F(WebViewContextMenuInteractiveTest,
916 ContextMenuParamCoordinates) { 916 ContextMenuParamCoordinates) {
917 TestHelper("testCoordinates", "web_view/context_menus/coordinates", 917 TestHelper("testCoordinates", "web_view/context_menus/coordinates",
918 NO_TEST_SERVER); 918 NO_TEST_SERVER);
919 ASSERT_TRUE(guest_web_contents()); 919 ASSERT_TRUE(guest_web_contents());
920 920
921 ContextMenuWaiter menu_observer(content::NotificationService::AllSources()); 921 ContextMenuWaiter menu_observer(content::NotificationService::AllSources());
922 SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost()->GetWidget(), 922 SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost()->GetWidget(),
923 blink::WebMouseEvent::ButtonRight, 10, 20); 923 blink::WebMouseEvent::Button::Right, 10, 20);
924 // Wait until the context menu is opened and closed. 924 // Wait until the context menu is opened and closed.
925 menu_observer.WaitForMenuOpenAndClose(); 925 menu_observer.WaitForMenuOpenAndClose();
926 ASSERT_EQ(10, menu_observer.params().x); 926 ASSERT_EQ(10, menu_observer.params().x);
927 ASSERT_EQ(20, menu_observer.params().y); 927 ASSERT_EQ(20, menu_observer.params().y);
928 } 928 }
929 929
930 // Tests whether <webview> context menu sees <webview> local coordinates in its 930 // Tests whether <webview> context menu sees <webview> local coordinates in its
931 // RenderViewContextMenu params, when it is subject to CSS transforms. 931 // RenderViewContextMenu params, when it is subject to CSS transforms.
932 // 932 //
933 // This test doesn't makes sense in --use-cross-process-frames-for-guests, since 933 // This test doesn't makes sense in --use-cross-process-frames-for-guests, since
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 embedder_web_contents()->GetRenderWidgetHostView()->GetViewBounds(); 967 embedder_web_contents()->GetRenderWidgetHostView()->GetViewBounds();
968 gfx::Rect guest_view_bounds = 968 gfx::Rect guest_view_bounds =
969 guest_web_contents()->GetRenderWidgetHostView()->GetViewBounds(); 969 guest_web_contents()->GetRenderWidgetHostView()->GetViewBounds();
970 ContextMenuWaiter menu_observer(content::NotificationService::AllSources()); 970 ContextMenuWaiter menu_observer(content::NotificationService::AllSources());
971 gfx::Point guest_window_point(150, 150); 971 gfx::Point guest_window_point(150, 150);
972 gfx::Point embedder_window_point = guest_window_point; 972 gfx::Point embedder_window_point = guest_window_point;
973 embedder_window_point += guest_view_bounds.OffsetFromOrigin(); 973 embedder_window_point += guest_view_bounds.OffsetFromOrigin();
974 embedder_window_point -= embedder_view_bounds.OffsetFromOrigin(); 974 embedder_window_point -= embedder_view_bounds.OffsetFromOrigin();
975 SimulateRWHMouseClick( 975 SimulateRWHMouseClick(
976 embedder_web_contents()->GetRenderViewHost()->GetWidget(), 976 embedder_web_contents()->GetRenderViewHost()->GetWidget(),
977 blink::WebMouseEvent::ButtonRight, 977 blink::WebMouseEvent::Button::Right,
978 /* Using window coordinates for the embedder */ 978 /* Using window coordinates for the embedder */
979 embedder_window_point.x(), embedder_window_point.y()); 979 embedder_window_point.x(), embedder_window_point.y());
980 980
981 menu_observer.WaitForMenuOpenAndClose(); 981 menu_observer.WaitForMenuOpenAndClose();
982 EXPECT_EQ(menu_observer.params().x, guest_window_point.x()); 982 EXPECT_EQ(menu_observer.params().x, guest_window_point.x());
983 EXPECT_EQ(menu_observer.params().y, guest_window_point.y()); 983 EXPECT_EQ(menu_observer.params().y, guest_window_point.y());
984 } 984 }
985 } 985 }
986 986
987 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, ExecuteCode) { 987 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, ExecuteCode) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); 1152 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
1153 ASSERT_TRUE(embedder_web_contents); 1153 ASSERT_TRUE(embedder_web_contents);
1154 ASSERT_TRUE(guest_web_contents()); 1154 ASSERT_TRUE(guest_web_contents());
1155 1155
1156 // 1) We click on the guest so that we get a focus event. 1156 // 1) We click on the guest so that we get a focus event.
1157 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); 1157 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false);
1158 next_step_listener.set_failure_message("TEST_STEP_FAILED"); 1158 next_step_listener.set_failure_message("TEST_STEP_FAILED");
1159 { 1159 {
1160 content::SimulateMouseClickAt(guest_web_contents(), 1160 content::SimulateMouseClickAt(guest_web_contents(),
1161 0, 1161 0,
1162 blink::WebMouseEvent::ButtonLeft, 1162 blink::WebMouseEvent::Button::Left,
1163 gfx::Point(10, 10)); 1163 gfx::Point(10, 10));
1164 EXPECT_TRUE(content::ExecuteScript( 1164 EXPECT_TRUE(content::ExecuteScript(
1165 embedder_web_contents, 1165 embedder_web_contents,
1166 "window.runCommand('testFocusRestoredRunNextStep', 1);")); 1166 "window.runCommand('testFocusRestoredRunNextStep', 1);"));
1167 } 1167 }
1168 // Wait for the next step to complete. 1168 // Wait for the next step to complete.
1169 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1169 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1170 1170
1171 // 2) We click on the embedder so the guest's focus goes away and it observes 1171 // 2) We click on the embedder so the guest's focus goes away and it observes
1172 // a blur event. 1172 // a blur event.
1173 next_step_listener.Reset(); 1173 next_step_listener.Reset();
1174 { 1174 {
1175 content::SimulateMouseClickAt(embedder_web_contents, 1175 content::SimulateMouseClickAt(embedder_web_contents,
1176 0, 1176 0,
1177 blink::WebMouseEvent::ButtonLeft, 1177 blink::WebMouseEvent::Button::Left,
1178 gfx::Point(200, 20)); 1178 gfx::Point(200, 20));
1179 EXPECT_TRUE(content::ExecuteScript( 1179 EXPECT_TRUE(content::ExecuteScript(
1180 embedder_web_contents, 1180 embedder_web_contents,
1181 "window.runCommand('testFocusRestoredRunNextStep', 2);")); 1181 "window.runCommand('testFocusRestoredRunNextStep', 2);"));
1182 } 1182 }
1183 // Wait for the next step to complete. 1183 // Wait for the next step to complete.
1184 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1184 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1185 1185
1186 // 3) We click on the guest again to bring back focus directly to the previous 1186 // 3) We click on the guest again to bring back focus directly to the previous
1187 // input element, then we ensure text_input_type is properly set. 1187 // input element, then we ensure text_input_type is properly set.
1188 next_step_listener.Reset(); 1188 next_step_listener.Reset();
1189 { 1189 {
1190 content::SimulateMouseClickAt(guest_web_contents(), 1190 content::SimulateMouseClickAt(guest_web_contents(),
1191 0, 1191 0,
1192 blink::WebMouseEvent::ButtonLeft, 1192 blink::WebMouseEvent::Button::Left,
1193 gfx::Point(10, 10)); 1193 gfx::Point(10, 10));
1194 EXPECT_TRUE(content::ExecuteScript( 1194 EXPECT_TRUE(content::ExecuteScript(
1195 embedder_web_contents, 1195 embedder_web_contents,
1196 "window.runCommand('testFocusRestoredRunNextStep', 3)")); 1196 "window.runCommand('testFocusRestoredRunNextStep', 3)"));
1197 } 1197 }
1198 // Wait for the next step to complete. 1198 // Wait for the next step to complete.
1199 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1199 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1200 1200
1201 // |text_input_client| is not available for mac and android. 1201 // |text_input_client| is not available for mac and android.
1202 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 1202 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 SetupTest("web_view/text_selection", 1297 SetupTest("web_view/text_selection",
1298 "/extensions/platform_apps/web_view/text_selection/guest.html"); 1298 "/extensions/platform_apps/web_view/text_selection/guest.html");
1299 ASSERT_TRUE(guest_web_contents()); 1299 ASSERT_TRUE(guest_web_contents());
1300 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( 1300 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
1301 GetPlatformAppWindow())); 1301 GetPlatformAppWindow()));
1302 1302
1303 // Wait until guest sees a context menu, select an arbitrary item (copy). 1303 // Wait until guest sees a context menu, select an arbitrary item (copy).
1304 ExtensionTestMessageListener ctx_listener("MSG_CONTEXTMENU", false); 1304 ExtensionTestMessageListener ctx_listener("MSG_CONTEXTMENU", false);
1305 ContextMenuNotificationObserver menu_observer(IDC_CONTENT_CONTEXT_COPY); 1305 ContextMenuNotificationObserver menu_observer(IDC_CONTENT_CONTEXT_COPY);
1306 SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost()->GetWidget(), 1306 SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost()->GetWidget(),
1307 blink::WebMouseEvent::ButtonRight, 20, 20); 1307 blink::WebMouseEvent::Button::Right, 20, 20);
1308 ASSERT_TRUE(ctx_listener.WaitUntilSatisfied()); 1308 ASSERT_TRUE(ctx_listener.WaitUntilSatisfied());
1309 1309
1310 // Now verify that the selection text propagates properly to RWHV. 1310 // Now verify that the selection text propagates properly to RWHV.
1311 content::RenderWidgetHostView* guest_rwhv = 1311 content::RenderWidgetHostView* guest_rwhv =
1312 guest_web_contents()->GetRenderWidgetHostView(); 1312 guest_web_contents()->GetRenderWidgetHostView();
1313 ASSERT_TRUE(guest_rwhv); 1313 ASSERT_TRUE(guest_rwhv);
1314 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); 1314 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText());
1315 ASSERT_TRUE(selected_text.size() >= 10u); 1315 ASSERT_TRUE(selected_text.size() >= 10u);
1316 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); 1316 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10));
1317 } 1317 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( 1387 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
1388 GetPlatformAppWindow(), ui::VKEY_C, false, false, false, false)); 1388 GetPlatformAppWindow(), ui::VKEY_C, false, false, false, false));
1389 1389
1390 next_step_listener.Reset(); 1390 next_step_listener.Reset();
1391 EXPECT_TRUE(content::ExecuteScript( 1391 EXPECT_TRUE(content::ExecuteScript(
1392 embedder_web_contents(), 1392 embedder_web_contents(),
1393 "window.runCommand('testKeyboardFocusRunNextStep', 'aBc');")); 1393 "window.runCommand('testKeyboardFocusRunNextStep', 'aBc');"));
1394 1394
1395 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1395 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1396 } 1396 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/guest_view/web_view_browsertest.cc ('k') | chrome/browser/apps/window_controls_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698