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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 2116663002: Test for BrowserPlugin-based WebView Focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/process/kill.h" 16 #include "base/process/kill.h"
17 #include "base/rand_util.h" 17 #include "base/rand_util.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_piece.h" 19 #include "base/strings/string_piece.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/synchronization/waitable_event.h" 21 #include "base/synchronization/waitable_event.h"
22 #include "base/test/test_timeouts.h" 22 #include "base/test/test_timeouts.h"
23 #include "base/values.h" 23 #include "base/values.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "content/browser/accessibility/accessibility_mode_helper.h" 25 #include "content/browser/accessibility/accessibility_mode_helper.h"
26 #include "content/browser/accessibility/browser_accessibility.h" 26 #include "content/browser/accessibility/browser_accessibility.h"
27 #include "content/browser/accessibility/browser_accessibility_manager.h" 27 #include "content/browser/accessibility/browser_accessibility_manager.h"
28 #include "content/browser/browser_plugin/browser_plugin_guest.h"
28 #include "content/browser/frame_host/frame_tree_node.h" 29 #include "content/browser/frame_host/frame_tree_node.h"
29 #include "content/browser/frame_host/render_frame_host_impl.h" 30 #include "content/browser/frame_host/render_frame_host_impl.h"
31 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
30 #include "content/browser/renderer_host/render_widget_host_impl.h" 32 #include "content/browser/renderer_host/render_widget_host_impl.h"
31 #include "content/browser/web_contents/web_contents_impl.h" 33 #include "content/browser/web_contents/web_contents_impl.h"
32 #include "content/browser/web_contents/web_contents_view.h" 34 #include "content/browser/web_contents/web_contents_view.h"
33 #include "content/common/input/synthetic_web_input_event_builders.h" 35 #include "content/common/input/synthetic_web_input_event_builders.h"
34 #include "content/common/input_messages.h" 36 #include "content/common/input_messages.h"
35 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
36 #include "content/public/browser/browser_context.h" 38 #include "content/public/browser/browser_context.h"
37 #include "content/public/browser/histogram_fetcher.h" 39 #include "content/public/browser/histogram_fetcher.h"
38 #include "content/public/browser/navigation_entry.h" 40 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 ui::AXTreeUpdate GetAccessibilityTreeSnapshot(WebContents* web_contents) { 998 ui::AXTreeUpdate GetAccessibilityTreeSnapshot(WebContents* web_contents) {
997 WebContentsImpl* web_contents_impl = 999 WebContentsImpl* web_contents_impl =
998 static_cast<WebContentsImpl*>(web_contents); 1000 static_cast<WebContentsImpl*>(web_contents);
999 BrowserAccessibilityManager* manager = 1001 BrowserAccessibilityManager* manager =
1000 web_contents_impl->GetRootBrowserAccessibilityManager(); 1002 web_contents_impl->GetRootBrowserAccessibilityManager();
1001 if (!manager) 1003 if (!manager)
1002 return ui::AXTreeUpdate(); 1004 return ui::AXTreeUpdate();
1003 return manager->SnapshotAXTreeForTesting(); 1005 return manager->SnapshotAXTreeForTesting();
1004 } 1006 }
1005 1007
1008 bool IsWebContentsBrowserPluginFocused(content::WebContents* web_contents) {
1009 WebContentsImpl* web_contents_impl =
1010 static_cast<WebContentsImpl*>(web_contents);
1011 BrowserPluginGuest* browser_plugin_guest =
1012 web_contents_impl->GetBrowserPluginGuest();
1013 return browser_plugin_guest ? browser_plugin_guest->focused() : false;
1014 }
1015
1016 #if defined(USE_AURA)
1017 void SendRoutedTouchTapSequence(content::WebContents* web_contents,
1018 gfx::Point point) {
1019 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
1020 web_contents->GetRenderWidgetHostView());
1021 ui::TouchEvent touch_start(ui::ET_TOUCH_PRESSED, point, 0,
1022 base::TimeTicks::Now());
1023 rwhva->OnTouchEvent(&touch_start);
1024 ui::TouchEvent touch_end(ui::ET_TOUCH_RELEASED, point, 0,
1025 base::TimeTicks::Now());
1026 rwhva->OnTouchEvent(&touch_end);
1027 }
1028
1029 void SendRoutedGestureTapSequence(content::WebContents* web_contents,
1030 gfx::Point point) {
1031 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
1032 web_contents->GetRenderWidgetHostView());
1033 ui::GestureEventDetails gesture_tap_down_details(ui::ET_GESTURE_TAP_DOWN);
1034 gesture_tap_down_details.set_device_type(
1035 ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
1036 ui::GestureEvent gesture_tap_down(point.x(), point.y(), 0,
1037 base::TimeTicks::Now(),
1038 gesture_tap_down_details);
1039 rwhva->OnGestureEvent(&gesture_tap_down);
1040 ui::GestureEventDetails gesture_tap_details(ui::ET_GESTURE_TAP);
1041 gesture_tap_details.set_device_type(
1042 ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
1043 gesture_tap_details.set_tap_count(1);
1044 ui::GestureEvent gesture_tap(point.x(), point.y(), 0, base::TimeTicks::Now(),
1045 gesture_tap_details);
1046 rwhva->OnGestureEvent(&gesture_tap);
1047 }
1048 #endif
1049
1050 void WaitForSurfaceReady(content::WebContents* web_contents) {
1051 RenderWidgetHostViewChildFrame* child_view =
1052 static_cast<RenderWidgetHostViewChildFrame*>(
1053 web_contents->GetRenderWidgetHostView());
1054 while (true) {
1055 base::RunLoop run_loop;
1056 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1057 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
1058 run_loop.Run();
1059 if (child_view->surface_frame_count() > 0)
Charlie Reis 2016/07/06 18:28:49 Should this check come before the first delayed ta
wjmaclean 2016/07/06 19:49:31 Done. The if-statement evloved as I worked on thi
1060 break;
1061 }
1062 }
1063
1006 TitleWatcher::TitleWatcher(WebContents* web_contents, 1064 TitleWatcher::TitleWatcher(WebContents* web_contents,
1007 const base::string16& expected_title) 1065 const base::string16& expected_title)
1008 : WebContentsObserver(web_contents), 1066 : WebContentsObserver(web_contents),
1009 message_loop_runner_(new MessageLoopRunner) { 1067 message_loop_runner_(new MessageLoopRunner) {
1010 EXPECT_TRUE(web_contents != NULL); 1068 EXPECT_TRUE(web_contents != NULL);
1011 expected_titles_.push_back(expected_title); 1069 expected_titles_.push_back(expected_title);
1012 } 1070 }
1013 1071
1014 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { 1072 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) {
1015 expected_titles_.push_back(expected_title); 1073 expected_titles_.push_back(expected_title);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1375 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1318 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) 1376 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN)
1319 return ack_result_; 1377 return ack_result_;
1320 base::RunLoop run_loop; 1378 base::RunLoop run_loop;
1321 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 1379 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
1322 run_loop.Run(); 1380 run_loop.Run();
1323 return ack_result_; 1381 return ack_result_;
1324 } 1382 }
1325 1383
1326 } // namespace content 1384 } // namespace content
OLDNEW
« content/public/test/browser_test_utils.h ('K') | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698