Skip to content

Commit bde69b6

Browse files
committed
fixup! test(button-harness): add performance tests for buttons using the protractor harness env
1 parent 988c16e commit bde69b6

File tree

2 files changed

+85
-11
lines changed

2 files changed

+85
-11
lines changed

test/benchmarks/material/button-harness/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {MatButtonModule} from '@angular/material/button';
2121
styleUrls: ['//src/material/core/theming/prebuilt/indigo-pink.css'],
2222
})
2323
export class ButtonHarnessTest {
24-
vals = Array.from({ length: 100 }, (_, i) => i);
24+
vals = Array.from({ length: 25 }, (_, i) => i);
2525
}
2626

2727
@NgModule({

test/benchmarks/material/button-harness/protractor.perf-spec.ts

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,70 @@ import {HarnessLoader} from '@angular/cdk/testing';
1010
import {MatButtonHarness} from '@angular/material/button/testing/button-harness';
1111
import {runBenchmark} from '@angular/dev-infra-private/benchmark/driver-utilities';
1212
import {ProtractorHarnessEnvironment} from '@angular/cdk/testing/protractor';
13+
import {$$, element, by} from 'protractor';
14+
15+
describe('performance baseline for the protractor harness', () => {
16+
it('should retrieve all of the buttons', async () => {
17+
await runBenchmark({
18+
id: 'get-all-buttons',
19+
url: '',
20+
ignoreBrowserSynchronization: true,
21+
params: [],
22+
work: async () => $$('.mat-button'),
23+
});
24+
});
25+
26+
it('should click the first button', async () => {
27+
await runBenchmark({
28+
id: 'click-first-button',
29+
url: '',
30+
ignoreBrowserSynchronization: true,
31+
params: [],
32+
setup: () => { loader = ProtractorHarnessEnvironment.loader(); },
33+
work: async () => await element(by.buttonText('0')).click(),
34+
});
35+
});
36+
37+
it('should click the middle button', async () => {
38+
await runBenchmark({
39+
id: 'click-middle-button',
40+
url: '',
41+
ignoreBrowserSynchronization: true,
42+
params: [],
43+
setup: () => { loader = ProtractorHarnessEnvironment.loader(); },
44+
work: async () => await element(by.buttonText('12')).click(),
45+
});
46+
});
47+
48+
it('should click the last button', async () => {
49+
await runBenchmark({
50+
id: 'click-last-button',
51+
url: '',
52+
ignoreBrowserSynchronization: true,
53+
params: [],
54+
setup: () => { loader = ProtractorHarnessEnvironment.loader(); },
55+
work: async () => await element(by.buttonText('24')).click(),
56+
});
57+
});
58+
59+
it('should click all of the buttons', async () => {
60+
await runBenchmark({
61+
id: 'click-every-button',
62+
url: '',
63+
ignoreBrowserSynchronization: true,
64+
params: [],
65+
setup: () => { loader = ProtractorHarnessEnvironment.loader(); },
66+
work: async () => {
67+
const buttons = $$('.mat-button');
68+
await buttons.each(async (button) => await button!.click());
69+
}
70+
});
71+
});
72+
});
1373

1474
let loader: HarnessLoader;
1575

16-
describe('perf test for basic protractor harness', () => {
76+
describe('performance overhead of the protractor harness', () => {
1777
it('should load the protractor harness environment', async () => {
1878
await runBenchmark({
1979
id: 'initial-harness-load',
@@ -26,7 +86,7 @@ describe('perf test for basic protractor harness', () => {
2686

2787
it('should retrieve all of the buttons', async () => {
2888
await runBenchmark({
29-
id: 'get-first-button',
89+
id: 'get-all-buttons',
3090
url: '',
3191
ignoreBrowserSynchronization: true,
3292
params: [],
@@ -35,9 +95,9 @@ describe('perf test for basic protractor harness', () => {
3595
});
3696
});
3797

38-
it('should retrieve the first button', async () => {
98+
it('should click the first button', async () => {
3999
await runBenchmark({
40-
id: 'get-first-button',
100+
id: 'click-first-button',
41101
url: '',
42102
ignoreBrowserSynchronization: true,
43103
params: [],
@@ -46,25 +106,39 @@ describe('perf test for basic protractor harness', () => {
46106
});
47107
});
48108

49-
it('should retrieve the middle button', async () => {
109+
it('should click the middle button', async () => {
110+
await runBenchmark({
111+
id: 'click-middle-button',
112+
url: '',
113+
ignoreBrowserSynchronization: true,
114+
params: [],
115+
setup: () => { loader = ProtractorHarnessEnvironment.loader(); },
116+
work: async () => await (await loader.getHarness(MatButtonHarness.with({text: '12'}))).click(),
117+
});
118+
});
119+
120+
it('should click the last button', async () => {
50121
await runBenchmark({
51-
id: 'get-middle-button',
122+
id: 'click-last-button',
52123
url: '',
53124
ignoreBrowserSynchronization: true,
54125
params: [],
55126
setup: () => { loader = ProtractorHarnessEnvironment.loader(); },
56-
work: async () => await (await loader.getHarness(MatButtonHarness.with({text: '49'}))).click(),
127+
work: async () => await (await loader.getHarness(MatButtonHarness.with({text: '24'}))).click(),
57128
});
58129
});
59130

60-
it('should retrieve the last button', async () => {
131+
it('should click all of the buttons', async () => {
61132
await runBenchmark({
62-
id: 'get-last-button',
133+
id: 'click-every-button',
63134
url: '',
64135
ignoreBrowserSynchronization: true,
65136
params: [],
66137
setup: () => { loader = ProtractorHarnessEnvironment.loader(); },
67-
work: async () => await (await loader.getHarness(MatButtonHarness.with({text: '99'}))).click(),
138+
work: async () => {
139+
const buttons = await loader.getAllHarnesses(MatButtonHarness);
140+
buttons.forEach(async (button) => await button.click());
141+
}
68142
});
69143
});
70144
});

0 commit comments

Comments
 (0)