2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-07-01 16:01:57 -07:00
|
|
|
import {AnimationPlayer} from '../../core/src/animation/animation_player';
|
|
|
|
import {isPresent} from '../../core/src/facade/lang';
|
2016-05-25 12:46:22 -07:00
|
|
|
|
|
|
|
export class MockAnimationPlayer implements AnimationPlayer {
|
2016-06-08 15:45:15 -07:00
|
|
|
private _subscriptions: any[] /** TODO #9100 */ = [];
|
2016-05-25 12:46:22 -07:00
|
|
|
private _finished = false;
|
|
|
|
private _destroyed = false;
|
2016-07-01 16:01:57 -07:00
|
|
|
private _started: boolean = false;
|
|
|
|
|
2016-05-25 12:46:22 -07:00
|
|
|
public parentPlayer: AnimationPlayer = null;
|
|
|
|
|
2016-06-08 15:45:15 -07:00
|
|
|
public log: any[] /** TODO #9100 */ = [];
|
2016-05-25 12:46:22 -07:00
|
|
|
|
|
|
|
private _onfinish(): void {
|
|
|
|
if (!this._finished) {
|
|
|
|
this._finished = true;
|
|
|
|
this.log.push('finish');
|
|
|
|
|
|
|
|
this._subscriptions.forEach((entry) => { entry(); });
|
|
|
|
this._subscriptions = [];
|
|
|
|
if (!isPresent(this.parentPlayer)) {
|
|
|
|
this.destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-01 16:01:57 -07:00
|
|
|
init(): void { this.log.push('init'); }
|
|
|
|
|
2016-05-25 12:46:22 -07:00
|
|
|
onDone(fn: Function): void { this._subscriptions.push(fn); }
|
|
|
|
|
2016-07-01 16:01:57 -07:00
|
|
|
hasStarted() { return this._started; }
|
|
|
|
|
|
|
|
play(): void {
|
|
|
|
this._started = true;
|
|
|
|
this.log.push('play');
|
|
|
|
}
|
2016-05-25 12:46:22 -07:00
|
|
|
|
|
|
|
pause(): void { this.log.push('pause'); }
|
|
|
|
|
|
|
|
restart(): void { this.log.push('restart'); }
|
|
|
|
|
|
|
|
finish(): void { this._onfinish(); }
|
|
|
|
|
|
|
|
reset(): void { this.log.push('reset'); }
|
|
|
|
|
|
|
|
destroy(): void {
|
|
|
|
if (!this._destroyed) {
|
|
|
|
this._destroyed = true;
|
|
|
|
this.finish();
|
|
|
|
this.log.push('destroy');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-08 15:45:15 -07:00
|
|
|
setPosition(p: any /** TODO #9100 */): void {}
|
2016-05-25 12:46:22 -07:00
|
|
|
getPosition(): number { return 0; }
|
|
|
|
}
|