1 /************************************************************************
\r
3 ** Copyright (C) 2010 Strahinja Markovic
\r
5 ** This file is part of FlightCrew.
\r
7 ** FlightCrew is free software: you can redistribute it and/or modify
\r
8 ** it under the terms of the GNU Lesser General Public License as published
\r
9 ** by the Free Software Foundation, either version 3 of the License, or
\r
10 ** (at your option) any later version.
\r
12 ** FlightCrew is distributed in the hope that it will be useful,
\r
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 ** GNU Lesser General Public License for more details.
\r
17 ** You should have received a copy of the GNU Lesser General Public License
\r
18 ** along with FlightCrew. If not, see <http://www.gnu.org/licenses/>.
\r
20 *************************************************************************/
\r
22 #include <stdafx_tests.h>
\r
23 #include "flightcrew.h"
\r
26 using namespace FlightCrew;
\r
28 // This is basically a sanity check
\r
29 TEST( EpubValidatesTest, MissingCreator )
\r
31 std::vector<Result> results = ValidateEpub(
\r
32 "test_data/framework_tests/EpubValidates_MissingTitle.epub" );
\r
34 ASSERT_EQ( results.size(), 1U );
\r
35 EXPECT_EQ( results[ 0 ].GetResultId(), ERROR_XML_ELEMENT_NOT_PRESENT );
\r
37 std::vector< std::string > message_arguments = results[ 0 ].GetMessageArguments();
\r
38 EXPECT_EQ( message_arguments[ 0 ], "title" );
\r
41 TEST( EpubValidatesTest, ResultsWithBasePath )
\r
43 std::vector<Result> results = ValidateEpub(
\r
44 "test_data/framework_tests/EpubValidates_MissingTitle.epub" );
\r
46 ASSERT_EQ( results.size(), 1U );
\r
47 EXPECT_EQ( results[ 0 ].GetFilepath(), "EpubValidates_MissingTitle.epub/OEBPS/content.opf" );
\r
50 TEST( EpubValidatesTest, NotAZip )
\r
52 std::vector<Result> results = ValidateEpub(
\r
53 "test_data/framework_tests/EpubValidates_NotAZip.epub" );
\r
55 ASSERT_EQ( results.size(), 1U );
\r
56 EXPECT_EQ( results[ 0 ].GetResultId(), ERROR_EPUB_NOT_VALID_ZIP_ARCHIVE );
\r
59 TEST( EpubValidatesTest, NoContainerXml )
\r
61 std::vector<Result> results = ValidateEpub(
\r
62 "test_data/framework_tests/EpubValidates_NoContainerXml.epub" );
\r
64 ASSERT_EQ( results.size(), 1U );
\r
65 EXPECT_EQ( results[ 0 ].GetResultId(), ERROR_EPUB_NO_CONTAINER_XML );
\r
68 TEST( EpubValidatesTest, MissingXhtmlFiles )
\r
70 ASSERT_NO_THROW( ValidateEpub(
\r
71 "test_data/framework_tests/EpubValidates_MissingXhtmlFiles.epub" ) );
\r
74 TEST( EpubValidatesTest, Valid )
\r
76 std::vector<Result> results = ValidateEpub(
\r
77 "test_data/framework_tests/EpubValidates_Valid.epub" );
\r
79 ASSERT_EQ( results.size(), 0U );
\r