| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * These tests require that the PDF plugin be available to run correctly. | 6 * These tests require that the PDF plugin be available to run correctly. |
| 7 */ | 7 */ |
| 8 var tests = [ | 8 var tests = [ |
| 9 /** | 9 /** |
| 10 * Test that the page is sized to the size of the document. | 10 * Test that the page is sized to the size of the document. |
| 11 */ | 11 */ |
| 12 function testPageSize() { | 12 function testPageSize() { |
| 13 // Verify that the initial zoom is less than or equal to 100%. | 13 // Verify that the initial zoom is less than or equal to 100%. |
| 14 chrome.test.assertTrue(viewer.viewport.zoom <= 1); | 14 chrome.test.assertTrue(viewer.viewport.zoom <= 1); |
| 15 | 15 |
| 16 viewer.viewport.setZoom(1); | 16 viewer.viewport.setZoom(1); |
| 17 var sizer = document.getElementById('sizer'); | 17 var sizer = document.getElementById('sizer'); |
| 18 chrome.test.assertEq(826, sizer.offsetWidth); | 18 chrome.test.assertEq(826, sizer.offsetWidth); |
| 19 chrome.test.assertEq(1066 + viewer.viewport.topToolbarHeight_, | 19 chrome.test.assertEq(1066 + viewer.viewport.topToolbarHeight_, |
| 20 sizer.offsetHeight); | 20 sizer.offsetHeight); |
| 21 chrome.test.succeed(); | 21 chrome.test.succeed(); |
| 22 }, | 22 }, |
| 23 | 23 |
| 24 function testAccessibility() { | |
| 25 scriptingAPI.getAccessibilityJSON(chrome.test.callbackPass(function(json) { | |
| 26 var dict = JSON.parse(json); | |
| 27 chrome.test.assertEq(true, dict.copyable); | |
| 28 chrome.test.assertEq(true, dict.loaded); | |
| 29 chrome.test.assertEq(1, dict.numberOfPages); | |
| 30 })); | |
| 31 }, | |
| 32 | |
| 33 function testAccessibilityWithPage() { | |
| 34 scriptingAPI.getAccessibilityJSON(chrome.test.callbackPass(function(json) { | |
| 35 var dict = JSON.parse(json); | |
| 36 chrome.test.assertEq(612, dict.width); | |
| 37 chrome.test.assertEq(792, dict.height); | |
| 38 chrome.test.assertEq(1.0, dict.textBox[0].fontSize); | |
| 39 chrome.test.assertEq('text', dict.textBox[0].textNodes[0].type); | |
| 40 chrome.test.assertEq('this is some text', | |
| 41 dict.textBox[0].textNodes[0].text); | |
| 42 chrome.test.assertEq('text', dict.textBox[1].textNodes[0].type); | |
| 43 chrome.test.assertEq('some more text', | |
| 44 dict.textBox[1].textNodes[0].text); | |
| 45 }), 0); | |
| 46 }, | |
| 47 | |
| 48 function testGetSelectedText() { | 24 function testGetSelectedText() { |
| 49 var client = new PDFScriptingAPI(window, window); | 25 var client = new PDFScriptingAPI(window, window); |
| 50 client.selectAll(); | 26 client.selectAll(); |
| 51 client.getSelectedText(chrome.test.callbackPass(function(selectedText) { | 27 client.getSelectedText(chrome.test.callbackPass(function(selectedText) { |
| 52 chrome.test.assertEq('this is some text\nsome more text', selectedText); | 28 chrome.test.assertEq('this is some text\nsome more text', selectedText); |
| 53 })); | 29 })); |
| 54 }, | 30 }, |
| 55 | 31 |
| 56 /** | 32 /** |
| 57 * Test that the filename is used as the title.pdf. | 33 * Test that the filename is used as the title.pdf. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 75 e.initEvent('keydown'); | 51 e.initEvent('keydown'); |
| 76 e.keyCode = 27; | 52 e.keyCode = 27; |
| 77 document.dispatchEvent(e); | 53 document.dispatchEvent(e); |
| 78 } | 54 } |
| 79 ]; | 55 ]; |
| 80 | 56 |
| 81 var scriptingAPI = new PDFScriptingAPI(window, window); | 57 var scriptingAPI = new PDFScriptingAPI(window, window); |
| 82 scriptingAPI.setLoadCallback(function() { | 58 scriptingAPI.setLoadCallback(function() { |
| 83 chrome.test.runTests(tests); | 59 chrome.test.runTests(tests); |
| 84 }); | 60 }); |
| OLD | NEW |