refactor(animations): move MockAnimationPlayer back into core (#9966)
Closes #9966
This commit is contained in:
64
modules/@angular/core/testing/mock_animation_player.ts
Normal file
64
modules/@angular/core/testing/mock_animation_player.ts
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
import {AnimationPlayer} from '../src/animation/animation_player';
|
||||
import {isPresent} from '../src/facade/lang';
|
||||
|
||||
export class MockAnimationPlayer implements AnimationPlayer {
|
||||
private _subscriptions: any[] /** TODO #9100 */ = [];
|
||||
private _finished = false;
|
||||
private _destroyed = false;
|
||||
private _started: boolean = false;
|
||||
|
||||
public parentPlayer: AnimationPlayer = null;
|
||||
|
||||
public log: any[] /** TODO #9100 */ = [];
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(): void { this.log.push('init'); }
|
||||
|
||||
onDone(fn: Function): void { this._subscriptions.push(fn); }
|
||||
|
||||
hasStarted() { return this._started; }
|
||||
|
||||
play(): void {
|
||||
this._started = true;
|
||||
this.log.push('play');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
setPosition(p: any /** TODO #9100 */): void {}
|
||||
getPosition(): number { return 0; }
|
||||
}
|
@ -13,10 +13,11 @@ import {Math, global, isFunction, isPromise} from '../src/facade/lang';
|
||||
import {AsyncTestCompleter} from './async_test_completer';
|
||||
import {getTestInjector, inject} from './test_injector';
|
||||
|
||||
export {MockAnimationPlayer} from '@angular/platform-browser/testing/mock_animation_player';
|
||||
export {AsyncTestCompleter} from './async_test_completer';
|
||||
export {MockAnimationPlayer} from './mock_animation_player';
|
||||
export {inject} from './test_injector';
|
||||
export {expect} from './testing';
|
||||
|
||||
export * from './logger';
|
||||
export * from './ng_zone_mock';
|
||||
export * from './mock_application_ref';
|
||||
|
Reference in New Issue
Block a user