diff options
author | Solly Ross <sross@redhat.com> | 2016-09-14 13:53:13 -0400 |
---|---|---|
committer | Solly Ross <sross@redhat.com> | 2016-09-14 14:15:19 -0400 |
commit | 8df31d1bfa96e830f263d6433957ec2c1d0ccf1b (patch) | |
tree | 7ac0b95bb43808baed0da9ed47a60b231fa323b0 | |
parent | 3666210f3ba1880a47a075c4d5891c3b13bf19f7 (diff) | |
download | novnc-8df31d1bfa96e830f263d6433957ec2c1d0ccf1b.tar.gz |
Clean up unused files in tests
There were quite a few old/irrelevant files in `tests/`.
This commit removes them.
-rw-r--r-- | tests/arrays.html | 39 | ||||
-rw-r--r-- | tests/arrays.js | 375 | ||||
-rw-r--r-- | tests/base64.html | 91 | ||||
-rw-r--r-- | tests/base64.js | 12 | ||||
-rw-r--r-- | tests/browser.js | 134 | ||||
-rw-r--r-- | tests/canvas.html | 148 | ||||
-rw-r--r-- | tests/cursor.html | 135 | ||||
-rw-r--r-- | tests/face.png | bin | 2303 -> 0 bytes | |||
-rw-r--r-- | tests/face.png.js | 1 | ||||
-rw-r--r-- | tests/keyboard-tests.html | 29 | ||||
-rw-r--r-- | tests/stats.js | 53 | ||||
-rw-r--r-- | tests/viewport.css | 43 | ||||
-rw-r--r-- | tests/viewport.html | 203 |
13 files changed, 0 insertions, 1263 deletions
diff --git a/tests/arrays.html b/tests/arrays.html deleted file mode 100644 index 257df26..0000000 --- a/tests/arrays.html +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Javascript Arrays Performance Test</title> - <!-- - <script type='text/javascript' - src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> - --> - <script src="../include/util.js"></script> - <script src="../include/webutil.js"></script> - <script src="browser.js"></script> - <script src="stats.js"></script> - <script src="arrays.js"></script> - </head> - <body> - <h3>Javascript Arrays Performance Test</h3> - Iterations: <input id='iterations' style='width:50'> - Array Size: <input id='arraySize' style='width:40'>*1024 - - <input id='startButton' type='button' value='Run Tests' - onclick="begin();"> - - <br><br> - Results:<br> - <textarea id="messages" style="font-size: 9;" cols=80 rows=50></textarea> - </br> - <canvas id="canvas" style="display: none;"></canvas> - - </body> - - <script> - var verbose = true; - window.onload = function() { - vmessage("in onload"); - init(); - - } - </script> -</html> diff --git a/tests/arrays.js b/tests/arrays.js deleted file mode 100644 index 69da7fb..0000000 --- a/tests/arrays.js +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Javascript binary array performance tests - * Copyright (C) 2012 Joel Martin - * Licensed under MPL 2.0 (see LICENSE.txt) - */ - -var ctx, i, j, randlist, - new_normal, new_imageData, new_arrayBuffer, - browser = Browser.browser + " " + - Browser.version + " on " + - Browser.OS, - do_imageData = false, - do_arrayBuffer = false, - conf = { - 'create_cnt' : 2000, - 'read_cnt' : 5000000, - 'write_cnt' : 5000000, - 'iterations' : 0, - 'order_l1' : [browser], - 'order_l2' : ['normal', - 'imageData', - 'arrayBuffer'], - 'order_l3' : ['create', - 'sequentialRead', - 'randomRead', - 'sequentialWrite'] - }, - stats = {}, - testFunc = {}, - iteration, arraySize; - -var newline = "\n"; -if (Util.Engine.trident) { - var newline = "<br>\n"; -} -function message(str) { - //console.log(str); - cell = $D('messages'); - cell.innerHTML += str + newline; - cell.scrollTop = cell.scrollHeight; -} - -function vmessage(str) { - if (verbose) { - message(str); - } else { - console.log(str); - } -} - -new_normal = function() { - var arr = [], i; - for (i = 0; i < arraySize; i++) { - arr[i] = 0; - } - return arr; -} - -/* Will be overridden with real function */ -new_imageData = function() { - throw("imageData not supported"); -}; - -new_imageData_createImageData = function() { - var imageData = ctx.createImageData(1024/4, arraySize / 1024); - return imageData.data; -}; - -new_imageData_getImageData = function() { - var imageData = ctx.getImageData(0, 0, 1024/4, arraySize / 1024), - arr = imageData.data; - for (i = 0; i < arraySize; i++) { - arr[i] = 0; - } - return arr; -}; - -new_arrayBuffer = function() { - var arr = new ArrayBuffer(arraySize); - return new Uint8Array(arr); -} - -function init_randlist() { - randlist = []; - for (var i=0; i < arraySize; i++) { - randlist[i] = parseInt(Math.random() * 256, 10); - } -} -function copy_randlist(arr) { - for (var i=0; i < arraySize; i++) { - arr[i] = randlist[i]; - } -} - -function begin() { - var i, j; - conf.iterations = parseInt($D('iterations').value, 10); - arraySize = parseInt($D('arraySize').value, 10) * 1024; - - init_randlist(); - - // TODO: randomize test_list - - stats = {}; - for (i = 0; i < conf.order_l2.length; i++) { - stats[conf.order_l2[i]] = {}; - for (j = 0; j < conf.order_l3.length; j++) { - stats[conf.order_l2[i]][conf.order_l3[j]] = []; - } - } - - $D('startButton').value = "Running"; - $D('startButton').disabled = true; - - message("running " + conf.iterations + " test iterations"); - iteration = 1; - setTimeout(run_next_iteration, 250); -} - -function finish() { - var totalTime, arrayType, testType, times; - message("tests finished"); - - for (j = 0; j < conf.order_l3.length; j++) { - testType = conf.order_l3[j]; - message("Test '" + testType + "'"); - for (i = 0; i < conf.order_l2.length; i++) { - arrayType = conf.order_l2[i]; - message(" Array Type '" + arrayType); - times = stats[arrayType][testType]; - message(" Average : " + times.mean() + "ms" + - " (Total: " + times.sum() + "ms)"); - message(" Min/Max : " + times.min() + "ms/" + - times.max() + "ms"); - message(" StdDev : " + times.stdDev() + "ms"); - } - } - - vmessage("array_chart.py JSON data:"); - chart_data = {'conf' : conf, 'stats' : { } }; - chart_data.stats[browser] = stats; - chart_data.stats['next_browser'] = {}; - vmessage(JSON.stringify(chart_data, null, 2)); - - $D('startButton').disabled = false; - $D('startButton').value = "Run Tests"; -} - -function run_next_iteration() { - var arrayType, testType, deltaTime; - - for (i = 0; i < conf.order_l2.length; i++) { - arrayType = conf.order_l2[i]; - if (arrayType === 'imageData' && (!do_imageData)) { - continue; - } - if (arrayType === 'arrayBuffer' && (!do_arrayBuffer)) { - continue; - } - for (j = 0; j < conf.order_l3.length; j++) { - testType = conf.order_l3[j]; - - deltaTime = testFunc[arrayType + "_" + testType](); - - stats[arrayType][testType].push(deltaTime); - vmessage("test " + (arrayType + "_" + testType) + - " time: " + (deltaTime) + "ms"); - } - } - - message("finished test iteration " + iteration); - if (iteration >= conf.iterations) { - setTimeout(finish, 1); - return; - } - iteration++; - setTimeout(run_next_iteration, 1); -} - -/* - * Test functions - */ - -testFunc["normal_create"] = function() { - var cnt, arrNormal, startTime, endTime; - vmessage("create normal array " + conf.create_cnt + "x, initialized to 0"); - - startTime = (new Date()).getTime(); - for (cnt = 0; cnt < conf.create_cnt; cnt++) { - arrNormal = new_normal(); - } - endTime = (new Date()).getTime(); - - return endTime - startTime; -}; - -testFunc["imageData_create"] = function() { - var cnt, arrImage, startTime, endTime; - vmessage("create imageData array " + conf.create_cnt + "x, initialized to 0"); - - startTime = (new Date()).getTime(); - for (cnt = 0; cnt < conf.create_cnt; cnt++) { - arrImage = new_imageData(); - } - endTime = (new Date()).getTime(); - - if (arrImage[103] !== 0) { - message("Initialization failed, arrImage[103] is: " + arrImage[103]); - throw("Initialization failed, arrImage[103] is: " + arrImage[103]); - } - return endTime - startTime; -}; - -testFunc["arrayBuffer_create"] = function() { - var cnt, arrBuffer, startTime, endTime; - vmessage("create arrayBuffer array " + conf.create_cnt + "x, initialized to 0"); - - startTime = (new Date()).getTime(); - for (cnt = 0; cnt < conf.create_cnt; cnt++) { - arrBuffer = new_arrayBuffer(); - } - endTime = (new Date()).getTime(); - - if (arrBuffer[103] !== 0) { - message("Initialization failed, arrBuffer[103] is: " + arrBuffer[103]); - throw("Initialization failed, arrBuffer[103] is: " + arrBuffer[103]); - } - return endTime - startTime; -}; - -function test_sequentialRead(arr) { - var i, j, cnt, startTime, endTime; - /* Initialize the array */ - copy_randlist(arr); - - startTime = (new Date()).getTime(); - i = 0; - j = 0; - for (cnt = 0; cnt < conf.read_cnt; cnt++) { - j = arr[i]; - i++; - if (i >= arraySize) { - i = 0; - } - } - endTime = (new Date()).getTime(); - - return endTime - startTime; -} - -function test_randomRead(arr) { - var i, cnt, startTime, endTime; - /* Initialize the array */ - copy_randlist(arr); // used as jumplist - - startTime = (new Date()).getTime(); - i = 0; - for (cnt = 0; cnt < conf.read_cnt; cnt++) { - i = (arr[i] + cnt) % arraySize; - } - endTime = (new Date()).getTime(); - - return endTime - startTime; -} - -function test_sequentialWrite(arr) { - var i, cnt, startTime, endTime; - /* Initialize the array */ - copy_randlist(arr); - - startTime = (new Date()).getTime(); - i = 0; - for (cnt = 0; cnt < conf.write_cnt; cnt++) { - arr[i] = (cnt % 256); - i++; - if (i >= arraySize) { - i = 0; - } - } - endTime = (new Date()).getTime(); - - return endTime - startTime; -} - -/* Sequential Read Tests */ -testFunc["normal_sequentialRead"] = function() { - vmessage("read normal array " + conf.read_cnt + "x"); - return test_sequentialRead(new_normal()); -}; - -testFunc["imageData_sequentialRead"] = function() { - vmessage("read imageData array " + conf.read_cnt + "x"); - return test_sequentialRead(new_imageData()); -}; - -testFunc["arrayBuffer_sequentialRead"] = function() { - vmessage("read arrayBuffer array " + conf.read_cnt + "x"); - return test_sequentialRead(new_arrayBuffer()); -}; - - -/* Random Read Tests */ -testFunc["normal_randomRead"] = function() { - vmessage("read normal array " + conf.read_cnt + "x"); - return test_randomRead(new_normal()); -}; - -testFunc["imageData_randomRead"] = function() { - vmessage("read imageData array " + conf.read_cnt + "x"); - return test_randomRead(new_imageData()); -}; - -testFunc["arrayBuffer_randomRead"] = function() { - vmessage("read arrayBuffer array " + conf.read_cnt + "x"); - return test_randomRead(new_arrayBuffer()); -}; - - -/* Sequential Write Tests */ -testFunc["normal_sequentialWrite"] = function() { - vmessage("write normal array " + conf.write_cnt + "x"); - return test_sequentialWrite(new_normal()); -}; - -testFunc["imageData_sequentialWrite"] = function() { - vmessage("write imageData array " + conf.write_cnt + "x"); - return test_sequentialWrite(new_imageData()); -}; - -testFunc["arrayBuffer_sequentialWrite"] = function() { - vmessage("write arrayBuffer array " + conf.write_cnt + "x"); - return test_sequentialWrite(new_arrayBuffer()); -}; - -init = function() { - vmessage(">> init"); - - $D('iterations').value = 10; - $D('arraySize').value = 10; - arraySize = parseInt($D('arraySize').value, 10) * 1024; - - message("Browser: " + browser); - - /* Determine browser binary array support */ - try { - ctx = $D('canvas').getContext('2d'); - new_imageData = new_imageData_createImageData; - new_imageData(); - do_imageData = true; - } catch (exc) { - vmessage("createImageData not supported: " + exc); - try { - ctx = $D('canvas').getContext('2d'); - new_imageData = new_imageData_getImageData; - blah = new_imageData(); - do_imageData = true; - } catch (exc) { - vmessage("getImageData not supported: " + exc); - } - } - if (! do_imageData) { - message("imageData arrays not supported"); - } - - try { - new_arrayBuffer(); - do_arrayBuffer = true; - } catch (exc) { - vmessage("Typed Arrays not supported: " + exc); - } - if (! do_arrayBuffer) { - message("Typed Arrays (ArrayBuffers) not suppoted"); - } - vmessage("<< init"); -} diff --git a/tests/base64.html b/tests/base64.html deleted file mode 100644 index dc45fdd..0000000 --- a/tests/base64.html +++ /dev/null @@ -1,91 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <title>Native Base64 Tests</title> - <script src="../include/util.js"></script> - <script src="../include/webutil.js"></script> - <script src="../include/base64.js"></script> - </head> - <body> - <h1>Native Base64 Tests</h1> - - <br> - Messages:<br> - <textarea id="debug" style="font-size: 9px;" cols=80 rows=25></textarea> - - <br> - </body> - -<script> - function debug(str) { - console.log(str); - cell = $D('debug'); - cell.innerHTML += str + "\n"; - cell.scrollTop = cell.scrollHeight; - } - - function assertRun(code, result) { - try { - var actual = eval(code); - } catch (exc) { - debug("FAIL: '" + code + "' threw an exception"); - fail += 1; - return false; - } - if (actual !== result) { - debug("FAIL: '" + code + "' returned '" + actual + "', expected '" + result + "'"); - fail += 1; - return false; - } - debug("PASS: '" + code + "' returned expected '" + result +"'"); - pass += 1; - return true; - } - - function Base64_decode(data) { - var arr = Base64.decode (data); - return arr.map(function (num) { - return String.fromCharCode(num); } ).join(''); - - } - - window.onload = function() { - var str; - debug('onload'); - fail = 0; - pass = 0; - assertRun('window.btoa("hello world")', 'aGVsbG8gd29ybGQ='); - assertRun('window.btoa("a")', 'YQ=='); - assertRun('window.btoa("ab")', 'YWI='); - assertRun('window.btoa("abc")', 'YWJj'); - assertRun('window.btoa("abcd")', 'YWJjZA=='); - assertRun('window.btoa("abcde")', 'YWJjZGU='); - assertRun('window.btoa("abcdef")', 'YWJjZGVm'); - assertRun('window.btoa("abcdefg")', 'YWJjZGVmZw=='); - assertRun('window.btoa("abcdefgh")', 'YWJjZGVmZ2g='); - - assertRun('window.atob("aGVsbG8gd29ybGQ=")', 'hello world'); - assertRun('Base64_decode("aGVsbG8gd29ybGQ=")', 'hello world'); - assertRun('window.atob("YQ==")', 'a'); - assertRun('Base64_decode("YQ==")', 'a'); - assertRun('window.atob("YWI=")', 'ab'); - assertRun('Base64_decode("YWI=")', 'ab'); - assertRun('window.atob("YWJj")', 'abc'); - assertRun('Base64_decode("YWJj")', 'abc'); - assertRun('window.atob("YWJjZA==")', 'abcd'); - assertRun('Base64_decode("YWJjZA==")', 'abcd'); - assertRun('window.atob("YWJjZGU=")', 'abcde'); - assertRun('Base64_decode("YWJjZGU=")', 'abcde'); - assertRun('window.atob("YWJjZGVm")', 'abcdef'); - assertRun('Base64_decode("YWJjZGVm")', 'abcdef'); - - assertRun('typeof window.btoa', 'function'); - assertRun('window.btoa("")', ''); - assertRun('window.btoa(null)', ''); - assertRun('window.atob(window.btoa(window))', window.toString()); // "[object DOMWindow]" - assertRun('window.btoa("\\u0080\\u0081")', 'gIE='); - - debug("Tests failed: " + fail); - debug("Tests passed: " + pass); - } -</script> diff --git a/tests/base64.js b/tests/base64.js deleted file mode 100644 index 6ade00a..0000000 --- a/tests/base64.js +++ /dev/null @@ -1,12 +0,0 @@ -// The following results in 'hello [MANGLED]' -// -// Filed as https://github.com/ry/node/issues/issue/402 - -var sys = require("sys"), - buf = new Buffer(1024), len, - str1 = "aGVsbG8g", // 'hello ' - str2 = "d29ybGQ=", // 'world' - -len = buf.write(str1, 0, 'base64'); -len += buf.write(str2, len, 'base64'); -sys.log("decoded result: " + buf.toString('binary', 0, len)); diff --git a/tests/browser.js b/tests/browser.js deleted file mode 100644 index 7cf8279..0000000 --- a/tests/browser.js +++ /dev/null @@ -1,134 +0,0 @@ -/* - * From: - * http://www.quirksmode.org/js/detect.html - */ - -var Browser = { - init: function () { - this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; - this.version = this.searchVersion(navigator.userAgent) - || this.searchVersion(navigator.appVersion) - || "an unknown version"; - this.majorVersion = this.searchMajorVersion(navigator.userAgent) - || this.searchMajorVersion(navigator.appVersion) - || "an unknown version"; - this.fullVersion = this.searchFullVersion(navigator.userAgent) - || this.searchFullVersion(navigator.appVersion) - || "an unknown version"; - this.OS = this.searchString(this.dataOS) || "an unknown OS"; - }, - searchString: function (data) { - for (var i=0;i<data.length;i++) { - var dataString = data[i].string; - var dataProp = data[i].prop; - this.versionSearchString = data[i].versionSearch || data[i].identity; - if (dataString) { - if (dataString.indexOf(data[i].subString) != -1) - return data[i].identity; - } - else if (dataProp) - return data[i].identity; - } - }, - searchFullVersion: function (dataString) { - var index = dataString.indexOf(this.versionSearchString); - if (index == -1) return; - return dataString.substring(index+this.versionSearchString.length+1); - }, - searchVersion: function (dataString) { - return this.searchFullVersion(dataString).split(" ")[0]; - }, - searchMajorVersion: function (dataString) { - return parseFloat(this.searchFullVersion(dataString).split(".")[0]); - }, - dataBrowser: [ - { - string: navigator.userAgent, - subString: "Chrome", - identity: "Chrome" - }, - { string: navigator.userAgent, - subString: "OmniWeb", - versionSearch: "OmniWeb/", - identity: "OmniWeb" - }, - { - string: navigator.vendor, - subString: "Apple", - identity: "Safari", - versionSearch: "Version" - }, - { - prop: window.opera, - identity: "Opera", - versionSearch: "Version" - }, - { - string: navigator.vendor, - subString: "iCab", - identity: "iCab" - }, - { - string: navigator.vendor, - subString: "KDE", - identity: "Konqueror" - }, - { - string: navigator.userAgent, - subString: "Firefox", - identity: "Firefox" - }, - { - string: navigator.vendor, - subString: "Camino", - identity: "Camino" - }, - { // for newer Netscapes (6+) - string: navigator.userAgent, - subString: "Netscape", - identity: "Netscape" - }, - { - string: navigator.userAgent, - subString: "MSIE", - identity: "Explorer", - versionSearch: "MSIE" - }, - { - string: navigator.userAgent, - subString: "Gecko", - identity: "Mozilla", - versionSearch: "rv" - }, - { // for older Netscapes (4-) - string: navigator.userAgent, - subString: "Mozilla", - identity: "Netscape", - versionSearch: "Mozilla" - } - ], - dataOS : [ - { - string: navigator.platform, - subString: "Win", - identity: "Windows" - }, - { - string: navigator.platform, - subString: "Mac", - identity: "Mac" - }, - { - string: navigator.userAgent, - subString: "iPhone", - identity: "iPhone/iPod" - }, - { - string: navigator.platform, - subString: "Linux", - identity: "Linux" - } - ] - -}; -Browser.init(); diff --git a/tests/canvas.html b/tests/canvas.html deleted file mode 100644 index 010e8f3..0000000 --- a/tests/canvas.html +++ /dev/null @@ -1,148 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Canvas Performance Test</title> - <!-- - <script type='text/javascript' - src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> - --> - <script src="../include/util.js"></script> - <script src="../include/webutil.js"></script> - <script src="../include/base64.js"></script> - <script src="../include/display.js"></script> - <script src="face.png.js"></script> - </head> - <body> - Iterations: <input id='iterations' style='width:50' value="100"> - - Width: <input id='width' style='width:50' value="640"> - Height: <input id='height' style='width:50' value="480"> - - <input id='startButton' type='button' value='Do Performance Test' - style='width:150px' onclick="begin();"> - - <br><br> - - <b>Canvas</b> (should see three squares and two happy faces):<br> - <canvas id="canvas" width="200" height="100" - style="border-style: dotted; border-width: 1px;"> - Canvas not supported. - </canvas> - - <br> - Results:<br> - <textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea> - </body> - - <script> - var msg_cnt = 0; - var display, start_width = 300, start_height = 100; - var iterations; - - function message(str) { - console.log(str); - cell = $D('messages'); - cell.innerHTML += msg_cnt + ": " + str + "\n"; - cell.scrollTop = cell.scrollHeight; - msg_cnt += 1; - } - - function test_functions () { - var img, x, y, w, h, ctx = display.get_context(); - w = display.get_width(); - h = display.get_height(); - display.fillRect(0, 0, w, h, [240,240,240]); - - display.blitStringImage("data:image/png;base64," + face64, 150, 10); - - var himg = new Image(); - himg.onload = function () { - ctx.drawImage(himg, 200, 40); }; - himg.src = "face.png"; - - /* Test array image data */ - data = []; - for (y=0; y< 50; y++) { - for (x=0; x< 50; x++) { - data[(y*50 + x)*4 + 0] = 255 - parseInt((255 / 50) * y, 10); - data[(y*50 + x)*4 + 1] = parseInt((255 / 50) * y, 10); - data[(y*50 + x)*4 + 2] = parseInt((255 / 50) * x, 10); - data[(y*50 + x)*4 + 3] = 255; - } - } - display.blitImage(30, 10, 50, 50, data, 0); - - img = display.getTile(5,5,16,16,[0,128,128]); - display.putTile(img); - - img = display.getTile(90,15,16,16,[0,0,0]); - display.setSubTile(img, 0,0,16,16,[128,128,0]); - display.putTile(img); - } - - function begin () { - $D('startButton').value = "Running"; - $D('startButton').disabled = true; - setTimeout(start_delayed, 250); - iterations = $D('iterations').value; - } - - function start_delayed () { - var ret; - - ret = display.set_prefer_js(true); - if (ret) { - message("Running test: prefer Javascript ops"); - var time1 = run_test(); - message("prefer Javascript ops: " + time1 + "ms total, " + - (time1 / iterations) + "ms per frame"); - } else { - message("Could not run: prefer Javascript ops"); - } - - display.set_prefer_js(false); - message("Running test: prefer Canvas ops"); - var time2 = run_test(); - message("prefer Canvas ops: " + time2 + "ms total, " + - (time2 / iterations) + "ms per frame"); - - if (Util.get_logging() !== 'debug') { - display.resize(start_width, start_height, true); - test_functions(); - } - $D('startButton').disabled = false; - $D('startButton').value = "Do Performance Test"; - } - - function run_test () { - var width, height; - width = $D('width').value; - height = $D('height').value; - display.resize(width, height); - var color, start_time = (new Date()).getTime(), w, h; - for (var i=0; i < iterations; i++) { - color = [128, 128, (255 / iterations) * i, 0]; - for (var x=0; x < width; x = x + 16) { - for (var y=0; y < height; y = y + 16) { - w = Math.min(16, width - x); - h = Math.min(16, height - y); - var tile = display.getTile(x, y, w, h, color); - display.setSubTile(tile, 0, 0, w, h, color); - display.putTile(tile); - } - } - } - var end_time = (new Date()).getTime(); - return (end_time - start_time); - } - - window.onload = function() { - message("in onload"); - $D('iterations').value = 10; - display = new Display({'target' : $D('canvas')}); - display.resize(start_width, start_height, true); - message("Canvas initialized"); - test_functions(); - } - </script> -</html> diff --git a/tests/cursor.html b/tests/cursor.html deleted file mode 100644 index 91e621b..0000000 --- a/tests/cursor.html +++ /dev/null @@ -1,135 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <title>Cursor Change test</title> - <meta charset="UTF-8"> - <!-- - <script type='text/javascript' - src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> - --> - <script src="../include/util.js"></script> - <script src="../include/webutil.js"></script> - <script src="../include/base64.js"></script> - <script src="../include/canvas.js"></script> - </head> - <body> - <h1>Roll over the buttons to test cursors</h1> - <br> - <input id=button1 type="button" value="Cursor from file (smiley face)"> - <input id=button2 type="button" value="Data URI cursor (crosshair)"> - - <br> - <br> - <br> - Debug:<br> - <textarea id="debug" style="font-size: 9px;" cols=80 rows=25></textarea> - <br> - <br> - <canvas id="testcanvas" width="100px" height="20px"> - Canvas not supported. - </canvas> - - </body> - - <script> - function debug(str) { - console.log(str); - cell = $D('debug'); - cell.innerHTML += str + "\n"; - cell.scrollTop = cell.scrollHeight; - } - - function makeCursor() { - var arr = [], x, y, w = 32, h = 32, hx = 16, hy = 16; - - var IHDRsz = 40; - var ANDsz = w * h * 4; - var XORsz = Math.ceil( (w * h) / 8.0 ); - - // Push multi-byte little-endian values - arr.push16le = function (num) { - this.push((num ) & 0xFF, - (num >> 8) & 0xFF ); - }; - arr.push32le = function (num) { - this.push((num ) & 0xFF, - (num >> 8) & 0xFF, - (num >> 16) & 0xFF, - (num >> 24) & 0xFF ); - }; - - // Main header - arr.push16le(0); // Reserved - arr.push16le(2); // .CUR type - arr.push16le(1); // Number of images, 1 for non-animated arr - - // Cursor #1 - arr.push(w); // width - arr.push(h); // height - arr.push(0); // colors, 0 -> true-color - arr.push(0); // reserved - arr.push16le(hx); // hotspot x coordinate - arr.push16le(hy); // hotspot y coordinate - arr.push32le(IHDRsz + XORsz + ANDsz); // cursor data byte size - arr.push32le(22); // offset of cursor data in the file - - // Infoheader for Cursor #1 - arr.push32le(IHDRsz); // Infoheader size - arr.push32le(w); // Cursor width - arr.push32le(h*2); // XOR+AND height - arr.push16le(1); // number of planes - arr.push16le(32); // bits per pixel - arr.push32le(0); // type of compression - arr.push32le(XORsz + ANDsz); // Size of Image - arr.push32le(0); - arr.push32le(0); - arr.push32le(0); - arr.push32le(0); - - // XOR/color data - for (y = h-1; y >= 0; y--) { - for (x = 0; x < w; x++) { - //if ((x === hx) || (y === (h-hy-1))) { - if ((x === hx) || (y === hy)) { - arr.push(0xe0); // blue - arr.push(0x00); // green - arr.push(0x00); // red - arr.push(0xff); // alpha - } else { - arr.push(0x05); // blue - arr.push(0xe6); // green - arr.push(0x00); // red - arr.push(0x80); // alpha - } - } - } - - // AND/bitmask data (seems to be ignored) - for (y = 0; y < h; y++) { - for (x = 0; x < Math.ceil(w / 8); x++) { - arr.push(0x00); - } - } - - debug("cursor generated"); - return arr; - } - - window.onload = function() { - debug("onload"); - var canvas, cross, cursor, cursor64; - - canvas = new Canvas({'target' : $D("testcanvas")}); - debug("canvas indicates Data URI cursor support is: " + canvas.get_cursor_uri()); - - $D('button1').style.cursor="url(face.png), default"; - - cursor = makeCursor(); - cursor64 = Base64.encode(cursor); - //debug("cursor: " + cursor.slice(0,100) + " (" + cursor.length + ")"); - //debug("cursor64: " + cursor64.slice(0,100) + " (" + cursor64.length + ")"); - $D('button2').style.cursor="url(data:image/x-icon;base64," + cursor64 + "), default"; - - debug("onload complete"); - } - </script> diff --git a/tests/face.png b/tests/face.png Binary files differdeleted file mode 100644 index 74c30d8..0000000 --- a/tests/face.png +++ /dev/null diff --git a/tests/face.png.js b/tests/face.png.js deleted file mode 100644 index e0b5d6c..0000000 --- a/tests/face.png.js +++ /dev/null @@ -1 +0,0 @@ -var face64 =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59cMU74GVKxcnhg5sdzN1jQtX5grtqVyj46ZtywIJrUOZeCKYCLxTU+PHkzhZ2vO1XH5MRIfcwvcHP9qRafp5XfN6l3PGGIA5ktJaJEJINXnkvmWrNza0rSBxEFYbnE6veGRq9IPQO54Ep5QItRYAs22Hu1k315QtdDYsuCzf1KHDt0XlbTu3ySuVRo6MNnc/6XLHTbmObc+QotAHIJUSQiSJTKLR4Nh9Pdc+kM44JA+D5RhfBud8ZjeD5WHVMVYHqwAYmGkyUyRPqPDfMnhTxcNW+jKpGj/94NX8eVtTmYWpFHddlzsOABaOzZGkkImQUsrI/1iVfrPq6vszuSyJD0EasGEVmN0KlgXLgYGMT6qkkwEthrQuG53Y2U0icT79YIfb2pup6+Gcp1zOXV4j9VdJxhghpJBSSCmEjL0+XXqsa+0tTYvWQ/aTHJrZW9JEkowwJjYmMjo0OmR8uZ1eNz12+Nih/zgtv0gXVrsur1Jcl1uWNUsK/GoQldZSSCGllEpIGYcndOm36Vyqa/VNmboFRh4ldZR02ZhpMhJwCGnmLGZ8SewXj/bvTkLDW3pT2UUu55w7Lufc5dVNAsCCsf4o8Gqpr8KkUlIqpZRUKim/Y/y/pVLZ1s5V+Zbl3C3Ybp5Iq2RKxhP+xFBxZFAmwi7cmaq/kjuO4zicO9xx5mPOQqrGvYZRWmulldYqGlLBf3X8EfQkSR8A43WMN1nuWid3hZPpcmzbdmzHtmuwarjnkw5FldNIczyljDZKa62NNpoM1QSA1WQx27Jt23Js27It7pzJmLthz/7/nzHOOThcImPoNBIIAMNpJMtiNcBZDZ3PfVIjgtkWsy3riyZ9AaFGMlozhuqCnDsxxv4PC7uS+QV5eeoAAAAASUVORK5CYII='; diff --git a/tests/keyboard-tests.html b/tests/keyboard-tests.html deleted file mode 100644 index a30aa6e..0000000 --- a/tests/keyboard-tests.html +++ /dev/null @@ -1,29 +0,0 @@ -<!doctype html> -<html> -<head> - <meta charset="utf-8"> - <title>Mocha Tests</title> - <link rel="stylesheet" href="node_modules/mocha/mocha.css" /> -</head> -<body> - <!-- - To run tests - cd .../noVNC/tests - npm install chai mocha - open keyboard-tests.html in a browser - --> - <div id="mocha"></div> - <script src="node_modules/chai/chai.js"></script> - <script src="node_modules/mocha/mocha.js"></script> - <script>mocha.setup('bdd')</script> - <script src="../include/keysymdef.js"></script> - <script src="../include/keyboard.js"></script> - <script src="test.keyboard.js"></script> - <script src="test.helper.js"></script> - <script> - mocha.checkLeaks(); - mocha.globals(['navigator']); - mocha.run(); - </script> -</body> -</html> diff --git a/tests/stats.js b/tests/stats.js deleted file mode 100644 index cd3011c..0000000 --- a/tests/stats.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Define some useful statistical functions on arrays of numbers - */ - -Array.prototype.sum = function() { - var i, sum = 0; - for (i = 0; i < this.length; i++) { - sum += this[i]; - } - return sum; -} - -Array.prototype.max = function() { - return Math.max.apply(null, this); -} - -Array.prototype.min = function() { - return Math.min.apply(null, this); -} - -Array.prototype.mean = function() { - return this.sum() / this.length; -} -Array.prototype.average = Array.prototype.mean; - -Array.prototype.median = function() { - var sorted = this.sort( function(a,b) { return a-b; }), - len = sorted.length; - if (len % 2) { - return sorted[Math.floor(len / 2)]; // Odd - } else { - return (sorted[len/2 - 1] + sorted[len/2]) / 2; // Even - } -} - -Array.prototype.stdDev = function(sample) { - var i, sumSqr = 0, mean = this.mean(), N; - - if (sample) { - // Population correction if this is a sample - N = this.length - 1; - } else { - // Standard deviation of just the array - N = this.length; - } - - for (i = 0; i < this.length; i++) { - sumSqr += Math.pow(this[i] - mean, 2); - } - - return Math.sqrt(sumSqr / N); -} - diff --git a/tests/viewport.css b/tests/viewport.css deleted file mode 100644 index 86f65ff..0000000 --- a/tests/viewport.css +++ /dev/null @@ -1,43 +0,0 @@ -html,body { - margin: 0px; - padding: 0px; - width: 100%; - height: 100%; -} - -.flex-layout { - width: 100%; - height: 100%; - - display: box; - display: -webkit-box; - display: -moz-box; - display: -ms-box; - - box-orient: vertical; - -webkit-box-orient: vertical; - -moz-box-orient: vertical; - -ms-box-orient: vertical; - - box-align: stretch; - -webkit-box-align: stretch; - -moz-box-align: stretch; - -ms-box-align: stretch; -} -.flex-box { - box-flex: 1; - -webkit-box-flex: 1; - -moz-box-flex: 1; - -ms-box-flex: 1; -} - -.container { - margin: 0px; - padding: 0px; -} - -.canvas { - position: absolute; - border-style: dotted; - border-width: 1px; -} diff --git a/tests/viewport.html b/tests/viewport.html deleted file mode 100644 index 374d8b1..0000000 --- a/tests/viewport.html +++ /dev/null @@ -1,203 +0,0 @@ -<!DOCTYPE html> -<html> - <head><title>Viewport Test</title> - <link rel="stylesheet" href="viewport.css"> - <!-- - <meta name="apple-mobile-web-app-capable" content="yes" /> - <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> - --> - <meta name=viewport content="width=device-width, initial-scale=1.0, user-scalable=no"> - </head> - <body> - <div class="flex-layout"> - <div> - Canvas: - <input id="move-selector" type="button" value="Move" - onclick="toggleMove();"> - <br> - </div> - <div class="container flex-box"> - <canvas id="canvas" class="canvas"> - Canvas not supported. - </canvas> - <br> - </div> - <div> - <br> - Results:<br> - <textarea id="messages" style="font-size: 9;" cols=80 rows=8></textarea> - </div> - </div> - </body> - - <!-- - <script type='text/javascript' - src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> - --> - <script src="../include/util.js"></script> - <script src="../include/webutil.js"></script> - <script src="../include/base64.js"></script> - <script src="../include/keysymdef.js"></script> - <script src="../include/keyboard.js"></script> - <script src="../include/input.js"></script> - <script src="../include/display.js"></script> - <script> - var msg_cnt = 0, iterations, - penDown = false, doMove = false, - inMove = false, lastPos = {}, - padW = 0, padH = 0, - display, ctx, keyboard, mouse; - - var newline = "\n"; - if (Util.Engine.trident) { - var newline = "<br>\n"; - } - - function message(str) { - console.log(str); - cell = $D('messages'); - cell.innerHTML += msg_cnt + ": " + str + newline; - cell.scrollTop = cell.scrollHeight; - msg_cnt++; - } - - function mouseButton(x, y, down, bmask) { - //msg = 'mouse x,y: ' + x + ',' + y + ' down: ' + down; - //msg += ' bmask: ' + bmask; - //message(msg); - - if (doMove) { - if (down && !inMove) { - inMove = true; - lastPos = {'x': x, 'y': y}; - } else if (!down && inMove) { - inMove = false; - //dirtyRedraw(); - } - return; - } - - if (down && ! penDown) { - penDown = true; - ctx.beginPath(); - ctx.moveTo(x, y); - } else if (!down && penDown) { - penDown = false; - ctx.closePath(); - } - } - - function mouseMove(x, y) { - var deltaX, deltaY; - - if (inMove) { - //deltaX = x - lastPos.x; // drag viewport - deltaX = lastPos.x - x; // drag frame buffer - //deltaY = y - lastPos.y; // drag viewport - deltaY = lastPos.y - y; // drag frame buffer - lastPos = {'x': x, 'y': y}; - - display.viewportChangePos(deltaX, deltaY); - return; - } - - if (penDown) { - ctx.lineTo(x, y); - ctx.stroke(); - } - } - - function dirtyRedraw() { - if (inMove) { - // Wait for user to stop moving viewport - return; - } - - var d = display.getCleanDirtyReset(); - - for (i = 0; i < d.dirtyBoxes.length; i++) { - //showBox(d.dirtyBoxes[i], "dirty[" + i + "]: "); - drawArea(d.dirtyBoxes[i]); - } - } - - function drawArea(b) { - var data = [], pixel, x, y; - - //message("draw "+b.x+","+b.y+" ("+b.w+","+b.h+")"); - - for (var i = 0; i < b.w; i++) { - x = b.x + i; - for (var j = 0; j < b.h; j++) { - y = b.y + j; - pixel = (j * b.w * 4 + i * 4); - data[pixel + 0] = ((x * y) / 13) % 256; - data[pixel + 1] = ((x * y) + 392) % 256; - data[pixel + 2] = ((x + y) + 256) % 256; - data[pixel + 3] = 255; - } - } - //message("i: " + i + ", j: " + j + ", pixel: " + pixel); - display.blitImage(b.x, b.y, b.w, b.h, data, 0); - } - - function toggleMove() { - if (doMove) { - doMove = false; - $D('move-selector').style.backgroundColor = ""; - $D('move-selector').style.color = ""; - } else { - doMove = true; - $D('move-selector').style.backgroundColor = "black"; - $D('move-selector').style.color = "lightgray"; - } - } - - function detectPad() { - var c = $D('canvas'), p = c.parentNode; - c.width = 10; - c.height = 10; - padW = c.offsetWidth - 10; - padH = c.offsetHeight - 10; - message("padW: " + padW + ", padH: " + padH); - } - - function doResize() { - var p = $D('canvas').parentNode; - message("doResize1: [" + (p.offsetWidth - padW) + - "," + (p.offsetHeight - padH) + "]"); - display.viewportChangeSize(p.offsetWidth - padW, p.offsetHeight - padH); - /* - var pos, new_w, new_h;pos - pos = Util.getPosition($D('canvas').parentNode); - new_w = window.innerWidth - pos.x; - new_h = window.innerHeight - pos.y; - display.viewportChangeSize(new_w, new_h); - */ - } - - window.onload = function() { - detectPad(); - - display = new Display({'target': $D('canvas')}); - display.resize(1600, 1024); - display.set_viewport(true); - ctx = display.get_context(); - - mouse = new Mouse({'target': $D('canvas'), - 'onMouseButton': mouseButton, - 'onMouseMove': mouseMove}); - mouse.grab(); - - - Util.addEvent(window, 'resize', doResize); - // Shrink viewport for first resize call so that the - // scrollbars are disabled - display.viewportChangeSize(10, 10); - setTimeout(doResize, 1); - setInterval(dirtyRedraw, 50); - - message("Display initialized"); - }; - </script> -</html> |