Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

4/27/2016

Google Cloud Test Lab with Robotium

Last time I setup Cloud Test Lab to execute instrumentation tests on the cloud, and Espresso was used as a default testing framework, but we can, of course, choose other options!

This time, let's use Robotium!


Setup

If you setup the NotePad app by following my previous post or  the official guide of Cloud Test Lab, then Robotium should be configured already.

Otherwise, you need to configure it by yourself in advance.
Since official tutorial doesn't cover Android Studio, you can refer these helpful web pages:


As well, if you'd like to use screenshot functions with your own app, you can find the instructions from the official guide.

Implementation

Default NotePadTest class (Espresso) is written like the following:


So, just we can make new test class with Robotium!
Robotium API reference is available from here.


Edit configuration & Run! 😄


[Android Studio 2.0]
[Robotium 5.3.0]

4/26/2016

A quick tour of Cloud Test Lab

Following a guide of Cloud Test Lab, I successfully made instrumentation tests on the cloud with Android Studio! 😄
https://developers.google.com/cloud-test-lab/

1. Create a billing account on Google Cloud Platform (free trial)

*You need to input your credit card info, but won't be charged unless you change the plan.

2. Create/edit .vmoptions file with this line:

here is how to find .vmoptions file. (You can make new one if not found)
(e.g.) Mac+AndroidStudio 2.0:  ~/Library/Preferences/AndroidStudio2.0/studio.vmoptions

3. Download and set up a sample app (or use your own app with instrumentation tests)
You can get a sample app (notepad.zip) from the guidance page.
https://developers.google.com/cloud-test-lab/android-studio#download_and_try_a_sample_app

4. Edit configuration
Select "Edit Configurations..." from app pulldown


Create new Android Tests


Configure general info by following the guidance page.
(You need to configure it properly if you use your own app)
https://developers.google.com/cloud-test-lab/android-studio#configure_a_test_matrix_and_run_a_test


You need to connect to Google Cloud Platform after you choose a target option "Cloud Test Lab Device Matrix":


Then you can choose a project on Google Cloud Platform or create a new one from "click here" link:




As well, you can choose test devices, platforms, locales and orientations from three dots button next to Matrix configuration:


5. Run your test!
You can see progress in Run window.


Output URL link leads to Test Lab page on Google Cloud Platform where you can view test results.




Since NotePadTest contains following line, you can check screenshots from the console.



Even you can see a video for each test case!

Done! 😄
As well, I wrote Cloud Test Lab + Robotium in next post!

[Android Studio 2.0]

4/14/2016

Change Seekbar thumb image size programatically

I needed to scale Seekbar thumb size based on physical device size (DP).
The layout was designed for 360 DP phones, so thumb image looked a bit too small for tablets.
And I didn't want to make other layout.xml just for this issue.

1. Added a static method to my Util class which scales thumb image size based on the current device size:


2. Then set padding to Seekbar so it wouldn't clip the scaled thumb image:


[Android Studio 2.0]
[compileSdkVersion 23]

Change font size based on physical device width

I needed to support both phones/tablets only with one layout file (layout-normal.xml).
The layout was very simple and originally designed for 360dp width phones, so there's no problem except for a bit small font size on 10 inches tablet.
I could just write a code to scale font size up for tablets.



[Android Studio 2.0]
[compileSdkVersion 23]