diff options
author | Nobuaki Sukegawa <nsukeg@gmail.com> | 2015-09-15 06:21:47 +0900 |
---|---|---|
committer | Nobuaki Sukegawa <nsukeg@gmail.com> | 2016-03-05 08:29:48 +0000 |
commit | 9b804c270d11d34d37c08a5145dba083a6b0c1a7 (patch) | |
tree | a8b8be98b6db51806493921bcfb6592c75a863d8 /tests/auto | |
parent | b021c367e3796d7046797d5b93af2606d30b1ff2 (diff) | |
download | qtwebsockets-9b804c270d11d34d37c08a5145dba083a6b0c1a7.tar.gz |
Add binary message support to QML WebSocket type
Change-Id: I4472e899606d261420141e7b382717cbe12943c8
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml index a8d3225..d0f19f6 100644 --- a/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml +++ b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml @@ -27,7 +27,7 @@ ****************************************************************************/ import QtQuick 2.5 -import QtWebSockets 1.0 +import QtWebSockets 1.1 import QtTest 1.1 Rectangle { @@ -84,5 +84,28 @@ Rectangle { socket.sendTextMessage('hello'); tryCompare(socket, 'status', WebSocket.Error); } + + function test_send_receive_binary() { + ensureConnected(); + + var o = {}; + var sending = new Uint8Array([42, 43]); + server.currentSocket.binaryMessageReceived.connect(function(received) { + var view = new DataView(received); + compare(received.byteLength, sending.length); + compare(view.getUInt8(0), sending[0]); + compare(view.getUInt8(1), sending[1]); + o.called = true; + }); + + socket.sendBinaryMessage(sending.buffer); + tryCompare(o, 'called', true); + } + + function test_send_binary_error_closed() { + ensureDisconnected(); + socket.sendBinaryMessage('hello'); + tryCompare(socket, 'status', WebSocket.Error); + } } } |