[gnome-commander/googletest] Adds the imagerenderer test to google test framework



commit fdd0dc54e9f2e6ec207dd278920d1bbcce216abe
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Tue Nov 10 21:02:21 2015 +0100

    Adds the imagerenderer test to google test framework

 tests/Makefile.am              |    2 +-
 tests/iv_imagerenderer_test.cc |  128 ++++++++++++----------------------------
 tests/iv_imagerenderer_test.h  |   33 ++++++++++
 3 files changed, 73 insertions(+), 90 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 146e895..479ecd7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -35,7 +35,7 @@ iv_dualrenderer_SOURCES = iv_dualrenderer_test.cc gcmd_tests_main.cc
 iv_dualrenderer_CXXFLAGS = $(INTVLIBS)
 iv_dualrenderer_LDFLAGS = $(INTVLIBS) -lgtest
 
-iv_imagerenderer_SOURCES = iv_imagerenderer_test.cc
+iv_imagerenderer_SOURCES = iv_imagerenderer_test.cc gcmd_tests_main.cc
 iv_imagerenderer_CXXFLAGS = $(INTVLIBS)
 iv_imagerenderer_LDFLAGS = $(INTVLIBS) -lgtest
 
diff --git a/tests/iv_imagerenderer_test.cc b/tests/iv_imagerenderer_test.cc
index ecf1509..7efd561 100644
--- a/tests/iv_imagerenderer_test.cc
+++ b/tests/iv_imagerenderer_test.cc
@@ -1,95 +1,43 @@
-/*
-  GNOME Commander - A GNOME based file manager
-  Copyright (C) 2001-2006 Marcus Bjurman
-  Copyright (C) 2007-2012 Piotr Eljasiak
-    Copyright (C) 2013-2015 Uwe Scholz
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-
-   Author: Assaf Gordon  <agordon88 gmail com>
-*/
-
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include <intviewer/libgviewer.h>
-
-static gchar *filename = NULL;
+/**
+ * @file iv_imagerenderer_test.cc
+ * @brief Part of GNOME Commander - A GNOME based file manager
+ * 
+ * @details In this single test the creation of a gtk widget is tested
+ * in which two elements are visualized. It is not to be considered to
+ * be a unit test, as individual functions are not fully tested!
+ *
+ * @copyright (C) 2006 Assaf Gordon\n
+ * @copyright (C) 2007-2012 Piotr Eljasiak\n
+ * @copyright (C) 2013-2015 Uwe Scholz\n
+ *
+ * @copyright This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * @copyright This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * @copyright You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "gtest/gtest.h"
+#include <iv_imagerenderer_test.h>
+
+const gchar *filename = "../pixmaps/gnome-commander.png";
 static gboolean best_fit = TRUE;
-static double scale_factor = 1.0;
-
-void usage()
-{
-    fprintf(stderr,"This program tests the image-render widget in 'libgviewer'.\n\n");
+static double scale_factor = 1.0; //0.1 < scale_factor < 3.0
 
-    fprintf(stderr,"Usage: test-imagerenderer [-s scale] filename\n\n");
-
-    fprintf(stderr,"\t-s scale: use fixed scaling factor (0.1 to 3.0)\n\t\t(Default is using 
best-fit-to-window)\n");
-    fprintf(stderr,"\tfilename: The file to display.\n");
-    exit(0);
-}
-
-void parse_command_line(int argc, char *argv[])
-{
-    extern char *optarg;
-    extern int optind, opterr, optopt;
-    int c;
-
-    best_fit = TRUE;
-    scale_factor = 1.0;
-
-    while ((c=getopt(argc,argv,"s:")) != -1) {
-        switch(c)
-        {
-        case 's':
-            best_fit = FALSE;
-            scale_factor = atof(optarg);
-            if (scale_factor<0.1 || scale_factor>3.0) {
-                g_warning("Invalid scale factor \"%f\".\n", scale_factor);
-                usage();
-            }
-            break;
-
-        default:
-            usage();
-            break;
-        }
-    }
-
-    if (optind == argc) {
-        g_warning("Need file name to work with...\n");
-        usage();
-    }
-    filename = g_strdup(argv[optind++]);
-}
-
-
-int main(int argc, char *argv[])
-{
+TEST_F(ImageRendererTest, image_render_test) {
     GtkWidget *window;
     GtkWidget *scrollbox;
     GtkWidget *imgr;
 
-    gtk_init(&argc,&argv);
-
-    parse_command_line(argc,argv);
+    gtk_init(NULL, NULL);
 
     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
@@ -120,7 +68,9 @@ int main(int argc, char *argv[])
     gtk_widget_show(scrollbox);
     gtk_widget_show(window);
 
-    gtk_main();
-
-    return 0;
+    while (g_main_context_pending(NULL))
+    {
+        g_main_context_iteration(NULL, FALSE);
+    }
+    gtk_widget_destroy (window);
 }
diff --git a/tests/iv_imagerenderer_test.h b/tests/iv_imagerenderer_test.h
new file mode 100644
index 0000000..93b689a
--- /dev/null
+++ b/tests/iv_imagerenderer_test.h
@@ -0,0 +1,33 @@
+/**
+ * @file iv_imagerenderer_test.h
+ * @brief Part of GNOME Commander - A GNOME based file manager
+ *
+ * @copyright (C) 2006 Assaf Gordon\n
+ * @copyright (C) 2007-2012 Piotr Eljasiak\n
+ * @copyright (C) 2013-2015 Uwe Scholz\n
+ *
+ * @copyright This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * @copyright This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * @copyright You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef IMAGERENDERER_TEST_H
+#define IMAGERENDERER_TEST_H
+
+#include <intviewer/libgviewer.h>
+
+// The fixture for testing class ImageRendererTest
+class ImageRendererTest : public ::testing::Test {
+};
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]