diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-17 23:12:27 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-18 02:41:29 +0100 |
commit | e57b0ebeb7e75d36546f6abef3a26a8edc7dea7f (patch) | |
tree | 1978c29a0cf9f7f588f6e31d207f12daa8c62b7a /sw/qa/extras | |
parent | ab2b384cd761c5c44fd00c19a8907ff220dd36c3 (diff) |
fdo#85876: add unittest
rather uglyish unittest, but still worth it as cutting nothing needing
to have sideeffects is really kind of non-obvious and prone to return
Change-Id: I02bbfb05f019874d873670cdae060ac3183f5ca6
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 313df374ba7d..5de79d3257b8 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <swmodeltestbase.hxx> #include <ndtxt.hxx> @@ -29,6 +30,11 @@ #include <svx/svdpage.hxx> #include <svx/svdview.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/scripttypeitem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/wghtitem.hxx> + #include "UndoManager.hxx" static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/"; @@ -65,6 +71,7 @@ public: void testMergeDoc(); void testCreatePortions(); void testBookmarkUndo(); + void testFdo85876(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -93,6 +100,7 @@ public: CPPUNIT_TEST(testMergeDoc); CPPUNIT_TEST(testCreatePortions); CPPUNIT_TEST(testBookmarkUndo); + CPPUNIT_TEST(testFdo85876); CPPUNIT_TEST_SUITE_END(); @@ -716,6 +724,42 @@ void SwUiWriterTest::testBookmarkUndo() CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); } +static void lcl_setWeight(SwWrtShell* pWrtShell, FontWeight aWeight) +{ + SvxWeightItem aWeightItem(aWeight, EE_CHAR_WEIGHT); + SvxScriptSetItem aScriptSetItem(SID_ATTR_CHAR_WEIGHT, pWrtShell->GetAttrPool()); + aScriptSetItem.PutItemForScriptType(SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX, aWeightItem); + pWrtShell->SetAttrSet(aScriptSetItem.GetItemSet()); +} + +void SwUiWriterTest::testFdo85876() +{ + SwDoc* const pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + lcl_setWeight(pWrtShell, WEIGHT_BOLD); + pWrtShell->Insert("test"); + lcl_setWeight(pWrtShell, WEIGHT_NORMAL); + pWrtShell->SplitNode(); + pWrtShell->SplitNode(); + pWrtShell->Up(false); + pWrtShell->Insert("test"); + auto xText = getParagraph(1)->getText(); + CPPUNIT_ASSERT(xText.is()); + { + auto xCursor(xText->createTextCursorByRange(getParagraph(1))); + CPPUNIT_ASSERT(xCursor.is()); + xCursor->collapseToStart(); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xCursor, "CharWeight")); + } + { + auto xCursor(xText->createTextCursorByRange(getParagraph(2))); + CPPUNIT_ASSERT(xCursor.is()); + xCursor->collapseToStart(); + // this used to be BOLD too with fdo#85876 + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xCursor, "CharWeight")); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); |