Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: adjust for Thunderbird 128 #102

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
include:
- file: /r4.1/gitlab-base.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.1/gitlab-dom0.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.1/gitlab-vm.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.2/gitlab-base.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.2/gitlab-host.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.2/gitlab-vm.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.3/gitlab-base.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.3/gitlab-host.yml
project: QubesOS/qubes-continuous-integration
- file: /r4.3/gitlab-vm.yml
project: QubesOS/qubes-continuous-integration
93 changes: 70 additions & 23 deletions tests/test_thunderbird.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def enter_imap_passwd(tb):
.doActionNamed('check')
pass_prompt.findChild(orPredicate(
GenericPredicate(name='OK', roleName='push button'), # tb < 91
GenericPredicate(name='Sign in', roleName='push button')) # tb >= 91
GenericPredicate(name='Sign in', roleName='push button'), # tb >= 91, tb < 128
GenericPredicate(name='OK', roleName='button')) # tb >= 128
).doActionNamed('press')

def accept_qubes_attachments(tb):
Expand Down Expand Up @@ -269,23 +270,36 @@ def configure_openpgp_account(tb):

def get_messages(tb):
try:
# TB >= 115
try:
# TB >= 128
tb.app.child('Get Messages', roleName='button').doActionNamed('press')
except tree.SearchError:
# TB < 128
tb.app.button('Get Messages').doActionNamed('press')
tb.app.child(name='Inbox.*', roleName='tree item').doActionNamed(
'activate')
except tree.SearchError:
# TB < 115
tb.app.child(name='user@localhost',
roleName='table row').doActionNamed('activate')
tb.app.button('Get Messages').doActionNamed('press')
tb.app.menuItem('Get All New Messages').doActionNamed('click')
tb.app.child(name='Inbox.*', roleName='table row').doActionNamed(
'activate')
except tree.SearchError:
# TB >= 115
tb.app.button('Get Messages').doActionNamed('press')
tb.app.child(name='Inbox.*', roleName='tree item').doActionNamed(
'activate')


def attach(tb, compose_window, path):
compose_window.button('Attach').button('Attach').doActionNamed('press')
compose_window.button('Attach').menuItem('File.*').doActionNamed('click')
try:
# TB >= 128
compose_window.child('Attach', roleName='button').\
doActionNamed('press')
compose_window.child('Attach', roleName='button').\
menuItem('File.*').doActionNamed('click')
except tree.SearchError:
# TB < 128
compose_window.button('Attach').button('Attach').doActionNamed('press')
compose_window.button('Attach').menuItem('File.*').doActionNamed('click')
# for some reason on some thunderbird versions do not expose 'Attach File'
# dialog through accessibility API, use xdotool instead
subprocess.check_call(
Expand Down Expand Up @@ -314,9 +328,13 @@ def attach(tb, compose_window, path):
def send_email(tb, sign=False, encrypt=False, inline=False, attachment=None):
config.searchCutoffCount = 20
try:
write = tb.app.button('New Message')
# TB >= 128
write = tb.app.child(name='New Message', roleName='button')
except tree.SearchError:
write = tb.app.button('Write')
try:
write = tb.app.button('New Message')
except tree.SearchError:
write = tb.app.button('Write')
config.searchCutoffCount = defaultCutoffCount
write.doActionNamed('press')
compose = tb.app.child(name='Write: .*', roleName='frame')
Expand All @@ -338,8 +356,14 @@ def send_email(tb, sign=False, encrypt=False, inline=False, attachment=None):
except tree.SearchError:
compose.child(
roleName='document frame').text = 'This is test message'
security = compose.findChild(
GenericPredicate(name='Security|OpenPGP', roleName='push button'))
try:
# TB >= 128
security = compose.findChild(
GenericPredicate(name='Security|OpenPGP', roleName='button'))
except tree.SearchError:
# TB < 128
security = compose.findChild(
GenericPredicate(name='Security|OpenPGP', roleName='push button'))
security.doActionNamed('press')
sign_button = security.childNamed('Digitally Sign.*')
encrypt_button = security.childNamed('Require Encryption|Encrypt')
Expand All @@ -349,7 +373,12 @@ def send_email(tb, sign=False, encrypt=False, inline=False, attachment=None):
encrypt_button.doActionNamed('click')
if attachment:
attach(tb, compose, attachment)
compose.button('Send').doActionNamed('press')
try:
# TB >= 128
compose.child('Send', roleName='button').doActionNamed('press')
except tree.SearchError:
# TB < 128
compose.button('Send').doActionNamed('press')
config.searchCutoffCount = 5
try:
if encrypt:
Expand Down Expand Up @@ -389,21 +418,33 @@ def receive_message(tb, signed=False, encrypted=False, attachment=None):
if encrypted:
config.searchCutoffCount = 5
try:
# TB >= 115
# TB >= 128
tb.app.child(name='user[^,]*, .*, \.\.\..*',
roleName='tree item').doActionNamed('activate')
roleName='table row').doActionNamed('clickAncestor')
except tree.SearchError:
# TB < 115
tb.app.child(name='Encrypted Message .*|.*\.\.\. .*',
roleName='table row').doActionNamed('activate')
try:
# TB >= 115
tb.app.child(name='user[^,]*, .*, \.\.\..*',
roleName='tree item').doActionNamed('activate')
except tree.SearchError:
# TB < 115
tb.app.child(name='Encrypted Message .*|.*\.\.\. .*',
roleName='table row').doActionNamed('activate')
finally:
config.searchCutoffCount = defaultCutoffCount
try:
# TB >= 128
tb.app.child(name='.*{}.*'.format(subject),
roleName='tree item').doActionNamed('activate')
roleName='table row').doActionNamed('clickAncestor')
except tree.SearchError:
tb.app.child(name='.*{}.*'.format(subject),
roleName='table row').doActionNamed('activate')
try:
# TB >= 115
tb.app.child(name='.*{}.*'.format(subject),
roleName='tree item').doActionNamed('activate')
except tree.SearchError:
# TB < 115
tb.app.child(name='.*{}.*'.format(subject),
roleName='table row').doActionNamed('activate')
# wait a little to TB decrypt/check the message
time.sleep(2)
# dogtail always add '$' at the end of regexp; and also "Escape all
Expand Down Expand Up @@ -461,8 +502,14 @@ def receive_message(tb, signed=False, encrypted=False, attachment=None):
attachment_size = attachment_label.parent.children[
attachment_label.indexInParent + 1 + offset]
assert attachment_size.text[0] != '0'
attachment_save = attachment_label.parent.children[
attachment_label.indexInParent + 2 + offset].button('Save.*')
attachment_save_parent = attachment_label.parent.children[
attachment_label.indexInParent + 2 + offset]
try:
# TB >= 128
attachment_save = attachment_save_parent.child('Save.*', roleName='button')
except tree.SearchError:
# TB < 128
attachment_save = attachment_save_parent.button('Save.*')
try:
# try child button first
attachment_save.children[1].doActionNamed('press')
Expand Down