21
21
#include "config.h"
23
#include <libdbusmenu-glib/client.h>
23
25
#include "QuicklistMenuItem.h"
24
26
#include "QuicklistMenuItemCheckmark.h"
25
27
#include "QuicklistMenuItemLabel.h"
26
28
#include "QuicklistMenuItemRadio.h"
27
29
#include "QuicklistMenuItemSeparator.h"
30
31
#include "Nux/VLayout.h"
31
32
#include "Nux/HLayout.h"
32
33
#include "Nux/WindowThread.h"
33
34
#include "Nux/WindowCompositor.h"
34
#include "Nux/BaseWindow.h"
36
36
#include "QuicklistView.h"
37
37
#include "TestThreadHelper.h"
90
90
QuicklistMenuItemCheckmark* qlCheckmarkItem = NULL;
92
qlCheckmarkItem = new QuicklistMenuItemCheckmark(item, true);
92
qlCheckmarkItem = new QuicklistMenuItemCheckmark(item);
94
g_assert_cmpstr(qlCheckmarkItem->GetLabel(), == , "Unchecked");
94
g_assert_cmpstr(qlCheckmarkItem->GetLabel().c_str(), == , "Unchecked");
95
95
g_assert_cmpint(qlCheckmarkItem->GetEnabled(), == , false);
96
96
g_assert_cmpint(qlCheckmarkItem->GetActive(), == , false);
97
97
g_assert_cmpint(qlCheckmarkItem->GetSelectable(), == , false);
127
127
QuicklistMenuItemLabel* qlLabelItem = NULL;
129
qlLabelItem = new QuicklistMenuItemLabel(item, true);
129
qlLabelItem = new QuicklistMenuItemLabel(item);
131
g_assert_cmpstr(qlLabelItem->GetLabel(), == , "A Label");
131
g_assert_cmpstr(qlLabelItem->GetLabel().c_str(), == , "A Label");
132
132
g_assert_cmpint(qlLabelItem->GetEnabled(), == , true);
133
133
g_assert_cmpint(qlLabelItem->GetSelectable(), == , true);
134
134
g_assert_cmpint(qlLabelItem->IsMarkupEnabled(), == , true);
166
166
QuicklistMenuItemRadio* qlRadioItem = NULL;
168
qlRadioItem = new QuicklistMenuItemRadio(item, true);
168
qlRadioItem = new QuicklistMenuItemRadio(item);
169
169
qlRadioItem->EnableLabelMarkup(true);
171
g_assert_cmpstr(qlRadioItem->GetLabel(), == , "Radio Active");
171
g_assert_cmpstr(qlRadioItem->GetLabel().c_str(), == , "Radio Active");
172
172
g_assert_cmpint(qlRadioItem->GetEnabled(), == , true);
173
173
g_assert_cmpint(qlRadioItem->GetActive(), == , true);
174
174
g_assert_cmpint(qlRadioItem->GetSelectable(), == , true);
199
199
QuicklistMenuItemSeparator* qlSeparatorItem = NULL;
201
qlSeparatorItem = new QuicklistMenuItemSeparator(item, true);
201
qlSeparatorItem = new QuicklistMenuItemSeparator(item);
203
203
g_assert_cmpint(qlSeparatorItem->GetEnabled(), == , true);
204
204
g_assert_cmpint(qlSeparatorItem->GetSelectable(), == , false);
207
207
g_object_unref(item);
210
void populate_test_quicklist(QuicklistView* ql, DbusmenuMenuitem* root)
212
ql->RemoveAllMenuItem();
218
for (child = dbusmenu_menuitem_get_children(root); child != NULL; child = g_list_next(child))
220
const gchar* type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TYPE);
221
const gchar* toggle_type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE);
223
if (g_strcmp0(type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0)
225
QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
226
ql->AddMenuItem(item);
228
else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0)
230
QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
231
ql->AddMenuItem(item);
233
else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0)
235
QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
236
ql->AddMenuItem(item);
238
else //if (g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
240
QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
241
ql->AddMenuItem(item);
211
247
TestQuicklistMenuItem()
239
275
dbusmenu_menuitem_child_append(root, child);
241
277
QuicklistView* quicklist = new QuicklistView();
243
quicklist->TestMenuItems(root);
278
populate_test_quicklist(quicklist, root);
245
280
g_assert_cmpint(quicklist->GetNumItems(), == , 4);
246
g_assert_cmpint(quicklist->GetNthType(0), == , unity::MENUITEM_TYPE_LABEL);
247
g_assert_cmpint(quicklist->GetNthType(1), == , unity::MENUITEM_TYPE_SEPARATOR);
248
g_assert_cmpint(quicklist->GetNthType(2), == , unity::MENUITEM_TYPE_LABEL);
249
g_assert_cmpint(quicklist->GetNthType(3), == , unity::MENUITEM_TYPE_CHECK);
281
g_assert(quicklist->GetNthType(0) == unity::QuicklistMenuItemType::LABEL);
282
g_assert(quicklist->GetNthType(1) == unity::QuicklistMenuItemType::SEPARATOR);
283
g_assert(quicklist->GetNthType(2) == unity::QuicklistMenuItemType::LABEL);
284
g_assert(quicklist->GetNthType(3) == unity::QuicklistMenuItemType::CHECK);
251
g_assert_cmpstr(quicklist->GetNthItems(0)->GetLabel(), == , "label 0");
252
g_assert_cmpstr(quicklist->GetNthItems(2)->GetLabel(), == , "label 1");
253
g_assert_cmpstr(quicklist->GetNthItems(3)->GetLabel(), == , "check mark 0");
286
g_assert_cmpstr(quicklist->GetNthItems(0)->GetLabel().c_str(), == , "label 0");
287
g_assert_cmpstr(quicklist->GetNthItems(2)->GetLabel().c_str(), == , "label 1");
288
g_assert_cmpstr(quicklist->GetNthItems(3)->GetLabel().c_str(), == , "check mark 0");
255
290
g_assert_cmpint(quicklist->GetChildren().size(), == , 4);