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

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

Issue 2062913002: [Media Router] Allow casting new media to sink with existing route. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @fileoverview Suite of tests for route-details. */ 5 /** @fileoverview Suite of tests for route-details. */
6 cr.define('route_details', function() { 6 cr.define('route_details', function() {
7 function registerTests() { 7 function registerTests() {
8 suite('RouteDetails', function() { 8 suite('RouteDetails', function() {
9 /** 9 /**
10 * Route Details created before each test. 10 * Route Details created before each test.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 fakeRouteOne = new media_router.Route('route id 1', 'sink id 1', 78 fakeRouteOne = new media_router.Route('route id 1', 'sink id 1',
79 'Video 1', 1, true, false, 79 'Video 1', 1, true, false,
80 'chrome-extension://123/custom_view.html'); 80 'chrome-extension://123/custom_view.html');
81 fakeRouteTwo = new media_router.Route('route id 2', 'sink id 2', 81 fakeRouteTwo = new media_router.Route('route id 2', 'sink id 2',
82 'Video 2', 2, false, true); 82 'Video 2', 2, false, true);
83 83
84 // Allow for the route details to be created and attached. 84 // Allow for the route details to be created and attached.
85 setTimeout(done); 85 setTimeout(done);
86 }); 86 });
87 87
88 // Tests that the cast button is shown under the correct circumstances and
89 // that updating |replaceRouteAvailable| updates the cast button
90 // visibility.
91 test('cast button visibility', function() {
92 details.route = fakeRouteTwo;
93 checkStartCastButtonIsShown();
94
95 details.availableCastModes = 1;
96 details.replaceRouteAvailable = false;
97 details.route = fakeRouteOne;
98 checkStartCastButtonIsNotShown();
99
100 details.replaceRouteAvailable = true;
101 checkStartCastButtonIsShown();
102 });
103
88 // Tests for 'close-route-click' event firing when the 104 // Tests for 'close-route-click' event firing when the
89 // 'close-route-button' button is clicked. 105 // 'close-route-button' button is clicked.
90 test('close route button click', function(done) { 106 test('close route button click', function(done) {
91 details.addEventListener('close-route-click', function() { 107 details.addEventListener('close-route', function() {
92 done(); 108 done();
93 }); 109 });
94 MockInteractions.tap(details.$['close-route-button']); 110 MockInteractions.tap(details.$['close-route-button']);
95 }); 111 });
96 112
97 // Tests for 'start-casting-to-route-click' event firing when the 113 // Tests for 'join-route-click' event firing when the
98 // 'start-casting-to-route-button' button is clicked. 114 // 'start-casting-to-route-button' button is clicked when the current
115 // route is joinable.
99 test('start casting to route button click', function(done) { 116 test('start casting to route button click', function(done) {
100 details.addEventListener( 117 details.addEventListener('join-route-click', function() { done(); });
101 'start-casting-to-route-click', function() { done(); }); 118 details.route = fakeRouteTwo;
102 MockInteractions.tap(details.$['start-casting-to-route-button']); 119 MockInteractions.tap(details.$['start-casting-to-route-button']);
103 }); 120 });
104 121
122 // Tests for 'replace-route-click' event firing when the
123 // 'start-casting-to-route-button' button is clicked when the current
124 // route is not joinable.
125 test('start casting button click replaces route', function(done) {
126 details.addEventListener(
127 'replace-route-click', function() { done(); });
128 details.route = fakeRouteOne;
129 details.availableCastModes = 1;
130 MockInteractions.tap(details.$['start-casting-to-route-button']);
131 });
132
105 // Tests the initial expected text. 133 // Tests the initial expected text.
106 test('initial text setting', function() { 134 test('initial text setting', function() {
107 // <paper-button> text is styled as upper case. 135 // <paper-button> text is styled as upper case.
108 checkSpanText(loadTimeData.getString('stopCastingButtonText') 136 checkSpanText(loadTimeData.getString('stopCastingButtonText')
109 .toUpperCase(), 'close-route-button'); 137 .toUpperCase(), 'close-route-button');
110 checkSpanText( 138 checkSpanText(
111 loadTimeData.getString('startCastingButtonText').toUpperCase(), 139 loadTimeData.getString('startCastingButtonText').toUpperCase(),
112 'start-casting-to-route-button'); 140 'start-casting-to-route-button');
113 checkSpanText('', 'route-information'); 141 checkSpanText('', 'route-information');
114 }); 142 });
115 143
116 // Tests when |route| is undefined or set. 144 // Tests when |route| is undefined or set.
117 test('route is undefined or set', function() { 145 test('route is undefined or set', function() {
118 // |route| is initially undefined. 146 // |route| is initially undefined.
119 assertEquals(undefined, details.route); 147 assertEquals(undefined, details.route);
148 assertEquals(0, details.availableCastModes);
120 checkDefaultViewIsShown(); 149 checkDefaultViewIsShown();
121 150
122 // Set |route|. 151 // Set |route|.
123 details.route = fakeRouteOne; 152 details.route = fakeRouteOne;
124 assertEquals(fakeRouteOne, details.route); 153 assertEquals(fakeRouteOne, details.route);
125 checkSpanText(loadTimeData.getStringF('castingActivityStatus', 154 checkSpanText(loadTimeData.getStringF('castingActivityStatus',
126 fakeRouteOne.description), 'route-information'); 155 fakeRouteOne.description), 'route-information');
127 checkDefaultViewIsShown(); 156 checkDefaultViewIsShown();
128 checkStartCastButtonIsNotShown(); 157 checkStartCastButtonIsNotShown();
129 158
130 // Set |route| to a different route. 159 // Set |route| to a different route.
131 details.route = fakeRouteTwo; 160 details.route = fakeRouteTwo;
132 assertEquals(fakeRouteTwo, details.route); 161 assertEquals(fakeRouteTwo, details.route);
133 checkSpanText(loadTimeData.getStringF('castingActivityStatus', 162 checkSpanText(loadTimeData.getStringF('castingActivityStatus',
134 fakeRouteTwo.description), 'route-information'); 163 fakeRouteTwo.description), 'route-information');
135 checkDefaultViewIsShown(); 164 checkDefaultViewIsShown();
136 checkStartCastButtonIsShown(); 165 checkStartCastButtonIsShown();
137 }); 166 });
138 167
168 // Tests when |availableCastModes| is undefined or set.
169 test('route available cast modes undefined or set', function() {
170 details.route = fakeRouteOne;
171 assertEquals(0, details.availableCastModes);
172 assertFalse(details.route.canJoin);
173 checkStartCastButtonIsNotShown();
174
175 details.availableCastModes = 1;
176 checkStartCastButtonIsShown();
177
178 details.availableCastModes = 2;
179 checkStartCastButtonIsShown();
180
181 details.availableCastModes = 3;
182 checkStartCastButtonIsShown();
183 });
184
139 // Tests when |route| exists, has a custom controller, and it loads. 185 // Tests when |route| exists, has a custom controller, and it loads.
140 test('route has custom controller and loading succeeds', function(done) { 186 test('route has custom controller and loading succeeds', function(done) {
141 var loadInvoked = false; 187 var loadInvoked = false;
142 details.$['custom-controller'].load = function(url) { 188 details.$['custom-controller'].load = function(url) {
143 loadInvoked = true; 189 loadInvoked = true;
144 assertEquals('chrome-extension://123/custom_view.html', url); 190 assertEquals('chrome-extension://123/custom_view.html', url);
145 return Promise.resolve(); 191 return Promise.resolve();
146 }; 192 };
147 193
148 details.route = fakeRouteOne; 194 details.route = fakeRouteOne;
(...skipping 19 matching lines...) Expand all
168 done(); 214 done();
169 }); 215 });
170 }); 216 });
171 }); 217 });
172 } 218 }
173 219
174 return { 220 return {
175 registerTests: registerTests, 221 registerTests: registerTests,
176 }; 222 };
177 }); 223 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698