Workspace 6.21.5
Classes | Namespaces | Macros | Functions
testcommon.h File Reference
#include <algorithm>
#include <cmath>
#include <exception>
#include <fstream>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
#include <qglobal.h>
#include "Workspace/Application/LanguageUtils/errorchecks.h"
#include "Workspace/DataExecution/Logging/logstream.h"
#include <QOpenGLContext>
#include "Application/LanguageUtils/streamqstring.h"
#include "DataExecution/DataObjects/datafactorytraits.h"
#include "DataExecution/InputOutput/input.h"
#include "DataExecution/InputOutput/output.h"
#include "DataExecution/Operations/operation.h"
#include "testoutputcapture.h"
Include dependency graph for testcommon.h:

Classes

class  MockLogStream
 
class  TestSuite::TestCase< TestNum >
 Nested class template defining a test case for test TestNum. More...
 
class  TestHarness
 Basic test harness for running test cases. More...
 
class  TestSuite
 Class for implementing a suite of related tests. More...
 

Namespaces

namespace  CSIRO
 Top level namespace for all Workspace code.
 
namespace  CSIRO::Testing
 Namespace in which all testing code resides.
 

Macros

#define assertTrue(value)
 
#define assertTrue1(value, msg)
 
#define failTest(msg)   fail(failTestString(msg))
 
#define failTestStep1(linenum, msg)   failTestStep2(linenum, msg)
 
#define failTestStep2(linenum, msg)   (std::string(__FILE__ "(" #linenum "): " + std::string(msg)))
 
#define failTestString(msg)   failTestStep1(__LINE__, msg)
 
#define QSKIP_TEST(x)   QSKIP(x, SkipAll)
 
#define QTEST_GUILESS_MAIN(TestObject)
 
#define WS_WORKAROUND_OPENGLCONTEXT()
 

Functions

template<typename T >
bool inputExists (const DataExecution::Operation &op, const QString &name, bool isScalar)
 
template<typename T >
bool outputExists (const DataExecution::Operation &op, const QString &name)
 
Q_GUI_EXPORT void qt_gl_set_global_share_context (QOpenGLContext *pContext)
 

Macro Definition Documentation

◆ assertTrue

#define assertTrue (   value)
Value:
{ \
if (!(value)) \
{ \
failTest("Assert true failed."); \
} \
}

◆ assertTrue1

#define assertTrue1 (   value,
  msg 
)
Value:
{ \
if (!(value)) \
{ \
failTest(msg); \
} \
}

Convenience function for asserting that a value is true and failing the test if it isn't. Can provide a custom failure string if necessary.

Would be nice if we could change it to have useful auto-generated messages, but we're not able to make any assumptions about datatype, so it's not really possible.

◆ failTest

#define failTest (   msg)    fail(failTestString(msg))
Parameters
msgThe message to include in the output.

Calls fail() with the file and line number preceding msg.

◆ failTestStep1

#define failTestStep1 (   linenum,
  msg 
)    failTestStep2(linenum, msg)

◆ failTestStep2

#define failTestStep2 (   linenum,
  msg 
)    (std::string(__FILE__ "(" #linenum "): " + std::string(msg)))

◆ failTestString

#define failTestString (   msg)    failTestStep1(__LINE__, msg)
Parameters
msgThe message to include in the output.

Evaluates to a string containing the file and line number followed by msg.

◆ QSKIP_TEST

#define QSKIP_TEST (   x)    QSKIP(x, SkipAll)

◆ QTEST_GUILESS_MAIN

#define QTEST_GUILESS_MAIN (   TestObject)
Value:
int main(int argc, char* argv[]) \
{ \
QCoreApplication app(argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
TestObject tc; \
QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
#define WS_WORKAROUND_OPENGLCONTEXT()
Definition: testcommon.h:1043
int main(int argc, char **argv)
Definition: wsscheduler_mongodb.cpp:81

◆ WS_WORKAROUND_OPENGLCONTEXT

#define WS_WORKAROUND_OPENGLCONTEXT ( )
Value:
QOpenGLContext* myOpenglContext = nullptr; \
static void destory() \
{ \
qt_gl_set_global_share_context(nullptr); \
delete myOpenglContext; \
myOpenglContext = nullptr; \
} \
static void initialize() \
{ \
myOpenglContext = new QOpenGLContext(); \
qt_gl_set_global_share_context(myOpenglContext); \
qAddPostRoutine(destory); \
} \
Q_COREAPP_STARTUP_FUNCTION(initialize)

Function Documentation

◆ qt_gl_set_global_share_context()

Q_GUI_EXPORT void qt_gl_set_global_share_context ( QOpenGLContext *  pContext)

This block of code is to eliminate crashes in tests with QTEST_GUILESS_MAIN with Qt 5.6.0. The QtWebEngineCore will initilize and access QGuiApplicationPrivate when the global share context is not set manually.