summaryrefslogtreecommitdiffstats
path: root/examples/tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tutorial')
-rw-r--r--examples/tutorial/main.cpp53
-rw-r--r--examples/tutorial/tests/01_parts/PartsTest.qml59
-rw-r--r--examples/tutorial/tests/02_validate/ValidateTest.qml55
-rw-r--r--examples/tutorial/tests/03_applicationUnderTest/ApplicationUnderTest.qml75
-rw-r--r--examples/tutorial/tests/04_findItem/FindItemTest.qml70
-rw-r--r--examples/tutorial/tests/04_findItem/TenPinTest.qml70
-rw-r--r--examples/tutorial/tests/05_input/InputTest.qml79
-rw-r--r--examples/tutorial/tests/05_input/TenPinTest.qml70
-rw-r--r--examples/tutorial/tests/06_data/InputTest.qml93
-rw-r--r--examples/tutorial/tests/06_data/InputTests.qml105
-rw-r--r--examples/tutorial/tests/06_data/TenPinTest.qml70
-rw-r--r--examples/tutorial/tpframe.cpp173
-rw-r--r--examples/tutorial/tpframe.h100
-rw-r--r--examples/tutorial/tpframe.ui357
-rw-r--r--examples/tutorial/tpframeball.cpp184
-rw-r--r--examples/tutorial/tpframeball.h102
-rw-r--r--examples/tutorial/tpgame.cpp75
-rw-r--r--examples/tutorial/tpgame.h63
-rw-r--r--examples/tutorial/tutorial.pro18
19 files changed, 1871 insertions, 0 deletions
diff --git a/examples/tutorial/main.cpp b/examples/tutorial/main.cpp
new file mode 100644
index 0000000..b7928ae
--- /dev/null
+++ b/examples/tutorial/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "tpgame.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ a.setApplicationName("tenpinGame");
+ TPGame w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/tutorial/tests/01_parts/PartsTest.qml b/examples/tutorial/tests/01_parts/PartsTest.qml
new file mode 100644
index 0000000..7570353
--- /dev/null
+++ b/examples/tutorial/tests/01_parts/PartsTest.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtSystemTest 1.0
+
+Test {
+ name: 'Parts'
+ description: 'Demonstrates parts of a test object'
+
+ function setup() {
+ print( "Init test function." );
+ }
+
+ function run() {
+ print( "Hello World!" );
+ }
+
+ function cleanup() {
+ print( "Finalize test function." );
+ }
+}
diff --git a/examples/tutorial/tests/02_validate/ValidateTest.qml b/examples/tutorial/tests/02_validate/ValidateTest.qml
new file mode 100644
index 0000000..f701dcc
--- /dev/null
+++ b/examples/tutorial/tests/02_validate/ValidateTest.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtSystemTest 1.0
+
+Test {
+ name: 'Validate'
+ description: 'Demonstrates validating values'
+
+ function run() {
+ var count = 3;
+
+ expect(count).toBe(3);
+ expect(count).not.toBe(2);
+ expect(count).toBeBetween(2, 4);
+ }
+}
diff --git a/examples/tutorial/tests/03_applicationUnderTest/ApplicationUnderTest.qml b/examples/tutorial/tests/03_applicationUnderTest/ApplicationUnderTest.qml
new file mode 100644
index 0000000..e1d6150
--- /dev/null
+++ b/examples/tutorial/tests/03_applicationUnderTest/ApplicationUnderTest.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+
+Test {
+ name: 'Start Application'
+ description: 'Start an existing application'
+
+ property string executableName: 'tenpinGame'
+ property Application app
+ property alias remote: host
+
+ remotes: [
+ Remote {
+ id: host
+ host: config.remotes.localhost.address
+ }
+ ]
+
+ function setup() {
+ expect(executableName).not.toBe('');
+ app = host.startApplication(executableName);
+ }
+
+ function run() {
+ var game = app.item({
+ inherits: 'TPGame'
+ });
+ expect(game).not.toBe(undefined);
+ }
+
+ function cleanup() {
+ app.terminate();
+ }
+}
diff --git a/examples/tutorial/tests/04_findItem/FindItemTest.qml b/examples/tutorial/tests/04_findItem/FindItemTest.qml
new file mode 100644
index 0000000..505b753
--- /dev/null
+++ b/examples/tutorial/tests/04_findItem/FindItemTest.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+
+TenPinTest {
+ function data() {}
+
+ function setup() {
+ startApplication();
+
+ data.main = app.items({inherits: 'TPFrame'})[0];
+ expect(data.main).not.toBe(null);
+ expect(data.main).not.toBe(undefined);
+
+ data.first = data.main.descendants({inherits: 'TPFrameBall'})[0];
+ expect(data.first).not.toBe(null);
+ data.second = data.main.descendants({inherits: 'TPFrameBall'})[1];
+ expect(data.second).not.toBe(null);
+ }
+
+ function run() {
+ expect(data.main.property('display')).toBe('');
+ expect(data.first.property('display')).toBe('');
+ expect(data.second.property('display')).toBe('');
+ }
+
+ function cleanup() {
+ terminateApplication();
+ }
+}
diff --git a/examples/tutorial/tests/04_findItem/TenPinTest.qml b/examples/tutorial/tests/04_findItem/TenPinTest.qml
new file mode 100644
index 0000000..961321d
--- /dev/null
+++ b/examples/tutorial/tests/04_findItem/TenPinTest.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+
+Test {
+ name: 'Start Application'
+ description: 'Start an existing application'
+
+ property string executableName: 'tenpinGame'
+ property alias remote: host
+
+ property Application app
+
+ remotes: [
+ Remote {
+ id: host
+ host: config.remotes.localhost.address
+ }
+ ]
+
+ function startApplication() {
+ expect(executableName).not.toBe('');
+ app = host.startApplication(executableName);
+ expect(app).not.toBe(null);
+ }
+
+ function terminateApplication() {
+ app.terminate();
+ }
+}
diff --git a/examples/tutorial/tests/05_input/InputTest.qml b/examples/tutorial/tests/05_input/InputTest.qml
new file mode 100644
index 0000000..ddfabd1
--- /dev/null
+++ b/examples/tutorial/tests/05_input/InputTest.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+
+TenPinTest {
+ function data() {}
+
+ function setup() {
+ startApplication();
+
+ data.main = app.items({inherits: 'TPFrame'})[0];
+ expect(data.main).not.toBe(null);
+ expect(data.main).not.toBe(undefined);
+
+ data.first = data.main.descendants({inherits: 'TPFrameBall'})[0];
+ expect(data.first).not.toBe(null);
+ data.second = data.main.descendants({inherits: 'TPFrameBall'})[1];
+ expect(data.second).not.toBe(null);
+ }
+
+ function run() {
+ expect(data.first.property('display')).toBe('');
+ expect(data.second.property('display')).toBe('');
+ expect(data.main.property('display')).toBe('');
+
+ app.mouseClick(data.first);
+ app.keyPress(Qt.Key_3);
+ app.mouseClick(data.second);
+ app.keyPress(Qt.Key_6);
+
+ expect(data.first.property('display')).toBe('3');
+ expect(data.second.property('display')).toBe('6');
+ expect(data.main.property('display')).toBe('9');
+ }
+
+ function cleanup() {
+ terminateApplication();
+ }
+}
diff --git a/examples/tutorial/tests/05_input/TenPinTest.qml b/examples/tutorial/tests/05_input/TenPinTest.qml
new file mode 100644
index 0000000..961321d
--- /dev/null
+++ b/examples/tutorial/tests/05_input/TenPinTest.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+
+Test {
+ name: 'Start Application'
+ description: 'Start an existing application'
+
+ property string executableName: 'tenpinGame'
+ property alias remote: host
+
+ property Application app
+
+ remotes: [
+ Remote {
+ id: host
+ host: config.remotes.localhost.address
+ }
+ ]
+
+ function startApplication() {
+ expect(executableName).not.toBe('');
+ app = host.startApplication(executableName);
+ expect(app).not.toBe(null);
+ }
+
+ function terminateApplication() {
+ app.terminate();
+ }
+}
diff --git a/examples/tutorial/tests/06_data/InputTest.qml b/examples/tutorial/tests/06_data/InputTest.qml
new file mode 100644
index 0000000..1b6610f
--- /dev/null
+++ b/examples/tutorial/tests/06_data/InputTest.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+
+TenPinTest {
+ name: 'Input Test'
+ description: 'Add some ball values and validate displays'
+
+ property variant firstEntry: ['3']
+ property variant secondEntry: ['6']
+
+ property string first: '3'
+ property string second: '6'
+ property string display: '9'
+
+ function data() {}
+
+ function setup() {
+ startApplication();
+
+ data.main = app.items({inherits: 'TPFrame'})[0];
+ expect(data.main).not.toBe(null);
+ expect(data.main).not.toBe(undefined);
+
+ data.first = data.main.descendants({inherits: 'TPFrameBall'})[0];
+ expect(data.first).not.toBe(null);
+ data.second = data.main.descendants({inherits: 'TPFrameBall'})[1];
+ expect(data.second).not.toBe(null);
+ }
+
+ function run() {
+ expect(data.first.property('display')).toBe('');
+ expect(data.second.property('display')).toBe('');
+ expect(data.main.property('display')).toBe('');
+
+ app.mouseClick(data.first);
+ firstEntry.forEach(function(item) {
+ app.keyPress(item);
+ });
+ app.mouseClick(data.second);
+ secondEntry.forEach(function(item) {
+ app.keyPress(item);
+ });
+
+ expect(data.first.property('display')).toBe(first);
+ expect(data.second.property('display')).toBe(second);
+ expect(data.main.property('display')).toBe(display);
+ }
+
+ function cleanup() {
+ terminateApplication();
+ }
+}
diff --git a/examples/tutorial/tests/06_data/InputTests.qml b/examples/tutorial/tests/06_data/InputTests.qml
new file mode 100644
index 0000000..d76a8a2
--- /dev/null
+++ b/examples/tutorial/tests/06_data/InputTests.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtSystemTest 1.0
+
+TestCollection {
+ name: 'Input test collection'
+ description: 'enter various values for first frame and validate display'
+
+ InputTest {
+ name: 'Gutter Ball'
+ firstEntry: ['0']
+ secondEntry: ['0']
+
+ first: '0'
+ second: '0'
+ display: '0'
+ }
+ InputTest {
+ name: 'Strike'
+
+ firstEntry: ['1', '0']
+ secondEntry: []
+
+ first: 'X'
+ second: ''
+ display: ''
+ }
+ InputTest {
+ name: 'Three Seven Spare'
+
+ firstEntry: ['3']
+ secondEntry: ['7']
+
+ first: '3'
+ second: '/'
+ display: ''
+ }
+ InputTest {
+ name: 'Three Zero'
+ firstEntry: ['3']
+ secondEntry: ['0']
+
+ first: '3'
+ second: '0'
+ display: '3'
+ }
+ InputTest {
+ name: 'Zero Ten Spare'
+
+ firstEntry: ['0']
+ secondEntry: ['1', '0']
+
+ first: '0'
+ second: '/'
+ display: ''
+ }
+ InputTest {
+ name: 'Zero Three'
+ firstEntry: ['0']
+ secondEntry: ['3']
+
+ first: '0'
+ second: '3'
+ display: '3'
+ }
+}
diff --git a/examples/tutorial/tests/06_data/TenPinTest.qml b/examples/tutorial/tests/06_data/TenPinTest.qml
new file mode 100644
index 0000000..961321d
--- /dev/null
+++ b/examples/tutorial/tests/06_data/TenPinTest.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+
+Test {
+ name: 'Start Application'
+ description: 'Start an existing application'
+
+ property string executableName: 'tenpinGame'
+ property alias remote: host
+
+ property Application app
+
+ remotes: [
+ Remote {
+ id: host
+ host: config.remotes.localhost.address
+ }
+ ]
+
+ function startApplication() {
+ expect(executableName).not.toBe('');
+ app = host.startApplication(executableName);
+ expect(app).not.toBe(null);
+ }
+
+ function terminateApplication() {
+ app.terminate();
+ }
+}
diff --git a/examples/tutorial/tpframe.cpp b/examples/tutorial/tpframe.cpp
new file mode 100644
index 0000000..bd71d0a
--- /dev/null
+++ b/examples/tutorial/tpframe.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tpframe.h"
+#include "ui_tpframe.h"
+
+#include <QDebug>
+
+TPFrame::TPFrame(QWidget *parent) :
+ QFrame(parent),
+ ui(new Ui::TPFrame),
+ m_previous(0),
+ m_next(0),
+ m_score(-1)
+{
+ ui->setupUi(this);
+ connect(ui->firstBall, SIGNAL(ballChanged(int)), ui->secondBall, SLOT(setPreviousBall(int)));
+
+ connect(ui->firstBall, SIGNAL(scoreChanged(int)), this, SIGNAL(ballsChanged()));
+ connect(ui->secondBall, SIGNAL(scoreChanged(int)), this, SIGNAL(ballsChanged()));
+ connect(ui->thirdBall, SIGNAL(scoreChanged(int)), this, SIGNAL(ballsChanged()));
+
+ connect(this, SIGNAL(ballsChanged()), this, SLOT(updateScore()));
+}
+
+TPFrame::~TPFrame()
+{
+ delete ui;
+}
+
+int TPFrame::first() const
+{
+ return ui->firstBall->ball();
+}
+
+int TPFrame::second() const
+{
+ if (m_next)
+ return ui->firstBall->isStrike() ? m_next->first() : ui->secondBall->ball();
+ return ui->secondBall->ball();
+}
+
+int TPFrame::third() const
+{
+ if (m_next)
+ return ui->firstBall->isStrike() ? m_next->second() : m_next->first();
+ return ui->thirdBall->ball();
+}
+
+int TPFrame::runningTotal() const
+{
+ if (m_previous) {
+ int prevTotal = m_previous->runningTotal();
+ if (prevTotal != -1 && m_score != -1)
+ return prevTotal + m_score;
+ return -1;
+ }
+ return m_score;
+}
+
+void TPFrame::setPreviousFrame(TPFrame *frame)
+{
+ if (m_previous)
+ disconnect(m_previous, 0, this, 0);
+
+ m_previous = frame;
+
+ if (m_previous) {
+ connect(m_previous, SIGNAL(runningTotalChanged(int)), this, SLOT(updateTotal()));
+ updateTotal();
+ }
+}
+
+void TPFrame::setNextFrame(TPFrame *frame)
+{
+ if (m_next)
+ disconnect(m_next, 0, this, 0);
+
+ m_next = frame;
+
+ if (m_next) {
+ ui->firstBall->setLastFrame(false);
+ ui->secondBall->setLastFrame(false);
+ ui->thirdBall->setLastFrame(false);
+ ui->thirdBall->hide();
+ connect(m_next, SIGNAL(ballsChanged()), this, SIGNAL(ballsChanged()));
+ } else {
+ ui->firstBall->setLastFrame(true);
+ ui->secondBall->setLastFrame(true);
+ ui->thirdBall->setLastFrame(true);
+ ui->thirdBall->show();
+ }
+}
+
+void TPFrame::reset()
+{
+ ui->firstBall->setBall(-1);
+ ui->secondBall->setBall(-1);
+ ui->thirdBall->setBall(-1);
+}
+
+void TPFrame::updateScore()
+{
+ int score = -1;
+ int f = first();
+ int s = second();
+ int t = third();
+ if (ui->firstBall->isStrike()) {
+ if (s != -1 && t != -1)
+ score = 10 + s + t;
+ } else if (ui->secondBall->isSpare()) {
+ if (t != -1)
+ score = 10 + t;
+ } else {
+ if (f != -1 && s != -1)
+ score = f + s;
+ }
+ if (score == m_score)
+ return;
+ m_score = score;
+ emit scoreChanged(m_score);
+ updateTotal();
+}
+
+void TPFrame::updateTotal()
+{
+ int total = runningTotal();
+ emit runningTotalChanged(total);
+ ui->frameDisplay->setText(total == -1 ? QString() : QString::number(total));
+}
+
+QString TPFrame::display() const
+{
+ return ui->frameDisplay->text();
+}
diff --git a/examples/tutorial/tpframe.h b/examples/tutorial/tpframe.h
new file mode 100644
index 0000000..e0416ba
--- /dev/null
+++ b/examples/tutorial/tpframe.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TPFRAME_H
+#define TPFRAME_H
+
+#include <QFrame>
+
+namespace Ui {
+class TPFrame;
+}
+
+class TPFrame : public QFrame
+{
+ Q_OBJECT
+ Q_PROPERTY(int first READ first DESIGNABLE false STORED false)
+ Q_PROPERTY(int second READ second DESIGNABLE false STORED false)
+ Q_PROPERTY(int third READ third DESIGNABLE false STORED false)
+ Q_PROPERTY(int score READ score NOTIFY scoreChanged DESIGNABLE false STORED false)
+ Q_PROPERTY(QString display READ display DESIGNABLE false STORED false)
+ Q_PROPERTY(int runningTotal READ runningTotal NOTIFY runningTotalChanged DESIGNABLE false STORED false)
+
+ Q_PROPERTY(TPFrame *previousFrame READ previousFrame WRITE setPreviousFrame DESIGNABLE false STORED false)
+ Q_PROPERTY(TPFrame *nextFrame READ nextFrame WRITE setNextFrame DESIGNABLE false STORED false)
+
+public:
+ explicit TPFrame(QWidget *parent = 0);
+ ~TPFrame();
+
+ int first() const;
+ int second() const;
+ int third() const;
+ int score() const { return m_score; }
+ int runningTotal() const;
+ QString display() const;
+
+ TPFrame *previousFrame() const { return m_previous; }
+ TPFrame *nextFrame() const { return m_next; }
+
+ void setPreviousFrame(TPFrame *);
+ void setNextFrame(TPFrame *);
+
+public slots:
+ void reset();
+
+signals:
+ void runningTotalChanged(int);
+ void scoreChanged(int);
+ void ballsChanged();
+
+private slots:
+ void updateScore();
+ void updateTotal();
+
+private:
+ Ui::TPFrame *ui;
+ TPFrame *m_previous;
+ TPFrame *m_next;
+ int m_score;
+};
+
+#endif // TPFRAME_H
diff --git a/examples/tutorial/tpframe.ui b/examples/tutorial/tpframe.ui
new file mode 100644
index 0000000..6795608
--- /dev/null
+++ b/examples/tutorial/tpframe.ui
@@ -0,0 +1,357 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TPFrame</class>
+ <widget class="QFrame" name="TPFrame">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>170</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Mid">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>170</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>170</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Mid">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>170</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>20</red>
+ <green>19</green>
+ <blue>18</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Mid">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>20</red>
+ <green>19</green>
+ <blue>18</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="horizontalSpacing">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>56</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="2">
+ <widget class="TPFrameBall" name="secondBall" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="TPFrameBall" name="firstBall" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="TPFrameBall" name="thirdBall" native="true">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="3">
+ <widget class="QLabel" name="frameDisplay">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>20</red>
+ <green>19</green>
+ <blue>18</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>20</red>
+ <green>19</green>
+ <blue>18</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>TPFrameBall</class>
+ <extends>QWidget</extends>
+ <header>tpframeball.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/tutorial/tpframeball.cpp b/examples/tutorial/tpframeball.cpp
new file mode 100644
index 0000000..d69884a
--- /dev/null
+++ b/examples/tutorial/tpframeball.cpp
@@ -0,0 +1,184 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tpframeball.h"
+#include <QKeyEvent>
+#include <QPainter>
+#include <QPaintEvent>
+#include <QTextOption>
+
+#include <QDebug>
+
+TPFrameBall::TPFrameBall(QWidget *parent) :
+ QWidget(parent),
+ m_score(-1),
+ m_ball(-1),
+ m_previousBall(-1),
+ m_lastFrame(true)
+{
+ setFocusPolicy(Qt::StrongFocus);
+}
+
+void TPFrameBall::setBall(int value)
+{
+ if (value < 0 || value > 10)
+ value = -1;
+ if (value == m_ball)
+ return;
+ m_ball = value;
+ emit ballChanged(m_ball);
+ updateScore();
+}
+
+void TPFrameBall::setPreviousBall(int value)
+{
+ if (value < 0 || value > 10)
+ value = -1;
+ if (m_lastFrame && value == 10)
+ value = -1;
+ if (value == m_previousBall)
+ return;
+ m_previousBall = value;
+ updateScore();
+}
+
+void TPFrameBall::mousePressEvent(QMouseEvent *event)
+{
+ Q_UNUSED(event);
+ setFocus();
+}
+
+void TPFrameBall::keyPressEvent(QKeyEvent *event)
+{
+ switch(event->key()) {
+ case Qt::Key_0:
+ if (m_ball == 1)
+ setBall(10);
+ else
+ setBall(0);
+ break;
+ case Qt::Key_1:
+ case Qt::Key_2:
+ case Qt::Key_3:
+ case Qt::Key_4:
+ case Qt::Key_5:
+ case Qt::Key_6:
+ case Qt::Key_7:
+ case Qt::Key_8:
+ case Qt::Key_9:
+ setBall(event->key() - Qt::Key_0);
+ break;
+ case Qt::Key_Backspace:
+ if (m_ball == 10)
+ setBall(1);
+ else
+ setBall(-1);
+ break;
+ case Qt::Key_X:
+ setBall(10);
+ break;
+ case Qt::Key_Slash:
+ if (m_previousBall != -1)
+ setBall(10 - m_previousBall);
+ break;
+ default:
+ break;
+ }
+}
+
+void TPFrameBall::updateScore()
+{
+ int score = -1;
+ if (m_ball != -1 && m_previousBall != -1)
+ score = m_ball + m_previousBall;
+ else if (m_ball != -1)
+ score = m_ball;
+
+ if (m_score != score) {
+ m_score = score;
+ emit scoreChanged(m_score);
+ }
+
+ QString text;
+ if (isStrike())
+ text = QString::fromLatin1("X");
+ else if (isSpare())
+ text = QString::fromLatin1("/");
+ else if (m_ball == -1)
+ text = QString();
+ else if (m_score < 0 || m_score > 10)
+ text = tr("E", "Error letter, not X or /");
+ else
+ text = QString::number(m_ball);
+
+ if (text != m_display) {
+ m_display = text;
+ update();
+ }
+}
+
+void TPFrameBall::paintEvent(QPaintEvent *event)
+{
+ QPainter p(this);
+ p.setClipRect(event->rect());
+
+ QPen pen(Qt::red);
+ QBrush brush(hasFocus() ? Qt::blue : Qt::black);
+ p.setPen(pen);
+ p.setBrush(brush);
+ p.drawRect(0, 0, width(), height()-1);
+
+ pen.setColor(Qt::white);
+ QFont f = font();
+ f.setWeight(QFont::Bold);
+ p.setPen(pen);
+ p.drawText(0, 0, width(), height(), Qt::AlignHCenter | Qt::AlignVCenter, m_display);
+}
+
+void TPFrameBall::focusInEvent(QFocusEvent *)
+{
+ update();
+}
+
+void TPFrameBall::focusOutEvent(QFocusEvent *)
+{
+ update();
+}
diff --git a/examples/tutorial/tpframeball.h b/examples/tutorial/tpframeball.h
new file mode 100644
index 0000000..bf9602e
--- /dev/null
+++ b/examples/tutorial/tpframeball.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TPBALL_H
+#define TPBALL_H
+
+#include <QWidget>
+
+#include <QDebug>
+
+class QLabel;
+
+class TPFrameBall : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(int ball READ ball WRITE setBall NOTIFY ballChanged USER true)
+ Q_PROPERTY(int previousBall READ previousBall WRITE setPreviousBall)
+ Q_PROPERTY(int score READ score NOTIFY scoreChanged DESIGNABLE false STORED false)
+ Q_PROPERTY(QString display READ display DESIGNABLE false STORED false)
+ Q_PROPERTY(bool isStrike READ isStrike DESIGNABLE false STORED false)
+ Q_PROPERTY(bool isSpare READ isSpare DESIGNABLE false STORED false)
+ Q_PROPERTY(bool isLastFrame READ isLastFrame WRITE setLastFrame)
+public:
+ explicit TPFrameBall(QWidget *parent = 0);
+
+ QString display() const { return m_display; }
+ int ball() const { return m_ball; }
+ int previousBall() const { return m_previousBall; }
+ int score() const { return m_score; }
+ bool isStrike() const { return m_previousBall == -1 && score() == 10; }
+ bool isSpare() const { return m_previousBall != 10 && score() == 10; }
+ bool isLastFrame() const { return m_lastFrame; }
+ void setLastFrame(bool value) { m_lastFrame = value; updateScore(); }
+
+public slots:
+ void setBall(int);
+ void setPreviousBall(int);
+
+signals:
+ void ballChanged(int);
+ void scoreChanged(int);
+
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void keyPressEvent(QKeyEvent *);
+
+ void paintEvent(QPaintEvent *);
+ void focusInEvent(QFocusEvent *);
+ void focusOutEvent(QFocusEvent *);
+
+private slots:
+ void updateScore();
+
+private:
+ QString m_display;
+ int m_score;
+ int m_ball;
+ int m_previousBall;
+ QLabel *m_label;
+
+ bool m_lastFrame;
+};
+
+#endif // TPBALL_H
diff --git a/examples/tutorial/tpgame.cpp b/examples/tutorial/tpgame.cpp
new file mode 100644
index 0000000..80f2da4
--- /dev/null
+++ b/examples/tutorial/tpgame.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tpgame.h"
+#include "tpframe.h"
+#include <QScrollArea>
+#include <QHBoxLayout>
+
+TPGame::TPGame(QWidget *parent) :
+ QWidget(parent)
+{
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->setMargin(0);
+ layout->setSpacing(0);
+ TPFrame *last = 0;
+ for (int i = 0; i < 10; i++) {
+ TPFrame *frame = new TPFrame;
+ layout->addWidget(frame);
+ m_frames.append(frame);
+ frame->setPreviousFrame(last);
+ if (last)
+ last->setNextFrame(frame);
+ last = frame;
+ }
+ setLayout(layout);
+}
+
+TPGame::~TPGame()
+{
+}
+
+void TPGame::reset()
+{
+ foreach(TPFrame *frame, m_frames) {
+ frame->reset();
+ }
+}
diff --git a/examples/tutorial/tpgame.h b/examples/tutorial/tpgame.h
new file mode 100644
index 0000000..a884211
--- /dev/null
+++ b/examples/tutorial/tpgame.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TENPINGAME_H
+#define TENPINGAME_H
+
+#include <QWidget>
+
+class TPFrame;
+
+class TPGame : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit TPGame(QWidget *parent = 0);
+ ~TPGame();
+
+public slots:
+ void reset();
+private:
+ QList<TPFrame *> m_frames;
+};
+
+#endif // TENPINGAME_H
diff --git a/examples/tutorial/tutorial.pro b/examples/tutorial/tutorial.pro
new file mode 100644
index 0000000..7570b77
--- /dev/null
+++ b/examples/tutorial/tutorial.pro
@@ -0,0 +1,18 @@
+QT += core gui
+
+TARGET = tenpinGame
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ tpframe.cpp \
+ tpframeball.cpp \
+ tpgame.cpp
+
+HEADERS += \
+ tpframe.h \
+ tpframeball.h \
+ tpgame.h
+
+FORMS += \
+ tpframe.ui