caa85fcb53d7339f8be4721e117078306b38269d
[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/ForceRepaint.cpp
49         ${TESTWEBKITAPI_DIR}/Tests/WebKit/FrameMIMETypeHTML.cpp
50         ${TESTWEBKITAPI_DIR}/Tests/WebKit/FrameMIMETypePNG.cpp
51         ${TESTWEBKITAPI_DIR}/Tests/WebKit/Geolocation.cpp
52         ${TESTWEBKITAPI_DIR}/Tests/WebKit/GetInjectedBundleInitializationUserDataCallback.cpp
53         ${TESTWEBKITAPI_DIR}/Tests/WebKit/HitTestResultNodeHandle.cpp
54         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleBasic.cpp
55         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleFrameHitTest.cpp
56         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleInitializationUserDataCallbackWins.cpp
57         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadAlternateHTMLStringWithNonDirectoryURL.cpp
58         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadCanceledNoServerRedirectCallback.cpp
59         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadPageOnCrash.cpp
60         ${TESTWEBKITAPI_DIR}/Tests/WebKit/MouseMoveAfterCrash.cpp
61         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayout.cpp
62         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFails.cpp
63         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutForImages.cpp
64         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFrames.cpp
65         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PageLoadBasic.cpp
66         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PageLoadDidChangeLocationWithinPageForFrame.cpp
67         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ParentFrame.cpp
68         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PendingAPIRequestURL.cpp
69         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PreventEmptyUserAgent.cpp
70         ${TESTWEBKITAPI_DIR}/Tests/WebKit/PrivateBrowsingPushStateNoHistoryCallback.cpp
71         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ProvisionalURLAfterWillSendRequestCallback.cpp
72         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ReloadPageAfterCrash.cpp
73         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ResizeWindowAfterCrash.cpp
74         ${TESTWEBKITAPI_DIR}/Tests/WebKit/RestoreSessionStateContainingFormData.cpp
75         ${TESTWEBKITAPI_DIR}/Tests/WebKit/TextFieldDidBeginAndEndEditing.cpp
76         ${TESTWEBKITAPI_DIR}/Tests/WebKit/UserMedia.cpp
77         ${TESTWEBKITAPI_DIR}/Tests/WebKit/UserMessage.cpp
78         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WillSendSubmitEvent.cpp
79         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKPageCopySessionStateWithFiltering.cpp
80         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKPageGetScaleFactorNotZero.cpp
81         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKPreferences.cpp
82         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKRetainPtr.cpp
83         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKString.cpp
84         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKStringJSString.cpp
85         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WKURL.cpp
86     )
87
88     list(APPEND TestWebKitAPI_LIBRARIES
89         WebKit
90     )
91 else ()
92     list(APPEND TestWebKitAPI_LIBRARIES
93         WebKitLegacy${DEBUG_SUFFIX}
94     )
95 endif ()
96
97
98 set(TestWTF_SOURCES
99     ${TESTWEBKITAPI_DIR}/Counters.cpp
100     ${TESTWEBKITAPI_DIR}/TestsController.cpp
101     ${TESTWEBKITAPI_DIR}/Tests/WTF/AtomicString.cpp
102     ${TESTWEBKITAPI_DIR}/Tests/WTF/BloomFilter.cpp
103     ${TESTWEBKITAPI_DIR}/Tests/WTF/CString.cpp
104     ${TESTWEBKITAPI_DIR}/Tests/WTF/CheckedArithmeticOperations.cpp
105     ${TESTWEBKITAPI_DIR}/Tests/WTF/ConcurrentPtrHashSet.cpp
106     ${TESTWEBKITAPI_DIR}/Tests/WTF/Condition.cpp
107     ${TESTWEBKITAPI_DIR}/Tests/WTF/CrossThreadTask.cpp
108     ${TESTWEBKITAPI_DIR}/Tests/WTF/DateMath.cpp
109     ${TESTWEBKITAPI_DIR}/Tests/WTF/Deque.cpp
110     ${TESTWEBKITAPI_DIR}/Tests/WTF/EnumTraits.cpp
111     ${TESTWEBKITAPI_DIR}/Tests/WTF/Expected.cpp
112     ${TESTWEBKITAPI_DIR}/Tests/WTF/Function.cpp
113     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashCountedSet.cpp
114     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashMap.cpp
115     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashSet.cpp
116     ${TESTWEBKITAPI_DIR}/Tests/WTF/Hasher.cpp
117     ${TESTWEBKITAPI_DIR}/Tests/WTF/IntegerToStringConversion.cpp
118     ${TESTWEBKITAPI_DIR}/Tests/WTF/JSONValue.cpp
119     ${TESTWEBKITAPI_DIR}/Tests/WTF/LEBDecoder.cpp
120     ${TESTWEBKITAPI_DIR}/Tests/WTF/LifecycleLogger.cpp
121     ${TESTWEBKITAPI_DIR}/Tests/WTF/LineEnding.cpp
122     ${TESTWEBKITAPI_DIR}/Tests/WTF/ListHashSet.cpp
123     ${TESTWEBKITAPI_DIR}/Tests/WTF/Lock.cpp
124     ${TESTWEBKITAPI_DIR}/Tests/WTF/Logger.cpp
125     ${TESTWEBKITAPI_DIR}/Tests/WTF/MD5.cpp
126     ${TESTWEBKITAPI_DIR}/Tests/WTF/MathExtras.cpp
127     ${TESTWEBKITAPI_DIR}/Tests/WTF/MediaTime.cpp
128     ${TESTWEBKITAPI_DIR}/Tests/WTF/MetaAllocator.cpp
129     ${TESTWEBKITAPI_DIR}/Tests/WTF/MoveOnlyLifecycleLogger.cpp
130     ${TESTWEBKITAPI_DIR}/Tests/WTF/NakedPtr.cpp
131     ${TESTWEBKITAPI_DIR}/Tests/WTF/NeverDestroyed.cpp
132     ${TESTWEBKITAPI_DIR}/Tests/WTF/Optional.cpp
133     ${TESTWEBKITAPI_DIR}/Tests/WTF/OptionSet.cpp
134     ${TESTWEBKITAPI_DIR}/Tests/WTF/ParkingLot.cpp
135     ${TESTWEBKITAPI_DIR}/Tests/WTF/Poisoned.cpp
136     ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedRef.cpp
137     ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedRefPtr.cpp
138     ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedUniquePtr.cpp
139     ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp
140     ${TESTWEBKITAPI_DIR}/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp
141     ${TESTWEBKITAPI_DIR}/Tests/WTF/PriorityQueue.cpp
142     ${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
143     ${TESTWEBKITAPI_DIR}/Tests/WTF/Ref.cpp
144     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefCounter.cpp
145     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefLogger.cpp
146     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefPtr.cpp
147     ${TESTWEBKITAPI_DIR}/Tests/WTF/SHA1.cpp
148     ${TESTWEBKITAPI_DIR}/Tests/WTF/SaturatedArithmeticOperations.cpp
149     ${TESTWEBKITAPI_DIR}/Tests/WTF/Scope.cpp
150     ${TESTWEBKITAPI_DIR}/Tests/WTF/ScopedLambda.cpp
151     ${TESTWEBKITAPI_DIR}/Tests/WTF/SetForScope.cpp
152     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringBuilder.cpp
153     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringConcatenate.cpp
154     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringHasher.cpp
155     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringImpl.cpp
156     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringOperators.cpp
157     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringView.cpp
158     ${TESTWEBKITAPI_DIR}/Tests/WTF/SynchronizedFixedQueue.cpp
159     ${TESTWEBKITAPI_DIR}/Tests/WTF/TextBreakIterator.cpp
160     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadGroup.cpp
161     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadMessages.cpp
162     ${TESTWEBKITAPI_DIR}/Tests/WTF/Threading.cpp
163     ${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp
164     ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueArray.cpp
165     ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp
166     ${TESTWEBKITAPI_DIR}/Tests/WTF/Variant.cpp
167     ${TESTWEBKITAPI_DIR}/Tests/WTF/Vector.cpp
168     ${TESTWEBKITAPI_DIR}/Tests/WTF/WTFString.cpp
169     ${TESTWEBKITAPI_DIR}/Tests/WTF/WeakPtr.cpp
170     ${TESTWEBKITAPI_DIR}/Tests/WTF/WorkQueue.cpp
171     ${TESTWEBKITAPI_DIR}/Tests/WTF/WorkerPool.cpp
172 )
173
174 # FIXME: Tests/WTF/RunLoop.cpp is missing because it doesn't work for Windows.
175 # FIXME: Platform-specific sources in Tests/WTF are not included in TestWTF_SOURCES.
176
177 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
178
179 include_directories(
180     ${TESTWEBKITAPI_DIR}
181     ${CMAKE_BINARY_DIR}
182     ${CMAKE_SOURCE_DIR}/Source
183     ${JAVASCRIPTCORE_DIR}
184     ${THIRDPARTY_DIR}/gtest/include
185     ${WEBKIT_DIR}/Platform/IPC
186     ${WEBKIT_DIR}/Shared
187     ${WEBKIT_DIR}/Shared/API
188     ${WEBKIT_DIR}/Shared/API/c
189     ${WEBKIT_DIR}/Shared/Plugins
190     ${WEBKIT_DIR}/UIProcess
191     ${WEBKIT_DIR}/UIProcess/API
192     ${WEBKIT_DIR}/UIProcess/API/C
193     ${WEBKIT_DIR}/WebProcess/InjectedBundle
194     ${WEBKIT_DIR}/WebProcess/InjectedBundle/API/c
195 )
196
197 if (ENABLE_WEBKIT)
198     add_library(TestWebKitAPIInjectedBundle SHARED
199         ${bundle_harness_SOURCES}
200         ${TESTWEBKITAPI_DIR}/InjectedBundleController.cpp
201         ${TESTWEBKITAPI_DIR}/InjectedBundleMain.cpp
202         ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
203         ${TESTWEBKITAPI_DIR}/Tests/WebKit/CanHandleRequest_Bundle.cpp
204         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DidAssociateFormControls_Bundle.cpp
205         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DOMWindowExtensionBasic_Bundle.cpp
206         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DOMWindowExtensionNoCache_Bundle.cpp
207         ${TESTWEBKITAPI_DIR}/Tests/WebKit/DocumentStartUserScriptAlertCrash_Bundle.cpp
208         ${TESTWEBKITAPI_DIR}/Tests/WebKit/GetInjectedBundleInitializationUserDataCallback_Bundle.cpp
209         ${TESTWEBKITAPI_DIR}/Tests/WebKit/HitTestResultNodeHandle_Bundle.cpp
210         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleBasic_Bundle.cpp
211         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleFrameHitTest_Bundle.cpp
212         ${TESTWEBKITAPI_DIR}/Tests/WebKit/InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp
213         ${TESTWEBKITAPI_DIR}/Tests/WebKit/LoadCanceledNoServerRedirectCallback_Bundle.cpp
214         ${TESTWEBKITAPI_DIR}/Tests/WebKit/MouseMoveAfterCrash_Bundle.cpp
215         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp
216         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp
217         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp
218         ${TESTWEBKITAPI_DIR}/Tests/WebKit/NewFirstVisuallyNonEmptyLayout_Bundle.cpp
219         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ParentFrame_Bundle.cpp
220         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp
221         ${TESTWEBKITAPI_DIR}/Tests/WebKit/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
222         ${TESTWEBKITAPI_DIR}/Tests/WebKit/TextFieldDidBeginAndEndEditing_Bundle.cpp
223         ${TESTWEBKITAPI_DIR}/Tests/WebKit/UserMessage_Bundle.cpp
224         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WillLoad_Bundle.cpp
225         ${TESTWEBKITAPI_DIR}/Tests/WebKit/WillSendSubmitEvent_Bundle.cpp
226     )
227
228     target_link_libraries(TestWebKitAPIInjectedBundle ${TestWebKitAPI_LIBRARIES})
229     add_dependencies(TestWebKitAPIInjectedBundle WTF ${TestWebKitAPI_DEPENDENCIES})
230
231     if (COMPILER_IS_GCC_OR_CLANG)
232         WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebKitAPIInjectedBundle -Wno-dangling-else
233                                                                 -Wno-sign-compare
234                                                                 -Wno-undef
235                                                                 -Wno-unused-parameter)
236     endif ()
237 endif ()
238
239 get_property(gtest_DEFINITIONS GLOBAL PROPERTY gtest_DEFINITIONS)
240
241 add_definitions(
242     ${gtest_DEFINITIONS}
243     -DTEST_WEBKIT2_RESOURCES_DIR=\"${TESTWEBKITAPI_DIR}/Tests/WebKit\"
244 )
245
246 add_executable(TestWTF
247     ${test_main_SOURCES}
248     ${TestWTF_SOURCES}
249 )
250
251 if (WIN32)
252     add_dependencies(TestWTF TestWTFLib)
253 else ()
254     add_dependencies(TestWTF WTF ${TestWebKitAPI_DEPENDENCIES})
255 endif ()
256
257 target_link_libraries(TestWTF ${test_wtf_LIBRARIES})
258 add_test(TestWTF ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF}/TestWTF)
259 set_tests_properties(TestWTF PROPERTIES TIMEOUT 60)
260 set_target_properties(TestWTF PROPERTIES
261     RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF}
262 )
263
264 if (COMPILER_IS_GCC_OR_CLANG)
265     WEBKIT_ADD_TARGET_CXX_FLAGS(TestWTF -Wno-dangling-else
266                                         -Wno-sign-compare
267                                         -Wno-undef
268                                         -Wno-unused-parameter)
269 endif ()
270
271 if (ENABLE_WEBKIT)
272     add_library(TestWebKitAPIBase
273         ${test_main_SOURCES}
274         ${webkit_api_harness_SOURCES}
275         ${TESTWEBKITAPI_DIR}/JavaScriptTest.cpp
276         ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
277         ${TESTWEBKITAPI_DIR}/TestsController.cpp
278     )
279
280     target_link_libraries(TestWebKitAPIBase JavaScriptCore WTF WebKit gtest)
281
282     add_dependencies(TestWebKitAPIBase WebKit ${TestWebKitAPI_DEPENDENCIES})
283
284     if (COMPILER_IS_GCC_OR_CLANG)
285         WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebKitAPIBase -Wno-sign-compare
286                                                       -Wno-undef
287                                                       -Wno-unused-parameter)
288     endif ()
289 endif ()