projects
/
hildon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Backfold debian/changelog 2.1.78-2
[hildon]
/
tests
/
check-hildon-color-button.c
diff --git
a/tests/check-hildon-color-button.c
b/tests/check-hildon-color-button.c
index
6792da5
..
4edfeec
100644
(file)
--- a/
tests/check-hildon-color-button.c
+++ b/
tests/check-hildon-color-button.c
@@
-1,11
+1,13
@@
/*
/*
- * Copyright (C) 2006 Nokia Corporation.
+ * This file is a part of hildon tests
*
*
- * Contact: Luc Pionchon <luc.pionchon@nokia.com>
+ * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved.
+ *
+ * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
+ * as published by the Free Software Foundation; version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
@@
-27,7
+29,7
@@
#include <glib/gprintf.h>
#include "test_suites.h"
#include "check_utils.h"
#include <glib/gprintf.h>
#include "test_suites.h"
#include "check_utils.h"
-#include "hildon-color-button.h"
+#include <hildon/hildon-color-button.h>
/* -------------------- Fixtures -------------------- */
static HildonColorButton *color_button = NULL;
/* -------------------- Fixtures -------------------- */
static HildonColorButton *color_button = NULL;
@@
-81,7
+83,7
@@
START_TEST (test_set_color_regular)
{
GdkColor color;
GdkColor * b_color;
{
GdkColor color;
GdkColor * b_color;
- GdkColor * ret_color;
+ GdkColor * ret_color = g_new (GdkColor, 1);
guint red;
guint green;
guint blue;
guint red;
guint green;
guint blue;
@@
-101,7
+103,7
@@
START_TEST (test_set_color_regular)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-121,7
+123,7
@@
START_TEST (test_set_color_regular)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-141,7
+143,7
@@
START_TEST (test_set_color_regular)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-161,7
+163,7
@@
START_TEST (test_set_color_regular)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-169,7
+171,11
@@
START_TEST (test_set_color_regular)
pixel, ret_color->red, ret_color->green,
ret_color->blue, ret_color->pixel);
pixel, ret_color->red, ret_color->green,
ret_color->blue, ret_color->pixel);
- gdk_color_free(b_color);
+ if (b_color)
+ gdk_color_free(b_color);
+
+ if (ret_color)
+ gdk_color_free(ret_color);
}
END_TEST
}
END_TEST
@@
-187,7
+193,7
@@
START_TEST (test_set_color_limits)
{
GdkColor color;
GdkColor * b_color;
{
GdkColor color;
GdkColor * b_color;
- GdkColor * ret_color;
+ GdkColor * ret_color = g_new (GdkColor, 1);
guint red;
guint green;
guint blue;
guint red;
guint green;
guint blue;
@@
-207,7
+213,7
@@
START_TEST (test_set_color_limits)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-227,7
+233,7
@@
START_TEST (test_set_color_limits)
b_color->blue=blue;
hildon_color_button_set_color(color_button,b_color);
b_color->blue=blue;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-247,7
+253,7
@@
START_TEST (test_set_color_limits)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-267,7
+273,7
@@
START_TEST (test_set_color_limits)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-287,7
+293,7
@@
START_TEST (test_set_color_limits)
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
b_color->pixel=pixel;
hildon_color_button_set_color(color_button,b_color);
- ret_color = hildon_color_button_get_color(color_button);
+ hildon_color_button_get_color(color_button, ret_color);
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
fail_if ((red != ret_color->red) || (green != ret_color->green) ||
(blue != ret_color->blue) || (pixel != ret_color->pixel),
@@
-295,8
+301,11
@@
START_TEST (test_set_color_limits)
pixel, ret_color->red, ret_color->green,
ret_color->blue, ret_color->pixel);
pixel, ret_color->red, ret_color->green,
ret_color->blue, ret_color->pixel);
- ret_color = NULL;
- gdk_color_free(b_color);
+ if (b_color)
+ gdk_color_free(b_color);
+
+ if (ret_color)
+ gdk_color_free(ret_color);
}
END_TEST
}
END_TEST
@@
-313,7
+322,7
@@
START_TEST (test_set_color_invalid)
{
GdkColor color;
GdkColor * b_color;
{
GdkColor color;
GdkColor * b_color;
- GdkColor * ret_color;
+ GdkColor * ret_color = g_new (GdkColor, 1);
GtkWidget *aux_object = NULL;
guint red;
guint green;
GtkWidget *aux_object = NULL;
guint red;
guint green;
@@
-334,7
+343,7
@@
START_TEST (test_set_color_invalid)
hildon_color_button_set_color(NULL,b_color);
/* Test 2: Get color from NULL object*/
hildon_color_button_set_color(NULL,b_color);
/* Test 2: Get color from NULL object*/
- ret_color = hildon_color_button_get_color(NULL);
+ hildon_color_button_get_color(NULL, ret_color);
/* Test 3: Set color defined by (0, 0, 0) on GtkHBox object. */
aux_object = gtk_hbox_new (TRUE, 0);
/* Test 3: Set color defined by (0, 0, 0) on GtkHBox object. */
aux_object = gtk_hbox_new (TRUE, 0);
@@
-342,15
+351,21
@@
START_TEST (test_set_color_invalid)
gdk_color_free(b_color);
/* Test 4: Get color from GtkHBox object. */
gdk_color_free(b_color);
/* Test 4: Get color from GtkHBox object. */
- ret_color = hildon_color_button_get_color((HildonColorButton *) (aux_object));
+ ret_color->red = 99;
+ ret_color->green = 99;
+ ret_color->blue = 99;
+ hildon_color_button_get_color((HildonColorButton *) (aux_object), ret_color);
- if (ret_color != NULL)
+ if (ret_color->red != 99 ||
+ ret_color->green != 99 ||
+ ret_color->blue != 99)
{
gtk_widget_destroy(aux_object);
{
gtk_widget_destroy(aux_object);
- fail ("hildon-color-button: get_color must not return any object");
+ fail ("hildon-color-button: get_color must not modify the color when launched on invalid widget");
}
gtk_widget_destroy(aux_object);
}
gtk_widget_destroy(aux_object);
+ g_free (ret_color);
}
END_TEST
}
END_TEST