66#define TEST_FIXTURE "keymanutil-test"
77
88void
9- delete_key (gchar * testname ) {
10- gchar * path = g_strdup_printf ("%s%s/%s/" , KEYMAN_DCONF_PATH , TEST_FIXTURE , testname );
11- GSettings * settings = g_settings_new_with_path (KEYMAN_CHILD_DCONF_NAME , path );
9+ delete_options_key (gchar * testname ) {
10+ gchar * path = g_strdup_printf ("%s%s/%s/" , KEYMAN_DCONF_OPTIONS_PATH , TEST_FIXTURE , testname );
11+ GSettings * settings = g_settings_new_with_path (KEYMAN_DCONF_OPTIONS_CHILD_NAME , path );
1212 g_settings_reset (settings , KEYMAN_DCONF_OPTIONS_KEY );
1313 g_object_unref (G_OBJECT (settings ));
1414 g_free (path );
1515}
1616
1717void
18- set_key (gchar * testname , gchar * * options ) {
19- gchar * path = g_strdup_printf ("%s%s/%s/" , KEYMAN_DCONF_PATH , TEST_FIXTURE , testname );
20- GSettings * settings = g_settings_new_with_path (KEYMAN_CHILD_DCONF_NAME , path );
18+ set_options_key (gchar * testname , gchar * * options ) {
19+ gchar * path = g_strdup_printf ("%s%s/%s/" , KEYMAN_DCONF_OPTIONS_PATH , TEST_FIXTURE , testname );
20+ GSettings * settings = g_settings_new_with_path (KEYMAN_DCONF_OPTIONS_CHILD_NAME , path );
2121 g_settings_set_strv (settings , KEYMAN_DCONF_OPTIONS_KEY , (const gchar * const * )options );
2222 g_object_unref (G_OBJECT (settings ));
2323 g_free (path );
2424}
2525
2626gchar * *
27- get_key (gchar * testname ) {
28- gchar * path = g_strdup_printf ("%s%s/%s/" , KEYMAN_DCONF_PATH , TEST_FIXTURE , testname );
29- GSettings * settings = g_settings_new_with_path (KEYMAN_CHILD_DCONF_NAME , path );
27+ get_options_key (gchar * testname ) {
28+ gchar * path = g_strdup_printf ("%s%s/%s/" , KEYMAN_DCONF_OPTIONS_PATH , TEST_FIXTURE , testname );
29+ GSettings * settings = g_settings_new_with_path (KEYMAN_DCONF_OPTIONS_CHILD_NAME , path );
3030 gchar * * result = g_settings_get_strv (settings , KEYMAN_DCONF_OPTIONS_KEY );
3131 g_object_unref (G_OBJECT (settings ));
3232 g_free (path );
3737test_keyman_put_options_todconf__new_key () {
3838 // Initialize
3939 gchar * testname = "test_keyman_put_options_todconf__new_key" ;
40- delete_key (testname );
40+ delete_options_key (testname );
4141 gchar * value = g_strdup_printf ("%d" , g_test_rand_int ());
4242
4343 // Execute
4444 keyman_put_options_todconf (TEST_FIXTURE , testname , "new_key" , value );
4545
4646 // Verify
47- gchar * * options = get_key (testname );
47+ gchar * * options = get_options_key (testname );
4848 gchar * expected = g_strdup_printf ("new_key=%s" , value );
4949 g_assert_nonnull (options );
5050 g_assert_cmpstr (options [0 ], = = , expected );
@@ -54,23 +54,23 @@ test_keyman_put_options_todconf__new_key() {
5454 g_free (expected );
5555 g_free (value );
5656 g_strfreev (options );
57- delete_key (testname );
57+ delete_options_key (testname );
5858}
5959
6060void
6161test_keyman_put_options_todconf__other_keys () {
6262 // Initialize
6363 gchar * testname = "test_keyman_put_options_todconf__other_keys" ;
64- delete_key (testname );
64+ delete_options_key (testname );
6565 gchar * existingKeys [] = {"key1=val1" , "key2=val2" , NULL };
66- set_key (testname , existingKeys );
66+ set_options_key (testname , existingKeys );
6767 gchar * value = g_strdup_printf ("%d" , g_test_rand_int ());
6868
6969 // Execute
7070 keyman_put_options_todconf (TEST_FIXTURE , testname , "new_key" , value );
7171
7272 // Verify
73- gchar * * options = get_key (testname );
73+ gchar * * options = get_options_key (testname );
7474 gchar * expected = g_strdup_printf ("new_key=%s" , value );
7575 g_assert_nonnull (options );
7676 g_assert_cmpstr (options [0 ], = = , "key1=val1" );
@@ -82,23 +82,23 @@ test_keyman_put_options_todconf__other_keys() {
8282 g_free (expected );
8383 g_free (value );
8484 g_strfreev (options );
85- delete_key (testname );
85+ delete_options_key (testname );
8686}
8787
8888void
8989test_keyman_put_options_todconf__existing_key () {
9090 // Initialize
9191 gchar * testname = "test_keyman_put_options_todconf__existing_key" ;
92- delete_key (testname );
92+ delete_options_key (testname );
9393 gchar * existingKeys [] = {"key1=val1" , "new_key=val2" , NULL };
94- set_key (testname , existingKeys );
94+ set_options_key (testname , existingKeys );
9595 gchar * value = g_strdup_printf ("%d" , g_test_rand_int ());
9696
9797 // Execute
9898 keyman_put_options_todconf (TEST_FIXTURE , testname , "new_key" , value );
9999
100100 // Verify
101- gchar * * options = get_key (testname );
101+ gchar * * options = get_options_key (testname );
102102 gchar * expected = g_strdup_printf ("new_key=%s" , value );
103103 g_assert_nonnull (options );
104104 g_assert_cmpstr (options [0 ], = = , "key1=val1" );
@@ -109,7 +109,7 @@ test_keyman_put_options_todconf__existing_key() {
109109 g_free (expected );
110110 g_free (value );
111111 g_strfreev (options );
112- delete_key (testname );
112+ delete_options_key (testname );
113113}
114114
115115int
0 commit comments