Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9220)

Unified Diff: chrome/test/data/webui/media_router/media_router_container_cast_mode_list_tests.js

Issue 1937963003: [Media Router WebUI] Move listeners to afterNextRender(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/media_router/media_router_container_cast_mode_list_tests.js
diff --git a/chrome/test/data/webui/media_router/media_router_container_cast_mode_list_tests.js b/chrome/test/data/webui/media_router/media_router_container_cast_mode_list_tests.js
index 9500f668ad7deec2e3f2608e55119923b6da6254..b2b7336f39a83379089eb3404e50dcb859c383a8 100644
--- a/chrome/test/data/webui/media_router/media_router_container_cast_mode_list_tests.js
+++ b/chrome/test/data/webui/media_router/media_router_container_cast_mode_list_tests.js
@@ -123,101 +123,109 @@ cr.define('media_router_container_cast_mode_list', function() {
// Tests that |container| returns to SINK_LIST view and arrow drop icon
// toggles after a cast mode is selected.
test('select cast mode', function(done) {
- container.castModeList = fakeCastModeListWithNonDefaultModesOnly;
+ setTimeout(function() {
+ container.castModeList = fakeCastModeListWithNonDefaultModesOnly;
- MockInteractions.tap(container.$['container-header'].
- $['arrow-drop-icon']);
- checkCurrentView(media_router.MediaRouterView.CAST_MODE_LIST);
+ MockInteractions.tap(container.$['container-header'].
+ $['arrow-drop-icon']);
+ checkCurrentView(media_router.MediaRouterView.CAST_MODE_LIST);
- setTimeout(function() {
- var castModeList =
- container.$$('#cast-mode-list').querySelectorAll('paper-item');
+ setTimeout(function() {
+ var castModeList =
+ container.$$('#cast-mode-list').querySelectorAll('paper-item');
- MockInteractions.tap(castModeList[2]);
- checkCurrentView(media_router.MediaRouterView.SINK_LIST);
- done();
+ MockInteractions.tap(castModeList[2]);
+ checkCurrentView(media_router.MediaRouterView.SINK_LIST);
+ done();
+ });
});
});
// Tests that clicking on the drop down icon will toggle |container|
// between SINK_LIST and CAST_MODE_LIST views.
test('click drop down icon', function() {
- checkCurrentView(media_router.MediaRouterView.SINK_LIST);
+ setTimeout(function() {
+ checkCurrentView(media_router.MediaRouterView.SINK_LIST);
- MockInteractions.tap(container.$['container-header'].
- $['arrow-drop-icon']);
- checkCurrentView(media_router.MediaRouterView.CAST_MODE_LIST);
+ MockInteractions.tap(container.$['container-header'].
+ $['arrow-drop-icon']);
+ checkCurrentView(media_router.MediaRouterView.CAST_MODE_LIST);
- MockInteractions.tap(container.$['container-header'].
- $['arrow-drop-icon']);
- checkCurrentView(media_router.MediaRouterView.SINK_LIST);
+ MockInteractions.tap(container.$['container-header'].
+ $['arrow-drop-icon']);
+ checkCurrentView(media_router.MediaRouterView.SINK_LIST);
+ });
});
// Tests the header text. Choosing a cast mode updates the header text.
test('header text with no default cast modes', function(done) {
- assertEquals(loadTimeData.getString('selectCastModeHeaderText'),
- container.i18n('selectCastModeHeaderText'));
+ setTimeout(function() {
+ assertEquals(loadTimeData.getString('selectCastModeHeaderText'),
+ container.i18n('selectCastModeHeaderText'));
- // The container is currently in auto cast mode, since we have not
- // picked a cast mode explicitly, and the sinks is not compatible
- // with exactly one cast mode.
- assertEquals(media_router.AUTO_CAST_MODE.description,
- container.headerText);
- assertFalse(container.userHasSelectedCastMode_);
+ // The container is currently in auto cast mode, since we have not
+ // picked a cast mode explicitly, and the sinks is not compatible
+ // with exactly one cast mode.
+ assertEquals(media_router.AUTO_CAST_MODE.description,
+ container.headerText);
+ assertFalse(container.userHasSelectedCastMode_);
- container.castModeList = fakeCastModeListWithNonDefaultModesOnly;
+ container.castModeList = fakeCastModeListWithNonDefaultModesOnly;
- // Switch to cast mode list view.
- MockInteractions.tap(container.$['container-header'].
- $['arrow-drop-icon']);
- setTimeout(function() {
- var castModeList =
- container.$$('#cast-mode-list').querySelectorAll('paper-item');
- assertEquals(fakeCastModeListWithNonDefaultModesOnly.length,
- castModeList.length);
- for (var i = 0; i < castModeList.length; i++) {
- MockInteractions.tap(castModeList[i]);
- assertEquals(
- fakeCastModeListWithNonDefaultModesOnly[i].description,
- container.headerText);
- checkElementText(
- fakeCastModeListWithNonDefaultModesOnly[i].description,
- castModeList[i]);
- }
+ // Switch to cast mode list view.
+ MockInteractions.tap(container.$['container-header'].
+ $['arrow-drop-icon']);
+ setTimeout(function() {
+ var castModeList =
+ container.$$('#cast-mode-list').querySelectorAll('paper-item');
+ assertEquals(fakeCastModeListWithNonDefaultModesOnly.length,
+ castModeList.length);
+ for (var i = 0; i < castModeList.length; i++) {
+ MockInteractions.tap(castModeList[i]);
+ assertEquals(
+ fakeCastModeListWithNonDefaultModesOnly[i].description,
+ container.headerText);
+ checkElementText(
+ fakeCastModeListWithNonDefaultModesOnly[i].description,
+ castModeList[i]);
+ }
- done();
+ done();
+ });
});
});
// Tests the header text when updated with a cast mode list with a mix of
// default and non-default cast modes.
test('cast modes with one default mode', function(done) {
- container.castModeList = fakeCastModeList;
-
- // Switch to cast mode list view.
- MockInteractions.tap(container.$['container-header'].
- $['arrow-drop-icon']);
setTimeout(function() {
- var castModeList =
- container.$$('#cast-mode-list').querySelectorAll('paper-item');
-
- for (var i = 0; i < fakeCastModeList.length; i++) {
- MockInteractions.tap(castModeList[i]);
- if (fakeCastModeList[i].type ==
- media_router.CastModeType.DEFAULT) {
- assertEquals(fakeCastModeList[i].description,
- container.headerText);
+ container.castModeList = fakeCastModeList;
- checkElementText(fakeCastModeList[i].host, castModeList[i]);
- } else {
- assertEquals(fakeCastModeList[i].description,
- container.headerText);
- checkElementText(fakeCastModeList[i].description,
- castModeList[i]);
+ // Switch to cast mode list view.
+ MockInteractions.tap(container.$['container-header'].
+ $['arrow-drop-icon']);
+ setTimeout(function() {
+ var castModeList =
+ container.$$('#cast-mode-list').querySelectorAll('paper-item');
+
+ for (var i = 0; i < fakeCastModeList.length; i++) {
+ MockInteractions.tap(castModeList[i]);
+ if (fakeCastModeList[i].type ==
+ media_router.CastModeType.DEFAULT) {
+ assertEquals(fakeCastModeList[i].description,
+ container.headerText);
+
+ checkElementText(fakeCastModeList[i].host, castModeList[i]);
+ } else {
+ assertEquals(fakeCastModeList[i].description,
+ container.headerText);
+ checkElementText(fakeCastModeList[i].description,
+ castModeList[i]);
+ }
}
- }
- done();
+ done();
+ });
});
});
@@ -252,31 +260,35 @@ cr.define('media_router_container_cast_mode_list', function() {
// no longer exists in the list of cast modes, then switch back to auto
// mode.
test('cast mode list updated in selected cast mode', function(done) {
- assertEquals(media_router.AUTO_CAST_MODE.description,
- container.headerText);
- assertEquals(media_router.CastModeType.AUTO,
- container.shownCastModeValue_);
- assertFalse(container.userHasSelectedCastMode_);
-
- MockInteractions.tap(container.$['container-header'].
- $['arrow-drop-icon']);
setTimeout(function() {
- var castModeList =
- container.$$('#cast-mode-list').querySelectorAll('paper-item');
- MockInteractions.tap(castModeList[0]);
+ assertEquals(media_router.AUTO_CAST_MODE.description,
+ container.headerText);
+ assertEquals(media_router.CastModeType.AUTO,
+ container.shownCastModeValue_);
+ assertFalse(container.userHasSelectedCastMode_);
+
+ MockInteractions.tap(container.$['container-header'].
+ $['arrow-drop-icon']);
setTimeout(function() {
- assertEquals(fakeCastModeList[0].description, container.headerText);
- assertEquals(fakeCastModeList[0].type,
- container.shownCastModeValue_);
- assertTrue(container.userHasSelectedCastMode_);
- container.castModeList = fakeCastModeList.slice(1);
+ var castModeList =
+ container.$$('#cast-mode-list')
+ .querySelectorAll('paper-item');
+ MockInteractions.tap(castModeList[0]);
setTimeout(function() {
- assertEquals(media_router.AUTO_CAST_MODE.description,
+ assertEquals(fakeCastModeList[0].description,
container.headerText);
- assertEquals(media_router.CastModeType.AUTO,
+ assertEquals(fakeCastModeList[0].type,
container.shownCastModeValue_);
- assertFalse(container.userHasSelectedCastMode_);
- done();
+ assertTrue(container.userHasSelectedCastMode_);
+ container.castModeList = fakeCastModeList.slice(1);
+ setTimeout(function() {
+ assertEquals(media_router.AUTO_CAST_MODE.description,
+ container.headerText);
+ assertEquals(media_router.CastModeType.AUTO,
+ container.shownCastModeValue_);
+ assertFalse(container.userHasSelectedCastMode_);
+ done();
+ });
});
});
});
@@ -285,33 +297,38 @@ cr.define('media_router_container_cast_mode_list', function() {
// Tests that after a different cast mode is selected, the sink list will
// change based on the sinks compatibility with the new cast mode.
test('changing cast mode changes sink list', function(done) {
- container.allSinks = fakeSinkList;
-
- MockInteractions.tap(container.$['container-header'].
- $['arrow-drop-icon']);
setTimeout(function() {
- var castModeList =
- container.$$('#cast-mode-list').querySelectorAll('paper-item');
- MockInteractions.tap(castModeList[0]);
- assertEquals(fakeCastModeList[0].description, container.headerText);
+ container.allSinks = fakeSinkList;
+ MockInteractions.tap(container.$['container-header'].
+ $['arrow-drop-icon']);
setTimeout(function() {
- var sinkList =
- container.shadowRoot.getElementById('sink-list')
- .querySelectorAll('paper-item');
-
- // The sink list is empty because none of the sinks in fakeSinkList
- // is compatible with cast mode 0.
- assertEquals(0, sinkList.length);
- MockInteractions.tap(castModeList[2]);
- assertEquals(fakeCastModeList[2].description, container.headerText);
+ var castModeList =
+ container.$$('#cast-mode-list')
+ .querySelectorAll('paper-item');
+ MockInteractions.tap(castModeList[0]);
+ assertEquals(fakeCastModeList[0].description,
+ container.headerText);
setTimeout(function() {
var sinkList =
container.shadowRoot.getElementById('sink-list')
.querySelectorAll('paper-item');
- assertEquals(3, sinkList.length);
- done();
+
+ // The sink list is empty because none of the sinks in
+ // fakeSinkList is compatible with cast mode 0.
+ assertEquals(0, sinkList.length);
+ MockInteractions.tap(castModeList[2]);
+ assertEquals(fakeCastModeList[2].description,
+ container.headerText);
+
+ setTimeout(function() {
+ var sinkList =
+ container.shadowRoot.getElementById('sink-list')
+ .querySelectorAll('paper-item');
+ assertEquals(3, sinkList.length);
+ done();
+ });
});
});
});
@@ -354,7 +371,8 @@ cr.define('media_router_container_cast_mode_list', function() {
var castModeList =
container.$$('#cast-mode-list').querySelectorAll('paper-item');
MockInteractions.tap(castModeList[1]);
- assertEquals(fakeCastModeList[1].description, container.headerText);
+ assertEquals(fakeCastModeList[1].description,
+ container.headerText);
assertEquals(fakeCastModeList[1].type,
container.shownCastModeValue_);

Powered by Google App Engine
This is Rietveld 408576698