Upgrading to GitLab 11.10.0. Expect errors and see debian-infrastructure-announce@lists.debian.org for further information.

Commit 171d12a8 authored by Mathieu Bridon's avatar Mathieu Bridon

tests: Add a bunch of unit tests for Cangjie

parent b74a0803
......@@ -59,3 +59,53 @@ class CangjieTestCase(unittest.TestCase):
self.assertEqual(len(self.engine._mock_committed_text), 1)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
self.assertEqual(self.engine._mock_committed_text, expected)
def test_max_input(self):
# Get to max char
self.engine.do_process_key_event(IBus.a, 0, 0)
self.engine.do_process_key_event(IBus.a, 0, 0)
self.engine.do_process_key_event(IBus.a, 0, 0)
self.engine.do_process_key_event(IBus.a, 0, 0)
self.engine.do_process_key_event(IBus.a, 0, 0)
# Try adding one more and get the error bell
self.engine.do_process_key_event(IBus.a, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
# And once more
self.engine.do_process_key_event(IBus.a, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
self.assertEqual(len(self.engine.canberra._mock_played_events), 2)
def test_inexistent_combination(self):
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.space, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
def test_wildcard(self):
self.engine.do_process_key_event(IBus.d, 0, 0)
self.engine.do_process_key_event(IBus.asterisk, 0, 0)
self.engine.do_process_key_event(IBus.d, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 3)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
self.engine.do_process_key_event(IBus.space, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 3)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertTrue(self.engine.lookuptable.get_number_of_candidates() > 1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment