aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Moenicke <thomas.moenicke@nokia.com>2010-11-11 15:17:19 +0200
committerArmin Berres <armin.berres@basyskom.de>2011-01-06 11:21:11 +0100
commit007270faed92e3ca9d2631d490c0a757a1f668b4 (patch)
tree7d3650319975e216f8b091d478b8579e9c3040f3 /tests
parent592508a26ae899a86392eeabca09404afd470f5b (diff)
Changes: replace strings by ids in style classes and style attributes
RevBy: Armin Berres, Peter Penz Details: Strings for names, types and keywords are passed around as unique integers to reduce overhead with string operations. The strings and the mapping to ids are stored in a mmaped file. The memory of all strings will be shared between application. This part has been written by Armin Berres.
Diffstat (limited to 'tests')
-rw-r--r--tests/ft_mstylesheet/ft_mstylesheet.pro4
-rw-r--r--tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp165
-rw-r--r--tests/ft_mstylesheetparser/ft_mstylesheetparser.pro7
-rw-r--r--tests/ut_mlogicalvalues/ut_mlogicalvalues.pro7
4 files changed, 95 insertions, 88 deletions
diff --git a/tests/ft_mstylesheet/ft_mstylesheet.pro b/tests/ft_mstylesheet/ft_mstylesheet.pro
index 78f8a940..1207f2b6 100644
--- a/tests/ft_mstylesheet/ft_mstylesheet.pro
+++ b/tests/ft_mstylesheet/ft_mstylesheet.pro
@@ -11,7 +11,8 @@ STYLE_HEADERS += testobjectstyle.h testobject2style.h testobject3style.h
SOURCES += \
ft_mstylesheet.cpp \
$$MSRCDIR/corelib/theme/mlogicalvalues.cpp \
- $$MSRCDIR/corelib/style/mstylesheetattribute.cpp
+ $$MSRCDIR/corelib/style/mstylesheetattribute.cpp \
+ $$MSRCDIR/corelib/style/muniquestringcache.cpp
HEADERS += \
ft_mstylesheet.h \
@@ -23,6 +24,7 @@ HEADERS += \
testwidget3.h \
$$MSRCDIR/corelib/theme/mlogicalvalues.h \
$$MSRCDIR/corelib/style/mstylesheetattribute.h \
+ $$MSRCDIR/corelib/style/muniquestringcache.h \
$$STYLE_HEADERS
support_files.files += \
diff --git a/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp b/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp
index 154f7125..fff45d74 100644
--- a/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp
+++ b/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp
@@ -28,7 +28,7 @@
// include this to get theme profiling support
//#include "../../src/corelib/theme/mtheme_p.h"
-const int NUMBER_OF_LOOPS = 100;
+const int NUMBER_OF_LOOPS = 10000;
Ft_MStyleSheetParser::Ft_MStyleSheetParser()
: m_logicalValues(NULL),
@@ -444,50 +444,51 @@ void Ft_MStyleSheetParser::test_constants()
info = m_subject->fileInfoList()[1];
QCOMPARE(info->selectors.count(), 1);
QCOMPARE(info->selectors[0]->attributes()->count(), 1);
- info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"), NULL);
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getValue(), QByteArray("10px"));
+ info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex("attr-width"), NULL);
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getValue(), QByteArray("10px"));
info = m_subject->fileInfoList()[2];
QCOMPARE(info->selectors.count(), 1);
QCOMPARE(info->selectors[0]->attributes()->count(), 13);
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getValue(), QByteArray("10"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getValue(), QByteArray("\"name\""));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getValue(), QByteArray("true"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getValue(), QByteArray("10px 15px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getValue(), QByteArray("17px 11px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getValue(), QByteArray("sans 12px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getValue(), QByteArray("arial 10px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getValue(), QByteArray("#0abba0"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getValue(), QByteArray(""));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getValue(), QByteArray(""));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getValue(), QByteArray("#000000"));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getValue(), QByteArray("#00ff00"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getValue(), QByteArray("10"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")));
+
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getValue(), QByteArray("\"name\""));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getValue(), QByteArray("true"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getValue(), QByteArray("10px 15px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getValue(), QByteArray("17px 11px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getValue(), QByteArray("sans 12px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getValue(), QByteArray("arial 10px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getValue(), QByteArray("#0abba0"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getValue(), QByteArray(""));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getValue(), QByteArray(""));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getValue(), QByteArray("#000000"));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getValue(), QByteArray("#00ff00"));
}
void Ft_MStyleSheetParser::test_constants_binary()
@@ -513,49 +514,49 @@ void Ft_MStyleSheetParser::test_constants_binary()
info = m_subject->fileInfoList()[1];
QCOMPARE(info->selectors.count(), 1);
QCOMPARE(info->selectors[0]->attributes()->count(), 1);
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getValue(), QByteArray("10px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getValue(), QByteArray("10px"));
info = m_subject->fileInfoList()[2];
QCOMPARE(info->selectors.count(), 1);
QCOMPARE(info->selectors[0]->attributes()->count(), 13);
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getValue(), QByteArray("10"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getValue(), QByteArray("\"name\""));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getValue(), QByteArray("true"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getValue(), QByteArray("10px 15px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getValue(), QByteArray("17px 11px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getValue(), QByteArray("sans 12px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getValue(), QByteArray("arial 10px"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getValue(), QByteArray("#0abba0"));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getValue(), QByteArray(""));
- QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"), NULL));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getValue(), QByteArray(""));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getValue(), QByteArray("#000000"));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")));
- QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getValue(), QByteArray("#00ff00"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getValue(), QByteArray("10"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getValue(), QByteArray("\"name\""));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getValue(), QByteArray("true"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getValue(), QByteArray("10px 15px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getValue(), QByteArray("17px 11px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getValue(), QByteArray("sans 12px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getValue(), QByteArray("arial 10px"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getValue(), QByteArray("#0abba0"));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getValue(), QByteArray(""));
+ QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")), NULL));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getValue(), QByteArray(""));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getValue(), QByteArray("#000000"));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")));
+ QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getValue(), QByteArray("#00ff00"));
}
void Ft_MStyleSheetParser::test_binary_equality()
diff --git a/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro b/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro
index afe434f6..efcf1ff3 100644
--- a/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro
+++ b/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro
@@ -8,13 +8,14 @@ INCLUDEPATH += $$MSRCDIR/corelib/core/
SOURCES += \
ft_mstylesheetparser.cpp \
$$MSRCDIR/corelib/theme/mlogicalvalues.cpp \
- $$MSRCDIR/corelib/style/mstylesheetattribute.cpp
-
+ $$MSRCDIR/corelib/style/muniquestringcache.cpp \
+ $$MSRCDIR/corelib/style/mstylesheetattribute.cpp \
HEADERS += \
ft_mstylesheetparser.h \
$$MSRCDIR/corelib/theme/mlogicalvalues.h \
- $$MSRCDIR/corelib/style/mstylesheetattribute.h
+ $$MSRCDIR/corelib/style/muniquestringcache.h \
+ $$MSRCDIR/corelib/style/mstylesheetattribute.h \
support_files.files += \
*.css \
diff --git a/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro b/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro
index a47f1440..a8366e99 100644
--- a/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro
+++ b/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro
@@ -8,13 +8,16 @@ INCLUDEPATH += $$MSRCDIR/corelib/core/
SOURCES += \
ut_mlogicalvalues.cpp \
$$MSRCDIR/corelib/theme/mlogicalvalues.cpp \
- $$MSRCDIR/corelib/style/mstylesheetattribute.cpp
+ $$MSRCDIR/corelib/style/mstylesheetattribute.cpp \
+ $$MSRCDIR/corelib/style/muniquestringcache.cpp
HEADERS += \
ut_mlogicalvalues.h \
$$MSRCDIR/corelib/theme/mlogicalvalues.h \
$$MSRCDIR/corelib/theme/mlogicalvalues_p.h \
- $$MSRCDIR/corelib/style/mstylesheetattribute.h
+ $$MSRCDIR/corelib/style/mstylesheetattribute.h \
+ $$MSRCDIR/corelib/style/muniquestringcache.h
+
support_files.files += *.ini