calabash-android 0.3.0.pre1 → 0.3.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.3.0.pre1"
3
+ VERSION = "0.3.0.pre2"
4
4
  end
5
5
  end
@@ -8,4 +8,4 @@
8
8
  # project structure.
9
9
 
10
10
  # Project target.
11
- target=Google Inc.:Google APIs:15
11
+ target=Google Inc.:Google APIs:8
@@ -18,36 +18,7 @@ import android.view.View;
18
18
  import android.widget.TextView;
19
19
 
20
20
  public class TestHelpers {
21
- private static Map<String, Integer> resourceNamesToIds = new HashMap<String, Integer>();
22
- private static Map<Integer, String> resourceIdsToNames = new HashMap<Integer, String>();
23
-
24
- public static void loadIds(Context context) {
25
-
26
- resourceNamesToIds = new HashMap<String, Integer>();
27
- try {
28
- InputStream is = context.getResources().getAssets().open("ids.txt");
29
- BufferedReader input = new BufferedReader(new InputStreamReader(is));
30
- String line = null;
31
- while (( line = input.readLine()) != null){
32
- line = line.trim();
33
- if (line.contains(InstrumentationBackend.TARGET_PACKAGE + ":id/")) {
34
- if (line.startsWith("resource")) {
35
- String[] tokens = line.split(" ");
36
- String name = tokens[2];
37
- name = name.replace(InstrumentationBackend.TARGET_PACKAGE + ":id/", "");
38
- name = name.replace(":", "");
39
-
40
- resourceNamesToIds.put(name, Integer.parseInt(tokens[1].substring(2), 16));
41
- resourceIdsToNames.put(Integer.parseInt(tokens[1].substring(2), 16), name);
42
- }
43
- }
44
- }
45
-
46
- } catch (IOException e) {
47
- e.printStackTrace();
48
- }
49
- }
50
-
21
+
51
22
  public static TextView getTextViewByDescription(String description) {
52
23
  View view = getViewByDescription(description);
53
24
  if (view != null && view instanceof TextView) {
@@ -87,55 +58,28 @@ public class TestHelpers {
87
58
  }
88
59
 
89
60
  public static View getViewById(String resName) {
90
- Integer intID = resourceNamesToIds.get(resName);
91
- System.out.println("getViewById: Looking for view " + resName + " as id " + intID);
92
- if (intID == null) {
93
- throw new RuntimeException("getViewById: Looking for view " + resName + " which does not have an id");
94
- }
95
- int id = intID.intValue();
96
- View view = InstrumentationBackend.solo.getView(id);
97
- if (view != null) {
98
- if (id == view.getId()) {
99
- System.out.println("Did find view " + resName + ".");
100
- return view;
101
- }
102
- System.out.println("Did find view " + resName + " but getId returned: " + view.getId());
61
+ int id = InstrumentationBackend.solo.getCurrentActivity().getResources().getIdentifier(resName, "id", InstrumentationBackend.solo.getCurrentActivity().getPackageName());
62
+ if (id == 0) {
63
+ return null;
103
64
  }
104
- System.out.println("Did not find view " + resName);
105
- return view;
65
+
66
+ return InstrumentationBackend.solo.getView(id);
106
67
  }
107
68
 
108
69
  public static Drawable getDrawableById(String resName) {
109
- int id;
110
- // This would probably work too...
111
- if( true ) {
112
- try {
113
- // if( resName.startsWith("drawable/") == false ) {
114
- // resName = "drawable/" + resName;
115
- // }
116
- // TypedValue outValue = new TypedValue();
117
- // InstrumentationBackend.solo.getCurrentActivity().getResources().getValue( resName, outValue, false );
118
- // id = outValue.resourceId;
119
- id = InstrumentationBackend.solo.getCurrentActivity().getResources().getIdentifier( resName, "drawable", InstrumentationBackend.solo.getCurrentActivity().getPackageName() );
70
+ int id;
71
+ try {
72
+ id = InstrumentationBackend.solo.getCurrentActivity().getResources().getIdentifier(resName, "drawable", InstrumentationBackend.solo.getCurrentActivity().getPackageName());
120
73
  } catch( NotFoundException e ) {
121
74
  throw new RuntimeException("getDrawableById: Looking for drawable " + resName + " but was not found");
122
75
  }
123
- } else {
124
- Integer intID = resourceNamesToIds.get(resName);
125
- System.out.println("getDrawableById: Looking for drawable " + resName + " as id " + intID);
126
- if (intID == null) {
127
- throw new RuntimeException("getDrawableById: Looking for drawable " + resName + " which does not have an id");
128
- }
129
- id = intID.intValue();
130
- }
131
76
  Drawable drawable = InstrumentationBackend.solo.getCurrentActivity().getResources().getDrawable(id);
132
77
  if (drawable != null) {
133
78
  System.out.println("Did find drawable " + resName + ": " + drawable);
134
- return drawable;
135
79
  } else {
136
80
  System.out.println("Did not find drawable " + resName);
137
- return drawable;
138
81
  }
82
+ return drawable;
139
83
  }
140
84
 
141
85
  public static int[] parseTime(String timeString) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre1
4
+ version: 0.3.0.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: