Commit 52ff5026 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

DevTools: migrate coverage tests to the new tests framework

Change-Id: I561218917c5491c4326eec34897d15af124add70
Reviewed-on: https://chromium-review.googlesource.com/780762Reviewed-by: default avatarWill Chen <chenwilliam@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518393}
parent e9bd34c6
...@@ -798,8 +798,8 @@ crbug.com/778391 http/tests/devtools/elements/styles-3/styles-disable-inherited. ...@@ -798,8 +798,8 @@ crbug.com/778391 http/tests/devtools/elements/styles-3/styles-disable-inherited.
crbug.com/778391 virtual/mojo-loading/http/tests/devtools/elements/styles-3/styles-add-new-rule.js [ Pass Failure ] crbug.com/778391 virtual/mojo-loading/http/tests/devtools/elements/styles-3/styles-add-new-rule.js [ Pass Failure ]
crbug.com/778391 virtual/mojo-loading/http/tests/devtools/elements/styles-3/styles-disable-inherited.js [ Pass Failure ] crbug.com/778391 virtual/mojo-loading/http/tests/devtools/elements/styles-3/styles-disable-inherited.js [ Pass Failure ]
crbug.com/773353 [ Mac ] http/tests/devtools/coverage/coverage-view.html [ Pass Failure ] crbug.com/773353 [ Mac ] http/tests/devtools/coverage/coverage-view.js [ Pass Failure ]
crbug.com/773353 [ Mac ] virtual/mojo-loading/http/tests/devtools/coverage/coverage-view.html [ Pass Failure ] crbug.com/773353 [ Mac ] virtual/mojo-loading/http/tests/devtools/coverage/coverage-view.js [ Pass Failure ]
crbug.com/767269 [ Win ] inspector-protocol/layout-fonts/cjk-ideograph-fallback-by-lang.js [ Pass Failure ] crbug.com/767269 [ Win ] inspector-protocol/layout-fonts/cjk-ideograph-fallback-by-lang.js [ Pass Failure ]
......
Tests the coverage list view after finishing recording in the Coverage view. Tests the coverage list view after finishing recording in the Coverage view.
Initial Initial
.../devtools/coverage/resources/coverage.js JS used: 350 unused: 218 total: 568 .../devtools/coverage/resources/coverage.js JS used: 354 unused: 214 total: 568
.../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209 .../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209
After second session After second session
.../devtools/coverage/resources/coverage.js JS used: 350 unused: 218 total: 568 .../devtools/coverage/resources/coverage.js JS used: 354 unused: 214 total: 568
.../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209 .../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209
After clear After clear
.../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209 .../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209
......
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../inspector/elements-test.js"></script>
<script src="../resources/coverage-test.js"></script> (async function() {
<script src="resources/coverage.js"></script> TestRunner.addResult(`Tests the coverage list view after finishing recording in the Coverage view.\n`);
await TestRunner.loadModule('coverage_test_runner');
await TestRunner.loadHTML(`
<p class="class">
</p>
`);
await TestRunner.addStylesheetTag('resources/highlight-in-source.css');
<link rel="stylesheet" type="text/css" href="resources/highlight-in-source.css">
<script>
async function test() {
CoverageTestRunner.startCoverage(); CoverageTestRunner.startCoverage();
await TestRunner.addScriptTag('resources/coverage.js');
await TestRunner.evaluateInPagePromise('performActions()'); await TestRunner.evaluateInPagePromise('performActions()');
await CoverageTestRunner.stopCoverage(); await CoverageTestRunner.stopCoverage();
TestRunner.addResult('Initial'); TestRunner.addResult('Initial');
...@@ -28,15 +31,4 @@ async function test() { ...@@ -28,15 +31,4 @@ async function test() {
CoverageTestRunner.dumpCoverageListView(); CoverageTestRunner.dumpCoverageListView();
TestRunner.completeTest(); TestRunner.completeTest();
} })();
</script>
</head>
<body onload="runTest()">
<p class="class">
Tests the coverage list view after finishing recording in the Coverage view.
</p>
</body>
</html>
\ No newline at end of file
Tests the coverage list view after finishing recording in the Coverage view. Tests the coverage list view after finishing recording in the Coverage view.
.../devtools/coverage/resources/coverage.js JS (coarse) used: 407 unused: 161 total: 568 .../devtools/coverage/resources/coverage.js JS (coarse) used: 411 unused: 157 total: 568
.../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209 .../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209
Reloading Page Reloading Page
Page reloaded. Page reloaded.
......
Tests the filter is properly applied to coverage list view. Tests the filter is properly applied to coverage list view.
Filter: devtools Filter: devtools
.../devtools/coverage/resources/coverage.js JS used: 350 unused: 218 total: 568 .../devtools/coverage/resources/coverage.js JS used: 354 unused: 214 total: 568
.../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209 .../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209
Filter: CES/COV Filter: CES/COV
.../devtools/coverage/resources/coverage.js JS used: 350 unused: 218 total: 568 .../devtools/coverage/resources/coverage.js JS used: 354 unused: 214 total: 568
Filter: no pasaran Filter: no pasaran
Filter: Filter:
.../devtools/coverage/resources/coverage.js JS used: 350 unused: 218 total: 568 .../devtools/coverage/resources/coverage.js JS used: 354 unused: 214 total: 568
.../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209 .../devtools/coverage/resources/highlight-in-source.css CSS used: 67 unused: 142 total: 209
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../inspector/elements-test.js"></script>
<script src="../resources/coverage-test.js"></script>
<script src="resources/coverage.js"></script>
<link rel="stylesheet" type="text/css" href="resources/highlight-in-source.css"> (async function() {
TestRunner.addResult(`Tests the filter is properly applied to coverage list view.\n`);
await TestRunner.loadModule('coverage_test_runner');
<script>
async function test() {
CoverageTestRunner.startCoverage(); CoverageTestRunner.startCoverage();
await TestRunner.navigatePromise(TestRunner.url('resources/basic-coverage.html'));
await TestRunner.evaluateInPagePromise('performActions()'); await TestRunner.evaluateInPagePromise('performActions()');
await CoverageTestRunner.stopCoverage(); await CoverageTestRunner.stopCoverage();
...@@ -29,15 +27,4 @@ async function test() { ...@@ -29,15 +27,4 @@ async function test() {
coverageView._filterInput._onChangeCallback(); coverageView._filterInput._onChangeCallback();
TestRunner.addResult(`Filter: ${text}`); TestRunner.addResult(`Filter: ${text}`);
} }
} })();
</script>
</head>
<body onload="runTest()">
<p class="class">
Tests the filter is properly applied to coverage list view.
</p>
</body>
</html>
\ No newline at end of file
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../inspector/elements-test.js"></script>
<script src="../resources/coverage-test.js"></script>
<script src="resources/coverage.js"></script>
<link rel="stylesheet" type="text/css" href="resources/highlight-in-source.css"> (async function() {
TestRunner.addResult(`Tests the coverage list view after finishing recording in the Coverage view.\n`);
await TestRunner.loadModule('coverage_test_runner');
await TestRunner.navigatePromise(TestRunner.url('resources/basic-coverage.html'));
<script>
async function test() {
await TestRunner.evaluateInPagePromise('performActions()'); await TestRunner.evaluateInPagePromise('performActions()');
CoverageTestRunner.startCoverage(); CoverageTestRunner.startCoverage();
await CoverageTestRunner.pollCoverage(); await CoverageTestRunner.pollCoverage();
CoverageTestRunner.dumpCoverageListView(); CoverageTestRunner.dumpCoverageListView();
TestRunner.addResult('Reloading Page'); TestRunner.addResult('Reloading Page');
await InspectorTest.reloadPagePromise(); await TestRunner.reloadPagePromise();
await TestRunner.evaluateInPagePromise('performActions()'); await TestRunner.evaluateInPagePromise('performActions()');
await CoverageTestRunner.stopCoverage(); await CoverageTestRunner.stopCoverage();
CoverageTestRunner.dumpCoverageListView(); CoverageTestRunner.dumpCoverageListView();
TestRunner.completeTest(); TestRunner.completeTest();
} })();
</script>
</head>
<body onload="runTest()">
<p class="class">
Tests the coverage list view after finishing recording in the Coverage view.
</p>
</body>
</html>
\ No newline at end of file
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
(async function() { (async function() {
TestRunner.addResult(`Tests the gutter decorations in target source code after ScriptFormatterEditorAction\n`); TestRunner.addResult(`Tests the gutter decorations in target source code after ScriptFormatterEditorAction\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.loadModule('coverage_test_runner'); await TestRunner.loadModule('coverage_test_runner');
await TestRunner.loadHTML(` await TestRunner.loadHTML(`
<p id="id">PASS</p> <p id="id">PASS</p>
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
(async function() { (async function() {
TestRunner.addResult(`Tests the coverage highlight in sources after the recording finishes.\n`); TestRunner.addResult(`Tests the coverage highlight in sources after the recording finishes.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.loadModule('coverage_test_runner'); await TestRunner.loadModule('coverage_test_runner');
await TestRunner.loadHTML(` await TestRunner.loadHTML(`
<p id="id">PASS</p> <p id="id">PASS</p>
......
...@@ -2,67 +2,48 @@ Tests the coverage highlight in sources after the recording finishes. ...@@ -2,67 +2,48 @@ Tests the coverage highlight in sources after the recording finishes.
0: <html> 0: <html>
1: <head> 1: <head>
2: <script src="../../inspector/inspector-test.js"></script> 2: <style>
3: <script src="../../inspector/debugger-test.js"></script> 3: .used {
4: <script src="../resources/coverage-test.js"></script> 4: color: black;
5: 5: }
6: <script> 6:
7: + function used1() { 7: .notUsed {
8: + window.a += 4; 8: color: red;
9: + } 9: }
10: 10: </style>
11: - function unused1() { 11: <style>
12: - window.a += 1; 12: #not-used {
13: - } 13: color: red;
14: </script> 14: }
15: 15:
16: <script> 16: #also-used {
17: - function unused2() { 17: color: black;
18: - window.a += 0.5; 18: }
19: - } 19: </style>
20: 20: </head>
21: + function used2() { 21: <body>
22: + window.a += 4; 22: <script>
23: + } 23: + function used1() {
24: </script> 24: + window.a += 4;
25: 25: + }
26: <style> 26:
27: + .used { 27: - function unused1() {
28: + color: black; 28: - window.a += 1;
29: + } 29: - }
30: 30:
31: - .notUsed { 31: - function unused2() {
32: - color: red; 32: - window.a += 0.5;
33: - } 33: - }
34: </style> 34:
35: 35: + function used2() {
36: <style> 36: + window.a += 4;
37: - #not-used { 37: + }
38: - color: red; 38:
39: - } 39: + function performActions() {
40: 40: + used1();
41: + #also-used { 41: + used2();
42: + color: black; 42: + }
43: + } 43: </script>
44: </style> 44: </body>
45: 45:
46: <script>
47: + function performActions() {
48: + used1();
49: + used2();
50: + }
51:
52: - async function test() {
53: - CoverageTestRunner.startCoverage();
54: - await TestRunner.evaluateInPagePromise('performActions()');
55: - await CoverageTestRunner.stopCoverage();
56: - await CoverageTestRunner.dumpDecorations('gutter-html.html');
57: - TestRunner.completeTest();
58: - }
59: </script>
60: </head>
61: <body onload="runTest()">
62: <p class="used" id="also-used">Tests the coverage highlight in sources after the recording finishes.</p>
63: </body>
64: </html>
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests the coverage highlight in sources after the recording finishes.\n`);
await TestRunner.loadModule('coverage_test_runner');
await TestRunner.navigatePromise(TestRunner.url('resources/document.html'));
CoverageTestRunner.startCoverage();
await TestRunner.evaluateInPagePromise('performActions()');
await CoverageTestRunner.stopCoverage();
await CoverageTestRunner.dumpDecorations('document.html');
TestRunner.completeTest();
})();
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
(async function() { (async function() {
TestRunner.addResult(`Tests the coverage highlight in sources after the recording finishes.\n`); TestRunner.addResult(`Tests the coverage highlight in sources after the recording finishes.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.loadModule('coverage_test_runner'); await TestRunner.loadModule('coverage_test_runner');
await TestRunner.addScriptTag('resources/coverage.js'); await TestRunner.addScriptTag('resources/coverage.js');
......
Tests the coverage list view after finishing recording in the Coverage view. Tests the coverage list view after finishing recording in the Coverage view.
.../devtools/coverage/resources/coverage.js JS used: 385 unused: 183 total: 568 .../devtools/coverage/resources/coverage.js JS used: 389 unused: 179 total: 568
.../devtools/coverage/resources/highlight-in-source.css CSS used: 90 unused: 119 total: 209 .../devtools/coverage/resources/highlight-in-source.css CSS used: 90 unused: 119 total: 209
.../devtools/coverage/resources/subframe.html JS used: 73 unused: 1 total: 74
0: + body { 0: + body {
1: + background-color: lightblue; 1: + background-color: lightblue;
2: + } 2: + }
......
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../inspector/debugger-test.js"></script>
<script src="../resources/coverage-test.js"></script>
<script src="resources/coverage.js"></script>
<link rel="stylesheet" type="text/css" href="resources/highlight-in-source.css"> (async function() {
TestRunner.addResult(`Tests the coverage list view after finishing recording in the Coverage view.\n`);
await TestRunner.loadModule('coverage_test_runner');
<script>
async function test() {
CoverageTestRunner.startCoverage(); CoverageTestRunner.startCoverage();
await TestRunner.loadHTML(`
<iframe src="resources/subframe.html"></iframe>
<p class="class">
</p>
`);
await TestRunner.addStylesheetTag('resources/highlight-in-source.css');
await TestRunner.addScriptTag('resources/coverage.js');
await TestRunner.evaluateInPagePromise('performActions(); frames[0].performActionsInFrame()'); await TestRunner.evaluateInPagePromise('performActions(); frames[0].performActionsInFrame()');
await CoverageTestRunner.stopCoverage(); await CoverageTestRunner.stopCoverage();
...@@ -18,7 +22,7 @@ async function test() { ...@@ -18,7 +22,7 @@ async function test() {
for (var child of dataGrid.rootNode().children) { for (var child of dataGrid.rootNode().children) {
var data = child._coverageInfo; var data = child._coverageInfo;
var url = TestRunner.formatters.formatAsURL(data.url()); var url = TestRunner.formatters.formatAsURL(data.url());
if (url.endsWith('-test.js') || url.endsWith('.html')) if (url.startsWith('test://'))
continue; continue;
var type = Coverage.CoverageListView._typeToString(data.type()); var type = Coverage.CoverageListView._typeToString(data.type());
TestRunner.addResult(`${url} ${type} used: ${data.usedSize()} unused: ${data.unusedSize()} total: ${data.size()}`); TestRunner.addResult(`${url} ${type} used: ${data.usedSize()} unused: ${data.unusedSize()} total: ${data.size()}`);
...@@ -28,16 +32,4 @@ async function test() { ...@@ -28,16 +32,4 @@ async function test() {
await CoverageTestRunner.dumpDecorations('coverage.js'); await CoverageTestRunner.dumpDecorations('coverage.js');
TestRunner.completeTest(); TestRunner.completeTest();
} })();
</script>
</head>
<body onload="runTest()">
<iframe src="resources/subframe.html"></iframe>
<p class="class">
Tests the coverage list view after finishing recording in the Coverage view.
</p>
</body>
</html>
\ No newline at end of file
<html>
<head>
<link rel="stylesheet" type="text/css" href="highlight-in-source.css">
</head>
<body>
<script src="coverage.js"></script>
<p class="class"></p>
</body>
</html>
<html> <html>
<head> <head>
<script src="../../inspector/inspector-test.js"></script>
<script src="../../inspector/debugger-test.js"></script>
<script src="../resources/coverage-test.js"></script>
<script>
function used1() {
window.a += 4;
}
function unused1() {
window.a += 1;
}
</script>
<script>
function unused2() {
window.a += 0.5;
}
function used2() {
window.a += 4;
}
</script>
<style> <style>
.used { .used {
color: black; color: black;
...@@ -33,7 +9,6 @@ function used2() { ...@@ -33,7 +9,6 @@ function used2() {
color: red; color: red;
} }
</style> </style>
<style> <style>
#not-used { #not-used {
color: red; color: red;
...@@ -43,23 +18,28 @@ function used2() { ...@@ -43,23 +18,28 @@ function used2() {
color: black; color: black;
} }
</style> </style>
</head>
<body>
<script> <script>
function used1() {
window.a += 4;
}
function unused1() {
window.a += 1;
}
function unused2() {
window.a += 0.5;
}
function used2() {
window.a += 4;
}
function performActions() { function performActions() {
used1(); used1();
used2(); used2();
} }
async function test() {
CoverageTestRunner.startCoverage();
await TestRunner.evaluateInPagePromise('performActions()');
await CoverageTestRunner.stopCoverage();
await CoverageTestRunner.dumpDecorations('gutter-html.html');
TestRunner.completeTest();
}
</script> </script>
</head>
<body onload="runTest()">
<p class="used" id="also-used">Tests the coverage highlight in sources after the recording finishes.</p>
</body> </body>
</html>
\ No newline at end of file
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
(async function() { (async function() {
TestRunner.addResult(`Tests the CSS highlight in sources after the Pretty print formatting.\n`); TestRunner.addResult(`Tests the CSS highlight in sources after the Pretty print formatting.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.loadModule('coverage_test_runner'); await TestRunner.loadModule('coverage_test_runner');
await TestRunner.loadHTML(` await TestRunner.loadHTML(`
<p id="id">PASS</p> <p id="id">PASS</p>
......
...@@ -13,20 +13,29 @@ CoverageTestRunner.startCoverage = function() { ...@@ -13,20 +13,29 @@ CoverageTestRunner.startCoverage = function() {
coverageView._startRecording(); coverageView._startRecording();
}; };
/**
* @return {!Promise}
*/
CoverageTestRunner.stopCoverage = function() { CoverageTestRunner.stopCoverage = function() {
var coverageView = self.runtime.sharedInstance(Coverage.CoverageView); var coverageView = self.runtime.sharedInstance(Coverage.CoverageView);
return coverageView._stopRecording(); return coverageView._stopRecording();
}; };
/**
* @return {!Promise}
*/
CoverageTestRunner.pollCoverage = function() { CoverageTestRunner.pollCoverage = function() {
var coverageView = self.runtime.sharedInstance(Coverage.CoverageView); var coverageView = self.runtime.sharedInstance(Coverage.CoverageView);
return coverageView._poll(); return coverageView._poll();
}; };
/**
* @return {!Promise<!SourceFrame.SourceFrame>}
*/
CoverageTestRunner.sourceDecorated = async function(source) { CoverageTestRunner.sourceDecorated = async function(source) {
await UI.inspectorView.showPanel('sources'); await UI.inspectorView.showPanel('sources');
var decoratePromise = TestRunner.addSnifferPromise(Coverage.CoverageView.LineDecorator.prototype, '_innerDecorate'); var decoratePromise = TestRunner.addSnifferPromise(Coverage.CoverageView.LineDecorator.prototype, '_innerDecorate');
var sourceFrame = await new Promise(fulfill => SourcesTestRunner.showScriptSource(source, fulfill)); var sourceFrame = await SourcesTestRunner.showScriptSourcePromise(source);
await decoratePromise; await decoratePromise;
return sourceFrame; return sourceFrame;
}; };
...@@ -36,6 +45,9 @@ CoverageTestRunner.dumpDecorations = async function(source) { ...@@ -36,6 +45,9 @@ CoverageTestRunner.dumpDecorations = async function(source) {
CoverageTestRunner.dumpDecorationsInSourceFrame(sourceFrame); CoverageTestRunner.dumpDecorationsInSourceFrame(sourceFrame);
}; };
/**
* @return {?DataGrid.DataGridNode}
*/
CoverageTestRunner.findCoverageNodeForURL = function(url) { CoverageTestRunner.findCoverageNodeForURL = function(url) {
var coverageListView = self.runtime.sharedInstance(Coverage.CoverageView)._listView; var coverageListView = self.runtime.sharedInstance(Coverage.CoverageView)._listView;
var rootNode = coverageListView._dataGrid.rootNode(); var rootNode = coverageListView._dataGrid.rootNode();
...@@ -80,7 +92,7 @@ CoverageTestRunner.dumpCoverageListView = function() { ...@@ -80,7 +92,7 @@ CoverageTestRunner.dumpCoverageListView = function() {
var data = child._coverageInfo; var data = child._coverageInfo;
var url = TestRunner.formatters.formatAsURL(data.url()); var url = TestRunner.formatters.formatAsURL(data.url());
if (url.endsWith('-test.js') || url.endsWith('.html')) if (url.startsWith('test://'))
continue; continue;
var type = Coverage.CoverageListView._typeToString(data.type()); var type = Coverage.CoverageListView._typeToString(data.type());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment