| 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 /** | 5 /** |
| 6 * Standalone unit tests of the PDF Polymer elements. | 6 * Standalone unit tests of the PDF Polymer elements. |
| 7 */ | 7 */ |
| 8 var tests = [ | 8 var tests = [ |
| 9 /** | 9 /** |
| 10 * Test that viewer-page-selector reacts correctly to text entry. The page | 10 * Test that viewer-page-selector reacts correctly to text entry. The page |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 lastEvent = e.type; | 153 lastEvent = e.type; |
| 154 } | 154 } |
| 155 var assertEvent = function(type) { | 155 var assertEvent = function(type) { |
| 156 chrome.test.assertEq(type, lastEvent); | 156 chrome.test.assertEq(type, lastEvent); |
| 157 lastEvent = null; | 157 lastEvent = null; |
| 158 } | 158 } |
| 159 zoomToolbar.addEventListener('fit-to-width', logEvent); | 159 zoomToolbar.addEventListener('fit-to-width', logEvent); |
| 160 zoomToolbar.addEventListener('fit-to-page', logEvent); | 160 zoomToolbar.addEventListener('fit-to-page', logEvent); |
| 161 | 161 |
| 162 // Initial: Show fit-to-page. | 162 // Initial: Show fit-to-page. |
| 163 chrome.test.assertEq(fitPageIcon, fab.icon); | 163 // TODO(tsergeant): This assertion attempts to be resilient to iconset |
| 164 // changes. A better solution is something like |
| 165 // https://github.com/PolymerElements/iron-icon/issues/68. |
| 166 chrome.test.assertTrue(fab.icon.endsWith(fitPageIcon)); |
| 164 | 167 |
| 165 // Tap 1: Fire fit-to-page, show fit-to-width. | 168 // Tap 1: Fire fit-to-page, show fit-to-width. |
| 166 MockInteractions.tap(fab); | 169 MockInteractions.tap(fab); |
| 167 assertEvent('fit-to-page'); | 170 assertEvent('fit-to-page'); |
| 168 chrome.test.assertEq(fitWidthIcon, fab.icon); | 171 chrome.test.assertTrue(fab.icon.endsWith(fitWidthIcon)); |
| 169 | 172 |
| 170 // Tap 2: Fire fit-to-width, show fit-to-page. | 173 // Tap 2: Fire fit-to-width, show fit-to-page. |
| 171 MockInteractions.tap(fab); | 174 MockInteractions.tap(fab); |
| 172 assertEvent('fit-to-width'); | 175 assertEvent('fit-to-width'); |
| 173 chrome.test.assertEq(fitPageIcon, fab.icon); | 176 chrome.test.assertTrue(fab.icon.endsWith(fitPageIcon)); |
| 174 | 177 |
| 175 // Tap 3: Fire fit-to-page again. | 178 // Tap 3: Fire fit-to-page again. |
| 176 MockInteractions.tap(fab); | 179 MockInteractions.tap(fab); |
| 177 assertEvent('fit-to-page'); | 180 assertEvent('fit-to-page'); |
| 178 | 181 |
| 179 chrome.test.succeed(); | 182 chrome.test.succeed(); |
| 180 } | 183 } |
| 181 ]; | 184 ]; |
| 182 | 185 |
| 183 importTestHelpers().then(function() { | 186 importTestHelpers().then(function() { |
| 184 chrome.test.runTests(tests); | 187 chrome.test.runTests(tests); |
| 185 }); | 188 }); |
| OLD | NEW |