Commit 0cf4b340 authored by Scott Chen's avatar Scott Chen Committed by Commit Bot

WebUI: fix flaky cr-action-menu test.

Bug: 812947
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: If2a653a7784b464d44bbde72d42df0ca719c2e90
Reviewed-on: https://chromium-review.googlesource.com/923580Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Scott Chen <scottchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537477}
parent e3e837b2
...@@ -306,7 +306,9 @@ suite('CrActionMenu', function() { ...@@ -306,7 +306,9 @@ suite('CrActionMenu', function() {
}); });
test('[auto-reposition] enables repositioning if content changes', function() { test(
'[auto-reposition] enables repositioning if content changes',
function(done) {
menu.autoReposition = true; menu.autoReposition = true;
dots.style.marginLeft = '800px'; dots.style.marginLeft = '800px';
...@@ -325,10 +327,7 @@ suite('CrActionMenu', function() { ...@@ -325,10 +327,7 @@ suite('CrActionMenu', function() {
const lastMenuLeft = menuRect.left; const lastMenuLeft = menuRect.left;
const lastMenuWidth = menuRect.width; const lastMenuWidth = menuRect.width;
// Still anchored at the right place after content size changes. menu.addEventListener('cr-action-menu-repositioned', () => {
items[0].textContent = 'this is a long string to make menu wide';
// Flush to wait for resizeObeserver's cycle.
return PolymerTest.flushTasks().then(() => {
assertTrue(menu.open); assertTrue(menu.open);
menuRect = menu.getBoundingClientRect(); menuRect = menu.getBoundingClientRect();
// Test that menu width got larger. // Test that menu width got larger.
...@@ -340,7 +339,11 @@ suite('CrActionMenu', function() { ...@@ -340,7 +339,11 @@ suite('CrActionMenu', function() {
Math.round(dotsRect.left + dotsRect.width), Math.round(dotsRect.left + dotsRect.width),
Math.round(menuRect.left + menuRect.width)); Math.round(menuRect.left + menuRect.width));
assertEquals(dotsRect.top, menuRect.top); assertEquals(dotsRect.top, menuRect.top);
done();
}); });
// Still anchored at the right place after content size changes.
items[0].textContent = 'this is a long string to make menu wide';
}); });
suite('offscreen scroll positioning', function() { suite('offscreen scroll positioning', function() {
......
...@@ -440,8 +440,10 @@ Polymer({ ...@@ -440,8 +440,10 @@ Polymer({
if (this.autoReposition) { if (this.autoReposition) {
this.resizeObserver_ = new ResizeObserver(() => { this.resizeObserver_ = new ResizeObserver(() => {
if (this.lastConfig_) if (this.lastConfig_) {
this.positionDialog_(this.lastConfig_); this.positionDialog_(this.lastConfig_);
this.fire('cr-action-menu-repositioned'); // For easier testing.
}
}); });
this.resizeObserver_.observe(this); this.resizeObserver_.observe(this);
......
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