6#include <QtCore/qstring.h> 
    8#include <QtTest/private/qtestlog_p.h> 
    9#include <QtTest/private/qtestresult_p.h> 
   11#import <XCTest/XCTest.h> 
   18@interface XCTestProbe (Private)
 
   27@property (readonly, assign) NSObject *IDEConnection;
 
   30@interface XCTest (Private)
 
   31- (NSString *)nameForLegacyLogging;
 
   44+ (XCTestSuiteRun*)testRun;
 
   48@property (nonatomic, retain) NSString* testObjectName;
 
   49@property (nonatomic, retain) NSString* testFunctionName;
 
   74    void wait(
Barrier barrier) { dispatch_semaphore_wait(barriers[barrier], DISPATCH_TIME_FOREVER); }
 
   75    void signal(
Barrier barrier) { dispatch_semaphore_signal(barriers[barrier]); }
 
   78    #define FOREACH_BARRIER(cmd) for (int i = 0; i < BarrierCount; ++i) { cmd } 
   83    dispatch_semaphore_t barriers[BarrierCount];
 
   86#define WAIT_FOR_BARRIER(b) ThreadBarriers::get()->wait(ThreadBarriers::b); 
   87#define SIGNAL_BARRIER(b) ThreadBarriers::get()->signal(ThreadBarriers::b); 
   95    NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
 
   97    if (![XCTestProbe isTesting])
 
  100    if (
Q_UNLIKELY(!([NSDate timeIntervalSinceReferenceDate] > 0)))
 
  101        qFatal(
"error: Device date '%s' is bad, likely set to update automatically. Please correct.",
 
  102            [[NSDate 
date] description].UTF8String);
 
  111    dispatch_async(dispatch_queue_create(
"io.qt.QTestLib.xctest-wrapper", DISPATCH_QUEUE_SERIAL), ^{
 
  113        [XCTestProbe runTests:nil];
 
  138            dispatch_semaphore_wait(dispatch_semaphore_create(0), DISPATCH_TIME_FOREVER);
 
  148    if ([[[NSProcessInfo processInfo] 
arguments] containsObject:
@"--use-testmanagerd"]) {
 
  150            [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
 
  157    [[NSNotificationCenter defaultCenter] removeObserver:[XCTestProbe class]
 
  158        name:[NSString stringWithFormat:@"%@DidFinishLaunchingNotification",
 
  159                #if defined(Q_OS_MACOS)
 
  167    [autoreleasepool release];
 
  170+ (QTestLibTests *)defaultTestSuite
 
  175+ (BOOL)usingTestManager
 
  177    return [[[NSProcessInfo processInfo] arguments] containsObject:@"--use-testmanagerd"];
 
  188- (
void)performTest:(XCTestSuiteRun *)testSuiteRun
 
  202        [testSuiteRun start];
 
  214+ (XCTestSuiteRun*)testRun
 
  225- (instancetype)initWithInvocation:(NSInvocation *)invocation
 
  227    if (self = [super initWithInvocation:invocation]) {
 
  230        self.testObjectName = [NSString stringWithUTF8String:QTestResult::currentTestObjectName()];
 
  231        self.testFunctionName = [NSString stringWithUTF8String:QTestResult::currentTestFunction()];
 
  237- (NSString *)testClassName
 
  239    return self.testObjectName;
 
  242- (NSString *)testMethodName
 
  244    return self.testFunctionName;
 
  247- (NSString *)nameForLegacyLogging
 
  249    NSString *
name = [NSString stringWithFormat:@"%@::%@", [
self testClassName], [
self testMethodName]];
 
  253        const char *filler = (
currentDataTag[0] && globalDataTag[0]) ? 
":" : 
"";
 
  255            globalDataTag, filler, currentDataTag]];
 
  267    return [XCTestProbe isTesting]; 
 
  272    if (strncmp(
argument, 
"-NS", 3) == 0 || strncmp(
argument, 
"-Apple", 6) == 0)
 
  274    else if (strcmp(
argument, 
"--use-testmanagerd") == 0)
 
  276    else if (strncmp(
argument, 
"-XCTest", 7) == 0)
 
  292    , m_testRuns([[NSMutableArray<XCTestRun *> arrayWithCapacity:2] retain])
 
  296    s_currentTestLogger = 
this;
 
  301    s_currentTestLogger = 0;
 
  302    [m_testRuns release];
 
  309    static dispatch_once_t onceToken;
 
  310    dispatch_once (&onceToken, ^{
 
  317    NSString *suiteName = [NSString stringWithUTF8String:QTestResult::currentTestObjectName()];
 
  318    pushTestRunForTest([XCTestSuite testSuiteWithName:suiteName], true);
 
  326static bool isTestFunctionInActiveScope(
const char *function)
 
  328    static NSString *testScope = [XCTestProbe testScope];
 
  331    static TestScope activeScope = 
Unknown;
 
  334        if ([testScope isEqualToString:
@"All"])
 
  336        else if ([testScope isEqualToString:
@"None"])
 
  338        else if ([testScope isEqualToString:
@"Self"])
 
  341            activeScope = Selected;
 
  344    if (activeScope == 
All)
 
  346    else if (activeScope == 
None)
 
  348    else if (activeScope == Self)
 
  353    static NSArray<NSString *> *forcedTests = [@[ @"initTestCase", @"initTestCase_data", @"cleanupTestCase" ] retain];
 
  354    if ([forcedTests containsObject:[NSString stringWithUTF8String:
function]])
 
  357    static NSArray<NSString *> *testsInScope = [[testScope componentsSeparatedByString:@","] retain];
 
  358    bool inScope = [testsInScope containsObject:[NSString stringWithFormat:@"%s/%s",
 
  359                        QTestResult::currentTestObjectName(), function]];
 
  361    if ([XCTestProbe isInverseTestScope])
 
  369    if (!isTestFunctionInActiveScope(function))
 
  384    XCTestRun *testRun = [m_testRuns lastObject];
 
  391        NSString *testCaseName = [[testRun test] nameForLegacyLogging];
 
  393            [testCaseName UTF8String], description);
 
  405        NSString *testCaseName = [[testRun test] nameForLegacyLogging];
 
  413    if (!
file || !description)
 
  416    [testRun recordFailureWithDescription:[NSString stringWithUTF8String:description]
 
  417        inFile:[NSString stringWithUTF8String:file] atLine:line expected:YES];
 
  431        XCTestRun *testRun = [m_testRuns lastObject];
 
  432        NSString *testCaseName = [[testRun test] nameForLegacyLogging];
 
  434            [testCaseName UTF8String], 
message.toUtf8().constData());
 
  447void QXcodeTestLogger::pushTestRunForTest(XCTest *test, 
bool start)
 
  449    XCTestRun *testRun = [[test testRunClass] testRunWithTest:test];
 
  450    [m_testRuns addObject:testRun];
 
  456XCTestRun *QXcodeTestLogger::popTestRun()
 
  458    XCTestRun *testRun = [[m_testRuns lastObject] retain];
 
  459    [m_testRuns removeLastObject];
 
  464    [[m_testRuns lastObject] addTestRun:testRun];
 
  472    return s_currentTestLogger;
 
BOOL isInverseTestScope()
Base class for test loggers.
void outputString(const char *msg)
Convenience method to write msg to the output stream.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static int verboseLevel()
static const char * currentGlobalDataTag()
static void setSkipCurrentTest(bool value)
static const char * currentDataTag()
static bool skipCurrentTest()
static int parseCommandLineArgument(const char *argument)
void addIncident(IncidentTypes type, const char *description, const char *file=nullptr, int line=0) override
This virtual method is called when an event occurs that relates to the resolution of the test.
void leaveTestFunction() override
This virtual method is called after a test function has completed, to match \l enterTestFunction().
static bool canLogTestProgress()
void enterTestFunction(const char *function) override
This virtual method is called before each test function is invoked.
~QXcodeTestLogger() override
void stopLogging() override
Called after the end of a test run.
void startLogging() override
Called before the start of a test run.
void addBenchmarkResult(const QBenchmarkResult &result) override
This virtual method is called after a benchmark has been run enough times to produce usable data.
void addMessage(MessageTypes type, const QString &message, const char *file=nullptr, int line=0) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
static ThreadBarriers * get()
void wait(Barrier barrier)
void signal(Barrier barrier)
QList< QVariant > arguments
XCTestSuiteRun * testRun()
XCTestDriver * sharedTestDriver()
int qt_asprintf(QTestCharBuffer *str, const char *format,...)
Q_TESTLIB_EXPORT const char * currentDataTag()
Returns the name of the current test data.
#define QT_WARNING_DISABLE_DEPRECATED
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
static QDBusError::ErrorType get(const char *name)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei const GLchar * message
int runTests(QObject *testObject, int argc, char *argv[])
static XCTestSuiteRun * s_qtTestSuiteRun
#define WAIT_FOR_BARRIER(b)
#define SIGNAL_BARRIER(b)
#define FOREACH_BARRIER(cmd)
QDateTime startDate(QDate(2012, 7, 6), QTime(8, 30, 0))
[14]