Graphical Qt Test popupmenu automation

This commit is contained in:
lakshyacis 2020-03-13 20:10:20 +05:30
parent 380de9d1d9
commit 5e92603fcc
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
13 changed files with 798 additions and 324 deletions

View File

@ -2514,7 +2514,6 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.textEditMessage.setFocus() self.ui.textEditMessage.setFocus()
def on_action_MarkAllRead(self): def on_action_MarkAllRead(self):
import state
if state.qttesting: if state.qttesting:
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
else: else:
@ -3287,8 +3286,12 @@ class MyForm(settingsmixin.SMainWindow):
self.popMenuAddressBook.addSeparator() self.popMenuAddressBook.addSeparator()
for plugin in self.menu_plugins['address']: for plugin in self.menu_plugins['address']:
self.popMenuAddressBook.addAction(plugin) self.popMenuAddressBook.addAction(plugin)
self.popMenuAddressBook.exec_( if state.qttesting:
self.ui.tableWidgetAddressBook.mapToGlobal(point)) self.popMenuAddressBook.move(point.x(), point.y())
self.popMenuAddressBook.show()
else:
self.popMenuAddressBook.exec_(
self.ui.tableWidgetAddressBook.mapToGlobal(point))
# Group of functions for the Subscriptions dialog box # Group of functions for the Subscriptions dialog box
def on_action_SubscriptionsNew(self): def on_action_SubscriptionsNew(self):
@ -3368,8 +3371,12 @@ class MyForm(settingsmixin.SMainWindow):
self.popMenuSubscriptions.addAction(self.actionMarkAllRead) self.popMenuSubscriptions.addAction(self.actionMarkAllRead)
if self.popMenuSubscriptions.isEmpty(): if self.popMenuSubscriptions.isEmpty():
return return
self.popMenuSubscriptions.exec_( if state.qttesting:
self.ui.treeWidgetSubscriptions.mapToGlobal(point)) self.popMenuSubscriptions.move(point.x(), point.y())
self.popMenuSubscriptions.show()
else:
self.popMenuSubscriptions.exec_(
self.ui.treeWidgetSubscriptions.mapToGlobal(point))
def widgetConvert(self, widget): def widgetConvert(self, widget):
if widget == self.ui.tableWidgetInbox: if widget == self.ui.tableWidgetInbox:

View File

@ -14,85 +14,74 @@ class BitmessageTest_AddressGeneration(BitmessageTestCase):
def test_generateaddress(self): def test_generateaddress(self):
"""Method clicks on new label pushbutton and create new address with random label""" """Method clicks on new label pushbutton and create new address with random label"""
print("=====================Test - Generating Address=====================")
try: try:
address_count = len(BMConfigParser().addresses())
QTest.qWait(500) QTest.qWait(500)
bm_addresses = BMConfigParser().addresses()
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
QTest.qWait(500) 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) QTest.qWait(50)
self.myapp.ui.pushButtonNewAddress.setStyleSheet("") self.myapp.ui.pushButtonNewAddress.setStyleSheet("")
label_gen_obj = address_dialogs.NewAddressDialog() label_gen_obj = address_dialogs.NewAddressDialog()
QTest.qWait(1000) QTest.qWait(750)
random_label = "" random_label = ""
for _ in range(12): for _ in range(15):
random_label += choice(ascii_lowercase) random_label += choice(ascii_lowercase)
label_gen_obj.newaddresslabel.setText(random_label) label_gen_obj.newaddresslabel.setText(random_label)
QTest.qWait(2) QTest.qWait(4)
QTest.qWait(500)
QTest.qWait(600)
label_gen_obj.accept() label_gen_obj.accept()
QTest.qWait(800) QTest.qWait(750)
new_bm_addresses = BMConfigParser().addresses()
self.assertEqual(len(BMConfigParser().addresses()), address_count + 1) self.assertEqual(len(new_bm_addresses), len(bm_addresses) + 1)
self.assertEqual(str(BMConfigParser().get(BMConfigParser().addresses()[-1], "label")), random_label) self.assertEqual(str(BMConfigParser().get(new_bm_addresses[-1], "label")), random_label)
print("\n Test Pass :--> Address Generated Successfully \n") print("Test Pass:--> Address Generated Successfully")
self.assertTrue(True, " \n Test Pass :--> Address Generated Successfully")
return 1 # if every thing is ok return 1 # if every thing is ok
except: except:
print("\n Test Fail :--> Address Generatation Failed or Taking too much time to generate address \n") print("Test Fail:--> Address Generatation Failed or Taking too much time to generate address")
self.assertTrue(False, " \n Test Fail :--> Address Generation Failed!")
return 0 # if test fail return 0 # if test fail
def test_generateaddresswithpassphrase(self): def test_generateaddresswithpassphrase(self):
"""Clicks on the create new label with passphrase pushbutton and generates 8 address""" """Clicks on the create new label with passphrase pushbutton and generates 8 address"""
print("=====================Test - Generating Address with passphrase=====================")
try: try:
address_count = len(BMConfigParser().addresses())
QTest.qWait(500) QTest.qWait(500)
bm_addresses = BMConfigParser().addresses()
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
QTest.qWait(500) 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) QTest.qWait(50)
self.myapp.ui.pushButtonNewAddress.setStyleSheet("") self.myapp.ui.pushButtonNewAddress.setStyleSheet("")
label_gen_obj = address_dialogs.NewAddressDialog() label_gen_obj = address_dialogs.NewAddressDialog()
QTest.qWait(500) QTest.qWait(750)
label_gen_obj.radioButtonDeterministicAddress.click() label_gen_obj.radioButtonDeterministicAddress.click()
QTest.qWait(400) QTest.qWait(250)
random_password1 = ""
random_password1, random_password2 = "", "" for _ in range(15):
for i in range(15):
random_password1 += choice(ascii_lowercase) random_password1 += choice(ascii_lowercase)
label_gen_obj.lineEditPassphrase.setText(random_password1) label_gen_obj.lineEditPassphrase.setText(random_password1)
QTest.qWait(2) QTest.qWait(4)
QTest.qWait(500) QTest.qWait(500)
random_password2 = ""
for i in random_password1: for i in random_password1:
random_password2 += i random_password2 += i
label_gen_obj.lineEditPassphraseAgain.setText(random_password2) label_gen_obj.lineEditPassphraseAgain.setText(random_password2)
QTest.qWait(2) QTest.qWait(2)
QTest.qWait(500)
QTest.qWait(850)
label_gen_obj.accept() label_gen_obj.accept()
QTest.qWait(750)
self.assertEqual(random_password1, random_password2) self.assertEqual(random_password1, random_password2)
print(" Creating Address ......") print(" Creating 8 Addresses. Please Wait! ......")
QTest.qWait(2500) QTest.qWait(2500)
print(" Please Wait.! Creating 8 Address ......") print(" Generating ......... ")
QTest.qWait(2500) QTest.qWait(2500)
self.assertEqual(len(BMConfigParser().addresses()), address_count + 8) self.assertEqual(len(BMConfigParser().addresses()), len(bm_addresses) + 8)
QTest.qWait(100) print("Test Pass:--> Address Generated Successfully with passphrase")
print("\n Test Pass :--> Address Generated Successfully with passphrase \n")
self.assertTrue(True, " \n Test Pass :--> Address Generated Successfully with passphrase")
return 1 return 1
except: except:
QTest.qWait(100)
print( print(
"\n Test Fail :--> Address Generatation Failed with passphrase" "Test Fail:--> Address Generatation Failed"
" or Taking too much time to generate address \n" " with passphrase or Taking too much time to generate address"
) )
self.assertTrue(False, " \n Test Fail :--> Address Generatation Failed with passphrase")
return 0 return 0

View File

@ -2,7 +2,8 @@
from random import choice from random import choice
from string import ascii_lowercase from string import ascii_lowercase
from PyQt4 import QtCore, QtGui from PyQt4 import QtGui
from PyQt4.QtCore import QTimer
from PyQt4.QtTest import QTest from PyQt4.QtTest import QTest
import shared import shared
@ -17,63 +18,56 @@ class BitmessageTest_AddSubscription(BitmessageTestCase):
def test_subscription(self): def test_subscription(self):
"""Test for subscription functionality""" """Test for subscription functionality"""
print("=====================Test - Subscribe Address=====================")
try: try:
if BMConfigParser().addresses(): if BMConfigParser().addresses():
QTest.qWait(500) QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
QTest.qWait(500) QTest.qWait(500)
self.myapp.ui.pushButtonAddSubscription.setStyleSheet(
self.dialog = dialogs.NewSubscriptionDialog(self.myapp) "QPushButton {background-color: #FF5733; color: white;}"
self.dialog.show() )
QTest.qWait(800) QTest.qWait(50)
self.myapp.ui.pushButtonAddSubscription.setStyleSheet("")
dialog = dialogs.NewSubscriptionDialog(self.myapp)
dialog.show()
QTest.qWait(750)
random_label = "" random_label = ""
for _ in range(30): for _ in range(30):
random_label += choice(ascii_lowercase) random_label += choice(ascii_lowercase)
self.dialog.lineEditLabel.setText(random_label) dialog.lineEditLabel.setText(random_label)
QTest.qWait(5) QTest.qWait(4)
QTest.qWait(500) QTest.qWait(500)
rand_address = choice(BMConfigParser().addresses()) rand_address = choice(BMConfigParser().addresses())
random_address = "" random_address = ""
for x in range(len(rand_address)): for i, _ in enumerate(rand_address):
random_address += rand_address[x] random_address += rand_address[i]
self.dialog.lineEditAddress.setText(random_address) dialog.lineEditAddress.setText(random_address)
QTest.qWait(5) QTest.qWait(4)
QTest.qWait(500) QTest.qWait(500)
QTimer.singleShot(0, dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
QtCore.QTimer.singleShot(0, self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
try: try:
QTest.qWait(800) QTest.qWait(800)
address, label = self.dialog.data address, label = dialog.data
except AttributeError: except:
print("Test Fail:--> Error, While Creating subscription list")
QTest.qWait(500) QTest.qWait(500)
print("\n Test Fail :--> Error, While Creating subscription list. \n")
return 0 return 0
if shared.isAddressInMySubscriptionsList(address): if shared.isAddressInMySubscriptionsList(address):
print( print(
"\n Test Fail :--> You cannot add the same address to your subscriptions twice." "Test Fail:--> You cannot add the same address to your subscriptions twice."
" Perhaps rename the existing one if you want. \n" " Perhaps rename the existing one if you want"
) )
QTest.qWait(500) QTest.qWait(500)
return 0 return 0
self.myapp.addSubscription(address, label) 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]) self.assertEqual(random_address, sub_add[0])
print("\n Test Pass :--> Subscription Done Successfully! \n") print("Test Pass:--> Subscription Done Successfully")
QTest.qWait(100)
self.assertTrue(True, " \n Test Pass :--> Subscription Done Successfully!")
return 1 return 1
else: else:
QTest.qWait(100) print("Test Fail:--> No Address Found")
print("\n Test Fail :--> No Address Found! \n")
self.assertTrue(False, " \n Test Fail :--> No Address Found!")
return 0 return 0
except: except:
QTest.qWait(100) print("Test Fail:--> Error Occured while adding address to subscription list")
print("\n Test Fail :--> Error Occured while adding address to subscription list! \n")
self.assertTrue(False, " \n Test Fail :--> Error Occured while adding address to subscription list! ")
return 0 return 0

View File

@ -20,49 +20,62 @@ class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
def test_blackwhitelist(self): def test_blackwhitelist(self):
"""Tab switch to blacklist and add the address on blacklist and whitelist""" """Tab switch to blacklist and add the address on blacklist and whitelist"""
print("=====================Test - Adding Address to Black/WhiteList=====================")
self.blacklist_obj = blacklist.Blacklist()
try: try:
QTest.qWait(500) QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist)
QTest.qWait(500) QTest.qWait(500)
self.blacklist_obj = blacklist.Blacklist()
self.dialog = AddAddressDialog(self.myapp) self.dialog = AddAddressDialog(self.myapp)
blacklistcount = len(sqlQuery("Select * from blacklist")) blacklistcount = len(sqlQuery("Select * from blacklist"))
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click() self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
self.checkblacklist(self.myapp) self.myapp.ui.blackwhitelist.pushButtonAddBlacklist.setStyleSheet(
"QPushButton {background-color: #FF5733; color: white;}"
)
QTest.qWait(50)
self.myapp.ui.blackwhitelist.pushButtonAddBlacklist.setStyleSheet("")
self.checkblacklist()
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
QTest.qWait(500)
whitelistcount = len(sqlQuery("Select * from whitelist"))
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
self.myapp.ui.blackwhitelist.pushButtonAddBlacklist.setStyleSheet(
"QPushButton {background-color: #FF5733; color: white;}"
)
QTest.qWait(50)
self.myapp.ui.blackwhitelist.pushButtonAddBlacklist.setStyleSheet("")
self.checkblacklist()
self.myapp.ui.blackwhitelist.radioButtonBlacklist.click()
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
QTest.qWait(500) QTest.qWait(500)
self.assertEqual(blacklistcount + 1, len(sqlQuery("Select * from blacklist"))) self.assertEqual(blacklistcount + 1, len(sqlQuery("Select * from blacklist")))
whitelistcount = len(sqlQuery("Select * from whitelist"))
self.myapp.ui.blackwhitelist.radioButtonWhitelist.click()
self.checkblacklist(self.myapp)
QTest.qWait(500)
self.assertEqual(whitelistcount + 1, len(sqlQuery("Select * from whitelist"))) self.assertEqual(whitelistcount + 1, len(sqlQuery("Select * from whitelist")))
self.assertTrue(True, " \n Test Pass :--> Black/WhiteList Functionality Tested Successfully!") print("Black/WhiteList Functionality Tested Successfully")
return 1
except: except:
self.assertTrue(False, " \n Test Fail :--> Black/WhiteList Functionality Failed!.") print("Black/WhiteList Functionality Failed")
return 0
def checkblacklist(self, myapp): def checkblacklist(self): # pylint: disable=too-many-statements
"""fill blacklist and whitelist fields""" """fill blacklist and whitelist fields"""
# pylint: disable=too-many-statements
QTest.qWait(1000)
self.dialog.lineEditLabel.setText("") self.dialog.lineEditLabel.setText("")
self.dialog.lineEditAddress.setText("") self.dialog.lineEditAddress.setText("")
QTest.qWait(350)
self.dialog.show() self.dialog.show()
QTest.qWait(800) QTest.qWait(750)
random_label = "" random_label = ""
for _ in range(30): for _ in range(30):
random_label += choice(ascii_lowercase) random_label += choice(ascii_lowercase)
self.dialog.lineEditLabel.setText(random_label) self.dialog.lineEditLabel.setText(random_label)
QTest.qWait(5) QTest.qWait(4)
QTest.qWait(500) QTest.qWait(500)
rand_address = choice(BMConfigParser().addresses()) rand_address = choice(BMConfigParser().addresses())
random_address = "" random_address = ""
for x in range(len(rand_address)): for i, _ in enumerate(rand_address):
random_address += rand_address[x] random_address += rand_address[i]
self.dialog.lineEditAddress.setText(random_address) self.dialog.lineEditAddress.setText(random_address)
QTest.qWait(5) QTest.qWait(4)
QTest.qWait(500) 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)
if self.dialog.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."): if self.dialog.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."):
@ -88,30 +101,23 @@ class BitmessageTest_BlackandWhiteList(BitmessageTestCase):
sql = """INSERT INTO blacklist VALUES (?,?,?)""" sql = """INSERT INTO blacklist VALUES (?,?,?)"""
sqlExecute(sql, *t) sqlExecute(sql, *t)
black_list_value = sqlQuery("Select address from blacklist where label='" + random_label + "'")[0] black_list_value = sqlQuery("Select address from blacklist where label='" + random_label + "'")[0]
print("\n Test Pass :--> Address Added to the blacklist! \n")
self.assertEqual(black_list_value[0], random_address) self.assertEqual(black_list_value[0], random_address)
return print("Test Pass:--> Address Added to the blacklist")
return 1
else: else:
sql = """INSERT INTO whitelist VALUES (?,?,?)""" sql = """INSERT INTO whitelist VALUES (?,?,?)"""
sqlExecute(sql, *t) sqlExecute(sql, *t)
white_list_value = sqlQuery("Select address from whitelist where label='" + random_label + "'")[0] white_list_value = sqlQuery("Select address from whitelist where label='" + random_label + "'")[0]
print("\n Test Pass :--> Address Added to the whitelist! \n")
self.assertEqual(white_list_value[0], random_address) self.assertEqual(white_list_value[0], random_address)
return print("Test Pass:--> Address Added to the whitelist")
return 1
else: else:
QTest.qWait(100)
print( print(
"\n Test Fail :--> You cannot add the same address to your list twice." "Test Fail:--> You cannot add the same address to your list twice."
" Perhaps rename the existing one if you want. \n" "Perhaps rename the existing one if you want"
)
self.assertTrue(
False,
"\n Test Fail :--> You cannot add the same address to your list twice."
" Perhaps rename the existing one if you want.",
) )
return 0 return 0
else: else:
QTest.qWait(100) QTest.qWait(100)
print("\n Test Fail :--> The address you entered was invalid. Ignoring it. \n") print("Test Fail:--> The address you entered was invalid. Ignoring it")
self.assertTrue(False, " \n Test Fail :--> The address you entered was invalid. Ignoring it.")
return 0 return 0

View File

@ -9,7 +9,8 @@ class BitmessageTest_ChansTest(BitmessageTestCase):
def test_chans(self): def test_chans(self):
"""Switch to chans window and test""" """Switch to chans window and test"""
print("=====================Test - Chans Functionality=====================")
QTest.qWait(1200) QTest.qWait(1200)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.chans) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.chans)
print("\n Test Pass :--> Chans Test Passed! \n") print("Test Pass :--> Chans Test Passed")
return 1 return 1

View File

@ -1,134 +0,0 @@
"""Inbox TabWidget QTreeWidget Testing"""
import random
from random import choice
from string import ascii_lowercase
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import Qt
from PyQt4.QtTest import QTest
from bitmessageqt import dialogs
from bmconfigparser import BMConfigParser
from testloader import BitmessageTestCase
class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
"""Inbox TabWidget QTreeWidget popMenu Fucntionality testing"""
def test_sider(self):
"""Show QTreeWidget popmenu"""
QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
QTest.qWait(500)
treeWidget = self.myapp.ui.treeWidgetYourIdentities
self.levelitem = treeWidget.topLevelItem(random.randint(1, len(BMConfigParser().addresses())))
self.myapp.ui.treeWidgetYourIdentities.setCurrentItem(self.levelitem)
rect = self.myapp.ui.treeWidgetYourIdentities.visualItemRect(self.levelitem)
self.currentItem = self.myapp.getCurrentItem()
self.myapp.on_context_menuYourIdentities(QtCore.QPoint(rect.x() + 200, rect.y() + 200))
QTest.qWait(500)
self.myapp.popMenuYourIdentities.hide()
QTest.qWait(100)
self.copy_clipboard()
QTest.qWait(100)
self.enable_disable()
QTest.qWait(100)
self.special_address_behavior()
QTest.qWait(100)
self.email_gateway()
QTest.qWait(100)
self.mark_all_as_read()
def copy_clipboard(self):
"""Copy address to clipboard and test"""
try:
text_selected = self.levelitem.text(0)
QTest.qWait(250)
self.myapp.popMenuYourIdentities.actions()[2].trigger()
QTest.qWait(750)
if str(QtGui.QApplication.clipboard().text()) in str(text_selected):
self.assertTrue(True, " Test Pass :--> Copy functionality working fine \n")
print(" Test Pass :--> Copy functionality working fine \n")
else:
print(" Test Fail :--> Copy functionality failed \n")
self.assertTrue(False, " Test Fail :--> Copy functionality failed \n")
except:
print(" Test Fail :--> Copy functionality failed \n")
self.assertTrue(False, " Test Fail :--> Copy functionality failed \n")
def enable_disable(self):
"""Enable address and disable address"""
QTest.qWait(500)
try:
if self.currentItem.isEnabled:
QTest.qWait(300)
self.myapp.popMenuYourIdentities.actions()[4].trigger()
print("Address is Disabled \n")
QTest.qWait(1000)
self.myapp.on_action_Enable()
print("Address is Enabled \n")
QTest.qWait(1000)
else:
QTest.qWait(300)
self.myapp.popMenuYourIdentities.actions()[4].trigger()
print("Address is Enabled \n")
QTest.qWait(1000)
self.myapp.on_action_Disable()
print("Address is Disabled \n")
QTest.qWait(1000)
except:
self.assertTrue(False, " Test Fail :--> Enable Disable failed \n")
def special_address_behavior(self):
"""Tests for special address"""
try:
special_add = dialogs.SpecialAddressBehaviorDialog(self.myapp, BMConfigParser())
special_add.lineEditMailingListName.setText("")
QTest.qWait(1000)
special_add.radioButtonBehaviorMailingList.click()
QTest.qWait(500)
special_add.lineEditMailingListName.setText("".join(choice(ascii_lowercase) for x in range(15)))
QTest.qWait(1000)
QTest.mouseClick(special_add.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
self.assertTrue(True, " Test Pass :--> Special Address Behavior Functionality Passed \n")
print(" Test Pass :--> Special Address Behavior Functionality Passed \n")
except:
print(" Test Fail :--> Special Address Behavior Functionality failed \n")
self.assertTrue(False, " Test Fail :--> Special Address Behavior Functionality failed \n")
def email_gateway(self):
"""Test email gateway functionality"""
try:
QTest.qWait(200)
email_gateway = dialogs.EmailGatewayDialog(self.myapp, config=BMConfigParser())
QTest.qWait(300)
email_gateway.show()
QTest.qWait(1000)
email_gateway.radioButtonRegister.click()
QTest.qWait(500)
email = (
("".join(choice(ascii_lowercase) for x in range(10)))
+ "@"
+ ("".join(choice(ascii_lowercase) for x in range(7)))
+ ".com"
)
email_gateway.lineEditEmail.setText(email)
QTest.qWait(1000)
QTest.mouseClick(email_gateway.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
self.assertTrue(True, " Test Pass :--> Email-Gateway Functionality Passed \n")
print(" Test Pass :--> Email-Gateway Functionality Passed \n")
except:
print(" Test Fail :--> Email-Gateway Functionality failed \n")
self.assertTrue(False, " Test Fail :--> Email-Gateway Functionality failed \n")
def mark_all_as_read(self):
"""Mark all messages as read"""
try:
QTest.qWait(1000)
self.myapp.popMenuYourIdentities.actions()[11].trigger()
QTest.qWait(200)
self.assertTrue(True, " Test Pass :--> Mark All as Read Functionality Passed \n")
print(" Test Pass :--> Mark All as Read Functionality Passed \n")
except:
print(" Test Fail :--> Mark All as Read Functionality failed \n")
self.assertTrue(False, " Test Fail :--> Mark All as Read Functionality failed \n")

View File

@ -16,68 +16,54 @@ class BitmessageTest_MessageTesting(BitmessageTestCase):
def test_msgsend(self): def test_msgsend(self):
"""Auto-fill senders address, receivers address, subject and message and sends the message""" """Auto-fill senders address, receivers address, subject and message and sends the message"""
print("=====================Test - Message Send/Receive Functionality=====================")
try: try:
if BMConfigParser().addresses(): if BMConfigParser().addresses():
inbox_length = len(sqlQuery("Select msgid from inbox"))
QTest.qWait(500) QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
QTest.qWait(500) QTest.qWait(500)
self.myapp.ui.comboBoxSendFrom.setCurrentIndex(
random.randrange(1, len(BMConfigParser().addresses()) + 1)
)
QTest.qWait(1000)
rand_address = choice(BMConfigParser().addresses()) rand_address = choice(BMConfigParser().addresses())
random_address = "" random_address = ""
for x in range(len(rand_address)): for i, _ in enumerate(rand_address):
random_address += rand_address[x] random_address += rand_address[i]
self.myapp.ui.lineEditTo.setText(random_address) self.myapp.ui.lineEditTo.setText(random_address)
QTest.qWait(1) QTest.qWait(4)
QTest.qWait(800) QTest.qWait(500)
random_subject = "" random_subject = ""
for x in range(40): for x in range(30):
random_subject += choice(ascii_lowercase) random_subject += choice(ascii_lowercase)
self.myapp.ui.lineEditSubject.setText(random_subject) self.myapp.ui.lineEditSubject.setText(random_subject)
QTest.qWait(1) QTest.qWait(4)
QTest.qWait(800) QTest.qWait(500)
random_message = "" random_message = ""
for x in range(200): for x in range(150):
random_message += choice(ascii_lowercase) random_message += choice(ascii_lowercase)
self.myapp.ui.textEditMessage.setText(random_message) self.myapp.ui.textEditMessage.setText(random_message)
QTest.qWait(1) QTest.qWait(1)
QTest.qWait(800) QTest.qWait(400)
randinteger = random.randrange(1, len(BMConfigParser().addresses()) + 1)
inbox_length = len(sqlQuery("Select msgid from inbox")) self.myapp.ui.comboBoxSendFrom.setCurrentIndex(randinteger)
QTest.qWait(1000)
QTest.mouseClick(self.myapp.ui.pushButtonSend, Qt.LeftButton) QTest.mouseClick(self.myapp.ui.pushButtonSend, Qt.LeftButton)
QTest.qWait(600) QTest.qWait(350)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
print(" .......................... waiting for message .......................... ") print(" Waiting For Message .......................... ")
for x in range(5): for x in range(5):
QTest.qWait(5000) QTest.qWait(4000)
print(" waiting " + x * ".") print(" waiting " + x * ".")
self.assertEqual(sqlQuery("Select toaddress,subject from inbox")[-1], (rand_address, random_subject)) new_inbox = sqlQuery("Select msgid,toaddress,subject from inbox")
self.assertEqual(new_inbox[-1][1], rand_address)
self.assertEqual(new_inbox[-1][2], random_subject)
if len(sqlQuery("Select msgid from inbox")) == inbox_length + 1: if len(sqlQuery("Select msgid from inbox")) == inbox_length + 1:
QTest.qWait(100) print("Test Pass:--> Message Received Successfully")
print("\n Test Pass :--> Message Received Successfully \n")
self.assertTrue(True, " Test Pass :--> Message Received Successfully")
return 1 return 1
else: else:
QTest.qWait(100) print("Test Fail:--> Doesn't Receive Any Message")
print("\n Test Fail :--> Doesn't Receive Any Message!! \n")
self.assertTrue(False, " \n Test Fail :--> Doesn't Receive Any Message!!")
return 0 return 0
else: else:
QTest.qWait(100) print("Test Fail:--> No Address Found")
print("\n Test Fail :--> No Address Found!! \n")
self.assertTrue(False, " \n Test Fail :--> No Address Found!!")
return 0 return 0
except: except:
QTest.qWait(100) print("Test Fail:--> Message Sending Test Fail")
print("\n Test Fail :--> Message Sending Test Fail!! \n")
self.assertTrue(False, " \n Test Fail :--> Message Sending Test Fail!!")
return 0 return 0

View File

@ -10,10 +10,12 @@ class BitmessageTest_NetworkTest(BitmessageTestCase):
def test_network(self): def test_network(self):
"""Switch to network window""" """Switch to network window"""
try: try:
print("=====================Test - Network Functionality=====================")
QTest.qWait(1000) QTest.qWait(1000)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.networkstatus) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.networkstatus)
QTest.qWait(1200) QTest.qWait(1200)
print("\n Test Pass :--> Network Functionality Working Well! \n") print("Test Pass:--> Network Functionality Working Well")
return 1 return 1
except: except:
print("\n Test Fail :--> Network Functionality Failed! \n") print("Test Fail:--> Network Functionality Failed")
return 0

View File

@ -0,0 +1,607 @@
"""Inbox TabWidget QTreeWidget Testing"""
import random
from random import choice
from string import ascii_lowercase
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import Qt
from PyQt4.QtTest import QTest
import queues
import shared
from bitmessageqt import blacklist, dialogs
from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlQuery
from testloader import BitmessageTestCase
from tr import _translate
class BitmessageTest_Inbox_PopMenu(BitmessageTestCase):
"""Inbox TabWidget QTreeWidget popMenu Fucntionality testing"""
def test_sider(self):
"""Show QTreeWidget popmenu"""
try:
QTest.qWait(500)
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.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.popMenuYourIdentities.hide()
self.copy_clipboard()
self.enable_disable()
self.special_address_behavior()
self.email_gateway()
self.mark_all_as_read()
return 1
except:
print("Test Fail:--> QTreeWidget popmenu functionality failed")
return 0
def copy_clipboard(self):
"""Copy Address to the ClipBoard and test whether the copied test is same or not?"""
print("=====================Test - Copy Address to the ClipBoard=====================")
try:
self.popup_menu(2)
text_selected = self.currentItem.text(0)
QTest.qWait(500)
self.myapp.popMenuYourIdentities.actions()[2].trigger()
QTest.qWait(750)
if str(QtGui.QApplication.clipboard().text()) in str(text_selected):
print("Test Pass:--> Copy functionality working fine")
return 1
else:
print("Test Fail:--> Copy functionality failed")
return 0
except:
print("Test Fail:--> Copy functionality failed")
return 0
def enable_disable(self):
"""Enable address and disable address"""
print("=====================Test - Address Enable-Disable Functionality=====================")
try:
self.popup_menu(4)
if self.currentItem.isEnabled:
QTest.qWait(500)
self.myapp.popMenuYourIdentities.actions()[4].trigger()
QTest.qWait(1000)
self.myapp.on_action_Enable()
QTest.qWait(500)
print("Test Pass:--> Enable-Disable working fine")
return 1
else:
QTest.qWait(500)
self.myapp.popMenuYourIdentities.actions()[4].trigger()
QTest.qWait(1000)
self.myapp.on_action_Disable()
QTest.qWait(500)
print("Test Pass:--> Enable-Disable working fine")
return 1
except:
print("Test Fail:--> Could not able to do Enable-Disable")
return 0
def special_address_behavior(self):
"""Tests for special address"""
print("=====================Test - Address Special Behavior=====================")
try:
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)))
QTest.qWait(500)
QTest.mouseClick(special_add.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
print("Test Pass:--> Special Address Behavior Functionality Passed")
return 1
except:
print("Test Fail:--> Special Address Behavior Functionality failed")
return 0
def email_gateway(self):
"""Test email gateway functionality"""
print("=====================Test - Email Gateway=====================")
try:
self.popup_menu(7)
QTest.qWait(200)
email_gateway = dialogs.EmailGatewayDialog(self.myapp, BMConfigParser())
email_gateway.show()
QTest.qWait(500)
email_gateway.radioButtonRegister.click()
QTest.qWait(450)
email = (
("".join(choice(ascii_lowercase) for x in range(10)))
+ "@"
+ ("".join(choice(ascii_lowercase) for x in range(7)))
+ ".com"
)
email_gateway.lineEditEmail.setText(email)
QTest.qWait(500)
QTest.mouseClick(email_gateway.buttonBox.button(QtGui.QDialogButtonBox.Ok), Qt.LeftButton)
print("Test Pass:--> Email-Gateway Functionality Passed")
return 1
except:
print("Test Fail:--> Email-Gateway Functionality failed")
return 0
def mark_all_as_read(self):
"""Mark all messages as read"""
print("=====================Test - Mark All as Read Functionality=====================")
try:
self.popup_menu(11)
QTest.qWait(500)
self.myapp.popMenuYourIdentities.actions()[11].trigger()
QTest.qWait(500)
print("Test Pass:--> Mark All as Read Functionality Passed")
return 1
except:
print("Test Fail:--> Mark All as Read Functionality failed")
return 0
def popup_menu(self, intval):
QTest.qWait(5)
self.myapp.popMenuYourIdentities.setActiveAction(self.myapp.popMenuYourIdentities.actions()[intval])
self.myapp.popMenuYourIdentities.setStyleSheet("QMenu:selected {background-color:#FF5733}")
self.myapp.popMenuYourIdentities.show()
QTest.qWait(400)
self.myapp.popMenuYourIdentities.hide()
QTest.qWait(50)
class BitmessageTest_AddressBox_PopMenu(BitmessageTestCase):
"""AddressBox TabWidget QTreeWidget popMenu Fucntionality testing"""
def test_sider(self):
try:
QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
self.treeWidget = self.myapp.ui.tableWidgetAddressBook
total_sub = sqlQuery("Select address from addressbook")
QTest.qWait(500)
self.rand_value = random.randint(0, len(total_sub) - 1)
self.current_address = str(self.treeWidget.item(self.rand_value, 1).text())
self.treeWidget.setCurrentCell(self.rand_value, 1)
self.treeWidget.item(self.rand_value, 1).setSelected(True)
rect = self.treeWidget.visualItemRect(self.treeWidget.item(self.rand_value, 1))
QTest.qWait(500)
self.myapp.on_context_menuAddressBook(QtCore.QPoint(rect.x() + 160, rect.y() + 200))
QTest.qWait(500)
if len(total_sub) > 0:
self.treeWidget.item(random.randint(0, self.rand_value), 1)
else:
print("No Address Found.")
self.add_new_address()
self.myapp.popMenuAddressBook.hide()
self.send_message_to_this_add()
self.copy_clipboard()
self.subscribe_to_this_address()
self.delete_addressbook()
return 1
except:
print("Test Fail:--> PopUpMenu Send Tab Functionality failed")
return 0
def add_new_address(self):
"""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.dialog = dialogs.AddAddressDialog(self.myapp)
self.dialog.show()
QTest.qWait(500)
self.dialog.lineEditLabel.setText("".join(choice(ascii_lowercase) for _ in range(15)))
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)
QTest.qWait(500)
try:
address, label = self.dialog.data
except:
print("Test Fail:--> Could Not able to add new address")
return 0
if shared.isAddressInMyAddressBook(address):
print(
" Test :--> You cannot add the same address to your address book twice."
" Try renaming the existing one if you want. \n"
)
self.myapp.updateStatusBar(
_translate(
"MainWindow",
"Error: You cannot add the same address to your adrress book twice."
" Try renaming the existing one if you want.",
)
)
return 0
self.myapp.addEntryToAddressBook(address, label)
print("Test Pass:--> Address Added to the Address Book!")
return 1
except:
print("Test Fail:--> Could Not able to add new address")
return 0
def send_message_to_this_add(self):
"""Test - Send Message to this Address"""
print("=====================Test - Send Message to this Address=====================")
try:
self.popup_menu(0)
if BMConfigParser().addresses():
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
inbox_length = len(sqlQuery("Select msgid from inbox"))
QTest.qWait(500)
self.myapp.popMenuAddressBook.actions()[0].trigger()
QTest.qWait(500)
random_subject = ""
for x in range(30):
random_subject += choice(ascii_lowercase)
self.myapp.ui.lineEditSubject.setText(random_subject)
QTest.qWait(4)
QTest.qWait(500)
random_message = ""
for x in range(150):
random_message += choice(ascii_lowercase)
self.myapp.ui.textEditMessage.setText(random_message)
QTest.qWait(1)
QTest.qWait(500)
randinteger = random.randrange(1, len(BMConfigParser().addresses()) + 1)
self.myapp.ui.comboBoxSendFrom.setCurrentIndex(randinteger)
QTest.qWait(500)
QTest.mouseClick(self.myapp.ui.pushButtonSend, Qt.LeftButton)
QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
print(" Waiting For Message .......................... ")
for x in range(5):
QTest.qWait(4000)
print(" waiting " + x * ".")
new_inbox = sqlQuery("Select msgid,toaddress,subject from inbox")
self.assertEqual(new_inbox[-1][2], random_subject)
if len(sqlQuery("Select msgid from inbox")) == inbox_length + 1:
print("Test Pass:--> Message Received Successfully")
return 1
else:
print("Test Fail:--> Doesn't Receive Any Message")
return 0
else:
print("Test Fail:--> No Address Found")
return 0
except:
print("Test Fail:--> Message Sending Test Fail")
return 0
def copy_clipboard(self):
"""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.current_address = str(self.treeWidget.item(random.randint(0, self.rand_value), 1).text())
QTest.qWait(500)
self.myapp.popMenuAddressBook.actions()[1].trigger()
QTest.qWait(1000)
if str(QtGui.QApplication.clipboard().text()) in self.current_address:
print("Test Pass:--> Copy functionality working fine")
return 1
else:
print("Test Fail:--> Copy functionality failed")
return 0
except:
print("Test Fail:--> Copy functionality failed")
return 0
def subscribe_to_this_address(self):
"""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.treeWidget.setCurrentCell(self.rand_value, 1)
QTest.qWait(500)
self.myapp.popMenuAddressBook.actions()[2].trigger()
QTest.qWait(750)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
subscription_list = sqlQuery("SELECT address FROM subscriptions")
if self.current_address in subscription_list:
print(
"Test Fail:-->" + "Subscribe to this functionality failed"
" because address is alreay added in the subscription list\n"
)
return 0
else:
print("Test Pass:--> Subscribe to this functionality working fine")
return 1
except:
print("Test Fail:--> Subscribe to this Address failed")
return 0
def delete_addressbook(self):
"""Delete Address from the Address Book"""
print("=====================Test - Delete Address from the Address Book=====================")
try:
self.popup_menu(7)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.send)
self.treeWidget.setCurrentCell(self.rand_value, 1)
self.myapp.on_action_AddressBookDelete()
QTest.qWait(500)
addressbook_list = sqlQuery("SELECT address FROM addressbook")
if self.current_address not in addressbook_list:
print("Test Pass:--> Address is Deleted from the AddressBook")
return 1
else:
print("Test Fail:--> Could not able to Delete this address")
return 0
except:
print("Test Fail:--> Could Not Able to Delete this Address from the AddressBook")
return 0
def popup_menu(self, intval):
QTest.qWait(5)
self.myapp.popMenuAddressBook.setActiveAction(self.myapp.popMenuAddressBook.actions()[intval])
self.myapp.popMenuAddressBook.setStyleSheet("QMenu:selected {background-color:#FF5733}")
self.myapp.popMenuAddressBook.show()
QTest.qWait(400)
self.myapp.popMenuAddressBook.hide()
QTest.qWait(50)
class BitmessageTest_Subscription_PopMenu(BitmessageTestCase):
"""Subscription TabWidget QTreeWidget popMenu Fucntionality testing"""
def test_sider(self):
try:
QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
QTest.qWait(500)
self.treeWidget = self.myapp.ui.treeWidgetSubscriptions
total_sub = sqlQuery("Select address from subscriptions")
self.levelitem = self.treeWidget.topLevelItem(random.randint(0, len(total_sub) - 1))
self.treeWidget.setCurrentItem(self.levelitem)
rect = self.treeWidget.visualItemRect(self.levelitem)
self.currentItem = self.myapp.getCurrentItem()
self.myapp.on_context_menuSubscriptions(QtCore.QPoint(rect.x() + 160, rect.y() + 200))
QTest.qWait(500)
self.myapp.popMenuSubscriptions.hide()
self.new_subscribe()
self.enable_disable()
self.copy_clipboard()
self.send_message_to_this_add()
self.mark_all_as_read()
self.del_address_from_sub()
return 1
except:
print("Test Fail:--> Subscription Tab PopUpMenu Functionality failed")
return 0
def new_subscribe(self):
print("=====================Test - Subscribe to New Address=====================")
try:
if BMConfigParser().addresses():
self.popup_menu(0)
dialog = dialogs.NewSubscriptionDialog(self.myapp)
QTest.qWait(500)
dialog.lineEditLabel.setText("")
dialog.lineEditAddress.setText("")
dialog.show()
QTest.qWait(500)
random_label = ""
for _ in range(30):
random_label += choice(ascii_lowercase)
dialog.lineEditLabel.setText(random_label)
QTest.qWait(5)
QTest.qWait(500)
rand_address = choice(BMConfigParser().addresses())
random_address = ""
for x in range(len(rand_address)):
random_address += rand_address[x]
dialog.lineEditAddress.setText(random_address)
QTest.qWait(5)
QtCore.QTimer.singleShot(0, dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked)
QTest.qWait(500)
try:
address, label = dialog.data
except AttributeError:
print("Test Fail:--> Could Not able to add new address to subscription list")
return 0
if shared.isAddressInMySubscriptionsList(address):
print(
"MainWindow",
"Error: You cannot add the same address to your subscriptions twice."
" Perhaps rename the existing one if you want.",
)
self.myapp.updateStatusBar(
_translate(
"MainWindow",
"Error: You cannot add the same address to your subscriptions twice."
" Perhaps rename the existing one if you want.",
)
)
return 0
self.myapp.addSubscription(address, label)
print("Test Pass:--> Address Added to subscription list")
if dialog.checkBoxDisplayMessagesAlreadyInInventory.isChecked():
for value in dialog.recent:
queues.objectProcessorQueue.put((value.type, value.payload))
return 1
else:
print("Test Fail:--> No address found")
return 0
except:
print("Test Fail:--> New Subscription Functionality Failed")
return 0
def enable_disable(self):
"""Enable address and disable address"""
print("=====================Test - Address Enable-Disable Functionality=====================")
QTest.qWait(500)
try:
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
self.treeWidget.setCurrentItem(self.levelitem)
self.popup_menu(3)
if self.currentItem.isEnabled:
QTest.qWait(500)
self.myapp.popMenuSubscriptions.actions()[3].trigger()
QTest.qWait(1000)
self.myapp.on_action_Enable()
QTest.qWait(500)
else:
QTest.qWait(500)
self.myapp.popMenuSubscriptions.actions()[3].trigger()
QTest.qWait(1000)
self.myapp.on_action_Disable()
QTest.qWait(500)
print("Test Pass:--> Enable Disable Working well")
return 0
except:
print("Test Fail:--> Enable Disable failed")
return 1
def copy_clipboard(self):
"""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)
self.popup_menu(6)
QTest.qWait(500)
self.myapp.popMenuSubscriptions.actions()[6].trigger()
QTest.qWait(1000)
if str(QtGui.QApplication.clipboard().text()) in str(self.currentItem.text(0)):
print("Test Pass:--> Copy functionality working fine")
return 1
else:
print("Test Fail:--> Copy functionality failed")
return 0
except:
print("Test Fail:--> Copy functionality failed")
return 0
def send_message_to_this_add(self):
"""Test - Send Message to this Address"""
print("=====================Test - Send Message to this Address=====================")
try:
self.popup_menu(7)
if BMConfigParser().addresses():
inbox_length = len(sqlQuery("Select msgid from inbox"))
QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
self.treeWidget.setCurrentItem(self.levelitem)
self.myapp.popMenuSubscriptions.actions()[7].trigger()
QTest.qWait(500)
random_subject = ""
for x in range(30):
random_subject += choice(ascii_lowercase)
self.myapp.ui.lineEditSubject.setText(random_subject)
QTest.qWait(4)
QTest.qWait(500)
random_message = ""
for x in range(150):
random_message += choice(ascii_lowercase)
self.myapp.ui.textEditMessage.setText(random_message)
QTest.qWait(1)
QTest.qWait(500)
randinteger = random.randrange(1, len(BMConfigParser().addresses()) + 1)
self.myapp.ui.comboBoxSendFrom.setCurrentIndex(randinteger)
QTest.qWait(500)
QTest.mouseClick(self.myapp.ui.pushButtonSend, Qt.LeftButton)
QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
print(" Waiting For Message .......................... ")
for x in range(5):
QTest.qWait(4000)
print(" waiting " + x * ".")
new_inbox = sqlQuery("Select msgid,toaddress,subject from inbox")
self.assertEqual(new_inbox[-1][2], random_subject)
if len(sqlQuery("Select msgid from inbox")) == inbox_length + 1:
print("Test Pass:--> Message Received Successfully")
return 1
else:
print("Test Fail:--> Doesn't Receive Any Message")
return 0
else:
print("Test Fail:--> No Address Found")
return 0
except:
print("Test Fail:--> Message Sending Test Fail")
return 0
def mark_all_as_read(self):
"""Mark all messages as read"""
print("=====================Test - Mark All as Read Functionality=====================")
try:
self.popup_menu(8)
QTest.qWait(550)
self.myapp.popMenuSubscriptions.actions()[8].trigger()
QTest.qWait(750)
print("Test Pass:--> Mark All as Read Functionality Passed")
return 1
except:
print("Test Fail:--> Mark All as Read Functionality failed")
return 0
def del_address_from_sub(self):
print("=====================Test - Delete Address from the subscription Field=====================")
try:
self.popup_menu(1)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.subscriptions)
self.treeWidget.setCurrentItem(self.levelitem)
address = self.myapp.getCurrentAccount()
QTest.qWait(750)
sqlExecute("""DELETE FROM subscriptions WHERE address=?""", address)
self.myapp.rerenderTabTreeSubscriptions()
self.myapp.rerenderMessagelistFromLabels()
self.myapp.rerenderAddressBook()
shared.reloadBroadcastSendersForWhichImWatching()
addressbook_list = sqlQuery("SELECT address FROM subscriptions")
if address not in addressbook_list:
print("Test Pass:--> Address is Deleted from the AddressBook")
return 1
else:
print("Test Fail:--> Could not able to Delete this address")
return 0
except:
print("Test Fail:--> Could Not Able to Delete this Address from the AddressBook")
return 0
def popup_menu(self, intval):
QTest.qWait(5)
self.myapp.popMenuSubscriptions.setActiveAction(self.myapp.popMenuSubscriptions.actions()[intval])
self.myapp.popMenuSubscriptions.setStyleSheet("QMenu:selected {background-color:#FF5733}")
self.myapp.popMenuSubscriptions.show()
QTest.qWait(400)
self.myapp.popMenuSubscriptions.hide()
QTest.qWait(50)
class BitmessageTest_BlackWhiteList_PopMenu(BitmessageTestCase):
"""Subscription TabWidget QTreeWidget popMenu Fucntionality testing"""
def test_sider(self):
total_bl = sqlQuery("Select address from blacklist")
if total_bl > 0:
QTest.qWait(500)
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.blackwhitelist)
self.tableWidget = self.myapp.ui.blackwhitelist.tableWidgetBlacklist
QTest.qWait(500)
self.rand_value = random.randint(0, len(total_bl) - 1)
self.current_address = str(self.tableWidget.item(self.rand_value, 1).text())
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 = blacklist.Blacklist()
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.add_delete()
else:
print("Test Fail:--> No black list Found")
return 0

View File

@ -20,6 +20,7 @@ class BitmessageTest_QuitTest(BitmessageTestCase):
def test_quitapplication(self): def test_quitapplication(self):
"""wait for pow and shutdown the application""" """wait for pow and shutdown the application"""
print("=====================Test - Quitting Application=====================")
if self.myapp.quitAccepted and not self.myapp.wait: if self.myapp.quitAccepted and not self.myapp.wait:
return return

View File

@ -16,22 +16,25 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
def test_settingwindow(self): def test_settingwindow(self):
"""Triggers the setting window""" """Triggers the setting window"""
self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox) print("=====================Test - Setting Window=====================")
QTest.qWait(1500) try:
dialog = dialogs.SettingsDialog(self.myapp, firstrun=self.myapp._firstrun) self.myapp.ui.tabWidget.setCurrentWidget(self.myapp.ui.inbox)
self.language_change(dialog) QTest.qWait(1500)
QTest.qWait(300) dialog = dialogs.SettingsDialog(self.myapp, firstrun=self.myapp._firstrun)
self.eng_convert(dialog) self.language_change(dialog)
QTest.qWait(300) self.eng_convert(dialog)
self.network_setting_window(dialog) self.network_setting_window(dialog)
QTest.qWait(300) self.tabresendsexpire_window(dialog)
self.tabresendsexpire_window(dialog) return 1
QTest.qWait(300) except:
print("Test Fail:-->Setting Window functionality failed")
return 0
def language_change(self, dialog): def language_change(self, dialog):
"""Function that changes the language of the application""" """Function that changes the language of the application"""
print("=====================Test - Language Change=====================")
try: try:
"""Change language""" QTest.qWait(500)
dialog.show() dialog.show()
dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface)) dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface))
QTest.qWait(800) QTest.qWait(800)
@ -42,17 +45,17 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
QTest.qWait(1000) QTest.qWait(1000)
ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok) ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
QTest.mouseClick(ok_btn, Qt.LeftButton) QTest.mouseClick(ok_btn, Qt.LeftButton)
print("\n Test Pass :--> Language Changed Successfully \n") print("Test Pass:--> Language Changed Successfully")
self.assertTrue(True, " \n Test Pass :--> Language Changed Successfully ")
return 1 return 1
except: except:
print("\n Test Fail :--> Error while changing Language! \n") print("Test Fail:--> Error while changing Language")
self.assertTrue(False, " \n Test Fail :--> Error while changing Language!")
return 0 return 0
def eng_convert(self, dialog): def eng_convert(self, dialog):
"""Convert any language to english, testing just for good readability""" """Convert any language to english, testing just for good readability"""
print("=====================Test - Converting Language Back to English=====================")
try: try:
QTest.qWait(500)
dialog.show() dialog.show()
dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface)) dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabUserInterface))
QTest.qWait(800) QTest.qWait(800)
@ -63,17 +66,17 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
QTest.qWait(1000) QTest.qWait(1000)
ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok) ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
QTest.mouseClick(ok_btn, Qt.LeftButton) QTest.mouseClick(ok_btn, Qt.LeftButton)
print("\n Test Pass :--> language changed to English Again \n") print("Test Pass:--> language changed to English Again")
self.assertTrue(True, " \n Test Pass :--> language changed to English Again ")
return 1 return 1
except: except:
print("\n Test Fail :--> Not able to change the language to English Again! Error! \n") print("Test Fail:--> Not able to change the language to English Again! Error")
self.assertTrue(False, " \n Test Fail :--> Not able to change the language to English Again! Error!")
return 0 return 0
def network_setting_window(self, dialog): def network_setting_window(self, dialog):
"""Test for Network setting window""" """Test for Network setting window"""
print("=====================Test - Network Setting Window=====================")
try: try:
QTest.qWait(500)
dialog.show() dialog.show()
QTest.qWait(300) QTest.qWait(300)
dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabNetworkSettings)) dialog.tabWidgetSettings.setCurrentIndex(dialog.tabWidgetSettings.indexOf(dialog.tabNetworkSettings))
@ -127,17 +130,17 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
QTest.qWait(1200) QTest.qWait(1200)
ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok) ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
QTest.mouseClick(ok_btn, Qt.LeftButton) QTest.mouseClick(ok_btn, Qt.LeftButton)
print("\n Test Pass :--> Successfully tested Network setting window \n") print("Test Pass:--> Successfully tested Network setting window")
self.assertTrue(True, " \n Test Pass :--> Successfully tested Network setting window ")
return 1 return 1
except: except:
print("\n Test Fail :--> Error while testing Network setting window! \n") print("Test Fail:--> Error while testing Network setting window")
self.assertTrue(False, " \n Test Fail :--> Error while testing Network setting window!")
return 0 return 0
def tabresendsexpire_window(self, dialog): def tabresendsexpire_window(self, dialog):
"""Testing for resend expire window""" """Testing for resend expire window"""
print("=====================Test - Tab Resend Expire Window=====================")
try: try:
QTest.qWait(500)
dialog.lineEditDays.setText("") dialog.lineEditDays.setText("")
dialog.lineEditMonths.setText("") dialog.lineEditMonths.setText("")
dialog.show() dialog.show()
@ -152,10 +155,8 @@ class BitmessageTest_SettingWindowTest(BitmessageTestCase):
QTest.qWait(800) QTest.qWait(800)
ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok) ok_btn = dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok)
QTest.mouseClick(ok_btn, Qt.LeftButton) QTest.mouseClick(ok_btn, Qt.LeftButton)
print("\n Test Pass :--> Test successfull. \n") print("Test Pass:--> Test successfull")
self.assertTrue(True, " \n Test Pass :--> Test successfull. ")
return 1 return 1
except: except:
print("\n Test Fail :--> Tab Resend Exprire! \n") print("Test Fail:--> Tab Resend Exprire")
self.assertTrue(False, " \n Test Fail :--> Tab Resend Exprire! ")
return 0 return 0

View File

@ -7,9 +7,9 @@ import test_blackwhitelist
import test_chans import test_chans
import test_messagesend import test_messagesend
import test_networkstatus import test_networkstatus
import test_popupmenu
import test_quit import test_quit
import test_settingwindow import test_settingwindow
import test_inbox_popmenu
from testloader import BitmessageTestCase from testloader import BitmessageTestCase
@ -17,17 +17,31 @@ def test_initialize(myapp):
"""Inititalizing the test cases""" """Inititalizing the test cases"""
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_addressgeneration.BitmessageTest_AddressGeneration, myapp=myapp)) BitmessageTestCase.bitmessage_testloader(test_addressgeneration.BitmessageTest_AddressGeneration, myapp=myapp)
)
suite.addTest( suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_messagesend.BitmessageTest_MessageTesting, myapp=myapp)) BitmessageTestCase.bitmessage_testloader(test_messagesend.BitmessageTest_MessageTesting, myapp=myapp)
)
suite.addTest( suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_addsubscription.BitmessageTest_AddSubscription, myapp=myapp)) BitmessageTestCase.bitmessage_testloader(test_addsubscription.BitmessageTest_AddSubscription, myapp=myapp)
)
suite.addTest(BitmessageTestCase.bitmessage_testloader(test_networkstatus.BitmessageTest_NetworkTest, myapp=myapp)) suite.addTest(BitmessageTestCase.bitmessage_testloader(test_networkstatus.BitmessageTest_NetworkTest, myapp=myapp))
suite.addTest( suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_blackwhitelist.BitmessageTest_BlackandWhiteList, myapp=myapp)) BitmessageTestCase.bitmessage_testloader(test_blackwhitelist.BitmessageTest_BlackandWhiteList, myapp=myapp)
)
suite.addTest(BitmessageTestCase.bitmessage_testloader(test_chans.BitmessageTest_ChansTest, myapp=myapp)) suite.addTest(BitmessageTestCase.bitmessage_testloader(test_chans.BitmessageTest_ChansTest, myapp=myapp))
suite.addTest(BitmessageTestCase.bitmessage_testloader(test_popupmenu.BitmessageTest_Inbox_PopMenu, myapp=myapp))
suite.addTest( suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_settingwindow.BitmessageTest_SettingWindowTest, myapp=myapp)) BitmessageTestCase.bitmessage_testloader(test_popupmenu.BitmessageTest_AddressBox_PopMenu, myapp=myapp)
suite.addTest(BitmessageTestCase.bitmessage_testloader(test_inbox_popmenu.BitmessageTest_Inbox_PopMenu, myapp=myapp)) )
suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_popupmenu.BitmessageTest_Subscription_PopMenu, myapp=myapp)
)
suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_popupmenu.BitmessageTest_BlackWhiteList_PopMenu, myapp=myapp)
)
suite.addTest(
BitmessageTestCase.bitmessage_testloader(test_settingwindow.BitmessageTest_SettingWindowTest, myapp=myapp)
)
suite.addTest(BitmessageTestCase.bitmessage_testloader(test_quit.BitmessageTest_QuitTest, myapp=myapp)) suite.addTest(BitmessageTestCase.bitmessage_testloader(test_quit.BitmessageTest_QuitTest, myapp=myapp))
unittest.TextTestRunner().run(suite) unittest.TextTestRunner().run(suite)

View File

@ -2,11 +2,11 @@ import os
import shutil import shutil
if __name__ == "__main__": if __name__ == "__main__":
APPNAME = "PyBitmessage" # APPNAME = "PyBitmessage"
if os.path.isdir(os.path.expanduser(os.path.join("~", ".config/" + APPNAME + "/"))): # if os.path.isdir(os.path.expanduser(os.path.join("~", ".config/" + APPNAME + "/"))):
shutil.rmtree(os.path.expanduser(os.path.join("~", ".config/" + APPNAME + "/"))) # shutil.rmtree(os.path.expanduser(os.path.join("~", ".config/" + APPNAME + "/")))
else: # else:
pass # pass
import state import state
state.qttesting = True state.qttesting = True
print(" --------------------------------- Graphical Qt Testing --------------------------------- ") print(" --------------------------------- Graphical Qt Testing --------------------------------- ")