[kazehakase-svn] [3720] more test.

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
Tue Feb 17 07:32:45 JST 2009


Revision: 3720
          http://svn.sourceforge.jp/view?root=kazehakase&view=rev&rev=3720
Author:   ikezoe
Date:     2009-02-17 07:32:45 +0900 (Tue, 17 Feb 2009)

Log Message:
-----------
more test.

Modified Paths:
--------------
    kazehakase/trunk/test/test-downloader.c

Modified: kazehakase/trunk/test/test-downloader.c
===================================================================
--- kazehakase/trunk/test/test-downloader.c	2009-02-16 22:16:10 UTC (rev 3719)
+++ kazehakase/trunk/test/test-downloader.c	2009-02-16 22:32:45 UTC (rev 3720)
@@ -4,7 +4,9 @@
 #include "kz-test-utils.h"
 
 void test_new (void);
+void test_new_with_filename (void);
 void test_to_buffer (void);
+void test_to_file (void);
 
 static KzDownloader *downloader;
 
@@ -13,6 +15,9 @@
 static gint n_error_received;
 static gchar *error_message;
 static gchar *expected_buffer;
+static gchar *actual_buffer;
+static const gchar target_uri[] = "http://svn.sourceforge.jp/view/kazehakase/trunk/test/fixtures/bookmarkbar.xml?view=co&root=kazehakase";
+static const gchar download_filename[] = "downloaded-file";
 
 void
 setup (void)
@@ -33,15 +38,26 @@
     if (downloader)
         g_object_unref(downloader);
     g_free(expected_buffer);
+    g_free(actual_buffer);
+
+    cut_remove_path(download_filename, NULL);
 }
 
 void
 test_new (void)
 {
-    downloader = kz_downloader_new("http://svn.sourceforge.jp/view/kazehakase/trunk/test/fixtures/bookmarkbar.xml?view=co&root=kazehakase");
+    downloader = kz_downloader_new(target_uri);
     cut_assert(downloader);
 }
 
+void
+test_new_with_filename (void)
+{
+    downloader = kz_downloader_new_with_filename(target_uri,
+                                                 download_filename);
+    cut_assert(downloader);
+}
+
 static gboolean
 cb_check_emitted (gpointer data)
 {
@@ -123,6 +139,38 @@
     cut_assert_equal_string(expected_buffer, kz_downloader_get_buffer(downloader));
 }
 
+void
+test_to_file (void)
+{
+    gchar *file_path;
+    GError *error = NULL;
+
+    cut_trace(test_new_with_filename());
+
+    setup_signals();
+    cut_assert_true(kz_downloader_to_file(downloader));
+
+    wait_signal(&n_start_received);
+    cut_assert_equal_int(1, n_start_received);
+    wait_signal(&n_completed_received);
+    cut_assert_equal_int(0, n_error_received);
+    cut_assert_equal_int(1, n_completed_received);
+
+    cut_assert_file_exist(download_filename);
+    g_file_get_contents(download_filename, &actual_buffer, NULL, &error);
+    gcut_assert_error(error);
+
+    file_path = g_build_filename(kz_test_get_base_dir(),
+                                 "fixtures", "bookmarkbar.xml",
+                                 NULL);
+    cut_take_string(file_path);
+
+    g_file_get_contents(file_path, &expected_buffer, NULL, &error);
+    gcut_assert_error(error);
+
+    cut_assert_equal_string(expected_buffer, actual_buffer);
+}
+
 /*
 vi:ts=4:nowrap:ai:expandtab:sw=4
 */




More information about the Kazehakase-cvs mailing list
アーカイブの一覧に戻る