diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSnapshotBridge.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSnapshotBridge.m index b224ab7290..771b536857 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSnapshotBridge.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSnapshotBridge.m @@ -187,7 +187,9 @@ static NSUInteger RunnerSnapshotBridgeBudgetMs(NSDictionary *request) static NSTimeInterval RunnerSnapshotBridgeAbandonedAt = 0; static const NSTimeInterval RunnerSnapshotBridgeWedgeSeconds = 5; -static dispatch_queue_t RunnerSnapshotBridgeReaderQueue(void) +// The reader queue and RunnerSnapshotBridgeRead have external linkage so the runner unit bundle can +// drive them through UnitTests/RunnerSnapshotBridge+Internal.h. +dispatch_queue_t RunnerSnapshotBridgeReaderQueue(void) { static dispatch_queue_t queue; static dispatch_once_t onceToken; @@ -207,10 +209,10 @@ @implementation RunnerSnapshotBridgeAnswer /// Runs one read on the reader queue and waits for it up to `budgetMs`. A read that outlives the budget /// is abandoned, not stopped: its answer is dropped when it returns. -static NSDictionary *RunnerSnapshotBridgeRead(NSDictionary *request, - NSUInteger budgetMs, - NSDictionary * (^read)(void), - NSTimeInterval (^clock)(void)) +NSDictionary *RunnerSnapshotBridgeRead(NSDictionary *request, + NSUInteger budgetMs, + NSDictionary * (^read)(void), + NSTimeInterval (^clock)(void)) { NSUInteger sequence; @synchronized (RunnerSnapshotBridgeAnswer.class) { @@ -252,18 +254,6 @@ @implementation RunnerSnapshotBridgeAnswer return answer.value; } -#if defined(AGENT_DEVICE_RUNNER_UNIT_TESTS) -NSDictionary *RunnerSnapshotBridgeReadForTest(NSDictionary *request, NSUInteger budgetMs, - NSDictionary *(^read)(void), NSTimeInterval now) -{ - return RunnerSnapshotBridgeRead(request, budgetMs, read, ^{ return now; }); -} -void RunnerSnapshotBridgeDrainForTest(void) -{ - dispatch_sync(RunnerSnapshotBridgeReaderQueue(), ^{}); -} -#endif - uint32_t RunnerSnapshotBridgeMaximumFrameBytes(void) { return kMaximumFrameBytes; diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerSnapshotBridge+Internal.h b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerSnapshotBridge+Internal.h new file mode 100644 index 0000000000..d5c29fcb9b --- /dev/null +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerSnapshotBridge+Internal.h @@ -0,0 +1,19 @@ +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +#if TARGET_OS_IOS && TARGET_OS_SIMULATOR + +// The snapshot bridge's read admission and reader queue, which RunnerSnapshotBridge.m defines for the +// runner unit bundle. The packaged runner omits UnitTests/. A read answers with what `read` returns, +// nil included. +NSDictionary * _Nullable RunnerSnapshotBridgeRead(NSDictionary *request, + NSUInteger budgetMs, + NSDictionary * _Nullable (^read)(void), + NSTimeInterval (^clock)(void)); +dispatch_queue_t RunnerSnapshotBridgeReaderQueue(void); + +#endif + +NS_ASSUME_NONNULL_END diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerSnapshotBridgeTesting.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerSnapshotBridgeTesting.m new file mode 100644 index 0000000000..4bb07a35f7 --- /dev/null +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerSnapshotBridgeTesting.m @@ -0,0 +1,20 @@ +#if defined(AGENT_DEVICE_RUNNER_UNIT_TESTS) +#import "RunnerSnapshotBridgeTesting.h" + +#if TARGET_OS_IOS && TARGET_OS_SIMULATOR + +#import "RunnerSnapshotBridge+Internal.h" + +NSDictionary *RunnerSnapshotBridgeReadForTest(NSDictionary *request, NSUInteger budgetMs, + NSDictionary *(^read)(void), NSTimeInterval now) +{ + return RunnerSnapshotBridgeRead(request, budgetMs, read, ^{ return now; }); +} + +void RunnerSnapshotBridgeDrainForTest(void) +{ + dispatch_sync(RunnerSnapshotBridgeReaderQueue(), ^{}); +} + +#endif +#endif