Commit 87e69d23 authored by Martin Nordholts's avatar Martin Nordholts

app/tests: Add test for GIMP 2.8 multi window session files

Move code in test-session-management.c to a common place so we can
have several variants of session management tests. We can't easily run
all session management tests in a single process, because some parts
of Gimp (the GObject) initialization eeks if done twice in the same
process.

Rename test-session-management.c to test-session-2-6-compatibility.c
and create a new test for GIMP 2.8 multi-window mode session files,
namely test-session-2-8-compatibility-multi-window.c. Copy and rename
sessionrc files accordingly.
parent 4121ac37
...@@ -8,7 +8,8 @@ test-core* ...@@ -8,7 +8,8 @@ test-core*
test-gimpidtable* test-gimpidtable*
test-layer-grouping* test-layer-grouping*
test-save-and-export* test-save-and-export*
test-session-management* test-session-2-6-compatibility*
test-session-2-8-compatibility-multi-window*
test-tools* test-tools*
test-ui* test-ui*
test-window-management* test-window-management*
......
...@@ -19,15 +19,15 @@ endif ...@@ -19,15 +19,15 @@ endif
TESTS = \ TESTS = \
test-core \ test-core \
test-gimpidtable \ test-gimpidtable \
test-save-and-export \ test-save-and-export \
test-session-management \ test-session-2-6-compatibility \
test-tools \ test-session-2-8-compatibility-multi-window \
test-ui \ test-tools \
test-ui \
test-xcf test-xcf
EXTRA_PROGRAMS = $(TESTS) EXTRA_PROGRAMS = $(TESTS)
CLEANFILES = $(EXTRA_PROGRAMS) CLEANFILES = $(EXTRA_PROGRAMS)
...@@ -35,8 +35,10 @@ $(TESTS): gimpdir-output ...@@ -35,8 +35,10 @@ $(TESTS): gimpdir-output
noinst_LIBRARIES = libgimpapptestutils.a noinst_LIBRARIES = libgimpapptestutils.a
libgimpapptestutils_a_SOURCES = \ libgimpapptestutils_a_SOURCES = \
gimp-app-test-utils.c \ gimp-app-test-utils.c \
gimp-app-test-utils.h gimp-app-test-utils.h \
gimp-test-session-utils.c \
gimp-test-session-utils.h
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
......
/* GIMP - The GNU Image Manipulation Program /* GIMP - The GNU Image Manipulation Program
* Copyright (C) 2009 Martin Nordholts * Copyright (C) 2011 Martin Nordholts <martinn@src.gnome.org>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "config.h"
#include <gegl.h> #include <gegl.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
...@@ -35,22 +37,9 @@ ...@@ -35,22 +37,9 @@
#include "tests.h" #include "tests.h"
#include "gimp-app-test-utils.h" #include "gimp-app-test-utils.h"
#include "gimp-test-session-utils.h"
#define ADD_TEST(function) \
g_test_add ("/gimp-session-management/" #function, \
GimpTestFixture, \
NULL, \
NULL, \
function, \
NULL);
typedef struct
{
int dummy;
} GimpTestFixture;
typedef struct typedef struct
{ {
gchar *filename; gchar *filename;
...@@ -157,12 +146,24 @@ gimp_test_file_state_changes (const gchar *filename, ...@@ -157,12 +146,24 @@ gimp_test_file_state_changes (const gchar *filename,
} }
/** /**
* Tests that a sessionrc from GIMP 2.6 is loaded and written (thus * gimp_test_session_load_and_write_session_files:
* also interpreted) like we expect. * @loaded_sessionrc: The name of the file of the sessionrc file to
* load
* @loaded_dockrc: The name of the file of the dockrc file to load
* @expected_sessionrc: The name of the file with the expected
* sessionrc file content
* @expected_dockrc: The name of the file with the expected dockrc
* file content
*
* Utility function for the various session management tests. We can't
* easily have all those tests in a single program several Gimp
* instance can't easily be initialized in the same process.
**/ **/
static void void
session_2_6_compatibility (GimpTestFixture *fixture, gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
gconstpointer data) const gchar *loaded_dockrc,
const gchar *expected_sessionrc,
const gchar *expected_dockrc)
{ {
Gimp *gimp; Gimp *gimp;
GimpTestFileState initial_sessionrc_state = { NULL, NULL, { 0, 0 } }; GimpTestFileState initial_sessionrc_state = { NULL, NULL, { 0, 0 } };
...@@ -181,8 +182,8 @@ session_2_6_compatibility (GimpTestFixture *fixture, ...@@ -181,8 +182,8 @@ session_2_6_compatibility (GimpTestFixture *fixture,
* the read file, which is why we check the MD5 of the -expected * the read file, which is why we check the MD5 of the -expected
* variant * variant
*/ */
sessionrc_filename = gimp_personal_rc_file ("sessionrc-expected"); sessionrc_filename = gimp_personal_rc_file (expected_sessionrc);
dockrc_filename = gimp_personal_rc_file ("dockrc-expected"); dockrc_filename = gimp_personal_rc_file (expected_dockrc);
/* Remeber the modtimes and MD5s */ /* Remeber the modtimes and MD5s */
g_assert (gimp_test_get_file_state_verbose (sessionrc_filename, g_assert (gimp_test_get_file_state_verbose (sessionrc_filename,
...@@ -190,6 +191,10 @@ session_2_6_compatibility (GimpTestFixture *fixture, ...@@ -190,6 +191,10 @@ session_2_6_compatibility (GimpTestFixture *fixture,
g_assert (gimp_test_get_file_state_verbose (dockrc_filename, g_assert (gimp_test_get_file_state_verbose (dockrc_filename,
&initial_dockrc_state)); &initial_dockrc_state));
/* Use specific input files when restoring the session */
g_setenv ("GIMP_TESTING_SESSIONRC_NAME", loaded_sessionrc, TRUE /*overwrite*/);
g_setenv ("GIMP_TESTING_DOCKRC_NAME", loaded_dockrc, TRUE /*overwrite*/);
/* Start up GIMP */ /* Start up GIMP */
gimp = gimp_init_for_gui_testing (TRUE /*show_gui*/); gimp = gimp_init_for_gui_testing (TRUE /*show_gui*/);
...@@ -205,6 +210,10 @@ session_2_6_compatibility (GimpTestFixture *fixture, ...@@ -205,6 +210,10 @@ session_2_6_compatibility (GimpTestFixture *fixture,
*/ */
gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR", gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
"app/tests/gimpdir-output"); "app/tests/gimpdir-output");
/* Use normal output names */
g_unsetenv ("GIMP_TESTING_SESSIONRC_NAME");
g_unsetenv ("GIMP_TESTING_DOCKRC_NAME");
g_free (sessionrc_filename); g_free (sessionrc_filename);
g_free (dockrc_filename); g_free (dockrc_filename);
sessionrc_filename = gimp_personal_rc_file ("sessionrc"); sessionrc_filename = gimp_personal_rc_file ("sessionrc");
...@@ -232,14 +241,3 @@ session_2_6_compatibility (GimpTestFixture *fixture, ...@@ -232,14 +241,3 @@ session_2_6_compatibility (GimpTestFixture *fixture,
&initial_dockrc_state, &initial_dockrc_state,
&final_dockrc_state)); &final_dockrc_state));
} }
int main(int argc, char **argv)
{
gimp_test_bail_if_no_display ();
gtk_test_init (&argc, &argv, NULL);
ADD_TEST (session_2_6_compatibility);
/* Don't bother freeing stuff, the process is short-lived */
return g_test_run ();
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 2009 Martin Nordholts <martinn@src.gnome.org>
*
* 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/>.
*/
#ifndef __GIMP_TEST_SESSION_UTILS_H__
#define __GIMP_TEST_SESSION_UTILS_H__
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);
#endif /* __GIMP_TEST_SESSION_UTILS_H__ */
# recently closed docks # recently closed docks
(GimpSessionInfo "Palettes - FG/BG - Images" (GimpSessionInfo "Palettes - FG/BG - Images"
(factory-entry "gimp-dock-window")
(position 585 115) (position 585 115)
(size 200 575) (size 200 575)
(open-on-exit) (open-on-exit)
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
(dockable "gimp-image-list" (dockable "gimp-image-list"
(tab-style preview))))) (tab-style preview)))))
(GimpSessionInfo "Selection, Fonts" (GimpSessionInfo "Selection, Fonts"
(factory-entry "gimp-dock-window")
(position 200 180) (position 200 180)
(size 200 300) (size 200 300)
(open-on-exit) (open-on-exit)
......
# recently closed docks
(GimpSessionInfo "Palettes - FG/BG - Images"
(position 585 115)
(size 200 575)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 0)
(dockable "gimp-palette-list"
(tab-style preview)))
(book
(position 140)
(current-page 0)
(dockable "gimp-color-editor"
(tab-style preview)
(aux-info
(current-page "GimpColorSelect"))))
(book
(position 415)
(current-page 0)
(dockable "gimp-image-list"
(tab-style preview)))))
(GimpSessionInfo "Selection, Fonts"
(position 200 180)
(size 200 300)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 1)
(dockable "gimp-selection-editor"
(tab-style icon))
(dockable "gimp-font-list"
(tab-style preview)))))
# end of recently closed docks
# recently closed docks
(GimpSessionInfo "Palettes - FG/BG - Images"
(factory-entry "gimp-dock-window")
(position 585 115)
(size 200 575)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 0)
(dockable "gimp-palette-list"
(tab-style preview)))
(book
(position 140)
(current-page 0)
(dockable "gimp-color-editor"
(tab-style preview)
(aux-info
(current-page "GimpColorSelect"))))
(book
(position 415)
(current-page 0)
(dockable "gimp-image-list"
(tab-style preview)))))
(GimpSessionInfo "Selection, Fonts"
(factory-entry "gimp-dock-window")
(position 200 180)
(size 200 300)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 1)
(dockable "gimp-selection-editor"
(tab-style icon))
(dockable "gimp-font-list"
(tab-style preview)))))
# end of recently closed docks
...@@ -5,63 +5,67 @@ ...@@ -5,63 +5,67 @@
# of course you can do. The sessionrc will be entirely rewritten every time # 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. # you quit GIMP. If this file isn't found, defaults are used.
(session-info "dock" "dock" (session-info "toplevel"
(factory-entry "gimp-dock-window")
(position 565 170) (position 565 170)
(size 210 535) (size 210 535)
(open-on-exit) (open-on-exit)
(aux-info (aux-info
(show-image-menu "false") (show-image-menu "false")
(follow-active-image "true")) (follow-active-image "true"))
(dock (gimp-dock
(book (book
(current-page 0) (current-page 0)
(dockable "gimp-layer-list" (dockable "gimp-layer-list"
(tab-style icon) (tab-style icon)
(preview-size 32))) (preview-size 32)))
(book (book
(position 289) (position 290)
(current-page 0) (current-page 0)
(dockable "gimp-brush-grid" (dockable "gimp-brush-grid"
(tab-style preview))))) (tab-style preview)))))
(session-info "dock" "dock" (session-info "toplevel"
(factory-entry "gimp-dock-window")
(position 140 290) (position 140 290)
(size 405 300) (size 405 300)
(open-on-exit) (open-on-exit)
(aux-info (aux-info
(show-image-menu "false") (show-image-menu "false")
(follow-active-image "true")) (follow-active-image "true"))
(dock (gimp-dock
(book (book
(current-page 0) (current-page 0)
(dockable "gimp-tool-options" (dockable "gimp-tool-options"
(tab-style icon)))) (tab-style icon))))
(dock (gimp-dock
(book (book
(current-page 0) (current-page 0)
(dockable "gimp-device-status" (dockable "gimp-device-status"
(tab-style icon))))) (tab-style icon)))))
(session-info "dock" "dock" (session-info "toplevel"
(factory-entry "gimp-dock-window")
(position 795 45) (position 795 45)
(size 200 265) (size 200 265)
(open-on-exit) (open-on-exit)
(aux-info (aux-info
(show-image-menu "true") (show-image-menu "true")
(follow-active-image "true")) (follow-active-image "true"))
(dock (gimp-dock
(book (book
(current-page 1) (current-page 1)
(dockable "gimp-pattern-grid" (dockable "gimp-pattern-grid"
(tab-style preview)) (tab-style preview))
(dockable "gimp-gradient-list" (dockable "gimp-gradient-list"
(tab-style preview))))) (tab-style preview)))))
(session-info "dock" "dock" (session-info "toplevel"
(factory-entry "gimp-dock-window")
(position 805 345) (position 805 345)
(size 200 450) (size 200 450)
(open-on-exit) (open-on-exit)
(aux-info (aux-info
(show-image-menu "true") (show-image-menu "true")
(follow-active-image "true")) (follow-active-image "true"))
(dock (gimp-dock
(book (book
(current-page 0) (current-page 0)
(dockable "gimp-channel-list" (dockable "gimp-channel-list"
...@@ -76,18 +80,15 @@ ...@@ -76,18 +80,15 @@
(edit-active "true") (edit-active "true")
(current-data "Standard") (current-data "Standard")
(zoom-factor "2.80")))))) (zoom-factor "2.80"))))))
# Enable this when we have a way to handle that the toolbox size is (session-info "toplevel"
# likely to change due to the use of GDK_HINT_RESIZE_INC (factory-entry "gimp-file-open-dialog")
# (session-info "toolbox" "dock"
# (position 15 35)
# (size 95 620)
# (open-on-exit))
(session-info "toplevel" "gimp-file-open-dialog"
(position 390 140) (position 390 140)
(size 900 815)) (size 900 815))
(session-info "toplevel" "gimp-image-new-dialog" (session-info "toplevel"
(factory-entry "gimp-image-new-dialog")
(position 100 100)) (position 100 100))
(session-info "display" "gimp-empty-image-window" (session-info "toplevel"
(factory-entry "gimp-empty-image-window")
(position 140 30) (position 140 30)
(size 610 190)) (size 610 190))
(session-info "toplevel" (session-info "toplevel"
......
# 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 "dock" "dock"
(position 565 170)
(size 210 535)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(dock
(book
(current-page 0)
(dockable "gimp-layer-list"
(tab-style icon)
(preview-size 32)))
(book
(position 289)
(current-page 0)
(dockable "gimp-brush-grid"
(tab-style preview)))))
(session-info "dock" "dock"
(position 140 290)
(size 405 300)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(dock
(book
(current-page 0)
(dockable "gimp-tool-options"
(tab-style icon))))
(dock
(book
(current-page 0)
(dockable "gimp-device-status"
(tab-style icon)))))
(session-info "dock" "dock"
(position 795 45)
(size 200 265)
(open-on-exit)
(aux-info
(show-image-menu "true")
(follow-active-image "true"))
(dock
(book
(current-page 1)
(dockable "gimp-pattern-grid"
(tab-style preview))
(dockable "gimp-gradient-list"
(tab-style preview)))))
(session-info "dock" "dock"
(position 805 345)
(size 200 450)
(open-on-exit)
(aux-info
(show-image-menu "true")
(follow-active-image "true"))
(dock
(book
(current-page 0)
(dockable "gimp-channel-list"
(tab-style automatic)
(preview-size 32)))
(book
(position 200)
(current-page 0)
(dockable "gimp-palette-editor"
(tab-style icon)
(aux-info
(edit-active "true")
(current-data "Standard")
(zoom-factor "2.80"))))))
# Enable this when we have a way to handle that the toolbox size is
# likely to change due to the use of GDK_HINT_RESIZE_INC
# (session-info "toolbox" "dock"
# (position 15 35)
# (size 95 620)
# (open-on-exit))
(session-info "toplevel" "gimp-file-open-dialog"
(position 390 140)
(size 900 815))
(session-info "toplevel" "gimp-image-new-dialog"
(position 100 100))
(session-info "display" "gimp-empty-image-window"
(position 140 30)
(size 610 190))
(session-info "toplevel"
(factory-entry "gimp-single-image-window")
(position 10 40)
(size 900 600))
(last-tip-shown 0)
# end of sessionrc
# 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-dock-window")
(position 565 170)
(size 210 535)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 0)
(dockable "gimp-layer-list"
(tab-style icon)
(preview-size 32)))
(book
(position 290)
(current-page 0)
(dockable "gimp-brush-grid"
(tab-style preview)))))
(session-info "toplevel"
(factory-entry "gimp-dock-window")
(position 140 290)
(size 405 300)
(open-on-exit)
(aux-info
(show-image-menu "false")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 0)
(dockable "gimp-tool-options"
(tab-style icon))))
(gimp-dock
(book
(current-page 0)
(dockable "gimp-device-status"
(tab-style icon)))))
(session-info "toplevel"
(factory-entry "gimp-dock-window")
(position 795 45)
(size 200 265)
(open-on-exit)
(aux-info
(show-image-menu "true")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 1)
(dockable "gimp-pattern-grid"
(tab-style preview))
(dockable "gimp-gradient-list"
(tab-style preview)))))
(session-info "toplevel"
(factory-entry "gimp-dock-window")
(position 805 345)
(size 200 450)
(open-on-exit)
(aux-info
(show-image-menu "true")
(follow-active-image "true"))
(gimp-dock
(book
(current-page 0)
(dockable "gimp-channel-list"
(tab-style automatic)
(preview-size 32)))
(book
(position 200)
(current-page 0)
(dockable "gimp-palette-editor"
(tab-style icon)
(aux-info
(edit-active "true")
(current-data "Standard")
(zoom-factor "2.80"))))))
(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 610 190))
(session-info "toplevel"
(factory-entry "gimp-single-image-window")
(position 10 40)
(size 900 600))
(last-tip-shown 0)
# end of sessionrc
/* 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-6-compatibility/" #function, \
GimpTestFixture, \
NULL, \
NULL, \
function, \
NULL);
typedef struct
{
int dummy;
} GimpTestFixture;
/**
* Tests that a sessionrc and dockrc from GIMP 2.6 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-6",
"dockrc-2-6",
"sessionrc-expected",
"dockrc-expected");
}
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 ();
}
/* 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