[gnome-commander/googletest] Uses parameter generator for imagerenderer_test



commit 9a32f8621f75f9e55c12b26e8536d7699b185d25
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Tue Nov 10 22:11:11 2015 +0100

    Uses parameter generator for imagerenderer_test

 tests/iv_imagerenderer_test.cc |   20 ++++++++++++++------
 tests/iv_imagerenderer_test.h  |    2 +-
 2 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/tests/iv_imagerenderer_test.cc b/tests/iv_imagerenderer_test.cc
index 7efd561..dce0dd5 100644
--- a/tests/iv_imagerenderer_test.cc
+++ b/tests/iv_imagerenderer_test.cc
@@ -29,13 +29,16 @@
 #include <iv_imagerenderer_test.h>
 
 const gchar *filename = "../pixmaps/gnome-commander.png";
-static gboolean best_fit = TRUE;
-static double scale_factor = 1.0; //0.1 < scale_factor < 3.0
 
-TEST_F(ImageRendererTest, image_render_test) {
+INSTANTIATE_TEST_CASE_P(InstantiationScaleFactor,
+                        ImageRendererTest,
+                        ::testing::Values(-1, 0.1, 0.2, 0.33, 0.5, 0.67, 1, 1.25, 1.50, 2, 3, 4, 5, 6, 7, 
8));
+
+TEST_P(ImageRendererTest, image_render_test) {
     GtkWidget *window;
     GtkWidget *scrollbox;
     GtkWidget *imgr;
+    gboolean best_fit;
 
     gtk_init(NULL, NULL);
 
@@ -55,10 +58,15 @@ TEST_F(ImageRendererTest, image_render_test) {
 
     image_render_load_file(IMAGE_RENDER(imgr), filename);
 
-    image_render_set_best_fit(IMAGE_RENDER(imgr),best_fit);
+    if (GetParam() == -1)
+        best_fit = TRUE;
+    else
+        best_fit = FALSE;
 
-    if (!best_fit)
-        image_render_set_scale_factor(IMAGE_RENDER(imgr), scale_factor);
+    if (best_fit)
+        image_render_set_best_fit(IMAGE_RENDER(imgr),best_fit);
+    else
+        image_render_set_scale_factor(IMAGE_RENDER(imgr), GetParam());
 
     scroll_box_set_client(SCROLL_BOX(scrollbox),imgr);
 
diff --git a/tests/iv_imagerenderer_test.h b/tests/iv_imagerenderer_test.h
index 93b689a..91f1b07 100644
--- a/tests/iv_imagerenderer_test.h
+++ b/tests/iv_imagerenderer_test.h
@@ -27,7 +27,7 @@
 #include <intviewer/libgviewer.h>
 
 // The fixture for testing class ImageRendererTest
-class ImageRendererTest : public ::testing::Test {
+class ImageRendererTest : public ::testing::TestWithParam<double> {
 };
 
 #endif


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