Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / tools / cc-frame-viewer / src / quad_view_test.html
blob6b13879b9245839607e1a508de5f6b4549db5a7d
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('model.layer_tree_host_impl');
13 base.require('quad_view');
14 base.require('quad_view_viewport');
15 </script>
16 </head>
17 <body>
18 <script>
19 'use strict';
21 var QuadView = ccfv.QuadView;
22 var QuadViewViewport = ccfv.QuadViewViewport;
24 function QuadFromXYWH(x, y, w, h) {
25 return {p1: {x: x, y: y},
26 p2: {x: x+w, y: y},
27 p3: {x: x+w, y: y+h},
28 p4: {x: x, y: y+h}};
31 function testInstantiate() {
32 var quadView = new QuadView();
33 this.addHTMLOutput('test', quadView);
35 var quads = [
36 QuadFromXYWH(0, 0, 10, 10),
37 QuadFromXYWH(10, 10, 10, 10),
38 QuadFromXYWH(20, 4, 10, 10),
39 QuadFromXYWH(30, 10, 20, 20),
40 QuadFromXYWH(20, 20, 10, 10),
41 QuadFromXYWH(15, 15, 10, 10)
43 quads[2].selected = true;
44 var quadsBBox = new base.BBox2();
45 for (var i = 0; i < quads.length; i++)
46 quadsBBox.addQuad(quads[i]);
48 quadView.title = 'Test Tree';
49 quadView.quads = quads;
50 quadView.viewport = new QuadViewViewport(quadsBBox, 10.0)
51 quadView.deviceViewportSizeForFrame = {widht: 50,
52 height: 30};
55 function testFindTiles() {
56 var quadView = new QuadView();
58 var quads = [
59 QuadFromXYWH(0, 0, 10, 10),
60 QuadFromXYWH(10, 10, 10, 10),
61 QuadFromXYWH(20, 4, 10, 10),
62 QuadFromXYWH(30, 10, 20, 20),
63 QuadFromXYWH(20, 20, 10, 10),
64 QuadFromXYWH(15, 15, 10, 10)
66 var quadsBBox = new base.BBox2();
67 for (var i = 0; i < quads.length; i++)
68 quadsBBox.addQuad(quads[i]);
70 quadView.title = 'Test Tree';
71 quadView.quads = quads;
72 quadView.viewport = new QuadViewViewport(quadsBBox, 10.0, true, 2);
73 quadView.deviceViewportSizeForFrame = {widht: 50,
74 height: 30};
76 document.body.appendChild(quadView);
77 try {
78 var rect = quadView.canvas_.getBoundingClientRect();
79 var hitIndices = quadView.findQuadsAtCanvasClientPoint(rect.left + 75,
80 rect.top + 75);
81 } finally {
82 document.body.removeChild(quadView);
85 assertEquals(2, hitIndices.length);
86 assertArrayEquals(hitIndices, [1, 5]);
89 </script>
90 </body>
91 </html>