Skip to content

Commit

Permalink
Add new test cases for input with tuples of 3 and less or more than
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadMuradG authored Sep 19, 2020
1 parent 3064f7a commit a717424
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions src/core/tests/widgets/test_splitcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,44 @@ def test_direction_property_default(self):
def test_setting_direction_property_invokes_impl_method(self):
new_value = False
self.split.direction = new_value
self.assertValueSet(self.split, 'direction', new_value)

def test_setting_content_valid_input_with_tuple(self):
self.assertValueSet(self.split, "direction", new_value)

def test_setting_content_valid_input_with_tuple_of2(self):
new_content = [
(toga.Box(style=TestStyle(), factory=toga_dummy.factory), 1.2),
(toga.Box(style=TestStyle(), factory=toga_dummy.factory), 2.5)
(toga.Box(style=TestStyle(), factory=toga_dummy.factory), 2.5),
]
self.split.content = new_content
self.assertEqual(self.split._weight[0], 1.2)
self.assertEqual(self.split._weight[1], 2.5)

def test_setting_content_valid_input_with_tuple_of3(self):
new_content = [
(toga.Box(style=TestStyle(), factory=toga_dummy.factory), 1.2),
(toga.Box(style=TestStyle(), factory=toga_dummy.factory), 2.5, False),
]
self.split.content = new_content
self.assertEqual(self.split._weight[0], 1.2)
self.assertEqual(self.split._weight[1], 2.5)
self.assertActionPerformedWith(
self.split,
"add content",
position=0,
widget=new_content[0][0]._impl,
flex=True,
)
self.assertActionPerformedWith(
self.split,
"add content",
position=1,
widget=new_content[1][0]._impl,
flex=False,
)

def test_setting_content_valid_input_with_tuple_of_more3(self):
new_content = [
(toga.Box(style=TestStyle(), factory=toga_dummy.factory), 1.2, True, True),
(toga.Box(style=TestStyle(), factory=toga_dummy.factory), 2.5, False, True),
]
with self.assertRaises(ValueError):
self.split.content = new_content

0 comments on commit a717424

Please sign in to comment.