[gnome-logs/wip/test: 36/43] Behave and dogtail tests for search and back functionality



commit 2b1b02c256a07879369c8f629f09cb3035befc14
Author: Rashi Aswani <aswanirashi19 gmail com>
Date:   Sun Aug 16 21:15:14 2015 +0530

    Behave and dogtail tests for search and back functionality

 Makefile.am                    |   12 +++------
 configure.ac                   |    2 +
 data/gl-eventtoolbar.ui        |   10 +++++++
 data/gl-eventviewlist.ui       |    5 ++++
 tests/common_steps.py          |    3 +-
 tests/environment.py           |    2 +-
 tests/general.feature          |   17 ++++++++++---
 tests/gl-mock-journal.c        |   18 +++----------
 tests/gnome-logs-behave-test.c |    2 +-
 tests/steps/general.py         |   53 ++++++++++++++++++++++++++++++----------
 10 files changed, 82 insertions(+), 42 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4150d6e..7f8ac50 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -175,10 +175,6 @@ 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 \
@@ -233,10 +229,6 @@ nodist_tests_gnome_logs_behave_test_SOURCES = \
         src/gl-enums.c \
         src/gl-resource.c
 
-enum_data = \
-        src/gl-enums.c \
-        src/gl-enums.h
-
 tests_gnome_logs_behave_test_enum_headers = \
         $(srcdir)/src/gl-categorylist.h \
         $(srcdir)/src/gl-eventtoolbar.h \
@@ -272,6 +264,10 @@ TESTS = \
        $(check_SCRIPTS)
 endif
 
+ BEHAVE_INSTALLED_TESTS_RULE@
+INSTALLED_TESTS=general.feature
+INSTALLED_TESTS_TYPE=session-exclusive
+
 iconthemedir = $(datadir)/icons/hicolor
 
 appicon16dir = $(iconthemedir)/16x16/apps
diff --git a/configure.ac b/configure.ac
index 95e76d1..533e776 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,8 @@ AS_IF([test "x$enable_man" != "xno"],
 
 AM_CONDITIONAL([ENABLE_MAN], [test "x$have_manutils" = "xyes"])
 
+BEHAVE_INSTALLED_TESTS
+
 dnl AppData XML
 APPSTREAM_XML
 
diff --git a/data/gl-eventtoolbar.ui b/data/gl-eventtoolbar.ui
index c42af57..98a44ee 100644
--- a/data/gl-eventtoolbar.ui
+++ b/data/gl-eventtoolbar.ui
@@ -11,6 +11,11 @@
                 <style>
                     <class name="image-button"/>
                 </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="Back">
+                    <property name="accessible-name" translatable="yes">Back</property>
+                  </object>
+                </child>
                 <child>
                     <object class="GtkImage" id="go_back_icon">
                         <property name="icon-name">go-previous-symbolic</property>
@@ -38,6 +43,11 @@
                 <property name="tooltip-text" translatable="yes">Search the displayed logs</property>
                 <property name="valign">center</property>
                 <property name="visible">True</property>
+               <child internal-child="accessible">
+                  <object class="AtkObject" id="Find">
+                    <property name="accessible-name" translatable="yes">Find</property>
+                  </object>
+                </child>
                 <style>
                     <class name="image-button"/>
                 </style>
diff --git a/data/gl-eventviewlist.ui b/data/gl-eventviewlist.ui
index 61dfa98..deef4f4 100644
--- a/data/gl-eventviewlist.ui
+++ b/data/gl-eventviewlist.ui
@@ -2,6 +2,11 @@
     <template class="GlEventViewList" parent="GtkBox">
         <property name="orientation">horizontal</property>
         <property name="visible">True</property>
+        <child internal-child="accessible">
+            <object class="AtkObject" id="Window">
+                <property name="accessible-name" translatable="yes">Window</property>
+            </object>
+        </child>
         <child>
             <object class="GlCategoryList" id="categories">
                 <property name="visible">True</property>
diff --git a/tests/common_steps.py b/tests/common_steps.py
index b449bbd..6d7f372 100644
--- a/tests/common_steps.py
+++ b/tests/common_steps.py
@@ -67,6 +67,7 @@ class App(object):
         """
         if self.a11yAppName is None:
             self.a11yAppName = self.internCommand
+       self.a11yAppName = 'gnome-logs'
 
         # Trap weird bus errors
         for attempt in xrange(0, 30):
@@ -118,7 +119,7 @@ class App(object):
         assert not self.isRunning(), "Application cannot be stopped"
 
 
- step(u'Make sure that gnome-logs-test is running')
+ step(u'Make sure gnome-logs-behave-test is running')
 def ensure_app_running(context):
     context.app = context.app_class.startViaCommand()
 
diff --git a/tests/environment.py b/tests/environment.py
index c8965b4..e7e48ba 100644
--- a/tests/environment.py
+++ b/tests/environment.py
@@ -16,7 +16,7 @@ def before_all(context):
 
     try:
         # Close running logs instances
-        os.system("./gnome-logs-test --force-shutdown > /dev/null")
+        os.system("./gnome-logs-behave-test --force-shutdown > /dev/null")
 
         # Skip dogtail actions to print to stdout
         config.logDebugToStdOut = False
diff --git a/tests/general.feature b/tests/general.feature
index 0794ed4..5fda19c 100644
--- a/tests/general.feature
+++ b/tests/general.feature
@@ -1,9 +1,18 @@
 Feature: General
 
-Background:
-  * Make sure that gnome-logs-test is running
-
 @start_logs
   Scenario: Search
+    * Make sure gnome-logs-behave-test is running
     * Click on Search
-    Then all selection toolbar buttons are sensitive
+    Then search is focused and selection toolbar buttons are sensitive
+
+  Scenario: Search with text
+    * Make sure gnome-logs-behave-test is running
+    * Type search text
+    Then assert test
+
+  Scenario: Go Back
+    * Make sure gnome-logs-behave-test is running
+    * Select the log listing
+    * Press the back button
+    Then return to the main window
diff --git a/tests/gl-mock-journal.c b/tests/gl-mock-journal.c
index 0d321d3..b0870f1 100644
--- a/tests/gl-mock-journal.c
+++ b/tests/gl-mock-journal.c
@@ -48,7 +48,6 @@ G_DEFINE_TYPE (GlMockJournalEntry, gl_mock_journal_entry, G_TYPE_OBJECT)
  * 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
 {
@@ -66,11 +65,6 @@ gl_mock_journal_error_quark (void)
     return g_quark_from_static_string ("gl-mock-journal-error-quark");
 }
 
-static void
-gl_mock_journal_get_boots (GlMockJournal *journal)
-{ 
-}
-
 GArray *
 gl_mock_journal_get_boot_ids (GlMockJournal *journal)
 {
@@ -107,10 +101,10 @@ gl_mock_journal_finalize (GObject *object)
 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
@@ -157,7 +151,7 @@ gl_mock_journal_query_entry (GlMockJournal *self)
 
     entry = g_object_new (GL_TYPE_MOCK_JOURNAL_ENTRY, NULL);
     
-    entry->timestamp = g_strdup("12");
+    entry->timestamp = (guint64)g_strdup("12");
     entry->cursor = g_strdup("start");
     entry->catalog = g_strdup("test");
     entry->message = gl_mock_journal_get_data (self, "MESSAGE", NULL);
@@ -172,7 +166,7 @@ gl_mock_journal_query_entry (GlMockJournal *self)
     }
 
     /* FIXME: priority is an int, not a char*. */
-    entry->priority = gl_mock_journal_get_data (self, "PRIORITY", NULL);
+    entry->priority = (guint64)gl_mock_journal_get_data (self, "PRIORITY", NULL);
 
     if (error != NULL)
     {
@@ -223,7 +217,6 @@ gl_mock_journal_set_matches (GlMockJournal           *journal,
     GlMockJournalPrivate *priv = gl_mock_journal_get_instance_private (journal);
     GPtrArray *mandatory_fields;
     gint i;
-    gboolean has_boot_id = FALSE;
     g_return_if_fail (matches != NULL);
 
     if (priv->mandatory_fields)
@@ -241,9 +234,6 @@ gl_mock_journal_set_matches (GlMockJournal           *journal,
             g_ptr_array_add (mandatory_fields, g_strdup (matches[i]));
             continue;
         }
-
-        if (g_str_has_prefix (matches[i], "_BOOT_ID="))
-          has_boot_id = TRUE;
     }
 
     /* add sentinel */
diff --git a/tests/gnome-logs-behave-test.c b/tests/gnome-logs-behave-test.c
index 2030b73..2f1f172 100644
--- a/tests/gnome-logs-behave-test.c
+++ b/tests/gnome-logs-behave-test.c
@@ -47,7 +47,7 @@ main (int argc, char** argv)
     g_set_prgname (PACKAGE_TARNAME);
     application = gl_application_new ();
     status = g_application_run (G_APPLICATION (application), argc, argv);
-    g_application_quit (G_APPLICATION (application));
+    //g_application_quit (G_APPLICATION (application));
     g_object_unref (application);
     return status;
 }
diff --git a/tests/steps/general.py b/tests/steps/general.py
index 55720bc..b46afb8 100644
--- a/tests/steps/general.py
+++ b/tests/steps/general.py
@@ -5,22 +5,49 @@ from pyatspi import STATE_SENSITIVE
 from time import sleep
 from common_steps import App
 
- step(u'Run gnome-logs-test')
+ step(u'Open gnome-logs-behave-test')
 def run_gnome_logs_test(context):
     system("./gnome-logs-test --force-shutdown 2&> /dev/null")
-    context.execute_steps(u'* Start a new Logs instance')
+    context.execute_steps(u'* Start a new gnome-logs-behave-test instance')
 
 @step(u'Click on search')
 def click_on_search(context):
-    context.app.child('Search').parent.click()
+    context.app.child('Find').click()
     
- then(u'all selection toolbar buttons are sensitive')
-def all_selection_toolbar_buttons_sensitive(context):
-    sleep(0.5)
-    assert context.app.child(translate('Important')).sensitive
-    assert context.app.child(translate('All')).sensitive
-    assert context.app.child(translate('Applications')).sensitive
-    assert context.app.child(translate('System')).sensitive
-    assert context.app.child(translate('Security')).sensitive
-    assert context.app.child(translate('Hardware')).sensitive
-    sleep(0.5) 
+ then(u'search is focused and selection toolbar buttons are sensitive')
+def search_focused_selection_toolbar_buttons_sensitive(context):
+    assert context.app.child('Search').focused
+    assert context.app.child('Important').sensitive
+    assert context.app.child('All').sensitive
+    assert context.app.child('Applications').sensitive
+    assert context.app.child('System').sensitive
+    assert context.app.child('Security').sensitive
+    assert context.app.child('Hardware').sensitive
+    context.app.child('Search').typeText("test")
+    assert context.app.child('This is a test').sensitive
+
+ step(u'Type search text')
+def type_search_text(context):
+    context.app.child('Search').typeText("test")
+
+ step(u'assert test')
+def assert_test(context):
+    assert context.app.child('Search').focused
+    assert context.app.child('This is a test').sensitive
+
+ step(u'Go Back')
+def go_back(context):
+    context.app.child('This is a test').click()
+
+ step(u'Select the log listing')
+def select_log_listing(context):
+    context.app.child('This is a test').click()
+
+ step(u'Press the back button')
+def press_back_button(context):
+    context.app.child('Back').click()
+
+ step('return to the main window')
+def return_main_window(context):
+    context.app.child('Window').sensitive
+


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