2807.2.4
by Albert Astals
Add a unit test for the dbus indicators that check the entries are in the correct order |
1 |
#include "test_service_panel.h" |
2 |
||
3149.2.1
by Marco Trevisan (Treviño)
test-gtest-service: move services to GDBusServer/GDBusObject |
3 |
namespace unity |
4 |
{
|
|
5 |
namespace service |
|
6 |
{
|
|
7 |
namespace
|
|
8 |
{
|
|
9 |
static const char * panel_interface = |
|
2807.2.4
by Albert Astals
Add a unit test for the dbus indicators that check the entries are in the correct order |
10 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
11 |
"<node name=\"/\">\n" |
|
3149.2.1
by Marco Trevisan (Treviño)
test-gtest-service: move services to GDBusServer/GDBusObject |
12 |
" <interface name=\"com.canonical.Unity.Panel.Service\">\n" |
2807.2.4
by Albert Astals
Add a unit test for the dbus indicators that check the entries are in the correct order |
13 |
"\n" |
14 |
"<!-- Begin of real methods/signals -->\n" |
|
15 |
" <method name='Sync'>"
|
|
16 |
" <arg type='a(ssssbbusbbi)' name='state' direction='out'/>"
|
|
17 |
" </method>"
|
|
18 |
"\n" |
|
19 |
" <signal name='ReSync'>"
|
|
20 |
" <arg type='s' name='indicator_id' />"
|
|
21 |
" </signal>"
|
|
22 |
"\n" |
|
23 |
"<!-- Begin of test only methods/signals -->\n" |
|
24 |
"\n" |
|
25 |
" <method name='TriggerResync1' />"
|
|
26 |
"\n" |
|
27 |
" <method name='TriggerResync1Sent'>"
|
|
28 |
" <arg type='b' name='sent' direction='out'/>"
|
|
29 |
" </method>"
|
|
30 |
"\n" |
|
31 |
" </interface>\n" |
|
32 |
"</node>\n" |
|
33 |
;
|
|
3149.2.1
by Marco Trevisan (Treviño)
test-gtest-service: move services to GDBusServer/GDBusObject |
34 |
|
35 |
void add_entry_id(GVariantBuilder *b) |
|
36 |
{
|
|
37 |
g_variant_builder_add (b, "(ssssbbusbbi)", |
|
38 |
"test_indicator_id", |
|
39 |
"test_entry_id", |
|
40 |
"test_entry_name_hint", |
|
41 |
"test_entry_label", |
|
42 |
TRUE, /* label sensitive */ |
|
43 |
TRUE, /* label visible */ |
|
44 |
0, /* image type */ |
|
45 |
"", /* image_data */ |
|
46 |
TRUE, /* image sensitive */ |
|
47 |
TRUE, /* image visible */ |
|
48 |
1 /* priority */); |
|
49 |
}
|
|
50 |
||
51 |
void add_entry_id_2(GVariantBuilder *b) |
|
52 |
{
|
|
53 |
g_variant_builder_add (b, "(ssssbbusbbi)", |
|
54 |
"test_indicator_id", |
|
55 |
"test_entry_id2", |
|
56 |
"test_entry_name_hint2", |
|
57 |
"test_entry_label2", |
|
58 |
TRUE, /* label sensitive */ |
|
59 |
TRUE, /* label visible */ |
|
60 |
0, /* image type */ |
|
61 |
"", /* image_data */ |
|
62 |
TRUE, /* image sensitive */ |
|
63 |
TRUE, /* image visible */ |
|
64 |
1 /* priority */); |
|
65 |
}
|
|
66 |
}
|
|
67 |
||
68 |
||
69 |
Panel::Panel() |
|
70 |
: sync_return_mode_(0) |
|
71 |
, trigger_resync1_sent_(false) |
|
72 |
{
|
|
73 |
auto object = glib::DBusObjectBuilder::GetObjectsForIntrospection(panel_interface).front(); |
|
74 |
object->SetMethodsCallsHandler(sigc::mem_fun(this, &Panel::OnMethodCall)); |
|
75 |
||
76 |
server_.AddObject(object, "/com/canonical/Unity/Panel/Service"); |
|
77 |
}
|
|
78 |
||
79 |
GVariant* Panel::OnMethodCall(std::string const& method, GVariant *parameters) |
|
80 |
{
|
|
81 |
if (method == "Sync") |
|
2807.2.4
by Albert Astals
Add a unit test for the dbus indicators that check the entries are in the correct order |
82 |
{
|
83 |
GVariantBuilder b; |
|
84 |
||
85 |
g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssssbbusbbi))")); |
|
86 |
g_variant_builder_open (&b, G_VARIANT_TYPE ("a(ssssbbusbbi)")); |
|
87 |
||
3149.2.1
by Marco Trevisan (Treviño)
test-gtest-service: move services to GDBusServer/GDBusObject |
88 |
if (sync_return_mode_ == 0) |
89 |
{
|
|
90 |
add_entry_id(&b); |
|
91 |
add_entry_id_2(&b); |
|
92 |
}
|
|
93 |
else if (sync_return_mode_ == 1) |
|
94 |
{
|
|
95 |
add_entry_id_2(&b); |
|
96 |
add_entry_id(&b); |
|
97 |
}
|
|
98 |
||
99 |
if (sync_return_mode_ == 1) |
|
100 |
{
|
|
101 |
trigger_resync1_sent_ = true; |
|
2807.2.4
by Albert Astals
Add a unit test for the dbus indicators that check the entries are in the correct order |
102 |
}
|
103 |
||
104 |
g_variant_builder_close (&b); |
|
3149.2.1
by Marco Trevisan (Treviño)
test-gtest-service: move services to GDBusServer/GDBusObject |
105 |
return g_variant_builder_end (&b); |
106 |
}
|
|
107 |
else if (method == "TriggerResync1") |
|
108 |
{
|
|
109 |
sync_return_mode_ = 1; |
|
110 |
trigger_resync1_sent_ = false; |
|
111 |
||
112 |
server_.GetObjects().front()->EmitSignal("ReSync", g_variant_new("(s)", "")); |
|
113 |
}
|
|
114 |
else if (method == "TriggerResync1Sent") |
|
115 |
{
|
|
116 |
return g_variant_new("(b)", trigger_resync1_sent_ ? TRUE : FALSE); |
|
117 |
}
|
|
118 |
||
119 |
return nullptr; |
|
120 |
}
|
|
121 |
||
122 |
}
|
|
123 |
}
|