Skip to content

Commit

Permalink
Fix Android tests, get to 100% coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Feb 25, 2023
1 parent 7077562 commit ec04ddc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 3 additions & 4 deletions android/src/toga_android/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ def get_text(self):
return str(self.native.getText())

def set_text(self, text):
self.native.setText(self.interface.text)
self.native.setText(text)

def set_enabled(self, value):
self.native.setEnabled(value)

def set_font(self, font):
if font:
self.native.setTextSize(TypedValue.COMPLEX_UNIT_SP, font._impl.get_size())
self.native.setTypeface(font._impl.get_typeface(), font._impl.get_style())
self.native.setTextSize(TypedValue.COMPLEX_UNIT_SP, font._impl.get_size())
self.native.setTypeface(font._impl.get_typeface(), font._impl.get_style())

def set_on_press(self, handler):
# No special handling required
Expand Down
10 changes: 8 additions & 2 deletions testbed/tests/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
# * assert_set_get(obj, name, pytest.approx(value)) - for floating point values
# * assert_set_get(obj, name, set_value, get_value) - where the two values are different
def assert_set_get(obj, name, value):
"""Calls a setter, then asserts that the same value is returned by the getter."""
"""Calls a setter, then asserts that the same value is returned by the getter.
:param obj: The object to inspect
:param name: The name of the attribute to set and get
:param value: The value to set
"""
setattr(obj, name, value)
assert getattr(obj, name) == value
actual = getattr(obj, name)
assert actual == value, f"Expected {value!r}, got {actual!r}"


def assert_color(actual, expected):
Expand Down

0 comments on commit ec04ddc

Please sign in to comment.