-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrun_tests.js
54 lines (47 loc) · 1.97 KB
/
run_tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2021 The Skiafy Authors
//
// 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
//
// https://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.
testCases = [
{ name: 'home' },
{ name: 'color_home', preserveFill: true },
{ name: 'color_home', preserveFill: false, expected: 'home' },
{ name: 'implicit_lineto' },
{ name: 'implicit_r_lineto' },
{ name: 'repeat_r_vh_lineto' },
{ name: 'fill_rule_evenodd' },
]
function runTests() {
var svgAnchor = $('svg-anchor');
var testOutputTemplate = $('test-output-template');
var testOutputAnchor = $('test-cases');
for (var i = 0; i < testCases.length; i++) {
var name = testCases[i].name;
svgAnchor.innerHTML = testData[name].svg;
var preserveFill = testCases[i].preserveFill || false;
var output = ProcessSvg(svgAnchor.querySelector('svg'), 1, 1, 0, 0, preserveFill);
var expected = testCases[i].expected || name;
var expectedOutput = testData[expected]['expected'];
outputNode = testOutputTemplate.cloneNode(true);
outputNode.id = null;
outputNode.hidden = false;
var testNameSpan = outputNode.querySelector('.testName');
testNameSpan.innerText = name + (preserveFill ? ' (preserveFill)' : '');
if (expectedOutput !== output) {
outputNode.classList.add('failedTest');
outputNode.querySelector('.actualOutput').innerText = output;
outputNode.querySelector('.expectedOutput').innerText = expectedOutput;
}
testOutputAnchor.appendChild(outputNode);
}
}
window.onload = runTests;