23 #include <berryStarter.h>
25 #include "internal/berryUITestWorkbenchAdvisor.h"
30 class WorkbenchCloseRunnable:
public Poco::Runnable
33 WorkbenchCloseRunnable(IWorkbench* workbench) :
44 IWorkbench* workbench;
47 UITestApplication::TestRunnable::TestRunnable(UITestApplication* app,
48 const QString& testPlugin) :
49 app(app), testPlugin(testPlugin)
53 void UITestApplication::TestRunnable::run()
59 catch (
const ctkException& e)
61 qWarning() << e.printStackTrace();
63 catch (
const std::exception& e)
65 qWarning() << e.what();
79 testPlugin = QString::fromStdString(Platform::GetConfiguration().getString(
80 Platform::ARG_TESTPLUGIN.toStdString()));
81 }
catch (
const Poco::NotFoundException& )
83 BERRY_ERROR <<
"You must specify a test plug-in id via "
84 << Platform::ARG_TESTPLUGIN <<
"=<id>";
90 poco_assert(application);
91 int result = RunApplication(application);
95 std::cerr <<
"UITestRunner: Unexpected result from running application " << application <<
": " << result << std::endl;
97 return testDriverResult;
106 WorkbenchCloseRunnable runnable(workbench);
112 TestRunnable runnable(
this, testPlugin);
113 testableObject->TestingStarting();
114 testableObject->RunTest(&runnable);
115 testableObject->TestingFinished();
125 QList<IConfigurationElement::Pointer> extensions(
128 QString appToRun = GetApplicationToRun();
132 id = configElem->GetAttribute(
"id");
135 extension = configElem->GetDeclaringExtension();
140 IApplication* app = 0;
144 QList<IConfigurationElement::Pointer> elements(
145 extension->GetConfigurationElements());
146 if (!elements.isEmpty())
148 QList<IConfigurationElement::Pointer> runs(
149 elements[0]->GetChildren(
"run"));
152 app = runs[0]->CreateExecutableExtension<IApplication> (
"class");
161 QString UITestApplication::GetApplicationToRun()
167 testApp = QString::fromStdString(Platform::GetConfiguration().getString(
168 Platform::ARG_TESTAPPLICATION.toStdString()));
170 catch (
const Poco::NotFoundException&)
177 int UITestApplication::RunApplication(IApplication* application)
182 if (application == dynamic_cast<IApplication*>(
this))
183 return RunUITestWorkbench();
185 return application->Start();
188 int UITestApplication::RunUITestWorkbench()
191 UITestWorkbenchAdvisor advisor;
itk::SmartPointer< Self > Pointer
virtual void SyncExec(Poco::Runnable *)=0
virtual Display * GetDisplay() const =0