Revert "Refactor docs to publish contents to readthedocs.io" (#618)
diff --git a/docs/Makefile b/docs/Makefile
index 600951b..9effe0e 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -3,7 +3,6 @@
# You can set these variables from the command line.
SPHINXOPTS =
-SPHINXAPIDOC = sphinx-apidoc
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
@@ -51,48 +50,45 @@
clean:
rm -rf $(BUILDDIR)/*
-autodoc:
- $(SPHINXAPIDOC) -f -o ./ ../mobly
-
.PHONY: html
-html: autodoc
+html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: dirhtml
-dirhtml: autodoc
+dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
-singlehtml: autodoc
+singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: pickle
-pickle: autodoc
+pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
.PHONY: json
-json: autodoc
+json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
.PHONY: htmlhelp
-htmlhelp: autodoc
+htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
.PHONY: qthelp
-qthelp: autodoc
+qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
@@ -102,7 +98,7 @@
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Mobly.qhc"
.PHONY: applehelp
-applehelp: autodoc
+applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@@ -111,7 +107,7 @@
"bundle."
.PHONY: devhelp
-devhelp: autodoc
+devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@@ -121,19 +117,19 @@
@echo "# devhelp"
.PHONY: epub
-epub: autodoc
+epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
.PHONY: epub3
-epub3: autodoc
+epub3:
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
@echo
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
.PHONY: latex
-latex: autodoc
+latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@@ -141,47 +137,47 @@
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
-latexpdf: autodoc
+latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: latexpdfja
-latexpdfja: autodoc
+latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: lualatexpdf
-lualatexpdf: autodoc
+lualatexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through lualatex..."
$(MAKE) PDFLATEX=lualatex -C $(BUILDDIR)/latex all-pdf
@echo "lualatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: xelatexpdf
-xelatexpdf: autodoc
+xelatexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through xelatex..."
$(MAKE) PDFLATEX=xelatex -C $(BUILDDIR)/latex all-pdf
@echo "xelatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: text
-text: autodoc
+text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
.PHONY: man
-man: autodoc
+man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
.PHONY: texinfo
-texinfo: autodoc
+texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@@ -189,57 +185,57 @@
"(use \`make info' here to do that automatically)."
.PHONY: info
-info: autodoc
+info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
.PHONY: gettext
-gettext: autodoc
+gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
.PHONY: changes
-changes: autodoc
+changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
.PHONY: linkcheck
-linkcheck: autodoc
+linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
.PHONY: doctest
-doctest: autodoc
+doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.PHONY: coverage
-coverage: autodoc
+coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
.PHONY: xml
-xml: autodoc
+xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
.PHONY: pseudoxml
-pseudoxml: autodoc
+pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
.PHONY: dummy
-dummy: autodoc
+dummy:
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
@echo
@echo "Build finished. Dummy builder generates no files."
diff --git a/docs/android_device_service.md b/docs/android_device_service.md
index f9b4ba1..220ff19 100644
--- a/docs/android_device_service.md
+++ b/docs/android_device_service.md
@@ -21,7 +21,7 @@
Here is a dummy service example:
-**my_service.py**
+`my_service.py`
```python
class Configs(object):
diff --git a/docs/conf.py b/docs/conf.py
index 02075ff..c116c19 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -81,7 +81,10 @@
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build',
'Thumbs.db',
- '.DS_Store']
+ '.DS_Store',
+ 'tutorial.md',
+ 'instrumentation_tutorial.md',
+ 'android_device_service.md']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
diff --git a/docs/index.rst b/docs/index.rst
index 779706e..093c955 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -6,51 +6,12 @@
Welcome to Mobly's documentation!
=================================
-**Mobly** is a Python-based test framework that specializes in supporting
-test cases that require multiple devices, complex environments, or custom
-hardware setups.
-
-Here are some example use cases:
-
-* P2P data transfer between two devices
-* Conference calls across three phones
-* Wearable device interacting with a phone
-* Internet-of-Things devices interacting with each other
-* Testing RF characteristics of devices with special equipment
-* Testing LTE network by controlling phones, base stations, and eNBs
-
-Mobly can support many different types of devices and equipment, and it's
-easy to plug your own device or custom equipment/service into Mobly.
-
-Mobly comes with a set of libraries to control common devices like Android
-devices.
-
-While developed by Googlers, Mobly is not an official Google product.
-
.. toctree::
- :maxdepth: 2
+ :maxdepth: 4
+ :caption: Contents:
- tutorial
- android_device_service
- instrumentation_tutorial
mobly
-License
--------
-
-Copyright 2019 Google Inc. All Rights Reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
Indices and tables
==================
diff --git a/docs/instrumentation_tutorial.md b/docs/instrumentation_tutorial.md
index 4291bc7..ff3d258 100644
--- a/docs/instrumentation_tutorial.md
+++ b/docs/instrumentation_tutorial.md
@@ -1,9 +1,8 @@
# Running Android instrumentation tests with Mobly
This tutorial shows how to write and execute Mobly tests for running Android
-instrumentation tests. For more details about instrumentation tests, please
-refer to
-[Android Studio](https://developer.android.com/studio/test/index.html).
+instrumentation tests. For more details about instrumentation tests, please refer to
+https://developer.android.com/studio/test/index.html.
## Setup Requirements
diff --git a/docs/mobly.controllers.android_device_lib.rst b/docs/mobly.controllers.android_device_lib.rst
new file mode 100644
index 0000000..a8d5395
--- /dev/null
+++ b/docs/mobly.controllers.android_device_lib.rst
@@ -0,0 +1,108 @@
+mobly.controllers.android_device_lib package
+============================================
+
+Subpackages
+-----------
+
+.. toctree::
+
+ mobly.controllers.android_device_lib.services
+
+Submodules
+----------
+
+mobly.controllers.android_device_lib.adb module
+-----------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.adb
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.callback_handler module
+------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.callback_handler
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.errors module
+--------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.errors
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.event_dispatcher module
+------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.event_dispatcher
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.fastboot module
+----------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.fastboot
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.jsonrpc_client_base module
+---------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.jsonrpc_client_base
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.jsonrpc_shell_base module
+--------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.jsonrpc_shell_base
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.service_manager module
+--------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.service_manager
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.sl4a_client module
+-------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.sl4a_client
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.snippet_client module
+----------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.snippet_client
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.snippet_event module
+--------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.snippet_event
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Module contents
+---------------
+
+.. automodule:: mobly.controllers.android_device_lib
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/mobly.controllers.android_device_lib.services.rst b/docs/mobly.controllers.android_device_lib.services.rst
new file mode 100644
index 0000000..602f9ab
--- /dev/null
+++ b/docs/mobly.controllers.android_device_lib.services.rst
@@ -0,0 +1,45 @@
+mobly.controllers.android_device_lib.services package
+=====================================================
+
+Submodules
+----------
+
+mobly.controllers.android_device_lib.services.base_service module
+-----------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.services.base_service
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.services.logcat module
+-----------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.services.logcat
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.services.sl4a_service module
+-----------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.services.sl4a_service
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.android_device_lib.services.snippet_management_service module
+-------------------------------------------------------------------------------
+
+.. automodule:: mobly.controllers.android_device_lib.services.snippet_management_service
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Module contents
+---------------
+
+.. automodule:: mobly.controllers.android_device_lib.services
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/mobly.controllers.attenuator_lib.rst b/docs/mobly.controllers.attenuator_lib.rst
new file mode 100644
index 0000000..38cf837
--- /dev/null
+++ b/docs/mobly.controllers.attenuator_lib.rst
@@ -0,0 +1,30 @@
+mobly.controllers.attenuator_lib package
+========================================
+
+Submodules
+----------
+
+mobly.controllers.attenuator_lib.minicircuits module
+----------------------------------------------------
+
+.. automodule:: mobly.controllers.attenuator_lib.minicircuits
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.attenuator_lib.telnet_scpi_client module
+----------------------------------------------------------
+
+.. automodule:: mobly.controllers.attenuator_lib.telnet_scpi_client
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+Module contents
+---------------
+
+.. automodule:: mobly.controllers.attenuator_lib
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/mobly.controllers.rst b/docs/mobly.controllers.rst
new file mode 100644
index 0000000..8871142
--- /dev/null
+++ b/docs/mobly.controllers.rst
@@ -0,0 +1,63 @@
+mobly.controllers package
+=========================
+
+Subpackages
+-----------
+
+.. toctree::
+
+ mobly.controllers.android_device_lib
+ mobly.controllers.attenuator_lib
+ mobly.controllers.sniffer_lib
+
+Submodules
+----------
+
+mobly.controllers.android_device module
+---------------------------------------
+
+.. automodule:: mobly.controllers.android_device
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.attenuator module
+-----------------------------------
+
+.. automodule:: mobly.controllers.attenuator
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.iperf_server module
+-------------------------------------
+
+.. automodule:: mobly.controllers.iperf_server
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.monsoon module
+--------------------------------
+
+.. automodule:: mobly.controllers.monsoon
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.sniffer module
+--------------------------------
+
+.. automodule:: mobly.controllers.sniffer
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+Module contents
+---------------
+
+.. automodule:: mobly.controllers
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/mobly.controllers.sniffer_lib.local.rst b/docs/mobly.controllers.sniffer_lib.local.rst
new file mode 100644
index 0000000..0c15a30
--- /dev/null
+++ b/docs/mobly.controllers.sniffer_lib.local.rst
@@ -0,0 +1,38 @@
+mobly.controllers.sniffer_lib.local package
+===========================================
+
+Submodules
+----------
+
+mobly.controllers.sniffer_lib.local.local_base module
+-----------------------------------------------------
+
+.. automodule:: mobly.controllers.sniffer_lib.local.local_base
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.sniffer_lib.local.tcpdump module
+--------------------------------------------------
+
+.. automodule:: mobly.controllers.sniffer_lib.local.tcpdump
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controllers.sniffer_lib.local.tshark module
+-------------------------------------------------
+
+.. automodule:: mobly.controllers.sniffer_lib.local.tshark
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+Module contents
+---------------
+
+.. automodule:: mobly.controllers.sniffer_lib.local
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/mobly.controllers.sniffer_lib.rst b/docs/mobly.controllers.sniffer_lib.rst
new file mode 100644
index 0000000..f728ce7
--- /dev/null
+++ b/docs/mobly.controllers.sniffer_lib.rst
@@ -0,0 +1,17 @@
+mobly.controllers.sniffer_lib package
+=====================================
+
+Subpackages
+-----------
+
+.. toctree::
+
+ mobly.controllers.sniffer_lib.local
+
+Module contents
+---------------
+
+.. automodule:: mobly.controllers.sniffer_lib
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/mobly.rst b/docs/mobly.rst
new file mode 100644
index 0000000..d855a22
--- /dev/null
+++ b/docs/mobly.rst
@@ -0,0 +1,133 @@
+mobly package
+=============
+
+Subpackages
+-----------
+
+.. toctree::
+
+ mobly.controllers
+
+Submodules
+----------
+
+mobly.asserts module
+--------------------
+
+.. automodule:: mobly.asserts
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.base_instrumentation_test module
+--------------------------------------
+
+.. automodule:: mobly.base_instrumentation_test
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.base_test module
+----------------------
+
+.. automodule:: mobly.base_test
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.config_parser module
+--------------------------
+
+.. automodule:: mobly.config_parser
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.controller_manager module
+-------------------------------
+
+.. automodule:: mobly.controller_manager
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.expects module
+--------------------
+
+.. automodule:: mobly.expects
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.keys module
+-----------------
+
+.. automodule:: mobly.keys
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.logger module
+-------------------
+
+.. automodule:: mobly.logger
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.records module
+--------------------
+
+.. automodule:: mobly.records
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.runtime_test_info module
+------------------------------
+
+.. automodule:: mobly.runtime_test_info
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.signals module
+--------------------
+
+.. automodule:: mobly.signals
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.suite_runner module
+-------------------------
+
+.. automodule:: mobly.suite_runner
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.test_runner module
+------------------------
+
+.. automodule:: mobly.test_runner
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mobly.utils module
+------------------
+
+.. automodule:: mobly.utils
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+Module contents
+---------------
+
+.. automodule:: mobly
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/tutorial.md b/docs/tutorial.md
index 3d50e7d..5fd98c0 100644
--- a/docs/tutorial.md
+++ b/docs/tutorial.md
@@ -6,23 +6,22 @@
## Setup Requirements
-* A computer with at least 2 USB ports.
-* Mobly package and its system dependencies installed on the computer.
-* One or two Android devices with the
- [Mobly Bundled Snippets](https://github.com/google/mobly-bundled-snippets)
- (MBS) installed. We will
- use MBS to trigger actions on the Android devices.
-* A working adb setup. To check, connect one Android device to the computer
- and make sure it has "USB debugging" enabled. Make sure the device shows up
- in the list printed by `adb devices`.
+* A computer with at least 2 USB ports.
+* Mobly package and its system dependencies installed on the computer.
+* One or two Android devices with the [Mobly Bundled Snippets]
+ (https://github.com/google/mobly-bundled-snippets) (MBS) installed. We will
+ use MBS to trigger actions on the Android devices.
+* A working adb setup. To check, connect one Android device to the computer
+ and make sure it has "USB debugging" enabled. Make sure the device shows up
+ in the list printed by `adb devices`.
## Example 1: Hello World!
-
+
Let's start with the simple example of posting "Hello World" on the Android
device's screen. Create the following files:
-
+
**sample_config.yml**
-
+
```yaml
TestBeds:
# A test bed where adb will find Android devices.
@@ -30,33 +29,32 @@
Controllers:
AndroidDevice: '*'
```
-
+
**hello_world_test.py**
-
+
```python
from mobly import base_test
from mobly import test_runner
from mobly.controllers import android_device
-
-
+
class HelloWorldTest(base_test.BaseTestClass):
+
def setup_class(self):
# Registering android_device controller module declares the test's
- # dependency on Android device hardware. By default, we expect at
- # least one object is created from this.
+ # dependency on Android device hardware. By default, we expect at least one
+ # object is created from this.
self.ads = self.register_controller(android_device)
self.dut = self.ads[0]
# Start Mobly Bundled Snippets (MBS).
self.dut.load_snippet('mbs', 'com.google.android.mobly.snippet.bundled')
-
+
def test_hello(self):
self.dut.mbs.makeToast('Hello World!')
-
-
+
if __name__ == '__main__':
- test_runner.main()
+ test_runner.main()
```
-
+
To execute:
```
@@ -67,10 +65,9 @@
A "Hello World!" toast notification appears on your device's screen.
-Within SampleTestBed's `Controllers` section, we used `AndroidDevice: '*'`
-to tell the test runner to automatically find all connected Android devices.
-You can also specify particular devices by serial number and attach extra
-attributes to the object:
+Within SampleTestBed's `Controllers` section, we used `AndroidDevice: '*'` to tell
+the test runner to automatically find all connected Android devices. You can also
+specify particular devices by serial number and attach extra attributes to the object:
```yaml
AndroidDevice:
@@ -91,20 +88,20 @@
from mobly import base_test
from mobly import test_runner
from mobly.controllers import android_device
-
+
class HelloWorldTest(base_test.BaseTestClass):
-
+
def setup_class(self):
self.ads = self.register_controller(android_device)
self.dut = self.ads[0]
self.dut.load_snippet('mbs', 'com.google.android.mobly.snippet.bundled')
-
+
def test_hello(self):
self.dut.mbs.makeToast('Hello World!')
-
+
def test_bye(self):
self.dut.mbs.makeToast('Goodbye!')
-
+
if __name__ == '__main__':
test_runner.main()
```
@@ -136,8 +133,7 @@
You could specify user parameters to be passed into your test class in the
config file.
-In the following config, we added a parameter `favorite_food` to be used in
-the test case.
+In the following config, we added a parameter `favorite_food` to be used in the test case.
**sample_config.yml**
@@ -207,8 +203,7 @@
In this example, we use one Android device to discover another Android device
via bluetooth. This test demonstrates several essential elements in test
-writing, like asserts, device debug tag, and general logging vs logging with
-device tag.
+writing, like asserts, device debug tag, and general logging vs logging with device tag.
**sample_config.yml**
@@ -298,27 +293,27 @@
There's potentially a lot more we could do in this test, e.g. check
the hardware address, see whether we can pair devices, transfer files, etc.
-To learn more about the features included in MBS, go to
-[MBS repo](https://github.com/google/mobly-bundled-snippets) to see how to
-check its help menu.
+To learn more about the features included in MBS, go to [MBS repo]
+(https://github.com/google/mobly-bundled-snippets) to see how to check its help
+menu.
-To learn more about Mobly Snippet Lib, including features like Espresso
-support and asynchronous calls, see the
-[snippet lib examples](https://github.com/google/mobly-snippet-lib/tree/master/examples).
+To learn more about Mobly Snippet Lib, including features like Espresso support
+and asynchronous calls, see the [snippet lib examples]
+(https://github.com/google/mobly-snippet-lib/tree/master/examples).
## Example 6: Generated Tests
A common use case in writing tests is to execute the same test logic multiple
-times, each time with a different set of parameters. Instead of duplicating
-the same test case with minor tweaks, you could use the **Generated tests**
-in Mobly.
+times, each time with a different set of parameters. Instead of duplicating the
+same test case with minor tweaks, you could use the **Generated tests** in
+Mobly.
Mobly could generate test cases for you based on a list of parameters and a
function that contains the test logic. Each generated test case is equivalent
to an actual test case written in the class in terms of execution, procedure
-functions (`setup`, `teardown`, `on_fail`), and result collection. You could
-also select generated test cases via the `--test_case` cli arg as well.
+functions (setup/teardown/on_fail), and result collection. You could also
+select generated test cases via the `--test_case` cli arg as well.
Here's an example of generated tests in action. We will reuse the "Example 1:
@@ -328,6 +323,7 @@
You could reuse the config file from Example 1.
The test class would look like:
+
**many_greetings_test.py**