summaryrefslogtreecommitdiff
path: root/test/test-page-manager.c
blob: ecff9972fbb328370813f528d6ae646fcffe7e5f (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
#include <gtk/gtk.h>
#include <endless/endless.h>

#include "run-tests.h"

#define PAGE1_NAME "page1"
#define PAGE2_NAME "page2"
#define PAGE3_NAME "page3"
#define PAGE1_BACKGROUND "back1"
#define PAGE2_BACKGROUND "back2"
#define PAGE3_BACKGROUND "back3"
#define EXPECTED_PAGE_NAME PAGE2_NAME
#define EXPECTED_CHANGED_PAGE_NAME "changed-name"
#define DUPLICATE_PAGE_NAME "duplicate-name"
#define EXPECTED_DUPLICATE_PAGE_NAME_ERRMSG "*Not setting page name to \"" \
  DUPLICATE_PAGE_NAME "\", because page manager already contains a page by " \
  "that name*"
#define EXPECTED_PAGE_BACKGROUND PAGE2_BACKGROUND
#define EXPECTED_CHANGED_NAME "changed-name"
#define ADD_PAGE_MANAGER_TEST(path, test_func) \
  g_test_add ((path), PageManagerFixture, NULL, \
              pm_fixture_setup, (test_func), pm_fixture_teardown)
#define ADD_EMPTY_PAGE_MANAGER_TEST(path, test_func) \
  g_test_add ((path), PageManagerFixture, NULL, \
              empty_pm_fixture_setup, (test_func), pm_fixture_teardown);
#define DURATION_DEFAULT 200
#define DURATION_1 1
#define DURATION_2 9999

typedef struct
{
  GtkWidget *pm;
  GtkWidget *page1;
  GtkWidget *page2;
  GtkWidget *page3;
  GtkWidget *toolbox2;
} PageManagerFixture;

static void
pm_fixture_setup (PageManagerFixture *fixture,
                  gconstpointer       unused)
{
  fixture->pm = eos_page_manager_new ();
  fixture->page1 = gtk_label_new ("1");
  fixture->page2 = gtk_label_new ("2");
  fixture->page3 = gtk_label_new ("3");
  fixture->toolbox2 = gtk_label_new ("toolbox2");
  gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
                                     fixture->page1,
                                     "name", PAGE1_NAME,
                                     "background-uri", PAGE1_BACKGROUND,
                                     NULL);
  gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
                                     fixture->page2,
                                     "name", PAGE2_NAME,
                                     "custom-toolbox-widget", fixture->toolbox2,
                                     "background-uri", PAGE2_BACKGROUND,
                                     NULL);
  gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
                                     fixture->page3,
                                     "name", PAGE3_NAME,
                                     "page-actions", TRUE,
                                     "background-uri", PAGE3_BACKGROUND,
                                     NULL);
}

static void
empty_pm_fixture_setup (PageManagerFixture *fixture,
                        gconstpointer       unused)
{
  fixture->pm = eos_page_manager_new ();
}

static void
pm_fixture_teardown (PageManagerFixture *fixture,
                     gconstpointer       unused)
{
  gtk_widget_destroy (fixture->pm);
}

static void
test_pm_get_set_visible_page (PageManagerFixture *fixture,
                              gconstpointer       unused)
{
  GtkWidget *visible_page;
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page != fixture->page2);
  eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (fixture->pm),
                                     fixture->page2);
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == fixture->page2);
}

static void
test_pm_prop_visible_page (PageManagerFixture *fixture,
                           gconstpointer       unused)
{
  GtkWidget *visible_page;
  g_object_get (fixture->pm, "visible-page", &visible_page, NULL);
  g_assert (visible_page != fixture->page2);
  g_object_set (fixture->pm, "visible-page", fixture->page2, NULL);
  g_object_get (fixture->pm, "visible-page", &visible_page, NULL);
  g_assert (visible_page == fixture->page2);
}

static void
test_pm_get_set_visible_page_name (PageManagerFixture *fixture,
                                   gconstpointer       unused)
{
  const gchar *name;
  name = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm));
  g_assert_cmpstr (name, !=, EXPECTED_PAGE_NAME);
  eos_page_manager_set_visible_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                          EXPECTED_PAGE_NAME);
  name = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm));
  g_assert_cmpstr (name, ==, EXPECTED_PAGE_NAME);
}

static void
test_pm_prop_visible_page_name (PageManagerFixture *fixture,
                                gconstpointer       unused)
{
  gchar *name;
  g_object_get (fixture->pm, "visible-page-name", &name, NULL);
  g_assert_cmpstr (name, !=, EXPECTED_PAGE_NAME);
  g_free (name);
  g_object_set (fixture->pm, "visible-page-name", EXPECTED_PAGE_NAME, NULL);
  g_object_get (fixture->pm, "visible-page-name", &name, NULL);
  g_assert_cmpstr (name, ==, EXPECTED_PAGE_NAME);
  g_free (name);
}

static void
test_pm_get_set_page_name (PageManagerFixture *fixture,
                           gconstpointer       unused)
{
  const gchar *name;
  name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                         fixture->page1);
  g_assert_cmpstr (name, ==, PAGE1_NAME);
  name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                         fixture->page2);
  g_assert_cmpstr (name, ==, PAGE2_NAME);
  name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                         fixture->page3);
  g_assert_cmpstr (name, ==, PAGE3_NAME);
  eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                  fixture->page2,
                                  EXPECTED_CHANGED_NAME);
  name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                         fixture->page2);
  g_assert_cmpstr (name, ==, EXPECTED_CHANGED_NAME);
}

static void
test_pm_child_prop_name (PageManagerFixture *fixture,
                         gconstpointer       unused)
{
  gchar *name;
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
                           "name", &name,
                           NULL);
  g_assert_cmpstr (name, ==, PAGE1_NAME);
  g_free (name);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "name", &name,
                           NULL);
  g_assert_cmpstr (name, ==, PAGE2_NAME);
  g_free (name);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
                           "name", &name,
                           NULL);
  g_assert_cmpstr (name, ==, PAGE3_NAME);
  g_free (name);
  gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "name", EXPECTED_CHANGED_NAME,
                           NULL);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "name", &name,
                           NULL);
  g_assert_cmpstr (name, ==, EXPECTED_CHANGED_NAME);
  g_free (name);
}

static void
test_pm_get_set_page_actions (PageManagerFixture *fixture,
                              gconstpointer unused)
{
  gboolean actions;
  actions = eos_page_manager_get_page_actions (EOS_PAGE_MANAGER (fixture->pm),
                                               fixture->page1);
  g_assert (actions == FALSE);
  actions = eos_page_manager_get_page_actions (EOS_PAGE_MANAGER (fixture->pm),
                                               fixture->page3);
  g_assert (actions == TRUE);
  eos_page_manager_set_page_actions (EOS_PAGE_MANAGER (fixture->pm),
                                     fixture->page3,
                                     FALSE);
  actions = eos_page_manager_get_page_actions (EOS_PAGE_MANAGER (fixture->pm),
                                               fixture->page3);
  g_assert (actions == FALSE);
}

static void
test_pm_child_prop_page_actions (PageManagerFixture *fixture,
                                 gconstpointer unused)
{
  gboolean actions;
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
                           "page-actions", &actions,
                           NULL);
  g_assert (actions == FALSE);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
                           "page-actions", &actions,
                           NULL);
  g_assert (actions == TRUE);
  gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page3,
                           "page-actions", FALSE,
                           NULL);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
                           "page-actions", &actions,
                           NULL);
  g_assert (actions == FALSE);
}

static void
test_pm_get_set_page_custom_toolbox (PageManagerFixture *fixture,
                                     gconstpointer unused)
{
  GtkWidget *new_tb = gtk_label_new ("Another toolbox");
  GtkWidget *tb;

  tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm),
                                                        fixture->page1);
  g_assert (tb == NULL);
  tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm),
                                                        fixture->page2);
  g_assert (tb == fixture->toolbox2);

  eos_page_manager_set_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm),
                                                   fixture->page1,
                                                   new_tb);
  eos_page_manager_set_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm),
                                                   fixture->page2,
                                                   new_tb);

  tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm),
                                                        fixture->page1);
  g_assert (tb == new_tb);
  tb = eos_page_manager_get_page_custom_toolbox_widget (EOS_PAGE_MANAGER (fixture->pm),
                                                        fixture->page2);
  g_assert (tb == new_tb);
}

static void
test_pm_child_prop_custom_toolbox (PageManagerFixture *fixture,
                                   gconstpointer unused)
{
  GtkWidget *new_tb = gtk_label_new ("Another toolbox");
  GtkWidget *tb;

  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
                           "custom-toolbox-widget", &tb,
                           NULL);
  g_assert (tb == NULL);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "custom-toolbox-widget", &tb,
                           NULL);
  g_assert (tb == fixture->toolbox2);

  gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page1,
                           "custom-toolbox-widget", new_tb,
                           NULL);
  gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "custom-toolbox-widget", new_tb,
                           NULL);

  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
                           "custom-toolbox-widget", &tb,
                           NULL);
  g_assert (tb == new_tb);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "custom-toolbox-widget", &tb,
                           NULL);
  g_assert (tb == new_tb);
}

static void
test_pm_child_prop_background (PageManagerFixture *fixture,
                               gconstpointer       unused)
{
  gchar *background;
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
                           "background-uri", &background,
                           NULL);
  g_assert_cmpstr (background, ==, PAGE1_BACKGROUND);
  g_free (background);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "background-uri", &background,
                           NULL);
  g_assert_cmpstr (background, ==, PAGE2_BACKGROUND);
  g_free (background);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
                           "background-uri", &background,
                           NULL);
  g_assert_cmpstr (background, ==, PAGE3_BACKGROUND);
  g_free (background);
  gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "background-uri", EXPECTED_CHANGED_NAME,
                           NULL);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
                           "background-uri", &background,
                           NULL);
  g_assert_cmpstr (background, ==, EXPECTED_CHANGED_NAME);
  g_free (background);
}

static void
test_pm_page_no_name (PageManagerFixture *fixture,
                      gconstpointer       unused)
{
  const gchar *name_get;
  gchar *name_prop;
  GtkWidget *new_page = gtk_label_new("new");
  gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
  name_get = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm), new_page);
  g_assert (name_get == NULL);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), new_page,
                           "name", &name_prop,
                           NULL);
  g_assert (name_prop == NULL);
}

static void
test_pm_set_page_no_name (PageManagerFixture *fixture,
                          gconstpointer       unused)
{
  const gchar *name;
  eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                  fixture->page1,
                                  NULL);
  name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                         fixture->page1);
  g_assert (name == NULL);
  name = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (name == NULL);
}

static void
test_pm_page_no_background (PageManagerFixture *fixture,
                            gconstpointer       unused)
{
  const gchar *background_get;
  gchar *background_prop;
  GtkWidget *new_page = gtk_label_new("new");
  gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
  background_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
                                                             new_page);
  g_assert_cmpstr (background_get, ==, NULL);
  gtk_container_child_get (GTK_CONTAINER (fixture->pm), new_page,
                           "background-uri", &background_prop,
                           NULL);
  g_assert_cmpstr (background_prop, ==, NULL);
  g_free (background_prop);
}

static void
test_pm_page_change_background (PageManagerFixture *fixture,
                                gconstpointer       unused)
{
  const gchar *background_get;
  const gchar *background_name_1 = "first background name";
  const gchar *background_name_2 = "second background name";
  GtkWidget *new_page = gtk_label_new("new");
  gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
  eos_page_manager_set_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
                                            new_page,
                                            background_name_1);
  background_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
                                                             new_page);
  g_assert_cmpstr (background_get, ==, background_name_1);

  eos_page_manager_set_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
                                            new_page,
                                            background_name_2);
  background_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
                                                             new_page);
  g_assert_cmpstr (background_get, ==, background_name_2);
}

static void
test_pm_remove_page_behavior (PageManagerFixture *fixture,
                              gconstpointer       unused)
{
  GtkWidget *visible_page;
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == fixture->page1);
  gtk_container_remove (GTK_CONTAINER (fixture->pm), fixture->page3);
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == fixture->page1);
  gtk_container_remove (GTK_CONTAINER (fixture->pm), fixture->page2);
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == fixture->page1);
  gtk_container_remove (GTK_CONTAINER (fixture->pm), fixture->page1);
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == NULL);
}

static void
test_pm_remove_page_undefined_behavior (PageManagerFixture *fixture,
                                        gconstpointer       unused)
{
  GtkWidget *visible_page;
  GtkWidget *page1 = gtk_label_new ("page1");
  GtkWidget *page2 = gtk_label_new ("page2");
  gtk_container_add (GTK_CONTAINER (fixture->pm), page1);
  gtk_container_add (GTK_CONTAINER (fixture->pm), page2);
  eos_page_manager_set_visible_page (EOS_PAGE_MANAGER (fixture->pm),
                                     page1);
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == page1);
  gtk_container_remove (GTK_CONTAINER (fixture->pm), page1);
  // Only one page left, so it should be the visible page.
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == page2);
}

static void
test_pm_remove_page_by_name (PageManagerFixture *fixture,
                             gconstpointer       unused)
{
  GList *pages = gtk_container_get_children (GTK_CONTAINER (fixture->pm));
  guint length = g_list_length (pages);
  g_list_free (pages);

  eos_page_manager_remove_page_by_name (EOS_PAGE_MANAGER (fixture->pm),
                                        PAGE2_NAME);
  pages = gtk_container_get_children (GTK_CONTAINER (fixture->pm));
  g_assert_cmpuint (g_list_length (pages), ==, length - 1);
  g_assert (g_list_find (pages, fixture->page1) != NULL);
  g_assert (g_list_find (pages, fixture->page2) == NULL);
  g_assert (g_list_find (pages, fixture->page3) != NULL);
  g_list_free (pages);
}

static void
test_pm_duplicate_page_name (PageManagerFixture *fixture,
                             gconstpointer unused)
{
  eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                  fixture->page1,
                                  DUPLICATE_PAGE_NAME);
  /* Should not complain */
  eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                  fixture->page1,
                                  DUPLICATE_PAGE_NAME);

  g_test_expect_message (TEST_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                         EXPECTED_DUPLICATE_PAGE_NAME_ERRMSG);
  eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                  fixture->page2,
                                  DUPLICATE_PAGE_NAME);
  g_test_assert_expected_messages ();

  const gchar *name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm),
                                                      fixture->page2);
  g_assert_cmpstr (name, !=, DUPLICATE_PAGE_NAME);
}

static void
test_pm_prop_transition_duration (PageManagerFixture *fixture,
                                  gconstpointer       unused)
{
  guint duration;
  g_object_get (fixture->pm, "transition-duration", &duration, NULL);
  g_assert (duration == DURATION_DEFAULT);
  g_object_set (fixture->pm, "transition-duration", DURATION_2, NULL);
  g_object_get (fixture->pm, "transition-duration", &duration, NULL);
  g_assert (duration == DURATION_2);
}

static void
test_pm_get_set_transition_duration (PageManagerFixture *fixture,
                                     gconstpointer       unused)
{
  g_assert (DURATION_DEFAULT == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm)));
  eos_page_manager_set_transition_duration (EOS_PAGE_MANAGER (fixture->pm), DURATION_1);
  g_assert (DURATION_1 == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm)));
  eos_page_manager_set_transition_duration (EOS_PAGE_MANAGER (fixture->pm), DURATION_2);
  g_assert (DURATION_2 == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm)));
}

static void
test_pm_prop_transition_type (PageManagerFixture *fixture,
                                  gconstpointer       unused)
{
  EosPageManagerTransitionType type;
  g_object_get (fixture->pm, "transition-type", &type, NULL);
  g_assert (type == EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE);
  g_object_set (fixture->pm, "transition-type", EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE, NULL);
  g_object_get (fixture->pm, "transition-type", &type, NULL);
  g_assert (type == EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE);
}

static void
test_pm_get_set_transition_type (PageManagerFixture *fixture,
                                 gconstpointer       unused)
{
  g_assert (EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE == eos_page_manager_get_transition_type (EOS_PAGE_MANAGER (fixture->pm)));
  eos_page_manager_set_transition_type (EOS_PAGE_MANAGER (fixture->pm), EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE);
  g_assert (EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE == eos_page_manager_get_transition_type (EOS_PAGE_MANAGER (fixture->pm)));
}

static void
test_empty_pm_visible_page (PageManagerFixture *fixture,
                            gconstpointer       unused)
{
  GtkWidget *visible_page_get, *visible_page_prop;
  visible_page_get = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page_get == NULL);
  g_object_get (fixture->pm, "visible-page", &visible_page_prop, NULL);
  g_assert (visible_page_prop == NULL);
}

static void
test_empty_pm_visible_page_name (PageManagerFixture *fixture,
                                 gconstpointer       unused)
{
  const gchar *name_get;
  gchar *name_prop;
  name_get = eos_page_manager_get_visible_page_name (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (name_get == NULL);
  g_object_get (fixture->pm, "visible-page-name", &name_prop, NULL);
  g_assert (name_prop == NULL);
}

static void
test_empty_pm_add_page_behavior (PageManagerFixture *fixture,
                                 gconstpointer       unused)
{
  GtkWidget *visible_page;
  GtkWidget *page1 = gtk_label_new ("page1");
  GtkWidget *page2 = gtk_label_new ("page2");
  gtk_container_add (GTK_CONTAINER (fixture->pm), page1);
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == page1);
  gtk_container_add (GTK_CONTAINER (fixture->pm), page2);
  visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->pm));
  g_assert (visible_page == page1); /* Not page2! */
}

void
add_page_manager_tests (void)
{
  ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-visible-page",
                         test_pm_get_set_visible_page);
  ADD_PAGE_MANAGER_TEST ("/page-manager/prop-visible-page",
                         test_pm_prop_visible_page);
  ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-visible-page-name",
                         test_pm_get_set_visible_page_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/prop-visible-page-name",
                         test_pm_prop_visible_page_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-name",
                         test_pm_get_set_page_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-name",
                         test_pm_child_prop_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-actions",
                         test_pm_get_set_page_actions);
  ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-page-actions",
                         test_pm_child_prop_page_actions);
  ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-custom-toolbox",
                         test_pm_get_set_page_custom_toolbox);
  ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-custom-toolbox",
                         test_pm_child_prop_custom_toolbox);
  ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-background",
                         test_pm_child_prop_background);
  ADD_PAGE_MANAGER_TEST ("/page-manager/page-no-name", test_pm_page_no_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/set-page-no-name",
                         test_pm_set_page_no_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/page-no-background",
                         test_pm_page_no_background);
  ADD_PAGE_MANAGER_TEST ("/page-manager/page-set-background",
                         test_pm_page_change_background);
  ADD_PAGE_MANAGER_TEST ("/page-manager/remove-page-by-name",
                         test_pm_remove_page_by_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/duplicate-page-name",
                         test_pm_duplicate_page_name);
  ADD_PAGE_MANAGER_TEST ("/page-manager/prop-transition-duration",
                         test_pm_prop_transition_duration);
  ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-transition-duration",
                         test_pm_get_set_transition_duration);
  ADD_PAGE_MANAGER_TEST ("/page-manager/prop-transition-type",
                         test_pm_prop_transition_type);
  ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-transition-type",
                         test_pm_get_set_transition_type);
  ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page",
                               test_empty_pm_visible_page);
  ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page-name",
                               test_empty_pm_visible_page_name);
  ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/add-page-behavior",
                               test_empty_pm_add_page_behavior);

  /* Disabled until https://bugzilla.gnome.org/show_bug.cgi?id=699756 is fixed
  [endlessm/eos-sdk#67] */
  if (FALSE)
    {
      ADD_PAGE_MANAGER_TEST ("/page-manager/remove-page-behavior",
                           test_pm_remove_page_behavior);
      ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/remove-page-undefined-behavior",
                                   test_pm_remove_page_undefined_behavior);
    }
}