From 6451f4e594cd8c41b7cadb109a25fb75d7e2fd7a Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 16 Feb 2011 15:50:31 +0100 Subject: Added CheckBox tests Merge-request: 282 Reviewed-by: Jens Bache-Wiig --- tests/auto/SpecCheckBox.qml | 62 +++++++++++++++++++++++++++++++++++++++ tests/auto/tst_CheckBox.qml | 70 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 tests/auto/SpecCheckBox.qml create mode 100644 tests/auto/tst_CheckBox.qml (limited to 'tests') diff --git a/tests/auto/SpecCheckBox.qml b/tests/auto/SpecCheckBox.qml new file mode 100644 index 00000000..bf1acd50 --- /dev/null +++ b/tests/auto/SpecCheckBox.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components API Conformance Test Suite. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +import QtQuick 1.0 +import "../../components" + +QtObject { + property Component raw: + Component { + CheckBox { + } + } + + property Component api: + Component { + QtObject { + property bool checked + property bool pressed + + signal clicked + } + } + + property Component defaults: + Component { + CheckBox { + checked: false + pressed: false + } + } + + property Component basic: + Component { + CheckBox { + width: 200 + height: 200 + } + } +} diff --git a/tests/auto/tst_CheckBox.qml b/tests/auto/tst_CheckBox.qml new file mode 100644 index 00000000..626e26b2 --- /dev/null +++ b/tests/auto/tst_CheckBox.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Components API Conformance Test Suite. +** +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions contained +** in the Technology Preview License Agreement accompanying this package. +** +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +****************************************************************************/ + +import QtQuick 1.0 +import QtQuickTest 1.0 + +ComponentTestCase { + name: "CheckBox" + + SpecCheckBox { + id: testSubject + } + + SignalSpy { + id: spy + signalName: "clicked" + } + + function test_clicked() { + spy.target = obj; + + var message = + "Clicking on the Checkbox must emit the signal clicked()."; + mouseClick(obj, obj.width / 2, obj.height / 2); + mouseClick(obj, obj.width / 2, obj.height / 2); + mouseClick(obj, obj.width / 2, obj.height / 2); + compare(spy.count, 3, message); + } + + function test_checked() { + var message = + "Clicking on the Checkbox should change the checked value."; + mouseClick(obj, obj.width / 2, obj.height / 2); + compare(obj.checked, true, message); + mouseClick(obj, obj.width / 2, obj.height / 2); + compare(obj.checked, false, message); + } + + function test_pressed() { + var message = + "Pressing and releasing the mouse must change pressed property."; + mousePress(obj, obj.width / 2, obj.height / 2); + compare(obj.pressed, true, message); + mouseRelease(obj, obj.width / 2, obj.height / 2); + compare(obj.pressed, false, message); + } +} -- cgit v1.2.1