From fa766648b234c65b9025ad62f3a29eb83d89ae8f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 16 Dec 2016 15:19:24 +0100 Subject: tst_page: use TestCase's new createTemporaryObject functions This ensures that the appropriate objects are destroyed at the end of each test function, even if the test fails. Change-Id: I7f61bb8da4b89af8fd3e5f508fe1a683484e799f Reviewed-by: J-P Nurmi --- tests/auto/controls/data/tst_page.qml | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_page.qml index 9b52236e..e49fba6b 100644 --- a/tests/auto/controls/data/tst_page.qml +++ b/tests/auto/controls/data/tst_page.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -106,54 +106,46 @@ TestCase { } function test_empty() { - var control = page.createObject(testCase) + var control = createTemporaryObject(page, testCase) verify(control) verify(control.contentItem) compare(control.contentWidth, 0) compare(control.contentHeight, 0) - - control.destroy() } function test_oneChild() { - var control = oneChildPage.createObject(testCase) + var control = createTemporaryObject(oneChildPage, testCase) verify(control) compare(control.contentWidth, 100) compare(control.contentHeight, 30) compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) - - control.destroy() } function test_twoChildren() { - var control = twoChildrenPage.createObject(testCase) + var control = createTemporaryObject(twoChildrenPage, testCase) verify(control) compare(control.contentWidth, 0) compare(control.contentHeight, 0) compare(control.implicitWidth, control.leftPadding + control.rightPadding) compare(control.implicitHeight, control.topPadding + control.bottomPadding) - - control.destroy() } function test_contentItem() { - var control = contentPage.createObject(testCase) + var control = createTemporaryObject(contentPage, testCase) verify(control) compare(control.contentWidth, 100) compare(control.contentHeight, 30) compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) - - control.destroy() } function test_layout() { - var control = page.createObject(testCase, {width: 100, height: 100}) + var control = createTemporaryObject(page, testCase, {width: 100, height: 100}) verify(control) compare(control.width, 100) @@ -223,8 +215,6 @@ TestCase { control.footer.implicitWidth = 160 compare(control.implicitWidth, control.footer.implicitWidth + control.leftPadding + control.rightPadding) - - control.destroy() } function test_spacing_data() { @@ -240,7 +230,7 @@ TestCase { } function test_spacing(data) { - var control = page.createObject(testCase, {spacing: 20, width: 100, height: 100}) + var control = createTemporaryObject(page, testCase, {spacing: 20, width: 100, height: 100}) verify(control) control.contentItem.visible = data.content @@ -263,7 +253,5 @@ TestCase { compare(control.contentItem.height, control.availableHeight - (data.header ? control.header.height + control.spacing : 0) - (data.footer ? control.footer.height + control.spacing : 0)) - - control.destroy() } } -- cgit v1.2.3