acouchi 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,3 +12,14 @@ end
12
12
  Cucumber::Rake::Task.new(:features) do |t|
13
13
  t.cucumber_opts = "features --format pretty"
14
14
  end
15
+
16
+ desc "open up an acouchi console"
17
+ task :console do
18
+ configuration = Acouchi::Configuration.from_json(File.read("acouchi_configuration.json"))
19
+ test_runner = Acouchi::TestRunner.new(configuration)
20
+ test_runner.start
21
+ page = Acouchi::Solo.new
22
+ require "pry"
23
+ binding.pry
24
+ test_runner.stop
25
+ end
@@ -33,3 +33,11 @@ end
33
33
  Then /^I see all views$/ do
34
34
  p page.views
35
35
  end
36
+
37
+ Then /^I see text views$/ do
38
+ p page.text_views
39
+ end
40
+
41
+ Then /^I see all content$/ do
42
+ p page.all_content
43
+ end
@@ -20,3 +20,9 @@ Feature: Write Text
20
20
 
21
21
  Scenario: Views
22
22
  Then I see all views
23
+
24
+ Scenario: List Text Views
25
+ Then I see text views
26
+
27
+ Scenario: All Content
28
+ Then I see all content
@@ -0,0 +1,7 @@
1
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
2
+ android:id="@+id/listviewrow"
3
+ android:layout_width="fill_parent"
4
+ android:layout_height="wrap_content"
5
+ android:padding="10dp"
6
+ android:textSize="16sp" >
7
+ </TextView>
@@ -27,4 +27,10 @@
27
27
  android:layout_height="wrap_content"
28
28
  android:text="click this text"
29
29
  />
30
+
31
+ <ListView android:layout_width="fill_parent"
32
+ android:layout_height="fill_parent"
33
+ android:id="@+id/listView">
34
+ </ListView>
35
+
30
36
  </LinearLayout>
@@ -6,9 +6,16 @@ import android.widget.TextView;
6
6
  import android.view.View.OnClickListener;
7
7
  import android.view.View;
8
8
  import android.widget.ImageView;
9
+ import android.widget.ArrayAdapter;
10
+ import android.widget.ListView;
11
+ import java.util.Arrays;
12
+ import java.util.ArrayList;
9
13
 
10
14
  public class StartupActivity extends Activity
11
15
  {
16
+ private ListView listView;
17
+ private ArrayAdapter<String> listAdapter;
18
+
12
19
  /** Called when the activity is first created. */
13
20
  @Override
14
21
  public void onCreate(Bundle savedInstanceState)
@@ -24,7 +31,6 @@ public class StartupActivity extends Activity
24
31
  }
25
32
  });
26
33
 
27
-
28
34
  ImageView imageView = (ImageView)findViewById(R.id.clickThisImageView);
29
35
  imageView.setOnClickListener(new OnClickListener(){
30
36
  public void onClick(View v) {
@@ -32,5 +38,16 @@ public class StartupActivity extends Activity
32
38
  clickThis.setText("You click an ImageView");
33
39
  }
34
40
  });
41
+
42
+ listView = (ListView) findViewById( R.id.listView );
43
+ String[] planets = new String[] {
44
+ "1", "2", "3", "4", "5", "6", "7", "8",
45
+ "9", "10", "11", "12", "13", "14", "15",
46
+ "16", "17", "18", "19", "20", "21", "22"
47
+ };
48
+ ArrayList<String> planetList = new ArrayList<String>();
49
+ planetList.addAll(Arrays.asList(planets));
50
+ listAdapter = new ArrayAdapter<String>(this, R.layout.listviewrow, planetList);
51
+ listView.setAdapter(listAdapter);
35
52
  }
36
53
  }
@@ -8,3 +8,16 @@ RSpec::Matchers.define :have_content do |expected|
8
8
  "expected \"#{actual.content.join("\n")}\" to include \"#{expected}\""
9
9
  end
10
10
  end
11
+
12
+ RSpec::Matchers.define :have_text do |expected|
13
+ match do |actual|
14
+ actual.has_text? expected
15
+ end
16
+ failure_message_for_should do |actual|
17
+ <<-FAIL
18
+ expected "#{actual.content.join("\n")}" to include "#{expected}"
19
+ all content on page:
20
+ #{actual.all_content.join("\n")}
21
+ FAIL
22
+ end
23
+ end
@@ -41,10 +41,24 @@ module Acouchi
41
41
  buttons.any? { |b| b["text"] == text }
42
42
  end
43
43
 
44
+ def text_views
45
+ call_method("getTextViews")
46
+ end
47
+
44
48
  def content
45
49
  call_method("getCurrentContent")
46
50
  end
47
51
 
52
+ def all_content
53
+ all_content = []
54
+ until scroll_up == false; end
55
+ begin
56
+ all_content << text_views.map {|t| t["text"]}
57
+ end while scroll_down
58
+ all_content << text_views.map {|t| t["text"]}
59
+ all_content.flatten.uniq
60
+ end
61
+
48
62
  def click_text text, options={}
49
63
  options = {
50
64
  :match => 1,
@@ -65,6 +79,10 @@ module Acouchi
65
79
  call_method("clickOnViewById", [id])
66
80
  end
67
81
 
82
+ def click_image index
83
+ call_method("clickOnImage", [index])
84
+ end
85
+
68
86
  def scroll_up
69
87
  call_method("scrollUp")
70
88
  end
@@ -89,8 +107,13 @@ module Acouchi
89
107
  call_method("scrollToSide", [RIGHT])
90
108
  end
91
109
 
110
+ def go_back
111
+ call_method("goBack")
112
+ end
113
+
92
114
  private
93
115
  def call_method name, arguments = []
116
+ arguments = arguments.map {|a| a.to_s}
94
117
  options = { :body => {:parameters => arguments.to_json} }
95
118
  response = HTTParty.post("http://127.0.0.1:7103/execute_method/#{name}", options)
96
119
  json = JSON.parse(response.body, :max_nesting => 100)
@@ -1,3 +1,3 @@
1
1
  module Acouchi
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -0,0 +1,15 @@
1
+ package com.acouchi;
2
+
3
+ import android.view.View;
4
+ import android.widget.TextView;
5
+
6
+ public class JsonTextView extends JsonView
7
+ {
8
+ private String text;
9
+
10
+ public JsonTextView(TextView textView)
11
+ {
12
+ super(textView);
13
+ text = textView.getText().toString();
14
+ }
15
+ }
@@ -6,10 +6,12 @@ public class JsonView
6
6
  {
7
7
  private int id;
8
8
  private String className;
9
+ private Boolean shown;
9
10
 
10
11
  public JsonView(View view)
11
12
  {
12
13
  id = view.getId();
13
14
  className = view.getClass().toString();
15
+ shown = view.isShown();
14
16
  }
15
17
  }
@@ -9,6 +9,7 @@ import com.google.gson.Gson;
9
9
  import com.acouchi.JsonResult;
10
10
  import com.acouchi.JsonView;
11
11
  import com.acouchi.JsonButton;
12
+ import com.acouchi.JsonTextView;
12
13
 
13
14
  import android.view.View;
14
15
  import android.widget.TextView;
@@ -41,10 +42,10 @@ public class MethodExecutor
41
42
  solo.clickOnText(parameters[0], Integer.parseInt(parameters[1]), Boolean.parseBoolean(parameters[2]));
42
43
 
43
44
  if (methodName.equals("scrollUpList"))
44
- solo.scrollUpList(Integer.parseInt(parameters[0]));
45
+ result = solo.scrollUpList(Integer.parseInt(parameters[0]));
45
46
 
46
47
  if (methodName.equals("scrollDownList"))
47
- solo.scrollDownList(Integer.parseInt(parameters[0]));
48
+ result = solo.scrollDownList(Integer.parseInt(parameters[0]));
48
49
 
49
50
  if (methodName.equals("sendKey"))
50
51
  solo.sendKey(Integer.parseInt(parameters[0]));
@@ -64,18 +65,27 @@ public class MethodExecutor
64
65
  if (methodName.equals("getViews"))
65
66
  result = getCurrentViews();
66
67
 
68
+ if (methodName.equals("getTextViews"))
69
+ result = getCurrentTextViews();
70
+
67
71
  if (methodName.equals("clickOnViewById"))
68
72
  clickOnViewById(Integer.parseInt(parameters[0]));
69
73
 
74
+ if (methodName.equals("clickOnImage"))
75
+ solo.clickOnImage(Integer.parseInt(parameters[0]));
76
+
70
77
  if (methodName.equals("scrollUp"))
71
- solo.scrollUp();
78
+ result = solo.scrollUp();
72
79
 
73
80
  if (methodName.equals("scrollDown"))
74
- solo.scrollDown();
81
+ result = solo.scrollDown();
75
82
 
76
83
  if (methodName.equals("scrollToSide"))
77
84
  solo.scrollToSide(Integer.parseInt(parameters[0]));
78
85
 
86
+ if (methodName.equals("goBack"))
87
+ solo.goBack();
88
+
79
89
  return methodResultAsJson(result);
80
90
  }
81
91
 
@@ -114,4 +124,12 @@ public class MethodExecutor
114
124
  jsonViews.add(new JsonView(view));
115
125
  return jsonViews;
116
126
  }
127
+
128
+ private ArrayList<JsonTextView> getCurrentTextViews()
129
+ {
130
+ ArrayList<JsonTextView> jsonTextViews = new ArrayList<JsonTextView>();
131
+ for (TextView textView: solo.getCurrentTextViews(null))
132
+ jsonTextViews.add(new JsonTextView(textView));
133
+ return jsonTextViews;
134
+ }
117
135
  }
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.6
4
+ version: 0.0.7
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-10-22 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -86,6 +86,7 @@ files:
86
86
  - examples/AcouchiSample/res/drawable-ldpi/ic_launcher.png
87
87
  - examples/AcouchiSample/res/drawable-mdpi/ic_launcher.png
88
88
  - examples/AcouchiSample/res/drawable-xhdpi/ic_launcher.png
89
+ - examples/AcouchiSample/res/layout/listviewrow.xml
89
90
  - examples/AcouchiSample/res/layout/main.xml
90
91
  - examples/AcouchiSample/res/values/strings.xml
91
92
  - examples/AcouchiSample/src/com/acouchi/sample/StartupActivity.java
@@ -108,6 +109,7 @@ files:
108
109
  - src/com/acouchi/Acouchi.java
109
110
  - src/com/acouchi/JsonButton.java
110
111
  - src/com/acouchi/JsonResult.java
112
+ - src/com/acouchi/JsonTextView.java
111
113
  - src/com/acouchi/JsonView.java
112
114
  - src/com/acouchi/MethodExecutor.java
113
115
  - src/com/acouchi/NanoHTTPD.java