[gimp] app: Add 'crop_set_width_without_pending_rect' regression test
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Add 'crop_set_width_without_pending_rect' regression test
- Date: Sun, 31 Oct 2010 13:59:38 +0000 (UTC)
commit df0772fcdee689140cfcd25deea6e6e6f01606b3
Author: Martin Nordholts <martinn src gnome org>
Date: Sun Oct 31 15:09:03 2010 +0100
app: Add 'crop_set_width_without_pending_rect' regression test
Add regression test 'crop_set_width_without_pending_rect' for "Bug
322396 - Crop dimension entering causes crash".
app/tests/test-tools.c | 67 +++++++++++++++++++++++++++++++++++--
app/tools/gimprectangleoptions.c | 17 +++++++++
app/tools/gimprectangleoptions.h | 5 +++
3 files changed, 85 insertions(+), 4 deletions(-)
---
diff --git a/app/tests/test-tools.c b/app/tests/test-tools.c
index a5b5633..54de1c7 100644
--- a/app/tests/test-tools.c
+++ b/app/tests/test-tools.c
@@ -28,6 +28,7 @@
#include "tools/tools-types.h"
+#include "tools/gimprectangleoptions.h"
#include "tools/tool_manager.h"
#include "display/gimpdisplay.h"
@@ -126,6 +127,26 @@ gimp_tools_teardown_image (GimpTestFixture *fixture,
}
/**
+ * gimp_tools_set_tool:
+ * @gimp:
+ * @tool_id:
+ * @display:
+ *
+ * Makes sure the given tool is the active tool and that the passed
+ * display is the focused tool display.
+ **/
+static void
+gimp_tools_set_tool (Gimp *gimp,
+ const gchar *tool_id,
+ GimpDisplay *display)
+{
+ /* Activate tool and setup active display for the new tool */
+ gimp_context_set_tool (gimp_get_user_context (gimp),
+ gimp_get_tool_info (gimp, tool_id));
+ tool_manager_focus_display_active (gimp, display);
+}
+
+/**
* gimp_test_get_only_display:
* @gimp:
*
@@ -376,10 +397,8 @@ crop_tool_can_crop (GimpTestFixture *fixture,
gimp_test_run_mainloop_until_idle ();
gimp_test_run_mainloop_until_idle ();
- /* Activate tool and setup active display for the new tool */
- gimp_context_set_tool (gimp_get_user_context (gimp),
- gimp_get_tool_info (gimp, "gimp-crop-tool"));
- tool_manager_focus_display_active (gimp, shell->display);
+ /* Activate crop tool */
+ gimp_tools_set_tool (gimp, "gimp-crop-tool", shell->display);
/* Do the crop rect */
gimp_tools_synthesize_image_click_drag_release (shell,
@@ -399,6 +418,45 @@ crop_tool_can_crop (GimpTestFixture *fixture,
g_assert_cmpint (cropped_h, ==, gimp_image_get_height (image));
}
+/**
+ * crop_tool_can_crop:
+ * @fixture:
+ * @data:
+ *
+ * Make sure it's possible to change width of crop rect in tool
+ * options without there being a pending rectangle. Regression test
+ * for "Bug 322396 - Crop dimension entering causes crash".
+ **/
+static void
+crop_set_width_without_pending_rect (GimpTestFixture *fixture,
+ gconstpointer data)
+{
+ Gimp *gimp = GIMP (data);
+ GimpDisplay *display = gimp_test_get_only_display (gimp);
+ GimpToolInfo *tool_info;
+ GimpRectangleOptions *rectangle_options;
+ GtkWidget *tool_options_gui;
+ GtkWidget *size_entry;
+
+ /* Activate crop tool */
+ gimp_tools_set_tool (gimp, "gimp-crop-tool", display);
+
+ /* Get tool options */
+ tool_info = gimp_get_tool_info (gimp, "gimp-crop-tool");
+ tool_options_gui = gimp_tools_get_tool_options_gui (tool_info->tool_options);
+ rectangle_options = GIMP_RECTANGLE_OPTIONS (tool_info->tool_options);
+
+ /* Find 'Width' or 'Height' GtkTextEntry in tool options */
+ size_entry = gimp_rectangle_options_get_width_entry (rectangle_options);
+
+ /* Set arbitrary non-0 value */
+ gimp_size_entry_set_value (GIMP_SIZE_ENTRY (size_entry),
+ 0 /*field*/,
+ 42.0 /*lower*/);
+
+ /* If we don't crash, everything s fine */
+}
+
int main(int argc, char **argv)
{
Gimp *gimp = NULL;
@@ -417,6 +475,7 @@ int main(int argc, char **argv)
/* Add tests */
ADD_TEST (crop_tool_can_crop);
+ ADD_TEST (crop_set_width_without_pending_rect);
/* Run the tests and return status */
result = g_test_run ();
diff --git a/app/tools/gimprectangleoptions.c b/app/tools/gimprectangleoptions.c
index b11f31a..28a22dd 100644
--- a/app/tools/gimprectangleoptions.c
+++ b/app/tools/gimprectangleoptions.c
@@ -657,6 +657,23 @@ gimp_rectangle_options_get_property (GObject *object,
}
/**
+ * gimp_rectangle_options_get_width_entry:
+ * @rectangle_options:
+ *
+ * Returns: GtkEntry used to enter desired width of rectangle. For
+ * testing purposes.
+ **/
+GtkWidget *
+gimp_rectangle_options_get_width_entry (GimpRectangleOptions *rectangle_options)
+{
+ GimpRectangleOptionsPrivate *private;
+
+ private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (rectangle_options);
+
+ return private->width_entry;
+}
+
+/**
* gimp_rectangle_options_fixed_rule_changed:
* @combo_box:
* @private:
diff --git a/app/tools/gimprectangleoptions.h b/app/tools/gimprectangleoptions.h
index 15c95e8..7c22b97 100644
--- a/app/tools/gimprectangleoptions.h
+++ b/app/tools/gimprectangleoptions.h
@@ -165,4 +165,9 @@ void gimp_rectangle_options_get_property (GObject *object,
GParamSpec *pspec);
+/* testing helper functions */
+
+GtkWidget * gimp_rectangle_options_get_width_entry (GimpRectangleOptions *rectangle_options);
+
+
#endif /* __GIMP_RECTANGLE_OPTIONS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]