|
| 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('checkbox performance benchmarks', () => { |
| 13 | + beforeAll(() => { |
| 14 | + browser.rootEl = '#root'; |
| 15 | + }); |
| 16 | + |
| 17 | + it('renders a checked checkbox', async() => { |
| 18 | + await runBenchmark({ |
| 19 | + id: 'checkbox-render-checked', |
| 20 | + url: '', |
| 21 | + ignoreBrowserSynchronization: true, |
| 22 | + params: [], |
| 23 | + setup: async () => { |
| 24 | + await $('#show').click(); |
| 25 | + await $('mat-checkbox').click(); |
| 26 | + }, |
| 27 | + prepare: async () => { |
| 28 | + expect(await $('mat-checkbox input').isSelected()) |
| 29 | + .toBe(true, 'The checkbox should be in a selected state.'); |
| 30 | + await $('#hide').click(); |
| 31 | + }, |
| 32 | + work: async () => await $('#show').click() |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + it('renders an unchecked checkbox', async() => { |
| 37 | + await runBenchmark({ |
| 38 | + id: 'checkbox-render-unchecked', |
| 39 | + url: '', |
| 40 | + ignoreBrowserSynchronization: true, |
| 41 | + params: [], |
| 42 | + setup: async() => await $('#show').click(), |
| 43 | + prepare: async () => { |
| 44 | + expect(await $('mat-checkbox input').isSelected()) |
| 45 | + .toBe(false, 'The checkbox should be in an unselected state.'); |
| 46 | + await $('#hide').click(); |
| 47 | + }, |
| 48 | + work: async () => await $('#show').click() |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + it('renders an indeterminate checkbox', async() => { |
| 53 | + await runBenchmark({ |
| 54 | + id: 'checkbox-render-indeterminate', |
| 55 | + url: '', |
| 56 | + ignoreBrowserSynchronization: true, |
| 57 | + params: [], |
| 58 | + setup: async() => { |
| 59 | + await $('#show').click(); |
| 60 | + await $('#indeterminate').click(); |
| 61 | + }, |
| 62 | + prepare: async () => { |
| 63 | + expect(await $('mat-checkbox input').getAttribute('indeterminate')) |
| 64 | + .toBe('true', 'The checkbox should be in an indeterminate state'); |
| 65 | + await $('#hide').click(); |
| 66 | + }, |
| 67 | + work: async () => await $('#show').click() |
| 68 | + }); |
| 69 | + }); |
| 70 | + |
| 71 | + it('updates from unchecked to checked', async() => { |
| 72 | + await runBenchmark({ |
| 73 | + id: 'checkbox-click-unchecked-to-checked', |
| 74 | + url: '', |
| 75 | + ignoreBrowserSynchronization: true, |
| 76 | + params: [], |
| 77 | + setup: async () => { |
| 78 | + await $('#show').click(); |
| 79 | + await $('mat-checkbox').click(); |
| 80 | + }, |
| 81 | + prepare: async () => { |
| 82 | + await $('mat-checkbox').click(); |
| 83 | + expect(await $('mat-checkbox input').isSelected()) |
| 84 | + .toBe(false, 'The checkbox should be in an unchecked state.'); |
| 85 | + }, |
| 86 | + work: async () => await $('mat-checkbox').click(), |
| 87 | + }); |
| 88 | + }); |
| 89 | + |
| 90 | + it('updates from checked to unchecked', async() => { |
| 91 | + await runBenchmark({ |
| 92 | + id: 'checkbox-click-checked-to-unchecked', |
| 93 | + url: '', |
| 94 | + ignoreBrowserSynchronization: true, |
| 95 | + params: [], |
| 96 | + setup: async () => await $('#show').click(), |
| 97 | + prepare: async () => { |
| 98 | + await $('mat-checkbox').click(); |
| 99 | + expect(await $('mat-checkbox input').isSelected()) |
| 100 | + .toBe(true, 'The checkbox should be in a checked state.'); |
| 101 | + }, |
| 102 | + work: async () => await $('mat-checkbox').click(), |
| 103 | + }); |
| 104 | + }); |
| 105 | +}); |
0 commit comments