summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-12-30 17:38:12 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-12-30 17:52:23 +0000
commitdcf947534778520bad32167f181b42ef6a451531 (patch)
treeb5d19521b94136e33ef2635777285083e738680e
parenta73475cecdac393b40c34770be65be40bf05e011 (diff)
fdo#84229 - add sot storage unit test.
Change-Id: Ic11c397984602bf8a2e292bc901cd7bf71ad555d
-rw-r--r--sot/qa/cppunit/data/pass/fdo84229-1.compoundbin0 -> 14848 bytes
-rw-r--r--sot/qa/cppunit/test_sot.cxx26
2 files changed, 26 insertions, 0 deletions
diff --git a/sot/qa/cppunit/data/pass/fdo84229-1.compound b/sot/qa/cppunit/data/pass/fdo84229-1.compound
new file mode 100644
index 000000000000..46eb4da8fddb
--- /dev/null
+++ b/sot/qa/cppunit/data/pass/fdo84229-1.compound
Binary files differ
diff --git a/sot/qa/cppunit/test_sot.cxx b/sot/qa/cppunit/test_sot.cxx
index c97a86e0b812..92ade70a11a4 100644
--- a/sot/qa/cppunit/test_sot.cxx
+++ b/sot/qa/cppunit/test_sot.cxx
@@ -36,9 +36,11 @@ namespace
unsigned int, unsigned int, unsigned int) SAL_OVERRIDE;
void test();
+ void testSize();
CPPUNIT_TEST_SUITE(SotTest);
CPPUNIT_TEST(test);
+ CPPUNIT_TEST(testSize);
CPPUNIT_TEST_SUITE_END();
};
@@ -120,6 +122,30 @@ namespace
OUString());
}
+ void SotTest::testSize()
+ {
+ OUString aURL(getURLFromSrc("/sot/qa/cppunit/data/pass/fdo84229-1.compound"));
+ SvFileStream aStream(aURL, STREAM_READ);
+ SotStorageRef xObjStor = new SotStorage(aStream);
+ CPPUNIT_ASSERT_MESSAGE("sot storage failed to open",
+ xObjStor.Is() && !xObjStor->GetError());
+ SotStorageStreamRef xStream = xObjStor->OpenSotStream("Book");
+ CPPUNIT_ASSERT_MESSAGE("stream failed to open",
+ xStream.Is() && !xObjStor->GetError());
+ CPPUNIT_ASSERT_MESSAGE("error in opened stream", !xStream->GetError());
+ sal_uLong nPos = xStream->GetSize();
+ CPPUNIT_ASSERT_MESSAGE("odd stream length", nPos == 13312);
+
+ xStream->Seek(STREAM_SEEK_TO_END);
+ CPPUNIT_ASSERT_MESSAGE("error seeking to end", !xStream->GetError());
+ // cf. comment in Pos2Page, not extremely intuitive ...
+ CPPUNIT_ASSERT_MESSAGE("stream not at beginning", xStream->Tell() == xStream->GetSize());
+ xStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ CPPUNIT_ASSERT_MESSAGE("error seeking to beginning", !xStream->GetError());
+ CPPUNIT_ASSERT_MESSAGE("stream not at beginning", xStream->Tell() == 0);
+ }
+
CPPUNIT_TEST_SUITE_REGISTRATION(SotTest);
}