summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2013-07-18 12:48:23 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2013-07-18 14:01:05 +0200
commit4f4bed9b46eaaf9ab483d7c1b9ab31fb49838c99 (patch)
tree11965e0c669c9901ceaeb10c0f46ef089a12f15b /shell
parenta25778abd898fae829d3910798f32089e455984c (diff)
Test also the IStream part
Change-Id: If36de8daffb547b07d1417863ccc1a7904b379a5
Diffstat (limited to 'shell')
-rw-r--r--shell/CppunitTest_shell_zip.mk1
-rw-r--r--shell/qa/zip/testzipimpl.cxx5
-rw-r--r--shell/qa/zip/testzipimpl.hxx10
-rw-r--r--shell/qa/zip/ziptest.cxx63
4 files changed, 64 insertions, 15 deletions
diff --git a/shell/CppunitTest_shell_zip.mk b/shell/CppunitTest_shell_zip.mk
index 7e5d6dc6a0ba..63d0bc9383be 100644
--- a/shell/CppunitTest_shell_zip.mk
+++ b/shell/CppunitTest_shell_zip.mk
@@ -26,6 +26,7 @@ $(eval $(call gb_CppunitTest_use_externals,zip,\
))
$(eval $(call gb_CppunitTest_use_system_win32_libs,zip, \
+ ole32 \
kernel32 \
msvcprt \
))
diff --git a/shell/qa/zip/testzipimpl.cxx b/shell/qa/zip/testzipimpl.cxx
index dea673960a64..b2bec74a8230 100644
--- a/shell/qa/zip/testzipimpl.cxx
+++ b/shell/qa/zip/testzipimpl.cxx
@@ -17,13 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define DLLIMPLEMENTATION
#include "testzipimpl.hxx"
-vector<string> expectedContents;
-
TestZipImpl::TestZipImpl(StreamInterface *stream) :
- zipFile(ZipFile(stream))
+ zipFile(ZipFile(stream)), expectedContents()
{
expectedContents.push_back("mimetype");
expectedContents.push_back("Configurations2/statusbar/");
diff --git a/shell/qa/zip/testzipimpl.hxx b/shell/qa/zip/testzipimpl.hxx
index d8a2e5f3daa0..2ae8753da648 100644
--- a/shell/qa/zip/testzipimpl.hxx
+++ b/shell/qa/zip/testzipimpl.hxx
@@ -22,20 +22,16 @@
#include <vector>
#include <algorithm>
#include "sal/types.h"
-#if defined(DLLIMPLEMENTATION)
- #define DLLPUBLIC SAL_DLLPUBLIC_EXPORT
-#else
- #define DLLPUBLIC SAL_DLLPUBLIC_IMPORT
-#endif
using namespace std;
-class DLLPUBLIC TestZipImpl
+class TestZipImpl
{
private:
ZipFile zipFile;
+ vector<string> expectedContents;
public:
- TestZipImpl(StreamInterface *stream);
+ TestZipImpl(StreamInterface *stream);
~TestZipImpl();
bool test_directory();
bool test_hasContentCaseInSensitive();
diff --git a/shell/qa/zip/ziptest.cxx b/shell/qa/zip/ziptest.cxx
index d7ed38e4d338..3335aea52d62 100644
--- a/shell/qa/zip/ziptest.cxx
+++ b/shell/qa/zip/ziptest.cxx
@@ -17,6 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <ole2.h>
+#include <stdio.h>
+
#include "cppunit/TestAssert.h"
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
@@ -30,6 +40,7 @@ class Test : public CppUnit::TestFixture
{
private:
string documentName;
+ LPSTREAM pStream;
public:
Test();
void setUp() {}
@@ -37,16 +48,22 @@ public:
void test_file_directory();
void test_file_hasContentCaseInSensitive();
void test_file_getContent();
+ void test_stream_directory();
+ void test_stream_hasContentCaseInSensitive();
+ void test_stream_getContent();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(test_file_directory);
CPPUNIT_TEST(test_file_hasContentCaseInSensitive);
CPPUNIT_TEST(test_file_getContent);
+ CPPUNIT_TEST(test_stream_directory);
+ CPPUNIT_TEST(test_stream_hasContentCaseInSensitive);
+ CPPUNIT_TEST(test_stream_getContent);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-Test::Test() : documentName()
+Test::Test() : documentName(), pStream(NULL)
{
const char* pSrcRoot = getenv( "SRC_ROOT" );
if (pSrcRoot)
@@ -55,6 +72,20 @@ Test::Test() : documentName()
documentName.append("/");
}
documentName.append("shell/qa/zip/simpledocument.odt");
+
+ // Create an IStream pointer from the file
+ HANDLE hFile = CreateFileA(documentName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
+
+ DWORD dwFileSize = GetFileSize(hFile, NULL);
+ HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
+
+ LPVOID pvData = GlobalLock(hGlobal);
+ DWORD dwBytesRead = 0;
+ BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
+ GlobalUnlock(hGlobal);
+ CloseHandle(hFile);
+
+ HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pStream);
}
void Test::test_file_directory()
@@ -62,7 +93,7 @@ void Test::test_file_directory()
FileStream stream(documentName.c_str());
TestZipImpl testImpl(&stream);
bool isPassed = testImpl.test_directory();
- CPPUNIT_ASSERT_MESSAGE("Content does not match with expected directory names.", isPassed);
+ CPPUNIT_ASSERT_MESSAGE("FileStream: Content does not match with expected directory names.", isPassed);
}
void Test::test_file_hasContentCaseInSensitive()
@@ -70,7 +101,7 @@ void Test::test_file_hasContentCaseInSensitive()
FileStream stream(documentName.c_str());
TestZipImpl testImpl(&stream);
bool isPassed = testImpl.test_hasContentCaseInSensitive();
- CPPUNIT_ASSERT_MESSAGE("Content in zip file was not found.", isPassed);
+ CPPUNIT_ASSERT_MESSAGE("FileStream: Content in zip file was not found.", isPassed);
}
void Test::test_file_getContent()
@@ -78,7 +109,31 @@ void Test::test_file_getContent()
FileStream stream(documentName.c_str());
TestZipImpl testImpl(&stream);
bool isPassed = testImpl.test_getContent();
- CPPUNIT_ASSERT_MESSAGE("Couldn't receive content buffer form zipfile.", isPassed);
+ CPPUNIT_ASSERT_MESSAGE("FileStream: Couldn't receive content buffer form zipfile.", isPassed);
+}
+
+void Test::test_stream_directory()
+{
+ BufferStream stream(pStream);
+ TestZipImpl testImpl(&stream);
+ bool isPassed = testImpl.test_directory();
+ CPPUNIT_ASSERT_MESSAGE("BufferStream: Content does not match with expected directory names.", isPassed);
+}
+
+void Test::test_stream_hasContentCaseInSensitive()
+{
+ BufferStream stream(pStream);
+ TestZipImpl testImpl(&stream);
+ bool isPassed = testImpl.test_hasContentCaseInSensitive();
+ CPPUNIT_ASSERT_MESSAGE("BufferStream: Content in zip file was not found.", isPassed);
+}
+
+void Test::test_stream_getContent()
+{
+ BufferStream stream(pStream);
+ TestZipImpl testImpl(&stream);
+ bool isPassed = testImpl.test_getContent();
+ CPPUNIT_ASSERT_MESSAGE("BufferStream: Couldn't receive content buffer form zipfile.", isPassed);
}
CPPUNIT_PLUGIN_IMPLEMENT();