Skip to content

Commit

Permalink
Add FirstInputDelay integration test
Browse files Browse the repository at this point in the history
This CL adds a test for FID that tests equality between the JS value and
the value reported in UKM and in UMA.

Change-Id: I00de8c947895700d86788ee4a95ea228458bb25f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067077
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743212}
  • Loading branch information
npm1 authored and Commit Bot committed Feb 20, 2020
1 parent 6beb0c7 commit 38d5e42
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/page_load_metrics/integration_tests/metric_integration_test.h"

#include "base/test/trace_event_analyzer.h"
#include "chrome/test/base/ui_test_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h"

using base::Bucket;
using base::Value;
using trace_analyzer::Query;
using trace_analyzer::TraceAnalyzer;
using trace_analyzer::TraceEventVector;
using ukm::builders::PageLoad;

IN_PROC_BROWSER_TEST_F(MetricIntegrationTest, FirstInputDelay) {
LoadHTML(R"HTML(
<script>
runtest = async () => {
const observePromise = new Promise(resolve => {
new PerformanceObserver(e => {
e.getEntries().forEach(entry => {
const fid = entry.processingStart - entry.startTime;
resolve(fid);
})
}).observe({type: 'first-input', buffered: true});
});
return await observePromise;
};
</script>
)HTML");

StartTracing({"loading"});

content::SimulateMouseClickAt(web_contents(), 0,
blink::WebMouseEvent::Button::kLeft,
gfx::Point(10, 10));

// Check web perf API.
double expected_fid = EvalJs(web_contents(), "runtest()").ExtractDouble();
EXPECT_GT(expected_fid, 0.0);

ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));

// Check UKM.
ExpectUKMPageLoadMetric(PageLoad::kInteractiveTiming_FirstInputDelay4Name,
expected_fid);

// Check UMA.
auto samples = histogram_tester().GetAllSamples(
"PageLoad.InteractiveTiming.FirstInputDelay4");
EXPECT_EQ(1ul, samples.size());
EXPECT_EQ(samples[0], Bucket(expected_fid, 1));
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# found in the LICENSE file.

metric_integration_sources = [
"//chrome/browser/page_load_metrics/integration_tests/first_input_delay_browsertest.cc",
"//chrome/browser/page_load_metrics/integration_tests/layout_instability_browsertest.cc",
"//chrome/browser/page_load_metrics/integration_tests/metric_integration_test.cc",
"//chrome/browser/page_load_metrics/integration_tests/metric_integration_test.h",
Expand Down

0 comments on commit 38d5e42

Please sign in to comment.