File: test-action-info-store.c

package info (click to toggle)
libgedit-amtk 5.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 692 kB
  • sloc: ansic: 2,996; xml: 288; makefile: 7
file content (57 lines) | stat: -rw-r--r-- 1,452 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* SPDX-FileCopyrightText: 2017 - Sébastien Wilmet <swilmet@gnome.org>
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include <amtk/amtk.h>

static void
test_add_entries (void)
{
	AmtkActionInfoStore *store;
	AmtkActionInfoCentralStore *central_store;
	AmtkActionInfo *info1;
	AmtkActionInfo *info2;

	const AmtkActionInfoEntry entries[] =
	{
		/* action, icon, label, accel, tooltip */

		{ "app.quit", "application-exit", "_Quit", "<Control>q",
		  "Quit the application" },

		/* Tooltip field missing, must be NULL. */
		{ "win.open", "document-open", "_Open", "<Control>o" },
	};

	store = amtk_action_info_store_new ();

	amtk_action_info_store_add_entries (store,
					    entries,
					    G_N_ELEMENTS (entries),
					    NULL);

	info1 = amtk_action_info_store_lookup (store, "win.open");
	g_assert_true (info1 != NULL);
	g_assert_cmpstr (amtk_action_info_get_icon_name (info1), ==, "document-open");
	g_assert_true (amtk_action_info_get_tooltip (info1) == NULL);

	central_store = amtk_action_info_central_store_get_singleton ();
	info2 = amtk_action_info_central_store_lookup (central_store, "win.open");
	g_assert_true (info1 == info2);

	info1 = amtk_action_info_store_lookup (store, "plouf");
	g_assert_true (info1 == NULL);

	g_object_unref (store);
}

int
main (int    argc,
      char **argv)
{
	g_test_init (&argc, &argv, NULL);

	g_test_add_func ("/action-info-store/add-entries", test_add_entries);

	return g_test_run ();
}