Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome/browser/resources/tracing/test_utils.js

Issue 10543144: Remove old tracing code now that it has moved to third_party. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 * @fileoverview Helper functions for use in tracing tests.
7 */
8
9
10 /**
11 * goog.testing.assertion's assertEquals tweaked to do equality-to-a-constant.
12 * @param {*} a First value.
13 * @param {*} b Second value.
14 */
15 function assertAlmostEquals(a, b) {
16 _validateArguments(2, arguments);
17 var var1 = nonCommentArg(1, 2, arguments);
18 var var2 = nonCommentArg(2, 2, arguments);
19 _assert(commentArg(2, arguments), Math.abs(var1 - var2) < 0.00001,
20 'Expected ' + _displayStringForValue(var1) + ' but was ' +
21 _displayStringForValue(var2));
22 }
23
24 cr.define('test_utils', function() {
25 function getAsync(url, cb) {
26 var req = new XMLHttpRequest();
27 req.open('GET', url, true);
28 req.onreadystatechange = function(aEvt) {
29 if (req.readyState == 4) {
30 window.setTimeout(function() {
31 if (req.status == 200) {
32 cb(req.responseText);
33 } else {
34 console.log('Failed to load ' + url);
35 }
36 }, 0);
37 }
38 };
39 req.send(null);
40 }
41
42 function newAsyncSlice(start, duration, startThread, endThread) {
43 return newAsyncSliceNamed('a', start, duration, startThread, endThread);
44 }
45
46 function newAsyncSliceNamed(name, start, duration, startThread, endThread) {
47 var s = new tracing.TimelineAsyncSlice(name, 0, start);
48 s.duration = duration;
49 s.startThread = startThread;
50 s.endThread = endThread;
51 var subSlice = new tracing.TimelineAsyncSlice(name, 0, start);
52 subSlice.duration = duration;
53 subSlice.startThread = startThread;
54 subSlice.endThread = endThread;
55 s.subSlices = [subSlice];
56 return s;
57 }
58
59 function assertArrayishEquals(ref, val) {
60 assertEquals(ref.length, val.length);
61 for (var i = 0; i < ref.length; i++)
62 assertEquals(ref[i], val[i]);
63 }
64
65
66 return {
67 getAsync: getAsync,
68 newAsyncSlice: newAsyncSlice,
69 newAsyncSliceNamed: newAsyncSliceNamed,
70 assertArrayishEquals: assertArrayishEquals
71 };
72 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/tracing/sorted_array_utils.js ('k') | chrome/browser/resources/tracing/tests.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698