Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#import <Foundation/Foundation.h>
#import <TargetConditionals.h>

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
Original file line number Diff line number Diff line change
@@ -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
Loading