 62909358e7
			
		
	
	62909358e7
	
	
	
		
			
			Include an empty file - this will be filled with Polymer 2 specific code later, and it's useful to have the empty file now because the Polymer 2 change will likely be pending very long, and we would like to avoid conflicts keeping so many files in a pending change for long. Also include a harmless polyfill that we need for Polymer 2. Change-Id: I504e52ae937edff1d35b29700882b522ef4dbc64
		
			
				
	
	
		
			141 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			141 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <!--
 | |
| @license
 | |
| Copyright (C) 2019 The Android Open Source Project
 | |
| 
 | |
| Licensed under the Apache License, Version 2.0 (the "License");
 | |
| you may not use this file except in compliance with the License.
 | |
| You may obtain a copy of the License at
 | |
| 
 | |
| http://www.apache.org/licenses/LICENSE-2.0
 | |
| 
 | |
| Unless required by applicable law or agreed to in writing, software
 | |
| distributed under the License is distributed on an "AS IS" BASIS,
 | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| See the License for the specific language governing permissions and
 | |
| limitations under the License.
 | |
| -->
 | |
| 
 | |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
 | |
| <title>gr-coverage-layer</title>
 | |
| <script src="/test/common-test-setup.js"></script>
 | |
| <script src="/bower_components/webcomponentsjs/custom-elements-es5-adapter.js"></script>
 | |
| 
 | |
| <script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
 | |
| <script src="/bower_components/web-component-tester/browser.js"></script>
 | |
| <script src="../gr-diff/gr-diff-line.js"></script>
 | |
| <link rel="import" href="../../../test/common-test-setup.html"/>
 | |
| 
 | |
| <link rel="import" href="gr-coverage-layer.html">
 | |
| 
 | |
| <script>void(0);</script>
 | |
| 
 | |
| <test-fixture id="basic">
 | |
|   <template>
 | |
|     <gr-coverage-layer></gr-coverage-layer>
 | |
|   </template>
 | |
| </test-fixture>
 | |
| 
 | |
| <script>
 | |
|   suite('gr-coverage-layer', () => {
 | |
|     let element;
 | |
| 
 | |
|     setup(() => {
 | |
|       const initialCoverageRanges = [
 | |
|         {
 | |
|           type: 'COVERED',
 | |
|           side: 'right',
 | |
|           code_range: {
 | |
|             start_line: 1,
 | |
|             end_line: 2,
 | |
|           },
 | |
|         },
 | |
|         {
 | |
|           type: 'NOT_COVERED',
 | |
|           side: 'right',
 | |
|           code_range: {
 | |
|             start_line: 3,
 | |
|             end_line: 4,
 | |
|           },
 | |
|         },
 | |
|         {
 | |
|           type: 'PARTIALLY_COVERED',
 | |
|           side: 'right',
 | |
|           code_range: {
 | |
|             start_line: 5,
 | |
|             end_line: 6,
 | |
|           },
 | |
|         },
 | |
|         {
 | |
|           type: 'NOT_INSTRUMENTED',
 | |
|           side: 'right',
 | |
|           code_range: {
 | |
|             start_line: 8,
 | |
|             end_line: 9,
 | |
|           },
 | |
|         },
 | |
|       ];
 | |
| 
 | |
|       element = fixture('basic');
 | |
|       element.coverageRanges = initialCoverageRanges;
 | |
|       element.side = 'right';
 | |
|     });
 | |
| 
 | |
|     suite('annotate', () => {
 | |
|       function createLine(lineNumber) {
 | |
|         lineEl = document.createElement('div');
 | |
|         lineEl.setAttribute('data-side', 'right');
 | |
|         lineEl.setAttribute('data-value', lineNumber);
 | |
|         lineEl.className = 'right';
 | |
|         return lineEl;
 | |
|       }
 | |
| 
 | |
|       function checkLine(lineNumber, className, opt_negated) {
 | |
|         const line = createLine(lineNumber);
 | |
|         element.annotate(undefined, line, undefined);
 | |
|         let contains = line.classList.contains(className);
 | |
|         if (opt_negated) contains = !contains;
 | |
|         assert.isTrue(contains);
 | |
|       }
 | |
| 
 | |
|       test('line 1-2 are covered', () => {
 | |
|         checkLine(1, 'COVERED');
 | |
|         checkLine(2, 'COVERED');
 | |
|       });
 | |
| 
 | |
|       test('line 3-4 are not covered', () => {
 | |
|         checkLine(3, 'NOT_COVERED');
 | |
|         checkLine(4, 'NOT_COVERED');
 | |
|       });
 | |
| 
 | |
|       test('line 5-6 are partially covered', () => {
 | |
|         checkLine(5, 'PARTIALLY_COVERED');
 | |
|         checkLine(6, 'PARTIALLY_COVERED');
 | |
|       });
 | |
| 
 | |
|       test('line 7 is implicitly not instrumented', () => {
 | |
|         checkLine(7, 'COVERED', true);
 | |
|         checkLine(7, 'NOT_COVERED', true);
 | |
|         checkLine(7, 'PARTIALLY_COVERED', true);
 | |
|         checkLine(7, 'NOT_INSTRUMENTED', true);
 | |
|       });
 | |
| 
 | |
|       test('line 8-9 are not instrumented', () => {
 | |
|         checkLine(8, 'NOT_INSTRUMENTED');
 | |
|         checkLine(9, 'NOT_INSTRUMENTED');
 | |
|       });
 | |
| 
 | |
|       test('coverage correct, if annotate is called out of order', () => {
 | |
|         checkLine(8, 'NOT_INSTRUMENTED');
 | |
|         checkLine(1, 'COVERED');
 | |
|         checkLine(5, 'PARTIALLY_COVERED');
 | |
|         checkLine(3, 'NOT_COVERED');
 | |
|         checkLine(6, 'PARTIALLY_COVERED');
 | |
|         checkLine(4, 'NOT_COVERED');
 | |
|         checkLine(9, 'NOT_INSTRUMENTED');
 | |
|         checkLine(2, 'COVERED');
 | |
|       });
 | |
|     });
 | |
|   });
 | |
| </script>
 |