diff options
author | Tobias Lippert <drtl@fastmail.fm> | 2014-06-26 19:59:15 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-23 11:07:54 +0000 |
commit | 8f8ee6fd2c50572c44363a6d5d23bd9d192fe08d (patch) | |
tree | 24e78f489621bf5f6a031433b6e333ee49837aba /svl/qa | |
parent | fd641c7b23ce4205c29fc0c564b73336cb2cfb07 (diff) |
fdo#76754 Add Positions by StyleSheetFamily to IndexedStyleSheets
Change-Id: I4eade2d00d145d8f65ccd70a1c6bbd0a134a1ad5
Reviewed-on: https://gerrit.libreoffice.org/10346
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svl/qa')
-rw-r--r-- | svl/qa/unit/items/test_IndexedStyleSheets.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/svl/qa/unit/items/test_IndexedStyleSheets.cxx b/svl/qa/unit/items/test_IndexedStyleSheets.cxx index 3b0a0e0b8eb7..99b816f2c781 100644 --- a/svl/qa/unit/items/test_IndexedStyleSheets.cxx +++ b/svl/qa/unit/items/test_IndexedStyleSheets.cxx @@ -21,8 +21,8 @@ using namespace svl; class MockedStyleSheet : public SfxStyleSheetBase { public: - MockedStyleSheet(const rtl::OUString& name) - : SfxStyleSheetBase(name, NULL, SFX_STYLE_FAMILY_CHAR, 0) + MockedStyleSheet(const rtl::OUString& name, SfxStyleFamily fam = SFX_STYLE_FAMILY_CHAR) + : SfxStyleSheetBase(name, NULL, fam, 0) {;} }; @@ -36,6 +36,7 @@ class IndexedStyleSheetsTest : public CppUnit::TestFixture void RemovingStyleSheetWhichIsNotAvailableHasNoEffect(); void StyleSheetsCanBeRetrievedByTheirName(); void KnowsThatItStoresAStyleSheet(); + void PositionCanBeQueriedByFamily(); // Adds code needed to register the test suite CPPUNIT_TEST_SUITE(IndexedStyleSheetsTest); @@ -47,6 +48,7 @@ class IndexedStyleSheetsTest : public CppUnit::TestFixture CPPUNIT_TEST(RemovingStyleSheetWhichIsNotAvailableHasNoEffect); CPPUNIT_TEST(StyleSheetsCanBeRetrievedByTheirName); CPPUNIT_TEST(KnowsThatItStoresAStyleSheet); + CPPUNIT_TEST(PositionCanBeQueriedByFamily); // End of test suite definition CPPUNIT_TEST_SUITE_END(); @@ -151,6 +153,27 @@ void IndexedStyleSheetsTest::KnowsThatItStoresAStyleSheet() true, iss.HasStyleSheet(sheet2)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Does not find style sheet which is not stored and has the same name as a stored.", false, iss.HasStyleSheet(sheet4)); +} + +void IndexedStyleSheetsTest::PositionCanBeQueriedByFamily() +{ + rtl::OUString name1("name1"); + rtl::OUString name2("name2"); + rtl::OUString name3("name3"); + rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet(name1, SFX_STYLE_FAMILY_CHAR)); + rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet(name2, SFX_STYLE_FAMILY_PARA)); + rtl::Reference<SfxStyleSheetBase> sheet3(new MockedStyleSheet(name3, SFX_STYLE_FAMILY_CHAR)); + + IndexedStyleSheets iss; + iss.AddStyleSheet(sheet1); + iss.AddStyleSheet(sheet2); + iss.AddStyleSheet(sheet3); + + const std::vector<unsigned>& v = iss.GetStyleSheetPositionsByFamily(SFX_STYLE_FAMILY_CHAR); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Separation by family works.", static_cast<size_t>(2), v.size()); + + const std::vector<unsigned>& w = iss.GetStyleSheetPositionsByFamily(SFX_STYLE_FAMILY_ALL); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wildcard works for family queries.", static_cast<size_t>(3), w.size()); } |