Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: third_party/WebKit/LayoutTests/fast/harness/resources/results-test.js

Issue 2605103004: Add names to layout test results.html unit tests. (Closed)
Patch Set: Rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/harness/results-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/harness/resources/results-test.js
diff --git a/third_party/WebKit/LayoutTests/fast/harness/resources/results-test.js b/third_party/WebKit/LayoutTests/fast/harness/resources/results-test.js
index 2d01864075b00a34b0f7c0bf585d3ae797a06f26..14593b946ac12add8e6f3885826950e3f7f6ad42 100644
--- a/third_party/WebKit/LayoutTests/fast/harness/resources/results-test.js
+++ b/third_party/WebKit/LayoutTests/fast/harness/resources/results-test.js
@@ -60,14 +60,21 @@ function mockExpectation(expected, actual)
};
}
+function currentTestName() {
+ var testName = 'TEST ' + g_testIndex;
+ if (g_testName)
+ testName += ' (' + g_testName + ')';
+ return testName;
+}
+
function logPass(msg)
{
- g_log.push('TEST-' + g_testIndex + ': <span class="test-pass">' + msg + '</span>')
+ g_log.push('<span class="test-pass">' + msg + '</span>: ' + currentTestName())
}
function logFail(msg)
{
- g_log.push('TEST-' + g_testIndex + ': <span class="test-fail">' + msg + '</span>')
+ g_log.push('<span class="test-fail">' + msg + '</span>: ' + currentTestName())
}
function assertTrue(bool)
@@ -78,11 +85,12 @@ function assertTrue(bool)
logFail('FAIL');
}
-function runTest(results, assertions, opt_localStorageValue)
+function runTest(results, assertions, opt_testName, opt_localStorageValue)
{
document.body.innerHTML = '';
g_testIndex++;
g_state = undefined;
+ g_testName = opt_testName || '';
localStorage.setItem(OptionWriter._key, opt_localStorageValue || '');
try {
@@ -99,14 +107,14 @@ function runTest(results, assertions, opt_localStorageValue)
}
}
-function runDefaultSingleRowTest(test, expected, actual, isExpected, textResults, imageResults)
+function runDefaultSingleRowTest(test, expected, actual, isExpected, textResults, imageResults, opt_testName)
{
results = mockResults();
results.tests[test] = mockExpectation(expected, actual);
- runSingleRowTest(results, isExpected, textResults, imageResults);
+ runSingleRowTest(results, isExpected, textResults, imageResults, opt_testName);
}
-function runSingleRowTest(results, isExpected, textResults, imageResults)
+function runSingleRowTest(results, isExpected, textResults, imageResults, opt_testName)
{
for (var key in results.tests)
var test = key;
@@ -123,7 +131,7 @@ function runSingleRowTest(results, isExpected, textResults, imageResults)
assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == imageResults);
assertTrue(document.querySelector('tbody td:nth-child(4)').textContent == actual);
assertTrue(document.querySelector('tbody td:nth-child(5)').textContent == expected);
- });
+ }, opt_testName || 'single row test');
}
@@ -135,7 +143,7 @@ function runTests()
runTest(results, function() {
assertTrue(document.getElementById('image-results-header').textContent == '');
assertTrue(document.getElementById('text-results-header').textContent != '');
- });
+ }, 'text results header');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -149,7 +157,7 @@ function runTests()
assertTrue(document.getElementsByClassName('result-link')[0].textContent == 'audio result');
assertTrue(document.getElementsByClassName('result-link')[1].textContent == 'result');
assertTrue(document.getElementsByClassName('result-link')[2].textContent == 'png result');
- });
+ }, 'actual result links');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -158,7 +166,7 @@ function runTests()
runTest(results, function() {
assertTrue(document.getElementById('results-table'));
assertTrue(document.querySelector('#stderr-table .result-link').textContent == 'stderr');
- });
+ }, 'stderr link');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -186,7 +194,7 @@ function runTests()
assertTrue(document.getElementById('crash-tests-table').textContent.indexOf('crash log') != -1);
assertTrue(document.getElementById('timeout-tests-table'));
assertTrue(document.getElementById('timeout-tests-table').textContent.indexOf('expected actual diff') != -1);
- });
+ }, 'crash and timeout tests tables');
function isExpanded(expandLink)
{
@@ -228,7 +236,7 @@ function runTests()
collapseExpectations(expandLinks[1]);
assertTrue(expandLinks[1].textContent == '+');
- });
+ }, 'collapsing expectation rows');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -255,13 +263,13 @@ function runTests()
expandAllExpectations();
assertTrue(document.querySelectorAll('.results-row').length == 2);
assertTrue(window.getComputedStyle(document.querySelectorAll('tbody')[0], null)['display'] != 'none');
- });
+ }, 'expanding expectation rows');
results = mockResults();
results.tests['only-expected-fail.html'] = mockExpectation('TEXT', 'TEXT');
runTest(results, function() {
assertTrue(window.getComputedStyle(document.getElementById('results-table').parentNode, null)['display'] == 'none');
- });
+ }, 'only one expected fail result');
runDefaultSingleRowTest('bar-skip.html', 'TEXT', 'SKIP', true, '', '');
runDefaultSingleRowTest('bar-flaky-fail.html', 'PASS FAIL', 'TEXT', true, 'expected actual diff pretty diff ', '');
@@ -279,12 +287,12 @@ function runTests()
results = mockResults();
results.tests['bar-reftest.html'] = mockExpectation('PASS', 'IMAGE');
results.tests['bar-reftest.html'].reftest_type = ['=='];
- runSingleRowTest(results, false, '', 'ref html images diff ');
+ runSingleRowTest(results, false, '', 'ref html images diff ', 'match reftest single row test');
results = mockResults();
results.tests['bar-reftest-mismatch.html'] = mockExpectation('PASS', 'IMAGE');
results.tests['bar-reftest-mismatch.html'].reftest_type = ['!='];
- runSingleRowTest(results, false, '', 'ref mismatch html actual ');
+ runSingleRowTest(results, false, '', 'ref mismatch html actual ', 'mismatch reftest single row test');
results = mockResults();
results.tests['bar-reftest.html'] = mockExpectation('IMAGE', 'PASS');
@@ -292,7 +300,7 @@ function runTests()
results.pixel_tests_enabled = false;
runTest(results, function() {
assertTrue(document.querySelector('tbody td:nth-child(1)').textContent == 'bar-reftest.html \u2691');
- });
+ }, 'match reftest');
results = mockResults();
results.tests['bar-reftest-mismatch.html'] = mockExpectation('IMAGE', 'PASS');
@@ -300,7 +308,7 @@ function runTests()
results.pixel_tests_enabled = false;
runTest(results, function() {
assertTrue(document.querySelector('tbody td:nth-child(1)').textContent == 'bar-reftest-mismatch.html \u2691');
- });
+ }, 'mismatch reftest');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -309,7 +317,7 @@ function runTests()
assertTrue(!document.getElementById('results-table'));
assertTrue(document.getElementById('passes-table'));
assertTrue(document.body.textContent.indexOf('foo/bar-flaky-pass.html') != -1);
- });
+ }, 'expected flaky and passed');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -318,7 +326,7 @@ function runTests()
assertTrue(!document.getElementById('results-table'));
assertTrue(document.getElementById('flaky-tests-table'));
assertTrue(document.body.textContent.indexOf('bar-flaky-fail.html') != -1);
- });
+ }, 'expected flaky and image mismatch');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -328,7 +336,7 @@ function runTests()
assertTrue(document.getElementById('flaky-tests-table'));
assertTrue(document.body.textContent.indexOf('bar-flaky-expected.html') != -1);
assertTrue(document.querySelector('tbody').className == 'expected');
- });
+ }, 'expected flaky and text mismatch');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -339,14 +347,14 @@ function runTests()
assertTrue(links[0].getClientRects().length == 2);
assertTrue(links[1].getClientRects().length == 1);
document.body.style.width = '';
- });
+ }, 'long test name');
results = mockResults();
var subtree = results.tests['foo'] = {}
subtree['bar.html'] = mockExpectation('TEXT', 'TEXT');
runTest(results, function() {
assertTrue(document.querySelector('tbody td:nth-child(2)').textContent.indexOf('pretty diff') != -1);
- });
+ }, 'pretty diff link');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -371,7 +379,7 @@ function runTests()
TableSorter.sortColumn(4);
TableSorter.sortColumn(0);
logPass('PASS');
- });
+ }, 'TableSorter.sortColumn does not raise a JS error');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -390,7 +398,7 @@ function runTests()
PixelZoomer.handleMouseMove(mockEvent);
assertTrue(!!document.querySelector('.pixel-zoom-container'));
assertTrue(document.querySelectorAll('.zoom-image-container').length == 3);
- });
+ }, 'zoom image on hover');
results = mockResults();
var subtree = results.tests['fullscreen'] = {}
@@ -399,7 +407,7 @@ function runTests()
// Use a regexp to match windows and unix-style paths.
var expectedRegExp = new RegExp('^file.*' + results.layout_tests_dir + '/fullscreen/full-screen-api.html$');
assertTrue(expectedRegExp.exec(document.querySelector('tbody td:first-child a').href));
- });
+ }, 'local test link');
var oldShouldUseTracLinks = shouldUseTracLinks;
shouldUseTracLinks = function() { return true; };
@@ -410,7 +418,7 @@ function runTests()
runTest(results, function() {
var expectedHref = 'https://crrev.com/' + results.chromium_revision + '/third_party/WebKit/LayoutTests/fullscreen/full-screen-api.html';
assertTrue(document.querySelector('tbody td:first-child a').href == expectedHref);
- });
+ }, 'chromium revision link');
results = mockResults();
var subtree = results.tests['fullscreen'] = {}
@@ -419,7 +427,7 @@ function runTests()
runTest(results, function() {
var expectedHref = 'https://chromium.googlesource.com/chromium/src/+/master/third_party/WebKit/LayoutTests/fullscreen/full-screen-api.html';
assertTrue(document.querySelector('tbody td:first-child a').href == expectedHref);
- });
+ }, 'googlesource test link');
shouldUseTracLinks = oldShouldUseTracLinks;
@@ -437,14 +445,14 @@ function runTests()
document.getElementById('toggle-images').checked = true;
updateTogglingImages();
assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == ' images diff ');
- });
+ }, 'toggle images option');
results = mockResults();
results.tests['reading-options-from-localstorage.html'] = mockExpectation('IMAGE+TEXT', 'IMAGE+TEXT');
runTest(results, function() {
assertTrue(window.getComputedStyle(document.querySelector('tbody'), null)['display'] != 'none');
assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'expected actual diff ');
- }, '{"toggle-images":false,"show-expected-failures":true}');
+ }, 'reading options from localstorage', '{"toggle-images":false,"show-expected-failures":true}');
function enclosingNodeWithTagNameHasClassName(node, tagName, className) {
while (node && (!node.tagName || node.localName != tagName))
@@ -483,7 +491,7 @@ function runTests()
assertTrue(testLinks[5].innerText == 'foo/expected-pass-or-fail-and-passed.html');
assertTrue(enclosingNodeWithTagNameHasClassName(testLinks[5], 'tbody', 'expected'));
assertTrue(!enclosingNodeWithTagNameHasClassName(testLinks[4], 'table', 'expected'));
- });
+ }, 'class names 1');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -505,7 +513,7 @@ function runTests()
assertTrue(testLinks[2].innerText == 'foo/expected-pass-or-fail-and-passed.html');
assertTrue(enclosingNodeWithTagNameHasClassName(testLinks[2], 'tbody', 'expected'));
assertTrue(enclosingNodeWithTagNameHasClassName(testLinks[2], 'div', 'expected'));
- });
+ }, 'class names 2');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -519,7 +527,7 @@ function runTests()
assertTrue(resultText.indexOf('crash.html') != -1);
assertTrue(resultText.indexOf('flaky-fail.html') != -1);
assertTrue(resultText.indexOf('crash.html') < resultText.indexOf('flaky-fail.html'));
- });
+ }, 'crash and flaky fail test order');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -541,8 +549,7 @@ function runTests()
document.getElementById('show-expected-failures').onchange();
expandAllExpectations();
assertTrue(visibleExpandLinks().length == 2);
- });
-
+ }, 'missing results table');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -558,7 +565,7 @@ function runTests()
assertTrue(!testRows[1].classList.contains('current'));
assertTrue(testRows[2].classList.contains('current'));
}
- });
+ }, 'keyboard shortcuts: prev');
runTest(results, function() {
if (window.eventSender) {
@@ -568,7 +575,7 @@ function runTests()
assertTrue(!testRows[1].classList.contains('current'));
assertTrue(!testRows[2].classList.contains('current'));
}
- });
+ }, 'keyboard shortcuts: next');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -680,7 +687,7 @@ function runTests()
eventSender.keyDown('f'); // flag
assertTrue(flaggedTestsTextbox.innerText == '');
}
- });
+ }, 'keyboard shortcuts');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -714,7 +721,7 @@ function runTests()
assertTrue(titles[3].textContent == 'Tests that timed out (1): [flag all] [unflag all]');
assertTrue(titles[4].textContent == 'Tests that had stderr output (1): [flag all] [unflag all]');
assertTrue(titles[5].textContent == 'Tests expected to fail but passed (1): [flag all] [unflag all]');
- });
+ }, 'table titles 1');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -725,11 +732,11 @@ function runTests()
runTest(results, function() {
var titles = document.getElementsByTagName('h1');
assertTrue(titles[0].textContent == 'Tests that failed text/pixel/audio diff (1): [flag all] [unflag all]');
- assertTrue(titles[1].textContent =='Flaky tests (failed the first run and passed on retry) (1): [flag all] [unflag all]');
+ assertTrue(titles[1].textContent == 'Flaky tests (failed the first run and passed on retry) (1): [flag all] [unflag all]');
assertTrue(document.querySelectorAll('#results-table tbody').length == 2);
assertTrue(document.querySelectorAll('#flaky-tests-table tbody').length == 2);
- });
+ }, 'table titles 2');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -749,7 +756,7 @@ function runTests()
unflag(document.querySelector('.flag'));
assertTrue(flaggedTestsTextbox.innerText == 'foo/bar1.html\nfoo/bar2.html');
- });
+ }, 'flagging tests');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -759,7 +766,7 @@ function runTests()
flagAll(document.querySelector('.flag-all'));
var flaggedTestsTextbox = document.getElementById('flagged-tests');
assertTrue(flaggedTestsTextbox.innerText == 'foo/bar.html\nfoo/bar1.html');
- }, '{"use-newlines":true}');
+ }, 'flagged tests with newlines', '{"use-newlines":true}');
results = mockResults();
var subtree = results.tests['foo'] = {}
@@ -769,14 +776,14 @@ function runTests()
flagAll(document.querySelector('.flag-all'));
var flaggedTestsTextbox = document.getElementById('flagged-tests');
assertTrue(flaggedTestsTextbox.innerText == 'foo/bar.html foo/bar1.html');
- }, '{"use-newlines":false}');
+ }, 'flagged tests with spaces', '{"use-newlines":false}');
results = mockResults();
results.tests['foo/bar-image.html'] = mockExpectation('PASS', 'TEXT IMAGE+TEXT');
results.pixel_tests_enabled = false;
runTest(results, function() {
assertTrue(document.querySelector('tbody td:nth-child(3) a').getAttribute('href') == 'retries/foo/bar-image-diffs.html');
- });
+ }, 'image diff links with IMAGE+TEXT result');
results = mockResults();
results.tests['foo/bar-image.html'] = mockExpectation('PASS', 'TEXT IMAGE');
@@ -784,14 +791,14 @@ function runTests()
runTest(results, function() {
assertTrue(!document.getElementById('results-table'));
assertTrue(document.querySelector('#flaky-tests-table td:nth-child(3) a').getAttribute('href') == 'retries/foo/bar-image-diffs.html');
- });
+ }, 'image diff links flaky TEXT IMAGE result');
results = mockResults();
results.tests['foo'] = mockExpectation('PASS', 'TEXT');
results.tests['foo'].has_repaint_overlay = true;
runTest(results, function() {
assertTrue(document.querySelector('tbody td:nth-child(2)').textContent.indexOf('overlay') != -1);
- })
+ }, 'repaint overlay')
document.body.innerHTML = '<pre>' + g_log.join('\n') + '</pre>';
}
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/harness/results-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698