misha beshkin - how to organize execution of tests on real android devices
TRANSCRIPT
How to organize
execution of tests
on real Android devices
Misha Beshkin. DevConfu 2. Jurmala May, 2014
Hello everyone!Glad to see you here on my lecture. I am going to tell you about an application, I developed to be able to run testing apk on many Android devices symultaniously.
Agenda
Little bit about me
A little about Nitro Nation and Creative Mobile
A lot about A.C.T.H.U.L.H.U
Qs&As
Waht we are going to speak today about?- Little bit about me- A little about Nitro Nation and Creative Mobile- A lot about A.C.T.H.U.L.H.U- Qs&As
Misha Beshkin
Was born and raised in Daugavpils, Latvia
Studied in Daugavpils University, Faculty of Humanities.
Moved to Tallinn in December 2003
Worked for Symantec Estonia as QA engineer
In 2013 changed for Creative Mobile
( 3) , . . . , :) 10 . , . .
Creative Mobile
As I said before, I am working in a company Creative Mobile. Creative Mobile develops and publishes games for mobile devices.
Nitro Nation
I am working on a project Nitro Nation. It is online drag-racing rame.
A.C.T.H.U.L.H.U
DreamLand Toys
Automation Controller. Tester's Hands Unloading LeadsHuman Unemployment
Here is the name of the system. We came to idea, that it looks like Cthulhu. It is a monster from Lovecraft's books.Actually, we named it A.C.T.H.U.L.H.U Automation Controller. Tester's Hands Unloading Leads to Human Unemployment.If you don't know what is Cthulhu, it is Octopus like monster. You can see it here.
How it looks like?
And here is how it looks like in our environment. Controller computer with lot of USB wires and lot of Android devices.
What does it do?
Download latest orset apkUninstall preciously installed version
Install apkCollect logsRun ActivitySave log for a device
Here we can see the algorithm, which shows how it works.
How devices are added?
String apkExe = "adb"; AndroidDebugBridge.initIfNeeded(false);AndroidDebugBridge adb = AndroidDebugBridge.createBridge(apkExe, true);if (adb == null) { System.err.println("Invalid ADB location."); System.exit(1);}
Init ADB
Prerequisites:Android SDK
DDMS library
ADB binary
A little bit of code. We can see how the devices are added to the list.First we need to initiate AndroidDebugBridge
How devices are added?
final List deviceList = new ArrayList();AndroidDebugBridge.addDeviceChangeListener(new AndroidDebugBridge.IDeviceChangeListener() {
@Override public void deviceChanged(IDevice device, int arg1) { // not implement }
@Override public void deviceConnected(IDevice device) {
System.out.println(String.format("%s connected", device.getSerialNumber())); Map properties = null; try { properties = getDeviceInformation(device); } catch (Exception e) { e.printStackTrace(); } if (properties!=null) { deviceList.add(device); } }
@Override public void deviceDisconnected(IDevice device) { System.out.println(String.format("%s disconnected", device.getSerialNumber()));}});
Add devices to list
And here we actually add devices to the list. I am using DeviceChangeListener.
Execute shell command
ShellOutputReceiver shellOutputReceiver= new ShellOutputReceiver("MemTotal");device.executeShellCommand("cat /proc/meminfo", shellOutputReceiver);String memory = shellOutputReceiver.toString();
Get RAM info
ShellOutputReceiver shellOutputReceiver= new ShellOutputReceiver("Processor");device.executeShellCommand("cat /proc/cpuinfo", shellOutputReceiver);String cpu = shellOutputReceiver.toString();
Get CPU info
ShellOutputReceiver shellOutputReceiver= new ShellOutputReceiver("GLES:");device.executeShellCommand("dumpsys", shellOutputReceiver);String gpu = shellOutputReceiver.toString();
Get GPU info
Some examples, what can be done with shell executions on devices. Note, that here we see ShellOutputReceiver. On next slide I will show how it works.
ShellOutputReceiver
public class ShellOutputReceiver implements IShellOutputReceiver { private String result; private int checkRunning = 0; private String grepPattern = "";
public ShellOutputReceiver(String grepPattern) { this.grepPattern = grepPattern; }
@Override public void addOutput(byte[] bytes, int i, int i2) { String result = ""; result = new String(bytes); String[] array = result.split("\r\n"); for (int i=0; i< array.length; i++) { if (array[i].contains(grepPattern)) { this.result = array[i]; break; } } }
@Override public void flush() { }
@Override public boolean isCancelled() { return false; }
@Override public String toString(){ return result; }}
ShellOutputReceiver code
Show Time
Show Time. I want to show you how it works in real time. It will take some 2-3 minutes. If someone want to share Android device and to try test our game on it, welcome. I can promise, nothing will be broken.
Questions & Answers
Thank you for attention
http://misha.beshkin.lv
mail://[email protected]
facebook://beshkin
twitter://midbar
phone://+372-53454663