+ handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
+ x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
+
+ ret = pclKeyHandleClose(handle2);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(1024);
+ x_fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
+#endif
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
+/*
+ * Extended key handle test.
+ * Test have been created after a bug in the key handle function occured.
+ */
+START_TEST(test_DataHandleOpen)
+{
+ X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+ X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+ X_TEST_REPORT_REFERENCE("NONE");
+ X_TEST_REPORT_DESCRIPTION("Test of data handle open");
+ X_TEST_REPORT_TYPE(GOOD);
+
+ int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+ // open handles ----------------------------------------------------
+ hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
+ x_fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
+
+ hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
+ x_fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
+
+ hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
+ x_fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
+
+ // close handles ---------------------------------------------------
+ ret = pclKeyHandleClose(hd1);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(hd2);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(hd3);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ // open handles ----------------------------------------------------
+ hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
+ x_fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
+
+ hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
+ x_fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
+
+ hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
+ x_fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
+
+ hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
+ x_fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
+
+ hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
+ x_fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
+
+ hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
+ x_fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
+
+ // close handles ---------------------------------------------------
+ ret = pclKeyHandleClose(hd4);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(hd5);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(hd6);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(hd7);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(hd8);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+
+ ret = pclKeyHandleClose(hd9);
+ x_fail_unless(ret != -1, "Failed to close handle!!");
+#endif
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_Plugin)
+{
+ X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+ X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+ X_TEST_REPORT_REFERENCE("NONE");
+ X_TEST_REPORT_DESCRIPTION("Test of plugins");
+ X_TEST_REPORT_TYPE(GOOD);
+
+ int ret = 0;
+ unsigned char buffer[READ_SIZE] = {0};
+
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+ ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
+ strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
+
+
+ ret = pclKeyReadData(0xFF, "language/country_code_early", 0, 0, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf("B U F F E R - early: %s\n", buffer);
+ x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
+ strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
+
+ ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf("B U F F E R - emergency: %s\n", buffer);
+ x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
+ strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
+
+ ret = pclKeyReadData(0xFF, "language/info", 0, 0, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf("B U F F E R - hwinfo: %s\n", buffer);
+ x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
+ strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
+
+ ret = pclKeyReadData(0xFF, "language/country_code_custom3", 0, 0, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf("B U F F E R - hwinfo: %s\n", buffer);
+ x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
+ strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
+#endif
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
+
+
+START_TEST(test_ReadDefault)
+{
+ X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+ X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+ X_TEST_REPORT_REFERENCE("NONE");
+ X_TEST_REPORT_DESCRIPTION("Test of read default");
+ X_TEST_REPORT_TYPE(GOOD);
+
+ int ret = 0;
+ unsigned char buffer[READ_SIZE] = {0};
+
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+ ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf("B U F F E R: %s\n", buffer);
+ x_fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+ ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ //printf("B U F F E R: %s\n", buffer);
+ x_fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+#endif
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_ReadConfDefault)
+{
+ X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+ X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+ X_TEST_REPORT_REFERENCE("NONE");
+ X_TEST_REPORT_DESCRIPTION("Test of configurable default data");
+ X_TEST_REPORT_TYPE(GOOD);
+
+ int ret = 0;
+ unsigned char buffer[READ_SIZE] = {0};
+
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+ ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+ ret = pclKeyReadData(0xFF, "statusHandle/confdefault02", 3, 2, buffer, READ_SIZE);
+ x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+ x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+#endif
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_GetPath)
+{
+ X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+ X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+ X_TEST_REPORT_REFERENCE("NONE");
+ X_TEST_REPORT_DESCRIPTION("Test of get path");
+ X_TEST_REPORT_TYPE(GOOD);
+
+ int ret = 0;
+ char* path = NULL;
+ const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
+ unsigned int pathSize = 0;
+
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+ ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
+
+ x_fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
+ x_fail_unless(pathSize == strlen((char*)path), "Path size not correct");
+
+ pclFileReleasePath(ret);
+#endif
+ pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_InitDeinit)
+{
+ int i = 0;
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ for(i=0; i< 3; i++)
+ {
+ // initialize and deinitialize 1. time
+ (void)pclInitLibrary(gTheAppId, shutdownReg);
+ pclDeinitLibrary();
+
+
+ // initialize and deinitialize 2. time
+ (void)pclInitLibrary(gTheAppId, shutdownReg);
+ pclDeinitLibrary();
+
+
+ // initialize and deinitialize 3. time
+ (void)pclInitLibrary(gTheAppId, shutdownReg);
+ pclDeinitLibrary();
+ }
+}
+END_TEST
+
+
+
+START_TEST(test_NegHandle)
+{
+ int handle = -1, ret = 0;;
+ int negativeHandle = -17;
+ unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+ unsigned char buffer[128] = {0};
+
+ (void)pclInitLibrary(gTheAppId, shutdownReg);
+
+ handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
+ x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
+
+
+
+ ret = pclKeyHandleReadData(negativeHandle, buffer, READ_SIZE);
+ x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
+
+ ret = pclKeyHandleClose(negativeHandle);
+ x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleClose => negative handle not detected");
+
+ ret = pclKeyHandleGetSize(negativeHandle);
+ x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleGetSize => negative handle not detected");
+
+ ret = pclKeyHandleReadData(negativeHandle, buffer, 128);
+ x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
+
+ ret = pclKeyHandleRegisterNotifyOnChange(negativeHandle, &myChangeCallback);
+ x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleRegisterNotifyOnChange => negative handle not detected");
+
+ ret = pclKeyHandleWriteData(negativeHandle, (unsigned char*)"Whatever", strlen("Whatever"));
+ x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleWriteData => negative handle not detected");
+