Home | History | Annotate | Download | only in analysis
      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 Copyright (c) 2012 The Chromium Authors. All rights reserved.
      5 Use of this source code is governed by a BSD-style license that can be
      6 found in the LICENSE file.
      7 -->
      8 <head>
      9 <title>Selection Analysis Tests</title>
     10 <script src="../base.js"></script>
     11 </head>
     12 <body>
     13   <script>
     14     base.require('unittest');
     15     base.require('test_utils');
     16     base.require('timeline_track_view');
     17     base.require('analysis.selection_analysis');
     18     base.require('analysis.test.analysis_test_support');
     19     base.requireStylesheet('analysis.test.analysis_test_support');
     20   </script>
     21   <script>
     22     'use strict';
     23 
     24     function testSelectionAnalysisWithSingleSlice() {
     25       var data = tracing.analysis.test.createReferenceData(true);
     26 
     27       var selection = new tracing.Selection();
     28       data.t1track.selectByTitle('f', selection);
     29 
     30       var analysis = new tracing.analysis.SelectionAnalysis();
     31       analysis.selection = selection;
     32 
     33       var selectionEl = analysis;
     34       var sliceSelectionEl = selectionEl.children[0];
     35       var singleSliceEl = sliceSelectionEl.children[0];
     36 
     37       assertEquals(true,
     38           analysis instanceof tracing.analysis.SelectionAnalysis);
     39       assertEquals(true, sliceSelectionEl instanceof
     40           tracing.analysis.SliceSelectionAnalysis);
     41       assertEquals(1, sliceSelectionEl.children.length);
     42       assertEquals(4, singleSliceEl.children.length);
     43 
     44       this.addHTMLOutput(undefined, analysis);
     45     }
     46 
     47     function testSelectionAnalysisWithSingleSliceArgsAndCategory() {
     48       var data = tracing.analysis.test.createReferenceData(true);
     49 
     50       var selection = new tracing.Selection();
     51       data.t1track.selectByTitle('D', selection);
     52 
     53       var analysis = new tracing.analysis.SelectionAnalysis();
     54       analysis.selection = selection;
     55 
     56       var selectionEl = analysis;
     57       var sliceSelectionEl = selectionEl.children[0];
     58       var singleSliceEl = sliceSelectionEl.children[0];
     59       var categoryEl = singleSliceEl.children[1];
     60       var argEl1 = singleSliceEl.children[5];
     61       var argEl2 = singleSliceEl.children[6];
     62 
     63       assertEquals(true,
     64           analysis instanceof tracing.analysis.SelectionAnalysis);
     65       assertEquals(true, sliceSelectionEl instanceof
     66           tracing.analysis.SliceSelectionAnalysis);
     67       assertEquals(true, singleSliceEl instanceof
     68           tracing.analysis.SingleSliceSelectionAnalysis);
     69       assertEquals(1, sliceSelectionEl.children.length);
     70       assertEquals(7, singleSliceEl.children.length);
     71 
     72       this.addHTMLOutput(undefined, analysis);
     73     }
     74 
     75     function testSelectionAnalysisWithSlicesAndCounters() {
     76 
     77       var data = tracing.analysis.test.createReferenceData(true);
     78 
     79       var selection = new tracing.Selection();
     80       data.t1track.selectByTitle('b', selection);
     81       selection.addCounterSample(data.ctr1track, data.ctr1track.counter, 0);
     82 
     83       var analysis = new tracing.analysis.SelectionAnalysis();
     84       analysis.selection = selection;
     85 
     86       var selectionEl = analysis;
     87       var sliceSelectionEl = selectionEl.children[0];
     88       var counterSelectionEl = selectionEl.children[1];
     89 
     90       assertEquals(true, sliceSelectionEl instanceof
     91           tracing.analysis.SliceSelectionAnalysis);
     92       assertEquals(true, counterSelectionEl instanceof
     93           tracing.analysis.CounterSelectionAnalysis);
     94       assertEquals(2, selectionEl.children.length);
     95       assertEquals(3, sliceSelectionEl.children.length);
     96       assertEquals(2, counterSelectionEl.children.length);
     97 
     98       this.addHTMLOutput(undefined, analysis);
     99 
    100     }
    101 
    102     function testSelectionAnalysisWithSingleCounter() {
    103       var data = tracing.analysis.test.createReferenceData(true);
    104 
    105       var selection = new tracing.Selection();
    106       selection.addCounterSample(data.ctr1track, data.ctr1track.counter, 0);
    107 
    108       var analysis = new tracing.analysis.SelectionAnalysis();
    109       analysis.selection = selection;
    110 
    111       var selectionEl = analysis;
    112       var counterSelectionEl = selectionEl.children[0];
    113       var singleCounterEl = counterSelectionEl.children[1];
    114 
    115       assertEquals(true,
    116           analysis instanceof tracing.analysis.SelectionAnalysis);
    117       assertEquals(true, counterSelectionEl instanceof
    118           tracing.analysis.CounterSelectionAnalysis);
    119       assertEquals(true, singleCounterEl instanceof
    120           tracing.analysis.SingleCounterSelectionAnalysis);
    121       assertEquals(2, counterSelectionEl.children.length);
    122       assertEquals(1, singleCounterEl.children.length);
    123 
    124       this.addHTMLOutput(undefined, analysis);
    125     }
    126 
    127     function testSelectionAnalysisWithMultipleCounters() {
    128       var data = tracing.analysis.test.createReferenceData(true);
    129 
    130       var selection = new tracing.Selection();
    131       selection.addCounterSample(data.ctr1track, data.ctr1track.counter, 0);
    132       selection.addCounterSample(data.ctr2track, data.ctr2track.counter, 3);
    133 
    134       var analysis = new tracing.analysis.SelectionAnalysis();
    135       analysis.selection = selection;
    136 
    137       var selectionEl = analysis;
    138       var counterSelectionEl = selectionEl.children[0];
    139       var singleCounterEl = counterSelectionEl.children[1];
    140       var singleCounterEl2 = counterSelectionEl.children[2];
    141 
    142       assertEquals(true,
    143           analysis instanceof tracing.analysis.SelectionAnalysis);
    144       assertEquals(true, counterSelectionEl instanceof
    145           tracing.analysis.CounterSelectionAnalysis);
    146       assertEquals(true, singleCounterEl instanceof
    147           tracing.analysis.SingleCounterSelectionAnalysis);
    148       assertEquals(true, singleCounterEl2 instanceof
    149           tracing.analysis.SingleCounterSelectionAnalysis);
    150       assertEquals(3, counterSelectionEl.children.length);
    151       assertEquals(1, singleCounterEl.children.length);
    152       assertEquals(1, singleCounterEl2.children.length);
    153 
    154       this.addHTMLOutput(undefined, analysis);
    155     }
    156 
    157   </script>
    158 </body>
    159 </html>
    160