| <!doctype html> |
| <!-- |
| Copyright 2015 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. |
| --> |
| |
| <script src="/jquery/jquery-2.1.4.min.js"></script> |
| <script src="/flot/jquery.flot.min.js"></script> |
| <script src="/flot/jquery.flot.crosshair.min.js"></script> |
| <script src="/flot/jquery.flot.fillbetween.min.js"></script> |
| <script src="/flot/jquery.flot.selection.min.js"></script> |
| |
| <link rel="import" href="/tracing/core/test_utils.html"> |
| |
| <link rel="import" href="/dashboard/elements/chart-container.html"> |
| <link rel="import" href="/dashboard/static/graph.html"> |
| <link rel="import" href="/dashboard/static/testing_common.html"> |
| <link rel="import" href="/dashboard/static/uri.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tr.b.unittest.testSuite(function() { |
| |
| var GRAPH_JSON = { |
| 'data': { |
| '0': { |
| 'color': 0, |
| 'data': [[348164, 24290], [348167, 22206], [348182, 24170], |
| [348198, 22847], [348224, 25224]], |
| 'id': 'line_0' |
| } |
| }, |
| 'error_bars': { |
| '0': [ |
| { |
| 'fillBetween': 'line_0', |
| 'clickable': false, |
| 'hoverable': false, |
| 'data': [[348164, 24290], [348167, 22206], [348182, 24170], |
| [348198, 22847], [348224, 25224]], |
| 'color': 0, |
| 'id': 'bottom_0', |
| 'lines': { |
| 'fill': 0.2, |
| 'lineWidth': 0, |
| 'show': true |
| } |
| }, |
| { |
| 'fillBetween': 'line_0', |
| 'clickable': false, |
| 'hoverable': false, |
| 'data': [[348164, 24290], [348167, 22206], [348182, 24170], |
| [348198, 22847], [348224, 25224]], |
| 'color': 0, |
| 'id': 'top_0', |
| 'lines': { |
| 'fill': 0.2, |
| 'lineWidth': 0, |
| 'show': true |
| } |
| } |
| ] |
| }, |
| 'annotations': { |
| '0': { |
| '0': { |
| 'a_trace_rerun_options': null, |
| 'error': 0, |
| 'r_webkit_rev': '202058', |
| 'a_stdio_uri': '[Buildbot stdio](//dromaeo/stdio)', |
| 'r_commit_pos': '348164', |
| 'timestamp': (new Date).getTime(), |
| 'r_chromium': '0c554b0e1233639e7428facc13ff674741368fb2' |
| } |
| }, |
| 'series': { |
| '0': { |
| 'name': 'dom', |
| 'description': null, |
| 'better': 'Higher', |
| 'units': 'runs/s', |
| 'path': 'ChromiumPerf/win/dromaeo/dom' |
| } |
| } |
| } |
| }; |
| |
| var GRAPH_REVISION_JSON = [ |
| [348164, 24290, 1445661677000], |
| [348167, 22206, 1445674668000], |
| [348182, 24170, 1445685601000], |
| [348198, 22847, 1445696455000], |
| [348224, 25224, 1445707715000] |
| ]; |
| |
| var testOptions = { |
| tearDown: function() { |
| testing_common.clearXhrMock(); |
| testing_common.clearFixture(); |
| } |
| }; |
| |
| function createBasicChart() { |
| var params = { |
| 'test_path_dict': { |
| 'ChromiumPerf/win/dromaeo': [] |
| }, |
| 'is_selected': true |
| }; |
| var graphQuery = ('/graph_json?graphs=' + |
| encodeURIComponent(JSON.stringify(params))); |
| testing_common.addXhrMock(graphQuery, JSON.stringify(GRAPH_JSON)); |
| var revisionQuery = ('/graph_revisions?test_path=' + |
| encodeURIComponent('ChromiumPerf/win/dromaeo/dom')); |
| testing_common.addXhrMock(revisionQuery, |
| JSON.stringify(GRAPH_REVISION_JSON)); |
| var chart = document.createElement('chart-container'); |
| return chart; |
| }; |
| |
| test('instantiate_ basic', function() { |
| var chart = createBasicChart(); |
| chart.addSeriesGroup([['ChromiumPerf/win/dromaeo', ['important']]]); |
| this.addHTMLOutput(chart); |
| }, testOptions); |
| |
| test('data is loaded when a series group is added', function() { |
| var chart = createBasicChart(); |
| testing_common.addToFixture(chart); |
| chart.addSeriesGroup([['ChromiumPerf/win/dromaeo', ['important']]]); |
| assert.equal(chart.getDataForFlot().length, 3); |
| }, testOptions); |
| |
| test('warning added for stale series', function() { |
| var params = { |
| 'test_path_dict': { |
| 'ChromiumPerf/win/dromaeo': [] |
| }, |
| 'is_selected': true |
| }; |
| var graphJson = testing_common.deepCopy(GRAPH_JSON); |
| graphJson['annotations']['0']['0']['timestamp'] -= 8 * 86400000; |
| var graphQuery = ('/graph_json?graphs=' + |
| encodeURIComponent(JSON.stringify(params))); |
| testing_common.addXhrMock(graphQuery, JSON.stringify(graphJson)); |
| |
| var chart = document.createElement('chart-container'); |
| testing_common.addToFixture(chart); |
| chart.addSeriesGroup([['ChromiumPerf/win/dromaeo', ['important']]]); |
| |
| return new Promise(function(resolve) { |
| function check() { |
| assert.notEqual(-1, chart.warnings[0].indexOf('Graph out of date!')); |
| resolve(); |
| } |
| setTimeout(check, 10); |
| }); |
| }, testOptions); |
| |
| }); |
| </script> |