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

Side by Side Diff: chrome/test/data/webui/media_router/media_router_container_test_base.js

Issue 1766473002: [Media Router] Further split media_router_container tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Collected common utility functions Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /** @fileoverview Provides basic utility functions and variables for
6 * media-router-container tests. */
7
8 cr.define('media_router_container_test_base', function() {
9 function init(container) {
10 /**
11 * The blocking issue to show.
12 * @type {?media_router.Issue}
13 */
14 var fakeBlockingIssue;
apacible 2016/03/09 17:33:15 You can just initialize the variables here instead
btolsch 2016/03/09 20:01:00 Done.
15
16 /**
17 * The list of CastModes to show.
18 * @type {!Array<!media_router.CastMode>}
19 */
20 var fakeCastModeList = [];
21
22 /**
23 * The list of CastModes to show with non-default modes only.
24 * @type {!Array<!media_router.CastMode>}
25 */
26 var fakeCastModeListWithNonDefaultModesOnly = [];
27
28 /**
29 * The blocking issue to show.
30 * @type {?media_router.Issue}
31 */
32 var fakeNonBlockingIssue;
33
34 /**
35 * The list of current routes.
36 * @type {!Array<!media_router.Route>}
37 */
38 var fakeRouteList = [];
39
40 /**
41 * The list of available sinks.
42 * @type {!Array<!media_router.Sink>}
43 */
44 var fakeSinkList = [];
45
46 /**
47 * The list of elements to check for visibility.
48 * @const {!Array<string>}
apacible 2016/03/09 17:33:15 nit: {!Array<!string>}
btolsch 2016/03/09 20:01:01 Done.
49 */
50 var hiddenCheckElementIdList = [
51 'cast-mode-list',
52 'container-header',
53 'device-missing',
54 'first-run-flow',
55 'first-run-flow-cloud-pref',
56 'issue-banner',
57 'no-search-matches',
58 'route-details',
59 'search-results',
60 'sink-list',
61 'sink-list-view',
62 ];
63
64 /**
65 * Search text that will match all sinks.
66 * @type {string}
67 */
68 var searchTextAll;
69
70 /**
71 * Search text that won't match any sink in fakeSinkList.
72 * @type {string}
73 */
74 var searchTextNone;
75
76 /**
77 * Search text that will match exactly one sink.
78 * @type {string}
79 */
80 var searchTextOne;
81
82 // Checks whether |view| matches the current view of |container|.
83 var checkCurrentView = function(view) {
84 assertEquals(view, container.currentView_);
85 };
86
87 // Checks whether the elements specified in |elementIdList| are visible.
88 // Checks whether all other elements are not visible.
89 var checkElementsVisibleWithId = function(elementIdList) {
90 for (var i = 0; i < elementIdList.length; i++)
91 checkElementVisibleWithId(true, elementIdList[i]);
92
93 for (var j = 0; j < hiddenCheckElementIdList.length; j++) {
94 if (elementIdList.indexOf(hiddenCheckElementIdList[j]) == -1)
95 checkElementVisibleWithId(false, hiddenCheckElementIdList[j]);
96 }
97 };
98
99 // Checks the visibility of an element with |elementId| in |container|.
100 // An element is considered visible if it exists and its |hidden| property
101 // is |false|.
102 var checkElementVisibleWithId = function(visible, elementId) {
103 var element = container.$$('#' + elementId);
104 var elementVisible = !!element && !element.hidden &&
105 element.style.display != 'none';
106 assertEquals(visible, elementVisible, elementId);
107 };
108
109 // Checks whether |expected| and the text in the |element| are equal.
110 var checkElementText = function(expected, element) {
111 assertEquals(expected.trim(), element.textContent.trim());
112 };
113
114 fakeCastModeList = [
115 new media_router.CastMode(0x1, 'Description 0', 'google.com'),
116 new media_router.CastMode(0x2, 'Description 1', null),
117 new media_router.CastMode(0x4, 'Description 2', null),
118 ];
119
120 fakeCastModeListWithNonDefaultModesOnly = [
121 new media_router.CastMode(0x2, 'Description 1', null),
122 new media_router.CastMode(0x4, 'Description 2', null),
123 new media_router.CastMode(0x8, 'Description 3', null),
124 ];
125
126 fakeRouteList = [
127 new media_router.Route('id 1', 'sink id 1',
128 'Title 1', 0, true, false),
129 new media_router.Route('id 2', 'sink id 2',
130 'Title 2', 1, false, true),
131 ];
132
133 fakeRouteListWithLocalRoutesOnly = [
134 new media_router.Route('id 1', 'sink id 1',
135 'Title 1', 0, true, false),
136 new media_router.Route('id 2', 'sink id 2',
137 'Title 2', 1, true, false),
138 ];
139
140 fakeRouteListWithLocalRoutesOnly = [
141 new media_router.Route('id 1', 'sink id 1',
142 'Title 1', 0, true, false),
143 new media_router.Route('id 2', 'sink id 2',
144 'Title 2', 1, true, false),
145 ];
146
147 var castModeBitset = 0x2 | 0x4 | 0x8;
148 fakeSinkList = [
149 new media_router.Sink('sink id 1', 'Sink 1', null, null,
150 media_router.SinkIconType.CAST,
151 media_router.SinkStatus.ACTIVE, castModeBitset),
152 new media_router.Sink('sink id 2', 'Sink 2', null, null,
153 media_router.SinkIconType.CAST,
154 media_router.SinkStatus.ACTIVE, castModeBitset),
155 new media_router.Sink('sink id 3', 'Sink 3', null, null,
156 media_router.SinkIconType.CAST,
157 media_router.SinkStatus.PENDING, castModeBitset),
158 ];
159
160 fakeBlockingIssue = new media_router.Issue(
161 'issue id 1', 'Issue Title 1', 'Issue Message 1', 0, 1,
162 'route id 1', true, 1234);
163
164 fakeNonBlockingIssue = new media_router.Issue(
165 'issue id 2', 'Issue Title 2', 'Issue Message 2', 0, 1,
166 'route id 2', false, 1234);
167
168 //container.castModeList = fakeCastModeList;
apacible 2016/03/09 17:33:15 Remove?
btolsch 2016/03/09 20:01:01 Done.
169
170 searchTextAll = 'sink';
171 searchTextNone = 'abc';
172 searchTextOne = 'sink 1';
173
174 return {
apacible 2016/03/09 17:33:15 nit: alphabetize and remove extra newline.
btolsch 2016/03/09 20:01:01 Done.
175 fakeBlockingIssue: fakeBlockingIssue,
176 fakeCastModeList: fakeCastModeList,
177 fakeCastModeListWithNonDefaultModesOnly:
178 fakeCastModeListWithNonDefaultModesOnly,
179 fakeNonBlockingIssue: fakeNonBlockingIssue,
180 fakeRouteList: fakeRouteList,
181 fakeRouteListWithLocalRoutesOnly: fakeRouteListWithLocalRoutesOnly,
182 fakeSinkList: fakeSinkList,
183 searchTextAll: searchTextAll,
184 searchTextNone: searchTextNone,
185 searchTextOne: searchTextOne,
186
187 checkCurrentView: checkCurrentView,
188 checkElementsVisibleWithId: checkElementsVisibleWithId,
189 checkElementVisibleWithId: checkElementVisibleWithId,
190 checkElementText: checkElementText,
191 };
192 }
193 return {init: init};
194 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698