Skip to content

Commit

Permalink
Reproduces crash in a test, refs #63
Browse files Browse the repository at this point in the history
AndreMiras committed Jul 19, 2017

Verified

This commit was signed with the committer’s verified signature.
Acconut Marius Kleidl
1 parent b2cf267 commit 8d32699
Showing 3 changed files with 31 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -682,6 +682,8 @@ def run_tests(self):
class Controller(FloatLayout):

current_account = ObjectProperty(None, allownone=True)
# keeps track of all dialogs alive
dialogs = []

def __init__(self, **kwargs):
super(Controller, self).__init__(**kwargs)
@@ -698,6 +700,11 @@ def overview(self):
def history(self):
return self.overview.ids.history_id

@property
def send(self):
overview_bnavigation_id = self.ids.overview_bnavigation_id
return overview_bnavigation_id.ids.send_id

@property
def toolbar(self):
return self.ids.toolbar_id
@@ -797,10 +804,18 @@ def create_list_dialog(title, items, on_selected_item):
action=lambda *x: dialog.dismiss())
return dialog

@staticmethod
def on_dialog_dismiss(dialog):
"""
Removes it from the dialogs track list.
"""
Controller.dialogs.remove(dialog)

@staticmethod
def create_dialog(title, body):
"""
Creates a dialog from given title and body.
Adds it to the dialogs track list.
"""
content = MDLabel(
font_style='Body1',
@@ -818,6 +833,8 @@ def create_dialog(title, body):
dialog.add_action_button(
"Dismiss",
action=lambda *x: dialog.dismiss())
dialog.bind(on_dismiss=Controller.on_dialog_dismiss)
Controller.dialogs.append(dialog)
return dialog

@staticmethod
1 change: 1 addition & 0 deletions src/pywallet.kv
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@
on_text: root.send_amount = args[1]
AnchorLayout:
MDRaisedButton:
id: send_button_id
text: "Send"
on_release: self.parent.on_send_click()
PushUp:
14 changes: 13 additions & 1 deletion src/tests/ui/test_ui_base.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
main_path = op.dirname(op.dirname(op.dirname(op.abspath(__file__))))
sys.path.append(main_path)

from main import Controller, PyWalletApp # NOQA: F402 # isort:skip
from main import PyWalletApp # NOQA: F402 # isort:skip


class Test(unittest.TestCase):
@@ -52,10 +52,22 @@ def helper_test_empty_account(self, app):
dialog.dismiss()
self.assertEqual(len(dialogs), 0)

def helper_test_on_send_click(self, app):
"""
This is a regression test for #63, verify clicking "Send" Ethers works
as expected.
https://github.com/AndreMiras/PyWallet/issues/63
"""
controller = app.controller
send = controller.send
send_button_id = send.ids.send_button_id
send_button_id.dispatch('on_release')

# main test function
def run_test(self, app, *args):
Clock.schedule_interval(self.pause, 0.000001)
self.helper_test_empty_account(app)
self.helper_test_on_send_click(app)

# Comment out if you are editing the test, it'll leave the
# Window opened.

0 comments on commit 8d32699

Please sign in to comment.