Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / third_party / tvcm / src / tvcm / ui / camera_test.js
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.
4
5 'use strict';
6
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');
12
13 tvcm.unittest.testSuite('tvcm.ui.camera_test', function() {
14
15   function createQuads() {
16     var quads = [
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
25     ];
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;
34     return quads;
35   }
36
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);
44     view.quads = quads;
45
46     testFramework.addHTMLOutput(view);
47     return view;
48   }
49
50   test('initialState', function() {
51     var view = createQuadStackView(this);
52
53     var viewRect =
54         view.getBoundingClientRect();
55     assertEquals(400, viewRect.height);
56     assertEquals(800, viewRect.width);
57   });
58 });