diff --git a/test/server.cpp b/test/server.cpp index 0b5e5bb95..08a640297 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -66,7 +66,10 @@ public: // types public: // functions ZimFileServer(int serverPort, std::string libraryFilePath); - ZimFileServer(int serverPort, const FilePathCollection& zimpaths, std::string indexTemplateString = ""); + ZimFileServer(int serverPort, + bool withTaskbar, + const FilePathCollection& zimpaths, + std::string indexTemplateString = ""); ~ZimFileServer(); Response GET(const char* path, const Headers& headers = Headers()) @@ -88,6 +91,7 @@ private: // data std::unique_ptr nameMapper; std::unique_ptr server; std::unique_ptr client; + const bool withTaskbar = true; }; ZimFileServer::ZimFileServer(int serverPort, std::string libraryFilePath) @@ -99,8 +103,12 @@ ZimFileServer::ZimFileServer(int serverPort, std::string libraryFilePath) run(serverPort); } -ZimFileServer::ZimFileServer(int serverPort, const FilePathCollection& zimpaths, std::string indexTemplateString) +ZimFileServer::ZimFileServer(int serverPort, + bool _withTaskbar, + const FilePathCollection& zimpaths, + std::string indexTemplateString) : manager(&this->library) +, withTaskbar(_withTaskbar) { for ( const auto& zimpath : zimpaths ) { if (!manager.addBookFromPath(zimpath, zimpath, "", false)) @@ -119,6 +127,7 @@ void ZimFileServer::run(int serverPort, std::string indexTemplateString) server->setPort(serverPort); server->setNbThreads(2); server->setVerbose(false); + server->setTaskbar(withTaskbar, withTaskbar); if (!indexTemplateString.empty()) { server->setIndexTemplateString(indexTemplateString); } @@ -148,7 +157,7 @@ protected: protected: void SetUp() override { - zfs1_.reset(new ZimFileServer(PORT, ZIMFILES)); + zfs1_.reset(new ZimFileServer(PORT, /*withTaskbar=*/true, ZIMFILES)); } void TearDown() override { @@ -156,6 +165,14 @@ protected: } }; +class TaskbarlessServerTest : public ServerTest +{ +protected: + void SetUp() override { + zfs1_.reset(new ZimFileServer(PORT, /*withTaskbar=*/false, ZIMFILES)); + } +}; + const bool WITH_ETAG = true; const bool NO_ETAG = false; @@ -241,7 +258,7 @@ TEST(indexTemplateStringTest, emptyIndexTemplate) { "./test/corner_cases.zim" }; - ZimFileServer zfs(PORT, ZIMFILES, ""); + ZimFileServer zfs(PORT, /*withTaskbar=*/true, ZIMFILES, ""); EXPECT_EQ(200, zfs.GET("/ROOT/")->status); } @@ -252,7 +269,7 @@ TEST(indexTemplateStringTest, indexTemplateCheck) { "./test/corner_cases.zim" }; - ZimFileServer zfs(PORT, ZIMFILES, "" + ZimFileServer zfs(PORT, /*withTaskbar=*/true, ZIMFILES, "" "Welcome to kiwix library" "" ""); @@ -1127,7 +1144,7 @@ TEST_F(ServerTest, ETagIsTheSameAcrossHeadAndGet) TEST_F(ServerTest, DifferentServerInstancesProduceDifferentETags) { - ZimFileServer zfs2(PORT + 1, ZIMFILES); + ZimFileServer zfs2(PORT + 1, /*withTaskbar=*/true, ZIMFILES); for ( const Resource& res : all200Resources() ) { if ( !res.etag_expected ) continue; const auto h1 = zfs1_->HEAD(res.url);