File tree 3 files changed +103
-0
lines changed
test/benchmarks/mdc/slide-toggle
3 files changed +103
-0
lines changed Original file line number Diff line number Diff line change
1
+ load ("@npm_angular_dev_infra_private//benchmark/component_benchmark:component_benchmark.bzl" , "component_benchmark" )
2
+
3
+ # TODO(wagnermaciel): Update this target to provide indigo-pink in a way that doesn't require having to import it with
4
+ # stylesUrls inside the components once `component_benchmark` supports asset injection.
5
+
6
+ component_benchmark (
7
+ name = "benchmark" ,
8
+ driver = ":slide-toggle.perf-spec.ts" ,
9
+ driver_deps = [
10
+ "@npm//@angular/dev-infra-private" ,
11
+ "@npm//protractor" ,
12
+ "@npm//@types/jasmine" ,
13
+ ],
14
+ ng_deps = [
15
+ "@npm//@angular/core" ,
16
+ "@npm//@angular/platform-browser" ,
17
+ "//src/material-experimental/mdc-slide-toggle" ,
18
+ ],
19
+ ng_srcs = [":app.module.ts" ],
20
+ prefix = "" ,
21
+ styles = ["//src/material-experimental/mdc-theming:indigo_pink_prebuilt" ],
22
+ )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+
9
+ import { Component , NgModule , ViewEncapsulation } from '@angular/core' ;
10
+ import { BrowserModule } from '@angular/platform-browser' ;
11
+ import { MatSlideToggleModule } from '@angular/material-experimental/mdc-slide-toggle' ;
12
+
13
+ /** component: mdc-slide-toggle */
14
+
15
+ @Component ( {
16
+ selector : 'app-root' ,
17
+ template : `
18
+ <button id="show" (click)="show()">Show</button>
19
+ <button id="hide" (click)="hide()">Hide</button>
20
+
21
+ <ng-container *ngIf="isVisible">
22
+ <mat-slide-toggle>Slide me!</mat-slide-toggle>
23
+ </ng-container>
24
+ ` ,
25
+ encapsulation : ViewEncapsulation . None ,
26
+ styleUrls : [ '//src/material-experimental/mdc-theming/prebuilt/indigo-pink.css' ] ,
27
+ } )
28
+ export class SlideToggleBenchmarkApp {
29
+ isVisible = false ;
30
+ show ( ) { this . isVisible = true ; }
31
+ hide ( ) { this . isVisible = false ; }
32
+ }
33
+
34
+
35
+ @NgModule ( {
36
+ declarations : [ SlideToggleBenchmarkApp ] ,
37
+ imports : [
38
+ BrowserModule ,
39
+ MatSlideToggleModule ,
40
+ ] ,
41
+ bootstrap : [ SlideToggleBenchmarkApp ]
42
+ } )
43
+ export class AppModule { }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+
9
+ import { $ , browser } from 'protractor' ;
10
+ import { runBenchmark } from '@angular/dev-infra-private/benchmark/driver-utilities' ;
11
+
12
+ describe ( 'slide toggle performance benchmarks' , ( ) => {
13
+ beforeAll ( ( ) => {
14
+ browser . rootEl = '#root' ;
15
+ } ) ;
16
+
17
+ it ( 'renders a slide toggle' , async ( ) => {
18
+ await runBenchmark ( {
19
+ id : 'slide-toggle-render' ,
20
+ url : '' ,
21
+ ignoreBrowserSynchronization : true ,
22
+ params : [ ] ,
23
+ prepare : async ( ) => await $ ( '#hide' ) . click ( ) ,
24
+ work : async ( ) => await $ ( '#show' ) . click ( ) ,
25
+ } ) ;
26
+ } ) ;
27
+
28
+ it ( 'clicks a slide toggle' , async ( ) => {
29
+ await runBenchmark ( {
30
+ id : 'slide-toggle-click' ,
31
+ url : '' ,
32
+ ignoreBrowserSynchronization : true ,
33
+ params : [ ] ,
34
+ setup : async ( ) => await $ ( '#show' ) . click ( ) ,
35
+ work : async ( ) => await $ ( '.mat-mdc-slide-toggle label' ) . click ( ) ,
36
+ } ) ;
37
+ } ) ;
38
+ } ) ;
You can’t perform that action at this time.
0 commit comments