Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / tools / cc-frame-viewer / src / quad_view_viewport_test.html
blobcf82fc74bafd191dbbfdfbac6fd3584a1017bfb8
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Copyright (c) 2012 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
7 -->
8 <head>
9 <script src="base.js"></script>
10 <script>
11 base.require('base.unittest');
12 base.require('base.bbox2');
13 base.require('quad_view_viewport');
14 </script>
15 </head>
16 <body>
17 <script>
18 'use strict';
20 var QuadViewViewport = ccfv.QuadViewViewport;
22 function testBasicsHighDPI() {
23 var bbox = new base.BBox2();
24 bbox.addXY(0, 0);
25 bbox.addXY(4000, 2000);
27 var vp = new QuadViewViewport(bbox, 0.125, true, 2);
28 assertEquals(500, vp.deviceWidth);
29 assertEquals(250, vp.deviceHeight);
31 assertEquals(250, vp.layoutWidth);
32 assertEquals(125, vp.layoutHeight);
34 // Top left.
35 var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(0, 0))
36 assertEquals(0, tmp[0]);
37 assertEquals(0, tmp[1]);
39 // World center.
40 var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(125, 62.5))
41 assertEquals(2000, tmp[0]);
42 assertEquals(1000, tmp[1]);
44 // Bottom right.
45 var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(250, 125))
46 assertEquals(4000, tmp[0]);
47 assertEquals(2000, tmp[1]);
50 function testBasicsHighDPIUnpadded() {
51 var bbox = new base.BBox2();
52 bbox.addXY(0, 0);
53 bbox.addXY(4000, 2000);
55 var vp = new QuadViewViewport(bbox, 0.125, false, 2);
56 assertEquals(550, vp.deviceWidth);
57 assertEquals(300, vp.deviceHeight);
59 assertEquals(275, vp.layoutWidth);
60 assertEquals(150, vp.layoutHeight);
62 // Top left.
63 var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(0, 0))
64 assertEquals(-200, tmp[0]);
65 assertEquals(-200, tmp[1]);
67 // World center.
68 var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(137.5, 75))
69 assertEquals(2000, tmp[0]);
70 assertEquals(1000, tmp[1]);
72 // Bottom right.
73 var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(275, 150))
74 assertEquals(4200, tmp[0]);
75 assertEquals(2200, tmp[1]);
77 </script>
78 </body>
79 </html>