diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testdatabase.c | 156 | ||||
-rw-r--r-- | tests/testsuminfo.c | 201 |
2 files changed, 140 insertions, 217 deletions
diff --git a/tests/testdatabase.c b/tests/testdatabase.c index 85fe1f9..8b8482b 100644 --- a/tests/testdatabase.c +++ b/tests/testdatabase.c @@ -1076,6 +1076,7 @@ static void create_file_data(const char *name, const char *data, unsigned size) static void test_streamtable(void) { + GError *error = NULL; LibmsiDatabase *hdb = 0; LibmsiRecord *rec; LibmsiQuery *query; @@ -1143,11 +1144,11 @@ static void test_streamtable(void) r = libmsi_database_get_summary_info( hdb, 1, &hsi ); ok( r == LIBMSI_RESULT_SUCCESS, "Failed to get summary information handle: %u\n", r ); - r = libmsi_summary_info_set_property( hsi, LIBMSI_PROPERTY_SECURITY, LIBMSI_PROPERTY_TYPE_INT, 2, NULL, NULL ); - ok( r == LIBMSI_RESULT_SUCCESS, "Failed to set property: %u\n", r ); + libmsi_summary_info_set_int(hsi, LIBMSI_PROPERTY_SECURITY, 2, &error); + ok(!error, "Failed to set property\n"); - r = libmsi_summary_info_persist( hsi ); - ok( r == LIBMSI_RESULT_SUCCESS, "Failed to save summary information: %u\n", r ); + r = libmsi_summary_info_persist( hsi, NULL ); + ok(r, "Failed to save summary information: %u\n", r ); g_object_unref( hsi ); @@ -1702,14 +1703,15 @@ static unsigned add_table_to_db(LibmsiDatabase *hdb, const char *table_data) static void test_suminfo_import(void) { + GError *error = NULL; LibmsiDatabase *hdb; LibmsiSummaryInfo *hsi; LibmsiQuery *query = 0; const char *sql; - unsigned r, count, size, type; - char str_value[50]; + unsigned r, count, type; + const char *str_value; int int_value; - uint64_t ft_value; + guint64 ft_value; r = libmsi_database_open(msifile, LIBMSI_DB_OPEN_CREATE, &hdb); ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); @@ -1734,89 +1736,59 @@ static void test_suminfo_import(void) ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); ok(count == 14, "Expected 14, got %u\n", count); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_CODEPAGE, &type, &int_value, NULL, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I2, got %u\n", type); + int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_CODEPAGE, &error); + ok(!error, "Expected success\n"); ok(int_value == 1252, "Expected 1252, got %d\n", int_value); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_TITLE, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(size == 18, "Expected 18, got %u\n", size); - ok(!strcmp(str_value, "Installer Database"), - "Expected \"Installer Database\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_TITLE, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "Installer Database"); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_SUBJECT, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(!strcmp(str_value, "Installer description"), - "Expected \"Installer description\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_SUBJECT, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "Installer description"); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_AUTHOR, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(!strcmp(str_value, "WineHQ"), - "Expected \"WineHQ\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_AUTHOR, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "WineHQ"); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_KEYWORDS, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(!strcmp(str_value, "Installer"), - "Expected \"Installer\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_KEYWORDS, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "Installer"); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_COMMENTS, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(!strcmp(str_value, "Installer comments"), - "Expected \"Installer comments\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_COMMENTS, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "Installer comments"); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_TEMPLATE, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(!strcmp(str_value, "Intel;1033,2057"), - "Expected \"Intel;1033,2057\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_TEMPLATE, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "Intel;1033,2057"); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_UUID, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(!strcmp(str_value, "{12345678-1234-1234-1234-123456789012}"), - "Expected \"{12345678-1234-1234-1234-123456789012}\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_UUID, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "{12345678-1234-1234-1234-123456789012}"); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_CREATED_TM, &type, NULL, &ft_value, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_FILETIME, "Expected VT_FILETIME, got %u\n", type); + ft_value = libmsi_summary_info_get_filetime (hsi, LIBMSI_PROPERTY_CREATED_TM, &error); + ok(!error, "Expected no error\n"); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_LASTSAVED_TM, &type, NULL, &ft_value, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_FILETIME, "Expected VT_FILETIME, got %u\n", type); + ft_value = libmsi_summary_info_get_filetime (hsi, LIBMSI_PROPERTY_LASTSAVED_TM, &error); + ok(!error, "Expected no error\n"); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_VERSION, &type, &int_value, NULL, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I4, got %u\n", type); + int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_VERSION, &error); + ok(!error, "Expected success\n"); ok(int_value == 200, "Expected 200, got %d\n", int_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_SOURCE, &type, &int_value, NULL, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I4, got %u\n", type); + int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_SOURCE, &error); + ok(!error, "Expected success\n"); ok(int_value == 2, "Expected 2, got %d\n", int_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_SECURITY, &type, &int_value, NULL, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_INT, "Expected VT_I4, got %u\n", type); + int_value = libmsi_summary_info_get_int (hsi, LIBMSI_PROPERTY_SECURITY, &error); + ok(!error, "Expected success\n"); ok(int_value == 2, "Expected 2, got %d\n", int_value); - size = sizeof(str_value); - r = libmsi_summary_info_get_property(hsi, LIBMSI_PROPERTY_APPNAME, &type, NULL, NULL, str_value, &size); - ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %u\n", r); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %u\n", type); - ok(!strcmp(str_value, "Vim"), "Expected \"Vim\", got %s\n", str_value); + str_value = libmsi_summary_info_get_string (hsi, LIBMSI_PROPERTY_APPNAME, &error); + ok(!error, "Expected no error\n"); + g_assert_cmpstr (str_value, ==, "Vim"); g_object_unref(hsi); g_object_unref(hdb); @@ -2440,6 +2412,7 @@ static void generate_transform_manual(void) static unsigned set_summary_info(LibmsiDatabase *hdb) { + GError *error = NULL; unsigned res; LibmsiSummaryInfo *suminfo; @@ -2447,34 +2420,29 @@ static unsigned set_summary_info(LibmsiDatabase *hdb) res = libmsi_database_get_summary_info(hdb, 7, &suminfo); ok( res == LIBMSI_RESULT_SUCCESS , "Failed to open summaryinfo\n" ); - res = libmsi_summary_info_set_property(suminfo,2, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL, - "Installation Database"); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" ); + libmsi_summary_info_set_string (suminfo, 2, "Installation Database", &error); + ok(!error, "Failed to set summary info\n"); - res = libmsi_summary_info_set_property(suminfo,3, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL, - "Installation Database"); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" ); + libmsi_summary_info_set_string (suminfo, 3, "Installation Database", &error); + ok(!error, "Failed to set summary info\n"); - res = libmsi_summary_info_set_property(suminfo,4, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL, - "Wine Hackers"); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" ); + libmsi_summary_info_set_string (suminfo, 4, "Wine Hackers", &error); + ok(!error, "Failed to set summary info\n"); - res = libmsi_summary_info_set_property(suminfo,7, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL, - ";1033,2057"); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" ); + libmsi_summary_info_set_string (suminfo, 7, ";1033,2057", &error); + ok(!error, "Failed to set summary info\n"); - res = libmsi_summary_info_set_property(suminfo,9, LIBMSI_PROPERTY_TYPE_STRING, 0,NULL, - "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}"); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" ); + libmsi_summary_info_set_string (suminfo, 9, "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &error); + ok(!error, "Failed to set summary info\n"); - res = libmsi_summary_info_set_property(suminfo, 14, LIBMSI_PROPERTY_TYPE_INT, 100, NULL, NULL); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" ); + libmsi_summary_info_set_int (suminfo, 14, 100, &error); + ok(!error, "Failed to set summary info\n"); - res = libmsi_summary_info_set_property(suminfo, 15, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, NULL); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to set summary info\n" ); + libmsi_summary_info_set_int (suminfo, 15, 0, &error); + ok(!error, "Failed to set summary info\n"); - res = libmsi_summary_info_persist(suminfo); - ok( res == LIBMSI_RESULT_SUCCESS , "Failed to make summary info persist\n" ); + res = libmsi_summary_info_persist(suminfo, NULL); + ok( res , "Failed to make summary info persist\n" ); g_object_unref( suminfo); diff --git a/tests/testsuminfo.c b/tests/testsuminfo.c index 522b8b3..a1b0191 100644 --- a/tests/testsuminfo.c +++ b/tests/testsuminfo.c @@ -35,13 +35,14 @@ static const WCHAR msifileW[] = { static void test_suminfo(void) { + GError *error = NULL; LibmsiDatabase *hdb = 0; LibmsiSummaryInfo *hsuminfo; unsigned r, count, type; unsigned sz; int val; uint64_t ft; - char buf[0x10]; + const gchar *str; DeleteFile(msifile); @@ -71,47 +72,17 @@ static void test_suminfo(void) ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n"); ok(count == 0, "count should be zero\n"); - r = libmsi_summary_info_get_property(hsuminfo, 0, NULL, NULL, NULL, 0, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n"); - - r = libmsi_summary_info_get_property(hsuminfo, -1, NULL, NULL, NULL, 0, NULL); - ok(r == LIBMSI_RESULT_UNKNOWN_PROPERTY, "libmsi_summary_info_get_property wrong error\n"); - - r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_SECURITY+1, NULL, NULL, NULL, 0, NULL); - ok(r == LIBMSI_RESULT_UNKNOWN_PROPERTY, "libmsi_summary_info_get_property wrong error\n"); - - type = -1; - r = libmsi_summary_info_get_property(hsuminfo, 0, &type, NULL, NULL, 0, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n"); - ok(type == 0, "wrong type\n"); - - type = -1; - val = 1234; - r = libmsi_summary_info_get_property(hsuminfo, 0, &type, &val, NULL, 0, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n"); - ok(type == 0, "wrong type\n"); - ok(val == 1234, "wrong val\n"); - - buf[0]='x'; - buf[1]=0; - sz = 0x10; - r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_UUID, &type, &val, NULL, buf, &sz); - ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n"); - ok(buf[0]=='x', "cleared buffer\n"); - ok(sz == 0x10, "count wasn't zero\n"); + type = libmsi_summary_info_get_property_type(hsuminfo, LIBMSI_PROPERTY_UUID, &error); + ok(!error, "returned error"); ok(type == LIBMSI_PROPERTY_TYPE_EMPTY, "should be empty\n"); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "Mike"); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n"); - - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, "JungAh"); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "Mike", &error); + ok(error, "libmsi_summary_info_set_property wrong error\n"); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike"); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n"); - - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, &ft, "JungAh"); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, 1, &error); + ok(error, "libmsi_summary_info_set_property wrong error\n"); + g_clear_error(error); g_object_unref(hsuminfo); @@ -119,66 +90,55 @@ static void test_suminfo(void) r = libmsi_database_get_summary_info(hdb, 1, &hsuminfo); ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed\n"); - r = libmsi_summary_info_set_property(hsuminfo, 0, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); - - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); - - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Mike"); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); - - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "JungAh"); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); - - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_KEYWORDS, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Mike"); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_string(hsuminfo, 0, NULL, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_COMMENTS, LIBMSI_PROPERTY_TYPE_FILETIME, 0, NULL, "JungAh"); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, NULL, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TEMPLATE, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Mike"); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_TITLE, NULL, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_LASTAUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, NULL); - ok(r == LIBMSI_RESULT_INVALID_PARAMETER, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_AUTHOR, 0, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_LASTSAVED_TM, LIBMSI_PROPERTY_TYPE_FILETIME, 0, NULL, NULL); - ok(r == LIBMSI_RESULT_INVALID_PARAMETER, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_KEYWORDS, 0, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_LASTAUTHOR, VT_LPWSTR, 0, NULL, "h\0i\0\0"); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_filetime(hsuminfo, LIBMSI_PROPERTY_COMMENTS, 0, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_UUID, LIBMSI_PROPERTY_TYPE_INT, 0, NULL, "Jungah"); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_TEMPLATE, 0, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_VERSION, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_LASTAUTHOR, NULL, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_INVALID_PARAMETER); + g_clear_error(error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "Mike"); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property failed\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_UUID, 0, &error); + g_assert_error(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - sz = 2; - strcpy(buf,"x"); - r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_TITLE, &type, NULL, NULL, buf, &sz ); - ok(r == LIBMSI_RESULT_MORE_DATA, "libmsi_summary_info_set_property failed\n"); - ok(sz == 4, "count was wrong\n"); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "type was wrong\n"); - ok(!strcmp(buf,"M"), "buffer was wrong\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_VERSION, NULL, &error); + g_assert(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(error); - sz = 4; - strcpy(buf,"x"); - r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_TITLE, &type, NULL, NULL, buf, &sz ); - ok(r == LIBMSI_RESULT_MORE_DATA, "libmsi_summary_info_set_property failed\n"); - ok(sz == 4, "count was wrong\n"); - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "type was wrong\n"); - ok(!strcmp(buf,"Mik"), "buffer was wrong\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "Mike", &error); + ok(!error, "libmsi_summary_info_set_property failed\n"); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "JungAh"); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property failed\n"); + str = libmsi_summary_info_get_string(hsuminfo, LIBMSI_PROPERTY_TITLE, &error); + ok(!error, "got error"); + ok(!strcpy(str, "Mike")); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, &ft, "Mike"); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "JungAh", &error); + ok(!error, "libmsi_summary_info_set_property failed\n"); g_object_unref(hsuminfo); @@ -186,23 +146,24 @@ static void test_suminfo(void) r = libmsi_database_get_summary_info(hdb, 10, &hsuminfo); ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed\n"); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "JungAh"); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property failed\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "JungAh", &error); + ok(!error, "libmsi_summary_info_set_property failed\n"); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_STRING, 1, NULL, NULL); - ok(r == LIBMSI_RESULT_DATATYPE_MISMATCH, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, "", &error); + g_assert(error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_DATATYPE_MISMATCH); + g_clear_error(&error); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, 1, &error); + ok(!error, "libmsi_summary_info_set_property failed\n"); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, LIBMSI_PROPERTY_TYPE_INT, 1, &ft, "Mike"); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_int(hsuminfo, LIBMSI_PROPERTY_CODEPAGE, 1, &error); + ok(!error, "libmsi_summary_info_set_property failed\n"); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike"); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n"); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_AUTHOR, "Mike", &error); + ok(!error, "libmsi_summary_info_set_property failed\n"); r = libmsi_summary_info_persist(hsuminfo); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_persist failed\n"); + ok(r, "libmsi_summary_info_persist failed\n"); libmsi_database_commit(hdb); @@ -217,11 +178,11 @@ static void test_suminfo(void) r = libmsi_database_get_summary_info(hdb, 1, &hsuminfo); ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed\n"); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike"); + r = libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_AUTHOR, "Mike", error); ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_set_property wrong error\n"); r = libmsi_summary_info_persist(hsuminfo); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_persist failed %u\n", r); + ok(r, "libmsi_summary_info_persist failed %u\n", r); g_object_unref(hsuminfo); @@ -234,11 +195,12 @@ static void test_suminfo(void) r = libmsi_database_get_summary_info(hdb, 0, &hsuminfo); ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_database_get_summary_info failed %u\n", r); - r = libmsi_summary_info_set_property(hsuminfo, LIBMSI_PROPERTY_AUTHOR, LIBMSI_PROPERTY_TYPE_STRING, 1, &ft, "Mike"); - todo_wine ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property wrong error, %u\n", r); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_AUTHOR, "Mike", &error); + todo_wine ok(error, "libmsi_summary_info_set_property wrong error\n"); + g_clear_error(&error); r = libmsi_summary_info_persist(hsuminfo); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_persist wrong error %u\n", r); + ok(!r, "libmsi_summary_info_persist wrong error %u\n", r); g_object_unref(hsuminfo); @@ -363,12 +325,12 @@ static void test_create_database_binary(void) static void test_summary_binary(void) { + GError *error = NULL; LibmsiDatabase *hdb = 0; LibmsiSummaryInfo *hsuminfo = 0; unsigned r, type, count; int ival; - unsigned sz; - char sval[20]; + const gchar *str; DeleteFile( msifile ); @@ -389,21 +351,13 @@ static void test_summary_binary(void) * but it appears that we're not allowed to read it back again. * We can still read its type though...? */ - sz = sizeof sval; - sval[0] = 0; - type = 0; - r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_LASTPRINTED, &type, NULL, NULL, sval, &sz); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_get_property failed\n"); - ok(!strcmp(sval, "") || !strcmp(sval, "7"), - "Expected empty string or \"7\", got \"%s\"\n", sval); - todo_wine { - ok(type == LIBMSI_PROPERTY_TYPE_STRING, "Expected VT_LPSTR, got %d\n", type); - ok(sz == 0 || sz == 1, "Expected 0 or 1, got %d\n", sz); - } - - ival = -1; - r = libmsi_summary_info_get_property(hsuminfo, LIBMSI_PROPERTY_SOURCE, &type, &ival, NULL, NULL, NULL); - ok(r == LIBMSI_RESULT_SUCCESS, "libmsi_summary_info_get_property failed\n"); + str = libmsi_summary_info_get_string(hsuminfo, LIBMSI_PROPERTY_LASTPRINTED, error); + ok(!error); + ok(!strcmp(str, "") || !strcmp(str, "7"), + "Expected empty string or \"7\", got \"%s\"\n", str); + + ival = libmsi_summary_info_get_int(hsuminfo, LIBMSI_PROPERTY_SOURCE, &error); + ok(!error, "libmsi_summary_info_get_property failed\n"); todo_wine ok( ival == 0, "value incorrect\n"); /* looks like msi adds some of its own values in here */ @@ -412,11 +366,12 @@ static void test_summary_binary(void) ok(r == LIBMSI_RESULT_SUCCESS, "getpropcount failed\n"); todo_wine ok(count == 10, "prop count incorrect\n"); - r = libmsi_summary_info_set_property( hsuminfo, LIBMSI_PROPERTY_TITLE, LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, "Mike" ); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_set_property failed %u\n", r); + libmsi_summary_info_set_string(hsuminfo, LIBMSI_PROPERTY_TITLE, "Mike", &error); + ok(error, "libmsi_summary_info_set_property failed\n"); + g_clear_error(&error); r = libmsi_summary_info_persist( hsuminfo ); - ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "libmsi_summary_info_persist failed %u\n", r); + ok(!r, "libmsi_summary_info_persist failed %u\n", r); g_object_unref( hsuminfo ); g_object_unref( hdb ); |