Ejemplo n.º 1
0
 def _run_flip_animation_test(self, fix_center: bool):
     card_widget = CardWidget(Card(Suit.SPADES, CardValue.ACE))
     self.render(card_widget)
     animation = card_widget.get_flip_animation(duration=1,
                                                fixed_center=fix_center)
     on_complete_callback = Mock()
     animation.bind(on_complete=on_complete_callback)
     self.assertTrue(card_widget.visible)
     on_complete_callback.assert_not_called()
     initial_size = card_widget.size
     initial_pos = card_widget.pos
     card_widget.check_aspect_ratio(False)
     animation.start(card_widget)
     self.advance_frames(5)
     on_complete_callback.assert_not_called()
     card_widget.center = 100, 100
     self.wait_for_mock_callback(on_complete_callback)
     self.assertEqual(initial_size, card_widget.size)
     self.assertEqual(fix_center, initial_pos == card_widget.pos)
     self.assertFalse(card_widget.visible)
     animation = card_widget.get_flip_animation(duration=0.5,
                                                fixed_center=fix_center)
     on_complete_callback.reset_mock()
     animation.bind(on_complete=on_complete_callback)
     on_complete_callback.assert_not_called()
     animation.start(card_widget)
     self.wait_for_mock_callback(on_complete_callback)
     self.assertEqual(initial_size, card_widget.size)
     self.assertEqual(fix_center, initial_pos == card_widget.pos)
     self.assertTrue(card_widget.visible)
Ejemplo n.º 2
0
 def test_aspect_ratio_is_enforced(self):
     card_widget = CardWidget(Card(Suit.SPADES, CardValue.ACE),
                              aspect_ratio=0.5)
     card_widget.size = 10, 20
     card_widget.size = 25, 50
     card_widget.size = 26, 50
     card_widget.size = 24, 50
     with self.assertRaisesRegex(AssertionError, r"\(\[23, 50\], 0.5\)"):
         card_widget.size = 23, 50
     with self.assertRaisesRegex(AssertionError, r"\(\[27, 50\], 0.5\)"):
         card_widget.size = 27, 50
     card_widget.check_aspect_ratio(False)
     card_widget.size = 23, 50
     card_widget.size = 27, 50