Merge lp:~michael-sheldon/ubuntu-keyboard/fix-1407588 into lp:ubuntu-keyboard

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 294
Merged at revision: 294
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-1407588
Merge into: lp:ubuntu-keyboard
Diff against target: 125 lines (+68/-3)
4 files modified
plugins/pinyin/src/chineselanguagefeatures.cpp (+5/-0)
plugins/pinyin/src/chineselanguagefeatures.h (+1/-0)
src/view/abstracttexteditor.cpp (+6/-3)
tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py (+56/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1407588
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+247292@code.launchpad.net

Commit message

Enable auto-punctuation for Pinyin input.

Description of the change

Enable auto-punctuation for Pinyin input.

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/ubuntu-keyboard) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * No change

If you changed UI labels, did you update the pot file?

 * No change

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?

 * No change

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

The jenkins node for the amd64 build failed, I've restarted a new ci run.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/pinyin/src/chineselanguagefeatures.cpp'
2--- plugins/pinyin/src/chineselanguagefeatures.cpp 2014-12-08 14:26:19 +0000
3+++ plugins/pinyin/src/chineselanguagefeatures.cpp 2015-01-26 13:01:43 +0000
4@@ -93,3 +93,8 @@
5 {
6 return true;
7 }
8+
9+QString ChineseLanguageFeatures::fullStopSequence() const
10+{
11+ return QString("。");
12+}
13
14=== modified file 'plugins/pinyin/src/chineselanguagefeatures.h'
15--- plugins/pinyin/src/chineselanguagefeatures.h 2014-12-08 14:26:19 +0000
16+++ plugins/pinyin/src/chineselanguagefeatures.h 2015-01-26 13:01:43 +0000
17@@ -35,6 +35,7 @@
18 virtual bool isSymbol(const QString &text) const;
19 virtual bool ignoreSimilarity() const;
20 virtual bool wordEngineAvailable() const;
21+ virtual QString fullStopSequence() const;
22 };
23
24 #endif // CHINESELANGUAGEFEATURES_H
25
26=== modified file 'src/view/abstracttexteditor.cpp'
27--- src/view/abstracttexteditor.cpp 2015-01-08 09:13:21 +0000
28+++ src/view/abstracttexteditor.cpp 2015-01-26 13:01:43 +0000
29@@ -544,7 +544,10 @@
30
31 // every double-space character inputs one-after-another force a full-stop, so trigger it if needed
32 if (d->double_space_full_stop_enabled && not look_for_a_double_space) {
33- d->look_for_a_double_space = true;
34+ // Only enable if the language plugin inserts spaces after word completion (e.g. pinyin doesn't)
35+ if (d->text->preedit().isEmpty() || d->word_engine->languageFeature()->appendixForReplacedPreedit(d->text->preedit()) == " ") {
36+ d->look_for_a_double_space = true;
37+ }
38 }
39
40 if (replace_preedit) {
41@@ -558,9 +561,9 @@
42 }
43 d->text->setPreedit(d->text->primaryCandidate());
44 }
45- else if (look_for_a_double_space && not stopSequence.isEmpty()) {
46+ else if (look_for_a_double_space && not stopSequence.isEmpty() && textOnLeft.right(1) == " ") {
47 removeTrailingWhitespaces();
48- d->text->appendToPreedit(d->word_engine->languageFeature()->fullStopSequence());
49+ d->text->appendToPreedit(stopSequence);
50
51 // we need to re-evaluate autocaps after our changes to the preedit
52 textOnLeft = d->text->surroundingLeft() + d->text->preedit();
53
54=== modified file 'tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py'
55--- tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-01-08 18:07:27 +0000
56+++ tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-01-26 13:01:43 +0000
57@@ -509,6 +509,42 @@
58 Eventually(Equals(expected))
59 )
60
61+ def test_override(self):
62+ """After typing 'i' followed by a space it should get auto-corrected to 'I'
63+ via the override mechanism.
64+
65+ """
66+ text_area = self.launch_test_input_area()
67+ self.ensure_focus_on_input(text_area)
68+ keyboard = Keyboard()
69+ self.addCleanup(keyboard.dismiss)
70+
71+ keyboard.type('i i i ')
72+
73+ expected = "I I I "
74+ self.assertThat(
75+ text_area.text,
76+ Eventually(Equals(expected))
77+ )
78+
79+ def test_double_space_single_character(self):
80+ """Spaces should be auto-inserted after double pressing space following
81+ a single character.
82+
83+ """
84+ text_area = self.launch_test_input_area()
85+ self.ensure_focus_on_input(text_area)
86+ keyboard = Keyboard()
87+ self.addCleanup(keyboard.dismiss)
88+
89+ keyboard.type('Test i ')
90+
91+ expected = "Test I. "
92+ self.assertThat(
93+ text_area.text,
94+ Eventually(Equals(expected))
95+ )
96+
97 def test_autocomplete(self):
98 """Tapping space in a field that supports auto-complete should
99 complete a word.
100@@ -627,6 +663,26 @@
101 Eventually(Equals(expected))
102 )
103
104+ def test_auto_punctuation(self):
105+ """A chinese full-stop character should be entered after space has
106+ been pressed three times (once to complete the character, once more
107+ to insert a space and then again to produce a full-stop.
108+
109+ """
110+ text_area = self.launch_test_input_area(self.label, self.hints)
111+ self.ensure_focus_on_input(text_area)
112+ keyboard = Keyboard()
113+ self.addCleanup(keyboard.dismiss)
114+
115+ keyboard.type('pinyin ')
116+
117+ expected = "拼音。 "
118+
119+ self.assertThat(
120+ text_area.text,
121+ Eventually(Equals(expected))
122+ )
123+
124
125 class UbuntuKeyboardSelection(UbuntuKeyboardTests):
126

Subscribers

People subscribed via source and target branches