From f0ceecaf0b51809a076ed0add159c95cada528bf Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 23 May 2015 11:53:42 +0200 Subject: Improve Control::background automatic resizing - width follows only if x and width are both not specified - height follows only if y and height are both not specified Change-Id: Ib881daa9da339baac53f7f9d4de6e5bdad7723e2 Reviewed-by: J-P Nurmi --- tests/auto/controls/data/tst_control.qml | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml index 3d46ff16..da0a979c 100644 --- a/tests/auto/controls/data/tst_control.qml +++ b/tests/auto/controls/data/tst_control.qml @@ -129,4 +129,50 @@ TestCase { control.destroy() } + + function test_background() { + var control = component.createObject(testCase) + + control.background = component.createObject(control) + + // background has no x or width set, so its width follows control's width + control.width = 320 + compare(control.background.width, control.width) + + // background has no y or height set, so its height follows control's height + compare(control.background.height, control.height) + control.height = 240 + + // has width => width does not follow + control.background.width /= 2 + control.width += 20 + verify(control.background.width !== control.width) + + // reset width => width follows again + control.background.width = undefined + control.width += 20 + compare(control.background.width, control.width) + + // has x => width does not follow + control.background.x = 10 + control.width += 20 + verify(control.background.width !== control.width) + + // has height => height does not follow + control.background.height /= 2 + control.height -= 20 + verify(control.background.height !== control.height) + + // reset height => height follows again + control.background.height = undefined + control.height -= 20 + compare(control.background.height, control.height) + + // has y => height does not follow + control.background.y = 10 + control.height -= 20 + verify(control.background.height !== control.height) + + control.destroy() + } } -- cgit v1.2.3