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

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

Issue 2002293003: [Media Router] Allow casting new media to sink with existing route. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for imcheng@'s off-the-record change 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 for 'close-route-click' event firing when the 88 // Tests for 'close-route-click' event firing when the
89 // 'close-route-button' button is clicked. 89 // 'close-route-button' button is clicked.
90 test('close route button click', function(done) { 90 test('close route button click', function(done) {
91 details.addEventListener('close-route-click', function() { 91 details.addEventListener('close-route', function() {
92 done(); 92 done();
93 }); 93 });
94 MockInteractions.tap(details.$['close-route-button']); 94 MockInteractions.tap(details.$['close-route-button']);
95 }); 95 });
96 96
97 // Tests for 'start-casting-to-route-click' event firing when the 97 // Tests for 'join-route-click' event firing when the
98 // 'start-casting-to-route-button' button is clicked. 98 // 'start-casting-to-route-button' button is clicked when the current
99 // route is joinable.
99 test('start casting to route button click', function(done) { 100 test('start casting to route button click', function(done) {
100 details.addEventListener( 101 details.addEventListener('join-route-click', function() { done(); });
101 'start-casting-to-route-click', function() { done(); }); 102 details.route = fakeRouteTwo;
102 MockInteractions.tap(details.$['start-casting-to-route-button']); 103 MockInteractions.tap(details.$['start-casting-to-route-button']);
103 }); 104 });
104 105
106 // Tests for 'cast-new-media-click' event firing when the
107 // 'start-casting-to-route-button' button is clicked when the current
108 // route is not joinable.
109 test('start casting button click starts new media', function(done) {
110 details.addEventListener(
111 'cast-new-media-click', function() { done(); });
112 details.route = fakeRouteOne;
113 MockInteractions.tap(details.$['start-casting-to-route-button']);
114 });
115
105 // Tests the initial expected text. 116 // Tests the initial expected text.
106 test('initial text setting', function() { 117 test('initial text setting', function() {
107 // <paper-button> text is styled as upper case. 118 // <paper-button> text is styled as upper case.
108 checkSpanText(loadTimeData.getString('stopCastingButtonText') 119 checkSpanText(loadTimeData.getString('stopCastingButtonText')
109 .toUpperCase(), 'close-route-button'); 120 .toUpperCase(), 'close-route-button');
110 checkSpanText( 121 checkSpanText(
111 loadTimeData.getString('startCastingButtonText').toUpperCase(), 122 loadTimeData.getString('startCastingButtonText').toUpperCase(),
112 'start-casting-to-route-button'); 123 'start-casting-to-route-button');
113 checkSpanText('', 'route-information'); 124 checkSpanText('', 'route-information');
114 }); 125 });
115 126
116 // Tests when |route| is undefined or set. 127 // Tests when |route| is undefined or set.
117 test('route is undefined or set', function() { 128 test('route is undefined or set', function() {
118 // |route| is initially undefined. 129 // |route| is initially undefined.
119 assertEquals(undefined, details.route); 130 assertEquals(undefined, details.route);
131 assertEquals(0, details.availableCastModes);
120 checkDefaultViewIsShown(); 132 checkDefaultViewIsShown();
121 133
122 // Set |route|. 134 // Set |route|.
123 details.route = fakeRouteOne; 135 details.route = fakeRouteOne;
124 assertEquals(fakeRouteOne, details.route); 136 assertEquals(fakeRouteOne, details.route);
125 checkSpanText(loadTimeData.getStringF('castingActivityStatus', 137 checkSpanText(loadTimeData.getStringF('castingActivityStatus',
126 fakeRouteOne.description), 'route-information'); 138 fakeRouteOne.description), 'route-information');
127 checkDefaultViewIsShown(); 139 checkDefaultViewIsShown();
128 checkStartCastButtonIsNotShown(); 140 checkStartCastButtonIsNotShown();
129 141
130 // Set |route| to a different route. 142 // Set |route| to a different route.
131 details.route = fakeRouteTwo; 143 details.route = fakeRouteTwo;
132 assertEquals(fakeRouteTwo, details.route); 144 assertEquals(fakeRouteTwo, details.route);
133 checkSpanText(loadTimeData.getStringF('castingActivityStatus', 145 checkSpanText(loadTimeData.getStringF('castingActivityStatus',
134 fakeRouteTwo.description), 'route-information'); 146 fakeRouteTwo.description), 'route-information');
135 checkDefaultViewIsShown(); 147 checkDefaultViewIsShown();
136 checkStartCastButtonIsShown(); 148 checkStartCastButtonIsShown();
137 }); 149 });
138 150
151 // Tests when |availableCastModes| is undefined or set.
152 test('route available cast modes undefined or set', function() {
153 details.route = fakeRouteOne;
154 assertEquals(0, details.availableCastModes);
155 assertFalse(details.route.canJoin);
156 checkStartCastButtonIsNotShown();
157
158 details.availableCastModes = 1;
159 checkStartCastButtonIsShown();
160
161 details.availableCastModes = 2;
162 checkStartCastButtonIsShown();
163
164 details.availableCastModes = 3;
165 checkStartCastButtonIsShown();
166 });
167
139 // Tests when |route| exists, has a custom controller, and it loads. 168 // Tests when |route| exists, has a custom controller, and it loads.
140 test('route has custom controller and loading succeeds', function(done) { 169 test('route has custom controller and loading succeeds', function(done) {
141 var loadInvoked = false; 170 var loadInvoked = false;
142 details.$['custom-controller'].load = function(url) { 171 details.$['custom-controller'].load = function(url) {
143 loadInvoked = true; 172 loadInvoked = true;
144 assertEquals('chrome-extension://123/custom_view.html', url); 173 assertEquals('chrome-extension://123/custom_view.html', url);
145 return Promise.resolve(); 174 return Promise.resolve();
146 }; 175 };
147 176
148 details.route = fakeRouteOne; 177 details.route = fakeRouteOne;
(...skipping 19 matching lines...) Expand all
168 done(); 197 done();
169 }); 198 });
170 }); 199 });
171 }); 200 });
172 } 201 }
173 202
174 return { 203 return {
175 registerTests: registerTests, 204 registerTests: registerTests,
176 }; 205 };
177 }); 206 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698