Add SMS snippet (#69)

* add sms snippet

* Remove unnecessary sleep

* Add missing copyright to IncomingSmsBroadcastReceiver

* Add sent confirmation for sendSms, this makes it an AsyncRpc.  - Added OutboundSmsReceiver to post events when SMS are send action is done. Posts error back if action is not successful. Also wait for all parts of a multipart message to be sent before posting event. Example usage now: event = s.sendSms('+15555678912', 'message message message').waitAndGet('SentSms')  - Renamed IncomingSmsBroardcastReceiver to SmsReceiver and make it a private class of SmsSnippet. Converted sendSms to AsyncRpc so it will post event back when message is sent

* Add sent confirmation for sendSms, this makes it an AsyncRpc.  - Added OutboundSmsReceiver to post events when SMS are send action is done. Posts error back if action is not successful. Also wait for all parts of a multipart message to be sent before posting event. Example usage now: event = s.sendSms('+15555678912', 'message message message').waitAndGet('SentSms')  - Renamed IncomingSmsBroardcastReceiver to SmsReceiver and make it a private class of SmsSnippet. Converted sendSms to AsyncRpc so it will post event back when message is sent

* Cleanup naming

* Align event key names with Java object property names.

* Use EventCache + built in mobly SnippetEvents to wait for SMS sent confirmation.

This shares code with EventSnippet in Mobly Snippet Lib. I'm not sure what the accepted practice is for sharing code across github projects? Should I refactor some of the event code in Mobly Bundle Lib into EventUtils, then use that in Mobly Bundled Snippets to avoid duplicating this?

I still want to check this is in as is, to have a working version earlier.

* Return data from event instead of fulll SnippetEvent. This way it works like so:

>>> result = s.sendSms("15551234567", "Hello world")
>>> pprint.pprint(result)
{u'sent': True}
>>>

* throw exception on error instead and some javadocs.

* cleanup
2 files changed
tree: 723f613b938e5dbea81fc508ac9c8d3f9f4d2c9f
  1. gradle/
  2. src/
  3. .gitignore
  4. build.gradle
  5. CONTRIBUTING.md
  6. gradle.properties
  7. gradlew
  8. LICENSE
  9. README.md
README.md

Mobly Bundled Snippets is a set of Snippets to allow Mobly tests to control Android devices by exposing a simplified verison of the public Android API suitable for testing.

We are adding more APIs as we go. If you have specific needs for certain groups of APIs, feel free to file a request in Issues.

Note: this is not an official Google product.

Usage

  1. Compile and install the bundled snippets

    ./gradlew assembleDebug
    adb install -d -r -g ./build/outputs/apk/mobly-bundled-snippets-debug.apk
    
  2. Use the Mobly snippet shell to interact with the bundled snippets

    snippet_shell.py com.google.android.mobly.snippet.bundled
    >>> print(s.help())
    Known methods:
      bluetoothDisable() returns void  // Disable bluetooth with a 30s timeout.
    ...
      wifiDisable() returns void  // Turns off Wi-Fi with a 30s timeout.
      wifiEnable() returns void  // Turns on Wi-Fi with a 30s timeout.
    ...
    
  3. To use these snippets within Mobly tests, load it on your AndroidDevice objects after registering android_device module:

    def setup_class(self):
      self.ad = self.register_controllers(android_device, min_number=1)[0]
      self.ad.load_snippet('api', 'com.google.android.mobly.snippet.bundled')
    
    def test_enable_wifi(self):
      self.ad.api.wifiEnable()
    

Other resources