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.
This commit is contained in:
icarter09 2020-01-18 14:52:07 -05:00 committed by Michael Webster
parent d5a48be670
commit 5a16a65643
8 changed files with 197 additions and 2 deletions

View File

@ -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))

1
test/LoremIpsum.txt Normal file
View File

@ -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.

19
test/meson.build Normal file
View File

@ -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

26
test/testCommon.py Executable file
View File

@ -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)

38
test/testFileMenu.py Executable file
View File

@ -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()

34
test/testHelpMenu.py Executable file
View File

@ -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('<Control>w')
# Keyboard Shortcuts
click('Help', roleName='menu')
click('Keyboard Shortcuts', roleName='menu item')
keyCombo('<Alt>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()

67
test/testToolbar.py Normal file
View File

@ -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('<Ctrl>a')
click('Cut', roleName='push button')
# PASTE
click('Paste', roleName='push button')
# COPY
keyCombo('<Ctrl>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()

View File

@ -158,7 +158,7 @@ libxed_dep = declare_dependency(
include_directories: [include_dirs, include_directories('.')]
)
executable(
xed = executable(
'xed',
xed_sources,
dependencies: libxed_dep,