redefinition of enumerator 'NSAttachmentCharacter' with Apple internal build
[WebKit-https.git] / Tools / TestWebKitAPI / Tests / WebCore / cocoa / AVFoundationSoftLinkTest.mm
1 /*
2  * Copyright (C) 2019 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27
28 #if PLATFORM(COCOA)
29
30 #import <pal/cocoa/AVFoundationSoftLink.h>
31
32 namespace TestWebKitAPI {
33
34 TEST(AVFoundationSoftLink, Classes)
35 {
36     EXPECT_NE(PAL::getAVPlayerClass(), nullptr);
37     EXPECT_NE(PAL::getAVPlayerItemClass(), nullptr);
38     EXPECT_NE(PAL::getAVPlayerItemVideoOutputClass(), nullptr);
39     EXPECT_NE(PAL::getAVPlayerLayerClass(), nullptr);
40     EXPECT_NE(PAL::getAVURLAssetClass(), nullptr);
41     EXPECT_NE(PAL::getAVAssetImageGeneratorClass(), nullptr);
42     EXPECT_NE(PAL::getAVMetadataItemClass(), nullptr);
43     EXPECT_NE(PAL::getAVAssetCacheClass(), nullptr);
44     EXPECT_NE(PAL::getAVPlayerItemLegibleOutputClass(), nullptr);
45     EXPECT_NE(PAL::getAVMediaSelectionGroupClass(), nullptr);
46     EXPECT_NE(PAL::getAVMediaSelectionOptionClass(), nullptr);
47     EXPECT_NE(PAL::getAVOutputContextClass(), nullptr);
48     EXPECT_NE(PAL::getAVAssetReaderClass(), nullptr);
49     EXPECT_NE(PAL::getAVAssetWriterClass(), nullptr);
50     EXPECT_NE(PAL::getAVAssetWriterInputClass(), nullptr);
51     EXPECT_NE(PAL::getAVCaptureSessionClass(), nullptr);
52     EXPECT_NE(PAL::getAVCaptureConnectionClass(), nullptr);
53     EXPECT_NE(PAL::getAVCaptureDeviceClass(), nullptr);
54     EXPECT_NE(PAL::getAVCaptureDeviceFormatClass(), nullptr);
55     EXPECT_NE(PAL::getAVCaptureDeviceInputClass(), nullptr);
56     EXPECT_NE(PAL::getAVCaptureOutputClass(), nullptr);
57     EXPECT_NE(PAL::getAVCaptureVideoDataOutputClass(), nullptr);
58     EXPECT_NE(PAL::getAVFrameRateRangeClass(), nullptr);
59     EXPECT_NE(PAL::getAVMutableAudioMixClass(), nullptr);
60     EXPECT_NE(PAL::getAVMutableAudioMixInputParametersClass(), nullptr);
61
62 #if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
63     EXPECT_NE(PAL::getAVStreamSessionClass(), nullptr);
64     EXPECT_NE(PAL::getAVStreamDataParserClass(), nullptr);
65 #endif
66
67 #if PLATFORM(IOS_FAMILY)
68     EXPECT_NE(PAL::getAVPersistableContentKeyRequestClass(), nullptr);
69     EXPECT_NE(PAL::getAVAudioSessionClass(), nullptr);
70     EXPECT_NE(PAL::getAVSpeechSynthesizerClass(), nullptr);
71     EXPECT_NE(PAL::getAVSpeechUtteranceClass(), nullptr);
72     EXPECT_NE(PAL::getAVSpeechSynthesisVoiceClass(), nullptr);
73 #endif
74
75 #if HAVE(MEDIA_PLAYER) && !PLATFORM(WATCHOS)
76     EXPECT_NE(PAL::getAVRouteDetectorClass(), nullptr);
77 #endif
78
79     EXPECT_NE(PAL::getAVContentKeyResponseClass(), nullptr);
80     EXPECT_NE(PAL::getAVContentKeySessionClass(), nullptr);
81     EXPECT_NE(PAL::getAVAssetResourceLoadingRequestClass(), nullptr);
82     EXPECT_NE(PAL::getAVAssetReaderSampleReferenceOutputClass(), nullptr);
83     EXPECT_NE(PAL::getAVVideoPerformanceMetricsClass(), nullptr);
84     EXPECT_NE(PAL::getAVSampleBufferAudioRendererClass(), nullptr);
85     EXPECT_NE(PAL::getAVSampleBufferDisplayLayerClass(), nullptr);
86     EXPECT_NE(PAL::getAVSampleBufferRenderSynchronizerClass(), nullptr);
87 }
88
89
90 TEST(AVFoundationSoftLink, Constants)
91 {
92     EXPECT_TRUE([AVAudioTimePitchAlgorithmSpectral isEqualToString:@"Spectral"]);
93     EXPECT_TRUE([AVAudioTimePitchAlgorithmVarispeed isEqualToString:@"Varispeed"]);
94     EXPECT_TRUE([AVMediaTypeClosedCaption isEqualToString:@"clcp"]);
95     EXPECT_TRUE([AVMediaTypeVideo isEqualToString:@"vide"]);
96     EXPECT_TRUE([AVMediaTypeAudio isEqualToString:@"soun"]);
97     EXPECT_TRUE([AVMediaTypeMuxed isEqualToString:@"muxx"]);
98     EXPECT_TRUE([AVMediaTypeMetadata isEqualToString:@"meta"]);
99     EXPECT_TRUE([AVAssetImageGeneratorApertureModeCleanAperture isEqualToString:@"CleanAperture"]);
100     EXPECT_TRUE([AVStreamingKeyDeliveryContentKeyType isEqualToString:@"com.apple.streamingkeydelivery.contentkey"]);
101     EXPECT_TRUE([AVMediaCharacteristicContainsOnlyForcedSubtitles isEqualToString:@"public.subtitles.forced-only"]);
102     EXPECT_TRUE([AVMetadataCommonKeyTitle isEqualToString:@"title"]);
103     EXPECT_TRUE([AVMetadataKeySpaceCommon isEqualToString:@"comn"]);
104     EXPECT_TRUE([AVMediaTypeSubtitle isEqualToString:@"sbtl"]);
105     EXPECT_TRUE([AVMediaCharacteristicIsMainProgramContent isEqualToString:@"public.main-program-content"]);
106     EXPECT_TRUE([AVMediaCharacteristicEasyToRead isEqualToString:@"public.easy-to-read"]);
107     EXPECT_TRUE([AVFileTypeMPEG4 isEqualToString:@"public.mpeg-4"]);
108     EXPECT_TRUE([AVVideoCodecH264 isEqualToString:@"avc1"]);
109     EXPECT_TRUE([AVVideoExpectedSourceFrameRateKey isEqualToString:@"ExpectedFrameRate"]);
110     EXPECT_TRUE([AVVideoProfileLevelKey isEqualToString:@"ProfileLevel"]);
111     EXPECT_TRUE([AVVideoAverageBitRateKey isEqualToString:@"AverageBitRate"]);
112     EXPECT_TRUE([AVVideoMaxKeyFrameIntervalKey isEqualToString:@"MaxKeyFrameInterval"]);
113     EXPECT_TRUE([AVVideoProfileLevelH264MainAutoLevel isEqualToString:@"H264_Main_AutoLevel"]);
114     EXPECT_TRUE([AVOutOfBandAlternateTrackDisplayNameKey isEqualToString:@"MediaSelectionOptionsName"]);
115     EXPECT_TRUE([AVOutOfBandAlternateTrackExtendedLanguageTagKey isEqualToString:@"MediaSelectionOptionsExtendedLanguageTag"]);
116     EXPECT_TRUE([AVOutOfBandAlternateTrackIsDefaultKey isEqualToString:@"MediaSelectionOptionsIsDefault"]);
117     EXPECT_TRUE([AVOutOfBandAlternateTrackMediaCharactersticsKey isEqualToString:@"MediaSelectionOptionsTaggedMediaCharacteristics"]);
118     EXPECT_TRUE([AVOutOfBandAlternateTrackIdentifierKey isEqualToString:@"MediaSelectionOptionsClientIdentifier"]);
119     EXPECT_TRUE([AVOutOfBandAlternateTrackSourceKey isEqualToString:@"MediaSelectionOptionsURL"]);
120     EXPECT_TRUE([AVMediaCharacteristicDescribesMusicAndSoundForAccessibility isEqualToString:@"public.accessibility.describes-music-and-sound"]);
121     EXPECT_TRUE([AVMediaCharacteristicTranscribesSpokenDialogForAccessibility isEqualToString:@"public.accessibility.transcribes-spoken-dialog"]);
122     EXPECT_TRUE([AVMediaCharacteristicIsAuxiliaryContent isEqualToString:@"public.auxiliary-content"]);
123     EXPECT_TRUE([AVMediaCharacteristicDescribesVideoForAccessibility isEqualToString:@"public.accessibility.describes-video"]);
124     EXPECT_TRUE([AVMetadataKeySpaceQuickTimeUserData isEqualToString:@"udta"]);
125     EXPECT_TRUE([AVMetadataKeySpaceQuickTimeMetadata isEqualToString:@"mdta"]);
126     EXPECT_TRUE([AVMetadataKeySpaceiTunes isEqualToString:@"itsk"]);
127     EXPECT_TRUE([AVMetadataKeySpaceID3 isEqualToString:@"org.id3"]);
128     EXPECT_TRUE([AVMetadataKeySpaceISOUserData isEqualToString:@"uiso"]);
129
130     if (PAL::canLoad_AVFoundation_AVEncoderBitRateKey())
131         EXPECT_TRUE([AVEncoderBitRateKey isEqualToString:@"AVEncoderBitRateKey"]);
132     if (PAL::canLoad_AVFoundation_AVFormatIDKey())
133         EXPECT_TRUE([AVFormatIDKey isEqualToString:@"AVFormatIDKey"]);
134     if (PAL::canLoad_AVFoundation_AVNumberOfChannelsKey())
135         EXPECT_TRUE([AVNumberOfChannelsKey isEqualToString:@"AVNumberOfChannelsKey"]);
136     if (PAL::canLoad_AVFoundation_AVSampleRateKey())
137         EXPECT_TRUE([AVSampleRateKey isEqualToString:@"AVSampleRateKey"]);
138
139 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 40000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 110000)
140     EXPECT_TRUE(PAL::canLoad_AVFoundation_AVURLAssetOutOfBandMIMETypeKey());
141     EXPECT_TRUE([AVURLAssetOutOfBandMIMETypeKey isEqualToString:@"AVURLAssetOutOfBandMIMETypeKey"]);
142 #endif
143
144 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 50000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 120000)
145     EXPECT_TRUE(PAL::canLoad_AVFoundation_AVURLAssetUseClientURLLoadingExclusively());
146     EXPECT_TRUE([AVURLAssetUseClientURLLoadingExclusively isEqualToString:@"AVURLAssetUseClientURLLoadingExclusively"]);
147 #endif
148
149 #if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION)
150     EXPECT_TRUE(PAL::canLoad_AVFoundation_AVContentKeySystemFairPlayStreaming());
151     EXPECT_TRUE([AVContentKeySystemFairPlayStreaming isEqualToString:@"FairPlayStreaming"]);
152 #endif
153
154 #if ENABLE(LEGACY_ENCRYPTED_MEDIA) && ENABLE(MEDIA_SOURCE)
155     EXPECT_TRUE(PAL::canLoad_AVFoundation_AVContentKeyRequestProtocolVersionsKey());
156     EXPECT_TRUE([AVContentKeyRequestProtocolVersionsKey isEqualToString:@"ProtocolVersionsKey"]);
157 #endif
158
159 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000)
160     EXPECT_TRUE(PAL::canLoad_AVFoundation_AVVideoCodecTypeHEVCWithAlpha());
161     EXPECT_TRUE([AVVideoCodecTypeHEVCWithAlpha isEqualToString:@"muxa"]);
162 #endif
163
164 #if PLATFORM(MAC)
165     EXPECT_TRUE([AVStreamDataParserContentKeyRequestProtocolVersionsKey isEqualToString:@"AVContentKeyRequestProtocolVersionsKey"]);
166 #endif
167
168 #if PLATFORM(IOS_FAMILY)
169     EXPECT_TRUE([AVURLAssetBoundNetworkInterfaceName isEqualToString:@"AVURLAssetBoundNetworkInterfaceName"]);
170     EXPECT_TRUE([AVURLAssetClientBundleIdentifierKey isEqualToString:@"AVURLAssetClientBundleIdentifierKey"]);
171     EXPECT_TRUE([AVCaptureSessionRuntimeErrorNotification isEqualToString:@"AVCaptureSessionRuntimeErrorNotification"]);
172     EXPECT_TRUE([AVCaptureSessionWasInterruptedNotification isEqualToString:@"AVCaptureSessionWasInterruptedNotification"]);
173     EXPECT_TRUE([AVCaptureSessionInterruptionEndedNotification isEqualToString:@"AVCaptureSessionInterruptionEndedNotification"]);
174     EXPECT_TRUE([AVCaptureSessionInterruptionReasonKey isEqualToString:@"AVCaptureSessionInterruptionReasonKey"]);
175     EXPECT_TRUE([AVCaptureSessionErrorKey isEqualToString:@"AVCaptureSessionErrorKey"]);
176     EXPECT_TRUE([AVAudioSessionCategoryAmbient isEqualToString:@"AVAudioSessionCategoryAmbient"]);
177     EXPECT_TRUE([AVAudioSessionCategorySoloAmbient isEqualToString:@"AVAudioSessionCategorySoloAmbient"]);
178     EXPECT_TRUE([AVAudioSessionCategoryPlayback isEqualToString:@"AVAudioSessionCategoryPlayback"]);
179     EXPECT_TRUE([AVAudioSessionCategoryRecord isEqualToString:@"AVAudioSessionCategoryRecord"]);
180     EXPECT_TRUE([AVAudioSessionCategoryPlayAndRecord isEqualToString:@"AVAudioSessionCategoryPlayAndRecord"]);
181     EXPECT_TRUE([AVAudioSessionCategoryAudioProcessing isEqualToString:@"AVAudioSessionCategoryAudioProcessing"]);
182     EXPECT_TRUE([AVAudioSessionModeDefault isEqualToString:@"AVAudioSessionModeDefault"]);
183     EXPECT_TRUE([AVAudioSessionModeVideoChat isEqualToString:@"AVAudioSessionModeVideoChat"]);
184     EXPECT_TRUE([AVAudioSessionInterruptionNotification isEqualToString:@"AVAudioSessionInterruptionNotification"]);
185     EXPECT_TRUE([AVAudioSessionInterruptionTypeKey isEqualToString:@"AVAudioSessionInterruptionTypeKey"]);
186     EXPECT_TRUE([AVAudioSessionInterruptionOptionKey isEqualToString:@"AVAudioSessionInterruptionOptionKey"]);
187     EXPECT_TRUE([AVRouteDetectorMultipleRoutesDetectedDidChangeNotification isEqualToString:@"AVRouteDetectorMultipleRoutesDetectedDidChangeNotification"]);
188 #endif
189 }
190
191 #endif // PLATFORM(COCOA)
192
193 } // namespace TestWebKitAPI
194