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

Side by Side Diff: chrome/common/instant_types_unittest.cc

Issue 2122903002: Move search-related files from chrome/common to chrome/common/search (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move search-related files Created 4 years, 5 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 | « chrome/common/instant_types.cc ('k') | chrome/common/ntp_logging_events.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/instant_types.h"
6
7 #include <stddef.h>
8
9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 struct TestData {
14 const char* search_request_url;
15 const char* expected_search_query;
16 const char* expected_original_query;
17 const char* expected_rlz_param;
18 const char* expected_input_encoding;
19 const char* expected_assisted_query_stats;
20 };
21
22 TEST(EmbeddedSearchRequestParams, ExtractParams) {
23 TestData cases[] = {
24 {"https://foo/search?q=google&oq=g&rlz=30ls&ie=utf-8&aqs=chrome..6l5.j04",
25 "google",
26 "g",
27 "30ls",
28 "utf-8",
29 "chrome..6l5.j04"
30 },
31 // Do not populate "rlz" param.
32 {"https://foo/search?q=google%20j&oq=g&ie=utf-8&aqs=chrome.2.65.j04",
33 "google j",
34 "g",
35 "",
36 "utf-8",
37 "chrome.2.65.j04"
38 },
39 // Unescape search query.
40 {"https://foo/search?q=google+j&oq=g&rlz=30&ie=utf-8&aqs=chrome.2.65.j04",
41 "google j",
42 "g",
43 "30",
44 "utf-8",
45 "chrome.2.65.j04"
46 },
47 // Unescape original query.
48 {"https://foo/search?q=g+j%20j&oq=g+j&rlz=30&ie=utf-8&aqs=chrome.2.65.j04",
49 "g j j",
50 "g j",
51 "30",
52 "utf-8",
53 "chrome.2.65.j04"
54 },
55 {"https://foo/search?q=google#q=fun&oq=f&ie=utf-8&aqs=chrome.0.1",
56 "fun",
57 "f",
58 "",
59 "utf-8",
60 "chrome.0.1"
61 },
62 };
63
64 for (size_t i = 0; i < arraysize(cases); ++i) {
65 EmbeddedSearchRequestParams params(GURL(cases[i].search_request_url));
66 EXPECT_EQ(cases[i].expected_search_query,
67 base::UTF16ToASCII(params.search_query)) << "For index: " << i;
68 EXPECT_EQ(cases[i].expected_original_query,
69 base::UTF16ToASCII(params.original_query)) << "For index: " << i;
70 EXPECT_EQ(cases[i].expected_rlz_param,
71 base::UTF16ToASCII(params.rlz_parameter_value)) <<
72 "For index: " << i;
73 EXPECT_EQ(cases[i].expected_input_encoding,
74 base::UTF16ToASCII(params.input_encoding)) << "For index: " << i;
75 EXPECT_EQ(cases[i].expected_assisted_query_stats,
76 base::UTF16ToASCII(params.assisted_query_stats)) <<
77 "For index: " << i;
78 }
79 }
OLDNEW
« no previous file with comments | « chrome/common/instant_types.cc ('k') | chrome/common/ntp_logging_events.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698