1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include <ctk/ctk.h>

const int KEEP_HEIGHT = 1 << 0;
const int KEEP_WIDTH  = 1 << 1;

static void
keep_size (int      direction,
           guint    transition_type,
           gboolean animations)
{
  gboolean animations_before;
  int min_height, min_width;
  int min_child_width, min_child_height;
  CtkRevealer *revealer = CTK_REVEALER (ctk_revealer_new ());
  CtkWidget   *child    = ctk_button_new_with_label ("Some Text!");
  CtkSettings *settings = ctk_settings_get_default ();

  g_object_get (settings, "ctk-enable-animations", &animations_before, NULL);
  g_object_set (settings, "ctk-enable-animations", animations, NULL);

  ctk_container_add (CTK_CONTAINER (revealer), child);
  ctk_widget_show_all (CTK_WIDGET (revealer));

  ctk_revealer_set_transition_type (revealer, transition_type);

  ctk_revealer_set_reveal_child (revealer, TRUE);

  ctk_widget_get_preferred_width (CTK_WIDGET (child), &min_child_width, NULL);
  ctk_widget_get_preferred_height (CTK_WIDGET (child), &min_child_height, NULL);

  ctk_widget_get_preferred_width (CTK_WIDGET (revealer), &min_width, NULL);
  ctk_widget_get_preferred_height (CTK_WIDGET (revealer), &min_height, NULL);

  g_assert_cmpint (min_width, ==, min_child_width);<--- syntax error
  g_assert_cmpint (min_height, ==, min_child_height);


  ctk_revealer_set_reveal_child (revealer, FALSE);
  ctk_widget_get_preferred_width (CTK_WIDGET (revealer), &min_width, NULL);
  ctk_widget_get_preferred_height (CTK_WIDGET (revealer), &min_height, NULL);

  if (direction & KEEP_WIDTH)
    g_assert_cmpint (min_width, ==, min_child_width);
  else
    g_assert_cmpint (min_width, ==, 0);

  if (direction & KEEP_HEIGHT)
    g_assert_cmpint (min_height, ==, min_child_height);
  else
    g_assert_cmpint (min_height, ==, 0);

  g_object_set (settings, "ctk-enable-animations", animations_before, NULL);
}


static void
slide_right_animations ()
{
  keep_size (KEEP_HEIGHT, CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT, TRUE);
}

static void
slide_right_no_animations ()
{
  keep_size (KEEP_HEIGHT, CTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT, FALSE);
}

static void
slide_left_animations ()
{
  keep_size (KEEP_HEIGHT, CTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT, TRUE);
}

static void
slide_left_no_animations ()
{
  keep_size (KEEP_HEIGHT, CTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT, FALSE);
}

static void
none_animations ()
{
  keep_size (0, CTK_REVEALER_TRANSITION_TYPE_NONE, TRUE);
}

static void
none_no_animations ()
{
  keep_size (0, CTK_REVEALER_TRANSITION_TYPE_NONE, FALSE);
}

static void
crossfade_animations()
{
  keep_size (KEEP_WIDTH | KEEP_HEIGHT, CTK_REVEALER_TRANSITION_TYPE_CROSSFADE, TRUE);
}

static void
crossfade_no_animations ()
{
  keep_size (KEEP_WIDTH | KEEP_HEIGHT, CTK_REVEALER_TRANSITION_TYPE_CROSSFADE, FALSE);
}

static void
slide_down_animations ()
{
  keep_size (KEEP_WIDTH, CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN, TRUE);
}

static void
slide_down_no_animations ()
{
  keep_size (KEEP_WIDTH, CTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN, FALSE);
}

static void
slide_up_animations ()
{
  keep_size (KEEP_WIDTH, CTK_REVEALER_TRANSITION_TYPE_SLIDE_UP, TRUE);
}

static void
slide_up_no_animations ()
{
  keep_size (KEEP_WIDTH, CTK_REVEALER_TRANSITION_TYPE_SLIDE_UP, FALSE);
}

int
main (int argc, char **argv)
{
  ctk_init (&argc, &argv);
  g_test_init (&argc, &argv, NULL);

  g_test_add_func ("/sizing/revealer/slide_right_animations", slide_right_animations);
  g_test_add_func ("/sizing/revealer/slide_right_no_animations", slide_right_no_animations);

  g_test_add_func ("/sizing/revealer/slide_left_animations", slide_left_animations);
  g_test_add_func ("/sizing/revealer/slide_left_no_animations", slide_left_no_animations);

  g_test_add_func ("/sizing/revealer/none_animations", none_animations);
  g_test_add_func ("/sizing/revealer/none_no_animations", none_no_animations);

  g_test_add_func ("/sizing/revealer/crossfade_animations", crossfade_animations);
  g_test_add_func ("/sizing/revealer/crossfade_no_animations", crossfade_no_animations);

  g_test_add_func ("/sizing/revealer/slide_down_animations", slide_down_animations);
  g_test_add_func ("/sizing/revealer/slide_down_no_animations", slide_down_no_animations);

  g_test_add_func ("/sizing/revealer/slide_up_animations", slide_up_animations);
  g_test_add_func ("/sizing/revealer/slide_up_no_animations", slide_up_no_animations);

  return g_test_run ();
}