Based on the Affine transformation examples shown in https://en.wikipedia.org/wiki/Affine_transformation , a 2D transformation matrix for scale, skew and translation in x and y axes can be shown as follows:
scaleX skewX tranxX
skewY scaleY transY
0 0 1
For example,
In order to scale a canvas by 2x in x and y axes, the transform that needs to be applied (multiplied with the transform matrix of the canvas) is:
2 0 0
0 2 0
0 0 1
So a canvas that is scaled using the above transformation matrix would look like:
The following shell script performs an action (tap) on the screen, then checks that a particular event does not happen on the device. It then performs another action (press back button) and then checks the target event happens only once. Then it closes a process and iterates through the same steps in a loop 50 times.
#!/bin/sh
# Clean up any reminiscent from previous run of the script
rm -rf script_logs
mkdir script_logs
for i in {1..50}
do
echo $i
echo "Clearing device logs"
adb logcat -c
echo "Starting log recording"
adb logcat >> script_logs/script_logs$i.txt &
logcat_pid=$!
echo "Clicking at a point on the screen"
adb shell input tap 200 300
echo "Waiting for 4 seconds for event to happen and logs generated"
sleep 4
events=`grep "<log_pattern>" script_logs/script_logs$i.txt | wc -l`
if [ $events == 0 ]
then
echo "No event found"
else
echo "$events were found, the test failed"
kill -9 $logcat_pid
exit 1
fi
adb shell input keyevent KEYCODE_BACK
echo "Waiting for 4 seconds for another event"
sleep 4
echo "Checking how many events were sent"
events=`grep "<log_pattern>" script_logs/script_logs$i.txt | wc -l`
if [ $events == 1 ]
then
echo "One and only one event was found"
else
echo "$events were found, the test failed"
kill -9 $logcat_pid
exit 1
fi
echo "Killing target process"
pid=`adb shell pidof <process_name>`
adb shell kill -9 $pid
echo "Stopping logcat"
kill -9 $logcat_pid
sleep 2
done
@Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel arg0, int arg1) { // TODO Auto-generated method stub arg0.writeString(asin); arg0.writeString(imageUrl); arg0.writeString(description); arg0.writeString(title); arg0.writeDouble(rating); }
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public Product createFromParcel(Parcel in) { return new Product(in); } public Product[] newArray(int size) { return new Product[size]; } }; }
Caution: 1. The order of reading data from the Parcel in Parcel argument constructor must be the same as order of writing the data in the Parcel in the writeToParcel method.
Initializing the objects of the class and sending as intent.