cleanup(tooling): move tooling to the browser platform and rename profile into instrumentation
BREAKING CHANGE Before import * as p from 'angular2/profile'; import * as t from 'angular2/tools'; After import * as p from 'angular2/instrumentation'; import * as t from 'angular2/platform/browser';
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'package:angular2/testing_internal.dart' show SpyObject;
|
||||
import 'package:angular2/core.dart' show Injector, bind;
|
||||
import 'package:angular2/src/core/application_ref.dart' show ApplicationRef;
|
||||
import 'package:angular2/src/core/linker/dynamic_component_loader.dart'
|
||||
show ComponentRef_;
|
||||
import 'dart:js';
|
||||
|
||||
@proxy
|
||||
class SpyApplicationRef extends SpyObject implements ApplicationRef {
|
||||
tick() {}
|
||||
noSuchMethod(m) => super.noSuchMethod(m);
|
||||
}
|
||||
|
||||
@proxy
|
||||
class SpyComponentRef extends SpyObject implements ComponentRef_ {
|
||||
Injector injector;
|
||||
|
||||
SpyComponentRef() {
|
||||
this.injector =
|
||||
Injector.resolveAndCreate([bind(ApplicationRef).toClass(SpyApplicationRef)]);
|
||||
}
|
||||
|
||||
noSuchMethod(m) => super.noSuchMethod(m);
|
||||
}
|
||||
|
||||
void callNgProfilerTimeChangeDetection([config]) {
|
||||
context['ng']['profiler']
|
||||
.callMethod('timeChangeDetection', config != null ? [config] : []);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import {SpyObject} from 'angular2/testing_internal';
|
||||
import {Injector, provide} from 'angular2/core';
|
||||
import {ComponentRef} from 'angular2/src/core/linker/dynamic_component_loader';
|
||||
import {global} from 'angular2/src/facade/lang';
|
||||
import {ApplicationRef, ApplicationRef_} from 'angular2/src/core/application_ref';
|
||||
|
||||
export class SpyApplicationRef extends SpyObject {
|
||||
constructor() { super(ApplicationRef_); }
|
||||
}
|
||||
|
||||
export class SpyComponentRef extends SpyObject {
|
||||
injector;
|
||||
constructor() {
|
||||
super();
|
||||
this.injector =
|
||||
Injector.resolveAndCreate([provide(ApplicationRef, {useClass: SpyApplicationRef})]);
|
||||
}
|
||||
}
|
||||
|
||||
export function callNgProfilerTimeChangeDetection(config?): void {
|
||||
(<any>global).ng.profiler.timeChangeDetection(config);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
afterEach,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {enableDebugTools, disableDebugTools} from 'angular2/platform/browser';
|
||||
import {SpyComponentRef, callNgProfilerTimeChangeDetection} from './spies';
|
||||
|
||||
export function main() {
|
||||
describe('profiler', () => {
|
||||
beforeEach(() => { enableDebugTools((<any>new SpyComponentRef())); });
|
||||
|
||||
afterEach(() => { disableDebugTools(); });
|
||||
|
||||
it('should time change detection', () => { callNgProfilerTimeChangeDetection(); });
|
||||
|
||||
it('should time change detection with recording',
|
||||
() => { callNgProfilerTimeChangeDetection({'record': true}); });
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user