summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRashi Aswani <aswanirashi19@gmail.com>2015-07-01 17:52:42 +0530
committerRashi Aswani <aswanirashi19@gmail.com>2015-08-27 15:16:43 +0530
commit37fb583a0c4b3752432644a5b7a426d90b01b904 (patch)
tree841422272f8de58ff3890f5dc0f92b58c8b4bcd4
parent782b8788c0642dc53885cac8785d594b71bc73cb (diff)
downloadgnome-logs-37fb583a0c4b3752432644a5b7a426d90b01b904.tar.gz
Add logs UI to gnome-logs-test.c
-rw-r--r--Makefile.am46
-rw-r--r--src/gl-application.h5
-rw-r--r--src/gl-eventview.c7
-rw-r--r--src/gl-eventview.h6
-rw-r--r--src/gl-eventviewdetail.h7
-rw-r--r--src/gl-eventviewlist.c6
-rw-r--r--src/gl-eventviewlist.h6
-rw-r--r--src/gl-eventviewrow.c5
-rw-r--r--src/gl-eventviewrow.h8
-rw-r--r--src/gl-journal-model.c6
-rw-r--r--tests/gl-mock-journal.c (renamed from tests/gl-journal-mock.c)63
-rw-r--r--tests/gl-mock-journal.h (renamed from tests/gl-journal-mock.h)31
-rw-r--r--tests/gnome-logs-test.c38
13 files changed, 215 insertions, 19 deletions
diff --git a/Makefile.am b/Makefile.am
index cee871e..7564e06 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -145,7 +145,7 @@ tests_test_gl_util_SOURCES = \
tests/test-gl-util.c \
src/gl-util.c
-tests_test_gnome_logs_test_CPPFLAGS = \
+tests_gnome_logs_test_CPPFLAGS = -DTEST \
-DLOCALEDIR=\""$(localedir)"\" \
-I$(top_builddir) \
-I$(top_srcdir)/src \
@@ -159,7 +159,49 @@ tests_gnome_logs_test_LDADD = \
tests_gnome_logs_test_SOURCES = \
tests/gnome-logs-test.c \
- tests/gl-journal-mock.c
+ src/gl-application.c \
+ src/gl-categorylist.c \
+ src/gl-eventtoolbar.c \
+ src/gl-eventview.c \
+ src/gl-eventviewdetail.c \
+ src/gl-eventviewlist.c \
+ src/gl-eventviewrow.c \
+ tests/gl-mock-journal.c \
+ src/gl-journal-model.c \
+ src/gl-util.c \
+ src/gl-window.c
+
+nodist_tests_gnome_logs_test_SOURCES = \
+ src/gl-enums.c \
+ src/gl-resource.c
+
+enum_data = \
+ src/gl-enums.c \
+ src/gl-enums.h
+
+tests_gnome_logs_test_enum_headers = \
+ $(srcdir)/src/gl-categorylist.h \
+ $(srcdir)/src/gl-eventtoolbar.h \
+ $(srcdir)/src/gl-eventview.h \
+ $(srcdir)/src/gl-eventviewrow.h \
+ $(srcdir)/src/gl-util.h
+
+noinst_tests_gnome_logs_test_headers = \
+ src/gl-application.h \
+ src/gl-categorylist.h \
+ src/gl-eventtoolbar.h \
+ src/gl-eventview.h \
+ src/gl-eventviewdetail.h \
+ src/gl-eventviewlist.h \
+ src/gl-eventviewrow.h \
+ tests/gl-mock-journal.h \
+ src/gl-journal-model.h \
+ src/gl-util.h \
+ src/gl-window.h
+
+nodist_tests_gnome_logs_test_headers = \
+ src/gl-enums.h \
+ src/gl-resource.h
check_PROGRAMS = \
tests/test-gl-util \
diff --git a/src/gl-application.h b/src/gl-application.h
index b254113..2f411cb 100644
--- a/src/gl-application.h
+++ b/src/gl-application.h
@@ -20,6 +20,11 @@
#define GL_APPLICATION_H_
#include <gtk/gtk.h>
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
G_BEGIN_DECLS
diff --git a/src/gl-eventview.c b/src/gl-eventview.c
index 41c8a9e..461e36f 100644
--- a/src/gl-eventview.c
+++ b/src/gl-eventview.c
@@ -28,7 +28,12 @@
#include "gl-eventtoolbar.h"
#include "gl-eventviewdetail.h"
#include "gl-eventviewlist.h"
-#include "gl-journal.h"
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
+
#include "gl-util.h"
enum
diff --git a/src/gl-eventview.h b/src/gl-eventview.h
index eb02ad4..58acb27 100644
--- a/src/gl-eventview.h
+++ b/src/gl-eventview.h
@@ -23,7 +23,11 @@
#include <gtk/gtk.h>
#include "gl-application.h"
-
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
G_BEGIN_DECLS
/*
diff --git a/src/gl-eventviewdetail.h b/src/gl-eventviewdetail.h
index 7998b9d..05e4e6d 100644
--- a/src/gl-eventviewdetail.h
+++ b/src/gl-eventviewdetail.h
@@ -23,7 +23,12 @@
G_BEGIN_DECLS
-#include "gl-journal.h"
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
+
#include "gl-util.h"
#define GL_TYPE_EVENT_VIEW_DETAIL (gl_event_view_detail_get_type ())
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c
index 614d0e8..9e1f88a 100644
--- a/src/gl-eventviewlist.c
+++ b/src/gl-eventviewlist.c
@@ -30,6 +30,12 @@
#include "gl-eventviewrow.h"
#include "gl-journal-model.h"
#include "gl-util.h"
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
+
struct _GlEventViewList
{
diff --git a/src/gl-eventviewlist.h b/src/gl-eventviewlist.h
index 3ba1083..b5c9d21 100644
--- a/src/gl-eventviewlist.h
+++ b/src/gl-eventviewlist.h
@@ -22,7 +22,11 @@
#include <gtk/gtk.h>
#include "gl-application.h"
-#include "gl-journal.h"
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
G_BEGIN_DECLS
diff --git a/src/gl-eventviewrow.c b/src/gl-eventviewrow.c
index 41de277..1ddbb79 100644
--- a/src/gl-eventviewrow.c
+++ b/src/gl-eventviewrow.c
@@ -21,6 +21,11 @@
#include <glib/gi18n.h>
#include <glib-unix.h>
#include <stdlib.h>
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
#include "gl-enums.h"
diff --git a/src/gl-eventviewrow.h b/src/gl-eventviewrow.h
index 4fbba00..85727a6 100644
--- a/src/gl-eventviewrow.h
+++ b/src/gl-eventviewrow.h
@@ -23,7 +23,13 @@
G_BEGIN_DECLS
-#include "gl-journal.h"
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
+
+
#include "gl-util.h"
/*
diff --git a/src/gl-journal-model.c b/src/gl-journal-model.c
index e8b48e2..c9219c7 100644
--- a/src/gl-journal-model.c
+++ b/src/gl-journal-model.c
@@ -17,7 +17,11 @@
*/
#include "gl-journal-model.h"
-#include "gl-journal.h"
+#ifdef TEST
+ #include "../tests/gl-mock-journal.h"
+#else
+ #include "gl-journal.h"
+#endif
struct _GlJournalModel
{
diff --git a/tests/gl-journal-mock.c b/tests/gl-mock-journal.c
index 77a87f5..2f246c0 100644
--- a/tests/gl-journal-mock.c
+++ b/tests/gl-mock-journal.c
@@ -17,15 +17,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define gl_journal_ gl_mock_journal_
-
-#include "gl-journal-mock.h"
+#include "gl-mock-journal.h"
#include <glib-unix.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
+
struct _GlMockJournalEntry
{
GObject parent_instance;
@@ -36,17 +35,27 @@ struct _GlMockJournalEntry
gchar *comm;
gchar *kernel_device;
gchar *audit_session;
+ gchar *transport;
gchar *catalog;
guint priority;
+ gint uid;
+
};
G_DEFINE_TYPE (GlMockJournalEntry, gl_mock_journal_entry, G_TYPE_OBJECT)
+/* "_BOOT_ID=" contains 9 characters, and 33 more characters is needed to
+ * store the string formated from a 128-bit ID. The ID will be formatted as
+ * 32 lowercase hexadecimal digits and be terminated by a NUL byte. So an
+ * array of with a size 42 is need. */
+static char match[42] = "_BOOT_ID=";
+
typedef struct
{
gint fd;
guint source_id;
gchar **mandatory_fields;
+ GArray *boot_ids;
} GlMockJournalPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GlMockJournal, gl_mock_journal, G_TYPE_OBJECT)
@@ -58,21 +67,50 @@ gl_mock_journal_error_quark (void)
}
static void
+gl_mock_journal_get_boots (GlMockJournal *journal)
+{
+}
+
+GArray *
+gl_mock_journal_get_boot_ids (GlMockJournal *journal)
+{
+ GlMockJournalPrivate *priv;
+
+ priv = gl_mock_journal_get_instance_private (journal);
+ priv->boot_ids = g_array_new (FALSE, FALSE, sizeof (GArray));
+ guint64 boot_id = 12;
+ priv->boot_ids = g_array_append_val (priv->boot_ids, boot_id);
+ return priv->boot_ids;
+}
+
+static void
gl_mock_journal_finalize (GObject *object)
{
+ guint i;
GlMockJournal *journal = GL_MOCK_JOURNAL (object);
GlMockJournalPrivate *priv = gl_mock_journal_get_instance_private (journal);
g_source_remove (priv->source_id);
g_clear_pointer (&priv->mandatory_fields, g_strfreev);
+ for (i = 0; i < priv->boot_ids->len; i++)
+ {
+ GlJournalBootID *boot_id;
+
+ boot_id = &g_array_index (priv->boot_ids, GlJournalBootID, i);
+
+ g_free (boot_id->boot_match);
+ }
+ g_array_free (priv->boot_ids, TRUE);
+
}
static void
gl_mock_journal_class_init (GlMockJournalClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ /* GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gl_mock_journal_finalize;
+*/
}
static void
@@ -290,6 +328,14 @@ gl_mock_journal_entry_get_audit_session (GlMockJournalEntry *entry)
}
const gchar *
+gl_mock_journal_entry_get_transport (GlMockJournalEntry *entry)
+{
+ g_return_val_if_fail (GL_IS_MOCK_JOURNAL_ENTRY (entry), NULL);
+
+ return entry->transport;
+}
+
+const gchar *
gl_mock_journal_entry_get_catalog (GlMockJournalEntry *entry)
{
g_return_val_if_fail (GL_IS_MOCK_JOURNAL_ENTRY (entry), NULL);
@@ -304,3 +350,12 @@ gl_mock_journal_entry_get_priority (GlMockJournalEntry *entry)
return entry->priority;
}
+
+gint
+gl_mock_journal_entry_get_uid (GlMockJournalEntry *entry)
+{
+ g_return_val_if_fail (GL_IS_MOCK_JOURNAL_ENTRY (entry), -1);
+
+ return entry->uid;
+}
+
diff --git a/tests/gl-journal-mock.h b/tests/gl-mock-journal.h
index 90ffc8b..eff29ba 100644
--- a/tests/gl-journal-mock.h
+++ b/tests/gl-mock-journal.h
@@ -21,7 +21,27 @@
#define GL_MOCK_JOURNAL_H_
#include <gio/gio.h>
-
+#define GL_TYPE_JOURNAL_ENTRY GL_TYPE_MOCK_JOURNAL_ENTRY
+#define GlMockJournalEntry GlJournalEntry
+#define GlMockJournalEntryClass GlJournalEntryClass
+#define GlMockJournalClass GlJournalClass
+#define GlMockJournal GlJournal
+#define GlMockJournalPrivate GlJournalPrivate
+#define GlMockJournalBootID GlJournalBootID
+#define gl_mock_journal_entry_get_type(GlMockJournalEntry) gl_journal_entry_get_type(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_command_line(GlMockJournalEntry) gl_journal_entry_get_command_line(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_timestamp(GlMockJournalEntry) gl_journal_entry_get_timestamp(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_message(GlMockJournalEntry) gl_journal_entry_get_message(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_audit_session(GlMockJournalEntry) gl_journal_entry_get_audit_session(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_kernel_device(GlMockJournalEntry) gl_journal_entry_get_kernel_device(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_priority(GlMockJournalEntry) gl_journal_entry_get_priority(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_catalog(GlMockJournalEntry) gl_journal_entry_get_catalog(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_transport(GlMockJournalEntry) gl_journal_entry_get_transport(GlMockJournalEntry)
+#define gl_mock_journal_entry_get_uid(GlMockJournalEntry) gl_journal_entry_get_uid(GlMockJournalEntry)
+#define gl_mock_journal_previous(GlMockJournal) gl_journal_previous(GlMockJournal)
+#define gl_mock_journal_new(void) gl_journal_new(void)
+#define gl_mock_journal_set_matches gl_journal_set_matches
+#define gl_mock_journal_get_boot_ids(GlMockJournal) gl_journal_get_boot_ids(GlMockJournal)
G_BEGIN_DECLS
/*
@@ -58,12 +78,19 @@ typedef struct
GObjectClass parent_class;
} GlMockJournalClass;
+typedef struct
+{
+ gchar *boot_match;
+ guint64 realtime;
+} GlMockJournalBootID;
+
#define GL_TYPE_MOCK_JOURNAL (gl_mock_journal_get_type ())
#define GL_MOCK_JOURNAL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GL_TYPE_MOCK_JOURNAL, GlMockJournal))
GType gl_mock_journal_result_get_type (void);
GType gl_mock_journal_get_type (void);
void gl_mock_journal_set_matches (GlMockJournal *journal, const gchar * const *matches);
+GArray * gl_mock_journal_get_boot_ids (GlMockJournal *journal);
GlMockJournalEntry * gl_mock_journal_previous (GlMockJournal *journal);
GlMockJournal * gl_mock_journal_new (void);
@@ -72,8 +99,10 @@ const gchar * gl_mock_journal_entry_get_message (Gl
const gchar * gl_mock_journal_entry_get_command_line (GlMockJournalEntry *entry);
const gchar * gl_mock_journal_entry_get_kernel_device (GlMockJournalEntry *entry);
const gchar * gl_mock_journal_entry_get_audit_session (GlMockJournalEntry *entry);
+const gchar * gl_mock_journal_entry_get_transport (GlMockJournalEntry *entry);
const gchar * gl_mock_journal_entry_get_catalog (GlMockJournalEntry *entry);
guint gl_mock_journal_entry_get_priority (GlMockJournalEntry *entry);
+gint gl_mock_journal_entry_get_uid (GlMockJournalEntry *entry);
G_END_DECLS
diff --git a/tests/gnome-logs-test.c b/tests/gnome-logs-test.c
index afcc252..ca60090 100644
--- a/tests/gnome-logs-test.c
+++ b/tests/gnome-logs-test.c
@@ -16,12 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gl-journal-mock.h"
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "gl-mock-journal.h"
+#include "../src/gl-application.h"
+#include "../src/gl-eventviewdetail.h"
+#include "../src/gl-journal-model.h"
+#include "../src/gl-categorylist.h"
+#include "../src/gl-eventview.h"
+#include "../src/gl-enums.h"
+#include "../src/gl-eventtoolbar.h"
+#include "../src/gl-eventviewlist.h"
+#include "../src/gl-eventviewrow.h"
+#include "../src/gl-util.h"
+#include "../src/gl-window.h"
+
static void
check_log_message (void)
-{
-
+{
GlMockJournal *journal = gl_mock_journal_new();
GlMockJournalEntry *entry = gl_mock_journal_previous(journal);
const gchar *mystring = gl_mock_journal_entry_get_message(entry);
@@ -31,9 +47,19 @@ check_log_message (void)
int
main (int argc, char** argv)
{
- g_test_init (&argc, &argv, NULL);
+ GtkApplication *application;
+ int status;
- g_test_add_func ("/util/check_log_message", check_log_message);
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (PACKAGE_TARNAME, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
- return g_test_run ();
+ g_set_prgname (PACKAGE_TARNAME);
+ application = gl_application_new ();
+ status = g_application_run (G_APPLICATION (application), argc, argv);
+ g_test_init (&argc, &argv, NULL);
+ g_test_add_func ("/util/check_log_message", check_log_message);
+ g_object_unref (application);
+
+ return g_test_run ();
}