[sysprof] tests: add process model with filter test
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] tests: add process model with filter test
- Date: Sat, 25 Nov 2017 06:05:17 +0000 (UTC)
commit 64da43caf349bea5e311eff20b0d010860aa4c76
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 24 00:36:03 2017 -0800
tests: add process model with filter test
tests/test-model-filter.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-model-filter.c b/tests/test-model-filter.c
index d078146..2860d14 100644
--- a/tests/test-model-filter.c
+++ b/tests/test-model-filter.c
@@ -1,4 +1,5 @@
#include <sysprof-ui.h>
+#include <string.h>
#include "util/sp-model-filter.h"
@@ -109,11 +110,51 @@ test_basic (void)
g_clear_object (&filter);
}
+static gboolean
+filter_keyword_cb (GObject *object,
+ gpointer user_data)
+{
+ SpProcessModelItem *item = SP_PROCESS_MODEL_ITEM (object);
+ const gchar *needle = user_data;
+ const gchar *haystack = sp_process_model_item_get_command_line (item);
+
+ return NULL != strstr (haystack, needle);
+}
+
+static void
+test_process (void)
+{
+ SpProcessModel *model = sp_process_model_new ();
+ SpModelFilter *filter;
+ static gchar *searches[] = {
+ "a", "b", "foo", "bar", "gnome", "gnome-test",
+ "gsd", "gsd-", "libexec", "/", ":",
+ };
+
+ filter = sp_model_filter_new (G_LIST_MODEL (model));
+
+ sp_process_model_reload (model);
+
+ for (guint i = 0; i < G_N_ELEMENTS (searches); i++)
+ {
+ sp_model_filter_set_filter_func (filter,
+ filter_keyword_cb,
+ g_strdup (searches[i]),
+ g_free);
+ sp_model_filter_invalidate (filter);
+ sp_process_model_reload (model);
+ }
+
+ g_object_unref (filter);
+ g_object_unref (model);
+}
+
gint
main (gint argc,
gchar *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/SpModelFilter/basic", test_basic);
+ g_test_add_func ("/SpModelFilter/process", test_process);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]