From ba7eb7eb3ed5e3b1dde9ad6e072ffb6c9c3ad225 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Thu, 5 Aug 2021 20:03:05 +0530 Subject: [PATCH] fixed app launch issue --- src/bitmessagekivy/baseclass/allmail.py | 4 +- src/bitmessagekivy/baseclass/common.py | 2 +- src/bitmessagekivy/baseclass/trash.py | 4 +- src/bitmessagekivy/main.kv | 2 +- src/bitmessagekivy/tests/telenium_process.py | 13 ++++- src/bitmessagekivy/tests/test_addressbook.py | 5 +- .../tests/test_allmail_message.py | 20 ++++---- .../tests/test_network_screen.py | 22 ++++---- .../tests/test_payment_subscription.py | 15 ++++-- .../tests/test_setting_screen.py | 17 ++++--- .../tests/test_trash_message.py | 50 ++++++++++--------- 11 files changed, 89 insertions(+), 65 deletions(-) diff --git a/src/bitmessagekivy/baseclass/allmail.py b/src/bitmessagekivy/baseclass/allmail.py index c22a96fa..fc3b8dd9 100644 --- a/src/bitmessagekivy/baseclass/allmail.py +++ b/src/bitmessagekivy/baseclass/allmail.py @@ -13,7 +13,7 @@ import state from bitmessagekivy.baseclass.common import ( showLimitedCnt, toast, ThemeClsColor, - avatarImageFirstLetter, CutsomSwipeToDeleteItem, + avatarImageFirstLetter, CustomSwipeToDeleteItem, ShowTimeHistoy ) from bitmessagekivy.baseclass.maildetail import MailDetail @@ -90,7 +90,7 @@ class Allmails(Screen): for item in self.all_mails: body = item[3].decode() if isinstance(item[3], bytes) else item[3] subject = item[2].decode() if isinstance(item[2], bytes) else item[2] - message_row = CutsomSwipeToDeleteItem( + message_row = CustomSwipeToDeleteItem( text=item[1], ) diff --git a/src/bitmessagekivy/baseclass/common.py b/src/bitmessagekivy/baseclass/common.py index 70b750fd..9fc568b2 100644 --- a/src/bitmessagekivy/baseclass/common.py +++ b/src/bitmessagekivy/baseclass/common.py @@ -136,7 +136,7 @@ class SwipeToDeleteItem(MDCardSwipe): opening_time = NumericProperty(0.5) -class CutsomSwipeToDeleteItem(MDCardSwipe): +class CustomSwipeToDeleteItem(MDCardSwipe): """Custom swipe delete class for App UI""" text = StringProperty() cla = Window.size[0] / 2 diff --git a/src/bitmessagekivy/baseclass/trash.py b/src/bitmessagekivy/baseclass/trash.py index a0eea1e9..6a0a14ce 100644 --- a/src/bitmessagekivy/baseclass/trash.py +++ b/src/bitmessagekivy/baseclass/trash.py @@ -16,7 +16,7 @@ import state from bitmessagekivy.baseclass.common import ( toast, showLimitedCnt, ThemeClsColor, - CutsomSwipeToDeleteItem, ShowTimeHistoy, + CustomSwipeToDeleteItem, ShowTimeHistoy, avatarImageFirstLetter ) @@ -85,7 +85,7 @@ class Trash(Screen): for item in self.trash_messages: subject = item[2].decode() if isinstance(item[2], bytes) else item[2] body = item[3].decode() if isinstance(item[3], bytes) else item[3] - message_row = CutsomSwipeToDeleteItem( + message_row = CustomSwipeToDeleteItem( text=item[1], ) message_row.bind(on_swipe_complete=partial(self.on_swipe_complete, message_row)) diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index 1b2a337b..fad654ac 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -378,7 +378,7 @@ MDNavigationLayout: size: [120, 140] if app.app_platform == "android" else [64, 80] -: +: size_hint_y: None height: content.height diff --git a/src/bitmessagekivy/tests/telenium_process.py b/src/bitmessagekivy/tests/telenium_process.py index a398d301..10129d73 100644 --- a/src/bitmessagekivy/tests/telenium_process.py +++ b/src/bitmessagekivy/tests/telenium_process.py @@ -6,6 +6,7 @@ import os import shutil import tempfile from time import time, sleep +from turtle import Turtle, pd from telenium.tests import TeleniumTestCase @@ -63,8 +64,18 @@ class TeleniumTestProcess(TeleniumTestCase): pass cleanup() + def assertCheck_app_launch(self, selector, timeout=-1): + """This method is written to check the application is launched otherwise it will wait untill timeout value""" + while timeout > 0: + try: + self.assertTrue(selector, 'inbox') + timeout -= 0.3 + except: + raise Exception("Timeout") + sleep(0.3) + def click_on(self, xpath, seconds=0.3): - """this methos is used for on_click event with time""" + """this method is used for on_click event with time""" self.cli.click_on(xpath) self.cli.sleep(seconds) diff --git a/src/bitmessagekivy/tests/test_addressbook.py b/src/bitmessagekivy/tests/test_addressbook.py index a084c8e6..6934bb19 100644 --- a/src/bitmessagekivy/tests/test_addressbook.py +++ b/src/bitmessagekivy/tests/test_addressbook.py @@ -1,4 +1,3 @@ -from tkinter.constants import S from .telenium_process import TeleniumTestProcess from .common import ordered @@ -120,14 +119,14 @@ class AddressBook(TeleniumTestProcess): # Checking current screen self.assertExists("//AddressBook[@name~=\"addressbook\"]", timeout=2) # Swipe to delete - self.assertTrue('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'True') + self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'True') self.drag( '//MDList[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', '//MDList[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]') # Click on trash-can icon self.cli.wait_click('//MDList[0]//SwipeToDeleteItem[0]', timeout=3) # Checking the trash icon is acrivated - self.assertTrue('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'False') + self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'False') # Click on trash icon self.cli.click_on('//MDList[0]//MDIconButton[@icon=\"delete-forever\"]') # Checking current screen diff --git a/src/bitmessagekivy/tests/test_allmail_message.py b/src/bitmessagekivy/tests/test_allmail_message.py index e5561cfd..6f2d8078 100644 --- a/src/bitmessagekivy/tests/test_allmail_message.py +++ b/src/bitmessagekivy/tests/test_allmail_message.py @@ -7,8 +7,13 @@ class AllMailMessage(TeleniumTestProcess): @ordered def test_show_allmail_list(self): """Show All Messages on Mail Screen/Window""" - print("=====================Test -Show Messages Of Mail Screen=====================") - self.cli.sleep(8) + try: + # checking current screen + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + except: + self.cli.sleep(8) + # checking current screen + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) # this is for opening Nav drawer self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3) # checking state of Nav drawer @@ -16,20 +21,17 @@ class AllMailMessage(TeleniumTestProcess): # this is for opening All Mail screen self.cli.wait_click('//NavigationItem[@text=\"All Mails\"]', timeout=5) # Assert for checking Current Screen(All mail) - self.assertExists("//Allmails[@name~=\"allmails\"]", timeout=5) + self.assertExists("//ScreenManager[@current=\"allmails\"]", timeout=5) @ordered def test_delete_message_from_allmail_list(self): """Delete Message From Message body of Mail Screen/Window""" - print("=====================Test -Delete Messages Of Mail Screen=====================") - # Assert for checking Current Screen(All mail) - self.assertExists("//Allmails[@name~=\"allmails\"]", timeout=2) # click on a Message to get message details screen self.cli.wait_click( - '//MDList[0]/CutsomSwipeToDeleteItem[0]', timeout=3) + '//MDList[0]/CustomSwipeToDeleteItem[0]', timeout=3) # Assert for checking Current Screen(Mail Detail) - self.assertExists("//MailDetail[@name~=\"mailDetail\"]", timeout=3) + self.assertExists("//ScreenManager[@current=\"mailDetail\"]", timeout=5) # CLicking on Trash-Can icon to delete Message self.cli.wait_click('//MDToolbar/BoxLayout[2]/MDActionTopAppBarButton[@icon=\"delete-forever\"]', timeout=5) # After deleting msg, screen is redirected to All mail screen - self.assertExists("//Allmails[@name~=\"allmails\"]", timeout=5) + self.assertExists("//ScreenManager[@current=\"allmails\"]", timeout=5) diff --git a/src/bitmessagekivy/tests/test_network_screen.py b/src/bitmessagekivy/tests/test_network_screen.py index 1f4bcd6e..a9198c5f 100644 --- a/src/bitmessagekivy/tests/test_network_screen.py +++ b/src/bitmessagekivy/tests/test_network_screen.py @@ -1,13 +1,17 @@ from .telenium_process import TeleniumTestProcess -class NetwrokStatusScreen(TeleniumTestProcess): +class NetworkStatusScreen(TeleniumTestProcess): """NetwrokStatus Screen Functionality Testing""" def test_network_status(self): - """Show NetwrokStatus""" - print("=====================Test -Show NetwrokStatus=====================") - self.cli.sleep(8) + """Show Netwrok Status""" + try: + # checking current screen + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + except: + self.cli.sleep(8) + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) # this is for opening Nav drawer self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=2) # checking state of Nav drawer @@ -18,9 +22,9 @@ class NetwrokStatusScreen(TeleniumTestProcess): self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) # Clicking on Network Status tab self.cli.wait_click('//NavigationItem[@text=\"Network status\"]', timeout=2) - # Checking for current screen (Network Status) - self.assertExists("//NetworkStat[@name~=\"networkstat\"]", timeout=2) + # checking current screen + self.assertExists("//ScreenManager[@current=\"networkstat\"]", timeout=2) # Clicking on Processes Tab - self.cli.wait_click('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"]', timeout=1) - # Checking for current screen (Network Status) - self.assertExists("//NetworkStat[@name~=\"networkstat\"]", timeout=2) + self.cli.wait_click('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"]', timeout=2) + # this is for checking current screen + self.assertExists("//ScreenManager[@current=\"networkstat\"]", timeout=2) diff --git a/src/bitmessagekivy/tests/test_payment_subscription.py b/src/bitmessagekivy/tests/test_payment_subscription.py index cc1c5e21..59998df3 100644 --- a/src/bitmessagekivy/tests/test_payment_subscription.py +++ b/src/bitmessagekivy/tests/test_payment_subscription.py @@ -1,3 +1,4 @@ +from requests import sessions from .telenium_process import TeleniumTestProcess @@ -6,8 +7,12 @@ class PaymentScreen(TeleniumTestProcess): def test_select_subscripton(self): """Select Subscripton From List of Subscriptons""" - print("=====================Test -Select Subscripton From List of Subscriptons=====================") - self.cli.sleep(8) + try: + # checking current screen + self.assertExists("//Scre enManager[@current=\"inbox\"]", timeout=5) + except: + self.cli.sleep(8) + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) # this is for opening Nav drawer self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3) # checking state of Nav drawer @@ -19,9 +24,9 @@ class PaymentScreen(TeleniumTestProcess): # this is for opening Payment screen self.cli.wait_click('//NavigationItem[@text=\"Purchase\"]', timeout=2) # Assert for checking Current Screen - self.assertExists("//Payment[@name~=\"payment\"]", timeout=3) + self.assertExists("//ScreenManager[@current=\"payment\"]", timeout=3) # Scrolling Down Product list - self.cli.sleep(0.5) + self.click_on('//ProductCategoryLayout[0]/ProductLayout[1]', seconds=1) self.drag( '//ProductCategoryLayout[0]/ProductLayout[1]', '//ProductCategoryLayout[0]/ProductLayout[0]') @@ -36,4 +41,4 @@ class PaymentScreen(TeleniumTestProcess): # Click out side to dismiss the popup self.cli.wait_click('//MDRaisedButton[3]', timeout=2) # Checking Current screen(Payment screen) - self.assertExists("//Payment[@name~=\"payment\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"payment\"]", timeout=3) diff --git a/src/bitmessagekivy/tests/test_setting_screen.py b/src/bitmessagekivy/tests/test_setting_screen.py index cffcfa7d..5060eaa5 100644 --- a/src/bitmessagekivy/tests/test_setting_screen.py +++ b/src/bitmessagekivy/tests/test_setting_screen.py @@ -6,19 +6,20 @@ class SettingScreen(TeleniumTestProcess): def test_setting_screen(self): """Show Setting Screen""" - print("=====================Test -Show Setting Screen=====================") - self.cli.sleep(8) - # this is for checking current screen - self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=3) + # self.cli.sleep(8) + self.assertCheck_app_launch('//ScreenManager[@current]', timeout=5) + # print(self.assertTrue('//ScreenManager[@current]', 'inbox'), "self.assertTrue('//ScreenManager[@current]', 'inbox')self.assertTrue('//ScreenManager[@current]', 'inbox')self.assertTrue('//ScreenManager[@current]', 'inbox')self.assertTrue('//ScreenManager[@current]', 'inbox')") + # self.assertTrue('//ScreenManager[@current]', 'inbox') + # self.assertCheck_app_launch('//ScreenManager[@current=\"inbox\"]', timeout=5) # this is for opening Nav drawer self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=2) # checking state of Nav drawer self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) # this is for scrolling Nav drawer self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") - # assert for checking scroll funcation - self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) + # assert for checking scroll function + self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=5) # this is for opening setting screen - self.cli.wait_click('//NavigationItem[@text=\"Settings\"]', timeout=1) + self.cli.wait_click('//NavigationItem[@text=\"Settings\"]', timeout=3) # Checking current screen - self.assertExists("//Setting[@name~=\"set\"]", timeout=2) + self.assertExists("//ScreenManager[@current=\"set\"]", timeout=2) diff --git a/src/bitmessagekivy/tests/test_trash_message.py b/src/bitmessagekivy/tests/test_trash_message.py index b18c08a1..7052ece7 100644 --- a/src/bitmessagekivy/tests/test_trash_message.py +++ b/src/bitmessagekivy/tests/test_trash_message.py @@ -1,46 +1,48 @@ from .telenium_process import TeleniumTestProcess + class TrashMessage(TeleniumTestProcess): """Trash Screen Functionality Testing""" def test_delete_trash_message(self): """Delete Trash message permanently from trash message listing""" - print("=====================Test -Delete Message From Trash Message Listing=====================") - self.cli.sleep(8) + try: + # checking current screen + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) + except: + self.cli.sleep(8) + # checking current screen + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=5) # this is for opening Nav drawer self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) # checking state of Nav drawer - self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) # this is for opening Trash screen - self.cli.wait_click('//NavigationItem[@text=\"Trash\"]', timeout=2) - # self.cli.click_on('//NavigationItem[4]') - # Checking Trash Screen - self.assertExists("//Trash[@name~=\"trash\"]", timeout=5) - # Transition Effect taking time, so halt is required - self.cli.sleep(2) + self.click_on('//NavigationItem[@text=\"Trash\"]', seconds=2) + # checking current screen(Trash Screen) + self.assertExists("//ScreenManager[@current=\"trash\"]", timeout=3) # Checking Trash Icon is in disable state - self.assertTrue('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'True') + self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'True') # This is for swiping message to activate delete icon. self.drag( '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[1]', '//Trash[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]') # Assert to check the drag is worked (Trash icon Activated) - self.assertTrue('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'False') - # Checking Popup is Opened - self.assertEqual(self.cli.getattr('//MDList[0]/CutsomSwipeToDeleteItem[0]', '_opens_process'), True) - self.click_on('//MDList[0]/CutsomSwipeToDeleteItem[0]', seconds=1) + self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@disabled]', 'False') # Checking the Trash Icon after swipe. - self.assertExists("//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[@icon~=\"trash-can\"]", timeout=2) + self.assertExists("//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[@icon~=\"trash-can\"]", timeout=2) + # Clicking on Trash icon to open Confirm delete pop up + self.click_on('//MDList[0]/CustomSwipeToDeleteItem[0]', seconds=1) + # Checking Confirm delete Popup is Opened + self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', 'True') # clicking on Trash Box icon to delete message. - self.cli.wait_click('//MDList[0]/CutsomSwipeToDeleteItem[0]//MDIconButton[0]', timeout=2) - # Checking the popup box screen. - self.assertExists("//MDDialog//MDFlatButton[@text=\"Yes\"]", timeout=2) + self.cli.wait_click('//MDList[0]/CustomSwipeToDeleteItem[0]//MDIconButton[0]', timeout=2) + # Checking the popup screen is closed. + self.assertTrue('//MDList[0]/CustomSwipeToDeleteItem[@_opens_process]', 'False') # Clicking on 'Yes' Button on Popup to confirm delete. self.click_on('//MDFlatButton[@text=\"Yes\"]', seconds=1.1) - # Checking Pop is closed - self.assertEqual(self.cli.getattr('//MDList[0]/CutsomSwipeToDeleteItem[0]', '_opens_process'), False) - # Checking Trash Screen - self.assertExists("//Trash[@name~=\"trash\"]", timeout=2) - total_trash_msgs = len(self.cli.select("//CutsomSwipeToDeleteItem")) - # Checking the number of messages after delete. + # checking current screen(Trash Screen) + self.assertExists("//ScreenManager[@current=\"trash\"]", timeout=2) + total_trash_msgs = len(self.cli.select("//CustomSwipeToDeleteItem")) + # Checking messages count after delete. self.assertEqual(total_trash_msgs, 1)