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 function NavigateInCurrentTabCallback() { | 5 function NavigateInCurrentTabCallback() { |
6 this.navigateInCurrentTabCalled = false; | 6 this.navigateInCurrentTabCalled = false; |
7 this.callback = function() { | 7 this.callback = function() { |
8 this.navigateInCurrentTabCalled = true; | 8 this.navigateInCurrentTabCalled = true; |
9 }.bind(this); | 9 }.bind(this); |
10 this.reset = function() { | 10 this.reset = function() { |
(...skipping 18 matching lines...) Expand all Loading... | |
29 */ | 29 */ |
30 function testNavigate() { | 30 function testNavigate() { |
31 var mockWindow = new MockWindow(100, 100); | 31 var mockWindow = new MockWindow(100, 100); |
32 var mockSizer = new MockSizer(); | 32 var mockSizer = new MockSizer(); |
33 var mockCallback = new MockViewportChangedCallback(); | 33 var mockCallback = new MockViewportChangedCallback(); |
34 var viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback, | 34 var viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback, |
35 function() {}, function() {}, 0, 0); | 35 function() {}, function() {}, 0, 0); |
36 | 36 |
37 var paramsParser = new OpenPDFParamsParser(); | 37 var paramsParser = new OpenPDFParamsParser(); |
38 paramsParser.namedDestinations['US'] = 0; | 38 paramsParser.namedDestinations['US'] = 0; |
39 paramsParser.namedDestinations['UY'] = 2; | 39 paramsParser.namedDestinations['UY'] = 2; |
raymes
2015/02/16 22:44:03
instead, we should pass in the function to get the
| |
40 var url = "http://xyz.pdf"; | 40 var url = "http://xyz.pdf"; |
41 | 41 |
42 var navigateInCurrentTabCallback = new NavigateInCurrentTabCallback(); | 42 var navigateInCurrentTabCallback = new NavigateInCurrentTabCallback(); |
43 var navigateInNewTabCallback = new NavigateInNewTabCallback(); | 43 var navigateInNewTabCallback = new NavigateInNewTabCallback(); |
44 var navigator = new Navigator(url, viewport, paramsParser, | 44 var navigator = new Navigator(url, viewport, paramsParser, |
45 navigateInCurrentTabCallback.callback, | 45 navigateInCurrentTabCallback.callback, |
46 navigateInNewTabCallback.callback); | 46 navigateInNewTabCallback.callback); |
47 | 47 |
48 var documentDimensions = new MockDocumentDimensions(); | 48 var documentDimensions = new MockDocumentDimensions(); |
49 documentDimensions.addPage(100, 100); | 49 documentDimensions.addPage(100, 100); |
(...skipping 19 matching lines...) Expand all Loading... | |
69 chrome.test.assertEq(0, viewport.position.x); | 69 chrome.test.assertEq(0, viewport.position.x); |
70 chrome.test.assertEq(0, viewport.position.y); | 70 chrome.test.assertEq(0, viewport.position.y); |
71 | 71 |
72 mockCallback.reset(); | 72 mockCallback.reset(); |
73 // This should move viewport to page 2. | 73 // This should move viewport to page 2. |
74 navigator.navigate(url + "#UY", false); | 74 navigator.navigate(url + "#UY", false); |
75 chrome.test.assertTrue(mockCallback.wasCalled); | 75 chrome.test.assertTrue(mockCallback.wasCalled); |
76 chrome.test.assertEq(0, viewport.position.x); | 76 chrome.test.assertEq(0, viewport.position.x); |
77 chrome.test.assertEq(300, viewport.position.y); | 77 chrome.test.assertEq(300, viewport.position.y); |
78 | 78 |
79 mockCallback.reset(); | |
80 navigateInCurrentTabCallback.reset(); | |
81 // #ABC is not a named destination in the page so viewport should not | |
82 // update and viewport position should remain same. As this link will open | |
83 // in the same tab. | |
84 navigator.navigate(url + "#ABC", false); | |
85 chrome.test.assertFalse(mockCallback.wasCalled); | |
86 chrome.test.assertTrue( | |
87 navigateInCurrentTabCallback.navigateInCurrentTabCalled); | |
88 chrome.test.assertEq(0, viewport.position.x); | |
89 chrome.test.assertEq(300, viewport.position.y); | |
raymes
2015/02/16 02:02:31
How come this is removed?
Deepak
2015/02/16 06:45:38
This is removed as:
when #ABC is not in paramsPars
raymes
2015/02/16 22:44:03
If we do the suggestion above we should be able to
| |
90 | |
91 chrome.test.succeed(); | 79 chrome.test.succeed(); |
92 } | 80 } |
93 ]; | 81 ]; |
94 | 82 |
95 var scriptingAPI = new PDFScriptingAPI(window, window); | 83 var scriptingAPI = new PDFScriptingAPI(window, window); |
96 scriptingAPI.setLoadCallback(function() { | 84 scriptingAPI.setLoadCallback(function() { |
97 chrome.test.runTests(tests); | 85 chrome.test.runTests(tests); |
98 }); | 86 }); |
OLD | NEW |