Commit cce1633c authored by Tom Lukaszewicz's avatar Tom Lukaszewicz Committed by Josip Sokcevic

Tab Search: Make metrics test more robust.

Fixes break in existing tests.

Bug: 1099917
Change-Id: I4b110eb133128b68994f35b4d16a9e38e49da7d3
Reviewed-on: https://chrome-internal-review.googlesource.com/c/chrome/browser/resources/tab_search/+/3304907Reviewed-by: default avatarYuheng Huang <yuhengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819626}
parent d714ca2e
...@@ -232,13 +232,15 @@ suite('TabSearchAppTest', () => { ...@@ -232,13 +232,15 @@ suite('TabSearchAppTest', () => {
}); });
test('Verify initial tab render time is logged correctly', async () => { test('Verify initial tab render time is logged correctly', async () => {
// |recordTimeCalled| tracks the number of calls to recordTime(). // |metricNames| tracks thow many times recordTime() has been called for
let recordTimeCalled = 0; // a metric.
// |metricString| tracks the metric name passed to recordTime(). const metricNames = {};
let metricName;
chrome.metricsPrivate.recordTime = (...args) => { chrome.metricsPrivate.recordTime = (...args) => {
recordTimeCalled += 1; if ( args[0] in metricNames ) {
metricName = args[0]; metricNames[args[0]] += 1;
} else {
metricNames[args[0]] = 1;
}
}; };
await setupTest(sampleData()); await setupTest(sampleData());
...@@ -248,9 +250,9 @@ suite('TabSearchAppTest', () => { ...@@ -248,9 +250,9 @@ suite('TabSearchAppTest', () => {
verifyTabIds(queryRows(), [ 1, 5, 6, 2, 3, 4 ]); verifyTabIds(queryRows(), [ 1, 5, 6, 2, 3, 4 ]);
// Ensure that |chrome.metricsPrivate.recordTime()| has been called // Ensure that |chrome.metricsPrivate.recordTime()| has been called
// once after initial tab data has been recieved. // once for InitialTabsRenderTime after initial tab data has been
assertEquals(1, recordTimeCalled); // recieved.
assertEquals('Tabs.TabSearch.WebUI.InitialTabsRenderTime', metricName); assertEquals(1, metricNames['Tabs.TabSearch.WebUI.InitialTabsRenderTime']);
// Force a change to filtered tab data that would result in a // Force a change to filtered tab data that would result in a
// re-render. // re-render.
...@@ -262,8 +264,8 @@ suite('TabSearchAppTest', () => { ...@@ -262,8 +264,8 @@ suite('TabSearchAppTest', () => {
verifyTabIds(queryRows(), [ 2 ]); verifyTabIds(queryRows(), [ 2 ]);
// |chrome.metricsPrivate.recordTime()| should still have only been // |chrome.metricsPrivate.recordTime()| should still have only been
// called once. // called once for InitialTabsRenderTime.
assertEquals(1, recordTimeCalled); assertEquals(1, metricNames['Tabs.TabSearch.WebUI.InitialTabsRenderTime']);
}); });
test('Verify tab switch is logged correctly', async () => { test('Verify tab switch is logged correctly', async () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment