Home | History | Annotate | Download | only in static
      1 // Copyright 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 /**
      6  * Test whether given line is valid.
      7  * @param {Object} line
      8  * @param {number} length Length of line data.
      9  * @return {boolean} Line is valid or not.
     10  */
     11 var lineIsValid = function(line, length) {
     12   if (!('id' in line))
     13     return false;
     14   if (!('label' in line))
     15     return false;
     16   if (!('data' in line) ||
     17       'data' in line && line.data.length !== length)
     18     return false;
     19 
     20   return true;
     21 };
     22 
     23 // Test title format is file-name:function-name.
     24 test('graph-view:generateLines_', function() {
     25   stop();
     26   $.getJSON('../data/sample.json', function(data) {
     27     start();
     28     var profiler = new Profiler(data);
     29     var models = profiler.parseTemplate_();
     30     var length = models.length;
     31     var lines = GraphView.prototype.generateLines_(models);
     32     lines.forEach(function(line) {
     33       ok(lineIsValid(line, length));
     34     });
     35     inspect(lines, 'lines generated by graph view:\n');
     36   });
     37 });
     38