@onekeyfe/react-native-text-input 6.7.0-2 → 6.7.0-21
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.
|
@@ -13,13 +13,17 @@ static dispatch_semaphore_t OneKeyTestReleaseRead;
|
|
|
13
13
|
|
|
14
14
|
- (BOOL)onekey_test_hasImages
|
|
15
15
|
{
|
|
16
|
-
dispatch_semaphore_t releaseRead;
|
|
17
|
-
dispatch_semaphore_t readStarted;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
dispatch_semaphore_t releaseRead = nil;
|
|
17
|
+
dispatch_semaphore_t readStarted = nil;
|
|
18
|
+
if (!NSThread.isMainThread) {
|
|
19
|
+
@synchronized (UIPasteboard.class) {
|
|
20
|
+
releaseRead = OneKeyTestReleaseRead;
|
|
21
|
+
readStarted = OneKeyTestReadStarted;
|
|
22
|
+
OneKeyTestReleaseRead = nil;
|
|
23
|
+
OneKeyTestReadStarted = nil;
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
|
-
if (
|
|
26
|
+
if (releaseRead != nil && readStarted != nil) {
|
|
23
27
|
dispatch_semaphore_signal(readStarted);
|
|
24
28
|
dispatch_semaphore_wait(releaseRead, dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC));
|
|
25
29
|
}
|
|
@@ -39,6 +43,8 @@ static dispatch_semaphore_t OneKeyTestReleaseRead;
|
|
|
39
43
|
NSArray<NSDictionary<NSString *, id> *> *previousItems = pasteboard.items;
|
|
40
44
|
RCTUITextField *field = [[RCTUITextField alloc] initWithFrame:CGRectZero];
|
|
41
45
|
SEL paste = @selector(paste:);
|
|
46
|
+
dispatch_semaphore_t readStarted = dispatch_semaphore_create(0);
|
|
47
|
+
dispatch_semaphore_t releaseRead = dispatch_semaphore_create(0);
|
|
42
48
|
|
|
43
49
|
@try {
|
|
44
50
|
pasteboard.items = @[];
|
|
@@ -49,8 +55,8 @@ static dispatch_semaphore_t OneKeyTestReleaseRead;
|
|
|
49
55
|
XCTAssertFalse([field canPerformAction:paste withSender:nil]);
|
|
50
56
|
|
|
51
57
|
@synchronized (UIPasteboard.class) {
|
|
52
|
-
OneKeyTestReadStarted =
|
|
53
|
-
OneKeyTestReleaseRead =
|
|
58
|
+
OneKeyTestReadStarted = readStarted;
|
|
59
|
+
OneKeyTestReleaseRead = releaseRead;
|
|
54
60
|
}
|
|
55
61
|
static dispatch_once_t onceToken;
|
|
56
62
|
dispatch_once(&onceToken, ^{
|
|
@@ -60,25 +66,22 @@ static dispatch_semaphore_t OneKeyTestReleaseRead;
|
|
|
60
66
|
});
|
|
61
67
|
|
|
62
68
|
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(1, 1)];
|
|
63
|
-
|
|
69
|
+
UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *context) {
|
|
64
70
|
[UIColor.blackColor setFill];
|
|
65
71
|
UIRectFill(CGRectMake(0, 0, 1, 1));
|
|
66
72
|
}];
|
|
73
|
+
[pasteboard setData:UIImagePNGRepresentation(image) forPasteboardType:@"public.png"];
|
|
67
74
|
[NSNotificationCenter.defaultCenter postNotificationName:UIPasteboardChangedNotification object:pasteboard];
|
|
68
|
-
XCTAssertEqual(dispatch_semaphore_wait(
|
|
75
|
+
XCTAssertEqual(dispatch_semaphore_wait(readStarted, dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC)), 0L);
|
|
69
76
|
|
|
70
77
|
[NSNotificationCenter.defaultCenter postNotificationName:name object:field];
|
|
71
78
|
XCTAssertTrue([field canPerformAction:paste withSender:nil]);
|
|
72
79
|
} @finally {
|
|
73
|
-
dispatch_semaphore_t releaseRead;
|
|
74
80
|
@synchronized (UIPasteboard.class) {
|
|
75
|
-
releaseRead = OneKeyTestReleaseRead;
|
|
76
81
|
OneKeyTestReleaseRead = nil;
|
|
77
82
|
OneKeyTestReadStarted = nil;
|
|
78
83
|
}
|
|
79
|
-
|
|
80
|
-
dispatch_semaphore_signal(releaseRead);
|
|
81
|
-
}
|
|
84
|
+
dispatch_semaphore_signal(releaseRead);
|
|
82
85
|
pasteboard.items = previousItems;
|
|
83
86
|
}
|
|
84
87
|
}
|