diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-06-15 09:42:03 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-06-15 14:35:05 +0200 |
commit | bae82d9a57e2ed399f43ce1fe785509b8ab853f0 (patch) | |
tree | ab2ccc768efcfb8dc56751fc07d98a456b2efab2 /sc | |
parent | eeb6f0740903a7e78156cf755cc442383ace77d9 (diff) |
CppunitTest_sc_macros_test: move test where it belongs
Change-Id: I95fd738f4fa8e93c1d90f4b8701e36facadaa7fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135865
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 64 | ||||
-rw-r--r-- | sc/qa/extras/vba-macro-test.cxx | 63 |
2 files changed, 63 insertions, 64 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index f8642d0a429c..6ad5a6d4aa7a 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -20,7 +20,6 @@ #include <docsh.hxx> #include <document.hxx> #include <scitems.hxx> -#include <sortparam.hxx> #include <com/sun/star/sheet/XFunctionAccess.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> @@ -75,7 +74,6 @@ public: void testMacroButtonFormControlXlsxExport(); void testTdf107572(); void testShapeLayerId(); - void testVbaRangeSort(); void testFunctionAccessIndirect(); CPPUNIT_TEST_SUITE(ScMacrosTest); @@ -110,7 +108,6 @@ public: CPPUNIT_TEST(testMacroButtonFormControlXlsxExport); CPPUNIT_TEST(testTdf107572); CPPUNIT_TEST(testShapeLayerId); - CPPUNIT_TEST(testVbaRangeSort); CPPUNIT_TEST(testFunctionAccessIndirect); CPPUNIT_TEST_SUITE_END(); @@ -1256,67 +1253,6 @@ void ScMacrosTest::testShapeLayerId() pDocSh->DoClose(); } -void ScMacrosTest::testVbaRangeSort() -{ - auto xComponent = loadFromDesktop("private:factory/scalc"); - - css::uno::Reference<css::document::XEmbeddedScripts> xDocScr(xComponent, UNO_QUERY_THROW); - auto xLibs = xDocScr->getBasicLibraries(); - auto xLibrary = xLibs->createLibrary("TestLibrary"); - xLibrary->insertByName( - "TestModule", - uno::Any(OUString("Option VBASupport 1\n" - "Sub TestRangeSort\n" - " Range(Cells(1, 1), Cells(3, 1)).Select\n" - " Selection.Sort Key1:=Range(\"A1\"), Header:=False\n" - "End Sub\n"))); - - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); - ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); - CPPUNIT_ASSERT(pDocSh); - ScDocument& rDoc = pDocSh->GetDocument(); - - rDoc.SetValue(ScAddress(0, 0, 0), 1.0); - rDoc.SetValue(ScAddress(0, 1, 0), 0.5); - rDoc.SetValue(ScAddress(0, 2, 0), 2.0); - - // Without the fix in place, this call would have crashed in debug builds with failed assertion - ErrCode result = SfxObjectShell::CallXScript( - xComponent, - "vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=document", - {}, aRet, aOutParamIndex, aOutParam); - CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); - - CPPUNIT_ASSERT_EQUAL(0.5, rDoc.GetValue(ScAddress(0, 0, 0))); - CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(0, 1, 0))); - CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(0, 2, 0))); - - // Change sheet's first param sorting order - ScSortParam aParam; - rDoc.GetSortParam(aParam, 0); - aParam.maKeyState[0].bAscending = false; - rDoc.SetSortParam(aParam, 0); - - result = SfxObjectShell::CallXScript( - xComponent, - "vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=document", - {}, aRet, aOutParamIndex, aOutParam); - CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); - - // Without the fix in place, this test would have failed in non-debug builds with - // - Expected: 2 - // - Actual : 0.5 - CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(0, 0, 0))); - CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(0, 1, 0))); - CPPUNIT_ASSERT_EQUAL(0.5, rDoc.GetValue(ScAddress(0, 2, 0))); - - pDocSh->DoClose(); -} - void ScMacrosTest::testFunctionAccessIndirect() { OUString aFileName; diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx index cb39490d29ae..1f93a6247975 100644 --- a/sc/qa/extras/vba-macro-test.cxx +++ b/sc/qa/extras/vba-macro-test.cxx @@ -20,6 +20,7 @@ #include <document.hxx> #include <attrib.hxx> #include <scitems.hxx> +#include <sortparam.hxx> #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/sheet/XPrintAreas.hpp> @@ -62,6 +63,7 @@ public: void testMacroKeyBinding(); void testVba(); + void testVbaRangeSort(); void testTdf107885(); void testTdf131562(); void testTdf107902(); @@ -80,6 +82,7 @@ public: CPPUNIT_TEST(testMacroKeyBinding); CPPUNIT_TEST(testVba); + CPPUNIT_TEST(testVbaRangeSort); CPPUNIT_TEST(testTdf107885); CPPUNIT_TEST(testTdf131562); CPPUNIT_TEST(testTdf107902); @@ -591,6 +594,66 @@ void VBAMacroTest::testVba() } } +void VBAMacroTest::testVbaRangeSort() +{ + auto xComponent = loadFromDesktop("private:factory/scalc"); + + css::uno::Reference<css::document::XEmbeddedScripts> xDocScr(xComponent, uno::UNO_QUERY_THROW); + auto xLibs = xDocScr->getBasicLibraries(); + auto xLibrary = xLibs->createLibrary("TestLibrary"); + xLibrary->insertByName("TestModule", + uno::Any(OUString("Option VBASupport 1\n" + "Sub TestRangeSort\n" + " Range(Cells(1, 1), Cells(3, 1)).Select\n" + " Selection.Sort Key1:=Range(\"A1\"), Header:=False\n" + "End Sub\n"))); + + uno::Any aRet; + uno::Sequence<sal_Int16> aOutParamIndex; + uno::Sequence<uno::Any> aOutParam; + + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); + CPPUNIT_ASSERT(pDocSh); + ScDocument& rDoc = pDocSh->GetDocument(); + + rDoc.SetValue(ScAddress(0, 0, 0), 1.0); + rDoc.SetValue(ScAddress(0, 1, 0), 0.5); + rDoc.SetValue(ScAddress(0, 2, 0), 2.0); + + // Without the fix in place, this call would have crashed in debug builds with failed assertion + ErrCode result = SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=document", + {}, aRet, aOutParamIndex, aOutParam); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); + + CPPUNIT_ASSERT_EQUAL(0.5, rDoc.GetValue(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(0, 1, 0))); + CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(0, 2, 0))); + + // Change sheet's first param sorting order + ScSortParam aParam; + rDoc.GetSortParam(aParam, 0); + aParam.maKeyState[0].bAscending = false; + rDoc.SetSortParam(aParam, 0); + + result = SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=document", + {}, aRet, aOutParamIndex, aOutParam); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); + + // Without the fix in place, this test would have failed in non-debug builds with + // - Expected: 2 + // - Actual : 0.5 + CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(0, 1, 0))); + CPPUNIT_ASSERT_EQUAL(0.5, rDoc.GetValue(ScAddress(0, 2, 0))); + + pDocSh->DoClose(); +} + void VBAMacroTest::testTdf107885() { OUString aFileName; |