Commit 5686f5fd authored by Eike Ziller's avatar Eike Ziller Committed by hjk

QUrl dumper: use correct string type name and extend test

Change-Id: I7fe88d11b3d52ba31d3e8564b673a35001e31488
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent d8aadac3
......@@ -1676,23 +1676,31 @@ def qdump__QUrl(d, value):
path = d.encodeStringHelper(d.dereference(schemeAddr + 4 * d.ptrSize()))
query = d.encodeStringHelper(d.dereference(schemeAddr + 5 * d.ptrSize()))
fragment = d.encodeStringHelper(d.dereference(schemeAddr + 6 * d.ptrSize()))
str = scheme
str += "3a002f002f00"
str += host
str += path
d.putValue(str, Hex4EncodedLittleEndian)
port = d.extractInt(d.dereferenceValue(value) + d.intSize())
url = scheme
url += "3a002f002f00"
if len(userName):
url += userName
url += "4000"
url += host
if port >= 0:
url += "3a00"
url += ''.join(["%02x00" % ord(c) for c in str(port)])
url += path
d.putValue(url, Hex4EncodedLittleEndian)
d.putNumChild(8)
if d.isExpanded():
stringType = d.lookupType(d.ns + "QString")
with Children(d):
d.putIntItem("port", d.extractInt(d.dereferenceValue(value) + d.intSize()))
d.putGenericItem("scheme", "QString", scheme, Hex4EncodedLittleEndian)
d.putGenericItem("userName", "QString", userName, Hex4EncodedLittleEndian)
d.putGenericItem("password", "QString", password, Hex4EncodedLittleEndian)
d.putGenericItem("host", "QString", host, Hex4EncodedLittleEndian)
d.putGenericItem("path", "QString", path, Hex4EncodedLittleEndian)
d.putGenericItem("query", "QString", query, Hex4EncodedLittleEndian)
d.putGenericItem("fragment", "QString", fragment, Hex4EncodedLittleEndian)
d.putIntItem("port", port)
d.putGenericItem("scheme", stringType, scheme, Hex4EncodedLittleEndian)
d.putGenericItem("userName", stringType, userName, Hex4EncodedLittleEndian)
d.putGenericItem("password", stringType, password, Hex4EncodedLittleEndian)
d.putGenericItem("host", stringType, host, Hex4EncodedLittleEndian)
d.putGenericItem("path", stringType, path, Hex4EncodedLittleEndian)
d.putGenericItem("query", stringType, query, Hex4EncodedLittleEndian)
d.putGenericItem("fragment", stringType, fragment, Hex4EncodedLittleEndian)
def qdumpHelper_QVariant_0(d, data):
# QVariant::Invalid
......
......@@ -196,10 +196,11 @@ static QByteArray parentIName(const QByteArray &iname)
struct ValueBase
{
ValueBase() : hasPtrSuffix(false), isFloatValue(false), version(0) {}
ValueBase() : hasPtrSuffix(false), isFloatValue(false), substituteNamespace(true), version(0) {}
bool hasPtrSuffix;
bool isFloatValue;
bool substituteNamespace;
int version;
};
......@@ -232,7 +233,8 @@ struct Value : public ValueBase
if (actualValue == QLatin1String(" "))
actualValue.clear(); // FIXME: Remove later.
QString expectedValue = value;
expectedValue.replace(QLatin1Char('@'), QString::fromLatin1(context.nameSpace));
if (substituteNamespace)
expectedValue.replace(QLatin1Char('@'), QString::fromLatin1(context.nameSpace));
if (hasPtrSuffix)
return actualValue.startsWith(expectedValue + QLatin1String(" @0x"))
......@@ -277,6 +279,11 @@ struct Value5 : Value
Value5(const QByteArray &value) : Value(value) { version = 5; }
};
struct UnsubstitutedValue : Value
{
UnsubstitutedValue(const QByteArray &value) : Value(value) { substituteNamespace = false; }
};
struct Type
{
Type() {}
......@@ -3171,10 +3178,18 @@ void tst_Dumpers::dumper_data()
QTest::newRow("QUrl")
<< Data("#include <QUrl>",
"QUrl url = QUrl::fromEncoded(\"http://qt-project.org/have_fun\");\n"
"QUrl url = QUrl::fromEncoded(\"http://foo@qt-project.org:10/have_fun\");\n"
"unused(&url);\n")
% CoreProfile()
% Check("url", "\"http://qt-project.org/have_fun\"", "@QUrl");
% Check("url", UnsubstitutedValue("\"http://foo@qt-project.org:10/have_fun\""), "@QUrl")
% Check("url.port", Value5("10"), "int")
% Check("url.scheme", Value5("\"http\""), "@QString")
% Check("url.userName", Value5("\"foo\""), "@QString")
% Check("url.password", Value5("\"\""), "@QString")
% Check("url.host", Value5("\"qt-project.org\""), "@QString")
% Check("url.path", Value5("\"/have_fun\""), "@QString")
//% Check("url.query", Value5("\"\""), "@QString") That's a QByteArray in Qt 4
% Check("url.fragment", Value5("\"\""), "@QString");
QTest::newRow("QStringQuotes")
<< Data("#include <QString>\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment