diff options
author | P. F. Chimento <philip.chimento@gmail.com> | 2013-04-29 16:02:18 +0200 |
---|---|---|
committer | P. F. Chimento <philip.chimento@gmail.com> | 2013-04-29 16:02:18 +0200 |
commit | 449b4d8e8d7c907020665a7a64324f46de67a8bb (patch) | |
tree | c0ac5948257d40b636b2f59c1a625137784ab684 /test/test-window.c | |
parent | 65fc04a83bfec371bb7cfb48d4b71c69deff6a79 (diff) | |
parent | a568631122c96468601e08b59e69090e76ab3eb5 (diff) |
Merge pull request #22 from endlessm#12
Issues/12 EosWindow based on eos-weather/window.py
Diffstat (limited to 'test/test-window.c')
-rw-r--r-- | test/test-window.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/test-window.c b/test/test-window.c index 831d94c..9127120 100644 --- a/test/test-window.c +++ b/test/test-window.c @@ -6,6 +6,10 @@ #include "run-tests.h" +#define EXPECTED_NULL_APPLICATION_ERRMSG \ + "In order to create a window, you must have an application for it to " \ + "connect to." + static void test_assign_application (GApplication *app) { @@ -17,8 +21,62 @@ test_assign_application (GApplication *app) gtk_widget_destroy (win); } +static void +test_application_not_null (GApplication *app) +{ + GtkWidget *win; + + g_test_expect_message (TEST_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, + EXPECTED_NULL_APPLICATION_ERRMSG); + + win = eos_window_new (NULL); + + g_test_assert_expected_messages (); + + gtk_widget_destroy (win); + g_application_release (app); + g_application_quit (app); /* Doesn't quit when win is destroyed */ +} + +static void +test_screen_size (GApplication *app) +{ + GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); + GdkRectangle screen_size, window_size; + GdkScreen *default_screen = gdk_screen_get_default (); + gint monitor = 0; + + /* If more than one monitor, find out which one to use */ + if (gdk_screen_get_n_monitors (default_screen) != 1) + { + GdkWindow *gdkwindow; + + /* Realize the window so that its GdkWindow is not NULL */ + gtk_widget_realize (GTK_WIDGET (win)); + gdkwindow = gtk_widget_get_window (GTK_WIDGET (win)); + monitor = gdk_screen_get_monitor_at_window (default_screen, gdkwindow); + } + + gdk_screen_get_monitor_workarea (default_screen, monitor, &screen_size); + + gtk_widget_show_now (GTK_WIDGET (win)); + + while (gtk_events_pending ()) + gtk_main_iteration (); + + gtk_widget_get_allocation (GTK_WIDGET (win), &window_size); + + g_assert_cmpint (screen_size.width, ==, window_size.width); + g_assert_cmpint (screen_size.height, ==, window_size.height); + + gtk_widget_destroy (win); +} + void add_window_tests (void) { ADD_APP_WINDOW_TEST ("/window/assign-application", test_assign_application); + ADD_APP_WINDOW_TEST ("/window/application-not-null", + test_application_not_null); + ADD_APP_WINDOW_TEST ("/window/screen-size", test_screen_size); } |