Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / chrome / test / data / pdf / params_parser_test.js
blob34bccf59f57302197b71015dc1b44143dd97b293
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
3 // found in the LICENSE file.
5 var tests = [
6   /**
7    * Test named destinations.
8    */
9   function testParamsParser() {
10     var paramsParser = new OpenPDFParamsParser();
11     // Assigning page number for #nameddests.
12     paramsParser.namedDestinations['RU'] = 26;
13     paramsParser.namedDestinations['US'] = 0;
14     paramsParser.namedDestinations['UY'] = 22;
16     var url = "http://xyz.pdf";
18     // Checking #nameddest.
19     var urlParams = paramsParser.getViewportFromUrlParams(url + "#RU");
20     chrome.test.assertEq(urlParams.page, 26);
22     // Checking #nameddest=name.
23     urlParams = paramsParser.getViewportFromUrlParams(url + "#nameddest=US");
24     chrome.test.assertEq(urlParams.page, 0);
26     // Checking #page=pagenum nameddest.The document first page has a pagenum
27     // value of 1.
28     urlParams = paramsParser.getViewportFromUrlParams(url + "#page=6");
29     chrome.test.assertEq(urlParams.page, 5);
31     // Checking #zoom=scale.
32     urlParams = paramsParser.getViewportFromUrlParams(url + "#zoom=200");
33     chrome.test.assertEq(urlParams.zoom, 2);
35     // Checking #zoom=scale,left,top.
36     urlParams = paramsParser.getViewportFromUrlParams(url +
37         "#zoom=200,100,200");
38     chrome.test.assertEq(urlParams.zoom, 2);
39     chrome.test.assertEq(urlParams.position.x, 100);
40     chrome.test.assertEq(urlParams.position.y, 200);
42     // Checking #nameddest=name and zoom=scale.
43     urlParams = paramsParser.getViewportFromUrlParams(url +
44         "#nameddest=UY&zoom=150");
45     chrome.test.assertEq(urlParams.page, 22);
46     chrome.test.assertEq(urlParams.zoom, 1.5);
48     // Checking #page=pagenum and zoom=scale.
49     urlParams = paramsParser.getViewportFromUrlParams(url +
50         "#page=2&zoom=250");
51     chrome.test.assertEq(urlParams.page, 1);
52     chrome.test.assertEq(urlParams.zoom, 2.5);
54     // Checking #nameddest=name and zoom=scale,left,top.
55     urlParams = paramsParser.getViewportFromUrlParams(url +
56         "#nameddest=UY&zoom=150,100,200");
57     chrome.test.assertEq(urlParams.page, 22);
58     chrome.test.assertEq(urlParams.zoom, 1.5);
59     chrome.test.assertEq(urlParams.position.x, 100);
60     chrome.test.assertEq(urlParams.position.y, 200);
62     // Checking #page=pagenum and zoom=scale,left,top.
63     urlParams = paramsParser.getViewportFromUrlParams(url +
64         "#page=2&zoom=250,100,200");
65     chrome.test.assertEq(urlParams.page, 1);
66     chrome.test.assertEq(urlParams.zoom, 2.5);
67     chrome.test.assertEq(urlParams.position.x, 100);
68     chrome.test.assertEq(urlParams.position.y, 200);
70     chrome.test.succeed();
71   }
74 var scriptingAPI = new PDFScriptingAPI(window, window);
75 scriptingAPI.setLoadCallback(function() {
76   chrome.test.runTests(tests);
77 });