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