aboutsummaryrefslogtreecommitdiff
path: root/tests/client
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-11-28 20:07:56 -0300
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-11-28 20:07:56 -0300
commit98ed17ed5c2ebab3a396906d4219af2e99988370 (patch)
tree526d7f52989723d623e426862393890c60b6cece /tests/client
parent53dfc2a919fd03f5570cb106d71d3989a3f528d9 (diff)
parentda5a0437d57df35409fedb568b7ebf4e3d6af0da (diff)
downloadqmenumodel-98ed17ed5c2ebab3a396906d4219af2e99988370.tar.gz
qmenumodel-98ed17ed5c2ebab3a396906d4219af2e99988370.tar.bz2
qmenumodel-98ed17ed5c2ebab3a396906d4219af2e99988370.zip
Merged mainline.
Diffstat (limited to 'tests/client')
-rw-r--r--tests/client/CMakeLists.txt8
-rw-r--r--tests/client/actiongrouptest.cpp9
-rw-r--r--tests/client/convertertest.cpp28
-rw-r--r--tests/client/modeltest.cpp20
-rwxr-xr-xtests/client/script_actiongrouptest.py5
-rwxr-xr-xtests/client/script_modeltest.py1
6 files changed, 65 insertions, 6 deletions
diff --git a/tests/client/CMakeLists.txt b/tests/client/CMakeLists.txt
index d946fad..392437c 100644
--- a/tests/client/CMakeLists.txt
+++ b/tests/client/CMakeLists.txt
@@ -8,9 +8,15 @@ macro(declare_test testname)
${GIO_LDFLAGS}
)
+ if(TEST_XML_OUTPUT)
+ set(TEST_ARGS -p -xunitxml -p -o -p test_${testname}.xml)
+ else()
+ set(TEST_ARGS "")
+ endif()
+
add_test(${testname}
${DBUS_RUNNER}
- --task ${CMAKE_CURRENT_BINARY_DIR}/${testname} -p -xunitxml -p -o -p test_${testname}.xml --task-name Client
+ --task ${CMAKE_CURRENT_BINARY_DIR}/${testname} ${TEST_ARGS} --task-name Client
--task ${CMAKE_CURRENT_SOURCE_DIR}/script_${testname}.py --task-name Server
--ignore-return)
set_tests_properties(${testname} PROPERTIES
diff --git a/tests/client/actiongrouptest.cpp b/tests/client/actiongrouptest.cpp
index 6598d2e..d187ea7 100644
--- a/tests/client/actiongrouptest.cpp
+++ b/tests/client/actiongrouptest.cpp
@@ -141,11 +141,16 @@ private Q_SLOTS:
QStateAction *act = m_actionGroup.action(action.toString());
QVERIFY(act);
- act->trigger();
+ // test action name
+ QCOMPARE(act->property("name").toString(), QString("Menu1Act"));
+
+ act->activate(QVariant("42"));
// wait for dbus propagation
QTest::qWait(500);
- QCOMPARE(m_script.popActivatedAction(), QString("Menu1Act"));
+ QPair<QString, QVariant> result = m_script.popActivatedAction();
+ QCOMPARE(result.first, QString("Menu1Act"));
+ QCOMPARE(result.second.toString(), QString("42"));
}
/*
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..8be92a6 100644
--- a/tests/client/modeltest.cpp
+++ b/tests/client/modeltest.cpp
@@ -25,6 +25,19 @@
#include <QtTest>
#include <QDebug>
+extern "C" {
+#include <gio/gio.h>
+}
+
+class TestMenuModel : public QMenuModel
+{
+public:
+ TestMenuModel(GMenuModel *other, QObject *parent=0)
+ : QMenuModel(other, parent)
+ {
+ }
+};
+
class ModelTest : public QObject
{
Q_OBJECT
@@ -218,6 +231,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);
}
/*
@@ -241,7 +260,6 @@ private Q_SLOTS:
delete model;
}
-
};
QTEST_MAIN(ModelTest)
diff --git a/tests/client/script_actiongrouptest.py b/tests/client/script_actiongrouptest.py
index 2af4841..bb54dae 100755
--- a/tests/client/script_actiongrouptest.py
+++ b/tests/client/script_actiongrouptest.py
@@ -3,10 +3,11 @@
import time
from gi.repository import GLib
from menuscript import Script, ActionList, MENU_OBJECT_PATH
+from gi._gi import variant_type_from_string
al = ActionList(MENU_OBJECT_PATH)
-al.appendItem("Menu0", "Menu0Act")
-al.appendItem("Menu1", "Menu1Act")
+al.appendItem("Menu0", "Menu0Act", actionStateType=variant_type_from_string('s'))
+al.appendItem("Menu1", "Menu1Act", actionStateType=variant_type_from_string('s'))
al.removeItem("1", "Menu1Act")
t = Script.create(al)
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")