Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: chrome/test/data/pdf/material_elements_test.js

Issue 1371913002: Material PDF: Adjust behaviour of page selector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pdf_material_rtl
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * selector validates that input is an integer, but does not check for 11 * selector validates that input is an integer, and does not allow navigation
12 * document bounds. 12 * past document bounds.
13 */ 13 */
14 function testPageSelectorChange() { 14 function testPageSelectorChange() {
15 var selector = 15 var selector =
16 Polymer.Base.create('viewer-page-selector', {docLength: 1234}); 16 Polymer.Base.create('viewer-page-selector', {docLength: 1234});
17 17
18 var input = selector.$.input; 18 var input = selector.$.input;
19 // Simulate entering text into `input` and pressing enter. 19 // Simulate entering text into `input` and pressing enter.
20 function changeInput(newValue) { 20 function changeInput(newValue) {
21 input.bindValue = newValue; 21 input.value = newValue;
22 input.dispatchEvent(new CustomEvent('change')); 22 input.dispatchEvent(new CustomEvent('change'));
23 } 23 }
24 24
25 var navigatedPages = []; 25 var navigatedPages = [];
26 selector.addEventListener('change-page', function(e) { 26 selector.addEventListener('change-page', function(e) {
27 navigatedPages.push(e.detail.page); 27 navigatedPages.push(e.detail.page);
28 // A change-page handler is expected to set the pageNo to the new value.
29 selector.pageNo = e.detail.page + 1;
28 }); 30 });
29 31
30 changeInput("1000"); 32 changeInput("1000");
31 changeInput("1234"); 33 changeInput("1234");
32 changeInput("abcd"); 34 changeInput("abcd");
33 changeInput("12pp"); 35 changeInput("12pp");
34 changeInput("3.14"); 36 changeInput("3.14");
37 changeInput("3000");
35 38
36 chrome.test.assertEq(4, navigatedPages.length); 39 chrome.test.assertEq(4, navigatedPages.length);
37 // The event page number is 0-based. 40 // The event page number is 0-based.
38 chrome.test.assertEq(999, navigatedPages[0]); 41 chrome.test.assertEq(999, navigatedPages[0]);
39 chrome.test.assertEq(1233, navigatedPages[1]); 42 chrome.test.assertEq(1233, navigatedPages[1]);
40 chrome.test.assertEq(11, navigatedPages[2]); 43 chrome.test.assertEq(11, navigatedPages[2]);
41 chrome.test.assertEq(2, navigatedPages[3]); 44 chrome.test.assertEq(2, navigatedPages[3]);
42 45
43 chrome.test.succeed(); 46 chrome.test.succeed();
44 }, 47 },
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 MockInteractions.tap(fab); 176 MockInteractions.tap(fab);
174 assertEvent('fit-to-page'); 177 assertEvent('fit-to-page');
175 178
176 chrome.test.succeed(); 179 chrome.test.succeed();
177 } 180 }
178 ]; 181 ];
179 182
180 importTestHelpers().then(function() { 183 importTestHelpers().then(function() {
181 chrome.test.runTests(tests); 184 chrome.test.runTests(tests);
182 }); 185 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698