[gnome-logs/wip/test: 13/31] Update the Makefile and gl-journal-files



commit 782b8788c0642dc53885cac8785d594b71bc73cb
Author: Rashi Aswani <aswanirashi19 gmail com>
Date:   Thu Jun 18 22:14:10 2015 +0530

    Update the Makefile and gl-journal-files

 Makefile.am             |   10 ----------
 tests/gl-journal-mock.c |   44 +++++++++++++++++---------------------------
 tests/gl-journal-mock.h |    2 --
 tests/gnome-logs-test.c |   10 ++++++----
 4 files changed, 23 insertions(+), 43 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 89ecbff..cee871e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -145,16 +145,6 @@ tests_test_gl_util_SOURCES = \
        tests/test-gl-util.c \
        src/gl-util.c
 
-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) \
diff --git a/tests/gl-journal-mock.c b/tests/gl-journal-mock.c
index 6925ba2..77a87f5 100644
--- a/tests/gl-journal-mock.c
+++ b/tests/gl-journal-mock.c
@@ -17,24 +17,8 @@
  *  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)
- 
+#define gl_journal_ gl_mock_journal_
+
 #include "gl-journal-mock.h"
 
 #include <glib-unix.h>
@@ -56,6 +40,8 @@ struct _GlMockJournalEntry
   guint priority;
 };
 
+G_DEFINE_TYPE (GlMockJournalEntry, gl_mock_journal_entry, G_TYPE_OBJECT)
+
 typedef struct
 {
     gint fd;
@@ -102,25 +88,25 @@ 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 (strcmp(field,"message")==0)
-            return "Test";
+    if (strcmp(field,"MESSAGE")==0)
+            return "This is a test";
 
-    if (strcmp(field,"priority")==0)
+    if (strcmp(field,"PRIORITY")==0)
             return "Low";
 
-    if(strcmp(field,"comm")==0)
+    if(strcmp(field,"_COMM")==0)
             return "No idea";
  
-    if(strcmp(field,"kernel_device")==0)
+    if(strcmp(field,"KERNEL_DEVICE")==0)
            return "Something";
 
-    if(strcmp(field,"audit_session")==0)
+    if(strcmp(field,"AUDIT_SESSION")==0)
            return "Session";
 
-    if(strcmp(field,"transport")==0)
+    if(strcmp(field,"TRANSPORT")==0)
            return "Transport";
 
-    if(strcmp(field,"uid")==0)
+    if(strcmp(field,"UID")==0)
            return "0001";
    return NULL;
 }
@@ -283,13 +269,15 @@ 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;
+ 
+   return entry->comm;
 }
 
 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;
 }
 
@@ -305,6 +293,7 @@ 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;
 }
 
@@ -312,5 +301,6 @@ guint
 gl_mock_journal_entry_get_priority (GlMockJournalEntry *entry)
 {
   g_return_val_if_fail (GL_IS_MOCK_JOURNAL_ENTRY (entry), 0);
+
   return entry->priority;
 }
diff --git a/tests/gl-journal-mock.h b/tests/gl-journal-mock.h
index eb55832..90ffc8b 100644
--- a/tests/gl-journal-mock.h
+++ b/tests/gl-journal-mock.h
@@ -45,8 +45,6 @@ GQuark gl_mock_journal_error_quark (void);
 
 #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
 {
diff --git a/tests/gnome-logs-test.c b/tests/gnome-logs-test.c
index cbdef30..afcc252 100644
--- a/tests/gnome-logs-test.c
+++ b/tests/gnome-logs-test.c
@@ -1,6 +1,6 @@
 /*
  *  GNOME Logs - View and search logs
- *  Copyright (C) 2015 Ekaterina Gerasimova
+ *  Copyright (C) 2015 Rashi Aswani
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -21,9 +21,11 @@
 static void
 check_log_message (void)
 {
-   GlMockJournalEntry *entry;
-   gchar *mystring = gl_mock_journal_entry_get_message(entry);
-   g_assert_cmpstr(mystring, ==, "Test");
+   
+   GlMockJournal *journal = gl_mock_journal_new();
+   GlMockJournalEntry *entry = gl_mock_journal_previous(journal);
+   const gchar *mystring = gl_mock_journal_entry_get_message(entry);
+   g_assert_cmpstr(mystring, ==, "This is a test");
 }
 
 int


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