[libnma/lr/nma-ws: 24/26] tests/ws: add NMAWs demo program
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnma/lr/nma-ws: 24/26] tests/ws: add NMAWs demo program
- Date: Sun, 16 Feb 2020 12:18:41 +0000 (UTC)
commit 5d6dd557134dda24d8e1934cbbd61f860ff90a3a
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Tue Oct 22 06:59:58 2019 +0200
tests/ws: add NMAWs demo program
.gitignore | 2 +
Makefile.am | 39 +++++++++++++++++
src/tests/meson.build | 1 +
src/tests/ws.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 155 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 61273f62..4369118b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -106,6 +106,8 @@ src/tests/wifi-dialog
src/tests/wifi-dialog-gtk4
src/tests/wifi-dialog-secrets
src/tests/wifi-dialog-secrets-gtk4
+src/tests/ws
+src/tests/ws-gtk4
src/tests/bar-code
src/tests/bar-code-gtk4
src/wireless-security/ws-resources.c
diff --git a/Makefile.am b/Makefile.am
index bb54e55b..96a2d629 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -483,6 +483,24 @@ src_tests_wifi_dialog_LDADD = \
$(LIBNM_LIBS) \
src/libnma.la
+check_PROGRAMS_norun += src/tests/ws
+
+src_tests_ws_CPPFLAGS = \
+ $(dflt_cppflags) \
+ $(GLIB_CFLAGS) \
+ $(GTK3_CFLAGS) \
+ $(LIBNM_CFLAGS) \
+ "-I$(srcdir)/shared/" \
+ "-I$(srcdir)/src" \
+ "-I$(srcdir)/src/nma-ws" \
+ -Isrc
+
+src_tests_ws_LDADD = \
+ $(GLIB_LIBS) \
+ $(GTK3_LIBS) \
+ $(LIBNM_LIBS) \
+ src/libnma.la
+
check_PROGRAMS_norun += src/tests/wifi-dialog-secrets
src_tests_wifi_dialog_secrets_CPPFLAGS = \
@@ -687,6 +705,27 @@ src_tests_wifi_dialog_gtk4_LDADD = \
$(LIBNM_LIBS) \
src/libnma-gtk4.la
+check_PROGRAMS_norun += src/tests/ws-gtk4
+
+src_tests_ws_gtk4_SOURCES = \
+ src/tests/ws.c
+
+src_tests_ws_gtk4_CPPFLAGS = \
+ $(dflt_cppflags) \
+ $(GLIB_CFLAGS) \
+ $(GTK4_CFLAGS) \
+ $(LIBNM_CFLAGS) \
+ "-I$(srcdir)/shared/" \
+ "-I$(srcdir)/src" \
+ "-I$(srcdir)/src/nma-ws" \
+ -Isrc
+
+src_tests_ws_gtk4_LDADD = \
+ $(GLIB_LIBS) \
+ $(GTK4_LIBS) \
+ $(LIBNM_LIBS) \
+ src/libnma-gtk4.la
+
check_PROGRAMS_norun += src/tests/wifi-dialog-secrets-gtk4
src_tests_wifi_dialog_secrets_gtk4_SOURCES = \
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 253de9e7..33c04d84 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -6,6 +6,7 @@ tests = [
'vpn-password-dialog',
'wifi-dialog',
'wifi-dialog-secrets',
+ 'ws',
]
foreach tst : tests
diff --git a/src/tests/ws.c b/src/tests/ws.c
new file mode 100644
index 00000000..97fe37c2
--- /dev/null
+++ b/src/tests/ws.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019 Red Hat, Inc.
+ */
+
+#include "nm-default.h"
+
+#include <gtk/gtk.h>
+
+#include "nma-ws.h"
+
+static gboolean
+delete (GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+static void
+ws_changed_cb (NMAWs *ws, gpointer user_data)
+{
+ NMConnection *connection = user_data;
+ GError *error = NULL;
+
+ nma_ws_fill_connection (ws, connection);
+ g_print ("\n=== Connection dump ===\n");
+ nm_connection_dump (connection);
+
+ if (nma_ws_validate (ws, &error))
+ return;
+
+ g_print ("*** Validation error: %s\n", error->message);
+ g_error_free (error);
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *w;
+ GtkWidget *notebook;
+ NMConnection *connection = NULL;
+ const char *hints[] = { "hello", "world", NULL };
+
+ connection = nm_simple_connection_new ();
+ nm_connection_add_setting (connection,
+ nm_setting_wireless_new ());
+
+#if GTK_CHECK_VERSION(3,90,0)
+ gtk_init ();
+#else
+ gtk_init (&argc, &argv);
+#endif
+
+ w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_show (w);
+ g_signal_connect (w, "delete-event", G_CALLBACK (delete), NULL);
+
+ notebook = gtk_notebook_new ();
+ gtk_widget_show (notebook);
+ gtk_container_add (GTK_CONTAINER (w), notebook);
+
+ w = GTK_WIDGET (nma_ws_sae_new (connection, FALSE));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("SAE"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
+ w = GTK_WIDGET (nma_ws_leap_new (connection, FALSE));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("LEAP"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
+ w = GTK_WIDGET (nma_ws_wpa_psk_new (connection, FALSE));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("WPA PSK"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
+ w = GTK_WIDGET (nma_ws_wep_key_new (connection, NM_WEP_KEY_TYPE_UNKNOWN, FALSE, FALSE));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("WEP Key"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
+ w = GTK_WIDGET (nma_ws_802_1x_new (connection, FALSE, FALSE));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("802.1x"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
+ w = GTK_WIDGET (nma_ws_dynamic_wep_new (connection, FALSE, FALSE));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("Dynamic WEP"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
+ w = GTK_WIDGET (nma_ws_wpa_eap_new (connection, FALSE, FALSE, hints));
+ gtk_widget_show (w);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), w, gtk_label_new ("WPA EAP"));
+ nma_ws_add_to_size_group (NMA_WS (w), gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL));
+ g_signal_connect (w, "ws-changed", G_CALLBACK (ws_changed_cb), connection);
+ ws_changed_cb (NMA_WS (w), connection);
+
+ gtk_main ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]