sku-pg
Version:
Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!
54 lines (45 loc) • 1.3 kB
HTML
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.debug.FpsDisplay</title>
<script src="../base.js"></script>
<script>
goog.require('goog.debug.FpsDisplay');
goog.require('goog.testing.AsyncTestCase');
goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>
var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
var fpsDisplay;
var timer;
asyncTestCase.stepTimeout = 10 * 1000;
function setUp() {
fpsDisplay = new goog.debug.FpsDisplay();
}
function tearDown() {
goog.dispose(fpsDisplay);
window.clearTimeout(timer);
}
function testRendering() {
fpsDisplay.render();
var elem = fpsDisplay.getElement();
assertHTMLEquals('', elem.innerHTML);
asyncTestCase.waitForAsync('Waiting for some frames to pass');
timer = window.setTimeout(function() {
var fps = parseInt(elem.innerHTML, 10);
assertTrue('FPS of ' + fps + ' should be non-negative', fps >= 0);
assertTrue('FPS of ' + fps + ' too big', fps < 1000);
asyncTestCase.continueTesting();
}, 2000);
}
</script>
</body>
</html>