| 
									
										
										
										
											2016-08-30 09:29:39 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. 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 {openBrowser, verifyNoBrowserErrors} from 'e2e_util/e2e_util'; | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  | import {$, browser} from 'protractor'; | 
					
						
							| 
									
										
										
										
											2016-08-30 09:29:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  | import {Benchmark, Benchmarks, CreateBtn, DestroyBtn, DetectChangesBtn, NumberOfChecksEl, RootEl} from './tree_data'; | 
					
						
							| 
									
										
										
										
											2016-08-30 09:29:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  | describe('tree benchmark spec', () => { | 
					
						
							| 
									
										
										
										
											2016-09-01 10:29:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |   let _oldRootEl: any; | 
					
						
							|  |  |  |   beforeEach(() => _oldRootEl = browser.rootEl); | 
					
						
							| 
									
										
										
										
											2016-08-30 09:29:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |   afterEach(() => { | 
					
						
							|  |  |  |     browser.rootEl = _oldRootEl; | 
					
						
							|  |  |  |     verifyNoBrowserErrors(); | 
					
						
							| 
									
										
										
										
											2016-09-01 10:31:11 -07:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-09-01 10:31:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |   Benchmarks.forEach(benchmark => { | 
					
						
							|  |  |  |     describe(benchmark.id, () => { | 
					
						
							|  |  |  |       it('should work for createDestroy', () => { | 
					
						
							|  |  |  |         openTreeBenchmark(benchmark); | 
					
						
							|  |  |  |         $(CreateBtn).click(); | 
					
						
							|  |  |  |         expect($(RootEl).getText()).toContain('0'); | 
					
						
							|  |  |  |         $(DestroyBtn).click(); | 
					
						
							|  |  |  |         expect($(RootEl).getText()).toEqual(''); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2016-09-01 10:31:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |       it('should work for update', () => { | 
					
						
							|  |  |  |         openTreeBenchmark(benchmark); | 
					
						
							|  |  |  |         $(CreateBtn).click(); | 
					
						
							|  |  |  |         $(CreateBtn).click(); | 
					
						
							|  |  |  |         expect($(RootEl).getText()).toContain('A'); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2016-08-30 09:29:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |       if (benchmark.buttons.indexOf(DetectChangesBtn) !== -1) { | 
					
						
							|  |  |  |         it('should work for detectChanges', () => { | 
					
						
							|  |  |  |           openTreeBenchmark(benchmark); | 
					
						
							|  |  |  |           $(DetectChangesBtn).click(); | 
					
						
							|  |  |  |           expect($(NumberOfChecksEl).getText()).toContain('10'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-08-30 13:44:52 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |   function openTreeBenchmark(benchmark: Benchmark) { | 
					
						
							| 
									
										
										
										
											2016-09-30 09:09:31 -07:00
										 |  |  |     let params = [{name: 'depth', value: 4}]; | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |     if (benchmark.extraParams) { | 
					
						
							|  |  |  |       params = params.concat(benchmark.extraParams); | 
					
						
							| 
									
										
										
										
											2016-09-30 09:09:31 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |     browser.rootEl = RootEl; | 
					
						
							| 
									
										
										
										
											2016-09-01 16:56:45 -07:00
										 |  |  |     openBrowser({ | 
					
						
							| 
									
										
										
										
											2017-04-13 15:00:59 -07:00
										 |  |  |       url: benchmark.url, | 
					
						
							|  |  |  |       ignoreBrowserSynchronization: benchmark.ignoreBrowserSynchronization, | 
					
						
							| 
									
										
										
										
											2016-09-30 09:09:31 -07:00
										 |  |  |       params: params, | 
					
						
							| 
									
										
										
										
											2016-09-01 16:56:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2016-08-30 14:17:37 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-08-30 09:29:39 -07:00
										 |  |  | }); |