I need an Android application which recognizes a "shake" in three directions/planes. And, I want Android JUnit tests which verify the application works correctly.
A "shake" is defined as someone moving the phone back and forth three times in the vertical, horizontal or side-to-side plane.
The speed of the shake should be variable, so someone could shake very quickly, or very slowly, and it would still recognize (within a tolerance) that this was a "shake."
For example, if I shake the phone up, down, up, down, up, down, then I want the application to provide a "toast" which says "vertical shake!"
If I move the phone left, right, left, right, left, right, then I want the application to provide a toast which says "side shake!"
If I move the phone forward, back, forward, back, forward, back, then I want the application to provide a toast which says "horizontal shake"
The Android accelerometer provides recognition of X, Y, and Z acceleration. So, basically, this application would be checking for changes to the accelerometer.
One required deliverable: I want TEST cases. So, I would like to have the application print out the accelerometer into the adb logcat console, like this:
1359111821594, 0.03891907, -0.459245, 9.924362
1359111821660, 0.11555969, -0.4209247, 9.924362
1359111821727, 0.03891907, -0.4209247, 9.924362
1359111821794, 0.07723938, -0.38260436, 9.886042
1359111821861, 0.11555969, -0.4209247, 9.962683
1359111821927, 0.11555969, -0.38260436, 9.886042
This is timestamp, X, Y, Z.
I want JUnit tests which verify the Android application is recognizes the "shake" in each of the three directions.
The best way to do this would be to have the application print out the timestamp, X, Y, Z , and then use adb logcat and capture this to a file. Then, read in the file and use them inside the tests. So, you probably would have three sets of files: an [login to view URL] file for successful "shake" in the X direction, a [login to view URL] file for successful shake in the Y direction, etc. AND, you would have three sets of files for failures, where the person shakes left, right, then up, down, and the tests cases indicate this is not a "shake" (and clears the state of the application).