5#import <OCMock/OCMock.h>
6#import <XCTest/XCTest.h>
8#include "flutter/fml/raster_thread_merger.h"
9#include "flutter/fml/thread.h"
11#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
12#import "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h"
17 auto thread = std::make_unique<fml::Thread>(
name);
18 auto runner = thread->GetTaskRunner();
25- (CADisplayLink*)getDisplayLink;
26- (void)onDisplayLink:(CADisplayLink*)link;
38 initWithTaskRunner:thread_task_runner
39 callback:[](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {}];
44 XCTAssertFalse(
link.isPaused);
49 XCTAssertTrue(
link.isPaused);
54 auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
55 id bundleMock = OCMPartialMock([NSBundle mainBundle]);
56 OCMStub([bundleMock objectForInfoDictionaryKey:
@"CADisableMinimumFrameDurationOnPhone"])
59 double maxFrameRate = 120;
60 [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
65 if (@available(iOS 15.0, *)) {
66 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.maximum, maxFrameRate, 0.1);
67 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.preferred, maxFrameRate, 0.1);
68 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.minimum, maxFrameRate / 2, 0.1);
70 XCTAssertEqualWithAccuracy(
link.preferredFramesPerSecond, maxFrameRate, 0.1);
76 auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
77 id bundleMock = OCMPartialMock([NSBundle mainBundle]);
78 OCMStub([bundleMock objectForInfoDictionaryKey:
@"CADisableMinimumFrameDurationOnPhone"])
81 double maxFrameRate = 120;
82 [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
87 if (@available(iOS 15.0, *)) {
88 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.maximum, 0, 0.1);
89 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.preferred, 0, 0.1);
90 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.minimum, 0, 0.1);
92 XCTAssertEqualWithAccuracy(
link.preferredFramesPerSecond, 0, 0.1);
98 auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
100 double maxFrameRate = 120;
101 [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
105 if (@available(iOS 15.0, *)) {
106 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.maximum, 0, 0.1);
107 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.preferred, 0, 0.1);
108 XCTAssertEqualWithAccuracy(
link.preferredFrameRateRange.minimum, 0, 0.1);
110 XCTAssertEqualWithAccuracy(
link.preferredFramesPerSecond, 0, 0.1);
117 initWithTaskRunner:thread_task_runner
118 callback:[](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {}];
121 XCTAssertTrue(
link.isPaused);
124 XCTAssertFalse(
link.isPaused);
127 XCTAssertTrue(
link.isPaused);
131 __weak CADisplayLink* weakLink;
135 initWithTaskRunner:thread_task_runner
136 callback:[](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {}];
139 XCTAssertNotNil(weakLink);
143 XCTAssertNil(weakLink);
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
CADisplayLink * getDisplayLink()
void onDisplayLink:(CADisplayLink *link)
BOOL allowPauseAfterVsync
Default value is YES. Vsync client will pause vsync callback after receiving a vsync signal....
void invalidate()
Call invalidate before releasing this object to remove from runloops.
void testReleasesLinkOnInvalidation()
void testSetAllowPauseAfterVsyncCorrect()
void testAwaitAndPauseWillWorkCorrectly()
void testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotSet()
void testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotOn()
void testSetCorrectVariableRefreshRates()
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name)
def link(from_root, to_root)
DEF_SWITCHES_START aot vmservice shared library name