Commit 40f304cc authored by btolsch's avatar btolsch Committed by Commit Bot

Split search and filter MediaRouterElementsBrowserTests into 2 parts

Search and filter tests have been flaky on Windows bots because they
time out.  In the past, the fix for this was to split the tests up into
more cases so this change further splits filter and search tests.

Bug: 657964, 760288
Change-Id: I01bd179aed3b7181a50ef0627320ccc643f8437a
Reviewed-on: https://chromium-review.googlesource.com/761260Reviewed-by: default avatarDerek Cheng <imcheng@chromium.org>
Commit-Queue: Brandon Tolsch <btolsch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515691}
parent c21a34ce
...@@ -6,140 +6,150 @@ ...@@ -6,140 +6,150 @@
* to the filter view. * to the filter view.
*/ */
cr.define('media_router_container_filter', function() { cr.define('media_router_container_filter', function() {
function registerTests() { /**
suite('MediaRouterContainerFilter', function() { * Wrapper that lets a function |f| run after the container animation promise
/** * completes but also lets any UI logic run before setting up the call. This
* Wrapper that lets a function |f| run after the container animation * is important because |container.animationPromise_| may not exist until the
* promise completes but also lets any UI logic run before setting up the * UI logic runs or it may be updated to a new Promise. This wrapper also
* call. This is important because |container.animationPromise_| may not * carries assertion errors (and any other exceptions) outside of the promise
* exist until the UI logic runs or it may be updated to a new Promise. * back into the test since throwing in a then() or catch() doesn't stop the
* This wrapper also carries assertion errors (and any other exceptions) * test.
* outside of the promise back into the test since throwing in a then() or *
* catch() doesn't stop the test. * @param {function()} f
* */
* @param {function()} f var chainOnAnimationPromise = function(f) {
*/ setTimeout(function() {
var chainOnAnimationPromise = function(f) { container.animationPromise_.then(f).catch(function(err) {
setTimeout(function() { setTimeout(function() { throw err; });
container.animationPromise_.then(f).catch(function(err) {
setTimeout(function() { throw err; });
});
});
};
/**
* Checks whether |view| matches the current view of |container|.
*
* @param {!media_router.MediaRouterView} view Expected view type.
*/
var checkCurrentView;
/**
* Checks whether the elements specified in |elementIdList| are visible.
* Checks whether all other elements are not visible. Throws an assertion
* error if this is not true.
*
* @param {!Array<!string>} elementIdList List of id's of elements that
* should be visible.
*/
var checkElementsVisibleWithId;
/**
* Checks whether |expected| and the text in the |element| are equal.
*
* @param {!string} expected Expected text.
* @param {!Element} element Element whose text will be checked.
*/
var checkElementText;
/**
* Media Router Container created before each test.
* @type {?MediaRouterContainer}
*/
var container;
/**
* The blocking issue to show.
* @type {?media_router.Issue}
*/
var fakeNonBlockingIssue;
/**
* The list of current routes.
* @type {!Array<!media_router.Route>}
*/
var fakeRouteList = [];
/**
* The list of available sinks.
* @type {!Array<!media_router.Sink>}
*/
var fakeSinkList = [];
/**
* Simulates pressing the Escape key on |element|.
* @param {!HTMLElement} element
*/
var pressEscapeOnElement = function(element) {
element.dispatchEvent(new KeyboardEvent('keydown', {
'key': 'Escape',
'code': 'Escape',
'bubbles': true,
'cancelable': true
}));
};
/**
* Search text that will match all sinks.
* @type {?string}
*/
var searchTextAll;
/**
* Search text that won't match any sink in fakeSinkList.
* @type {?string}
*/
var searchTextNone;
/**
* Search text that will match exactly one sink.
* @type {?string}
*/
var searchTextOne;
// Import media_router_container.html before running suite.
suiteSetup(function() {
return PolymerTest.importHtml(
'chrome://media-router/elements/media_router_container/' +
'media_router_container.html');
}); });
});
};
setup(function(done) { /**
PolymerTest.clearBody(); * Checks whether |view| matches the current view of |container|.
// Initialize a media-router-container before each test. *
container = document.createElement('media-router-container'); * @param {!media_router.MediaRouterView} view Expected view type.
document.body.appendChild(container); */
var checkCurrentView;
// Get common functions and variables.
var test_base = media_router_container_test_base.init(container); /**
* Checks whether the elements specified in |elementIdList| are visible.
checkCurrentView = test_base.checkCurrentView; * Checks whether all other elements are not visible. Throws an assertion
checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; * error if this is not true.
checkElementText = test_base.checkElementText; *
fakeNonBlockingIssue = test_base.fakeNonBlockingIssue; * @param {!Array<!string>} elementIdList List of id's of elements that
fakeRouteList = test_base.fakeRouteList; * should be visible.
fakeSinkList = test_base.fakeSinkList; */
searchTextAll = test_base.searchTextAll; var checkElementsVisibleWithId;
searchTextNone = test_base.searchTextNone;
searchTextOne = test_base.searchTextOne; /**
* Checks whether |expected| and the text in the |element| are equal.
container.castModeList = test_base.fakeCastModeList; *
container.searchEnabled_ = true; * @param {!string} expected Expected text.
* @param {!Element} element Element whose text will be checked.
// Allow for the media router container to be created, attached, and */
// listeners registered in an afterNextRender() call. var checkElementText;
Polymer.RenderStatus.afterNextRender(this, done);
}); /**
* Media Router Container created before each test.
* @type {?MediaRouterContainer}
*/
var container;
/**
* The blocking issue to show.
* @type {?media_router.Issue}
*/
var fakeNonBlockingIssue;
/**
* The list of current routes.
* @type {!Array<!media_router.Route>}
*/
var fakeRouteList = [];
/**
* The list of available sinks.
* @type {!Array<!media_router.Sink>}
*/
var fakeSinkList = [];
/**
* Simulates pressing the Escape key on |element|.
* @param {!HTMLElement} element
*/
var pressEscapeOnElement = function(element) {
element.dispatchEvent(new KeyboardEvent('keydown', {
'key': 'Escape',
'code': 'Escape',
'bubbles': true,
'cancelable': true
}));
};
/**
* Search text that will match all sinks.
* @type {?string}
*/
var searchTextAll;
/**
* Search text that won't match any sink in fakeSinkList.
* @type {?string}
*/
var searchTextNone;
/**
* Search text that will match exactly one sink.
* @type {?string}
*/
var searchTextOne;
/**
* Import media_router_container.html before running suite.
*/
var doSuiteSetup = function() {
return PolymerTest.importHtml(
'chrome://media-router/elements/media_router_container/' +
'media_router_container.html');
};
/**
* Performs test setup before each test.
*
* @param {function()} done Function for async test completion.
*/
var doSetup = function(done) {
PolymerTest.clearBody();
// Initialize a media-router-container before each test.
container = document.createElement('media-router-container');
document.body.appendChild(container);
// Get common functions and variables.
var test_base = media_router_container_test_base.init(container);
checkCurrentView = test_base.checkCurrentView;
checkElementsVisibleWithId = test_base.checkElementsVisibleWithId;
checkElementText = test_base.checkElementText;
fakeNonBlockingIssue = test_base.fakeNonBlockingIssue;
fakeRouteList = test_base.fakeRouteList;
fakeSinkList = test_base.fakeSinkList;
searchTextAll = test_base.searchTextAll;
searchTextNone = test_base.searchTextNone;
searchTextOne = test_base.searchTextOne;
container.castModeList = test_base.fakeCastModeList;
container.searchEnabled_ = true;
// Allow for the media router container to be created, attached, and
// listeners registered in an afterNextRender() call.
Polymer.RenderStatus.afterNextRender(this, done);
};
function registerTestsPart1() {
suite('MediaRouterContainerFilterPart1', function() {
suiteSetup(doSuiteSetup);
setup(doSetup);
// Tests that clicking the search icon will cause the container to enter // Tests that clicking the search icon will cause the container to enter
// filter view. // filter view.
...@@ -430,6 +440,13 @@ cr.define('media_router_container_filter', function() { ...@@ -430,6 +440,13 @@ cr.define('media_router_container_filter', function() {
done(); done();
}); });
}); });
});
}
function registerTestsPart2() {
suite('MediaRouterContainerFilterPart2', function() {
suiteSetup(doSuiteSetup);
setup(doSetup);
// Tests that the correct number of results are returned in the search // Tests that the correct number of results are returned in the search
// results. // results.
...@@ -977,6 +994,7 @@ cr.define('media_router_container_filter', function() { ...@@ -977,6 +994,7 @@ cr.define('media_router_container_filter', function() {
} }
return { return {
registerTests: registerTests, registerTestsPart1: registerTestsPart1,
registerTestsPart2: registerTestsPart2,
}; };
}); });
...@@ -152,16 +152,17 @@ TEST_F('MediaRouterElementsBrowserTest', ...@@ -152,16 +152,17 @@ TEST_F('MediaRouterElementsBrowserTest',
mocha.run(); mocha.run();
}); });
// This test is flaky on Windows. See https://crbug.com/760288.
GEN('#if defined(OS_WIN)');
GEN('#define MAYBE_MediaRouterContainerSearch DISABLED_MediaRouterContainerSearch');
GEN('#else');
GEN('#define MAYBE_MediaRouterContainerSearch MediaRouterContainerSearch');
GEN('#endif');
TEST_F('MediaRouterElementsBrowserTest', TEST_F('MediaRouterElementsBrowserTest',
'MAYBE_MediaRouterContainerSearch', 'MediaRouterContainerSearchPart1',
function() { function() {
media_router_container_search.registerTests(); media_router_container_search.registerTestsPart1();
mocha.run();
});
TEST_F('MediaRouterElementsBrowserTest',
'MediaRouterContainerSearchPart2',
function() {
media_router_container_search.registerTestsPart2();
mocha.run(); mocha.run();
}); });
...@@ -173,9 +174,16 @@ TEST_F('MediaRouterElementsBrowserTest', ...@@ -173,9 +174,16 @@ TEST_F('MediaRouterElementsBrowserTest',
}); });
TEST_F('MediaRouterElementsBrowserTest', TEST_F('MediaRouterElementsBrowserTest',
'DISABLED_MediaRouterContainerFilter', 'MediaRouterContainerFilterPart1',
function() {
media_router_container_filter.registerTestsPart1();
mocha.run();
});
TEST_F('MediaRouterElementsBrowserTest',
'MediaRouterContainerFilterPart2',
function() { function() {
media_router_container_filter.registerTests(); media_router_container_filter.registerTestsPart2();
mocha.run(); mocha.run();
}); });
......
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