/* -*- 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/bootstrapfixture.hxx>
std::unique_ptr<Gallery> pGallery(new Gallery(aGalleryURL));
CPPUNIT_ASSERT_MESSAGE("Could not create gallery instance", (pGallery != nullptr)); static constexpr OUString myThemeName = u"addytesttheme"_ustr;
CPPUNIT_ASSERT_MESSAGE("Could not create theme", pGallery->CreateTheme(myThemeName));
CPPUNIT_ASSERT_MESSAGE("Could not find theme", pGallery->HasTheme(myThemeName));
// Delete Theme
CPPUNIT_ASSERT_MESSAGE("Could not remove theme", pGallery->RemoveTheme(myThemeName));
CPPUNIT_ASSERT_MESSAGE("Could not remove theme, theme found even after trying to remove",
!pGallery->HasTheme(myThemeName));
// Check that files do not exist
CPPUNIT_ASSERT_MESSAGE( "Found .thm file inside it after deletion",
!comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".thm"));
CPPUNIT_ASSERT_MESSAGE( "Found .sdv file inside it after deletion",
!comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".sdv"));
CPPUNIT_ASSERT_MESSAGE( "Found .sdg file inside it after deletion",
!comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".sdg"));
CPPUNIT_ASSERT_MESSAGE( "Found .str file inside it after deletion",
!comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".str"));
}
// Create theme, set name, assert the name is expected void GalleryObjTest::TestSetThemeName()
{ // Create theme
std::unique_ptr<utl::TempFileNamed> pTempDir;
pTempDir.reset(new utl::TempFileNamed(nullptr, true));
CPPUNIT_ASSERT_MESSAGE("Could not create valid temporary directory", pTempDir->IsValid());
pTempDir->EnableKillingFile(); const OUString aGalleryURL = pTempDir->GetURL();
std::unique_ptr<Gallery> pGallery(new Gallery(aGalleryURL));
CPPUNIT_ASSERT_MESSAGE("Could not create gallery instance", (pGallery != nullptr)); static constexpr OUString myThemeName = u"addytesttheme"_ustr;
CPPUNIT_ASSERT_MESSAGE("Could not create theme", pGallery->CreateTheme(myThemeName));
CPPUNIT_ASSERT_MESSAGE("Could not find theme", pGallery->HasTheme(myThemeName));
// Rename theme static constexpr OUString myNewThemeName = u"addytestthemenew"_ustr;
pGallery->RenameTheme(myThemeName, myNewThemeName);
CPPUNIT_ASSERT_MESSAGE("Could not rename theme because old theme name still exists",
!pGallery->HasTheme(myThemeName));
CPPUNIT_ASSERT_MESSAGE("Could not find new renamed theme", pGallery->HasTheme(myNewThemeName));
// Check that files are not renamed
CPPUNIT_ASSERT_MESSAGE( "Could not find .thm file inside it",
comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".thm"));
CPPUNIT_ASSERT_MESSAGE( "Could not find .sdv file inside it",
comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".sdv"));
}
// Mixed Case Theme Name static constexpr OUString myThemeName = u"AddyTestTheme"_ustr;
CPPUNIT_ASSERT_MESSAGE("Could not create theme", pGallery->CreateTheme(myThemeName));
CPPUNIT_ASSERT_MESSAGE("Could not find theme", pGallery->HasTheme(myThemeName));
#ifdefined(LINUX)
CPPUNIT_ASSERT_MESSAGE("[LINUX] Could not find .thm in lowercase",
comphelper::DirectoryHelper::fileExists(
aGalleryURL + "/" + myThemeName.toAsciiLowerCase() + ".thm"));
CPPUNIT_ASSERT_MESSAGE("[LINUX] Could not find .sdv in lowercase",
comphelper::DirectoryHelper::fileExists(
aGalleryURL + "/" + myThemeName.toAsciiLowerCase() + ".sdv")); #else
CPPUNIT_ASSERT_MESSAGE( "[WINDOWS] Could not find .thm in mixed case",
comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".thm"));
CPPUNIT_ASSERT_MESSAGE( "[WINDOWS] Could not find .sdv in mixed case",
comphelper::DirectoryHelper::fileExists(aGalleryURL + "/" + myThemeName + ".sdv")); #endif
}
// Loop through and test theme count in each pass.
sal_uInt32 nLimit = 10; for (sal_uInt32 i = 1; i <= nLimit; i++)
{
OUString myThemeName = "addytesttheme" + OUString::number(i); // Create theme
CPPUNIT_ASSERT_MESSAGE("Could not create theme", pGallery->CreateTheme(myThemeName));
CPPUNIT_ASSERT_MESSAGE("Could not find theme", pGallery->HasTheme(myThemeName));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Inconsistent theme count", static_cast<sal_uInt32>(pGallery->GetThemeCount()), i);
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Inconsistent theme count", static_cast<sal_uInt32>(pGallery->GetThemeCount()), nLimit); for (sal_uInt32 i = nLimit; i > 0; i--)
{
OUString myThemeName = "addytesttheme" + OUString::number(i); // Delete Theme
CPPUNIT_ASSERT_MESSAGE("Could not remove theme", pGallery->RemoveTheme(myThemeName));
CPPUNIT_ASSERT_MESSAGE("Could not remove theme, theme found even after trying to remove",
!pGallery->HasTheme(myThemeName));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Inconsistent theme count", static_cast<sal_uInt32>(pGallery->GetThemeCount()), i - 1);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.