Permalink
Browse files

First commit

  • Loading branch information...
jonasmaturana committed Feb 5, 2012
0 parents commit b677a6f46830aa8dfbd099a9d12c29aba31b1c68
Showing with 2,504 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +13 −0 AndroidManifest.xml
  3. +12 −0 build.properties
  4. +178 −0 build.xml
  5. +10 −0 features/step_definitions/app_steps.rb
  6. +17 −0 features/step_definitions/assert_steps.rb
  7. +3 −0 features/step_definitions/check_box_steps.rb
  8. +12 −0 features/step_definitions/context_menu_steps.rb
  9. +8 −0 features/step_definitions/date_picker_steps.rb
  10. +3 −0 features/step_definitions/dummy_steps.rb
  11. +25 −0 features/step_definitions/enter_text_steps.rb
  12. +19 −0 features/step_definitions/location_steps.rb
  13. +27 −0 features/step_definitions/navigation_steps.rb
  14. +40 −0 features/step_definitions/press_button_steps.rb
  15. +26 −0 features/step_definitions/progress_steps.rb
  16. +8 −0 features/step_definitions/rotation_steps.rb
  17. +8 −0 features/step_definitions/time_picker_steps.rb
  18. +75 −0 features/support/hooks.rb
  19. +12 −0 features/support/locations.rb
  20. +12 −0 instrumentation_backend/.classpath
  21. +33 −0 instrumentation_backend/.project
  22. +15 −0 instrumentation_backend/AndroidManifest.xml
  23. +23 −0 instrumentation_backend/gen/com/lesspainful/simpleui/test/R.java
  24. BIN instrumentation_backend/libs/jackson-core-asl-1.9.1.jar
  25. BIN instrumentation_backend/libs/jackson-mapper-asl-1.9.1.jar
  26. BIN instrumentation_backend/libs/robotium-solo-2.5.jar
  27. +11 −0 instrumentation_backend/project.properties
  28. BIN instrumentation_backend/res/drawable-hdpi/ic_launcher.png
  29. BIN instrumentation_backend/res/drawable-ldpi/ic_launcher.png
  30. BIN instrumentation_backend/res/drawable-mdpi/ic_launcher.png
  31. +12 −0 instrumentation_backend/res/layout/main.xml
  32. +7 −0 instrumentation_backend/res/values/strings.xml
  33. +40 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/Command.java
  34. +188 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/InstrumentationBackend.java
  35. +61 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/Result.java
  36. +143 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/TestHelpers.java
  37. +11 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/Action.java
  38. +122 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/Actions.java
  39. +23 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/NullAction.java
  40. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/button/PressButtonNumber.java
  41. +27 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/button/PressButtonText.java
  42. +22 −0 ...mentation_backend/src/sh/calaba/instrumentationbackend/actions/button/PressImageButtonNumber.java
  43. +47 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
  44. +22 −0 ...mentation_backend/src/sh/calaba/instrumentationbackend/actions/checkbox/ToggleCheckboxNumber.java
  45. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressText.java
  46. +26 −0 .../src/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressTextAndSelectFromMenuById.java
  47. +22 −0 ...c/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressTextAndSelectFromMenuByIndex.java
  48. +26 −0 ...rc/sh/calaba/instrumentationbackend/actions/contextmenu/LongPressTextAndSelectFromMenuByText.java
  49. +31 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/gestures/ClickOnScreen.java
  50. +28 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/gestures/Swipe.java
  51. +26 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/helpers/ListActions.java
  52. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/list/LongPressListItems.java
  53. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/list/PressListItems.java
  54. +79 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/location/FakeGPSLocation.java
  55. +28 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/scrolling/ScrollDown.java
  56. +28 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/scrolling/ScrollUp.java
  57. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/softkey/GoBack.java
  58. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/softkey/PressMenu.java
  59. +24 −0 ...umentation_backend/src/sh/calaba/instrumentationbackend/actions/softkey/SelectFromMenuByText.java
  60. +31 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/text/AssertText.java
  61. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/text/ClearTextByIndex.java
  62. +32 −0 ...backend/src/sh/calaba/instrumentationbackend/actions/text/ClearTextFieldByContentDescription.java
  63. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/text/ClickOnText.java
  64. +32 −0 ...tion_backend/src/sh/calaba/instrumentationbackend/actions/text/EnterTextByContentDescription.java
  65. +22 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/text/EnterTextByIndex.java
  66. +33 −0 ...tation_backend/src/sh/calaba/instrumentationbackend/actions/time/SetDateByContentDescription.java
  67. +24 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/time/SetDateByIndex.java
  68. +34 −0 ...tation_backend/src/sh/calaba/instrumentationbackend/actions/time/SetTimeByContentDescription.java
  69. +26 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/time/SetTimeByIndex.java
  70. +63 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
  71. +66 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/view/ListAllViews.java
  72. +89 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/view/Press.java
  73. +24 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/wait/Wait.java
  74. +21 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForDialogClose.java
  75. +47 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForProgress.java
  76. +26 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/wait/WaitForText.java
  77. +78 −0 ...umentation_backend/src/sh/calaba/instrumentationbackend/actions/webview/CalabashChromeClient.java
  78. +43 −0 instrumentation_backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
@@ -0,0 +1,4 @@
+*.class
+bin
+staging
+instrumentation_backend/.settings
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="#TESTED_APP_PACKAGE#.test"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:label="instrumentation_backend">
+
+ <uses-library android:name="android.test.runner" />
+ </application>
+ <uses-sdk android:minSdkVersion="4" />
+ <instrumentation android:targetPackage="#TESTED_APP_PACKAGE#" android:name="android.test.InstrumentationTestRunner" />
+ <uses-permission android:name="android.permission.INTERNET" />
+</manifest>
@@ -0,0 +1,12 @@
+tested.package_name=sh.calabash.test
+tested.main_activity=sh.calabash.test.activities.LoginActivity
+tested.project.apk=YourApp.apk
+
+#You might have to update these values
+key.store=${user.home}/.android/debug.keystore
+key.store.password=android
+key.alias=androiddebugkey
+key.alias.password=android
+
+
+
178 build.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project name="" default="test" basedir=".">
+ <description>
+ Bits and pices plucked out of $ANDROID_HOME/tools/ant/build.xml
+ </description>
+
+ <property environment="env"/>
+ <property file="build.properties"/>
+ <property name="staging.dir" value="staging"/>
+ <property name="bin.dir" value="bin"/>
+ <property name="test.app" value="${bin.dir}/Test.apk"/>
+ <property name="test.app.aapt" value="${bin.dir}/Test_aapt.apk"/>
+ <property name="dex.file" value="${bin.dir}/classes.dex"/>
+ <property name="test.app.unsigned" value ="${bin.dir}/Test_unsigned.apk"/>
+ <property name="test.app.signed" value ="${bin.dir}/Test.apk"/>
+
+
+ <property name="android.lib" value="${env.ANDROID_HOME}/platforms/android-4/android.jar"/>
+ <path id="android.antlibs">
+ <pathelement path="${env.ANDROID_HOME}/tools/lib/anttasks.jar" />
+ </path>
+ <taskdef name="xpath" classname="com.android.ant.XPathTask" classpathref="android.antlibs"/>
+ <taskdef name="aapt" classname="com.android.ant.AaptExecTask" classpathref="android.antlibs" />
+ <taskdef name="apkbuilder" classname="com.android.ant.ApkBuilderTask" classpathref="android.antlibs" />
+
+
+ <uptodate property="test.app.upto.date" targetfile="${test.app.signed}" >
+ <srcfiles dir= "instrumentation_backend/" includes="**/*"/>
+ <srcfiles file="build.properties/"/>
+ </uptodate>
+
+ <path id="jar.libs.ref">
+ <fileset dir="${staging.dir}/libs/" includes="*.jar" />
+ </path>
+
+ <path id="cucumber.path">
+ <fileset dir="cucumber/" includes="*.jar" />
+ </path>
+
+ <path id="android.target.classpath">
+ <fileset dir="${env.ANDROID_HOME}/platforms/android-8/" includes="*.jar"/>
+ </path>
+
+ <target name="test" description="Run test features" depends="install.app, install.test">
+ <exec executable="cucumber">
+ <env key="TEST_PACKAGE_NAME" value="${tested.package_name}.test" />
+ <arg line="features/playlist.feature" />
+ </exec>
+ </target>
+
+
+ <target name="-init" unless="test.app.upto.date">
+ <mkdir dir="${staging.dir}"/>
+ <mkdir dir="${bin.dir}"/>
+ </target>
+
+ <target name="stage" unless="test.app.upto.date">
+ <antcall target="clean"/>
+ <antcall target="-init"/>
+ <antcall target="-prepare.manifest"/>
+ <antcall target="-prepare.testserver"/>
+ </target>
+
+ <target name="-prepare.manifest" description="Makes sure the manifest matches the tested application by looking at its manifest file">
+ <copy file="AndroidManifest.xml" todir="${staging.dir}"/>
+ <replace file="${staging.dir}/AndroidManifest.xml" token="#TESTED_APP_PACKAGE#" value="${tested.package_name}"/>
+ </target>
+
+ <target name="-prepare.testserver" description="Makes sure the testserver matches the tested application by looking at its manifest file">
+ <copy todir="${staging.dir}">
+ <fileset dir="instrumentation_backend"/>
+ </copy>
+ <replace file="${staging.dir}/src/sh/calaba/instrumentationbackend/InstrumentationBackend.java" token="#ACTIVITY_PACKAGE#" value="${tested.package_name}"/>
+
+ <replace file="${staging.dir}/src/sh/calaba/instrumentationbackend/InstrumentationBackend.java" token="#ACTIVITY_QUALIFIED_NAME#" value="${tested.main_activity}"/>
+ <exec executable="${env.ANDROID_HOME}/platform-tools/aapt" failonerror="true" output="${staging.dir}/assets/ids.txt">
+ <arg line="dump resources ${tested.project.apk}" />
+ </exec>
+ </target>
+
+
+ <target name="compile" depends="stage" unless="test.app.upto.date">
+ <javac
+ srcdir="${staging.dir}/src"
+ destdir="${bin.dir}"
+ verbose="${verbose}"
+ bootclasspathref="android.target.classpath"
+ classpath="${extensible.classpath}"
+ classpathref="jar.libs.ref">
+ </javac>
+ </target>
+
+
+ <target name="package" depends="compile, -aapt, -dex, -apk, -sign" unless="test.app.upto.date">
+ </target>
+
+ <target name="install.test" description="Install the test server">
+ <antcall target="package"/>
+ <echo message="Installing test"/>
+ <antcall target="-install.helper">
+ <param name="apk.to.install" value="${test.app}"/>
+ </antcall>
+ </target>
+
+ <target name="install.app" description="Install the app under test">
+ <antcall target="-install.helper">
+ <param name="apk.to.install" value="${tested.project.apk}"/>
+ </antcall>
+ </target>
+
+
+ <target name="clean" description="clean up">
+ <delete dir="${staging.dir}"/>
+ <delete dir="${bin.dir}"/>
+ </target>
+
+ <target name="-install.helper" description="Helper to install apk file">
+ <!-- Make sure path to apk is absolute -->
+ <property name="apk.full.path" location="${apk.to.install}"/>
+
+ <echo message="Installing:${apk.to.install}"/>
+
+ <exec executable="${env.ANDROID_HOME}/platform-tools/adb" failonerror="true">
+ <arg value="install" />
+ <arg value="-r" />
+ <arg path="${apk.full.path}" />
+ </exec>
+ </target>
+
+ <target name="-aapt" unless="test.app.upto.date">
+ <exec executable="${env.ANDROID_HOME}/platform-tools/aapt" failonerror="yes">
+ <arg line="package"/>
+ <arg line="-f"/>
+ <arg line="-M ${staging.dir}/AndroidManifest.xml"/>
+ <arg line="-F ${test.app.aapt}"/>
+ <arg line="-I ${android.lib}"/>
+ <arg line="-A ${staging.dir}/assets"/>
+ <arg line="-m"/>
+ <arg line="-J gen"/>
+ </exec>
+ </target>
+
+ <target name="-dex" depends ="-stage.libs" unless="test.app.upto.date">
+ <exec executable="${env.ANDROID_HOME}/platform-tools/dx" failonerror="yes">
+ <arg line="--dex"/>
+ <arg line="--output ${dex.file}"/>
+ <arg line="${bin.dir}"/>
+ </exec>
+ </target>
+
+ <target name="-stage.libs">
+ <copy todir="${bin.dir}/libs">
+ <fileset dir="instrumentation_backend/libs"/>
+ </copy>
+ </target>
+
+ <target name="-apk" unless="test.app.upto.date">
+ <exec executable="${env.ANDROID_HOME}/tools/apkbuilder" failonerror="yes">
+ <arg line="${test.app.unsigned}"/>
+ <arg line="-u"/>
+ <arg line="-z ${test.app.aapt}"/>
+ <arg line="-f ${dex.file}"/>
+ </exec>
+ </target>
+
+
+ <target name ="-sign" unless="test.app.upto.date">
+ <signjar
+ jar="${test.app.unsigned}"
+ signedjar="${test.app.signed}"
+ keystore="${key.store}"
+ storepass="${key.store.password}"
+ alias="${key.alias}"
+ keypass="${key.alias.password}"
+ verbose="false"/>
+ </target>
+
+</project>
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+Given /^My app is running$/ do
+# rotate_phone(0)
+end
+
+Given /^my app is running$/ do
+# rotate_phone(0)
+end
+
+
@@ -0,0 +1,17 @@
+Then /^I see the text "([^\"]*)"$/ do |text|
+ performAction('assert_text',text, true)
+end
+
+Then /^I see "([^\"]*)"$/ do |text|
+ performAction('assert_text', text, true)
+end
+
+Then /^I dont see the text "([^\"]*)"$/ do |text|
+ performAction('assert_text', text, false) #second param indicated that the text should _not_ be found
+end
+
+Then /^I dont see "([^\"]*)"$/ do |text|
+ performAction('assert_text', text, false) #second param indicated that the text should _not_ be found
+end
+
+
@@ -0,0 +1,3 @@
+Then /^I toggle checkbox number (\d+)$/ do |checkboxNumber|
+ performAction('toggle_numbered_checkbox', checkboxNumber)
+end
@@ -0,0 +1,12 @@
+
+Then /^I long press "([^\"]*)" and select item number "([^\"]*)"$/ do |text_to_press, index|
+ performAction('press_long_on_text_and_select_with_index', text_to_press, index)
+end
+
+Then /^I long press "([^\"]*)" and select "([^\"]*)"$/ do |text_to_press, context_text|
+ performAction('press_long_on_text_and_select_with_text', text_to_press, context_text)
+end
+
+Then /^I long press "([^\"]*)"$/ do |text_to_press|
+ performAction('press_long_on_text', text_to_press)
+end
@@ -0,0 +1,8 @@
+
+Given /^I set the date to "(\d\d-\d\d-\d\d\d\d)" on DatePicker with index "([^\"]*)"$/ do |date, index|
+ performAction('set_date_with_index', date, index)
+end
+
+Given /^I set the "([^\"]*)" date to "(\d\d-\d\d-\d\d\d\d)"$/ do |content_description, date|
+ performAction('set_date_with_description', content_description, date)
+end
@@ -0,0 +1,3 @@
+Then /^take picture$/ do
+ puts "Dummy implementation of take picture"
+end
@@ -0,0 +1,25 @@
+
+Then /^I enter "([^\"]*)" as "([^\"]*)"$/ do |text, target|
+ performAction('enter_text_into_named_field', text, target)
+end
+
+Then /^I enter "([^\"]*)" into input field number (\d+)$/ do |text, number|
+ performAction('enter_text_into_numbered_field',text, number)
+end
+
+Then /^I enter "([^\"]*)" into input field number (\d+) - beta$/ do |text, number|
+ performAction('enter_text_into_numbered_field_show_keyboard',text, number)
+end
+
+Then /^I enter "([^\"]*)" into "([^\"]*)"$/ do |text, name|
+ performAction('enter_text_into_named_field',text, name)
+end
+
+Then /^I clear "([^\"]*)"$/ do |name|
+ performAction('clear_named_field',name)
+end
+
+Then /^I clear input field number (\d+)$/ do |number|
+ performAction('clear_numbered_field',number)
+end
+
@@ -0,0 +1,19 @@
+Then /^I am in "([^\"]*)"$/ do |location|
+ set_gps_coordinates_from_location(location)
+end
+
+Then /^I am at "([^\"]*)"$/ do |location|
+ set_gps_coordinates_from_location(location)
+end
+
+Then /^I go to "([^\"]*)"$/ do |location|
+ set_gps_coordinates_from_location(location)
+end
+
+Then /^I am at ([-+]?[0-9]*\.?[0-9]+), ([-+]?[0-9]*\.?[0-9]+)$/ do |latitude, longitude|
+ set_gps_coordinates(latitude, longitude)
+end
+
+Then /^I to to ([-+]?[0-9]*\.?[0-9]+), ([-+]?[0-9]*\.?[0-9]+)$/ do |latitude, longitude|
+ set_gps_coordinates(latitude, longitude)
+end
@@ -0,0 +1,27 @@
+Then /^I go back$/ do
+ performAction('go_back')
+end
+
+Then /^I press the menu key$/ do
+ performAction('press_menu_key')
+end
+
+Then /^I swipe left$/ do
+ performAction('swipe', 'left')
+end
+
+Then /^I swipe right$/ do
+ performAction('swipe', 'right')
+end
+
+Then /^I select "([^\"]*)" from the menu$/ do |item|
+ performAction('select_from_menu', item)
+end
+
+Then /^I scroll down$/ do
+ performAction('scroll_down')
+end
+
+Then /^I scroll up$/ do
+ performAction('scroll_up')
+end
@@ -0,0 +1,40 @@
+Given /^I press the "([^\"]*)" button$/ do |buttonText|
+ performAction('press_button_with_text', buttonText)
+end
+
+Then /^I press button number (\d+)$/ do |buttonNumber|
+ puts "Press button step invoked"
+ performAction('press_button_number', buttonNumber)
+end
+
+Then /^I press image button number (\d+)$/ do |buttonNumber|
+ performAction('press_image_button_number', buttonNumber)
+end
+
+Then /^I press view with id "([^\"]*)"$/ do |view_id|
+ performAction('click_on_view_by_id',view_id)
+end
+
+Then /^I press view with name "([^\"]*)"$/ do |view_name|
+ performAction('press_view_with_name',view_name)
+end
+
+Then /^I press "([^\"]*)"$/ do |identifier|
+ performAction('press',identifier)
+end
+
+Then /^I click on screen (\d+)% from the left and (\d+)% from the top$/ do |x, y|
+ performAction('click_on_screen',x, y)
+end
+
+Then /^I touch the "([^\"]*)" text$/ do |text|
+ performAction('click_on_text',text)
+end
+
+Then /^I press list item number (\d+)$/ do |line_index|
+ performAction('press_list_item', 0, line_index)
+end
+
+Then /^I long press list item number (\d+)$/ do |line_index|
+ performAction('long_press_list_item', 0, line_index)
+end
Oops, something went wrong.

0 comments on commit b677a6f

Please sign in to comment.