[gnome-control-center/gbsneto/reenable-tests] tests: Port tests to GTK4




commit 238a92f4a92311aea3229fbc8edf0e5309295e4d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jan 20 00:36:28 2022 -0300

    tests: Port tests to GTK4
    
    Port the tests, especially the interactive ones, to GTK4, and
    libadwaita.

 meson.build                                        |   2 +-
 .../applications/gtp-sidebar-widget.desktop.in     |   2 +-
 tests/interactive-panels/gtp-dynamic-panel.ui      |  75 ++------
 tests/interactive-panels/gtp-header-widget.c       |  19 --
 tests/interactive-panels/gtp-header-widget.ui      |  51 ++----
 tests/interactive-panels/gtp-sidebar-widget.ui     |  42 +----
 tests/interactive-panels/gtp-static-init.ui        |  41 +----
 tests/network/cc-test-window.c                     |  29 +--
 tests/network/test-network-panel.c                 | 202 +++++++++++++++------
 9 files changed, 187 insertions(+), 276 deletions(-)
---
diff --git a/meson.build b/meson.build
index 4770dc1f4..09aa30f84 100644
--- a/meson.build
+++ b/meson.build
@@ -278,7 +278,7 @@ subdir('shell')
 subdir('search-provider')
 
 if get_option('tests')
-#  subdir('tests')
+  subdir('tests')
 endif
 
 if get_option('documentation')
diff --git a/tests/interactive-panels/applications/gtp-sidebar-widget.desktop.in 
b/tests/interactive-panels/applications/gtp-sidebar-widget.desktop.in
index 9e3749241..6c96c2d75 100644
--- a/tests/interactive-panels/applications/gtp-sidebar-widget.desktop.in
+++ b/tests/interactive-panels/applications/gtp-sidebar-widget.desktop.in
@@ -8,4 +8,4 @@ Type=Application
 NoDisplay=true
 StartupNotify=true
 Categories=GNOME;GTK;Settings;X-GNOME-Settings-Panel;X-GNOME-DetailsSettings;
-OnlyShowIn=GNOME;Unity;
\ No newline at end of file
+OnlyShowIn=GNOME;Unity;
diff --git a/tests/interactive-panels/gtp-dynamic-panel.ui b/tests/interactive-panels/gtp-dynamic-panel.ui
index 77516cfc2..30e1bdd97 100644
--- a/tests/interactive-panels/gtp-dynamic-panel.ui
+++ b/tests/interactive-panels/gtp-dynamic-panel.ui
@@ -2,75 +2,26 @@
 <interface>
   <requires lib="gtk+" version="3.22"/>
   <template class="GtpDynamicPanel" parent="CcPanel">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <child>
-      <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
+    <child type="content">
+      <object class="AdwStatusPage">
+        <property name="icon-name">weather-clear-night-symbolic</property>
+        <property name="title">Dynamic Panel</property>
+        <property name="description">Dynamic panels may hide if you don't have some hardware. Use the button 
below to toggle the panel visibility:</property>
 
         <child>
-          <object class="GtkBox">
-            <property name="visible">True</property>
-            <property name="hexpand">True</property>
-            <property name="orientation">vertical</property>
-          </object>
-        </child>
-
-        <child>
-          <object class="GtkBox">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="valign">center</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">12</property>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="pixel_size">96</property>
-                <property name="icon_name">weather-clear-night-symbolic</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="max-width-chars">50</property>
-                <property name="wrap">True</property>
-                <property name="label">Dynamic panels may hide if you don't have some hardware. Use the 
switch below to toggle the panel visibility:</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-            </child>
-            <child>
-              <object class="GtkButton">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="halign">center</property>
-                <property name="label">Hide</property>
-                <signal name="clicked" handler="on_button_clicked_cb" object="GtpDynamicPanel" swapped="no" 
/>
-              </object>
-            </child>
-          </object>
-        </child>
-
-        <child>
-          <object class="GtkBox">
-            <property name="visible">True</property>
-            <property name="hexpand">True</property>
-            <property name="orientation">vertical</property>
+          <object class="GtkButton">
+            <property name="halign">center</property>
+            <property name="label">Hide</property>
+            <signal name="clicked" handler="on_button_clicked_cb" object="GtpDynamicPanel" swapped="no" />
+            <style>
+              <class name="pill" />
+            </style>
           </object>
         </child>
 
       </object>
     </child>
+
   </template>
 </interface>
 
diff --git a/tests/interactive-panels/gtp-header-widget.c b/tests/interactive-panels/gtp-header-widget.c
index 44f6d8038..b27327a2d 100644
--- a/tests/interactive-panels/gtp-header-widget.c
+++ b/tests/interactive-panels/gtp-header-widget.c
@@ -23,35 +23,16 @@
 struct _GtpHeaderWidget
 {
   CcPanel    parent;
-
-  GtkWidget *header_widget;
 };
 
 G_DEFINE_TYPE (GtpHeaderWidget, gtp_header_widget, CC_TYPE_PANEL)
 
-static void
-gtp_header_widget_constructed (GObject *object)
-{
-  GtpHeaderWidget *self = (GtpHeaderWidget *)object;
-  CcShell *shell;
-
-  G_OBJECT_CLASS (gtp_header_widget_parent_class)->constructed (object);
-
-  shell = cc_panel_get_shell (CC_PANEL (self));
-  cc_shell_embed_widget_in_header (shell, self->header_widget, GTK_POS_LEFT);
-}
-
 static void
 gtp_header_widget_class_init (GtpHeaderWidgetClass *klass)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class->constructed = gtp_header_widget_constructed;
-
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/tests/panels/gtp-header-widget.ui");
-
-  gtk_widget_class_bind_template_child (widget_class, GtpHeaderWidget, header_widget);
 }
 
 static void
diff --git a/tests/interactive-panels/gtp-header-widget.ui b/tests/interactive-panels/gtp-header-widget.ui
index 00e3b6821..8eb9b88f8 100644
--- a/tests/interactive-panels/gtp-header-widget.ui
+++ b/tests/interactive-panels/gtp-header-widget.ui
@@ -1,47 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="3.22"/>
   <template class="GtpHeaderWidget" parent="CcPanel">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <child>
-      <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="halign">center</property>
-        <property name="valign">center</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkImage">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="pixel_size">96</property>
-            <property name="icon_name">go-top-symbolic</property>
-            <style>
-              <class name="dim-label"/>
-            </style>
-          </object>
-        </child>
-        <child>
-          <object class="GtkLabel">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label">Embedding widgets in the header bar</property>
-            <style>
-              <class name="dim-label"/>
-            </style>
-          </object>
-        </child>
+
+    <child type="titlebar-end">
+      <object class="GtkLabel" id="header_widget">
+        <property name="label">I'm a header widget</property>
       </object>
     </child>
-  </template>
 
-  <object class="GtkLabel" id="header_widget">
-    <property name="visible">True</property>
-    <property name="label">I'm a header widget</property>
-  </object>
+    <child type="content">
+      <object class="AdwStatusPage">
+        <property name="icon-name">go-top-symbolic</property>
+        <property name="title">Header Widgets</property>
+        <property name="description">Embed widgets in the header bar</property>
+      </object>
+    </child>
+  </template>
 </interface>
 
diff --git a/tests/interactive-panels/gtp-sidebar-widget.ui b/tests/interactive-panels/gtp-sidebar-widget.ui
index ad91c725c..cba80fc34 100644
--- a/tests/interactive-panels/gtp-sidebar-widget.ui
+++ b/tests/interactive-panels/gtp-sidebar-widget.ui
@@ -1,46 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="3.22"/>
   <template class="GtpSidebarWidget" parent="CcPanel">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <child>
-      <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="halign">center</property>
-        <property name="valign">center</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkImage">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="pixel_size">96</property>
-            <property name="icon_name">go-first-symbolic</property>
-            <style>
-              <class name="dim-label"/>
-            </style>
-          </object>
-        </child>
-        <child>
-          <object class="GtkLabel">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label">Embedding widgets in the sidebar</property>
-            <style>
-              <class name="dim-label"/>
-            </style>
-          </object>
-        </child>
+
+    <child type="content">
+      <object class="AdwStatusPage">
+        <property name="icon_name">go-first-symbolic</property>
+        <property name="title">Sidebar</property>
+        <property name="description">Add a custom sidebar to the panel</property>
       </object>
     </child>
+
   </template>
 
   <object class="GtkLabel" id="sidebar_widget">
-    <property name="visible">True</property>
     <property name="label">I'm a sidebar widget</property>
   </object>
 </interface>
diff --git a/tests/interactive-panels/gtp-static-init.ui b/tests/interactive-panels/gtp-static-init.ui
index e7338888d..32b02a918 100644
--- a/tests/interactive-panels/gtp-static-init.ui
+++ b/tests/interactive-panels/gtp-static-init.ui
@@ -1,42 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="3.22"/>
   <template class="GtpStaticInit" parent="CcPanel">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <child>
-      <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="halign">center</property>
-        <property name="valign">center</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkImage">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="pixel_size">96</property>
-            <property name="icon_name">view-continuous-symbolic</property>
-            <style>
-              <class name="dim-label"/>
-            </style>
-          </object>
-        </child>
-        <child>
-          <object class="GtkLabel">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label">Static initializers</property>
-            <style>
-              <class name="dim-label"/>
-            </style>
-          </object>
-        </child>
+
+    <child type="content">
+      <object class="AdwStatusPage">
+        <property name="icon_name">view-continuous-symbolic</property>
+        <property name="title">Static Initializer</property>
+        <property name="description">A panel with a static initializer</property>
       </object>
     </child>
+
   </template>
 </interface>
 
diff --git a/tests/network/cc-test-window.c b/tests/network/cc-test-window.c
index ddb6b488e..3e27fa90c 100644
--- a/tests/network/cc-test-window.c
+++ b/tests/network/cc-test-window.c
@@ -29,7 +29,6 @@
 #include <gio/gio.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>
 #include <string.h>
 
 #include "shell/cc-panel.h"
@@ -73,12 +72,7 @@ set_active_panel (CcTestWindow *shell,
   if (panel)
     {
       shell->active_panel = g_object_ref (panel);
-      gtk_container_add_with_properties (GTK_CONTAINER (shell->main_box), GTK_WIDGET (panel),
-                                         "pack-type", GTK_PACK_END,
-                                         "expand", TRUE,
-                                         "fill", TRUE,
-                                         NULL);
-      gtk_widget_show (GTK_WIDGET (shell->active_panel));
+      gtk_box_append (GTK_BOX (shell->main_box), GTK_WIDGET (panel));
     }
 }
 
@@ -93,22 +87,6 @@ cc_test_window_set_active_panel_from_id (CcShell      *shell,
   g_assert_not_reached ();
 }
 
-static void
-cc_test_window_embed_widget_in_header (CcShell         *shell,
-                                       GtkWidget       *widget,
-                                       GtkPositionType  position)
-{
-  CcTestWindow *self = CC_TEST_WINDOW (shell);
-
-  /* add to main box */
-  gtk_container_add_with_properties (GTK_CONTAINER (self->main_box), GTK_WIDGET (widget),
-                                     "pack-type", GTK_PACK_START,
-                                     "expand", FALSE,
-                                     "fill", TRUE,
-                                     NULL);
-  gtk_widget_show (widget);
-}
-
 static GtkWidget *
 cc_test_window_get_toplevel (CcShell *shell)
 {
@@ -119,7 +97,6 @@ static void
 cc_shell_iface_init (CcShellInterface *iface)
 {
   iface->set_active_panel_from_id = cc_test_window_set_active_panel_from_id;
-  iface->embed_widget_in_header = cc_test_window_embed_widget_in_header;
   iface->get_toplevel = cc_test_window_get_toplevel;
 }
 
@@ -191,8 +168,7 @@ cc_test_window_init (CcTestWindow *self)
 
   self->main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
 
-  gtk_container_add (GTK_CONTAINER (self), self->main_box);
-  gtk_widget_show (self->main_box);
+  gtk_window_set_child (GTK_WINDOW (self), self->main_box);
 }
 
 CcTestWindow *
@@ -201,6 +177,5 @@ cc_test_window_new (void)
   return g_object_new (CC_TYPE_TEST_WINDOW,
                        "resizable", TRUE,
                        "title", "Test Settings",
-                       "window-position", GTK_WIN_POS_CENTER,
                        NULL);
 }
diff --git a/tests/network/test-network-panel.c b/tests/network/test-network-panel.c
index 4f33e41ab..b68c06fa4 100644
--- a/tests/network/test-network-panel.c
+++ b/tests/network/test-network-panel.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (c) 2010-2014, 2018 Red Hat, Inc.
  *
@@ -33,7 +32,6 @@
 #include <sys/types.h>
 #include <signal.h>
 #include <gtk/gtk.h>
-#include <handy.h>
 
 #include "cc-test-window.h"
 #include "shell/cc-object-storage.h"
@@ -46,7 +44,7 @@ typedef struct {
 
   NMDevice *main_ether;
 
-  GtkWidget *shell;
+  GtkWindow *shell;
   CcPanel *panel;
 } NetworkPanelFixture;
 
@@ -70,7 +68,7 @@ fixture_set_up_empty (NetworkPanelFixture  *fixture,
   /* Insert into object storage so that we see the same events as the panel. */
   cc_object_storage_add_object (CC_OBJECT_NMCLIENT, fixture->client);
 
-  fixture->shell = GTK_WIDGET (cc_test_window_new ());
+  fixture->shell = GTK_WINDOW (cc_test_window_new ());
 
   fixture->panel = g_object_new (cc_network_panel_get_type (),
                                  "shell", CC_SHELL (fixture->shell),
@@ -79,7 +77,7 @@ fixture_set_up_empty (NetworkPanelFixture  *fixture,
   g_object_ref (fixture->panel);
   cc_shell_set_active_panel (CC_SHELL (fixture->shell), fixture->panel);
 
-  gtk_widget_show (GTK_WIDGET (fixture->shell));
+  gtk_window_present (fixture->shell);
 }
 
 static void
@@ -88,7 +86,7 @@ fixture_tear_down (NetworkPanelFixture  *fixture,
 {
   g_clear_object (&fixture->panel);
   g_clear_object (&fixture->client);
-  g_clear_pointer (&fixture->shell, gtk_widget_destroy);
+  g_clear_pointer (&fixture->shell, gtk_window_destroy);
 
   cc_object_storage_destroy ();
 
@@ -124,6 +122,7 @@ static GtkWidget *
 find_label (GtkWidget   *widget,
             const gchar *label_pattern)
 {
+  GtkWidget *child;
   GtkWidget *label = NULL;
 
   if (GTK_IS_LABEL (widget)) {
@@ -132,30 +131,119 @@ find_label (GtkWidget   *widget,
       return widget;
   }
 
-  if (HDY_IS_PREFERENCES_ROW (widget)) {
-    const gchar *text = hdy_preferences_row_get_title (HDY_PREFERENCES_ROW (widget));
+  if (ADW_IS_PREFERENCES_ROW (widget)) {
+    const gchar *text = adw_preferences_row_get_title (ADW_PREFERENCES_ROW (widget));
     if (g_pattern_match_simple (label_pattern, text))
       return widget;
   }
 
-  if (HDY_IS_ACTION_ROW (widget)) {
-    const gchar *text = hdy_action_row_get_subtitle (HDY_ACTION_ROW (widget));
+  if (ADW_IS_ACTION_ROW (widget)) {
+    const gchar *text = adw_action_row_get_subtitle (ADW_ACTION_ROW (widget));
     if (g_pattern_match_simple (label_pattern, text))
       return widget;
   }
 
-  if (GTK_IS_CONTAINER (widget)) {
-    g_autoptr(GList) list = gtk_container_get_children (GTK_CONTAINER (widget));
-    GList *node;
+  for (child = gtk_widget_get_first_child (widget);
+       child;
+       child = gtk_widget_get_next_sibling (child)) {
+    label = find_label (child, label_pattern);
+    if (label)
+      break;
+  }
+
+  return label;
+}
+
+static int
+widget_geo_dist (GtkWidget *a,
+                 GtkWidget *b,
+                 GtkWidget *base)
+{
+  GtkAllocation allocation;
+  double ax0, ay0, ax1, ay1, bx0, by0, bx1, by1, xdist = 0, ydist = 0;
+
+  gtk_widget_get_allocation (a, &allocation);
+  if (!gtk_widget_translate_coordinates (a, base, 0, 0, &ax0, &ay0) ||
+      !gtk_widget_translate_coordinates (a, base, allocation.width, allocation.height, &ax1, &ay1))
+    return -G_MAXINT;
+
+  gtk_widget_get_allocation (b, &allocation);
+  if (!gtk_widget_translate_coordinates (b, base, 0, 0, &bx0, &by0) ||
+      !gtk_widget_translate_coordinates (b, base, allocation.width, allocation.height, &bx1, &by1))
+    return +G_MAXINT;
+
+  if (bx0 >= ax1)
+    xdist = bx0 - ax1;
+  else if (ax0 >= bx1)
+    xdist = ax0 - bx1;
+  if (by0 >= ay1)
+    ydist = by0 - ay1;
+  else if (ay0 >= by1)
+    ydist = ay0 - by1;
+
+  return xdist + ydist;
+}
 
-    for (node = list; node; node = node->next) {
-      label = find_label (node->data, label_pattern);
-      if (label)
+static GList*
+test_list_descendants (GtkWidget *widget,
+                       GType      widget_type)
+{
+  GtkWidget *child;
+  GList *results = NULL;
+
+  for (child = gtk_widget_get_first_child (widget);
+       child;
+       child = gtk_widget_get_next_sibling (child)) {
+    if (!widget_type || g_type_is_a (G_OBJECT_TYPE (child), widget_type))
+      results = g_list_prepend (results, child);
+    else
+      results = g_list_concat (results, test_list_descendants (child, widget_type));
+  }
+
+  return results;
+}
+
+static int
+widget_geo_cmp (gconstpointer a,
+                gconstpointer b,
+                gpointer      user_data)
+{
+  gpointer *data = user_data;
+  GtkWidget *wa = (void*) a, *wb = (void*) b, *toplevel = data[0], *base_widget = data[1];
+  int adist = widget_geo_dist (wa, base_widget, toplevel);
+  int bdist = widget_geo_dist (wb, base_widget, toplevel);
+  return adist > bdist ? +1 : adist == bdist ? 0 : -1;
+}
+
+static GtkWidget *
+find_sibling (GtkWidget *widget,
+              GType      parent_type,
+              GType      sibling_type)
+{
+  g_autoptr(GList) siblings = NULL;
+  GtkWidget *tmpwidget = widget;
+  gpointer data[2];
+
+  /* find all sibling candidates */
+  while ((tmpwidget = gtk_widget_get_parent (tmpwidget)) != NULL)
+    {
+      siblings = g_list_concat (siblings, test_list_descendants (tmpwidget, sibling_type));
+
+      /* Stop searching further up if we reached the defined parent */
+      if (parent_type && g_type_is_a (G_OBJECT_TYPE (tmpwidget), parent_type))
         break;
     }
-  }
 
-  return label;
+  /* sort them by distance to base_widget */
+  data[0] = gtk_widget_get_native (widget);
+  data[1] = widget;
+  siblings = g_list_sort_with_data (siblings, widget_geo_cmp, data);
+
+  /* pick nearest != base_widget */
+  siblings = g_list_remove (siblings, widget);
+  tmpwidget = siblings ? siblings->data : NULL;
+
+  return tmpwidget;
 }
 
 /*****************************************************************************/
@@ -184,10 +272,10 @@ test_empty_ui (NetworkPanelFixture  *fixture,
   GtkWidget *wired_header;
 
   /* There should be no Wired or Bluetooth sections */
-  wired_header = find_label(fixture->shell, "Wired");
+  wired_header = find_label (GTK_WIDGET (fixture->shell), "Wired");
   g_assert_false (wired_header && gtk_widget_is_visible(wired_header));
 
-  bt_header = find_label(fixture->shell, "Bluetooth");
+  bt_header = find_label (GTK_WIDGET (fixture->shell), "Bluetooth");
   g_assert_false (bt_header && gtk_widget_is_visible(bt_header));
 }
 
@@ -210,7 +298,7 @@ test_device_add (NetworkPanelFixture  *fixture,
   device_path = nm_object_get_path (NM_OBJECT (fixture->main_ether));
   g_debug("Device added: %s\n", device_path);
 
-  g_assert_nonnull (find_label(fixture->shell, "Wired"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Wired"));
 }
 
 static void
@@ -230,9 +318,9 @@ test_second_device_add (NetworkPanelFixture  *fixture,
   device_path = nm_object_get_path (NM_OBJECT (device));
   g_debug("Second device added: %s\n", device_path);
 
-  g_assert_null (find_label (fixture->shell, "Wired"));
-  g_assert_nonnull (find_label (fixture->shell, "Ethernet (eth1000)"));
-  g_assert_nonnull (find_label (fixture->shell, "Ethernet (eth1001)"));
+  g_assert_null (find_label (GTK_WIDGET (fixture->shell), "Wired"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1000)"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1001)"));
 }
 
 static void
@@ -257,12 +345,12 @@ test_second_device_add_remove (NetworkPanelFixture  *fixture,
   g_debug("Second device removed again\n");
 
   /* eth1000 should be labeled "Wired" again */
-  g_assert_nonnull (find_label (fixture->shell, "Wired"));
-  g_assert_null (find_label (fixture->shell, "Ethernet (eth1000)"));
-  g_assert_null (find_label (fixture->shell, "Ethernet (eth1001)"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Wired"));
+  g_assert_null (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1000)"));
+  g_assert_null (find_label (GTK_WIDGET (fixture->shell), "Ethernet (eth1001)"));
 
   /* Some more checks for unrelated UI not showing up randomly */
-  bt_header = find_label(fixture->shell, "Bluetooth");
+  bt_header = find_label (GTK_WIDGET (fixture->shell), "Bluetooth");
   g_assert_false (bt_header && gtk_widget_is_visible(bt_header));
 }
 
@@ -324,7 +412,7 @@ test_connection_add (NetworkPanelFixture  *fixture,
   g_object_unref (conn);
 
   /* We have one (non-active) connection only, so we get a special case */
-  g_assert_nonnull (find_label (fixture->shell, "Cable unplugged"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Cable unplugged"));
 }
 
 /*****************************************************************************/
@@ -336,7 +424,7 @@ test_unconnected_carrier_plug (NetworkPanelFixture  *fixture,
   nmtst_set_wired_speed (fixture->sinfo, fixture->main_ether, 1234);
   nmtst_set_device_state (fixture->sinfo, fixture->main_ether, NM_DEVICE_STATE_DISCONNECTED, 
NM_DEVICE_STATE_REASON_CARRIER);
 
-  g_assert_nonnull (find_label (fixture->shell, "1234 Mb/s"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "1234 Mb/s"));
 }
 
 
@@ -364,8 +452,8 @@ test_connection_add_activate (NetworkPanelFixture  *fixture,
   active_conn = nmtst_add_and_activate_connection (fixture->sinfo, fixture->client, fixture->main_ether, 
conn);
   g_object_unref (active_conn);
 
-  label = find_label (fixture->shell, "1234 Mb/s");
-  sw = gtk_test_find_sibling (label, GTK_TYPE_SWITCH);
+  label = find_label (GTK_WIDGET (fixture->shell), "1234 Mb/s");
+  sw = find_sibling (label, GTK_TYPE_LIST_BOX_ROW, GTK_TYPE_SWITCH);
   g_assert_nonnull (sw);
   g_assert_false (gtk_switch_get_state (GTK_SWITCH (sw)));
 
@@ -377,7 +465,7 @@ test_connection_add_activate (NetworkPanelFixture  *fixture,
   gtk_switch_set_active (GTK_SWITCH (sw), FALSE);
 
   /* Only one connection, so a generic label. */
-  g_assert_nonnull (find_label (fixture->shell, "Connected - 1234 Mb/s"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "Connected - 1234 Mb/s"));
 }
 
 static void
@@ -402,12 +490,12 @@ test_connection_multi_add_activate (NetworkPanelFixture  *fixture,
 
   g_object_unref (nmtst_add_and_activate_connection (fixture->sinfo, fixture->client, fixture->main_ether, 
conn));
 
-  g_assert_nonnull (find_label (fixture->shell, "test-inactive"));
-  g_assert_nonnull (find_label (fixture->shell, "test-active"));
-  g_assert_null (find_label (fixture->shell, "52:54:00:ab:db:23"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "test-inactive"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "test-active"));
+  g_assert_null (find_label (GTK_WIDGET (fixture->shell), "52:54:00:ab:db:23"));
 
   /* We have no switch if there are multiple connections */
-  sw = gtk_test_find_sibling (find_label (fixture->shell, "test-active"), GTK_TYPE_SWITCH);
+  sw = find_sibling (find_label (GTK_WIDGET (fixture->shell), "test-active"), GTK_TYPE_LIST_BOX_ROW, 
GTK_TYPE_SWITCH);
   if (sw)
     g_assert_false (gtk_widget_is_visible (sw));
 
@@ -415,10 +503,10 @@ test_connection_multi_add_activate (NetworkPanelFixture  *fixture,
   nmtst_set_device_state (fixture->sinfo, fixture->main_ether, NM_DEVICE_STATE_ACTIVATED, 
NM_DEVICE_STATE_REASON_NONE);
 
   /* Hardware address is shown at this point */
-  g_assert_nonnull (find_label (fixture->shell, "52:54:00:ab:db:23"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "52:54:00:ab:db:23"));
 
   /* Some more checks for unrelated UI not showing up randomly */
-  bt_header = find_label(fixture->shell, "Bluetooth");
+  bt_header = find_label (GTK_WIDGET (fixture->shell), "Bluetooth");
   g_assert_false (bt_header && gtk_widget_is_visible(bt_header));
 }
 
@@ -431,7 +519,7 @@ test_vpn_add (NetworkPanelFixture  *fixture,
   NMConnection *conn;
   NMSettingConnection *connsetting;
   NMSettingVpn *setting;
-  g_autoptr(GError) error = NULL;
+
   WAIT_DECL()
 
   conn = nmtst_create_minimal_connection ("test_vpn_a", NULL, NM_SETTING_VPN_SETTING_NAME, &connsetting);
@@ -451,7 +539,7 @@ test_vpn_add (NetworkPanelFixture  *fixture,
   g_clear_object (&info.rc);
 
   /* Make sure it shows up. */
-  g_assert_nonnull (find_label (fixture->shell, "A VPN"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A"));
 }
 
 /*****************************************************************************/
@@ -463,7 +551,6 @@ test_vpn_add_remove (NetworkPanelFixture  *fixture,
   NMConnection *conn;
   NMSettingConnection *connsetting;
   NMSettingVpn *setting;
-  g_autoptr(GError) error = NULL;
   WAIT_DECL()
 
   conn = nmtst_create_minimal_connection ("test_vpn_a", NULL, NM_SETTING_VPN_SETTING_NAME, &connsetting);
@@ -479,7 +566,7 @@ test_vpn_add_remove (NetworkPanelFixture  *fixture,
   WAIT_FINISHED(5)
 
   /* Make sure it shows up. */
-  g_assert_nonnull (find_label (fixture->shell, "A VPN"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A"));
 
   /* And delete again */
   nm_remote_connection_delete_async (info.rc, NULL, delete_cb, &info);
@@ -493,7 +580,7 @@ test_vpn_add_remove (NetworkPanelFixture  *fixture,
   g_object_unref (conn);
 
   /* Make sure it does not show up. */
-  g_assert_null (find_label (fixture->shell, "A VPN"));
+  g_assert_null (find_label (GTK_WIDGET (fixture->shell), "A"));
 }
 
 /*****************************************************************************/
@@ -505,7 +592,6 @@ test_vpn_updating (NetworkPanelFixture  *fixture,
   NMConnection *conn;
   NMSettingConnection *connsetting;
   NMSettingVpn *setting;
-  g_autoptr(GError) error = NULL;
   GVariantBuilder builder;
   WAIT_DECL()
 
@@ -524,7 +610,7 @@ test_vpn_updating (NetworkPanelFixture  *fixture,
   g_object_unref (conn);
 
   /* Make sure it shows up. */
-  g_assert_nonnull (find_label (fixture->shell, "A VPN"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A"));
 
   /* Rename VPN from A to B */
   g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sa{sv}}"));
@@ -565,8 +651,8 @@ test_vpn_updating (NetworkPanelFixture  *fixture,
   g_clear_object (&info.rc);
 
   /* Make sure it the label got renamed. */
-  g_assert_null (find_label (fixture->shell, "A VPN"));
-  g_assert_nonnull (find_label (fixture->shell, "B VPN"));
+  g_assert_null (find_label (GTK_WIDGET (fixture->shell), "A"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "B"));
 }
 
 /*****************************************************************************/
@@ -616,12 +702,12 @@ test_vpn_sorting (NetworkPanelFixture  *fixture,
   g_object_unref (conn);
 
   /* Make sure both VPNs are there. */
-  g_assert_nonnull (find_label (fixture->shell, "A VPN"));
-  g_assert_nonnull (find_label (fixture->shell, "1 VPN"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "1"));
 
   /* And test that A is after 1 */
-  a = find_parent_of_type (find_label (fixture->shell, "A VPN"), GTK_TYPE_STACK);
-  b = find_parent_of_type (find_label (fixture->shell, "1 VPN"), GTK_TYPE_STACK);
+  a = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "A"), GTK_TYPE_STACK);
+  b = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "1"), GTK_TYPE_STACK);
   container = gtk_widget_get_parent (a);
   list = gtk_container_get_children (GTK_CONTAINER (container));
   g_assert_cmpint (g_list_index (list, a), >, g_list_index (list, b));
@@ -666,13 +752,13 @@ test_vpn_sorting (NetworkPanelFixture  *fixture,
   g_clear_object (&info.rc);
 
   /* Make sure it the label got renamed. */
-  g_assert_null (find_label (fixture->shell, "1 VPN"));
-  g_assert_nonnull (find_label (fixture->shell, "A VPN"));
-  g_assert_nonnull (find_label (fixture->shell, "B VPN"));
+  g_assert_null (find_label (GTK_WIDGET (fixture->shell), "1"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "A"));
+  g_assert_nonnull (find_label (GTK_WIDGET (fixture->shell), "B"));
 
   /* And test that A is before B */
-  a = find_parent_of_type (find_label (fixture->shell, "A VPN"), GTK_TYPE_STACK);
-  b = find_parent_of_type (find_label (fixture->shell, "B VPN"), GTK_TYPE_STACK);
+  a = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "A"), GTK_TYPE_STACK);
+  b = find_parent_of_type (find_label (GTK_WIDGET (fixture->shell), "B"), GTK_TYPE_STACK);
   container = gtk_widget_get_parent (a);
   list = gtk_container_get_children (GTK_CONTAINER (container));
   g_assert_cmpint (g_list_index (list, a), <, g_list_index (list, b));
@@ -690,7 +776,7 @@ main (int argc, char **argv)
   g_setenv ("LC_ALL", "C", TRUE);
 
   gtk_test_init (&argc, &argv, NULL);
-  hdy_init ();
+  adw_init ();
 
   g_test_add ("/network-panel-wired/empty-ui",
               NetworkPanelFixture,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]