@@ -10,10 +10,70 @@ import {HarnessLoader} from '@angular/cdk/testing';
10
10
import { MatButtonHarness } from '@angular/material/button/testing/button-harness' ;
11
11
import { runBenchmark } from '@angular/dev-infra-private/benchmark/driver-utilities' ;
12
12
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
+ } ) ;
13
73
14
74
let loader : HarnessLoader ;
15
75
16
- describe ( 'perf test for basic protractor harness' , ( ) => {
76
+ describe ( 'performance overhead of the protractor harness' , ( ) => {
17
77
it ( 'should load the protractor harness environment' , async ( ) => {
18
78
await runBenchmark ( {
19
79
id : 'initial-harness-load' ,
@@ -26,7 +86,7 @@ describe('perf test for basic protractor harness', () => {
26
86
27
87
it ( 'should retrieve all of the buttons' , async ( ) => {
28
88
await runBenchmark ( {
29
- id : 'get-first-button ' ,
89
+ id : 'get-all-buttons ' ,
30
90
url : '' ,
31
91
ignoreBrowserSynchronization : true ,
32
92
params : [ ] ,
@@ -35,9 +95,9 @@ describe('perf test for basic protractor harness', () => {
35
95
} ) ;
36
96
} ) ;
37
97
38
- it ( 'should retrieve the first button' , async ( ) => {
98
+ it ( 'should click the first button' , async ( ) => {
39
99
await runBenchmark ( {
40
- id : 'get -first-button' ,
100
+ id : 'click -first-button' ,
41
101
url : '' ,
42
102
ignoreBrowserSynchronization : true ,
43
103
params : [ ] ,
@@ -46,25 +106,39 @@ describe('perf test for basic protractor harness', () => {
46
106
} ) ;
47
107
} ) ;
48
108
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 ( ) => {
50
121
await runBenchmark ( {
51
- id : 'get-middle -button' ,
122
+ id : 'click-last -button' ,
52
123
url : '' ,
53
124
ignoreBrowserSynchronization : true ,
54
125
params : [ ] ,
55
126
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 ( ) ,
57
128
} ) ;
58
129
} ) ;
59
130
60
- it ( 'should retrieve the last button ' , async ( ) => {
131
+ it ( 'should click all of the buttons ' , async ( ) => {
61
132
await runBenchmark ( {
62
- id : 'get-last -button' ,
133
+ id : 'click-every -button' ,
63
134
url : '' ,
64
135
ignoreBrowserSynchronization : true ,
65
136
params : [ ] ,
66
137
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
+ }
68
142
} ) ;
69
143
} ) ;
70
144
} ) ;
0 commit comments