mirror of https://github.com/kiwix/libkiwix.git
Adapt `test/server_xml_search.cpp` to xml search.
This is the real change.
This commit is contained in:
parent
9ec8593f8c
commit
ee01859984
|
@ -3,147 +3,37 @@
|
|||
#include "./httplib.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define SERVER_PORT 8101
|
||||
#define SERVER_PORT 8201
|
||||
#include "server_testing_tools.h"
|
||||
|
||||
std::string makeSearchResultsHtml(const std::string& pattern,
|
||||
const std::string& header,
|
||||
const std::string& results,
|
||||
const std::string& footer)
|
||||
std::string makeSearchResultsXml(const std::string& header,
|
||||
const std::string& results)
|
||||
{
|
||||
const char SEARCHRESULTS_HTML_TEMPLATE[] = R"HTML(<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
|
||||
const char SEARCHRESULTS_XML_TEMPLATE[] = R"XML(<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0"
|
||||
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
|
||||
xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
%HEADER%%RESULTS%
|
||||
</channel>
|
||||
</rss>
|
||||
)XML";
|
||||
|
||||
//EOLWHITESPACEMARKER
|
||||
<style type="text/css">
|
||||
body{
|
||||
color: #000000;
|
||||
font: small/normal Arial,Helvetica,Sans-Serif;
|
||||
margin-top: 0.5em;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
a{
|
||||
color: #04c;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #639
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline
|
||||
}
|
||||
|
||||
.header {
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin:0;
|
||||
padding:0
|
||||
}
|
||||
|
||||
.results {
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
.results li {
|
||||
list-style-type:none;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.results a {
|
||||
font-size: 110%;
|
||||
text-decoration: underline
|
||||
}
|
||||
|
||||
cite {
|
||||
font-style:normal;
|
||||
word-wrap:break-word;
|
||||
display: block;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.informations {
|
||||
color: #388222;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.book-title {
|
||||
color: #662200;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 0;
|
||||
margin-top: 1em;
|
||||
width: 100%;
|
||||
float: left
|
||||
}
|
||||
|
||||
.footer a, .footer span {
|
||||
display: block;
|
||||
padding: .3em .7em;
|
||||
margin: 0 .38em 0 0;
|
||||
text-align:center;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.footer a:hover {
|
||||
background: #ededed;
|
||||
}
|
||||
|
||||
.footer ul, .footer li {
|
||||
list-style:none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.footer li {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.selected {
|
||||
background: #ededed;
|
||||
}
|
||||
|
||||
</style>
|
||||
<title>Search: %PATTERN%</title>
|
||||
<link type="root" href="/ROOT"></head>
|
||||
<body bgcolor="white">
|
||||
<div class="header">
|
||||
%HEADER%
|
||||
</div>
|
||||
|
||||
<div class="results">
|
||||
<ul>%RESULTS%
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer">%FOOTER%
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
)HTML";
|
||||
|
||||
std::string html = removeEOLWhitespaceMarkers(SEARCHRESULTS_HTML_TEMPLATE);
|
||||
html = replace(html, "%PATTERN%", pattern);
|
||||
std::string html = removeEOLWhitespaceMarkers(SEARCHRESULTS_XML_TEMPLATE);
|
||||
html = replace(html, "%HEADER%", header);
|
||||
html = replace(html, "%RESULTS%", results);
|
||||
html = replace(html, "%FOOTER%", footer);
|
||||
return html;
|
||||
}
|
||||
|
||||
#define SEARCH_RESULT(LINK, TITLE, SNIPPET, BOOK_TITLE, WORDCOUNT) \
|
||||
"\n <a href=\"" LINK "\">\n"\
|
||||
" " TITLE "\n"\
|
||||
" </a>\n"\
|
||||
" <cite>" SNIPPET "</cite>\n"\
|
||||
" <div class=\"book-title\">from " BOOK_TITLE "</div>\n"\
|
||||
" <div class=\"informations\">" WORDCOUNT " words</div>\n"
|
||||
" <title>" TITLE "</title>\n"\
|
||||
" <link>" LINK "</link>\n"\
|
||||
" <description>" SNIPPET "</description>\n"\
|
||||
" <book>\n"\
|
||||
" <title>" BOOK_TITLE "</title>\n"\
|
||||
" </book>\n"\
|
||||
" <wordCount>" WORDCOUNT "</wordCount>"
|
||||
|
||||
|
||||
const std::vector<std::string> LARGE_SEARCH_RESULTS = {
|
||||
SEARCH_RESULT(
|
||||
|
@ -187,7 +77,7 @@ const std::vector<std::string> LARGE_SEARCH_RESULTS = {
|
|||
),
|
||||
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT/zimfile/A/Catchin'_Some_Rays:_The_Music_of_Ray_Charles",
|
||||
/*link*/ "/ROOT/zimfile/A/Catchin'_Some_Rays:_The_Music_of_Ray_Charles",
|
||||
/*title*/ "Catchin' Some Rays: The Music of Ray Charles",
|
||||
/*snippet*/ R"SNIPPET(...<b>jazz</b> singer Roseanna Vitro, released in August 1997 on the Telarc <b>Jazz</b> label. Catchin' Some Rays: The Music of Ray Charles Studio album by Roseanna Vitro Released August 1997 Recorded March 26, 1997 at Sound on Sound, NYC April 4,1997 at Quad Recording Studios, NYC Genre Vocal <b>jazz</b> Length 61:00 Label Telarc <b>Jazz</b> CD-83419 Producer Paul Wickliffe Roseanna Vitro chronology Passion Dance (1996) Catchin' Some Rays: The Music of Ray Charles (1997) The Time of My Life: Roseanna Vitro Sings the Songs of......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
|
@ -195,7 +85,7 @@ const std::vector<std::string> LARGE_SEARCH_RESULTS = {
|
|||
),
|
||||
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT/zimfile/A/That's_What_I_Say:_John_Scofield_Plays_the_Music_of_Ray_Charles",
|
||||
/*link*/ "/ROOT/zimfile/A/That's_What_I_Say:_John_Scofield_Plays_the_Music_of_Ray_Charles",
|
||||
/*title*/ "That's What I Say: John Scofield Plays the Music of Ray Charles",
|
||||
/*snippet*/ R"SNIPPET(That's What I Say: John Scofield Plays the Music of Ray Charles Studio album by John Scofield Released June 7, 2005 (2005-06-07) Recorded December 2004 Studio Avatar Studios, New York City Genre <b>Jazz</b> Length 65:21 Label Verve Producer Steve Jordan John Scofield chronology EnRoute: John Scofield Trio LIVE (2004) That's What I Say: John Scofield Plays the Music of Ray Charles (2005) Out Louder (2006) Professional ratings Review scores Source Rating Allmusic All About <b>Jazz</b> All About <b>Jazz</b>...)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
|
@ -435,7 +325,7 @@ const std::vector<std::string> LARGE_SEARCH_RESULTS = {
|
|||
),
|
||||
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT/zimfile/A/Don't_Let_the_Sun_Catch_You_Cryin'",
|
||||
/*link*/ "/ROOT/zimfile/A/Don't_Let_the_Sun_Catch_You_Cryin'",
|
||||
/*title*/ "Don't Let the Sun Catch You Cryin'",
|
||||
/*snippet*/ R"SNIPPET(...R&B Sides" and No. 95 on the Billboard Hot 100. It was also recorded by Jackie DeShannon on her 1965 album This is Jackie De Shannon, Paul McCartney on his 1990 live album Tripping the Live Fantastic, Jex Saarelaht and Kate Ceberano on their album Open the Door - Live at Mietta's (1992) and <b>jazz</b> singer Roseanna Vitro on her 1997 album Catchin’ Some Rays: The Music of Ray Charles. Karin Krog and Steve Kuhn include it on their 2005 album, Together Again. Steve Alaimo released a version in 1963...)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
|
@ -443,7 +333,7 @@ const std::vector<std::string> LARGE_SEARCH_RESULTS = {
|
|||
),
|
||||
|
||||
SEARCH_RESULT(
|
||||
/*link*/ "/ROOT/zimfile/A/I_Don't_Need_No_Doctor",
|
||||
/*link*/ "/ROOT/zimfile/A/I_Don't_Need_No_Doctor",
|
||||
/*title*/ "I Don't Need No Doctor",
|
||||
/*snippet*/ R"SNIPPET(...<b>jazz</b> guitar player John Scofield recorded a version for his album That's What I Say: John Scofield Plays the Music of Ray Charles in 2005, featuring the blues guitarist John Mayer on additional guitar and vocals. Mayer covered the song again with his band during his tour in summer 2007. A recorded live version from a Los Angeles show during that tour is available on Mayer's CD/DVD release Where the Light Is. A Ray Charles tribute album also provided the impetus for <b>jazz</b> singer Roseanna Vitro's......)SNIPPET",
|
||||
/*bookTitle*/ "Ray Charles",
|
||||
|
@ -531,7 +421,7 @@ const std::vector<std::string> LARGE_SEARCH_RESULTS = {
|
|||
|
||||
std::string maskSnippetsInSearchResults(std::string s)
|
||||
{
|
||||
return replace(s, "<cite>.+</cite>", "<cite>SNIPPET TEXT WAS MASKED</cite>");
|
||||
return replace(s, "<description>(?!Search result for).+</description>", "<description>SNIPPET TEXT WAS MASKED</description>");
|
||||
}
|
||||
|
||||
bool isValidSnippet(const std::string& s)
|
||||
|
@ -587,26 +477,18 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
{
|
||||
struct TestData
|
||||
{
|
||||
struct PaginationEntry
|
||||
{
|
||||
std::string label;
|
||||
size_t start;
|
||||
bool selected;
|
||||
};
|
||||
|
||||
std::string query;
|
||||
int start;
|
||||
size_t resultsPerPage;
|
||||
size_t totalResultCount;
|
||||
size_t firstResultIndex;
|
||||
std::vector<std::string> results;
|
||||
std::vector<PaginationEntry> pagination;
|
||||
|
||||
static std::string makeUrl(const std::string& query, int start, size_t resultsPerPage)
|
||||
{
|
||||
std::string url = "/ROOT/search?" + query;
|
||||
std::string url = "/ROOT/search?" + query + "&format=xml";
|
||||
|
||||
if ( start >= 0 ) {
|
||||
if (start >= 0) {
|
||||
url += "&start=" + to_string(start);
|
||||
}
|
||||
|
||||
|
@ -632,23 +514,23 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
|
||||
std::string expectedHeader() const
|
||||
{
|
||||
if ( totalResultCount == 0 ) {
|
||||
return "\n No results were found for <b>\"" + getPattern() + "\"</b>";
|
||||
}
|
||||
std::string header = R"(<title>Search: PATTERN</title>
|
||||
<link>URL</link>
|
||||
<description>Search result for PATTERN</description>
|
||||
<opensearch:totalResults>RESULTCOUNT</opensearch:totalResults>
|
||||
<opensearch:startIndex>FIRSTRESULT</opensearch:startIndex>
|
||||
<opensearch:itemsPerPage>ITEMCOUNT</opensearch:itemsPerPage>
|
||||
<atom:link rel="search" type="application/opensearchdescription+xml" href="/ROOT/search/searchdescription.xml"/>
|
||||
<opensearch:Query role="request"
|
||||
searchTerms="PATTERN"
|
||||
startIndex="FIRSTRESULT"
|
||||
count="ITEMCOUNT"
|
||||
/>)";
|
||||
|
||||
std::string header = R"( Results
|
||||
<b>
|
||||
FIRSTRESULT-LASTRESULT
|
||||
</b> of <b>
|
||||
RESULTCOUNT
|
||||
</b> for <b>
|
||||
"PATTERN"
|
||||
</b>
|
||||
)";
|
||||
|
||||
const size_t lastResultIndex = std::min(totalResultCount, firstResultIndex + results.size() - 1);
|
||||
auto realResultsPerPage = resultsPerPage?resultsPerPage:25;
|
||||
header = replace(header, "URL", replace(makeUrl(query, firstResultIndex, realResultsPerPage), "&", "&"));
|
||||
header = replace(header, "FIRSTRESULT", to_string(firstResultIndex));
|
||||
header = replace(header, "LASTRESULT", to_string(lastResultIndex));
|
||||
header = replace(header, "ITEMCOUNT", to_string(realResultsPerPage));
|
||||
header = replace(header, "RESULTCOUNT", to_string(totalResultCount));
|
||||
header = replace(header, "PATTERN", getPattern());
|
||||
return header;
|
||||
|
@ -657,49 +539,23 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
std::string expectedResultsString() const
|
||||
{
|
||||
if ( results.empty() ) {
|
||||
return "\n ";
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
std::string s;
|
||||
for ( const auto& r : results ) {
|
||||
s += "\n <li>";
|
||||
s += "\n <item>\n";
|
||||
s += maskSnippetsInSearchResults(r);
|
||||
s += " </li>";
|
||||
s += "\n </item>";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string expectedFooter() const
|
||||
std::string expectedXml() const
|
||||
{
|
||||
if ( pagination.empty() ) {
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "\n <ul>\n";
|
||||
for ( const auto& p : pagination ) {
|
||||
const auto url = makeUrl(query, p.start, resultsPerPage);
|
||||
oss << " <li>\n";
|
||||
oss << " <a ";
|
||||
if ( p.selected ) {
|
||||
oss << "class=\"selected\"";
|
||||
}
|
||||
oss << "\n href=\"" << url << "\">\n";
|
||||
oss << " " << p.label << "\n";
|
||||
oss << " </a>\n";
|
||||
oss << " </li>\n";
|
||||
}
|
||||
oss << " </ul>";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::string expectedHtml() const
|
||||
{
|
||||
return makeSearchResultsHtml(
|
||||
getPattern(),
|
||||
return makeSearchResultsXml(
|
||||
expectedHeader(),
|
||||
expectedResultsString(),
|
||||
expectedFooter()
|
||||
expectedResultsString()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -710,7 +566,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
|
||||
void check(const std::string& html) const
|
||||
{
|
||||
EXPECT_EQ(maskSnippetsInSearchResults(html), expectedHtml())
|
||||
EXPECT_EQ(maskSnippetsInSearchResults(html), expectedXml())
|
||||
<< testContext();
|
||||
|
||||
checkSnippets(extractSearchResultSnippets(html));
|
||||
|
@ -721,7 +577,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
static Snippets extractSearchResultSnippets(const std::string& html)
|
||||
{
|
||||
Snippets snippets;
|
||||
const std::regex snippetRegex("<cite>(.*)</cite>");
|
||||
const std::regex snippetRegex("<description>(?!Search result for)(.*)</description>");
|
||||
std::sregex_iterator snippetIt(html.begin(), html.end(), snippetRegex);
|
||||
const std::sregex_iterator end;
|
||||
for ( ; snippetIt != end; ++snippetIt)
|
||||
|
@ -774,8 +630,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/* resultsPerPage */ 0,
|
||||
/* totalResultCount */ 0,
|
||||
/* firstResultIndex */ 1,
|
||||
/* results */ {},
|
||||
/* pagination */ {}
|
||||
/* results */ {}
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -792,8 +647,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "93"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -818,8 +672,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -844,8 +697,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -870,8 +722,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -880,8 +731,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/* resultsPerPage */ 100,
|
||||
/* totalResultCount */ 44,
|
||||
/* firstResultIndex */ 1,
|
||||
/* results */ LARGE_SEARCH_RESULTS,
|
||||
/* pagination */ {}
|
||||
/* results */ LARGE_SEARCH_RESULTS
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -896,15 +746,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[2],
|
||||
LARGE_SEARCH_RESULTS[3],
|
||||
LARGE_SEARCH_RESULTS[4],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, true },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "▶", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -920,16 +761,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[7],
|
||||
LARGE_SEARCH_RESULTS[8],
|
||||
LARGE_SEARCH_RESULTS[9],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, false },
|
||||
{ "2", 5, true },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "6", 25, false },
|
||||
{ "▶", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -945,17 +776,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[12],
|
||||
LARGE_SEARCH_RESULTS[13],
|
||||
LARGE_SEARCH_RESULTS[14],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, false },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, true },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "6", 25, false },
|
||||
{ "7", 30, false },
|
||||
{ "▶", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -971,18 +791,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[17],
|
||||
LARGE_SEARCH_RESULTS[18],
|
||||
LARGE_SEARCH_RESULTS[19],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, false },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, true },
|
||||
{ "5", 20, false },
|
||||
{ "6", 25, false },
|
||||
{ "7", 30, false },
|
||||
{ "8", 35, false },
|
||||
{ "▶", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -998,18 +806,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[22],
|
||||
LARGE_SEARCH_RESULTS[23],
|
||||
LARGE_SEARCH_RESULTS[24],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, false },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, true },
|
||||
{ "6", 25, false },
|
||||
{ "7", 30, false },
|
||||
{ "8", 35, false },
|
||||
{ "9", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1025,18 +821,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[27],
|
||||
LARGE_SEARCH_RESULTS[28],
|
||||
LARGE_SEARCH_RESULTS[29],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "◀", 0, false },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "6", 25, true },
|
||||
{ "7", 30, false },
|
||||
{ "8", 35, false },
|
||||
{ "9", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1052,17 +836,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[32],
|
||||
LARGE_SEARCH_RESULTS[33],
|
||||
LARGE_SEARCH_RESULTS[34],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "◀", 0, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "6", 25, false },
|
||||
{ "7", 30, true },
|
||||
{ "8", 35, false },
|
||||
{ "9", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1078,16 +851,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[37],
|
||||
LARGE_SEARCH_RESULTS[38],
|
||||
LARGE_SEARCH_RESULTS[39],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "◀", 0, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "6", 25, false },
|
||||
{ "7", 30, false },
|
||||
{ "8", 35, true },
|
||||
{ "9", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1102,15 +865,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[41],
|
||||
LARGE_SEARCH_RESULTS[42],
|
||||
LARGE_SEARCH_RESULTS[43],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "◀", 0, false },
|
||||
{ "5", 20, false },
|
||||
{ "6", 25, false },
|
||||
{ "7", 30, false },
|
||||
{ "8", 35, false },
|
||||
{ "9", 40, true },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1124,20 +878,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[21],
|
||||
LARGE_SEARCH_RESULTS[22],
|
||||
LARGE_SEARCH_RESULTS[23],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "◀", 0, false },
|
||||
{ "4", 9, false },
|
||||
{ "5", 12, false },
|
||||
{ "6", 15, false },
|
||||
{ "7", 18, false },
|
||||
{ "8", 21, true },
|
||||
{ "9", 24, false },
|
||||
{ "10", 27, false },
|
||||
{ "11", 30, false },
|
||||
{ "12", 33, false },
|
||||
{ "▶", 42, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1149,15 +889,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/* resultsPerPage */ 5,
|
||||
/* totalResultCount */ 44,
|
||||
/* firstResultIndex */ 46,
|
||||
/* results */ {},
|
||||
|
||||
/* pagination */ {
|
||||
{ "◀", 0, false },
|
||||
{ "6", 25, false },
|
||||
{ "7", 30, false },
|
||||
{ "8", 35, false },
|
||||
{ "9", 40, false },
|
||||
}
|
||||
/* results */ {}
|
||||
},
|
||||
|
||||
// We must return results from the two books
|
||||
|
@ -1185,8 +917,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/*bookTitle*/ "Wikibooks",
|
||||
/*wordCount*/ "538"
|
||||
)
|
||||
},
|
||||
/* pagination */ {}
|
||||
}
|
||||
},
|
||||
|
||||
// Only RayCharles is in English.
|
||||
|
@ -1206,8 +937,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/*bookTitle*/ "Ray Charles",
|
||||
/*wordCount*/ "204"
|
||||
),
|
||||
},
|
||||
/* pagination */ {}
|
||||
}
|
||||
},
|
||||
|
||||
// Adding a book (without match) doesn't change the results
|
||||
|
@ -1219,8 +949,7 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
/* resultsPerPage */ 100,
|
||||
/* totalResultCount */ 44,
|
||||
/* firstResultIndex */ 1,
|
||||
/* results */ LARGE_SEARCH_RESULTS,
|
||||
/* pagination */ {}
|
||||
/* results */ LARGE_SEARCH_RESULTS
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -1236,15 +965,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[2],
|
||||
LARGE_SEARCH_RESULTS[3],
|
||||
LARGE_SEARCH_RESULTS[4],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, true },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "▶", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1261,15 +981,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[2],
|
||||
LARGE_SEARCH_RESULTS[3],
|
||||
LARGE_SEARCH_RESULTS[4],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, true },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "▶", 40, false },
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1287,15 +998,6 @@ TEST_F(TaskbarlessServerTest, searchResults)
|
|||
LARGE_SEARCH_RESULTS[2],
|
||||
LARGE_SEARCH_RESULTS[3],
|
||||
LARGE_SEARCH_RESULTS[4],
|
||||
},
|
||||
|
||||
/* pagination */ {
|
||||
{ "1", 0, true },
|
||||
{ "2", 5, false },
|
||||
{ "3", 10, false },
|
||||
{ "4", 15, false },
|
||||
{ "5", 20, false },
|
||||
{ "▶", 40, false },
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue