-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
121 lines (112 loc) · 3.95 KB
/
test.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!-- This file is part of City.
City is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
City is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with City. If not, see <http://www.gnu.org/licenses/>.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="city/phaser.min.js"></script>
<script src="src/error.js"></script>
<script src="src/utils.js"></script>
<script src="src/point.js"></script>
<script src="src/tile.js"></script>
<script src="src/cardriver.js"></script>
<script src="src/bezier.js"></script>
<script src="src/vehicle.js"></script>
<script src="src/car.js"></script>
<script src="test/bezier_test.js"></script>
<script src="test/util_test.js"></script>
<script src="test/tile_test.js"></script>
<script src="test/vehicle_test.js"></script>
<style type="text/css">
#spinner {
position: absolute;
left: calc(50vw - 76px);
top: calc(50vh - 76px);
border: 16px dashed #000000;
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 3s linear infinite;
}
#result {
font: 20px Arial;
}
table {
font-family: Courier New;
}
td {
padding-right: 40px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div id="spinner"></div>
<div id="result"></div>
<script>
var game = new Phaser.Game(1, 1, Phaser.CANVAS, '', { preload: preload, create: create });
var config;
function preload() {
game.load.json('config', 'city/config.json');
}
function displayText(message) {
document.getElementById('spinner').style.display = 'none';
document.getElementById('result').innerHTML = message;
}
function displayError(error) {
var message = error.message;
var stack = error.stack.split('\n');
var table = '<table>';
for (var line of stack) {
if (line.indexOf('@') > 0) {
var functionName = line.split('@')[0];
if (functionName.includes('assertTrue')) {
continue;
}
var fileName = line.split('@')[1];
if (fileName.includes('test.html')) {
break;
}
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
var lineNumber = fileName.split(':')[1];
fileName = fileName.split(':')[0];
table += '<tr><td><b>' + functionName + '</b></td><td>' + fileName + '</td><td>' + lineNumber + '</td></tr>';
}
}
table += '</table>';
displayText('<h1>' + message + '</h1>' + table);
}
function assertTrue(expression) {
if (!expression) {
throw new Error('Assertion Error');
}
}
function create() {
config = game.cache.getJSON('config');
try {
new BezierCurveTest();
new UtilTest();
new TileTest();
new VehicleTest();
} catch (e) {
displayError(e);
throw e;
}
displayText('<h1>Tests successful</h1>');
}
</script>
</body>
</html>