Enlightenment CVS committal
Author : ningerso
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/bin/tests/button
Modified Files:
ewl_button.c
Log Message:
Split up test cases into separate functions.
Clean up allocated widgets in each test case.
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/button/ewl_button.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_button.c 8 Nov 2007 02:19:29 -0000 1.9
+++ ewl_button.c 8 Nov 2007 06:02:12 -0000 1.10
@@ -29,7 +29,10 @@
static int create_test(Ewl_Container *win);
static int label_test_set_get(char *buf, int len);
-static int image_test_set_get(char *buf, int len);
+static int image_null_test_get(char *buf, int len);
+static int image_null_test_set_get(char *buf, int len);
+static int image_nonexist_relative_test_set_get(char *buf, int len);
+static int image_size_null_height_test_set_get(char *buf, int len);
static int image_size_null_height_test_set_get(char *buf, int len);
static int image_size_null_width_test_set_get(char *buf, int len);
static int image_size_match_test_set_get(char *buf, int len);
@@ -38,7 +41,9 @@
static Ewl_Unit_Test button_unit_tests[] = {
{"label set/get", label_test_set_get, -1, NULL},
- {"image set/get", image_test_set_get, -1, NULL},
+ {"image null get", image_null_test_get, -1, NULL},
+ {"image null set/get", image_null_test_set_get, -1, NULL},
+ {"image nonexistent set/get",
image_nonexist_relative_test_set_get, -1, NULL},
{"image size null height set/get",
image_size_null_height_test_set_get, -1, NULL},
{"image size null width set/get",
image_size_null_width_test_set_get, -1, NULL},
{"image size match set/get", image_size_match_test_set_get, -1,
NULL},
@@ -227,11 +232,13 @@
else
ret = 1;
+ ewl_widget_destroy(button);
+
return ret;
}
static int
-image_test_set_get(char *buf, int len)
+image_null_test_get(char *buf, int len)
{
Ewl_Widget *button;
int ret = 0;
@@ -243,17 +250,47 @@
else
ret = 1;
+ ewl_widget_destroy(button);
+
+ return ret;
+}
+
+static int
+image_null_test_set_get(char *buf, int len)
+{
+ Ewl_Widget *button;
+ const char *val;
+ int ret = 0;
+
+ button = ewl_button_new();
+
+ ewl_button_image_set(EWL_BUTTON(button), NULL, NULL);
+ val = ewl_button_image_get(EWL_BUTTON(button));
+ if (val)
+ snprintf(buf, len, "image_get %s when set to NULL", val);
+ else
+ ret = 1;
+
+ ewl_widget_destroy(button);
+
+ return ret;
+}
+
+static int
+image_nonexist_relative_test_set_get(char *buf, int len)
+{
+ Ewl_Widget *button;
+ int ret = 0;
+
+ button = ewl_button_new();
+
ewl_button_image_set(EWL_BUTTON(button), "my_image", NULL);
- if (strcmp("my_image", ewl_button_image_get(EWL_BUTTON(button)))) {
+ if (strcmp("my_image", ewl_button_image_get(EWL_BUTTON(button))))
snprintf(buf, len, "image_get dosen't match image_set");
- ret = 0;
- }
+ else
+ ret = 1;
- ewl_button_image_set(EWL_BUTTON(button), NULL, NULL);
- if (ewl_button_image_get(EWL_BUTTON(button))) {
- snprintf(buf, len, "image_get not NULL when set to NULL");
- ret = 0;
- }
+ ewl_widget_destroy(button);
return ret;
}
@@ -273,6 +310,8 @@
else
ret = 1;
+ ewl_widget_destroy(button);
+
return ret;
}
@@ -291,6 +330,8 @@
else
ret = 1;
+ ewl_widget_destroy(button);
+
return ret;
}
@@ -305,13 +346,13 @@
ewl_button_image_size_set(EWL_BUTTON(button), 32, 32);
ewl_button_image_size_get(EWL_BUTTON(button), &w, &h);
- if (w != 32 || h != 32) {
+ if (w != 32 || h != 32)
snprintf(buf, len, "image_size_get width and height don't
match");
- ret = 0;
- }
else
ret = 1;
+ ewl_widget_destroy(button);
+
return ret;
}
@@ -325,13 +366,13 @@
button = ewl_button_new();
ewl_button_image_size_set(EWL_BUTTON(button), 30, 24);
ewl_button_image_size_get(EWL_BUTTON(button), &w, &h);
- if (w != 30 || h != 24) {
+ if (w != 30 || h != 24)
snprintf(buf, len, "image_size_get width and height don't
differ");
- ret = 0;
- }
else
ret = 1;
+ ewl_widget_destroy(button);
+
return ret;
}
@@ -345,12 +386,12 @@
button = ewl_button_new();
ewl_button_image_size_set(EWL_BUTTON(button), INT_MAX, INT_MAX);
ewl_button_image_size_get(EWL_BUTTON(button), &w, &h);
- if (w != INT_MAX|| h != INT_MAX) {
+ if (w != INT_MAX|| h != INT_MAX)
snprintf(buf, len, "image_size_get width and height not
INT_MAX");
- ret = 0;
- }
else
ret = 1;
+
+ ewl_widget_destroy(button);
return ret;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs