-
Notifications
You must be signed in to change notification settings - Fork 6.8k
test(mdc-checkbox): add performance tests for mdc-checkbox #20129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrewseguin
merged 7 commits into
angular:master
from
wagnermaciel:mdc-checkbox-benchmark
Aug 13, 2020
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aa62750
fix(mdc-indigo-pink): add mat-core and mat-core-theme to indigo-pink
wagnermaciel cc4e1a2
fixup! fix(mdc-indigo-pink): add mat-core and mat-core-theme to indig…
wagnermaciel 149c6ac
test(mdc-checkbox): add performance tests for mdc-checkbox
wagnermaciel 955ec50
fix(benchmarks): remove unnecessary providers
wagnermaciel a096b45
fixup! test(mdc-checkbox): add performance tests for mdc-checkbox
wagnermaciel ae2c8a6
fixup! test(mdc-checkbox): add performance tests for mdc-checkbox
wagnermaciel 1828916
fixup! test(mdc-checkbox): add performance tests for mdc-checkbox
wagnermaciel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
load("@npm_angular_dev_infra_private//benchmark/component_benchmark:component_benchmark.bzl", "component_benchmark") | ||
|
||
# TODO(wagnermaciel): Update this target to provide indigo-pink in a way that doesn't require having to import it with | ||
# stylesUrls inside the components once `component_benchmark` supports asset injection. | ||
|
||
component_benchmark( | ||
name = "benchmark", | ||
driver = ":checkbox.perf-spec.ts", | ||
driver_deps = [ | ||
"@npm//@angular/dev-infra-private", | ||
"@npm//protractor", | ||
"@npm//@types/jasmine", | ||
], | ||
ng_deps = [ | ||
"@npm//@angular/core", | ||
"@npm//@angular/platform-browser", | ||
"//src/material-experimental/mdc-checkbox", | ||
], | ||
ng_srcs = [":app.module.ts"], | ||
prefix = "", | ||
styles = ["//src/material-experimental/mdc-theming:indigo_pink_prebuilt"], | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC 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 {Component, NgModule, ViewEncapsulation} from '@angular/core'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
import {MatCheckboxModule} from '@angular/material-experimental/mdc-checkbox'; | ||
|
||
/** component: mdc-checkbox */ | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
template: ` | ||
<button id="show" (click)="show()">Show</button> | ||
<button id="hide" (click)="hide()">Hide</button> | ||
<button id="indeterminate" (click)="indeterminate()">Indeterminate</button> | ||
|
||
<mat-checkbox *ngIf="isVisible" | ||
[checked]="isChecked" | ||
[indeterminate]="isIndeterminate" | ||
(change)="toggleIsChecked()"> | ||
Check me!</mat-checkbox> | ||
`, | ||
encapsulation: ViewEncapsulation.None, | ||
styleUrls: ['//src/material-experimental/mdc-theming/prebuilt/indigo-pink.css'], | ||
}) | ||
export class CheckboxBenchmarkApp { | ||
|
||
// isChecked is used to maintain the buttons checked state even after it has been hidden. This is | ||
// used, for example, when we want to test the render speed of a checked vs unchecked checkbox. | ||
|
||
isChecked = false; | ||
isVisible = false; | ||
isIndeterminate = false; | ||
|
||
show() { this.isVisible = true; } | ||
hide() { this.isVisible = false; } | ||
indeterminate() { this.isIndeterminate = true; } | ||
toggleIsChecked() { this.isChecked = !this.isChecked; } | ||
} | ||
|
||
@NgModule({ | ||
declarations: [CheckboxBenchmarkApp], | ||
imports: [ | ||
BrowserModule, | ||
MatCheckboxModule, | ||
], | ||
bootstrap: [CheckboxBenchmarkApp], | ||
}) | ||
export class AppModule {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC 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 {$, browser} from 'protractor'; | ||
import {runBenchmark} from '@angular/dev-infra-private/benchmark/driver-utilities'; | ||
|
||
describe('checkbox performance benchmarks', () => { | ||
beforeAll(() => { | ||
browser.rootEl = '#root'; | ||
}); | ||
|
||
it('renders a checked checkbox', async() => { | ||
await runBenchmark({ | ||
id: 'checkbox-render-checked', | ||
url: '', | ||
ignoreBrowserSynchronization: true, | ||
params: [], | ||
setup: async () => { | ||
await $('#show').click(); | ||
await $('mat-checkbox').click(); | ||
}, | ||
prepare: async () => { | ||
expect(await $('mat-checkbox input').isSelected()) | ||
.toBe(true, 'The checkbox should be in a selected state.'); | ||
await $('#hide').click(); | ||
}, | ||
work: async () => await $('#show').click() | ||
}); | ||
}); | ||
|
||
it('renders an unchecked checkbox', async() => { | ||
await runBenchmark({ | ||
id: 'checkbox-render-unchecked', | ||
url: '', | ||
ignoreBrowserSynchronization: true, | ||
params: [], | ||
setup: async() => await $('#show').click(), | ||
prepare: async () => { | ||
expect(await $('mat-checkbox input').isSelected()) | ||
.toBe(false, 'The checkbox should be in an unselected state.'); | ||
await $('#hide').click(); | ||
}, | ||
work: async () => await $('#show').click() | ||
}); | ||
}); | ||
|
||
it('renders an indeterminate checkbox', async() => { | ||
await runBenchmark({ | ||
id: 'checkbox-render-indeterminate', | ||
url: '', | ||
ignoreBrowserSynchronization: true, | ||
params: [], | ||
setup: async() => { | ||
await $('#show').click(); | ||
await $('#indeterminate').click(); | ||
}, | ||
prepare: async () => { | ||
expect(await $('mat-checkbox input').getAttribute('indeterminate')) | ||
.toBe('true', 'The checkbox should be in an indeterminate state'); | ||
await $('#hide').click(); | ||
}, | ||
work: async () => await $('#show').click() | ||
}); | ||
}); | ||
|
||
it('updates from unchecked to checked', async() => { | ||
await runBenchmark({ | ||
id: 'checkbox-click-unchecked-to-checked', | ||
url: '', | ||
ignoreBrowserSynchronization: true, | ||
params: [], | ||
setup: async () => { | ||
await $('#show').click(); | ||
await $('mat-checkbox').click(); | ||
}, | ||
prepare: async () => { | ||
await $('mat-checkbox').click(); | ||
devversion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect(await $('mat-checkbox input').isSelected()) | ||
.toBe(false, 'The checkbox should be in an unchecked state.'); | ||
}, | ||
work: async () => await $('mat-checkbox').click(), | ||
}); | ||
}); | ||
|
||
it('updates from checked to unchecked', async() => { | ||
await runBenchmark({ | ||
id: 'checkbox-click-checked-to-unchecked', | ||
url: '', | ||
ignoreBrowserSynchronization: true, | ||
params: [], | ||
setup: async () => await $('#show').click(), | ||
prepare: async () => { | ||
await $('mat-checkbox').click(); | ||
expect(await $('mat-checkbox input').isSelected()) | ||
.toBe(true, 'The checkbox should be in a checked state.'); | ||
}, | ||
work: async () => await $('mat-checkbox').click(), | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.