Merge lp:~jonas-drange/ubuntu-system-settings/security-focus-correct-entry into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 1385
Merged at revision: 1410
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/security-focus-correct-entry
Merge into: lp:ubuntu-system-settings
Diff against target: 149 lines (+67/-1)
3 files modified
plugins/security-privacy/LockSecurity.qml (+25/-1)
plugins/security-privacy/PhoneLocking.qml (+1/-0)
tests/autopilot/ubuntu_system_settings/tests/test_security.py (+41/-0)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/security-focus-correct-entry
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Sebastien Bacher (community) Approve
Review via email: mp+256345@code.launchpad.net

Commit message

[security-privacy] give the focus to the right entry, if the current
unlock method is swipe then there is no "current password" so the new
input line should be the focussed one

Description of the change

[security-privacy] give the focus to the right entry, if the current
unlock method is swipe then there is no "current password" so the new
input line should be the focussed one

To post a comment you must log in.
1384. By Jonas G. Drange

use assertTrue

1385. By Jonas G. Drange

handle the case where security is swipe

Revision history for this message
Sebastien Bacher (seb128) wrote :

looks fine to me, thanks

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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/security-privacy/LockSecurity.qml'
2--- plugins/security-privacy/LockSecurity.qml 2015-02-09 15:46:27 +0000
3+++ plugins/security-privacy/LockSecurity.qml 2015-04-15 16:40:34 +0000
4@@ -29,6 +29,7 @@
5
6 ItemPage {
7 id: page
8+ objectName: "lockSecurityPage"
9 title: i18n.tr("Lock security")
10
11 // The user can still press the main "back" button or other buttons on the
12@@ -94,6 +95,7 @@
13
14 Dialog {
15 id: changeSecurityDialog
16+ objectName: "changeSecurityDialog"
17
18 function displayMismatchWarning() {
19 /* If the entry have the same length and different content,
20@@ -159,6 +161,7 @@
21
22 TextField {
23 id: currentInput
24+ objectName: "currentInput"
25 echoMode: TextInput.Password
26 inputMethodHints: {
27 if (changeSecurityDialog.oldMethod ===
28@@ -181,7 +184,10 @@
29 UbuntuSecurityPrivacyPanel.Swipe)
30 confirmButton.enabled = text.length > 0
31 }
32- Component.onCompleted: forceActiveFocus()
33+ Component.onCompleted: {
34+ if (securityPrivacy.securityType !== UbuntuSecurityPrivacyPanel.Swipe)
35+ forceActiveFocus()
36+ }
37 }
38
39 /* Using bindings since it is, according to documentation,
40@@ -226,6 +232,7 @@
41
42 TextField {
43 id: newInput
44+ objectName: "newInput"
45 echoMode: TextInput.Password
46 inputMethodHints: {
47 if (changeSecurityDialog.newMethod ===
48@@ -244,6 +251,10 @@
49 changeSecurityDialog.newMethod ===
50 UbuntuSecurityPrivacyPanel.Passphrase
51 onTextChanged: { displayMismatchWarning() }
52+ Component.onCompleted: {
53+ if (securityPrivacy.securityType === UbuntuSecurityPrivacyPanel.Swipe)
54+ forceActiveFocus()
55+ }
56 }
57
58 /* Using bindings since it is, according to documentation,
59@@ -434,6 +445,18 @@
60 id: unlockMethod
61 model: 3
62 delegate: OptionSelectorDelegate {
63+ objectName: {
64+ switch (index) {
65+ case 0:
66+ return "method_swipe";
67+ case 1:
68+ return "method_code";
69+ case 2:
70+ return "method_phrase";
71+ default:
72+ return "method_unknown";
73+ }
74+ }
75 text: index == 0 ? (unlockMethod.selectedIndex == 0 ? unlockMethod.swipe : unlockMethod.swipeAlt) :
76 (index == 1 ? (unlockMethod.selectedIndex == 1 ? unlockMethod.passcode : unlockMethod.passcodeAlt) :
77 (unlockMethod.selectedIndex == 2 ? unlockMethod.passphrase : unlockMethod.passphraseAlt))
78@@ -466,6 +489,7 @@
79 property bool passcode: securityPrivacy.securityType ===
80 UbuntuSecurityPrivacyPanel.Passcode
81
82+ objectName: "changePass"
83 enabled: parent.visible
84
85 text: passcode ? changePasscode : changePassphrase
86
87=== modified file 'plugins/security-privacy/PhoneLocking.qml'
88--- plugins/security-privacy/PhoneLocking.qml 2015-02-09 15:42:47 +0000
89+++ plugins/security-privacy/PhoneLocking.qml 2015-04-15 16:40:34 +0000
90@@ -46,6 +46,7 @@
91 property string passcode: i18n.tr("Passcode")
92 property string passphrase: i18n.tr("Passphrase")
93
94+ objectName: "lockSecurity"
95 text: i18n.tr("Lock security")
96 value: {
97 switch (securityPrivacy.securityType) {
98
99=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_security.py'
100--- tests/autopilot/ubuntu_system_settings/tests/test_security.py 2015-02-19 15:18:09 +0000
101+++ tests/autopilot/ubuntu_system_settings/tests/test_security.py 2015-04-15 16:40:34 +0000
102@@ -139,6 +139,47 @@
103 Equals(_('Phone locking'))
104 )
105
106+ def test_lock_security_focus_on_entry(self):
107+ self._go_to_phone_lock()
108+
109+ phone_lock_page = self.main_view.select_single(
110+ objectName='phoneLockingPage')
111+ selector = phone_lock_page.select_single(objectName='lockSecurity')
112+ self.main_view.scroll_to_and_click(selector)
113+
114+ lock_security_page = self.main_view.wait_select_single(
115+ objectName='lockSecurityPage')
116+
117+ # Find the selected security method.
118+ unlock_methods = ['method_swipe', 'method_code', 'method_phrase']
119+ selected_method = None
120+ for m in unlock_methods:
121+ if lock_security_page.select_single(objectName=m).selected:
122+ selected_method = m
123+
124+ # If swipe is the selected security, we trigger the dialog by
125+ # changing the security to method_code
126+ if selected_method == 'method_swipe':
127+ dialog_trigger = lock_security_page.select_single(
128+ objectName='method_code')
129+ input_selector = 'newInput'
130+ else:
131+ # If the security is anything besides swipe, we trigger the dialog
132+ # by changing the code/phrase.
133+ dialog_trigger = lock_security_page.select_single(
134+ objectName='changePass')
135+ input_selector = 'currentInput'
136+
137+ # Trigger dialog.
138+ self.main_view.scroll_to_and_click(dialog_trigger)
139+
140+ # Find the text input.
141+ dialog = self.main_view.wait_select_single(
142+ objectName='changeSecurityDialog')
143+ text_input = dialog.wait_select_single(
144+ objectName=input_selector)
145+ self.assertTrue(text_input.focus)
146+
147 def test_phone_lock_value(self):
148 self._go_to_phone_lock()
149 phone_lock_page = self.main_view.select_single(

Subscribers

People subscribed via source and target branches