-
-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1799 from freakboy3742/audit-label
[widget audit] toga.Label
- Loading branch information
Showing
33 changed files
with
276 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from rubicon.java import JavaClass | ||
|
||
Build = JavaClass("android/os/Build") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
iOS now supports newlines in Labels. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The Label widget now has 100% test coverage, and complete API documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,46 @@ | ||
import pytest | ||
|
||
import toga | ||
from toga_dummy.utils import TestCase | ||
from toga_dummy.utils import ( | ||
EventLog, | ||
assert_action_performed, | ||
attribute_value, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def label(): | ||
return toga.Label("Test Label") | ||
|
||
|
||
class LabelTests(TestCase): | ||
def setUp(self): | ||
super().setUp() | ||
def test_label_created(label): | ||
"A label can be created." | ||
# Round trip the impl/interface | ||
assert label._impl.interface == label | ||
assert_action_performed(label, "create Label") | ||
|
||
self.text = "test text" | ||
|
||
self.label = toga.Label(self.text) | ||
@pytest.mark.parametrize( | ||
"value, expected", | ||
[ | ||
("New Text", "New Text"), | ||
(12345, "12345"), | ||
(None, ""), | ||
("\u200B", ""), | ||
("Contains\nsome\nnewlines", "Contains\nsome\nnewlines"), | ||
], | ||
) | ||
def test_update_label_text(label, value, expected): | ||
assert label.text == "Test Label" | ||
|
||
def test_widget_created(self): | ||
self.assertEqual(self.label._impl.interface, self.label) | ||
self.assertActionPerformed(self.label, "create Label") | ||
# Clear the event log | ||
EventLog.reset() | ||
|
||
def test_update_label_text(self): | ||
new_text = "updated text" | ||
self.label.text = new_text | ||
self.assertEqual(self.label.text, new_text) | ||
self.assertValueSet(self.label, "text", new_text) | ||
self.assertActionPerformed(self.label, "refresh") | ||
label.text = value | ||
assert label.text == expected | ||
|
||
self.label.text = None | ||
self.assertEqual(self.label.text, "") | ||
# test backend has the right value | ||
assert attribute_value(label, "text") == expected | ||
|
||
self.assertValueSet(self.label, "text", "") | ||
# A rehint was performed | ||
assert_action_performed(label, "refresh") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Usage | |
import toga | ||
label = toga.Label('Hello world') | ||
label = toga.Label("Hello world") | ||
Notes | ||
----- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.