summaryrefslogtreecommitdiff
path: root/chromium/third_party/trace-viewer/src/ui/camera_test.js
blob: 4ae777ef77e3a5ff769e428408570a367849ffe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2013 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.

'use strict';

base.require('base.rect');
base.require('base.quad');
base.require('base.unittest');
base.require('base.bbox2');
base.require('ui.quad_stack_view');

base.unittest.testSuite('ui.camera', function() {

  function createQuads() {
    var quads = [
      base.Quad.fromXYWH(-500, -500, 30, 30), // 4 corners
      base.Quad.fromXYWH(-500, 470, 30, 30),
      base.Quad.fromXYWH(470, -500, 30, 30),
      base.Quad.fromXYWH(470, 470, 30, 30),
      base.Quad.fromXYWH(-250, -250, 250, 250), // crosshairs
      base.Quad.fromXYWH(0, -250, 250, 250), // crosshairs
      base.Quad.fromXYWH(-250, 0, 250, 250), // crosshairs
      base.Quad.fromXYWH(0, 0, 250, 250) // crosshairs
    ];
    quads[0].stackingGroupId = 0;
    quads[1].stackingGroupId = 0;
    quads[2].stackingGroupId = 0;
    quads[3].stackingGroupId = 0;
    quads[4].stackingGroupId = 1;
    quads[5].stackingGroupId = 1;
    quads[6].stackingGroupId = 1;
    quads[7].stackingGroupId = 1;
    return quads;
  }

  function createQuadStackView(testFramework) {
    var quads = createQuads();
    var view = new ui.QuadStackView();
    // simulate the constraints of the layer-tree-view
    view.style.height = '400px';
    view.style.width = '800px';
    view.deviceRect = base.Rect.fromXYWH(-250, -250, 500, 500);
    view.quads = quads;

    testFramework.addHTMLOutput(view);
    return view;
  }

  test('initialState', function() {
    var view = createQuadStackView(this);

    var viewRect =
        view.getBoundingClientRect();
    assertEquals(400, viewRect.height);
    assertEquals(800, viewRect.width);
  });
});