diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-07-29 21:03:29 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-07-30 09:07:03 +0200 |
commit | 286aeb8385285220105c21ef352f5c437e19ebb5 (patch) | |
tree | e48160ca9e0342b310ef930c0cfd714f1fd5fd87 /sw/qa/uibase | |
parent | d6ce2c0500ab026ba131782365a41da93794196f (diff) |
sw: extract createDoc() from various test suites to a single getSwDoc()
Change-Id: I72d769860be8a401416e57111bea91d7a26ea4e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99751
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/uibase')
-rw-r--r-- | sw/qa/uibase/dochdl/dochdl.cxx | 13 | ||||
-rw-r--r-- | sw/qa/uibase/frmdlg/frmdlg.cxx | 16 | ||||
-rw-r--r-- | sw/qa/uibase/shells/shells.cxx | 20 |
3 files changed, 5 insertions, 44 deletions
diff --git a/sw/qa/uibase/dochdl/dochdl.cxx b/sw/qa/uibase/dochdl/dochdl.cxx index 26f8fe502e50..1de97968da2e 100644 --- a/sw/qa/uibase/dochdl/dochdl.cxx +++ b/sw/qa/uibase/dochdl/dochdl.cxx @@ -17,23 +17,12 @@ /// Covers sw/source/uibase/dochdl/ fixes. class SwUibaseDochdlTest : public SwModelTestBase { -public: - SwDoc* createDoc(); }; -SwDoc* SwUibaseDochdlTest::createDoc() -{ - loadURL("private:factory/swriter", nullptr); - - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - return pTextDoc->GetDocShell()->GetDoc(); -} - CPPUNIT_TEST_FIXTURE(SwUibaseDochdlTest, testSelectPasteFormat) { // Create a new document and cut a character. - SwDoc* pDoc = createDoc(); + SwDoc* pDoc = createSwDoc(); SwDocShell* pDocShell = pDoc->GetDocShell(); SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); pWrtShell->Insert2("x"); diff --git a/sw/qa/uibase/frmdlg/frmdlg.cxx b/sw/qa/uibase/frmdlg/frmdlg.cxx index 3700abb9d946..39d55be0a880 100644 --- a/sw/qa/uibase/frmdlg/frmdlg.cxx +++ b/sw/qa/uibase/frmdlg/frmdlg.cxx @@ -16,26 +16,12 @@ char const DATA_DIRECTORY[] = "/sw/qa/uibase/frmdlg/data/"; /// Covers sw/source/uibase/frmdlg/ fixes. class SwUibaseFrmdlgTest : public SwModelTestBase { -public: - void createDoc(const char* pName = nullptr); }; -void SwUibaseFrmdlgTest::createDoc(const char* pName) -{ - if (!pName) - { - loadURL("private:factory/swriter", nullptr); - } - else - { - load(DATA_DIRECTORY, pName); - } -} - CPPUNIT_TEST_FIXTURE(SwUibaseFrmdlgTest, testWrappedMathObject) { // The document includes a Math object with explicit wrapping. - createDoc("wrapped-math-object.docx"); + load(DATA_DIRECTORY, "wrapped-math-object.docx"); uno::Reference<drawing::XShape> xMath = getShape(1); // Without the accompanying fix in place, this test would have failed with: diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index 446fbacb2278..e8fc09418713 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -31,25 +31,11 @@ char const DATA_DIRECTORY[] = "/sw/qa/uibase/shells/data/"; /// Covers sw/source/uibase/shells/ fixes. class SwUibaseShellsTest : public SwModelTestBase { -public: - SwDoc* createDoc(const char* pName = nullptr); }; -SwDoc* SwUibaseShellsTest::createDoc(const char* pName) -{ - if (!pName) - loadURL("private:factory/swriter", nullptr); - else - load(DATA_DIRECTORY, pName); - - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - return pTextDoc->GetDocShell()->GetDoc(); -} - CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testTdf130179) { - SwDoc* pDoc = createDoc(); + SwDoc* pDoc = createSwDoc(); IDocumentContentOperations& rIDCO = pDoc->getIDocumentContentOperations(); SwCursorShell* pShell(pDoc->GetEditShell()); SfxItemSet aFrameSet(pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{}); @@ -80,7 +66,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testShapeTextAlignment) // FIXME find out why this fails on macOS/Windows #if !defined(MACOSX) && !defined(_WIN32) // Create a document with a rectangle in it. - SwDoc* pDoc = createDoc(); + SwDoc* pDoc = createSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); Point aStartPos(1000, 1000); pWrtShell->BeginCreate(static_cast<sal_uInt16>(OBJ_RECT), aStartPos); @@ -121,7 +107,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testOleSavePreviewUpdate) { // Load a document with 2 charts in it. The second is down enough that you have to scroll to // trigger its rendering. Previews are missing for both. - createDoc("ole-save-preview-update.odt"); + load(DATA_DIRECTORY, "ole-save-preview-update.odt"); // Explicitly update OLE previews, etc. dispatchCommand(mxComponent, ".uno:UpdateAll", {}); |