features/step_definitions/adb_steps.rb in ADB-0.5.4 vs features/step_definitions/adb_steps.rb in ADB-0.5.5

- old
+ new

@@ -1,5 +1,9 @@ +APK_FILE_NAME = 'features/support/ApiDemos.apk' +TEMP_FILE_NAME = 'cuke_test_file.txt' +TEMP_FILE_REMOTE_LOCATION = '/sdcard/' + When /^the adb server is started$/ do start_server end Then /^the adb server should be running$/ do @@ -23,18 +27,18 @@ end Then /^I should be able to install the sample application$/ do sn = devices[0] wait_for_device({:serial => sn}, 60) - install 'features/support/ApiDemos.apk', nil, {:serial => sn}, 60 + install APK_FILE_NAME, nil, {:serial => sn}, 60 last_stdout.should include 'Success' end Then /^I should be able to install the sample application using the "(.*?)" option$/ do |option| sn = devices[0] wait_for_device({:serial => sn}, 60) - install 'features/support/ApiDemos.apk', option, {:serial => sn}, 60 + install APK_FILE_NAME, option, {:serial => sn}, 60 end Then /^I should be able to uninstall the sample application$/ do sn = devices[0] uninstall 'com.example.android.apis', {:serial => sn} @@ -74,31 +78,31 @@ Then /^I should be able to push a file to the local device$/ do # be sure that the file doesn't already exist sn = devices[0] wait_for_device({:serial => sn}, 60) remount({:serial => sn}) - shell('rm /system/cuke_test_file.txt', {:serial => sn}) - shell('ls /system/cuke_test_file.txt', {:serial => sn}) + shell("rm #{TEMP_FILE_NAME}", {:serial => sn}) + shell("ls #{TEMP_FILE_NAME}", {:serial => sn}) last_stdout.should include 'No such file or directory' # create the temp file - File.open('cuke_test_file.txt', 'w'){ |f| f.write('Temporary file for adb testing. If found, please delete.') } + File.open(TEMP_FILE_NAME, 'w'){ |f| f.write('Temporary file for adb testing. If found, please delete.') } # push the file - push('cuke_test_file.txt', '/system/cuke_test_file.txt', {:serial => sn}) + push(TEMP_FILE_NAME, "#{TEMP_FILE_REMOTE_LOCATION}#{TEMP_FILE_NAME}", {:serial => sn}) last_stderr.should_not include 'failed to copy' end Then /^I should be able to pull a file from the local device$/ do # confirm that the file exists on the device and not locally sn = devices[0] wait_for_device({:serial => sn}, 60) remount({:serial => sn}) - shell("touch /system/cuke_test_file.txt", {:serial => sn}) + shell("touch #{TEMP_FILE_REMOTE_LOCATION}#{TEMP_FILE_NAME}", {:serial => sn}) # pull the file - pull('/system/cuke_test_file.txt', 'cuke_test_file.txt', {:serial => sn}) + pull "#{TEMP_FILE_REMOTE_LOCATION}#{TEMP_FILE_NAME}", #{TEMP_FILE_NAME}", {:serial => sn}) # confirm that the file was created - File.exists?('cuke_test_file.txt').should == true + File.exists?(TEMP_FILE_NAME).should == true end