aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-10-08 22:27:16 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-10-09 13:18:52 +0000
commit2f902694656d67d671d9a8616060d598a478e7b7 (patch)
treee0cf7e891247d736ebd6737c2d6d9db96c2949cd /tests/auto/controls
parent5e7d7dfc07ea00b53873a6ad5399f2400781f8b9 (diff)
Fix crash in theme code when loading engines in succession
Store global engine specific themes as dynamic properties on the engines themselves. This avoids the problem that storing engines and their themes to a hash map had that destroyed engines and themes were not cleaned up from the hash map. Change-Id: I7330995339c263d456f74d33f6535d5ac7d9d5d4 Task-number: QTBUG-48651 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com> Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'tests/auto/controls')
-rw-r--r--tests/auto/controls/data/tst_theme.qml277
1 files changed, 0 insertions, 277 deletions
diff --git a/tests/auto/controls/data/tst_theme.qml b/tests/auto/controls/data/tst_theme.qml
deleted file mode 100644
index 4f94f2f5..00000000
--- a/tests/auto/controls/data/tst_theme.qml
+++ /dev/null
@@ -1,277 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.2
-import QtQuick.Window 2.2
-import QtTest 1.0
-import Qt.labs.controls 1.0
-
-TestCase {
- id: testCase
- width: 200
- height: 200
- visible: true
- when: windowShown
- name: "Theme"
-
- Component {
- id: button
- Button { }
- }
-
- Component {
- id: themedButton
- Button {
- Theme.accentColor: "#111111"
- Theme.backgroundColor: "#222222"
- Theme.baseColor: "#333333"
- Theme.disabledColor: "#aaaaaa"
- Theme.focusColor: "#444444"
- Theme.frameColor: "#555555"
- Theme.pressColor: "#666666"
- Theme.selectedTextColor: "#777777"
- Theme.selectionColor: "#888888"
- Theme.textColor: "#999999"
- }
- }
-
- Component {
- id: window
- Window { }
- }
-
- Component {
- id: themedWindow
- Window {
- Theme.accentColor: "#111111"
- Theme.backgroundColor: "#222222"
- Theme.baseColor: "#333333"
- Theme.disabledColor: "#aaaaaa"
- Theme.focusColor: "#444444"
- Theme.frameColor: "#555555"
- Theme.pressColor: "#666666"
- Theme.selectedTextColor: "#777777"
- Theme.selectionColor: "#888888"
- Theme.textColor: "#999999"
- }
- }
-
- Component {
- id: loader
- Loader {
- active: false
- sourceComponent: Button { }
- }
- }
-
- function test_defaults() {
- var control = button.createObject(testCase)
- verify(control)
- verify(control.Theme)
- verify(control.Theme.accentColor !== undefined)
- verify(control.Theme.backgroundColor !== undefined)
- verify(control.Theme.baseColor !== undefined)
- verify(control.Theme.disabledColor !== undefined)
- verify(control.Theme.focusColor !== undefined)
- verify(control.Theme.frameColor !== undefined)
- verify(control.Theme.pressColor !== undefined)
- verify(control.Theme.selectedTextColor !== undefined)
- verify(control.Theme.selectionColor !== undefined)
- verify(control.Theme.textColor !== undefined)
- control.destroy()
- }
-
- function test_set() {
- var control = button.createObject(testCase)
- verify(control)
- control.Theme.accentColor = "#111111"
- control.Theme.backgroundColor = "#222222"
- control.Theme.baseColor = "#333333"
- control.Theme.disabledColor = "#aaaaaa"
- control.Theme.focusColor = "#444444"
- control.Theme.frameColor = "#555555"
- control.Theme.pressColor = "#666666"
- control.Theme.selectedTextColor = "#777777"
- control.Theme.selectionColor = "#888888"
- control.Theme.textColor = "#999999"
- compare(control.Theme.accentColor, "#111111")
- compare(control.Theme.backgroundColor, "#222222")
- compare(control.Theme.baseColor, "#333333")
- compare(control.Theme.disabledColor, "#aaaaaa")
- compare(control.Theme.focusColor, "#444444")
- compare(control.Theme.frameColor, "#555555")
- compare(control.Theme.pressColor, "#666666")
- compare(control.Theme.selectedTextColor, "#777777")
- compare(control.Theme.selectionColor, "#888888")
- compare(control.Theme.textColor, "#999999")
- control.destroy()
- }
-
- function test_reset() {
- var control = themedButton.createObject(testCase)
- verify(control)
- compare(control.Theme.accentColor, "#111111")
- compare(control.Theme.backgroundColor, "#222222")
- compare(control.Theme.baseColor, "#333333")
- compare(control.Theme.disabledColor, "#aaaaaa")
- compare(control.Theme.focusColor, "#444444")
- compare(control.Theme.frameColor, "#555555")
- compare(control.Theme.pressColor, "#666666")
- compare(control.Theme.selectedTextColor, "#777777")
- compare(control.Theme.selectionColor, "#888888")
- compare(control.Theme.textColor, "#999999")
- control.Theme.accentColor = undefined
- control.Theme.backgroundColor = undefined
- control.Theme.baseColor = undefined
- control.Theme.disabledColor = undefined
- control.Theme.focusColor = undefined
- control.Theme.frameColor = undefined
- control.Theme.pressColor = undefined
- control.Theme.selectedTextColor = undefined
- control.Theme.selectionColor = undefined
- control.Theme.textColor = undefined
- compare(control.Theme.accentColor, testCase.Theme.accentColor)
- compare(control.Theme.backgroundColor, testCase.Theme.backgroundColor)
- compare(control.Theme.baseColor, testCase.Theme.baseColor)
- compare(control.Theme.disabledColor, testCase.Theme.disabledColor)
- compare(control.Theme.focusColor, testCase.Theme.focusColor)
- compare(control.Theme.frameColor, testCase.Theme.frameColor)
- compare(control.Theme.pressColor, testCase.Theme.pressColor)
- compare(control.Theme.selectedTextColor, testCase.Theme.selectedTextColor)
- compare(control.Theme.selectionColor, testCase.Theme.selectionColor)
- compare(control.Theme.textColor, testCase.Theme.textColor)
- control.destroy()
- }
-
- function test_inheritance_data() {
- return [
- { tag: "accentColor", value1: "#111111", value2: "#101010" },
- { tag: "backgroundColor", value1: "#222222", value2: "#202020" },
- { tag: "baseColor", value1: "#333333", value2: "#303030" },
- { tag: "disabledColor", value1: "#aaaaaa", value2: "#a0a0a0" },
- { tag: "focusColor", value1: "#444444", value2: "#404040" },
- { tag: "frameColor", value1: "#555555", value2: "#505050" },
- { tag: "pressColor", value1: "#666666", value2: "#606060" },
- { tag: "selectedTextColor", value1: "#777777", value2: "#707070" },
- { tag: "selectionColor", value1: "#888888", value2: "#808080" },
- { tag: "textColor", value1: "#999999", value2: "#909090" }
- ]
- }
-
- function test_inheritance(data) {
- var prop = data.tag
- var parent = button.createObject(testCase)
- parent.Theme[prop] = data.value1
- compare(parent.Theme[prop], data.value1)
-
- var child1 = button.createObject(parent)
- compare(child1.Theme[prop], data.value1)
-
- parent.Theme[prop] = data.value2
- compare(parent.Theme[prop], data.value2)
- compare(child1.Theme[prop], data.value2)
-
- var child2 = button.createObject(parent)
- compare(child2.Theme[prop], data.value2)
-
- child2.Theme[prop] = data.value1
- compare(child2.Theme[prop], data.value1)
- compare(child1.Theme[prop], data.value2)
- compare(parent.Theme[prop], data.value2)
-
- parent.Theme[prop] = undefined
- verify(parent.Theme[prop] !== data.value1)
- verify(parent.Theme[prop] !== data.value2)
- verify(parent.Theme[prop] !== undefined)
- compare(child1.Theme[prop], parent.Theme[prop])
- verify(child2.Theme[prop] !== parent.Theme[prop])
-
- var grandChild1 = button.createObject(child1)
- var grandChild2 = button.createObject(child2)
- compare(grandChild1.Theme[prop], child1.Theme[prop])
- compare(grandChild2.Theme[prop], child2.Theme[prop])
-
- var themelessGrandGrandChild = button.createObject(grandChild1)
- var grandGrandGrandChild1 = button.createObject(themelessGrandGrandChild)
- compare(grandGrandGrandChild1.Theme[prop], parent.Theme[prop])
-
- child1.Theme[prop] = data.value2
- verify(parent.Theme[prop] !== data.value2)
- compare(child1.Theme[prop], data.value2)
- compare(grandChild1.Theme[prop], data.value2)
- compare(grandGrandGrandChild1.Theme[prop], data.value2)
-
- parent.destroy()
- }
-
- function test_window() {
- var parent = window.createObject()
-
- var control = button.createObject(parent.contentItem)
- compare(control.Theme.backgroundColor, parent.Theme.backgroundColor)
-
- var themedChild = themedWindow.createObject(window)
- verify(themedChild.Theme.backgroundColor !== parent.Theme.backgroundColor)
-
- var unthemedChild = window.createObject(window)
- compare(unthemedChild.Theme.backgroundColor, parent.Theme.backgroundColor)
-
- parent.Theme.backgroundColor = "#123456"
- compare(control.Theme.backgroundColor, "#123456")
- verify(themedChild.Theme.backgroundColor !== "#123456")
- // ### FIXME: compare(unthemedChild.Theme.backgroundColor, "#123456")
-
- parent.destroy()
- }
-
- function test_loader() {
- var control = loader.createObject(testCase)
- control.Theme.accentColor = "#111111"
- control.active = true
- compare(control.item.Theme.accentColor, "#111111")
- control.Theme.accentColor = "#222222"
- compare(control.item.Theme.accentColor, "#222222")
- control.active = false
- control.Theme.accentColor = "#333333"
- control.active = true
- compare(control.item.Theme.accentColor, "#333333")
- control.destroy()
- }
-}