diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-12 20:09:18 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-13 16:40:53 +0200 |
commit | 8c72ab48bf150da05435d93991e1e9c9f47ce4fd (patch) | |
tree | 3043c3cd1604aa3635156f66901c26c8b0dffec3 | |
parent | 2a9814090c260a2e3154bff36792fcd7d86cf60c (diff) |
external data: add a test that shows that cropping to DB area works
Change-Id: Ic883a5f625d54bf8cc95785a9ab1a83f0c8aa2ec
-rw-r--r-- | sc/qa/unit/dataproviders_test.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sc/qa/unit/dataproviders_test.cxx b/sc/qa/unit/dataproviders_test.cxx index 737362618845..11dd5f97c49e 100644 --- a/sc/qa/unit/dataproviders_test.cxx +++ b/sc/qa/unit/dataproviders_test.cxx @@ -29,9 +29,11 @@ public: virtual void tearDown() override; void testCSVImport(); + void testDataLargerThanDB(); CPPUNIT_TEST_SUITE(ScDataProvidersTest); CPPUNIT_TEST(testCSVImport); + CPPUNIT_TEST(testDataLargerThanDB); CPPUNIT_TEST_SUITE_END(); private: @@ -67,6 +69,34 @@ void ScDataProvidersTest::testCSVImport() CPPUNIT_ASSERT_EQUAL(OUString("test3"), m_pDoc->GetString(2, 1, 0)); } +void ScDataProvidersTest::testDataLargerThanDB() +{ + ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 1, 1); + bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData); + CPPUNIT_ASSERT(bInserted); + + 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(0.0, m_pDoc->GetValue(2, 0, 0)); + CPPUNIT_ASSERT_EQUAL(0.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(), m_pDoc->GetString(2, 1, 0)); +} + ScDataProvidersTest::ScDataProvidersTest() : ScBootstrapFixture( "/sc/qa/unit/data/dataprovider" ), m_pDoc(nullptr) |