~mterry/unity8/split

« back to all changes in this revision

Viewing changes to tests/plugins/Unity/Indicators/rootactionstatetest.cpp

  • Committer: Michael Terry
  • Date: 2014-05-15 15:04:44 UTC
  • mfrom: (138.516.136 unity8)
  • Revision ID: michael.terry@canonical.com-20140515150444-mijpp6zz1c6o04jn
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include <unitymenumodel.h>
23
23
#include <QtTest>
 
24
#include <gio/gio.h>
24
25
 
25
26
class RootActionStateTest : public QObject
26
27
{
52
53
        QVERIFY(rootState->menu() == NULL);
53
54
        delete rootState;
54
55
    }
 
56
 
 
57
    void testToQVariantIcons()
 
58
    {
 
59
        GVariantBuilder builderIcons;
 
60
        g_variant_builder_init(&builderIcons, G_VARIANT_TYPE("av"));
 
61
        for (int i = 0; i < 3; i ++) {
 
62
 
 
63
            GIcon* icon = NULL;
 
64
            icon = g_icon_new_for_string (QString("testIcon%1").arg(i).toUtf8().constData(), NULL);
 
65
 
 
66
            g_variant_builder_add(&builderIcons,
 
67
                                  "v",
 
68
                                  g_icon_serialize (icon));
 
69
            g_object_unref(icon);
 
70
        }
 
71
 
 
72
        GVariantBuilder builderParams;
 
73
        g_variant_builder_init(&builderParams, G_VARIANT_TYPE_ARRAY);
 
74
        GVariant* icons = g_variant_builder_end (&builderIcons);
 
75
        g_variant_ref_sink (icons);
 
76
        g_variant_builder_add (&builderParams, "{sv}", g_strdup ("icons"), icons, NULL);
 
77
 
 
78
        GVariant* params = g_variant_builder_end (&builderParams);
 
79
 
 
80
        RootActionState rootState;
 
81
        QVariant result = rootState.toQVariant(params);
 
82
        g_variant_unref(params);
 
83
 
 
84
        QVariantMap paramResult = result.toMap();
 
85
        QVERIFY(paramResult.contains("icons"));
 
86
 
 
87
        QStringList serializedIcons = paramResult["icons"].toStringList();
 
88
        QVERIFY(serializedIcons[0] == "image://theme/testIcon0");
 
89
        QVERIFY(serializedIcons[1] == "image://theme/testIcon1");
 
90
        QVERIFY(serializedIcons[2] == "image://theme/testIcon2");
 
91
    }
55
92
};
56
93
 
57
94
QTEST_GUILESS_MAIN(RootActionStateTest)