summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-12 19:13:10 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-13 16:40:53 +0200
commit2a9814090c260a2e3154bff36792fcd7d86cf60c (patch)
tree37fe18593d45c8ae577796a4886600ce3682d439 /sc
parentc2c3d86770efc1e39860441d625fcb3b4be7c58e (diff)
external data: reenable the test and adapt to new interfaces
Change-Id: I2d82b560e0bd499eb85c6ce22f5969f82dfe8937
Diffstat (limited to 'sc')
-rw-r--r--sc/CppunitTest_sc_dataprovider.mk (renamed from sc/CppunitTest_sc_dataproviders_test.mk)24
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/qa/unit/data/dataprovider/csv/test1.csv4
-rw-r--r--sc/qa/unit/dataproviders_test.cxx77
5 files changed, 53 insertions, 55 deletions
diff --git a/sc/CppunitTest_sc_dataproviders_test.mk b/sc/CppunitTest_sc_dataprovider.mk
index 58222408b623..fe389fdb3ee5 100644
--- a/sc/CppunitTest_sc_dataproviders_test.mk
+++ b/sc/CppunitTest_sc_dataprovider.mk
@@ -7,19 +7,19 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-$(eval $(call gb_CppunitTest_CppunitTest,sc_dataproviders_test))
+$(eval $(call gb_CppunitTest_CppunitTest,sc_dataprovider))
-$(eval $(call gb_CppunitTest_add_exception_objects,sc_dataproviders_test, \
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_dataprovider, \
sc/qa/unit/dataproviders_test \
))
-$(eval $(call gb_CppunitTest_use_externals,sc_dataproviders_test, \
+$(eval $(call gb_CppunitTest_use_externals,sc_dataprovider, \
boost_headers \
mdds_headers \
libxml2 \
))
-$(eval $(call gb_CppunitTest_use_libraries,sc_dataproviders_test, \
+$(eval $(call gb_CppunitTest_use_libraries,sc_dataprovider, \
basegfx \
comphelper \
cppu \
@@ -56,23 +56,23 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_dataproviders_test, \
$(gb_UWINAPI) \
))
-$(eval $(call gb_CppunitTest_set_include,sc_dataproviders_test,\
+$(eval $(call gb_CppunitTest_set_include,sc_dataprovider,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
-I$(SRCDIR)/sc/source/filter/inc \
$$(INCLUDE) \
))
-$(eval $(call gb_CppunitTest_use_custom_headers,sc_dataproviders_test,\
+$(eval $(call gb_CppunitTest_use_custom_headers,sc_dataprovider,\
officecfg/registry \
))
-$(eval $(call gb_CppunitTest_use_sdk_api,sc_dataproviders_test))
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_dataprovider))
-$(eval $(call gb_CppunitTest_use_ure,sc_dataproviders_test))
-$(eval $(call gb_CppunitTest_use_vcl,sc_dataproviders_test))
+$(eval $(call gb_CppunitTest_use_ure,sc_dataprovider))
+$(eval $(call gb_CppunitTest_use_vcl,sc_dataprovider))
-$(eval $(call gb_CppunitTest_use_components,sc_dataproviders_test,\
+$(eval $(call gb_CppunitTest_use_components,sc_dataprovider,\
basic/util/sb \
chart2/source/chartcore \
chart2/source/controller/chartcontroller \
@@ -112,7 +112,7 @@ $(eval $(call gb_CppunitTest_use_components,sc_dataproviders_test,\
xmlsecurity/util/xmlsecurity \
))
-$(eval $(call gb_CppunitTest_use_externals,sc_dataproviders_test,\
+$(eval $(call gb_CppunitTest_use_externals,sc_dataprovider,\
orcus \
orcus-parser \
boost_filesystem \
@@ -121,6 +121,6 @@ $(eval $(call gb_CppunitTest_use_externals,sc_dataproviders_test,\
zlib \
))
-$(eval $(call gb_CppunitTest_use_configuration,sc_dataproviders_test))
+$(eval $(call gb_CppunitTest_use_configuration,sc_dataprovider))
# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 6a6a538d189c..0526764df2c5 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
CppunitTest_sc_range_test \
CppunitTest_sc_mark_test \
CppunitTest_sc_core \
+ CppunitTest_sc_dataprovider \
))
ifneq ($(ENABLE_HEADLESS),TRUE)
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6071fe642c45..0e6cf79b1b6a 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -710,7 +710,7 @@ public:
const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
void RefreshDirtyTableColumnNames();
- sc::ExternalDataMapper& GetExternalDataMapper();
+ SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper();
SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString* pName ) const;
diff --git a/sc/qa/unit/data/dataprovider/csv/test1.csv b/sc/qa/unit/data/dataprovider/csv/test1.csv
new file mode 100644
index 000000000000..a9242346603f
--- /dev/null
+++ b/sc/qa/unit/data/dataprovider/csv/test1.csv
@@ -0,0 +1,4 @@
+1,2,3,4
+test1,test2,test3
+"some longer text
+"
diff --git a/sc/qa/unit/dataproviders_test.cxx b/sc/qa/unit/dataproviders_test.cxx
index df5b248d4021..737362618845 100644
--- a/sc/qa/unit/dataproviders_test.cxx
+++ b/sc/qa/unit/dataproviders_test.cxx
@@ -17,11 +17,6 @@
#include <memory>
-struct TestImpl
-{
- ScDocShellRef m_xDocShell;
-};
-
class ScDataProvidersTest : public ScBootstrapFixture
{
public:
@@ -40,45 +35,42 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
- std::unique_ptr<TestImpl> m_pImpl;
+ ScDocShellRef m_xDocShell;
ScDocument *m_pDoc;
};
-ScDataProvidersTest::ScDataProvidersTest() :
- ScBootstrapFixture( "/sc/qa/unit/data" ),
- m_pImpl(new TestImpl),
- m_pDoc(nullptr)
+void ScDataProvidersTest::testCSVImport()
{
-}
+ ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10);
+ bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+ CPPUNIT_ASSERT(bInserted);
-ScDocShell& ScDataProvidersTest::getDocShell()
-{
- return *m_pImpl->m_xDocShell;
+ OUString aFileURL;
+ createFileURL("test1.", "csv", aFileURL);
+ sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.csv", m_pDoc);
+ aDataSource.setDBData(pDBData);
+
+
+ m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource);
+ auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources();
+ CPPUNIT_ASSERT(!rDataSources.empty());
+
+ rDataSources[0].refresh(m_pDoc, true);
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, 0));
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 0, 0));
+ CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(2, 0, 0));
+ CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(3, 0, 0));
+ CPPUNIT_ASSERT_EQUAL(OUString("test1"), m_pDoc->GetString(0, 1, 0));
+ CPPUNIT_ASSERT_EQUAL(OUString("test2"), m_pDoc->GetString(1, 1, 0));
+ CPPUNIT_ASSERT_EQUAL(OUString("test3"), m_pDoc->GetString(2, 1, 0));
}
-void ScDataProvidersTest::testCSVImport()
+ScDataProvidersTest::ScDataProvidersTest() :
+ ScBootstrapFixture( "/sc/qa/unit/data/dataprovider" ),
+ m_pDoc(nullptr)
{
- m_pDoc->InsertTab(0, "foo");
- bool success;
- OUString aCSVPath;
- createCSVPath( "dataprovider.", aCSVPath );
- OUString aDBName = "TEST";
- sc::ExternalDataMapper aExternalDataMapper (&getDocShell(), aCSVPath, aDBName, 0, 0, 0, 5, 5, false, success);
- aExternalDataMapper.StartImport();
- Scheduler::ProcessEventsToIdle();
- CPPUNIT_ASSERT_EQUAL (-2012.0, m_pDoc->GetValue(0, 0, 0));
- CPPUNIT_ASSERT_EQUAL (-1.0, m_pDoc->GetValue(1, 0, 0));
- CPPUNIT_ASSERT_EQUAL (0.0, m_pDoc->GetValue(2, 0, 0));
- CPPUNIT_ASSERT_EQUAL (1.0, m_pDoc->GetValue(3, 0, 0));
- CPPUNIT_ASSERT_EQUAL (2012.0, m_pDoc->GetValue(4, 0, 0));
- CPPUNIT_ASSERT_EQUAL (-3.14, m_pDoc->GetValue(0, 1, 0));
- CPPUNIT_ASSERT_EQUAL (-0.99, m_pDoc->GetValue(1, 1, 0));
- CPPUNIT_ASSERT_EQUAL (0.01, m_pDoc->GetValue(2, 1, 0));
- CPPUNIT_ASSERT_EQUAL (3.14, m_pDoc->GetValue(3, 1, 0));
- CPPUNIT_ASSERT_EQUAL (OUString("H"), m_pDoc->GetString(0, 2, 0));
- CPPUNIT_ASSERT_EQUAL (OUString("Hello, Calc!"), m_pDoc->GetString(1, 2, 0));
- CPPUNIT_ASSERT_EQUAL (0.0, m_pDoc->GetValue(2, 2, 0));
- CPPUNIT_ASSERT_EQUAL (0.0, m_pDoc->GetValue(0, 3, 0));
}
void ScDataProvidersTest::setUp()
@@ -86,20 +78,21 @@ void ScDataProvidersTest::setUp()
ScBootstrapFixture::setUp();
ScDLL::Init();
- m_pImpl->m_xDocShell = new ScDocShell(
+ m_xDocShell = new ScDocShell(
SfxModelFlags::EMBEDDED_OBJECT |
SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
- m_pImpl->m_xDocShell->SetIsInUcalc();
- m_pImpl->m_xDocShell->DoInitUnitTest();
- m_pDoc = &m_pImpl->m_xDocShell->GetDocument();
+ m_xDocShell->SetIsInUcalc();
+ m_xDocShell->DoInitUnitTest();
+ m_pDoc = &m_xDocShell->GetDocument();
+ m_pDoc->InsertTab(0, "Tab");
}
void ScDataProvidersTest::tearDown()
{
- m_pImpl->m_xDocShell->DoClose();
- m_pImpl->m_xDocShell.clear();
+ m_xDocShell->DoClose();
+ m_xDocShell.clear();
ScBootstrapFixture::tearDown();
}