Commit c29d1e55 authored by Roman Arora's avatar Roman Arora Committed by Chromium LUCI CQ

Tab Search: Flaky test fix

Modified `Verify ShowUI()` test to avoid timing issues that can cause
the test to flake and re-enabled it.

Move the listenOnce/showUI logic to the ready() function of the
component.

Bug: 1148061
Change-Id: I1a583dcc1ba531b39e8f92a5f9b9faf4fcfc18e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538150Reviewed-by: default avatarThomas Lukaszewicz <tluk@chromium.org>
Commit-Queue: Roman Arora <romanarora@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832026}
parent eb38ef1d
...@@ -134,6 +134,22 @@ export class TabSearchAppElement extends PolymerElement { ...@@ -134,6 +134,22 @@ export class TabSearchAppElement extends PolymerElement {
callbackRouter.tabUpdated.addListener(tab => this.onTabUpdated_(tab)), callbackRouter.tabUpdated.addListener(tab => this.onTabUpdated_(tab)),
callbackRouter.tabsRemoved.addListener( callbackRouter.tabsRemoved.addListener(
tabIds => this.onTabsRemoved_(tabIds))); tabIds => this.onTabsRemoved_(tabIds)));
// The infinite-list only triggers a dom-change event after it is ready
// and observes a change on the list items.
listenOnce(this.$.tabsList, 'dom-change', () => {
// Push showUI() to the event loop to allow reflow to occur following
// the DOM update.
setTimeout(() => {
this.apiProxy_.showUI();
// Record the first time it takes for the initial list of tabs to
// render.
chrome.metricsPrivate.recordTime(
'Tabs.TabSearch.WebUI.InitialTabsRenderTime',
Math.round(window.performance.now()));
}, 0);
});
this.updateTabs_(); this.updateTabs_();
} }
...@@ -151,20 +167,6 @@ export class TabSearchAppElement extends PolymerElement { ...@@ -151,20 +167,6 @@ export class TabSearchAppElement extends PolymerElement {
'Tabs.TabSearch.WebUI.TabListDataReceived', 'Tabs.TabSearch.WebUI.TabListDataReceived',
Math.round(Date.now() - getTabsStartTimestamp)); Math.round(Date.now() - getTabsStartTimestamp));
// Prior to the first load |this.openTabs_| has not been set. Record the
// time it takes for the initial list of tabs to render.
if (!this.openTabs_) {
listenOnce(this.$.tabsList, 'dom-change', () => {
// Push showUI() to the event loop to allow reflow to occur following
// the DOM update.
setTimeout(() => {
this.apiProxy_.showUI();
chrome.metricsPrivate.recordTime(
'Tabs.TabSearch.WebUI.InitialTabsRenderTime',
Math.round(window.performance.now()));
}, 0);
});
}
this.openTabs_ = profileTabs.windows; this.openTabs_ = profileTabs.windows;
}); });
} }
......
...@@ -276,9 +276,10 @@ suite('TabSearchAppTest', () => { ...@@ -276,9 +276,10 @@ suite('TabSearchAppTest', () => {
}; };
await setupTest(sampleData()); await setupTest(sampleData());
await testProxy.whenCalled('showUI');
await waitAfterNextRender(tabSearchApp); await waitAfterNextRender(tabSearchApp);
// Make sure that tab data has been recieved. // Make sure that tab data has been received.
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
...@@ -359,21 +360,16 @@ suite('TabSearchAppTest', () => { ...@@ -359,21 +360,16 @@ suite('TabSearchAppTest', () => {
}); });
}); });
/** TODO(crbug.com/1148061) Investigate/Fix flaky test. */ test('Verify showUI() is called correctly', async () => {
// Casting to avoid inexistent skip() function closure validation error.
/** @type {!Object} */
(test).skip('Verify showUI() is called correctly', async () => {
assertEquals(0, testProxy.getCallCount('showUI'));
await setupTest(sampleData()); await setupTest(sampleData());
await waitAfterNextRender(tabSearchApp); await waitAfterNextRender(tabSearchApp);
// Make sure that tab data has been received. // Make sure that tab data has been received.
verifyTabIds(queryRows(), [ 1, 5, 6, 2, 3, 4 ]); verifyTabIds(queryRows(), [ 1, 5, 6, 2, 3, 4 ]);
// Ensure that showUI() has been called once after initial data has been // Ensure that showUI() has been called after the initial data has been
// rendered. // rendered.
assertEquals(1, testProxy.getCallCount('showUI')); await testProxy.whenCalled('showUI');
// 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.
......
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