Commit 9f787e2f authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: Hide tooltip when window resizes

Change FilesTooltip to hide the tooltip when the window is resized.

Fixes issue 989456, where the tooltip could be misplaced after the
window resizing. This patch is due to Giovanni Panaro and his work
to resolve this issue, see CL:1743090.

Test: browser_tests --gtest_filter="*filesTooltipHidesOnWindowResize*"
Bug: 989456
Change-Id: I1a78b047e2c18ff79fa54e6e2ad58d4a1e804315
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2119290
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753108}
parent db9ec705
...@@ -858,7 +858,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -858,7 +858,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
FilesAppBrowserTest, FilesAppBrowserTest,
::testing::Values(TestCase("filesTooltipFocus"), ::testing::Values(TestCase("filesTooltipFocus"),
TestCase("filesTooltipMouseOver"), TestCase("filesTooltipMouseOver"),
TestCase("filesTooltipClickHides"))); TestCase("filesTooltipClickHides"),
TestCase("filesTooltipHidesOnWindowResize")));
WRAPPED_INSTANTIATE_TEST_SUITE_P( WRAPPED_INSTANTIATE_TEST_SUITE_P(
FileList, /* file_list.js */ FileList, /* file_list.js */
......
...@@ -64,8 +64,9 @@ const FilesTooltip = Polymer({ ...@@ -64,8 +64,9 @@ const FilesTooltip = Polymer({
* Adds an event listener to the body. * Adds an event listener to the body.
*/ */
attached: function() { attached: function() {
document.body.addEventListener( const closeTooltipHandler = this.onDocumentMouseDown_.bind(this);
'mousedown', this.onDocumentMouseDown_.bind(this)); document.body.addEventListener('mousedown', closeTooltipHandler);
window.addEventListener('resize', closeTooltipHandler);
}, },
/** /**
...@@ -142,8 +143,8 @@ const FilesTooltip = Polymer({ ...@@ -142,8 +143,8 @@ const FilesTooltip = Polymer({
if (this.hideTooltipTimerId_) { if (this.hideTooltipTimerId_) {
clearTimeout(this.hideTooltipTimerId_); clearTimeout(this.hideTooltipTimerId_);
} }
this.hideTooltipTimerId_ = setTimeout( this.hideTooltipTimerId_ =
this.hideTooltip_.bind(this), this.hideTimeout); setTimeout(this.hideTooltip_.bind(this), this.hideTimeout);
}, },
/** /**
...@@ -243,5 +244,5 @@ const FilesTooltip = Polymer({ ...@@ -243,5 +244,5 @@ const FilesTooltip = Polymer({
clearTimeout(this.showTooltipTimerId_); clearTimeout(this.showTooltipTimerId_);
this.showTooltipTimerId_ = 0; this.showTooltipTimerId_ = 0;
} }
} },
}); });
...@@ -123,4 +123,28 @@ ...@@ -123,4 +123,28 @@
// The tooltip should be hidden. // The tooltip should be hidden.
tooltip = await remoteCall.waitForElement(appId, tooltipQueryHidden); tooltip = await remoteCall.waitForElement(appId, tooltipQueryHidden);
}; };
/**
* Tests that the tooltip should hide when the window resizes.
*/
testcase.filesTooltipHidesOnWindowResize = async () => {
const appId = await setupAndWaitUntilReady(
RootPath.DOWNLOADS, [ENTRIES.beautiful], []);
// The tooltip should be hidden.
await remoteCall.waitForElement(appId, tooltipQueryHidden);
// Focus a button with tooltip.
chrome.test.assertTrue(
await remoteCall.callRemoteTestUtil('focus', appId, [searchButton]));
// The tooltip should be visible.
await remoteCall.waitForElement(appId, tooltipQueryVisible);
// Resize the window.
await remoteCall.callRemoteTestUtil('resizeWindow', appId, [1200, 1200]);
// The tooltip should be hidden.
await remoteCall.waitForElement(appId, tooltipQueryHidden);
};
})(); })();
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