Merge lp:~zsombi/ubuntu-ui-toolkit/theming-selector-parsing into lp:ubuntu-ui-toolkit

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: 380
Merged at revision: 378
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/theming-selector-parsing
Merge into: lp:ubuntu-ui-toolkit
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/normalize-style-properties
Diff against target: 469 lines (+126/-136)
9 files modified
modules/Ubuntu/Components/plugin/itemstyleattached.cpp (+1/-2)
modules/Ubuntu/Components/plugin/qmlthemeloader.cpp (+1/-1)
modules/Ubuntu/Components/plugin/suffixtree.cpp (+71/-9)
modules/Ubuntu/Components/plugin/suffixtree_p.h (+11/-2)
modules/Ubuntu/Components/plugin/themeengine.cpp (+4/-50)
modules/Ubuntu/Components/plugin/themeengine_p.h (+0/-1)
modules/Ubuntu/Components/ubuntu-components-theming.qdoc (+1/-1)
tests/unit/tst_theme_engine/tst_theme_enginetest.cpp (+0/-2)
tests/unit/tst_theme_engine_private/tst_theme_engine_privatetest.cpp (+37/-68)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/theming-selector-parsing
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tim Peeters Approve
Review via email: mp+150295@code.launchpad.net

Commit message

Selector parsing moved into SelectorNode. Extra white space required between selector nodes and compositors removed.

Description of the change

Selector parsing moved into SelectorNode. Extra white space required between selector nodes and compositors removed.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

Looks good, but I didn't check the tests.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'modules/Ubuntu/Components/plugin/itemstyleattached.cpp'
--- modules/Ubuntu/Components/plugin/itemstyleattached.cpp 2013-01-14 14:16:54 +0000
+++ modules/Ubuntu/Components/plugin/itemstyleattached.cpp 2013-02-27 06:21:21 +0000
@@ -297,7 +297,6 @@
297bool ItemStyleAttachedPrivate::registerName(const QString &id)297bool ItemStyleAttachedPrivate::registerName(const QString &id)
298{298{
299 bool result = true;299 bool result = true;
300 Q_Q(ItemStyleAttached);
301 if (ThemeEnginePrivate::registerName(attachee, id)) {300 if (ThemeEnginePrivate::registerName(attachee, id)) {
302 styleData.styleId = id;301 styleData.styleId = id;
303 attachee->setProperty("name", styleData.styleId);302 attachee->setProperty("name", styleData.styleId);
@@ -461,7 +460,7 @@
461{460{
462 Q_D(const ItemStyleAttached);461 Q_D(const ItemStyleAttached);
463 return d->styleRule ?462 return d->styleRule ?
464 ThemeEnginePrivate::selectorToString(d->styleRule->path()) :463 d->styleRule->path().toString() :
465 QString("(null)");464 QString("(null)");
466}465}
467466
468467
=== modified file 'modules/Ubuntu/Components/plugin/qmlthemeloader.cpp'
--- modules/Ubuntu/Components/plugin/qmlthemeloader.cpp 2013-02-25 13:07:03 +0000
+++ modules/Ubuntu/Components/plugin/qmlthemeloader.cpp 2013-02-27 06:21:21 +0000
@@ -503,7 +503,7 @@
503 QString qmap;503 QString qmap;
504 for (int count = selector.count(); count > 0; count--) {504 for (int count = selector.count(); count > 0; count--) {
505 subset = selectorSubset(selector, count, SelectorNode::Normal);505 subset = selectorSubset(selector, count, SelectorNode::Normal);
506 qmap = ThemeEnginePrivate::selectorToString(subset);506 qmap = subset.toString();
507 if (qmlMap.contains(qmap)) {507 if (qmlMap.contains(qmap)) {
508 return qmlMap.value(qmap);508 return qmlMap.value(qmap);
509 }509 }
510510
=== modified file 'modules/Ubuntu/Components/plugin/suffixtree.cpp'
--- modules/Ubuntu/Components/plugin/suffixtree.cpp 2013-01-15 13:27:54 +0000
+++ modules/Ubuntu/Components/plugin/suffixtree.cpp 2013-02-27 06:21:21 +0000
@@ -23,6 +23,7 @@
23#include <QtQml/QQmlContext>23#include <QtQml/QQmlContext>
24#include <QtQml/QQmlComponent>24#include <QtQml/QQmlComponent>
25#include <QtQuick/QQuickItem>25#include <QtQuick/QQuickItem>
26#include <QtCore/QRegularExpression>
2627
27/*28/*
28 This file contains the Rule-element suffix-tree handling classes. The suffix-tree29 This file contains the Rule-element suffix-tree handling classes. The suffix-tree
@@ -36,16 +37,31 @@
36 relationship(Descendant),37 relationship(Descendant),
37 sensitivity(Normal)38 sensitivity(Normal)
38{}39{}
40
39/*!41/*!
40 \internal42 \internal
41 Creates an instance of a SelectorNode with a given class, name43 Creates an instance of a SelectorNode by parsing the selectorString. The
42 and relationship. The sensitivity parameter configures the node so that during44 sensitivity parameter configures the node so that during string conversion
43 string conversion and comparison ignores the relationship, the name45 and comparison ignores the relationship, the name both or none. This feature
44 both or none. This feature is used when building up QmlTheme selectorTable.46 is used when building up QmlTheme selectorTable.
45*/47*/
46SelectorNode::SelectorNode(const QString &styleClass, const QString &styleId, Relationship relationship, NodeSensitivity sensitivity) :48SelectorNode::SelectorNode(const QString &selectorString, NodeSensitivity sensitivity) :
47 styleClass(styleClass.toLower()), styleId(styleId.toLower()), relationship(relationship), sensitivity(sensitivity)49 relationship(Descendant), sensitivity(sensitivity)
48{50{
51 styleClass = selectorString;
52 if (styleClass.startsWith('>')) {
53 relationship = Child;
54 styleClass.remove('>');
55 }
56 int idIndex = styleClass.indexOf('#');
57 if (idIndex != -1) {
58 styleId = styleClass.mid(idIndex + 1).toLower();
59 styleClass = styleClass.left(idIndex);
60 if (idIndex > 1 && styleClass[0] == '.')
61 styleClass = styleClass.mid(1, idIndex - 1);
62 } else if (styleClass[0] == '.')
63 styleClass = styleClass.mid(1);
64 styleClass = styleClass.toLower();
49}65}
5066
51/*!67/*!
@@ -58,7 +74,7 @@
58 QString result;74 QString result;
59 if (((sensitivity & IgnoreRelationship) != IgnoreRelationship) &&75 if (((sensitivity & IgnoreRelationship) != IgnoreRelationship) &&
60 (relationship == SelectorNode::Child))76 (relationship == SelectorNode::Child))
61 result += "> ";77 result += ">";
62 if (!styleClass.isEmpty())78 if (!styleClass.isEmpty())
63 result += "." + styleClass;79 result += "." + styleClass;
64 else if (!className.isEmpty()) {80 else if (!className.isEmpty()) {
@@ -81,17 +97,63 @@
81}97}
8298
83/*!99/*!
100 * \internal
101 * Converts a selector string into Selector object.
102 * Current support (ref: www.w3.org/TR/selector.html):
103 * - Type selectors, e.g: "Button"
104 * - Descendant selectors, e.g: "Dialog Button"
105 * - Child selectors, e.g: "Dialog>Button"
106 * - ID selectors, e.g: "Button#mySpecialButton"
107 */
108Selector::Selector(const QString &string, SelectorNode::NodeSensitivity sensitivity)
109{
110 QString tmp(string);
111 // prepare for split
112 if (tmp.contains('>')) {
113 tmp.replace(QRegularExpression(" (>) "), ">").replace('>', "|>");
114 }
115 tmp.replace(' ', '|');
116
117 QStringList nodes = tmp.simplified().split('|');
118 QStringListIterator inodes(nodes);
119 inodes.toBack();
120 while (inodes.hasPrevious()) {
121 const QString &node = inodes.previous();
122 if (node.isEmpty())
123 continue;
124 prepend(SelectorNode(node, sensitivity));
125 }
126}
127
128/*!
129 \internal
130 Converts a style path back to selector string.
131*/
132QString Selector::toString() const
133{
134 QString result;
135
136 QListIterator<SelectorNode> i(*this);
137 while (i.hasNext()) {
138 SelectorNode node = i.next();
139 result += ' ' + node.toString();
140 }
141 result.replace(" >", ">");
142 return result.simplified();
143}
144
145/*!
84 \internal146 \internal
85 Hash key for Selector. Uses QString's hash function.147 Hash key for Selector. Uses QString's hash function.
86 */148 */
87uint qHash(const Selector &key)149uint qHash(const Selector &key)
88{150{
89 return qHash(ThemeEnginePrivate::selectorToString(key));151 return qHash(key.toString());
90}152}
91153
92154
93StyleTreeNode::StyleTreeNode(StyleTreeNode *parent) :155StyleTreeNode::StyleTreeNode(StyleTreeNode *parent) :
94 parent(parent), styleNode("", "", SelectorNode::Descendant), style(0), delegate(0)156 parent(parent), style(0), delegate(0)
95{157{
96}158}
97159
98160
=== modified file 'modules/Ubuntu/Components/plugin/suffixtree_p.h'
--- modules/Ubuntu/Components/plugin/suffixtree_p.h 2012-12-11 10:46:19 +0000
+++ modules/Ubuntu/Components/plugin/suffixtree_p.h 2013-02-27 06:21:21 +0000
@@ -21,6 +21,7 @@
2121
22#include <QtCore/QHash>22#include <QtCore/QHash>
23#include <QtCore/QString>23#include <QtCore/QString>
24#include <QtCore/QList>
2425
25// node of a selector26// node of a selector
26class SelectorNode {27class SelectorNode {
@@ -32,7 +33,7 @@
32 IgnoreStyleId = 0x02,33 IgnoreStyleId = 0x02,
33 IgnoreAll = IgnoreRelationship | IgnoreStyleId};34 IgnoreAll = IgnoreRelationship | IgnoreStyleId};
34 SelectorNode();35 SelectorNode();
35 SelectorNode(const QString &styleClass, const QString &styleId, Relationship relationship = Descendant, NodeSensitivity sensitivity = Normal);36 SelectorNode(const QString &selectorString, NodeSensitivity sensitivity = Normal);
36 QString toString() const;37 QString toString() const;
37 bool operator==(const SelectorNode &other);38 bool operator==(const SelectorNode &other);
38 QString className;39 QString className;
@@ -43,7 +44,15 @@
43};44};
4445
45// selector type46// selector type
46typedef QList<SelectorNode> Selector;47class Selector : public QList<SelectorNode> {
48public:
49 inline Selector() {}
50 inline Selector(const Selector& s) : QList<SelectorNode>(s){}
51 Selector(const QString &string, SelectorNode::NodeSensitivity sensitivity = SelectorNode::Normal);
52 virtual ~Selector() {}
53 QString toString() const;
54};
55Q_DECLARE_TYPEINFO(Selector, Q_MOVABLE_TYPE);
47uint qHash(const Selector &key);56uint qHash(const Selector &key);
4857
49// style rule tree58// style rule tree
5059
=== modified file 'modules/Ubuntu/Components/plugin/themeengine.cpp'
--- modules/Ubuntu/Components/plugin/themeengine.cpp 2012-12-11 11:47:33 +0000
+++ modules/Ubuntu/Components/plugin/themeengine.cpp 2013-02-27 06:21:21 +0000
@@ -231,64 +231,18 @@
231 return qobject_cast<ItemStyleAttached*>(attached);231 return qobject_cast<ItemStyleAttached*>(attached);
232}232}
233233
234
235/*!
236 \internal
237 Converts a style path back to selector string.
238*/
239QString ThemeEnginePrivate::selectorToString(const Selector &path)
240{
241 QString result;
242 Q_FOREACH (SelectorNode node, path) {
243 result += " " + node.toString();
244 }
245 return result.simplified();
246}
247
248/*!234/*!
249 \internal235 \internal
250 Parses and returns the path described by \a selector as a list of236 Parses and returns the path described by \a selector as a list of
251 class and name pairs.237 class and name pairs. Supports selector grouping (separated with commas).
252 Current support (ref: www.w3.org/TR/selector.html):
253 - Type selectors, e.g: "Button"
254 - Descendant selectors, e.g: "Dialog Button"
255 - Child selectors, e.g: "Dialog > Button"
256 - ID selectors, e.g: "Button#mySpecialButton"
257 - Grouping, e.g: "Button#foo, Checkbox, #bar"
258 */238 */
259QList<Selector> ThemeEnginePrivate::parseSelector(const QString &selectorString, SelectorNode::NodeSensitivity sensitivity)239QList<Selector> ThemeEnginePrivate::parseSelector(const QString &selectorString, SelectorNode::NodeSensitivity sensitivity)
260{240{
261 QList<Selector> pathList;241 QList<Selector> pathList;
262 QStringList groupList = selectorString.split(",");242 QStringList groupList = selectorString.split(",");
263 SelectorNode::Relationship nextRelationShip = SelectorNode::Descendant;243
264244 Q_FOREACH (const QString &group, groupList) {
265 Q_FOREACH (QString group, groupList) {245 pathList.append(Selector(group, sensitivity));
266 Selector selector;
267 QStringList tokens = group.simplified().split(' ');
268
269 Q_FOREACH (QString token, tokens) {
270 if (token.isEmpty() || token == " ")
271 continue;
272 if (token == ">") {
273 nextRelationShip = SelectorNode::Child;
274 } else {
275 QString styleClass;
276 QString styleId;
277 int idIndex = token.indexOf('#');
278 if (idIndex != -1) {
279 styleId = token.mid(idIndex + 1);
280 if (idIndex > 1 && token[0] == '.')
281 styleClass = token.mid(1, idIndex - 1);
282 } else if (token[0] == '.') {
283 styleClass = token.mid(1);
284 } else
285 styleClass = token;
286 if (!styleClass.isEmpty() || !styleId.isEmpty())
287 selector.append(SelectorNode(styleClass.toLower(), styleId.toLower(), nextRelationShip, sensitivity));
288 nextRelationShip = SelectorNode::Descendant;
289 }
290 }
291 pathList.append(selector);
292 }246 }
293 return pathList;247 return pathList;
294}248}
295249
=== modified file 'modules/Ubuntu/Components/plugin/themeengine_p.h'
--- modules/Ubuntu/Components/plugin/themeengine_p.h 2012-12-11 10:46:19 +0000
+++ modules/Ubuntu/Components/plugin/themeengine_p.h 2013-02-27 06:21:21 +0000
@@ -72,7 +72,6 @@
72 static bool registerName(QQuickItem *item, const QString &newName);72 static bool registerName(QQuickItem *item, const QString &newName);
73 static void setError(const QString &error);73 static void setError(const QString &error);
74 static ItemStyleAttached *attachedStyle(QObject *obj);74 static ItemStyleAttached *attachedStyle(QObject *obj);
75 static QString selectorToString(const Selector &path);
76 static QList<Selector> parseSelector(const QString &selectorString, SelectorNode::NodeSensitivity sensitivity = SelectorNode::Normal);75 static QList<Selector> parseSelector(const QString &selectorString, SelectorNode::NodeSensitivity sensitivity = SelectorNode::Normal);
7776
78// private slots77// private slots
7978
=== modified file 'modules/Ubuntu/Components/ubuntu-components-theming.qdoc'
--- modules/Ubuntu/Components/ubuntu-components-theming.qdoc 2012-11-20 10:07:44 +0000
+++ modules/Ubuntu/Components/ubuntu-components-theming.qdoc 2013-02-27 06:21:21 +0000
@@ -206,7 +206,7 @@
206 named as "red" and which are direct children of QML elements styled as class "frame"206 named as "red" and which are direct children of QML elements styled as class "frame"
207 \code207 \code
208 //QmlTheme rule208 //QmlTheme rule
209 .frame > .Button#red {209 .frame>.Button#red {
210 ...210 ...
211 }211 }
212 \endcode212 \endcode
213213
=== modified file 'tests/unit/tst_theme_engine/tst_theme_enginetest.cpp'
--- tests/unit/tst_theme_engine/tst_theme_enginetest.cpp 2012-12-11 11:09:44 +0000
+++ tests/unit/tst_theme_engine/tst_theme_enginetest.cpp 2013-02-27 06:21:21 +0000
@@ -163,8 +163,6 @@
163163
164 QObject *style = qvariant_cast<QObject*>(attached->property("style"));164 QObject *style = qvariant_cast<QObject*>(attached->property("style"));
165 QVERIFY(style);165 QVERIFY(style);
166
167 QObject *anim = qvariant_cast<QObject*>(style->property(""));
168}166}
169167
170void tst_ThemeEngine::testCase_selectorDelegates()168void tst_ThemeEngine::testCase_selectorDelegates()
171169
=== modified file 'tests/unit/tst_theme_engine_private/tst_theme_engine_privatetest.cpp'
--- tests/unit/tst_theme_engine_private/tst_theme_engine_privatetest.cpp 2013-02-25 07:19:19 +0000
+++ tests/unit/tst_theme_engine_private/tst_theme_engine_privatetest.cpp 2013-02-27 06:21:21 +0000
@@ -161,41 +161,32 @@
161 StyleTreeNode *rule;161 StyleTreeNode *rule;
162 Selector path, expected;162 Selector path, expected;
163163
164 path << SelectorNode("baseA", "", SelectorNode::Descendant);164 path = Selector(".baseA");
165 rule = engine->styleRuleForPath(path);165 rule = engine->styleRuleForPath(path);
166 // should pass166 // should pass
167 result = (rule != 0) && (rule->path() == path);167 result = (rule != 0) && (rule->path() == path);
168 QCOMPARE(result, true);168 QCOMPARE(result, true);
169169
170 path.clear();170 path = Selector("testA baseA");
171 path << SelectorNode("testA", "", SelectorNode::Descendant);171 rule = engine->styleRuleForPath(path);
172 path << SelectorNode("baseA", "", SelectorNode::Descendant);172 // should pass
173 rule = engine->styleRuleForPath(path);173 result = (rule != 0) && (rule->path() == path);
174 // should pass174 QCOMPARE(result, true);
175 result = (rule != 0) && (rule->path() == path);175
176 QCOMPARE(result, true);176 path = Selector("testA>baseA");
177177 expected = Selector("testA baseA");
178 path.clear();
179 path << SelectorNode("testA", "", SelectorNode::Descendant);
180 path << SelectorNode("baseA", "", SelectorNode::Child);
181 expected << SelectorNode("testA", "", SelectorNode::Descendant);
182 expected << SelectorNode("baseA", "", SelectorNode::Descendant);
183 rule = engine->styleRuleForPath(path);178 rule = engine->styleRuleForPath(path);
184 // should pass, but should be ".testA .baseA"179 // should pass, but should be ".testA .baseA"
185 result = (rule != 0) && (rule->path() == expected);180 result = (rule != 0) && (rule->path() == expected);
186 QCOMPARE(result, true);181 QCOMPARE(result, true);
187182
188 path.clear();183 path = Selector("testB>baseA");
189 path << SelectorNode("testB", "", SelectorNode::Descendant);
190 path << SelectorNode("baseA", "", SelectorNode::Child);
191 rule = engine->styleRuleForPath(path);184 rule = engine->styleRuleForPath(path);
192 // should pass185 // should pass
193 result = (rule != 0) && (rule->path() == path);186 result = (rule != 0) && (rule->path() == path);
194 QCOMPARE(result, true);187 QCOMPARE(result, true);
195188
196 path.clear();189 path = Selector("testB baseA");
197 path << SelectorNode("testB", "", SelectorNode::Descendant);
198 path << SelectorNode("baseA", "", SelectorNode::Descendant);
199 rule = engine->styleRuleForPath(path);190 rule = engine->styleRuleForPath(path);
200 QVERIFY2(rule != 0, "Rule not found.");191 QVERIFY2(rule != 0, "Rule not found.");
201 // should fail192 // should fail
@@ -209,9 +200,7 @@
209200
210 // build selector path201 // build selector path
211 QList<Selector> selectors = engine->parseSelector(".testB .baseA");202 QList<Selector> selectors = engine->parseSelector(".testB .baseA");
212 Selector expected, expected2;203 Selector expected("testB baseA");
213 expected << SelectorNode("testB", "", SelectorNode::Descendant);
214 expected << SelectorNode("baseA", "", SelectorNode::Descendant);
215 // should match204 // should match
216 bool result = (selectors.count() == 1) && (selectors[0] == expected);205 bool result = (selectors.count() == 1) && (selectors[0] == expected);
217 QCOMPARE(result, true);206 QCOMPARE(result, true);
@@ -221,23 +210,19 @@
221 result = (selectors.count() == 1) && !(selectors[0] == expected);210 result = (selectors.count() == 1) && !(selectors[0] == expected);
222 QCOMPARE(result, true);211 QCOMPARE(result, true);
223212
224 expected.clear();213 expected = Selector("root#id>testB baseB");
225 expected << SelectorNode("root", "id", SelectorNode::Descendant);
226 expected << SelectorNode("testB", "", SelectorNode::Child);
227 expected << SelectorNode("baseB", "", SelectorNode::Descendant);
228 selectors = engine->parseSelector(".root#id .testB > .baseA");214 selectors = engine->parseSelector(".root#id .testB > .baseA");
229 // should not match!215 // should not match!
230 result = (selectors.count() == 1) && !(selectors[0] == expected);216 result = (selectors.count() == 1) && !(selectors[0] == expected);
231 QCOMPARE(result, true);217 QCOMPARE(result, true);
232218
233 selectors = engine->parseSelector(".root#id > .testB .baseB");219 selectors = engine->parseSelector(".root#id>.testB .baseB");
234 // should match220 // should match
235 result = (selectors.count() == 1) && (selectors[0] == expected);221 result = (selectors.count() == 1) && (selectors[0] == expected);
236 QCOMPARE(result, true);222 QCOMPARE(result, true);
237223
238 selectors = engine->parseSelector(".root#id > .testB .baseB, .oneNode.bing .baseC");224 selectors = engine->parseSelector(".root#id > .testB .baseB, .oneNode.bing .baseC");
239 expected2 << SelectorNode("oneNode.bing", "", SelectorNode::Descendant);225 Selector expected2("oneNode.bing baseC");
240 expected2 << SelectorNode("baseC", "", SelectorNode::Descendant);
241 result = (selectors.count() == 2) &&226 result = (selectors.count() == 2) &&
242 (selectors[0] == expected) &&227 (selectors[0] == expected) &&
243 (selectors[1] == expected2);228 (selectors[1] == expected2);
@@ -247,44 +232,28 @@
247void tst_ThemeEnginePrivate::testCase_selectorToString()232void tst_ThemeEnginePrivate::testCase_selectorToString()
248{233{
249 engine->errorString = QString();234 engine->errorString = QString();
250 bool result = true;
251 Selector selector;235 Selector selector;
252 QString expected;236 QString expected;
253237
254 selector.clear();238 selector = Selector(".classA .classB");
255 selector << SelectorNode("classA", "", SelectorNode::Descendant);
256 selector << SelectorNode("classB", "", SelectorNode::Descendant);
257 expected = ".classa .classb";239 expected = ".classa .classb";
258 result = engine->selectorToString(selector) == expected;240 QCOMPARE(selector.toString(), expected);
259 QCOMPARE(result, true);241
260242 selector = Selector(".classA > .classB");
261 selector.clear();243 expected = ".classa>.classb";
262 selector << SelectorNode("classA", "", SelectorNode::Descendant);244 QCOMPARE(selector.toString(), expected);
263 selector << SelectorNode("classB", "", SelectorNode::Child);245
264 expected = ".classa > .classb";246 selector = Selector(".classA#id .classB");
265 result = engine->selectorToString(selector) == expected;
266 QCOMPARE(result, true);
267
268 selector.clear();
269 selector << SelectorNode("classA", "id", SelectorNode::Descendant);
270 selector << SelectorNode("classB", "", SelectorNode::Descendant);
271 expected = ".classa#id .classb";247 expected = ".classa#id .classb";
272 result = engine->selectorToString(selector) == expected;248 QCOMPARE(selector.toString(), expected);
273 QCOMPARE(result, true);249
274250 selector = Selector(".classA > .classB#id");
275 selector.clear();251 expected = ".classa>.classb#id";
276 selector << SelectorNode("classA", "", SelectorNode::Descendant);252 QCOMPARE(selector.toString(), expected);
277 selector << SelectorNode("classB", "id", SelectorNode::Child);253
278 expected = ".classa > .classb#id";254 selector = Selector(".classA.attribute>.classB#id");
279 result = engine->selectorToString(selector) == expected;255 expected = ".classa.attribute>.classb#id";
280 QCOMPARE(result, true);256 QCOMPARE(selector.toString(), expected);
281
282 selector.clear();
283 selector << SelectorNode("classA.attribute", "", SelectorNode::Descendant);
284 selector << SelectorNode("classB", "id", SelectorNode::Child);
285 expected = ".classa.attribute > .classb#id";
286 result = engine->selectorToString(selector) == expected;
287 QCOMPARE(result, true);
288}257}
289258
290QTEST_MAIN(tst_ThemeEnginePrivate)259QTEST_MAIN(tst_ThemeEnginePrivate)

Subscribers

People subscribed via source and target branches

to status/vote changes: