smart_monkey 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/smart_monkey/monkey_runner.rb +3 -2
- data/lib/ui-auto-monkey/UIAutoMonkey.js +19 -3
- data/lib/ui-auto-monkey/custom.js +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a388af57aa441c073b1f2f719f430d9f0bd68b3
|
4
|
+
data.tar.gz: a3c437b1dc27134339ce87084fe7a5a8adcbfdbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f98e149fbf8e43947fbb20b8eb084fedb03e76259a1df34cd35bdf7f6887bf2efa29dde77a322e9b8b6f093bdcf3aeb1f72b9cbf31fd9fb084a53dac9b4f441d
|
7
|
+
data.tar.gz: 64269835c8a2b79cdd25c443549103dcbc2e7e0195d19561c57d8ae8abdbaf33e0c7c5e37481989bba9f0e29832bbde1b0eefbb094873e7bb2144f5b5c8f6812
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2
|
1
|
+
0.2.1
|
@@ -424,7 +424,8 @@ module UIAutoMonkey
|
|
424
424
|
# if extend_javascript_flag
|
425
425
|
# js = File.read(extend_javascript_path) + "\n" + js
|
426
426
|
# end
|
427
|
-
#
|
427
|
+
envs_str="UniqueDeviceID=\"#{device}\";"
|
428
|
+
File.open(File.join(result_base_dir,"Env.js"), 'w') {|f| f.write(envs_str)}
|
428
429
|
FileUtils.copy(config_custom_path, result_base_dir)
|
429
430
|
FileUtils.copy(ui_auto_monkey_original_path, result_base_dir)
|
430
431
|
FileUtils.cp_r(ui_hole_handler_original_path, result_base_dir)
|
@@ -527,7 +528,7 @@ module UIAutoMonkey
|
|
527
528
|
|
528
529
|
def rm_unused_imgs(used_imgs, dir)
|
529
530
|
used_strs = used_imgs.join("\\|")
|
530
|
-
`cd "#{dir}";find . -type 'f' -name '*.png' | grep -v "#{used_strs}" | xargs rm`
|
531
|
+
`cd "#{dir}";find . -type 'f' -name '*.png' | grep -v "#{used_strs}" | xargs -I{} rm {}`
|
531
532
|
end
|
532
533
|
|
533
534
|
def decode_latest(num=10, drop_useless_img, drop_dir)
|
@@ -19,10 +19,10 @@
|
|
19
19
|
// THE SOFTWARE.
|
20
20
|
|
21
21
|
"use strict";
|
22
|
+
#import "Env.js"
|
22
23
|
|
23
24
|
function UIAutoMonkey() {
|
24
25
|
|
25
|
-
|
26
26
|
this.config = {
|
27
27
|
//run either by minutesToRun or numberOfEvents. Only one of these can set. (To use minutes you can use config.numberOfEvents = 0)
|
28
28
|
//minutesToRun = 60 * 8; //sample to run for 8 hours.
|
@@ -101,7 +101,10 @@ function UIAutoMonkey() {
|
|
101
101
|
multipleTaps: 0.05,
|
102
102
|
multipleTouches: 0.05,
|
103
103
|
longPress: 0.05
|
104
|
-
}
|
104
|
+
},
|
105
|
+
|
106
|
+
targetBundleId: UIATarget.localTarget().frontMostApp().bundleID(),
|
107
|
+
|
105
108
|
|
106
109
|
|
107
110
|
// Uncomment the following to restrict events to a rectangluar area of
|
@@ -255,6 +258,9 @@ UIAutoMonkey.prototype.RELEASE_THE_MONKEY = function() {
|
|
255
258
|
UIALogger.logDebug(this.config.minutesToRun - elapsedMinutes + " minutes left to run.")
|
256
259
|
}
|
257
260
|
}
|
261
|
+
|
262
|
+
if (this.target().frontMostApp().bundleID() !== this.config.targetBundleId) this.reLaunchApp();
|
263
|
+
|
258
264
|
this.triggerRandomEvent();
|
259
265
|
if (anrFingerprintFunction && (i % anrEventsBetweenSnapshots == 0)) this.anrCheck(i, anrFingerprintFunction, anrDebug);
|
260
266
|
// if (this.config.screenshotInterval) this.takeScreenShotIfItIsTime();
|
@@ -297,7 +303,9 @@ UIAutoMonkey.prototype.anrCheck = function(i, fingerprintFunction, debugFlag){
|
|
297
303
|
this.anrMaxElapsedCount = Math.max(this.anrMaxElapsedCount, elapsedCount);
|
298
304
|
UIALogger.logDebug("UIAutoMonkey:anrCheck(): snapshot == with elapsed count=" + elapsedCount);
|
299
305
|
if (elapsedCount > this.config.anrSettings.eventsBeforeANRDeclared) {
|
300
|
-
|
306
|
+
if (this.config.anrSettings.debug){
|
307
|
+
UIALogger.logDebug("duplicate snapshot detected" + this.anrSnapshot);
|
308
|
+
}
|
301
309
|
throw "anr exception-identical after " + elapsedCount + " events";
|
302
310
|
};
|
303
311
|
};
|
@@ -459,6 +467,14 @@ UIAutoMonkey.prototype.takeScreenShotIfItIsTime = function() {
|
|
459
467
|
// }
|
460
468
|
var filename = "monkey-" + (new Date()).toISOString().replace(/[:\.]+/g, "-");
|
461
469
|
this.target().captureScreenWithName(filename);
|
470
|
+
if (this.target().frontMostApp().bundleID() !== this.config.targetBundleId) this.reLaunchApp();
|
471
|
+
};
|
472
|
+
|
473
|
+
UIAutoMonkey.prototype.reLaunchApp = function() {
|
474
|
+
UIALogger.logWarning("Target app go outside, Re-launch tested app via UIAutoMonkey.");
|
475
|
+
var result = this.target().host().performTaskWithPathArgumentsTimeout("/usr/bin/which", ["idevicedebug"], 5);
|
476
|
+
var idevicedebug_original_path = result.stdout.trim();
|
477
|
+
this.target().host().performTaskWithPathArgumentsTimeout(idevicedebug_original_path, ["-u", UniqueDeviceID, "run", this.config.targetBundleId, ">/dev/null", "2>&1", "&"], 5);
|
462
478
|
};
|
463
479
|
|
464
480
|
// Commodity function to call RELEASE_THE_MONKEY directly on UIAutoMonkey
|
@@ -67,7 +67,7 @@ var aFingerprintFunction = function() {
|
|
67
67
|
monkey.config.anrSettings.fingerprintFunction = false;//false | aFingerprintFunction
|
68
68
|
monkey.config.anrSettings.eventsBeforeANRDeclared = 18; //throw exception if the fingerprint hasn't changed within this number of events
|
69
69
|
monkey.config.anrSettings.eventsBetweenSnapshots = 8; //how often (in events) to take a snapshot using the fingerprintFunction
|
70
|
-
monkey.config.anrSettings.debug =
|
70
|
+
monkey.config.anrSettings.debug = false; //log extra info on ANR state changes
|
71
71
|
|
72
72
|
// Release the monkey!
|
73
73
|
monkey.RELEASE_THE_MONKEY();
|