If you just started to do this now, the best guide I can find is HERE. However, there are two places that might give you troubles. So when you are following the guide, keep two things in mind.
1). in step 3. After reboot, create new Guest OS on VirtualBox and choose MAC OS X server
10.7.2 does not show MAC OS X server in VirtualBox 4.2.4. However, both MAC OS X and MAC OS X (64 bit) will work. I have both installed and running well. (See pic)
2). After 16. choose our installed partition for booting using arrow key and press Enter
Your screen might seen to freeze with a process ring keeps spinning forever. May be you are thinking “oops, this does not work”. Don’t panic, you have the ubiquitous problem solving tool for Windows–reboot. No, do not reboot your Windows. Just reset the OS X you installed in VirtualBox menu.
You are done.
VirtualBox wins VM Player this time. I was not able to install it on VM Player.
A project I am working on requires testers to input some 2750 integers and their +0.1 value into the search box on an Android devices, and compare result from server to records in a XML file. Good thing is that the numbers are consecutive. Good candidate for automation. Note that it does not require any code access.
Combining codes in my earlier posts here and here, I was able to fully automate the process, only need to pause to compare the result.
The pros of this method: work straight out on the shell, don’t need source code, don’t need re-sign apk (as Robotium does).
The cons: For different screen resolution and Android version, you will need different code. Robotium wins here.
1) xml parsing! I already created sample code to use InstrumentationTestCase2 to do Android unit test, and compare the parsed xml result with “mock” server result. This will require source code in order to build the unit test to it. I don’t feel like reverse engineering the product so I will probably stop here. I already know how to do the unit test with the “mock” server result.
A couple of friends was asking how to do loop in shell scripts. Here is some simple code.
To loop in DOS:
@set /p start="From:"
@set /p end="To:"
@REM test condition
@IF %start% GTR %end% (GOTO wend)
@REM procedure where condition is "true"
@REM replace with real operations
@REM set new test value
@SET /a start=start+1
This will print the first number to the last number you input on the screen. Replace
@echo %start% with your real operation.
However, DOS script does not handle real numbers. So if I want to loop from 1 to 10, and print the number + 0.5, this will not work. One solution is using Perl. Second, using Linux. Here is the code for Linux.
echo -n "Enter starting code> "
echo -n "Enter ending code> "
for ((i=start; i<=end;i++))
echo "$i+0.1" | bc
If you input 1 and 5, this is print 1.5, 2.5, 3.5, 4.5, 5.5.
Note: I did not create these codes. They are from Google search. However, they are from different sources (especially the use of bc) so I lost the source link.
Thanks to SoftTeco. I found how to send touch event directly to Android devices. However, his code works for 2.3.3, but not ICS and Jelly Bean. (I did not test 3.x).
However, his great blog not only gives you the code, but also tells you how to get it. After searching valid code for ICS without any result, I just catch the codes using
adb shell getevent | grep event2
Then convert Hex to decimal.
Here is the code to touch the center of my GS2 (240, 400) running AOKP ICS 4.0.X ( I am lazy, this is NOT the newest version of AOKP)
adb shell sendevent /dev/input/event2 3 57 29
adb shell sendevent /dev/input/event2 3 53 240
adb shell sendevent /dev/input/event2 3 54 400
adb shell sendevent /dev/input/event2 3 48 29
adb shell sendevent /dev/input/event2 3 58 2
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 57 4294967295
adb shell sendevent /dev/input/event2 0 0 0
As you can see, only 8 lines of code is needed now, versus 16 lines for 2.x.
Also, if you run this on DOS cmd, copy all lines and add one more line of something, and paste it all to execute all 8 lines. If you don’t add one more line, you only run 7 lines and result is unpredictable.
You can also put all of them in one line with no new line break:
adb shell "sendevent /dev/input/event2 3 57 29;sendevent /dev/input/event2 3 53 240;sendevent /dev/input/event2 3 54 400;sendevent /dev/input/event2 3 48 29;sendevent /dev/input/event2 3 58 2;sendevent /dev/input/event2 0 0 0;sendevent /dev/input/event2 3 57 4294967295;sendevent /dev/input/event2 0 0 0;"
I did not test it on Jelly Bean, but I think it should be same.
Again, the credit goes to SOFTTE, I am merely using his method to get the code for a different version of Android.
Revision: Tested on Jelly Bean. Different code. So your best shot is getevent.