[Timer] Updated Timer UI to indicate playing or paused state

Removed PauseCheck & TimeOfPause from properties, Removed duplicate functionality Resume class , replaced peeking restart at 0 button with persistent play/pause button
This commit is contained in:
DJ
2017-01-18 07:08:54 -06:00
parent d04bdd2685
commit ecf1bac5c7
15 changed files with 201 additions and 330 deletions

View File

@ -30,7 +30,6 @@ define([
"./src/actions/RestartTimerAction", "./src/actions/RestartTimerAction",
"./src/actions/StopTimerAction", "./src/actions/StopTimerAction",
"./src/actions/PauseTimerAction", "./src/actions/PauseTimerAction",
"./src/actions/ResumeTimerAction",
"text!./res/templates/clock.html", "text!./res/templates/clock.html",
"text!./res/templates/timer.html", "text!./res/templates/timer.html",
'legacyRegistry' 'legacyRegistry'
@ -44,7 +43,6 @@ define([
RestartTimerAction, RestartTimerAction,
StopTimerAction, StopTimerAction,
PauseTimerAction, PauseTimerAction,
ResumeTimerAction,
clockTemplate, clockTemplate,
timerTemplate, timerTemplate,
legacyRegistry legacyRegistry
@ -145,17 +143,6 @@ define([
"cssclass": "icon-play", "cssclass": "icon-play",
"priority": "preferred" "priority": "preferred"
}, },
{
"key": "timer.restart",
"implementation": RestartTimerAction,
"depends": [
"now"
],
"category": "contextual",
"name": "Restart at 0",
"cssclass": "icon-refresh",
"priority": "preferred"
},
{ {
"key": "timer.pause", "key": "timer.pause",
"implementation": PauseTimerAction, "implementation": PauseTimerAction,
@ -168,14 +155,14 @@ define([
"priority": "preferred" "priority": "preferred"
}, },
{ {
"key": "timer.resume", "key": "timer.restart",
"implementation": ResumeTimerAction, "implementation": RestartTimerAction,
"depends": [ "depends": [
"now" "now"
], ],
"category": "contextual", "category": "contextual",
"name": "Resume", "name": "Restart at 0",
"cssclass": "icon-play", "cssclass": "icon-refresh",
"priority": "preferred" "priority": "preferred"
}, },
{ {
@ -277,16 +264,6 @@ define([
"name": "hh:mm:ss" "name": "hh:mm:ss"
} }
] ]
},
{
"key": "paused",
"control": "boolean",
"name": "PauseCheck"
},
{
"key": "pausedTime",
"control": "long",
"name": "TimeOfPause"
} }
], ],
"model": { "model": {

View File

@ -23,7 +23,7 @@
<div class="l-elem-wrapper l-flex-row"> <div class="l-elem-wrapper l-flex-row">
<a ng-click="timer.clickButton()" <a ng-click="timer.clickButton()"
title="{{timer.buttonText()}}" title="{{timer.buttonText()}}"
class="flex-elem control s-icon-button {{timer.buttonCssClass()}}"></a> class="flex-elem s-icon-button {{timer.buttonCssClass()}}"></a>
<span class="flex-elem l-value {{timer.signClass()}}"> <span class="flex-elem l-value {{timer.signClass()}}">
<span class="value" <span class="value"
ng-class="{ active:timer.text() }">{{timer.text() || "--:--:--"}} ng-class="{ active:timer.text() }">{{timer.text() || "--:--:--"}}

View File

@ -50,15 +50,26 @@ define(
now = this.now; now = this.now;
function setTimestamp(model) { function setTimestamp(model) {
//if we are resuming
if (model.pausedTime) {
var timeShift = now() - model.pausedTime;
model.timestamp = model.timestamp + timeShift;
} else {
model.timestamp = now(); model.timestamp = now();
} }
}
function setPaused(model) { function setTimerState(model) {
model.paused = false; model.timerState = 'play';
}
function setPausedTime(model) {
model.pausedTime = undefined;
} }
return domainObject.useCapability('mutation', setTimestamp) && return domainObject.useCapability('mutation', setTimestamp) &&
domainObject.useCapability('mutation', setPaused); domainObject.useCapability('mutation', setTimerState) &&
domainObject.useCapability('mutation', setPausedTime);
}; };
return AbstractTimerAction; return AbstractTimerAction;

View File

@ -25,10 +25,10 @@ define(
function (AbstractTimerAction) { function (AbstractTimerAction) {
/** /**
* Implements the "Start" action for timers. * Implements the "Pause" action for timers.
* *
* Sets the reference timestamp in a timer to the current * Sets the reference pausedTime in a timer to the current
* time, such that it begins counting up. * time, such that it stops counting up.
* *
* @extends {platform/features/clock.AbstractTimerAction} * @extends {platform/features/clock.AbstractTimerAction}
* @implements {Action} * @implements {Action}
@ -51,25 +51,26 @@ define(
{}; {};
// We show this variant for timers which do not yet have // We show this variant for timers which have
// a target time. // a target time, or is in a playing state.
return model.type === 'timer' && return model.type === 'timer' &&
model.timestamp !== undefined && !model.paused; (model.timestamp !== undefined ||
model.timerState === 'play');
}; };
PauseTimerAction.prototype.perform = function () { PauseTimerAction.prototype.perform = function () {
var domainObject = this.domainObject, var domainObject = this.domainObject,
now = this.now; now = this.now;
function setPaused(model) { function setTimerState(model) {
model.paused = true; model.timerState = 'pause';
} }
function setPausedTime(model) { function setPausedTime(model) {
model.pausedTime = now(); model.pausedTime = now();
} }
return domainObject.useCapability('mutation', setPaused) && return domainObject.useCapability('mutation', setTimerState) &&
domainObject.useCapability('mutation', setPausedTime); domainObject.useCapability('mutation', setPausedTime);
}; };

View File

@ -53,7 +53,8 @@ define(
// We show this variant for timers which already have // We show this variant for timers which already have
// a target time. // a target time.
return model.type === 'timer' && return model.type === 'timer' &&
model.timestamp !== undefined; (model.timestamp !== undefined ||
model.timerState !== undefined);
}; };
return RestartTimerAction; return RestartTimerAction;

View File

@ -1,85 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2009-2016, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(
['./AbstractTimerAction'],
function (AbstractTimerAction) {
/**
* Implements the "Start" action for timers.
*
* Sets the reference timestamp in a timer to the current
* time, such that it begins counting up.
*
* @extends {platform/features/clock.AbstractTimerAction}
* @implements {Action}
* @memberof platform/features/clock
* @constructor
* @param {Function} now a function which returns the current
* time (typically wrapping `Date.now`)
* @param {ActionContext} context the context for this action
*/
function ResumeTimerAction(now, context) {
AbstractTimerAction.apply(this, [now, context]);
}
ResumeTimerAction.prototype =
Object.create(AbstractTimerAction.prototype);
ResumeTimerAction.appliesTo = function (context) {
var model =
(context.domainObject && context.domainObject.getModel()) ||
{};
// We show this variant for timers which do not yet have
// a target time.
return model.type === 'timer' &&
model.timestamp !== undefined &&
model.paused;
};
ResumeTimerAction.prototype.perform = function () {
var domainObject = this.domainObject,
now = this.now;
function setPaused(model) {
model.paused = false;
}
function setTimestamp(model) {
var timeShift = now() - model.pausedTime;
model.timestamp = model.timestamp + timeShift;
}
function setPausedTime(model) {
model.pausedTime = undefined;
}
return domainObject.useCapability('mutation', setPaused) &&
domainObject.useCapability('mutation', setTimestamp) &&
domainObject.useCapability('mutation', setPausedTime);
};
return ResumeTimerAction;
}
);

View File

@ -53,7 +53,8 @@ define(
// We show this variant for timers which do not yet have // We show this variant for timers which do not yet have
// a target time. // a target time.
return model.type === 'timer' && return model.type === 'timer' &&
model.timestamp === undefined; (model.timestamp === undefined ||
model.timerState !== 'play');
}; };
return StartTimerAction; return StartTimerAction;

View File

@ -25,10 +25,10 @@ define(
function (AbstractTimerAction) { function (AbstractTimerAction) {
/** /**
* Implements the "Start" action for timers. * Implements the "Stop" action for timers.
* *
* Sets the reference timestamp in a timer to the current * Sets the reference timestamp in a timer undefined,
* time, such that it begins counting up. * such that it is reset and makes no movements.
* *
* @extends {platform/features/clock.AbstractTimerAction} * @extends {platform/features/clock.AbstractTimerAction}
* @implements {Action} * @implements {Action}
@ -54,7 +54,8 @@ define(
// We show this variant for timers which do not yet have // We show this variant for timers which do not yet have
// a target time. // a target time.
return model.type === 'timer' && return model.type === 'timer' &&
model.timestamp !== undefined; (model.timestamp !== undefined ||
model.timerState !== undefined);
}; };
StopTimerAction.prototype.perform = function () { StopTimerAction.prototype.perform = function () {
@ -64,12 +65,17 @@ define(
model.timestamp = undefined; model.timestamp = undefined;
} }
function setPaused(model) { function setTimerState(model) {
model.paused = false; model.timerState = undefined;
}
function setPausedTime(model) {
model.pausedTime = undefined;
} }
return domainObject.useCapability('mutation', setTimestamp) && return domainObject.useCapability('mutation', setTimestamp) &&
domainObject.useCapability('mutation', setPaused); domainObject.useCapability('mutation', setTimerState) &&
domainObject.useCapability('mutation', setPausedTime);
}; };
return StopTimerAction; return StopTimerAction;

View File

@ -42,6 +42,7 @@ define(
active = true, active = true,
relativeTimestamp, relativeTimestamp,
lastTimestamp, lastTimestamp,
relativeTimerState,
self = this; self = this;
function update() { function update() {
@ -68,24 +69,34 @@ define(
relativeTimestamp = timestamp; relativeTimestamp = timestamp;
} }
function updateTimerState(timerState) {
relativeTimerState = timerState;
}
function isPaused() {
return relativeTimerState === 'pause';
}
function updateObject(domainObject) { function updateObject(domainObject) {
var model = domainObject.getModel(), var model = domainObject.getModel(),
timestamp = model.timestamp, timestamp = model.timestamp,
formatKey = model.timerFormat, formatKey = model.timerFormat,
timerState = model.timerState,
actionCapability = domainObject.getCapability('action'), actionCapability = domainObject.getCapability('action'),
actionKey = (timestamp === undefined) ? actionKey = (timerState !== 'play') ?
'timer.start' : 'timer.restart'; 'timer.start' : 'timer.pause';
self.paused = model.paused; self.timerState = model.timerState;
self.pausedTime = model.pausedTime; self.pausedTime = model.pausedTime;
//if paused on startup show last known position
if (self.paused && !lastTimestamp){
lastTimestamp = self.pausedTime;
}
updateFormat(formatKey); updateFormat(formatKey);
updateTimestamp(timestamp); updateTimestamp(timestamp);
updateTimerState(timerState);
//if paused on startup show last known position
if (isPaused() && !lastTimestamp) {
lastTimestamp = self.pausedTime;
}
self.relevantAction = actionCapability && self.relevantAction = actionCapability &&
actionCapability.getActions(actionKey)[0]; actionCapability.getActions(actionKey)[0];
@ -107,7 +118,7 @@ define(
var lastSign = self.signValue, var lastSign = self.signValue,
lastText = self.textValue; lastText = self.textValue;
if (!self.paused) { if (!isPaused()) {
lastTimestamp = now(); lastTimestamp = now();
update(); update();
} }
@ -141,7 +152,7 @@ define(
/** /**
* Get the CSS class to display the right icon * Get the CSS class to display the right icon
* for the start/restart button. * for the start/pause button.
* @returns {string} cssclass to display * @returns {string} cssclass to display
*/ */
TimerController.prototype.buttonCssClass = function () { TimerController.prototype.buttonCssClass = function () {
@ -150,7 +161,7 @@ define(
}; };
/** /**
* Get the text to show for the start/restart button * Get the text to show for the start/pause button
* (e.g. in a tooltip) * (e.g. in a tooltip)
* @returns {string} name of the action * @returns {string} name of the action
*/ */
@ -161,7 +172,7 @@ define(
/** /**
* Perform the action associated with the start/restart button. * Perform the action associated with the start/pause button.
*/ */
TimerController.prototype.clickButton = function () { TimerController.prototype.clickButton = function () {
if (this.relevantAction) { if (this.relevantAction) {

View File

@ -57,7 +57,7 @@ define(
}); });
testModel = {}; testModel = {};
testContext = { domainObject: mockDomainObject }; testContext = {domainObject: mockDomainObject};
action = new PauseTimerAction(mockNow, testContext); action = new PauseTimerAction(mockNow, testContext);
}); });
@ -68,36 +68,36 @@ define(
expect(testModel.timestamp).toEqual(12000); expect(testModel.timestamp).toEqual(12000);
}); });
it("applies only to timers without a target time", function () { it("applies only to timers in a playing state", function () {
//Timer is on //in a stopped state
testModel.type = 'timer'; testStates(testModel, 'timer', undefined, undefined, false);
testModel.timestamp = 12000;
testModel.paused = true; //in a paused state
expect(PauseTimerAction.appliesTo(testContext)).toBeFalsy(); testStates(testModel, 'timer', 'pause', undefined, false);
testModel.paused = false; //in a playing state
expect(PauseTimerAction.appliesTo(testContext)).toBeTruthy(); testStates(testModel, 'timer', 'play', undefined, true);
//Timer has not started //not a timer
testModel.timestamp = undefined; testStates(testModel, 'clock', 'pause', undefined, false);
testModel.paused = true;
expect(PauseTimerAction.appliesTo(testContext)).toBeFalsy();
testModel.paused = false;
expect(PauseTimerAction.appliesTo(testContext)).toBeFalsy();
//Timer is actually a clock
testModel.type = 'clock';
testModel.timestamp = 12000;
testModel.paused = true;
expect(PauseTimerAction.appliesTo(testContext)).toBeFalsy();
testModel.paused = false;
expect(PauseTimerAction.appliesTo(testContext)).toBeFalsy();
}); });
function testStates(testModel, type, timerState, timestamp, expected) {
testModel.type = type;
testModel.timerState = timerState;
testModel.timestamp = timestamp;
if (expected) {
expect(PauseTimerAction.appliesTo(testContext)).toBeTruthy()
} else {
expect(PauseTimerAction.appliesTo(testContext)).toBeFalsy()
}
//first test without time, this test with time
if (timestamp === undefined) {
testStates(testModel, type, timerState, 12000, expected);
}
}
}); });
} }
); );

View File

@ -68,19 +68,36 @@ define(
expect(testModel.timestamp).toEqual(12000); expect(testModel.timestamp).toEqual(12000);
}); });
it("applies only to timers with a target time", function () { it("applies only to timers in a non-stopped state", function () {
testModel.type = 'timer'; //in a stopped state
testModel.timestamp = 12000; testStates(testModel, 'timer', undefined, undefined, false);
expect(RestartTimerAction.appliesTo(testContext)).toBeTruthy();
testModel.type = 'timer'; //in a paused state
testModel.timestamp = undefined; testStates(testModel, 'timer', 'pause', undefined, true);
expect(RestartTimerAction.appliesTo(testContext)).toBeFalsy();
testModel.type = 'clock'; //in a playing state
testModel.timestamp = 12000; testStates(testModel, 'timer', 'play', undefined, true);
expect(RestartTimerAction.appliesTo(testContext)).toBeFalsy();
//not a timer
testStates(testModel, 'clock', 'pause', undefined, false);
}); });
function testStates(testModel, type, timerState, timestamp, expected) {
testModel.type = type;
testModel.timerState = timerState;
testModel.timestamp = timestamp;
if (expected) {
expect(RestartTimerAction.appliesTo(testContext)).toBeTruthy()
} else {
expect(RestartTimerAction.appliesTo(testContext)).toBeFalsy()
}
//first test without time, this test with time
if (timestamp === undefined) {
testStates(testModel, type, timerState, 12000, expected);
}
}
}); });
} }
); );

View File

@ -1,103 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2009-2016, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(
["../../src/actions/ResumeTimerAction"],
function (ResumeTimerAction) {
describe("A timer's Resume action", function () {
var mockNow,
mockDomainObject,
testModel,
testContext,
action;
function asPromise(value) {
return (value || {}).then ? value : {
then: function (callback) {
return asPromise(callback(value));
}
};
}
beforeEach(function () {
mockNow = jasmine.createSpy('now');
mockDomainObject = jasmine.createSpyObj(
'domainObject',
['getCapability', 'useCapability', 'getModel']
);
mockDomainObject.useCapability.andCallFake(function (c, v) {
if (c === 'mutation') {
testModel = v(testModel) || testModel;
return asPromise(true);
}
});
mockDomainObject.getModel.andCallFake(function () {
return testModel;
});
testModel = {};
testContext = { domainObject: mockDomainObject };
action = new ResumeTimerAction(mockNow, testContext);
});
it("updates the model with a timestamp", function () {
mockNow.andReturn(12000);
action.perform();
expect(testModel.timestamp).toEqual(12000);
});
it("applies only to timers without a target time", function () {
//Timer is on
testModel.type = 'timer';
testModel.timestamp = 12000;
testModel.paused = true;
expect(ResumeTimerAction.appliesTo(testContext)).toBeTruthy();
testModel.paused = false;
expect(ResumeTimerAction.appliesTo(testContext)).toBeFalsy();
//Timer has not started
testModel.timestamp = undefined;
testModel.paused = true;
expect(ResumeTimerAction.appliesTo(testContext)).toBeFalsy();
testModel.paused = false;
expect(ResumeTimerAction.appliesTo(testContext)).toBeFalsy();
//Timer is actually a clock
testModel.type = 'clock';
testModel.timestamp = 12000;
testModel.paused = true;
expect(ResumeTimerAction.appliesTo(testContext)).toBeFalsy();
testModel.paused = false;
expect(ResumeTimerAction.appliesTo(testContext)).toBeFalsy();
});
});
}
);

View File

@ -57,7 +57,7 @@ define(
}); });
testModel = {}; testModel = {};
testContext = { domainObject: mockDomainObject }; testContext = {domainObject: mockDomainObject};
action = new StartTimerAction(mockNow, testContext); action = new StartTimerAction(mockNow, testContext);
}); });
@ -68,19 +68,36 @@ define(
expect(testModel.timestamp).toEqual(12000); expect(testModel.timestamp).toEqual(12000);
}); });
it("applies only to timers without a target time", function () { it("applies only to timers not in a playing state", function () {
testModel.type = 'timer'; //in a stopped state
testModel.timestamp = 12000; testStates(testModel, 'timer', undefined, undefined, true);
expect(StartTimerAction.appliesTo(testContext)).toBeFalsy();
testModel.type = 'timer'; //in a paused state
testModel.timestamp = undefined; testStates(testModel, 'timer', 'pause', undefined, true);
expect(StartTimerAction.appliesTo(testContext)).toBeTruthy();
testModel.type = 'clock'; //in a playing state
testModel.timestamp = 12000; testStates(testModel, 'timer', 'play', undefined, false);
expect(StartTimerAction.appliesTo(testContext)).toBeFalsy();
//not a timer
testStates(testModel, 'clock', 'pause', undefined, false);
}); });
function testStates(testModel, type, timerState, timestamp, expected) {
testModel.type = type;
testModel.timerState = timerState;
testModel.timestamp = timestamp;
if (expected) {
expect(StartTimerAction.appliesTo(testContext)).toBeTruthy()
} else {
expect(StartTimerAction.appliesTo(testContext)).toBeFalsy()
}
//first test without time, this test with time
if (timestamp === undefined) {
testStates(testModel, type, timerState, 12000, expected);
}
}
}); });
} }
); );

View File

@ -57,7 +57,7 @@ define(
}); });
testModel = {}; testModel = {};
testContext = { domainObject: mockDomainObject }; testContext = {domainObject: mockDomainObject};
action = new StopTimerAction(mockNow, testContext); action = new StopTimerAction(mockNow, testContext);
}); });
@ -68,19 +68,36 @@ define(
expect(testModel.timestamp).toEqual(12000); expect(testModel.timestamp).toEqual(12000);
}); });
it("applies only to timers without a target time", function () { it("applies only to timers in a non-stopped state", function () {
testModel.type = 'timer'; //in a stopped state
testModel.timestamp = 12000; testStates(testModel, 'timer', undefined, undefined, false);
expect(StopTimerAction.appliesTo(testContext)).toBeTruthy();
testModel.type = 'timer'; //in a paused state
testModel.timestamp = undefined; testStates(testModel, 'timer', 'pause', undefined, true);
expect(StopTimerAction.appliesTo(testContext)).toBeFalsy();
testModel.type = 'clock'; //in a playing state
testModel.timestamp = 12000; testStates(testModel, 'timer', 'play', undefined, true);
expect(StopTimerAction.appliesTo(testContext)).toBeFalsy();
//not a timer
testStates(testModel, 'clock', 'pause', undefined, false);
}); });
function testStates(testModel, type, timerState, timestamp, expected) {
testModel.type = type;
testModel.timerState = timerState;
testModel.timestamp = timestamp;
if (expected) {
expect(StopTimerAction.appliesTo(testContext)).toBeTruthy()
} else {
expect(StopTimerAction.appliesTo(testContext)).toBeFalsy()
}
//first test without time, this test with time
if (timestamp === undefined) {
testStates(testModel, type, timerState, 12000, expected);
}
}
}); });
} }
); );

View File

@ -34,7 +34,7 @@ define(
mockDomainObject, mockDomainObject,
mockActionCapability, mockActionCapability,
mockStart, mockStart,
mockRestart, mockPause,
testModel, testModel,
controller; controller;
@ -67,8 +67,8 @@ define(
'start', 'start',
['getMetadata', 'perform'] ['getMetadata', 'perform']
); );
mockRestart = jasmine.createSpyObj( mockPause = jasmine.createSpyObj(
'restart', 'pause',
['getMetadata', 'perform'] ['getMetadata', 'perform']
); );
mockNow = jasmine.createSpy('now'); mockNow = jasmine.createSpy('now');
@ -82,11 +82,11 @@ define(
mockActionCapability.getActions.andCallFake(function (k) { mockActionCapability.getActions.andCallFake(function (k) {
return [{ return [{
'timer.start': mockStart, 'timer.start': mockStart,
'timer.restart': mockRestart 'timer.pause': mockPause
}[k]]; }[k]];
}); });
mockStart.getMetadata.andReturn({ cssclass: "icon-play", name: "Start" }); mockStart.getMetadata.andReturn({cssclass: "icon-play", name: "Start"});
mockRestart.getMetadata.andReturn({ cssclass: "icon-refresh", name: "Restart" }); mockPause.getMetadata.andReturn({cssclass: "icon-pause", name: "Pause"});
mockScope.domainObject = mockDomainObject; mockScope.domainObject = mockDomainObject;
testModel = {}; testModel = {};
@ -144,18 +144,18 @@ define(
expect(controller.text()).toEqual("0D 00:00:00"); expect(controller.text()).toEqual("0D 00:00:00");
}); });
it("shows cssclass & name for the applicable start/restart action", function () { it("shows cssclass & name for the applicable start/pause action", function () {
invokeWatch('domainObject', mockDomainObject); invokeWatch('domainObject', mockDomainObject);
expect(controller.buttonCssClass()).toEqual("icon-play"); expect(controller.buttonCssClass()).toEqual("icon-play");
expect(controller.buttonText()).toEqual("Start"); expect(controller.buttonText()).toEqual("Start");
testModel.timestamp = 12321; testModel.timestamp = 12321;
invokeWatch('model.modified', 1); invokeWatch('model.modified', 1);
expect(controller.buttonCssClass()).toEqual("icon-refresh"); expect(controller.buttonCssClass()).toEqual("icon-pause");
expect(controller.buttonText()).toEqual("Restart"); expect(controller.buttonText()).toEqual("Pause");
}); });
it("performs correct start/restart action on click", function () { it("performs correct start/pause action on click", function () {
invokeWatch('domainObject', mockDomainObject); invokeWatch('domainObject', mockDomainObject);
expect(mockStart.perform).not.toHaveBeenCalled(); expect(mockStart.perform).not.toHaveBeenCalled();
controller.clickButton(); controller.clickButton();
@ -163,9 +163,9 @@ define(
testModel.timestamp = 12321; testModel.timestamp = 12321;
invokeWatch('model.modified', 1); invokeWatch('model.modified', 1);
expect(mockRestart.perform).not.toHaveBeenCalled(); expect(mockPause.perform).not.toHaveBeenCalled();
controller.clickButton(); controller.clickButton();
expect(mockRestart.perform).toHaveBeenCalled(); expect(mockPause.perform).toHaveBeenCalled();
}); });
it("stops requesting animation frames when destroyed", function () { it("stops requesting animation frames when destroyed", function () {