| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 "components/search_engines/detect_desktop_search_win.h" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 | |
| 9 #include "base/macros.h" | |
| 10 #include "base/strings/string16.h" | |
| 11 #include "components/search_engines/testing_search_terms_data.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 #include "url/gurl.h" | |
| 14 | |
| 15 namespace { | |
| 16 struct DetectWindowsDesktopSearchTestData { | |
| 17 const char* url; | |
| 18 const wchar_t* expected_search_terms; | |
| 19 }; | |
| 20 } // namespace | |
| 21 | |
| 22 TEST(DetectWindowsDesktopSearch, DetectWindowsDesktopSearch) { | |
| 23 const DetectWindowsDesktopSearchTestData test_data[] = { | |
| 24 {"https://www.google.com", L""}, | |
| 25 {"https://www.bing.com/search", L""}, | |
| 26 {"https://www.bing.com/search?q=keyword&form=QBLH", L""}, | |
| 27 {"https://www.bing.com/search?q=keyword&form=WNSGPH", L"keyword"}, | |
| 28 {"https://www.bing.com/search?q=keyword&form=WNSBOX", L"keyword"}, | |
| 29 {"https://www.bing.com/search?q=keyword&FORM=WNSGPH", L"keyword"}, | |
| 30 {"https://www.bing.com/search?q=keyword&FORM=WNSBOX", L"keyword"}, | |
| 31 {"https://www.bing.com/search?form=WNSGPH&q=keyword", L"keyword"}, | |
| 32 {"https://www.bing.com/search?q=keyword&form=WNSGPH&other=stuff", | |
| 33 L"keyword"}, | |
| 34 {"https://www.bing.com/search?q=%C3%A8+%C3%A9&form=WNSGPH", L"\xE8 \xE9"}, | |
| 35 }; | |
| 36 | |
| 37 for (size_t i = 0; i < arraysize(test_data); ++i) { | |
| 38 TestingSearchTermsData search_terms_data("https://www.google.com"); | |
| 39 base::string16 search_terms; | |
| 40 bool is_desktop_search = DetectWindowsDesktopSearch( | |
| 41 GURL(test_data[i].url), search_terms_data, &search_terms); | |
| 42 const base::string16 expected_search_terms( | |
| 43 test_data[i].expected_search_terms); | |
| 44 EXPECT_EQ(!expected_search_terms.empty(), is_desktop_search); | |
| 45 EXPECT_EQ(expected_search_terms, search_terms); | |
| 46 } | |
| 47 } | |
| OLD | NEW |