expo-targets 0.1.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.
- package/.eslintrc.js +2 -0
- package/README.md +244 -0
- package/android/build.gradle +22 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsLogger.kt +98 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsReceiver.kt +136 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsRemoteViewsProvider.kt +72 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetProvider.kt +47 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetSync.kt +78 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetUpdateReceiver.kt +30 -0
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsExtensionModule.kt +27 -0
- package/android/src/main/java/expo/modules/targets/messages/ExpoTargetsMessagesModule.kt +40 -0
- package/android/src/main/java/expo/modules/targets/storage/ExpoTargetsStorageModule.kt +119 -0
- package/app.plugin.js +1 -0
- package/build/metro/src/index.d.ts +2 -0
- package/build/metro/src/index.d.ts.map +1 -0
- package/build/metro/src/index.js +6 -0
- package/build/metro/src/index.js.map +1 -0
- package/build/metro/src/withTargetsMetro.d.ts +6 -0
- package/build/metro/src/withTargetsMetro.d.ts.map +1 -0
- package/build/metro/src/withTargetsMetro.js +171 -0
- package/build/metro/src/withTargetsMetro.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.js +56 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.js +70 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.js +41 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.js +75 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.d.ts +28 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.js +28 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.js +86 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.js +23 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.js.map +1 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.d.ts +7 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.js +31 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.js.map +1 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.d.ts +3 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.js +24 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.js.map +1 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.d.ts +3 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.js +27 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.js.map +1 -0
- package/build/plugin/src/android/withAndroidTarget.d.ts +10 -0
- package/build/plugin/src/android/withAndroidTarget.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidTarget.js +22 -0
- package/build/plugin/src/android/withAndroidTarget.js.map +1 -0
- package/build/plugin/src/android/withAndroidWidget.d.ts +13 -0
- package/build/plugin/src/android/withAndroidWidget.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidWidget.js +564 -0
- package/build/plugin/src/android/withAndroidWidget.js.map +1 -0
- package/build/plugin/src/config.d.ts +141 -0
- package/build/plugin/src/config.d.ts.map +1 -0
- package/build/plugin/src/config.js +54 -0
- package/build/plugin/src/config.js.map +1 -0
- package/build/plugin/src/index.d.ts +9 -0
- package/build/plugin/src/index.d.ts.map +1 -0
- package/build/plugin/src/index.js +11 -0
- package/build/plugin/src/index.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts +11 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.js +49 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts +17 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.js +152 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.d.ts +8 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.js +25 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.d.ts +8 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.js +52 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.d.ts +12 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.js +162 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts +15 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.js +646 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.js.map +1 -0
- package/build/plugin/src/ios/target.d.ts +41 -0
- package/build/plugin/src/ios/target.d.ts.map +1 -0
- package/build/plugin/src/ios/target.js +574 -0
- package/build/plugin/src/ios/target.js.map +1 -0
- package/build/plugin/src/ios/utils/asset.d.ts +60 -0
- package/build/plugin/src/ios/utils/asset.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/asset.js +375 -0
- package/build/plugin/src/ios/utils/asset.js.map +1 -0
- package/build/plugin/src/ios/utils/file.d.ts +33 -0
- package/build/plugin/src/ios/utils/file.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/file.js +88 -0
- package/build/plugin/src/ios/utils/file.js.map +1 -0
- package/build/plugin/src/ios/utils/index.d.ts +12 -0
- package/build/plugin/src/ios/utils/index.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/index.js +38 -0
- package/build/plugin/src/ios/utils/index.js.map +1 -0
- package/build/plugin/src/ios/utils/paths.d.ts +128 -0
- package/build/plugin/src/ios/utils/paths.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/paths.js +141 -0
- package/build/plugin/src/ios/utils/paths.js.map +1 -0
- package/build/plugin/src/ios/utils/plist.d.ts +29 -0
- package/build/plugin/src/ios/utils/plist.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/plist.js +114 -0
- package/build/plugin/src/ios/utils/plist.js.map +1 -0
- package/build/plugin/src/ios/utils/podfile.d.ts +82 -0
- package/build/plugin/src/ios/utils/podfile.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/podfile.js +408 -0
- package/build/plugin/src/ios/utils/podfile.js.map +1 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.d.ts +11 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.js +263 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.js.map +1 -0
- package/build/plugin/src/ios/utils/xcode.d.ts +185 -0
- package/build/plugin/src/ios/utils/xcode.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/xcode.js +706 -0
- package/build/plugin/src/ios/utils/xcode.js.map +1 -0
- package/build/plugin/src/logger.d.ts +10 -0
- package/build/plugin/src/logger.d.ts.map +1 -0
- package/build/plugin/src/logger.js +62 -0
- package/build/plugin/src/logger.js.map +1 -0
- package/build/plugin/src/parseTargetConfig.d.ts +3 -0
- package/build/plugin/src/parseTargetConfig.d.ts.map +1 -0
- package/build/plugin/src/parseTargetConfig.js +113 -0
- package/build/plugin/src/parseTargetConfig.js.map +1 -0
- package/build/plugin/src/withTargetsDir.d.ts +6 -0
- package/build/plugin/src/withTargetsDir.d.ts.map +1 -0
- package/build/plugin/src/withTargetsDir.js +90 -0
- package/build/plugin/src/withTargetsDir.js.map +1 -0
- package/build/src/Target.d.ts +43 -0
- package/build/src/Target.d.ts.map +1 -0
- package/build/src/Target.js +128 -0
- package/build/src/Target.js.map +1 -0
- package/build/src/index.d.ts +9 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +27 -0
- package/build/src/index.js.map +1 -0
- package/build/src/modules/extension/index.d.ts +18 -0
- package/build/src/modules/extension/index.d.ts.map +1 -0
- package/build/src/modules/extension/index.js +44 -0
- package/build/src/modules/extension/index.js.map +1 -0
- package/build/src/modules/messages/index.d.ts +40 -0
- package/build/src/modules/messages/index.d.ts.map +1 -0
- package/build/src/modules/messages/index.js +94 -0
- package/build/src/modules/messages/index.js.map +1 -0
- package/build/src/modules/storage/index.d.ts +16 -0
- package/build/src/modules/storage/index.d.ts.map +1 -0
- package/build/src/modules/storage/index.js +122 -0
- package/build/src/modules/storage/index.js.map +1 -0
- package/expo-module.config.json +17 -0
- package/ios/ExpoTargetsExtension.podspec +23 -0
- package/ios/ExpoTargetsExtensionModule.swift +181 -0
- package/ios/ExpoTargetsMessages.podspec +23 -0
- package/ios/ExpoTargetsMessagesModule.swift +267 -0
- package/ios/ExpoTargetsStorage.podspec +23 -0
- package/ios/ExpoTargetsStorageModule.swift +91 -0
- package/ios/Tests/.swiftlint.yml +52 -0
- package/ios/Tests/Helpers/MockExtensionContext.swift +58 -0
- package/ios/Tests/Helpers/MockUserDefaults.swift +70 -0
- package/ios/Tests/Helpers/MockWidgetCenter.swift +71 -0
- package/ios/Tests/Helpers/TestHelpers.swift +90 -0
- package/ios/Tests/Integration/TargetIntegrationTests.swift +478 -0
- package/ios/Tests/Main/AllTests.swift +80 -0
- package/ios/Tests/Package.swift +66 -0
- package/ios/Tests/Performance/StoragePerformanceTests.swift +461 -0
- package/ios/Tests/Unit/Extension/ExpoTargetsExtensionModuleTests.swift +501 -0
- package/ios/Tests/Unit/Storage/ExpoTargetsStorageModuleTests.swift +578 -0
- package/ios/Tests/Unit/Template/ShareExtensionTemplateTests.swift +421 -0
- package/ios/Tests/XCTestPlan.xctestplan +87 -0
- package/metro/src/index.ts +1 -0
- package/metro/src/withTargetsMetro.ts +247 -0
- package/metro/tsconfig.build.json +9 -0
- package/package.json +74 -0
- package/plugin/src/android/withAndroidAppBuildGradle.ts +34 -0
- package/plugin/src/android/withAndroidTarget.ts +26 -0
- package/plugin/src/android/withAndroidWidget.ts +778 -0
- package/plugin/src/config.ts +255 -0
- package/plugin/src/index.ts +19 -0
- package/plugin/src/ios/config-plugins/withEntitlements.ts +69 -0
- package/plugin/src/ios/config-plugins/withIOSTarget.ts +179 -0
- package/plugin/src/ios/config-plugins/withIosColorset.ts +29 -0
- package/plugin/src/ios/config-plugins/withIosStickerPack.ts +65 -0
- package/plugin/src/ios/config-plugins/withPodfile.ts +238 -0
- package/plugin/src/ios/config-plugins/withXcodeChanges.ts +891 -0
- package/plugin/src/ios/target.ts +668 -0
- package/plugin/src/ios/templates/MessagesViewController.swift +120 -0
- package/plugin/src/ios/templates/ReactNativeViewController.swift +240 -0
- package/plugin/src/ios/templates/action-extension-data.swift +106 -0
- package/plugin/src/ios/templates/clip-extension-data.swift +28 -0
- package/plugin/src/ios/templates/messages-extension-data.swift +28 -0
- package/plugin/src/ios/templates/share-extension-data.swift +113 -0
- package/plugin/src/ios/utils/asset.ts +490 -0
- package/plugin/src/ios/utils/file.ts +80 -0
- package/plugin/src/ios/utils/index.ts +12 -0
- package/plugin/src/ios/utils/paths.ts +253 -0
- package/plugin/src/ios/utils/plist.ts +101 -0
- package/plugin/src/ios/utils/podfile.ts +534 -0
- package/plugin/src/ios/utils/reactNativeSwift.ts +283 -0
- package/plugin/src/ios/utils/xcode.ts +989 -0
- package/plugin/src/logger.ts +63 -0
- package/plugin/src/parseTargetConfig.ts +115 -0
- package/plugin/src/types/normalize-colors.d.ts +3 -0
- package/plugin/src/withTargetsDir.ts +120 -0
- package/plugin/tsconfig.build.json +9 -0
- package/plugin/tsconfig.json +9 -0
- package/src/Target.ts +239 -0
- package/src/index.ts +52 -0
- package/src/modules/extension/index.ts +54 -0
- package/src/modules/messages/index.ts +124 -0
- package/src/modules/storage/index.ts +126 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import XCTest
|
|
2
|
+
import Foundation
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
/// Tests for share extension data loading template functionality
|
|
6
|
+
class ShareExtensionTemplateTests: XCTestCase {
|
|
7
|
+
|
|
8
|
+
var mockContext: MockExtensionContext!
|
|
9
|
+
|
|
10
|
+
// MARK: - Setup & Teardown
|
|
11
|
+
|
|
12
|
+
override func setUp() {
|
|
13
|
+
super.setUp()
|
|
14
|
+
mockContext = MockExtensionContext()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override func tearDown() {
|
|
18
|
+
mockContext.reset()
|
|
19
|
+
mockContext = nil
|
|
20
|
+
super.tearDown()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// MARK: - Async Content Loading Tests
|
|
24
|
+
|
|
25
|
+
func testAsyncLoadTextContent() async {
|
|
26
|
+
// Given
|
|
27
|
+
mockContext.addMockTextItem("Test content")
|
|
28
|
+
|
|
29
|
+
// When
|
|
30
|
+
let result = await loadSharedContent(from: mockContext)
|
|
31
|
+
|
|
32
|
+
// Then
|
|
33
|
+
XCTAssertNotNil(result)
|
|
34
|
+
XCTAssertEqual(result?["text"] as? String, "Test content")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func testAsyncLoadURLContent() async {
|
|
38
|
+
// Given
|
|
39
|
+
let testURL = URL(string: "https://example.com")!
|
|
40
|
+
mockContext.addMockURLItem(testURL)
|
|
41
|
+
|
|
42
|
+
// When
|
|
43
|
+
let result = await loadSharedContent(from: mockContext)
|
|
44
|
+
|
|
45
|
+
// Then
|
|
46
|
+
XCTAssertNotNil(result)
|
|
47
|
+
XCTAssertEqual(result?["url"] as? String, testURL.absoluteString)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func testAsyncLoadImageContent() async {
|
|
51
|
+
// Given
|
|
52
|
+
mockContext.addMockImageItem(createTestImage())
|
|
53
|
+
|
|
54
|
+
// When
|
|
55
|
+
let result = await loadSharedContent(from: mockContext)
|
|
56
|
+
|
|
57
|
+
// Then
|
|
58
|
+
XCTAssertNotNil(result)
|
|
59
|
+
let images = result?["images"] as? [String]
|
|
60
|
+
XCTAssertNotNil(images)
|
|
61
|
+
XCTAssertGreaterThan(images?.count ?? 0, 0)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
func testAsyncLoadMultipleAttachments() async {
|
|
65
|
+
// Given
|
|
66
|
+
mockContext.addMockTextItem("Sample text")
|
|
67
|
+
mockContext.addMockURLItem(URL(string: "https://example.com")!)
|
|
68
|
+
mockContext.addMockImageItem(createTestImage())
|
|
69
|
+
|
|
70
|
+
// When
|
|
71
|
+
let result = await loadSharedContent(from: mockContext)
|
|
72
|
+
|
|
73
|
+
// Then
|
|
74
|
+
XCTAssertNotNil(result)
|
|
75
|
+
XCTAssertNotNil(result?["text"])
|
|
76
|
+
XCTAssertNotNil(result?["url"])
|
|
77
|
+
XCTAssertNotNil(result?["images"])
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// MARK: - Image Processing Tests
|
|
81
|
+
|
|
82
|
+
func testImageToPNGConversion() {
|
|
83
|
+
// Given
|
|
84
|
+
let testImage = createTestImage(color: .red)
|
|
85
|
+
|
|
86
|
+
// When
|
|
87
|
+
guard let pngData = testImage.pngData() else {
|
|
88
|
+
XCTFail("Failed to convert image to PNG")
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Then
|
|
93
|
+
XCTAssertGreaterThan(pngData.count, 0)
|
|
94
|
+
|
|
95
|
+
// Verify it can be loaded back
|
|
96
|
+
let loadedImage = UIImage(data: pngData)
|
|
97
|
+
XCTAssertNotNil(loadedImage)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
func testImageTemporaryFileStorage() {
|
|
101
|
+
// Given
|
|
102
|
+
let testImage = createTestImage()
|
|
103
|
+
guard let pngData = testImage.pngData() else {
|
|
104
|
+
XCTFail("Failed to convert image to PNG")
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// When
|
|
109
|
+
let tempURL = FileManager.default.temporaryDirectory
|
|
110
|
+
.appendingPathComponent(UUID().uuidString + ".png")
|
|
111
|
+
|
|
112
|
+
do {
|
|
113
|
+
try pngData.write(to: tempURL)
|
|
114
|
+
|
|
115
|
+
// Then
|
|
116
|
+
XCTAssertTrue(FileManager.default.fileExists(atPath: tempURL.path))
|
|
117
|
+
|
|
118
|
+
// Cleanup
|
|
119
|
+
try? FileManager.default.removeItem(at: tempURL)
|
|
120
|
+
} catch {
|
|
121
|
+
XCTFail("Failed to write image: \(error)")
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
func testMultipleImageProcessing() {
|
|
126
|
+
// Given
|
|
127
|
+
let images = [
|
|
128
|
+
createTestImage(color: .red),
|
|
129
|
+
createTestImage(color: .green),
|
|
130
|
+
createTestImage(color: .blue)
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
// When
|
|
134
|
+
var imageURLs: [String] = []
|
|
135
|
+
for image in images {
|
|
136
|
+
if let pngData = image.pngData() {
|
|
137
|
+
let tempURL = FileManager.default.temporaryDirectory
|
|
138
|
+
.appendingPathComponent(UUID().uuidString + ".png")
|
|
139
|
+
try? pngData.write(to: tempURL)
|
|
140
|
+
imageURLs.append(tempURL.absoluteString)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Then
|
|
145
|
+
XCTAssertEqual(imageURLs.count, 3)
|
|
146
|
+
|
|
147
|
+
// Cleanup
|
|
148
|
+
for urlString in imageURLs {
|
|
149
|
+
if let url = URL(string: urlString) {
|
|
150
|
+
try? FileManager.default.removeItem(at: url)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// MARK: - Attachment Item Loading Tests
|
|
156
|
+
|
|
157
|
+
func testLoadAttachmentItem_Text() async {
|
|
158
|
+
// Given
|
|
159
|
+
let attachment = NSItemProvider(item: "Test text" as NSString, typeIdentifier: "public.plain-text")
|
|
160
|
+
|
|
161
|
+
// When
|
|
162
|
+
let result = await loadAttachmentItem(attachment, typeIdentifier: "public.plain-text")
|
|
163
|
+
|
|
164
|
+
// Then
|
|
165
|
+
XCTAssertNotNil(result)
|
|
166
|
+
XCTAssertTrue(result is String)
|
|
167
|
+
XCTAssertEqual(result as? String, "Test text")
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
func testLoadAttachmentItem_URL() async {
|
|
171
|
+
// Given
|
|
172
|
+
let testURL = URL(string: "https://example.com")!
|
|
173
|
+
let attachment = NSItemProvider(item: testURL as NSURL, typeIdentifier: "public.url")
|
|
174
|
+
|
|
175
|
+
// When
|
|
176
|
+
let result = await loadAttachmentItem(attachment, typeIdentifier: "public.url")
|
|
177
|
+
|
|
178
|
+
// Then
|
|
179
|
+
XCTAssertNotNil(result)
|
|
180
|
+
XCTAssertTrue(result is URL)
|
|
181
|
+
XCTAssertEqual((result as? URL)?.absoluteString, testURL.absoluteString)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
func testLoadAttachmentItem_InvalidType() async {
|
|
185
|
+
// Given
|
|
186
|
+
let attachment = NSItemProvider(item: "Text" as NSString, typeIdentifier: "public.plain-text")
|
|
187
|
+
|
|
188
|
+
// When - Try to load as wrong type
|
|
189
|
+
let result = await loadAttachmentItem(attachment, typeIdentifier: "public.image")
|
|
190
|
+
|
|
191
|
+
// Then
|
|
192
|
+
XCTAssertNil(result)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// MARK: - Shared Data Props Tests
|
|
196
|
+
|
|
197
|
+
func testGetSharedDataProps_EmptyData() {
|
|
198
|
+
// Given
|
|
199
|
+
let sharedText: String? = nil
|
|
200
|
+
let sharedURL: String? = nil
|
|
201
|
+
let sharedImages: [String] = []
|
|
202
|
+
let sharedFiles: [String] = []
|
|
203
|
+
|
|
204
|
+
// When
|
|
205
|
+
let props = createSharedDataProps(
|
|
206
|
+
text: sharedText,
|
|
207
|
+
url: sharedURL,
|
|
208
|
+
images: sharedImages,
|
|
209
|
+
files: sharedFiles
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
// Then
|
|
213
|
+
XCTAssertTrue(props.isEmpty)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
func testGetSharedDataProps_WithText() {
|
|
217
|
+
// Given
|
|
218
|
+
let sharedText = "Sample text"
|
|
219
|
+
|
|
220
|
+
// When
|
|
221
|
+
let props = createSharedDataProps(
|
|
222
|
+
text: sharedText,
|
|
223
|
+
url: nil,
|
|
224
|
+
images: [],
|
|
225
|
+
files: []
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
// Then
|
|
229
|
+
XCTAssertEqual(props.count, 1)
|
|
230
|
+
XCTAssertEqual(props["text"] as? String, sharedText)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
func testGetSharedDataProps_WithURL() {
|
|
234
|
+
// Given
|
|
235
|
+
let sharedURL = "https://example.com"
|
|
236
|
+
|
|
237
|
+
// When
|
|
238
|
+
let props = createSharedDataProps(
|
|
239
|
+
text: nil,
|
|
240
|
+
url: sharedURL,
|
|
241
|
+
images: [],
|
|
242
|
+
files: []
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
// Then
|
|
246
|
+
XCTAssertEqual(props.count, 1)
|
|
247
|
+
XCTAssertEqual(props["url"] as? String, sharedURL)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
func testGetSharedDataProps_WithImages() {
|
|
251
|
+
// Given
|
|
252
|
+
let images = ["file:///tmp/image1.png", "file:///tmp/image2.png"]
|
|
253
|
+
|
|
254
|
+
// When
|
|
255
|
+
let props = createSharedDataProps(
|
|
256
|
+
text: nil,
|
|
257
|
+
url: nil,
|
|
258
|
+
images: images,
|
|
259
|
+
files: []
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
// Then
|
|
263
|
+
XCTAssertEqual(props.count, 1)
|
|
264
|
+
let resultImages = props["images"] as? [String]
|
|
265
|
+
XCTAssertEqual(resultImages, images)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
func testGetSharedDataProps_WithAllData() {
|
|
269
|
+
// Given
|
|
270
|
+
let text = "Text"
|
|
271
|
+
let url = "https://example.com"
|
|
272
|
+
let images = ["image1.png"]
|
|
273
|
+
let files = ["file1.pdf"]
|
|
274
|
+
|
|
275
|
+
// When
|
|
276
|
+
let props = createSharedDataProps(
|
|
277
|
+
text: text,
|
|
278
|
+
url: url,
|
|
279
|
+
images: images,
|
|
280
|
+
files: files
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
// Then
|
|
284
|
+
XCTAssertEqual(props.count, 4)
|
|
285
|
+
XCTAssertEqual(props["text"] as? String, text)
|
|
286
|
+
XCTAssertEqual(props["url"] as? String, url)
|
|
287
|
+
XCTAssertEqual(props["images"] as? [String], images)
|
|
288
|
+
XCTAssertEqual(props["files"] as? [String], files)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// MARK: - Error Handling Tests
|
|
292
|
+
|
|
293
|
+
func testHandleLoadingError() async {
|
|
294
|
+
// Given - Empty context
|
|
295
|
+
|
|
296
|
+
// When
|
|
297
|
+
let result = await loadSharedContent(from: mockContext)
|
|
298
|
+
|
|
299
|
+
// Then - Should return nil gracefully
|
|
300
|
+
XCTAssertNil(result)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
func testHandleCorruptedAttachment() async {
|
|
304
|
+
// Given - Mock context with no actual data
|
|
305
|
+
let item = NSExtensionItem()
|
|
306
|
+
item.attachments = []
|
|
307
|
+
mockContext.mockInputItems = [item]
|
|
308
|
+
|
|
309
|
+
// When
|
|
310
|
+
let result = await loadSharedContent(from: mockContext)
|
|
311
|
+
|
|
312
|
+
// Then
|
|
313
|
+
XCTAssertNil(result)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// MARK: - Performance Tests
|
|
317
|
+
|
|
318
|
+
func testPerformance_LoadMultipleAttachments() async {
|
|
319
|
+
// Given
|
|
320
|
+
mockContext.addMockTextItem("Text 1")
|
|
321
|
+
mockContext.addMockTextItem("Text 2")
|
|
322
|
+
mockContext.addMockURLItem(URL(string: "https://example1.com")!)
|
|
323
|
+
mockContext.addMockURLItem(URL(string: "https://example2.com")!)
|
|
324
|
+
|
|
325
|
+
// Measure
|
|
326
|
+
let startTime = Date()
|
|
327
|
+
_ = await loadSharedContent(from: mockContext)
|
|
328
|
+
let duration = Date().timeIntervalSince(startTime)
|
|
329
|
+
|
|
330
|
+
print("Load multiple attachments duration: \(duration)s")
|
|
331
|
+
XCTAssertLessThan(duration, 2.0, "Loading took too long")
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// MARK: - Helper Methods
|
|
335
|
+
|
|
336
|
+
private func loadSharedContent(from context: MockExtensionContext) async -> [String: Any]? {
|
|
337
|
+
guard let extensionItem = context.inputItems.first as? NSExtensionItem,
|
|
338
|
+
let attachments = extensionItem.attachments else {
|
|
339
|
+
return nil
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
var result: [String: Any] = [:]
|
|
343
|
+
|
|
344
|
+
for attachment in attachments {
|
|
345
|
+
if attachment.hasItemConformingToTypeIdentifier("public.plain-text") {
|
|
346
|
+
if let data = await loadAttachmentItem(attachment, typeIdentifier: "public.plain-text") as? String {
|
|
347
|
+
result["text"] = data
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if attachment.hasItemConformingToTypeIdentifier("public.url") {
|
|
352
|
+
if let url = await loadAttachmentItem(attachment, typeIdentifier: "public.url") as? URL {
|
|
353
|
+
result["url"] = url.absoluteString
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if attachment.hasItemConformingToTypeIdentifier("public.image") {
|
|
358
|
+
if let url = await loadAttachmentItem(attachment, typeIdentifier: "public.image") as? URL {
|
|
359
|
+
var images = result["images"] as? [String] ?? []
|
|
360
|
+
images.append(url.absoluteString)
|
|
361
|
+
result["images"] = images
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return result.isEmpty ? nil : result
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
private func loadAttachmentItem(_ attachment: NSItemProvider, typeIdentifier: String) async -> NSSecureCoding? {
|
|
370
|
+
return await withCheckedContinuation { continuation in
|
|
371
|
+
attachment.loadItem(forTypeIdentifier: typeIdentifier, options: nil) { data, error in
|
|
372
|
+
if error != nil {
|
|
373
|
+
continuation.resume(returning: nil)
|
|
374
|
+
} else {
|
|
375
|
+
continuation.resume(returning: data)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
private func createSharedDataProps(
|
|
382
|
+
text: String?,
|
|
383
|
+
url: String?,
|
|
384
|
+
images: [String],
|
|
385
|
+
files: [String]
|
|
386
|
+
) -> [String: Any] {
|
|
387
|
+
var data: [String: Any] = [:]
|
|
388
|
+
|
|
389
|
+
if let text = text {
|
|
390
|
+
data["text"] = text
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if let url = url {
|
|
394
|
+
data["url"] = url
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if !images.isEmpty {
|
|
398
|
+
data["images"] = images
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if !files.isEmpty {
|
|
402
|
+
data["files"] = files
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return data
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
private func createTestImage(
|
|
409
|
+
size: CGSize = CGSize(width: 100, height: 100),
|
|
410
|
+
color: UIColor = .blue
|
|
411
|
+
) -> UIImage {
|
|
412
|
+
UIGraphicsBeginImageContextWithOptions(size, false, 1.0)
|
|
413
|
+
defer { UIGraphicsEndImageContext() }
|
|
414
|
+
|
|
415
|
+
let context = UIGraphicsGetCurrentContext()
|
|
416
|
+
context?.setFillColor(color.cgColor)
|
|
417
|
+
context?.fill(CGRect(origin: .zero, size: size))
|
|
418
|
+
|
|
419
|
+
return UIGraphicsGetImageFromCurrentImageContext() ?? UIImage()
|
|
420
|
+
}
|
|
421
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"configurations" : [
|
|
3
|
+
{
|
|
4
|
+
"id" : "DEFAULT",
|
|
5
|
+
"name" : "Configuration 1",
|
|
6
|
+
"options" : {
|
|
7
|
+
"codeCoverage" : {
|
|
8
|
+
"targets" : [
|
|
9
|
+
{
|
|
10
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
11
|
+
"identifier" : "ExpoTargetsStorage",
|
|
12
|
+
"name" : "ExpoTargetsStorage"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
16
|
+
"identifier" : "ExpoTargetsExtension",
|
|
17
|
+
"name" : "ExpoTargetsExtension"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"environmentVariableEntries" : [
|
|
22
|
+
{
|
|
23
|
+
"key" : "DEBUG",
|
|
24
|
+
"value" : "expo-targets:*"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"language" : "en",
|
|
28
|
+
"region" : "US",
|
|
29
|
+
"targetForVariableExpansion" : {
|
|
30
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
31
|
+
"identifier" : "ExpoTargetsTests",
|
|
32
|
+
"name" : "ExpoTargetsTests"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"defaultOptions" : {
|
|
38
|
+
"codeCoverage" : true,
|
|
39
|
+
"defaultTestExecutionTimeAllowance" : 60,
|
|
40
|
+
"maximumTestExecutionTimeAllowance" : 120,
|
|
41
|
+
"testExecutionOrdering" : "random",
|
|
42
|
+
"testTimeoutsEnabled" : true
|
|
43
|
+
},
|
|
44
|
+
"testTargets" : [
|
|
45
|
+
{
|
|
46
|
+
"parallelizable" : true,
|
|
47
|
+
"target" : {
|
|
48
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
49
|
+
"identifier" : "ExpoTargetsStorageModuleTests",
|
|
50
|
+
"name" : "ExpoTargetsStorageModuleTests"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"parallelizable" : true,
|
|
55
|
+
"target" : {
|
|
56
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
57
|
+
"identifier" : "ExpoTargetsExtensionModuleTests",
|
|
58
|
+
"name" : "ExpoTargetsExtensionModuleTests"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"parallelizable" : true,
|
|
63
|
+
"target" : {
|
|
64
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
65
|
+
"identifier" : "TargetIntegrationTests",
|
|
66
|
+
"name" : "TargetIntegrationTests"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"parallelizable" : false,
|
|
71
|
+
"target" : {
|
|
72
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
73
|
+
"identifier" : "StoragePerformanceTests",
|
|
74
|
+
"name" : "StoragePerformanceTests"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"parallelizable" : true,
|
|
79
|
+
"target" : {
|
|
80
|
+
"containerPath" : "container:ExpoTargets.xcodeproj",
|
|
81
|
+
"identifier" : "ShareExtensionTemplateTests",
|
|
82
|
+
"name" : "ShareExtensionTemplateTests"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"version" : 1
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { withTargetsMetro } from './withTargetsMetro';
|