MCPcopy Create free account
hub / github.com/KDE/labplot / multiLabelEditColorChange

Method multiLabelEditColorChange

tests/backend/TextLabel/TextLabelTest.cpp:118–166  ·  view source on GitHub ↗

! * \brief TextLabelTest::multiLabelEdit * Test if changing the background color of one label * only the background color will be changed for the second * label, but no other properties */

Source from the content-addressed store, hash-verified

116 * label, but no other properties
117 */
118void TextLabelTest::multiLabelEditColorChange() {
119 Project project;
120 auto* ws = new Worksheet(QStringLiteral("worksheet"));
121 QVERIFY(ws != nullptr);
122 project.addChild(ws);
123
124 auto* p = new CartesianPlot(QStringLiteral("plot"));
125 QVERIFY(p != nullptr);
126 ws->addChild(p);
127
128 auto* l1 = new TextLabel(QStringLiteral("Label"));
129 QVERIFY(l1 != nullptr);
130 l1->setText(QStringLiteral("Text1"));
131 ws->addChild(l1);
132
133 VERIFYLABELCOLORS(l1, Qt::black, Qt::transparent);
134
135 auto* l2 = new TextLabel(QStringLiteral("Label"));
136 QVERIFY(l2 != nullptr);
137 l2->setText(QStringLiteral("Text2"));
138 ws->addChild(l2);
139
140 STORETEXTPROPERTIES(l1, l1InitProperties);
141 STORETEXTPROPERTIES(l2, l2InitProperties);
142
143 LabelWidget w(nullptr);
144 w.setLabels({l1}); // change only one textlabel
145 w.fontColorChanged(Qt::red);
146 w.backgroundColorChanged(Qt::blue);
147
148 TextProperties l1p = l1InitProperties;
149 l1p.fontColor = Qt::red;
150 l1p.backgroundColor = Qt::blue;
151 COMPARETEXTPROPERTIESLABEL(l1, l1p);
152 COMPARETEXTPROPERTIESLABEL(l2, l2InitProperties);
153
154 w.setLabels({l1, l2});
155 w.fontColorChanged(Qt::cyan);
156 w.backgroundColorChanged(Qt::green);
157
158 l1p = l1InitProperties;
159 l1p.fontColor = Qt::cyan;
160 l1p.backgroundColor = Qt::green;
161 COMPARETEXTPROPERTIESLABEL(l1, l1p);
162 TextProperties l2p = l2InitProperties;
163 l2p.fontColor = Qt::cyan;
164 l2p.backgroundColor = Qt::green;
165 COMPARETEXTPROPERTIESLABEL(l2, l2p);
166}
167
168/*!
169 * \brief TextLabelTest::multiLabelEditTextChange

Callers

nothing calls this directly

Calls 5

setLabelsMethod · 0.80
fontColorChangedMethod · 0.80
addChildMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected