/*
- * 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
- * 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
{
GdkColor color;
GdkColor * b_color;
- GdkColor * ret_color;
+ GdkColor * ret_color = g_new (GdkColor, 1);
guint red;
guint green;
guint blue;
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),
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),
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),
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),
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
{
GdkColor color;
GdkColor * b_color;
- GdkColor * ret_color;
+ GdkColor * ret_color = g_new (GdkColor, 1);
guint red;
guint green;
guint blue;
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),
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),
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),
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),
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),
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
{
GdkColor color;
GdkColor * b_color;
- GdkColor * ret_color;
+ GdkColor * ret_color = g_new (GdkColor, 1);
GtkWidget *aux_object = NULL;
guint red;
guint green;
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);
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);
- 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);
+ g_free (ret_color);
}
END_TEST