diff options
author | Michael BrĂ¼ning <michael.bruning@qt.io> | 2020-06-03 16:50:00 +0200 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-06-04 05:42:07 +0000 |
commit | 083b02377d4308119ed8b9e2cfffab8e89517c1f (patch) | |
tree | 789dcdafab56a2575832025cfae808204088796f /tests/auto | |
parent | c6b06152c0cf3b340a13f9695c2d3c410b0dfef6 (diff) |
Add option to apply style sheet coordinates
Enables the user to have pixel positions in the style sheet even if the
template does not use pixel positioning.
Also adds some more ordered properties to make the test case
deterministic.
Task-number: QDS-2208
Change-Id: I79b6af0c24539d1b9eb03dcf0fb52bb078d74afe
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'tests/auto')
4 files changed, 639 insertions, 0 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index c99805152c..52fa6f519f 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -3762,6 +3762,11 @@ void tst_TestCore::testMergeModelRewriter1_data() QString buttonAbsoluteTemplateWithOptionsQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonAbsoluteTemplateWithOptions.qml"); QString buttonStyleUiWithOptionsExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging/ButtonStyleWithOptions.ui.Expected.qml"); + QString testExportButtonTemplateQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging//test_export_button_template.ui.qml"); + QString testExportButtonStylesheetQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging//test_export_button_stylesheet.ui.qml"); + QString testExportButtonExpectedQmlContents = readQmlFromFile(QString(TESTSRCDIR) + "/../data/merging//test_export_button_expected.ui.qml"); + + QTest::newRow("Simple style replacement") << simpleTemplateQmlContents << simpleStyleQmlContents << simpleExpectedQmlContents; QTest::newRow("Complex style replacement") << complexTemplateQmlContents << complexStyleQmlContents << complexExpectedQmlContents; QTest::newRow("Empty stylesheet") << emptyTemplateQmlContents << emptyStyleQmlContents << emptyExpectedQmlContents; @@ -3775,6 +3780,7 @@ void tst_TestCore::testMergeModelRewriter1_data() QTest::newRow("Button Designer styling") << buttonAbsoluteTemplateQmlContents << buttonStyleUiQmlContents << buttonStyleUiExpectedQmlContents; QTest::newRow("Button Designer styling with options") << buttonAbsoluteTemplateWithOptionsQmlContents << buttonStyleUiQmlContents << buttonStyleUiWithOptionsExpectedQmlContents; + QTest::newRow("Button styling with info screen test case ") << testExportButtonTemplateQmlContents << testExportButtonStylesheetQmlContents << testExportButtonExpectedQmlContents; } diff --git a/tests/auto/qml/qmldesigner/data/merging/test_export_button_expected.ui.qml b/tests/auto/qml/qmldesigner/data/merging/test_export_button_expected.ui.qml new file mode 100644 index 0000000000..976431b8cd --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/test_export_button_expected.ui.qml @@ -0,0 +1,279 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T +import Home 1.0 + +T.Button { + id: control + width: 296 + height: 538 + + font: Constants.font + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + background: normalBG + contentItem: normalContent + Item { + id: normalBG + x: 0 + y: 0 + width: 296 + height: 538 + + Image { + id: normalBGAsset + x: 0 + y: 0 + source: "assets/normalBG.png" + } + } + + Item { + id: normalContent + x: 0 + y: 42 + width: 296 + height: 428 + + Image { + id: normalContentAsset + x: 115 + y: 40 + source: "assets/normalContent.png" + } + + Text { + id: normal_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#c1c1c1" + text: "Normal button text" + font.pixelSize: 30 + lineHeight: 44 + lineHeightMode: Text.FixedHeight + wrapMode: Text.WordWrap + } + + Text { + id: normal_button_label + x: 113 + y: 203 + color: "#c1c1c1" + text: "Normal Button label" + font.pixelSize: 36 + } + } + Item { + id: focusedBG + x: 0 + y: 0 + width: 296 + height: 538 + + Image { + id: focusedBGAsset + x: 0 + y: 0 + source: "assets/focusedBG.png" + } + + Item { + id: highlight_item_focused_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_focused_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_focusedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_focusedBG_1.png" + } + + Image { + id: highlight_img_focusedBG_1 + x: 0 + y: 0 + source: "assets/highlight_img_focusedBG_1.png" + } + + Image { + id: highlight_img_focused_1 + x: 291 + y: 7 + source: "assets/highlight_img_focused_1.png" + } + } + Item { + id: focusedContent + x: 0 + y: 42 + width: 296 + height: 428 + + Image { + id: focusedContentAsset + x: 115 + y: 40 + source: "assets/focusedContent.png" + } + + Text { + id: focus_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#ffffff" + text: "Focus button text" + font.pixelSize: 30 + lineHeight: 44 + lineHeightMode: Text.FixedHeight + wrapMode: Text.WordWrap + } + + Text { + id: focus_button_label + x: 113 + y: 203 + color: "#ba544d" + text: "Button label focus" + font.pixelSize: 36 + } + } + + Item { + id: pressedBG + x: 0 + y: 0 + width: 296 + height: 538 + + Image { + id: pressedBGAsset + x: 0 + y: 0 + source: "assets/pressedBG.png" + } + + Item { + id: highlight_item_pressed_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_pressed_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_pressedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_pressedBG_1.png" + } + + Image { + id: highlight_img_pressed_1 + x: 0 + y: 0 + source: "assets/highlight_img_pressed_1.png" + } + + Image { + id: highlight_img_pressed_2 + x: 291 + y: 7 + source: "assets/highlight_img_pressed_2.png" + } + } + + Image { + id: defaultBG + x: 35 + y: 339 + source: "assets/defaultBG.png" + } + + + + + + + states: [ + State { + name: "normal" + when: !control.down && !control.focus + + PropertyChanges { + target: focusedBG + visible: false + } + PropertyChanges { + target: focusedContent + visible: false + } + PropertyChanges { + target: pressedBG + visible: false + } + }, + State { + name: "press" + when: control.down && control.focus + PropertyChanges { + target: control + contentItem: focusedContent + } + + PropertyChanges { + target: normalBG + visible: false + } + + PropertyChanges { + target: normalContent + visible: false + } + + PropertyChanges { + target: pressedBG + visible: true + } + + PropertyChanges { + target: focusedContent + visible: true + } + + PropertyChanges { + target: control + background: pressedBG + } + } + ] +} diff --git a/tests/auto/qml/qmldesigner/data/merging/test_export_button_stylesheet.ui.qml b/tests/auto/qml/qmldesigner/data/merging/test_export_button_stylesheet.ui.qml new file mode 100644 index 0000000000..75c8653b39 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/test_export_button_stylesheet.ui.qml @@ -0,0 +1,255 @@ +import QtQuick 2.10 + +Item { + id: info_screen + width: 296 + height: 538 + + Item { + id: normalBG + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: normalBGAsset + x: 0 + y: 0 + source: "assets/normalBG.png" + } + } + + Item { + id: normalContent + x: 0 + y: 42 + width: 296 + height: 428 + Image { + id: normalContentAsset + x: 115 + y: 40 + source: "assets/normalContent.png" + } + + Text { + id: normal_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#C1C1C1" + text: "Normal button text" + font.pixelSize: 30 + lineHeightMode: Text.FixedHeight + lineHeight: 44 + wrapMode: Text.WordWrap + } + + Text { + id: normal_button_label + x: 113 + y: 203 + color: "#C1C1C1" + text: "Normal Button label" + font.pixelSize: 36 + } + } + + Item { + id: pressedBG + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: pressedBGAsset + x: 0 + y: 0 + source: "assets/pressedBG.png" + } + + Item { + id: highlight_item_pressed_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_pressed_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_pressedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_pressedBG_1.png" + } + + Image { + id: highlight_img_pressed_1 + x: 0 + y: 0 + source: "assets/highlight_img_pressed_1.png" + } + + Image { + id: highlight_img_pressed_2 + x: 291 + y: 7 + source: "assets/highlight_img_pressed_2.png" + } + } + + Item { + id: focusedBG + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: focusedBGAsset + x: 0 + y: 0 + source: "assets/focusedBG.png" + } + + Item { + id: highlight_item_focused_1 + x: 0 + y: 0 + width: 296 + height: 196 + } + + Item { + id: highlight_item_focused_2 + x: 39 + y: 0 + width: 197 + height: 99 + } + + Image { + id: rectangle_focusedBG_1 + x: 0 + y: 0 + source: "assets/rectangle_focusedBG_1.png" + } + + Image { + id: highlight_img_focusedBG_1 + x: 0 + y: 0 + source: "assets/highlight_img_focusedBG_1.png" + } + + Image { + id: highlight_img_focused_1 + x: 291 + y: 7 + source: "assets/highlight_img_focused_1.png" + } + } + + Item { + id: focusedContent + x: 0 + y: 42 + width: 296 + height: 428 + Image { + id: focusedContentAsset + x: 115 + y: 40 + source: "assets/focusedContent.png" + } + + Text { + id: focus_button_text + x: 59 + y: 353 + width: 241 + height: 75 + color: "#FFFFFF" + text: "Focus button text" + font.pixelSize: 30 + lineHeightMode: Text.FixedHeight + lineHeight: 44 + wrapMode: Text.WordWrap + } + + Text { + id: focus_button_label + x: 113 + y: 203 + color: "#BA544D" + text: "Button label focus" + font.pixelSize: 36 + } + } + + Item { + id: disabledBG + x: 0 + y: 0 + width: 296 + height: 533 + Image { + id: disabledBGAsset + x: 0 + y: 0 + source: "assets/disabledBG.png" + } + } + + Item { + id: disabledContent + x: 0 + y: 0 + width: 296 + height: 538 + Image { + id: disabledContentAsset + x: 115 + y: 82 + source: "assets/disabledContent.png" + } + + Text { + id: disabled_button_text + x: 59 + y: 395 + width: 241 + height: 75 + color: "#413E3C" + text: "Disabled button text" + font.pixelSize: 30 + lineHeightMode: Text.FixedHeight + lineHeight: 44 + wrapMode: Text.WordWrap + } + + Text { + id: disabled_button_label + x: 109 + y: 242 + color: "#413E3C" + text: "Disabled button label" + font.pixelSize: 40 + } + } + + Image { + id: defaultBG + x: 35 + y: 339 + source: "assets/defaultBG.png" + } +} diff --git a/tests/auto/qml/qmldesigner/data/merging/test_export_button_template.ui.qml b/tests/auto/qml/qmldesigner/data/merging/test_export_button_template.ui.qml new file mode 100644 index 0000000000..ac96a076f9 --- /dev/null +++ b/tests/auto/qml/qmldesigner/data/merging/test_export_button_template.ui.qml @@ -0,0 +1,99 @@ +import QtQuick 2.10 +import QtQuick.Templates 2.1 as T +import Home 1.0 + +T.Button { + id: control + width: 296 + height: 538 + + font: Constants.font + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + leftPadding: 4 + rightPadding: 4 + + background: normalBG + contentItem: normalContent + + Item { + id: normalBG + } + Item { + id: normalContent + } + + Item { + id: focusedBG + } + Item { + id: focusedContent + } + Item { + id: pressedBG + } + Item { + id: defaultBG + } + + states: [ + State { + name: "normal" + when: !control.down && !control.focus + + PropertyChanges { + target: focusedBG + visible: false + } + PropertyChanges { + target: focusedContent + visible: false + } + PropertyChanges { + target: pressedBG + visible: false + } + }, + State { + name: "press" + when: control.down && control.focus + PropertyChanges { + target: control + contentItem: focusedContent + } + + PropertyChanges { + target: normalBG + visible: false + } + + PropertyChanges { + target: normalContent + visible: false + } + + PropertyChanges { + target: pressedBG + visible: true + } + + PropertyChanges { + target: focusedContent + visible: true + } + + PropertyChanges { + target: control + background: pressedBG + } + } + ] + QtObject { + id: qds_stylesheet_merger_options + property bool useStyleSheetPositions: true + } +} |