[Libreoffice-commits] core.git: writerperfect/qa
David Tardon
dtardon at redhat.com
Mon Mar 31 04:19:45 PDT 2014
writerperfect/qa/unit/WpftImportTestBase.cxx | 48 +++++++++++++++------------
1 file changed, 27 insertions(+), 21 deletions(-)
New commits:
commit c6821e66a66bd8fbb2c5a617e49783b7a4fc0724
Author: David Tardon <dtardon at redhat.com>
Date: Mon Mar 31 12:36:27 2014 +0200
speed up the import tests
Change-Id: If3f0198d58b6c64a4efd4be294f1d66fb39f2302
diff --git a/writerperfect/qa/unit/WpftImportTestBase.cxx b/writerperfect/qa/unit/WpftImportTestBase.cxx
index 773fa3b..4a05d05 100644
--- a/writerperfect/qa/unit/WpftImportTestBase.cxx
+++ b/writerperfect/qa/unit/WpftImportTestBase.cxx
@@ -80,6 +80,30 @@ bool WpftImportTestBase::load(const OUString &, const OUString &rURL, const OUSt
m_xDesktop->loadComponentFromURL(m_aFactoryURL, "_blank", 0, uno::Sequence<beans::PropertyValue>()),
uno::UNO_QUERY_THROW);
+ // Find the model and frame. We need them later.
+ uno::Reference<frame::XFrame> xFrame(xDoc, uno::UNO_QUERY);
+ uno::Reference<frame::XModel> xModel(xDoc, uno::UNO_QUERY);
+ uno::Reference<frame::XController> xController(xDoc, uno::UNO_QUERY);
+
+ if (xFrame.is())
+ {
+ xController = xFrame->getController();
+ xModel = xController->getModel();
+ }
+ else if (xModel.is())
+ {
+ xController = xModel->getCurrentController();
+ xFrame = xController->getFrame();
+ }
+ else if (xController.is())
+ {
+ xFrame = xController->getFrame();
+ xModel = xController->getModel();
+ }
+
+ if (!xFrame.is() || !xModel.is())
+ throw uno::RuntimeException();
+
bool result = false;
// try to import the document (and load it into the prepared frame)
@@ -105,7 +129,9 @@ bool WpftImportTestBase::load(const OUString &, const OUString &rURL, const OUSt
impl_detectFilterName(aDescriptor, aTypeName);
+ xModel->lockControllers();
result = m_xFilter->filter(aDescriptor);
+ xModel->unlockControllers();
}
catch (const uno::Exception &)
{
@@ -113,29 +139,9 @@ bool WpftImportTestBase::load(const OUString &, const OUString &rURL, const OUSt
}
// close the opened document
- uno::Reference<util::XCloseable> xCloseable(xDoc, uno::UNO_QUERY);
-
- if (!xCloseable.is())
- {
- uno::Reference<frame::XController> xController(xDoc, uno::UNO_QUERY);
-
- if (!xController.is())
- {
- const uno::Reference<frame::XModel> xModel(xDoc, uno::UNO_QUERY);
- if (xModel.is())
- xController = xModel->getCurrentController();
- }
-
- if (xController.is())
- {
- const uno::Reference<frame::XFrame> xFrame = xController->getFrame();
- if (xFrame.is())
- xCloseable.set(xFrame, uno::UNO_QUERY);
- }
- }
-
try
{
+ uno::Reference<util::XCloseable> xCloseable(xFrame, uno::UNO_QUERY);
if (xCloseable.is())
xCloseable->close(true);
else
More information about the Libreoffice-commits
mailing list