From 5a16a65643b227c6a1af06a51b2967fa1077ce37 Mon Sep 17 00:00:00 2001 From: icarter09 Date: Sat, 18 Jan 2020 14:52:07 -0500 Subject: [PATCH] Created initial test dir. Created File menu test. Added test for Help menu. Created test case for Toolbar. Updated meson build for test. Removed unnecessary file. --- meson.build | 12 +++++++- test/LoremIpsum.txt | 1 + test/meson.build | 19 +++++++++++++ test/testCommon.py | 26 +++++++++++++++++ test/testFileMenu.py | 38 +++++++++++++++++++++++++ test/testHelpMenu.py | 34 ++++++++++++++++++++++ test/testToolbar.py | 67 ++++++++++++++++++++++++++++++++++++++++++++ xed/meson.build | 2 +- 8 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 test/LoremIpsum.txt create mode 100644 test/meson.build create mode 100755 test/testCommon.py create mode 100755 test/testFileMenu.py create mode 100755 test/testHelpMenu.py create mode 100644 test/testToolbar.py diff --git a/meson.build b/meson.build index b06f0d0..eabddfc 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,8 @@ version = meson.project_version() xed_conf = configuration_data() xed_conf.set_quoted('VERSION', version) -xed_conf.set_quoted('GETTEXT_PACKAGE', 'xed') +#xed_conf.set_quoted('GETTEXT_PACKAGE', 'xed') +xed_conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) # directories prefix = get_option('prefix') @@ -94,6 +95,15 @@ if get_option('docs') subdir('docs/reference') endif +# The tests use an option that doesn't exist in meson before 0.46. +# Since they aren't strictly necessary, we'll just skip them for earlier versions +# rather than making 0.46 a hard requirement. This condition can be removed once we +# no longer need to worry about building on 0.45 or earlier +meson_version_parts = meson.version().split('.') +if meson_version_parts[0].to_int() > 0 or meson_version_parts[1].to_int() >= 46 + subdir('test') +endif + message('prefix = @0@'.format(prefix)) message('bindir = @0@'.format(bindir)) message('datadir = @0@'.format(datadir)) diff --git a/test/LoremIpsum.txt b/test/LoremIpsum.txt new file mode 100644 index 0000000..1b37687 --- /dev/null +++ b/test/LoremIpsum.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..f477f91 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,19 @@ +test_cases = [ + 'testFileMenu.py', + 'testHelpMenu.py', + 'testToolbar.py' +] + +foreach case : test_cases + test_script = find_program(case) + + test( + case, + test_script, + args: [xed.full_path()], + is_parallel: false, + depends: xed, + workdir: join_paths(prefix, bindir), + timeout: 120, + ) +endforeach diff --git a/test/testCommon.py b/test/testCommon.py new file mode 100755 index 0000000..049b5b3 --- /dev/null +++ b/test/testCommon.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 + +import os +import sys +import signal + +os.environ['LANG'] = 'C' + +from dogtail.config import config +config.logDebugToStdOut = True +config.logDebugToFile = False + +import dogtail.procedural as dt + +def run_app(file=None): + global pid + + if file is not None: + arguments = os.path.join(os.path.dirname(__file__), file) + else: + arguments = '' + pid = dt.run(sys.argv[1], arguments=arguments, appName='xed') + +def bail(): + os.kill(pid, signal.SIGTERM) + sys.exit(1) diff --git a/test/testFileMenu.py b/test/testFileMenu.py new file mode 100755 index 0000000..2af328d --- /dev/null +++ b/test/testFileMenu.py @@ -0,0 +1,38 @@ +#!/usr/bin/python3 + +# Test that the File menu and menu items work correctly. + +from testCommon import run_app, bail + +from dogtail.procedural import * + +try: + run_app(file='LoremIpsum.txt') + + # Save a Copy + click('File', roleName='menu') + click('Save As...', roleName='menu item') + click('Cancel', roleName='push button') + + # Print Preview + focus.application('xed') + click('File', roleName='menu') + click('Print Preview', roleName='menu item') + click('Close preview', roleName='push button') + + # Print + focus.application('xed') + click('File', roleName='menu') + click('Print...', roleName='menu item') + focus.dialog('Print') + click('Page Setup', roleName='page tab') + click('Text Editor', roleName='page tab') + click('Cancel', roleName='push button') + + # Quit application + focus.application('xed') + click('File', roleName='menu') + click('Quit', roleName='menu item') + +except: + bail() diff --git a/test/testHelpMenu.py b/test/testHelpMenu.py new file mode 100755 index 0000000..34e771c --- /dev/null +++ b/test/testHelpMenu.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 + +# This test opens the Help menu and runs through the menu items. + +from testCommon import run_app, bail + +from dogtail.procedural import * + +try: + run_app() + + # Contents + click('Help', roleName='menu') + click('Contents', roleName='menu item') + focus.dialog('Text Editor') + keyCombo('w') + + # Keyboard Shortcuts + click('Help', roleName='menu') + click('Keyboard Shortcuts', roleName='menu item') + keyCombo('F4') + + # About + click('Help', roleName='menu') + click('About', roleName='menu item') + focus.dialog('About xed') + click('Close', roleName='push button') + + # Quit application + click('File', roleName='menu') + click('Quit', roleName='menu item') + +except: + bail() diff --git a/test/testToolbar.py b/test/testToolbar.py new file mode 100644 index 0000000..99b2438 --- /dev/null +++ b/test/testToolbar.py @@ -0,0 +1,67 @@ +#!/usr/bin/python3 + +# Test that the Toolbar works correctly. + +from testCommon import run_app, bail + +from dogtail.procedural import * + +try: + run_app(file='LoremIpsum.txt') + + # NEW + click('New', roleName='push button') + focus.widget('LoremIpsum.txt', roleName='page tab') + focus.widget.node.select() + + # OPEN + click('Open', roleName='push button') + click('Cancel', roleName='push button') + + + focus.application('xed') + click('Edit', roleName='menu') + click('Select All', roleName='menu item') + focus.application('xed') + type('testing') + + # UNDO + click('Undo', roleName='push button') + # REDO + click('Redo', roleName='push button') + + # THE ISSUE OF NEEDING TO PRESS UNDO TWICE AS BEEN DOCUMENTED AS A + # FEATURE REQUEST (#344) + # ONCE THAT FR HAS BEEN IMPLEMENTED, ONE OF THESE LINES CAN BE REMOVED + click('Undo', roleName='push button') + click('Undo', roleName='push button') + + # CUT + keyCombo('a') + click('Cut', roleName='push button') + + # PASTE + click('Paste', roleName='push button') + + # COPY + keyCombo('a') + click('Copy', roleName='push button') + click('New', roleName='push button') + click('Paste', roleName='push button') + + # SEARCH + click('Find', roleName='push button') + type('search test') + + # REPLACE + click('Find and Replace', roleName='push button') + type('replace test') + + # QUIT APPLICATION + focus.application('xed') + click('File', roleName='menu') + click('Quit', roleName='menu item') + click('Close without Saving', roleName='push button') + +except: + bail() diff --git a/xed/meson.build b/xed/meson.build index 848b005..9fc0f1b 100644 --- a/xed/meson.build +++ b/xed/meson.build @@ -158,7 +158,7 @@ libxed_dep = declare_dependency( include_directories: [include_dirs, include_directories('.')] ) -executable( +xed = executable( 'xed', xed_sources, dependencies: libxed_dep,