summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-14 05:05:18 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-14 05:05:18 (GMT)
commit176698a91d3b2256a093785967c6706328981af4 (patch)
tree8c94a018b4e12a81b1b9ee4ae2e5853010435606
parent513cc4be0bec4a5fb303062ecbecf87708dc0e9b (diff)
downloadQt-176698a91d3b2256a093785967c6706328981af4.zip
Qt-176698a91d3b2256a093785967c6706328981af4.tar.gz
Qt-176698a91d3b2256a093785967c6706328981af4.tar.bz2
Force QML files to be always UTF-8.
Ensure test works in all locales.
-rw-r--r--src/declarative/qml/qmlerror.cpp1
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp1
-rw-r--r--tests/auto/declarative/declarative.pro3
-rw-r--r--tests/auto/declarative/qmllanguage/data/I18nType30.qml (renamed from tests/auto/declarative/qmllanguage/data/I18nÁâãäå.qml)0
-rw-r--r--tests/auto/declarative/qmllanguage/data/i18nType.qml2
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp30
6 files changed, 28 insertions, 9 deletions
diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp
index 5ee9144..514fe44 100644
--- a/src/declarative/qml/qmlerror.cpp
+++ b/src/declarative/qml/qmlerror.cpp
@@ -201,6 +201,7 @@ QDebug operator<<(QDebug debug, const QmlError &error)
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
QTextStream stream(data, QIODevice::ReadOnly);
+ stream.setCodec("UTF-8");
const QString code = stream.readAll();
const QStringList lines = code.split(QLatin1Char('\n'));
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 9cc12b3..6e5f315 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -870,6 +870,7 @@ bool QmlScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
const QString fileName = url.toString();
QTextStream stream(qmldata, QIODevice::ReadOnly);
+ stream.setCodec("UTF-8");
const QString code = stream.readAll();
data = new QmlScriptParserJsASTData(fileName);
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index eef9da7..b51e285 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -25,9 +25,6 @@ SUBDIRS += anchors \
states \
visual
-SUBDIRS -= examples # Human-interactive
-
# Tests which should run in Pulse
PULSE_TESTS = $$SUBDIRS
-PULSE_TESTS -= visual # All except 'visual' tests, allegedly too flaky
diff --git a/tests/auto/declarative/qmllanguage/data/I18nÁâãäå.qml b/tests/auto/declarative/qmllanguage/data/I18nType30.qml
index 42dbc69..42dbc69 100644
--- a/tests/auto/declarative/qmllanguage/data/I18nÁâãäå.qml
+++ b/tests/auto/declarative/qmllanguage/data/I18nType30.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nType.qml b/tests/auto/declarative/qmllanguage/data/i18nType.qml
index 11ef895..d7954ef 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nType.qml
+++ b/tests/auto/declarative/qmllanguage/data/i18nType.qml
@@ -1 +1 @@
-I18nÁâãäå { }
+I18nTypeÁâãäå { }
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index b99d040..b68d9bf 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -24,6 +24,8 @@ public:
}
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void errors_data();
void errors();
@@ -116,6 +118,24 @@ inline QUrl TEST_FILE(const char *filename)
return TEST_FILE(QLatin1String(filename));
}
+void tst_qmllanguage::initTestCase()
+{
+ // Create locale-specific file
+ // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit
+ // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
+ // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
+ QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
+ QVERIFY(in.open(QIODevice::ReadOnly));
+ QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\241\303\242\303\243\303\244\303\245.qml")).toLocalFile());
+ QVERIFY(out.open(QIODevice::WriteOnly));
+ out.write(in.readAll());
+}
+
+void tst_qmllanguage::cleanupTestCase()
+{
+ QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\241\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
+}
+
void tst_qmllanguage::errors_data()
{
QTest::addColumn<QString>("file");
@@ -686,11 +706,11 @@ void tst_qmllanguage::i18n_data()
{
QTest::addColumn<QString>("file");
QTest::addColumn<QString>("stringProperty");
- QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test áâãäå (5 accented 'a' letters)");
- QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test áâãäå: 10");
- QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test áâãäå: 15");
- QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test áâãäå: 20");
- QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test áâãäå: 30");
+ QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)");
+ QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10");
+ QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
+ QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
+ QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
}
void tst_qmllanguage::i18n()