From 7fe2b4a4d9b2c082d08c9380bbcce46ed7527585 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Wed, 10 Apr 2013 11:32:10 +0200 Subject: [PATCH] Testlib: Fix qml objects not deleted in TestCase MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit After destroy() been called in the test function. wait(0) is used to call processEvents(). Task-number: QTBUG-30523 Change-Id: I208f213e2de6b530dd0965b301d046aee0182d9b Reviewed-by: Jan Arve Sæther --- src/imports/testlib/TestCase.qml | 3 ++ tests/auto/qmltest/selftests/tst_destroy.qml | 62 ++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/auto/qmltest/selftests/tst_destroy.qml diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index fbfad28..5484d5a 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -682,6 +682,9 @@ Item { qtest_runFunction(prop, null, isBenchmark) } qtest_results.finishTestFunction() + // wait(0) will call processEvents() so objects marked for deletion + // in the test function will be deleted. + wait(0) qtest_results.skipped = false } diff --git a/tests/auto/qmltest/selftests/tst_destroy.qml b/tests/auto/qmltest/selftests/tst_destroy.qml new file mode 100644 index 0000000..b2a473d --- /dev/null +++ b/tests/auto/qmltest/selftests/tst_destroy.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +import QtQuick 2.1 +import QtTest 1.0 + +TestCase { + id: testCase + width: 100 + height: 100 + name: "SelfTests_Destroy" + + function test_a_QTBUG_30523() { + compare(testCase.children.length, 0) + var tmp = Qt.createQmlObject('import QtQuick 2.1; Rectangle {width: 20; height: 20;}', testCase, '') + compare(testCase.children.length, 1) + tmp.destroy() + } + + function test_b_QTBUG_30523() { + // The object created in test above should be deleted + compare(testCase.children.length, 0) + } +} -- 2.7.4