Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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/search_engines_test_util.h" | |
| 6 | |
| 7 #include "base/macros.h" | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "components/search_engines/template_url.h" | |
| 11 #include "components/search_engines/template_url_data.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 std::unique_ptr<TemplateURLData> GenerateDummyTemplateURLData( | |
| 15 const std::string& provider_name) { | |
| 16 std::unique_ptr<TemplateURLData> data(new TemplateURLData()); | |
|
Peter Kasting
2016/12/22 20:49:04
Nit: Prefer MakeUnique() to bare new
Alexander Yashkin
2016/12/23 19:44:09
Done
| |
| 17 data->SetShortName(base::UTF8ToUTF16(provider_name + "name")); | |
| 18 data->SetKeyword(base::UTF8ToUTF16(provider_name + "key")); | |
| 19 data->SetURL(std::string("http://") + provider_name + "foo/{searchTerms}"); | |
| 20 data->suggestions_url = std::string("http://") + provider_name + "sugg"; | |
| 21 data->alternate_urls.push_back(std::string("http://") + provider_name + | |
| 22 "foo/alt"); | |
| 23 data->favicon_url = GURL("http://icon1"); | |
| 24 data->safe_for_autoreplace = true; | |
| 25 data->input_encodings = {"UTF-8", "UTF-16"}; | |
| 26 data->date_created = base::Time(); | |
| 27 data->last_modified = base::Time(); | |
| 28 return data; | |
| 29 } | |
| 30 | |
| 31 void ExpectSimilar(const TemplateURLData* expected, | |
| 32 const TemplateURLData* actual) { | |
| 33 ASSERT_TRUE(expected != NULL); | |
| 34 ASSERT_TRUE(actual != NULL); | |
|
Peter Kasting
2016/12/22 20:49:04
Nit: Use nullptr, or just write ASSERT_TRUE(expect
Alexander Yashkin
2016/12/23 19:44:09
Done
| |
| 35 | |
| 36 EXPECT_EQ(expected->short_name(), actual->short_name()); | |
| 37 EXPECT_EQ(expected->keyword(), actual->keyword()); | |
| 38 EXPECT_EQ(expected->url(), actual->url()); | |
| 39 EXPECT_EQ(expected->suggestions_url, actual->suggestions_url); | |
| 40 EXPECT_EQ(expected->instant_url, actual->instant_url); | |
| 41 EXPECT_EQ(expected->image_url, actual->image_url); | |
| 42 EXPECT_EQ(expected->new_tab_url, actual->new_tab_url); | |
| 43 EXPECT_EQ(expected->contextual_search_url, actual->contextual_search_url); | |
| 44 | |
| 45 EXPECT_EQ(expected->search_url_post_params, actual->search_url_post_params); | |
| 46 EXPECT_EQ(expected->suggestions_url_post_params, | |
| 47 actual->suggestions_url_post_params); | |
| 48 EXPECT_EQ(expected->instant_url_post_params, actual->instant_url_post_params); | |
| 49 EXPECT_EQ(expected->image_url_post_params, actual->image_url_post_params); | |
| 50 | |
| 51 EXPECT_EQ(expected->favicon_url, actual->favicon_url); | |
| 52 EXPECT_EQ(expected->safe_for_autoreplace, actual->safe_for_autoreplace); | |
| 53 EXPECT_EQ(expected->input_encodings, actual->input_encodings); | |
| 54 EXPECT_EQ(expected->alternate_urls, actual->alternate_urls); | |
| 55 EXPECT_TRUE(TemplateURL::SearchTermsReplacementKeysMatch( | |
| 56 expected->search_terms_replacement_key, | |
| 57 actual->search_terms_replacement_key)); | |
| 58 } | |
| OLD | NEW |