Support for CSS URL in HTML response tests

This commit is contained in:
Veloman Yunkan 2022-02-11 18:41:33 +04:00
parent a3460f6f48
commit aaf232bee4
1 changed files with 33 additions and 10 deletions

View File

@ -328,12 +328,17 @@ namespace TestingOfHtmlResponses
struct ExpectedResponseData struct ExpectedResponseData
{ {
const std::string expectedPageTitle, bookName, bookTitle, expectedBody; const std::string expectedPageTitle;
const std::string expectedCssUrl;
const std::string bookName;
const std::string bookTitle;
const std::string expectedBody;
}; };
enum ExpectedResponseDataType enum ExpectedResponseDataType
{ {
expected_page_title, expected_page_title,
expected_css_url,
book_name, book_name,
book_title, book_title,
expected_body expected_body
@ -346,10 +351,11 @@ ExpectedResponseData operator==(ExpectedResponseDataType t, std::string s)
{ {
switch (t) switch (t)
{ {
case expected_page_title: return ExpectedResponseData{s, "", "", ""}; case expected_page_title: return ExpectedResponseData{s, "", "", "", ""};
case book_name: return ExpectedResponseData{"", s, "", ""}; case expected_css_url: return ExpectedResponseData{"", s, "", "", ""};
case book_title: return ExpectedResponseData{"", "", s, ""}; case book_name: return ExpectedResponseData{"", "", s, "", ""};
case expected_body: return ExpectedResponseData{"", "", "", s}; case book_title: return ExpectedResponseData{"", "", "", s, ""};
case expected_body: return ExpectedResponseData{"", "", "", "", s};
default: assert(false); return ExpectedResponseData{}; default: assert(false); return ExpectedResponseData{};
} }
} }
@ -367,6 +373,7 @@ ExpectedResponseData operator&&(const ExpectedResponseData& a,
{ {
return ExpectedResponseData{ return ExpectedResponseData{
selectNonEmpty(a.expectedPageTitle, b.expectedPageTitle), selectNonEmpty(a.expectedPageTitle, b.expectedPageTitle),
selectNonEmpty(a.expectedCssUrl, b.expectedCssUrl),
selectNonEmpty(a.bookName, b.bookName), selectNonEmpty(a.bookName, b.bookName),
selectNonEmpty(a.bookTitle, b.bookTitle), selectNonEmpty(a.bookTitle, b.bookTitle),
selectNonEmpty(a.expectedBody, b.expectedBody) selectNonEmpty(a.expectedBody, b.expectedBody)
@ -388,6 +395,7 @@ public:
private: private:
std::string pageTitle() const; std::string pageTitle() const;
std::string pageCssLink() const;
std::string hiddenBookNameInput() const; std::string hiddenBookNameInput() const;
std::string searchPatternInput() const; std::string searchPatternInput() const;
std::string taskbarLinks() const; std::string taskbarLinks() const;
@ -403,7 +411,9 @@ std::string TestContentIn404HtmlResponse::expectedResponse() const
<title>)FRAG", <title>)FRAG",
R"FRAG(</title> R"FRAG(</title>
<link type="root" href="/ROOT"><link type="text/css" href="/ROOT/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" /> )FRAG",
R"FRAG( <link type="root" href="/ROOT"><link type="text/css" href="/ROOT/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
<link type="text/css" href="/ROOT/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" /> <link type="text/css" href="/ROOT/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
<link type="text/css" href="/ROOT/skin/taskbar.css" rel="Stylesheet" /> <link type="text/css" href="/ROOT/skin/taskbar.css" rel="Stylesheet" />
<script type="text/javascript" src="/ROOT/skin/jquery-ui/external/jquery/jquery.js" defer></script> <script type="text/javascript" src="/ROOT/skin/jquery-ui/external/jquery/jquery.js" defer></script>
@ -444,14 +454,16 @@ std::string TestContentIn404HtmlResponse::expectedResponse() const
return frag[0] return frag[0]
+ pageTitle() + pageTitle()
+ frag[1] + frag[1]
+ hiddenBookNameInput() + pageCssLink()
+ frag[2] + frag[2]
+ searchPatternInput() + hiddenBookNameInput()
+ frag[3] + frag[3]
+ taskbarLinks() + searchPatternInput()
+ frag[4] + frag[4]
+ taskbarLinks()
+ frag[5]
+ removeEOLWhitespaceMarkers(expectedBody) + removeEOLWhitespaceMarkers(expectedBody)
+ frag[5]; + frag[6];
} }
std::string TestContentIn404HtmlResponse::pageTitle() const std::string TestContentIn404HtmlResponse::pageTitle() const
@ -461,6 +473,17 @@ std::string TestContentIn404HtmlResponse::pageTitle() const
: expectedPageTitle; : expectedPageTitle;
} }
std::string TestContentIn404HtmlResponse::pageCssLink() const
{
if ( expectedCssUrl.empty() )
return "";
return R"( <link type="text/css" href=")"
+ expectedCssUrl
+ R"(" rel="Stylesheet" />
)";
}
std::string TestContentIn404HtmlResponse::hiddenBookNameInput() const std::string TestContentIn404HtmlResponse::hiddenBookNameInput() const
{ {
return bookName.empty() return bookName.empty()