run_loop 1.1.1.pre2 → 1.1.1.pre3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aed9a3d8201f63a37840030f1a5f1546f1b797b
4
- data.tar.gz: 416eaa3768ed27b66d77ea3c3df9e6c9a2f3aa6e
3
+ metadata.gz: 1822fe07be976e6f4388798cf3056b7580d014f6
4
+ data.tar.gz: 267f9c4e9035cebe48ef7f1ff31c75b4f76a0943
5
5
  SHA512:
6
- metadata.gz: c2be0670d8965174a841caeb073066da24251dcb3c4e58585508fa5f5c122f4b763cd5cf565df61ef5e1b58dcd560bb84aa7786eaae9895a907e00de3df85d76
7
- data.tar.gz: 56110caaf37b4b8eb4e080ea307a40854a4bc73ddacbb721f2f590ed4f477c45c3c10242bffeee3e3d877933103390a0cec5d488bda6ed84034fb1aeb37843aa
6
+ metadata.gz: b3f667f1ea1ed63c1378806ab311d9489567d5567db883ea6467b3dbf0511d9ec2a49961f5cbcd6da042bd178b67aa2346335d0f0bce71c91deb9310f105cf7c
7
+ data.tar.gz: 8f7b98186a41edc20c158b577ac141a59259ea65b58c556f1dc654646d53d47b2574e98c138d8d9dc0aed6e742f1135d72c8cb3e506e16977870533adf8e4654
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = '1.1.1.pre2'
2
+ VERSION = '1.1.1.pre3'
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
@@ -146,10 +146,12 @@ if (typeof JSON !== 'object') {
146
146
  }());
147
147
 
148
148
 
149
+ _RUN_LOOP_MAX_RETRY_AFTER_HANDLER = 10;
149
150
  var _expectedIndex = 0,//expected index of next command
150
151
  _actualIndex=0,//actual index of next command by reading commandPath
151
152
  _exp,//expression to be eval'ed
152
- _result;
153
+ _result,
154
+ _lastResponse=null;
153
155
 
154
156
  var Log = (function () {
155
157
  var forceFlush = [],
@@ -221,8 +223,11 @@ function isLocationPrompt(alert) {
221
223
  }
222
224
 
223
225
  UIATarget.onAlert = function (alert) {
224
- Log.output({"output":"on alert"}, true);
225
- var target = UIATarget.localTarget();
226
+ var target = UIATarget.localTarget(),
227
+ app = target.frontMostApp(),
228
+ req = null,
229
+ rsp = null,
230
+ actualIndex = null;
226
231
  target.pushTimeout(10);
227
232
  function attemptTouchOKOnLocation(retry_count) {
228
233
  retry_count = retry_count || 0;
@@ -248,6 +253,20 @@ UIATarget.onAlert = function (alert) {
248
253
 
249
254
  attemptTouchOKOnLocation(0);
250
255
  target.popTimeout();
256
+ for (var i=0;i<_RUN_LOOP_MAX_RETRY_AFTER_HANDLER;i++) {
257
+ req = app.preferencesValueForKey(__calabashRequest);
258
+ rsp = app.preferencesValueForKey(__calabashResponse);
259
+ actualIndex = req && req['index'];
260
+ if (req && !isNaN(actualIndex) && actualIndex <= _lastResponse['index']) {
261
+ UIALogger.logMessage("Deleting previous response: "+(rsp && rsp['index']));
262
+ app.setPreferencesValueForKey(0, __calabashRequest);
263
+ app.setPreferencesValueForKey(null, __calabashRequest);
264
+ }
265
+ if (_lastResponse) {
266
+ UIALogger.logMessage("Re-Writing response: "+_lastResponse['value']);
267
+ _response(_lastResponse);
268
+ }
269
+ }
251
270
  return true;
252
271
  };
253
272
 
@@ -292,9 +311,8 @@ var target = null,
292
311
  tmp;
293
312
 
294
313
  for (i=0; i<MAX_TRIES; i+=1) {
295
- UIALogger.logMessage("Write result...");
296
314
  tmp = target.frontMostApp().preferencesValueForKey(__calabashResponse);
297
- UIALogger.logMessage("Last response..."+tmp);
315
+ UIALogger.logMessage("Last response..."+(tmp && tmp['index']+"->"+tmp['value']));
298
316
  target.frontMostApp().setPreferencesValueForKey(sanitized, __calabashResponse);
299
317
  res = target.frontMostApp().preferencesValueForKey(__calabashRequest);
300
318
  res = target.frontMostApp().preferencesValueForKey(__calabashResponse);
@@ -302,7 +320,6 @@ var target = null,
302
320
  target.delay(0.1);
303
321
  res = target.frontMostApp().preferencesValueForKey(__calabashResponse);
304
322
  UIALogger.logMessage("Post delay response..."+(res && res['value']));
305
-
306
323
  if (res && res['index'] == sanitized['index']) {
307
324
  UIALogger.logMessage("Storage succeeded: "+ res['index']);
308
325
  return;
@@ -312,18 +329,18 @@ var target = null,
312
329
  }
313
330
  }
314
331
  throw new Error("Unable to write to preferences");
315
-
316
332
  },
317
333
  _success = function(result,index) {
318
-
319
- _response({"status":'success', "value":result, "index": index});
334
+ _lastResponse = {"status":'success', "value":result, "index": index};
335
+ _response(_lastResponse);
320
336
 
321
337
  },
322
338
  _failure = function(err, index) {
323
- _response({"status":'error',
324
- "value":err.toString(),
325
- "backtrace":(err.stack ? err.stack.toString() : ""),
326
- "index":index});
339
+ _lastResponse = {"status":'error',
340
+ "value":err.toString(),
341
+ "backtrace":(err.stack ? err.stack.toString() : ""),
342
+ "index":index};
343
+ _response(_lastResponse);
327
344
  },
328
345
  _resetCalabashPreferences = function () {
329
346
  //Implementation is weird but reading pref values seems to have side effects
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1.pre2
4
+ version: 1.1.1.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor