From 787e6a7f501a90a10c7ea043e7d93a84cdef1153 Mon Sep 17 00:00:00 2001 From: adorokhine Date: Tue, 10 Jan 2017 18:19:50 -0800 Subject: Rename example folders so they do not start with a number. (#15) This causes problems for some systems. --- examples/ex1_standalone_app/README.md | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 examples/ex1_standalone_app/README.md (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md new file mode 100644 index 0000000..b5805ed --- /dev/null +++ b/examples/ex1_standalone_app/README.md @@ -0,0 +1,100 @@ +# Standalone App Snippet Example + +This tutorial shows you how to create a standalone Mobly snippet app, which runs +by itself and doesn't instrument a main app. + +## Tutorial + +1. Use Android Studio to create a new app project. + +1. Link against Mobly Snippet Lib in your `build.gradle` file + + ``` + dependencies { + compile 'com.google.android.mobly:snippetlib:0.0.1' + } + ``` + +1. Write a Java class implementing `Snippet` and add methods to trigger the + behaviour that you want. Annotate them with `@Rpc` + + ```java + package com.my.app; + ... + public class ExampleSnippet implements Snippet { + @Rpc(description='Returns a string containing the given number.') + public String getFoo(Integer input) { + return 'foo ' + input; + } + + @Override + public void shutdown() {} + } + ``` + +1. Add any classes that implement the `Snippet` interface in your + `AndroidManifest.xml` application section as `meta-data` + + ```xml + + + + ... + ``` + + +1. Add an `instrumentation` tag to your `AndroidManifest.xml` so that the + framework can launch your server through an `instrument` command. + + ```xml + + ... + + + ``` + +1. Build your apk and install it on your phone + +1. In your Mobly python test, connect to your snippet .apk in `setup_class` + + ```python + class HelloWorldTest(base_test.BaseTestClass): + def setup_class(self): + self.ads = self.register_controller(android_device) + self.dut1 = self.ads[0] + self.dut1.load_snippet(name='snippet', package='com.my.app.test') + ``` + +6. Invoke your needed functionality within your test + + ```python + def test_get_foo(self): + actual_foo = self.dut1.snippet.getFoo(5) + asserts.assert_equal("foo 5", actual_foo) + ``` + +## Running the example code + +This folder contains a fully working example of a standalone snippet apk. + +1. Compile the example + + ./gradlew examples:ex1_standalone_app:assembleDebug + +1. Install the apk on your phone + + adb install -r ./examples/ex1_standalone_app/build/outputs/apk/ex1_standalone_app-debug.apk + + +1. Create a python test to trigger `getFoo` following the above instructions. -- cgit v1.2.3 From a37aeec71f9d2a863a8d09c78ce981078bc8d6ba Mon Sep 17 00:00:00 2001 From: adorokhine Date: Tue, 10 Jan 2017 22:34:15 -0800 Subject: Update READMEs of examples to use snippet_shell. (#16) --- examples/ex1_standalone_app/README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index b5805ed..c816400 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -94,7 +94,14 @@ This folder contains a fully working example of a standalone snippet apk. adb install -r ./examples/ex1_standalone_app/build/outputs/apk/ex1_standalone_app-debug.apk - -1. Create a python test to trigger `getFoo` following the above instructions. +1. Use `snippet_shell` from mobly to trigger `getFoo()`: + + snippet_shell.py com.google.android.mobly.snippet.example1 + + >>> print(s.help()) + Known methods: + getBar(String) returns String // Returns the given string with the prefix "bar" + getFoo(Integer) returns String // Returns the given integer with the prefix "foo" + + >>> s.getFoo(5) + u'foo 5' -- cgit v1.2.3 From 83f36f778244c54424f9a3df737582a999b249c3 Mon Sep 17 00:00:00 2001 From: adorokhine Date: Fri, 13 Jan 2017 16:35:54 -0800 Subject: Update readmes to point to the real published version of the lib. (#22) --- examples/ex1_standalone_app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index c816400..824bafd 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -11,7 +11,7 @@ by itself and doesn't instrument a main app. ``` dependencies { - compile 'com.google.android.mobly:snippetlib:0.0.1' + compile 'com.google.android.mobly:mobly-snippet-lib:1.0.0' } ``` -- cgit v1.2.3 From 9384f22de36b20ed0cf55c3ad8f01f3e5d30f35a Mon Sep 17 00:00:00 2001 From: Alexander Dorokhine Date: Mon, 13 Feb 2017 14:38:52 -0800 Subject: Snippet lib release v1.0.1. (#35) --- examples/ex1_standalone_app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index 824bafd..47a4d41 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -11,7 +11,7 @@ by itself and doesn't instrument a main app. ``` dependencies { - compile 'com.google.android.mobly:mobly-snippet-lib:1.0.0' + compile 'com.google.android.mobly:mobly-snippet-lib:1.0.1' } ``` -- cgit v1.2.3 From f2fa372c8512c64149db7ffcb91921d4699c3f1c Mon Sep 17 00:00:00 2001 From: Alexander Dorokhine Date: Mon, 1 May 2017 14:18:32 -0700 Subject: Snippet lib release v1.1.0. (#55) --- examples/ex1_standalone_app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index 47a4d41..f5b4163 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -11,7 +11,7 @@ by itself and doesn't instrument a main app. ``` dependencies { - compile 'com.google.android.mobly:mobly-snippet-lib:1.0.1' + compile 'com.google.android.mobly:mobly-snippet-lib:1.1.0' } ``` -- cgit v1.2.3 From 04d34211496595a4ecabe996244d3956f8dec255 Mon Sep 17 00:00:00 2001 From: Alexander Dorokhine Date: Thu, 25 May 2017 18:56:36 -0700 Subject: Snippet lib release v1.2.0. --- examples/ex1_standalone_app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index f5b4163..3a1546a 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -11,7 +11,7 @@ by itself and doesn't instrument a main app. ``` dependencies { - compile 'com.google.android.mobly:mobly-snippet-lib:1.1.0' + compile 'com.google.android.mobly:mobly-snippet-lib:1.2.0' } ``` -- cgit v1.2.3 From a6f4252d923aae9b3a43c27fa9da7a2d6b7375dc Mon Sep 17 00:00:00 2001 From: "David T.H. Kao" Date: Tue, 15 Aug 2017 21:52:46 -0700 Subject: Add all examples to top level readme and massage descriptions. (#67) * Add all examples to top level readme and massage descriptions. * edits * Addressing comments * comments --- examples/ex1_standalone_app/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index 3a1546a..8e782b1 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -1,7 +1,8 @@ -# Standalone App Snippet Example +# Standalone Snippet App Example -This tutorial shows you how to create a standalone Mobly snippet app, which runs -by itself and doesn't instrument a main app. +This tutorial shows you how to create a standalone Mobly snippet app. To create +a snippet app that controls (instruments) another app under test, please see +(Example 2](../ex2_espresso/README.md). ## Tutorial -- cgit v1.2.3 From df4a0e82596c10c2c41f86168ff3d0ce3db60efa Mon Sep 17 00:00:00 2001 From: Ang Li Date: Tue, 23 Jan 2018 09:55:59 -0800 Subject: Minor clean ups (#87) * Remove accidental duplication of example1 source. * Fix apk paths in README. --- examples/ex1_standalone_app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index 8e782b1..428dd7d 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -93,7 +93,7 @@ This folder contains a fully working example of a standalone snippet apk. 1. Install the apk on your phone - adb install -r ./examples/ex1_standalone_app/build/outputs/apk/ex1_standalone_app-debug.apk + adb install -r ./examples/ex1_standalone_app/build/outputs/apk/debug/ex1_standalone_app-debug.apk 1. Use `snippet_shell` from mobly to trigger `getFoo()`: -- cgit v1.2.3 From 035c2b1332743d8d7c6a9087ab69d5bcef3cd5bb Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 24 Mar 2018 13:40:12 -0400 Subject: Snippet lib release v1.3.0. (#92) Snippet lib release v1.3.0. --- examples/ex1_standalone_app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index 428dd7d..a7ecaa8 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -12,7 +12,7 @@ a snippet app that controls (instruments) another app under test, please see ``` dependencies { - compile 'com.google.android.mobly:mobly-snippet-lib:1.2.0' + implementation 'com.google.android.mobly:mobly-snippet-lib:1.3.0' } ``` -- cgit v1.2.3 From 56a86a043b8ed30b86eb6a1f0d3cd56423cb6e31 Mon Sep 17 00:00:00 2001 From: Ang Li Date: Fri, 1 Jun 2018 02:46:57 -0700 Subject: Update gradle and project deps. (#94) --- examples/ex1_standalone_app/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index a7ecaa8..d62f9fc 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -2,7 +2,7 @@ This tutorial shows you how to create a standalone Mobly snippet app. To create a snippet app that controls (instruments) another app under test, please see -(Example 2](../ex2_espresso/README.md). +[Example 2](../ex2_espresso/README.md). ## Tutorial @@ -25,7 +25,7 @@ a snippet app that controls (instruments) another app under test, please see public class ExampleSnippet implements Snippet { @Rpc(description='Returns a string containing the given number.') public String getFoo(Integer input) { - return 'foo ' + input; + return "foo " + input; } @Override -- cgit v1.2.3 From 1a6913a8e4e5d24cb96b3ea4aa456d701dcbdb96 Mon Sep 17 00:00:00 2001 From: Xianyuan Jia Date: Thu, 23 Sep 2021 14:37:22 -0700 Subject: Snippet lib release v1.3.1 --- examples/ex1_standalone_app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/ex1_standalone_app/README.md') diff --git a/examples/ex1_standalone_app/README.md b/examples/ex1_standalone_app/README.md index d62f9fc..5d68e34 100644 --- a/examples/ex1_standalone_app/README.md +++ b/examples/ex1_standalone_app/README.md @@ -12,7 +12,7 @@ a snippet app that controls (instruments) another app under test, please see ``` dependencies { - implementation 'com.google.android.mobly:mobly-snippet-lib:1.3.0' + implementation 'com.google.android.mobly:mobly-snippet-lib:1.3.1' } ``` -- cgit v1.2.3