1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include <test/calc_unoapi_test.hxx>
11 #include <test/sheet/xrecentfunctions.hxx>
12 
13 #include <com/sun/star/lang/XComponent.hpp>
14 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
15 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
16 #include <com/sun/star/uno/XInterface.hpp>
17 
18 #include <com/sun/star/uno/Reference.hxx>
19 
20 using namespace css;
21 using namespace css::uno;
22 using namespace com::sun::star;
23 
24 namespace sc_apitest
25 {
26 class ScRecentFunctionsObj : public CalcUnoApiTest, public apitest::XRecentFunctions
27 {
28 public:
29     ScRecentFunctionsObj();
30 
31     virtual uno::Reference<uno::XInterface> init() override;
32     virtual void setUp() override;
33     virtual void tearDown() override;
34 
35     CPPUNIT_TEST_SUITE(ScRecentFunctionsObj);
36 
37     // XRecentFunctions
38     CPPUNIT_TEST(testGetRecentFunctionIds);
39     CPPUNIT_TEST(testSetRecentFunctionIds);
40     CPPUNIT_TEST(testGetMaxRecentFunctions);
41 
42     CPPUNIT_TEST_SUITE_END();
43 
44 private:
45     uno::Reference<lang::XComponent> mxComponent;
46 };
47 
ScRecentFunctionsObj()48 ScRecentFunctionsObj::ScRecentFunctionsObj()
49     : CalcUnoApiTest("/sc/qa/extras/testdocuments")
50 {
51 }
52 
init()53 uno::Reference<uno::XInterface> ScRecentFunctionsObj::init()
54 {
55     uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
56     uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
57     return xMSF->createInstance("com.sun.star.sheet.RecentFunctions");
58 }
59 
setUp()60 void ScRecentFunctionsObj::setUp()
61 {
62     CalcUnoApiTest::setUp();
63     // create a calc document
64     mxComponent = loadFromDesktop("private:factory/scalc");
65 }
66 
tearDown()67 void ScRecentFunctionsObj::tearDown()
68 {
69     closeDocument(mxComponent);
70     CalcUnoApiTest::tearDown();
71 }
72 
73 CPPUNIT_TEST_SUITE_REGISTRATION(ScRecentFunctionsObj);
74 
75 } // end namespace
76 
77 CPPUNIT_PLUGIN_IMPLEMENT();
78 
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
80