<!DOCTYPE HTML>
<html>
<!--
Copyright (c) 2012 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>
<style>
  .timeline-view {
    border: 1px solid black;
    margin: 10px;
  }
  .timeline-find-dialog {
    border: 1px solid black;
    margin: 10px;
  }
</style>
<script src="base.js"></script>
<script>
  base.require('unittest');
  base.require('test_utils');
  base.require('timeline_model');
</script>
</head>
<body>
<script>
'use strict';

var TimelineSlice = tracing.TimelineSlice;
var TimelineThreadSlice = tracing.TimelineThreadSlice;
var TimelineThread = tracing.TimelineThread;
var TimelineModel = tracing.TimelineModel;
var TimelineTitleFilter = tracing.TimelineTitleFilter;

function createModelWithOneOfEverything() {
  var m = new TimelineModel();
  var cpu = m.getOrCreateCpu(1);
  cpu.slices.push(test_utils.newSlice(1, 3));

  var p = m.getOrCreateProcess(1);
  var t = p.getOrCreateThread(1);
  t.pushSlice(new TimelineThreadSlice('', 'a', 0, 1, {}, 4));
  t.asyncSlices.push(test_utils.newAsyncSlice(0, 1, t, t));

  var c = p.getOrCreateCounter('', 'ProcessCounter');
  c.seriesNames.push('a', 'b');
  c.seriesColors.push(0, 1);
  c.timestamps.push(0, 1, 2, 3);
  c.samples.push(5, 10, 6, 15, 5, 12, 7, 16);

  var c1 = cpu.getOrCreateCounter('', 'CpuCounter');
  c1.seriesNames.push('a', 'b');
  c1.seriesColors.push(0, 1);
  c1.timestamps.push(0, 1, 2, 3);
  c1.samples.push(5, 10, 6, 15, 5, 12, 7, 16);

  m.updateBounds();

  return m;
}

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_OneThread() {
  var m = new TimelineModel();
  var t = m.getOrCreateProcess(1).getOrCreateThread(1);
  t.pushSlice(new TimelineThreadSlice('', '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.pushSlice(new TimelineThreadSlice('', 'a', 0, 1, {}, 3));
  var t2 = m.getOrCreateProcess(1).getOrCreateThread(1);
  m.updateBounds();
  assertEquals(1, m.minTimestamp);
  assertEquals(4, m.maxTimestamp);
}

function testModelBounds_OneCpu() {
  var m = new TimelineModel();
  var cpu = m.getOrCreateCpu(1);
  cpu.slices.push(test_utils.newSlice(1, 3));
  m.updateBounds();
  assertEquals(1, m.minTimestamp);
  assertEquals(4, m.maxTimestamp);
}


function testModelBounds_OneCpuOneThread() {
  var m = new TimelineModel();
  var cpu = m.getOrCreateCpu(1);
  cpu.slices.push(test_utils.newSlice(1, 3));

  var t = m.getOrCreateProcess(1).getOrCreateThread(1);
  t.pushSlice(new TimelineThreadSlice('', 'a', 0, 1, {}, 4));

  m.updateBounds();
  assertEquals(1, m.minTimestamp);
  assertEquals(5, m.maxTimestamp);
}

function testModelCanImportEmpty() {
  var m;
  m = new TimelineModel([]);
  m = new TimelineModel('');
}

function testTimelineTitleFilter() {
  var s0 = test_utils.newSlice(1, 3);
  assertFalse(new TimelineTitleFilter('').matchSlice(s0));

  assertTrue(new TimelineTitleFilter('a').matchSlice(s0));
  assertFalse(new TimelineTitleFilter('x').matchSlice(s0));

  var s1 = test_utils.newSliceNamed('ba', 1, 3);
  assertTrue(new TimelineTitleFilter('a').matchSlice(s1));
  assertTrue(new TimelineTitleFilter('ba').matchSlice(s1));
  assertFalse(new TimelineTitleFilter('x').matchSlice(s1));
}

function testTimelineModel_toJSON() {
  var m = createModelWithOneOfEverything();
  assertNotNull(JSON.stringify(m));
}

function testTimelineModel_findAllThreadsNamed() {
  var m = new TimelineModel();
  var t = m.getOrCreateProcess(1).getOrCreateThread(1);
  t.name = 'CrBrowserMain';

  m.updateBounds();
  var f = m.findAllThreadsNamed('CrBrowserMain');
  assertArrayEquals([t], f);
  f = m.findAllThreadsNamed('NoSuchThread');
  assertEquals(0, f.length);
}

function testTimelineModel_updateCategories() {
  var m = new TimelineModel();
  var t = m.getOrCreateProcess(1).getOrCreateThread(1);
  t.pushSlice(new TimelineThreadSlice('categoryA', 'a', 0, 1, {}, 3));
  t.pushSlice(new TimelineThreadSlice('categoryA', 'a', 0, 1, {}, 3));
  t.pushSlice(new TimelineThreadSlice('categoryB', 'a', 0, 1, {}, 3));
  t.pushSlice(new TimelineThreadSlice('categoryA', 'a', 0, 1, {}, 3));
  t.pushSlice(new TimelineThreadSlice('', 'a', 0, 1, {}, 3));
  m.updateCategories_();
  assertArrayEquals(['categoryA', 'categoryB'], m.categories);
}
</script>
</body>
</html>
