50
|
1 |
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
72
|
17 |
#include <sys/stat.h>
|
50
|
18 |
#include<stdio.h>
|
|
19 |
#include <glib.h>
|
72
|
20 |
#include <glib/gprintf.h>
|
|
21 |
#ifdef __SYMBIAN32__
|
|
22 |
#include "mrt2_glib2_test.h"
|
|
23 |
#endif /*__SYMBIAN32__*/
|
50
|
24 |
#define in_FILE "file.xbel"
|
|
25 |
|
|
26 |
int
|
|
27 |
main (int argc,
|
|
28 |
char *argv[])
|
|
29 |
{
|
|
30 |
GBookmarkFile* bookmark;
|
|
31 |
gsize uris_len;
|
|
32 |
gchar *bookmark_data = NULL;
|
|
33 |
gboolean file_written,file_load;
|
|
34 |
const gchar *rel_path;
|
|
35 |
time_t time;
|
|
36 |
const gchar *bookmark_filename = argv[1];
|
|
37 |
GError *error = NULL;
|
|
38 |
gchar **bookmark_uri = NULL;
|
72
|
39 |
|
|
40 |
#ifdef __SYMBIAN32__
|
|
41 |
g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
|
|
42 |
g_set_print_handler(mrtPrintHandler);
|
|
43 |
#endif /*__SYMBIAN32__*/
|
|
44 |
|
|
45 |
g_print("Test bookmarkfile-test1 Start");
|
50
|
46 |
bookmark = g_bookmark_file_new();
|
|
47 |
file_load= g_bookmark_file_load_from_file(bookmark, bookmark_filename, &error);
|
|
48 |
if(file_load != TRUE)
|
|
49 |
{
|
72
|
50 |
g_print("g_bookmark_file_load_from_file fails with err:%s",error->message);
|
50
|
51 |
assert_failed = 1;
|
|
52 |
}
|
|
53 |
bookmark_data = g_bookmark_file_to_data(bookmark,&uris_len,&error);
|
|
54 |
if(bookmark_data == NULL)
|
|
55 |
{
|
72
|
56 |
g_print("Bg_bookmark_file_to_data fails with err:%s",error->message);
|
50
|
57 |
assert_failed = 1;
|
|
58 |
}
|
|
59 |
rel_path = in_FILE; // Code changed to Hardcode the data file in the c:\ private path.
|
|
60 |
file_written = g_bookmark_file_load_from_data_dirs(bookmark, rel_path,NULL, &error);
|
|
61 |
if(file_written == FALSE)
|
|
62 |
{
|
72
|
63 |
g_print("g_bookmark_file_load_from_data_dirs fails with err:%s",error->message);
|
50
|
64 |
assert_failed = 1;
|
|
65 |
}
|
|
66 |
|
|
67 |
bookmark_uri = g_bookmark_file_get_uris(bookmark, NULL);
|
|
68 |
if(bookmark_uri == NULL)
|
|
69 |
{
|
72
|
70 |
g_print("g_bookmark_file_get_uris fails");
|
50
|
71 |
assert_failed = 1;
|
|
72 |
}
|
|
73 |
|
|
74 |
bookmark_data = g_bookmark_file_get_mime_type(bookmark,*bookmark_uri,&error);
|
|
75 |
if(bookmark_data == NULL)
|
|
76 |
{
|
72
|
77 |
g_print("URI cannot be found and the error code:%s",error->message);
|
50
|
78 |
assert_failed = 1;
|
|
79 |
}
|
|
80 |
g_bookmark_file_set_is_private(bookmark,*bookmark_uri, TRUE);
|
|
81 |
file_written = g_bookmark_file_get_is_private(bookmark,*bookmark_uri, &error);
|
|
82 |
if(file_written == FALSE)
|
|
83 |
{
|
72
|
84 |
g_print("Private flag is not set in the URI and fails with :%s",error->message);
|
50
|
85 |
assert_failed = 1;
|
|
86 |
}
|
|
87 |
|
|
88 |
g_bookmark_file_set_added(bookmark,*bookmark_uri,-1);//-1, To use the current time.
|
|
89 |
time = g_bookmark_file_get_added(bookmark,*bookmark_uri,&error);
|
|
90 |
if(time == -1)
|
|
91 |
{
|
72
|
92 |
g_print("URI cannot be found and fails with :%s",error->message);
|
50
|
93 |
assert_failed = 1;
|
|
94 |
}
|
|
95 |
g_strfreev(bookmark_uri);
|
|
96 |
g_bookmark_file_free(bookmark);
|
|
97 |
|
|
98 |
if(assert_failed)
|
72
|
99 |
g_print("Test bookmarkfile-test1 Fail");
|
50
|
100 |
else
|
72
|
101 |
g_print("Test bookmarkfile-test1 Successful");
|
50
|
102 |
|
72
|
103 |
#if __SYMBIAN32__
|
|
104 |
testResultXml("bookmarkfile-test1");
|
|
105 |
#endif /* EMULATOR */
|
50
|
106 |
return 0;
|
|
107 |
}
|