OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Test whether given line is valid. | 6 * Test whether given line is valid. |
7 * @param {Object} line | 7 * @param {Object} line |
8 * @param {number} length Length of line data. | 8 * @param {number} length Length of line data. |
9 * @return {boolean} Line is valid or not. | 9 * @return {boolean} Line is valid or not. |
10 */ | 10 */ |
11 var lineIsValid = function(line, length) { | 11 var lineIsValid = function(line, length) { |
12 if (!('id' in line)) | 12 if (!('id' in line)) |
13 return false; | 13 return false; |
14 if (!('label' in line)) | 14 if (!('label' in line)) |
15 return false; | 15 return false; |
16 if (!('data' in line) || | 16 if (!('data' in line) || |
17 'data' in line && line.data.length !== length) | 17 'data' in line && line.data.length !== length) |
18 return false; | 18 return false; |
19 | 19 |
20 return true; | 20 return true; |
21 }; | 21 }; |
22 | 22 |
23 // Test title format is file-name:function-name. | 23 // Test title format is file-name:function-name. |
24 test('graph-view:generateLines_', function() { | 24 test('graph-view:generateLines_', function() { |
25 stop(); | 25 stop(); |
26 $.getJSON('data/sample.json', function(data) { | 26 $.getJSON('../data/sample.json', function(data) { |
27 start(); | 27 start(); |
28 var profiler = new Profiler(data); | 28 var profiler = new Profiler(data); |
29 var models = profiler.parseTemplate_(); | 29 var models = profiler.parseTemplate_(); |
30 var length = models.length; | 30 var length = models.length; |
31 var lines = GraphView.prototype.generateLines_(models); | 31 var lines = GraphView.prototype.generateLines_(models); |
32 lines.forEach(function(line) { | 32 lines.forEach(function(line) { |
33 ok(lineIsValid(line, length)); | 33 ok(lineIsValid(line, length)); |
34 }); | 34 }); |
35 inspect(lines, 'lines generated by graph view:\n'); | 35 inspect(lines, 'lines generated by graph view:\n'); |
36 }); | 36 }); |
37 }); | 37 }); |
OLD | NEW |