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