Html程序  |  105行  |  3.56 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 Selection Analysis Tests</title>
<script src="/src/base.js"></script>
</head>
<body>
  <script>
    base.require('unittest');
    base.require('test_utils');
    base.require('analysis.slice_selection_analysis');
    base.require('analysis.test.analysis_test_support');
  </script>
  <script>
    'use strict';

    function testEmptySelection() {
      var selection = new tracing.Selection();
      var analysis = new tracing.analysis.SliceSelectionAnalysis();
      assertThrows(function() {
        analysis.selection = selection;
      });
    }

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

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

      var analysis = new tracing.analysis.SliceSelectionAnalysis();
      analysis.selection = selection;

      var sliceSelectionEl = analysis;
      var groupSliceEl = sliceSelectionEl.children[1];
      var headerEl = sliceSelectionEl.children[0];

      assertEquals(true, sliceSelectionEl instanceof
          tracing.analysis.SliceSelectionAnalysis);
      assertEquals(3, sliceSelectionEl.children.length);
      assertEquals(true, groupSliceEl instanceof
          tracing.analysis.SliceGroupSelectionAnalysis);
      assertEquals(1, groupSliceEl.children.length);
      assertEquals(3, headerEl.children.length);
    }


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

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

      var analysis = new tracing.analysis.SliceSelectionAnalysis();
      analysis.selection = selection;

      var sliceSelectionEl = analysis;
      var headerEl = sliceSelectionEl.children[0];
      var groupSliceEl = sliceSelectionEl.children[1];
      var summaryEl = sliceSelectionEl.children[2];

      assertEquals(true,
          analysis instanceof tracing.analysis.SliceSelectionAnalysis);
      assertEquals(3, analysis.children.length);
      assertEquals(3, headerEl.children.length);
      assertEquals(1, groupSliceEl.children.length);
      assertEquals(3, summaryEl.children.length);
    }

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

      var selection = new tracing.Selection();
      data.t1track.selectByTitle('b', selection);
      data.t1track.selectByTitle('c', selection);
      data.t1track.selectByTitle('d', selection);
      data.t1track.selectByTitle('e', selection);
      data.t1track.selectByTitle('Slice with a really, really long name.',
                                  selection);

      var analysis = new tracing.analysis.SliceSelectionAnalysis();
      analysis.selection = selection;

      var sliceSelectionEl = analysis;
      var groupSliceEl = sliceSelectionEl.children[1];
      var headerEl = sliceSelectionEl.children[0];

      assertEquals(true, sliceSelectionEl instanceof
          tracing.analysis.SliceSelectionAnalysis);
      assertEquals(true, groupSliceEl instanceof
          tracing.analysis.SliceGroupSelectionAnalysis);
      assertEquals(7, sliceSelectionEl.children.length);
      assertEquals(1, groupSliceEl.children.length);
      assertEquals(3, headerEl.children.length);
    }

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