[gnome-sound-recorder/testing: 48/49] Add test scenarios
- From: Margaret Ford <megford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder/testing: 48/49] Add test scenarios
- Date: Wed, 29 Nov 2017 02:50:53 +0000 (UTC)
commit 63c3bab6dde0386c04b8184656882f9d3d87a58e
Author: Meg Ford <megford gnome org>
Date: Tue Nov 28 20:17:19 2017 -0600
Add test scenarios
tests/app_test.feature | 50 +++++++---
tests/environment.py | 12 ++-
tests/steps/app_test.py | 249 +++++++++++++++++++++++++++++++++++++++++++----
tests/testutil.py | 4 +-
4 files changed, 278 insertions(+), 37 deletions(-)
---
diff --git a/tests/app_test.feature b/tests/app_test.feature
index 0c70d5a..141ed40 100644
--- a/tests/app_test.feature
+++ b/tests/app_test.feature
@@ -3,29 +3,55 @@ Feature: Smoke tests
Background:
* Make sure gnome-sound-recorder is running
- @about
+
+ @mainwindow_refresh_del_file
+ Scenario: Create Recording
+ * Create Recording
+ Then Delete the file
+ Then MainWindow is shown
+ Then Recordings directory is present
+
+ @no_recordings
+ Scenario: No recordings in the Recordings folder
+ * Delete the Recordings folder
+ Then MainWindow is shown
+ Then Recordings directory is present
+
+
+ @mainwindow_refresh_del_dir
+ Scenario: Create Recording
+ * Create Recording
+ Then Delete the Recordings folder
+ Then MainWindow is shown
+ Then Recordings directory is present
+
+
+
+ @about
Scenario: About dialog
* Open About dialog
Then About UI is displayed
Then Press Credits
+ @quit_via_app_menu
+ Scenario: Quit via app menu
+ * Select "Quit" from the app menu
+ Then gnome-sound-recorder is not running
+
@preferences
Scenario: Preferences dialog
* Open Preferences dialog
Then Preferences UI is displayed
- Then the h
- @quit_via_app_menu
- Scenario: Quit via app menu
- * Select "Quit" from the app menu
- Then gnome-sound-recorder is not running
+ @codecs
+ Scenario: Record using all codecs and channels options
+ * Changing codecs and channels works @codecs
+ Scenario: Record using all codecs and channels options
+ * Changing codecs and channels works
+
+
@quit_via_shortcut
Scenario: Quit via shortcut
* Press the quit shortcut
- Then gnome-sound-recorder is not running
-
-# @no_recordings
-# Scenario: No recordings in the Recordings folder
-# Then the main window is shown
-# Then the Recordings folder is present
\ No newline at end of file
+ Then gnome-sound-recorder is not running
\ No newline at end of file
diff --git a/tests/environment.py b/tests/environment.py
index b53a886..7b3a813 100644
--- a/tests/environment.py
+++ b/tests/environment.py
@@ -1,12 +1,14 @@
+from os import system, makedirs
+from shutil import copyfile
from time import sleep
+
+from dogtail.config import config
from dogtail.utils import isA11yEnabled, enableA11y
-if not isA11yEnabled():
- enableA11y(True)
from common_steps import App
-from dogtail.config import config
-from os import system, makedirs
-from shutil import copyfile
+
+if not isA11yEnabled():
+ enableA11y(True)
def before_all(context):
diff --git a/tests/steps/app_test.py b/tests/steps/app_test.py
index 2a50ad9..45a38c9 100644
--- a/tests/steps/app_test.py
+++ b/tests/steps/app_test.py
@@ -1,9 +1,14 @@
#! /usr/bin/python
-import pyatspi
+
+from datetime import datetime, timedelta
import os
import sys
+import time
+import shutil
from gi.repository import Gio, GLib
+import pyatspi
+
from subprocess import Popen, PIPE
from behave import step, then
@@ -11,18 +16,115 @@ from dogtail import i18n
from dogtail import tree
from dogtail import utils
from dogtail.procedural import *
+
from common_steps import *
+
def display_err(err_str):
return '{} is not displayed'.format(err_str)
-def is_displayed(ui, role, ui_string):
+
+def is_displayed(ui, ui_string, role=None):
if role == 'radio button':
return ui(translate(ui_string), role).checked
+ elif not role:
+ return ui(translate(ui_string)).showing
return ui(translate(ui_string), role).showing
+def record_with_codec_works(context, ui, codec_name):
+ ui.child('Record').click()
+ time.sleep(10)
+ ui.child('Done').click()
+
+ done_time = datetime.now().strftime('%H:%M:%S')
+ mod_time = done_time.split(':')
+ print(len(mod_time[0]))
+ print(mod_time[0])
+
+ if mod_time[0] > 12:
+ hour = int(mod_time[0]) % 12
+
+ if len(str(hour)) < 2:
+ str_time = '0'
+ else:
+ str_time = ''
+ str_time += str(hour) + ':' + mod_time[1]
+ else:
+ if len(mod_time[0]) < 2:
+ str_time = '0'
+ str_time = mod_time[0] + ':' + mod_time[1]
+
+ pressKey('Down')
+ pressKey('Right')
+ pressKey('Right')
+ pressKey('Enter')
+
+ dialog_name = 'Info'
+ info_ui = context.app.dialog(translate(dialog_name)).child
+ assert is_displayed(info_ui, codec_name), display_err('Correct codec')
+ # Inexact match
+ print(list(iter(context.app.dialog(translate(
+ dialog_name)).children))[1][0].children[1].name)
+ print(str_time)
+ assert (str_time in list(iter(context.app.dialog(translate(
+ dialog_name)).children))[1][0].children[1].name), \
+ display_err('Correct date modified')
+
+ pressKey('Esc')
+
+
+@step(u'Delete the Recordings folder')
+def delete_recordings_folder(context):
+ dir_path = GLib.build_filenamev([GLib.get_home_dir(), "Recordings"])
+ print(dir_path)
+ shutil.rmtree(dir_path)
+ # # Wait for the app to refresh before moving on to the next test
+ time.sleep(30)
+
+@step(u'Delete the file')
+def delete_file(context):
+ file_path = GLib.build_filenamev([GLib.get_home_dir(), "Recordings", "Clip 1"])
+ shutil.rmtree(file_path)
+ # # Wait for the app to refresh before moving on to the next test
+ time.sleep(30)
+
+
+@then(u'MainWindow is shown')
+def mainwindow_shown(context):
+ ui = context.app
+ emptyPageDirections = 'Use the Record button to make sound recordings'
+ emptyPageTitle = 'Add Recordings'
+ assert (emptyPageDirections in list(
+ list(
+ list(
+ list(
+ list(
+ list(
+ iter(
+ ui.children))[0][1].children)[0].children
+ )[0].children)[0].children)[0].children)[0].name), \
+ display_err('emptyPageDirections')
+ assert (emptyPageTitle in list(
+ list(
+ list(
+ list(
+ list(
+ list(
+ iter(
+ ui.children))[0][1].children)[0].children
+ )[0].children)[0].children)[0].children)[1].name), \
+ display_err('emptyPageTitle')
+
+
+@then(u'Recordings directory is present')
+def record_dir_present(context):
+ ui = context.app
+ dir_path = os.path.join(GLib.get_home_dir(), 'Recordings')
+ assert os.path.isdir(dir_path), 'Recordings directory is not present'
+
+
@step(u'Open About dialog')
def open_about_dialog(context):
context.execute_steps(u'* Select "About" in GApplication menu')
@@ -39,15 +141,16 @@ def open_and_close_about_dialog(context):
@then(u'About UI is displayed')
def about_ui_is_displayed(context):
ui = context.about_dialog.child
- assert is_displayed(ui, 'label', 'Sound Recorder'), display_err('App name')
- assert is_displayed(ui, 'label', 'Website'), display_err('Website link')
+ assert is_displayed(ui, 'Sound Recorder', 'label'), display_err('App name')
+ assert is_displayed(ui, 'Website', 'label'), display_err('Website link')
assert is_displayed(ui,
- 'label',
'This program comes with absolutely no warranty.\n'
'See the GNU General Public License,'
- ' version 2 or later for details.'), display_err('License link')
- assert is_displayed(ui, 'radio button', 'About'), display_err('About tab')
- assert not is_displayed(ui, 'radio button', 'Credits'), display_err('Credits tab')
+ ' version 2 or later for details.',
+ 'label'), display_err('License link')
+ assert is_displayed(ui, 'About', 'radio button'), display_err('About tab')
+ assert not is_displayed(ui, 'Credits', 'radio button'), \
+ display_err('Credits tab')
@then(u'Press Credits')
@@ -56,7 +159,8 @@ def press_credits(context):
pressKey('Right')
pressKey('Enter')
- assert is_displayed(ui, 'radio button', 'Credits'), display_err('Credits tab')
+ assert is_displayed(ui, 'Credits', 'radio button'), \
+ display_err('Credits tab')
@step(u'Open Preferences dialog')
@@ -68,19 +172,126 @@ def open_pref_dialog(context):
@then(u'Preferences UI is displayed')
def pref_ui_is_displayed(context):
- ui = context.pref_dialog.child
+ # for some reason the global contect.pref_dialog doesn't work here
+ # so assign again fo this test
+ dialog_name = 'Preferences'
+ ui = context.app.dialog(translate(dialog_name)).child
+ # for i in iter(context.app.dialog(translate(dialog_name)).children):
+ # for j in i:
+ # for k in j.children:
+ # print(k.role)
+ # print(k.name)
- assert is_displayed(ui, 'label', 'Ogg Vorbis'), display_err('Correct codec')
- assert is_displayed(ui, 'label', 'Stereo'), display_err('Stereo label')
- assert is_displayed(ui, '0.7'), display_err('Volume level')
- assert is_displayed(ui, '0.7'), display_err('Mic volume level')
+ assert is_displayed(ui, 'Ogg Vorbis'), display_err('Correct codec')
+ assert is_displayed(ui, 'Stereo'), display_err('Stereo label')
+ assert is_displayed(ui, 'Volume', 'label'), display_err('Volume level')
+ assert is_displayed(ui, 'Microphone', 'label'), \
+ display_err('Mic volume level')
-@then(u'Changing codecs and channels works')
-def pref_ui_is_displayed(context):
- ui = context.pref_dialog.child
+@step(u'Create Recording')
+def change_codecs_channels(context):
+ application = context.app
+ record_with_codec_works(context, application, 'Ogg Vorbis')
+
+@step(u'Changing codecs and channels works')
+def change_codecs_channels(context):
+ application = context.app
+ record_with_codec_works(context, application, 'Ogg Vorbis')
+
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ dialog_name = 'Preferences'
+ ui = context.app.dialog(translate(dialog_name)).child
+ ui(translate('Stereo')).click(button=1)
+ pressKey('Down')
+ pressKey('Enter')
+ assert is_displayed(ui, 'Mono'), display_err('Stereo label')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'Ogg Vorbis')
+
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
pressKey('Down')
+ pressKey('Enter')
+ assert is_displayed(ui, 'Opus'), display_err('Correct codec')
+ assert is_displayed(ui, 'Mono'), display_err('Stereo label')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'Opus')
+
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
+ ui(translate('Mono')).click(button=1)
+ pressKey('Down')
+ pressKey('Enter')
+ assert is_displayed(ui, 'Stereo'), display_err('Stereo label')
+ assert is_displayed(ui, 'Opus'), display_err('Correct codec')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'Opus')
+
+ # Flac
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
+ pressKey('Down')
+ assert is_displayed(ui, 'FLAC'), display_err('Correct codec')
+ assert is_displayed(ui, 'Stereo'), display_err('Stereo label')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'FLAC')
+
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
+ ui(translate('Stereo')).click(button=1)
+ pressKey('Down')
+ pressKey('Enter')
+ assert is_displayed(ui, 'Mono'), display_err('Stereo label')
+ assert is_displayed(ui, 'FLAC'), display_err('Correct codec')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'FLAC')
+
+ # MP3
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
+ pressKey('Down')
+
+ assert is_displayed(ui, 'MP3'), display_err('Correct codec')
+ assert is_displayed(ui, 'Mono'), display_err('Stereo label')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'MP3')
+
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
+ ui(translate('Mono')).click(button=1)
+ pressKey('Down')
+ pressKey('Enter')
+ assert is_displayed(ui, 'Stereo'), display_err('Stereo label')
+ assert is_displayed(ui, 'MP3'), display_err('Correct codec')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'MP3')
+
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
+ pressKey('Down')
+ assert is_displayed(ui, 'MOV'), display_err('Correct codec')
+ assert is_displayed(ui, 'Stereo'), display_err('Stereo label')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'MOV')
+
+ context.execute_steps(u'* Select "Preferences" in GApplication menu')
+ ui = context.app.dialog(translate(dialog_name)).child
+ ui(translate('Stereo')).click(button=1)
+ pressKey('Down')
+ pressKey('Enter')
+
+ assert is_displayed(ui, 'Stereo'), display_err('Stereo label')
+ assert is_displayed(ui, 'MOV'), display_err('Correct codec')
+ pressKey('Esc')
+ record_with_codec_works(context, application, 'MOV')
+ pressKey('Up')
@step(u'Select "Quit" from the app menu')
-def quit_is(context):
- context.execute_steps(u'* Select "Quit" in GApplication menu')
\ No newline at end of file
+def quit_menu(context):
+ context.execute_steps(u'* Select "Quit" in GApplication menu')
+
+
+@step(u'Press the quit shortcut')
+def quit_sc(context):
+ keyCombo('<Control><q>')
diff --git a/tests/testutil.py b/tests/testutil.py
index 08f3c50..9723c08 100644
--- a/tests/testutil.py
+++ b/tests/testutil.py
@@ -1,9 +1,10 @@
# ! /usr/bin/python
import os
import sys
+
from subprocess import Popen, PIPE
+
from gi.repository import GLib, Gio
-from dogtail.utils import *
from behave import step
from dogtail import i18n
@@ -11,6 +12,7 @@ from dogtail.predicate import *
from dogtail.procedural import *
from dogtail.rawinput import keyCombo, absoluteMotion, pressKey
from dogtail.tree import *
+from dogtail.utils import *
from unittest import TestCase
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]