Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "base/strings/utf_string_conversions.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 struct TestData { | |
| 11 const char* search_request_url; | |
| 12 const char* expected_search_query; | |
| 13 const char* expected_original_query; | |
| 14 const char* expected_rlz_param; | |
| 15 const char* expected_input_encoding; | |
| 16 const char* expected_assisted_query_stats; | |
| 17 }; | |
| 18 | |
| 19 TEST(EmbeddedSearchRequestParams, ExtractParams) { | |
| 20 TestData cases[] = { | |
| 21 {"https://foo/search?q=google&oq=g&rlz=30ls&ie=utf-8&aqs=chrome..6l5.j04", | |
| 22 "google", | |
| 23 "g", | |
| 24 "30ls", | |
| 25 "utf-8", | |
| 26 "chrome..6l5.j04" | |
| 27 }, | |
| 28 // Do not populate "rlz" param. | |
| 29 {"https://foo/search?q=google%20j&oq=g&ie=utf-8&aqs=chrome.2.65.j04", | |
| 30 "google j", | |
| 31 "g", | |
| 32 "", | |
| 33 "utf-8", | |
| 34 "chrome.2.65.j04" | |
| 35 }, | |
| 36 // Unescape search query. | |
| 37 {"https://foo/search?q=google+j&oq=g&rlz=30&ie=utf-8&aqs=chrome.2.65.j04", | |
| 38 "google j", | |
| 39 "g", | |
| 40 "30", | |
| 41 "utf-8", | |
| 42 "chrome.2.65.j04" | |
| 43 }, | |
| 44 // Unescape original query. | |
| 45 {"https://foo/search?q=g+j%20j&oq=g+j&rlz=30&ie=utf-8&aqs=chrome.2.65.j04", | |
| 46 "g j j", | |
| 47 "g j", | |
| 48 "30", | |
| 49 "utf-8", | |
| 50 "chrome.2.65.j04" | |
| 51 }, | |
| 52 }; | |
| 53 | |
| 54 for (size_t i = 0; i < arraysize(cases); ++i) { | |
| 55 EmbeddedSearchRequestParams params(GURL(cases[i].search_request_url)); | |
| 56 EXPECT_EQ(cases[i].expected_search_query, | |
|
sky
2014/11/18 00:12:22
Use << for these so that if something fails you kn
kmadhusu
2014/11/18 00:58:27
Done.
| |
| 57 base::UTF16ToASCII(params.search_query)); | |
| 58 EXPECT_EQ(cases[i].expected_original_query, | |
| 59 base::UTF16ToASCII(params.original_query)); | |
| 60 EXPECT_EQ(cases[i].expected_rlz_param, | |
| 61 base::UTF16ToASCII(params.rlz_parameter_value)); | |
| 62 EXPECT_EQ(cases[i].expected_input_encoding, | |
| 63 base::UTF16ToASCII(params.input_encoding)); | |
| 64 EXPECT_EQ(cases[i].expected_assisted_query_stats, | |
| 65 base::UTF16ToASCII(params.assisted_query_stats)); | |
| 66 } | |
| 67 } | |
| OLD | NEW |