[gimp] app/tests: Add single-window mode session files test



commit f55f26c9b8c2a0cd3c22d88fac85558e8689803e
Author: Martin Nordholts <martinn src gnome org>
Date:   Thu May 19 07:10:22 2011 +0200

    app/tests: Add single-window mode session files test
    
    Rename and copy some session files and add a single-window mode
    session files test.

 app/tests/.gitignore                               |    1 +
 app/tests/Makefile.am                              |    3 +-
 app/tests/gimp-test-session-utils.c                |   14 ++++-
 app/tests/gimp-test-session-utils.h                |    3 +-
 app/tests/gimpdir/Makefile.am                      |   21 ++++---
 app/tests/gimpdir/gimprc-single-window             |   12 ++++
 .../{sessionrc-2-8 => sessionrc-2-8-multi-window}  |    0
 app/tests/gimpdir/sessionrc-2-8-single-window      |   60 +++++++++++++++++
 ...ssionrc-2-8 => sessionrc-expected-multi-window} |    0
 app/tests/gimpdir/sessionrc-expected-single-window |   60 +++++++++++++++++
 app/tests/test-session-2-6-compatibility.c         |    3 +-
 .../test-session-2-8-compatibility-multi-window.c  |    9 ++-
 .../test-session-2-8-compatibility-single-window.c |   69 ++++++++++++++++++++
 13 files changed, 237 insertions(+), 18 deletions(-)
---
diff --git a/app/tests/.gitignore b/app/tests/.gitignore
index 0abb305..d4a517e 100644
--- a/app/tests/.gitignore
+++ b/app/tests/.gitignore
@@ -10,6 +10,7 @@ test-layer-grouping*
 test-save-and-export*
 test-session-2-6-compatibility*
 test-session-2-8-compatibility-multi-window*
+test-session-2-8-compatibility-single-window*
 test-tools*
 test-ui*
 test-window-management*
diff --git a/app/tests/Makefile.am b/app/tests/Makefile.am
index 8a97e5b..f86ed3e 100644
--- a/app/tests/Makefile.am
+++ b/app/tests/Makefile.am
@@ -24,8 +24,9 @@ TESTS = \
 	test-save-and-export				\
 	test-session-2-6-compatibility			\
 	test-session-2-8-compatibility-multi-window	\
+	test-session-2-8-compatibility-single-window	\
 	test-tools					\
-	test-ui					\
+	test-ui						\
 	test-xcf
 
 EXTRA_PROGRAMS = $(TESTS)
diff --git a/app/tests/gimp-test-session-utils.c b/app/tests/gimp-test-session-utils.c
index 1e41023..a5b3a6f 100644
--- a/app/tests/gimp-test-session-utils.c
+++ b/app/tests/gimp-test-session-utils.c
@@ -163,7 +163,8 @@ void
 gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
                                                 const gchar *loaded_dockrc,
                                                 const gchar *expected_sessionrc,
-                                                const gchar *expected_dockrc)
+                                                const gchar *expected_dockrc,
+                                                gboolean     single_window_mode)
 {
   Gimp              *gimp;
   GimpTestFileState  initial_sessionrc_state = { NULL, NULL, { 0, 0 } };
@@ -172,6 +173,7 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
   GimpTestFileState  final_dockrc_state      = { NULL, NULL, { 0, 0 } };
   gchar             *sessionrc_filename      = NULL;
   gchar             *dockrc_filename         = NULL;
+  gchar             *gimprc_filename         = NULL;
 
   /* Make sure to run this before we use any GIMP functions */
   gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
@@ -196,7 +198,15 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
   g_setenv ("GIMP_TESTING_DOCKRC_NAME", loaded_dockrc, TRUE /*overwrite*/);
 
   /* Start up GIMP */
-  gimp = gimp_init_for_gui_testing (TRUE /*show_gui*/);
+  if (single_window_mode)
+    {
+      gimprc_filename =
+        g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
+                          "app/tests/gimpdir/gimprc-single-window",
+                          NULL);
+    }
+  gimp = gimp_init_for_gui_testing_with_rc (TRUE /*show_gui*/, gimprc_filename);
+  g_free (gimprc_filename);
 
   /* Let the main loop run until idle to let things stabilize. This
    * includes parsing sessionrc and dockrc
diff --git a/app/tests/gimp-test-session-utils.h b/app/tests/gimp-test-session-utils.h
index 32b6c21..1ee0b37 100644
--- a/app/tests/gimp-test-session-utils.h
+++ b/app/tests/gimp-test-session-utils.h
@@ -22,7 +22,8 @@
 void gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
                                                      const gchar *loaded_dockrc,
                                                      const gchar *expected_sessionrc,
-                                                     const gchar *expected_dockrc);
+                                                     const gchar *expected_dockrc,
+                                                     gboolean     single_window_mode);
 
 
 #endif /* __GIMP_TEST_SESSION_UTILS_H__ */
diff --git a/app/tests/gimpdir/Makefile.am b/app/tests/gimpdir/Makefile.am
index cbe0fcd..d1cd1df 100644
--- a/app/tests/gimpdir/Makefile.am
+++ b/app/tests/gimpdir/Makefile.am
@@ -4,13 +4,16 @@ SUBDIRS = \
 	patterns
 
 EXTRA_DIST = \
-	dockrc			\
-	dockrc-2-6		\
-	dockrc-2-8		\
-	dockrc-expected		\
-	sessionrc		\
-	sessionrc-2-6		\
-	sessionrc-2-8		\
-	sessionrc-expected	\
-	sessionrc-expected-2-6	\
+	dockrc					\
+	dockrc-2-6				\
+	dockrc-2-8				\
+	dockrc-expected				\
+	gimprc-single-window			\
+	sessionrc				\
+	sessionrc-2-6				\
+	sessionrc-2-8-multi-window		\
+	sessionrc-2-8-single-window		\
+	sessionrc-expected-2-6			\
+	sessionrc-expected-multi-window		\
+	sessionrc-expected-single-window	\
 	tags.xml
diff --git a/app/tests/gimpdir/gimprc-single-window b/app/tests/gimpdir/gimprc-single-window
new file mode 100644
index 0000000..0c4c93b
--- /dev/null
+++ b/app/tests/gimpdir/gimprc-single-window
@@ -0,0 +1,12 @@
+# GIMP gimprc
+# 
+# This is your personal gimprc file.  Any variable defined in this file takes
+# precedence over the value defined in the system-wide gimprc:
+# /home/martin/prefix/dev/etc/gimp/2.0/gimprc
+# Most values can be set within GIMP by changing some options in the
+# Preferences dialog.
+
+(single-window-mode yes)
+
+
+# end of gimprc
diff --git a/app/tests/gimpdir/sessionrc-2-8 b/app/tests/gimpdir/sessionrc-2-8-multi-window
similarity index 100%
copy from app/tests/gimpdir/sessionrc-2-8
copy to app/tests/gimpdir/sessionrc-2-8-multi-window
diff --git a/app/tests/gimpdir/sessionrc-2-8-single-window b/app/tests/gimpdir/sessionrc-2-8-single-window
new file mode 100644
index 0000000..3c1d84e
--- /dev/null
+++ b/app/tests/gimpdir/sessionrc-2-8-single-window
@@ -0,0 +1,60 @@
+# GIMP sessionrc
+# 
+# This file takes session-specific info (that is info, you want to keep
+# between two GIMP sessions).  You are not supposed to edit it manually, but
+# of course you can do.  The sessionrc will be entirely rewritten every time
+# you quit GIMP.  If this file isn't found, defaults are used.
+
+(session-info "toplevel"
+    (factory-entry "gimp-file-open-dialog")
+    (position 390 140)
+    (size 900 815))
+(session-info "toplevel"
+    (factory-entry "gimp-image-new-dialog")
+    (position 100 100))
+(session-info "toplevel"
+    (factory-entry "gimp-empty-image-window")
+    (position 140 30)
+    (size 1285 750))
+(session-info "toplevel"
+    (factory-entry "gimp-single-image-window")
+    (position 140 30)
+    (size 1050 770)
+    (open-on-exit)
+    (aux-info
+        (left-docks-width "80")
+        (right-docks-position "200"))
+    (gimp-toolbox
+        (side left))
+    (gimp-dock
+        (side right)
+        (book
+            (current-page 0)
+            (dockable "gimp-layer-list"
+                (tab-style icon)
+                (preview-size 32)))
+        (book
+            (position 380)
+            (current-page 0)
+            (dockable "gimp-brush-grid"
+                (tab-style preview))))
+    (gimp-dock
+        (side right)
+        (position 200)
+        (book
+            (current-page 0)
+            (dockable "gimp-tool-options"
+                (tab-style icon))))
+    (gimp-dock
+        (side right)
+        (position 550)
+        (book
+            (current-page 1)
+            (dockable "gimp-pattern-grid"
+                (tab-style preview))
+            (dockable "gimp-gradient-list"
+                (tab-style preview)))))
+
+(last-tip-shown 0)
+
+# end of sessionrc
diff --git a/app/tests/gimpdir/sessionrc-2-8 b/app/tests/gimpdir/sessionrc-expected-multi-window
similarity index 100%
rename from app/tests/gimpdir/sessionrc-2-8
rename to app/tests/gimpdir/sessionrc-expected-multi-window
diff --git a/app/tests/gimpdir/sessionrc-expected-single-window b/app/tests/gimpdir/sessionrc-expected-single-window
new file mode 100644
index 0000000..3c1d84e
--- /dev/null
+++ b/app/tests/gimpdir/sessionrc-expected-single-window
@@ -0,0 +1,60 @@
+# GIMP sessionrc
+# 
+# This file takes session-specific info (that is info, you want to keep
+# between two GIMP sessions).  You are not supposed to edit it manually, but
+# of course you can do.  The sessionrc will be entirely rewritten every time
+# you quit GIMP.  If this file isn't found, defaults are used.
+
+(session-info "toplevel"
+    (factory-entry "gimp-file-open-dialog")
+    (position 390 140)
+    (size 900 815))
+(session-info "toplevel"
+    (factory-entry "gimp-image-new-dialog")
+    (position 100 100))
+(session-info "toplevel"
+    (factory-entry "gimp-empty-image-window")
+    (position 140 30)
+    (size 1285 750))
+(session-info "toplevel"
+    (factory-entry "gimp-single-image-window")
+    (position 140 30)
+    (size 1050 770)
+    (open-on-exit)
+    (aux-info
+        (left-docks-width "80")
+        (right-docks-position "200"))
+    (gimp-toolbox
+        (side left))
+    (gimp-dock
+        (side right)
+        (book
+            (current-page 0)
+            (dockable "gimp-layer-list"
+                (tab-style icon)
+                (preview-size 32)))
+        (book
+            (position 380)
+            (current-page 0)
+            (dockable "gimp-brush-grid"
+                (tab-style preview))))
+    (gimp-dock
+        (side right)
+        (position 200)
+        (book
+            (current-page 0)
+            (dockable "gimp-tool-options"
+                (tab-style icon))))
+    (gimp-dock
+        (side right)
+        (position 550)
+        (book
+            (current-page 1)
+            (dockable "gimp-pattern-grid"
+                (tab-style preview))
+            (dockable "gimp-gradient-list"
+                (tab-style preview)))))
+
+(last-tip-shown 0)
+
+# end of sessionrc
diff --git a/app/tests/test-session-2-6-compatibility.c b/app/tests/test-session-2-6-compatibility.c
index 97f9783..c1797ee 100644
--- a/app/tests/test-session-2-6-compatibility.c
+++ b/app/tests/test-session-2-6-compatibility.c
@@ -53,7 +53,8 @@ read_and_write_session_files (GimpTestFixture *fixture,
   gimp_test_session_load_and_write_session_files ("sessionrc-2-6",
                                                   "dockrc-2-6",
                                                   "sessionrc-expected-2-6",
-                                                  "dockrc-expected");
+                                                  "dockrc-expected",
+                                                  FALSE /*single_window_mode*/);
 }
 
 int main(int argc, char **argv)
diff --git a/app/tests/test-session-2-8-compatibility-multi-window.c b/app/tests/test-session-2-8-compatibility-multi-window.c
index e0b02a3..7c470c0 100644
--- a/app/tests/test-session-2-8-compatibility-multi-window.c
+++ b/app/tests/test-session-2-8-compatibility-multi-window.c
@@ -43,17 +43,18 @@ typedef struct
 
 
 /**
- * Tests that a multi-window sessionrc in GIMP 2.8 format is loaded
+ * Tests that a single-window sessionrc in GIMP 2.8 format is loaded
  * and written (thus also interpreted) like we expect.
  **/
 static void
 read_and_write_session_files (GimpTestFixture *fixture,
                           gconstpointer    data)
 {
-  gimp_test_session_load_and_write_session_files ("sessionrc-2-8",
+  gimp_test_session_load_and_write_session_files ("sessionrc-2-8-multi-window",
                                                   "dockrc-2-8",
-                                                  "sessionrc-expected",
-                                                  "dockrc-expected");
+                                                  "sessionrc-expected-multi-window",
+                                                  "dockrc-expected",
+                                                  FALSE /*single_window_mode*/);
 }
 
 int main(int argc, char **argv)
diff --git a/app/tests/test-session-2-8-compatibility-single-window.c b/app/tests/test-session-2-8-compatibility-single-window.c
new file mode 100644
index 0000000..e9cf09d
--- /dev/null
+++ b/app/tests/test-session-2-8-compatibility-single-window.c
@@ -0,0 +1,69 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 2011 Martin Nordholts
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "dialogs/dialogs-types.h"
+
+#include "tests.h"
+
+#include "gimp-test-session-utils.h"
+#include "gimp-app-test-utils.h"
+
+
+#define ADD_TEST(function) \
+  g_test_add ("/gimp-session-2-8-compatibility-single-window/" #function, \
+              GimpTestFixture, \
+              NULL, \
+              NULL, \
+              function, \
+              NULL);
+
+
+typedef struct
+{
+  int dummy;
+} GimpTestFixture;
+
+
+/**
+ * Tests that a multi-window sessionrc in GIMP 2.8 format is loaded
+ * and written (thus also interpreted) like we expect.
+ **/
+static void
+read_and_write_session_files (GimpTestFixture *fixture,
+                              gconstpointer    data)
+{
+  gimp_test_session_load_and_write_session_files ("sessionrc-2-8-single-window",
+                                                  "dockrc-2-8",
+                                                  "sessionrc-expected-single-window",
+                                                  "dockrc-expected",
+                                                  TRUE /*single_window_mode*/);
+}
+
+int main(int argc, char **argv)
+{
+  gimp_test_bail_if_no_display ();
+  gtk_test_init (&argc, &argv, NULL);
+
+  ADD_TEST (read_and_write_session_files);
+
+  /* Don't bother freeing stuff, the process is short-lived */
+  return g_test_run ();
+}



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