appium-webdriveragent 3.9.2 → 3.12.0

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.
Files changed (65) hide show
  1. package/PrivateHeaders/.DS_Store +0 -0
  2. package/PrivateHeaders/XCTest/XCTestManager_ManagerInterface-Protocol.h +3 -0
  3. package/README.md +0 -1
  4. package/WebDriverAgent.xcodeproj/project.pbxproj +56 -56
  5. package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/elf.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  6. package/WebDriverAgent.xcodeproj/xcuserdata/elf.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +51 -0
  7. package/WebDriverAgent.xcodeproj/xcuserdata/{kazuaki.xcuserdatad → elf.xcuserdatad}/xcschemes/xcschememanagement.plist +23 -8
  8. package/WebDriverAgentLib/.DS_Store +0 -0
  9. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +0 -17
  10. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +0 -16
  11. package/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m +28 -14
  12. package/WebDriverAgentLib/Categories/XCUIElement+FBResolve.h +37 -0
  13. package/WebDriverAgentLib/Categories/XCUIElement+FBResolve.m +51 -0
  14. package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m +8 -2
  15. package/WebDriverAgentLib/Commands/FBElementCommands.m +3 -1
  16. package/WebDriverAgentLib/Commands/FBOrientationCommands.m +20 -9
  17. package/WebDriverAgentLib/Commands/FBSessionCommands.m +119 -99
  18. package/WebDriverAgentLib/FBApplication.m +1 -1
  19. package/WebDriverAgentLib/Routing/FBElementCache.m +42 -11
  20. package/WebDriverAgentLib/Routing/FBResponsePayload.m +9 -3
  21. package/WebDriverAgentLib/Routing/FBSession.h +6 -0
  22. package/WebDriverAgentLib/Routing/FBSession.m +45 -55
  23. package/WebDriverAgentLib/Utilities/FBAlertsMonitor.h +1 -3
  24. package/WebDriverAgentLib/Utilities/FBAlertsMonitor.m +6 -13
  25. package/WebDriverAgentLib/Utilities/FBCapabilities.h +23 -0
  26. package/WebDriverAgentLib/Utilities/FBCapabilities.m +23 -0
  27. package/WebDriverAgentLib/Utilities/FBConfiguration.m +6 -1
  28. package/WebDriverAgentLib/Utilities/FBScreenshot.m +125 -14
  29. package/WebDriverAgentLib/Utilities/FBSettings.h +23 -23
  30. package/WebDriverAgentLib/Utilities/FBSettings.m +23 -23
  31. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +16 -0
  32. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +16 -0
  33. package/WebDriverAgentLib/Utilities/FBXPath.m +15 -44
  34. package/WebDriverAgentLib/Utilities/LRUCache/.DS_Store +0 -0
  35. package/WebDriverAgentLib/Utilities/LRUCache/LRUCache.h +59 -0
  36. package/WebDriverAgentLib/Utilities/LRUCache/LRUCache.m +104 -0
  37. package/WebDriverAgentLib/Utilities/LRUCache/LRUCacheNode.h +43 -0
  38. package/WebDriverAgentLib/Utilities/LRUCache/LRUCacheNode.m +59 -0
  39. package/WebDriverAgentLib/Vendor/.DS_Store +0 -0
  40. package/WebDriverAgentRunner/.DS_Store +0 -0
  41. package/WebDriverAgentRunner-Runner.app.zip +0 -0
  42. package/WebDriverAgentTests/IntegrationApp/Resources/.DS_Store +0 -0
  43. package/WebDriverAgentTests/IntegrationTests/FBSessionIntegrationTests.m +20 -16
  44. package/WebDriverAgentTests/IntegrationTests/XCUIApplicationHelperTests.m +2 -1
  45. package/WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m +11 -0
  46. package/WebDriverAgentTests/UnitTests/Doubles/FBApplicationDouble.h +3 -0
  47. package/WebDriverAgentTests/UnitTests/Doubles/FBApplicationDouble.m +15 -0
  48. package/WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.h +1 -0
  49. package/WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.m +1 -0
  50. package/WebDriverAgentTests/UnitTests/FBSessionTests.m +11 -1
  51. package/WebDriverAgentTests/UnitTests/FBXPathTests.m +3 -1
  52. package/WebDriverAgentTests/UnitTests_tvOS/Doubles/XCUIElementDouble.h +1 -0
  53. package/WebDriverAgentTests/UnitTests_tvOS/Doubles/XCUIElementDouble.m +1 -0
  54. package/package.json +3 -3
  55. package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/kazuaki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  56. package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/kazuaki.xcuserdatad/WorkspaceSettings.xcsettings +0 -20
  57. package/WebDriverAgent.xcodeproj/xcuserdata/kazuaki.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -906
  58. package/WebDriverAgentLib/Vendor/YYCache/YYCache.h +0 -206
  59. package/WebDriverAgentLib/Vendor/YYCache/YYCache.m +0 -140
  60. package/WebDriverAgentLib/Vendor/YYCache/YYDiskCache.h +0 -412
  61. package/WebDriverAgentLib/Vendor/YYCache/YYDiskCache.m +0 -462
  62. package/WebDriverAgentLib/Vendor/YYCache/YYKVStorage.h +0 -325
  63. package/WebDriverAgentLib/Vendor/YYCache/YYKVStorage.m +0 -1068
  64. package/WebDriverAgentLib/Vendor/YYCache/YYMemoryCache.h +0 -213
  65. package/WebDriverAgentLib/Vendor/YYCache/YYMemoryCache.m +0 -508
@@ -1,462 +0,0 @@
1
- //
2
- // YYDiskCache.m
3
- // YYCache <https://github.com/ibireme/YYCache>
4
- //
5
- // Created by ibireme on 15/2/11.
6
- // Copyright (c) 2015 ibireme.
7
- //
8
- // This source code is licensed under the MIT-style license found in the
9
- // LICENSE file in the root directory of this source tree.
10
- //
11
-
12
- #import "YYDiskCache.h"
13
- #import "YYKVStorage.h"
14
- #import <UIKit/UIKit.h>
15
- #import <CommonCrypto/CommonCrypto.h>
16
- #import <objc/runtime.h>
17
- #import <time.h>
18
-
19
- #define Lock() dispatch_semaphore_wait(self->_lock, DISPATCH_TIME_FOREVER)
20
- #define Unlock() dispatch_semaphore_signal(self->_lock)
21
-
22
- #pragma clang diagnostic push
23
- #pragma clang diagnostic ignored "-Wshadow"
24
-
25
- static const int extended_data_key;
26
-
27
- /// Free disk space in bytes.
28
- static int64_t _YYDiskSpaceFree() {
29
- NSError *error = nil;
30
- NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:&error];
31
- if (error) return -1;
32
- int64_t space = [[attrs objectForKey:NSFileSystemFreeSize] longLongValue];
33
- if (space < 0) space = -1;
34
- return space;
35
- }
36
-
37
- /// String's md5 hash.
38
- static NSString *_YYNSStringMD5(NSString *string) {
39
- if (!string) return nil;
40
- NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
41
- unsigned char result[CC_MD5_DIGEST_LENGTH];
42
- CC_MD5(data.bytes, (CC_LONG)data.length, result);
43
- return [NSString stringWithFormat:
44
- @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
45
- result[0], result[1], result[2], result[3],
46
- result[4], result[5], result[6], result[7],
47
- result[8], result[9], result[10], result[11],
48
- result[12], result[13], result[14], result[15]
49
- ];
50
- }
51
-
52
- /// weak reference for all instances
53
- static NSMapTable *_globalInstances;
54
- static dispatch_semaphore_t _globalInstancesLock;
55
-
56
- static void _YYDiskCacheInitGlobal() {
57
- static dispatch_once_t onceToken;
58
- dispatch_once(&onceToken, ^{
59
- _globalInstancesLock = dispatch_semaphore_create(1);
60
- _globalInstances = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsWeakMemory capacity:0];
61
- });
62
- }
63
-
64
- static YYDiskCache *_YYDiskCacheGetGlobal(NSString *path) {
65
- if (path.length == 0) return nil;
66
- _YYDiskCacheInitGlobal();
67
- dispatch_semaphore_wait(_globalInstancesLock, DISPATCH_TIME_FOREVER);
68
- id cache = [_globalInstances objectForKey:path];
69
- dispatch_semaphore_signal(_globalInstancesLock);
70
- return cache;
71
- }
72
-
73
- static void _YYDiskCacheSetGlobal(YYDiskCache *cache) {
74
- if (cache.path.length == 0) return;
75
- _YYDiskCacheInitGlobal();
76
- dispatch_semaphore_wait(_globalInstancesLock, DISPATCH_TIME_FOREVER);
77
- [_globalInstances setObject:cache forKey:cache.path];
78
- dispatch_semaphore_signal(_globalInstancesLock);
79
- }
80
-
81
-
82
-
83
- @implementation YYDiskCache {
84
- YYKVStorage *_kv;
85
- dispatch_semaphore_t _lock;
86
- dispatch_queue_t _queue;
87
- }
88
-
89
- - (void)_trimRecursively {
90
- __weak typeof(self) _self = self;
91
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_autoTrimInterval * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
92
- __strong typeof(_self) self = _self;
93
- if (!self) return;
94
- [self _trimInBackground];
95
- [self _trimRecursively];
96
- });
97
- }
98
-
99
- - (void)_trimInBackground {
100
- __weak typeof(self) _self = self;
101
- dispatch_async(_queue, ^{
102
- __strong typeof(_self) self = _self;
103
- if (!self) return;
104
- Lock();
105
- [self _trimToCost:self.costLimit];
106
- [self _trimToCount:self.countLimit];
107
- [self _trimToAge:self.ageLimit];
108
- [self _trimToFreeDiskSpace:self.freeDiskSpaceLimit];
109
- Unlock();
110
- });
111
- }
112
-
113
- - (void)_trimToCost:(NSUInteger)costLimit {
114
- if (costLimit >= INT_MAX) return;
115
- [_kv removeItemsToFitSize:(int)costLimit];
116
-
117
- }
118
-
119
- - (void)_trimToCount:(NSUInteger)countLimit {
120
- if (countLimit >= INT_MAX) return;
121
- [_kv removeItemsToFitCount:(int)countLimit];
122
- }
123
-
124
- - (void)_trimToAge:(NSTimeInterval)ageLimit {
125
- if (ageLimit <= 0) {
126
- [_kv removeAllItems];
127
- return;
128
- }
129
- long timestamp = time(NULL);
130
- if (timestamp <= ageLimit) return;
131
- long age = timestamp - (long)ageLimit;
132
- if (age >= INT_MAX) return;
133
- [_kv removeItemsEarlierThanTime:(int)age];
134
- }
135
-
136
- - (void)_trimToFreeDiskSpace:(NSUInteger)targetFreeDiskSpace {
137
- if (targetFreeDiskSpace == 0) return;
138
- int64_t totalBytes = [_kv getItemsSize];
139
- if (totalBytes <= 0) return;
140
- int64_t diskFreeBytes = _YYDiskSpaceFree();
141
- if (diskFreeBytes < 0) return;
142
- int64_t needTrimBytes = targetFreeDiskSpace - diskFreeBytes;
143
- if (needTrimBytes <= 0) return;
144
- int64_t costLimit = totalBytes - needTrimBytes;
145
- if (costLimit < 0) costLimit = 0;
146
- [self _trimToCost:(int)costLimit];
147
- }
148
-
149
- - (NSString *)_filenameForKey:(NSString *)key {
150
- NSString *filename = nil;
151
- if (_customFileNameBlock) filename = _customFileNameBlock(key);
152
- if (!filename) filename = _YYNSStringMD5(key);
153
- return filename;
154
- }
155
-
156
- - (void)_appWillBeTerminated {
157
- Lock();
158
- _kv = nil;
159
- Unlock();
160
- }
161
-
162
- #pragma mark - public
163
-
164
- - (void)dealloc {
165
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
166
- }
167
-
168
- - (instancetype)init {
169
- @throw [NSException exceptionWithName:@"YYDiskCache init error" reason:@"YYDiskCache must be initialized with a path. Use 'initWithPath:' or 'initWithPath:inlineThreshold:' instead." userInfo:nil];
170
- }
171
-
172
- - (instancetype)initWithPath:(NSString *)path {
173
- return [self initWithPath:path inlineThreshold:1024 * 20]; // 20KB
174
- }
175
-
176
- - (instancetype)initWithPath:(NSString *)path
177
- inlineThreshold:(NSUInteger)threshold {
178
- self = [super init];
179
- if (!self) return nil;
180
-
181
- YYDiskCache *globalCache = _YYDiskCacheGetGlobal(path);
182
- if (globalCache) return globalCache;
183
-
184
- YYKVStorageType type;
185
- if (threshold == 0) {
186
- type = YYKVStorageTypeFile;
187
- } else if (threshold == NSUIntegerMax) {
188
- type = YYKVStorageTypeSQLite;
189
- } else {
190
- type = YYKVStorageTypeMixed;
191
- }
192
-
193
- YYKVStorage *kv = [[YYKVStorage alloc] initWithPath:path type:type];
194
- if (!kv) return nil;
195
-
196
- _kv = kv;
197
- _path = path;
198
- _lock = dispatch_semaphore_create(1);
199
- _queue = dispatch_queue_create("com.ibireme.cache.disk", DISPATCH_QUEUE_CONCURRENT);
200
- _inlineThreshold = threshold;
201
- _countLimit = NSUIntegerMax;
202
- _costLimit = NSUIntegerMax;
203
- _ageLimit = DBL_MAX;
204
- _freeDiskSpaceLimit = 0;
205
- _autoTrimInterval = 60;
206
-
207
- [self _trimRecursively];
208
- _YYDiskCacheSetGlobal(self);
209
-
210
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_appWillBeTerminated) name:UIApplicationWillTerminateNotification object:nil];
211
- return self;
212
- }
213
-
214
- - (BOOL)containsObjectForKey:(NSString *)key {
215
- if (!key) return NO;
216
- Lock();
217
- BOOL contains = [_kv itemExistsForKey:key];
218
- Unlock();
219
- return contains;
220
- }
221
-
222
- - (void)containsObjectForKey:(NSString *)key withBlock:(void(^)(NSString *key, BOOL contains))block {
223
- if (!block) return;
224
- __weak typeof(self) _self = self;
225
- dispatch_async(_queue, ^{
226
- __strong typeof(_self) self = _self;
227
- BOOL contains = [self containsObjectForKey:key];
228
- block(key, contains);
229
- });
230
- }
231
-
232
- - (id<NSCoding>)objectForKey:(NSString *)key {
233
- if (!key) return nil;
234
- Lock();
235
- YYKVStorageItem *item = [_kv getItemForKey:key];
236
- Unlock();
237
- if (!item.value) return nil;
238
-
239
- id object = nil;
240
- if (_customUnarchiveBlock) {
241
- object = _customUnarchiveBlock(item.value);
242
- } else {
243
- @try {
244
- object = [NSKeyedUnarchiver unarchiveObjectWithData:item.value];
245
- }
246
- @catch (NSException *) {
247
- // nothing to do...
248
- }
249
- }
250
- if (object && item.extendedData) {
251
- [YYDiskCache setExtendedData:item.extendedData toObject:object];
252
- }
253
- return object;
254
- }
255
-
256
- - (void)objectForKey:(NSString *)key withBlock:(void(^)(NSString *key, id<NSCoding> object))block {
257
- if (!block) return;
258
- __weak typeof(self) _self = self;
259
- dispatch_async(_queue, ^{
260
- __strong typeof(_self) self = _self;
261
- id<NSCoding> object = [self objectForKey:key];
262
- block(key, object);
263
- });
264
- }
265
-
266
- - (void)setObject:(id<NSCoding>)object forKey:(NSString *)key {
267
- if (!key) return;
268
- if (!object) {
269
- [self removeObjectForKey:key];
270
- return;
271
- }
272
-
273
- NSData *extendedData = [YYDiskCache getExtendedDataFromObject:object];
274
- NSData *value = nil;
275
- if (_customArchiveBlock) {
276
- value = _customArchiveBlock(object);
277
- } else {
278
- @try {
279
- value = [NSKeyedArchiver archivedDataWithRootObject:object];
280
- }
281
- @catch (NSException *) {
282
- // nothing to do...
283
- }
284
- }
285
- if (!value) return;
286
- NSString *filename = nil;
287
- if (_kv.type != YYKVStorageTypeSQLite) {
288
- if (value.length > _inlineThreshold) {
289
- filename = [self _filenameForKey:key];
290
- }
291
- }
292
-
293
- Lock();
294
- [_kv saveItemWithKey:key value:value filename:filename extendedData:extendedData];
295
- Unlock();
296
- }
297
-
298
- - (void)setObject:(id<NSCoding>)object forKey:(NSString *)key withBlock:(void(^)(void))block {
299
- __weak typeof(self) _self = self;
300
- dispatch_async(_queue, ^{
301
- __strong typeof(_self) self = _self;
302
- [self setObject:object forKey:key];
303
- if (block) block();
304
- });
305
- }
306
-
307
- - (void)removeObjectForKey:(NSString *)key {
308
- if (!key) return;
309
- Lock();
310
- [_kv removeItemForKey:key];
311
- Unlock();
312
- }
313
-
314
- - (void)removeObjectForKey:(NSString *)key withBlock:(void(^)(NSString *key))block {
315
- __weak typeof(self) _self = self;
316
- dispatch_async(_queue, ^{
317
- __strong typeof(_self) self = _self;
318
- [self removeObjectForKey:key];
319
- if (block) block(key);
320
- });
321
- }
322
-
323
- - (void)removeAllObjects {
324
- Lock();
325
- [_kv removeAllItems];
326
- Unlock();
327
- }
328
-
329
- - (void)removeAllObjectsWithBlock:(void(^)(void))block {
330
- __weak typeof(self) _self = self;
331
- dispatch_async(_queue, ^{
332
- __strong typeof(_self) self = _self;
333
- [self removeAllObjects];
334
- if (block) block();
335
- });
336
- }
337
-
338
- - (void)removeAllObjectsWithProgressBlock:(void(^)(int removedCount, int totalCount))progress
339
- endBlock:(void(^)(BOOL error))end {
340
- __weak typeof(self) _self = self;
341
- dispatch_async(_queue, ^{
342
- __strong typeof(_self) self = _self;
343
- if (!self) {
344
- if (end) end(YES);
345
- return;
346
- }
347
- Lock();
348
- [self->_kv removeAllItemsWithProgressBlock:progress endBlock:end];
349
- Unlock();
350
- });
351
- }
352
-
353
- - (NSInteger)totalCount {
354
- Lock();
355
- int count = [_kv getItemsCount];
356
- Unlock();
357
- return count;
358
- }
359
-
360
- - (void)totalCountWithBlock:(void(^)(NSInteger totalCount))block {
361
- if (!block) return;
362
- __weak typeof(self) _self = self;
363
- dispatch_async(_queue, ^{
364
- __strong typeof(_self) self = _self;
365
- NSInteger totalCount = [self totalCount];
366
- block(totalCount);
367
- });
368
- }
369
-
370
- - (NSInteger)totalCost {
371
- Lock();
372
- int count = [_kv getItemsSize];
373
- Unlock();
374
- return count;
375
- }
376
-
377
- - (void)totalCostWithBlock:(void(^)(NSInteger totalCost))block {
378
- if (!block) return;
379
- __weak typeof(self) _self = self;
380
- dispatch_async(_queue, ^{
381
- __strong typeof(_self) self = _self;
382
- NSInteger totalCost = [self totalCost];
383
- block(totalCost);
384
- });
385
- }
386
-
387
- - (void)trimToCount:(NSUInteger)count {
388
- Lock();
389
- [self _trimToCount:count];
390
- Unlock();
391
- }
392
-
393
- - (void)trimToCount:(NSUInteger)count withBlock:(void(^)(void))block {
394
- __weak typeof(self) _self = self;
395
- dispatch_async(_queue, ^{
396
- __strong typeof(_self) self = _self;
397
- [self trimToCount:count];
398
- if (block) block();
399
- });
400
- }
401
-
402
- - (void)trimToCost:(NSUInteger)cost {
403
- Lock();
404
- [self _trimToCost:cost];
405
- Unlock();
406
- }
407
-
408
- - (void)trimToCost:(NSUInteger)cost withBlock:(void(^)(void))block {
409
- __weak typeof(self) _self = self;
410
- dispatch_async(_queue, ^{
411
- __strong typeof(_self) self = _self;
412
- [self trimToCost:cost];
413
- if (block) block();
414
- });
415
- }
416
-
417
- - (void)trimToAge:(NSTimeInterval)age {
418
- Lock();
419
- [self _trimToAge:age];
420
- Unlock();
421
- }
422
-
423
- - (void)trimToAge:(NSTimeInterval)age withBlock:(void(^)(void))block {
424
- __weak typeof(self) _self = self;
425
- dispatch_async(_queue, ^{
426
- __strong typeof(_self) self = _self;
427
- [self trimToAge:age];
428
- if (block) block();
429
- });
430
- }
431
-
432
- + (NSData *)getExtendedDataFromObject:(id)object {
433
- if (!object) return nil;
434
- return (NSData *)objc_getAssociatedObject(object, &extended_data_key);
435
- }
436
-
437
- + (void)setExtendedData:(NSData *)extendedData toObject:(id)object {
438
- if (!object) return;
439
- objc_setAssociatedObject(object, &extended_data_key, extendedData, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
440
- }
441
-
442
- - (NSString *)description {
443
- if (_name) return [NSString stringWithFormat:@"<%@: %p> (%@:%@)", self.class, (void *)self, _name, _path];
444
- else return [NSString stringWithFormat:@"<%@: %p> (%@)", self.class, (void *)self, _path];
445
- }
446
-
447
- - (BOOL)errorLogsEnabled {
448
- Lock();
449
- BOOL enabled = _kv.errorLogsEnabled;
450
- Unlock();
451
- return enabled;
452
- }
453
-
454
- - (void)setErrorLogsEnabled:(BOOL)errorLogsEnabled {
455
- Lock();
456
- _kv.errorLogsEnabled = errorLogsEnabled;
457
- Unlock();
458
- }
459
-
460
- @end
461
-
462
- #pragma clang diagnostic pop