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