2016-08-30 12:29:39 -04: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
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {openBrowser, verifyNoBrowserErrors} from 'e2e_util/e2e_util';
|
2017-04-13 18:00:59 -04:00
|
|
|
import {$, browser} from 'protractor';
|
2016-08-30 12:29:39 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
import {Benchmark, Benchmarks, CreateBtn, DestroyBtn, DetectChangesBtn, NumberOfChecksEl, RootEl} from './tree_data';
|
2016-08-30 12:29:39 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
describe('tree benchmark spec', () => {
|
2016-09-01 13:29:35 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
let _oldRootEl: any;
|
|
|
|
beforeEach(() => _oldRootEl = browser.rootEl);
|
2016-08-30 12:29:39 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
afterEach(() => {
|
|
|
|
browser.rootEl = _oldRootEl;
|
|
|
|
verifyNoBrowserErrors();
|
2016-09-01 13:31:11 -04:00
|
|
|
});
|
2016-09-01 13:31:31 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
Benchmarks.forEach(benchmark => {
|
|
|
|
describe(benchmark.id, () => {
|
|
|
|
it('should work for createDestroy', () => {
|
|
|
|
openTreeBenchmark(benchmark);
|
|
|
|
$(CreateBtn).click();
|
|
|
|
expect($(RootEl).getText()).toContain('0');
|
|
|
|
$(DestroyBtn).click();
|
|
|
|
expect($(RootEl).getText()).toEqual('');
|
|
|
|
});
|
2016-09-01 13:31:31 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
it('should work for update', () => {
|
|
|
|
openTreeBenchmark(benchmark);
|
|
|
|
$(CreateBtn).click();
|
|
|
|
$(CreateBtn).click();
|
|
|
|
expect($(RootEl).getText()).toContain('A');
|
|
|
|
});
|
2016-08-30 12:29:39 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
if (benchmark.buttons.indexOf(DetectChangesBtn) !== -1) {
|
|
|
|
it('should work for detectChanges', () => {
|
|
|
|
openTreeBenchmark(benchmark);
|
|
|
|
$(DetectChangesBtn).click();
|
|
|
|
expect($(NumberOfChecksEl).getText()).toContain('10');
|
|
|
|
});
|
|
|
|
}
|
2016-08-30 16:44:52 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
function openTreeBenchmark(benchmark: Benchmark) {
|
2016-09-30 12:09:31 -04:00
|
|
|
let params = [{name: 'depth', value: 4}];
|
2017-04-13 18:00:59 -04:00
|
|
|
if (benchmark.extraParams) {
|
|
|
|
params = params.concat(benchmark.extraParams);
|
2016-09-30 12:09:31 -04:00
|
|
|
}
|
2017-04-13 18:00:59 -04:00
|
|
|
browser.rootEl = RootEl;
|
2016-09-01 19:56:45 -04:00
|
|
|
openBrowser({
|
2017-04-13 18:00:59 -04:00
|
|
|
url: benchmark.url,
|
|
|
|
ignoreBrowserSynchronization: benchmark.ignoreBrowserSynchronization,
|
2016-09-30 12:09:31 -04:00
|
|
|
params: params,
|
2016-09-01 19:56:45 -04:00
|
|
|
});
|
2016-08-30 17:17:37 -04:00
|
|
|
}
|
2016-08-30 12:29:39 -04:00
|
|
|
});
|