Add kivy network UI and test
This commit is contained in:
parent
f6c7e50acf
commit
49e0a31b8f
|
@ -5,14 +5,21 @@
|
|||
Network status
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from kivy.clock import Clock
|
||||
from kivy.properties import StringProperty
|
||||
from kivy.uix.screenmanager import Screen
|
||||
|
||||
from pybitmessage.network import objectracker, stats
|
||||
|
||||
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):
|
||||
"""NetworkStat class for kivy Ui"""
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
tab_display_mode:'text'
|
||||
|
||||
Tab:
|
||||
text: app.tr._("Total connections")
|
||||
title: app.tr._("Total connections")
|
||||
ScrollView:
|
||||
do_scroll_x: False
|
||||
MDList:
|
||||
|
@ -34,7 +34,7 @@
|
|||
# color: (1,1,1,1)
|
||||
# halign: 'center'
|
||||
Tab:
|
||||
text: app.tr._('Processes')
|
||||
title: app.tr._('Processes')
|
||||
ScrollView:
|
||||
do_scroll_x: False
|
||||
MDList:
|
||||
|
|
|
@ -220,6 +220,8 @@ MDNavigationLayout:
|
|||
id:id_payment
|
||||
Create:
|
||||
id:id_create
|
||||
NetworkStat:
|
||||
id:id_networkstat
|
||||
|
||||
MDNavigationDrawer:
|
||||
id: nav_drawer
|
||||
|
|
|
@ -21,5 +21,10 @@
|
|||
"kv_string": "msg_composer",
|
||||
"name_screen": "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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ class TeleniumTestProcess(TeleniumTestCase):
|
|||
# Checking the drawer is in 'closed' state
|
||||
self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5)
|
||||
# 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
|
||||
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5)
|
||||
self.cli.wait_click('//ActionTopAppBarButton[@icon=\"menu\"]', timeout=5)
|
||||
# checking state of Nav drawer
|
||||
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5)
|
||||
|
|
|
@ -1,35 +1,24 @@
|
|||
# pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Kivy Networkstat UI test
|
||||
"""
|
||||
|
||||
from time import sleep
|
||||
from .telenium_process import TeleniumTestProcess
|
||||
from .common import skip_screen_checks
|
||||
|
||||
|
||||
class NetworkStatusScreen(TeleniumTestProcess):
|
||||
"""NetworkStatus Screen Functionality Testing"""
|
||||
|
||||
@skip_screen_checks
|
||||
def test_network_status(self):
|
||||
"""Show NetworkStatus"""
|
||||
# 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
|
||||
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()
|
||||
# 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=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)
|
||||
|
|
|
@ -5,20 +5,23 @@
|
|||
|
||||
import os
|
||||
from kivy.config import Config
|
||||
import multiqueue
|
||||
from pybitmessage.mock import multiqueue
|
||||
from pybitmessage import state
|
||||
|
||||
if os.environ.get('INSTALL_TESTS', False):
|
||||
Config.set('graphics', 'height', 1280)
|
||||
Config.set('graphics', 'width', 720)
|
||||
Config.set('graphics', 'position', 'custom')
|
||||
Config.set('graphics', 'top', 0)
|
||||
Config.set('graphics', 'left', 0)
|
||||
if os.environ.get("INSTALL_TESTS", False):
|
||||
Config.set("graphics", "height", 1280)
|
||||
Config.set("graphics", "width", 720)
|
||||
Config.set("graphics", "position", "custom")
|
||||
Config.set("graphics", "top", 0)
|
||||
Config.set("graphics", "left", 0)
|
||||
|
||||
|
||||
from pybitmessage.mock.class_addressGenerator import FakeAddressGenerator # 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():
|
||||
|
@ -33,5 +36,5 @@ def main():
|
|||
state.kivyapp.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -7,12 +7,16 @@
|
|||
|
||||
class objectracker(object):
|
||||
"""Mock object tracker"""
|
||||
|
||||
missingObjects = {}
|
||||
|
||||
|
||||
class stats(object):
|
||||
"""Mock network statics"""
|
||||
|
||||
@staticmethod
|
||||
def connectedHostsList():
|
||||
"""List of all the connected hosts"""
|
||||
return ()
|
||||
"""List of all the mock connected hosts"""
|
||||
return [
|
||||
"conn1", "conn2", "conn3", "conn4"
|
||||
]
|
||||
|
|
Reference in New Issue
Block a user