2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
\r
4 * Licensed under the Apache License, Version 2.0 (the License);
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an AS IS BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 #include <tet_api.h>
\r
18 #include <download.h>
\r
20 #include <glib-object.h>
\r
23 static void startup(void);
\r
24 static void cleanup(void);
\r
26 void (*tet_startup)(void) = startup;
\r
27 void (*tet_cleanup)(void) = cleanup;
\r
29 static void utc_download_get_downloaded_file_path_positive1(void);
\r
31 struct tet_testlist tet_testlist[] = {
\r
32 {utc_download_get_downloaded_file_path_positive1, 1},
\r
36 static GMainLoop* gloop = NULL;
\r
37 #define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"
\r
39 static void state_cb (int download_id, download_state_e state, void *user_data)
\r
41 const char *TC_NAME = __FUNCTION__;
\r
43 download_error_e err = DOWNLOAD_ERROR_NONE;
\r
44 if (state == DOWNLOAD_STATE_COMPLETED)
\r
45 g_main_loop_quit(gloop);
\r
47 retcode = download_get_error(download_id, &err);
\r
48 if (retcode != DOWNLOAD_ERROR_NONE) {
\r
49 dts_fail(TC_NAME, "Fail to get error");
\r
50 g_main_loop_quit(gloop);
\r
53 dts_message(TC_NAME, "err[%d]", err);
\r
54 if (err == DOWNLOAD_ERROR_INVALID_URL)
\r
55 dts_message(TC_NAME, "invaild url err");
\r
57 dts_message(TC_NAME, "another error[%d]", err);
\r
61 static void startup(void)
\r
64 gloop = g_main_loop_new (NULL, 0);
\r
67 static void cleanup(void)
\r
69 g_main_loop_unref(gloop);
\r
74 void utc_download_get_downloaded_file_path_positive1(void)
\r
76 const char *TC_NAME = __FUNCTION__;
\r
78 char *output = NULL;
\r
81 retcode = download_create(&id);
\r
82 if (retcode != DOWNLOAD_ERROR_NONE) {
\r
83 dts_fail(TC_NAME,"Fail to create download handle");
\r
86 retcode = download_set_url(id, TEST_URL);
\r
87 if ( retcode != DOWNLOAD_ERROR_NONE ) {
\r
88 dts_fail(TC_NAME,"Fail to set url");
\r
91 retcode = download_set_state_changed_cb(id, state_cb, NULL);
\r
92 if (retcode != DOWNLOAD_ERROR_NONE)
\r
93 dts_fail(TC_NAME, "Fail to set callback");
\r
95 retcode = download_start(id);
\r
96 if (retcode == DOWNLOAD_ERROR_NONE)
\r
97 g_main_loop_run(gloop);
\r
99 retcode = download_get_downloaded_file_path(id, &output);
\r
100 if ( retcode != DOWNLOAD_ERROR_NONE )
\r
101 dts_message(TC_NAME,"Fail to get content name");
\r
103 download_unset_state_changed_cb(id);
\r
104 download_destroy(id);
\r
106 if (retcode == DOWNLOAD_ERROR_NONE)
\r
107 dts_pass(TC_NAME, "retcode has no error");
\r
109 dts_fail(TC_NAME, "retcode has error");
\r