• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Mobly Bundled Snippets is a set of Snippets to allow Mobly tests to control
2Android devices by exposing a simplified version of the public Android API
3suitable for testing.
4
5We are adding more APIs as we go. If you have specific needs for certain groups
6of APIs, feel free to file a request in [Issues](https://github.com/google/mobly-bundled-snippets/issues).
7
8Note: this is not an official Google product.
9
10
11## Usage
12
131.  Compile and install the bundled snippets
14
15        ./gradlew assembleDebug
16        adb install -d -r -g ./build/outputs/apk/debug/mobly-bundled-snippets-debug.apk
17
181.  Use the Mobly snippet shell to interact with the bundled snippets
19
20        snippet_shell.py com.google.android.mobly.snippet.bundled
21        >>> print(s.help())
22        Known methods:
23          bluetoothDisable() returns void  // Disable bluetooth with a 30s timeout.
24        ...
25          wifiDisable() returns void  // Turns off Wi-Fi with a 30s timeout.
26          wifiEnable() returns void  // Turns on Wi-Fi with a 30s timeout.
27        ...
28
291.  To use these snippets within Mobly tests, load it on your AndroidDevice objects
30    after registering android_device module:
31
32    ```python
33    def setup_class(self):
34      self.ad = self.register_controllers(android_device, min_number=1)[0]
35      self.ad.load_snippet('api', 'com.google.android.mobly.snippet.bundled')
36
37    def test_enable_wifi(self):
38      self.ad.api.wifiEnable()
39    ```
40
41## Develop
42
43If you want to contribute, use the usual github method of forking and sending
44a pull request.
45
46Before sending a pull request, run the `presubmit` target to format and run
47lint over the code. Fix any issues it indicates. When complete, send the pull
48request.
49
50```shell
51./gradlew presubmit
52```
53
54This target will reformat the code with
55[googleJavaFormat](https://github.com/sherter/google-java-format-gradle-plugin)
56and run lint. The lint report should open in your default browser.
57
58Be sure to address *all* off the errors reported by lint. When finished and you
59run `presubmit` one last time you should see:
60
61> No Issues Found
62>   Congratulations!
63
64in your browser.
65
66## Other resources
67
68  * [Mobly multi-device test framework](http://github.com/google/mobly)
69  * [Mobly Snippet Lib](http://github.com/google/mobly-snippet-lib)
70