<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<!-- unit test -->
<script type="text/javascript" src="test-bundle.js"></script>
<title>OpenPGP.js testpage</title>

<style>
* {
	font-family: monospace;
}

#debug, #testoutput {
	border: 1px dotted #aaa;
	background-color: #eee;
	margin: 5px;
	padding: 5px;
}

.successful {
	background-color: #afa;
}
.failed {
	background-color: #faa;
}

#unittests {
	width: 98%;
	max-width: 99%;
	table-layout: fixed;
	word-wrap: break-word;
	white-space: pre;
}


#unittests tbody tr th {
	background-color: #eee;
	border: 1px dotted #aaa;
}

#unittests tbody tr td {
	padding: 2px;
	border: 1px solid #ccc;
}

.unittesttitle {
	font-weight: bold;
	vertical-align: top;
}

.unittestrow {
	border-top: 1px solid #aaa;
}


</style>
<script type="text/javascript">


var test = require('test-bundle.js');

function unit_tests() {
	var table = document.getElementById('unittests');

	var single_test = function() {
		var result = test.run();

		var html = '<tr class="unittestrow"><td rowspan="' +
			result.tests.length + '" class="unittesttitle">' + result.title + '</td>';


		for (var i in result.tests) {
			html += (i != 0 ?
					'<tr>' : '')
				+ '<td>' + result.tests[i].description
				+ '</td><td ' + (result.tests[i].result ? 
					'class="successful">PASSED</td>' : 
					'class="failed">FAILED</td>') 
				+ '</tr>';
		}

		table.innerHTML += html;

		if(test.tests.length > 0) {
			setTimeout(single_test, 100);
		}
	}

	single_test();
}

</script>
</head>
<body>
	<a href="index.html">Unit Tests</a> | 
	<a href="parser.html">Parser</a> | 
	<a href="encryption.html">Encryption / Decryption</a> | 
	<a href="coverage.html">Coverage</a>

<h1>Unit tests</h1>

<table id="unittests">
	<colgroup>
		<col style="width: 20%;">
		<col>
		<col style="width: 5%;">
	</colgroup>
	<tr><th>Test</th><th>Description</th><th>Result</th></tr>
</table>

<br>
<button type="submit" onmousedown="unit_tests();">Run unit tests</button>

<!-- src/util/util.js print_debug() writes to  -->
<h2>Messages</h2>
<div id="debug"></div>
</body>
</html>