blob: 5697d26911ef1389ae89576e2da48e4b6919fe8e (
plain)
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
|
<!DOCTYPE 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>
|