This is an automated email from the ASF dual-hosted git repository.
dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git
The following commit(s) were added to refs/heads/master by this push:
new f525ec9e fix(tests): Fix test warnings about nil UISceneSession (#1694)
f525ec9e is described below
commit f525ec9ec8b434f79928c66dff2bca06e178066d
Author: Darryl Pogue <[email protected]>
AuthorDate: Tue Aug 25 02:41:06 2026 -0700
fix(tests): Fix test warnings about nil UISceneSession (#1694)
The +alloc method on UISceneSession isn't publicly exposed, so we need
to do it indirectly by calling it on the class instance. We don't
actually do anything with the session, we just need it not to be nil so
it doesn't cause warnings.
---
tests/CordovaLibTests/CDVSceneDelegateTests.m | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/tests/CordovaLibTests/CDVSceneDelegateTests.m
b/tests/CordovaLibTests/CDVSceneDelegateTests.m
index e925426f..7a84acdc 100644
--- a/tests/CordovaLibTests/CDVSceneDelegateTests.m
+++ b/tests/CordovaLibTests/CDVSceneDelegateTests.m
@@ -63,6 +63,7 @@
@interface CDVSceneDelegateTests : XCTestCase
@property (nonatomic, strong) CDVSceneDelegate *sceneDelegate;
@property (nonatomic, strong) UIScene *placeholderScene;
+@property (nonatomic, strong) UISceneSession *placeholderSession;
@end
@implementation CDVSceneDelegateTests
@@ -71,9 +72,14 @@
{
[super setUp];
self.sceneDelegate = [[CDVSceneDelegate alloc] init];
+
// The scene object is only stored and passed back through; it is never
// messaged, so any non-nil placeholder cast to UIScene * is sufficient.
self.placeholderScene = (UIScene *)[NSObject new];
+
+ // You can't construct a UISceneSession directly, but you can workaround
+ // that by indirectly sending +alloc to the class instance
+ self.placeholderSession = [[[UISceneSession class] alloc] init];
}
- (void)tearDown
@@ -82,6 +88,7 @@
[self.sceneDelegate sceneDidDisconnect:self.placeholderScene];
self.sceneDelegate = nil;
self.placeholderScene = nil;
+ self.placeholderSession = nil;
[super tearDown];
}
@@ -103,7 +110,7 @@
notFiredYet.inverted = YES;
[self.sceneDelegate scene:self.placeholderScene
- willConnectToSession:nil
+ willConnectToSession:self.placeholderSession
options:[self connectionOptionsForURL:launchURL]];
// Before the page loads, the open-URL notification must not have fired.
@@ -117,7 +124,7 @@
NSURL *launchURL = [NSURL URLWithString:@"testscheme://path?foo=bar"];
[self.sceneDelegate scene:self.placeholderScene
- willConnectToSession:nil
+ willConnectToSession:self.placeholderSession
options:[self connectionOptionsForURL:launchURL]];
XCTNSNotificationExpectation *openURLFired =
[[XCTNSNotificationExpectation alloc]
@@ -138,7 +145,7 @@
CDVFakeSceneConnectionOptions *options = [CDVFakeSceneConnectionOptions
optionsWithURLContexts:[NSSet set]];
[self.sceneDelegate scene:self.placeholderScene
- willConnectToSession:nil
+ willConnectToSession:self.placeholderSession
options:options];
XCTNSNotificationExpectation *notFired = [[XCTNSNotificationExpectation
alloc]
@@ -157,7 +164,7 @@
NSURL *launchURL = [NSURL URLWithString:@"testscheme://path?foo=bar"];
[self.sceneDelegate scene:self.placeholderScene
- willConnectToSession:nil
+ willConnectToSession:self.placeholderSession
options:[self connectionOptionsForURL:launchURL]];
[self.sceneDelegate sceneDidDisconnect:self.placeholderScene];
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]