Replace this with something like
text_field = self.select_single(ubuntuuitoolkit.TextField, objectName='...')
text_field.write('...')
It will take care of clicking and waiting for it to be focused. It won't sleep the extra .3. Why is that needed? If it's not, just remove it. If it is, you can overwrite the write method, but please comment with the reason.
You need to explain that select argument in a docstring.
45 + self.keyboard.press_and_release("Enter")
Pressing Enter is something that you can't do from the phone, as a real user. Is there a button to click instead?
50 + def select_contact_from_list(self, name):
51 + """Select the given contact from the list
52 +
53 + :parameter name: name of the contact
54 + """
55 +
56 + contact_list = self.get_root_instance().select_single(
57 + 'ContactSimpleListView')
58 + list_item = contact_list.wait_select_single(
59 + 'Label', text='<b>{}</b>'.format(name))
60 + self.pointing_device.click_object(list_item)
This needs to be improved to follow closely the page object pattern.
First, the method shouldn't be in main_view. It should be on the component that executes the action. That's the new chat page, right?
Then, the you can make an object for ContactSimpleListView and add a method select_contact there.
Let me know if you need any kind of help with this.
19 text_entry = self.get_ newmessage_ textarea( ) device. click_object( text_entry) focus.wait_ for(True) field(text_ entry) type(str( message) , delay=0.2)
20 - self.pointing_
21 - text_entry.
22 - time.sleep(.3)
23 + self._focus_
24 self.keyboard.
Replace this with something like single( ubuntuuitoolkit .TextField, objectName='...') write(' ...')
text_field = self.select_
text_field.
It will take care of clicking and waiting for it to be focused. It won't sleep the extra .3. Why is that needed? If it's not, just remove it. If it is, you can overwrite the write method, but please comment with the reason.
29 + def type_contact_ phone_num( self, num_or_contact, select=False):
You need to explain that select argument in a docstring.
45 + self.keyboard. press_and_ release( "Enter" )
Pressing Enter is something that you can't do from the phone, as a real user. Is there a button to click instead?
50 + def select_ contact_ from_list( self, name): root_instance( ).select_ single( istView' ) list.wait_ select_ single( b>{}</b> '.format( name)) device. click_object( list_item)
51 + """Select the given contact from the list
52 +
53 + :parameter name: name of the contact
54 + """
55 +
56 + contact_list = self.get_
57 + 'ContactSimpleL
58 + list_item = contact_
59 + 'Label', text='<
60 + self.pointing_
This needs to be improved to follow closely the page object pattern.
First, the method shouldn't be in main_view. It should be on the component that executes the action. That's the new chat page, right?
Then, the you can make an object for ContactSimpleLi stView and add a method select_contact there.
Let me know if you need any kind of help with this.
The test you added is nice, thanks for that.