Merge lp:~elopio/ubuntu-ui-toolkit/textfield_emulators into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Merged
Approved by: Cris Dywan
Approved revision: 818
Merged at revision: 919
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/textfield_emulators
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 226 lines (+152/-3)
4 files modified
modules/Ubuntu/Components/TextField.qml (+1/-0)
modules/Ubuntu/Components/TextInputPopover.qml (+1/-0)
tests/autopilot/ubuntuuitoolkit/emulators.py (+77/-3)
tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+73/-0)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/textfield_emulators
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Richard Huddie Pending
Javier Collado Pending
VĂ­ctor R. Ruiz Pending
Florian Boucault Pending
Review via email: mp+189796@code.launchpad.net

Commit message

Added the TextField autopilot emulator.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
I Ahmad (iahmad) wrote :

Looks good!

792. By Leo Arias

Added a comment about the clear parameter.

793. By Leo Arias

We have to wait only if the text field is not empty.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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: Needs Fixing (continuous-integration)
794. By Leo Arias

Merged with trunk.

795. By Leo Arias

Use BackSpace to delete.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:795
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1000/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/421
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3049
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/857
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/857
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/857/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/318
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4569
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4569/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3051
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3051/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2556
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2607
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/142
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/143

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1000/rebuild

review: Approve (continuous-integration)
796. By Leo Arias

First attempt at using the popover to select all the text. It requires autopilot 1.4.

797. By Leo Arias

Not really, with autopilot 1.3 we can select the root.

Revision history for this message
Leo Arias (elopio) wrote :

I have the job #1000. I should get a nice gift from CI.

798. By Leo Arias

Use the on-screen keyboard.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:797
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1001/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/422
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3050
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/858
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/858
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/858/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/319
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4570
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4570/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3052
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3052/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2557
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2608
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/144
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/145

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1001/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
799. By Leo Arias

Dismiss the keyboard after clicking the textfield.

800. By Leo Arias

Fixed pep8.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
801. By Leo Arias

Merged with trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
802. By Leo Arias

Fixed pep8.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:802
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1011/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/436
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3069
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/868
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/868
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/868/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/328
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4584
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4584/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3071
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3071/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2569
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2620
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/169
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/168

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1011/rebuild

review: Needs Fixing (continuous-integration)
803. By Leo Arias

pass OSK as a preferred backend.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:803
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1012/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/437
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3070
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/869
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/869
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/869/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/329
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4585
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4585/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3072
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3072/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2570
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2621
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/170
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/171

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1012/rebuild

review: Needs Fixing (continuous-integration)
804. By Leo Arias

Merged with trunk.

805. By Leo Arias

Added ubuntu-keyboard-autopilot to the autopilot tests dependencies.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:805
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1053/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/4
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/1
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/1
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/1/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2641
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2692
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/319
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/320

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1053/rebuild

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

FAILED: Continuous integration, rev:805
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1054/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/5
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/5
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/2
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/2
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/2/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/5
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/5/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2642
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2693
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/321
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/322

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1054/rebuild

review: Needs Fixing (continuous-integration)
806. By Leo Arias

Moved the keyboard to the textfield init.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:806
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/1064/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/25
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/25/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-amd64-ci/12
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/12
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-trusty-armhf-ci/12/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/20
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/25
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/25/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/25
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/25/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2656/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2707/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/351
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/350

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/1064/rebuild

review: Needs Fixing (continuous-integration)
807. By Leo Arias

Merged with trunk, p1.

808. By Leo Arias

Merged with trunk, p2.

809. By Leo Arias

Fixed pep8.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
810. By Leo Arias

Merged with trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
811. By Leo Arias

Merged with trunk.

812. By Leo Arias

Remove the exception catch.

813. By Leo Arias

Use the keyboard focused_type context manager.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
814. By Leo Arias

Merged with trunk.

815. By Leo Arias

For now, do not use the osk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
816. By Leo Arias

Workaround mako not showing the popover.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
817. By Leo Arias

Added a comment about the bug that prevents us showing the popover.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Christian, I requested a review for this and they told me you might be affected by my changes. So, can you please take a look?

818. By Leo Arias

Merged with trunk.

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

I don't quite like that clear() is very dynamic - if a test is expected to have a text field with a clear button using that method will hide errors involving it not being there and this extends to write. I'd rather have - clear_with_button, clear_with_keys and write without clearing out of the box. Depending on the test convenience might be a factor but I'd hesitate before seeing what it looks like in practise.

test_textinput.py needs to be updated to use the new emulator.

review: Needs Fixing
Revision history for this message
Leo Arias (elopio) wrote :

Please notice that the autopilot tests that will be using these helpers are not the right place to check if the text field has the clear button or not. What we are trying to test with autopilot are high level user stories, so the goal of the tests would be to add your U1 account to system settings, for example. In order to do that, we will need to fill a text field, but we really don't care how autopilot does the filling.

We should already have qt tests to check that depending on the hasClearButton property, the right components are displayed. And we should have autopilot tests to check that you can write and clear text fields with and without clear button. So we don't have to check those things on the apps or on the emulators.

So, lets say that design suggest to remove the clear button from a text field on the online accounts app. That change shouldn't require a change on the autopilot test for the add u1 story. That should just require a change on the lower level qt tests.

Having said that, if you still feel we will eventually need to call clear with button or clear with keys directly, I'll make them public methods of the emulator API. So we have clear, for when we don't care how the clear is done, and the other two for when we care.

Let me know what do you think about this.

About test_textinput.py, can I do it in a separate branch? I added it to my TODO for next week, but I would like to keep the MPs small.

Thanks for reviewing!

Revision history for this message
Cris Dywan (kalikiana) wrote :

I see the point of view now, it makes sense. High level app tests probably see it as an unnecessary detail which is handled in the components so UITK tests would cover that.

And yes, separate branch sounds fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'modules/Ubuntu/Components/TextField.qml'
--- modules/Ubuntu/Components/TextField.qml 2014-01-10 15:33:02 +0000
+++ modules/Ubuntu/Components/TextField.qml 2014-01-15 06:43:05 +0000
@@ -948,6 +948,7 @@
948948
949 AbstractButton {949 AbstractButton {
950 id: clearButton950 id: clearButton
951 objectName: "clear_button"
951 property url iconSource: control.__styleInstance.iconSource952 property url iconSource: control.__styleInstance.iconSource
952 anchors {953 anchors {
953 top: parent.top954 top: parent.top
954955
=== modified file 'modules/Ubuntu/Components/TextInputPopover.qml'
--- modules/Ubuntu/Components/TextInputPopover.qml 2013-08-07 12:50:35 +0000
+++ modules/Ubuntu/Components/TextInputPopover.qml 2014-01-15 06:43:05 +0000
@@ -19,6 +19,7 @@
19import "Popups" 0.119import "Popups" 0.1
2020
21ActionSelectionPopover {21ActionSelectionPopover {
22 objectName: "text_input_popover"
22 actions: ActionList {23 actions: ActionList {
23 Action {24 Action {
24 text: i18n.tr("Select All")25 text: i18n.tr("Select All")
2526
=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
--- tests/autopilot/ubuntuuitoolkit/emulators.py 2014-01-09 19:24:01 +0000
+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2014-01-15 06:43:05 +0000
@@ -26,6 +26,7 @@
26)26)
27from autopilot.introspection import dbus27from autopilot.introspection import dbus
2828
29
29_NO_TABS_ERROR = 'The MainView has no Tabs.'30_NO_TABS_ERROR = 'The MainView has no Tabs.'
3031
31logger = logging.getLogger(__name__)32logger = logging.getLogger(__name__)
@@ -49,6 +50,12 @@
49 return input.Pointer(device=input_device_class.create())50 return input.Pointer(device=input_device_class.create())
5051
5152
53def get_keyboard():
54 """Return the keyboard device."""
55 # TODO return the OSK if we are on the phone. --elopio - 2014-01-13
56 return input.Keyboard.create()
57
58
52def check_autopilot_version():59def check_autopilot_version():
53 """Check that the Autopilot installed version matches the one required.60 """Check that the Autopilot installed version matches the one required.
5461
@@ -69,8 +76,6 @@
69 check_autopilot_version()76 check_autopilot_version()
70 super(UbuntuUIToolkitEmulatorBase, self).__init__(*args)77 super(UbuntuUIToolkitEmulatorBase, self).__init__(*args)
71 self.pointing_device = get_pointing_device()78 self.pointing_device = get_pointing_device()
72 # TODO it would be nice to have access to the screen keyboard if we are
73 # on the touch UI -- elopio - 2013-09-04
7479
7580
76class MainView(UbuntuUIToolkitEmulatorBase):81class MainView(UbuntuUIToolkitEmulatorBase):
@@ -396,7 +401,11 @@
396 'Button with text "{0}" not found.'.format(text))401 'Button with text "{0}" not found.'.format(text))
397 self.pointing_device.click_object(button)402 self.pointing_device.click_object(button)
398 if self.autoClose:403 if self.autoClose:
399 self.visible.wait_for(False)404 try:
405 self.visible.wait_for(False)
406 except dbus.StateNotFoundError:
407 # The popover was removed from the tree.
408 pass
400409
401 def _get_button(self, text):410 def _get_button(self, text):
402 buttons = self.select_many('Empty')411 buttons = self.select_many('Empty')
@@ -446,6 +455,71 @@
446 self.checked.wait_for(not original_state, timeout)455 self.checked.wait_for(not original_state, timeout)
447456
448457
458class TextField(UbuntuUIToolkitEmulatorBase):
459 """TextField Autopilot emulator."""
460
461 def __init__(self, *args):
462 super(TextField, self).__init__(*args)
463 self.keyboard = get_keyboard()
464
465 def write(self, text, clear=True):
466 """Write into the text field.
467
468 :parameter text: The text to write.
469 :parameter clear: If True, the text field will be cleared before
470 writing the text. If False, the text will be appended at the end
471 of the text field. Default is True.
472
473 """
474 with self.keyboard.focused_type(self):
475 if clear:
476 self.clear()
477 else:
478 if not self.is_empty():
479 self.keyboard.press_and_release('End')
480 self.keyboard.type(text)
481
482 def clear(self):
483 """Clear the text field."""
484 if not self.is_empty():
485 if self.hasClearButton:
486 self._click_clear_button()
487 else:
488 self._clear_with_keys()
489 self.text.wait_for('')
490
491 def is_empty(self):
492 """Return True if the text field is empty. False otherwise."""
493 return self.text == ''
494
495 def _click_clear_button(self):
496 clear_button = self.select_single(
497 'AbstractButton', objectName='clear_button')
498 if not clear_button.visible:
499 self.pointing_device.click_object(self)
500 self.pointing_device.click_object(clear_button)
501
502 def _clear_with_keys(self):
503 if platform.model() == 'Desktop':
504 self._select_all()
505 else:
506 # Touch tap currently doesn't have a press_duration parameter, so
507 # we can't show the popover. Reported as bug http://pad.lv/1268782
508 # --elopio - 2014-01-13
509 self.keyboard.press_and_release('End')
510 while not self.is_empty():
511 # We delete with backspace because the on-screen keyboard has that
512 # key.
513 self.keyboard.press_and_release('BackSpace')
514
515 def _select_all(self):
516 self.pointing_device.click_object(self, press_duration=1)
517 root = self.get_root_instance()
518 main_view = root.select_single(MainView)
519 popover = main_view.get_action_selection_popover('text_input_popover')
520 popover.click_button_by_text('Select All')
521
522
449class QQuickListView(UbuntuUIToolkitEmulatorBase):523class QQuickListView(UbuntuUIToolkitEmulatorBase):
450524
451 @autopilot_logging.log_action(logger.info)525 @autopilot_logging.log_action(logger.info)
452526
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py'
--- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2014-01-10 03:45:29 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2014-01-15 06:43:05 +0000
@@ -882,6 +882,79 @@
882 self.assertEqual(self.header.title, 'Page 0')882 self.assertEqual(self.header.title, 'Page 0')
883883
884884
885class TextFieldTestCase(tests.QMLStringAppTestCase):
886
887 test_qml = ("""
888import QtQuick 2.0
889import Ubuntu.Components 0.1
890
891MainView {
892 width: units.gu(48)
893 height: units.gu(60)
894
895 Item {
896 TextField {
897 id: simpleTextField
898 objectName: "simple_text_field"
899 }
900 TextField {
901 id: textFieldWithoutClearButton
902 objectName: "text_field_without_clear_button"
903 hasClearButton: false
904 anchors.top: simpleTextField.bottom
905 }
906 }
907}
908""")
909
910 def setUp(self):
911 super(TextFieldTestCase, self).setUp()
912 self.simple_text_field = self.main_view.select_single(
913 emulators.TextField, objectName='simple_text_field')
914
915 def test_text_field_emulator(self):
916 self.assertIsInstance(self.simple_text_field, emulators.TextField)
917
918 def test_write(self):
919 self.simple_text_field.write('test')
920 self.assertEqual(self.simple_text_field.text, 'test')
921
922 def test_clear_with_clear_button(self):
923 self.simple_text_field.write('test')
924 self.simple_text_field.clear()
925 self.assertEqual(self.simple_text_field.text, '')
926
927 def test_clear_without_clear_button(self):
928 text_field = self.main_view.select_single(
929 emulators.TextField, objectName='text_field_without_clear_button')
930 text_field.write('test')
931 text_field.clear()
932 self.assertEqual(text_field.text, '')
933
934 def test_clear_and_write(self):
935 self.simple_text_field.write('test1')
936 self.simple_text_field.write('test2')
937 self.assertEqual(self.simple_text_field.text, 'test2')
938
939 def test_write_without_clear(self):
940 self.simple_text_field.write('test1')
941 self.simple_text_field.write('test2', clear=False)
942 self.assertEqual(self.simple_text_field.text, 'test1test2')
943
944 def test_write_without_clear_writes_at_the_end(self):
945 self.simple_text_field.write(
946 'long text that will fill more than half of the text field.')
947 self.simple_text_field.write('append', clear=False)
948 self.assertEqual(
949 self.simple_text_field.text,
950 'long text that will fill more than half of the text field.append')
951
952 def test_is_empty(self):
953 self.assertTrue(self.simple_text_field.is_empty())
954 self.simple_text_field.write('test')
955 self.assertFalse(self.simple_text_field.is_empty())
956
957
885class ComposerSheetTestCase(tests.QMLStringAppTestCase):958class ComposerSheetTestCase(tests.QMLStringAppTestCase):
886959
887 test_qml = ("""960 test_qml = ("""

Subscribers

People subscribed via source and target branches

to status/vote changes: