diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 6922ad56..3904e24e 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -251,10 +251,6 @@ class NavigateApp(MDApp): kivyuisignaler.release() super(NavigateApp, self).run() - @staticmethod - def clickNavDrawer(): - state.kivyapp.root.ids.nav_drawer.set_state('toggle') - @staticmethod def showmeaddresses(name="text"): """Show the addresses in spinner to make as dropdown""" diff --git a/src/bitmessagekivy/tests/sampleData (copy)/keys.dat b/src/bitmessagekivy/tests/sampleData (copy)/keys.dat new file mode 100644 index 00000000..940b3e14 --- /dev/null +++ b/src/bitmessagekivy/tests/sampleData (copy)/keys.dat @@ -0,0 +1,59 @@ +[bitmessagesettings] +settingsversion = 0 +port = 8444 +timeformat = %%c +blackwhitelist = black +startonlogon = false +minimizetotray = false +showtraynotifications = true +startintray = false +socksproxytype = none +sockshostname = localhost +socksport = 9050 +socksauthentication = false +socksusername = +sockspassword = +keysencrypted = false +messagesencrypted = false +defaultnoncetrialsperbyte = 1000 +defaultpayloadlengthextrabytes = 1000 +minimizeonclose = false +replybelow = False +maxdownloadrate = 0 +maxuploadrate = 0 +stopresendingafterxdays = +stopresendingafterxmonths = +sockslisten = false +userlocale = system +sendoutgoingconnections = True +useidenticons = True +identiconsuffix = qcqQGW6sQtZK +maxacceptablenoncetrialsperbyte = 20000000000 +maxacceptablepayloadlengthextrabytes = 20000000000 +onionhostname = +onionport = 8444 +onionbindip = 127.0.0.1 +smtpdeliver = +hidetrayconnectionnotifications = false +ttl = 367200 + +[BM-2cTpgCn57rYUgqm5BrgmykuV9gK1Ak1THF] +label = test1 +enabled = true +decoy = false +noncetrialsperbyte = 1000 +payloadlengthextrabytes = 1000 +privsigningkey = 5KYCPJ4Vp31UD6k5NWmDKtHhfapW25UJ7V2MjctYxcgL3BpWGA3 +privencryptionkey = 5JLER8q2zyj3KDEgGMv682en2SRUkkWWhUrNuqVYfGNNhHJmdkJ +lastpubkeysendtime = 1623160189 + +[BM-2cVrdzQjCQRqUuET6dc3byVyRTjZcgcJXj] +label = test2 +enabled = true +decoy = false +noncetrialsperbyte = 1000 +payloadlengthextrabytes = 1000 +privsigningkey = 5KhryWvNowFWWA9JRjQnLVStYKwhpKpAG4RtWwzyaQqmK2fTMue +privencryptionkey = 5JKQ9NqX2LRzHBCgyxc1GAL3rDvyDTHPifpL22a6UNN7K6y9BmL +lastpubkeysendtime = 1623160221 + diff --git a/src/bitmessagekivy/tests/sampleData (copy)/knownnodes.dat b/src/bitmessagekivy/tests/sampleData (copy)/knownnodes.dat new file mode 100644 index 00000000..41ba8a28 --- /dev/null +++ b/src/bitmessagekivy/tests/sampleData (copy)/knownnodes.dat @@ -0,0 +1,110 @@ +[ + { + "stream": 1, + "peer": { + "host": "5.45.99.75", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "75.167.159.54", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "95.165.168.168", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "85.180.139.241", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "158.222.217.190", + "port": 8080 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "178.62.12.187", + "port": 8448 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "24.188.198.204", + "port": 8111 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "109.147.204.113", + "port": 1195 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + }, + { + "stream": 1, + "peer": { + "host": "178.11.46.221", + "port": 8444 + }, + "info": { + "lastseen": 1620741290.255359, + "rating": 0, + "self": false + } + } +] \ No newline at end of file diff --git a/src/bitmessagekivy/tests/sampleData (copy)/messages.dat b/src/bitmessagekivy/tests/sampleData (copy)/messages.dat new file mode 100644 index 00000000..ad9aae5f Binary files /dev/null and b/src/bitmessagekivy/tests/sampleData (copy)/messages.dat differ diff --git a/src/bitmessagekivy/tests/sampleData (copy)/singleton.lock b/src/bitmessagekivy/tests/sampleData (copy)/singleton.lock new file mode 100644 index 00000000..97ee3ea3 --- /dev/null +++ b/src/bitmessagekivy/tests/sampleData (copy)/singleton.lock @@ -0,0 +1 @@ +16342 diff --git a/src/bitmessagekivy/tests/test_addressbook.py b/src/bitmessagekivy/tests/test_addressbook.py index 20be1c0a..a62fd4f7 100644 --- a/src/bitmessagekivy/tests/test_addressbook.py +++ b/src/bitmessagekivy/tests/test_addressbook.py @@ -15,11 +15,12 @@ class AddressBook(TeleniumTestProcess): """Save Address On Address Book Screen/Window""" print("=====================Test -Save Address In Address Book=====================") self.cli.sleep(6) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(4) self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.cli.sleep(3) self.cli.click_on('//NavigationItem[6]') + self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=0) self.cli.sleep(4) self.cli.execute('app.addingtoaddressbook()') self.cli.sleep(3) @@ -53,6 +54,8 @@ class AddressBook(TeleniumTestProcess): self.cli.sleep(3) self.cli.click_on('//MDRaisedButton[0]') self.cli.sleep(4) + address_book_msgs = len(self.cli.select("//SwipeToDeleteItem")) + self.assertEqual(address_book_msgs, 1) @ordered def test_cancel_addressbook_popup(self): @@ -66,6 +69,7 @@ class AddressBook(TeleniumTestProcess): self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[1]', 'text', data[0]) self.cli.sleep(3) self.cli.click_on('//MDRaisedButton[1]') + self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=1) @ordered def test_send_message_to_addressbook(self): @@ -76,6 +80,7 @@ class AddressBook(TeleniumTestProcess): '//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/SwipeToDeleteItem[0]') self.cli.sleep(3) self.cli.click_on('//MDRaisedButton[0]') + self.assertExists("//Create[@name~=\"create\"]", timeout=1) self.cli.sleep(3) self.cli.click_on( '//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]') @@ -91,16 +96,18 @@ class AddressBook(TeleniumTestProcess): '//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]', 'text', random_label) self.cli.sleep(0.2) self.cli.click_on('//MDActionTopAppBarButton[2]') - self.cli.sleep(2) + self.cli.sleep(4) + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=1) @ordered def test_delete_address_from_address_contact(self): """Delete Address From Address Book""" print("=====================Test -Delete Address From Address Book=====================") - self.cli.sleep(3) - self.cli.execute('app.clickNavDrawer()') + self.cli.sleep(2) + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(3) self.cli.click_on('//NavigationItem[6]') + self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=1) self.cli.sleep(3) self.cli.drag( '//MDList[0]/SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', @@ -108,4 +115,4 @@ class AddressBook(TeleniumTestProcess): self.cli.click_on('//MDList[0]/SwipeToDeleteItem[0]') self.cli.sleep(2) self.cli.click_on('//MDList[0]/SwipeToDeleteItem[0]//MDIconButton[0]') - self.cli.sleep(2) + self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2) diff --git a/src/bitmessagekivy/tests/test_allmail_message.py b/src/bitmessagekivy/tests/test_allmail_message.py index 0c34e474..9e0f4371 100644 --- a/src/bitmessagekivy/tests/test_allmail_message.py +++ b/src/bitmessagekivy/tests/test_allmail_message.py @@ -10,10 +10,11 @@ class AllMailMessage(TeleniumTestProcess): """Show All Messages on Mail Screen/Window""" print("=====================Test -Show Messages Of Mail Screen=====================") self.cli.sleep(5) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(4) self.cli.click_on('//NavigationItem[5]') self.cli.sleep(4) + self.assertExists("//Allmails[@name~=\"allmails\"]", timeout=2) @ordered def test_delete_message_from_allmail_list(self): @@ -22,6 +23,8 @@ class AllMailMessage(TeleniumTestProcess): self.cli.sleep(4) self.cli.click_on( '//Allmails[0]/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/CutsomSwipeToDeleteItem[0]') + self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=0) self.cli.sleep(5) self.cli.click_on('//MDToolbar/BoxLayout[2]/MDActionTopAppBarButton[1]') self.cli.sleep(5) + self.assertExists("//Allmails[@name~=\"allmails\"]", timeout=0) diff --git a/src/bitmessagekivy/tests/test_create_random_address.py b/src/bitmessagekivy/tests/test_create_random_address.py index 995a955a..f51ba188 100644 --- a/src/bitmessagekivy/tests/test_create_random_address.py +++ b/src/bitmessagekivy/tests/test_create_random_address.py @@ -21,9 +21,11 @@ class CreateRandomAddress(TeleniumTestProcess): """Clicking on Proceed Button to Proceed to Next Screen.""" print("=====================Test - Login Screen=====================") self.cli.sleep(3) + self.assertExists("//Login[@name~=\"login\"]", timeout=1) self.cli.wait_click( '//ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]') self.cli.sleep(3) + self.assertExists("//Random[@name~=\"random\"]", timeout=1) @ordered def test_random_screen(self): @@ -43,21 +45,25 @@ class CreateRandomAddress(TeleniumTestProcess): self.cli.sleep(1) self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[2]/MDFillRoundFlatIconButton[0]') self.cli.sleep(5) + self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=3) @ordered def test_create_new_address(self): """Clicking on Navigation Drawer To Open New Address""" print("=====================Test - Create New Address=====================") self.cli.sleep(5) - self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")') + # self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(2) self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.cli.sleep(3) self.cli.click_on('//NavigationItem[9]') + self.assertExists("//Login[@name~=\"login\"]", timeout=1) self.cli.sleep(4) self.cli.wait_click( '''//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]''' '''/MDFillRoundFlatIconButton[0]''') + self.assertExists("//Random[@name~=\"random\"]", timeout=1) self.test_random_screen() @ordered @@ -66,7 +72,7 @@ class CreateRandomAddress(TeleniumTestProcess): print("=====================Test - Select First Address From Drawer-Box=======================") self.cli.sleep(3) # self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")') - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(2) self.cli.drag("//NavigationItem[@text=\"Address Book\"]", "//NavigationItem[@text=\"Settings\"]", 1) self.cli.sleep(2) @@ -74,3 +80,4 @@ class CreateRandomAddress(TeleniumTestProcess): self.cli.sleep(2) self.cli.click_on('//MySpinnerOption[0]') self.cli.sleep(3) + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=1) diff --git a/src/bitmessagekivy/tests/test_draft_message.py b/src/bitmessagekivy/tests/test_draft_message.py index 4e4467e9..3de659e3 100644 --- a/src/bitmessagekivy/tests/test_draft_message.py +++ b/src/bitmessagekivy/tests/test_draft_message.py @@ -12,13 +12,15 @@ class DraftMessage(TeleniumTestProcess): print("=====================Test - Select A Draft Screen From Navigaion-Drawer-Box=====================") # OPEN NAVIGATION-DRAWER self.cli.sleep(4) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(2) # OPEN INBOX SCREEN self.cli.click_on('//NavigationItem[1]') + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2) self.cli.sleep(2) # CLICK ON PLUS ICON BUTTON self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]') + self.assertExists("//Create[@name~=\"create\"]", timeout=2) self.cli.sleep(3) # SELECT - TO ADDRESS self.cli.click_on( @@ -32,8 +34,10 @@ class DraftMessage(TeleniumTestProcess): self.cli.sleep(3) # CLICK BACK-BUTTON self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2) self.cli.sleep(5) self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]') + self.assertExists("//Create[@name~=\"create\"]", timeout=2) self.cli.sleep(3) # SELECT - TO ADDRESS self.cli.click_on( @@ -53,6 +57,7 @@ class DraftMessage(TeleniumTestProcess): # CLICK BACK-BUTTON self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(4) + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=1) @ordered def test_edit_and_resend_draft_messgae(self): @@ -60,17 +65,20 @@ class DraftMessage(TeleniumTestProcess): make changes and send it.""" print("=====================Test - Edit A Message From Draft Screen=====================") # OPEN NAVIGATION-DRAWER - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(4) # OPEN DRAFT SCREEN self.cli.click_on('//NavigationItem[3]') + self.assertExists("//Draft[@name~=\"draft\"]", timeout=2) self.cli.sleep(4) # SHOW DRAFT MESSAGE AND SELECT FIRST MESSAGE # self.cli.click_on('//Carousel[0]//TwoLineAvatarIconListItem[0]') self.cli.click_on('//SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]') + self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=2) self.cli.sleep(3) # CLICK EDIT BUTTON self.cli.click_on('//MDToolbar/BoxLayout[2]/MDActionTopAppBarButton[0]') + self.assertExists("//Create[@name~=\"create\"]", timeout=2) self.cli.sleep(5) random_label = "" for char in "Hey,This is draft Message Body": @@ -80,7 +88,8 @@ class DraftMessage(TeleniumTestProcess): self.cli.sleep(0.2) self.cli.sleep(3) self.cli.click_on('//MDActionTopAppBarButton[2]') - self.cli.sleep(5) + # self.cli.sleep(5) + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5) @ordered def test_delete_draft_message(self): @@ -88,12 +97,15 @@ class DraftMessage(TeleniumTestProcess): print("=====================Test - Delete A Message From List of Messages=====================") self.cli.sleep(5) # self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")') - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(4) self.cli.click_on('//NavigationItem[3]') + self.assertExists("//Draft[@name~=\"draft\"]", timeout=1) self.cli.sleep(5) self.cli.click_on('//SwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]') + self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=2) # self.cli.click_on('//Carousel[0]//TwoLineAvatarIconListItem[0]') self.cli.sleep(5) self.cli.click_on('//MDToolbar/BoxLayout[2]/MDActionTopAppBarButton[1]') self.cli.sleep(5) + self.assertExists("//Draft[@name~=\"draft\"]", timeout=1) diff --git a/src/bitmessagekivy/tests/test_myaddress_screen.py b/src/bitmessagekivy/tests/test_myaddress_screen.py index c017b763..4019ca98 100644 --- a/src/bitmessagekivy/tests/test_myaddress_screen.py +++ b/src/bitmessagekivy/tests/test_myaddress_screen.py @@ -15,12 +15,13 @@ class MyAddressScreen(TeleniumTestProcess): """Select Address From List of Address""" print("=====================Test -Select Address From List of Address=====================") self.cli.sleep(4) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(3) self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.cli.sleep(3) self.cli.click_on('//NavigationItem[11]') self.cli.sleep(4) + self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) @ordered def test_show_Qrcode(self): @@ -32,9 +33,11 @@ class MyAddressScreen(TeleniumTestProcess): '''CustomTwoLineAvatarIconListItem[0]''') self.cli.sleep(3) self.cli.click_on('//MyaddDetailPopup/BoxLayout[1]/MDRaisedButton[1]/MDLabel[0]') + self.assertExists("//ShowQRCode[@name~=\"showqrcode\"]", timeout=2) self.cli.sleep(3) self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(3) + self.assertExists("//MyAddress[@name~=\"myaddress\"]", timeout=2) @ordered def test_send_message_from(self): @@ -46,6 +49,7 @@ class MyAddressScreen(TeleniumTestProcess): '''CustomTwoLineAvatarIconListItem[0]''') self.cli.sleep(4) self.cli.click_on('//MyaddDetailPopup/BoxLayout[1]/MDRaisedButton[0]/MDLabel[0]') + self.assertExists("//Create[@name~=\"create\"]", timeout=2) self.cli.sleep(3) self.cli.setattr( '//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput', "text", data[1]) @@ -61,3 +65,5 @@ class MyAddressScreen(TeleniumTestProcess): self.cli.sleep(2) self.cli.click_on('//MDActionTopAppBarButton[2]') self.cli.sleep(4) + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2) + diff --git a/src/bitmessagekivy/tests/test_network_screen.py b/src/bitmessagekivy/tests/test_network_screen.py index 6eb921cf..476ad161 100644 --- a/src/bitmessagekivy/tests/test_network_screen.py +++ b/src/bitmessagekivy/tests/test_network_screen.py @@ -8,7 +8,7 @@ class NetwrokStatusScreen(TeleniumTestProcess): """Show NetwrokStatus""" print("=====================Test -Show NetwrokStatus=====================") self.cli.sleep(4) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(3) self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.cli.sleep(3) @@ -16,3 +16,4 @@ class NetwrokStatusScreen(TeleniumTestProcess): self.cli.sleep(4) self.cli.click_on('//NetworkStat/MDTabs[0]/MDTabsBar[0]/MDTabsScrollView[0]/MDGridLayout[0]/MDTabsLabel[1]') self.cli.sleep(4) + self.assertExists("//NetworkStat[@name~=\"networkstat\"]", timeout=2) diff --git a/src/bitmessagekivy/tests/test_payment_subscription.py b/src/bitmessagekivy/tests/test_payment_subscription.py index 165e53cd..36a88bef 100644 --- a/src/bitmessagekivy/tests/test_payment_subscription.py +++ b/src/bitmessagekivy/tests/test_payment_subscription.py @@ -8,11 +8,12 @@ class PaymentScreen(TeleniumTestProcess): """Select Subscripton From List of Subscriptons""" print("=====================Test -Select Subscripton From List of Subscriptons=====================") self.cli.sleep(4) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(3) self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.cli.sleep(3) self.cli.click_on('//NavigationItem[8]') + self.assertExists("//Payment[@name~=\"payment\"]", timeout=2) self.cli.sleep(3) self.cli.drag( '//Payment/BoxLayout[0]/ScrollView[0]/BoxLayout[0]/ProductCategoryLayout[0]/ProductLayout[1]', @@ -24,3 +25,5 @@ class PaymentScreen(TeleniumTestProcess): self.cli.sleep(2) self.cli.click_on('//MDRaisedButton[3]') self.cli.sleep(2) + self.assertExists("//Payment[@name~=\"payment\"]", timeout=2) + diff --git a/src/bitmessagekivy/tests/test_sent_message.py b/src/bitmessagekivy/tests/test_sent_message.py index d15c1809..a4227ea1 100644 --- a/src/bitmessagekivy/tests/test_sent_message.py +++ b/src/bitmessagekivy/tests/test_sent_message.py @@ -19,11 +19,13 @@ class SendMessage(TeleniumTestProcess): print("=======Test - Sending Message From Inbox Screen with validation Checks=======") self.cli.sleep(3) # self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")') - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(2) self.cli.click_on('//NavigationItem[1]') + self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2) self.cli.sleep(2) self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]') + self.assertExists("//Create[@name~=\"create\"]", timeout=2) self.cli.sleep(3) self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/MyMDTextField[0]') self.cli.sleep(3) @@ -67,42 +69,9 @@ class SendMessage(TeleniumTestProcess): self.cli.sleep(3) self.cli.click_on('//MDActionTopAppBarButton[2]') self.cli.sleep(3) - - @ordered - def test_sent_multiple_messages(self): - """ - Sending Second Message From Inbox Screen - for testing the search and delete functionality for two messages on the screen - """ - print("=====================Test - Sending Message From Inbox Screen=====================") - self.cli.sleep(3) - # self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")') - self.cli.execute('app.clickNavDrawer()') - self.cli.sleep(5) - self.cli.click_on('//NavigationItem[1]') - self.cli.sleep(3) - self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]') - self.cli.sleep(3) - self.cli.click_on( - '//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]') - self.cli.sleep(2) - self.cli.click_on('//MyTextInput[0]') - self.cli.sleep(3) - self.cli.setattr( - '//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text", data[0]) - self.cli.sleep(3) - self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Second') - self.cli.sleep(3) - random_label = "" - for char in "Hey This Is Second Message Body": - random_label += char - self.cli.setattr( - '//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]', "text", random_label) - self.cli.sleep(0.2) - self.cli.sleep(2) - self.cli.click_on('//MDActionTopAppBarButton[2]') - self.cli.sleep(5) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(3) self.cli.click_on('//NavigationItem[2]') self.cli.sleep(3) + total_sent_msgs = len(self.cli.select("//SwipeToDeleteItem")) + self.assertEqual(total_sent_msgs, 2) diff --git a/src/bitmessagekivy/tests/test_setting_screen.py b/src/bitmessagekivy/tests/test_setting_screen.py index b6d9933a..0ee029b6 100644 --- a/src/bitmessagekivy/tests/test_setting_screen.py +++ b/src/bitmessagekivy/tests/test_setting_screen.py @@ -8,9 +8,11 @@ class SettingScreen(TeleniumTestProcess): """Show Setting Screen""" print("=====================Test -Show Setting Screen=====================") self.cli.sleep(3) - self.cli.execute('app.clickNavDrawer()') + # self.cli.wait_click("//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]", timeout=20) + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(3) self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.cli.sleep(3) self.cli.click_on('//NavigationItem[7]') - self.cli.sleep(4) + self.cli.sleep(2) + self.assertExists("//Setting[@name~=\"set\"]", timeout=2) diff --git a/src/bitmessagekivy/tests/test_trash_message.py b/src/bitmessagekivy/tests/test_trash_message.py index 05371acf..f7021330 100644 --- a/src/bitmessagekivy/tests/test_trash_message.py +++ b/src/bitmessagekivy/tests/test_trash_message.py @@ -8,9 +8,10 @@ class TrashMessage(TeleniumTestProcess): """Delete Trash message permanently from trash message listing""" print("=====================Test -Delete Message From Trash Message Listing=====================") self.cli.sleep(4) - self.cli.execute('app.clickNavDrawer()') + self.cli.click_on('//MDToolbar/BoxLayout[0]/MDActionTopAppBarButton[0]') self.cli.sleep(4) self.cli.click_on('//NavigationItem[4]') + self.assertExists("//Trash[@name~=\"trash\"]", timeout=2) self.cli.sleep(4) self.cli.drag( '//MDList[0]/CutsomSwipeToDeleteItem[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', @@ -21,4 +22,6 @@ class TrashMessage(TeleniumTestProcess): self.cli.sleep(2) self.cli.click_on('//MDDialog/MDCard[0]/AnchorLayout[0]/MDBoxLayout[0]/MDFlatButton[0]') # self.cli.click_on('//MDDialog/DialogFakeCard[0]/AnchorLayout[0]/MDBoxLayout[0]/MDFlatButton[0]') - self.cli.sleep(4) + self.cli.sleep(2) + total_trash_msgs = len(self.cli.select("//CutsomSwipeToDeleteItem")) + self.assertEqual(total_trash_msgs, 1) diff --git a/src/mock/__init__.py b/src/mock/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/mock/class_addressGenerator.py b/src/mock/class_addressGenerator.py new file mode 100644 index 00000000..5d6b0351 --- /dev/null +++ b/src/mock/class_addressGenerator.py @@ -0,0 +1,93 @@ +""" +A thread for creating addresses +""" +# import queues +try: + import queue as Queue +except ImportError: + import Queue + +import logging +import random +from pybitmessage import state +import threading + +from pybitmessage.bmconfigparser import BMConfigParser + +# from network.threads import StoppableThread + + +fake_addresses = [ + 'BM-2cXDconV3bk6nPwWgBwN7wXaqZoT1bEzGv', + 'BM-2cTWjUVedYftZJbnZfs7MWts92v1R35Try', + 'BM-2cV1UN3er2YVQBcmJaaeYMXvpwBVokJNTo', + 'BM-2cWVkWk3TyKUscdcn9E7s9hrwpv2ZsBBog', + 'BM-2cW2a5R1KidMGNByqPKn6nJDDnHtazoere' +] + +UISignalQueue = Queue.Queue() +addressGeneratorQueue = Queue.Queue() + + +class StoppableThread(threading.Thread): + """Base class for application threads with stopThread method""" + name = None + logger = logging.getLogger('default') + + def __init__(self, name=None): + if name: + self.name = name + super(StoppableThread, self).__init__(name=self.name) + self.stop = threading.Event() + self._stopped = False + random.seed() + self.logger.info('Init thread %s', self.name) + + def stopThread(self): + """Stop the thread""" + self._stopped = True + self.stop.set() + + +class FakeAddressGenerator(StoppableThread): + """A thread for creating fake addresses""" + name = "addressGenerator" + + def stopThread(self): + try: + addressGeneratorQueue.put(("stopThread", "data")) + except: + pass + super(FakeAddressGenerator, self).stopThread() + + def run(self): + """ + Process the requests for addresses generation + from `.queues.addressGeneratorQueue` + """ + while state.shutdown == 0: + queueValue = addressGeneratorQueue.get() + streamNumber = 1 + try: + if len(BMConfigParser().addresses()) > 0: + address = fake_addresses[len(BMConfigParser().addresses())] + else: + address = fake_addresses[0] + + label = queueValue[3] + BMConfigParser().add_section(address) + BMConfigParser().set(address, 'label', label) + BMConfigParser().set(address, 'enabled', 'true') + BMConfigParser().set( + address, 'privencryptionkey', '5KUayt1aPSsNWsxMJnk27kv79wfRE3cWVPYLazyLQc752bXfQP3') + BMConfigParser().save() + + UISignalQueue.put(( + 'updateStatusBar', "" + )) + UISignalQueue.put(('writeNewAddressToTable', ( + label, address, streamNumber))) + addressGeneratorQueue.task_done() + except IndexError: + self.logger.error( + 'Program error: you can only create 5 fake addresses') diff --git a/src/mock/main.py b/src/mock/main.py new file mode 100644 index 00000000..0a5fbb84 --- /dev/null +++ b/src/mock/main.py @@ -0,0 +1,29 @@ +"""This module is for thread start.""" + +from pybitmessage import state +from pybitmessage.bitmessagekivy.mpybit import NavigateApp +from class_addressGenerator import FakeAddressGenerator +# from class_sqlThread import sqlThread + + +def main(): + """main method for starting threads""" + if state.enableObjProc: + # Start the address generation thread + addressGeneratorThread = FakeAddressGenerator() + # close the main program even if there are threads left + addressGeneratorThread.daemon = True + addressGeneratorThread.start() + + # sqlLookup = sqlThread() + # DON'T close the main program even if there are threads left. + # The closeEvent should command this thread to exit gracefully. + # sqlLookup.daemon = False + # sqlLookup.start() + + state.kivyapp = NavigateApp() + state.kivyapp.run() + + +if __name__ == '__main__': + main() diff --git a/src/shutdown.py b/src/shutdown.py index 618dc3aa..e85b0803 100644 --- a/src/shutdown.py +++ b/src/shutdown.py @@ -22,7 +22,7 @@ def doCleanShutdown(): objectProcessorQueue.put(('checkShutdownVariable', 'no data')) for thread in threading.enumerate(): - if thread.isAlive() and isinstance(thread, StoppableThread): + if thread.is_alive() and isinstance(thread, StoppableThread): thread.stopThread() UISignalQueue.put((