|
| 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, ElementFinder} from 'protractor'; |
| 10 | +import {runBenchmark} from '@angular/dev-infra-private/benchmark/driver-utilities'; |
| 11 | + |
| 12 | +describe('tabs performance benchmarks', () => { |
| 13 | + beforeAll(() => { |
| 14 | + browser.rootEl = '#root'; |
| 15 | + }); |
| 16 | + |
| 17 | + it('renders three tabs', async() => { |
| 18 | + await runBenchmark({ |
| 19 | + id: 'three-tab-render', |
| 20 | + url: '', |
| 21 | + ignoreBrowserSynchronization: true, |
| 22 | + params: [], |
| 23 | + prepare: async() => await $('#hide').click(), |
| 24 | + work: async() => await $('#show-three-tabs').click(), |
| 25 | + }); |
| 26 | + }); |
| 27 | + |
| 28 | + it('renders ten tabs', async() => { |
| 29 | + await runBenchmark({ |
| 30 | + id: 'ten-tab-render', |
| 31 | + url: '', |
| 32 | + ignoreBrowserSynchronization: true, |
| 33 | + params: [], |
| 34 | + prepare: async() => await $('#hide').click(), |
| 35 | + work: async() => await $('#show-ten-tabs').click(), |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
| 39 | + it('renders twenty tabs', async() => { |
| 40 | + await runBenchmark({ |
| 41 | + id: 'twenty-tab-render', |
| 42 | + url: '', |
| 43 | + ignoreBrowserSynchronization: true, |
| 44 | + params: [], |
| 45 | + prepare: async() => await $('#hide').click(), |
| 46 | + work: async() => await $('#show-twenty-tabs').click(), |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + it('switches between tabs', async() => { |
| 51 | + await runBenchmark({ |
| 52 | + id: 'tab-switching', |
| 53 | + url: '', |
| 54 | + ignoreBrowserSynchronization: true, |
| 55 | + params: [], |
| 56 | + setup: async() => await $('#show-three-tabs').click(), |
| 57 | + prepare: async() => await $('#mat-tab-label-0-0').click(), |
| 58 | + work: async() => await $('#mat-tab-label-0-1').click(), |
| 59 | + }); |
| 60 | + }); |
| 61 | + |
| 62 | + it('paginates tabs', async() => { |
| 63 | + async function isTabPaginatorDisabled(ele: ElementFinder) { |
| 64 | + return (await ele.getAttribute('class')).includes('mat-mdc-tab-header-pagination-disabled'); |
| 65 | + } |
| 66 | + await runBenchmark({ |
| 67 | + id: 'tab-pagination', |
| 68 | + url: '', |
| 69 | + ignoreBrowserSynchronization: true, |
| 70 | + params: [], |
| 71 | + prepare: async() => { |
| 72 | + await $('#hide').click(); |
| 73 | + await $('#show-twenty-tabs').click(); |
| 74 | + }, |
| 75 | + work: async() => { |
| 76 | + const nextBtn = $('.mat-mdc-tab-header-pagination-after'); |
| 77 | + while (!isTabPaginatorDisabled(nextBtn)) { |
| 78 | + await nextBtn.click(); |
| 79 | + } |
| 80 | + } |
| 81 | + }); |
| 82 | + }); |
| 83 | +}); |
0 commit comments