1 // Copyright (c) 2013 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.
7 tvcm.require('tvcm.rect');
8 tvcm.require('tvcm.quad');
9 tvcm.require('tvcm.unittest');
10 tvcm.require('tvcm.bbox2');
11 tvcm.require('tvcm.ui.quad_stack_view');
13 tvcm.unittest.testSuite('tvcm.ui.camera_test', function() {
15 function createQuads() {
17 tvcm.Quad.fromXYWH(-500, -500, 30, 30), // 4 corners
18 tvcm.Quad.fromXYWH(-500, 470, 30, 30),
19 tvcm.Quad.fromXYWH(470, -500, 30, 30),
20 tvcm.Quad.fromXYWH(470, 470, 30, 30),
21 tvcm.Quad.fromXYWH(-250, -250, 250, 250), // crosshairs
22 tvcm.Quad.fromXYWH(0, -250, 250, 250), // crosshairs
23 tvcm.Quad.fromXYWH(-250, 0, 250, 250), // crosshairs
24 tvcm.Quad.fromXYWH(0, 0, 250, 250) // crosshairs
26 quads[0].stackingGroupId = 0;
27 quads[1].stackingGroupId = 0;
28 quads[2].stackingGroupId = 0;
29 quads[3].stackingGroupId = 0;
30 quads[4].stackingGroupId = 1;
31 quads[5].stackingGroupId = 1;
32 quads[6].stackingGroupId = 1;
33 quads[7].stackingGroupId = 1;
37 function createQuadStackView(testFramework) {
38 var quads = createQuads();
39 var view = new tvcm.ui.QuadStackView();
40 // simulate the constraints of the layer-tree-view
41 view.style.height = '400px';
42 view.style.width = '800px';
43 view.deviceRect = tvcm.Rect.fromXYWH(-250, -250, 500, 500);
46 testFramework.addHTMLOutput(view);
50 test('initialState', function() {
51 var view = createQuadStackView(this);
54 view.getBoundingClientRect();
55 assertEquals(400, viewRect.height);
56 assertEquals(800, viewRect.width);