sl@0: // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #define LOG_FILE "c:\\logs\\bookmark_test1_log.txt" sl@0: #include "std_log_result.h" sl@0: #define LOG_FILENAME_LINE __FILE__, __LINE__ sl@0: #define in_FILE "file.xbel" sl@0: sl@0: sl@0: void create_xml(int result) sl@0: { sl@0: if(result) sl@0: assert_failed = 1; sl@0: sl@0: testResultXml("bookmark-test1"); sl@0: close_log_file(); sl@0: } sl@0: sl@0: int sl@0: main (int argc, sl@0: char *argv[]) sl@0: { sl@0: GBookmarkFile* bookmark; sl@0: gsize uris_len; sl@0: gchar *bookmark_data = NULL; sl@0: gboolean file_written,file_load; sl@0: const gchar *rel_path; sl@0: time_t time; sl@0: const gchar *bookmark_filename = argv[1]; sl@0: GError *error = NULL; sl@0: gchar **bookmark_uri = NULL; sl@0: sl@0: bookmark = g_bookmark_file_new(); sl@0: file_load= g_bookmark_file_load_from_file(bookmark, bookmark_filename, &error); sl@0: if(file_load != TRUE) sl@0: { sl@0: std_log(LOG_FILENAME_LINE,"g_bookmark_file_load_from_file fails with err:%s",error->message); sl@0: assert_failed = 1; sl@0: } sl@0: bookmark_data = g_bookmark_file_to_data(bookmark,&uris_len,&error); sl@0: if(bookmark_data == NULL) sl@0: { sl@0: std_log(LOG_FILENAME_LINE,"Bg_bookmark_file_to_data fails with err:%s",error->message); sl@0: assert_failed = 1; sl@0: } sl@0: rel_path = in_FILE; // Code changed to Hardcode the data file in the c:\ private path. sl@0: file_written = g_bookmark_file_load_from_data_dirs(bookmark, rel_path,NULL, &error); sl@0: if(file_written == FALSE) sl@0: { sl@0: std_log(LOG_FILENAME_LINE,"g_bookmark_file_load_from_data_dirs fails with err:%s",error->message); sl@0: assert_failed = 1; sl@0: } sl@0: sl@0: bookmark_uri = g_bookmark_file_get_uris(bookmark, NULL); sl@0: if(bookmark_uri == NULL) sl@0: { sl@0: std_log(LOG_FILENAME_LINE,"g_bookmark_file_get_uris fails"); sl@0: assert_failed = 1; sl@0: } sl@0: sl@0: bookmark_data = g_bookmark_file_get_mime_type(bookmark,*bookmark_uri,&error); sl@0: if(bookmark_data == NULL) sl@0: { sl@0: std_log(LOG_FILENAME_LINE,"URI cannot be found and the error code:%s",error->message); sl@0: assert_failed = 1; sl@0: } sl@0: g_bookmark_file_set_is_private(bookmark,*bookmark_uri, TRUE); sl@0: file_written = g_bookmark_file_get_is_private(bookmark,*bookmark_uri, &error); sl@0: if(file_written == FALSE) sl@0: { sl@0: std_log(LOG_FILENAME_LINE,"Private flag is not set in the URI and fails with :%s",error->message); sl@0: assert_failed = 1; sl@0: } sl@0: sl@0: g_bookmark_file_set_added(bookmark,*bookmark_uri,-1);//-1, To use the current time. sl@0: time = g_bookmark_file_get_added(bookmark,*bookmark_uri,&error); sl@0: if(time == -1) sl@0: { sl@0: std_log(LOG_FILENAME_LINE,"URI cannot be found and fails with :%s",error->message); sl@0: assert_failed = 1; sl@0: } sl@0: g_strfreev(bookmark_uri); sl@0: g_bookmark_file_free(bookmark); sl@0: sl@0: if(assert_failed) sl@0: std_log(LOG_FILENAME_LINE,"Test Fail"); sl@0: else sl@0: std_log(LOG_FILENAME_LINE,"Test Successful"); sl@0: sl@0: sl@0: create_xml(assert_failed); sl@0: return 0; sl@0: }