Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1162 rwhva->OnGestureEvent(&gesture_tap_down); | 1162 rwhva->OnGestureEvent(&gesture_tap_down); |
| 1163 ui::GestureEventDetails gesture_tap_details(ui::ET_GESTURE_TAP); | 1163 ui::GestureEventDetails gesture_tap_details(ui::ET_GESTURE_TAP); |
| 1164 gesture_tap_details.set_device_type( | 1164 gesture_tap_details.set_device_type( |
| 1165 ui::GestureDeviceType::DEVICE_TOUCHSCREEN); | 1165 ui::GestureDeviceType::DEVICE_TOUCHSCREEN); |
| 1166 gesture_tap_details.set_tap_count(1); | 1166 gesture_tap_details.set_tap_count(1); |
| 1167 ui::GestureEvent gesture_tap(point.x(), point.y(), 0, base::TimeTicks::Now(), | 1167 ui::GestureEvent gesture_tap(point.x(), point.y(), 0, base::TimeTicks::Now(), |
| 1168 gesture_tap_details); | 1168 gesture_tap_details); |
| 1169 rwhva->OnGestureEvent(&gesture_tap); | 1169 rwhva->OnGestureEvent(&gesture_tap); |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 #endif | |
| 1173 | |
| 1172 // TODO(wjmaclean): The next two functions are a modified version of | 1174 // TODO(wjmaclean): The next two functions are a modified version of |
| 1173 // SurfaceHitTestReadyNotifier that (1) works for BrowserPlugin-based guests, | 1175 // SurfaceHitTestReadyNotifier that (1) works for BrowserPlugin-based guests, |
| 1174 // and (2) links outside of content-browsertests. At some point in time we | 1176 // and (2) links outside of content-browsertests. At some point in time we |
| 1175 // should probably merge these. | 1177 // should probably merge these. |
|
alexmos
2017/03/31 21:57:55
Update this comment?
kenrb
2017/04/03 17:28:29
Removed instead, it becomes obsolete with this cha
| |
| 1176 namespace { | 1178 namespace { |
| 1177 | 1179 |
| 1178 bool ContainsSurfaceId(const cc::SurfaceId& container_surface_id, | 1180 class SurfaceHitTestReadyNotifier { |
| 1179 RenderWidgetHostViewChildFrame* target_view) { | 1181 public: |
| 1182 SurfaceHitTestReadyNotifier(RenderWidgetHostViewBase* target_view); | |
| 1183 ~SurfaceHitTestReadyNotifier() {} | |
| 1184 | |
| 1185 void WaitForSurfaceReady(RenderWidgetHostViewBase* root_container); | |
| 1186 | |
| 1187 private: | |
| 1188 bool ContainsSurfaceId(const cc::SurfaceId& container_surface_id); | |
| 1189 | |
| 1190 cc::SurfaceManager* surface_manager_; | |
| 1191 cc::SurfaceId root_surface_id_; | |
|
alexmos
2017/03/31 21:57:55
This appears to be unused now.
kenrb
2017/04/03 17:28:29
Done.
| |
| 1192 RenderWidgetHostViewBase* target_view_; | |
| 1193 | |
| 1194 DISALLOW_COPY_AND_ASSIGN(SurfaceHitTestReadyNotifier); | |
| 1195 }; | |
| 1196 | |
| 1197 SurfaceHitTestReadyNotifier::SurfaceHitTestReadyNotifier( | |
| 1198 RenderWidgetHostViewBase* target_view) | |
| 1199 : target_view_(target_view) { | |
| 1200 surface_manager_ = GetSurfaceManager(); | |
| 1201 } | |
| 1202 | |
| 1203 void SurfaceHitTestReadyNotifier::WaitForSurfaceReady( | |
| 1204 RenderWidgetHostViewBase* root_view) { | |
| 1205 cc::SurfaceId root_surface_id = root_view->SurfaceIdForTesting(); | |
| 1206 while (!ContainsSurfaceId(root_surface_id)) { | |
| 1207 // TODO(kenrb): Need a better way to do this. If | |
| 1208 // RenderWidgetHostViewBase lifetime observer lands (see | |
| 1209 // https://codereview.chromium.org/1711103002/), we can add a callback | |
| 1210 // from OnSwapCompositorFrame and avoid this busy waiting, which is very | |
| 1211 // frequent in tests in this file. | |
|
alexmos
2017/03/31 21:57:55
"in this file" is outdated, since the tests are no
kenrb
2017/04/03 17:28:29
Done. Also reworked the comment a bit.
| |
| 1212 base::RunLoop run_loop; | |
| 1213 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 1214 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); | |
| 1215 run_loop.Run(); | |
| 1216 } | |
| 1217 } | |
| 1218 | |
| 1219 bool SurfaceHitTestReadyNotifier::ContainsSurfaceId( | |
| 1220 const cc::SurfaceId& container_surface_id) { | |
| 1180 if (!container_surface_id.is_valid()) | 1221 if (!container_surface_id.is_valid()) |
| 1181 return false; | 1222 return false; |
| 1182 | 1223 |
| 1183 cc::Surface* container_surface = | 1224 cc::Surface* container_surface = |
| 1184 GetSurfaceManager()->GetSurfaceForId(container_surface_id); | 1225 surface_manager_->GetSurfaceForId(container_surface_id); |
| 1185 if (!container_surface || !container_surface->active_referenced_surfaces()) | 1226 if (!container_surface || !container_surface->active_referenced_surfaces()) |
| 1186 return false; | 1227 return false; |
| 1187 | 1228 |
| 1188 for (const cc::SurfaceId& id : | 1229 for (const cc::SurfaceId& id : |
| 1189 *container_surface->active_referenced_surfaces()) { | 1230 *container_surface->active_referenced_surfaces()) { |
| 1190 if (id == target_view->SurfaceIdForTesting() || | 1231 if (id == target_view_->SurfaceIdForTesting() || ContainsSurfaceId(id)) |
| 1191 ContainsSurfaceId(id, target_view)) | |
| 1192 return true; | 1232 return true; |
| 1193 } | 1233 } |
| 1194 return false; | 1234 return false; |
| 1195 } | 1235 } |
| 1196 | 1236 |
| 1197 } // namespace | 1237 } // namespace |
| 1198 | 1238 |
| 1239 #if defined(USE_AURA) | |
| 1199 void WaitForGuestSurfaceReady(content::WebContents* guest_web_contents) { | 1240 void WaitForGuestSurfaceReady(content::WebContents* guest_web_contents) { |
| 1200 RenderWidgetHostViewChildFrame* child_view = | 1241 RenderWidgetHostViewChildFrame* child_view = |
| 1201 static_cast<RenderWidgetHostViewChildFrame*>( | 1242 static_cast<RenderWidgetHostViewChildFrame*>( |
| 1202 guest_web_contents->GetRenderWidgetHostView()); | 1243 guest_web_contents->GetRenderWidgetHostView()); |
| 1203 | 1244 |
| 1204 cc::SurfaceId root_surface_id = | 1245 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
| 1205 static_cast<RenderWidgetHostViewAura*>( | 1246 static_cast<content::WebContentsImpl*>(guest_web_contents) |
| 1206 static_cast<content::WebContentsImpl*>(guest_web_contents) | 1247 ->GetOuterWebContents() |
| 1207 ->GetOuterWebContents() | 1248 ->GetRenderWidgetHostView()); |
| 1208 ->GetRenderWidgetHostView()) | |
| 1209 ->SurfaceIdForTesting(); | |
| 1210 | 1249 |
| 1211 while (!ContainsSurfaceId(root_surface_id, child_view)) { | 1250 SurfaceHitTestReadyNotifier notifier(child_view); |
| 1212 base::RunLoop run_loop; | 1251 notifier.WaitForSurfaceReady(root_view); |
| 1213 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 1214 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); | |
| 1215 run_loop.Run(); | |
| 1216 } | |
| 1217 } | 1252 } |
| 1253 | |
| 1218 #endif | 1254 #endif |
| 1219 | 1255 |
| 1256 void WaitForChildFrameSurfaceReady(content::RenderFrameHost* child_frame) { | |
| 1257 RenderWidgetHostViewBase* child_view = | |
| 1258 static_cast<RenderFrameHostImpl*>(child_frame) | |
| 1259 ->GetRenderWidgetHost() | |
| 1260 ->GetView(); | |
| 1261 if (!child_view->IsRenderWidgetHostViewChildFrame()) | |
|
alexmos
2017/03/31 21:57:54
Do we care to handle the case where child_view is
kenrb
2017/04/03 17:28:29
Added.
| |
| 1262 return; | |
| 1263 | |
| 1264 RenderWidgetHostViewBase* root_view = | |
| 1265 static_cast<RenderWidgetHostViewChildFrame*>(child_view) | |
| 1266 ->FrameConnectorForTesting() | |
| 1267 ->GetRootRenderWidgetHostViewForTesting(); | |
| 1268 | |
| 1269 SurfaceHitTestReadyNotifier notifier(child_view); | |
| 1270 notifier.WaitForSurfaceReady(root_view); | |
| 1271 } | |
| 1272 | |
| 1220 TitleWatcher::TitleWatcher(WebContents* web_contents, | 1273 TitleWatcher::TitleWatcher(WebContents* web_contents, |
| 1221 const base::string16& expected_title) | 1274 const base::string16& expected_title) |
| 1222 : WebContentsObserver(web_contents) { | 1275 : WebContentsObserver(web_contents) { |
| 1223 expected_titles_.push_back(expected_title); | 1276 expected_titles_.push_back(expected_title); |
| 1224 } | 1277 } |
| 1225 | 1278 |
| 1226 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { | 1279 void TitleWatcher::AlsoWaitForTitle(const base::string16& expected_title) { |
| 1227 expected_titles_.push_back(expected_title); | 1280 expected_titles_.push_back(expected_title); |
| 1228 } | 1281 } |
| 1229 | 1282 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1874 bool user_gesture, | 1927 bool user_gesture, |
| 1875 bool last_unlocked_by_target, | 1928 bool last_unlocked_by_target, |
| 1876 bool privileged) { | 1929 bool privileged) { |
| 1877 IPC::IpcSecurityTestUtil::PwnMessageReceived( | 1930 IPC::IpcSecurityTestUtil::PwnMessageReceived( |
| 1878 process->GetChannel(), | 1931 process->GetChannel(), |
| 1879 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, | 1932 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, |
| 1880 privileged)); | 1933 privileged)); |
| 1881 } | 1934 } |
| 1882 | 1935 |
| 1883 } // namespace content | 1936 } // namespace content |
| OLD | NEW |