acouchi 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 1.9.3-p0
1
+ 1.9.3-p194
data/README.md CHANGED
@@ -1,11 +1,6 @@
1
1
  Acouchi
2
2
  =======
3
3
 
4
- WARNING
5
- -------
6
-
7
- This gem was initially a spike, and has since then become rather useful. It is very much not unit tested. For this I apologise, and offer up this picture of an [Acouchi](http://en.wikipedia.org/wiki/Acouchi):
8
-
9
4
  ![acouchi](https://github.com/AndrewVos/acouchi/raw/master/acouchi.jpg)
10
5
 
11
6
  Requirements
@@ -43,6 +38,9 @@ Cucumber
43
38
  require "acouchi/rspec/matchers"
44
39
 
45
40
  configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
41
+ configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
42
+ configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
43
+
46
44
  Acouchi::Cucumber.prepare(configuration)
47
45
 
48
46
  def page
@@ -4,7 +4,7 @@
4
4
  android:versionCode="1"
5
5
  android:versionName="1.0">
6
6
 
7
- <uses-sdk android:targetSdkVersion="16" />
7
+ <uses-sdk android:targetSdkVersion="17" />
8
8
 
9
9
  <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
10
10
  <activity android:name="StartupActivity"
@@ -6,6 +6,8 @@ require "acouchi/rspec/matchers"
6
6
  desc "build project with Acouchi code included"
7
7
  task :build do
8
8
  configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
9
+ configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
10
+ configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
9
11
  Acouchi::ProjectBuilder.new(configuration).build
10
12
  end
11
13
 
@@ -16,10 +18,12 @@ end
16
18
  desc "open up an acouchi console"
17
19
  task :console do
18
20
  configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
21
+ configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
22
+ configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
19
23
  test_runner = Acouchi::TestRunner.new(configuration)
20
24
  test_runner.start
21
- page = Acouchi::Solo.new
25
+ page = Acouchi::Solo.new(configuration)
22
26
  require "pry"
23
27
  binding.pry
24
28
  test_runner.stop
25
- end
29
+ end
@@ -3,8 +3,11 @@ require "acouchi/cucumber"
3
3
  require "acouchi/rspec/matchers"
4
4
 
5
5
  configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
6
+ configuration.device =ENV["ACOUCHI_DEVICE"] if ENV["ACOUCHI_DEVICE"]
7
+ configuration.port =ENV["ACOUCHI_PORT"] if ENV["ACOUCHI_PORT"]
8
+
6
9
  Acouchi::Cucumber.prepare(configuration)
7
10
 
8
11
  def page
9
12
  Acouchi::Cucumber.page
10
- end
13
+ end
@@ -6,19 +6,19 @@ module Acouchi
6
6
  end
7
7
 
8
8
  def install_apk
9
- ProcessLauncher.new(
10
- Executables.adb,
11
- "install",
12
- @apk_path
13
- ).start_and_crash_if_process_fails
9
+ if @configuration.device
10
+ ProcessLauncher.new(Executables.adb,"-s",@configuration.device,"install",@apk_path).start_and_crash_if_process_fails
11
+ else
12
+ ProcessLauncher.new(Executables.adb,"install",@apk_path).start_and_crash_if_process_fails
13
+ end
14
14
  end
15
15
 
16
16
  def uninstall_apk
17
- ProcessLauncher.new(
18
- Executables.adb,
19
- "uninstall",
20
- @configuration.target_package
21
- ).start
17
+ if @configuration.device
18
+ ProcessLauncher.new(Executables.adb,"-s",@configuration.device,"uninstall",@configuration.target_package).start
19
+ else
20
+ ProcessLauncher.new(Executables.adb,"uninstall",@configuration.target_package).start
21
+ end
22
22
  end
23
23
  end
24
24
  end
@@ -1,6 +1,6 @@
1
1
  module Acouchi
2
2
  class Configuration
3
- attr_accessor :target_package, :activity, :project_path, :apk
3
+ attr_accessor :target_package, :activity, :project_path, :apk,:device,:port
4
4
 
5
5
  def self.from_json json
6
6
  require "json"
@@ -10,6 +10,8 @@ module Acouchi
10
10
  configuration.activity = json["activity"]
11
11
  configuration.project_path = json["project_path"]
12
12
  configuration.apk = json["apk"]
13
+ configuration.device = json["device"]
14
+ configuration.port = json["port"] || 7103
13
15
  configuration
14
16
  end
15
17
  end
@@ -15,7 +15,7 @@ module Acouchi
15
15
  def self.before
16
16
  @test_runner = TestRunner.new(@configuration)
17
17
  @test_runner.start
18
- @page = Solo.new
18
+ @page = Solo.new(@configuration)
19
19
  end
20
20
 
21
21
  def self.after
@@ -7,6 +7,10 @@ module Acouchi
7
7
  LEFT = 21
8
8
  RIGHT = 22
9
9
 
10
+ def initialize(configuration)
11
+ @configuration = configuration
12
+ end
13
+
10
14
  def send_key key
11
15
  call_method("sendKey", [key])
12
16
  end
@@ -131,7 +135,7 @@ module Acouchi
131
135
  def call_method name, arguments = []
132
136
  arguments = arguments.map {|a| a.to_s}
133
137
  options = { :body => {:parameters => arguments.to_json} }
134
- response = HTTParty.post("http://127.0.0.1:7103/execute_method/#{name}", options)
138
+ response = HTTParty.post("http://127.0.0.1:#{@configuration.port}/execute_method/#{name}", options)
135
139
  json = JSON.parse(response.body, :max_nesting => 100)
136
140
  if json.empty?
137
141
  nil
@@ -5,24 +5,32 @@ module Acouchi
5
5
  end
6
6
 
7
7
  def start
8
+
8
9
  apk_installer = ApkInstaller.new(@configuration)
9
10
  apk_installer.uninstall_apk
10
- apk_installer.install_apk
11
+ apk_installer.install_apk
12
+
13
+
14
+ if @configuration.device
15
+ ProcessLauncher.new(Executables.adb,"-s",@configuration.device, "forward", "tcp:#{@configuration.port}", "tcp:7103").start_and_crash_if_process_fails
16
+ @test_runner_process = ProcessLauncher.new(Executables.adb, "-s" ,@configuration.device, "shell", "am", "instrument", "-w", "#{@configuration.target_package}/android.test.InstrumentationTestRunner")
17
+ else
18
+ ProcessLauncher.new(Executables.adb, "forward", "tcp:#{@configuration.port}", "tcp:7103").start_and_crash_if_process_fails
19
+ @test_runner_process = ProcessLauncher.new(Executables.adb, "shell", "am", "instrument", "-w", "#{@configuration.target_package}/android.test.InstrumentationTestRunner")
20
+ end
11
21
 
12
- ProcessLauncher.new(Executables.adb, "forward", "tcp:7103", "tcp:7103").start_and_crash_if_process_fails
13
- @test_runner_process = ProcessLauncher.new(Executables.adb, "shell", "am", "instrument", "-w", "#{@configuration.target_package}/android.test.InstrumentationTestRunner")
14
22
  @test_runner_process.start_in_background
15
23
 
16
24
  sleep 0.1 until ready?
17
25
  end
18
26
 
19
27
  def stop
20
- HTTParty.get("http://127.0.0.1:7103/finish") rescue nil
28
+ HTTParty.get("http://127.0.0.1:#{@configuration.port}/finish") rescue nil
21
29
  end
22
30
 
23
31
  private
24
32
  def ready?
25
- HTTParty.get("http://127.0.0.1:7103/").body == "Acouchi" rescue false
33
+ HTTParty.get("http://127.0.0.1:#{@configuration.port}/").body == "Acouchi" rescue false
26
34
  end
27
35
  end
28
36
  end
@@ -1,3 +1,3 @@
1
1
  module Acouchi
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acouchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -150,8 +150,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 1.8.24
153
+ rubygems_version: 1.8.23
154
154
  signing_key:
155
155
  specification_version: 3
156
156
  summary: ''
157
157
  test_files: []
158
+ has_rdoc: