| Index: chrome/browser/android/contextualsearch/contextual_search_delegate_unittest.cc
|
| diff --git a/chrome/browser/android/contextualsearch/contextual_search_delegate_unittest.cc b/chrome/browser/android/contextualsearch/contextual_search_delegate_unittest.cc
|
| index 56a25b7473b904f09a2289cf0ff74b4b50854563..f3de4db9c7ca96b9bed62e3262604afbcd6a87e0 100644
|
| --- a/chrome/browser/android/contextualsearch/contextual_search_delegate_unittest.cc
|
| +++ b/chrome/browser/android/contextualsearch/contextual_search_delegate_unittest.cc
|
| @@ -115,12 +115,12 @@ class ContextualSearchDelegateTest : public testing::Test {
|
| return bar_quoted;
|
| }
|
|
|
| - void CreateDefaultSearchWithContextualCardsData(
|
| - const std::string contextual_cards_data) {
|
| + void CreateDefaultSearchWithAdditionalJsonData(
|
| + const std::string additional_json_data) {
|
| CreateDefaultSearchContextAndRequestSearchTerm();
|
| fetcher()->set_response_code(200);
|
| std::string response =
|
| - escapeBarQuoted("{|search_term|:|obama|" + contextual_cards_data + "}");
|
| + escapeBarQuoted("{|search_term|:|obama|" + additional_json_data + "}");
|
| fetcher()->SetResponseString(response);
|
| fetcher()->delegate()->OnURLFetchComplete(fetcher());
|
|
|
| @@ -129,12 +129,6 @@ class ContextualSearchDelegateTest : public testing::Test {
|
| EXPECT_EQ("obama", search_term());
|
| }
|
|
|
| - void CreateDefaultSearchWithContextualCardsValue(
|
| - const std::string contextual_cards_value) {
|
| - CreateDefaultSearchWithContextualCardsData(", |contextual_cards|:" +
|
| - contextual_cards_value);
|
| - }
|
| -
|
| void SetResponseStringAndFetch(const std::string& selected_text,
|
| const std::string& mentions_start,
|
| const std::string& mentions_end) {
|
| @@ -584,85 +578,24 @@ TEST_F(ContextualSearchDelegateTest, HeaderContainsBasePageUrl) {
|
| EXPECT_EQ(kSomeSpecificBasePage, getBasePageUrlFromRequest());
|
| }
|
|
|
| -// Tests a response with a single card from Contextual Cards.
|
| -TEST_F(ContextualSearchDelegateTest,
|
| - ContextualCardsResponseSingleCardBarQuotedTest) {
|
| - CreateDefaultSearchWithContextualCardsValue(
|
| - "{|cards|:[{|singleCard|:{|subtitle|: |president|,"
|
| - "|thumbnail|:{|uri|:|https://t0.gstatic.com/images?q=tbn:ANd9|}}}]}");
|
| - EXPECT_EQ("president", caption());
|
| - EXPECT_EQ("https://t0.gstatic.com/images?q=tbn:ANd9", thumbnail_url());
|
| -}
|
| -
|
| // Missing all Contextual Cards data.
|
| TEST_F(ContextualSearchDelegateTest, ContextualCardsResponseWithNoData) {
|
| - CreateDefaultSearchWithContextualCardsData("");
|
| + CreateDefaultSearchWithAdditionalJsonData("");
|
| EXPECT_EQ("", caption());
|
| EXPECT_EQ("", thumbnail_url());
|
| }
|
|
|
| -// Missing subtitle (for caption).
|
| -TEST_F(ContextualSearchDelegateTest,
|
| - ContextualCardsResponseWithMissingCaption) {
|
| - CreateDefaultSearchWithContextualCardsValue(
|
| - "{|cards|:[{|singleCard|:{|stubtitlemisspelled|: |president|,"
|
| - "|thumbnail|:{|uri|:|https://t0.gstatic.com/images?q=tbn:ANd9|}}}]}");
|
| - EXPECT_EQ("", caption());
|
| - EXPECT_EQ("https://t0.gstatic.com/images?q=tbn:ANd9", thumbnail_url());
|
| -}
|
| -
|
| -// Missing the Thumbnail URI.
|
| -TEST_F(ContextualSearchDelegateTest,
|
| - ContextualCardsResponseWithMissingThumbnailUri) {
|
| - CreateDefaultSearchWithContextualCardsValue(
|
| - "{|cards|:[{|singleCard|:{|subtitle|: |president|,"
|
| - "|thumbnail|:{}}}]}");
|
| - EXPECT_EQ("president", caption());
|
| - EXPECT_EQ("", thumbnail_url());
|
| -}
|
| -
|
| -// Missing the whole Thumbnail.
|
| -TEST_F(ContextualSearchDelegateTest,
|
| - ContextualCardsResponseWithMissingThumbnail) {
|
| - CreateDefaultSearchWithContextualCardsValue(
|
| - "{|cards|:[{|singleCard|:{|subtitle|: |president|,"
|
| - "|ignored key|:|ignored value|}}]}");
|
| - EXPECT_EQ("president", caption());
|
| +// Test just the root level caption.
|
| +TEST_F(ContextualSearchDelegateTest, ContextualCardsResponseWithCaption) {
|
| + CreateDefaultSearchWithAdditionalJsonData(", |caption|:|aCaption|");
|
| + EXPECT_EQ("aCaption", caption());
|
| EXPECT_EQ("", thumbnail_url());
|
| }
|
|
|
| -// Empty cards list.
|
| -TEST_F(ContextualSearchDelegateTest,
|
| - ContextualCardsResponseWithMissingSingleCard) {
|
| - CreateDefaultSearchWithContextualCardsValue("{|cards|:[]}");
|
| +// Test just the root level thumbnail.
|
| +TEST_F(ContextualSearchDelegateTest, ContextualCardsResponseWithThumbnail) {
|
| + CreateDefaultSearchWithAdditionalJsonData(
|
| + ", |thumbnail|:|https://t0.gstatic.com/images?q=tbn:ANd9|");
|
| EXPECT_EQ("", caption());
|
| - EXPECT_EQ("", thumbnail_url());
|
| -}
|
| -
|
| -// Tests carouselCard followed by singleCard.
|
| -TEST_F(ContextualSearchDelegateTest,
|
| - ContextualCardsResponseWithSingleAndCarouselCards) {
|
| - CreateDefaultSearchWithContextualCardsValue(
|
| - "{|cards|:[{|carouselCard|:{}},{|singleCard|:{|subtitle|: |president|,"
|
| - "|thumbnail|:{|uri|:|https://t0.gstatic.com/images?q=tbn:ANd9|}}}]}");
|
| - EXPECT_EQ("president", caption());
|
| - EXPECT_EQ("https://t0.gstatic.com/images?q=tbn:ANd9", thumbnail_url());
|
| -}
|
| -
|
| -// Missing cards.
|
| -TEST_F(ContextualSearchDelegateTest, ContextualCardsResponseWithMissingCards) {
|
| - CreateDefaultSearchWithContextualCardsValue("{}");
|
| - EXPECT_EQ("", caption());
|
| - EXPECT_EQ("", thumbnail_url());
|
| -}
|
| -
|
| -// Multiple cards (latter should be ignored).
|
| -TEST_F(ContextualSearchDelegateTest, ContextualCardsResponseWithMultipleCards) {
|
| - CreateDefaultSearchWithContextualCardsValue(
|
| - "{|cards|:[{|singleCard|:{|subtitle|: |president|,"
|
| - "|thumbnail|:{|uri|:|https://t0.gstatic.com/images?q=tbn:ANd9|}}},"
|
| - "{|singleCard|:{|subtitle|:|wrong subtitle|,"
|
| - "|thumbnail|:{|uri|:|https://t0.gstatic.com/wrongThumbnail|}}}]}");
|
| - EXPECT_EQ("president", caption());
|
| EXPECT_EQ("https://t0.gstatic.com/images?q=tbn:ANd9", thumbnail_url());
|
| }
|
|
|