Dan Beam | f9b688e8 | 2018-02-28 03:04:20 | [diff] [blame] | 1 | // Copyright 2018 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/template_url_data.h" |
| 6 | |
| 7 | #include "base/strings/string_piece.h" |
| 8 | #include "base/strings/utf_string_conversions.h" |
| 9 | #include "base/values.h" |
| 10 | #include "testing/gtest/include/gtest/gtest.h" |
| 11 | |
| 12 | TEST(TemplateURLDataTest, Trim) { |
| 13 | TemplateURLData data( |
| 14 | base::ASCIIToUTF16(" shortname "), base::ASCIIToUTF16(" keyword "), |
| 15 | "https://cs.chromium.org", base::StringPiece(), base::StringPiece(), |
| 16 | base::StringPiece(), base::StringPiece(), base::StringPiece(), |
| 17 | base::StringPiece(), base::StringPiece(), base::StringPiece(), |
| 18 | base::StringPiece(), base::StringPiece(), base::StringPiece(), |
| 19 | base::ListValue(), 0); |
| 20 | |
| 21 | EXPECT_EQ(base::ASCIIToUTF16("shortname"), data.short_name()); |
| 22 | EXPECT_EQ(base::ASCIIToUTF16("keyword"), data.keyword()); |
| 23 | |
| 24 | data.SetShortName(base::ASCIIToUTF16(" othershortname ")); |
| 25 | data.SetKeyword(base::ASCIIToUTF16(" otherkeyword ")); |
| 26 | |
| 27 | EXPECT_EQ(base::ASCIIToUTF16("othershortname"), data.short_name()); |
| 28 | EXPECT_EQ(base::ASCIIToUTF16("otherkeyword"), data.keyword()); |
| 29 | } |