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

Unified Diff: chrome/browser/devtools/devtools_sanity_browsertest.cc

Issue 1704723002: DevTools: add input event instrumentation test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative attempt to fix MacOS 10.6 flakiness 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 | « no previous file | chrome/test/data/devtools/latency_info.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/devtools_sanity_browsertest.cc
diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc
index 2803ecc0a279a7713353328e8abede3e968df5f9..39013af3b61d4ac56e1e2cb6ad9a82ba7ee16ad5 100644
--- a/chrome/browser/devtools/devtools_sanity_browsertest.cc
+++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc
@@ -49,6 +49,8 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_widget_host.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/worker_service.h"
#include "content/public/browser/worker_service_observer.h"
@@ -62,6 +64,7 @@
#include "extensions/common/value_builder.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/gl/gl_switches.h"
@@ -89,6 +92,7 @@ const char kPageWithContentScript[] =
const char kNavigateBackTestPage[] =
"files/devtools/navigate_back.html";
const char kWindowOpenTestPage[] = "files/devtools/window_open.html";
+const char kLatencyInfoTestPage[] = "files/devtools/latency_info.html";
const char kChunkedTestPage[] = "chunked";
const char kSlowTestPage[] =
"chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2";
@@ -102,6 +106,25 @@ const char kReloadSharedWorkerTestWorker[] =
"files/workers/debug_shared_worker_initialization.js";
template <typename... T>
+void DispatchOnTestSuiteSkipCheck(DevToolsWindow* window,
+ const char* method,
+ T... args) {
+ RenderViewHost* rvh = DevToolsWindowTesting::Get(window)
+ ->main_web_contents()
+ ->GetRenderViewHost();
+ std::string result;
+ const char* args_array[] = {method, args...};
+ std::ostringstream script;
+ script << "uiTests.dispatchOnTestSuite([";
+ for (size_t i = 0; i < arraysize(args_array); ++i)
+ script << (i ? "," : "") << '\"' << args_array[i] << '\"';
+ script << "])";
+ ASSERT_TRUE(
+ content::ExecuteScriptAndExtractString(rvh, script.str(), &result));
+ EXPECT_EQ("[OK]", result);
+}
+
+template <typename... T>
void DispatchOnTestSuite(DevToolsWindow* window,
const char* method,
T... args) {
@@ -119,16 +142,7 @@ void DispatchOnTestSuite(DevToolsWindow* window,
" '' + (window.uiTests && (typeof uiTests.dispatchOnTestSuite)));",
&result));
ASSERT_EQ("function", result) << "DevTools front-end is broken.";
-
- const char* args_array[] = {method, args...};
- std::ostringstream script;
- script << "uiTests.dispatchOnTestSuite([";
- for (size_t i = 0; i < arraysize(args_array); ++i)
- script << (i ? "," : "") << '\"' << args_array[i] << '\"';
- script << "])";
- ASSERT_TRUE(
- content::ExecuteScriptAndExtractString(rvh, script.str(), &result));
- EXPECT_EQ("[OK]", result);
+ DispatchOnTestSuiteSkipCheck(window, method, args...);
}
void RunTestFunction(DevToolsWindow* window, const char* test_name) {
@@ -168,6 +182,21 @@ class DevToolsSanityTest : public InProcessBrowserTest {
CloseDevToolsWindow();
}
+ template <typename... T>
+ void RunTestMethod(const char* method, T... args) {
+ DispatchOnTestSuiteSkipCheck(window_, method, args...);
+ }
+
+ template <typename... T>
+ void DispatchAndWait(const char* method, T... args) {
+ DispatchOnTestSuiteSkipCheck(window_, "waitForAsync", method, args...);
+ }
+
+ template <typename... T>
+ void DispatchInPageAndWait(const char* method, T... args) {
+ DispatchAndWait("invokePageFunctionAsync", method, args...);
+ }
+
void LoadTestPage(const std::string& test_page) {
GURL url = spawned_test_server()->GetURL(test_page);
ui_test_utils::NavigateToURL(browser(), url);
@@ -1145,8 +1174,46 @@ class DevToolsPixelOutputTests : public DevToolsSanityTest {
#else
#define MAYBE_TestScreenshotRecording TestScreenshotRecording
#endif
-// Tests raw headers text.
IN_PROC_BROWSER_TEST_F(DevToolsPixelOutputTests,
MAYBE_TestScreenshotRecording) {
RunTest("testScreenshotRecording", std::string());
}
+
+// This test enables switches::kUseGpuInTests which causes false positives
+// with MemorySanitizer.
+#if defined(MEMORY_SANITIZER) || defined(ADDRESS_SANITIZER)
+#define MAYBE_TestLatencyInfoInstrumentation \
+ DISABLED_TestLatencyInfoInstrumentation
+#else
+#define MAYBE_TestLatencyInfoInstrumentation TestLatencyInfoInstrumentation
+#endif
+IN_PROC_BROWSER_TEST_F(DevToolsPixelOutputTests,
+ MAYBE_TestLatencyInfoInstrumentation) {
+ WebContents* web_contents = GetInspectedTab();
+ OpenDevToolsWindow(kLatencyInfoTestPage, false);
+ RunTestMethod("enableExperiment", "timelineLatencyInfo");
+ DispatchAndWait("startTimeline");
+
+ for (int i = 0; i < 3; ++i) {
+ SimulateMouseEvent(web_contents, blink::WebInputEvent::MouseMove,
+ gfx::Point(30, 60));
+ DispatchInPageAndWait("waitForEvent", "mousemove");
+ }
+
+ SimulateMouseClickAt(web_contents, 0, blink::WebPointerProperties::ButtonLeft,
+ gfx::Point(30, 60));
+ DispatchInPageAndWait("waitForEvent", "click");
+
+ SimulateMouseWheelEvent(web_contents, gfx::Point(300, 100),
+ gfx::Vector2d(0, 120));
+ DispatchInPageAndWait("waitForEvent", "wheel");
+
+ SimulateTapAt(web_contents, gfx::Point(30, 60));
+ DispatchInPageAndWait("waitForEvent", "gesturetap");
+
+ DispatchAndWait("stopTimeline");
+ RunTestMethod("checkInputEventsPresent", "MouseMove", "MouseDown",
+ "MouseWheel", "GestureTap");
+
+ CloseDevToolsWindow();
+}
« no previous file with comments | « no previous file | chrome/test/data/devtools/latency_info.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698