Add utility function to allow easy reverse range-based iteration of a container
[WebKit-https.git] / Tools / TestWebKitAPI / CMakeLists.txt
1 set(TESTWEBKITAPI_DIR "${TOOLS_DIR}/TestWebKitAPI")
2 set(test_wtf_LIBRARIES
3     WTF${DEBUG_SUFFIX}
4     gtest
5 )
6
7 set(test_webcore_LIBRARIES
8     WTF${DEBUG_SUFFIX}
9     WebCore${DEBUG_SUFFIX}
10     gtest
11 )
12
13 set(TestWebKitAPI_LIBRARIES
14     WTF${DEBUG_SUFFIX}
15 )
16
17 set(TestWebKitAPI_DEPENDENCIES
18     JavaScriptCoreForwardingHeaders
19     JavaScriptCorePrivateForwardingHeaders
20     WTFForwardingHeaders
21 )
22
23 if (ENABLE_WEBCORE)
24     list(APPEND TestWebKitAPI_DEPENDENCIES PALForwardingHeaders)
25 endif ()
26
27 if (ENABLE_WEBKIT)
28     set(test_webkit_api_LIBRARIES
29         JavaScriptCore
30         TestWebKitAPIBase
31         WTF
32         WebKit
33         gtest
34     )
35
36     set(test_webkit_api_SOURCES
37         ${TESTWEBKITAPI_DIR}/Tests/WebKit/AboutBlankLoad.cpp
38         ${TESTWEBKITAPI_DIR}/Tests/WebKit/CanHandleRequest.cpp
39         ${TESTWEBKITAPI_DIR}/Tests/WebKit/CookieManager.cpp
40         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DocumentStartUserScriptAlertCrash.cpp
41         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DOMWindowExtensionBasic.cpp
42         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DOMWindowExtensionNoCache.cpp
43         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DownloadDecideDestinationCrash.cpp
44         ${TESTWEBKITAPI_DIR}/Tests/WebKit/EnumerateMediaDevices.cpp
45         ${TESTWEBKITAPI_DIR}/Tests/WebKit/EvaluateJavaScript.cpp
46         ${TESTWEBKITAPI_DIR}/Tests/WebKit/FailedLoad.cpp
47         ${TESTWEBKITAPI_DIR}/Tests/WebKit/Find.cpp
48         ${TESTWEBKITAPI_DIR}/Tests/WebKit/FirstMeaningfulPaintMilestone.cpp
49         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ForceRepaint.cpp
50         ${TESTWEBKITAPI_DIR}/Tests/WebKit/FrameMIMETypeHTML.cpp
51         ${TESTWEBKITAPI_DIR}/Tests/WebKit/FrameMIMETypePNG.cpp
52         ${TESTWEBKITAPI_DIR}/Tests/WebKit/Geolocation.cpp
53         ${TESTWEBKITAPI_DIR}/Tests/WebKit/GetInjectedBundleInitializationUserDataCallback.cpp
54         ${TESTWEBKITAPI_DIR}/Tests/WebKit/HitTestResultNodeHandle.cpp
55         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleBasic.cpp
56         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleFrameHitTest.cpp
57         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleInitializationUserDataCallbackWins.cpp
58         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadAlternateHTMLStringWithNonDirectoryURL.cpp
59         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadCanceledNoServerRedirectCallback.cpp
60         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadPageOnCrash.cpp
61         ${TESTWEBKITAPI_DIR}/Tests/WebKit/MouseMoveAfterCrash.cpp
62         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayout.cpp
63         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFails.cpp
64         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutForImages.cpp
65         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFrames.cpp
66         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PageLoadBasic.cpp
67         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PageLoadDidChangeLocationWithinPageForFrame.cpp
68         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ParentFrame.cpp
69         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PendingAPIRequestURL.cpp
70         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PreventEmptyUserAgent.cpp
71         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PrivateBrowsingPushStateNoHistoryCallback.cpp
72         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ProvisionalURLAfterWillSendRequestCallback.cpp
73         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ReloadPageAfterCrash.cpp
74         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ResizeWindowAfterCrash.cpp
75         ${TESTWEBKITAPI_DIR}/Tests/WebKit/RestoreSessionStateContainingFormData.cpp
76         ${TESTWEBKITAPI_DIR}/Tests/WebKit/TextFieldDidBeginAndEndEditing.cpp
77         ${TESTWEBKITAPI_DIR}/Tests/WebKit/UserMedia.cpp
78         ${TESTWEBKITAPI_DIR}/Tests/WebKit/UserMessage.cpp
79         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WillSendSubmitEvent.cpp
80         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKPageCopySessionStateWithFiltering.cpp
81         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKPageGetScaleFactorNotZero.cpp
82         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKPreferences.cpp
83         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKRetainPtr.cpp
84         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKString.cpp
85         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKStringJSString.cpp
86         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKURL.cpp
87     )
88
89     set(TestWebKitAPIBase_LIBRARIES
90         JavaScriptCore
91         WTF
92         WebKit
93         gtest
94     )
95
96     set(TestWebKitAPIBase_SOURCES
97         ${TESTWEBKITAPI_DIR}/JavaScriptTest.cpp
98         ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
99         ${TESTWEBKITAPI_DIR}/TestsController.cpp
100     )
101
102     list(APPEND TestWebKitAPI_LIBRARIES
103         WebKit
104     )
105 else ()
106     list(APPEND TestWebKitAPI_LIBRARIES
107         WebKitLegacy${DEBUG_SUFFIX}
108     )
109 endif ()
110
111
112 set(TestWTF_SOURCES
113     ${TESTWEBKITAPI_DIR}/Counters.cpp
114     ${TESTWEBKITAPI_DIR}/TestsController.cpp
115     ${TESTWEBKITAPI_DIR}/Tests/WTF/AtomicString.cpp
116     ${TESTWEBKITAPI_DIR}/Tests/WTF/BloomFilter.cpp
117     ${TESTWEBKITAPI_DIR}/Tests/WTF/CString.cpp
118     ${TESTWEBKITAPI_DIR}/Tests/WTF/CheckedArithmeticOperations.cpp
119     ${TESTWEBKITAPI_DIR}/Tests/WTF/ConcurrentPtrHashSet.cpp
120     ${TESTWEBKITAPI_DIR}/Tests/WTF/Condition.cpp
121     ${TESTWEBKITAPI_DIR}/Tests/WTF/CrossThreadTask.cpp
122     ${TESTWEBKITAPI_DIR}/Tests/WTF/DateMath.cpp
123     ${TESTWEBKITAPI_DIR}/Tests/WTF/Deque.cpp
124     ${TESTWEBKITAPI_DIR}/Tests/WTF/EnumTraits.cpp
125     ${TESTWEBKITAPI_DIR}/Tests/WTF/Expected.cpp
126     ${TESTWEBKITAPI_DIR}/Tests/WTF/Function.cpp
127     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashCountedSet.cpp
128     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashMap.cpp
129     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashSet.cpp
130     ${TESTWEBKITAPI_DIR}/Tests/WTF/Hasher.cpp
131     ${TESTWEBKITAPI_DIR}/Tests/WTF/IntegerToStringConversion.cpp
132     ${TESTWEBKITAPI_DIR}/Tests/WTF/IteratorRange.cpp
133     ${TESTWEBKITAPI_DIR}/Tests/WTF/JSONValue.cpp
134     ${TESTWEBKITAPI_DIR}/Tests/WTF/LEBDecoder.cpp
135     ${TESTWEBKITAPI_DIR}/Tests/WTF/LifecycleLogger.cpp
136     ${TESTWEBKITAPI_DIR}/Tests/WTF/LineEnding.cpp
137     ${TESTWEBKITAPI_DIR}/Tests/WTF/ListHashSet.cpp
138     ${TESTWEBKITAPI_DIR}/Tests/WTF/Lock.cpp
139     ${TESTWEBKITAPI_DIR}/Tests/WTF/Logger.cpp
140     ${TESTWEBKITAPI_DIR}/Tests/WTF/MD5.cpp
141     ${TESTWEBKITAPI_DIR}/Tests/WTF/Markable.cpp
142     ${TESTWEBKITAPI_DIR}/Tests/WTF/MathExtras.cpp
143     ${TESTWEBKITAPI_DIR}/Tests/WTF/MediaTime.cpp
144     ${TESTWEBKITAPI_DIR}/Tests/WTF/MetaAllocator.cpp
145     ${TESTWEBKITAPI_DIR}/Tests/WTF/MoveOnlyLifecycleLogger.cpp
146     ${TESTWEBKITAPI_DIR}/Tests/WTF/NakedPtr.cpp
147     ${TESTWEBKITAPI_DIR}/Tests/WTF/NeverDestroyed.cpp
148     ${TESTWEBKITAPI_DIR}/Tests/WTF/Optional.cpp
149     ${TESTWEBKITAPI_DIR}/Tests/WTF/OptionSet.cpp
150     ${TESTWEBKITAPI_DIR}/Tests/WTF/ParkingLot.cpp
151     ${TESTWEBKITAPI_DIR}/Tests/WTF/PriorityQueue.cpp
152     ${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
153     ${TESTWEBKITAPI_DIR}/Tests/WTF/Ref.cpp
154     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefCounter.cpp
155     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefLogger.cpp
156     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefPtr.cpp
157     ${TESTWEBKITAPI_DIR}/Tests/WTF/RunLoop.cpp
158     ${TESTWEBKITAPI_DIR}/Tests/WTF/SHA1.cpp
159     ${TESTWEBKITAPI_DIR}/Tests/WTF/SaturatedArithmeticOperations.cpp
160     ${TESTWEBKITAPI_DIR}/Tests/WTF/Scope.cpp
161     ${TESTWEBKITAPI_DIR}/Tests/WTF/ScopedLambda.cpp
162     ${TESTWEBKITAPI_DIR}/Tests/WTF/SetForScope.cpp
163     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringBuilder.cpp
164     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringConcatenate.cpp
165     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringHasher.cpp
166     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringImpl.cpp
167     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringOperators.cpp
168     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringView.cpp
169     ${TESTWEBKITAPI_DIR}/Tests/WTF/SynchronizedFixedQueue.cpp
170     ${TESTWEBKITAPI_DIR}/Tests/WTF/TextBreakIterator.cpp
171     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadGroup.cpp
172     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadMessages.cpp
173     ${TESTWEBKITAPI_DIR}/Tests/WTF/Threading.cpp
174     ${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp
175     ${TESTWEBKITAPI_DIR}/Tests/WTF/URL.cpp
176     ${TESTWEBKITAPI_DIR}/Tests/WTF/URLParser.cpp
177     ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueArray.cpp
178     ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp
179     ${TESTWEBKITAPI_DIR}/Tests/WTF/Variant.cpp
180     ${TESTWEBKITAPI_DIR}/Tests/WTF/Vector.cpp
181     ${TESTWEBKITAPI_DIR}/Tests/WTF/WTFString.cpp
182     ${TESTWEBKITAPI_DIR}/Tests/WTF/WeakPtr.cpp
183     ${TESTWEBKITAPI_DIR}/Tests/WTF/WorkQueue.cpp
184     ${TESTWEBKITAPI_DIR}/Tests/WTF/WorkerPool.cpp
185 )
186
187 # FIXME: Make these work on Windows too.
188 if (NOT WIN32)
189     list(APPEND TestWTF_SOURCES
190         ${TESTWEBKITAPI_DIR}/Tests/WTF/FileSystem.cpp
191     )
192 endif ()
193
194 # FIXME: Platform-specific sources in Tests/WTF are not included in TestWTF_SOURCES.
195
196 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
197
198 include_directories(
199     ${TESTWEBKITAPI_DIR}
200     ${CMAKE_BINARY_DIR}
201     ${CMAKE_SOURCE_DIR}/Source
202     ${JAVASCRIPTCORE_DIR}
203     ${THIRDPARTY_DIR}/gtest/include
204     ${WEBKIT_DIR}/Platform/IPC
205     ${WEBKIT_DIR}/Shared
206     ${WEBKIT_DIR}/Shared/API
207     ${WEBKIT_DIR}/Shared/API/c
208     ${WEBKIT_DIR}/Shared/Plugins
209     ${WEBKIT_DIR}/UIProcess
210     ${WEBKIT_DIR}/UIProcess/API
211     ${WEBKIT_DIR}/UIProcess/API/C
212     ${WEBKIT_DIR}/WebProcess/InjectedBundle
213     ${WEBKIT_DIR}/WebProcess/InjectedBundle/API/c
214 )
215
216 if (ENABLE_WEBKIT)
217     add_library(TestWebKitAPIInjectedBundle SHARED
218         ${bundle_harness_SOURCES}
219         ${TESTWEBKITAPI_DIR}/InjectedBundleController.cpp
220         ${TESTWEBKITAPI_DIR}/InjectedBundleMain.cpp
221         ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
222         ${TESTWEBKITAPI_DIR}/Tests/WebKit/CanHandleRequest_Bundle.cpp
223         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DidAssociateFormControls_Bundle.cpp
224         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DOMWindowExtensionBasic_Bundle.cpp
225         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DOMWindowExtensionNoCache_Bundle.cpp
226         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DocumentStartUserScriptAlertCrash_Bundle.cpp
227         ${TESTWEBKITAPI_DIR}/Tests/WebKit/GetInjectedBundleInitializationUserDataCallback_Bundle.cpp
228         ${TESTWEBKITAPI_DIR}/Tests/WebKit/HitTestResultNodeHandle_Bundle.cpp
229         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleBasic_Bundle.cpp
230         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleFrameHitTest_Bundle.cpp
231         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp
232         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadCanceledNoServerRedirectCallback_Bundle.cpp
233         ${TESTWEBKITAPI_DIR}/Tests/WebKit/MouseMoveAfterCrash_Bundle.cpp
234         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp
235         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp
236         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp
237         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayout_Bundle.cpp
238         ${TESTWEBKITAPI_DIR}/Tests/WebKit/FirstMeaningfulPaintMilestone_Bundle.cpp
239         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ParentFrame_Bundle.cpp
240         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp
241         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
242         ${TESTWEBKITAPI_DIR}/Tests/WebKit/TextFieldDidBeginAndEndEditing_Bundle.cpp
243         ${TESTWEBKITAPI_DIR}/Tests/WebKit/UserMessage_Bundle.cpp
244         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WillLoad_Bundle.cpp
245         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WillSendSubmitEvent_Bundle.cpp
246     )
247
248     target_link_libraries(TestWebKitAPIInjectedBundle ${TestWebKitAPI_LIBRARIES})
249     add_dependencies(TestWebKitAPIInjectedBundle WTF ${TestWebKitAPI_DEPENDENCIES})
250
251     if (COMPILER_IS_GCC_OR_CLANG)
252         WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebKitAPIInjectedBundle -Wno-dangling-else
253                                                                 -Wno-sign-compare
254                                                                 -Wno-undef
255                                                                 -Wno-unused-parameter)
256     endif ()
257 endif ()
258
259 get_property(gtest_DEFINITIONS GLOBAL PROPERTY gtest_DEFINITIONS)
260
261 add_definitions(
262     ${gtest_DEFINITIONS}
263     -DTEST_WEBKIT2_RESOURCES_DIR=\"${TESTWEBKITAPI_DIR}/Tests/WebKit\"
264 )
265
266 add_executable(TestWTF
267     ${test_main_SOURCES}
268     ${TestWTF_SOURCES}
269 )
270
271 if (WIN32)
272     add_dependencies(TestWTF TestWTFLib)
273 else ()
274     add_dependencies(TestWTF WTF ${TestWebKitAPI_DEPENDENCIES})
275 endif ()
276
277 target_link_libraries(TestWTF ${test_wtf_LIBRARIES})
278 add_test(TestWTF ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF}/TestWTF)
279 set_tests_properties(TestWTF PROPERTIES TIMEOUT 60)
280 set_target_properties(TestWTF PROPERTIES
281     RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF}
282 )
283
284 if (COMPILER_IS_GCC_OR_CLANG)
285     WEBKIT_ADD_TARGET_CXX_FLAGS(TestWTF -Wno-dangling-else
286                                         -Wno-sign-compare
287                                         -Wno-undef
288                                         -Wno-unused-parameter)
289 endif ()
290
291 if (ENABLE_WEBKIT)
292     add_library(TestWebKitAPIBase
293         ${test_main_SOURCES}
294         ${webkit_api_harness_SOURCES}
295         ${TestWebKitAPIBase_SOURCES}
296     )
297
298     target_link_libraries(TestWebKitAPIBase ${TestWebKitAPIBase_LIBRARIES})
299
300     add_dependencies(TestWebKitAPIBase WebKit ${TestWebKitAPI_DEPENDENCIES})
301
302     if (COMPILER_IS_GCC_OR_CLANG)
303         WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebKitAPIBase -Wno-sign-compare
304                                                       -Wno-undef
305                                                       -Wno-unused-parameter)
306     endif ()
307 endif ()