Add kivy network UI and test

This commit is contained in:
shekhar-cis 2022-09-19 21:34:34 +05:30
parent f6c7e50acf
commit 49e0a31b8f
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
8 changed files with 46 additions and 36 deletions

View File

@ -5,14 +5,21 @@
Network status Network status
""" """
import os
from kivy.clock import Clock from kivy.clock import Clock
from kivy.properties import StringProperty from kivy.properties import StringProperty
from kivy.uix.screenmanager import Screen from kivy.uix.screenmanager import Screen
from pybitmessage.network import objectracker, stats
from pybitmessage import state from pybitmessage import state
if os.environ.get('INSTALL_TESTS', False):
from pybitmessage.mock import kivy_main
stats = kivy_main.network.stats
objectracker = kivy_main.network.objectracker
else:
from pybitmessage.network import stats, objectracker
class NetworkStat(Screen): class NetworkStat(Screen):
"""NetworkStat class for kivy Ui""" """NetworkStat class for kivy Ui"""

View File

@ -5,7 +5,7 @@
tab_display_mode:'text' tab_display_mode:'text'
Tab: Tab:
text: app.tr._("Total connections") title: app.tr._("Total connections")
ScrollView: ScrollView:
do_scroll_x: False do_scroll_x: False
MDList: MDList:
@ -34,7 +34,7 @@
# color: (1,1,1,1) # color: (1,1,1,1)
# halign: 'center' # halign: 'center'
Tab: Tab:
text: app.tr._('Processes') title: app.tr._('Processes')
ScrollView: ScrollView:
do_scroll_x: False do_scroll_x: False
MDList: MDList:

View File

@ -220,6 +220,8 @@ MDNavigationLayout:
id:id_payment id:id_payment
Create: Create:
id:id_create id:id_create
NetworkStat:
id:id_networkstat
MDNavigationDrawer: MDNavigationDrawer:
id: nav_drawer id: nav_drawer

View File

@ -21,5 +21,10 @@
"kv_string": "msg_composer", "kv_string": "msg_composer",
"name_screen": "create", "name_screen": "create",
"Import": "from pybitmessage.bitmessagekivy.baseclass.msg_composer import Create" "Import": "from pybitmessage.bitmessagekivy.baseclass.msg_composer import Create"
},
"Network status": {
"kv_string": "network",
"name_screen": "networkstat",
"Import": "from pybitmessage.bitmessagekivy.baseclass.network import NetworkStat"
} }
} }

View File

@ -121,8 +121,8 @@ class TeleniumTestProcess(TeleniumTestCase):
# Checking the drawer is in 'closed' state # Checking the drawer is in 'closed' state
self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5)
# This is for checking the menu button is appeared # This is for checking the menu button is appeared
self.assertExists('//MDActionTopAppBarButton[@icon~=\"menu\"]', timeout=5) self.assertExists('//ActionTopAppBarButton[@icon~=\"menu\"]', timeout=5)
# this is for opening Nav drawer # this is for opening Nav drawer
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5) self.cli.wait_click('//ActionTopAppBarButton[@icon=\"menu\"]', timeout=5)
# checking state of Nav drawer # checking state of Nav drawer
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5) self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5)

View File

@ -1,35 +1,24 @@
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
"""
Kivy Networkstat UI test
"""
from time import sleep
from .telenium_process import TeleniumTestProcess from .telenium_process import TeleniumTestProcess
from .common import skip_screen_checks
class NetworkStatusScreen(TeleniumTestProcess): class NetworkStatusScreen(TeleniumTestProcess):
"""NetworkStatus Screen Functionality Testing""" """NetworkStatus Screen Functionality Testing"""
@skip_screen_checks
def test_network_status(self): def test_network_status(self):
"""Show NetworkStatus""" """Show NetworkStatus"""
# This is for checking Current screen # This is for checking Current screen
self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='login')
# Method to open side navbar # Method to open side navbar
if self.cli.wait('//ActionTopAppBarButton[@icon~=\"menu\"]', timeout=5):
sleep(0.2) # due to rapid transition effect, it doesn't click on menu-bar
self.open_side_navbar() self.open_side_navbar()
# this is for scrolling Nav drawer # this is for scrolling Nav drawer
self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]") self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
# assert for checking scroll function # assert for checking scroll function
self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=5) self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=5)
# Clicking on Network Status tab
self.cli.wait_click('//NavigationItem[@text=\"Network status\"]', timeout=5)
# checking current screen
self.assertExists("//ScreenManager[@current=\"networkstat\"]", timeout=5)
# Checking the state of "Total Connection" tab
self.assertExists(
'//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Total connections\"][@state=\"down\"]', timeout=3)
# Checking the state of "Processes" tab
self.assertExists('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"][@state=\"normal\"]', timeout=3)
# Checking the "Tab" is rendered
self.assertExists('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"]', timeout=4)
# Clicking on Processes Tab
self.cli.wait_click('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"]', timeout=4)
# Checking the state of "Processes" tab
self.assertExists('//NetworkStat/MDTabs[0]//MDTabsLabel[@text=\"Processes\"][@state=\"normal\"]', timeout=3)

View File

@ -5,20 +5,23 @@
import os import os
from kivy.config import Config from kivy.config import Config
import multiqueue from pybitmessage.mock import multiqueue
from pybitmessage import state from pybitmessage import state
if os.environ.get('INSTALL_TESTS', False): if os.environ.get("INSTALL_TESTS", False):
Config.set('graphics', 'height', 1280) Config.set("graphics", "height", 1280)
Config.set('graphics', 'width', 720) Config.set("graphics", "width", 720)
Config.set('graphics', 'position', 'custom') Config.set("graphics", "position", "custom")
Config.set('graphics', 'top', 0) Config.set("graphics", "top", 0)
Config.set('graphics', 'left', 0) Config.set("graphics", "left", 0)
from pybitmessage.mock.class_addressGenerator import FakeAddressGenerator # noqa:E402 from pybitmessage.mock.class_addressGenerator import FakeAddressGenerator # noqa:E402
from pybitmessage.bitmessagekivy.mpybit import NavigateApp # noqa:E402 from pybitmessage.bitmessagekivy.mpybit import NavigateApp # noqa:E402
from pybitmessage.mock.network import stats, objectracker # noqa:E402 from pybitmessage.mock import network # noqa:E402
stats = network.stats
objectracker = network.objectracker
def main(): def main():
@ -33,5 +36,5 @@ def main():
state.kivyapp.run() state.kivyapp.run()
if __name__ == '__main__': if __name__ == "__main__":
main() main()

View File

@ -7,12 +7,16 @@
class objectracker(object): class objectracker(object):
"""Mock object tracker""" """Mock object tracker"""
missingObjects = {} missingObjects = {}
class stats(object): class stats(object):
"""Mock network statics""" """Mock network statics"""
@staticmethod @staticmethod
def connectedHostsList(): def connectedHostsList():
"""List of all the connected hosts""" """List of all the mock connected hosts"""
return () return [
"conn1", "conn2", "conn3", "conn4"
]