Html程序  |  75行  |  2.43 KB

<!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>
<title>Slice Group Selection Analysis Tests</title>
<script src="/src/base.js"></script>
</head>
<body>
  <script>
    base.require('unittest');
    base.require('test_utils');
    base.require('analysis.slice_group_selection_analysis');
    base.require('analysis.test.analysis_test_support');
  </script>
  <script>
    'use strict';

    function testSliceGroupSelectionAnalysisWithOneSlice() {
      var data = tracing.analysis.test.createReferenceData(true);

      var selection = new tracing.Selection();
      data.t1track.selectByTitle('f', selection);

      var analysis = new tracing.analysis.SliceGroupSelectionAnalysis();
      analysis.selection = selection;
      var rowEl = analysis.children[0];

      assertEquals(true, analysis instanceof
          tracing.analysis.SliceGroupSelectionAnalysis);
      assertEquals(1, analysis.children.length);
      assertEquals(3, rowEl.children.length);
      assertEquals('f', rowEl.children[0].textContent);
      assertEquals('0.002', rowEl.children[1].textContent);
      assertEquals('1', rowEl.children[2].textContent);
    }

    function testSliceGroupSelectionAnalysisWithTwoSlicesSameTitle() {
      var data = tracing.analysis.test.createReferenceData(true);

      var selection = new tracing.Selection();
      data.t1track.selectByTitle('b', selection);

      var analysis = new tracing.analysis.SliceGroupSelectionAnalysis();
      analysis.selection = selection;
      var rowEl = analysis.children[0];

      assertEquals(true, analysis instanceof
          tracing.analysis.SliceGroupSelectionAnalysis);
      assertEquals(1, analysis.children.length);
      assertEquals('b', rowEl.children[0].textContent);
      assertEquals('0.004', rowEl.children[1].textContent);
      assertEquals('2', rowEl.children[2].textContent);
    }

    function testSliceGroupSelectionAnalysisWithTwoSlicesDifferentTitles() {
      var data = tracing.analysis.test.createReferenceData(true);

      var selection = new tracing.Selection();
      data.t1track.selectByTitle('b', selection);
      data.t1track.selectByTitle('c', selection);

      var analysis = new tracing.analysis.SliceGroupSelectionAnalysis();
      assertThrows(function() {
        analysis.selection = selection;
      });
    }

  </script>
</body>
</html>