diff --git a/src/bitmessagekivy/tests/telenium_process.py b/src/bitmessagekivy/tests/telenium_process.py index 4ae97942..85e12c8f 100644 --- a/src/bitmessagekivy/tests/telenium_process.py +++ b/src/bitmessagekivy/tests/telenium_process.py @@ -100,3 +100,17 @@ class TeleniumTestProcess(TeleniumTestCase): if timeout > 0 and time() - start > timeout: raise Exception("Timeout") sleep(0.1) + + def assertCheckScrollUp(self, selector, timeout=-1): + """this method is for checking scroll UP""" + start = time() + while True: + scroll_distance = self.cli.getattr(selector, 'scroll_y') + if scroll_distance < 1.0: + self.assertGreaterEqual(scroll_distance, 0.0) + return True + if timeout == -1: + return False + if timeout > 0 and time() - start > timeout: + raise Exception("Timeout") + sleep(0.1) diff --git a/src/bitmessagekivy/tests/test_myaddress_screen.py b/src/bitmessagekivy/tests/test_myaddress_screen.py new file mode 100644 index 00000000..b7517c8b --- /dev/null +++ b/src/bitmessagekivy/tests/test_myaddress_screen.py @@ -0,0 +1,121 @@ +from .telenium_process import TeleniumTestProcess +from .common import skip_screen_checks +from .common import ordered + + +test_address = { + 'recipient': 'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr' +} + + +class MyAddressScreen(TeleniumTestProcess): + """MyAddress Screen Functionality Testing""" + subject = 'Hey this is Demo Subject' + body = 'Hey,i am sending message directly from MyAddress book' + + @skip_screen_checks + @ordered + def test_select_myaddress_list(self): + """Select Address From List of Address""" + # This is for checking Current screen + self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') + # This is for checking the Side nav Bar is closed + self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) + # This is for checking the menu button is appeared + self.assertExists('//MDActionTopAppBarButton[@icon~=\"menu\"]', 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=5) + # this is for scrolling Nav drawer + self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") + # assert for checking scroll function + self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=3) + # this is for opening My Address screen + self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=2) + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + + @skip_screen_checks + @ordered + def test_send_message_from(self): + """Send Message From send Button""" + # This is for checking Current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + # Click on Address to open popup + self.cli.wait_click('//MDList[0]/CustomTwoLineAvatarIconListItem[0]', timeout=2) + # Checking Popup Opened + self.assertExists('//MyaddDetailPopup//MDLabel[@text=\"Send message from\"]', timeout=2) + # Click on Send Message Button to redirect Create Screen + self.cli.wait_click('//MyaddDetailPopup//MDRaisedButton[0]/MDLabel[@text=\"Send message from\"]', timeout=2) + # Checking Current screen(Create) + self.assertExists("//ScreenManager[@current=\"create\"]", timeout=2) + # Entering Receiver Address + self.cli.setattr( + '//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", test_address['recipient']) + # Checking Receiver Address filled or not + self.assertNotEqual('//DropDownWidget//MyTextInput[0]', '') + # ADD SUBJECT + self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', self.subject) + # Checking Subject Field is Entered + self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', '') + # ADD MESSAGE BODY + self.cli.setattr( + '//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[0]', 'text', + self.body) + # Checking Message body is Entered + self.assertNotEqual('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text]', '') + # Click on Send Icon + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=3) + # Check for redirected screen (Inbox Screen) + self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=7) + + @skip_screen_checks + @ordered + def test_show_qrcode(self): + """Show the Qr code of selected address""" + # This is for checking the Side nav Bar is closed + self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3) + # checking state of Nav drawer + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + # Clicking on Sent Tab + self.cli.wait_click('//NavigationItem[@text=\"My addresses\"]', timeout=3) + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + # Click on Address to open popup + self.cli.wait_click('//MDList[0]/CustomTwoLineAvatarIconListItem[0]', timeout=2) + # Check the Popup is opened + self.assertExists('//MyaddDetailPopup//MDLabel[@text=\"Show QR code\"]', timeout=2) + # Cick on 'Show QR code' button to view QR Code + self.cli.wait_click('//MyaddDetailPopup//MDLabel[@text=\"Show QR code\"]') + # Check Current screen is QR Code screen + self.assertExists("//ScreenManager[@current=\"showqrcode\"]", timeout=2) + # Click on BACK button + self.cli.wait_click('//MDToolbar//MDActionTopAppBarButton[@icon=\"arrow-left\"]', timeout=2) + # Checking current screen(My Address) after BACK press + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + + @skip_screen_checks + @ordered + def test_sent_box(self): + """ + Checking Message in Sent Screen after sending a Message. + """ + # Checking current screen + self.assertExists("//ScreenManager[@current=\"myaddress\"]", timeout=3) + # this is for opening Nav drawer + self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3) + # checking state of Nav drawer + self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2) + # this is for scrolling Nav drawer + self.drag("//NavigationItem[@text=\"Purchase\"]", "//NavigationItem[@text=\"My addresses\"]") + # assert for checking scroll function + self.assertCheckScrollUp('//ContentNavigationDrawer//ScrollView[0]', timeout=3) + # Clicking on Sent Tab + self.cli.wait_click('//NavigationItem[@text=\"Sent\"]', timeout=3) + # Checking current screen; Sent + self.assertExists("//ScreenManager[@current=\"sent\"]", timeout=3) + # Checking number of messages in sent box + total_sent_msgs = len(self.cli.select("//SwipeToDeleteItem")) + self.assertEqual(total_sent_msgs, 1)