Skip to content

Commit

Permalink
Basic support for catalyst tests (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahsmartin authored May 1, 2024
1 parent 8a82556 commit c726c8b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions DemoApp/DemoApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"DemoApp/Preview Content\"";
DEVELOPMENT_TEAM = 62J2XHNK9T;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
Expand Down Expand Up @@ -652,7 +652,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"DemoApp/Preview Content\"";
DEVELOPMENT_TEAM = 62J2XHNK9T;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
Expand Down
7 changes: 1 addition & 6 deletions DemoApp/DemoApp/DemoApp.entitlements
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
<dict/>
</plist>
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let package = Package(
// Target that provides the XCTest
.target(name: "SnapshottingTests"),
// Core functionality
.target(name: "SnapshotPreviewsCore", dependencies: ["PreviewsSupport", .product(name: "AccessibilitySnapshotCore", package: "AccessibilitySnapshot", condition: .when(platforms: [.iOS]))]),
.target(name: "SnapshotPreviewsCore", dependencies: ["PreviewsSupport", .product(name: "AccessibilitySnapshotCore", package: "AccessibilitySnapshot", condition: .when(platforms: [.iOS, .macCatalyst]))]),
.target(name: "SnapshotPreferences", dependencies: ["SnapshotPreviewsCore"]),
// Inserted dylib
.target(name: "Snapshotting", dependencies: ["SnapshottingSwift"]),
Expand Down
4 changes: 2 additions & 2 deletions Sources/SnapshottingSwift/Snapshots.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension SnapshotError: LocalizedError {
}

class Snapshots {
let server = HTTPServer(port: 8080)
let server = HTTPServer(port: 38824)
let testHandler: NSObject.Type? = NSClassFromString("EMGTestHandler") as? NSObject.Type

public init() {
Expand All @@ -34,7 +34,7 @@ class Snapshots {
.filter { $0.activationState == .foregroundActive }
.first

let window = UIWindow(windowScene: windowScene as! UIWindowScene)
let window = windowScene != nil ? UIWindow(windowScene: windowScene as! UIWindowScene) : UIWindow()
window.windowLevel = .statusBar + 1
window.backgroundColor = UIColor.systemBackground
window.makeKeyAndVisible()
Expand Down
4 changes: 2 additions & 2 deletions Sources/SnapshottingTests/PreviewTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ - (void)generateSnapshots {
[app launch];

XCTestExpectation *expectation = [self expectationWithDescription:@"Waiting for network response"];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8080/file"]];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:38824/file"]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (data) {
Expand Down Expand Up @@ -164,7 +164,7 @@ void dynamicTestMethod(id self, SEL _cmd) {
NSString *typeName = typeNames[index];
NSNumber *previewId = previewIds[index];
XCTestExpectation *expectation = [self expectationWithDescription:@"Waiting for network response"];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8080/display/%@/%d", typeName, previewId.intValue]];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:38824/display/%@/%d", typeName, previewId.intValue]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

__block NSData *resultData;
Expand Down

0 comments on commit c726c8b

Please sign in to comment.