1<!DOCTYPE html> 2<!-- 3Copyright (c) 2015 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/core/test_utils.html"> 9<link rel="import" href="/tracing/model/user_model/user_expectation.html"> 10 11<script> 12'use strict'; 13 14/** 15 * @fileoverview Stub version of UserExpectation for testing. 16 */ 17tr.exportTo('tr.model.um', function() { 18 function StubExpectation(args) { 19 this.stageTitle_ = args.stageTitle || 'Idle'; 20 this.initiatorTitle_ = args.initiatorTitle || ''; 21 22 this.title_ = args.title; 23 if (!this.title_) { 24 var defaultTitle = []; 25 if (this.initiatorTitle_) 26 defaultTitle.push(this.initiatorTitle_); 27 if (this.stageTitle_) 28 defaultTitle.push(this.stageTitle_); 29 this.title_ = defaultTitle.join(' ') || 'title'; 30 } 31 32 this.normalizedUserComfort_ = args.normalizedUserComfort || 0; 33 this.normalizedEfficiency_ = args.normalizedEfficiency || 0; 34 35 var sd = tr.c.TestUtils.getStartAndDurationFromDict(args); 36 37 tr.model.um.UserExpectation.call( 38 this, args.parentModel, this.initiatorTitle, sd.start, sd.duration); 39 40 // Must be set after base class call. 41 this.colorId_ = args.colorId || 0; 42 43 if (args.associatedEvents) { 44 args.associatedEvents.forEach(function(event) { 45 this.associatedEvents.push(event); 46 }, this); 47 } 48 } 49 50 StubExpectation.prototype = { 51 __proto__: tr.model.um.UserExpectation.prototype, 52 53 get colorId() { 54 return this.colorId_; 55 }, 56 57 get title() { 58 return this.title_; 59 }, 60 61 get stageTitle() { 62 return this.stageTitle_; 63 }, 64 65 get initiatorTitle() { 66 return this.initiatorTitle_; 67 } 68 }; 69 70 return { 71 StubExpectation: StubExpectation 72 }; 73}); 74</script> 75