calabash / calabash-ios-server

An embedded HTTP server for performing queries and test automation
Other
87 stars 82 forks source link

GET /clearText: call delegate methods and post notifications after removing text from first responder #382

Closed jescriba closed 7 years ago

jescriba commented 7 years ago

Motivation Currently clearing text doesn't trigger any of the appropriate delegate methods or NSNotifications - this PR attempts to address that.

Update - I rebased to use the LPRoute approach.

Tested locally using GET on the /clearText route. Note - now this requires the keyboard to be open before clearing text.

Accounts for possible scenarios: UITextField Calls shouldChangeCharactersInRange (when selecting all and cut) and shouldClear (when selecting the 'x' button) on delegate Fires UITextFieldTextDidChange NSNotification

UITextView Calls shouldChangeTextIn, textViewDidChangeSelection, textViewDidChange on delegate Fires UITextViewTextDidChange NSNotification

UISearchBar Calls shouldChangeTextIn, textDidChange on delegate no notifications fired

UIKeyInput Implements this protocol in which case it attempts to deleteBackward until hasText returns false

TODO

Tests

Scenario: LPServer GET /clearText
Given the TestApp has launched
And I am looking at the Misc tab
And I am looking at the Text Input page
When I use the LPServer to clear text
And there is no visible keyboard on the Text Input page
Then an error is raised about clear text requiring a first responder
Then I clear text with the LPServer in the UITextField
Then I clear text with the LPServer in the UITextView
Then I clear text with the LPServer in the UIKeyInput view
Given I am looking at the Pan tab
And I am looking at the Company table
Then I clear text with the LPServer in the UISearchBar
jmoody commented 7 years ago

Shares some logic with PR #381 so we may want to refactor some if we merge both

Assume that #381 will not be merged. If it is ever merged, we can perform an extract refactor.

Another point I was concerned with is the while(hasText) { deleteBackward } logic

Add comment about timing out or limiting to a number of characters.

Add tests. What's the most appropriate way of adding test?

I don't think there is any way to add meaningful unit tests. The best we can do is add integration tests, either with Cucumber or UITest.

I was wrong about the LPTestTarget containing the required text input views.

Here is a depressing summary of the test applications that you might use. No application has every view that is required. CalSmoke is the closest. There might be a Xamarin test app with some of these.

I think the best place is for these views is actually in the DeviceAgent TextApp because we will eventually want to know if DeviceAgent can handle interacting with these kinds of views.

jmoody commented 7 years ago

Jenkins test this please.