| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 }, | 95 }, |
| 96 { | 96 { |
| 97 title: 'Test 1b', | 97 title: 'Test 1b', |
| 98 page: 3, | 98 page: 3, |
| 99 children: [] | 99 children: [] |
| 100 }] | 100 }] |
| 101 }], | 101 }], |
| 102 depth: 1 | 102 depth: 1 |
| 103 }); | 103 }); |
| 104 | 104 |
| 105 // Wait for the <template>s to be properly initialized. | 105 // Force templates to render. |
| 106 bookmarkContent.async(function() { | 106 Polymer.dom.flush(); |
| 107 var rootBookmarks = | |
| 108 bookmarkContent.shadowRoot.querySelectorAll('viewer-bookmark'); | |
| 109 chrome.test.assertEq(1, rootBookmarks.length, "one root bookmark"); | |
| 110 var rootBookmark = rootBookmarks[0]; | |
| 111 | 107 |
| 112 var subBookmarks = | 108 var rootBookmarks = |
| 113 rootBookmark.shadowRoot.querySelectorAll('viewer-bookmark'); | 109 bookmarkContent.shadowRoot.querySelectorAll('viewer-bookmark'); |
| 114 chrome.test.assertEq(2, subBookmarks.length, "two sub bookmarks"); | 110 chrome.test.assertEq(1, rootBookmarks.length, "one root bookmark"); |
| 115 chrome.test.assertEq(1, subBookmarks[1].depth, | 111 var rootBookmark = rootBookmarks[0]; |
| 116 "sub bookmark depth correct"); | |
| 117 | 112 |
| 118 var lastPageChange; | 113 var subBookmarks = |
| 119 rootBookmark.addEventListener('change-page', function(e) { | 114 rootBookmark.shadowRoot.querySelectorAll('viewer-bookmark'); |
| 120 lastPageChange = e.detail.page; | 115 chrome.test.assertEq(2, subBookmarks.length, "two sub bookmarks"); |
| 121 }); | 116 chrome.test.assertEq(1, subBookmarks[1].depth, |
| 117 "sub bookmark depth correct"); |
| 122 | 118 |
| 123 MockInteractions.tap(rootBookmark.$.item); | 119 var lastPageChange; |
| 124 chrome.test.assertEq(1, lastPageChange); | 120 rootBookmark.addEventListener('change-page', function(e) { |
| 121 lastPageChange = e.detail.page; |
| 122 }); |
| 125 | 123 |
| 126 MockInteractions.tap(subBookmarks[1].$.item); | 124 MockInteractions.tap(rootBookmark.$.item); |
| 127 chrome.test.assertEq(3, lastPageChange); | 125 chrome.test.assertEq(1, lastPageChange); |
| 128 | 126 |
| 129 var subBookmarkDiv = | 127 MockInteractions.tap(subBookmarks[1].$.item); |
| 130 rootBookmark.shadowRoot.querySelector('.sub-bookmark'); | 128 chrome.test.assertEq(3, lastPageChange); |
| 131 | 129 |
| 132 chrome.test.assertTrue(subBookmarkDiv.hidden); | 130 var subBookmarkDiv = |
| 133 MockInteractions.tap(rootBookmark.$.expand); | 131 rootBookmark.shadowRoot.querySelector('.sub-bookmark'); |
| 134 chrome.test.assertFalse(subBookmarkDiv.hidden); | |
| 135 chrome.test.assertEq('hidden', subBookmarks[1].$.expand.style.visibility); | |
| 136 | 132 |
| 137 chrome.test.succeed(); | 133 chrome.test.assertTrue(subBookmarkDiv.hidden); |
| 138 }); | 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(); |
| 139 } | 139 } |
| 140 ]; | 140 ]; |
| 141 | 141 |
| 142 importTestHelpers().then(function() { | 142 importTestHelpers().then(function() { |
| 143 chrome.test.runTests(tests); | 143 chrome.test.runTests(tests); |
| 144 }); | 144 }); |
| OLD | NEW |