blob: 7edf70f6c5b20eb12ffee4765dbc6e2b8dd08871 [file] [log] [blame]
<!DOCTYPE html>
<html>
<!--
Copyright (c) 2010 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.
-->
<head>
<title>TimelineModel tests</title>
<script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
<script src="../shared/js/cr.js"></script>
<script src="../shared/js/cr/event_target.js"></script>
<script src="timeline_model.js"></script>
<script>
goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>
var TimelineCpu = tracing.TimelineCpu;
var TimelineSlice = tracing.TimelineSlice;
var TimelineProcess = tracing.TimelineProcess;
var TimelineThread = tracing.TimelineThread;
var TimelineModel = tracing.TimelineModel;
function testThreadBounds_Empty() {
var t = new TimelineThread(undefined, 1);
t.updateBounds();
assertEquals(undefined, t.minTimestamp);
assertEquals(undefined, t.maxTimestamp);
}
function testThreadBounds_SubRow() {
var t = new TimelineThread(undefined, 1);
t.subRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
t.updateBounds();
assertEquals(1, t.minTimestamp);
assertEquals(4, t.maxTimestamp);
}
function testThreadBounds_NestedSubrow() {
var t = new TimelineThread(undefined, 1);
t.nonNestedSubRows.push([]);
t.nonNestedSubRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
t.updateBounds();
assertEquals(1, t.minTimestamp);
assertEquals(4, t.maxTimestamp);
}
function testThreadBounds_SubRowAndNonNestedSubRow() {
var t = new TimelineThread(undefined, 1);
t.subRows[0].push(new TimelineSlice('a', 0, 0.5, {}, 3));
t.nonNestedSubRows.push([]);
t.nonNestedSubRows[0].push(new TimelineSlice('b', 0, 1, {}, 4.5));
t.updateBounds();
assertEquals(0.5, t.minTimestamp);
assertEquals(5.5, t.maxTimestamp);
}
function testModelBounds_EmptyModel() {
var m = new TimelineModel();
m.updateBounds();
assertEquals(undefined, m.minTimestamp);
assertEquals(undefined, m.maxTimestamp);
}
function testModelBounds_OneEmptyThread() {
var m = new TimelineModel();
var t = m.getOrCreateProcess(1).getOrCreateThread(1);
m.updateBounds();
assertEquals(undefined, m.minTimestamp);
assertEquals(undefined, m.maxTimestamp);
}
function testModelBounds_OneThrad() {
var m = new TimelineModel();
var t = m.getOrCreateProcess(1).getOrCreateThread(1);
t.subRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
m.updateBounds();
assertEquals(1, m.minTimestamp);
assertEquals(4, m.maxTimestamp);
}
function testModelBounds_OneThreadAndOneEmptyThread() {
var m = new TimelineModel();
var t1 = m.getOrCreateProcess(1).getOrCreateThread(1);
t1.subRows[0].push(new TimelineSlice('a', 0, 1, {}, 3));
var t2 = m.getOrCreateProcess(1).getOrCreateThread(1);
m.updateBounds();
assertEquals(1, m.minTimestamp);
assertEquals(4, m.maxTimestamp);
}
function testCpuBounds_Empty() {
var cpu = new TimelineCpu(undefined, 1);
cpu.updateBounds();
assertEquals(undefined, cpu.minTimestamp);
assertEquals(undefined, cpu.maxTimestamp);
}
function testCpuBounds_OneSlice() {
var cpu = new TimelineCpu(undefined, 1);
cpu.slices.push(new TimelineSlice('a', 0, 1, {}, 3));
cpu.updateBounds();
assertEquals(1, cpu.minTimestamp);
assertEquals(4, cpu.maxTimestamp);
}
function testModelBounds_OneCpu() {
}
function testModelBounds_OneCpuOneThread() {
}
</script>
</body>
</html>