55
66#define TestFunction (FUNCTION ) XCTAssertTrue(GetFunctionPointer(FUNCTION) != nil)
77
8+ void Identifier (getNowPlayingClient )(Identifier (Tests ) * self ) {
9+ typeof (MRMediaRemoteGetNowPlayingClient ) * func = nil ;
10+
11+ #ifdef LINKED_TESTS
12+ func = & MRMediaRemoteGetNowPlayingClient ;
13+ #elif defined(UNLINKED_TESTS )
14+ func = CFBundleGetFunctionPointerForName (self .cfBundle , CFSTR ("MRMediaRemoteGetNowPlayingClient" ));
15+ #endif
16+
17+ XCTestExpectation * expectation = [self expectationWithDescription :@"Long method" ];
18+ (* func )(dispatch_get_main_queue (), ^(id client ) {
19+ XCTAssertNotNil (client , @"`client` is `nil` when calling `MRMediaRemoteGetNowPlayingClient`. Play some music for this test to pass." );
20+
21+ if (@available (macOS 10.15 , * )) {
22+ XCTAssertTrue ([((NSObject * )client ).className isEqualToString :@"MRClient" ]);
23+ } else {
24+ XCTAssertTrue ([((NSObject * )client ).className isEqualToString :@"_MRNowPlayingClientProtobuf" ]);
25+ }
26+
27+ [expectation fulfill ];
28+ });
29+
30+ [self waitForExpectationsWithTimeout :1 handler :nil ];
31+ }
32+
33+ #define TestMRMediaRemoteGetNowPlayingClient Identifier(getNowPlayingClient)
34+
835#define TestFunctions \
936TestFunction(MRMediaRemoteRegisterForNowPlayingNotifications); \
1037TestFunction(MRMediaRemoteUnregisterForNowPlayingNotifications); \
@@ -15,5 +42,6 @@ TestFunction(MRNowPlayingClientGetBundleIdentifier); \
1542TestFunction(MRNowPlayingClientGetParentAppBundleIdentifier); \
1643TestFunction(MRMediaRemoteSetElapsedTime); \
1744TestFunction(MRMediaRemoteSendCommand); \
45+ TestMRMediaRemoteGetNowPlayingClient(self); \
1846
1947#endif /* TestFunctions_h */
0 commit comments