| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 depth: 1 | 102 depth: 1 |
| 103 }); | 103 }); |
| 104 | 104 |
| 105 // Force templates to render. | 105 // Force templates to render. |
| 106 Polymer.dom.flush(); | 106 Polymer.dom.flush(); |
| 107 | 107 |
| 108 var rootBookmarks = | 108 var rootBookmarks = |
| 109 bookmarkContent.shadowRoot.querySelectorAll('viewer-bookmark'); | 109 bookmarkContent.shadowRoot.querySelectorAll('viewer-bookmark'); |
| 110 chrome.test.assertEq(1, rootBookmarks.length, "one root bookmark"); | 110 chrome.test.assertEq(1, rootBookmarks.length, "one root bookmark"); |
| 111 var rootBookmark = rootBookmarks[0]; | 111 var rootBookmark = rootBookmarks[0]; |
| 112 MockInteractions.tap(rootBookmark.$.expand); |
| 113 |
| 114 Polymer.dom.flush(); |
| 112 | 115 |
| 113 var subBookmarks = | 116 var subBookmarks = |
| 114 rootBookmark.shadowRoot.querySelectorAll('viewer-bookmark'); | 117 rootBookmark.shadowRoot.querySelectorAll('viewer-bookmark'); |
| 115 chrome.test.assertEq(2, subBookmarks.length, "two sub bookmarks"); | 118 chrome.test.assertEq(2, subBookmarks.length, "two sub bookmarks"); |
| 116 chrome.test.assertEq(1, subBookmarks[1].depth, | 119 chrome.test.assertEq(1, subBookmarks[1].depth, |
| 117 "sub bookmark depth correct"); | 120 "sub bookmark depth correct"); |
| 118 | 121 |
| 119 var lastPageChange; | 122 var lastPageChange; |
| 120 rootBookmark.addEventListener('change-page', function(e) { | 123 rootBookmark.addEventListener('change-page', function(e) { |
| 121 lastPageChange = e.detail.page; | 124 lastPageChange = e.detail.page; |
| 122 }); | 125 }); |
| 123 | 126 |
| 124 MockInteractions.tap(rootBookmark.$.item); | 127 MockInteractions.tap(rootBookmark.$.item); |
| 125 chrome.test.assertEq(1, lastPageChange); | 128 chrome.test.assertEq(1, lastPageChange); |
| 126 | 129 |
| 127 MockInteractions.tap(subBookmarks[1].$.item); | 130 MockInteractions.tap(subBookmarks[1].$.item); |
| 128 chrome.test.assertEq(3, lastPageChange); | 131 chrome.test.assertEq(3, lastPageChange); |
| 129 | 132 |
| 130 var subBookmarkDiv = | |
| 131 rootBookmark.shadowRoot.querySelector('.sub-bookmark'); | |
| 132 | |
| 133 chrome.test.assertTrue(subBookmarkDiv.hidden); | |
| 134 MockInteractions.tap(rootBookmark.$.expand); | |
| 135 chrome.test.assertFalse(subBookmarkDiv.hidden); | |
| 136 chrome.test.assertEq('hidden', subBookmarks[1].$.expand.style.visibility); | |
| 137 | |
| 138 chrome.test.succeed(); | 133 chrome.test.succeed(); |
| 139 }, | 134 }, |
| 140 | 135 |
| 141 /** | 136 /** |
| 142 * Test that the zoom toolbar toggles between showing the fit-to-page and | 137 * Test that the zoom toolbar toggles between showing the fit-to-page and |
| 143 * fit-to-width buttons. | 138 * fit-to-width buttons. |
| 144 */ | 139 */ |
| 145 function testZoomToolbarToggle() { | 140 function testZoomToolbarToggle() { |
| 146 var zoomToolbar = Polymer.Base.create('viewer-zoom-toolbar', {}); | 141 var zoomToolbar = Polymer.Base.create('viewer-zoom-toolbar', {}); |
| 147 var fitButton = zoomToolbar.$['fit-button']; | 142 var fitButton = zoomToolbar.$['fit-button']; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 178 MockInteractions.tap(fab); | 173 MockInteractions.tap(fab); |
| 179 assertEvent('fit-to-page'); | 174 assertEvent('fit-to-page'); |
| 180 | 175 |
| 181 chrome.test.succeed(); | 176 chrome.test.succeed(); |
| 182 } | 177 } |
| 183 ]; | 178 ]; |
| 184 | 179 |
| 185 importTestHelpers().then(function() { | 180 importTestHelpers().then(function() { |
| 186 chrome.test.runTests(tests); | 181 chrome.test.runTests(tests); |
| 187 }); | 182 }); |
| OLD | NEW |