| 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); |
| 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 checkStartCastButtonIsShown(); |
| 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 168 done(); | 180 done(); |
| 169 }); | 181 }); |
| 170 }); | 182 }); |
| 171 }); | 183 }); |
| 172 } | 184 } |
| 173 | 185 |
| 174 return { | 186 return { |
| 175 registerTests: registerTests, | 187 registerTests: registerTests, |
| 176 }; | 188 }; |
| 177 }); | 189 }); |
| OLD | NEW |