diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-10-15 07:31:09 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-10-15 09:37:22 +0300 |
commit | c5d9c5c1973408f0233c9f257a80b484585079c0 (patch) | |
tree | 18ffeabf873b2a6b0e41ab21859f8ac927785865 /tests | |
parent | 91a9698b80bcb072a5ec3af69515249bac96aff5 (diff) |
QML tests for theme
Task-number: QTRD-3368
Change-Id: I1fa3de637dafcd601490155e29fb36008b1eafcf
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qmltest/qmltest.pro | 5 | ||||
-rw-r--r-- | tests/auto/qmltest/theme3d/tst_colorgradient.qml | 89 | ||||
-rw-r--r-- | tests/auto/qmltest/theme3d/tst_theme.qml | 242 | ||||
-rw-r--r-- | tests/auto/qmltest/theme3d/tst_themecolor.qml | 66 |
4 files changed, 401 insertions, 1 deletions
diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro index a6430862..ea869a2e 100644 --- a/tests/auto/qmltest/qmltest.pro +++ b/tests/auto/qmltest/qmltest.pro @@ -11,7 +11,10 @@ OTHER_FILES += bars3d\tst_basic.qml \ scatter3d\tst_scatterseries.qml \ surface3d\tst_basic.qml \ surface3d\tst_surface.qml \ - surface3d\tst_surfaceseries.qml + surface3d\tst_surfaceseries.qml \ + theme3d\tst_theme.qml \ + theme3d\tst_colorgradient.qml \ + theme3d\tst_themecolor.qml RESOURCES += \ qmltest.qrc diff --git a/tests/auto/qmltest/theme3d/tst_colorgradient.qml b/tests/auto/qmltest/theme3d/tst_colorgradient.qml new file mode 100644 index 00000000..395b6672 --- /dev/null +++ b/tests/auto/qmltest/theme3d/tst_colorgradient.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + ColorGradient { + id: initial + } + + ColorGradient { + id: initialized + stops: [ + ColorGradientStop { color: "blue"; position: 0 }, + ColorGradientStop { color: "white"; position: 0.5 }, + ColorGradientStop { color: "red"; position: 1 } + ] + } + + ColorGradient { + id: change + } + + TestCase { + name: "ColorGradient Initial" + + function test_initial() { + compare(initial.stops.length, 0) + } + } + + TestCase { + name: "ColorGradient Initialized" + + function test_initialized() { + compare(initialized.stops.length, 3) + compare(initialized.stops[0].color, "#0000ff") + compare(initialized.stops[1].color, "#ffffff") + compare(initialized.stops[2].color, "#ff0000") + } + } + + TestCase { + name: "ColorGradient Change" + + ColorGradientStop { id: stop1; color: "blue"; position: 0 } + ColorGradientStop { id: stop2; color: "red"; position: 1.0 } + ColorGradientStop { id: stop3; color: "white"; position: 0.5 } + + function test_change() { + change.stops = [stop1] + compare(change.stops.length, 1) + change.stops = [stop1, stop2] + compare(change.stops.length, 2) + compare(change.stops[0].color, "#0000ff") + change.stops[0].color = "red" + compare(change.stops[0].color, "#ff0000") + compare(change.stops[1].color, "#ff0000") + change.stops = [stop1, stop2, stop3] + compare(change.stops[2].color, "#ffffff") + compare(change.stops.length, 3) + stop2.position = 0.25 + stop3.position = 1.0 + compare(change.stops[1].position, 0.25) + compare(change.stops[2].position, 1.0) + } + } +} diff --git a/tests/auto/qmltest/theme3d/tst_theme.qml b/tests/auto/qmltest/theme3d/tst_theme.qml new file mode 100644 index 00000000..9c1a22f1 --- /dev/null +++ b/tests/auto/qmltest/theme3d/tst_theme.qml @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + Theme3D { + id: initial + } + + ColorGradient { + id: gradient1 + stops: [ + ColorGradientStop { color: "red"; position: 0 }, + ColorGradientStop { color: "blue"; position: 1 } + ] + } + + ColorGradient { + id: gradient2 + stops: [ + ColorGradientStop { color: "green"; position: 0 }, + ColorGradientStop { color: "red"; position: 1 } + ] + } + + ColorGradient { + id: gradient3 + stops: [ + ColorGradientStop { color: "gray"; position: 0 }, + ColorGradientStop { color: "darkgray"; position: 1 } + ] + } + + ThemeColor { + id: color1 + color: "red" + } + + ThemeColor { + id: color2 + color: "blue" + } + + Theme3D { + id: initialized + ambientLightStrength: 0.3 + backgroundColor: "#ff0000" + backgroundEnabled: false + baseColors: [color1, color2] + baseGradients: [gradient1, gradient2] + colorStyle: Theme3D.ColorStyleRangeGradient + font.family: "Arial" + gridEnabled: false + gridLineColor: "#00ff00" + highlightLightStrength: 5.0 + labelBackgroundColor: "#ff00ff" + labelBackgroundEnabled: false + labelBorderEnabled: false + labelTextColor: "#00ffff" + lightColor: "#ffff00" + lightStrength: 2.5 + multiHighlightColor: "#ff00ff" + multiHighlightGradient: gradient3 + singleHighlightColor: "#ff0000" + singleHighlightGradient: gradient3 + type: Theme3D.ThemeQt // Default values will be overwritten by initialized values + windowColor: "#fff00f" + } + + Theme3D { + id: change + } + + TestCase { + name: "Theme3D Initial" + + Text { id: dummy } + + function test_initial() { + compare(initial.ambientLightStrength, 0.25) + compare(initial.backgroundColor, "#000000") + compare(initial.backgroundEnabled, true) + compare(initial.baseColors.length, 1) + compare(initial.baseColors[0].color, "#000000") + compare(initial.baseGradients.length, 1) + compare(initial.baseGradients[0].stops[0].color, "#000000") + compare(initial.baseGradients[0].stops[1].color, "#ffffff") + compare(initial.colorStyle, Theme3D.ColorStyleUniform) + // Initial font needs to be tested like this, as different platforms have different default font (QFont()) + compare(initial.font.family, dummy.font.family) + compare(initial.gridEnabled, true) + compare(initial.gridLineColor, "#ffffff") + compare(initial.highlightLightStrength, 7.5) + compare(initial.labelBackgroundColor, "#a0a0a4") + compare(initial.labelBackgroundEnabled, true) + compare(initial.labelBorderEnabled, true) + compare(initial.labelTextColor, "#ffffff") + compare(initial.lightColor, "#ffffff") + compare(initial.lightStrength, 5) + compare(initial.multiHighlightColor, "#0000ff") + compare(initial.multiHighlightGradient, null) + compare(initial.singleHighlightColor, "#ff0000") + compare(initial.singleHighlightGradient, null) + compare(initial.type, Theme3D.ThemeUserDefined) + compare(initial.windowColor, "#000000") + } + } + + TestCase { + name: "Theme3D Initialized" + + function test_initialized() { + compare(initialized.ambientLightStrength, 0.3) + compare(initialized.backgroundColor, "#ff0000") + compare(initialized.backgroundEnabled, false) + compare(initialized.baseColors.length, 2) + compare(initialized.baseColors[0].color, "#ff0000") + compare(initialized.baseColors[1].color, "#0000ff") + compare(initialized.baseGradients.length, 2) + compare(initialized.baseGradients[0], gradient1) + compare(initialized.baseGradients[1], gradient2) + compare(initialized.colorStyle, Theme3D.ColorStyleRangeGradient) + compare(initialized.font.family, "Arial") + compare(initialized.gridEnabled, false) + compare(initialized.gridLineColor, "#00ff00") + compare(initialized.highlightLightStrength, 5.0) + compare(initialized.labelBackgroundColor, "#ff00ff") + compare(initialized.labelBackgroundEnabled, false) + compare(initialized.labelBorderEnabled, false) + compare(initialized.labelTextColor, "#00ffff") + compare(initialized.lightColor, "#ffff00") + compare(initialized.lightStrength, 2.5) + compare(initialized.multiHighlightColor, "#ff00ff") + compare(initialized.multiHighlightGradient, gradient3) + compare(initialized.singleHighlightColor, "#ff0000") + compare(initialized.singleHighlightGradient, gradient3) + compare(initialized.type, Theme3D.ThemeQt) + compare(initialized.windowColor, "#fff00f") + } + } + + TestCase { + name: "Theme3D Change" + + ThemeColor { + id: color3 + color: "red" + } + + ColorGradient { + id: gradient4 + stops: [ + ColorGradientStop { color: "red"; position: 0 }, + ColorGradientStop { color: "blue"; position: 1 } + ] + } + + function test_1_change() { + change.type = Theme3D.ThemeStoneMoss // Default values will be overwritten by the following sets + change.ambientLightStrength = 0.3 + change.backgroundColor = "#ff0000" + change.backgroundEnabled = false + change.baseColors = [color3, color2] + change.baseGradients = [gradient4, gradient2] + change.colorStyle = Theme3D.ColorStyleObjectGradient + change.font.family = "Arial" + change.gridEnabled = false + change.gridLineColor = "#00ff00" + change.highlightLightStrength = 5.0 + change.labelBackgroundColor = "#ff00ff" + change.labelBackgroundEnabled = false + change.labelBorderEnabled = false + change.labelTextColor = "#00ffff" + change.lightColor = "#ffff00" + change.lightStrength = 2.5 + change.multiHighlightColor = "#ff00ff" + change.multiHighlightGradient = gradient3 + change.singleHighlightColor = "#ff0000" + change.singleHighlightGradient = gradient3 + change.windowColor = "#fff00f" + + compare(change.ambientLightStrength, 0.3) + compare(change.backgroundColor, "#ff0000") + compare(change.backgroundEnabled, false) + compare(change.baseColors.length, 2) + compare(change.baseColors[0].color, "#ff0000") + compare(change.baseColors[1].color, "#0000ff") + compare(change.baseGradients.length, 2) + compare(change.baseGradients[0], gradient4) + compare(change.baseGradients[1], gradient2) + compare(change.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(change.font.family, "Arial") + compare(change.gridEnabled, false) + compare(change.gridLineColor, "#00ff00") + compare(change.highlightLightStrength, 5.0) + compare(change.labelBackgroundColor, "#ff00ff") + compare(change.labelBackgroundEnabled, false) + compare(change.labelBorderEnabled, false) + compare(change.labelTextColor, "#00ffff") + compare(change.lightColor, "#ffff00") + compare(change.lightStrength, 2.5) + compare(change.multiHighlightColor, "#ff00ff") + compare(change.multiHighlightGradient, gradient3) + compare(change.singleHighlightColor, "#ff0000") + compare(change.singleHighlightGradient, gradient3) + compare(change.type, Theme3D.ThemeStoneMoss) + compare(change.windowColor, "#fff00f") + } + + function test_2_change_color() { + color3.color = "white" + compare(change.baseColors[0].color, "#ffffff") + } + + function test_3_change_gradient() { + gradient4.stops[0].color = "black" + compare(change.baseGradients[0].stops[0].color, "#000000") + } + } +} diff --git a/tests/auto/qmltest/theme3d/tst_themecolor.qml b/tests/auto/qmltest/theme3d/tst_themecolor.qml new file mode 100644 index 00000000..d7dd3490 --- /dev/null +++ b/tests/auto/qmltest/theme3d/tst_themecolor.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + ThemeColor { + id: initial + } + + ThemeColor { + id: initialized + color: "red" + } + + ThemeColor { + id: change + } + + TestCase { + name: "ThemeColor Initial" + + function test_initial() { + compare(initial.color, "#000000") + } + } + + TestCase { + name: "ThemeColor Initialized" + + function test_initialized() { + compare(initialized.color, "#ff0000") + } + } + + TestCase { + name: "ThemeColor Change" + + function test_1_change() { + change.color = "blue" + + compare(change.color, "#0000ff") + } + } +} |