aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-11-23 12:22:57 +0000
committerTarmac <>2012-11-23 12:22:57 +0000
commit374e999b82edf8ac36bf88521102bc87c30c596c (patch)
tree26ab85ce6b8a25344d9f500844c681b5b23ba24d /tests
parent04391e9723278f8bb0a0985abd50aa9c3455980d (diff)
parent2b54bfb285ab5b2571808bfc9233da4847b27017 (diff)
downloadqmenumodel-374e999b82edf8ac36bf88521102bc87c30c596c.tar.gz
qmenumodel-374e999b82edf8ac36bf88521102bc87c30c596c.tar.bz2
qmenumodel-374e999b82edf8ac36bf88521102bc87c30c596c.zip
Implemented support to tuple conversions.
Approved by PS Jenkins bot.
Diffstat (limited to 'tests')
-rw-r--r--tests/client/convertertest.cpp28
-rw-r--r--tests/client/modeltest.cpp6
-rwxr-xr-xtests/client/script_modeltest.py1
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp
index 5301653..f382332 100644
--- a/tests/client/convertertest.cpp
+++ b/tests/client/convertertest.cpp
@@ -88,6 +88,34 @@ private Q_SLOTS:
// Map
QVERIFY(compare(QVariantMap(), G_VARIANT_TYPE_VARDICT));
+
+ }
+
+ void testTupleConversion()
+ {
+ QVariantList qTuple;
+ qTuple << 1 << "2" << 3.3;
+
+ GVariant *gTuple = Converter::toGVariant(qTuple);
+ QVERIFY(g_variant_type_is_tuple(g_variant_get_type(gTuple)));
+ QCOMPARE(g_variant_n_children(gTuple), (gsize)3);
+
+ GVariant *v = g_variant_get_child_value(gTuple, 0);
+ int v0 = g_variant_get_int32(v);
+ QCOMPARE(v0, 1);
+ g_variant_unref(v);
+
+ v = g_variant_get_child_value(gTuple, 1);
+ const gchar *v1 = g_variant_get_string(v, NULL);
+ QCOMPARE(QString(v1), QString("2"));
+ g_variant_unref(v);
+
+ v = g_variant_get_child_value(gTuple, 2);
+ gdouble v2 = g_variant_get_double(v);
+ QCOMPARE(v2, 3.3);
+ g_variant_unref(v);
+
+ g_variant_unref(gTuple);
}
};
diff --git a/tests/client/modeltest.cpp b/tests/client/modeltest.cpp
index c6b2f0e..1b0ea95 100644
--- a/tests/client/modeltest.cpp
+++ b/tests/client/modeltest.cpp
@@ -218,6 +218,12 @@ private Q_SLOTS:
QCOMPARE(v.type(), QVariant::String);
QCOMPARE(v.toString(), QString("dança"));
+ // Tuple
+ v = extra["tuple"];
+ QVariantList lst;
+ lst << "1" << 2 << 3.3;
+ QCOMPARE(v.type(), QVariant::List);
+ QCOMPARE(v.toList(), lst);
}
/*
diff --git a/tests/client/script_modeltest.py b/tests/client/script_modeltest.py
index 72c294c..9f5df9c 100755
--- a/tests/client/script_modeltest.py
+++ b/tests/client/script_modeltest.py
@@ -24,6 +24,7 @@ al.appendItem("Menu0", "Menu0Act", None, None, {'x-boolean' : GLib.Variant('b',
'x-string' : GLib.Variant('s', '42'),
'x-utf8' : GLib.Variant('s', 'dança'),
'x-map' : GLib.Variant('a{sv}', pmap),
+ 'x-tuple' : GLib.Variant('(sid)', ("1", 2, 3.3)),
})
al.appendItem("Menu1", "Menu1Act")