framework/CppunitTest_framework_CheckXTitle.mk |   43 +++
 framework/JunitTest_framework_complex.mk       |    2 
 framework/Module_framework.mk                  |    1 
 framework/qa/complex/XTitle/CheckXTitle.java   |  325 -------------------------
 framework/qa/cppunit/CheckXTitle.cxx           |  158 ++++++++++++
 5 files changed, 202 insertions(+), 327 deletions(-)

New commits:
commit 4078428a401f4a99045451b59863d6001cdcc20b
Author:     Adam Seskunas <adamsesku...@gmail.com>
AuthorDate: Tue May 28 10:33:38 2024 -0700
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jun 4 09:11:39 2024 +0200

    Port framework/qa/complex/XTitle/CheckXTile.java to Cppunit
    
    framework
        - Remove CheckXTitle.java from makefiles
        - Create new makefile for CheckXTitle
    
    framework qa complex XTitle
        - Remove JUnit test
    
    framework qa cppunit
        - Add new CppUnit test suit CheckXTitle.cxx
        - checkDefaultTitle: tests if default title is the same after cycling 
through the default window and print preview
        - checkTitleDefaultFileName: tests if a window title set with  
SuggestedSaveAs is in fact set with said name
        - setTitleAndCheck: tests if after setting window title and cycling 
through default window and print preview, there is infinite recursion
    
    Change-Id: If7794f0f853ef427bb735a22752cff3635f5ff63
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168168
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/framework/CppunitTest_framework_CheckXTitle.mk 
b/framework/CppunitTest_framework_CheckXTitle.mk
new file mode 100644
index 000000000000..59f02421f5ed
--- /dev/null
+++ b/framework/CppunitTest_framework_CheckXTitle.mk
@@ -0,0 +1,43 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,framework_CheckXTitle))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,framework_CheckXTitle, \
+    framework/qa/cppunit/CheckXTitle \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,framework_CheckXTitle))
+
+$(eval $(call gb_CppunitTest_use_libraries,framework_CheckXTitle, \
+       comphelper \
+       cppu \
+       cppuhelper \
+       sal \
+       salhelper \
+       subsequenttest \
+       test \
+       unotest \
+       utl \
+       tl \
+       vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_external,framework_CheckXTitle,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,framework_CheckXTitle))
+
+$(eval $(call gb_CppunitTest_use_ure,framework_CheckXTitle))
+$(eval $(call gb_CppunitTest_use_vcl,framework_CheckXTitle))
+
+$(eval $(call gb_CppunitTest_use_rdb,framework_CheckXTitle,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,framework_CheckXTitle))
+
+# vim: set noet sw=4 ts=4:
diff --git a/framework/JunitTest_framework_complex.mk 
b/framework/JunitTest_framework_complex.mk
index 30f24b810458..a582235b8d41 100644
--- a/framework/JunitTest_framework_complex.mk
+++ b/framework/JunitTest_framework_complex.mk
@@ -58,12 +58,10 @@ $(eval $(call 
gb_JunitTest_add_sourcefiles,framework_complex,\
     framework/qa/complex/dispatches/checkdispatchapi \
     framework/qa/complex/dispatches/Interceptor \
     framework/qa/complex/ModuleManager/CheckXModuleManager \
-    framework/qa/complex/XTitle/CheckXTitle \
 ))
 
 $(eval $(call gb_JunitTest_add_classes,framework_complex,\
     complex.dispatches.checkdispatchapi \
-    complex.XTitle.CheckXTitle \
 ))
 # these were disabled in the old build system too, please check
 # carefully before reenabling
diff --git a/framework/Module_framework.mk b/framework/Module_framework.mk
index 924989d0672a..7521418d3861 100644
--- a/framework/Module_framework.mk
+++ b/framework/Module_framework.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_Module_add_targets,framework,\
 $(eval $(call gb_Module_add_slowcheck_targets,framework,\
     CppunitTest_framework_dispatch \
     CppunitTest_framework_loadenv \
+       CppunitTest_framework_CheckXTitle \
 ))
 
 # Not sure why this is not stable on macOS.
diff --git a/framework/qa/complex/XTitle/CheckXTitle.java 
b/framework/qa/complex/XTitle/CheckXTitle.java
deleted file mode 100644
index e20697eba974..000000000000
--- a/framework/qa/complex/XTitle/CheckXTitle.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package complex.XTitle;
-
-import static org.junit.Assert.*;
-import util.utils;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openoffice.test.OfficeConnection;
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.frame.Desktop;
-import com.sun.star.frame.XComponentLoader;
-import com.sun.star.frame.XFrame2;
-import com.sun.star.frame.XModel;
-import com.sun.star.frame.XTitle;
-import com.sun.star.frame.XController;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.URLTransformer;
-import com.sun.star.util.XURLTransformer;
-import com.sun.star.util.URL;
-import com.sun.star.frame.XDispatchProvider;
-import com.sun.star.frame.XDispatch;
-
-/** @short Check the interface XTitle
-
-    @descr These tests check in various cases the correctness of
-           the title in the ui window.
-*/
-
-public class CheckXTitle
-{
-
-    // some const
-    private static final String DOCUMENT_TITLE                    = 
"documentTitle";
-    private static final String UNO_URL_FOR_PRINT_PREVIEW         = 
".uno:PrintPreview";
-    private static final String UNO_URL_FOR_CLOSING_PRINT_PREVIEW = 
".uno:ClosePreview";
-    private static final String UNO_URL_FOR_CLOSING_DOC           = 
".uno:CloseWin";
-
-    // members
-
-    /** will be set to xDesktop OR xFrame. */
-    private XComponentLoader m_xLoader = null;
-
-    /** provides uno service manager */
-    private XMultiServiceFactory m_xMSF = null;
-
-    /** used for parsing uno query URLs */
-    private XURLTransformer m_xParser = null;
-
-    // test environment
-    /** @short  Create the environment for following tests.
-
-        @descr  Use either a component loader from desktop or
-                from frame
-     */
-    @Before public void before() throws Exception
-    {
-        // get uno service manager from global test environment
-        /* points to the global uno service manager. */
-        m_xMSF = getMSF();
-
-        // define default loader
-        m_xLoader = Desktop.create(connection.getComponentContext());
-
-        // get URL parser
-        m_xParser = URLTransformer.create(connection.getComponentContext());
-    }
-
-    /** @short  close the environment.
-     */
-    @After public void after() throws Exception
-    {
-        m_xLoader = null;
-        m_xParser = null;
-        m_xMSF    = null;
-    }
-
-    private URL parseURL(String unoURL)
-    {
-        URL[] aParseURL = new URL[] { new URL() };
-        aParseURL[0].Complete = unoURL;
-        m_xParser.parseStrict(aParseURL);
-        return aParseURL[0];
-    }
-
-    private void waitUntilDispatcherAvailable(XModel xModel, String unoURL)
-        throws InterruptedException
-    {
-        utils.waitForEventIdle(m_xMSF);
-
-        // On Windows, some events such as focus changes are handled
-        // asynchronously using PostMessage (Windows message queue)
-        // so the previous UI transition may still not have completed yet
-        // even though we called waitForEventIdle.
-        //
-        // Loop a few times until the desired dispatcher is available, which
-        // is a better indication that the UI transition has completed.
-
-        XDispatchProvider xDisProv;
-        XDispatch xDispatcher = null;
-        URL parsed_url = parseURL(unoURL);
-
-        for (int ntries = 1; ntries < 5; ++ntries) {
-            xDisProv = UnoRuntime.queryInterface(
-                XDispatchProvider.class, xModel.getCurrentController() );
-            xDispatcher = xDisProv.queryDispatch(parsed_url, "", 0);
-            if (xDispatcher != null)
-                break;
-            Thread.sleep(250);
-        }
-        assertNotNull("Can not obtain dispatcher for query: " + unoURL, 
xDispatcher);
-    }
-
-
-    // prepare a uno URL query and dispatch it
-    private void prepareQueryAndDispatch(XDispatchProvider xDisProv, String 
unoURL)
-    {
-        XDispatch xDispatcher = null;
-        URL parsed_url = parseURL(unoURL);
-
-        xDispatcher = xDisProv.queryDispatch(parsed_url, "", 0);
-        assertNotNull("Can not obtain dispatcher for query: " + unoURL, 
xDispatcher);
-        xDispatcher.dispatch(parsed_url, null);
-    }
-
-    /** @short checks the numbers displayed in the title
-
-        @descr cycles through default view and print preview
-               and asserts that the title doesn't change.
-
-        disabled until the waitUntilDispatcherAvailable can be replaced
-    */
-    @Test
-    public void checkTitleNumbers() throws Exception
-    {
-        PropertyValue[] lArgs = new PropertyValue[1];
-
-        lArgs[0]         = new PropertyValue();
-        lArgs[0].Name    = "Hidden";
-        lArgs[0].Value   = Boolean.FALSE;
-
-        // load doc
-        XComponent xDoc=null;
-        xDoc = m_xLoader.loadComponentFromURL("private:factory/swriter", 
"_blank", 0, lArgs);
-        assertNotNull("Could not load temporary document", xDoc);
-
-        XModel xModel = UnoRuntime.queryInterface( XModel.class, xDoc );
-        XController xController = UnoRuntime.queryInterface( 
XController.class, xModel.getCurrentController() );
-        XTitle xTitle = UnoRuntime.queryInterface( XTitle.class, 
xModel.getCurrentController().getFrame() );
-        XDispatchProvider xDisProv = null;
-
-        // get window title with ui in default mode
-        String defaultTitle = xTitle.getTitle();
-
-        xDisProv = UnoRuntime.queryInterface( XDispatchProvider.class, 
xModel.getCurrentController() );
-        prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_PRINT_PREVIEW );
-        waitUntilDispatcherAvailable( xModel, 
UNO_URL_FOR_CLOSING_PRINT_PREVIEW );
-
-        // get window title with ui in print preview mode
-        String printPreviewTitle = xTitle.getTitle();
-        assertEquals("Title mismatch between default view window title and 
print preview window title",
-                     defaultTitle, printPreviewTitle);
-
-        xDisProv = UnoRuntime.queryInterface( XDispatchProvider.class, 
xModel.getCurrentController() );
-        prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_CLOSING_PRINT_PREVIEW );
-        waitUntilDispatcherAvailable( xModel, UNO_URL_FOR_CLOSING_DOC );
-
-        //get window title with ui back in default mode
-        String printPreviewClosedTitle = xTitle.getTitle();
-        assertEquals("Title mismatch between default view window title and 
title after switching from print preview to default view window"                
     ,defaultTitle, printPreviewClosedTitle);
-
-        xDisProv = UnoRuntime.queryInterface( XDispatchProvider.class, 
xModel.getCurrentController() );
-        prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_CLOSING_DOC );
-
-        xDoc     = null;
-        xDisProv = null;
-    }
-
-    /** checks the if SuggestedSaveAsName is displayed in the title */
-    @Test
-    public void checkTitleSuggestedFileName() throws Exception
-    {
-        PropertyValue[] lArgs = new PropertyValue[2];
-
-        lArgs[0]         = new PropertyValue();
-        lArgs[0].Name    = "Hidden";
-        lArgs[0].Value   = Boolean.FALSE;
-        lArgs[1]         = new PropertyValue();
-        lArgs[1].Name    = "SuggestedSaveAsName";
-        lArgs[1].Value   = "suggestme.odt";
-
-        // load doc
-        XComponent xDoc = 
m_xLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, lArgs);
-        assertNotNull("Could not load temporary document", xDoc);
-
-        XModel xModel = UnoRuntime.queryInterface( XModel.class, xDoc );
-        XTitle xTitle = UnoRuntime.queryInterface( XTitle.class, 
xModel.getCurrentController().getFrame() );
-
-        String title = xTitle.getTitle();
-        assertTrue(title.startsWith("suggestme.odt"));
-
-        XDispatchProvider xDisProv = UnoRuntime.queryInterface( 
XDispatchProvider.class, xModel.getCurrentController() );
-        prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_CLOSING_DOC );
-    }
-
-    /** @short sets frame title and checks for infinite recursion
-
-        @descr sets frame title. then cycles through default and
-               print preview. then closes the window and checks
-               for infinite recursion.
-
-        disabled until the waitUntilDispatcherAvailable can be replaced
-    */
-    @Test
-    public void setTitleAndCheck() throws Exception
-    {
-        PropertyValue[] lArgs = new PropertyValue[1];
-
-        lArgs[0]       = new PropertyValue();
-        lArgs[0].Name  = "Hidden";
-        lArgs[0].Value = Boolean.FALSE;
-
-        // load doc
-        XComponent xDoc = null;
-        xDoc = m_xLoader.loadComponentFromURL("private:factory/swriter", 
"_blank", 0, lArgs);
-        assertNotNull("Could not create office document", xDoc);
-        XModel xModel  = UnoRuntime.queryInterface( XModel.class, xDoc );
-        XFrame2 xFrame = UnoRuntime.queryInterface( XFrame2.class, 
xModel.getCurrentController().getFrame() );
-        XDispatchProvider xDisProv = null;
-        // set doc title
-        xFrame.setTitle(DOCUMENT_TITLE);
-
-        // switch to print preview mode
-        xDisProv = UnoRuntime.queryInterface( XDispatchProvider.class, 
xModel.getCurrentController() );
-        prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_PRINT_PREVIEW );
-        waitUntilDispatcherAvailable( xModel, 
UNO_URL_FOR_CLOSING_PRINT_PREVIEW );
-
-        // switch back to default mode
-        xDisProv = UnoRuntime.queryInterface( XDispatchProvider.class, 
xModel.getCurrentController() );
-        prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_CLOSING_PRINT_PREVIEW );
-        waitUntilDispatcherAvailable( xModel, UNO_URL_FOR_CLOSING_DOC );
-
-        // close document
-        xDisProv = UnoRuntime.queryInterface( XDispatchProvider.class, 
xModel.getCurrentController() );
-        try{
-                prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_CLOSING_DOC );
-        } catch( Exception e ) {
-            fail(e.toString());
-        }
-
-        xDoc     = null;
-        xDisProv = null;
-    }
-
-    /** @short checks creation of new empty document with readonly set to true
-
-        @descr creation of a new document with readonly property set
-               to true.  this should not fail even if as such it can
-               be seen as a slightly silly thing to do. But existing
-               3rd-party code depends on it to work.
-    */
-    @Test public void checkLoadingWithReadOnly()
-    {
-        PropertyValue[] lArgs = new PropertyValue[2];
-
-        lArgs[0]         = new PropertyValue();
-        lArgs[0].Name    = "Hidden";
-        lArgs[0].Value   = Boolean.FALSE;
-        lArgs[1]         = new PropertyValue();
-        lArgs[1].Name    = "ReadOnly";
-        lArgs[1].Value   = Boolean.TRUE;
-
-        // load doc
-        XComponent xDoc = null;
-        try{
-                xDoc = 
m_xLoader.loadComponentFromURL("private:factory/swriter", "_default", 0, lArgs);
-        } catch (Exception e) {
-        }
-        assertNotNull("Creating a new document read with ReadOnly property 
true should work (even if slightly silly)", xDoc);
-    }
-
-    private XMultiServiceFactory getMSF()
-    {
-        return UnoRuntime.queryInterface(XMultiServiceFactory.class, 
connection.getComponentContext().getServiceManager());
-    }
-
-    // setup and close connections
-    @BeforeClass
-    public static void setUpConnection() throws Exception
-    {
-        System.out.println("setUpConnection()");
-        connection.setUp();
-    }
-
-    @AfterClass
-    public static void tearDownConnection()
-            throws InterruptedException, com.sun.star.uno.Exception
-    {
-        System.out.println("tearDownConnection()");
-        connection.tearDown();
-    }
-    private static final OfficeConnection connection = new OfficeConnection();
-}
diff --git a/framework/qa/cppunit/CheckXTitle.cxx 
b/framework/qa/cppunit/CheckXTitle.cxx
new file mode 100644
index 000000000000..8f15eb40d91a
--- /dev/null
+++ b/framework/qa/cppunit/CheckXTitle.cxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/unoapi_test.hxx>
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XTitle.hpp>
+#include <com/sun/star/frame/XDispatchHelper.hpp>
+#include <com/sun/star/frame/XFrame2.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <vcl/scheduler.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+// These were JUnit tests from framework/qa/complex/XTitle/CheckXTitle.java
+class Test : public UnoApiTest
+{
+public:
+    Test()
+        : UnoApiTest(u"/framework/qa/cppunit/data/"_ustr)
+    {
+    }
+};
+
+CPPUNIT_TEST_FIXTURE(Test, checkDefaultTitle)
+{
+    // Cycles through default view and print preview
+    // and asserts that the title doesn't change.
+
+    // Load document
+    uno::Reference<lang::XMultiServiceFactory> 
xFactory(comphelper::getProcessServiceFactory());
+    uno::Reference<uno::XInterface> xInterface
+        = xFactory->createInstance("com.sun.star.frame.Desktop");
+    uno::Reference<frame::XComponentLoader> xComponentLoader(xInterface, 
uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aLoadArgs{ 
comphelper::makePropertyValue("Hidden", false) };
+    mxComponent = 
xComponentLoader->loadComponentFromURL("private:factory/swriter", "_default", 0,
+                                                         aLoadArgs);
+
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<frame::XController> 
xController(xModel->getCurrentController());
+    uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), 
uno::UNO_QUERY);
+
+    uno::Reference<frame::XTitle> xTitle(xFrame, css::uno::UNO_QUERY);
+    OUString defaultTitle = xTitle->getTitle();
+
+    uno::Reference<util::XURLTransformer> 
xParser(util::URLTransformer::create(mxComponentContext));
+
+    // Open print preview window and get title.
+    util::URL printPreviewURL;
+    printPreviewURL.Complete = u".uno::PrintPreview"_ustr;
+    xParser->parseStrict(printPreviewURL);
+    uno::Reference<frame::XDispatchProvider> 
xDispatchProvider(xModel->getCurrentController(),
+                                                               uno::UNO_QUERY);
+    xDispatchProvider->queryDispatch(printPreviewURL, "", 0);
+    uno::Reference<frame::XTitle> xTitle2(xFrame, css::uno::UNO_QUERY);
+    Scheduler::ProcessEventsToIdle();
+
+    // Default window title and print preview window title should be the same.
+    CPPUNIT_ASSERT_EQUAL(defaultTitle, xTitle2->getTitle());
+
+    // Close print preview window and check to see if default window title has 
changed
+    util::URL closePreviewURL;
+    closePreviewURL.Complete = u".uno::ClosePreview"_ustr;
+    xParser->parseStrict(closePreviewURL);
+    uno::Reference<frame::XDispatchProvider> 
xDispatchProvider2(xModel->getCurrentController(),
+                                                                
uno::UNO_QUERY);
+    xDispatchProvider2->queryDispatch(closePreviewURL, "", 0);
+    uno::Reference<frame::XTitle> xTitle3(xFrame, css::uno::UNO_QUERY);
+    Scheduler::ProcessEventsToIdle();
+
+    // Default window title should be the same after closing print preview 
window.
+    CPPUNIT_ASSERT_EQUAL(defaultTitle, xTitle3->getTitle());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, checkTitleSuggestedFileName)
+{
+    uno::Sequence<beans::PropertyValue> aArguments
+        = { comphelper::makePropertyValue(u"SuggestedSaveAsName"_ustr, 
u"suggestedname.odt"_ustr),
+            comphelper::makePropertyValue(u"Hidden"_ustr, false) };
+    mxComponent = loadFromDesktop(u"private:factory/swriter"_ustr, 
"com.sun.star.text.TextDocument",
+                                  aArguments);
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<frame::XController> 
xController(xModel->getCurrentController());
+    uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), 
uno::UNO_QUERY);
+
+    uno::Reference<frame::XTitle> xTitle(xFrame, css::uno::UNO_QUERY);
+    OUString windowTitle = xTitle->getTitle();
+
+    CPPUNIT_ASSERT(windowTitle.startsWith("suggestedname.odt"));
+}
+
+CPPUNIT_TEST_FIXTURE(Test, setTitleAndCheck)
+{
+    // Set the frame title, then cycle through default and print preview. 
Close the window
+    // and check for infinite recursion.
+
+    uno::Reference<lang::XMultiServiceFactory> 
xFactory(comphelper::getProcessServiceFactory());
+    uno::Reference<uno::XInterface> xInterface
+        = xFactory->createInstance("com.sun.star.frame.Desktop");
+    uno::Reference<frame::XComponentLoader> xComponentLoader(xInterface, 
uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aLoadArgs{ 
comphelper::makePropertyValue("Hidden", false) };
+    mxComponent = 
xComponentLoader->loadComponentFromURL("private:factory/swriter", "_default", 0,
+                                                         aLoadArgs);
+
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<frame::XController> 
xController(xModel->getCurrentController());
+    uno::Reference<frame::XFrame2> xFrame(xController->getFrame(), 
uno::UNO_QUERY);
+
+    xFrame->setTitle(u"documentTitle"_ustr);
+
+    uno::Reference<frame::XDispatchProvider> 
xDispatchProvider(xModel->getCurrentController(),
+                                                               uno::UNO_QUERY);
+    uno::Reference<util::XURLTransformer> 
xParser(util::URLTransformer::create(mxComponentContext));
+
+    util::URL printPreviewURL;
+    printPreviewURL.Complete = u".uno::PrintPreview"_ustr;
+    xParser->parseStrict(printPreviewURL);
+    xDispatchProvider->queryDispatch(printPreviewURL, "", 0);
+    Scheduler::ProcessEventsToIdle();
+
+    util::URL closePreviewURL;
+    closePreviewURL.Complete = u".uno::ClosePreview"_ustr;
+    xParser->parseStrict(closePreviewURL);
+    uno::Reference<frame::XDispatchProvider> 
xDispatchProvider2(xModel->getCurrentController(),
+                                                                
uno::UNO_QUERY);
+    xDispatchProvider2->queryDispatch(closePreviewURL, "", 0);
+    Scheduler::ProcessEventsToIdle();
+
+    util::URL closeDocURL;
+    closeDocURL.Complete = u".uno::CloseWin"_ustr;
+    xParser->parseStrict(closeDocURL);
+    uno::Reference<frame::XDispatchProvider> 
xDispatchProvider3(xModel->getCurrentController(),
+                                                                
uno::UNO_QUERY);
+    uno::Reference<frame::XTitle> xTitle(xFrame, css::uno::UNO_QUERY);
+    OUString windowTitle = xTitle->getTitle();
+
+    CPPUNIT_ASSERT_EQUAL(windowTitle, u"documentTitle"_ustr);
+
+    xDispatchProvider3->queryDispatch(closeDocURL, "", 0);
+    Scheduler::ProcessEventsToIdle();
+}
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to