xref: /trunk/main/shell/qa/zip/testimpl/testzipimpl.cxx (revision f8e2c85a)
1*f8e2c85aSAndrew Rist /**************************************************************
25448f169SMichael Stahl  *
3*f8e2c85aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e2c85aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e2c85aSAndrew Rist  * distributed with this work for additional information
6*f8e2c85aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e2c85aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e2c85aSAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e2c85aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f8e2c85aSAndrew Rist  *
11*f8e2c85aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f8e2c85aSAndrew Rist  *
13*f8e2c85aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e2c85aSAndrew Rist  * software distributed under the License is distributed on an
15*f8e2c85aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e2c85aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e2c85aSAndrew Rist  * specific language governing permissions and limitations
18*f8e2c85aSAndrew Rist  * under the License.
19*f8e2c85aSAndrew Rist  *
20*f8e2c85aSAndrew Rist  *************************************************************/
21*f8e2c85aSAndrew Rist 
22*f8e2c85aSAndrew Rist 
235448f169SMichael Stahl 
245448f169SMichael Stahl // MARKER(update_precomp.py): autogen include statement, do not remove
255448f169SMichael Stahl #include "precompiled_shell.hxx"
265448f169SMichael Stahl 
275448f169SMichael Stahl #define DLLIMPLEMENTATION
285448f169SMichael Stahl #include "testzipimpl.hxx"
295448f169SMichael Stahl 
305448f169SMichael Stahl vector<string> expectedContents;
315448f169SMichael Stahl 
325448f169SMichael Stahl TestZipImpl::TestZipImpl(const char * documentName) :
335448f169SMichael Stahl 		zipFile(ZipFile(string(documentName)))
345448f169SMichael Stahl {
355448f169SMichael Stahl 		expectedContents.push_back("mimetype");
365448f169SMichael Stahl 		expectedContents.push_back("Configurations2/statusbar/");
375448f169SMichael Stahl 		expectedContents.push_back("Configurations2/accelerator/current.xml");
385448f169SMichael Stahl 		expectedContents.push_back("Configurations2/floater/");
395448f169SMichael Stahl 		expectedContents.push_back("Configurations2/popupmenu/");
405448f169SMichael Stahl 		expectedContents.push_back("Configurations2/progressbar/");
415448f169SMichael Stahl 		expectedContents.push_back("Configurations2/toolpanel/");
425448f169SMichael Stahl 		expectedContents.push_back("Configurations2/menubar/");
435448f169SMichael Stahl 		expectedContents.push_back("Configurations2/toolbar/");
445448f169SMichael Stahl 		expectedContents.push_back("Configurations2/images/Bitmaps/");
455448f169SMichael Stahl 		expectedContents.push_back("content.xml");
465448f169SMichael Stahl 		expectedContents.push_back("manifest.rdf");
475448f169SMichael Stahl 		expectedContents.push_back("styles.xml");
485448f169SMichael Stahl 		expectedContents.push_back("meta.xml");
495448f169SMichael Stahl 		expectedContents.push_back("Thumbnails/thumbnail.png");
505448f169SMichael Stahl 		expectedContents.push_back("settings.xml");
515448f169SMichael Stahl 		expectedContents.push_back("META-INF/manifest.xml");
525448f169SMichael Stahl 		sort(expectedContents.begin(), expectedContents.end());
535448f169SMichael Stahl }
545448f169SMichael Stahl 
555448f169SMichael Stahl TestZipImpl::~TestZipImpl()
565448f169SMichael Stahl {
575448f169SMichael Stahl }
585448f169SMichael Stahl 
595448f169SMichael Stahl 
605448f169SMichael Stahl //------------------------------------------------
615448f169SMichael Stahl bool TestZipImpl::test_directory()
625448f169SMichael Stahl {
635448f169SMichael Stahl 		ZipFile::DirectoryPtr_t contents = zipFile.GetDirectory();
645448f169SMichael Stahl 		vector<string> &stringVector = *contents.get();
655448f169SMichael Stahl 		sort(stringVector.begin(), stringVector.end());
665448f169SMichael Stahl 		return expectedContents == expectedContents;
675448f169SMichael Stahl }
685448f169SMichael Stahl 
695448f169SMichael Stahl //------------------------------------------------
705448f169SMichael Stahl bool TestZipImpl::test_hasContentCaseInSensitive()
715448f169SMichael Stahl {
725448f169SMichael Stahl 		return zipFile.HasContent("mimetype");
735448f169SMichael Stahl }
745448f169SMichael Stahl 
755448f169SMichael Stahl //------------------------------------------------
765448f169SMichael Stahl bool TestZipImpl::test_getContent()
775448f169SMichael Stahl {
785448f169SMichael Stahl 		ZipFile::ZipContentBuffer_t contentBuf;
795448f169SMichael Stahl 		zipFile.GetUncompressedContent("content.xml", contentBuf);
805448f169SMichael Stahl 		return !contentBuf.empty();
815448f169SMichael Stahl }
825448f169SMichael Stahl 
83