Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: components/search_engines/template_url_unittest.cc

Issue 424013002: Update the contextual search API to include a parameter specifying whether the server shoudl return… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/search_engines/template_url.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/metrics/proto/omnibox_event.pb.h" 10 #include "components/metrics/proto/omnibox_event.pb.h"
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 "{google:contextualSearchContextData}"); 1504 "{google:contextualSearchContextData}");
1505 1505
1506 TemplateURL url(data); 1506 TemplateURL url(data);
1507 TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo")); 1507 TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo"));
1508 std::string result = url.url_ref().ReplaceSearchTerms(search_terms_args, 1508 std::string result = url.url_ref().ReplaceSearchTerms(search_terms_args,
1509 search_terms_data_); 1509 search_terms_data_);
1510 EXPECT_EQ("http://bar/_/contextualsearch?", result); 1510 EXPECT_EQ("http://bar/_/contextualsearch?", result);
1511 1511
1512 TemplateURLRef::SearchTermsArgs::ContextualSearchParams params( 1512 TemplateURLRef::SearchTermsArgs::ContextualSearchParams params(
1513 1, 6, 11, "allen", "woody+allen+movies", "www.wikipedia.org", 1513 1, 6, 11, "allen", "woody+allen+movies", "www.wikipedia.org",
1514 "utf-8"); 1514 "utf-8", true);
1515 search_terms_args.contextual_search_params = params; 1515 search_terms_args.contextual_search_params = params;
1516 result = url.url_ref().ReplaceSearchTerms(search_terms_args, 1516 result = url.url_ref().ReplaceSearchTerms(search_terms_args,
1517 search_terms_data_); 1517 search_terms_data_);
1518 EXPECT_EQ("http://bar/_/contextualsearch?" 1518 EXPECT_EQ("http://bar/_/contextualsearch?"
1519 "ctxs=1&" 1519 "ctxs=1&"
1520 "ctxs_start=6&" 1520 "ctxs_start=6&"
1521 "ctxs_end=11&" 1521 "ctxs_end=11&"
1522 "q=allen&" 1522 "q=allen&"
1523 "ctxs_content=woody+allen+movies&" 1523 "ctxs_content=woody+allen+movies&"
1524 "ctxs_url=www.wikipedia.org&" 1524 "ctxsl_url=www.wikipedia.org&"
1525 "ctxs_encoding=utf-8&", result); 1525 "ctxs_encoding=utf-8&"
1526 "ctxsl_resolve=1", result);
donnd 2014/07/29 18:01:06 Not from this CL, but the indentation looks wrong
jeremycho 2014/07/29 21:22:24 Done.
1526 } 1527 }
1527 1528
1528 TEST_F(TemplateURLTest, GenerateKeyword) { 1529 TEST_F(TemplateURLTest, GenerateKeyword) {
1529 ASSERT_EQ(ASCIIToUTF16("foo"), 1530 ASSERT_EQ(ASCIIToUTF16("foo"),
1530 TemplateURL::GenerateKeyword(GURL("http://foo"))); 1531 TemplateURL::GenerateKeyword(GURL("http://foo")));
1531 // www. should be stripped. 1532 // www. should be stripped.
1532 ASSERT_EQ(ASCIIToUTF16("foo"), 1533 ASSERT_EQ(ASCIIToUTF16("foo"),
1533 TemplateURL::GenerateKeyword(GURL("http://www.foo"))); 1534 TemplateURL::GenerateKeyword(GURL("http://www.foo")));
1534 // Make sure we don't get a trailing '/'. 1535 // Make sure we don't get a trailing '/'.
1535 ASSERT_EQ(ASCIIToUTF16("blah"), 1536 ASSERT_EQ(ASCIIToUTF16("blah"),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 EXPECT_EQ("http://bar/search?q=foo&pfq=full%20query%20text&qha=2338&xssi=t", 1576 EXPECT_EQ("http://bar/search?q=foo&pfq=full%20query%20text&qha=2338&xssi=t",
1576 result); 1577 result);
1577 1578
1578 TemplateURL url2(data); 1579 TemplateURL url2(data);
1579 search_terms_args.prefetch_query.clear(); 1580 search_terms_args.prefetch_query.clear();
1580 search_terms_args.prefetch_query_type.clear(); 1581 search_terms_args.prefetch_query_type.clear();
1581 result = 1582 result =
1582 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); 1583 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_);
1583 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result); 1584 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result);
1584 } 1585 }
OLDNEW
« no previous file with comments | « components/search_engines/template_url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698