Skip to content

Commit 6f9b66d

Browse files
committed
Qt test for UDP setting
1 parent 79efacf commit 6f9b66d

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/bitmessageqt/tests/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
from addressbook import TestAddressbook
44
from main import TestMain, TestUISignaler
5+
from settings import TestSettings
56
from support import TestSupport
67

7-
__all__ = ["TestAddressbook", "TestMain", "TestSupport", "TestUISignaler"]
8+
__all__ = [
9+
"TestAddressbook", "TestMain", "TestSettings", "TestSupport",
10+
"TestUISignaler"
11+
]

src/bitmessageqt/tests/settings.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import threading
2+
import time
3+
4+
from main import TestBase
5+
from bmconfigparser import BMConfigParser
6+
from bitmessageqt import settings
7+
8+
9+
class TestSettings(TestBase):
10+
"""A test case for the "Settings" dialog"""
11+
def setUp(self):
12+
super(TestSettings, self).setUp()
13+
self.dialog = settings.SettingsDialog(self.window)
14+
15+
def test_udp(self):
16+
"""Test the effect of checkBoxUDP"""
17+
udp_setting = BMConfigParser().safeGetBoolean(
18+
'bitmessagesettings', 'udp')
19+
self.assertEqual(udp_setting, self.dialog.checkBoxUDP.isChecked())
20+
self.dialog.checkBoxUDP.setChecked(not udp_setting)
21+
self.dialog.accept()
22+
self.assertEqual(
23+
not udp_setting,
24+
BMConfigParser().safeGetBoolean('bitmessagesettings', 'udp'))
25+
time.sleep(5)
26+
for thread in threading.enumerate():
27+
if thread.name == 'Announcer': # find Announcer thread
28+
if udp_setting:
29+
self.fail(
30+
'Announcer thread is running while udp set to False')
31+
break
32+
else:
33+
if not udp_setting:
34+
self.fail('No Announcer thread found while udp set to True')

0 commit comments

Comments
 (0)