blob: 611e24b70df557cd2537bdc1ddbee28750c4a378 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2013 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.
-->
<link rel="import" href="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/extras/rail/stub_rail_interaction_record.html">
<link rel="import" href="/tracing/model/model.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
var test_utils = tr.c.TestUtils;
var CompoundEventSelectionState = tr.model.CompoundEventSelectionState;
function createModel(opt_customizeModelCallback) {
return test_utils.newModel(function(model) {
model.p1 = model.getOrCreateProcess(1);
model.t2 = model.p1.getOrCreateThread(2);
model.s1 = model.t2.sliceGroup.pushSlice(test_utils.newSliceEx({
title: 'a', start: 10, end: 20
}));
model.s2 = model.t2.sliceGroup.pushSlice(test_utils.newSliceEx({
title: 'b', start: 20, end: 30
}));
model.ir1 = new tr.e.rail.StubRAILInteractionRecord({
parentModel: model,
start: 100, end: 200,
railTypeName: 'rail_response',
normalizedEfficiency: 1.,
normalizedUserComfort: 0.0
});
model.addInteractionRecord(model.ir1);
model.ir1.associatedEvents.push(model.s1);
model.ir1.associatedEvents.push(model.s2);
if (opt_customizeModelCallback)
opt_customizeModelCallback(model);
});
}
test('notSelected', function() {
var model = createModel();
var sel = new tr.model.EventSet();
assert.equal(CompoundEventSelectionState.NOT_SELECTED,
model.ir1.computeCompoundEvenSelectionState(sel));
});
test('directSelected', function() {
var model = createModel();
var sel = new tr.model.EventSet();
sel.push(model.ir1);
assert.equal(CompoundEventSelectionState.EVENT_SELECTED,
model.ir1.computeCompoundEvenSelectionState(sel));
});
test('directAndSomeAssociatedSelected', function() {
var model = createModel();
var sel = new tr.model.EventSet();
sel.push(model.ir1);
sel.push(model.s1);
assert.equal(
CompoundEventSelectionState.EVENT_AND_SOME_ASSOCIATED_SELECTED,
model.ir1.computeCompoundEvenSelectionState(sel));
});
test('allAssociatedEventsSelected', function() {
var model = createModel();
var sel = new tr.model.EventSet();
sel.push(model.s1);
sel.push(model.s2);
assert.equal(CompoundEventSelectionState.ALL_ASSOCIATED_EVENTS_SELECTED,
model.ir1.computeCompoundEvenSelectionState(sel));
});
test('directAndAllAssociated', function() {
var model = createModel();
var sel = new tr.model.EventSet();
sel.push(model.ir1);
sel.push(model.s1);
sel.push(model.s2);
assert.equal(CompoundEventSelectionState.EVENT_AND_ALL_ASSOCIATED_SELECTED,
model.ir1.computeCompoundEvenSelectionState(sel));
});
test('stableId', function() {
var model = test_utils.newModel();
var ir1 = model.addInteractionRecord(
test_utils.newInteractionRecord(model, 0, 10));
var ir2 = model.addInteractionRecord(
test_utils.newInteractionRecord(model, 10, 10));
var ir3 = model.addInteractionRecord(
test_utils.newInteractionRecord(model, 20, 10));
assert.equal('IR.0', ir1.stableId);
assert.equal('IR.1', ir2.stableId);
assert.equal('IR.2', ir3.stableId);
});
});
</script>