diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 765fc804c..9e419f8ee 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1505,6 +1505,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release ) endif() + if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 6 + AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") + set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1}) + ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $ -V) + endif() + add_test(linkorder1 ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/LinkLineOrder" diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt new file mode 100644 index 000000000..e8666231b --- /dev/null +++ b/Tests/XCTest/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.1) +project(XCTest) +enable_testing() + +find_package(XCTest REQUIRED) + +# Framework + +add_library(FrameworkExample SHARED + FrameworkExample/FrameworkExample.c + FrameworkExample/FrameworkExample.h + FrameworkExample/Info.plist) + +target_include_directories(FrameworkExample PUBLIC .) + +set_target_properties(FrameworkExample PROPERTIES + FRAMEWORK TRUE + VERSION "1.0.0" + SOVERSION "1.0.0" + FRAMEWORK_VERSION "A" + MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/FrameworkExample/Info.plist + PUBLIC_HEADER FrameworkExample/FrameworkExample.h) + +# XCTest for Framework + +xctest_add_bundle(FrameworkExampleTests FrameworkExample + FrameworkExampleTests/FrameworkExampleTests.m + FrameworkExampleTests/Info.plist) + +set_target_properties(FrameworkExampleTests PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/FrameworkExampleTests/Info.plist + ) + +xctest_add_test(XCTest.FrameworkExample FrameworkExampleTests) + +# Cocoa App Bundle + +add_executable(CocoaExample MACOSX_BUNDLE + CocoaExample/main.m + CocoaExample/AppDelegate.m + CocoaExample/AppDelegate.h + CocoaExample/MainMenu.xib +) + +target_link_libraries(CocoaExample PRIVATE "-framework Foundation") +target_link_libraries(CocoaExample PRIVATE "-framework AppKit") + +set_target_properties(CocoaExample PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/CocoaExample/Info.plist + RESOURCE "CocoaExample/MainMenu.xib") + +# XCTest for Cocoa App Bundle + +xctest_add_bundle(CocoaExampleTests CocoaExample + CocoaExampleTests/CocoaExampleTests.m) + +xctest_add_test(XCTest.CocoaExample CocoaExampleTests) diff --git a/Tests/XCTest/CocoaExample/AppDelegate.h b/Tests/XCTest/CocoaExample/AppDelegate.h new file mode 100644 index 000000000..4bf41019e --- /dev/null +++ b/Tests/XCTest/CocoaExample/AppDelegate.h @@ -0,0 +1,6 @@ +#import + +@interface AppDelegate : NSObject + + +@end diff --git a/Tests/XCTest/CocoaExample/AppDelegate.m b/Tests/XCTest/CocoaExample/AppDelegate.m new file mode 100644 index 000000000..07af62fd5 --- /dev/null +++ b/Tests/XCTest/CocoaExample/AppDelegate.m @@ -0,0 +1,18 @@ +#import "AppDelegate.h" + +@interface AppDelegate () + +@property (assign) IBOutlet NSWindow *window; +@end + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // Insert code here to initialize your application +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + // Insert code here to tear down your application +} + +@end diff --git a/Tests/XCTest/CocoaExample/Info.plist b/Tests/XCTest/CocoaExample/Info.plist new file mode 100644 index 000000000..5267c6322 --- /dev/null +++ b/Tests/XCTest/CocoaExample/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + CocoaExample + CFBundleIconFile + + CFBundleIdentifier + org.cmake.CocoaExample + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + CocoaExample + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/Tests/XCTest/CocoaExample/MainMenu.xib b/Tests/XCTest/CocoaExample/MainMenu.xib new file mode 100644 index 000000000..9498a0a7d --- /dev/null +++ b/Tests/XCTest/CocoaExample/MainMenu.xib @@ -0,0 +1,680 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/XCTest/CocoaExample/main.m b/Tests/XCTest/CocoaExample/main.m new file mode 100644 index 000000000..8a6799b41 --- /dev/null +++ b/Tests/XCTest/CocoaExample/main.m @@ -0,0 +1,5 @@ +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} diff --git a/Tests/XCTest/CocoaExampleTests/CocoaExampleTests.m b/Tests/XCTest/CocoaExampleTests/CocoaExampleTests.m new file mode 100644 index 000000000..70d61d6ff --- /dev/null +++ b/Tests/XCTest/CocoaExampleTests/CocoaExampleTests.m @@ -0,0 +1,13 @@ +#import + +@interface CocoaExampleTests : XCTestCase + +@end + +@implementation CocoaExampleTests + +- (void)testExample { + XCTAssert(YES, @"Pass"); +} + +@end diff --git a/Tests/XCTest/FrameworkExample/FrameworkExample.c b/Tests/XCTest/FrameworkExample/FrameworkExample.c new file mode 100644 index 000000000..2da78da78 --- /dev/null +++ b/Tests/XCTest/FrameworkExample/FrameworkExample.c @@ -0,0 +1,6 @@ +#include "FrameworkExample.h" + +int FourtyTwo() +{ + return 42; +} diff --git a/Tests/XCTest/FrameworkExample/FrameworkExample.h b/Tests/XCTest/FrameworkExample/FrameworkExample.h new file mode 100644 index 000000000..2e0b499bf --- /dev/null +++ b/Tests/XCTest/FrameworkExample/FrameworkExample.h @@ -0,0 +1 @@ +int FourtyTwo(); diff --git a/Tests/XCTest/FrameworkExample/Info.plist b/Tests/XCTest/FrameworkExample/Info.plist new file mode 100644 index 000000000..a22acea22 --- /dev/null +++ b/Tests/XCTest/FrameworkExample/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + FrameworkExample + CFBundleIdentifier + org.cmake.FrameworkExample + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + FrameworkExample + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + + NSHumanReadableCopyright + + NSPrincipalClass + + + diff --git a/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m b/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m new file mode 100644 index 000000000..7cba23ecb --- /dev/null +++ b/Tests/XCTest/FrameworkExampleTests/FrameworkExampleTests.m @@ -0,0 +1,16 @@ +#import + +#import "FrameworkExample/FrameworkExample.h" + +@interface FrameworkExampleTests : XCTestCase + +@end + +@implementation FrameworkExampleTests + +- (void)testFourtyTwo { + // This is an example of a functional test case. + XCTAssertEqual(42, FourtyTwo()); +} + +@end diff --git a/Tests/XCTest/FrameworkExampleTests/Info.plist b/Tests/XCTest/FrameworkExampleTests/Info.plist new file mode 100644 index 000000000..293921b75 --- /dev/null +++ b/Tests/XCTest/FrameworkExampleTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + FrameworkExampleTests + CFBundleIdentifier + org.cmake.FrameworkExampleTests + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + FrameworkExampleTests + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + +