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

Unified Diff: chrome/test/data/pdf/params_parser_test.js

Issue 838723003: Testcases for nameddests and navigate for PDF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/pdf/navigator_test.js ('k') | chrome/test/data/pdf/test_util.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/pdf/params_parser_test.js
diff --git a/chrome/test/data/pdf/params_parser_test.js b/chrome/test/data/pdf/params_parser_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..34bccf59f57302197b71015dc1b44143dd97b293
--- /dev/null
+++ b/chrome/test/data/pdf/params_parser_test.js
@@ -0,0 +1,77 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var tests = [
+ /**
+ * Test named destinations.
+ */
+ function testParamsParser() {
+ var paramsParser = new OpenPDFParamsParser();
+ // Assigning page number for #nameddests.
+ paramsParser.namedDestinations['RU'] = 26;
+ paramsParser.namedDestinations['US'] = 0;
+ paramsParser.namedDestinations['UY'] = 22;
+
+ var url = "http://xyz.pdf";
+
+ // Checking #nameddest.
+ var urlParams = paramsParser.getViewportFromUrlParams(url + "#RU");
+ chrome.test.assertEq(urlParams.page, 26);
+
+ // Checking #nameddest=name.
+ urlParams = paramsParser.getViewportFromUrlParams(url + "#nameddest=US");
+ chrome.test.assertEq(urlParams.page, 0);
+
+ // Checking #page=pagenum nameddest.The document first page has a pagenum
+ // value of 1.
+ urlParams = paramsParser.getViewportFromUrlParams(url + "#page=6");
+ chrome.test.assertEq(urlParams.page, 5);
+
+ // Checking #zoom=scale.
+ urlParams = paramsParser.getViewportFromUrlParams(url + "#zoom=200");
+ chrome.test.assertEq(urlParams.zoom, 2);
+
+ // Checking #zoom=scale,left,top.
+ urlParams = paramsParser.getViewportFromUrlParams(url +
+ "#zoom=200,100,200");
+ chrome.test.assertEq(urlParams.zoom, 2);
+ chrome.test.assertEq(urlParams.position.x, 100);
+ chrome.test.assertEq(urlParams.position.y, 200);
+
+ // Checking #nameddest=name and zoom=scale.
+ urlParams = paramsParser.getViewportFromUrlParams(url +
+ "#nameddest=UY&zoom=150");
+ chrome.test.assertEq(urlParams.page, 22);
+ chrome.test.assertEq(urlParams.zoom, 1.5);
+
+ // Checking #page=pagenum and zoom=scale.
+ urlParams = paramsParser.getViewportFromUrlParams(url +
+ "#page=2&zoom=250");
+ chrome.test.assertEq(urlParams.page, 1);
+ chrome.test.assertEq(urlParams.zoom, 2.5);
+
+ // Checking #nameddest=name and zoom=scale,left,top.
+ urlParams = paramsParser.getViewportFromUrlParams(url +
+ "#nameddest=UY&zoom=150,100,200");
+ chrome.test.assertEq(urlParams.page, 22);
+ chrome.test.assertEq(urlParams.zoom, 1.5);
+ chrome.test.assertEq(urlParams.position.x, 100);
+ chrome.test.assertEq(urlParams.position.y, 200);
+
+ // Checking #page=pagenum and zoom=scale,left,top.
+ urlParams = paramsParser.getViewportFromUrlParams(url +
+ "#page=2&zoom=250,100,200");
+ chrome.test.assertEq(urlParams.page, 1);
+ chrome.test.assertEq(urlParams.zoom, 2.5);
+ chrome.test.assertEq(urlParams.position.x, 100);
+ chrome.test.assertEq(urlParams.position.y, 200);
+
+ chrome.test.succeed();
+ }
+];
+
+var scriptingAPI = new PDFScriptingAPI(window, window);
+scriptingAPI.setLoadCallback(function() {
+ chrome.test.runTests(tests);
+});
« no previous file with comments | « chrome/test/data/pdf/navigator_test.js ('k') | chrome/test/data/pdf/test_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698