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

Unified Diff: chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js

Issue 1204943002: Tests for Media Router media-router-container Polymer element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per dbeam@'s comments. Created 5 years, 5 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/browser/resources/media_router/elements/media_router_container/media_router_container.js
diff --git a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
index d6f6090d26f112c85feaa28896a54932612b0245..bc0c3bee47cb1f9086199c62a9576b7eb744fdfd 100644
--- a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
+++ b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
@@ -2,20 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-(function() {
- /**
- * The possible states of media-router-container. Used to determine which
- * components of media-router-container to show.
- *
- * @enum {string}
- */
- var MediaRouterContainerView = {
- CAST_MODE_LIST: 'cast-mode-list',
- FILTER: 'filter',
- ROUTE_DETAILS: 'route-details',
- SINK_LIST: 'sink-list',
- };
-
// This Polymer element contains the entire media router interface. It handles
// hiding and showing specific components.
Polymer({
@@ -28,8 +14,26 @@ Polymer({
*/
castModeList: {
type: Array,
- value: function() {
- return [];
+ value: [],
+ },
+
+ /**
+ * The possible states of media-router-container. Used to determine which
+ * components of media-router-container to show.
+ * This is a property of media-router-container because it is used in
+ * tests.
+ *
+ * @enum {string}
+ * @private
+ */
+ CONTAINER_VIEW_: {
+ type: Object,
+ readOnly: true,
+ value: {
+ CAST_MODE_LIST: 'cast-mode-list',
+ FILTER: 'filter',
+ ROUTE_DETAILS: 'route-details',
+ SINK_LIST: 'sink-list',
},
},
@@ -44,11 +48,11 @@ Polymer({
/**
* The current view to be shown.
- * @private {!MediaRouterContainerView}
+ * @private {string}
*/
currentView_: {
type: String,
- value: MediaRouterContainerView.SINK_LIST,
+ value: '',
},
/**
@@ -84,9 +88,7 @@ Polymer({
*/
routeList: {
type: Array,
- value: function() {
- return [];
- },
+ value: [],
observer: 'rebuildRouteMaps_',
},
@@ -96,9 +98,7 @@ Polymer({
*/
routeMap_: {
type: Object,
- value: function() {
- return {};
- },
+ value: {},
},
/**
@@ -127,9 +127,7 @@ Polymer({
*/
sinkList: {
type: Array,
- value: function() {
- return [];
- },
+ value: [],
observer: 'rebuildSinkMap_',
},
@@ -139,9 +137,7 @@ Polymer({
*/
sinkMap_: {
type: Object,
- value: function() {
- return {};
- },
+ value: {},
},
/**
@@ -150,12 +146,14 @@ Polymer({
*/
sinkToRouteMap_: {
type: Object,
- value: function() {
- return {};
- },
+ value: {},
},
},
+ ready: function() {
+ this.currentView_ = this.CONTAINER_VIEW_.SINK_LIST;
+ },
+
/**
* Adds |route| to |routeList|.
*
@@ -174,54 +172,54 @@ Polymer({
},
/**
- * @param {!MediaRouterContainerView} view The current view.
Dan Beam 2015/07/10 22:29:43 I'm not sure this is a good change
apacible 2015/07/10 23:25:28 What do you prefer?
Dan Beam 2015/07/10 23:56:13 using the enum (like you were before) it doesn't
apacible 2015/07/11 00:49:58 Acknowledged.
+ * @param {string} view The current view.
* @return {string} The current arrow-drop-* icon to use.
* @private
*/
computeArrowDropIcon_: function(view) {
- return view == MediaRouterContainerView.CAST_MODE_LIST ?
+ return view == this.CONTAINER_VIEW_.CAST_MODE_LIST ?
'arrow-drop-up' : 'arrow-drop-down';
},
/**
- * @param {!MediaRouterContainerView} view The current view.
+ * @param {string} view The current view.
* @return {boolean} Whether or not to hide the cast mode list.
* @private
*/
computeCastModeHidden_: function(view) {
- return view != MediaRouterContainerView.CAST_MODE_LIST;
+ return view != this.CONTAINER_VIEW_.CAST_MODE_LIST;
},
/**
- * @param {!MediaRouterContainerView} view The current view.
+ * @param {string} view The current view.
* @param {?media_router.Issue} issue The current issue.
* @return {boolean} Whether or not to hide the header.
* @private
*/
computeHeaderHidden_: function(view, issue) {
- return view == MediaRouterContainerView.ROUTE_DETAILS ||
- (view == MediaRouterContainerView.SINK_LIST &&
+ return view == this.CONTAINER_VIEW_.ROUTE_DETAILS ||
+ (view == this.CONTAINER_VIEW_.SINK_LIST &&
issue && issue.isBlocking);
},
/**
- * @param {!MediaRouterContainerView} view The current view.
+ * @param {string} view The current view.
* @param {?media_router.Issue} issue The current issue.
* @return {boolean} Whether or not to hide the issue banner.
* @private
*/
computeIssueBannerHidden_: function(view, issue) {
- return !issue || view == MediaRouterContainerView.CAST_MODE_LIST;
+ return !issue || view == this.CONTAINER_VIEW_.CAST_MODE_LIST;
},
/**
- * @param {!MediaRouterContainerView} view The current view.
+ * @param {string} view The current view.
* @param {?media_router.Issue} issue The current issue.
* @return {boolean} Whether or not to hide the route details.
* @private
*/
computeRouteDetailsHidden_: function(view, issue) {
- return view != MediaRouterContainerView.ROUTE_DETAILS ||
+ return view != this.CONTAINER_VIEW_.ROUTE_DETAILS ||
(issue && issue.isBlocking);
},
@@ -275,13 +273,13 @@ Polymer({
},
/**
- * @param {!MediaRouterContainerView} view The current view.
+ * @param {string} view The current view.
* @param {?media_router.Issue} issue The current issue.
* @return {boolean} Whether or not to hide entire the sink list view.
* @private
*/
computeSinkListViewHidden_: function(view, issue) {
- return view != MediaRouterContainerView.SINK_LIST ||
+ return view != this.CONTAINER_VIEW_.SINK_LIST ||
(issue && issue.isBlocking);
},
@@ -373,7 +371,7 @@ Polymer({
* @private
*/
showCastModeList_: function() {
- this.currentView_ = MediaRouterContainerView.CAST_MODE_LIST;
+ this.currentView_ = this.CONTAINER_VIEW_.CAST_MODE_LIST;
},
/**
@@ -382,7 +380,7 @@ Polymer({
* @private
*/
showRouteDetails_: function() {
- this.currentView_ = MediaRouterContainerView.ROUTE_DETAILS;
+ this.currentView_ = this.CONTAINER_VIEW_.ROUTE_DETAILS;
},
/**
@@ -391,7 +389,7 @@ Polymer({
* @private
*/
showSinkList_: function() {
- this.currentView_ = MediaRouterContainerView.SINK_LIST;
+ this.currentView_ = this.CONTAINER_VIEW_.SINK_LIST;
},
/**
@@ -400,11 +398,10 @@ Polymer({
* @private
*/
toggleCastModeHidden_: function() {
- if (this.currentView_ == MediaRouterContainerView.CAST_MODE_LIST) {
+ if (this.currentView_ == this.CONTAINER_VIEW_.CAST_MODE_LIST) {
this.showSinkList_();
} else {
this.showCastModeList_();
}
Dan Beam 2015/07/10 22:29:43 nit: no curlies
apacible 2015/07/10 23:25:28 Done.
},
});
-})();

Powered by Google App Engine
This is Rietveld 408576698