[gnome-logs/wip/test: 12/16] Update mock journal files and Makefile.am



commit a7490f7a5f1f40bcf9e4e98b18738a6a9842c0a2
Author: Rashi Aswani <aswanirashi19 gmail com>
Date:   Thu Jun 18 16:21:25 2015 +0530

    Update mock journal files and Makefile.am

 Makefile.am             |   21 +++++++++++++++++-
 tests/gl-journal-mock.c |   55 +++++++++++++++++++++++++++++-----------------
 tests/gl-journal-mock.h |    8 ++++--
 3 files changed, 60 insertions(+), 24 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 28b1065..89ecbff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -148,13 +148,32 @@ tests_test_gl_util_SOURCES = \
 tests_gl_journal_mock_CFLAGS = \
        $(LOGS_CFLAGS)
 
+tests_gl_journal_mock_LDADD = \
+        $(LOGS_LIBS)
+
 tests_gl_journal_mock_SOURCES = \
        tests/gl-journal-mock.c \
        src/gl-journal.c
 
+tests_test_gnome_logs_test_CPPFLAGS = \
+        -DLOCALEDIR=\""$(localedir)"\" \
+        -I$(top_builddir) \
+        -I$(top_srcdir)/src \
+        $(WARN_CFLAGS)
+
+tests_gnome_logs_test_CFLAGS = \
+        $(LOGS_CFLAGS)
+
+tests_gnome_logs_test_LDADD = \
+        $(LOGS_LIBS)
+
+tests_gnome_logs_test_SOURCES = \
+        tests/gnome-logs-test.c \
+        tests/gl-journal-mock.c
+
 check_PROGRAMS = \
        tests/test-gl-util \
-       tests/gl-journal-mock
+       tests/gnome-logs-test
 
 TESTS = \
        $(check_PROGRAMS) \
diff --git a/tests/gl-journal-mock.c b/tests/gl-journal-mock.c
index 822db81..6925ba2 100644
--- a/tests/gl-journal-mock.c
+++ b/tests/gl-journal-mock.c
@@ -17,13 +17,32 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define gl_journal_error_quack (void) gl_mock_journal_error_quack (void)
+#define gl_journal_finalize (GObject *object) gl_mock_journal_finalize (GObject *object)
+#define gl_journal_class_init (GlJournalClass *klass) gl_mock_journal_class_init (GlMockJournalClass *klass)
+#define gl_journal_init (GlJournal *self)  gl_mock_journal_init (GlMockJournal *self)
+#define gl_journal_get_data (GlJournal *self, const gchar *field, GError **error) 
gl_mock_journal_get_data(GlMockJournal *self, const gchar *field, GError **error)
+#define gl_journal_query_entry (GlJournal *self) gl_mock_journal_query_entry (GlMockJournal *self) 
+#define gl_journal_set_matches (GlJournal *journal, const gchar * const *matches) 
gl_mock_journal_set_matches (GlMockJournal *journal, const gchar * const *matches)
+#define gl_journal_previous (GlJournal *journal) gl_mock_journal_previous (GlMockJournal *journal)
+#define gl_journal_new (void) gl_mock_journal_new (void)
+#define gl_journal_entry_init (GlJournalEntry *entry) gl_mock_journal_entry_init (GlMockJournalEntry *entry)
+#define gl_journal_entry_get_timestamp (GlJournalEntry *entry) gl_mock_journal_entry_get_timestamp 
(GlMockJournalEntry *entry)
+#define gl_journal_entry_get_message (GlJournalEntry *entry) gl_mock_journal_entry_get_message 
(GlMockJournalEntry *entry)
+#define gl_journal_entry_get_command_line (GlJournalEntry *entry) gl_mock_journal_entry_get_command_line 
(GlMockJournalEntry *entry)
+#define gl_journal_entry_get_kernel_device (GlJournalEntry *entry) gl_mock_journal_entry_get_kernel_device 
(GlMockJournalEntry *entry)
+#define gl_journal_entry_get_audit_session (GlJournalEntry *entry) gl_mock_journal_entry_get_audit_session 
(GlMockJournalEntry *entry)
+#define gl_journal_entry_get_catalog (GlJournalEntry *entry) gl_mock_journal_entry_get_catalog 
(GlMockJournalEntry *entry)
+#define gl_journal_entry_get_priority (GlJournalEntry *entry) 
gl_mock_journal_entry_get_priority(GlMockJournalEntry *entry)
+ 
 #include "gl-journal-mock.h"
 
 #include <glib-unix.h>
 #include <gio/gio.h>
 #include <stdlib.h>
+#include <string.h>
 
-struct GlMockJournalEntry
+struct _GlMockJournalEntry
 {
   GObject parent_instance;
 
@@ -49,7 +68,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GlMockJournal, gl_mock_journal, G_TYPE_OBJECT)
 GQuark
 gl_mock_journal_error_quark (void)
 {
-    return g_quark_from_static_string ("gl-journal-error-quark");
+    return g_quark_from_static_string ("gl-mock-journal-error-quark");
 }
 
 static void
@@ -83,26 +102,27 @@ gl_mock_journal_get_data (GlMockJournal *self,
     g_return_val_if_fail (error == NULL || *error == NULL, NULL);
     g_return_val_if_fail (field != NULL, NULL);
 
-    if (field =="message")
-            return "This is a test";
+    if (strcmp(field,"message")==0)
+            return "Test";
 
-    if (field == "priority")
+    if (strcmp(field,"priority")==0)
             return "Low";
 
-    if(field == "comm")
+    if(strcmp(field,"comm")==0)
             return "No idea";
  
-    if(field == "kernel_device")
+    if(strcmp(field,"kernel_device")==0)
            return "Something";
 
-    if(field == "audit_session")
+    if(strcmp(field,"audit_session")==0)
            return "Session";
 
-    if(field == "transport")
+    if(strcmp(field,"transport")==0)
            return "Transport";
 
-    if(field == "uid")
+    if(strcmp(field,"uid")==0)
            return "0001";
+   return NULL;
 }
 
 static GlMockJournalEntry *
@@ -110,9 +130,8 @@ gl_mock_journal_query_entry (GlMockJournal *self)
 {
     GlMockJournalEntry *entry;
     GError *error = NULL;
-    gchar *priority;
 
-    entry = g_object_new (GL_MOCK_TYPE_JOURNAL_ENTRY, NULL);
+    entry = g_object_new (GL_TYPE_MOCK_JOURNAL_ENTRY, NULL);
 
     entry->message = gl_mock_journal_get_data (self, "MESSAGE", NULL);
 
@@ -123,6 +142,7 @@ gl_mock_journal_query_entry (GlMockJournal *self)
         goto out;
     }
 
+    /* FIXME: priority is an int, not a char*. */
     entry->priority = gl_mock_journal_get_data (self, "PRIORITY", NULL);
 
     if (error != NULL)
@@ -168,15 +188,13 @@ out:
  * beginning.
  */
 void
-gl_mockjournal_set_matches (GlMockJournal           *journal,
+gl_mock_journal_set_matches (GlMockJournal           *journal,
                              const gchar * const *matches)
 {
     GlMockJournalPrivate *priv = gl_mock_journal_get_instance_private (journal);
     GPtrArray *mandatory_fields;
-    int r;
     gint i;
     gboolean has_boot_id = FALSE;
-
     g_return_if_fail (matches != NULL);
 
     if (priv->mandatory_fields)
@@ -206,7 +224,7 @@ gl_mockjournal_set_matches (GlMockJournal           *journal,
 }
 
 GlMockJournalEntry *
-_gl_mock_journal_previous (GlMockJournal *journal)
+gl_mock_journal_previous (GlMockJournal *journal)
 {
     return gl_mock_journal_query_entry (journal);
 }
@@ -214,7 +232,7 @@ _gl_mock_journal_previous (GlMockJournal *journal)
 GlMockJournal *
 gl_mock_journal_new (void)
 {
-    return g_object_new (GL_MOCK_TYPE_JOURNAL, NULL);
+    return g_object_new (GL_TYPE_MOCK_JOURNAL, NULL);
 }
 
 static void
@@ -265,7 +283,6 @@ const gchar *
 gl_mock_journal_entry_get_command_line (GlMockJournalEntry *entry)
 {
   g_return_val_if_fail (GL_IS_MOCK_JOURNAL_ENTRY (entry), NULL);
-
   return entry->comm;
 }
 
@@ -273,7 +290,6 @@ const gchar *
 gl_mock_journal_entry_get_kernel_device (GlMockJournalEntry *entry)
 {
   g_return_val_if_fail (GL_IS_MOCK_JOURNAL_ENTRY (entry), NULL);
-
   return entry->kernel_device;
 }
 
@@ -289,7 +305,6 @@ const gchar *
 gl_mock_journal_entry_get_catalog (GlMockJournalEntry *entry)
 {
   g_return_val_if_fail (GL_IS_MOCK_JOURNAL_ENTRY (entry), NULL);
-
   return entry->catalog;
 }
 
diff --git a/tests/gl-journal-mock.h b/tests/gl-journal-mock.h
index 2ac158e..eb55832 100644
--- a/tests/gl-journal-mock.h
+++ b/tests/gl-journal-mock.h
@@ -43,8 +43,10 @@ typedef enum
 
 GQuark gl_mock_journal_error_quark (void);
 
-#define GL_MOCK_TYPE_JOURNAL_ENTRY gl_mock_journal_entry_get_type()
+#define GL_TYPE_MOCK_JOURNAL_ENTRY gl_mock_journal_entry_get_type()
 G_DECLARE_FINAL_TYPE (GlMockJournalEntry, gl_mock_journal_entry, GL, MOCK_JOURNAL_ENTRY, GObject)
+G_DECLARE_FINAL_TYPE (GlIsMockJournalEntry, gl_is_mock_journal_entry, GL, JOURNAL_ENTRY, GObject)
+G_DECLARE_FINAL_TYPE (GlMockJournalEntryParentClass, gl_mock_journal_entry_parent_class, GL, 
JOURNAL_ENTRY_PARENT_CLASS, GObject)
 
 typedef struct
 {
@@ -58,8 +60,8 @@ typedef struct
     GObjectClass parent_class;
 } GlMockJournalClass;
 
-#define GL_MOCK_TYPE_JOURNAL (gl_mock_journal_get_type ())
-#define GL_MOCK_JOURNAL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GL_MOCK_TYPE_JOURNAL, GlMockJournal))
+#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);


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