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

Unified Diff: tools/cc-frame-viewer/src/quad_view_viewport_test.html

Issue 12225131: [cc] Initial checkin of cc-frame-viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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 | « tools/cc-frame-viewer/src/quad_view_viewport.js ('k') | tools/cc-frame-viewer/src/tests.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cc-frame-viewer/src/quad_view_viewport_test.html
diff --git a/tools/cc-frame-viewer/src/quad_view_viewport_test.html b/tools/cc-frame-viewer/src/quad_view_viewport_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..cf82fc74bafd191dbbfdfbac6fd3584a1017bfb8
--- /dev/null
+++ b/tools/cc-frame-viewer/src/quad_view_viewport_test.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Copyright (c) 2012 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.
+-->
+<head>
+<script src="base.js"></script>
+<script>
+ base.require('base.unittest');
+ base.require('base.bbox2');
+ base.require('quad_view_viewport');
+</script>
+</head>
+<body>
+<script>
+ 'use strict';
+
+ var QuadViewViewport = ccfv.QuadViewViewport;
+
+ function testBasicsHighDPI() {
+ var bbox = new base.BBox2();
+ bbox.addXY(0, 0);
+ bbox.addXY(4000, 2000);
+
+ var vp = new QuadViewViewport(bbox, 0.125, true, 2);
+ assertEquals(500, vp.deviceWidth);
+ assertEquals(250, vp.deviceHeight);
+
+ assertEquals(250, vp.layoutWidth);
+ assertEquals(125, vp.layoutHeight);
+
+ // Top left.
+ var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(0, 0))
+ assertEquals(0, tmp[0]);
+ assertEquals(0, tmp[1]);
+
+ // World center.
+ var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(125, 62.5))
+ assertEquals(2000, tmp[0]);
+ assertEquals(1000, tmp[1]);
+
+ // Bottom right.
+ var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(250, 125))
+ assertEquals(4000, tmp[0]);
+ assertEquals(2000, tmp[1]);
+ }
+
+ function testBasicsHighDPIUnpadded() {
+ var bbox = new base.BBox2();
+ bbox.addXY(0, 0);
+ bbox.addXY(4000, 2000);
+
+ var vp = new QuadViewViewport(bbox, 0.125, false, 2);
+ assertEquals(550, vp.deviceWidth);
+ assertEquals(300, vp.deviceHeight);
+
+ assertEquals(275, vp.layoutWidth);
+ assertEquals(150, vp.layoutHeight);
+
+ // Top left.
+ var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(0, 0))
+ assertEquals(-200, tmp[0]);
+ assertEquals(-200, tmp[1]);
+
+ // World center.
+ var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(137.5, 75))
+ assertEquals(2000, tmp[0]);
+ assertEquals(1000, tmp[1]);
+
+ // Bottom right.
+ var tmp = vp.layoutPixelsToWorldPixels2(vec2.createXY(275, 150))
+ assertEquals(4200, tmp[0]);
+ assertEquals(2200, tmp[1]);
+ }
+</script>
+</body>
+</html>
« no previous file with comments | « tools/cc-frame-viewer/src/quad_view_viewport.js ('k') | tools/cc-frame-viewer/src/tests.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698