From b5d59c75a7dee830483631cd9045d5338fc25c2d Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 6 Aug 2020 11:27:27 +0200 Subject: QmlDesigner: Fix bool handling in the list model editor Task-number: QDS-2581 Change-Id: I47a9ed4ca55532bb7199a6c5dd4894b7adb7d05d Reviewed-by: Thomas Hartmann --- tests/unit/unittest/listmodeleditor-test.cpp | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/unittest/listmodeleditor-test.cpp b/tests/unit/unittest/listmodeleditor-test.cpp index 0a5a91327a..bdd5e9c070 100644 --- a/tests/unit/unittest/listmodeleditor-test.cpp +++ b/tests/unit/unittest/listmodeleditor-test.cpp @@ -1310,4 +1310,70 @@ TEST_F(ListModelEditor, ListViewHasModelBinding) ElementsAre("pic.png", "poo", 111, IsInvalid()))); } +TEST_F(ListModelEditor, AddBooleanDisplayValues) +{ + model.setListModel(listModelNode); + + model.setValue(0, 1, true); + + ASSERT_THAT(displayValues(), + ElementsAre(ElementsAre(IsInvalid(), true, 1, 42), + ElementsAre("pic.png", "bar", 4, IsInvalid()), + ElementsAre("pic.png", "poo", 111, IsInvalid()))); +} + +TEST_F(ListModelEditor, AddBooleanProperties) +{ + model.setListModel(listModelNode); + + model.setValue(0, 1, true); + + ASSERT_THAT(properties(), + ElementsAre(UnorderedElementsAre(IsVariantProperty("name", "foo"), + IsVariantProperty("value", true), + IsVariantProperty("value2", 42)), + UnorderedElementsAre(IsVariantProperty("image", "pic.png"), + IsVariantProperty("name", "bar"), + IsVariantProperty("value", 4)), + UnorderedElementsAre(IsVariantProperty("image", "pic.png"), + IsVariantProperty("name", "poo"), + IsVariantProperty("value", 111)))); +} + +TEST_F(ListModelEditor, AddTrueAsStringProperties) +{ + model.setListModel(listModelNode); + + model.setValue(0, 1, "true"); + + ASSERT_THAT(properties(), + ElementsAre(UnorderedElementsAre(IsVariantProperty("name", true), + IsVariantProperty("value", 1), + IsVariantProperty("value2", 42)), + UnorderedElementsAre(IsVariantProperty("image", "pic.png"), + IsVariantProperty("name", "bar"), + IsVariantProperty("value", 4)), + UnorderedElementsAre(IsVariantProperty("image", "pic.png"), + IsVariantProperty("name", "poo"), + IsVariantProperty("value", 111)))); +} + +TEST_F(ListModelEditor, AddFalseAsStringProperties) +{ + model.setListModel(listModelNode); + + model.setValue(0, 1, "false"); + + ASSERT_THAT(properties(), + ElementsAre(UnorderedElementsAre(IsVariantProperty("name", false), + IsVariantProperty("value", 1), + IsVariantProperty("value2", 42)), + UnorderedElementsAre(IsVariantProperty("image", "pic.png"), + IsVariantProperty("name", "bar"), + IsVariantProperty("value", 4)), + UnorderedElementsAre(IsVariantProperty("image", "pic.png"), + IsVariantProperty("name", "poo"), + IsVariantProperty("value", 111)))); +} + } // namespace -- cgit v1.2.3