summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorMichael Stahl <mst@apache.org>2011-09-17 21:37:36 +0000
committerMichael Stahl <mst@apache.org>2011-09-17 21:37:36 +0000
commit4587dc772ebe5a0251246d9c7cb79ad71c2d8f9f (patch)
tree66f8d0c5496eff782dee1e33dc51bce0301bd24f /shell
parent5c4f2172d7dfd58b74a44beda315a98df394605e (diff)
tkr41: #117828# office crash fixed . (null pointer) + add unit test
# HG changeset patch # User Tobias Krause <tkr@openoffice.org> # Date 1303116372 -7200 # Node ID 10c707c39a92a6284158f635b7b69115403d1ed0 # Parent 12fa3ee3d107fb6bbb980de805e20c6c3ca2408a
Diffstat (limited to 'shell')
-rwxr-xr-xshell/prj/build.lst2
-rwxr-xr-xshell/qa/recent_docs.cxx224
-rw-r--r--shell/qa/zip/export.map34
-rw-r--r--[-rwxr-xr-x]shell/qa/zip/makefile.mk (renamed from shell/qa/makefile.mk)38
-rw-r--r--shell/qa/zip/simpledocument.odtbin0 -> 16259 bytes
-rw-r--r--shell/qa/zip/testimpl/makefile.mk59
-rw-r--r--shell/qa/zip/testimpl/testzipimpl.cxx86
-rw-r--r--shell/qa/zip/testimpl/testzipimpl.hxx (renamed from shell/qa/i_xml_parser_event_handler.hxx)61
-rw-r--r--shell/qa/zip/ziptest.cxx91
-rw-r--r--shell/source/all/zipfile/zipfile.cxx3
10 files changed, 304 insertions, 294 deletions
diff --git a/shell/prj/build.lst b/shell/prj/build.lst
index abf9af0c0c8e..bbb05f14fa16 100755
--- a/shell/prj/build.lst
+++ b/shell/prj/build.lst
@@ -32,3 +32,5 @@ sl shell\source\backends\kdebe nmake - u sl_backends_k
sl shell\source\backends\kde4be nmake - u sl_backends_kde4be sl_inc NULL
sl shell\source\backends\desktopbe nmake - u sl_backends_desktopbe sl_inc NULL
sl shell\source\win32\shlxthandler\ooofilt nmake - w sl_win32_shlxthandler_ooofilt sl_all_zipfile.w sl_all_ooofilereader.w sl_win32_shlxthandler_util.w sl_all sl_inc NULL
+sl shell\qa\zip\testimpl nmake - w sl_qa_zip_testimpl sl_all_zipfile.w NULL
+sl shell\qa\zip nmake - w sl_qa_zip sl_qa_zip_testimpl.w NULL
diff --git a/shell/qa/recent_docs.cxx b/shell/qa/recent_docs.cxx
deleted file mode 100755
index b4408e2f7737..000000000000
--- a/shell/qa/recent_docs.cxx
+++ /dev/null
@@ -1,224 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_shell.hxx"
-
-#include <testshl/simpleheader.hxx>
-
-#include "systemshell.hxx"
-#include "osl/file.hxx"
-#include "osl/security.hxx"
-#include "rtl/ustring.hxx"
-
-#include <stdlib.h>
-#include <iostream>
-
-//########################################
-using namespace osl;
-using namespace rtl;
-
-namespace syssh = SystemShell;
-
-//########################################
-const OUString SXW_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.writer");
-const OUString SXC_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.calc");
-const OUString SXI_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.impress");
-const OUString SXD_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.draw");
-const OUString SXM_MIME_TYPE = OUString::createFromAscii("application/vnd.sun.xml.math");
-
-class Test_AddToRecentDocs : public CppUnit::TestFixture
-{
-public:
-
- Test_AddToRecentDocs()
- {
- }
-
- //------------------------------------------------
- void test_existing_recently_used_file_with_valid_xml()
- {
- system("rm $HOME/.recently-used");
- system("echo '<?xml version=\"1.0\"?>\n<RecentFiles>\n<RecentItem>\n<URI>file:///home/federico/gedit.txt</URI>\n<Mime-Type>text/plain</Mime-Type>\n<Timestamp>1046485966</Timestamp>\n<Groups>\n<Group>gedit</Group>\n</Groups>\n</RecentItem>\n</RecentFiles>' > $HOME/.recently-used");
-
- rtl::OUString url = rtl::OUString::createFromAscii("file:///home_athene/test.sxw");
- syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxc");
- syssh::AddToRecentDocumentList(url, SXC_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxi");
- syssh::AddToRecentDocumentList(url, SXI_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxd");
- syssh::AddToRecentDocumentList(url, SXD_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxm");
- syssh::AddToRecentDocumentList(url, SXM_MIME_TYPE);
- }
-
- //------------------------------------------------
- void test_existing_recently_used_file_with_invalid_xml()
- {
- system("rm $HOME/.recently-used");
- system("echo '<?xml version=\"1.0\"?>\n<RecentFiles>\n<RecentItem>\n<URI>file:///home/federico/gedit.txt</URI>\n<Mime-Type>text/plain</Mime-Type>\n<Timestamp>1046485966</Timestamp>\n<Groups>\n<Group>gedit</Group>\n</Groups>\n<RecentItem>\n<URI>file:///home/federico/gedit2.txt</URI>\n<Mime-Type>text/plain</Mime-Type>\n<Timestamp>1046485966</Timestamp>\n<Groups>\n<Group>gedit</Group>\n</Groups>\n</RecentItem>\n</RecentFiles>' > $HOME/.recently-used");
-
- rtl::OUString url = rtl::OUString::createFromAscii("file:///home_athene/test.sxw");
- syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
- }
-
- //------------------------------------------------
- void test_non_existing_recently_used_file()
- {
- int ret = system("rm $HOME/.recently-used");
-
- rtl::OUString url = rtl::OUString::createFromAscii("file:///home_athene/test.sxw");
- syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxc");
- syssh::AddToRecentDocumentList(url, SXC_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxi");
- syssh::AddToRecentDocumentList(url, SXI_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxd");
- syssh::AddToRecentDocumentList(url, SXD_MIME_TYPE);
-
- url = rtl::OUString::createFromAscii("file:///home_athene/test.sxm");
- syssh::AddToRecentDocumentList(url, SXM_MIME_TYPE);
-
- ret = system("ls $HOME/.recently-used");
-
- CPPUNIT_ASSERT_MESSAGE(".recently-used doesn't exist", 0 == ret);
- }
-
- //------------------------------------------------
- OUString get_recently_used_url()
- {
- Security sec;
- OUString recently_used_url;
-
- CPPUNIT_ASSERT_MESSAGE("cannot get user home directory", sec.getHomeDir(recently_used_url));
-
- if ((recently_used_url.getLength() > 0) &&
- ('/' != recently_used_url.pData->buffer[recently_used_url.getLength() - 1]))
- recently_used_url += rtl::OUString::createFromAscii("/");
-
- recently_used_url += rtl::OUString::createFromAscii(".recently-used");
- return recently_used_url;
- }
-
- //------------------------------------------------
- void read_recently_used(void* buffer, size_t size)
- {
- File ruf(get_recently_used_url());
- FileBase::RC rc = ruf.open(OpenFlag_Read);
-
- CPPUNIT_ASSERT_MESSAGE("Cannot open ~/.recently-used", FileBase::E_None == rc);
-
- sal_uInt64 read;
- ruf.read(buffer, size, read);
- ruf.close();
- CPPUNIT_ASSERT_MESSAGE("Cannot read .recently-used", (read > 0));
- }
-
- //------------------------------------------------
- void test_existing_recently_used_file_without_xml()
- {
- // remove an existing .recently-used file
- // create a new one with non xml data
- system("rm $HOME/.recently-used");
- system("date > $HOME/.recently-used");
-
- char cnt_before[128];
- memset(cnt_before, 0, sizeof(cnt_before));
- read_recently_used(cnt_before, sizeof(cnt_before));
-
- OUString url = OUString::createFromAscii("file:///home_athene/test.sxw");
- syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
-
- char cnt_after[128];
- memset(cnt_after, 0, sizeof(cnt_after));
- read_recently_used(cnt_after, sizeof(cnt_after));
- CPPUNIT_ASSERT_MESSAGE(".recently-used unexpectly touched", (0 == strcmp(cnt_before, cnt_after)));
- }
-
- //------------------------------------------------
- void test_existing_recently_used_with_unknown_xml()
- {
- system("rm $HOME/.recently-used");
-
- char* xml_unknown = "<?xml version=\"1.0\"?>\n<test>test</test>";
- char cmd[256];
- sprintf(cmd, "echo '%s' > $HOME/.recently-used", xml_unknown);
- system(cmd);
-
- OUString url = OUString::createFromAscii("file:///home_athene/test.sxw");
- syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
-
- char buffer[256];
- memset(buffer, 0, sizeof(buffer));
- read_recently_used(buffer, sizeof(buffer));
-
- CPPUNIT_ASSERT_MESSAGE("Unexpected recently-used content", (0 == strncmp(xml_unknown, buffer, strlen(xml_unknown))));
- }
-
- //------------------------------------------------
- void test_existing_empty_recently_used_file()
- {
- system("rm $HOME/.recently-used");
- system("touch $HOME/.recently-used");
-
- OUString url = OUString::createFromAscii("file:///home_athene/test.sxw");
- syssh::AddToRecentDocumentList(url, SXW_MIME_TYPE);
-
- char buffer[256];
- memset(buffer, 0, sizeof(buffer));
- read_recently_used(buffer, sizeof(buffer));
-
- char* expected = "<?xml version=\"1.0\"?>\n<RecentFiles>";
- CPPUNIT_ASSERT_MESSAGE("Unexpected recently-used content", (0 == strncmp(buffer, expected, strlen(expected))));
- }
-
- //------------------------------------------------
- CPPUNIT_TEST_SUITE(Test_AddToRecentDocs);
- CPPUNIT_TEST(test_existing_recently_used_file_with_valid_xml);
- CPPUNIT_TEST(test_non_existing_recently_used_file);
- CPPUNIT_TEST(test_existing_recently_used_file_without_xml);
- CPPUNIT_TEST(test_existing_recently_used_with_unknown_xml);
- CPPUNIT_TEST(test_existing_empty_recently_used_file);
- CPPUNIT_TEST(test_existing_recently_used_file_with_invalid_xml);
- CPPUNIT_TEST_SUITE_END();
-};
-
-
-//#####################################
-// register test suites
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test_AddToRecentDocs, "Test_AddToRecentDocs");
-
-NOADDITIONAL;
-
diff --git a/shell/qa/zip/export.map b/shell/qa/zip/export.map
new file mode 100644
index 000000000000..3308588ef6f8
--- /dev/null
+++ b/shell/qa/zip/export.map
@@ -0,0 +1,34 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+UDK_3_0_0 {
+ global:
+ cppunitTestPlugIn;
+
+ local:
+ *;
+};
diff --git a/shell/qa/makefile.mk b/shell/qa/zip/makefile.mk
index 290798bab18e..946b01db19f1 100755..100644
--- a/shell/qa/makefile.mk
+++ b/shell/qa/zip/makefile.mk
@@ -24,45 +24,29 @@
# for a copy of the LGPLv3 License.
#
#*************************************************************************
-PRJ=..
+PRJ=../..
PRJNAME=shell
-TARGET=qa
-
+TARGET=qa_zip
ENABLE_EXCEPTIONS=TRUE
-
+#USE_STLP_DEBUG=
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
CFLAGSCXX += $(CPPUNIT_CFLAGS)
-# BEGIN ----------------------------------------------------------------
-# auto generated Target:testjob by codegen.pl
-
-SHL1OBJS=$(SLO)$/recent_docs.obj $(SLO)$/xml_parser.obj
-SHL1TARGET=recent_docs
-SHL1STDLIBS=$(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-.IF "$(GUI)" == "UNX"
-..$/unxsols4.pro$/slb$/libsysshell.a \
-$(EXPATASCII3RDLIB)
-.ENDIF
-
-SHL1IMPLIB= i$(SHL1TARGET)
-SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1OBJS = $(SLOFILES)
+SHL1RPATH = NONE
+SHL1STDLIBS = $(SALLIB) $(CPPUNITLIB)
+SHL1LIBS = $(SLB)$/..$/lib$/iqa_zipimpl.lib
+SHL1TARGET = $(TARGET)
+SHL1VERSIONMAP = $(PRJ)/qa/zip/export.map
DEF1NAME=$(SHL1TARGET)
-DEF1EXPORTFILE= export.exp
-
-# END ------------------------------------------------------------------
-
-
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-
-SLOFILES=$(SHL1OBJS)
+SLOFILES=$(SLO)$/ziptest.obj
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
+.INCLUDE: _cppunit.mk
diff --git a/shell/qa/zip/simpledocument.odt b/shell/qa/zip/simpledocument.odt
new file mode 100644
index 000000000000..bf83a648b7ed
--- /dev/null
+++ b/shell/qa/zip/simpledocument.odt
Binary files differ
diff --git a/shell/qa/zip/testimpl/makefile.mk b/shell/qa/zip/testimpl/makefile.mk
new file mode 100644
index 000000000000..e4de7f543834
--- /dev/null
+++ b/shell/qa/zip/testimpl/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=../../..
+
+PRJNAME=shell
+TARGET=qa_zipimpl
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+.IF "$(OS)" == "WNT"
+ NO_DEFAULT_STL=TRUE
+ USE_STLP_DEBUG=
+.ENDIF
+USE_DEFFILE=TRUE
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+UWINAPILIB =
+
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1OBJS = $(SLOFILES)
+SHL1RPATH = NONE
+.IF "$(OS)" == "WNT"
+ SHL1STDLIBS = msvcprt.lib
+.ENDIF
+SHL1LIBS = $(SOLARLIBDIR)$/zlib.lib $(SLB)$/ooofilereader.lib
+SLOFILES=$(SLO)$/testzipimpl.obj
+SHL1TARGET = $(TARGET)
+DEF1NAME=$(SHL1TARGET)
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.IF "$(OS)" == "WNT"
+ INCLUDE!:=$(subst,/stl, $(INCLUDE))
+ .EXPORT : INCLUDE
+.ENDIF
+
diff --git a/shell/qa/zip/testimpl/testzipimpl.cxx b/shell/qa/zip/testimpl/testzipimpl.cxx
new file mode 100644
index 000000000000..60750819b405
--- /dev/null
+++ b/shell/qa/zip/testimpl/testzipimpl.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#define DLLIMPLEMENTATION
+#include "testzipimpl.hxx"
+
+vector<string> expectedContents;
+
+TestZipImpl::TestZipImpl(const char * documentName) :
+ zipFile(ZipFile(string(documentName)))
+{
+ expectedContents.push_back("mimetype");
+ expectedContents.push_back("Configurations2/statusbar/");
+ expectedContents.push_back("Configurations2/accelerator/current.xml");
+ expectedContents.push_back("Configurations2/floater/");
+ expectedContents.push_back("Configurations2/popupmenu/");
+ expectedContents.push_back("Configurations2/progressbar/");
+ expectedContents.push_back("Configurations2/toolpanel/");
+ expectedContents.push_back("Configurations2/menubar/");
+ expectedContents.push_back("Configurations2/toolbar/");
+ expectedContents.push_back("Configurations2/images/Bitmaps/");
+ expectedContents.push_back("content.xml");
+ expectedContents.push_back("manifest.rdf");
+ expectedContents.push_back("styles.xml");
+ expectedContents.push_back("meta.xml");
+ expectedContents.push_back("Thumbnails/thumbnail.png");
+ expectedContents.push_back("settings.xml");
+ expectedContents.push_back("META-INF/manifest.xml");
+ sort(expectedContents.begin(), expectedContents.end());
+}
+
+TestZipImpl::~TestZipImpl()
+{
+}
+
+
+//------------------------------------------------
+bool TestZipImpl::test_directory()
+{
+ ZipFile::DirectoryPtr_t contents = zipFile.GetDirectory();
+ vector<string> &stringVector = *contents.get();
+ sort(stringVector.begin(), stringVector.end());
+ return expectedContents == expectedContents;
+}
+
+//------------------------------------------------
+bool TestZipImpl::test_hasContentCaseInSensitive()
+{
+ return zipFile.HasContent("mimetype");
+}
+
+//------------------------------------------------
+bool TestZipImpl::test_getContent()
+{
+ ZipFile::ZipContentBuffer_t contentBuf;
+ zipFile.GetUncompressedContent("content.xml", contentBuf);
+ return !contentBuf.empty();
+}
+
diff --git a/shell/qa/i_xml_parser_event_handler.hxx b/shell/qa/zip/testimpl/testzipimpl.hxx
index 1758e2075b55..7de101c91c21 100644
--- a/shell/qa/i_xml_parser_event_handler.hxx
+++ b/shell/qa/zip/testimpl/testzipimpl.hxx
@@ -25,53 +25,30 @@
*
************************************************************************/
-#ifndef _I_XML_PARSER_EVENT_HANDLER_HXX_
-#define _I_XML_PARSER_EVENT_HANDLER_HXX_
-
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/zipfile.hxx"
#include <string>
-#include <map>
-#include <utility>
-
-#if defined(XML_UNICODE) || defined(XML_UNICODE_WCHAR_T)
- typedef std::wstring string_t;
+#include <vector>
+#include <algorithm>
+#include "sal/types.h"
+#if defined(DLLIMPLEMENTATION)
+ #define DLLPUBLIC SAL_DLLPUBLIC_EXPORT
#else
- typedef std::string string_t;
+ #define DLLPUBLIC SAL_DLLPUBLIC_IMPORT
#endif
-// name-value container
-typedef std::map<string_t, string_t> xml_tag_attribute_container_t;
+using namespace std;
-
-//#########################################
-class i_xml_parser_event_handler
+class DLLPUBLIC TestZipImpl
{
-public:
- virtual ~i_xml_parser_event_handler() {};
-
- virtual void start_document() = 0;
-
- virtual void end_document() = 0;
-
- virtual void start_element(
- const string_t& raw_name,
- const string_t& local_name,
- const xml_tag_attribute_container_t& attributes) = 0;
-
- virtual void end_element(
- const string_t& raw_name,
- const string_t& local_name) = 0;
-
- virtual void characters(
- const string_t& character) = 0;
-
- virtual void ignore_whitespace(
- const string_t& whitespaces) = 0;
-
- virtual void processing_instruction(
- const string_t& target, const string_t& data) = 0;
-
- virtual void comment(const string_t& comment) = 0;
+ private:
+ ZipFile zipFile;
+ public:
+ TestZipImpl(const char * documentName);
+ ~TestZipImpl();
+ bool test_directory();
+ bool test_hasContentCaseInSensitive();
+ bool test_getContent();
};
-#endif
-
diff --git a/shell/qa/zip/ziptest.cxx b/shell/qa/zip/ziptest.cxx
new file mode 100644
index 000000000000..e08f76869764
--- /dev/null
+++ b/shell/qa/zip/ziptest.cxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+#include "cppunit/plugin/TestPlugIn.h"
+#include <string>
+#include "testimpl/testzipimpl.hxx"
+using namespace std;
+
+class Test : public CppUnit::TestFixture
+{
+ private:
+ string documentName;
+ public:
+ Test();
+ void setUp() {}
+ void tearDown() {}
+ void test_directory();
+ void test_hasContentCaseInSensitive();
+ void test_getContent();
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(test_directory);
+ CPPUNIT_TEST(test_hasContentCaseInSensitive);
+ CPPUNIT_TEST(test_getContent);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+Test::Test() :
+ documentName("simpledocument.odt")
+{
+}
+
+//------------------------------------------------
+void Test::test_directory()
+{
+ TestZipImpl testImpl(documentName.c_str());
+ bool isPassed = testImpl.test_directory();
+ CPPUNIT_ASSERT_MESSAGE("Content does not match with expected directory names.", isPassed);
+}
+
+//------------------------------------------------
+void Test::test_hasContentCaseInSensitive()
+{
+ TestZipImpl testImpl(documentName.c_str());
+ bool isPassed = testImpl.test_hasContentCaseInSensitive();
+ CPPUNIT_ASSERT_MESSAGE("Content in zip file was not found.", isPassed);
+}
+
+//------------------------------------------------
+void Test::test_getContent()
+{
+ TestZipImpl testImpl(documentName.c_str());
+ bool isPassed = testImpl.test_getContent();
+ CPPUNIT_ASSERT_MESSAGE("Couldn't recieve content buffer form zipfile.", isPassed);
+}
+
+//#####################################
+// register test suites
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
diff --git a/shell/source/all/zipfile/zipfile.cxx b/shell/source/all/zipfile/zipfile.cxx
index 96dd7922ec08..26ea14ad7060 100644
--- a/shell/source/all/zipfile/zipfile.cxx
+++ b/shell/source/all/zipfile/zipfile.cxx
@@ -196,8 +196,9 @@ ZipFile::DirectoryPtr_t ZipFile::GetDirectory() const
while (UNZ_OK == rc && UNZ_END_OF_LIST_OF_FILE != rc)
{
+ unz_file_info finfo;
unzGetCurrentFileInfo(
- m_uzFile, 0, szFileName, lmax, 0, 0, 0, 0);
+ m_uzFile, &finfo, szFileName, lmax, 0, 0, 0, 0);
dir->push_back(szFileName);