diff --git a/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox b/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox index 2631060b56..066fc9c444 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox @@ -1,99 +1,94 @@ /** \page BlueBerryExtPointsIndex BlueBerry Extension-Point Reference

BlueBerry Platform Extension Points

The following extension points can be used to extend the capabilities of the platform infrastructure:

Platform Core Expressions

Platform Runtime

Workbench

Other

\page xp_org_blueberry_core_expressions_definitions org.blueberry.core.expressions.definitions \htmlinclude org_blueberry_core_expressions_definitions.html \page xp_org_blueberry_core_expressions_commonExpression org.blueberry.core.expressions.commonExpression \htmlinclude org_blueberry_core_expressions_commonExpression.html \page xp_org_blueberry_core_expressions_propertyTesters org.blueberry.core.expressions.propertyTesters \htmlinclude org_blueberry_core_expressions_propertyTesters.html - \page xp_org_blueberry_osgi_applications org.blueberry.osgi.applications \htmlinclude org_blueberry_osgi_applications.html \page xp_org_blueberry_core_runtime_products org.blueberry.core.runtime.products \htmlinclude org_blueberry_core_runtime_products.html - \page xp_org_blueberry_ui_elementFactories org.blueberry.ui.elementFactories \htmlinclude org_blueberry_ui_elementFactories.html \page xp_org_blueberry_ui_menus org.blueberry.ui.menus \htmlinclude org_blueberry_ui_menus.html \page xp_org_blueberry_ui_perspectiveExtensions org.blueberry.ui.perspectiveExtensions \htmlinclude org_blueberry_ui_perspectiveExtensions.html \page xp_org_blueberry_ui_editors org.blueberry.ui.editors \htmlinclude org_blueberry_ui_editors.html \page xp_org_blueberry_ui_perspectives org.blueberry.ui.perspectives \htmlinclude org_blueberry_ui_perspectives.html \page xp_org_blueberry_ui_presentationFactories org.blueberry.ui.presentationFactories \htmlinclude org_blueberry_ui_presentationFactories.html \page xp_org_blueberry_ui_services org.blueberry.ui.services \htmlinclude org_blueberry_ui_services.html \page xp_org_blueberry_ui_keywords org.blueberry.ui.keywords \htmlinclude org_blueberry_ui_keywords.html \page xp_org_blueberry_ui_preferencePages org.blueberry.ui.preferencePages \htmlinclude org_blueberry_ui_preferencePages.html \page xp_org_blueberry_ui_tweaklets org.blueberry.ui.tweaklets \htmlinclude org_blueberry_ui_tweaklets.html \page xp_org_blueberry_ui_views org.blueberry.ui.views \htmlinclude org_blueberry_ui_views.html -\page xp_org_blueberry_tests org.blueberry.tests -\htmlinclude org_blueberry_tests.html - */ diff --git a/Modules/AppUtil/include/mitkBaseApplication.h b/Modules/AppUtil/include/mitkBaseApplication.h index e1a36b1964..9b263db6d9 100644 --- a/Modules/AppUtil/include/mitkBaseApplication.h +++ b/Modules/AppUtil/include/mitkBaseApplication.h @@ -1,321 +1,317 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkBaseApplication_h #define mitkBaseApplication_h #include #include #include #include class ctkPluginContext; class ctkPluginFramework; class QCoreApplication; class QTranslator; namespace mitk { /** * A utility class for starting BlueBerry applications. * * In the simplest case, create an instance of this class and call run(). * This will launch a CTK plugin framework instance and execute the * default application registered by a plug-in via the * org.blueberry.osgi.applications extension point. * * This class contains many convenience methods to: * - Put the application in \emph{safe mode} which catches unhandled * exceptions thrown in the Qt event loop and displays an error * message. * - Put the application in \emph{single mode} which by default * sends the command line arguments to an already running instance * of the same application instead of creating a second instance. * - Add a list of library names which should be pre-loaded at * application start-up, e.g. to speed up the initial launch during * the caching process of the plug-in meta-data. * - Set a custom provisioning file to start a specific set of CTK * plug-ins during application start-up. * - Set and get CTK plugin framework properties * * The behavior can further be customized by deriving from BaseApplication * and overriding specific methods, such as: * - initializeLibraryPaths() to add specific library / plugin search paths * - defineOptions(Poco::Util::OptionSet&) to define a custom set of * command line options * - getQApplication() to provide a custom QCoreApplication instance * * A simple but complete example: * * #include * * int main(int argc, char* argv[]) * { * mitk::BaseApplication app(argc, argv); * app.setApplicationName("MyApp"); * app.setOrganizationName("MyOrganization"); * * // Run the workbench * return app.run(); * } * */ class MITKAPPUTIL_EXPORT BaseApplication : public Poco::Util::Application { public: // Command line arguments static const QString ARG_APPLICATION; static const QString ARG_CLEAN; static const QString ARG_CONSOLELOG; static const QString ARG_DEBUG; static const QString ARG_FORCE_PLUGIN_INSTALL; static const QString ARG_HOME; static const QString ARG_NEWINSTANCE; static const QString ARG_NO_LAZY_REGISTRY_CACHE_LOADING; static const QString ARG_NO_REGISTRY_CACHE; static const QString ARG_PLUGIN_CACHE; static const QString ARG_PLUGIN_DIRS; static const QString ARG_PRELOAD_LIBRARY; static const QString ARG_PRODUCT; static const QString ARG_PROVISIONING; static const QString ARG_REGISTRY_MULTI_LANGUAGE; static const QString ARG_SPLASH_IMAGE; static const QString ARG_STORAGE_DIR; - static const QString ARG_TESTAPPLICATION; - static const QString ARG_TESTPLUGIN; static const QString ARG_XARGS; // BlueBerry specific plugin framework properties static const QString PROP_APPLICATION; static const QString PROP_FORCE_PLUGIN_INSTALL; static const QString PROP_NEWINSTANCE; static const QString PROP_NO_LAZY_REGISTRY_CACHE_LOADING; static const QString PROP_NO_REGISTRY_CACHE; static const QString PROP_PRODUCT; static const QString PROP_REGISTRY_MULTI_LANGUAGE; - static const QString PROP_TESTAPPLICATION; - static const QString PROP_TESTPLUGIN; BaseApplication(int argc, char **argv); ~BaseApplication() override; /** * Initialize the Qt library such that a QCoreApplication * instance is available and e.g. Qt widgets can be created. * * This is usually not called directly by the user. */ void initializeQt(); /** * Launches the BlueBerry framework and runs the default application * or the one specified in the PROP_APPLICATION framework property. * * @return The return code of the application after it was shut down. */ int run() override; void printHelp(const std::string &name, const std::string &value); /** * Set the application name. Same as QCoreApplication::setApplicationName. * @param name The application name. */ void setApplicationName(const QString &name); QString getApplicationName() const; /** * Set the organization name. Same as QCoreApplication::setOrganizationName. * @param name The organization name. */ void setOrganizationName(const QString &name); QString getOrganizationName() const; /** * Set the organization domain. Same as QCoreApplication::setOrganizationDomain. * @param name The organization domain. */ void setOrganizationDomain(const QString &name); QString getOrganizationDomain() const; /** * Put the application in single mode, which by default only allows * a single instance of the application to be created. * * Calling this method after run() has been called has no effect. * * @param singleMode */ void setSingleMode(bool singleMode); bool getSingleMode() const; /** * Put the application in safe mode, catching exceptions from the * Qt event loop. * * @param safeMode */ void setSafeMode(bool safeMode); bool getSafeMode() const; /** * Set a list of library names or absoulte file paths * which should be loaded at application start-up. The name * and file path may contain a library version appended at the * end and separated by a '$' charactger. * * For example liborg_mitk_gui_qt_common$1.0. * Platform specific suffixes are appended automatically. * * @param libraryBaseNames A list of library base names. */ void setPreloadLibraries(const QStringList &libraryBaseNames); /** * Get the list of library base names which should be pre-loaded. * * @return A list of pre-loaded libraries. */ QStringList getPreloadLibraries() const; /** * Set the path to the provisioning file. * * By default a provisioning file located in the same directory * as the executable and named .provisioning * is loaded if it exists. To disable parsing of provisioning * files, use an empty string as the argument. Use a * null QString (QString::null) to reset to the * default behaviour. * * @param filePath An absolute file path to the provisioning file. */ void setProvisioningFilePath(const QString &filePath); /** * Get the file path to the provisioning file. * @return The provisioning file path. */ QString getProvisioningFilePath() const; void setProperty(const QString &property, const QVariant &value); QVariant getProperty(const QString &property) const; void installTranslator(QTranslator*); bool isRunning(); void sendMessage(const QByteArray); protected: void initialize(Poco::Util::Application &self) override; void uninitialize() override; int getArgc() const; char **getArgv() const; /** * Get the framework storage directory for the CTK plugin * framework. This method is called in the initialize(Poco::Util::Application&) * method. It must not be called without a QCoreApplications instance. * * @return The CTK Plugin Framework storage directory. */ virtual QString getCTKFrameworkStorageDir() const; /** * Initialize the CppMicroServices library. * * The default implementation set the CppMicroServices storage * path to the current ctkPluginConstants::FRAMEWORK_STORAGE property * value. * * This method is called in the initialize(Poco::Util::Application&) * after the CTK Plugin Framework storage directory property * was set. */ virtual void initializeCppMicroServices(); /** * Get the QCoreApplication object. * * This method is called in the initialize(Poco::Util::Application&) * method and must create a QCoreApplication instance if the * global qApp variable is not initialized yet. * * @return The current QCoreApplication instance. This method * never returns null. */ virtual QCoreApplication *getQApplication() const; /** * Add plugin library search paths to the CTK Plugin Framework. * * This method is called in the nitialize(Poco::Util::Application&) * method after getQApplication() was called. */ virtual void initializeLibraryPaths(); /** * Runs the application for which the platform was started. The platform * must be running. *

* The given argument is passed to the application being run. If it is an invalid QVariant * then the command line arguments used in starting the platform, and not consumed * by the platform code, are passed to the application as a QStringList. *

* @param argument the argument passed to the application. May be invalid * @return the result of running the application * @throws std::exception if anything goes wrong */ int main(const std::vector &args) override; /** * Define command line arguments * @param options */ void defineOptions(Poco::Util::OptionSet &options) override; QSharedPointer getFramework() const; ctkPluginContext *getFrameworkContext() const; /** * Get the initial properties for the CTK plugin framework. * * The returned map contains the initial framework properties for * initializing the CTK plugin framework. The value of specific * properties may change at runtime and differ from the initial * value. * * @return The initial CTK Plugin Framework properties. */ QHash getFrameworkProperties() const; /* * Initialize and display the splash screen if an image filename is given * */ void initializeSplashScreen(QCoreApplication * application) const; private: struct Impl; Impl* d; }; } #endif // MITKBASEAPPLICATION_H diff --git a/Modules/AppUtil/src/mitkBaseApplication.cpp b/Modules/AppUtil/src/mitkBaseApplication.cpp index 316bd28185..c5b3252693 100644 --- a/Modules/AppUtil/src/mitkBaseApplication.cpp +++ b/Modules/AppUtil/src/mitkBaseApplication.cpp @@ -1,865 +1,853 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { void outputQtMessage(QtMsgType type, const QMessageLogContext&, const QString& msg) { auto message = msg.toStdString(); switch (type) { case QtDebugMsg: MITK_DEBUG << message; break; case QtInfoMsg: MITK_INFO << message; break; case QtWarningMsg: MITK_WARN << message; break; case QtCriticalMsg: MITK_ERROR << message; break; case QtFatalMsg: MITK_ERROR << message; abort(); default: MITK_INFO << message; break; } } } namespace mitk { const QString BaseApplication::ARG_APPLICATION = "BlueBerry.application"; const QString BaseApplication::ARG_CLEAN = "BlueBerry.clean"; const QString BaseApplication::ARG_CONSOLELOG = "BlueBerry.consoleLog"; const QString BaseApplication::ARG_DEBUG = "BlueBerry.debug"; const QString BaseApplication::ARG_FORCE_PLUGIN_INSTALL = "BlueBerry.forcePlugins"; const QString BaseApplication::ARG_HOME = "BlueBerry.home"; const QString BaseApplication::ARG_NEWINSTANCE = "BlueBerry.newInstance"; const QString BaseApplication::ARG_NO_LAZY_REGISTRY_CACHE_LOADING = "BlueBerry.noLazyRegistryCacheLoading"; const QString BaseApplication::ARG_NO_REGISTRY_CACHE = "BlueBerry.noRegistryCache"; const QString BaseApplication::ARG_PLUGIN_CACHE = "BlueBerry.plugin_cache_dir"; const QString BaseApplication::ARG_PLUGIN_DIRS = "BlueBerry.plugin_dirs"; const QString BaseApplication::ARG_PRELOAD_LIBRARY = "BlueBerry.preloadLibrary"; const QString BaseApplication::ARG_PRODUCT = "BlueBerry.product"; const QString BaseApplication::ARG_PROVISIONING = "BlueBerry.provisioning"; const QString BaseApplication::ARG_REGISTRY_MULTI_LANGUAGE = "BlueBerry.registryMultiLanguage"; const QString BaseApplication::ARG_SPLASH_IMAGE = "BlueBerry.splashscreen"; const QString BaseApplication::ARG_STORAGE_DIR = "BlueBerry.storageDir"; - const QString BaseApplication::ARG_TESTAPPLICATION = "BlueBerry.testapplication"; - const QString BaseApplication::ARG_TESTPLUGIN = "BlueBerry.testplugin"; const QString BaseApplication::ARG_XARGS = "xargs"; const QString BaseApplication::PROP_APPLICATION = "blueberry.application"; const QString BaseApplication::PROP_FORCE_PLUGIN_INSTALL = BaseApplication::ARG_FORCE_PLUGIN_INSTALL; const QString BaseApplication::PROP_NEWINSTANCE = BaseApplication::ARG_NEWINSTANCE; const QString BaseApplication::PROP_NO_LAZY_REGISTRY_CACHE_LOADING = BaseApplication::ARG_NO_LAZY_REGISTRY_CACHE_LOADING; const QString BaseApplication::PROP_NO_REGISTRY_CACHE = BaseApplication::ARG_NO_REGISTRY_CACHE; const QString BaseApplication::PROP_PRODUCT = "blueberry.product"; const QString BaseApplication::PROP_REGISTRY_MULTI_LANGUAGE = BaseApplication::ARG_REGISTRY_MULTI_LANGUAGE; - const QString BaseApplication::PROP_TESTAPPLICATION = "BlueBerry.testapplication"; - const QString BaseApplication::PROP_TESTPLUGIN = "BlueBerry.testplugin"; class SplashCloserCallback : public QRunnable { public: SplashCloserCallback(QSplashScreen* splashscreen) : m_Splashscreen(splashscreen) { } void run() override { this->m_Splashscreen->close(); } private: QSplashScreen *m_Splashscreen; // Owned by BaseApplication::Impl }; struct BaseApplication::Impl { ctkProperties m_FWProps; QCoreApplication *m_QApp; int m_Argc; char **m_Argv; #ifdef Q_OS_MAC std::vector m_Argv_macOS; #endif QString m_AppName; QString m_OrgaName; QString m_OrgaDomain; bool m_SingleMode; bool m_SafeMode; QSplashScreen *m_Splashscreen; SplashCloserCallback *m_SplashscreenClosingCallback; QStringList m_PreloadLibs; QString m_ProvFile; Impl(int argc, char **argv) : m_Argc(argc), m_Argv(argv), #ifdef Q_OS_MAC m_Argv_macOS(), #endif m_SingleMode(false), m_SafeMode(true), m_Splashscreen(nullptr), m_SplashscreenClosingCallback(nullptr) { #ifdef Q_OS_MAC /* On macOS the process serial number is passed as an command line argument (-psn_) in certain circumstances. This option causes a Poco exception. We remove it, if present. */ m_Argv_macOS.reserve(argc); const char psn[] = "-psn"; for (decltype(argc) i = 0; i < argc; ++i) { if (0 == strncmp(argv[i], psn, sizeof(psn))) continue; m_Argv_macOS.push_back(argv[i]); } m_Argc = static_cast(m_Argv_macOS.size()); m_Argv = m_Argv_macOS.data(); #endif } ~Impl() { delete m_SplashscreenClosingCallback; delete m_Splashscreen; delete m_QApp; } QVariant getProperty(const QString &property) const { auto iter = m_FWProps.find(property); return m_FWProps.end() != iter ? iter.value() : QVariant(); } void handleBooleanOption(const std::string &name, const std::string &) { auto fwKey = QString::fromStdString(name); // Translate some keys to proper framework properties if (ARG_CONSOLELOG == fwKey) fwKey = ctkPluginFrameworkLauncher::PROP_CONSOLE_LOG; // For all other options we use the command line option name as the // framework property key. m_FWProps[fwKey] = true; } void handlePreloadLibraryOption(const std::string &, const std::string &value) { m_PreloadLibs.push_back(QString::fromStdString(value)); } void handleClean(const std::string &, const std::string &) { m_FWProps[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN] = ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT; } void initializeCTKPluginFrameworkProperties(Poco::Util::LayeredConfiguration &configuration) { // Add all configuration key/value pairs as framework properties Poco::Util::LayeredConfiguration::Keys keys; Poco::Util::LayeredConfiguration::Keys keyStack; configuration.keys(keyStack); std::vector keyChain; while (!keyStack.empty()) { const auto currSubKey = keyStack.back(); if (!keyChain.empty() && keyChain.back() == currSubKey) { keyChain.pop_back(); keyStack.pop_back(); continue; } Poco::Util::LayeredConfiguration::Keys subKeys; configuration.keys(currSubKey, subKeys); if (subKeys.empty()) { std::string finalKey; keyStack.pop_back(); for (const auto key : keyChain) finalKey += key + '.'; finalKey += currSubKey; keys.push_back(finalKey); } else { keyChain.push_back(currSubKey); for (const auto key : subKeys) keyStack.push_back(key); } } for (const auto key : keys) { if (configuration.hasProperty(key)) { // .ini and command line options overwrite already inserted keys auto qKey = QString::fromStdString(key); m_FWProps[qKey] = QString::fromStdString(configuration.getString(key)); } } } void parseProvisioningFile(const QString &filePath) { // Skip parsing if the file path is empty if (filePath.isEmpty()) return; auto consoleLog = this->getProperty(ctkPluginFrameworkLauncher::PROP_CONSOLE_LOG).toBool(); // Read initial plugins from a provisioning file QFileInfo provFile(filePath); QStringList pluginsToStart; if (provFile.exists()) { MITK_INFO(consoleLog) << "Using provisioning file: " << qPrintable(provFile.absoluteFilePath()); ProvisioningInfo provInfo(provFile.absoluteFilePath()); // It can still happen that the encoding is not compatible with the fromUtf8 function (i.e. when // manipulating the LANG variable). The QStringList in provInfo is empty then. if (provInfo.getPluginDirs().empty()) { MITK_ERROR << "Cannot search for provisioning file, the retrieved directory list is empty.\n" << "This can happen if there are some special non-ASCII characters in the install path."; } else { for(const auto pluginPath : provInfo.getPluginDirs()) ctkPluginFrameworkLauncher::addSearchPath(pluginPath); auto pluginUrlsToStart = provInfo.getPluginsToStart(); for (const auto url : pluginUrlsToStart) pluginsToStart.push_back(url.toString()); } } else { MITK_INFO(consoleLog) << "Provisionig file does not exist."; } if (!pluginsToStart.isEmpty()) { m_FWProps[ctkPluginFrameworkLauncher::PROP_PLUGINS] = pluginsToStart; // Use transient start with declared activation policy (this helps when the provisioning file // changes and some plug-ins should not be installed in the application any more). ctkPlugin::StartOptions startOptions(ctkPlugin::START_TRANSIENT | ctkPlugin::START_ACTIVATION_POLICY); m_FWProps[ctkPluginFrameworkLauncher::PROP_PLUGINS_START_OPTIONS] = static_cast(startOptions); } } }; BaseApplication::BaseApplication(int argc, char **argv) : Application(), d(new Impl(argc, argv)) { } BaseApplication::~BaseApplication() { delete d; } void BaseApplication::printHelp(const std::string &, const std::string &) { Poco::Util::HelpFormatter help(this->options()); help.setAutoIndent(); help.setCommand(this->commandName()); help.format(std::cout); exit(EXIT_OK); } void BaseApplication::setApplicationName(const QString &name) { if (nullptr != qApp) qApp->setApplicationName(name); d->m_AppName = name; } QString BaseApplication::getApplicationName() const { return nullptr != qApp ? qApp->applicationName() : d->m_AppName; } void BaseApplication::setOrganizationName(const QString &name) { if (nullptr != qApp) qApp->setOrganizationName(name); d->m_OrgaName = name; } QString BaseApplication::getOrganizationName() const { return nullptr != qApp ? qApp->organizationName() : d->m_OrgaName; } void BaseApplication::setOrganizationDomain(const QString &domain) { if (nullptr != qApp) qApp->setOrganizationDomain(domain); d->m_OrgaDomain = domain; } QString BaseApplication::getOrganizationDomain() const { return nullptr != qApp ? qApp->organizationDomain() : d->m_OrgaDomain; } void BaseApplication::setSingleMode(bool singleMode) { if (nullptr != qApp) return; d->m_SingleMode = singleMode; } bool BaseApplication::getSingleMode() const { return d->m_SingleMode; } void BaseApplication::setSafeMode(bool safeMode) { if (nullptr != qApp && nullptr == d->m_QApp) return; d->m_SafeMode = safeMode; nullptr == d->m_QApp && getSingleMode() ? static_cast(d->m_QApp)->setSafeMode(safeMode) : static_cast(d->m_QApp)->setSafeMode(safeMode); } bool BaseApplication::getSafeMode() const { return d->m_SafeMode; } void BaseApplication::setPreloadLibraries(const QStringList &libraryBaseNames) { d->m_PreloadLibs = libraryBaseNames; } QStringList BaseApplication::getPreloadLibraries() const { return d->m_PreloadLibs; } void BaseApplication::setProvisioningFilePath(const QString &filePath) { d->m_ProvFile = filePath; } QString BaseApplication::getProvisioningFilePath() const { auto provFilePath = d->m_ProvFile; // A null QString means look up a default provisioning file if (provFilePath.isNull() && nullptr != qApp) { QFileInfo appFilePath(QCoreApplication::applicationFilePath()); QDir basePath(QCoreApplication::applicationDirPath()); auto provFileName = appFilePath.baseName() + ".provisioning"; QFileInfo provFile(basePath.absoluteFilePath(provFileName)); #ifdef Q_OS_MAC /* * On macOS, if started from the build directory, the .provisioning file is located at: * * The executable path is: * * In this case we have to cdUp threetimes. * * During packaging the MitkWorkbench.provisioning file is placed at the same * level like the executable. Nothing has to be done. */ if (!provFile.exists()) { basePath.cdUp(); basePath.cdUp(); basePath.cdUp(); provFile = basePath.absoluteFilePath(provFileName); } #endif if (provFile.exists()) { provFilePath = provFile.absoluteFilePath(); } #ifdef CMAKE_INTDIR else { basePath.cdUp(); provFile.setFile(basePath.absoluteFilePath(provFileName)); if (provFile.exists()) provFilePath = provFile.absoluteFilePath(); } #endif } return provFilePath; } void BaseApplication::initializeQt() { if (nullptr != qApp) return; // If parameters have been set before, we have to store them to hand them // through to the application auto appName = this->getApplicationName(); auto orgName = this->getOrganizationName(); auto orgDomain = this->getOrganizationDomain(); // Create a QCoreApplication instance this->getQApplication(); // Provide parameters to QCoreApplication this->setApplicationName(appName); this->setOrganizationName(orgName); this->setOrganizationDomain(orgDomain); qInstallMessageHandler(outputQtMessage); } void BaseApplication::initialize(Poco::Util::Application &self) { // 1. Call the super-class method Poco::Util::Application::initialize(self); // 2. Initialize the Qt framework (by creating a QCoreApplication) this->initializeQt(); // 3. Seed the random number generator, once at startup. QTime time = QTime::currentTime(); qsrand((uint)time.msec()); // 4. Load the "default" configuration, which involves parsing // an optional .ini file and parsing any // command line arguments this->loadConfiguration(); // 5. Add configuration data from the command line and the // optional .ini file as CTK plugin // framework properties. d->initializeCTKPluginFrameworkProperties(this->config()); // 6. Initialize splash screen if an image path is provided // in the .ini file this->initializeSplashScreen(qApp); // 7. Set the custom CTK Plugin Framework storage directory QString storageDir = this->getCTKFrameworkStorageDir(); if (!storageDir.isEmpty()) d->m_FWProps[ctkPluginConstants::FRAMEWORK_STORAGE] = storageDir; // 8. Set the library search paths and the pre-load library property this->initializeLibraryPaths(); auto preloadLibs = this->getPreloadLibraries(); if (!preloadLibs.isEmpty()) d->m_FWProps[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES] = preloadLibs; // 9. Initialize the CppMicroServices library. // The initializeCppMicroServices() method reuses the // FRAMEWORK_STORAGE property, so we call it after the // getCTKFrameworkStorageDir method. this->initializeCppMicroServices(); // 10. Parse the (optional) provisioning file and set the // correct framework properties. d->parseProvisioningFile(this->getProvisioningFilePath()); // 11. Set the CTK Plugin Framework properties ctkPluginFrameworkLauncher::setFrameworkProperties(d->m_FWProps); } void BaseApplication::uninitialize() { auto pfw = this->getFramework(); if (pfw) { pfw->stop(); // Wait for up to 10 seconds for the CTK plugin framework to stop pfw->waitForStop(10000); } Poco::Util::Application::uninitialize(); } int BaseApplication::getArgc() const { return d->m_Argc; } char **BaseApplication::getArgv() const { return d->m_Argv; } QString BaseApplication::getCTKFrameworkStorageDir() const { QString storageDir; if (this->getSingleMode()) { // This function checks if an instance is already running and either sends a message to // it containing the command line arguments or checks if a new instance was forced by // providing the BlueBerry.newInstance command line argument. In the latter case, a path // to a temporary directory for the new application's storage directory is returned. storageDir = handleNewAppInstance(static_cast(d->m_QApp), d->m_Argc, d->m_Argv, ARG_NEWINSTANCE); } if (storageDir.isEmpty()) { // This is a new instance and no other instance is already running. We specify the // storage directory here (this is the same code as in berryInternalPlatform.cpp) // so that we can re-use the location for the persistent data location of the // the CppMicroServices library. // Append a hash value of the absolute path of the executable to the data location. // This allows to start the same application from different build or install trees. storageDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/" + this->getOrganizationName() + "/" + this->getApplicationName() + '_'; storageDir += QString::number(qHash(QCoreApplication::applicationDirPath())) + "/"; } return storageDir; } void BaseApplication::initializeCppMicroServices() { auto storageDir = this->getProperty(ctkPluginConstants::FRAMEWORK_STORAGE).toString(); if (!storageDir.isEmpty()) us::ModuleSettings::SetStoragePath((storageDir + "us" + QDir::separator()).toStdString()); } QCoreApplication *BaseApplication::getQApplication() const { if (nullptr == qApp) { vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples(0); auto defaultFormat = QVTKOpenGLWidget::defaultFormat(); defaultFormat.setSamples(0); QSurfaceFormat::setDefaultFormat(defaultFormat); #ifdef Q_OS_OSX QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #endif QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); d->m_QApp = this->getSingleMode() ? static_cast(new QmitkSingleApplication(d->m_Argc, d->m_Argv, this->getSafeMode())) : static_cast(new QmitkSafeApplication(d->m_Argc, d->m_Argv, this->getSafeMode())); } return qApp; } void BaseApplication::initializeLibraryPaths() { QStringList suffixes; suffixes << "plugins"; #ifdef Q_OS_WINDOWS suffixes << "bin/plugins"; #ifdef CMAKE_INTDIR suffixes << "bin/" CMAKE_INTDIR "/plugins"; #endif #else suffixes << "lib/plugins"; #ifdef CMAKE_INTDIR suffixes << "lib/" CMAKE_INTDIR "/plugins"; #endif #endif #ifdef Q_OS_MAC suffixes << "../../plugins"; #endif // We add a couple of standard library search paths for plug-ins QDir appDir(QCoreApplication::applicationDirPath()); // Walk one directory up and add bin and lib sub-dirs; this might be redundant appDir.cdUp(); for (const auto suffix : suffixes) ctkPluginFrameworkLauncher::addSearchPath(appDir.absoluteFilePath(suffix)); } int BaseApplication::main(const std::vector &args) { // Start the plugin framework and all installed plug-ins according to their auto-start setting QStringList arguments; for (auto const &arg : args) arguments.push_back(QString::fromStdString(arg)); if (nullptr != d->m_Splashscreen) { // A splash screen is displayed. Create the closing callback. d->m_SplashscreenClosingCallback = new SplashCloserCallback(d->m_Splashscreen); } return ctkPluginFrameworkLauncher::run(d->m_SplashscreenClosingCallback, QVariant::fromValue(arguments)).toInt(); } void BaseApplication::defineOptions(Poco::Util::OptionSet &options) { Poco::Util::Option helpOption("help", "h", "print this help text"); helpOption.callback(Poco::Util::OptionCallback(this, &BaseApplication::printHelp)); options.addOption(helpOption); Poco::Util::Option newInstanceOption(ARG_NEWINSTANCE.toStdString(), "", "forces a new instance of this application"); newInstanceOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption)); options.addOption(newInstanceOption); Poco::Util::Option cleanOption(ARG_CLEAN.toStdString(), "", "cleans the plugin cache"); cleanOption.callback(Poco::Util::OptionCallback(d, &Impl::handleClean)); options.addOption(cleanOption); Poco::Util::Option productOption(ARG_PRODUCT.toStdString(), "", "the id of the product to be launched"); productOption.argument("").binding(PROP_PRODUCT.toStdString()); options.addOption(productOption); Poco::Util::Option appOption(ARG_APPLICATION.toStdString(), "", "the id of the application extension to be executed"); appOption.argument("").binding(PROP_APPLICATION.toStdString()); options.addOption(appOption); Poco::Util::Option provOption(ARG_PROVISIONING.toStdString(), "", "the location of a provisioning file"); provOption.argument("").binding(ARG_PROVISIONING.toStdString()); options.addOption(provOption); Poco::Util::Option storageDirOption(ARG_STORAGE_DIR.toStdString(), "", "the location for storing persistent application data"); storageDirOption.argument("").binding(ctkPluginConstants::FRAMEWORK_STORAGE.toStdString()); options.addOption(storageDirOption); Poco::Util::Option consoleLogOption(ARG_CONSOLELOG.toStdString(), "", "log messages to the console"); consoleLogOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption)); options.addOption(consoleLogOption); Poco::Util::Option debugOption(ARG_DEBUG.toStdString(), "", "enable debug mode"); debugOption.argument("", false).binding(ctkPluginFrameworkLauncher::PROP_DEBUG.toStdString()); options.addOption(debugOption); Poco::Util::Option forcePluginOption(ARG_FORCE_PLUGIN_INSTALL.toStdString(), "", "force installing plug-ins with same symbolic name"); forcePluginOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption)); options.addOption(forcePluginOption); Poco::Util::Option preloadLibsOption(ARG_PRELOAD_LIBRARY.toStdString(), "", "preload a library"); preloadLibsOption.argument("") .repeatable(true) .callback(Poco::Util::OptionCallback(d, &Impl::handlePreloadLibraryOption)); options.addOption(preloadLibsOption); - Poco::Util::Option testPluginOption(ARG_TESTPLUGIN.toStdString(), "", "the plug-in to be tested"); - testPluginOption.argument("").binding(PROP_TESTPLUGIN.toStdString()); - options.addOption(testPluginOption); - - Poco::Util::Option testAppOption(ARG_TESTAPPLICATION.toStdString(), "", "the application to be tested"); - testAppOption.argument("").binding(PROP_TESTAPPLICATION.toStdString()); - options.addOption(testAppOption); - Poco::Util::Option noRegistryCacheOption(ARG_NO_REGISTRY_CACHE.toStdString(), "", "do not use a cache for the registry"); noRegistryCacheOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption)); options.addOption(noRegistryCacheOption); Poco::Util::Option noLazyRegistryCacheLoadingOption(ARG_NO_LAZY_REGISTRY_CACHE_LOADING.toStdString(), "", "do not use lazy cache loading for the registry"); noLazyRegistryCacheLoadingOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption)); options.addOption(noLazyRegistryCacheLoadingOption); Poco::Util::Option registryMultiLanguageOption(ARG_REGISTRY_MULTI_LANGUAGE.toStdString(), "", "enable multi-language support for the registry"); registryMultiLanguageOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption)); options.addOption(registryMultiLanguageOption); Poco::Util::Option splashScreenOption(ARG_SPLASH_IMAGE.toStdString(), "", "optional picture to use as a splash screen"); splashScreenOption.argument("").binding(ARG_SPLASH_IMAGE.toStdString()); options.addOption(splashScreenOption); Poco::Util::Option xargsOption(ARG_XARGS.toStdString(), "", "Extended argument list"); xargsOption.argument("").binding(ARG_XARGS.toStdString()); options.addOption(xargsOption); Poco::Util::Application::defineOptions(options); } QSharedPointer BaseApplication::getFramework() const { return ctkPluginFrameworkLauncher::getPluginFramework(); } ctkPluginContext *BaseApplication::getFrameworkContext() const { auto framework = getFramework(); return framework ? framework->getPluginContext() : nullptr; } void BaseApplication::initializeSplashScreen(QCoreApplication * application) const { auto pixmapFileNameProp = d->getProperty(ARG_SPLASH_IMAGE); if (!pixmapFileNameProp.isNull()) { auto pixmapFileName = pixmapFileNameProp.toString(); QFileInfo checkFile(pixmapFileName); if (checkFile.exists() && checkFile.isFile()) { QPixmap pixmap(checkFile.absoluteFilePath()); d->m_Splashscreen = new QSplashScreen(pixmap, Qt::WindowStaysOnTopHint); d->m_Splashscreen->show(); application->processEvents(); } } } QHash BaseApplication::getFrameworkProperties() const { return d->m_FWProps; } int BaseApplication::run() { this->init(d->m_Argc, d->m_Argv); return Application::run(); } void BaseApplication::setProperty(const QString &property, const QVariant &value) { d->m_FWProps[property] = value; } QVariant BaseApplication::getProperty(const QString &property) const { return d->getProperty(property); } void BaseApplication::installTranslator(QTranslator* translator) { this->getQApplication()->installTranslator(translator); } bool BaseApplication::isRunning() { auto app = dynamic_cast(this->getQApplication()); if (nullptr != app) app->isRunning(); mitkThrow() << "Method not implemented."; } void BaseApplication::sendMessage(const QByteArray msg) { auto app = dynamic_cast(this->getQApplication()); if (nullptr != app) app->sendMessage(msg); mitkThrow() << "Method not implemented."; } } diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/CMakeLists.txt b/Plugins/Testing/org.blueberry.core.runtime.tests/CMakeLists.txt deleted file mode 100644 index 4f06c8b200..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(org_blueberry_core_runtime_tests) - -mitk_create_plugin( - EXPORT_DIRECTIVE BERRY_RUNTIME_TESTS - TEST_PLUGIN -) - -target_link_libraries(${PROJECT_NAME} optimized CppUnit debug CppUnitd) - -MACRO_TEST_PLUGIN() diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/files.cmake b/Plugins/Testing/org.blueberry.core.runtime.tests/files.cmake deleted file mode 100644 index 904a56991c..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/files.cmake +++ /dev/null @@ -1,30 +0,0 @@ -set(MOC_H_FILES - src/berryCoreRuntimeTestSuite.h - src/berryPluginActivator.h -) - -set(CACHED_RESOURCE_FILES - plugin.xml -) - -set(SRC_CPP_FILES - berryCoreRuntimeTestSuite.cpp - berryPreferencesServiceTest.cpp - berryPreferencesTest.cpp - - berryPluginActivator.cpp -) - -set(INTERNAL_CPP_FILES - -) - -set(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/manifest_headers.cmake b/Plugins/Testing/org.blueberry.core.runtime.tests/manifest_headers.cmake deleted file mode 100644 index 5b1f7b7e14..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "Core Runtime Test Bundle") -set(Plugin-Version "0.9") -set(Plugin-Vendor "German Cancer Research Center (DKFZ)") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.blueberry.test org.blueberry.core.runtime) - diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/plugin.xml b/Plugins/Testing/org.blueberry.core.runtime.tests/plugin.xml deleted file mode 100644 index a788a9f121..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/plugin.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.cpp b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.cpp deleted file mode 100644 index 595ff7f254..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#include -#include -#include - -#include "berryCoreRuntimeTestSuite.h" - -#include "berryPreferencesTest.h" -#include "berryPreferencesServiceTest.h" - -namespace berry { - -CoreRuntimeTestSuite::CoreRuntimeTestSuite(const CoreRuntimeTestSuite& other) -{ - -} - -CoreRuntimeTestSuite::CoreRuntimeTestSuite() -: CppUnit::TestSuite("CoreRuntimeTestSuite") -{ - addTest(PreferencesTest::Suite()); - addTest(PreferencesServiceTest::Suite()); -} - -} diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.h b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.h deleted file mode 100644 index 7032be05da..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryCoreRuntimeTestSuite.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYCORERUNTIMETESTSUITE_H_ -#define BERRYCORERUNTIMETESTSUITE_H_ - -#include - -#include - -Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test") - -namespace berry { - -class CoreRuntimeTestSuite : public QObject, public CppUnit::TestSuite -{ - Q_OBJECT - Q_INTERFACES(CppUnit::Test) - -public: - - CoreRuntimeTestSuite(); - CoreRuntimeTestSuite(const CoreRuntimeTestSuite& other); -}; - -} - -#endif /* BERRYCORERUNTIMETESTSUITE_H_ */ diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.cpp b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.cpp deleted file mode 100644 index 4d01f61999..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include "berryPluginActivator.h" -#include "berryCoreRuntimeTestSuite.h" - -namespace berry { - -void org_blueberry_core_runtime_tests_Activator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(CoreRuntimeTestSuite, context) -} - -void org_blueberry_core_runtime_tests_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.h b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.h deleted file mode 100644 index 7a5e6ca163..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPluginActivator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYPLUGINACTIVATOR_H -#define BERRYPLUGINACTIVATOR_H - -#include -#include - -namespace berry { - -class org_blueberry_core_runtime_tests_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_blueberry_core_runtime_tests") - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; - -typedef org_blueberry_core_runtime_tests_Activator PluginActivator; - -} - -#endif // BERRYPLUGINACTIVATOR_H diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.cpp b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.cpp deleted file mode 100644 index ba0dc787f8..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryPreferencesServiceTest.h" -#include -#include -#include - -#include "berryLog.h" - -#include -#include - -#include "Poco/File.h" -#include "Poco/Path.h" -#include "Poco/AutoPtr.h" - -#include -#include -#include - -using namespace std; - -namespace berry -{ - - PreferencesServiceTest::PreferencesServiceTest(const std::string& testName) - : berry::TestCase(testName) - {} - - CppUnit::Test* PreferencesServiceTest::Suite() - { - CppUnit::TestSuite* suite = new CppUnit::TestSuite("PreferencesServiceTest"); - - CppUnit_addTest(suite, PreferencesServiceTest, TestAll); - return suite; - } - - - void PreferencesServiceTest::TestAll() - { - try - { - IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID); - assert(prefService.IsNotNull()); - - /// Test for: IPreferences::GetSystemPreferences() - IPreferences::Pointer sysPrefs = prefService->GetSystemPreferences(); - assert(sysPrefs.IsNotNull()); - - /// Test for: IPreferences::GetUserPreferences(std::string name) - IPreferences::Pointer testUserPrefs = prefService->GetUserPreferences("testUser"); - assert(testUserPrefs.IsNotNull()); - - /// Test for: IPreferences::GetUsers() - std::vector userList = prefService->GetUsers(); - // userList should now contain "testUser" - bool userListContainsTestUser = false; - for (std::vector::iterator it = userList.begin() - ; it != userList.end(); it++) - { - if(*it == "testUser") - { - userListContainsTestUser = true; - break; - } - } - assert(userListContainsTestUser); - - IBerryPreferencesService::Pointer berryPrefService = prefService.Cast(); - // optional test for IBerryPreferencesService - if(berryPrefService.IsNotNull()) - { - /// Test for: IBerryPreferencesService::ExportPreferences(Poco::File f, std::string name="") - - // write general prefs - std::string sysPrefsExportFilePath = Poco::Path::temp() + Poco::Path::separator() + "systemBerryPreferences"; - Poco::File sysPrefsExportFile(sysPrefsExportFilePath); - sysPrefs->PutInt("testNumber", 1); - berryPrefService->ExportPreferences(sysPrefsExportFile); - // assert somethings was written - assert(sysPrefsExportFile.getSize() > 0); - - // write testUser prefs - std::string testUserPrefsExportFilePath = Poco::Path::temp() + Poco::Path::separator() + "testUserBerryPreferences"; - Poco::File testUserPrefsExportFile(testUserPrefsExportFilePath); - testUserPrefs->PutInt("testNumber", 2); - berryPrefService->ExportPreferences(testUserPrefsExportFile, "testUser"); - assert(testUserPrefsExportFile.getSize() > 0); - - /// Test for: IBerryPreferencesService::ImportPreferences(Poco::File f, std::string name="") - - // import general prefs - // change testNumber value - sysPrefs->PutInt("testNumber", 3); - berryPrefService->ImportPreferences(sysPrefsExportFile); - // "testNumber" preference should now again be overwritten with its old value 1 - assert(sysPrefs->GetInt("testNumber", 3) == 1); - - // import testUser prefs - // change testNumber value - testUserPrefs->PutInt("testNumber", 4); - berryPrefService->ImportPreferences(testUserPrefsExportFile, "testUser"); - // "testNumber" preference should now again be overwritten with its old value 2 - assert(testUserPrefs->GetInt("testNumber", 4) == 2); - - // delete files again - sysPrefsExportFile.remove(); - testUserPrefsExportFile.remove(); - } - } - catch (Poco::CreateFileException& e) - { - std::string msg = "Failed to create preferences file: "; - msg.append(e.what()); - this->fail( msg ); - } - catch (std::exception& e) - { - this->fail( e.what() ); - } - catch (...) - { - this->fail( "unknown exception occured" ); - } - } -} diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.h b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.h deleted file mode 100644 index 286abb9010..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesServiceTest.h +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYPREFERENCESSERVICETEST_H_ -#define BERRYPREFERENCESSERVICETEST_H_ - -#include - -namespace berry { - -class PreferencesServiceTest : public berry::TestCase -{ -public: - - static CppUnit::Test* Suite(); - - PreferencesServiceTest(const std::string& testName); - - void TestAll(); -}; - -} - -#endif /* BERRYPREFERENCESSERVICETEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.cpp b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.cpp deleted file mode 100644 index cecc437691..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryPreferencesTest.h" - -#include -#include -#include - -#include -#include - -#include "berryLog.h" - -#include "Poco/File.h" -#include "Poco/Path.h" - -#include -#include -#include - -using namespace std; - -namespace berry -{ - - PreferencesTest::PreferencesTest(const std::string& testName) - : berry::TestCase(testName) - {} - - CppUnit::Test* PreferencesTest::Suite() - { - CppUnit::TestSuite* suite = new CppUnit::TestSuite("PreferencesTest"); - - CppUnit_addTest(suite, PreferencesTest, TestAll); - return suite; - } - - // simple class for testing berry changed events - class TestPreferencesChangedListener - { - public: - TestPreferencesChangedListener(IBerryPreferences* _berryPrefNode) : numCalled(0), berryPrefNode(_berryPrefNode) - { - berryPrefNode->OnChanged.AddListener( - berry::MessageDelegate1 ( - this, &TestPreferencesChangedListener::PreferencesChanged ) - ); - }; - - ~TestPreferencesChangedListener() - { - berryPrefNode->OnChanged.RemoveListener( - berry::MessageDelegate1 ( - this, &TestPreferencesChangedListener::PreferencesChanged ) - ); - }; - - void PreferencesChanged(const IBerryPreferences*) - { - ++numCalled; - } - int numCalled; - IBerryPreferences* berryPrefNode; - }; - - void PreferencesTest::TestAll() - { - IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID); - assert(prefService.IsNotNull()); - - /// Test for: IPreferences::GetSystemPreferences() - IPreferences::Pointer root = prefService->GetSystemPreferences(); - assert(root.IsNotNull()); - - { - BERRY_INFO << "testing Preferences::Node(), Preferences::NodeExists(), Preferences::Parent(), " - "Preferences::ChildrenNames(), Preferences::RemoveNode()"; - - berry::IPreferences::Pointer editorsNode(0); - editorsNode = root->Node("/editors"); - assert(editorsNode.IsNotNull()); - - assert(editorsNode->NodeExists("/editors")); - - assert(editorsNode->Parent() == root); - - berry::IPreferences::Pointer editorsGeneralNode = root->Node("/editors/general"); - assert(editorsNode->NodeExists("/editors/general")); - - berry::IPreferences::Pointer editorsSyntaxNode = root->Node("/editors/syntax"); - assert(editorsGeneralNode->NodeExists("/editors/syntax")); - - berry::IPreferences::Pointer editorsFontNode = root->Node("/editors/font"); - assert(editorsSyntaxNode->NodeExists("/editors/font")); - - vector childrenNames; - childrenNames.push_back("general"); - childrenNames.push_back("syntax"); - childrenNames.push_back("font"); - assert(editorsNode->ChildrenNames() == childrenNames); - - editorsFontNode->RemoveNode(); - try { - editorsFontNode->Parent(); - failmsg("this should throw a Poco::IllegalStateException"); - } - catch (Poco::IllegalStateException) - { - // expected - } - } - - // testing methods - // Preferences::put*() - // Preferences::get*() - { - BERRY_INFO << "testing Preferences::put*(), Preferences::get*(), OnChanged"; - - assert(root->NodeExists("/editors/general")); - berry::IPreferences::Pointer editorsGeneralNode = root->Node("/editors/general"); - - IBerryPreferences::Pointer berryEditorsGeneralNode = editorsGeneralNode.Cast< IBerryPreferences >(); - assert(berryEditorsGeneralNode.IsNotNull()); - - TestPreferencesChangedListener listener(berryEditorsGeneralNode.GetPointer()); - - std::string strKey = "Bad words";std::string strValue = "badword1 badword2"; - editorsGeneralNode->Put(strKey, strValue); - - assert(listener.numCalled == 1); - assert(editorsGeneralNode->Get(strKey, "") == strValue); - assert(editorsGeneralNode->Get("wrong key", "default value") == "default value"); - - strKey = "Show Line Numbers";bool bValue = true; - editorsGeneralNode->PutBool(strKey, bValue); - assert(listener.numCalled == 2); - assert(editorsGeneralNode->GetBool(strKey, !bValue) == bValue); - - strKey = "backgroundcolor"; strValue = "#00FF00"; - editorsGeneralNode->PutByteArray(strKey, strValue); - assert(listener.numCalled == 3); - assert(editorsGeneralNode->GetByteArray(strKey, "") == strValue); - - strKey = "update time"; double dValue = 1.23; - editorsGeneralNode->PutDouble(strKey, dValue); - assert(editorsGeneralNode->GetDouble(strKey, 0.0) == dValue); - - strKey = "update time float"; float fValue = 1.23f; - editorsGeneralNode->PutFloat(strKey, fValue); - assert(editorsGeneralNode->GetFloat(strKey, 0.0f) == fValue); - - strKey = "Break on column"; int iValue = 80; - editorsGeneralNode->PutInt(strKey, iValue); - assert(editorsGeneralNode->GetInt(strKey, 0) == iValue); - - strKey = "Maximum number of words"; long lValue = 11000000; - editorsGeneralNode->PutLong(strKey, lValue); - assert(editorsGeneralNode->GetLong(strKey, 0) == lValue); - } - - } - -} diff --git a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.h b/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.h deleted file mode 100644 index 7cddaf0d04..0000000000 --- a/Plugins/Testing/org.blueberry.core.runtime.tests/src/berryPreferencesTest.h +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYPREFERENCESTEST_H_ -#define BERRYPREFERENCESTEST_H_ - -#include - -namespace berry { - -class PreferencesTest : public berry::TestCase -{ -public: - - PreferencesTest(const std::string& testName); - - static CppUnit::Test* Suite(); - - void TestAll(); - -}; - -} - -#endif /* BERRYPREFERENCESTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.osgi.tests/CMakeLists.txt b/Plugins/Testing/org.blueberry.osgi.tests/CMakeLists.txt deleted file mode 100755 index a7a9a5798b..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(org_blueberry_osgi_tests) - -mitk_create_plugin( - EXPORT_DIRECTIVE BERRY_OSGI_TESTS - TEST_PLUGIN -) - -target_link_libraries(${PROJECT_NAME} optimized CppUnit debug CppUnitd) - -MACRO_TEST_PLUGIN() diff --git a/Plugins/Testing/org.blueberry.osgi.tests/files.cmake b/Plugins/Testing/org.blueberry.osgi.tests/files.cmake deleted file mode 100644 index 197cf50487..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/files.cmake +++ /dev/null @@ -1,31 +0,0 @@ -set(MOC_H_FILES - src/berryOSGiCoreTestSuite.h - src/berryPluginActivator.h -) - -set(CACHED_RESOURCE_FILES - plugin.xml -) - -set(SRC_CPP_FILES - berryMessageTest.cpp - berryObjectTest.cpp - berryOSGiCoreTestSuite.cpp - berryPluginActivator.cpp - berrySmartPointerTest.cpp - berryWeakPointerTest.cpp -) - -set(INTERNAL_CPP_FILES - -) - -set(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/Testing/org.blueberry.osgi.tests/manifest_headers.cmake b/Plugins/Testing/org.blueberry.osgi.tests/manifest_headers.cmake deleted file mode 100644 index b4779358f4..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "OSGi Test Bundle") -set(Plugin-Version "0.9") -set(Plugin-Vendor "German Cancer Research Center (DKFZ)") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.blueberry.test) - diff --git a/Plugins/Testing/org.blueberry.osgi.tests/plugin.xml b/Plugins/Testing/org.blueberry.osgi.tests/plugin.xml deleted file mode 100644 index a866ea07e1..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/plugin.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryMessageTest.cpp b/Plugins/Testing/org.blueberry.osgi.tests/src/berryMessageTest.cpp deleted file mode 100755 index f0cdb6ac21..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryMessageTest.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryMessageTest.h" - -#include -//#include - -#include -#include - -namespace berry -{ - -struct MessageReceiver -{ - bool received; - - MessageReceiver() : received(false) {} - - void PureSignal() { received = true; } - bool PureSignalWithReturn() { received = true; return received; } - - void Message1(int i) { received = (i != 0); } - bool Message1WithReturn(int i) { received = (i != 0); return received; } - - void Message2(int i, float d) { received = (i != 0 && d != 0); } - bool Message2WithReturn(int i, float d) { received = (i != 0 && d!= 0); return received; } - - void Message3(int i, float d, double e) { received = (i != 0 && d != 0 && e != 0); } - bool Message3WithReturn(int i, float d, double e) { received = (i != 0 && d != 0 && e != 0); return received; } - - void Message4(int i, float d, double e, bool b) { received = (i != 0 && d != 0 && e != 0 && b); } - bool Message4WithReturn(int i, float d, double e, bool b) { received = (i != 0 && d != 0 && e != 0 && b); return received; } - -}; - -MessageTest::MessageTest(const std::string& testName) -: TestCase(testName) -{ - -} - -CppUnit::Test* MessageTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("MessageTest"); - - CppUnit_addTest(suite, MessageTest, TestMessage); - CppUnit_addTest(suite, MessageTest, TestMessageWithReturn); - CppUnit_addTest(suite, MessageTest, TestMessage1); - CppUnit_addTest(suite, MessageTest, TestMessage1WithReturn); - CppUnit_addTest(suite, MessageTest, TestMessage2); - CppUnit_addTest(suite, MessageTest, TestMessage2WithReturn); - CppUnit_addTest(suite, MessageTest, TestMessage3); - CppUnit_addTest(suite, MessageTest, TestMessage3WithReturn); - CppUnit_addTest(suite, MessageTest, TestMessage4); - CppUnit_addTest(suite, MessageTest, TestMessage4WithReturn); - - return suite; -} - - void MessageTest::TestMessage() - { - berry::Message<> msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef berry::MessageDelegate Delegate; - - msg += Delegate(&receiver, &MessageReceiver::PureSignal); - assertEqual(1, (long)msg.GetListeners().size()); - msg += Delegate(&receiver2, &MessageReceiver::PureSignal); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::PureSignal); - assertEqual(2, (long)msg.GetListeners().size()); - - msg.Send(); - assert(receiver.received && receiver2.received); - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::PureSignal); - assertEqual(1, (long)msg.GetListeners().size()); - - msg.Send(); - assert(receiver.received == false && receiver2.received); - } - - void MessageTest::TestMessageWithReturn() - { - berry::Message msg; - - MessageReceiver receiver; - typedef berry::MessageDelegate Delegate; - msg += Delegate(&receiver, &MessageReceiver::PureSignalWithReturn); - msg(); - assert(receiver.received); - - receiver.received = false; - typedef berry::Message::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(); - if (valueReturned) break; - } - assert(valueReturned); - } - - void MessageTest::TestMessage1() - { - berry::Message1 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef berry::MessageDelegate1 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message1); - assertEqual(1, (long)msg.GetListeners().size()); - msg += Delegate(&receiver2, &MessageReceiver::Message1); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message1); - assertEqual(2, (long)msg.GetListeners().size()); - - msg.Send(1); - assert(receiver.received && receiver2.received); - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message1); - assertEqual(1, (long)msg.GetListeners().size()); - - msg.Send(1); - assert(receiver.received == false && receiver2.received); - } - - void MessageTest::TestMessage1WithReturn() - { - berry::Message1 msg; - - MessageReceiver receiver; - typedef berry::MessageDelegate1 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message1WithReturn); - msg(1); - assert(receiver.received); - - receiver.received = false; - typedef berry::Message1::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1); - if (valueReturned) break; - } - assert(valueReturned); - } - - void MessageTest::TestMessage2() - { - berry::Message2 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef berry::MessageDelegate2 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message2); - assertEqual(1, (long)msg.GetListeners().size()); - msg += Delegate(&receiver2, &MessageReceiver::Message2); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message2); - assertEqual(2, (long)msg.GetListeners().size()); - - msg.Send(1, 1.0); - assert(receiver.received && receiver2.received); - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message2); - assertEqual(1, (long)msg.GetListeners().size()); - - msg.Send(1, 1.0); - assert(receiver.received == false && receiver2.received); - } - - void MessageTest::TestMessage2WithReturn() - { - berry::Message2 msg; - - MessageReceiver receiver; - typedef berry::MessageDelegate2 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message2WithReturn); - msg(1, 2); - assert(receiver.received); - - receiver.received = false; - typedef berry::Message2::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1, 0.4f); - if (valueReturned) break; - } - assert(valueReturned); - } - - void MessageTest::TestMessage3() - { - berry::Message3 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef berry::MessageDelegate3 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message3); - assertEqual(1, (long)msg.GetListeners().size()); - msg += Delegate(&receiver2, &MessageReceiver::Message3); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message3); - assertEqual(2, (long)msg.GetListeners().size()); - - msg.Send(1, 1.0, 2.0); - assert(receiver.received && receiver2.received); - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message3); - assertEqual(1, (long)msg.GetListeners().size()); - - msg.Send(1, -1.0, 5.0); - assert(receiver.received == false && receiver2.received); - } - - void MessageTest::TestMessage3WithReturn() - { - berry::Message3 msg; - - MessageReceiver receiver; - typedef berry::MessageDelegate3 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message3WithReturn); - msg(1, -2, 0.2); - assert(receiver.received); - - receiver.received = false; - typedef berry::Message3::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1, 23.5, -12.2); - if (valueReturned) break; - } - assert(valueReturned); - } - - void MessageTest::TestMessage4() - { - berry::Message4 msg; - - MessageReceiver receiver; - MessageReceiver receiver2; - - typedef berry::MessageDelegate4 Delegate; - - msg += Delegate(&receiver, &MessageReceiver::Message4); - assertEqual(1, (long)msg.GetListeners().size()); - msg += Delegate(&receiver2, &MessageReceiver::Message4); - // duplicate entry - msg += Delegate(&receiver, &MessageReceiver::Message4); - assertEqual(2, (long)msg.GetListeners().size()); - - msg.Send(1, 5.4f, -1.0f, true); - assert(receiver.received && receiver2.received); - - receiver.received = false; - receiver2.received = false; - msg -= Delegate(&receiver, &MessageReceiver::Message4); - assertEqual(1, (long)msg.GetListeners().size()); - - msg.Send(1, 0.2f, 12.0f, true); - assert(receiver.received == false && receiver2.received); - } - - void MessageTest::TestMessage4WithReturn() - { - berry::Message4 msg; - - MessageReceiver receiver; - typedef berry::MessageDelegate4 Delegate; - msg += Delegate(&receiver, &MessageReceiver::Message4WithReturn); - msg(1, 4.1f, -1, true); - assert(receiver.received); - - receiver.received = false; - typedef berry::Message4::ListenerList Listeners; - const Listeners& listeners = msg.GetListeners(); - bool valueReturned = false; - for (Listeners::const_iterator iter = listeners.begin(); - iter != listeners.end(); ++iter) - { - valueReturned = (*iter)->Execute(1, -34.21f, 2, true); - if (valueReturned) break; - } - assert(valueReturned); - } - - -} diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryMessageTest.h b/Plugins/Testing/org.blueberry.osgi.tests/src/berryMessageTest.h deleted file mode 100644 index 9ef394df41..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryMessageTest.h +++ /dev/null @@ -1,44 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYMESSAGETEST_H_ -#define BERRYMESSAGETEST_H_ - -#include - -namespace berry { - -class MessageTest : public TestCase { - -public: - - MessageTest(const std::string& testName); - - static CppUnit::Test* Suite(); - - void TestMessage(); - void TestMessageWithReturn(); - void TestMessage1(); - void TestMessage1WithReturn(); - void TestMessage2(); - void TestMessage2WithReturn(); - void TestMessage3(); - void TestMessage3WithReturn(); - void TestMessage4(); - void TestMessage4WithReturn(); - -}; - -} - -#endif /* BERRYMESSAGETEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.cpp b/Plugins/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.cpp deleted file mode 100644 index 5b9c1cfea5..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#include -#include -#include - -#include "berryOSGiCoreTestSuite.h" - -#include "berryObjectTest.h" -#include "berrySmartPointerTest.h" -#include "berryWeakPointerTest.h" -#include "berryMessageTest.h" - -namespace berry { - -OSGiCoreTestSuite::OSGiCoreTestSuite() -: CppUnit::TestSuite("OSGiCoreTestSuite") -{ - addTest(ObjectTest::Suite()); - addTest(SmartPointerTest::Suite()); - addTest(WeakPointerTest::Suite()); - addTest(MessageTest::Suite()); -} - -OSGiCoreTestSuite::OSGiCoreTestSuite(const OSGiCoreTestSuite& other) -{ - Q_UNUSED(other) -} - -} diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.h b/Plugins/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.h deleted file mode 100644 index fe203aaf5c..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryOSGiCoreTestSuite.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYOSGICORETESTSUITE_H_ -#define BERRYOSGICORETESTSUITE_H_ - -#include - -#include - -Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test") - -namespace berry { - -class OSGiCoreTestSuite : public QObject, public CppUnit::TestSuite -{ - Q_OBJECT - Q_INTERFACES(CppUnit::Test) - -public: - - OSGiCoreTestSuite(); - OSGiCoreTestSuite(const OSGiCoreTestSuite& other); -}; - -} - -#endif /* BERRYOSGICORETESTSUITE_H_ */ diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryObjectTest.cpp b/Plugins/Testing/org.blueberry.osgi.tests/src/berryObjectTest.cpp deleted file mode 100755 index 4c9e0402d4..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryObjectTest.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryObjectTest.h" - -#include -#include -#include -//#include - -namespace berry -{ - -class TestObject: public Object -{ -public: - TestObject() : - Object() - { - } -}; - -/** - * used for listening to destroy events - */ -struct ObjectListener -{ - bool m_ObjectDeleted; - - ObjectListener() : - m_ObjectDeleted(false) - { - - } - - void DestroyListener() - { - m_ObjectDeleted = true; - } - -}; - -CppUnit::Test* ObjectTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("ObjectTest"); - - CppUnit_addTest(suite, ObjectTest, TestReferenceCount); - CppUnit_addTest(suite, ObjectTest, TestAddDestroyListener); - CppUnit_addTest(suite, ObjectTest, TestRemoveDestroyListener); - - return suite; -} - -ObjectTest::ObjectTest(const std::string& testName) : - TestCase(testName) -{ - -} - -void ObjectTest::TestReferenceCount() -{ - TestObject* obj = new TestObject(); - assertEqual(obj->GetReferenceCount(), 0); - - obj->Register(); - assertEqual(obj->GetReferenceCount(), 1); - - obj->SetReferenceCount(3); - assertEqual(obj->GetReferenceCount(), 3); - - obj->SetReferenceCount(0); -} - -void ObjectTest::TestAddDestroyListener() -{ - TestObject* obj = new TestObject(); - - ObjectListener objectListener; - - obj->AddDestroyListener(berry::MessageDelegate( - &objectListener, &ObjectListener::DestroyListener)); - delete obj; - assertEqual(true, objectListener.m_ObjectDeleted); -} - -void ObjectTest::TestRemoveDestroyListener() -{ - TestObject* obj = new TestObject(); - - ObjectListener objectListener; - - obj->AddDestroyListener(berry::MessageDelegate( - &objectListener, &ObjectListener::DestroyListener)); - obj->RemoveDestroyListener(berry::MessageDelegate( - &objectListener, &ObjectListener::DestroyListener)); - delete obj; - assertEqual(false, objectListener.m_ObjectDeleted); -} - -} diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryObjectTest.h b/Plugins/Testing/org.blueberry.osgi.tests/src/berryObjectTest.h deleted file mode 100644 index 78cdd44d83..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryObjectTest.h +++ /dev/null @@ -1,36 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYOBJECTTEST_H_ -#define BERRYOBJECTTEST_H_ - -#include - -namespace berry { - -class ObjectTest : public TestCase -{ -public: - - static CppUnit::Test* Suite(); - - ObjectTest(const std::string& testName); - - void TestReferenceCount(); - void TestAddDestroyListener(); - void TestRemoveDestroyListener(); -}; - -} - -#endif /* BERRYOBJECTTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.cpp b/Plugins/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.cpp deleted file mode 100644 index 56bfcaf1fb..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include "berryPluginActivator.h" -#include "berryOSGiCoreTestSuite.h" - -namespace berry { - -void org_blueberry_osgi_tests_Activator::start(ctkPluginContext* context) -{ - Q_UNUSED(context) - - BERRY_REGISTER_EXTENSION_CLASS(OSGiCoreTestSuite, context) -} - -void org_blueberry_osgi_tests_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.h b/Plugins/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.h deleted file mode 100644 index ff480c83e5..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryPluginActivator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYPLUGINACTIVATOR_H -#define BERRYPLUGINACTIVATOR_H - -#include -#include - -namespace berry { - -class org_blueberry_osgi_tests_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_blueberry_osgi_tests") - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; - -typedef org_blueberry_osgi_tests_Activator PluginActivator; - -} - -#endif // BERRYPLUGINACTIVATOR_H diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.cpp b/Plugins/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.cpp deleted file mode 100755 index 7db7b57055..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#include "berrySmartPointerTest.h" - -#include -#include - -#include -#include -#include - -#include -//#include - -namespace berry -{ - -class TestObject : public berry::Object -{ -public: - TestObject() : Object(), m_Val(0) {} - TestObject(int value) : m_Val(value) {} - - bool operator==(const Object* o) const - { - if (const TestObject* to = dynamic_cast(o)) - return m_Val == to->m_Val; - - return false; - } - -private: - - int m_Val; -}; - - -SmartPointerTest::SmartPointerTest(const std::string& testName) -: TestCase(testName) -{} - -CppUnit::Test* SmartPointerTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("SmartPointerTest"); - - CppUnit_addTest(suite, SmartPointerTest, TestConstructors); - CppUnit_addTest(suite, SmartPointerTest, TestCasting); - CppUnit_addTest(suite, SmartPointerTest, TestReferenceCounting); - CppUnit_addTest(suite, SmartPointerTest, TestOperators); - - return suite; -} - - - void SmartPointerTest::TestConstructors() - { - { - // standard constructor - berry::SmartPointer testobj; - assertNullPtr(testobj.GetPointer()); - } - - - { - // standard pointer constructor - berry::SmartPointer testobj(new TestObject()); - assertNotNullPtr(testobj.GetPointer()); - assertEqual(1, testobj->GetReferenceCount()); - - // copy constructor - berry::SmartPointer testobj2 = testobj; - assertEqual(testobj.GetPointer(), testobj2.GetPointer()); - assertEqual(2, testobj2->GetReferenceCount()); - } - - { - // WeakPointer constructor - berry::WeakPointer ptr_weak; - try { - berry::SmartPointer testobj(ptr_weak); - failmsg("this should throw a BadWeakPointerException"); - } - catch (BadWeakPointerException ) - { - // expected - } - } - - { - // const_cast template constructor - berry::SmartPointer testobj(new TestObject()); - berry::SmartPointer obj(testobj); - assertNotNullPtr(obj.GetPointer()); - assertEqual(2, obj->GetReferenceCount()); - assert(typeid(*(obj.GetPointer())) == typeid(TestObject)); - } - } - - void SmartPointerTest::TestCasting() - // cast tests - { - berry::SmartPointer obj(new TestObject()); - assertNotNullPtr(obj.GetPointer()); - assertEqual(1, obj->GetReferenceCount()); - - berry::SmartPointer testobj = obj.Cast(); - assertNotNullPtr(testobj.GetPointer()); - assertEqual(2, testobj->GetReferenceCount()); - assertEqual(testobj.GetPointer(), obj.GetPointer()); - } - - void SmartPointerTest::TestReferenceCounting() - // reference count tests - { - berry::SmartPointer obj(new TestObject()); - { - berry::SmartPointer tmpobj = obj; - } - assertEqual(1, obj->GetReferenceCount()); - } - - void SmartPointerTest::TestOperators() - { - // operator tests - { - berry::SmartPointer obj(new TestObject(1)); - berry::SmartPointer testobj(new TestObject(2)); - berry::SmartPointer nullobj; - - // boolean conversions - assert(obj.IsNotNull()); - assert(false == obj.IsNull()); - assert(obj); - assert(false == !obj); - - // != operators - assert(obj != 0); - - try - { - obj != 1; - failmsg("should throw a std::invalid_argument exception"); - } - catch (std::invalid_argument) - { //expectted } - - } - - // operator!=(R) - assert(obj != testobj.GetPointer()); - - // operator!=(const berry::SmartPointer&) - assert(obj != testobj); - - // == operators - // operator==(int) - assert((obj == 0) == false); - try { - obj == 1; - failmsg("should throw a std::invalid_argument exception"); - } - catch (std::invalid_argument) - { // expected } - - } - // operator==(R) - assert((obj == testobj.GetPointer()) == false); - // operator==(R) - assert(obj == obj.GetPointer()); - // operator==(R) - assert((obj == nullobj.GetPointer()) == false); - // operator==(const berry::SmartPointer&) - assert((obj == testobj) == false); - // operator==(const berry::SmartPointer&) - assert(obj == obj); - // operator==(const berry::SmartPointer&) - assert((obj == nullobj) == false); - } - - { - // = operators - berry::SmartPointer obj(new TestObject(1)); - berry::SmartPointer testobj(new TestObject(2)); - - obj = testobj; - // operator=(const berry::SmartPointer&) - assert(obj == testobj); - assertEqual(2, obj->GetReferenceCount()); - - // operator=(Object*) - obj = testobj.GetPointer(); - assert(obj == testobj); - assertEqual(2, obj->GetReferenceCount()); - } - -} - -} diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.h b/Plugins/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.h deleted file mode 100644 index a31b1def1c..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berrySmartPointerTest.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYSMARTPOINTERTEST_H_ -#define BERRYSMARTPOINTERTEST_H_ - -#include - -namespace berry { - -class SmartPointerTest : public TestCase -{ -public: - - SmartPointerTest(const std::string& testName); - - static CppUnit::Test* Suite(); - - void TestConstructors(); - void TestCasting(); - void TestReferenceCounting(); - void TestOperators(); - -}; - -} - -#endif /* BERRYSMARTPOINTERTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.cpp b/Plugins/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.cpp deleted file mode 100644 index 095cb240ba..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include -#include -#include -#include -//#include - -#include "berryWeakPointerTest.h" - -#include -#include - -namespace berry -{ - -struct TestObject: public Object -{ - - /** creating a test object in order to test the weakpointer functions */ - - TestObject() - { } - -}; - -WeakPointerTest::WeakPointerTest(const std::string& testName) : - TestCase(testName) -{ - -} - -CppUnit::Test* WeakPointerTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("WeakPointerTest"); - - CppUnit_addTest(suite, WeakPointerTest, TestReferenceCounting); - CppUnit_addTest(suite, WeakPointerTest, TestConstructorAndLock); - CppUnit_addTest(suite, WeakPointerTest, TestOperators); - - return suite; -} - -void WeakPointerTest::TestReferenceCounting() -{ - - SmartPointer ptr_smart(new TestObject()); - - WeakPointer ptr_weak(ptr_smart); - assertEqual(1, ptr_smart->GetReferenceCount()); - - /* Testing the Object reference counter after returning a smartpointer - * to an object, Reference counter should be increased to 2 */ - SmartPointer ptr_smart2(ptr_weak); - assertEqual(2, ptr_smart->GetReferenceCount()); -} - -void WeakPointerTest::TestConstructorAndLock() -{ - SmartPointer* ptr_smart = new SmartPointer ( - new TestObject); - WeakPointer ptr_weak(*ptr_smart); - WeakPointer ptr_weak2(ptr_weak); - { - SmartPointer ptr_smart1(ptr_weak); - SmartPointer ptr_smart2(ptr_weak2); - assertEqual(ptr_smart1.GetPointer(), ptr_smart2.GetPointer()); - } - assertEqual(1, (*ptr_smart)->GetReferenceCount()); - delete ptr_smart; - assert(ptr_weak2.Lock() == 0); -} - -void WeakPointerTest::TestOperators() -{ - SmartPointer ptr_smart(new TestObject); - SmartPointer ptr_smart2(new TestObject); - { - WeakPointer ptr_weak(ptr_smart); - WeakPointer ptr_weak2(ptr_smart2); - ptr_weak = ptr_weak2; - SmartPointer ptr_smart3(ptr_weak2); - SmartPointer ptr_smart4(ptr_weak); - assertEqual(ptr_smart3.GetPointer(), ptr_smart4.GetPointer()); - } -} - -} diff --git a/Plugins/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.h b/Plugins/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.h deleted file mode 100644 index 49999b0e39..0000000000 --- a/Plugins/Testing/org.blueberry.osgi.tests/src/berryWeakPointerTest.h +++ /dev/null @@ -1,36 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYWEAKPOINTERTEST_H_ -#define BERRYWEAKPOINTERTEST_H_ - -#include - -namespace berry { - -class WeakPointerTest : public TestCase -{ -public: - - WeakPointerTest(const std::string& testName); - - static CppUnit::Test* Suite(); - - void TestReferenceCounting(); - void TestConstructorAndLock(); - void TestOperators(); -}; - -} - -#endif /* BERRYWEAKPOINTERTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/CMakeLists.txt b/Plugins/Testing/org.blueberry.ui.tests/CMakeLists.txt deleted file mode 100644 index f57bb14965..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -project(org_blueberry_ui_tests) - -mitk_create_plugin( - EXPORT_DIRECTIVE BERRY_UI_TESTS - TEST_PLUGIN -) - -target_link_libraries(${PROJECT_NAME} optimized CppUnit debug CppUnitd) - -add_dependencies(${PROJECT_NAME} org_blueberry_ui_qt) - -MACRO_TEST_UIPLUGIN() diff --git a/Plugins/Testing/org.blueberry.ui.tests/documentation/doxygen/modules.dox b/Plugins/Testing/org.blueberry.ui.tests/documentation/doxygen/modules.dox deleted file mode 100644 index 8cbf496b3a..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_blueberry_ui_tests org.blueberry.ui.tests - \ingroup BlueBerryPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_blueberry_ui_tests_internal Internal - \ingroup org_blueberry_ui_tests - - \brief This subcategory includes the internal classes of the org.blueberry.ui.tests plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Plugins/Testing/org.blueberry.ui.tests/files.cmake b/Plugins/Testing/org.blueberry.ui.tests/files.cmake deleted file mode 100644 index 2bc694a110..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/files.cmake +++ /dev/null @@ -1,45 +0,0 @@ -set(MOC_H_FILES - src/berryPluginActivator.h - src/berryUiTestSuite.h - - src/api/berryMockViewPart.h - src/api/berrySaveableMockViewPart.h -) - -set(CACHED_RESOURCE_FILES - plugin.xml - icons/view.gif -) - -set(SRC_CPP_FILES - - berryPluginActivator.cpp - berryUiTestSuite.cpp - - # API Tests - api/berryIPageLayoutTest.cpp - api/berryIViewPartTest.cpp - api/berryIWorkbenchPartTest.cpp - api/berryMockSelectionProvider.cpp - api/berryMockViewPart.cpp - api/berryMockWorkbenchPart.cpp - api/berrySaveableMockViewPart.cpp - api/berryUiApiTestSuite.cpp - api/berryXMLMementoTest.cpp - -) - -set(INTERNAL_CPP_FILES - -) - -set(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/Plugins/Testing/org.blueberry.ui.tests/icons/view.gif b/Plugins/Testing/org.blueberry.ui.tests/icons/view.gif deleted file mode 100755 index efc77a7f75..0000000000 Binary files a/Plugins/Testing/org.blueberry.ui.tests/icons/view.gif and /dev/null differ diff --git a/Plugins/Testing/org.blueberry.ui.tests/manifest_headers.cmake b/Plugins/Testing/org.blueberry.ui.tests/manifest_headers.cmake deleted file mode 100644 index a62f14f395..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "UI Automated Tests") -set(Plugin-Version "0.9") -set(Plugin-Vendor "German Cancer Research Center (DKFZ)") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.blueberry.uitest) - diff --git a/Plugins/Testing/org.blueberry.ui.tests/plugin.xml b/Plugins/Testing/org.blueberry.ui.tests/plugin.xml deleted file mode 100644 index d3902f6dfc..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/plugin.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.cpp deleted file mode 100644 index f7ab8f4ee7..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryIPageLayoutTest.h" - -#include -#include - -#include - -namespace berry -{ - -IPageLayoutTest::IPageLayoutTest(const std::string& testName) : - UITestCase(testName) -{ - -} - -CppUnit::Test* IPageLayoutTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("IPageLayoutTest"); - - CppUnit_addTest(suite, IPageLayoutTest, TestGetDescriptor); - - return suite; -} - -void IPageLayoutTest::TestGetDescriptor() -{ - this->IgnoreLeakingObjects(); - //this->LeakDetailsOn(); - - EmptyPerspective::SetLastPerspective(""); - OpenTestWindow(EmptyPerspective::PERSP_ID); - assertEqual(EmptyPerspective::PERSP_ID, EmptyPerspective::GetLastPerspective()); -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.h deleted file mode 100644 index 6fb416f071..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIPageLayoutTest.h +++ /dev/null @@ -1,44 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYIPAGELAYOUTTEST_H_ -#define BERRYIPAGELAYOUTTEST_H_ - -#include - -#include - -namespace berry { - -/** - * Test cases for the IPageLayout API. - * - * @since 3.2 - */ -class IPageLayoutTest : public UITestCase { - -public: - - friend class CppUnit::TestCaller; - - IPageLayoutTest(const std::string& testName); - - static CppUnit::Test* Suite(); - - void TestGetDescriptor(); - -}; - -} - -#endif /* BERRYIPAGELAYOUTTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.cpp deleted file mode 100644 index 1ef4c88b2b..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryIViewPartTest.h" - -#include "berrySaveableMockViewPart.h" - -#include - -#include - -namespace berry -{ - -IViewPartTest::IViewPartTest(const std::string& testName) : - IWorkbenchPartTest(testName) -{ - -} - -CppUnit::Test* IViewPartTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("IViewPartTest"); - - CppUnit_addTest(suite, IViewPartTest, TestOpenAndCloseSaveNotNeeded); - CppUnit_addTest(suite, IViewPartTest, TestOpenAndClose); - CppUnit_addTest(suite, IViewPartTest, TestOpenAndWindowClose); - - return suite; -} - -void IViewPartTest::TestOpenAndCloseSaveNotNeeded() -{ - this->IgnoreLeakingObjects(); - //this->LeakDetailsOn(); - - CallHistory::Pointer history; - - { - // Open a part. - SaveableMockViewPart::Pointer part = fPage->ShowView( - SaveableMockViewPart::ID).Cast (); - - part->SetDirty(true); - part->SetSaveNeeded(false); - ClosePart(fPage, part); - - history = part->GetCallHistory(); - } - - // TODO: This verifies the 3.0 disposal order. However, there may be a bug here. - // That is, it may be necessary to change this and dispose the contribution items - // after the view's dispose method in order to ensure that the site is never returning - // a disposed contribution item. See bug 94457 for details. - std::vector callOrder; - callOrder.push_back("SetInitializationData"); - callOrder.push_back("Init"); - callOrder.push_back("CreatePartControl"); - callOrder.push_back("SetFocus"); - callOrder.push_back("IsSaveOnCloseNeeded"); - callOrder.push_back("WidgetDisposed"); - //callOrder.push_back("ToolbarContributionItemWidgetDisposed"); - //callOrder.push_back("ToolbarContributionItemDisposed"); - callOrder.push_back("PartDestructor"); - assert(history->VerifyOrder(callOrder)); - // TODO enable assert when saveable support is complete - //assert(history->Contains("DoSave")); -} - -MockWorkbenchPart::Pointer IViewPartTest::OpenPart(IWorkbenchPage::Pointer page) -{ - return page->ShowView(MockViewPart::ID).Cast (); -} - -void IViewPartTest::ClosePart(IWorkbenchPage::Pointer page, - MockWorkbenchPart::Pointer part) -{ - page->HideView(part.Cast ()); -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.h deleted file mode 100644 index d9cf70d068..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIViewPartTest.h +++ /dev/null @@ -1,68 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYIVIEWPARTTEST_H_ -#define BERRYIVIEWPARTTEST_H_ - -#include "berryIWorkbenchPartTest.h" - -#include - -namespace berry -{ - -/** - * This is a test for IViewPart. Since IViewPart is an - * interface this test verifies the IViewPart lifecycle rather - * than the implementation. - */ -class IViewPartTest: public IWorkbenchPartTest -{ - -public: - - friend class CppUnit::TestCaller; - - /** - * Constructor for IViewPartTest - */ - IViewPartTest(const std::string& testName); - - static CppUnit::Test* Suite(); - - /** - * Tests that the view is closed without saving if isSaveOnCloseNeeded() - * returns false. This also tests some disposal behaviors specific to - * views: namely, that the contribution items are disposed in the correct - * order with respect to the disposal of the view. - * - * @see ISaveablePart#isSaveOnCloseNeeded() - */ - void TestOpenAndCloseSaveNotNeeded(); - -protected: - - /** - * @see IWorkbenchPartTest#openPart(IWorkbenchPage) - */ - MockWorkbenchPart::Pointer OpenPart(IWorkbenchPage::Pointer page); - - /** - * @see IWorkbenchPartTest#closePart(IWorkbenchPage, MockWorkbenchPart) - */ - void ClosePart(IWorkbenchPage::Pointer page, MockWorkbenchPart::Pointer part); - -}; - -} - -#endif /* BERRYIVIEWPARTTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.cpp deleted file mode 100644 index 691de05bb3..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryIWorkbenchPartTest.h" - -namespace berry -{ - -void IWorkbenchPartTest::DoSetUp() -{ - UITestCase::DoSetUp(); - fWindow = OpenTestWindow(); - fPage = fWindow->GetActivePage(); -} - -void IWorkbenchPartTest::DoTearDown() -{ - fPage = 0; - fWindow = 0; - UITestCase::DoTearDown(); -} - -IWorkbenchPartTest::IWorkbenchPartTest(const std::string& testName) : - UITestCase(testName) -{ - -} - -void IWorkbenchPartTest::TestOpenAndClose() -{ - this->IgnoreLeakingObjects(); - - CallHistory::Pointer history; - std::vector callOrder; - { - // Open a part. - MockWorkbenchPart::Pointer part = OpenPart(fPage); - assert(part->IsSiteInitialized()); - history = part->GetCallHistory(); - - callOrder.push_back("SetInitializationData"); - callOrder.push_back("Init"); - callOrder.push_back("CreatePartControl"); - callOrder.push_back("SetFocus"); - - assert(history->VerifyOrder(callOrder)); - - // Close the part. - ClosePart(fPage, part); - } - - callOrder.push_back("WidgetDisposed"); - callOrder.push_back("PartDestructor"); - assert(history->VerifyOrder(callOrder)); -} - -void IWorkbenchPartTest::TestOpenAndWindowClose() -{ - this->IgnoreLeakingObjects(); - - CallHistory::Pointer history; - std::vector callOrder; - { - // Open a new window - IWorkbenchWindow::Pointer newWindow = OpenTestWindow(); - - // Open a part. - MockWorkbenchPart::Pointer part = OpenPart(newWindow->GetActivePage()); - assert(part->IsSiteInitialized()); - history = part->GetCallHistory(); - - callOrder.push_back("SetInitializationData"); - callOrder.push_back("Init"); - callOrder.push_back("CreatePartControl"); - callOrder.push_back("SetFocus"); - - assert(history->VerifyOrder(callOrder)); - - // Close the window. - newWindow->Close(); - } - - // The Qt widget for the window is deleted - // asynchronously, so the "WidgetDisposed" - // call may come after the part destructor - //callOrder.push_back("WidgetDisposed"); - callOrder.push_back("PartDestructor"); - assert(history->VerifyOrder(callOrder)); -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.h deleted file mode 100644 index 5ff79c661a..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryIWorkbenchPartTest.h +++ /dev/null @@ -1,65 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYIWORKBENCHPARTTEST_H_ -#define BERRYIWORKBENCHPARTTEST_H_ - -#include -#include -#include - -#include "berryMockWorkbenchPart.h" - -namespace berry { - -/** - * This is a test for IWorkbenchPart. Since IWorkbenchPart is an - * interface this test verifies the IWorkbenchPart lifecycle rather - * than the implementation. - */ -class IWorkbenchPartTest : public UITestCase { - -protected: - - IWorkbenchWindow::Pointer fWindow; - IWorkbenchPage::Pointer fPage; - - void DoSetUp(); - void DoTearDown(); - - /** - * Opens a part. Subclasses should override - */ - virtual MockWorkbenchPart::Pointer OpenPart(IWorkbenchPage::Pointer page) = 0; - - /** - * Closes a part. Subclasses should override - */ - virtual void ClosePart(IWorkbenchPage::Pointer page, MockWorkbenchPart::Pointer part) = 0; - -public: - - /** - * Constructor for IActionDelegateTest - */ - IWorkbenchPartTest(const std::string& testName); - - void TestOpenAndClose(); - - void TestOpenAndWindowClose(); - -}; - -} - -#endif /* BERRYIWORKBENCHPARTTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.cpp deleted file mode 100644 index 5a15443c7e..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryMockSelectionProvider.h" - -namespace berry -{ - -struct EmptyStructuredSelection : public IStructuredSelection -{ - - EmptyStructuredSelection() - : elements(new ContainerType()) - {} - - Object::Pointer GetFirstElement() const - { - return Object::Pointer(0); - } - - iterator Begin() const - { - return elements->begin(); - } - - iterator End() const - { - return elements->end(); - } - - int Size() const - { - return elements->size(); - } - - bool IsEmpty() const - { - return true; - } - - ContainerType::Pointer ToVector() const - { - return elements; - } - -private: - - ContainerType::Pointer elements; -}; - -MockSelectionProvider::MockSelectionProvider() -: emptySelection(new EmptyStructuredSelection()) -{ - -} - -void MockSelectionProvider::FireSelection() -{ - SelectionChangedEvent::Pointer event(new SelectionChangedEvent( - ISelectionProvider::Pointer(this), emptySelection)); - FireSelection(event); -} - -void MockSelectionProvider::FireSelection(SelectionChangedEvent::Pointer event) -{ - listeners.selectionChanged(event); -} - -void MockSelectionProvider::AddSelectionChangedListener( - ISelectionChangedListener::Pointer listener) -{ - listeners.AddListener(listener); -} - -ISelection::ConstPointer MockSelectionProvider::GetSelection() const -{ - return emptySelection; -} - -void MockSelectionProvider::RemoveSelectionChangedListener( - ISelectionChangedListener::Pointer listener) -{ - listeners.RemoveListener(listener); -} - -void MockSelectionProvider::SetSelection(ISelection::Pointer /*selection*/) -{ -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.h deleted file mode 100644 index fe1b1c4473..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockSelectionProvider.h +++ /dev/null @@ -1,70 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYMOCKSELECTIONPROVIDER_H_ -#define BERRYMOCKSELECTIONPROVIDER_H_ - -#include -#include - -namespace berry -{ - -class MockSelectionProvider: public ISelectionProvider -{ - -private: - - ISelectionChangedListener::Events listeners; - IStructuredSelection::Pointer emptySelection; - -public: - - berryObjectMacro(MockSelectionProvider); - - MockSelectionProvider(); - - /** - * Fires out a selection to all listeners. - */ - void FireSelection(); - - /** - * Fires out a selection to all listeners. - */ - void FireSelection(SelectionChangedEvent::Pointer event); - - /** - * @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener) - */ - void AddSelectionChangedListener(ISelectionChangedListener::Pointer listener); - - /** - * @see ISelectionProvider#getSelection() - */ - ISelection::ConstPointer GetSelection() const; - - /** - * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener) - */ - void RemoveSelectionChangedListener( - ISelectionChangedListener::Pointer listener); - - /** - * @see ISelectionProvider#setSelection(ISelection) - */ - void SetSelection(ISelection::Pointer /*selection*/); -}; - -} - -#endif /* BERRYMOCKSELECTIONPROVIDER_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.cpp deleted file mode 100644 index 1e4403e480..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryMockViewPart.h" - -namespace berry -{ - -const std::string MockViewPart::ID = "org.blueberry.ui.tests.api.MockViewPart"; -const std::string MockViewPart::ID2 = MockViewPart::ID + "2"; -const std::string MockViewPart::ID3 = MockViewPart::ID + "3"; -const std::string MockViewPart::ID4 = MockViewPart::ID + "4"; -const std::string MockViewPart::IDMULT = MockViewPart::ID + "Mult"; -const std::string MockViewPart::NAME = "Mock View 1"; - -MockViewPart::MockViewPart() -{ - -} - -MockViewPart::MockViewPart(const MockViewPart& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -IViewSite::Pointer MockViewPart::GetViewSite() -{ - return GetSite().Cast (); -} - -void MockViewPart::Init(IViewSite::Pointer site, IMemento::Pointer /*memento*/) - throw (PartInitException) -{ - SetSite(site); - callTrace->Add("Init"); - SetSiteInitialized(); - //AddToolbarContributionItem(); -} - -void MockViewPart::CreatePartControl(void* parent) -{ - MockWorkbenchPart::CreatePartControl(parent); - - // Button addAction = new Button(parent, SWT.PUSH); - // addAction.setText("Add Action to Tool Bar"); - // addAction.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // IActionBars bars = getViewSite().getActionBars(); - // bars.getToolBarManager().add(new DummyAction()); - // bars.updateActionBars(); - // } - // }); - // - // Button removeAction = new Button(parent, SWT.PUSH); - // removeAction.setText("Remove Action from Tool Bar"); - // removeAction.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // IActionBars bars = getViewSite().getActionBars(); - // IToolBarManager tbm = bars.getToolBarManager(); - // IContributionItem[] items = tbm.getItems(); - // if (items.length > 0) { - // IContributionItem item = items[items.length-1]; - // if (item instanceof ActionContributionItem) { - // if (((ActionContributionItem) item).getAction() instanceof DummyAction) { - // tbm.remove(item); - // bars.updateActionBars(); - // } - // } - // } - // } - // }); -} - -MockViewPart::~MockViewPart() -{ - // // Test for bug 94457: The contribution items must still be in the toolbar manager at the - // // time the part is disposed. (Changing this behavior would be a breaking change for some - // // clients). - // Assert.assertTrue( - // "Contribution items should not be removed from the site until after the part is disposed", - // getViewSite().getActionBars().getToolBarManager().find( - // toolbarItem.getId()) == toolbarItem); -} - -void MockViewPart::ToolbarContributionItemWidgetDisposed() -{ - callTrace->Add("ToolbarContributionItemWidgetDisposed"); -} - -void MockViewPart::ToolbarContributionItemDisposed() -{ - callTrace->Add("ToolbarContributionItemDisposed"); -} - -void MockViewPart::SaveState(IMemento::Pointer /*memento*/) -{ - // do nothing -} - -IWorkbenchPartSite::Pointer MockViewPart::GetSite() const -{ - return MockWorkbenchPart::GetSite(); -} - -std::string MockViewPart::GetPartName() const -{ - return MockWorkbenchPart::GetPartName(); -} - -std::string MockViewPart::GetContentDescription() const -{ - return MockWorkbenchPart::GetContentDescription(); -} - -std::string MockViewPart::GetTitleToolTip() const -{ - return MockWorkbenchPart::GetTitleToolTip(); -} - -std::string MockViewPart::GetPartProperty(const std::string& key) const -{ - return MockWorkbenchPart::GetPartProperty(key); -} - -void MockViewPart::SetPartProperty(const std::string& key, - const std::string& value) -{ - MockWorkbenchPart::SetPartProperty(key, value); -} - -const std::map& MockViewPart::GetPartProperties() const -{ - return MockWorkbenchPart::GetPartProperties(); -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.h deleted file mode 100644 index 5067f2e3ad..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockViewPart.h +++ /dev/null @@ -1,150 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYMOCKVIEWPART_H_ -#define BERRYMOCKVIEWPART_H_ - -#include "berryMockWorkbenchPart.h" - -#include -#include - - -namespace berry -{ - -class MockViewPart: public QObject, public MockWorkbenchPart, public IViewPart -{ - Q_OBJECT - Q_INTERFACES(berry::IExecutableExtension berry::IViewPart) - -public: - - berryObjectMacro(MockViewPart); - - static const std::string ID; // = "org.blueberry.ui.tests.api.MockViewPart"; - static const std::string ID2; // = ID + "2"; - static const std::string ID3; // = ID + "3"; - static const std::string ID4; // = ID + "4"; - static const std::string IDMULT; // = ID + "Mult"; - static const std::string NAME; // = "Mock View 1"; - - MockViewPart(); - MockViewPart(const MockViewPart& other); - - /** - * @see IViewPart#getViewSite() - */ - IViewSite::Pointer GetViewSite(); - - /** - * @see IViewPart#Init(IViewSite, IMemento) - */ - void Init(IViewSite::Pointer site, IMemento::Pointer /*memento*/) - throw (PartInitException); - - /* (non-Javadoc) - * @see org.eclipse.ui.tests.api.MockWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - void CreatePartControl(void* parent); - - /* (non-Javadoc) - * @see org.eclipse.ui.tests.api.MockPart#dispose() - */ - ~MockViewPart(); - - void ToolbarContributionItemWidgetDisposed(); - - void ToolbarContributionItemDisposed(); - - /** - * @see IViewPart#saveState(IMemento) - */ - void SaveState(IMemento::Pointer /*memento*/); - - /** - * @see IWorkbenchPart#GetSite() - */ - IWorkbenchPartSite::Pointer GetSite() const; - - /** - * @see IWorkbenchPart#GetTitle() - */ - std::string GetPartName() const; - - std::string GetContentDescription() const; - - /** - * @see IWorkbenchPart#GetTitleToolTip() - */ - std::string GetTitleToolTip() const; - - std::string GetPartProperty(const std::string& key) const; - - void SetPartProperty(const std::string& key, const std::string& value); - - const std::map& GetPartProperties() const; - -private: - - // ContributionItem toolbarItem = new ContributionItem("someId") { - // - // private DisposeListener disposeListener = new DisposeListener() { - // public void widgetDisposed(DisposeEvent e) { - // toolbarContributionItemWidgetDisposed(); - // } - // - // public void fill(ToolBar parent, int index) { - // super.fill(parent, index); - // - // ToolItem item = new ToolItem(parent, index); - // - // item.addDisposeListener(disposeListener); - // item.setImage(WorkbenchImages.getImage(ISharedImages.IMG_DEF_VIEW)); - // } - // - // public void dispose() { - // toolbarContributionItemDisposed(); - // super.dispose(); - // } - // }; - // - // class DummyAction extends Action { - // public DummyAction() { - // setText("Monkey"); - // setImageDescriptor(getViewSite().getWorkbenchWindow() - // .getWorkbench().getSharedImages() - // .getImageDescriptor( - // ISharedImages.IMG_TOOL_DELETE)); - // } - // }; - // - // - // - // void AddToolbarContributionItem() { - // getViewSite().getActionBars().getToolBarManager().add(toolbarItem); - // } - - -protected: - - /* (non-Javadoc) - * @see org.eclipse.ui.tests.api.MockWorkbenchPart#getActionBars() - */ - // IActionBars GetActionBars() { - // return getViewSite().getActionBars(); - // } -}; - -} - -#endif /* BERRYMOCKVIEWPART_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.cpp deleted file mode 100644 index 4353c1fd5f..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryMockWorkbenchPart.h" - -#include -#include -#include -#include -#include -#include - -namespace berry -{ - -MockWorkbenchPart::MockWorkbenchPart() -: titleImage(0), parentWidget(0), - disposeListener(new GuiTk::ControlDestroyedAdapter(this, &MockWorkbenchPart::ControlDestroyed)) -, siteState(false) -{ - callTrace = new CallHistory(); - selectionProvider = new MockSelectionProvider(); -} - -void MockWorkbenchPart::SetSite(IWorkbenchPartSite::Pointer site) -{ - this->site = site; - site->SetSelectionProvider(selectionProvider); -} - -IWorkbenchPartSite::Pointer MockWorkbenchPart::GetSite() const -{ - return site; -} - -std::string MockWorkbenchPart::GetPartName() const -{ - return title; -} - -std::string MockWorkbenchPart::GetContentDescription() const -{ - return title; -} - -std::string MockWorkbenchPart::GetTitleToolTip() const -{ - return title; -} - -CallHistory::Pointer MockWorkbenchPart::GetCallHistory() const -{ - return callTrace; -} - -ISelectionProvider::Pointer MockWorkbenchPart::GetSelectionProvider() -{ - return selectionProvider; -} - -void MockWorkbenchPart::SetInitializationData( - IConfigurationElement::Pointer config, const std::string& /*propertyName*/, - Object::Pointer data) -{ - - callTrace->Add("SetInitializationData"); - - this->config = config; - this->data = data; - - // Icon. - std::string strIcon; - if (config->GetAttribute("icon", strIcon)) - { - ImageDescriptor::Pointer imageDesc = ImageDescriptor::CreateFromFile( - strIcon, config->GetContributor()); - titleImage = imageDesc->CreateImage(); - } - - config->GetAttribute("name", title); -} - -void MockWorkbenchPart::ControlDestroyed(GuiTk::ControlEvent::Pointer) -{ - callTrace->Add("WidgetDisposed"); - parentWidget = 0; -} - -void MockWorkbenchPart::AddPropertyListener( - IPropertyChangeListener::Pointer listener) -{ - propertyEvent.AddListener(listener); -} - -void MockWorkbenchPart::RemovePropertyListener( - IPropertyChangeListener::Pointer listener) -{ - propertyEvent.RemoveListener(listener); -} - -void MockWorkbenchPart::CreatePartControl(void* parent) -{ - callTrace->Add("CreatePartControl"); - - this->parentWidget = parent; - Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(parent, - disposeListener); -} - -MockWorkbenchPart::~MockWorkbenchPart() -{ - callTrace->Add("PartDestructor"); - - if (parentWidget) - { - Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(parentWidget, - disposeListener); - } -} - -void* MockWorkbenchPart::GetTitleImage() const -{ - return titleImage; -} - -void MockWorkbenchPart::SetFocus() -{ - callTrace->Add("SetFocus"); -} - -void MockWorkbenchPart::FireSelection() -{ - selectionProvider->FireSelection(); -} - -bool MockWorkbenchPart::IsSiteInitialized() -{ - return siteState; -} - -void MockWorkbenchPart::SetSiteInitialized() -{ - SetSiteInitialized( - // GetSite()->GetKeyBindingService() != 0 && - (GetSite()->GetPage() != 0) && (GetSite()->GetSelectionProvider() != 0) - && (GetSite()->GetWorkbenchWindow() != 0) // && - // TestActionBars(GetActionBars()) - ); -} - -IConfigurationElement::Pointer MockWorkbenchPart::GetConfig() -{ - return config; -} - -Object::Pointer MockWorkbenchPart::GetData() -{ - return data; -} - -void MockWorkbenchPart::FirePropertyChange(int propertyId) -{ - ObjectInt::Pointer value(new ObjectInt(propertyId)); - PropertyChangeEvent::Pointer event(new PropertyChangeEvent(Object::Pointer( - this), IWorkbenchPartConstants::INTEGER_PROPERTY, value, value)); - propertyEvent.propertyChange(event); -} - -void MockWorkbenchPart::SetSiteInitialized(bool initialized) -{ - siteState = initialized; -} - -std::string MockWorkbenchPart::GetPartProperty(const std::string& key) const -{ - std::map::const_iterator i = properties.find(key); - if (i != properties.end()) return i->second; - return ""; -} - -void MockWorkbenchPart::SetPartProperty(const std::string& key, - const std::string& value) -{ - properties[key] = value; -} - -const std::map& MockWorkbenchPart::GetPartProperties() const -{ - return properties; -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.h deleted file mode 100644 index 1884a4ef0b..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryMockWorkbenchPart.h +++ /dev/null @@ -1,191 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYWORKBENCHMOCKPART_H_ -#define BERRYWORKBENCHMOCKPART_H_ - -#include - -#include "berryMockSelectionProvider.h" - -#include -#include -#include -#include -#include -#include - -namespace berry -{ - -/** - * Base class for mock intro and workbench parts. - * - * @since 3.0 - */ -class MockWorkbenchPart: public virtual IWorkbenchPart, public IExecutableExtension -{ - -public: - - berryObjectMacro(MockWorkbenchPart); - - MockWorkbenchPart(); - - void SetSite(IWorkbenchPartSite::Pointer site); - - IWorkbenchPartSite::Pointer GetSite() const; - - /** - * @see IWorkbenchPart#GetPartName() - */ - std::string GetPartName() const; - - /** - * @see IWorkbenchPart#GetContentDescription() - */ - std::string GetContentDescription() const; - - /** - * @see IWorkbenchPart#getTitleToolTip() - */ - std::string GetTitleToolTip() const; - - CallHistory::Pointer GetCallHistory() const; - - ISelectionProvider::Pointer GetSelectionProvider(); - - void SetInitializationData(IConfigurationElement::Pointer config, - const std::string& /*propertyName*/, Object::Pointer data); - - // This isn't actually part of the part API, but we call this method from a dispose listener - // in order to mark the point in time at which the widgets are disposed - void ControlDestroyed(GuiTk::ControlEvent::Pointer e); - - /** - * @see IWorkbenchPart#addPropertyListener(IPropertyListener) - */ - void AddPropertyListener(IPropertyChangeListener::Pointer listener); - - /** - * @see IWorkbenchPart#removePropertyListener(IPropertyListener) - */ - void RemovePropertyListener(IPropertyChangeListener::Pointer listener); - - std::string GetPartProperty(const std::string& key) const; - - void SetPartProperty(const std::string& key, const std::string& value); - - const std::map& GetPartProperties() const; - - /** - * @see IWorkbenchPart#createPartControl(Composite) - */ - void CreatePartControl(void* parent); - - /** - * @see IWorkbenchPart#dispose() - */ - ~MockWorkbenchPart(); - - /** - * @see IWorkbenchPart#getTitleImage() - */ - void* GetTitleImage() const; - - /** - * @see IWorkbenchPart#setFocus() - */ - void SetFocus(); - - // /** - // * @see IAdaptable#getAdapter(Class) - // */ - // Object::Pointer GetAdapter(Class arg0) { - // return null; - // } - - /** - * Fires a selection out. - */ - void FireSelection(); - - /** - * Gets whether the site was properly initialized in the init method. - */ - bool IsSiteInitialized(); - -protected: - - CallHistory::Pointer callTrace; - - MockSelectionProvider::Pointer selectionProvider; - - // IActionBars GetActionBars() = 0; - - void SetSiteInitialized(); - - IConfigurationElement::Pointer GetConfig(); - - Object::Pointer GetData(); - - /** - * Fires a property change event. - */ - void FirePropertyChange(int propertyId); - - /** - * Sets whether the site was properly initialized in the init method. - */ - void SetSiteInitialized(bool initialized); - -private: - - IConfigurationElement::Pointer config; - - Object::Pointer data; - - void* titleImage; - - void* parentWidget; - - IWorkbenchPartSite::Pointer site; - - std::string title; - - IPropertyChangeListener::Events propertyEvent; - - GuiTk::IControlListener::Pointer disposeListener; - - /** - * boolean to declare whether the site was properly initialized in the init method. - */ - bool siteState; - - // /** - // * @param actionBars - // * @return - // */ - // bool TestActionBars(IActionBars bars) { - // return bars != null && bars.getMenuManager() != null - // && bars.getToolBarManager() != null - // && bars.getStatusLineManager() != null; - // - // } - - std::map properties; - -}; - -} - -#endif /* BERRYWORKBENCHMOCKPART_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.cpp deleted file mode 100644 index 585b0aa11f..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berrySaveableMockViewPart.h" - -namespace berry -{ - -const std::string SaveableMockViewPart::ID = - "org.blueberry.ui.tests.api.SaveableMockViewPart"; - -SaveableMockViewPart::SaveableMockViewPart() : - isDirty(false), saveAsAllowed(false), saveNeeded(true) -{ - -} - -SaveableMockViewPart::SaveableMockViewPart(const SaveableMockViewPart& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -void SaveableMockViewPart::CreatePartControl(void* parent) -{ - MockViewPart::CreatePartControl(parent); - - // final Button dirtyToggle = new Button(parent, SWT.CHECK); - // dirtyToggle.setText("Dirty"); - // dirtyToggle.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // setDirty(dirtyToggle.getSelection()); - // } - // }); - // dirtyToggle.setSelection(isDirty()); - // - // final Button saveNeededToggle = new Button(parent, SWT.CHECK); - // saveNeededToggle.setText("Save on close"); - // saveNeededToggle.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // setSaveNeeded(saveNeededToggle.getSelection()); - // } - // }); - // saveNeededToggle.setSelection(saveNeeded); - // - // final Button saveAsToggle = new Button(parent, SWT.CHECK); - // saveAsToggle.setText("Save as allowed"); - // saveAsToggle.addSelectionListener(new SelectionAdapter() { - // public void widgetSelected(SelectionEvent e) { - // setSaveAsAllowed(saveAsToggle.getSelection()); - // } - // }); - // saveAsToggle.setSelection(saveAsAllowed); -} - -void SaveableMockViewPart::DoSave(/*IProgressMonitor monitor*/) -{ - callTrace->Add("DoSave"); -} - -void SaveableMockViewPart::DoSaveAs() -{ - callTrace->Add("DoSaveAs"); -} - -bool SaveableMockViewPart::IsDirty() const -{ - callTrace->Add("IsDirty"); - return isDirty; -} - -bool SaveableMockViewPart::IsSaveAsAllowed() const -{ - callTrace->Add("IsSaveAsAllowed"); - return saveAsAllowed; -} - -bool SaveableMockViewPart::IsSaveOnCloseNeeded() const -{ - callTrace->Add("IsSaveOnCloseNeeded"); - return saveNeeded; -} - -void SaveableMockViewPart::SetDirty(bool isDirty) -{ - this->isDirty = isDirty; - FirePropertyChange(ISaveablePart::PROP_DIRTY); -} - -void SaveableMockViewPart::SetSaveAsAllowed(bool isSaveAsAllowed) -{ - this->saveAsAllowed = isSaveAsAllowed; -} - -void SaveableMockViewPart::SetSaveNeeded(bool isSaveOnCloseNeeded) -{ - this->saveNeeded = isSaveOnCloseNeeded; -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.h deleted file mode 100644 index 8c03683e5d..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berrySaveableMockViewPart.h +++ /dev/null @@ -1,88 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYSAVEABLEMOCKVIEWPART_H_ -#define BERRYSAVEABLEMOCKVIEWPART_H_ - -#include "berryMockViewPart.h" - -#include - -namespace berry -{ - -/** - * Mock view part that implements ISaveablePart. - * Used for testing hideView and other view lifecycle on saveable views. - * - * @since 3.0.1 - */ -class SaveableMockViewPart: public MockViewPart, public ISaveablePart -{ - Q_OBJECT - Q_INTERFACES(berry::ISaveablePart) - -public: - - berryObjectMacro(SaveableMockViewPart); - - static const std::string ID; // = "org.blueberry.ui.tests.api.SaveableMockViewPart"; - - SaveableMockViewPart(); - SaveableMockViewPart(const SaveableMockViewPart& other); - - void CreatePartControl(void* parent); - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) - */ - void DoSave(/*IProgressMonitor monitor*/); - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#doSaveAs() - */ - void DoSaveAs(); - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isDirty() - */ - bool IsDirty() const; - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() - */ - bool IsSaveAsAllowed() const; - - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() - */ - bool IsSaveOnCloseNeeded() const; - - void SetDirty(bool isDirty); - - void SetSaveAsAllowed(bool isSaveAsAllowed); - - void SetSaveNeeded(bool isSaveOnCloseNeeded); - -private: - - bool isDirty; - - bool saveAsAllowed; - - bool saveNeeded; - -}; - -} - -#endif /* BERRYSAVEABLEMOCKVIEWPART_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.cpp deleted file mode 100644 index 2d8a93e9d4..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryUiApiTestSuite.h" - -#include "berryXMLMementoTest.h" -#include "berryIPageLayoutTest.h" -#include "berryIViewPartTest.h" - -namespace berry { - -UiApiTestSuite::UiApiTestSuite() -: CppUnit::TestSuite("UiApiTestSuite") -{ - addTest(IPageLayoutTest::Suite()); - addTest(IViewPartTest::Suite()); - addTest(XMLMementoTest::Suite()); -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.h deleted file mode 100644 index 7ac2f07abe..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryUiApiTestSuite.h +++ /dev/null @@ -1,31 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYUIAPITESTSUITE_H_ -#define BERRYUIAPITESTSUITE_H_ - -#include - -namespace berry { - -class UiApiTestSuite : public CppUnit::TestSuite -{ - -public: - - UiApiTestSuite(); -}; - -} - -#endif /* BERRYUIAPITESTSUITE_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.cpp deleted file mode 100644 index 593ee46fe8..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.cpp +++ /dev/null @@ -1,749 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#define NOMINMAX - -#include "berryXMLMementoTest.h" - -#include -#include -#include -#include -#include - -namespace berry -{ - -struct PutMementoChecker: public XMLMementoTest::MementoChecker -{ - - PutMementoChecker(XMLMementoTest* t) : - mementoTest(t) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - mementoToSerialize->PutTextData("unchanged text data"); - mementoToSerialize->PutString("neverlost", "retained value"); - - IMemento::Pointer aMemento = XMLMemento::CreateWriteRoot("foo"); - mementoTest->FillMemento(aMemento); - - // note that this does not copy the text data: - mementoToSerialize->PutMemento(aMemento); - - // do not check for text data: - mementoTest->CheckMemento(mementoToSerialize, false); - - assertEqual("unchanged text data", mementoToSerialize->GetTextData()); - std::string str; - mementoToSerialize->GetString("neverlost", str); - assertEqual("retained value", str); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - // do not check for text data: - mementoTest->CheckMemento(deserializedMemento, false); - - assertEqual("unchanged text data", deserializedMemento - ->GetTextData()); - std::string str; - deserializedMemento->GetString("neverlost", str); - assertEqual("retained value", str); - } - -private: - - XMLMementoTest* mementoTest; -}; - -struct PutAndGetStringChecker: public XMLMementoTest::MementoChecker -{ - - PutAndGetStringChecker(const std::string& key, const std::string& value) : - key(key), value(value) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - std::string helper; - assertEqual(false, mementoToSerialize->GetString(key, helper)); - mementoToSerialize->PutString(key, value); - mementoToSerialize->GetString(key, helper); - assertEqual(value, helper); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - std::string helper; - deserializedMemento->GetString(key, helper); - assertEqual(value, helper); - } - -private: - const std::string& key; - const std::string& value; -}; - -struct CopyChildChecker: public XMLMementoTest::MementoChecker -{ - - CopyChildChecker(XMLMementoTest* t) : - mementoTest(t) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - IMemento::Pointer child = mementoToSerialize->CreateChild("c", "i"); - mementoTest->FillMemento(child); - IMemento::Pointer copiedChild = mementoToSerialize->CopyChild(child); - assertEqual("i", copiedChild->GetID()); - mementoTest->CheckMemento(copiedChild, true); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - IMemento::Pointer child = deserializedMemento->GetChild("c"); - mementoTest->CheckMemento(child, true); - std::vector children(deserializedMemento->GetChildren( - "c")); - assertEqual(2, (long)children.size()); - assertEqual("i", children[0]->GetID()); - mementoTest->CheckMemento(children[0], true); - assertEqual("i", children[1]->GetID()); - mementoTest->CheckMemento(children[1], true); - } - -private: - - XMLMementoTest* mementoTest; -}; - -struct CreateAndGetChildChecker: public XMLMementoTest::MementoChecker -{ - - CreateAndGetChildChecker() : - type1("type1"), type2("type2"), id("id") - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - // check that nothing is there yet - assertNullPtr(mementoToSerialize->GetChild(type1).GetPointer()); - assertNullPtr(mementoToSerialize->GetChild(type2).GetPointer()); - - // creation without ID - IMemento::Pointer child1 = mementoToSerialize->CreateChild(type1); - assertNotNullPtr(child1.GetPointer()); - assertNotNullPtr(mementoToSerialize->GetChild(type1).GetPointer()); - - // creation with ID - IMemento::Pointer child2 = mementoToSerialize->CreateChild(type2, id); - assertNotNullPtr(child2.GetPointer()); - assertNotNullPtr(mementoToSerialize->GetChild(type2).GetPointer()); - assertEqual(id, child2->GetID()); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - IMemento::Pointer child1 = deserializedMemento->GetChild(type1); - assertNotNullPtr(child1.GetPointer()); - IMemento::Pointer child2 = deserializedMemento->GetChild(type2); - assertNotNullPtr(child2.GetPointer()); - assertEqual(id, child2->GetID()); - } - -private: - - const std::string type1; - const std::string type2; - const std::string id; -}; - -struct GetChildrenChecker: public XMLMementoTest::MementoChecker -{ - - GetChildrenChecker() : - type("type"), id1("id"), id2("id2") - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - // check that nothing is there yet - assertNullPtr(mementoToSerialize->GetChild(type).GetPointer()); - - IMemento::Pointer child1 = mementoToSerialize->CreateChild(type, id1); - assertNotNullPtr(child1.GetPointer()); - assertNotNullPtr(mementoToSerialize->GetChild(type).GetPointer()); - assertEqual(id1, child1->GetID()); - - // second child with the same type - IMemento::Pointer child2 = mementoToSerialize->CreateChild(type, id2); - assertNotNullPtr(child2.GetPointer()); - assertEqual(2, (long)mementoToSerialize->GetChildren(type).size()); - assertEqual(id2, child2->GetID()); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - std::vector children(deserializedMemento->GetChildren( - type)); - assertEqual(2, (long)children.size()); - - // this checks that the order is maintained. - // the spec does not promise this, but clients - // may rely on the current implementation behaviour. - assertEqual(id1, children[0]->GetID()); - assertEqual(id2, children[1]->GetID()); - } - -private: - const std::string type; - const std::string id1; - const std::string id2; -}; - -struct GetIDChecker: public XMLMementoTest::MementoChecker -{ - - GetIDChecker(const std::string& type, const std::string& id) : - type(type), id(id) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - assertNullPtr(mementoToSerialize->GetChild(type).GetPointer()); - IMemento::Pointer child = mementoToSerialize->CreateChild(type, id); - assertEqual(id, child->GetID()); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - IMemento::Pointer child = deserializedMemento->GetChild(type); - assertNotNullPtr(child.GetPointer()); - assertEqual(id, child->GetID()); - } - -private: - - const std::string type; - const std::string id; -}; - -struct PutAndGetFloatChecker: public XMLMementoTest::MementoChecker -{ - - PutAndGetFloatChecker(const std::string& key, double value) : - key(key), value(value) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - double v; - assertEqual(false, mementoToSerialize->GetFloat(key, v)); - mementoToSerialize->PutFloat(key, value); - mementoToSerialize->GetFloat(key, v); - assertEqual(value, v); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - double v; - deserializedMemento->GetFloat(key, v); - assertEqual(value, v); - } - -private: - const std::string key; - const double value; -}; - -struct PutAndGetIntChecker: public XMLMementoTest::MementoChecker -{ - - PutAndGetIntChecker(const std::string& key, const int value) : - key(key), value(value) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - int v; - assertEqual(false, mementoToSerialize->GetInteger(key, v)); - mementoToSerialize->PutInteger(key, value); - mementoToSerialize->GetInteger(key, v); - assertEqual(value, v); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - int v; - deserializedMemento->GetInteger(key, v); - assertEqual(value, v); - } - -private: - const std::string key; - const int value; -}; - -struct PutAndGetTextDataChecker: public XMLMementoTest::MementoChecker -{ - - PutAndGetTextDataChecker(const std::string& data) : - data(data) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - assertEqual("", mementoToSerialize->GetTextData()); - mementoToSerialize->PutTextData(data); - assertEqual(data, mementoToSerialize->GetTextData()); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - assertEqual(data, deserializedMemento->GetTextData()); - } - -private: - const std::string data; -}; - -struct LegalKeysChecker: public XMLMementoTest::MementoChecker -{ - - LegalKeysChecker(const std::string& key) : - key(key) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - std::string v; - assertEqual(false, mementoToSerialize->GetString(key, v)); - try - { - mementoToSerialize->PutString(key, "some string"); - } catch (Poco::RuntimeException& ex) - { - std::cout << "offending key: '" + key + "'" << std::endl; - ex.rethrow(); - } - mementoToSerialize->GetString(key, v); - assertEqual("some string", v); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - std::string v; - deserializedMemento->GetString(key, v); - assertEqual("some string", v); - } - -private: - const std::string key; -}; - -struct PutTextDataWithChildrenChecker: public XMLMementoTest::MementoChecker -{ - - PutTextDataWithChildrenChecker(const std::string& textData) : - textData(textData) - { - } - - void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) - { - mementoToSerialize->CreateChild("type", "id"); - mementoToSerialize->PutTextData(textData); - mementoToSerialize->CreateChild("type", "id"); - mementoToSerialize->CreateChild("type", "id"); - assertEqual(textData, mementoToSerialize->GetTextData()); - } - - void CheckAfterDeserialization(XMLMemento::Pointer deserializedMemento) - { - assertEqual(textData, deserializedMemento->GetTextData()); - } - -private: - const std::string textData; -}; - -const std::string XMLMementoTest::TEST_STRINGS[10] = -{ "value", " value with spaces ", "value.with.many.dots", - "value_with_underscores", "valuewith>greaterthan", - "value&with&ersand", "value\"with\"quote", "value#with#hash", "", }; - -const unsigned int XMLMementoTest::TEST_STRINGS_LENGTH = 10; -/* - * the following cases are for bug 93720 - */ -// "\nvalue\nwith\nnewlines\n", "\tvalue\twith\ttab\t", -// "\rvalue\rwith\rreturn\r", }; - -CppUnit::Test* XMLMementoTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("XMLMementoTest"); - - CppUnit_addTest(suite, XMLMementoTest, TestPutMemento); - CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetString); - CppUnit_addTest(suite, XMLMementoTest, TestCreateReadRootReaderExceptionCases); - CppUnit_addTest(suite, XMLMementoTest, TestCreateReadRootReader); - CppUnit_addTest(suite, XMLMementoTest, TestCreateWriteRoot); - CppUnit_addTest(suite, XMLMementoTest, TestSpacesInRootAreIllegal); - CppUnit_addTest(suite, XMLMementoTest, TestSpacesInKeysAreIllegal); - CppUnit_addTest(suite, XMLMementoTest, TestCopyChild); - CppUnit_addTest(suite, XMLMementoTest, TestCreateAndGetChild); - CppUnit_addTest(suite, XMLMementoTest, TestGetChildren); - CppUnit_addTest(suite, XMLMementoTest, TestGetID); - CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetFloat); - CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetInteger); - CppUnit_addTest(suite, XMLMementoTest, TestPutAndGetTextData); - CppUnit_addTest(suite, XMLMementoTest, TestLegalKeys); - CppUnit_addTest(suite, XMLMementoTest, TestIllegalKeys); - CppUnit_addTest(suite, XMLMementoTest, TestPutTextDataWithChildren); - CppUnit_addTest(suite, XMLMementoTest, TestMementoWithTextContent); - - return suite; -} - -XMLMementoTest::XMLMementoTest(const std::string& testName) : - TestCase(testName) -{ - -} - -void XMLMementoTest::FillMemento(IMemento::Pointer memento) -{ - memento->PutFloat("floatKey", 0.4f); - memento->PutInteger("integerKey", 324765); - memento->PutString("stringKey", "a string"); - memento->PutTextData("some text data"); - memento->CreateChild("child1"); - memento->CreateChild("child2", "child2id1"); - memento->CreateChild("child2", "child2id2"); -} - -void XMLMementoTest::TestPutAndGet(MementoChecker& mementoChecker) - throw (Poco::IOException, WorkbenchException) -{ - XMLMemento::Pointer mementoToSerialize = XMLMemento::CreateWriteRoot( - "XMLMementoTest"); - - mementoChecker.PrepareAndCheckBeforeSerialization(mementoToSerialize); - - std::stringstream writer; - mementoToSerialize->Save(writer); - writer.flush(); - - XMLMemento::Pointer deserializedMemento = XMLMemento::CreateReadRoot(writer); - - mementoChecker.CheckAfterDeserialization(deserializedMemento); -} - -void XMLMementoTest::CheckMemento(IMemento::Pointer memento, - bool checkForTextData) -{ - double floatVal; - memento->GetFloat("floatKey", floatVal); - assertEqualDelta(0.4, floatVal, 0.0001); - - int intVal; - memento->GetInteger("integerKey", intVal); - assertEqual(324765, intVal); - - std::string strVal; - memento->GetString("stringKey", strVal); - assertEqual("a string", strVal); - - if (checkForTextData) - { - assertEqual("some text data", memento->GetTextData()); - } - - IMemento::Pointer child1 = memento->GetChild("child1"); - assertNotNullPtr(child1.GetPointer()); - IMemento::Pointer child2 = memento->GetChild("child2"); - assertNotNullPtr(child2.GetPointer()); - assertEqual("child2id1", child2->GetID()); - std::vector children(memento->GetChildren("child2")); - assertEqual(2, (long)children.size()); - assertEqual("child2id1", children[0]->GetID()); - assertEqual("child2id2", children[1]->GetID()); -} - -void XMLMementoTest::TestPutMemento() throw (WorkbenchException, - Poco::IOException) -{ - PutMementoChecker checker(this); - TestPutAndGet(checker); -} - -void XMLMementoTest::TestPutAndGetString() throw (Poco::IOException, - WorkbenchException) -{ - const std::string key = "key"; - - for (unsigned int i = 0; i < TEST_STRINGS_LENGTH; ++i) - { - const std::string value; - PutAndGetStringChecker checker(key, TEST_STRINGS[i]); - TestPutAndGet(checker); - } -} - -void XMLMementoTest::TestCreateReadRootReaderExceptionCases() -{ - try - { - std::stringstream ss("Invalid format"); - - XMLMemento::CreateReadRoot(ss); - failmsg("should throw WorkbenchException because of invalid format"); - } catch (WorkbenchException e) - { - // expected - } - try - { - std::stringstream ss(""); - XMLMemento::CreateReadRoot(ss); - failmsg("should throw WorkbenchException because there is no element"); - } catch (WorkbenchException e) - { - // expected - } - try - { - std::ifstream file("__123thisshouldnotexist_238waer"); - XMLMemento::CreateReadRoot(file); - failmsg("should throw WorkbenchException because of IOException"); - } catch (WorkbenchException e) - { - // expected - } -} - -void XMLMementoTest::TestCreateReadRootReader() throw (WorkbenchException) -{ - std::stringstream - ss( - "some text data"); - XMLMemento::Pointer memento = XMLMemento::CreateReadRoot(ss); - assertEqual("some text data", memento->GetTextData()); -} - -void XMLMementoTest::TestCreateWriteRoot() -{ - std::string rootTypes[] = - { "type", "type.with.dots", "type_with_underscores" }; - for (unsigned int i = 0; i < 3; i++) - { - XMLMemento::Pointer memento = XMLMemento::CreateWriteRoot(rootTypes[i]); - assertNotNullPtr(memento.GetPointer()); - } -} - -void XMLMementoTest::TestSpacesInRootAreIllegal() -{ - try - { - XMLMemento::CreateWriteRoot("with space"); - failmsg("should fail"); - } catch (std::exception& /*e*/) - { - // expected - } -} - -void XMLMementoTest::TestSpacesInKeysAreIllegal() -{ - XMLMemento::Pointer memento = XMLMemento::CreateWriteRoot("foo"); - try - { - memento->CreateChild("with space", "bar"); - failmsg("should fail"); - } catch (std::exception& /*e*/) - { - // expected - } - try - { - memento->PutString("with space", "bar"); - failmsg("should fail"); - } catch (std::exception& /*e*/) - { - // expected - } -} - -void XMLMementoTest::TestCopyChild() throw (WorkbenchException, - Poco::IOException) -{ - CopyChildChecker checker(this); - TestPutAndGet(checker); -} - -void XMLMementoTest::TestCreateAndGetChild() throw (WorkbenchException, - Poco::IOException) -{ - CreateAndGetChildChecker checker; - TestPutAndGet(checker); -} - -void XMLMementoTest::TestGetChildren() throw (WorkbenchException, - Poco::IOException) -{ - GetChildrenChecker checker; - TestPutAndGet(checker); -} - -void XMLMementoTest::TestGetID() throw (WorkbenchException, Poco::IOException) -{ - const std::string type = "type"; - - const std::string ids[] = - { "id", "", "id.with.many.dots", "id_with_underscores", "idwith>greaterthan", "id&with&ersand", "id\"with\"quote", - "id#with#hash" }; - - for (unsigned int i = 0; i < 9; i++) - { - GetIDChecker checker(type, ids[i]); - TestPutAndGet(checker); - } -} - -void XMLMementoTest::TestPutAndGetFloat() throw (WorkbenchException, - Poco::IOException) -{ - const std::string key = "key"; - - const double values[] = - { -3.1415, 1, 0, 4554.45235, std::numeric_limits::max(), - std::numeric_limits::min(), - std::numeric_limits::quiet_NaN(), - std::numeric_limits::infinity() }; - - for (unsigned int i = 0; i < 8; i++) - { - PutAndGetFloatChecker checker(key, values[i]); - TestPutAndGet(checker); - } -} - -void XMLMementoTest::TestPutAndGetInteger() throw (WorkbenchException, - Poco::IOException) -{ - const std::string key = "key"; - - const int values[] = - { 36254, 0, 1, -36254, std::numeric_limits::max(), std::numeric_limits< - int>::min() }; - - for (unsigned int i = 0; i < 6; i++) - { - PutAndGetIntChecker checker(key, values[i]); - TestPutAndGet(checker); - } - -} - -void XMLMementoTest::TestPutAndGetTextData() throw (WorkbenchException, - Poco::IOException) -{ - for (unsigned int i = 0; i < TEST_STRINGS_LENGTH; i++) - { - PutAndGetTextDataChecker checker(TEST_STRINGS[i]); - TestPutAndGet(checker); - } -} - -void XMLMementoTest::TestLegalKeys() throw (WorkbenchException, - Poco::IOException) -{ - const std::string legalKeys[] = - { "value", "value.with.many.dots", "value_with_underscores" }; - - for (unsigned int i = 0; i < 3; i++) - { - LegalKeysChecker checker(legalKeys[i]); - TestPutAndGet(checker); - } - -} - -void XMLMementoTest::TestIllegalKeys() throw () -{ - const std::string illegalKeys[] = - { "", " ", " key", "key ", "key key", "\t", "\tkey", "key\t", "key\tkey", - "\n", "\nkey", "key\n", "key\nkey", "keywith>greaterthan", "key&with&ersand", "key#with#hash", - "key\"with\"quote", "\"" }; - - for (unsigned int i = 0; i < 19; i++) - { - XMLMemento::Pointer memento = XMLMemento::CreateWriteRoot("foo"); - try - { - memento->PutString(illegalKeys[i], "some string"); - failmsg("putString with illegal key should fail"); - } catch (std::exception& /*ex*/) - { - // expected - } - } -} - -void XMLMementoTest::TestPutTextDataWithChildren() throw (WorkbenchException, - Poco::IOException) -{ - const std::string textData = - "\n\tThis is\ntext data\n\t\twith newlines and \ttabs\t\n\t "; - PutTextDataWithChildrenChecker checker(textData); - TestPutAndGet(checker); -} - -void XMLMementoTest::TestMementoWithTextContent() -{ - IMemento::Pointer memento = XMLMemento::CreateWriteRoot("root"); - IMemento::Pointer mementoWithChild = XMLMemento::CreateWriteRoot("root"); - IMemento::Pointer child = mementoWithChild->CreateChild("child"); - child->PutTextData("text"); - memento->PutMemento(mementoWithChild); - IMemento::Pointer copiedChild = memento->GetChild("child"); - assertEqual("text", copiedChild->GetTextData()); -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.h b/Plugins/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.h deleted file mode 100644 index 95e97680c9..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/api/berryXMLMementoTest.h +++ /dev/null @@ -1,129 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYXMLMEMENTOTEST_H_ -#define BERRYXMLMEMENTOTEST_H_ - -#include -#include - -namespace berry -{ - -/** - * Testing XMLMemento - * - */ -class XMLMementoTest: public TestCase -{ - -private: - - static const std::string TEST_STRINGS[10]; - static const unsigned int TEST_STRINGS_LENGTH; - -public: - - static CppUnit::Test* Suite(); - - XMLMementoTest(const std::string& testName); - - /* - * Class under test for XMLMemento createReadRoot(Reader) - */ - void TestCreateReadRootReaderExceptionCases(); - - void TestCreateReadRootReader() throw (WorkbenchException); - - /* - * Class under test for XMLMemento createReadRoot(Reader, String) - */ - // void testCreateReadRootReaderString() { - // // TODO - I don't know how to test this. The method is not called by - // // anyone as of 2005/04/05. - // } - - void TestCreateWriteRoot(); - - void TestSpacesInRootAreIllegal(); - - void TestSpacesInKeysAreIllegal(); - - void TestCopyChild() throw (WorkbenchException, Poco::IOException); - - /** - * Helper method to fill a memento to be checked later by checkMemento. - * - * @param memento - */ - void FillMemento(IMemento::Pointer memento); - - /** - * Helper method to check if the values set by fillMemento are still there. - * The boolean parameter is needed because in some cases - * (IMememento#putMemento), the text data gets lost. - * - * @param memento - * @param checkForTextData - */ - void CheckMemento(IMemento::Pointer memento, bool checkForTextData); - - void TestCreateAndGetChild() throw (WorkbenchException, Poco::IOException); - - void TestGetChildren() throw (WorkbenchException, Poco::IOException); - - void TestGetID() throw (WorkbenchException, Poco::IOException); - - void TestPutAndGetFloat() throw (WorkbenchException, Poco::IOException); - - void TestPutAndGetInteger() throw (WorkbenchException, Poco::IOException); - - void TestPutMemento() throw (WorkbenchException, Poco::IOException); - - void TestPutAndGetString() throw (Poco::IOException, WorkbenchException); - - void TestPutAndGetTextData() throw (WorkbenchException, Poco::IOException); - - void TestLegalKeys() throw (WorkbenchException, Poco::IOException); - - void TestIllegalKeys() throw (); - - void TestPutTextDataWithChildren() throw (WorkbenchException, - Poco::IOException); - - void TestMementoWithTextContent(); - - struct MementoChecker: public CppUnit::TestCase - { - - MementoChecker() : - CppUnit::TestCase("MementoChecker") - { - } - - virtual void PrepareAndCheckBeforeSerialization( - XMLMemento::Pointer mementoToSerialize) = 0; - - virtual void CheckAfterDeserialization( - XMLMemento::Pointer deserializedMemento) = 0; - }; - -private: - - void TestPutAndGet(MementoChecker& mementoChecker) throw (Poco::IOException, - WorkbenchException); - -}; - -} - -#endif /* BERRYXMLMEMENTOTEST_H_ */ diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/berryPluginActivator.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/berryPluginActivator.cpp deleted file mode 100644 index dceb56dca7..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/berryPluginActivator.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryPluginActivator.h" -#include "berryUiTestSuite.h" -#include "api/berryMockViewPart.h" -#include "api/berrySaveableMockViewPart.h" - -namespace berry { - -void org_blueberry_ui_tests_Activator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(UiTestSuite, context) - BERRY_REGISTER_EXTENSION_CLASS(MockViewPart, context) - BERRY_REGISTER_EXTENSION_CLASS(SaveableMockViewPart, context) -} - -void org_blueberry_ui_tests_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/berryPluginActivator.h b/Plugins/Testing/org.blueberry.ui.tests/src/berryPluginActivator.h deleted file mode 100644 index b5fbf8e676..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/berryPluginActivator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYPLUGINACTIVATOR_H -#define BERRYPLUGINACTIVATOR_H - -#include -#include - -namespace berry { - -class org_blueberry_ui_tests_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_blueberry_ui_tests") - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; - -typedef org_blueberry_ui_tests_Activator PluginActivator; - -} - -#endif // BERRYPLUGINACTIVATOR_H diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.cpp b/Plugins/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.cpp deleted file mode 100644 index a0c700e43f..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryUiTestSuite.h" - -#include "api/berryUiApiTestSuite.h" - -#include - -namespace berry { - -UiTestSuite::UiTestSuite() -: CppUnit::TestSuite("UiTestSuite") -{ - addTest(new UiApiTestSuite()); -} - -UiTestSuite::UiTestSuite(const UiTestSuite& other) -{ - Q_UNUSED(other); - throw std::runtime_error("Copy constructor not implemented"); -} - -} diff --git a/Plugins/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.h b/Plugins/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.h deleted file mode 100644 index 653efb08de..0000000000 --- a/Plugins/Testing/org.blueberry.ui.tests/src/berryUiTestSuite.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYUITESTSUITE_H_ -#define BERRYUITESTSUITE_H_ - -#include - -#include - -Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test") - -namespace berry { - -class UiTestSuite : public QObject, public CppUnit::TestSuite -{ - Q_OBJECT - Q_INTERFACES(CppUnit::Test) - -public: - - UiTestSuite(); - UiTestSuite(const UiTestSuite& other); -}; - -} - -#endif /* BERRYUITESTSUITE_H_ */ diff --git a/Plugins/org.blueberry.core.runtime/src/berryPlatform.cpp b/Plugins/org.blueberry.core.runtime/src/berryPlatform.cpp index 3224c85951..a30ccd79f3 100644 --- a/Plugins/org.blueberry.core.runtime/src/berryPlatform.cpp +++ b/Plugins/org.blueberry.core.runtime/src/berryPlatform.cpp @@ -1,250 +1,247 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "berryPlatform.h" #include #include "internal/berryInternalPlatform.h" #include "internal/berryIRuntimeConstants.h" #include namespace berry { const QString Platform::PI_RUNTIME = IRuntimeConstants::PI_RUNTIME(); const int Platform::OS_FREE_BSD = BERRY_OS_FREE_BSD; const int Platform::OS_AIX = BERRY_OS_AIX; const int Platform::OS_HPUX = BERRY_OS_HPUX; const int Platform::OS_TRU64 = BERRY_OS_TRU64; const int Platform::OS_LINUX = BERRY_OS_LINUX; const int Platform::OS_MAC_OS_X = BERRY_OS_MAC_OS_X; const int Platform::OS_NET_BSD = BERRY_OS_NET_BSD; const int Platform::OS_OPEN_BSD = BERRY_OS_OPEN_BSD; const int Platform::OS_IRIX = BERRY_OS_IRIX; const int Platform::OS_SOLARIS = BERRY_OS_SOLARIS; const int Platform::OS_QNX = BERRY_OS_QNX; const int Platform::OS_VXWORKS = BERRY_OS_VXWORKS; const int Platform::OS_CYGWIN = BERRY_OS_CYGWIN; const int Platform::OS_UNKNOWN_UNIX = BERRY_OS_UNKNOWN_UNIX; const int Platform::OS_WINDOWS_NT = BERRY_OS_WINDOWS_NT; const int Platform::OS_WINDOWS_CE = BERRY_OS_WINDOWS_CE; const int Platform::OS_VMS = BERRY_OS_VMS; const int Platform::ARCH_ALPHA = BERRY_ARCH_ALPHA; const int Platform::ARCH_IA32 = BERRY_ARCH_IA32; const int Platform::ARCH_IA64 = BERRY_ARCH_IA64; const int Platform::ARCH_MIPS = BERRY_ARCH_MIPS; const int Platform::ARCH_HPPA = BERRY_ARCH_HPPA; const int Platform::ARCH_PPC = BERRY_ARCH_PPC; const int Platform::ARCH_POWER = BERRY_ARCH_POWER; const int Platform::ARCH_SPARC = BERRY_ARCH_SPARC; const int Platform::ARCH_AMD64 = BERRY_ARCH_AMD64; const int Platform::ARCH_ARM = BERRY_ARCH_ARM; const QString Platform::PROP_QTPLUGIN_PATH = "BlueBerry.qtplugin_path"; const QString Platform::PROP_NEWINSTANCE = "BlueBerry.newInstance"; const QString Platform::PROP_APPLICATION = "BlueBerry.application"; const QString Platform::PROP_PLUGIN_DIRS = "BlueBerry.plugin_dirs"; const QString Platform::PROP_FORCE_PLUGIN_INSTALL = "BlueBerry.forcePlugins"; -const QString Platform::PROP_TESTPLUGIN = "BlueBerry.testplugin"; -const QString Platform::PROP_TESTAPPLICATION = "BlueBerry.testapplication"; - const QString Platform::PROP_IGNOREAPP = "BlueBerry.ignoreApp"; const QString Platform::PROP_XARGS = "xargs"; QDir Platform::GetConfigurationPath() { ctkLocation* location = GetConfigurationLocation(); if (location) { return location->getUrl().toLocalFile(); } return QDir(); } ctkLocation* Platform::GetConfigurationLocation() { return InternalPlatform::GetInstance()->GetConfigurationLocation(); } IAdapterManager* Platform::GetAdapterManager() { return InternalPlatform::GetInstance()->GetAdapterManager(); } IExtensionRegistry *Platform::GetExtensionRegistry() { return InternalPlatform::GetInstance()->GetExtensionRegistry(); } IPreferencesService *Platform::GetPreferencesService() { return InternalPlatform::GetInstance()->GetPreferencesService(); } //PlatformEvents& Platform::GetEvents() //{ // return InternalPlatform::GetInstance()->GetEvents(); //} QDir Platform::GetInstallPath() { ctkLocation* location = GetInstallLocation(); if (location) { return location->getUrl().toLocalFile(); } return QDir(); } ctkLocation* Platform::GetInstallLocation() { return InternalPlatform::GetInstance()->GetInstallLocation(); } QDir Platform::GetInstancePath() { ctkLocation* location = GetInstanceLocation(); if (location) { return location->getUrl().toLocalFile(); } return QDir(); } ctkLocation* Platform::GetInstanceLocation() { return InternalPlatform::GetInstance()->GetInstanceLocation(); } int Platform::GetOS() { return BERRY_OS; } int Platform::GetOSArch() { return BERRY_ARCH; } bool Platform::IsUnix() { #ifdef BERRY_OS_FAMILY_UNIX return true; #else return false; #endif } bool Platform::IsWindows() { #ifdef BERRY_OS_FAMILY_WINDOWS return true; #else return false; #endif } bool Platform::IsBSD() { #ifdef BERRY_OS_FAMILY_BSD return true; #else return false; #endif } bool Platform::IsLinux() { #ifdef BERRY_OS_FAMILY_LINUX return true; #else return false; #endif } bool Platform::IsVMS() { #ifdef BERRY_OS_FAMILY_VMS return true; #else return false; #endif } bool Platform::GetStatePath(QDir& statePath, const QSharedPointer& plugin, bool /*create*/) { statePath = GetStateLocation(plugin); return true; } QDir Platform::GetStateLocation(const QSharedPointer& plugin) { return InternalPlatform::GetInstance()->GetStateLocation(plugin); } QDir Platform::GetUserPath() { ctkLocation* location = GetUserLocation(); if (location) { return location->getUrl().toLocalFile(); } return QDir(); } ctkLocation* Platform::GetUserLocation() { return InternalPlatform::GetInstance()->GetUserLocation(); } bool Platform::IsRunning() { return InternalPlatform::GetInstance()->IsRunning(); } QStringList Platform::GetApplicationArgs() { return InternalPlatform::GetInstance()->GetApplicationArgs(); } QSharedPointer Platform::GetPlugin(const QString& symbolicName) { return InternalPlatform::GetInstance()->GetPlugin(symbolicName); } QList > Platform::GetPlugins(const QString& symbolicName, const QString& version) { return InternalPlatform::GetInstance()->GetPlugins(symbolicName, version); } QVariant berry::Platform::GetDebugOption(const QString& option) { return InternalPlatform::GetInstance()->GetOption(option); } IProduct::Pointer berry::Platform::GetProduct() { return InternalPlatform::GetInstance()->GetProduct(); } } diff --git a/Plugins/org.blueberry.core.runtime/src/berryPlatform.h b/Plugins/org.blueberry.core.runtime/src/berryPlatform.h index f072f5b8ed..548002f7e4 100644 --- a/Plugins/org.blueberry.core.runtime/src/berryPlatform.h +++ b/Plugins/org.blueberry.core.runtime/src/berryPlatform.h @@ -1,495 +1,492 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef BERRY_Platform_INCLUDED #define BERRY_Platform_INCLUDED // // Platform Identification // #define BERRY_OS_FREE_BSD 0x0001 #define BERRY_OS_AIX 0x0002 #define BERRY_OS_HPUX 0x0003 #define BERRY_OS_TRU64 0x0004 #define BERRY_OS_LINUX 0x0005 #define BERRY_OS_MAC_OS_X 0x0006 #define BERRY_OS_NET_BSD 0x0007 #define BERRY_OS_OPEN_BSD 0x0008 #define BERRY_OS_IRIX 0x0009 #define BERRY_OS_SOLARIS 0x000a #define BERRY_OS_QNX 0x000b #define BERRY_OS_VXWORKS 0x000c #define BERRY_OS_CYGWIN 0x000d #define BERRY_OS_UNKNOWN_UNIX 0x00ff #define BERRY_OS_WINDOWS_NT 0x1001 #define BERRY_OS_WINDOWS_CE 0x1011 #define BERRY_OS_VMS 0x2001 #if defined(__FreeBSD__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_FREE_BSD #elif defined(_AIX) || defined(__TOS_AIX__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_AIX #elif defined(hpux) || defined(_hpux) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_HPUX #elif defined(__digital__) || defined(__osf__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_TRU64 #elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_LINUX #elif defined(__APPLE__) || defined(__TOS_MACOS__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_MAC_OS_X #elif defined(__NetBSD__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_NET_BSD #elif defined(__OpenBSD__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS_FAMILY_BSD 1 #define BERRY_OS BERRY_OS_OPEN_BSD #elif defined(sgi) || defined(__sgi) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_IRIX #elif defined(sun) || defined(__sun) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_SOLARIS #elif defined(__QNX__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_QNX #elif defined(unix) || defined(__unix) || defined(__unix__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_UNKNOWN_UNIX #elif defined(_WIN32_WCE) #define BERRY_OS_FAMILY_WINDOWS 1 #define BERRY_OS BERRY_OS_WINDOWS_CE #elif defined(_WIN32) || defined(_WIN64) #define BERRY_OS_FAMILY_WINDOWS 1 #define BERRY_OS BERRY_OS_WINDOWS_NT #elif defined(__CYGWIN__) #define BERRY_OS_FAMILY_UNIX 1 #define BERRY_OS BERRY_OS_CYGWIN #elif defined(__VMS) #define BERRY_OS_FAMILY_VMS 1 #define BERRY_OS BERRY_OS_VMS #endif // // Hardware Architecture and Byte Order // #define BERRY_ARCH_ALPHA 0x01 #define BERRY_ARCH_IA32 0x02 #define BERRY_ARCH_IA64 0x03 #define BERRY_ARCH_MIPS 0x04 #define BERRY_ARCH_HPPA 0x05 #define BERRY_ARCH_PPC 0x06 #define BERRY_ARCH_POWER 0x07 #define BERRY_ARCH_SPARC 0x08 #define BERRY_ARCH_AMD64 0x09 #define BERRY_ARCH_ARM 0x0a #if defined(__ALPHA) || defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA) #define BERRY_ARCH BERRY_ARCH_ALPHA #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) #define BERRY_ARCH BERRY_ARCH_IA32 #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__ia64) || defined(_M_IA64) #define BERRY_ARCH BERRY_ARCH_IA64 #if defined(hpux) || defined(_hpux) #define BERRY_ARCH_BIG_ENDIAN 1 #else #define BERRY_ARCH_LITTLE_ENDIAN 1 #endif #elif defined(__x86_64__) #define BERRY_ARCH BERRY_ARCH_AMD64 #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(_M_X64) #define BERRY_ARCH BERRY_ARCH_AMD64 #define BERRY_ARCH_LITTLE_ENDIAN 1 #elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000) #define BERRY_ARCH BERRY_ARCH_MIPS #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__hppa) || defined(__hppa__) #define BERRY_ARCH BERRY_ARCH_HPPA #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__PPC) || defined(__POWERPC__) || defined(__powerpc) || defined(__PPC__) || \ defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC) || defined(_M_PPC) #define BERRY_ARCH BERRY_ARCH_PPC #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(_POWER) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_ARCH_PWR3) || \ defined(_ARCH_PWR4) || defined(__THW_RS6000) #define BERRY_ARCH BERRY_ARCH_POWER #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__sparc__) || defined(__sparc) || defined(sparc) #define BERRY_ARCH BERRY_ARCH_SPARC #define BERRY_ARCH_BIG_ENDIAN 1 #elif defined(__arm__) || defined(__arm) || defined(ARM) || defined(_ARM_) || defined(__ARM__) || defined(_M_ARM) #define BERRY_ARCH BERRY_ARCH_ARM #if defined(__ARMEB__) #define BERRY_ARCH_BIG_ENDIAN 1 #else #define BERRY_ARCH_LITTLE_ENDIAN 1 #endif #endif #include #include #include #include struct ctkLocation; class ctkPlugin; namespace Poco { class Path; } namespace berry { struct IAdapterManager; struct IBundle; struct IExtensionPointService; struct IExtensionRegistry; struct IPreferencesService; struct IProduct; /** * The central class of the BlueBerry Platform Runtime. This class cannot * be instantiated or subclassed by clients; all functionality is provided * by static methods. Features include: *
    *
  • the platform registry of installed plug-ins
  • *
  • the platform adapter manager
  • *
  • the platform log
  • *
*

* Most users don't have to worry about Platform's lifecycle. However, if your * code can call methods of this class when Platform is not running, it becomes * necessary to check {@link #IsRunning()} before making the call. A runtime * exception might be thrown or incorrect result might be returned if a method * from this class is called while Platform is not running. *

*/ class org_blueberry_core_runtime_EXPORT Platform { public: static const QString PI_RUNTIME; static const int OS_FREE_BSD; static const int OS_AIX; static const int OS_HPUX; static const int OS_TRU64; static const int OS_LINUX; static const int OS_MAC_OS_X; static const int OS_NET_BSD; static const int OS_OPEN_BSD; static const int OS_IRIX; static const int OS_SOLARIS; static const int OS_QNX; static const int OS_VXWORKS; static const int OS_CYGWIN; static const int OS_UNKNOWN_UNIX; static const int OS_WINDOWS_NT; static const int OS_WINDOWS_CE; static const int OS_VMS; static const int ARCH_ALPHA; static const int ARCH_IA32; static const int ARCH_IA64; static const int ARCH_MIPS; static const int ARCH_HPPA; static const int ARCH_PPC; static const int ARCH_POWER; static const int ARCH_SPARC; static const int ARCH_AMD64; static const int ARCH_ARM; static const QString PROP_QTPLUGIN_PATH; static const QString PROP_NEWINSTANCE; static const QString PROP_PLUGIN_DIRS; static const QString PROP_FORCE_PLUGIN_INSTALL; static const QString PROP_APPLICATION; static const QString PROP_IGNOREAPP; - static const QString PROP_TESTPLUGIN; - static const QString PROP_TESTAPPLICATION; - static const QString PROP_XARGS; /** * Returns the adapter manager used for extending * IAdaptable objects. * * @return the adapter manager for this platform * @see IAdapterManager */ static IAdapterManager* GetAdapterManager(); /** * Returns the extension registry for this platform. * May return null if the registry has not been created yet. * * @return existing extension registry or null * @see IExtensionRegistry */ static IExtensionRegistry* GetExtensionRegistry(); /** * Return the interface into the preference mechanism. The returned * object can be used for such operations as searching for preference * values across multiple scopes and preference import/export. *

* Clients are also able to acquire the IPreferencesService service via * CTK mechanisms and use it for preference functions. *

* * @return an object to interface into the preference mechanism */ static IPreferencesService* GetPreferencesService(); /** * Returns the product which was selected when running this BlueBerry instance * or null if none * @return the current product or null if none */ static SmartPointer GetProduct(); /** * Returns the identified option. A null QString * is returned if no such option is found. Options are specified * in the general form <plug-in id>/<option-path>. * For example, org.blueberry.core.runtime/debug *

* Clients are also able to acquire the {@link DebugOptions} service * and query it for debug options. *

* @param option the name of the option to lookup * @return the value of the requested debug option or QString::null */ static QVariant GetDebugOption(const QString& option); /** * Returns the path of the configuration information * used to run this instance of the BlueBerry platform. * The configuration area typically * contains the list of plug-ins available for use, various settings * (those shared across different instances of the same configuration) * and any other such data needed by plug-ins. * An empty path is returned if the platform is running without a configuration location. * * @return the location of the platform's configuration data area * @deprecatedSince{2015_05} Use GetConfigurationLocation() instead. */ QT_DEPRECATED static QDir GetConfigurationPath(); /** * Returns the location of the configuration information * used to run this instance of BlueBerry. The configuration area typically * contains the list of plug-ins available for use, various settings * (those shared across different instances of the same configuration) * and any other such data needed by plug-ins. * null is returned if the platform is running without a configuration location. *

* This method is equivalent to acquiring the org.commontk.service.datalocation.Location * service with the property "type" equal to ctkLocation::CONFIGURATION_FILTER. *

* @return the location of the platform's configuration data area or null if none * @see ctkLocation::CONFIGURATION_FILTER */ static ctkLocation* GetConfigurationLocation(); /** * Returns the path of the base installation for the running platform * * @return the location of the platform's installation area or null if none * @deprecatedSince{2015_05} Use GetInstallLocation() instead. */ QT_DEPRECATED static QDir GetInstallPath(); /** * Returns the location of the base installation for the running platform * null is returned if the platform is running without a configuration location. *

* This method is equivalent to acquiring the org.commontk.service.datalocation.Location * service with the property "type" equal to ctkLocation::INSTALL_FILTER. *

* @return the location of the platform's installation area or null if none * @see ctkLocation::INSTALL_FILTER */ static ctkLocation* GetInstallLocation(); /** * Returns the path of the platform's working directory (also known as the instance data area). * An empty path is returned if the platform is running without an instance location. * * @return the location of the platform's instance data area or null if none * @deprecatedSince{2015_05} Use GetInstanceLocation() instead. */ QT_DEPRECATED static QDir GetInstancePath(); /** * Returns the location of the platform's working directory (also known as the instance data area). * null is returned if the platform is running without an instance location. *

* This method is equivalent to acquiring the org.commontk.service.datalocation.Location * service with the property "type" equal to ctkLocation::INSTANCE_FILTER. *

* @return the location of the platform's instance data area or null if none * @see ctkLocation::INSTANCE_FILTER */ static ctkLocation* GetInstanceLocation(); /** * Returns the path in the local file system of the * plug-in state area for the given plug-in. * If the plug-in state area did not exist prior to this call, * it is created. *

* The plug-in state area is a file directory within the * platform's metadata area where a plug-in is free to create files. * The content and structure of this area is defined by the plug-in, * and the particular plug-in is solely responsible for any files * it puts there. It is recommended for plug-in preference settings and * other configuration parameters. *

* * @param plugin the plug-in whose state location is returned * @return a local file system path * TODO Investigate the usage of a service factory * @deprecatedSince{2015_05} Use GetStateLocation instead. */ QT_DEPRECATED static bool GetStatePath(QDir& statePath, const QSharedPointer& plugin, bool create = true); /** * Returns the location in the local file system of the * plug-in state area for the given plug-in. * If the plug-in state area did not exist prior to this call, * it is created. *

* The plug-in state area is a file directory within the * platform's metadata area where a plug-in is free to create files. * The content and structure of this area is defined by the plug-in, * and the particular plug-in is solely responsible for any files * it puts there. It is recommended for plug-in preference settings and * other configuration parameters. *

* * @param plugin the plugin whose state location if returned * @return a local file system path * @throws ctkIllegalStateException if no instance location was specified * @throws RuntimeException if the plug-in state area could not be created. */ static QDir GetStateLocation(const QSharedPointer& plugin); /** * Returns the path of the platform's user data area. The user data area is a location on the system * which is specific to the system's current user. By default it is located relative to the * location given by the System property "user.home". * An empty path is returned if the platform is running without an user location. * * @return the location of the platform's user data area or null if none * @deprecatedSince{2015_05} Use GetUserLocation() instead. */ QT_DEPRECATED static QDir GetUserPath(); /** * Returns the location of the platform's user data area. The user data area is a location on the system * which is specific to the system's current user. By default it is located relative to the * location given by the system property "user.home". * null is returned if the platform is running without an user location. *

* This method is equivalent to acquiring the org.commontk.service.datalocation.Location * service with the property "type" equal to ctkLocation::USER_FILTER. *

* @return the location of the platform's user data area or null if none * @see ctkLocation::USER_FILTER */ static ctkLocation* GetUserLocation(); static int GetOS(); static int GetOSArch(); static bool IsUnix(); static bool IsWindows(); static bool IsBSD(); static bool IsLinux(); static bool IsVMS(); static bool IsRunning(); /** * Returns the applications command line arguments which * have not been consumed by the platform. */ static QStringList GetApplicationArgs(); /** * Returns the resolved plug-in with the specified symbolic name that has the * highest version. If no resolved plug-ins are installed that have the * specified symbolic name then null is returned. *

* Note that clients may want to filter * the results based on the state of the plug-ins. *

* @param symbolicName the symbolic name of the plug-in to be returned. * @return the plug-in that has the specified symbolic name with the * highest version, or null if no plug-in is found. */ static QSharedPointer GetPlugin(const QString& symbolicName); /** * Returns all plug-ins with the specified symbolic name. If no resolved plug-ins * with the specified symbolic name can be found, an empty list is returned. * If the version argument is not null then only the plug-ins that have * the specified symbolic name and a version greater than or equal to the * specified version are returned. The returned plug-ins are ordered in * descending plug-in version order. *

* Note that clients may want to filter * the results based on the state of the plug-ins. *

* @param symbolicName the symbolic name of the plug-ins that are to be returned. * @param version the version that the returned plug-in versions must match, * or QString() if no version matching is to be done. * @return the list of plug-ins with the specified name that match the * specified version and match rule, or null if no plug-ins are found. */ static QList > GetPlugins(const QString& symbolicName, const QString& version = QString()); private: Platform(); }; } // namespace #endif // BERRY_Platform_INCLUDED diff --git a/Plugins/org.blueberry.test/CMakeLists.txt b/Plugins/org.blueberry.test/CMakeLists.txt deleted file mode 100644 index a1fb3b2ae3..0000000000 --- a/Plugins/org.blueberry.test/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(org_blueberry_test) - -include_directories(${CppUnit_INCLUDE_DIRS}) - -mitk_create_plugin( - EXPORT_DIRECTIVE BERRY_TEST_EXPORT - EXPORTED_INCLUDE_SUFFIXES src src/harness - NO_INSTALL - ) - -target_link_libraries(${PROJECT_NAME} PRIVATE ${CppUnit_LIBRARIES}) diff --git a/Plugins/org.blueberry.test/documentation/doxygen/modules.dox b/Plugins/org.blueberry.test/documentation/doxygen/modules.dox deleted file mode 100644 index f15b97ba2a..0000000000 --- a/Plugins/org.blueberry.test/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_blueberry_test org.blueberry.test - \ingroup BlueBerryPlugins - - \brief Testing infrastructure for running unit tests defined in BlueBerry plug-ins. - -*/ - -/** - \defgroup org_blueberry_test_internal Internal - \ingroup org_blueberry_test - - \brief This subcategory includes the internal classes of the org.blueberry.test plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Plugins/org.blueberry.test/files.cmake b/Plugins/org.blueberry.test/files.cmake deleted file mode 100644 index 2021d90c53..0000000000 --- a/Plugins/org.blueberry.test/files.cmake +++ /dev/null @@ -1,35 +0,0 @@ -set(MOC_H_FILES - src/internal/berryPluginActivator.h - - src/berryCoreTestApplication.h -) - -set(CACHED_RESOURCE_FILES - plugin.xml -) - -set(SRC_CPP_FILES - berryCoreTestApplication.cpp - berryBlueBerryTestDriver.cpp - - harness/berryTestCase.cpp - - util/berryCallHistory.cpp -) - -set(INTERNAL_CPP_FILES - berryPluginActivator.cpp - berryTestDescriptor.cpp - berryTestRegistry.cpp -) - -set(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/Plugins/org.blueberry.test/manifest_headers.cmake b/Plugins/org.blueberry.test/manifest_headers.cmake deleted file mode 100644 index 6b5e458b86..0000000000 --- a/Plugins/org.blueberry.test/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "BlueBerry Automated Testing") -set(Plugin-Version "0.9") -set(Plugin-Vendor "German Cancer Research Center (DKFZ)") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin "org.blueberry.core.runtime") - diff --git a/Plugins/org.blueberry.test/plugin.xml b/Plugins/org.blueberry.test/plugin.xml deleted file mode 100644 index df091b2154..0000000000 --- a/Plugins/org.blueberry.test/plugin.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/org.blueberry.test/schema/tests.exsd b/Plugins/org.blueberry.test/schema/tests.exsd deleted file mode 100644 index cb2ca7893e..0000000000 --- a/Plugins/org.blueberry.test/schema/tests.exsd +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - The test extension point allows plugins to contribute unit tests to the BlueBerry Platform. The tests should be written with the help of the Poco CppUnit library. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Following is an example of a test declaration. -<p> - <pre> - <extension id="SampleTestSuite" point="org.blueberry.tests"> - <test id="SampleTest" class="xyz::SampleTest"/> - </extension> - </pre> -</p> - - - - - - - - - Test classes must be a subclass of <code>CppUnit::Test</code>. - - - - - - diff --git a/Plugins/org.blueberry.test/src/berryBlueBerryTestDriver.cpp b/Plugins/org.blueberry.test/src/berryBlueBerryTestDriver.cpp deleted file mode 100644 index c4ec16d8d3..0000000000 --- a/Plugins/org.blueberry.test/src/berryBlueBerryTestDriver.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryBlueBerryTestDriver.h" - -#include "internal/berryTestRegistry.h" - -#include "cppunit/TestRunner.h" -#include "cppunit/TestResult.h" -#include "cppunit/TestResultCollector.h" - -namespace berry -{ - -BlueBerryTestDriver::BlueBerryTestDriver( - const QList& descriptors, - bool uitests, - const QString& testName, - bool wait) - : descriptors(descriptors) - , uitests(uitests) - , testName(testName) - , wait(wait) -{ - -} - -int BlueBerryTestDriver::Run() -{ - CppUnit::TestRunner runner; - - unsigned int testCounter = 0; - foreach (const ITestDescriptor::Pointer& descr, descriptors) - { - if (descr->IsUITest() == uitests) - { - CppUnit::Test* test = descr->CreateTest(); - runner.addTest(test); - ++testCounter; - } - } - - if (testCounter == 0) - { - std::cout << "No " << (uitests ? "UI " : "") << "tests registered." - << std::endl; - return 0; - } - - /* - std::vector args; - args.push_back("BlueBerryTestDriver"); - if (testName.empty()) - args.push_back("-all"); - else - args.push_back(testName); - if (wait) - args.push_back("-wait"); - - return runner.run(args) ? 0 : 1; - */ - - CppUnit::TestResult controller; - - CppUnit::TestResultCollector result; - controller.addListener(&result); - - runner.run(controller); - return result.wasSuccessful() ? 0 : 1; -} - -int BlueBerryTestDriver::Run(const QString& pluginId, bool uitests) -{ - TestRegistry testRegistry; - const QList& tests = testRegistry.GetTestsForId( - pluginId); - - BlueBerryTestDriver driver(tests, uitests); - return driver.Run(); -} - -} diff --git a/Plugins/org.blueberry.test/src/berryBlueBerryTestDriver.h b/Plugins/org.blueberry.test/src/berryBlueBerryTestDriver.h deleted file mode 100644 index 361abb6050..0000000000 --- a/Plugins/org.blueberry.test/src/berryBlueBerryTestDriver.h +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYBLUEBERRYTESTDRIVER_H_ -#define BERRYBLUEBERRYTESTDRIVER_H_ - -#include - -#include "berryITestDescriptor.h" - -namespace berry -{ - -/** - * A TestDriver for CppUnit that supports running tests inside BlueBerry as well as - * running standalone. - * Example call: TODO - */ -class BERRY_TEST_EXPORT BlueBerryTestDriver -{ -public: - - BlueBerryTestDriver(const QList& descriptors, bool uitests = false, const QString& testName="", bool wait=false); - - int Run(); - - static int Run(const QString& pluginId, bool uitests = false); - -protected: - - QList descriptors; - bool uitests; - QString testName; - bool wait; -}; - -} - -#endif /* BERRYBLUEBERRYTESTDRIVER_H_ */ diff --git a/Plugins/org.blueberry.test/src/berryCoreTestApplication.cpp b/Plugins/org.blueberry.test/src/berryCoreTestApplication.cpp deleted file mode 100644 index fe3e265689..0000000000 --- a/Plugins/org.blueberry.test/src/berryCoreTestApplication.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryCoreTestApplication.h" - -#include -#include - -#include "berryBlueBerryTestDriver.h" - -namespace berry { - -CoreTestApplication::CoreTestApplication() -{ - -} - -CoreTestApplication::CoreTestApplication(const CoreTestApplication& other) - : QObject() -{ - Q_UNUSED(other) -} - -int CoreTestApplication::Start() { - std::string testPlugin; - try { - testPlugin = Platform::GetConfiguration().getString(Platform::ARG_TESTPLUGIN.toStdString()); - } - catch (const Poco::NotFoundException& /*e*/) - { - BERRY_ERROR << "You must specify a test plug-in id via " << Platform::ARG_TESTPLUGIN << "="; - return 1; - } - - return BlueBerryTestDriver::Run(QString::fromStdString(testPlugin)); -} - -void CoreTestApplication::Stop() { - -} - -} diff --git a/Plugins/org.blueberry.test/src/berryCoreTestApplication.h b/Plugins/org.blueberry.test/src/berryCoreTestApplication.h deleted file mode 100644 index b2d9cf799a..0000000000 --- a/Plugins/org.blueberry.test/src/berryCoreTestApplication.h +++ /dev/null @@ -1,39 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYCORETESTAPPLICATION_H_ -#define BERRYCORETESTAPPLICATION_H_ - -#include - -#include - -namespace berry { - -class CoreTestApplication : public QObject, public IApplication -{ - Q_OBJECT - Q_INTERFACES(berry::IApplication) - -public: - - CoreTestApplication(); - CoreTestApplication(const CoreTestApplication& other); - - int Start(); - void Stop(); -}; - -} - -#endif /* BERRYCORETESTAPPLICATION_H_ */ diff --git a/Plugins/org.blueberry.test/src/berryITestDescriptor.h b/Plugins/org.blueberry.test/src/berryITestDescriptor.h deleted file mode 100644 index f012c9185b..0000000000 --- a/Plugins/org.blueberry.test/src/berryITestDescriptor.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYITESTDESCRIPTOR_H_ -#define BERRYITESTDESCRIPTOR_H_ - -#include -#include - -#include - -namespace berry { - -struct ITestDescriptor : public Object -{ - berryObjectMacro(berry::ITestDescriptor); - - virtual CppUnit::Test* CreateTest() = 0; - virtual QString GetId() const = 0; - virtual QString GetContributor() const = 0; - virtual QString GetDescription() const = 0; - - virtual bool IsUITest() const = 0; -}; - -} - -#endif /* BERRYITESTDESCRIPTOR_H_ */ diff --git a/Plugins/org.blueberry.test/src/harness/berryTestCase.cpp b/Plugins/org.blueberry.test/src/harness/berryTestCase.cpp deleted file mode 100644 index df3b67d605..0000000000 --- a/Plugins/org.blueberry.test/src/harness/berryTestCase.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryTestCase.h" - -#include -#include - -#ifdef BLUEBERRY_DEBUG_SMARTPOINTER -#include -#endif - -#include - -#include - -berry::TestCase::TestCase(const QString& testName) : - CppUnit::TestCase(testName.toStdString()), m_LeakDetails(false), - m_IgnoreLeakage(false) -{ - -} - -void berry::TestCase::LeakDetailsOn() -{ - m_LeakDetails = true; -} - -void berry::TestCase::IgnoreLeakingObjects() -{ - BERRY_WARN << "Ignoring Leaking Objects!!"; - m_IgnoreLeakage = true; -} - -void berry::TestCase::DoSetUp() -{ - -} - -void berry::TestCase::DoTearDown() -{ - -} - -void berry::TestCase::setUp() -{ - CppUnit::TestCase::setUp(); -#ifdef BLUEBERRY_DEBUG_SMARTPOINTER - DebugUtil::ResetObjectSummary(); -#endif - DoSetUp(); -} - -void berry::TestCase::tearDown() -{ - CppUnit::TestCase::tearDown(); - DoTearDown(); -#ifdef BLUEBERRY_DEBUG_SMARTPOINTER - assert(m_IgnoreLeakage || !DebugUtil::PrintObjectSummary(m_LeakDetails)); -#endif - - m_LeakDetails = false; -} - diff --git a/Plugins/org.blueberry.test/src/harness/berryTestCase.h b/Plugins/org.blueberry.test/src/harness/berryTestCase.h deleted file mode 100644 index 8d0d31ed9e..0000000000 --- a/Plugins/org.blueberry.test/src/harness/berryTestCase.h +++ /dev/null @@ -1,80 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYTESTCASE_H_ -#define BERRYTESTCASE_H_ - -#include - -#include - -namespace berry { - -class BERRY_TEST_EXPORT TestCase : public CppUnit::TestCase -{ - -public: - - TestCase(const QString& testName); - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * The default implementation does nothing. - * Subclasses may extend. - */ - virtual void DoSetUp(); - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * The default implementation closes all test windows, processing events both before - * and after doing so. - * Subclasses may extend. - */ - virtual void DoTearDown(); - - /** - * Clients should overwrite DoSetUp() instead of this method. - */ - void setUp(); - - /** - * Clients should overwrite DoSetUp() instead of this method. - */ - void tearDown(); - -protected: - - /** - * Call this method in your unit test to enable detailed - * output about leaking berry::Object instances. - */ - void LeakDetailsOn(); - - /** - * Call this method to ignore leaking objects and to continue - * with the unit tests. - */ - void IgnoreLeakingObjects(); - -private: - - bool m_LeakDetails; - bool m_IgnoreLeakage; - -}; - -} - -#endif /* BERRYTESTCASE_H_ */ diff --git a/Plugins/org.blueberry.test/src/internal/berryPluginActivator.cpp b/Plugins/org.blueberry.test/src/internal/berryPluginActivator.cpp deleted file mode 100644 index a68f8131c3..0000000000 --- a/Plugins/org.blueberry.test/src/internal/berryPluginActivator.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryPluginActivator.h" -#include "berryMacros.h" -#include "berryCoreTestApplication.h" - -namespace berry { - -org_blueberry_test_Activator::org_blueberry_test_Activator() -{ - -} - -void org_blueberry_test_Activator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(CoreTestApplication, context) -} - -void org_blueberry_test_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} diff --git a/Plugins/org.blueberry.test/src/internal/berryPluginActivator.h b/Plugins/org.blueberry.test/src/internal/berryPluginActivator.h deleted file mode 100644 index fe80c1efeb..0000000000 --- a/Plugins/org.blueberry.test/src/internal/berryPluginActivator.h +++ /dev/null @@ -1,39 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYPLUGINACTIVATOR_H -#define BERRYPLUGINACTIVATOR_H - -#include - -namespace berry { - -class org_blueberry_test_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_blueberry_test") - Q_INTERFACES(ctkPluginActivator) - -public: - org_blueberry_test_Activator(); - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); -}; - -typedef org_blueberry_test_Activator PluginActivator; - -} - -#endif // BERRYPLUGINACTIVATOR_H diff --git a/Plugins/org.blueberry.test/src/internal/berryTestDescriptor.cpp b/Plugins/org.blueberry.test/src/internal/berryTestDescriptor.cpp deleted file mode 100644 index f405c7c5c8..0000000000 --- a/Plugins/org.blueberry.test/src/internal/berryTestDescriptor.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryTestDescriptor.h" -#include "berryTestRegistry.h" -#include "berryIContributor.h" - -#include - -Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test") - -namespace berry -{ - -TestDescriptor::TestDescriptor(IConfigurationElement::Pointer elem) : - configElem(elem) -{ - -} - -CppUnit::Test* TestDescriptor::CreateTest() -{ - CppUnit::Test* test = configElem->CreateExecutableExtension ( - TestRegistry::ATT_CLASS); - if (test == 0) - { - // Try legacy BlueBerry manifests instead - test = configElem->CreateExecutableExtension ( - TestRegistry::ATT_CLASS); - } - return test; -} - -QString TestDescriptor::GetId() const -{ - return configElem->GetAttribute(TestRegistry::ATT_ID); -} - -QString TestDescriptor::GetContributor() const -{ - return configElem->GetContributor()->GetName(); -} - -QString TestDescriptor::GetDescription() const -{ - return configElem->GetAttribute(TestRegistry::ATT_DESCRIPTION); -} - -bool TestDescriptor::IsUITest() const -{ - QString isUi = configElem->GetAttribute(TestRegistry::ATT_UITEST); - return isUi.compare("true", Qt::CaseInsensitive); -} - -} diff --git a/Plugins/org.blueberry.test/src/internal/berryTestDescriptor.h b/Plugins/org.blueberry.test/src/internal/berryTestDescriptor.h deleted file mode 100644 index 32fa3ca44f..0000000000 --- a/Plugins/org.blueberry.test/src/internal/berryTestDescriptor.h +++ /dev/null @@ -1,45 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYTESTDESCRIPTOR_H_ -#define BERRYTESTDESCRIPTOR_H_ - -#include "berryITestDescriptor.h" - -#include - -namespace berry { - -class TestDescriptor : public ITestDescriptor -{ -public: - - berryObjectMacro(TestDescriptor); - - TestDescriptor(IConfigurationElement::Pointer elem); - - CppUnit::Test* CreateTest(); - QString GetId() const; - QString GetContributor() const; - QString GetDescription() const; - - bool IsUITest() const; - -private: - - IConfigurationElement::Pointer configElem; -}; - -} - -#endif /* BERRYTESTDESCRIPTOR_H_ */ diff --git a/Plugins/org.blueberry.test/src/internal/berryTestRegistry.cpp b/Plugins/org.blueberry.test/src/internal/berryTestRegistry.cpp deleted file mode 100644 index f785778a7c..0000000000 --- a/Plugins/org.blueberry.test/src/internal/berryTestRegistry.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryTestRegistry.h" -#include "berryTestDescriptor.h" - -#include -#include - -namespace berry -{ - -const QString TestRegistry::TAG_TEST = "test"; -const QString TestRegistry::ATT_ID = "id"; -const QString TestRegistry::ATT_CLASS = "class"; -const QString TestRegistry::ATT_DESCRIPTION = "description"; -const QString TestRegistry::ATT_UITEST = "uitest"; - -TestRegistry::TestRegistry() -{ - QList elements( - Platform::GetExtensionRegistry()->GetConfigurationElementsFor( - "org.blueberry.tests")); - - foreach (const IConfigurationElement::Pointer& configElem, elements) - { - if (configElem->GetName() == TAG_TEST) - { - this->ReadTest(configElem); - } - } -} - -const QList& -TestRegistry::GetTestsForId(const QString& pluginid) -{ - return mapIdToTests[pluginid]; -} - -void TestRegistry::ReadTest(const IConfigurationElement::Pointer& testElem) -{ - ITestDescriptor::Pointer descriptor(new TestDescriptor(testElem)); - Q_ASSERT(!descriptor->GetId().isEmpty()); - mapIdToTests[descriptor->GetContributor()].push_back(descriptor); -} - -} diff --git a/Plugins/org.blueberry.test/src/internal/berryTestRegistry.h b/Plugins/org.blueberry.test/src/internal/berryTestRegistry.h deleted file mode 100644 index 95bccfae0a..0000000000 --- a/Plugins/org.blueberry.test/src/internal/berryTestRegistry.h +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYTESTREGISTRY_H_ -#define BERRYTESTREGISTRY_H_ - -#include - -#include "berryITestDescriptor.h" - -namespace berry { - -class TestRegistry -{ -public: - - static const QString TAG_TEST; // = "test" - static const QString ATT_ID; // = "id" - static const QString ATT_CLASS; // = "class" - static const QString ATT_DESCRIPTION; // = "description" - static const QString ATT_UITEST; // = "uitest" - - TestRegistry(); - - const QList& GetTestsForId(const QString& pluginid); - -protected: - - void ReadTest(const IConfigurationElement::Pointer& testElem); - -private: - - QHash > mapIdToTests; -}; - -} - -#endif /* BERRYTESTREGISTRY_H_ */ diff --git a/Plugins/org.blueberry.test/src/util/berryCallHistory.cpp b/Plugins/org.blueberry.test/src/util/berryCallHistory.cpp deleted file mode 100644 index e7a101ddbd..0000000000 --- a/Plugins/org.blueberry.test/src/util/berryCallHistory.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryCallHistory.h" - -#include - -namespace berry -{ - -CallHistory::CallHistory(/*Object target*/) -{ - // classType = target.getClass(); -} - -void CallHistory::Add(const std::string& methodName) -{ - TestMethodName(methodName); - methodList.push_back(methodName); -} - -void CallHistory::Clear() -{ - methodList.clear(); -} - -bool CallHistory::VerifyOrder(const std::vector& testNames) const -throw(Poco::InvalidArgumentException) -{ - std::size_t testIndex = 0; - std::size_t testLength = testNames.size(); - if (testLength == 0) - return true; - for (std::size_t nX = 0; nX < methodList.size(); nX++) - { - const std::string& methodName = methodList[nX]; - const std::string& testName = testNames[testIndex]; - TestMethodName(testName); - if (testName == methodName) - ++testIndex; - if (testIndex >= testLength) - return true; - } - return false; -} - -bool CallHistory::Contains(const std::string& methodName) const -{ - TestMethodName(methodName); - return std::find(methodList.begin(), methodList.end(), methodName) != methodList.end(); -} - -bool CallHistory::Contains(const std::vector& methodNames) const -{ - for (std::size_t i = 0; i < methodNames.size(); i++) - { - TestMethodName(methodNames[i]); - if (std::find(methodList.begin(), methodList.end(), methodNames[i]) == methodList.end()) - return false; - } - return true; -} - -bool CallHistory::IsEmpty() const -{ - return methodList.empty(); -} - -void CallHistory::PrintTo(std::ostream& out) const -{ - for (std::size_t i = 0; i < methodList.size(); i++) - out << methodList[i] << std::endl; -} - -void CallHistory::TestMethodName(const std::string&) const -throw(Poco::InvalidArgumentException) -{ -// Method[] methods = classType.getMethods(); -// for (int i = 0; i < methods.length; i++) -// if (methods[i].getName().equals(methodName)) -// return; -// throw new IllegalArgumentException("Target class (" + classType.getName() -// + ") does not contain method: " + methodName); -} - -} diff --git a/Plugins/org.blueberry.test/src/util/berryCallHistory.h b/Plugins/org.blueberry.test/src/util/berryCallHistory.h deleted file mode 100644 index f954ba1cbe..0000000000 --- a/Plugins/org.blueberry.test/src/util/berryCallHistory.h +++ /dev/null @@ -1,131 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYCALLHISTORY_H_ -#define BERRYCALLHISTORY_H_ - -#include - -#include -#include - -#include - -#include -#include - -namespace berry { - -/** - * CallHistory is used to record the invocation - * of methods within a target object. This is useful during - * lifecycle testing for an object. - *

- * To use CallHistory .. - *

    - *
  1. Create a CallHistory in the target or pass one in.
  2. - *
  3. Invoke some test scenario.
  4. - *
  5. If a method is called on the target record the invocation - * in the call history
  6. - *
  7. Verify the call history after the test scenario is - * complete.
  8. - *
- *

- * Each CallHistory has a target which is used to - * verify the method names passed to the history. If an invalid - * name is passed an IllegalArgumentException will - * be thrown. - *

- */ -class BERRY_TEST_EXPORT CallHistory : public Object { - -private: - - std::vector methodList; - - // Class classType; - -public: - - berryObjectMacro(CallHistory); - - /** - * Creates a new call history for an object. - * - * @param target the call history target. - */ - CallHistory(/*Object target*/); - - /** - * Adds a method name to the call history. - * - * @param methodName the name of a method - */ - void Add(const std::string& methodName); - - /** - * Clears the call history. - */ - void Clear(); - - /** - * Returns whether a list of methods have been called in - * order. - * - * @param testNames an array of the method names in the order they are expected - * @return true if the methods were called in order - */ - bool VerifyOrder(const std::vector& testNames) const - throw(Poco::InvalidArgumentException); - - /** - * Returns whether a method has been called. - * - * @param methodName a method name - * @return true if the method was called - */ - bool Contains(const std::string& methodName) const ; - - /** - * Returns whether a list of methods were called. - * - * @param methodNames a list of methods - * @return true if the methods were called - */ - bool Contains(const std::vector& methodNames) const; - - /** - * Returns whether the list of methods called is empty. - * - * @return true iff the list of methods is empty - */ - bool IsEmpty() const; - - /** - * Prints the call history to the console. - */ - void PrintTo(std::ostream& out) const; - -private: - - /** - * Throws an exception if the method name is invalid - * for the given target class. - */ - void TestMethodName(const std::string&) const throw(Poco::InvalidArgumentException); - -}; - -} - -#endif /* BERRYCALLHISTORY_H_ */ diff --git a/Plugins/org.blueberry.uitest/CMakeLists.txt b/Plugins/org.blueberry.uitest/CMakeLists.txt deleted file mode 100644 index 7f828c370c..0000000000 --- a/Plugins/org.blueberry.uitest/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(org_blueberry_uitest) - -include_directories(${CppUnit_INCLUDE_DIRS}) - -mitk_create_plugin( - EXPORT_DIRECTIVE BERRY_UITEST_EXPORT - EXPORTED_INCLUDE_SUFFIXES src src/harness src/util - NO_INSTALL -) - -target_link_libraries(${PROJECT_NAME} PRIVATE ${CppUnit_LIBRARIES}) diff --git a/Plugins/org.blueberry.uitest/documentation/doxygen/modules.dox b/Plugins/org.blueberry.uitest/documentation/doxygen/modules.dox deleted file mode 100644 index 95c905fe9d..0000000000 --- a/Plugins/org.blueberry.uitest/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_blueberry_uitest org.blueberry.uitest - \ingroup BlueBerryPlugins - - \brief Testing infrastructure for executing unit tests which require a running workbench. - -*/ - -/** - \defgroup org_blueberry_uitest_internal Internal - \ingroup org_blueberry_uitest - - \brief This subcategory includes the internal classes of the org.blueberry.uitest plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Plugins/org.blueberry.uitest/files.cmake b/Plugins/org.blueberry.uitest/files.cmake deleted file mode 100644 index 412fa2378b..0000000000 --- a/Plugins/org.blueberry.uitest/files.cmake +++ /dev/null @@ -1,35 +0,0 @@ -set(MOC_H_FILES - src/internal/berryPluginActivator.h - src/util/berryEmptyPerspective.h - - src/berryUITestApplication.h -) - -set(CACHED_RESOURCE_FILES - plugin.xml -) - -set(SRC_CPP_FILES - berryUITestApplication.cpp - - harness/berryUITestCase.cpp - - util/berryEmptyPerspective.cpp -) - -set(INTERNAL_CPP_FILES - berryPluginActivator.cpp - berryUITestWorkbenchAdvisor.cpp - berryUITestWorkbenchWindowAdvisor.cpp -) - -set(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/Plugins/org.blueberry.uitest/manifest_headers.cmake b/Plugins/org.blueberry.uitest/manifest_headers.cmake deleted file mode 100644 index 01f620b32f..0000000000 --- a/Plugins/org.blueberry.uitest/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "BlueBerry Automated UI Testing") -set(Plugin-Version "0.9") -set(Plugin-Vendor "German Cancer Research Center (DKFZ)") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.blueberry.test org.blueberry.ui.qt) - diff --git a/Plugins/org.blueberry.uitest/plugin.xml b/Plugins/org.blueberry.uitest/plugin.xml deleted file mode 100644 index b67f1583a8..0000000000 --- a/Plugins/org.blueberry.uitest/plugin.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Plugins/org.blueberry.uitest/src/berryUITestApplication.cpp b/Plugins/org.blueberry.uitest/src/berryUITestApplication.cpp deleted file mode 100644 index f083a5ea8b..0000000000 --- a/Plugins/org.blueberry.uitest/src/berryUITestApplication.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryUITestApplication.h" - -#include -#include -#include -#include -#include - -#include "internal/berryUITestWorkbenchAdvisor.h" - -namespace berry -{ - -class WorkbenchCloseRunnable: public Poco::Runnable -{ -public: - WorkbenchCloseRunnable(IWorkbench* workbench) : - workbench(workbench) - { - } - - void run() - { - workbench->Close(); - } - -private: - IWorkbench* workbench; -}; - -UITestApplication::TestRunnable::TestRunnable(UITestApplication* app, - const QString& testPlugin) : - app(app), testPlugin(testPlugin) -{ -} - -void UITestApplication::TestRunnable::run() -{ - try - { - app->testDriverResult = BlueBerryTestDriver::Run(testPlugin, true); - } - catch (const ctkException& e) - { - qWarning() << e.printStackTrace(); - } - catch (const std::exception& e) - { - qWarning() << e.what(); - } -} - -UITestApplication::UITestApplication() -{ - -} - -int UITestApplication::Start() -{ - // Get the plug-in to test - try - { - testPlugin = QString::fromStdString(Platform::GetConfiguration().getString( - Platform::ARG_TESTPLUGIN.toStdString())); - } catch (const Poco::NotFoundException& /*e*/) - { - BERRY_ERROR << "You must specify a test plug-in id via " - << Platform::ARG_TESTPLUGIN << "="; - return 1; - } - - // Get the application to test - IApplication* application = GetApplication(); - poco_assert(application); - int result = RunApplication(application); - - if (IApplication::EXIT_OK != result) - { - std::cerr << "UITestRunner: Unexpected result from running application " << application << ": " << result << std::endl; - } - return testDriverResult; -} - -void UITestApplication::Stop() -{ - IWorkbench* workbench = PlatformUI::GetWorkbench(); - if (!workbench) - return; - Display* display = workbench->GetDisplay(); - WorkbenchCloseRunnable runnable(workbench); - display->SyncExec(&runnable); -} - -void UITestApplication::RunTests() -{ - TestRunnable runnable(this, testPlugin); - testableObject->TestingStarting(); - testableObject->RunTest(&runnable); - testableObject->TestingFinished(); -} - -IApplication* UITestApplication::GetApplication() -{ - - IExtension::Pointer extension; - /*Platform::GetExtensionPointService()->GetExtension( - Starter::XP_APPLICATIONS, GetApplicationToRun());*/ - - QList extensions( - Platform::GetExtensionRegistry()->GetConfigurationElementsFor(Starter::XP_APPLICATIONS)); - - QString appToRun = GetApplicationToRun(); - QString id; - foreach (const IConfigurationElement::Pointer& configElem, extensions) - { - id = configElem->GetAttribute("id"); - if(id == appToRun) - { - extension = configElem->GetDeclaringExtension(); - break; - } - } - - IApplication* app = 0; - - if (extension) - { - QList elements( - extension->GetConfigurationElements()); - if (!elements.isEmpty()) - { - QList runs( - elements[0]->GetChildren("run")); - if (!runs.isEmpty()) - { - app = runs[0]->CreateExecutableExtension ("class"); - } - } - return app; - } - - return this; -} - -QString UITestApplication::GetApplicationToRun() -{ - - QString testApp; - try - { - testApp = QString::fromStdString(Platform::GetConfiguration().getString( - Platform::ARG_TESTAPPLICATION.toStdString())); - } - catch (const Poco::NotFoundException&) - { - } - - return testApp; -} - -int UITestApplication::RunApplication(IApplication* application) -{ - testableObject = PlatformUI::GetTestableObject(); - testableObject->SetTestHarness(ITestHarness::Pointer(this)); - - if (application == dynamic_cast(this)) - return RunUITestWorkbench(); - - return application->Start(); -} - -int UITestApplication::RunUITestWorkbench() -{ - Display* display = PlatformUI::CreateDisplay(); - UITestWorkbenchAdvisor advisor; - return PlatformUI::CreateAndRunWorkbench(display, &advisor); -} - -} diff --git a/Plugins/org.blueberry.uitest/src/berryUITestApplication.h b/Plugins/org.blueberry.uitest/src/berryUITestApplication.h deleted file mode 100644 index 46cc9bb663..0000000000 --- a/Plugins/org.blueberry.uitest/src/berryUITestApplication.h +++ /dev/null @@ -1,81 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYUITESTAPPLICATION_H_ -#define BERRYUITESTAPPLICATION_H_ - -#include -#include -#include -#include - -#include - -namespace berry -{ - -class BERRY_UITEST_EXPORT UITestApplication: public QObject, public IApplication, public ITestHarness -{ - Q_OBJECT - Q_INTERFACES(berry::IApplication berry::ITestHarness) - -public: - - UITestApplication(); - - int Start(); - - void Stop(); - - /* - * @see berry#ITestHarness#RunTests() - */ - void RunTests(); - -private: - - TestableObject::Pointer testableObject; - int testDriverResult; - QString testPlugin; - - /* - * return the application to run, or null if not even the default application - * is found. - */ - IApplication* GetApplication(); - - /** - * The -BlueBerry.testApplication argument specifies the application to be run. - * If the argument is not set, an empty string is returned and the UITestApplication - * itself will be started. - */ - QString GetApplicationToRun(); - - int RunApplication(IApplication* application); - - int RunUITestWorkbench(); - - struct TestRunnable: public Poco::Runnable - { - TestRunnable(UITestApplication* app, const QString& testPlugin); - - void run(); - - private: - UITestApplication* app; - QString testPlugin; - }; -}; - -} - -#endif /* BERRYUITESTAPPLICATION_H_ */ diff --git a/Plugins/org.blueberry.uitest/src/harness/berryUITestCase.cpp b/Plugins/org.blueberry.uitest/src/harness/berryUITestCase.cpp deleted file mode 100644 index e95afec4c4..0000000000 --- a/Plugins/org.blueberry.uitest/src/harness/berryUITestCase.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryUITestCase.h" - -#include -#include - -#include "util/berryEmptyPerspective.h" - -#ifdef BLUEBERRY_DEBUG_SMARTPOINTER -#include -#endif - -namespace berry -{ - -IAdaptable* UITestCase::GetPageInput() -{ - return 0; -} - -UITestCase::UITestCase(const QString& testName) : - TestCase(testName) -{ - // ErrorDialog.NO_UI = true; - fWorkbench = PlatformUI::GetWorkbench(); -} - -void UITestCase::failexc(const QString& message, const std::exception& e, - long /*lineNumber*/, const QString& /*fileName*/) -{ - //TODO IStatus - // If the exception is a CoreException with a multistatus - // then print out the multistatus so we can see all the info. - // if (e instanceof CoreException) { - // IStatus status = ((CoreException) e).getStatus(); - // write(status, 0); - // } else - // e.printStackTrace(); - CPPUNIT_FAIL(message.toStdString() + ": " + e.what()); -} - -IWorkbenchWindow::Pointer UITestCase::OpenTestWindow() -{ - return OpenTestWindow(EmptyPerspective::PERSP_ID); -} - -IWorkbenchWindow::Pointer UITestCase::OpenTestWindow( - const QString& perspectiveId) -{ - try - { - IWorkbenchWindow::Pointer window = fWorkbench->OpenWorkbenchWindow( - perspectiveId, GetPageInput()); - WaitOnShell(window->GetShell()); - return window; - } catch (const WorkbenchException& e) - { - CPPUNIT_FAIL(e.what()); - return IWorkbenchWindow::Pointer(0); - } -} - -void UITestCase::CloseAllTestWindows() -{ - while (!testWindows.empty()) - { - testWindows.back()->Close(); - testWindows.pop_back(); - } -} - -IWorkbenchPage::Pointer UITestCase::OpenTestPage(const IWorkbenchWindow::Pointer& /*win*/) -{ - // IWorkbenchPage[] pages = openTestPage(win, 1); - // if (pages != null) - // return pages[0]; - // else - return IWorkbenchPage::Pointer(0); -} - -QList UITestCase::OpenTestPage( - const IWorkbenchWindow::Pointer& /*win*/, int /*pageTotal*/) -{ - // try { - // IWorkbenchPage[] pages = new IWorkbenchPage[pageTotal]; - // IAdaptable input = getPageInput(); - // - // for (int i = 0; i < pageTotal; i++) { - // pages[i] = win.openPage(EmptyPerspective.PERSP_ID, input); - // } - // return pages; - // } catch (WorkbenchException e) { - // fail(); - // return null; - // } - return QList(); -} - -void UITestCase::CloseAllPages(const IWorkbenchWindow::Pointer& /*window*/) -{ - // IWorkbenchPage[] pages = window.getPages(); - // for (int i = 0; i < pages.length; i++) - // pages[i].close(); -} - -void UITestCase::Trace(const QString& msg) -{ - qDebug() << msg; -} - -void UITestCase::setUp() -{ - QString name = QString::fromStdString(this->getName()); - Trace("----- " + name); - Trace(name + ": setUp..."); - AddWindowListener(); - berry::TestCase::setUp(); -} - -void UITestCase::DoSetUp() -{ - // do nothing. -} - -void UITestCase::tearDown() -{ - Trace(QString::fromStdString(this->getName()) + ": tearDown...\n"); - RemoveWindowListener(); - berry::TestCase::tearDown(); -} - -void UITestCase::DoTearDown() -{ - ProcessEvents(); - CloseAllTestWindows(); - ProcessEvents(); -} - -void UITestCase::ProcessEvents() -{ - // Display display = PlatformUI.getWorkbench().getDisplay(); - // if (display != null) - // while (display.readAndDispatch()) - // ; -} - -void UITestCase::ManageWindows(bool manage) -{ - windowListener->SetEnabled(manage); -} - -IWorkbench* UITestCase::GetWorkbench() -{ - return fWorkbench; -} - -UITestCase::TestWindowListener::TestWindowListener( - QList& testWindows) - : enabled(true), testWindows(testWindows) -{ -} - -void UITestCase::TestWindowListener::SetEnabled(bool enabled) -{ - this->enabled = enabled; -} - -void UITestCase::TestWindowListener::WindowActivated( - const IWorkbenchWindow::Pointer& /*window*/) -{ - // do nothing -} - -void UITestCase::TestWindowListener::WindowDeactivated( - const IWorkbenchWindow::Pointer& /*window*/) -{ - // do nothing -} - -void UITestCase::TestWindowListener::WindowClosed( - const IWorkbenchWindow::Pointer& window) -{ - if (enabled) - testWindows.removeAll(window); -} - -void UITestCase::TestWindowListener::WindowOpened( - const IWorkbenchWindow::Pointer& window) -{ - if (enabled) - testWindows.push_back(window); -} - -void UITestCase::Indent(std::ostream& output, unsigned int indent) -{ - for (unsigned int i = 0; i < indent; i++) - output << " "; -} - -// void UITestCase::Write(IStatus status, unsigned int indent) { -// PrintStream output = System.out; -// indent(output, indent); -// output.println("Severity: " + status.getSeverity()); -// -// indent(output, indent); -// output.println("Plugin ID: " + status.getPlugin()); -// -// indent(output, indent); -// output.println("Code: " + status.getCode()); -// -// indent(output, indent); -// output.println("Message: " + status.getMessage()); -// -// if (status.getException() != null) { -// indent(output, indent); -// output.print("Exception: "); -// status.getException().printStackTrace(output); -// } -// -// if (status.isMultiStatus()) { -// IStatus[] children = status.getChildren(); -// for (int i = 0; i < children.length; i++) -// write(children[i], indent + 1); -// } -// } - -void UITestCase::AddWindowListener() -{ - windowListener.reset(new TestWindowListener(testWindows)); - fWorkbench->AddWindowListener(windowListener.data()); -} - -void UITestCase::RemoveWindowListener() -{ - if (windowListener) - { - fWorkbench->RemoveWindowListener(windowListener.data()); - } -} - -void UITestCase::WaitOnShell(Shell::Pointer /*shell*/) -{ - - ProcessEvents(); - // long endTime = System.currentTimeMillis() + 5000; - // - // while (shell.getDisplay().getActiveShell() != shell - // && System.currentTimeMillis() < endTime) { - // processEvents(); - // } -} - -} diff --git a/Plugins/org.blueberry.uitest/src/harness/berryUITestCase.h b/Plugins/org.blueberry.uitest/src/harness/berryUITestCase.h deleted file mode 100644 index ef1275ce98..0000000000 --- a/Plugins/org.blueberry.uitest/src/harness/berryUITestCase.h +++ /dev/null @@ -1,206 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYUITESTCASE_H_ -#define BERRYUITESTCASE_H_ - -#include - -#include -#include -#include - -#include - -#include - -namespace berry -{ - -/** - * UITestCase is a useful super class for most - * UI tests cases. It contains methods to create new windows - * and pages. It will also automatically close the test - * windows when the tearDown method is called. - */ -class BERRY_UITEST_EXPORT UITestCase: public TestCase -{ - -public: - - /** - * Returns the workbench page input to use for newly created windows. - * - * @return the page input to use for newly created windows - * @since 3.1 - */ - static IAdaptable* GetPageInput(); - - UITestCase(const QString& testName); - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * The default implementation does nothing. - * Subclasses may extend. - */ - virtual void DoSetUp(); - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * The default implementation closes all test windows, processing events both before - * and after doing so. - * Subclasses may extend. - */ - virtual void DoTearDown(); - - /** - * Fails the test due to the given throwable. - */ - void failexc(const QString& message, const std::exception& e, - long lineNumber = -1, - const QString& fileName = "unknown"); - - /** - * Open a test window with the empty perspective. - */ - IWorkbenchWindow::Pointer OpenTestWindow(); - - /** - * Open a test window with the provided perspective. - */ - IWorkbenchWindow::Pointer OpenTestWindow(const QString& perspectiveId); - - /** - * Close all test windows. - */ - void CloseAllTestWindows(); - - /** - * Open a test page with the empty perspective in a window. - */ - IWorkbenchPage::Pointer OpenTestPage(const IWorkbenchWindow::Pointer& win); - - /** - * Open "n" test pages with the empty perspective in a window. - */ - QList OpenTestPage( - const IWorkbenchWindow::Pointer& win, int pageTotal); - - /** - * Close all pages within a window. - */ - void CloseAllPages(const IWorkbenchWindow::Pointer& window); - -protected: - - /** - * Outputs a trace message to the trace output device, if enabled. - * By default, trace messages are sent to System.out. - * - * @param msg the trace message - */ - void Trace(const QString& msg); - - /** - * Simple implementation of setUp. Subclasses are prevented - * from overriding this method to maintain logging consistency. - * DoSetUp() should be overriden instead. - */ - void setUp(); - - /** - * Simple implementation of tearDown. Subclasses are prevented - * from overriding this method to maintain logging consistency. - * DoTearDown() should be overriden instead. - */ - void tearDown(); - - static void ProcessEvents(); - - /** - * Set whether the window listener will manage opening and closing of created windows. - */ - void ManageWindows(bool manage); - - /** - * Returns the workbench. - * - * @return the workbench - * @since 3.1 - */ - IWorkbench* GetWorkbench(); - - class TestWindowListener: public IWindowListener - { - - private: - bool enabled; - QList& testWindows; - - public: - - TestWindowListener(QList& testWindows); - - void SetEnabled(bool enabled); - - void WindowActivated(const IWorkbenchWindow::Pointer& window); - - void WindowDeactivated(const IWorkbenchWindow::Pointer& window); - - void WindowClosed(const IWorkbenchWindow::Pointer& window); - - void WindowOpened(const IWorkbenchWindow::Pointer& window); - }; - - IWorkbench* fWorkbench; - -private: - - QList testWindows; - - QScopedPointer windowListener; - - static void Indent(std::ostream& output, unsigned int indent); - - //static void Write(IStatus status, unsigned int indent); - - /** - * Adds a window listener to the workbench to keep track of - * opened test windows. - */ - void AddWindowListener(); - - /** - * Removes the listener added by addWindowListener. - */ - void RemoveWindowListener(); - - /** - * Try and process events until the new shell is the active shell. This may - * never happen, so time out after a suitable period. - * - * @param shell - * the shell to wait on - * @since 3.2 - */ - void WaitOnShell(Shell::Pointer shell); - -}; - -#define failuimsg(msg, exc) \ - (this->failexc(msg, exc, __LINE__, __FILE__)) - -} - -#endif /* BERRYUITESTCASE_H_ */ diff --git a/Plugins/org.blueberry.uitest/src/internal/berryPluginActivator.cpp b/Plugins/org.blueberry.uitest/src/internal/berryPluginActivator.cpp deleted file mode 100644 index 1840dbac6a..0000000000 --- a/Plugins/org.blueberry.uitest/src/internal/berryPluginActivator.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#include "berryPluginActivator.h" - -#include "berryUITestApplication.h" -#include "util/berryEmptyPerspective.h" - -namespace berry { - -org_blueberry_uitest_Activator::org_blueberry_uitest_Activator() -{ - -} - -void org_blueberry_uitest_Activator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(UITestApplication, context) - BERRY_REGISTER_EXTENSION_CLASS(EmptyPerspective, context) -} - -void org_blueberry_uitest_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} diff --git a/Plugins/org.blueberry.uitest/src/internal/berryPluginActivator.h b/Plugins/org.blueberry.uitest/src/internal/berryPluginActivator.h deleted file mode 100644 index 357ad53b61..0000000000 --- a/Plugins/org.blueberry.uitest/src/internal/berryPluginActivator.h +++ /dev/null @@ -1,39 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYPLUGINACTIVATOR_H -#define BERRYPLUGINACTIVATOR_H - -#include - -namespace berry { - -class org_blueberry_uitest_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_blueberry_uitest") - Q_INTERFACES(ctkPluginActivator) - -public: - org_blueberry_uitest_Activator(); - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); -}; - -typedef org_blueberry_uitest_Activator PluginActivator; - -} - -#endif // BERRYPLUGINACTIVATOR_H diff --git a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.cpp b/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.cpp deleted file mode 100644 index 9e90c3af1c..0000000000 --- a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryUITestWorkbenchAdvisor.h" -#include "berryUITestWorkbenchWindowAdvisor.h" - -namespace berry -{ - -UITestWorkbenchAdvisor::UITestWorkbenchAdvisor() -{ - -} - -WorkbenchWindowAdvisor* UITestWorkbenchAdvisor::CreateWorkbenchWindowAdvisor( - IWorkbenchWindowConfigurer::Pointer configurer) -{ - return new UITestWorkbenchWindowAdvisor(configurer); -} - -QString UITestWorkbenchAdvisor::GetInitialWindowPerspectiveId() -{ - return QString::null; -} - -} diff --git a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.h b/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.h deleted file mode 100644 index af8c7791d3..0000000000 --- a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchAdvisor.h +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYUITESTWORKBENCHADVISOR_H_ -#define BERRYUITESTWORKBENCHADVISOR_H_ - -#include - -namespace berry { - -class UITestWorkbenchAdvisor : public WorkbenchAdvisor -{ - -public: - - UITestWorkbenchAdvisor(); - - WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor( - IWorkbenchWindowConfigurer::Pointer configurer); - - QString GetInitialWindowPerspectiveId(); - -}; - -} - -#endif /* BERRYUITESTWORKBENCHADVISOR_H_ */ diff --git a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.cpp b/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.cpp deleted file mode 100644 index 86a2be6874..0000000000 --- a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryUITestWorkbenchWindowAdvisor.h" - -#include - -namespace berry { - -UITestWorkbenchWindowAdvisor::UITestWorkbenchWindowAdvisor(const IWorkbenchWindowConfigurer::Pointer& configurer) -: WorkbenchWindowAdvisor(configurer) -{ - -} - -} diff --git a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.h b/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.h deleted file mode 100644 index 8f347eb145..0000000000 --- a/Plugins/org.blueberry.uitest/src/internal/berryUITestWorkbenchWindowAdvisor.h +++ /dev/null @@ -1,30 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYUITESTWORKBENCHWINDOWADVISOR_H_ -#define BERRYUITESTWORKBENCHWINDOWADVISOR_H_ - -#include - -namespace berry { - -class UITestWorkbenchWindowAdvisor : public WorkbenchWindowAdvisor -{ -public: - - UITestWorkbenchWindowAdvisor(const SmartPointer& configurer); -}; - -} - -#endif /* BERRYUITESTWORKBENCHWINDOWADVISOR_H_ */ diff --git a/Plugins/org.blueberry.uitest/src/util/berryEmptyPerspective.cpp b/Plugins/org.blueberry.uitest/src/util/berryEmptyPerspective.cpp deleted file mode 100644 index 49f7d7436d..0000000000 --- a/Plugins/org.blueberry.uitest/src/util/berryEmptyPerspective.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "berryEmptyPerspective.h" - -namespace berry -{ - -QString EmptyPerspective::LastPerspective; -const QString EmptyPerspective::PERSP_ID = - "org.blueberry.uitest.util.EmptyPerspective"; -const QString EmptyPerspective::PERSP_ID2 = - "org.blueberry.uitest.util.EmptyPerspective2"; - -EmptyPerspective::EmptyPerspective() -{ - -} - -EmptyPerspective::EmptyPerspective(const EmptyPerspective& other) - : QObject() -{ - Q_UNUSED(other) -} - -QString EmptyPerspective::GetLastPerspective() -{ - return LastPerspective; -} - -void EmptyPerspective::SetLastPerspective(const QString& perspId) -{ - LastPerspective = perspId; -} - -void EmptyPerspective::CreateInitialLayout(IPageLayout::Pointer layout) -{ - SetLastPerspective(layout->GetDescriptor()->GetId()); - // do no layout, this is the empty perspective -} - -} diff --git a/Plugins/org.blueberry.uitest/src/util/berryEmptyPerspective.h b/Plugins/org.blueberry.uitest/src/util/berryEmptyPerspective.h deleted file mode 100644 index 19b25838c9..0000000000 --- a/Plugins/org.blueberry.uitest/src/util/berryEmptyPerspective.h +++ /dev/null @@ -1,89 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef BERRYEMPTYPERSPECTIVE_H_ -#define BERRYEMPTYPERSPECTIVE_H_ - -#include - -#include - -namespace berry -{ - -/** - * This perspective is used for testing api. It defines an initial - * layout with no parts, just an editor area. - */ -class BERRY_UITEST_EXPORT EmptyPerspective: public QObject, public IPerspectiveFactory -{ - Q_OBJECT - Q_INTERFACES(berry::IPerspectiveFactory) - -private: - - static QString LastPerspective; - -public: - - EmptyPerspective(const EmptyPerspective& other); - - /** - * The perspective id for the empty perspective. - */ - static const QString PERSP_ID; // = "org.blueberry.uitest.util.EmptyPerspective"; - - /** - * The perspective id for the second empty perspective. - */ - static const QString PERSP_ID2; // = "org.blueberry.uitest.util.EmptyPerspective2"; - - - /** - * Returns the descriptor for the perspective last opened using this factory. - * - * @return the descriptor for the perspective last opened using this factory, or null - */ - static QString GetLastPerspective(); - - /** - * Sets the descriptor for the perspective last opened using this factory. - * - * @param persp the descriptor for the perspective last opened using this factory, or null - */ - static void SetLastPerspective(const QString& perspId); - - /** - * Constructs a new Default layout engine. - */ - EmptyPerspective(); - - /** - * Defines the initial layout for a perspective. - * - * Implementors of this method may add additional views to a - * perspective. The perspective already contains an editor folder - * with ID = ILayoutFactory::ID_EDITORS. Add additional views - * to the perspective in reference to the editor folder. - * - * This method is only called when a new perspective is created. If - * an old perspective is restored from a persistence file then - * this method is not called. - * - * @param factory the factory used to add views to the perspective - */ - void CreateInitialLayout(IPageLayout::Pointer layout); -}; - -} - -#endif /* BERRYEMPTYPERSPECTIVE_H_ */ diff --git a/Plugins/org.blueberry.uitest/src/util/berryUITestCaller.h b/Plugins/org.blueberry.uitest/src/util/berryUITestCaller.h deleted file mode 100644 index 39bea30484..0000000000 --- a/Plugins/org.blueberry.uitest/src/util/berryUITestCaller.h +++ /dev/null @@ -1,67 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef BERRYUITESTCALLER_H_ -#define BERRYUITESTCALLER_H_ - -#include -#include - -#include - -namespace berry { - -template -class UITestCaller: public CppUnit::TestCase -{ - REFERENCEOBJECT (UITestCaller) - - typedef void (Fixture::*TestMethod)(); - -public: - UITestCaller(const std::string& name, TestMethod test): - CppUnit::TestCase(name), - _test(test), - _fixture(new Fixture(name)) - { - } - -protected: - void runTest() - { - (_fixture.get()->*_test)(); - } - - void setUp() - { - _fixture.get()->DoSetUp(); - } - - void tearDown() - { - _fixture.get()->DoTearDown(); - } - -private: - TestMethod _test; - std::unique_ptr _fixture; -}; - - -} // namespace berry - - -#define CppUnit_addUITest(suite, cls, mth) \ - suite->addTest(new berry::UITestCaller(#mth, &cls::mth)) - -#endif /* BERRYUITESTCALLER_H_ */ diff --git a/Plugins/org.mitk.gui.qt.common/testing/CMakeLists.txt b/Plugins/org.mitk.gui.qt.common/testing/CMakeLists.txt deleted file mode 100644 index c56ac6d48a..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -project(org_mitk_gui_qt_common_tests) - -mitk_create_plugin( - EXPORT_DIRECTIVE org_mitk_gui_qt_common_tests_EXPORT - EXPORTED_INCLUDE_SUFFIXES src src/api - MODULE_DEPENDS MitkQtWidgets - TEST_PLUGIN -) - -target_link_libraries(${PROJECT_NAME} optimized CppUnit debug CppUnitd) - -MACRO_TEST_UIPLUGIN(${MITK_DEFAULT_SUBPROJECTS}) - diff --git a/Plugins/org.mitk.gui.qt.common/testing/files.cmake b/Plugins/org.mitk.gui.qt.common/testing/files.cmake deleted file mode 100644 index 04afecf423..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/files.cmake +++ /dev/null @@ -1,37 +0,0 @@ -set(MOC_H_FILES - src/QmitkQtCommonTestSuite.h - src/api/QmitkMockFunctionality.h - - src/internal/mitkPluginActivator.h -) - -set(SRC_CPP_FILES - - QmitkQtCommonTestSuite.cpp - - # API Tests - api/QmitkFunctionalityTest.cpp - api/QmitkMockFunctionality.cpp - api/QmitkUiApiTestSuite.cpp - -) - -set(INTERNAL_CPP_FILES - mitkPluginActivator.cpp -) - -set(CPP_FILES ) - -set(RESOURCE_FILES - -# icons/view.gif -) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/Plugins/org.mitk.gui.qt.common/testing/manifest.cpp b/Plugins/org.mitk.gui.qt.common/testing/manifest.cpp deleted file mode 100644 index 5323237093..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/manifest.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include - -#include "src/QmitkQtCommonTestSuite.h" - -#include "src/api/QmitkMockFunctionality.h" - -POCO_BEGIN_NAMED_MANIFEST(CppUnitTest, CppUnit::Test) - POCO_EXPORT_CLASS(QmitkQtCommonTestSuite) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart) - POCO_EXPORT_CLASS(QmitkMockFunctionality) -POCO_END_MANIFEST - diff --git a/Plugins/org.mitk.gui.qt.common/testing/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.common/testing/manifest_headers.cmake deleted file mode 100644 index 43e03a0eb8..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "MITK Common GUI Qt Tests") -set(Plugin-Version "0.9") -set(Plugin-Vendor "German Cancer Research Center (DKFZ)") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.blueberry.uitest org.mitk.gui.qt.common) - diff --git a/Plugins/org.mitk.gui.qt.common/testing/plugin.xml b/Plugins/org.mitk.gui.qt.common/testing/plugin.xml deleted file mode 100644 index 2b6d834020..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/plugin.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.cpp deleted file mode 100644 index b134a8221c..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkQtCommonTestSuite.h" - -#include "api/QmitkUiApiTestSuite.h" - -#include - -QmitkQtCommonTestSuite::QmitkQtCommonTestSuite() -: CppUnit::TestSuite("QmitkQtCommonTestSuite") -{ - addTest(new QmitkUiApiTestSuite()); -} - -QmitkQtCommonTestSuite::QmitkQtCommonTestSuite(const QmitkQtCommonTestSuite& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.h b/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.h deleted file mode 100644 index 86b28a4edc..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.h +++ /dev/null @@ -1,33 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QMITKQTCOMMONTESTSUITE_H_ -#define QMITKQTCOMMONTESTSUITE_H_ - -#include - -#include - -Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test") - -class QmitkQtCommonTestSuite : public QObject, public CppUnit::TestSuite -{ - Q_OBJECT - Q_INTERFACES(CppUnit::Test) - -public: - - QmitkQtCommonTestSuite(); - QmitkQtCommonTestSuite(const QmitkQtCommonTestSuite& other); -}; - -#endif /* QMITKQTCOMMONTESTSUITE_H_ */ diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.cpp deleted file mode 100644 index 542ac39160..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkFunctionalityTest.h" - -#include -#include - -#include "QmitkMockFunctionality.h" - -QmitkFunctionalityTest::QmitkFunctionalityTest(const std::string& testName) - : berry::UITestCase(testName) -{ - -} - -CppUnit::Test* QmitkFunctionalityTest::Suite() -{ - CppUnit::TestSuite* suite = new CppUnit::TestSuite("QmitkFunctionalityTest"); - - CppUnit_addTest(suite, QmitkFunctionalityTest, TestOpenAndClose); - - return suite; -} - -void QmitkFunctionalityTest::DoSetUp() -{ - UITestCase::DoSetUp(); - fWindow = OpenTestWindow(); - fPage = fWindow->GetActivePage(); -} - -void QmitkFunctionalityTest::DoTearDown() -{ - fPage = 0; - fWindow = 0; - UITestCase::DoTearDown(); -} - -void QmitkFunctionalityTest::TestOpenAndClose() -{ - this->IgnoreLeakingObjects(); - - berry::CallHistory::Pointer history; - std::vector callOrder; - { - // Open a functionality. - QmitkMockFunctionality::Pointer part = fPage->ShowView(QmitkMockFunctionality::ID).Cast (); - history = part->GetCallHistory(); - - //callOrder.push_back("SetInitializationData"); - //callOrder.push_back("Init"); - callOrder.push_back("CreateQtPartControl"); - callOrder.push_back("SetFocus"); - - assert(history->VerifyOrder(callOrder)); - - // Close the part. - fPage->HideView(part.Cast()); - } - - //callOrder.push_back("WidgetDisposed"); - callOrder.push_back("FunctionalityDestructor"); - assert(history->VerifyOrder(callOrder)); -} - -void QmitkFunctionalityTest::TestOpenAndWindowClose() -{ - this->IgnoreLeakingObjects(); - - berry::CallHistory::Pointer history; - std::vector callOrder; - { - // Open a new window - berry::IWorkbenchWindow::Pointer newWindow = OpenTestWindow(); - - // Open a part. - QmitkMockFunctionality::Pointer part = newWindow->GetActivePage()->ShowView(QmitkMockFunctionality::ID).Cast ();; - history = part->GetCallHistory(); - - //callOrder.push_back("SetInitializationData"); - //callOrder.push_back("Init"); - callOrder.push_back("CreateQtPartControl"); - callOrder.push_back("SetFocus"); - - assert(history->VerifyOrder(callOrder)); - - // Close the window. - newWindow->Close(); - } - - //callOrder.push_back("WidgetDisposed"); - callOrder.push_back("FunctionalityDestructor"); - assert(history->VerifyOrder(callOrder)); -} diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.h b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.h deleted file mode 100644 index 66395f8a99..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.h +++ /dev/null @@ -1,52 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef QMITKFUNCTIONALITYTEST_H_ -#define QMITKFUNCTIONALITYTEST_H_ - -#include - -#include -#include - -#include - -/** - * Test cases for the QmitkFunctionality API. - */ -class QmitkFunctionalityTest : public berry::UITestCase { - -public: - - friend class CppUnit::TestCaller; - - QmitkFunctionalityTest(const std::string& testName); - - static CppUnit::Test* Suite(); - - void TestOpenAndClose(); - void TestOpenAndWindowClose(); - -protected: - - berry::IWorkbenchWindow::Pointer fWindow; - berry::IWorkbenchPage::Pointer fPage; - - void DoSetUp(); - void DoTearDown(); - - -}; - - -#endif /* QMITKFUNCTIONALITYTEST_H_ */ diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.cpp deleted file mode 100644 index 0a2f9b1152..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkMockFunctionality.h" - -const std::string QmitkMockFunctionality::ID = "org.mitk.gui.qt.common.tests.api.MockFunctionality"; - -QmitkMockFunctionality::QmitkMockFunctionality() -: callTrace(new berry::CallHistory()) -{ - -} - -QmitkMockFunctionality::QmitkMockFunctionality(const QmitkMockFunctionality& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -QmitkMockFunctionality::~QmitkMockFunctionality() -{ - callTrace->Add("FunctionalityDestructor"); -} - -berry::CallHistory::Pointer QmitkMockFunctionality::GetCallHistory() const -{ - return callTrace; -} - -void QmitkMockFunctionality::CreateQtPartControl(QWidget* parent) -{ - callTrace->Add("CreateQtPartControl"); -} - -void QmitkMockFunctionality::SetFocus() -{ - QmitkFunctionality::SetFocus(); - callTrace->Add("SetFocus"); -} diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.h b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.h deleted file mode 100644 index f419eaf1d3..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.h +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef QMITKMOCKFUNCTIONALITY_H_ -#define QMITKMOCKFUNCTIONALITY_H_ - -#include - -#include - -class QmitkMockFunctionality : public QmitkFunctionality -{ - Q_OBJECT - -public: - - berryObjectMacro(QmitkMockFunctionality); - - static const std::string ID; // = "org.mitk.gui.qt.common.tests.api.MockFunctionality"; - - QmitkMockFunctionality(); - QmitkMockFunctionality(const QmitkMockFunctionality& other); - - ~QmitkMockFunctionality(); - - berry::CallHistory::Pointer GetCallHistory() const; - - void SetFocus(); - -protected: - - void CreateQtPartControl(QWidget* parent); - -private: - - berry::CallHistory::Pointer callTrace; -}; - -#endif /* QMITKMOCKFUNCTIONALITY_H_ */ diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.cpp deleted file mode 100644 index f35fa6e463..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkUiApiTestSuite.h" - -#include "QmitkFunctionalityTest.h" - -QmitkUiApiTestSuite::QmitkUiApiTestSuite() -: CppUnit::TestSuite("QmitkUiApiTestSuite") -{ - addTest(QmitkFunctionalityTest::Suite()); - -} diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.h b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.h deleted file mode 100644 index 6791905d4c..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.h +++ /dev/null @@ -1,27 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef QMITKUIAPITESTSUITE_H_ -#define QMITKUIAPITESTSUITE_H_ - -#include - -class QmitkUiApiTestSuite : public CppUnit::TestSuite -{ - -public: - - QmitkUiApiTestSuite(); -}; - -#endif /* QMITKUIAPITESTSUITE_H_ */ diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.cpp deleted file mode 100644 index ca10365e4c..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "mitkPluginActivator.h" -#include "../QmitkQtCommonTestSuite.h" -#include "../api/QmitkMockFunctionality.h" - -namespace mitk { - -void PluginActivator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(QmitkQtCommonTestSuite, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkMockFunctionality, context) -} - -void PluginActivator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} diff --git a/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.h deleted file mode 100644 index f188e754ae..0000000000 --- a/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.h +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ -#ifndef MITKPLUGINACTIVATOR_H -#define MITKPLUGINACTIVATOR_H - -#include - -namespace mitk { - -class PluginActivator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_common_tests") - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; // PluginActivator - -} - -#endif // MITKPLUGINACTIVATOR_H