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

Unified Diff: content/test/content_browser_test_utils_internal.cc

Issue 1734403003: Add helper class for tests using browser process hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gcc compile warnings Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/content_browser_test_utils_internal.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/content_browser_test_utils_internal.cc
diff --git a/content/test/content_browser_test_utils_internal.cc b/content/test/content_browser_test_utils_internal.cc
index 431e2abeaf5fbcc64e5981f956484f7ee2c62e36..1d36a8e5c8c0cbfb0a867ef702c616b692f0f034 100644
--- a/content/test/content_browser_test_utils_internal.cc
+++ b/content/test/content_browser_test_utils_internal.cc
@@ -12,9 +12,18 @@
#include <vector>
#include "base/strings/stringprintf.h"
+#include "base/test/test_timeouts.h"
+#include "base/thread_task_runner_handle.h"
+#include "cc/surfaces/surface.h"
+#include "cc/surfaces/surface_manager.h"
+#include "content/browser/compositor/delegated_frame_host.h"
+#include "content/browser/compositor/surface_utils.h"
+#include "content/browser/frame_host/cross_process_frame_connector.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/frame_host/render_frame_proxy_host.h"
+#include "content/browser/frame_host/render_widget_host_view_child_frame.h"
+#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_throttle.h"
#include "content/public/test/browser_test_utils.h"
@@ -256,6 +265,45 @@ class HttpRequestStallThrottle : public ResourceThrottle {
} // namespace
+SurfaceHitTestReadyNotifier::SurfaceHitTestReadyNotifier(
+ RenderWidgetHostViewChildFrame* target_view)
+ : target_view_(target_view) {
+ surface_manager_ = GetSurfaceManager();
+}
+
+void SurfaceHitTestReadyNotifier::WaitForSurfaceReady() {
+ root_surface_id_ = target_view_->FrameConnectorForTesting()
+ ->GetRootRenderWidgetHostViewForTesting()
+ ->SurfaceIdForTesting();
+ if (ContainsSurfaceId())
+ return;
+
+ while (true) {
+ // TODO(kenrb): Need a better way to do this. If
+ // RenderWidgetHostViewBase lifetime observer lands (see
+ // https://codereview.chromium.org/1711103002/), we can add a callback
+ // from OnSwapCompositorFrame and avoid this busy waiting, which is very
+ // frequent in tests in this file.
+ base::RunLoop run_loop;
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
+ run_loop.Run();
+ if (ContainsSurfaceId())
+ break;
+ }
+}
+
+bool SurfaceHitTestReadyNotifier::ContainsSurfaceId() {
+ if (root_surface_id_.is_null())
+ return false;
+ for (cc::SurfaceId id : surface_manager_->GetSurfaceForId(root_surface_id_)
+ ->referenced_surfaces()) {
+ if (id == target_view_->SurfaceIdForTesting())
+ return true;
+ }
+ return false;
+}
+
NavigationStallDelegate::NavigationStallDelegate(const GURL& url) : url_(url) {}
void NavigationStallDelegate::RequestBeginning(
« no previous file with comments | « content/test/content_browser_test_utils_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698