Exemple #1
0
static void
test_click_content_widget (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on content widget");
  GtkWidget *expander = gtk_expander_new ("Test Expander");
  GtkWidget *entry = gtk_entry_new ();
  gboolean expanded;
  gboolean simsuccess;
  gtk_container_add (GTK_CONTAINER (expander), entry);
  gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  gtk_widget_show (expander);
  gtk_widget_show (entry);
  gtk_widget_show_now (window);

  /* check click on content with expander open */
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
  simsuccess = gtk_test_widget_click (entry, 1, 0);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
    gtk_main_iteration ();
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
}
Exemple #2
0
static void
test_click_expander (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on expander");
  GtkWidget *expander = gtk_expander_new ("Test Expander");
  GtkWidget *label = gtk_label_new ("Test Label");
  gboolean expanded;
  gboolean simsuccess;
  gtk_container_add (GTK_CONTAINER (expander), label);
  gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
  gtk_widget_show (expander);
  gtk_widget_show (label);
  gtk_widget_show_now (window);
  /* check initial expander state */
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (!expanded);
  /* check expanding */
  simsuccess = gtk_test_widget_click (expander, 1, 0);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
    gtk_main_iteration ();
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
  /* check collapsing */
  simsuccess = gtk_test_widget_click (expander, 1, 0);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
    gtk_main_iteration ();
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (!expanded);
}
Exemple #3
0
static void
test_click_content_widget (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on content widget");
  GtkWidget *expander = gtk_expander_new ("Test Expander");
  GtkWidget *entry = gtk_entry_new ();
  gboolean expanded;
  gboolean simsuccess;
  gtk_container_add (GTK_CONTAINER (expander), entry);
  gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  gtk_widget_show (expander);
  gtk_widget_show (entry);
  gtk_widget_show_now (window);

  /* check click on content with expander open */
  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
  simsuccess = gtk_test_widget_click (entry, 1, 0);
  g_assert (simsuccess == TRUE);

  gtk_test_widget_wait_for_draw (expander);

  expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
  g_assert (expanded);
}
Exemple #4
0
static void
test_xserver_sync (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_xserver_sync");
  GtkWidget *darea = gtk_drawing_area_new ();
  GTimer *gtimer = g_timer_new();
  gint sync_is_slower = 0, repeat = 5;
  gtk_widget_set_size_request (darea, 320, 200);
  gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), darea);
  gtk_widget_show (darea);
  gtk_widget_show_now (window);
  while (repeat--)
    {
      gint i, many = 200;
      double nosync_time, sync_time;
      cairo_t *cr;

      while (gtk_events_pending ())
        gtk_main_iteration ();
      cr = gdk_cairo_create (darea->window);
      cairo_set_source_rgba (cr, 0, 1, 0, 0.1);
      /* run a number of consecutive drawing requests, just using drawing queue */
      g_timer_start (gtimer);
      for (i = 0; i < many; i++)
        {
          cairo_paint (cr);
        }
      g_timer_stop (gtimer);
      nosync_time = g_timer_elapsed (gtimer, NULL);
      gdk_flush();
      while (gtk_events_pending ())
        gtk_main_iteration ();
      g_timer_start (gtimer);
      /* run a number of consecutive drawing requests with intermediate drawing syncs */
      for (i = 0; i < many; i++)
        {
          cairo_paint (cr);
          gdk_test_render_sync (darea->window);
        }
      g_timer_stop (gtimer);
      sync_time = g_timer_elapsed (gtimer, NULL);
      sync_is_slower += sync_time > nosync_time * 1.5;
    }
  g_timer_destroy (gtimer);
  g_assert (sync_is_slower > 0);
}
Exemple #5
0
static void
test_spin_button_arrows (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_spin_button_arrows");
  GtkWidget *spinner = gtk_spin_button_new_with_range (0, 100, 5);
  gboolean simsuccess;
  double oldval, newval;
  gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), spinner);
  gtk_widget_show (spinner);
  gtk_widget_show_now (window);
  gtk_test_slider_set_perc (spinner, 0);
  /* check initial spinner value */
  oldval = gtk_test_slider_get_value (spinner);
  g_assert (oldval == 0);
  /* check simple increment */
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 1, TRUE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  newval = gtk_test_slider_get_value (spinner);
  g_assert (newval > oldval);
  /* check maximum warp */
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 3, TRUE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  oldval = gtk_test_slider_get_value (spinner);
  g_assert (oldval == 100);
  /* check simple decrement */
  oldval = gtk_test_slider_get_value (spinner);
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 1, FALSE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  newval = gtk_test_slider_get_value (spinner);
  g_assert (newval < oldval);
  /* check minimum warp */
  simsuccess = gtk_test_spin_button_click (GTK_SPIN_BUTTON (spinner), 3, FALSE);
  g_assert (simsuccess == TRUE);
  while (gtk_events_pending ()) /* let spin button timeout/idle handlers update */
    gtk_main_iteration ();
  oldval = gtk_test_slider_get_value (spinner);
  g_assert (oldval == 0);
}
Exemple #6
0
static void
test_slider_ranges (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: gtk_test_warp_slider");
  GtkWidget *hscale = gtk_hscale_new_with_range (-50, +50, 5);
  gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), hscale);
  gtk_widget_show (hscale);
  gtk_widget_show_now (window);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  gtk_test_slider_set_perc (hscale, 0.0);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  g_assert (gtk_test_slider_get_value (hscale) == -50);
  gtk_test_slider_set_perc (hscale, 50.0);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  g_assert (fabs (gtk_test_slider_get_value (hscale)) < 0.0001);
  gtk_test_slider_set_perc (hscale, 100.0);
  while (gtk_events_pending ())
    gtk_main_iteration ();
  g_assert (gtk_test_slider_get_value (hscale) == +50.0);
}