run_loop 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/run_loop/core.rb CHANGED
@@ -28,6 +28,10 @@ module RunLoop
28
28
  end
29
29
 
30
30
  def self.run_with_options(options)
31
+
32
+ device = options[:device] || :iphone
33
+
34
+
31
35
  template = automation_template
32
36
  instruments_path = "instruments"#File.join(scripts_path,"unix_instruments")
33
37
  results_dir = options[:results_dir] || Dir.mktmpdir("run_loop")
@@ -56,6 +60,16 @@ module RunLoop
56
60
  if File.exist?(bundle_dir_or_bundle_id)
57
61
  #Assume simulator
58
62
  udid = nil
63
+ plistbuddy="/usr/libexec/PlistBuddy"
64
+ plistfile="#{bundle_dir_or_bundle_id}/Info.plist"
65
+ if device == :iphone
66
+ uidevicefamily=1
67
+ else
68
+ uidevicefamily=2
69
+ end
70
+ system("#{plistbuddy} -c 'Delete :UIDeviceFamily' '#{plistfile}'")
71
+ system("#{plistbuddy} -c 'Add :UIDeviceFamily array' '#{plistfile}'")
72
+ system("#{plistbuddy} -c 'Add :UIDeviceFamily:0 integer #{uidevicefamily}' '#{plistfile}'")
59
73
  else
60
74
  udid = options[:udid]
61
75
  unless udid
@@ -1,3 +1,3 @@
1
1
  module RunLoop
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/scripts/run_loop.js CHANGED
@@ -38,7 +38,7 @@ var Log = (function () {
38
38
  N = 0, i = N;
39
39
  if ("$MODE" == "FLUSH")
40
40
  {
41
- N = 16384
41
+ N = 16384;
42
42
  }
43
43
  while(i--) { forceFlush[i] = "*"; }
44
44
  forceFlush = forceFlush.join('');
@@ -59,8 +59,65 @@ var Log = (function () {
59
59
  };
60
60
  })();
61
61
 
62
- var target = UIATarget.localTarget(),
63
- host = target.host();
62
+
63
+ function findAlertViewText(alert)
64
+ {
65
+ if (!alert) {return false;}
66
+ var txt = alert.name(),
67
+ txts;
68
+ if (txt == null)
69
+ {
70
+ txts = alert.staticTexts();
71
+ if (txts != null && txts.length > 0)
72
+ {
73
+
74
+ txt = txts[0].name();
75
+ }
76
+
77
+ }
78
+ return txt;
79
+ }
80
+
81
+ function isLocationPrompt(alert)
82
+ {
83
+ var exps = [
84
+ ["OK", /vil bruge din aktuelle placering/],
85
+ ["OK", /Would Like to Use Your Current Location/],
86
+ ["Ja", /Darf (?:.)+ Ihren aktuellen Ort verwenden/]
87
+ ],
88
+ ans, exp,
89
+ txt,
90
+ txts;
91
+
92
+ txt = findAlertViewText(alert);
93
+ for (var i = 0; i < exps.length; i++)
94
+ {
95
+ ans = exps[i][0];
96
+ exp = exps[i][1];
97
+ if (exp.test(txt))
98
+ {
99
+ return ans;
100
+ }
101
+ }
102
+ return false;
103
+ }
104
+
105
+
106
+ UIATarget.onAlert = function (alert)
107
+ {
108
+ var answer = isLocationPrompt(alert);
109
+ if (answer)
110
+ {
111
+ alert.buttons()[answer].tap();
112
+ }
113
+ return true;
114
+ };
115
+
116
+
117
+
118
+
119
+ var target = null,
120
+ host = null;
64
121
 
65
122
  var expectedIndex = 0,//expected index of next command
66
123
  actualIndex,//actual index of next command by reading commandPath
@@ -72,6 +129,8 @@ var expectedIndex = 0,//expected index of next command
72
129
 
73
130
  while (true)
74
131
  {
132
+ target = UIATarget.localTarget();
133
+ host = target.host();
75
134
  target.delay(0.2);
76
135
  try
77
136
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-12-19 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor