2016-06-23 16:47:54 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
2020-05-19 19:08:49 +00:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2016-06-23 16:47:54 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
2021-05-23 20:16:02 +00:00
|
|
|
import {ApplicationRef, Injector, ɵglobal as global} from '@angular/core';
|
2023-03-26 19:27:49 +00:00
|
|
|
import {ComponentRef} from '@angular/core/src/render3';
|
2016-06-08 23:38:52 +00:00
|
|
|
import {disableDebugTools, enableDebugTools} from '@angular/platform-browser';
|
2015-09-04 21:44:24 +00:00
|
|
|
|
2023-03-12 22:44:50 +00:00
|
|
|
import {AngularProfiler} from '../../../src/browser/tools/common_tools';
|
|
|
|
|
|
2023-10-17 09:45:16 +00:00
|
|
|
describe('profiler', () => {
|
|
|
|
|
if (isNode) {
|
|
|
|
|
// Jasmine will throw if there are no tests.
|
|
|
|
|
it('should pass', () => {});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
enableDebugTools({
|
|
|
|
|
injector: Injector.create({
|
|
|
|
|
providers: [{
|
|
|
|
|
provide: ApplicationRef,
|
|
|
|
|
useValue: jasmine.createSpyObj(
|
|
|
|
|
'ApplicationRef', ['bootstrap', 'tick', 'attachView', 'detachView']),
|
|
|
|
|
deps: []
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
} as ComponentRef<any>);
|
2015-09-04 21:44:24 +00:00
|
|
|
});
|
2023-10-17 09:45:16 +00:00
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
disableDebugTools();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should time change detection', () => {
|
|
|
|
|
callNgProfilerTimeChangeDetection();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should time change detection with recording', () => {
|
|
|
|
|
callNgProfilerTimeChangeDetection({'record': true});
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-05-23 20:16:02 +00:00
|
|
|
|
2023-03-12 22:44:50 +00:00
|
|
|
export function callNgProfilerTimeChangeDetection(config?: {record: true}): void {
|
|
|
|
|
(global.ng.profiler as AngularProfiler).timeChangeDetection(config);
|
2021-05-23 20:16:02 +00:00
|
|
|
}
|