Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uibase / shells / textsh.cxx
bloba97fc8bd7f5f16dfc57aac144fe38bcb839e808f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <swmodeltestbase.hxx>
12 #include <comphelper/propertyvalue.hxx>
13 #include <comphelper/propertysequence.hxx>
14 #include <comphelper/sequence.hxx>
16 #include <docary.hxx>
18 namespace
20 /// Covers sw/source/uibase/shells/textsh.cxx fixes.
21 class Test : public SwModelTestBase
23 public:
24 Test()
25 : SwModelTestBase("/sw/qa/uibase/shells/data/")
30 CPPUNIT_TEST_FIXTURE(Test, testDeleteSections)
32 // Given a document with a section:
33 createSwDoc();
34 SwDoc* pDoc = getSwDoc();
35 uno::Sequence<css::beans::PropertyValue> aArgs = {
36 comphelper::makePropertyValue("RegionName",
37 uno::Any(OUString("ZOTERO_BIBL {} CSL_BIBLIOGRAPHY RND"))),
38 comphelper::makePropertyValue("Content", uno::Any(OUString("old content"))),
40 dispatchCommand(mxComponent, ".uno:InsertSection", aArgs);
41 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDoc->GetSections().size());
43 // When deleting sections:
44 std::vector<beans::PropertyValue> aArgsVec = comphelper::JsonToPropertyValues(R"json(
46 "SectionNamePrefix": {
47 "type": "string",
48 "value": "ZOTERO_BIBL"
51 )json");
52 aArgs = comphelper::containerToSequence(aArgsVec);
53 dispatchCommand(mxComponent, ".uno:DeleteSections", aArgs);
55 // Then make sure that the section is deleted:
56 // Without the accompanying fix in place, this test would have failed with:
57 // - Expected: 0
58 // - Actual : 1
59 // i.e. the section was not deleted.
60 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pDoc->GetSections().size());
64 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */