code fixes
This commit is contained in:
parent
48c9cd73d0
commit
288fb35c47
|
@ -13,50 +13,60 @@ class BitmessageTest_AddressGeneration(BitmessageTestCase):
|
|||
"""Testing Environment"""
|
||||
|
||||
def test_generateaddress(self):
|
||||
"""Method clicks on new label pushbutton and create new address with random label"""
|
||||
"""Method clicks on pushbutton and create new address with random label"""
|
||||
print("=====================Test - Generating Address=====================")
|
||||
try:
|
||||
QTest.qWait(500)
|
||||
bm_addresses = BMConfigParser().addresses()
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
QTest.qWait(500)
|
||||
self.myapp.ui.pushButtonNewAddress.setStyleSheet("QPushButton {background-color: #FF5733; color: white;}")
|
||||
|
||||
self.myapp.ui.pushButtonNewAddress.setStyleSheet(
|
||||
"QPushButton {background-color: #FF5733; color: white;}")
|
||||
QTest.qWait(50)
|
||||
self.myapp.ui.pushButtonNewAddress.setStyleSheet("")
|
||||
label_gen_obj = address_dialogs.NewAddressDialog()
|
||||
QTest.qWait(750)
|
||||
|
||||
random_label = ""
|
||||
for _ in range(15):
|
||||
random_label += choice(ascii_lowercase)
|
||||
label_gen_obj.newaddresslabel.setText(random_label)
|
||||
QTest.qWait(4)
|
||||
|
||||
QTest.qWait(500)
|
||||
label_gen_obj.accept()
|
||||
QTest.qWait(750)
|
||||
new_bm_addresses = BMConfigParser().addresses()
|
||||
self.assertEqual(len(new_bm_addresses), len(bm_addresses) + 1)
|
||||
self.assertEqual(str(BMConfigParser().get(new_bm_addresses[-1], "label")), random_label)
|
||||
self.assertEqual(
|
||||
str(BMConfigParser().get(new_bm_addresses[-1], "label")), random_label)
|
||||
print("Test Pass:--> Address Generated Successfully")
|
||||
return 1 # if every thing is ok
|
||||
except:
|
||||
print("Test Fail:--> Address Generatation Failed or Taking too much time to generate address")
|
||||
print(
|
||||
"Test Fail:--> Address Generatation Failed or Taking too much time to generate address")
|
||||
return 0 # if test fail
|
||||
|
||||
def test_generateaddresswithpassphrase(self):
|
||||
"""Clicks on the create new label with passphrase pushbutton and generates 8 address"""
|
||||
print("=====================Test - Generating Address with passphrase=====================")
|
||||
print(
|
||||
"=====================Test - Generating Address with passphrase=====================")
|
||||
try:
|
||||
QTest.qWait(500)
|
||||
bm_addresses = BMConfigParser().addresses()
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
QTest.qWait(500)
|
||||
self.myapp.ui.pushButtonNewAddress.setStyleSheet("QPushButton {background-color: #FF5733; color: white;}")
|
||||
|
||||
self.myapp.ui.pushButtonNewAddress.setStyleSheet(
|
||||
"QPushButton {background-color: #FF5733; color: white;}")
|
||||
QTest.qWait(50)
|
||||
self.myapp.ui.pushButtonNewAddress.setStyleSheet("")
|
||||
label_gen_obj = address_dialogs.NewAddressDialog()
|
||||
QTest.qWait(750)
|
||||
label_gen_obj.radioButtonDeterministicAddress.click()
|
||||
QTest.qWait(250)
|
||||
|
||||
random_password1 = ""
|
||||
for _ in range(15):
|
||||
random_password1 += choice(ascii_lowercase)
|
||||
|
@ -68,10 +78,12 @@ class BitmessageTest_AddressGeneration(BitmessageTestCase):
|
|||
random_password2 += i
|
||||
label_gen_obj.lineEditPassphraseAgain.setText(random_password2)
|
||||
QTest.qWait(2)
|
||||
|
||||
QTest.qWait(500)
|
||||
label_gen_obj.accept()
|
||||
QTest.qWait(750)
|
||||
self.assertEqual(random_password1, random_password2)
|
||||
|
||||
print(" Creating 8 Addresses. Please Wait! ......")
|
||||
QTest.qWait(3000)
|
||||
print(" Generating ......... ")
|
||||
|
@ -81,6 +93,6 @@ class BitmessageTest_AddressGeneration(BitmessageTestCase):
|
|||
return 1
|
||||
except:
|
||||
print(
|
||||
"Test Fail:--> Address Generatation Failed"
|
||||
" with passphrase or Taking too much time to generate address")
|
||||
"Test Fail:--> Address Generatation Failed with passphrase"
|
||||
" or Taking too much time to generate address")
|
||||
return 0
|
||||
|
|
|
@ -31,6 +31,7 @@ class BitmessageTest_AddSubscription(BitmessageTestCase):
|
|||
dialog = dialogs.NewSubscriptionDialog(self.myapp)
|
||||
dialog.show()
|
||||
QTest.qWait(750)
|
||||
|
||||
random_label = ""
|
||||
for _ in range(30):
|
||||
random_label += choice(ascii_lowercase)
|
||||
|
@ -45,6 +46,7 @@ class BitmessageTest_AddSubscription(BitmessageTestCase):
|
|||
QTest.qWait(4)
|
||||
QTest.qWait(500)
|
||||
QTimer.singleShot(0, dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
|
||||
|
||||
try:
|
||||
QTest.qWait(800)
|
||||
address, label = dialog.data
|
||||
|
@ -59,7 +61,8 @@ class BitmessageTest_AddSubscription(BitmessageTestCase):
|
|||
QTest.qWait(500)
|
||||
return 0
|
||||
self.myapp.addSubscription(address, label)
|
||||
sub_add = sqlQuery("select address from subscriptions where label='" + random_label + "'")[0]
|
||||
sub_add = sqlQuery(
|
||||
"select address from subscriptions where label='" + random_label + "'")[0]
|
||||
self.assertEqual(random_address, sub_add[0])
|
||||
print("Test Pass:--> Subscription Done Successfully")
|
||||
return 1
|
||||
|
|
|
@ -17,6 +17,7 @@ from tr import _translate
|
|||
|
||||
class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
|
||||
"""Blacklist and Whitelist address add functionality tests"""
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
|
||||
def test_blackwhitelist(self):
|
||||
"""Tab switch to blacklist and add the address on blacklist and whitelist"""
|
||||
|
@ -26,6 +27,7 @@ class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
|
|||
QTest.qWait(500)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist)
|
||||
QTest.qWait(500)
|
||||
|
||||
self.dialog = AddAddressDialog(self.myapp)
|
||||
blacklistcount = len(sqlQuery("Select * from blacklist"))
|
||||
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
|
||||
|
@ -33,7 +35,7 @@ class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
|
|||
"QPushButton {background-color: #FF5733; color: white;}")
|
||||
QTest.qWait(50)
|
||||
self.myapp.ui.blackwhitelist.pushButtonAddBlacklist.setStyleSheet("")
|
||||
self.checkblacklist()
|
||||
self.blackwhitelist_autofill()
|
||||
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
|
||||
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
|
||||
QTest.qWait(500)
|
||||
|
@ -43,40 +45,46 @@ class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
|
|||
"QPushButton {background-color: #FF5733; color: white;}")
|
||||
QTest.qWait(50)
|
||||
self.myapp.ui.blackwhitelist.pushButtonAddBlacklist.setStyleSheet("")
|
||||
self.checkblacklist()
|
||||
self.blackwhitelist_autofill()
|
||||
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
|
||||
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
|
||||
QTest.qWait(500)
|
||||
self.assertEqual(blacklistcount + 1, len(sqlQuery("Select * from blacklist")))
|
||||
self.assertEqual(whitelistcount + 1, len(sqlQuery("Select * from whitelist")))
|
||||
print("Black/WhiteList Functionality Tested Successfully")
|
||||
return 1
|
||||
except:
|
||||
print("Black/WhiteList Functionality Failed")
|
||||
return 0
|
||||
|
||||
def checkblacklist(self): # pylint: disable=too-many-statements
|
||||
"""fill blacklist and whitelist fields"""
|
||||
def blackwhitelist_autofill(self):
|
||||
"""Auto fills the blackwhitelist fields"""
|
||||
try:
|
||||
self.dialog.lineEditLabel.setText("")
|
||||
self.dialog.lineEditAddress.setText("")
|
||||
QTest.qWait(350)
|
||||
self.dialog.show()
|
||||
QTest.qWait(750)
|
||||
random_label = ""
|
||||
self.random_label = ""
|
||||
for _ in range(30):
|
||||
random_label += choice(ascii_lowercase)
|
||||
self.dialog.lineEditLabel.setText(random_label)
|
||||
self.random_label += choice(ascii_lowercase)
|
||||
self.dialog.lineEditLabel.setText(self.random_label)
|
||||
QTest.qWait(4)
|
||||
QTest.qWait(500)
|
||||
rand_address = choice(BMConfigParser().addresses())
|
||||
random_address = ""
|
||||
self.random_address = ""
|
||||
for i, _ in enumerate(rand_address):
|
||||
random_address += rand_address[i]
|
||||
self.dialog.lineEditAddress.setText(random_address)
|
||||
self.random_address += rand_address[i]
|
||||
self.dialog.lineEditAddress.setText(self.random_address)
|
||||
QTest.qWait(4)
|
||||
QTest.qWait(500)
|
||||
QtCore.QTimer.singleShot(0, self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
|
||||
QtCore.QTimer.singleShot(
|
||||
0, self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
|
||||
self.blacklist_test()
|
||||
except:
|
||||
pass
|
||||
|
||||
def blacklist_test(self):
|
||||
"""fill blacklist and whitelist fields"""
|
||||
# pylint: disable=no-else-return
|
||||
try:
|
||||
if self.dialog.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."):
|
||||
address = addBMIfNotPresent(str(self.dialog.lineEditAddress.text()))
|
||||
t = (address,)
|
||||
|
@ -88,7 +96,8 @@ class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
|
|||
if queryreturn == []:
|
||||
self.blacklist_obj.tableWidgetBlacklist.setSortingEnabled(False)
|
||||
self.blacklist_obj.tableWidgetBlacklist.insertRow(0)
|
||||
newItem = QtGui.QTableWidgetItem(unicode(self.dialog.lineEditLabel.text().toUtf8(), "utf-8"))
|
||||
newItem = QtGui.QTableWidgetItem(
|
||||
unicode(self.dialog.lineEditLabel.text().toUtf8(), "utf-8"))
|
||||
newItem.setIcon(avatarize(address))
|
||||
self.blacklist_obj.tableWidgetBlacklist.setItem(0, 0, newItem)
|
||||
newItem = QtGui.QTableWidgetItem(address)
|
||||
|
@ -100,16 +109,16 @@ class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
|
|||
sql = """INSERT INTO blacklist VALUES (?,?,?)"""
|
||||
sqlExecute(sql, *t)
|
||||
black_list_value = sqlQuery(
|
||||
"Select address from blacklist where label='" + random_label + "'")[0]
|
||||
self.assertEqual(black_list_value[0], random_address)
|
||||
"Select address from blacklist where label='" + self.random_label + "'")[0]
|
||||
self.assertEqual(black_list_value[0], self.random_address)
|
||||
print("Test Pass:--> Address Added to the blacklist")
|
||||
return 1
|
||||
else:
|
||||
sql = """INSERT INTO whitelist VALUES (?,?,?)"""
|
||||
sqlExecute(sql, *t)
|
||||
white_list_value = sqlQuery(
|
||||
"Select address from whitelist where label='" + random_label + "'")[0]
|
||||
self.assertEqual(white_list_value[0], random_address)
|
||||
"Select address from whitelist where label='" + self.random_label + "'")[0]
|
||||
self.assertEqual(white_list_value[0], self.random_address)
|
||||
print("Test Pass:--> Address Added to the whitelist")
|
||||
return 1
|
||||
else:
|
||||
|
|
|
@ -13,10 +13,12 @@ from testloader import BitmessageTestCase
|
|||
|
||||
class BitmessageTest_MessageTesting(BitmessageTestCase):
|
||||
"""Test Message Sending functionality"""
|
||||
# pylint: disable= no-else-return
|
||||
|
||||
def test_msgsend(self):
|
||||
"""Auto-fill senders address, receivers address, subject and message and sends the message"""
|
||||
print("=====================Test - Message Send/Receive Functionality=====================")
|
||||
print(
|
||||
"=====================Test - Message Send/Receive Functionality=====================")
|
||||
try:
|
||||
if BMConfigParser().addresses():
|
||||
inbox_length = len(sqlQuery("Select msgid from inbox"))
|
||||
|
|
|
@ -15,6 +15,8 @@ from helper_sql import sqlExecute, sqlQuery
|
|||
from testloader import BitmessageTestCase
|
||||
from tr import _translate
|
||||
|
||||
# pylint: disable=no-else-return, inconsistent-return-statements, attribute-defined-outside-init
|
||||
|
||||
|
||||
class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
||||
"""Inbox TabWidget QTreeWidget popMenu Fucntionality testing"""
|
||||
|
@ -27,11 +29,13 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
QTest.qWait(500)
|
||||
self.treeWidget = self.myapp.ui.treeWidgetYourIdentities
|
||||
self.levelitem = self.treeWidget.topLevelItem(random.randint(1, len(BMConfigParser().addresses()) + 1))
|
||||
self.levelitem = self.treeWidget.topLevelItem(
|
||||
random.randint(1, len(BMConfigParser().addresses()) + 1))
|
||||
self.treeWidget.setCurrentItem(self.levelitem)
|
||||
self.currentItem = self.myapp.getCurrentItem()
|
||||
self.rect = self.treeWidget.visualItemRect(self.levelitem)
|
||||
self.myapp.on_context_menuYourIdentities(QtCore.QPoint(self.rect.x() + 160, self.rect.y() + 200))
|
||||
self.myapp.on_context_menuYourIdentities(
|
||||
QtCore.QPoint(self.rect.x() + 160, self.rect.y() + 200))
|
||||
self.myapp.popMenuYourIdentities.hide()
|
||||
self.copy_clipboard()
|
||||
self.enable_disable()
|
||||
|
@ -47,6 +51,7 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
"""Copy Address to the ClipBoard and test whether the copied test is same or not?"""
|
||||
print("=====================Test - Copy Address to the ClipBoard=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
self.popup_menu(2)
|
||||
text_selected = self.currentItem.text(0)
|
||||
QTest.qWait(500)
|
||||
|
@ -64,8 +69,10 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
|
||||
def enable_disable(self):
|
||||
"""Enable address and disable address"""
|
||||
print("=====================Test - Address Enable-Disable Functionality=====================")
|
||||
print(
|
||||
"=====================Test - Address Enable-Disable Functionality=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
self.popup_menu(4)
|
||||
if self.currentItem.isEnabled:
|
||||
QTest.qWait(500)
|
||||
|
@ -91,15 +98,18 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
"""Tests for special address"""
|
||||
print("=====================Test - Address Special Behavior=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
self.popup_menu(6)
|
||||
special_add = dialogs.SpecialAddressBehaviorDialog(self.myapp, BMConfigParser())
|
||||
special_add.lineEditMailingListName.setText("")
|
||||
QTest.qWait(500)
|
||||
special_add.radioButtonBehaviorMailingList.click()
|
||||
QTest.qWait(1000)
|
||||
special_add.lineEditMailingListName.setText("".join(choice(ascii_lowercase) for x in range(15)))
|
||||
special_add.lineEditMailingListName.setText(
|
||||
"".join(choice(ascii_lowercase) for x in range(15)))
|
||||
QTest.qWait(500)
|
||||
QTest.mouseClick(special_add.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
|
||||
QTest.mouseClick(
|
||||
special_add.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
|
||||
print("Test Pass:--> Special Address Behavior Functionality Passed")
|
||||
return 1
|
||||
except:
|
||||
|
@ -110,6 +120,7 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
"""Test email gateway functionality"""
|
||||
print("=====================Test - Email Gateway=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
self.popup_menu(7)
|
||||
QTest.qWait(200)
|
||||
email_gateway = dialogs.EmailGatewayDialog(self.myapp, BMConfigParser())
|
||||
|
@ -124,7 +135,8 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
+ ".com")
|
||||
email_gateway.lineEditEmail.setText(email)
|
||||
QTest.qWait(500)
|
||||
QTest.mouseClick(email_gateway.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
|
||||
QTest.mouseClick(
|
||||
email_gateway.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
|
||||
print("Test Pass:--> Email-Gateway Functionality Passed")
|
||||
return 1
|
||||
except:
|
||||
|
@ -135,6 +147,7 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
"""Mark all messages as read"""
|
||||
print("=====================Test - Mark All as Read Functionality=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
self.popup_menu(11)
|
||||
QTest.qWait(500)
|
||||
self.myapp.popMenuYourIdentities.actions()[11].trigger()
|
||||
|
@ -148,8 +161,10 @@ class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
|
|||
def popup_menu(self, intval):
|
||||
"""Display popupmenu and clicking action UI"""
|
||||
QTest.qWait(5)
|
||||
self.myapp.popMenuYourIdentities.setActiveAction(self.myapp.popMenuYourIdentities.actions()[intval])
|
||||
self.myapp.popMenuYourIdentities.setStyleSheet("QMenu:selected {background-color:#FF5733}")
|
||||
self.myapp.popMenuYourIdentities.setActiveAction(
|
||||
self.myapp.popMenuYourIdentities.actions()[intval])
|
||||
self.myapp.popMenuYourIdentities.setStyleSheet(
|
||||
"QMenu:selected {background-color: #FF5733; color: white;}")
|
||||
self.myapp.popMenuYourIdentities.show()
|
||||
QTest.qWait(400)
|
||||
self.myapp.popMenuYourIdentities.hide()
|
||||
|
@ -163,8 +178,8 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
"""Show QTreeWidget popmenu"""
|
||||
print("-----------------------------------------------------------2")
|
||||
try:
|
||||
QTest.qWait(500)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
|
||||
QTest.qWait(500)
|
||||
self.treeWidget = self.myapp.ui.tableWidgetAddressBook
|
||||
total_sub = sqlQuery("Select address from addressbook")
|
||||
QTest.qWait(500)
|
||||
|
@ -176,7 +191,7 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
QTest.qWait(500)
|
||||
self.myapp.on_context_menuAddressBook(QtCore.QPoint(rect.x() + 160, rect.y() + 200))
|
||||
QTest.qWait(500)
|
||||
if len(total_sub) > 0:
|
||||
if total_sub:
|
||||
self.treeWidget.item(random.randint(0, self.rand_value), 1)
|
||||
else:
|
||||
print("No Address Found.")
|
||||
|
@ -193,10 +208,11 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
|
||||
def add_new_address(self):
|
||||
"""Adding New Address to Address Book"""
|
||||
print("=====================Test - Adding New Address to Address Book=====================")
|
||||
print(
|
||||
"=====================Test - Adding New Address to Address Book=====================")
|
||||
try:
|
||||
self.popup_menu(6)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
|
||||
self.popup_menu(6)
|
||||
self.dialog = dialogs.AddAddressDialog(self.myapp)
|
||||
self.dialog.show()
|
||||
QTest.qWait(500)
|
||||
|
@ -204,7 +220,8 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
QTest.qWait(500)
|
||||
self.dialog.lineEditAddress.setText(choice(BMConfigParser().addresses()))
|
||||
QTest.qWait(500)
|
||||
QtCore.QTimer.singleShot(0, self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
|
||||
QtCore.QTimer.singleShot(
|
||||
0, self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
|
||||
QTest.qWait(500)
|
||||
try:
|
||||
address, label = self.dialog.data
|
||||
|
@ -232,6 +249,7 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
"""Test - Send Message to this Address"""
|
||||
print("=====================Test - Send Message to this Address=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
|
||||
self.popup_menu(0)
|
||||
if BMConfigParser().addresses():
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
|
||||
|
@ -278,10 +296,11 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
|
||||
def copy_clipboard(self):
|
||||
"""Copy Address to the ClipBoard and test whether the copied test is same or not?"""
|
||||
print("=====================Test - Copy Address Book Address to Clipboard=====================")
|
||||
print(
|
||||
"=====================Test - Copy Address Book Address to Clipboard=====================")
|
||||
try:
|
||||
self.popup_menu(1)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
|
||||
self.popup_menu(1)
|
||||
# self.current_address = str(self.treeWidget.item(random.randint(0, self.rand_value), 1).text())
|
||||
QTest.qWait(500)
|
||||
self.myapp.popMenuAddressBook.actions()[1].trigger()
|
||||
|
@ -300,8 +319,8 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
"""Subscribe to This Address"""
|
||||
print("=====================Test - Subscribe to This Address=====================")
|
||||
try:
|
||||
self.popup_menu(2)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
|
||||
self.popup_menu(2)
|
||||
self.treeWidget.setCurrentCell(self.rand_value, 1)
|
||||
QTest.qWait(500)
|
||||
self.myapp.popMenuAddressBook.actions()[2].trigger()
|
||||
|
@ -325,11 +344,12 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
|
||||
def delete_addressbook(self):
|
||||
"""Delete Address from the Address Book"""
|
||||
print("=====================Test - Delete Address from the Address Book=====================")
|
||||
print(
|
||||
"=====================Test - Delete Address from the Address Book=====================")
|
||||
try:
|
||||
QTest.qWait(100)
|
||||
self.popup_menu(7)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
|
||||
self.popup_menu(7)
|
||||
self.treeWidget.setCurrentCell(self.rand_value, 1)
|
||||
self.myapp.on_action_AddressBookDelete()
|
||||
QTest.qWait(500)
|
||||
|
@ -347,8 +367,10 @@ class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
|
|||
def popup_menu(self, intval):
|
||||
"""Display popupmenu and clicking action UI"""
|
||||
QTest.qWait(5)
|
||||
self.myapp.popMenuAddressBook.setActiveAction(self.myapp.popMenuAddressBook.actions()[intval])
|
||||
self.myapp.popMenuAddressBook.setStyleSheet("QMenu:selected {background-color:#FF5733}")
|
||||
self.myapp.popMenuAddressBook.setActiveAction(
|
||||
self.myapp.popMenuAddressBook.actions()[intval])
|
||||
self.myapp.popMenuAddressBook.setStyleSheet(
|
||||
"QMenu:selected {background-color: #FF5733; color: white;}")
|
||||
self.myapp.popMenuAddressBook.show()
|
||||
QTest.qWait(400)
|
||||
self.myapp.popMenuAddressBook.hide()
|
||||
|
@ -410,7 +432,8 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
random_address += rand_address[i]
|
||||
dialog.lineEditAddress.setText(random_address)
|
||||
QTest.qWait(4)
|
||||
QtCore.QTimer.singleShot(0, dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
|
||||
QtCore.QTimer.singleShot(
|
||||
0, dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
|
||||
QTest.qWait(500)
|
||||
try:
|
||||
address, label = dialog.data
|
||||
|
@ -421,7 +444,7 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
print(
|
||||
"MainWindow",
|
||||
"Error: You cannot add the same address to your subscriptions twice."
|
||||
" Perhaps rename the existing one if you want.")
|
||||
" Perhaps rename the existing one if you want.",)
|
||||
self.myapp.updateStatusBar(
|
||||
_translate(
|
||||
"MainWindow",
|
||||
|
@ -443,7 +466,8 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
|
||||
def enable_disable(self):
|
||||
"""Enable address and disable address"""
|
||||
print("=====================Test - Address Enable-Disable Functionality=====================")
|
||||
print(
|
||||
"=====================Test - Address Enable-Disable Functionality=====================")
|
||||
QTest.qWait(500)
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
|
||||
|
@ -469,7 +493,8 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
|
||||
def copy_clipboard(self):
|
||||
"""Copy Address to the ClipBoard and test whether the copied test is same or not?"""
|
||||
print("=====================Test - Copy Address Book Address to Clipboard=====================")
|
||||
print(
|
||||
"=====================Test - Copy Address Book Address to Clipboard=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
|
||||
self.treeWidget.setCurrentItem(self.levelitem)
|
||||
|
@ -491,6 +516,7 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
"""Test - Send Message to this Address"""
|
||||
print("=====================Test - Send Message to this Address=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
|
||||
self.popup_menu(7)
|
||||
if BMConfigParser().addresses():
|
||||
inbox_length = len(sqlQuery("Select msgid from inbox"))
|
||||
|
@ -540,6 +566,7 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
"""Mark all messages as read"""
|
||||
print("=====================Test - Mark All as Read Functionality=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
|
||||
self.popup_menu(8)
|
||||
QTest.qWait(550)
|
||||
self.myapp.popMenuSubscriptions.actions()[8].trigger()
|
||||
|
@ -552,10 +579,11 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
|
||||
def del_address_from_sub(self):
|
||||
"""Method deletes the address from the subscription"""
|
||||
print("=====================Test - Delete Address from the subscription Field=====================")
|
||||
print(
|
||||
"=====================Test - Delete Address from the subscription Field=====================")
|
||||
try:
|
||||
self.popup_menu(1)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
|
||||
self.popup_menu(1)
|
||||
self.treeWidget.setCurrentItem(self.levelitem)
|
||||
address = self.myapp.getCurrentAccount()
|
||||
QTest.qWait(750)
|
||||
|
@ -578,8 +606,10 @@ class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
|
|||
def popup_menu(self, intval):
|
||||
"""Display popupmenu and clicking action UI"""
|
||||
QTest.qWait(5)
|
||||
self.myapp.popMenuSubscriptions.setActiveAction(self.myapp.popMenuSubscriptions.actions()[intval])
|
||||
self.myapp.popMenuSubscriptions.setStyleSheet("QMenu:selected {background-color:#FF5733}")
|
||||
self.myapp.popMenuSubscriptions.setActiveAction(
|
||||
self.myapp.popMenuSubscriptions.actions()[intval])
|
||||
self.myapp.popMenuSubscriptions.setStyleSheet(
|
||||
"QMenu:selected {background-color: #FF5733; color: white;}")
|
||||
self.myapp.popMenuSubscriptions.show()
|
||||
QTest.qWait(400)
|
||||
self.myapp.popMenuSubscriptions.hide()
|
||||
|
@ -593,68 +623,77 @@ class BitmessageTest_BlackWhiteList_PopMenu(BitmessageTestCase):
|
|||
"""Show QTableWidget Popupmenu"""
|
||||
print("-----------------------------------------------------------4")
|
||||
try:
|
||||
total_bl = sqlQuery("Select address from blacklist")
|
||||
total_wl = sqlQuery("Select address from whitelist")
|
||||
if len(total_bl) > 0:
|
||||
self.blacklist_obj = blacklist.Blacklist()
|
||||
QTest.qWait(500)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist)
|
||||
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
|
||||
self.tableWidget = self.myapp.ui.blackwhitelist.tableWidgetBlacklist
|
||||
QTest.qWait(500)
|
||||
|
||||
self.rand_value = random.randint(0, len(total_bl) - 1)
|
||||
self.tableWidget.setCurrentCell(self.rand_value, 1)
|
||||
self.tableWidget.item(self.rand_value, 1).setSelected(True)
|
||||
rect = self.tableWidget.visualItemRect(self.tableWidget.item(self.rand_value, 1))
|
||||
QTest.qWait(500)
|
||||
|
||||
self.blacklist_obj.init_blacklist_popup_menu()
|
||||
self.blacklist_obj.popMenuBlacklist.move(QtCore.QPoint(rect.x(), rect.y() + 290))
|
||||
self.blacklist_obj.popMenuBlacklist.show()
|
||||
QTest.qWait(300)
|
||||
self.blacklist_obj.popMenuBlacklist.hide()
|
||||
self.copy_clipboard()
|
||||
self.enable_blackwhitelist()
|
||||
self.disble_blackwhitelist()
|
||||
self.address_delete()
|
||||
return 1
|
||||
else:
|
||||
print("Test Fail:--> No White list Found")
|
||||
return 0
|
||||
if len(total_wl) > 0:
|
||||
self.blacklist_obj = blacklist.Blacklist()
|
||||
|
||||
QTest.qWait(500)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist)
|
||||
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
|
||||
self.tableWidget = self.myapp.ui.blackwhitelist.tableWidgetBlacklist
|
||||
QTest.qWait(500)
|
||||
|
||||
self.rand_value = random.randint(0, len(total_wl) - 1)
|
||||
self.tableWidget.setCurrentCell(self.rand_value, 1)
|
||||
self.tableWidget.item(self.rand_value, 1).setSelected(True)
|
||||
rect = self.tableWidget.visualItemRect(self.tableWidget.item(self.rand_value, 1))
|
||||
QTest.qWait(500)
|
||||
|
||||
self.blacklist_obj.init_blacklist_popup_menu()
|
||||
self.blacklist_obj.popMenuBlacklist.move(QtCore.QPoint(rect.x(), rect.y() + 290))
|
||||
self.blacklist_obj.popMenuBlacklist.show()
|
||||
QTest.qWait(300)
|
||||
self.blacklist_obj.popMenuBlacklist.hide()
|
||||
|
||||
self.copy_clipboard()
|
||||
self.enable_blackwhitelist()
|
||||
self.disble_blackwhitelist()
|
||||
self.address_delete()
|
||||
return 1
|
||||
else:
|
||||
print("Test Fail:--> No White list Found")
|
||||
return 0
|
||||
self.total_bl = sqlQuery("Select address from blacklist")
|
||||
self.total_wl = sqlQuery("Select address from whitelist")
|
||||
if self.total_bl:
|
||||
self.trigger_blacklist_test()
|
||||
if self.total_wl:
|
||||
self.trigger_whitelist_test()
|
||||
except:
|
||||
print("Test Fail:--> Getting Error while testing on Black/WhiteList Addresses")
|
||||
return 0
|
||||
|
||||
def trigger_blacklist_test(self):
|
||||
"""Triggers blacklist test cases"""
|
||||
try:
|
||||
self.blacklist_obj = blacklist.Blacklist()
|
||||
QTest.qWait(500)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist)
|
||||
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
|
||||
self.tableWidget = self.myapp.ui.blackwhitelist.tableWidgetBlacklist
|
||||
QTest.qWait(500)
|
||||
|
||||
self.rand_value = random.randint(0, len(self.total_bl) - 1)
|
||||
self.tableWidget.setCurrentCell(self.rand_value, 1)
|
||||
self.tableWidget.item(self.rand_value, 1).setSelected(True)
|
||||
rect = self.tableWidget.visualItemRect(self.tableWidget.item(self.rand_value, 1))
|
||||
QTest.qWait(500)
|
||||
|
||||
self.blacklist_obj.init_blacklist_popup_menu()
|
||||
self.blacklist_obj.popMenuBlacklist.move(QtCore.QPoint(rect.x(), rect.y() + 290))
|
||||
self.blacklist_obj.popMenuBlacklist.show()
|
||||
QTest.qWait(300)
|
||||
self.blacklist_obj.popMenuBlacklist.hide()
|
||||
self.copy_clipboard()
|
||||
self.enable_blackwhitelist()
|
||||
self.disble_blackwhitelist()
|
||||
self.address_delete()
|
||||
return 1
|
||||
except:
|
||||
print("Test Fail:--> Getting Error While Testing Blacklist")
|
||||
return 0
|
||||
|
||||
def trigger_whitelist_test(self):
|
||||
"""Triggers whitelist test cases"""
|
||||
try:
|
||||
self.blacklist_obj = blacklist.Blacklist()
|
||||
QTest.qWait(500)
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist)
|
||||
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
|
||||
self.tableWidget = self.myapp.ui.blackwhitelist.tableWidgetBlacklist
|
||||
QTest.qWait(500)
|
||||
|
||||
self.rand_value = random.randint(0, len(self.total_wl) - 1)
|
||||
self.tableWidget.setCurrentCell(self.rand_value, 1)
|
||||
self.tableWidget.item(self.rand_value, 1).setSelected(True)
|
||||
rect = self.tableWidget.visualItemRect(self.tableWidget.item(self.rand_value, 1))
|
||||
QTest.qWait(500)
|
||||
|
||||
self.blacklist_obj.init_blacklist_popup_menu()
|
||||
self.blacklist_obj.popMenuBlacklist.move(QtCore.QPoint(rect.x(), rect.y() + 290))
|
||||
self.blacklist_obj.popMenuBlacklist.show()
|
||||
QTest.qWait(300)
|
||||
self.blacklist_obj.popMenuBlacklist.hide()
|
||||
|
||||
self.copy_clipboard()
|
||||
self.enable_blackwhitelist()
|
||||
self.disble_blackwhitelist()
|
||||
self.address_delete()
|
||||
return 1
|
||||
except:
|
||||
print("Test Fail:--> Getting Error While Testing WhiteList")
|
||||
return 0
|
||||
|
||||
def address_delete(self):
|
||||
"""Delte address from the Black/WhiteList"""
|
||||
try:
|
||||
|
@ -712,16 +751,20 @@ class BitmessageTest_BlackWhiteList_PopMenu(BitmessageTestCase):
|
|||
self.popup_menu(4)
|
||||
currentRow = self.tableWidget.currentRow()
|
||||
addressAtCurrentRow = self.tableWidget.item(currentRow, 1).text()
|
||||
self.tableWidget.item(currentRow, 0).setTextColor(QtGui.QApplication.palette().text().color())
|
||||
self.tableWidget.item(currentRow, 1).setTextColor(QtGui.QApplication.palette().text().color())
|
||||
self.tableWidget.item(currentRow, 0).setTextColor(
|
||||
QtGui.QApplication.palette().text().color())
|
||||
self.tableWidget.item(currentRow, 1).setTextColor(
|
||||
QtGui.QApplication.palette().text().color())
|
||||
QTest.qWait(500)
|
||||
if BMConfigParser().get("bitmessagesettings", "blackwhitelist") == "black":
|
||||
QTest.qWait(500)
|
||||
sqlExecute("""UPDATE blacklist SET enabled=1 WHERE address=?""", str(addressAtCurrentRow))
|
||||
sqlExecute(
|
||||
"""UPDATE blacklist SET enabled=1 WHERE address=?""", str(addressAtCurrentRow))
|
||||
print("Test Pass:--> Enabled the Blacklist address")
|
||||
else:
|
||||
QTest.qWait(500)
|
||||
sqlExecute("""UPDATE whitelist SET enabled=1 WHERE address=?""", str(addressAtCurrentRow))
|
||||
sqlExecute(
|
||||
"""UPDATE whitelist SET enabled=1 WHERE address=?""", str(addressAtCurrentRow))
|
||||
print("Test Pass:--> Enabled the Whitelist address")
|
||||
return 1
|
||||
except:
|
||||
|
@ -740,11 +783,13 @@ class BitmessageTest_BlackWhiteList_PopMenu(BitmessageTestCase):
|
|||
QTest.qWait(500)
|
||||
if BMConfigParser().get("bitmessagesettings", "blackwhitelist") == "black":
|
||||
QTest.qWait(500)
|
||||
sqlExecute("""UPDATE blacklist SET enabled=0 WHERE address=?""", str(addressAtCurrentRow))
|
||||
sqlExecute(
|
||||
"""UPDATE blacklist SET enabled=0 WHERE address=?""", str(addressAtCurrentRow))
|
||||
print("Test Pass:--> Disabled the Blacklist address")
|
||||
else:
|
||||
QTest.qWait(500)
|
||||
sqlExecute("""UPDATE whitelist SET enabled=0 WHERE address=?""", str(addressAtCurrentRow))
|
||||
sqlExecute(
|
||||
"""UPDATE whitelist SET enabled=0 WHERE address=?""", str(addressAtCurrentRow))
|
||||
print("Test Pass:--> Disabled the Blacklist address")
|
||||
return 1
|
||||
except:
|
||||
|
@ -755,8 +800,10 @@ class BitmessageTest_BlackWhiteList_PopMenu(BitmessageTestCase):
|
|||
"""Display popupmenu and clicking action UI"""
|
||||
try:
|
||||
QTest.qWait(5)
|
||||
self.blacklist_obj.popMenuBlacklist.setActiveAction(self.blacklist_obj.popMenuBlacklist.actions()[intval])
|
||||
self.blacklist_obj.popMenuBlacklist.setStyleSheet("QMenu:selected {background-color:#FF5733}")
|
||||
self.blacklist_obj.popMenuBlacklist.setActiveAction(
|
||||
self.blacklist_obj.popMenuBlacklist.actions()[intval])
|
||||
self.blacklist_obj.popMenuBlacklist.setStyleSheet(
|
||||
"QMenu:selected {background-color: #FF5733; color: white;}")
|
||||
self.blacklist_obj.popMenuBlacklist.show()
|
||||
QTest.qWait(400)
|
||||
self.blacklist_obj.popMenuBlacklist.hide()
|
||||
|
|
|
@ -17,7 +17,7 @@ from tr import _translate
|
|||
|
||||
class BitmessageTest_QuitTest(BitmessageTestCase):
|
||||
"""Quit the bitmessage qt application"""
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
def test_quitapplication(self):
|
||||
"""wait for pow and shutdown the application"""
|
||||
print("=====================Test - Quitting Application=====================")
|
||||
|
@ -28,57 +28,21 @@ class BitmessageTest_QuitTest(BitmessageTestCase):
|
|||
self.myapp.raise_()
|
||||
self.myapp.activateWindow()
|
||||
|
||||
waitForPow = True
|
||||
waitForConnection = False
|
||||
waitForSync = False
|
||||
self.waitForPow = True
|
||||
self.waitForConnection = False
|
||||
self.waitForSync = False
|
||||
if getPowType() == "python" and (bitmessageqt.powQueueSize() > 0 or pendingUpload() > 0):
|
||||
waitForPow = False
|
||||
self.waitForPow = False
|
||||
if pendingDownload() > 0:
|
||||
self.myapp.wait = waitForSync = True
|
||||
self.myapp.wait = self.waitForSync = True
|
||||
if shared.statusIconColor == "red" and not BMConfigParser().safeGetBoolean(
|
||||
"bitmessagesettings", "dontconnect"
|
||||
):
|
||||
waitForConnection = True
|
||||
self.myapp.wait = waitForSync = True
|
||||
"bitmessagesettings", "dontconnect"):
|
||||
self.waitForConnection = True
|
||||
self.myapp.wait = self.waitForSync = True
|
||||
self.myapp.quitAccepted = True
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Shutting down PyBitmessage... %1%").arg(0))
|
||||
if waitForConnection:
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Waiting for network connection..."))
|
||||
while shared.statusIconColor == "red":
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
if waitForSync:
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Waiting for finishing synchronisation..."))
|
||||
while pendingDownload() > 0:
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
if waitForPow:
|
||||
maxWorkerQueue = 0
|
||||
curWorkerQueue = bitmessageqt.powQueueSize()
|
||||
while curWorkerQueue > 0:
|
||||
curWorkerQueue = bitmessageqt.powQueueSize()
|
||||
if curWorkerQueue > maxWorkerQueue:
|
||||
maxWorkerQueue = curWorkerQueue
|
||||
if curWorkerQueue > 0:
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Waiting for PoW to finish... %1%").arg(
|
||||
50 * (maxWorkerQueue - curWorkerQueue) / maxWorkerQueue))
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Shutting down Pybitmessage... %1%").arg(50))
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
if maxWorkerQueue > 0:
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(50))
|
||||
maxPendingUpload = max(1, pendingUpload())
|
||||
while pendingUpload() > 1:
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(
|
||||
int(50 + 20 * (pendingUpload() / maxPendingUpload))))
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Shutting down PyBitmessage... %1%").arg(0))
|
||||
self.waiting_for_closing()
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Saving settings... %1%").arg(70))
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
|
@ -91,8 +55,53 @@ class BitmessageTest_QuitTest(BitmessageTestCase):
|
|||
self.myapp.updateStatusBar(_translate("MainWindow", "Shutting down core... %1%").arg(80))
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
shutdown.doCleanShutdown()
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Stopping notifications... %1%").arg(90))
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Stopping notifications... %1%").arg(90))
|
||||
self.myapp.tray.hide()
|
||||
self.myapp.updateStatusBar(_translate("MainWindow", "Shutdown imminent... %1%").arg(100))
|
||||
logger.info("Shutdown complete")
|
||||
QtGui.qApp.closeAllWindows()
|
||||
|
||||
def waiting_for_closing(self):
|
||||
"""Waiting for connections, sync, and Pow"""
|
||||
if self.waitForConnection:
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Waiting for network connection..."))
|
||||
while shared.statusIconColor == "red":
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
if self.waitForSync:
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Waiting for finishing synchronisation..."))
|
||||
while pendingDownload() > 0:
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
if self.waitForPow:
|
||||
maxWorkerQueue = 0
|
||||
curWorkerQueue = bitmessageqt.powQueueSize()
|
||||
while curWorkerQueue > 0:
|
||||
curWorkerQueue = bitmessageqt.powQueueSize()
|
||||
if curWorkerQueue > maxWorkerQueue:
|
||||
maxWorkerQueue = curWorkerQueue
|
||||
if curWorkerQueue > 0:
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Waiting for PoW to finish... %1%").arg(
|
||||
50 * (maxWorkerQueue - curWorkerQueue) / maxWorkerQueue))
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Shutting down Pybitmessage... %1%").arg(50))
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
if maxWorkerQueue > 0:
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(50))
|
||||
maxPendingUpload = max(1, pendingUpload())
|
||||
while pendingUpload() > 1:
|
||||
self.myapp.updateStatusBar(
|
||||
_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(
|
||||
int(50 + 20 * (pendingUpload() / maxPendingUpload))))
|
||||
time.sleep(0.5)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000)
|
||||
|
|
|
@ -10,12 +10,15 @@ from PyQt4.QtTest import QTest
|
|||
from bitmessageqt import dialogs
|
||||
from testloader import BitmessageTestCase
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
|
||||
class BitmessageTest_SettingWindowTest(BitmessageTestCase):
|
||||
"""Switch to setting tab and test"""
|
||||
|
||||
def test_settingwindow(self):
|
||||
"""Triggers the setting window"""
|
||||
# pylint: disable=protected-access
|
||||
print("=====================Test - Setting Window=====================")
|
||||
try:
|
||||
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
|
||||
|
@ -36,9 +39,11 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
|
|||
try:
|
||||
QTest.qWait(500)
|
||||
dialog.show()
|
||||
dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface))
|
||||
dialog.tabWidgetSettings.setCurrentIndex(
|
||||
dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface))
|
||||
QTest.qWait(800)
|
||||
dialog.languageComboBox.setStyleSheet("QComboBox {background-color: #FF5733; color: white;}")
|
||||
dialog.languageComboBox.setStyleSheet(
|
||||
"QComboBox {background-color: #FF5733; color: white;}")
|
||||
QTest.qWait(50)
|
||||
dialog.languageComboBox.setStyleSheet("")
|
||||
dialog.languageComboBox.setCurrentIndex(random.randint(1, 17))
|
||||
|
@ -53,13 +58,16 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
|
|||
|
||||
def eng_convert(self, dialog):
|
||||
"""Convert any language to english, testing just for good readability"""
|
||||
print("=====================Test - Converting Language Back to English=====================")
|
||||
print(
|
||||
"=====================Test - Converting Language Back to English=====================")
|
||||
try:
|
||||
QTest.qWait(500)
|
||||
dialog.show()
|
||||
dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface))
|
||||
dialog.tabWidgetSettings.setCurrentIndex(
|
||||
dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface))
|
||||
QTest.qWait(800)
|
||||
dialog.languageComboBox.setStyleSheet("QComboBox {background-color: #FF5733; color: white;}")
|
||||
dialog.languageComboBox.setStyleSheet(
|
||||
"QComboBox {background-color: #FF5733; color: white;}")
|
||||
QTest.qWait(50)
|
||||
dialog.languageComboBox.setStyleSheet("")
|
||||
dialog.languageComboBox.setCurrentIndex(5)
|
||||
|
@ -79,19 +87,11 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
|
|||
QTest.qWait(500)
|
||||
dialog.show()
|
||||
QTest.qWait(300)
|
||||
dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabNetworkSettings))
|
||||
dialog.tabWidgetSettings.setCurrentIndex(
|
||||
dialog.tabWidgetSettings.indexOf(dialog.tabNetworkSettings))
|
||||
QTest.qWait(500)
|
||||
|
||||
dialog.lineEditSocksHostname.setText("")
|
||||
dialog.lineEditSocksPort.setText("")
|
||||
dialog.lineEditSocksUsername.setText("")
|
||||
dialog.lineEditSocksPassword.setText("")
|
||||
if dialog.checkBoxAuthentication.isChecked():
|
||||
dialog.checkBoxAuthentication.click()
|
||||
if dialog.checkBoxSocksListen.isChecked():
|
||||
dialog.checkBoxSocksListen.click()
|
||||
if dialog.checkBoxOnionOnly.isChecked():
|
||||
dialog.checkBoxOnionOnly.click()
|
||||
self.network_setting_window_preprocess(dialog)
|
||||
|
||||
QTest.qWait(500)
|
||||
dialog.comboBoxProxyType.setCurrentIndex(random.randint(1, 3))
|
||||
|
@ -112,9 +112,11 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
|
|||
dialog.checkBoxAuthentication.click()
|
||||
QTest.qWait(500)
|
||||
|
||||
dialog.lineEditSocksUsername.setText("".join(choice(ascii_lowercase) for i in range(10)))
|
||||
dialog.lineEditSocksUsername.setText(
|
||||
"".join(choice(ascii_lowercase) for i in range(10)))
|
||||
QTest.qWait(500)
|
||||
dialog.lineEditSocksPassword.setText("".join(choice(ascii_lowercase) for i in range(10)))
|
||||
dialog.lineEditSocksPassword.setText(
|
||||
"".join(choice(ascii_lowercase) for i in range(10)))
|
||||
QTest.qWait(500)
|
||||
|
||||
if dialog.checkBoxSocksListen.isChecked():
|
||||
|
@ -136,6 +138,22 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
|
|||
print("Test Fail:--> Error while testing Network setting window")
|
||||
return 0
|
||||
|
||||
def network_setting_window_preprocess(self, dialog):
|
||||
"""Setting text to fields"""
|
||||
try:
|
||||
dialog.lineEditSocksHostname.setText("")
|
||||
dialog.lineEditSocksPort.setText("")
|
||||
dialog.lineEditSocksUsername.setText("")
|
||||
dialog.lineEditSocksPassword.setText("")
|
||||
if dialog.checkBoxAuthentication.isChecked():
|
||||
dialog.checkBoxAuthentication.click()
|
||||
if dialog.checkBoxSocksListen.isChecked():
|
||||
dialog.checkBoxSocksListen.click()
|
||||
if dialog.checkBoxOnionOnly.isChecked():
|
||||
dialog.checkBoxOnionOnly.click()
|
||||
except:
|
||||
pass
|
||||
|
||||
def tabresendsexpire_window(self, dialog):
|
||||
"""Testing for resend expire window"""
|
||||
print("=====================Test - Tab Resend Expire Window=====================")
|
||||
|
@ -145,7 +163,8 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
|
|||
dialog.lineEditMonths.setText("")
|
||||
dialog.show()
|
||||
QTest.qWait(300)
|
||||
dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabResendsExpire))
|
||||
dialog.tabWidgetSettings.setCurrentIndex(
|
||||
dialog.tabWidgetSettings.indexOf(dialog.tabResendsExpire))
|
||||
QTest.qWait(500)
|
||||
|
||||
QTest.qWait(500)
|
||||
|
|
Reference in New Issue
Block a user