Skip to content

Commit

Permalink
Fix browser tests, move to test/optional. Now working fully locally.
Browse files Browse the repository at this point in the history
	modified:   benchmark/bce.html         Add header for IE11
	deleted:    test/HttpServer.jl	       code exist elsewhere, delete
	renamed:    test/browsertest.html -> test/optional/browsertest.html
	renamed:    test/browsertest.jl -> test/optional/browsertest.jl
	renamed:    test/browsertest2.html -> test/optional/browsertest2.html
	renamed:    test/favicon.ico -> test/optional/favicon.ico
	renamed:    test/functions_log_test.jl -> test/optional/functions_log_test.jl
	renamed:    test/functions_open_browsers.jl -> test/optional/functions_open_browsers.jl
	renamed:    test/functions_server.jl -> test/optional/functions_server.jl
	renamed:    test/handler_functions_events.jl -> test/optional/handler_functions_events.jl
	renamed:    test/handler_functions_websockets_general_test.jl -> test/optional/handler_functions_websockets_general_test.jl
	renamed:    test/handler_functions_websockets_subprotocol_test.jl -> test/optional/handler_functions_websockets_subprotocol_test.jl
	renamed:    test/phantom.js -> test/optional/phantom.js
  • Loading branch information
hustf committed Jun 10, 2018
1 parent cca4849 commit 89cf5d1
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 228 deletions.
2 changes: 1 addition & 1 deletion benchmark/bce.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>WS text</title>
</head>
<body>
Expand Down
211 changes: 0 additions & 211 deletions test/HttpServer.jl

This file was deleted.

21 changes: 15 additions & 6 deletions test/browsertest.html → test/optional/browsertest.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>WS text</title>
</head>
<body>
Expand All @@ -27,12 +27,21 @@

<script>

function uuid4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
var hex = [];

for (var i = 0; i < 256; i++) {
hex[i] = (i < 16 ? '0' : '') + (i).toString(16);
}

// note this is not formally valid. It is difficult to find a valid function working on all browsers.
function makeUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var id = uuid4();

var id = makeUUID();

var exitmsg = "Close, wait, and navigate to: browsertest2.html"

Expand Down
21 changes: 18 additions & 3 deletions test/browsertest.jl → test/optional/browsertest.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
# Included in runtests at the end.
# Can also be run directly.
# These tests are not currently run from runtests.jl

# Tests may currently fail 'randomly' because of the limitations
# of running everything in a single thread, using libuv.
# For example, trying to connect while the websocket is
# busy in a blocking operation can cause timeouts somewhere.
#
# The test set outside of this is now complete, and /benchmark
# is a more effective context for testing the efficiency.
#
# TODO
# 'functions_open_browsers.jl' is an older version
# of the same file name from /benchmark. Using that requires
# some restructuring of this file.
# 'functions_log_test.jl' is an older version of
# /logutils/... Use the new methods.

# Launches available browsers on browsertest.html.
# Websockets are intiated by the browser / web page.
# Handler_functions_websockets respond and store allocations & etc.
# After a successfull exchange, the browsers navigate to a second html page
# for binary performance tests. In the end, all websockets are closed
# and a summary is output.

cd(Pkg.dir("WebSockets","test"))
cd(Pkg.dir("WebSockets", "test", "optional"))
using Compat
using HttpServer
using WebSockets
Expand Down
15 changes: 9 additions & 6 deletions test/browsertest2.html → test/optional/browsertest2.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>WS binary</title>
</head>
<body>
Expand Down Expand Up @@ -33,12 +33,15 @@ <h3>Destination image </h3>

<script>

function uuid4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
// note this is not formally valid. It is difficult to find a valid function working on all browsers.
function makeUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var id = uuid4();

var id = makeUUID();
var recvwidth = 0;
var recvheight = 0;
var recvbyteperpixel = 0;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ end
function open_all_browsers()
info("Try to open browsers")
brs = ["chrome", "firefox", "iexplore", "safari", "phantomjs"]

openbrowsers = 0
for b in brs
openbrowsers += open_testpage(b)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function ws_test_binary(ws::WebSockets.WebSocket)
fill!(view(data, intersect(itpquarter, ired)), 0x88)
rand!(view(data, ired), [0x00, 0x88, 0xff])
hedata = UInt16.([height, width, 4])
clog(id, "Manipulated image and made ready in $(toq()*1000) ms. \n\t\tSending header, then image.\n")
clog(id, "Manipulated image and made ready in $(toq()*1000) ms. \n\t\tSending header, then image.\n")
writeto(id, reinterpret(UInt8, hedata))
writeto(id, data)
else
Expand Down
File renamed without changes.

0 comments on commit 89cf5d1

Please sign in to comment.