Flutter Engine
The Flutter Engine
Instance Methods | List of all members
VsyncWaiterIosTest Class Reference
Inheritance diagram for VsyncWaiterIosTest:

Instance Methods

(void) - testSetAllowPauseAfterVsyncCorrect [implementation]
 
(void) - testSetCorrectVariableRefreshRates [implementation]
 
(void) - testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotOn [implementation]
 
(void) - testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotSet [implementation]
 
(void) - testAwaitAndPauseWillWorkCorrectly [implementation]
 
(void) - testReleasesLinkOnInvalidation [implementation]
 

Detailed Description

Definition at line 30 of file VsyncWaiterIosTest.mm.

Method Documentation

◆ testAwaitAndPauseWillWorkCorrectly

- (void) testAwaitAndPauseWillWorkCorrectly
implementation

Definition at line 16 of file VsyncWaiterIosTest.mm.

114 {
115 auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
116 VSyncClient* vsyncClient = [[VSyncClient alloc]
117 initWithTaskRunner:thread_task_runner
118 callback:[](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {}];
119
120 CADisplayLink* link = [vsyncClient getDisplayLink];
121 XCTAssertTrue(link.isPaused);
122
123 [vsyncClient await];
124 XCTAssertFalse(link.isPaused);
125
126 [vsyncClient pause];
127 XCTAssertTrue(link.isPaused);
128}
CADisplayLink * getDisplayLink()
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name)
def link(from_root, to_root)
Definition: dart_pkg.py:44

◆ testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotOn

- (void) testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotOn
implementation

Definition at line 16 of file VsyncWaiterIosTest.mm.

74 {
75 auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
76 auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
77 id bundleMock = OCMPartialMock([NSBundle mainBundle]);
78 OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"])
79 .andReturn(@NO);
80 id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
81 double maxFrameRate = 120;
82 [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
83
84 VSyncClient* vsyncClient = [[VSyncClient alloc] initWithTaskRunner:thread_task_runner
85 callback:callback];
86 CADisplayLink* link = [vsyncClient getDisplayLink];
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);
91 } else {
92 XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, 0, 0.1);
93 }
94}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotSet

- (void) testDoNotSetVariableRefreshRatesIfCADisableMinimumFrameDurationOnPhoneIsNotSet
implementation

Definition at line 16 of file VsyncWaiterIosTest.mm.

96 {
97 auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
98 auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
99 id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
100 double maxFrameRate = 120;
101 [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
102 VSyncClient* vsyncClient = [[VSyncClient alloc] initWithTaskRunner:thread_task_runner
103 callback:callback];
104 CADisplayLink* link = [vsyncClient getDisplayLink];
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);
109 } else {
110 XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, 0, 0.1);
111 }
112}

◆ testReleasesLinkOnInvalidation

- (void) testReleasesLinkOnInvalidation
implementation

Definition at line 16 of file VsyncWaiterIosTest.mm.

130 {
131 __weak CADisplayLink* weakLink;
132 @autoreleasepool {
133 auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
134 VSyncClient* vsyncClient = [[VSyncClient alloc]
135 initWithTaskRunner:thread_task_runner
136 callback:[](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {}];
137
138 weakLink = [vsyncClient getDisplayLink];
139 XCTAssertNotNil(weakLink);
140 [vsyncClient invalidate];
141 }
142 // VSyncClient has released the CADisplayLink.
143 XCTAssertNil(weakLink);
144}
void invalidate()
Call invalidate before releasing this object to remove from runloops.

◆ testSetAllowPauseAfterVsyncCorrect

- (void) testSetAllowPauseAfterVsyncCorrect
implementation

Definition at line 16 of file VsyncWaiterIosTest.mm.

35 {
36 auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
37 VSyncClient* vsyncClient = [[VSyncClient alloc]
38 initWithTaskRunner:thread_task_runner
39 callback:[](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {}];
40 CADisplayLink* link = [vsyncClient getDisplayLink];
41 vsyncClient.allowPauseAfterVsync = NO;
42 [vsyncClient await];
43 [vsyncClient onDisplayLink:link];
44 XCTAssertFalse(link.isPaused);
45
46 vsyncClient.allowPauseAfterVsync = YES;
47 [vsyncClient await];
48 [vsyncClient onDisplayLink:link];
49 XCTAssertTrue(link.isPaused);
50}
void onDisplayLink:(CADisplayLink *link)
BOOL allowPauseAfterVsync
Default value is YES. Vsync client will pause vsync callback after receiving a vsync signal....

◆ testSetCorrectVariableRefreshRates

- (void) testSetCorrectVariableRefreshRates
implementation

Definition at line 16 of file VsyncWaiterIosTest.mm.

52 {
53 auto thread_task_runner = CreateNewThread("VsyncWaiterIosTest");
54 auto callback = [](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {};
55 id bundleMock = OCMPartialMock([NSBundle mainBundle]);
56 OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"])
57 .andReturn(@YES);
58 id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
59 double maxFrameRate = 120;
60 [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
61
62 VSyncClient* vsyncClient = [[VSyncClient alloc] initWithTaskRunner:thread_task_runner
63 callback:callback];
64 CADisplayLink* link = [vsyncClient getDisplayLink];
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);
69 } else {
70 XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, maxFrameRate, 0.1);
71 }
72}

The documentation for this class was generated from the following file: