Kaydet (Commit) e57b0ebe authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

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
üst ab2b384c
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * 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 <com/sun/star/i18n/TextConversionOption.hpp>
#include <swmodeltestbase.hxx> #include <swmodeltestbase.hxx>
#include <ndtxt.hxx> #include <ndtxt.hxx>
...@@ -29,6 +30,11 @@ ...@@ -29,6 +30,11 @@
#include <svx/svdpage.hxx> #include <svx/svdpage.hxx>
#include <svx/svdview.hxx> #include <svx/svdview.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/scripttypeitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/wghtitem.hxx>
#include "UndoManager.hxx" #include "UndoManager.hxx"
static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/"; static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/";
...@@ -65,6 +71,7 @@ public: ...@@ -65,6 +71,7 @@ public:
void testMergeDoc(); void testMergeDoc();
void testCreatePortions(); void testCreatePortions();
void testBookmarkUndo(); void testBookmarkUndo();
void testFdo85876();
CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward); CPPUNIT_TEST(testReplaceForward);
...@@ -93,6 +100,7 @@ public: ...@@ -93,6 +100,7 @@ public:
CPPUNIT_TEST(testMergeDoc); CPPUNIT_TEST(testMergeDoc);
CPPUNIT_TEST(testCreatePortions); CPPUNIT_TEST(testCreatePortions);
CPPUNIT_TEST(testBookmarkUndo); CPPUNIT_TEST(testBookmarkUndo);
CPPUNIT_TEST(testFdo85876);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -716,6 +724,42 @@ void SwUiWriterTest::testBookmarkUndo() ...@@ -716,6 +724,42 @@ void SwUiWriterTest::testBookmarkUndo()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount()); 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_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment