diff options
Diffstat (limited to 'tests/qml/data')
-rw-r--r-- | tests/qml/data/bench_init.html | 4 | ||||
-rw-r--r-- | tests/qml/data/disconnect.html | 4 | ||||
-rw-r--r-- | tests/qml/data/grouping.html | 4 | ||||
-rw-r--r-- | tests/qml/data/method.html | 4 | ||||
-rw-r--r-- | tests/qml/data/property.html | 4 | ||||
-rw-r--r-- | tests/qml/data/receiveRaw.html | 6 | ||||
-rw-r--r-- | tests/qml/data/respond.html | 6 | ||||
-rw-r--r-- | tests/qml/data/send.html | 6 | ||||
-rw-r--r-- | tests/qml/data/signal.html | 4 | ||||
-rw-r--r-- | tests/qml/data/testsetup.js | 47 | ||||
-rw-r--r-- | tests/qml/data/wrapper.html | 4 |
11 files changed, 70 insertions, 23 deletions
diff --git a/tests/qml/data/bench_init.html b/tests/qml/data/bench_init.html index cb1b488..7d3af5b 100644 --- a/tests/qml/data/bench_init.html +++ b/tests/qml/data/bench_init.html @@ -1,10 +1,10 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) {}); + createWebChannel(function(channel) {}); //END SETUP </script> </head> diff --git a/tests/qml/data/disconnect.html b/tests/qml/data/disconnect.html index dc771b9..a9a479c 100644 --- a/tests/qml/data/disconnect.html +++ b/tests/qml/data/disconnect.html @@ -1,10 +1,10 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { myObj.mySignal.connect(function(arg) { channel.exec({label: "mySignalReceived", args: [arg]}); myObj.mySignal.disconnect(this); diff --git a/tests/qml/data/grouping.html b/tests/qml/data/grouping.html index 2a6c158..60fa0f8 100644 --- a/tests/qml/data/grouping.html +++ b/tests/qml/data/grouping.html @@ -1,10 +1,10 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - window.channel = new QWebChannel(baseUrl, function(channel) { + window.channel = createWebChannel(function(channel) { channel.subscribe("Qt.propertyUpdate", function() { channel.exec({label: "gotPropertyUpdate", values: [myObj.myProperty(), myOtherObj.foo(), myOtherObj.bar()]}); }); diff --git a/tests/qml/data/method.html b/tests/qml/data/method.html index 04048a6..6dbaa90 100644 --- a/tests/qml/data/method.html +++ b/tests/qml/data/method.html @@ -1,10 +1,10 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { channel.subscribe("invokeMethod", function(arg) { myObj.myMethod(arg); }); diff --git a/tests/qml/data/property.html b/tests/qml/data/property.html index 5d03118..9565aaa 100644 --- a/tests/qml/data/property.html +++ b/tests/qml/data/property.html @@ -1,10 +1,10 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { channel.exec({label: "init", value: myObj.myProperty()}); myObj.myPropertyChanged.connect(function() { channel.exec({label: "changed", value: myObj.myProperty()}); diff --git a/tests/qml/data/receiveRaw.html b/tests/qml/data/receiveRaw.html index 7c98bab..139b2b1 100644 --- a/tests/qml/data/receiveRaw.html +++ b/tests/qml/data/receiveRaw.html @@ -1,12 +1,12 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { channel.send("foobar"); - }, true); + }, true /* raw */); //END SETUP </script> </head> diff --git a/tests/qml/data/respond.html b/tests/qml/data/respond.html index 6c8db0d..5f0e7fc 100644 --- a/tests/qml/data/respond.html +++ b/tests/qml/data/respond.html @@ -1,14 +1,14 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { channel.exec("foobar", function(response) { channel.send("received:"+response); }); - }, true); + }, true /* raw */); //END SETUP </script> </head> diff --git a/tests/qml/data/send.html b/tests/qml/data/send.html index 7d601a8..c60fbf4 100644 --- a/tests/qml/data/send.html +++ b/tests/qml/data/send.html @@ -1,14 +1,14 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { channel.subscribe("myMessage", function(payload) { channel.send("myMessagePong:" + payload); }); - }, true); + }, true /* raw */); //END SETUP </script> </head> diff --git a/tests/qml/data/signal.html b/tests/qml/data/signal.html index 92b0ed5..bdce0c7 100644 --- a/tests/qml/data/signal.html +++ b/tests/qml/data/signal.html @@ -1,10 +1,10 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { myObj.mySignal.connect(function(arg) { channel.exec({label: "signalReceived", value: arg}); }); diff --git a/tests/qml/data/testsetup.js b/tests/qml/data/testsetup.js new file mode 100644 index 0000000..c0db83a --- /dev/null +++ b/tests/qml/data/testsetup.js @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebChannel module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +window.createWebChannel = function(callback, raw) +{ + var baseUrlMatch = /[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search); + var transport = baseUrlMatch ? baseUrlMatch[1] : navigator.qt; + return new QWebChannel(transport, callback, raw); +} diff --git a/tests/qml/data/wrapper.html b/tests/qml/data/wrapper.html index 9c4386c..a556486 100644 --- a/tests/qml/data/wrapper.html +++ b/tests/qml/data/wrapper.html @@ -1,10 +1,10 @@ <html> <head> <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script> + <script type="text/javascript" src="testsetup.js"></script> <script type="text/javascript"> //BEGIN SETUP - var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]); - new QWebChannel(baseUrl, function(channel) { + createWebChannel(function(channel) { myFactory.create("testObj", function(obj) { window[obj.objectName()] = obj; obj.mySignal.connect(function(arg1, arg2) { |