1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_shell.hxx"
26 
27 #define DLLIMPLEMENTATION
28 #include "testzipimpl.hxx"
29 
30 vector<string> expectedContents;
31 
TestZipImpl(const char * documentName)32 TestZipImpl::TestZipImpl(const char * documentName) :
33 		zipFile(ZipFile(string(documentName)))
34 {
35 		expectedContents.push_back("mimetype");
36 		expectedContents.push_back("Configurations2/statusbar/");
37 		expectedContents.push_back("Configurations2/accelerator/current.xml");
38 		expectedContents.push_back("Configurations2/floater/");
39 		expectedContents.push_back("Configurations2/popupmenu/");
40 		expectedContents.push_back("Configurations2/progressbar/");
41 		expectedContents.push_back("Configurations2/toolpanel/");
42 		expectedContents.push_back("Configurations2/menubar/");
43 		expectedContents.push_back("Configurations2/toolbar/");
44 		expectedContents.push_back("Configurations2/images/Bitmaps/");
45 		expectedContents.push_back("content.xml");
46 		expectedContents.push_back("manifest.rdf");
47 		expectedContents.push_back("styles.xml");
48 		expectedContents.push_back("meta.xml");
49 		expectedContents.push_back("Thumbnails/thumbnail.png");
50 		expectedContents.push_back("settings.xml");
51 		expectedContents.push_back("META-INF/manifest.xml");
52 		sort(expectedContents.begin(), expectedContents.end());
53 }
54 
~TestZipImpl()55 TestZipImpl::~TestZipImpl()
56 {
57 }
58 
59 
60 //------------------------------------------------
test_directory()61 bool TestZipImpl::test_directory()
62 {
63 		ZipFile::DirectoryPtr_t contents = zipFile.GetDirectory();
64 		vector<string> &stringVector = *contents.get();
65 		sort(stringVector.begin(), stringVector.end());
66 		return expectedContents == expectedContents;
67 }
68 
69 //------------------------------------------------
test_hasContentCaseInSensitive()70 bool TestZipImpl::test_hasContentCaseInSensitive()
71 {
72 		return zipFile.HasContent("mimetype");
73 }
74 
75 //------------------------------------------------
test_getContent()76 bool TestZipImpl::test_getContent()
77 {
78 		ZipFile::ZipContentBuffer_t contentBuf;
79 		zipFile.GetUncompressedContent("content.xml", contentBuf);
80 		return !contentBuf.empty();
81 }
82 
83