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

Unified Diff: tools/cc-frame-viewer/src/quad_view_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.js ('k') | tools/cc-frame-viewer/src/quad_view_viewport.js » ('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_test.html
diff --git a/tools/cc-frame-viewer/src/quad_view_test.html b/tools/cc-frame-viewer/src/quad_view_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..6b13879b9245839607e1a508de5f6b4549db5a7d
--- /dev/null
+++ b/tools/cc-frame-viewer/src/quad_view_test.html
@@ -0,0 +1,91 @@
+<!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('model.layer_tree_host_impl');
+ base.require('quad_view');
+ base.require('quad_view_viewport');
+</script>
+</head>
+<body>
+<script>
+ 'use strict';
+
+ var QuadView = ccfv.QuadView;
+ var QuadViewViewport = ccfv.QuadViewViewport;
+
+ function QuadFromXYWH(x, y, w, h) {
+ return {p1: {x: x, y: y},
+ p2: {x: x+w, y: y},
+ p3: {x: x+w, y: y+h},
+ p4: {x: x, y: y+h}};
+ }
+
+ function testInstantiate() {
+ var quadView = new QuadView();
+ this.addHTMLOutput('test', quadView);
+
+ var quads = [
+ QuadFromXYWH(0, 0, 10, 10),
+ QuadFromXYWH(10, 10, 10, 10),
+ QuadFromXYWH(20, 4, 10, 10),
+ QuadFromXYWH(30, 10, 20, 20),
+ QuadFromXYWH(20, 20, 10, 10),
+ QuadFromXYWH(15, 15, 10, 10)
+ ];
+ quads[2].selected = true;
+ var quadsBBox = new base.BBox2();
+ for (var i = 0; i < quads.length; i++)
+ quadsBBox.addQuad(quads[i]);
+
+ quadView.title = 'Test Tree';
+ quadView.quads = quads;
+ quadView.viewport = new QuadViewViewport(quadsBBox, 10.0)
+ quadView.deviceViewportSizeForFrame = {widht: 50,
+ height: 30};
+ }
+
+ function testFindTiles() {
+ var quadView = new QuadView();
+
+ var quads = [
+ QuadFromXYWH(0, 0, 10, 10),
+ QuadFromXYWH(10, 10, 10, 10),
+ QuadFromXYWH(20, 4, 10, 10),
+ QuadFromXYWH(30, 10, 20, 20),
+ QuadFromXYWH(20, 20, 10, 10),
+ QuadFromXYWH(15, 15, 10, 10)
+ ];
+ var quadsBBox = new base.BBox2();
+ for (var i = 0; i < quads.length; i++)
+ quadsBBox.addQuad(quads[i]);
+
+ quadView.title = 'Test Tree';
+ quadView.quads = quads;
+ quadView.viewport = new QuadViewViewport(quadsBBox, 10.0, true, 2);
+ quadView.deviceViewportSizeForFrame = {widht: 50,
+ height: 30};
+
+ document.body.appendChild(quadView);
+ try {
+ var rect = quadView.canvas_.getBoundingClientRect();
+ var hitIndices = quadView.findQuadsAtCanvasClientPoint(rect.left + 75,
+ rect.top + 75);
+ } finally {
+ document.body.removeChild(quadView);
+ }
+
+ assertEquals(2, hitIndices.length);
+ assertArrayEquals(hitIndices, [1, 5]);
+ }
+
+</script>
+</body>
+</html>
« no previous file with comments | « tools/cc-frame-viewer/src/quad_view.js ('k') | tools/cc-frame-viewer/src/quad_view_viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698