Chromium Code Reviews| Index: chrome/browser/ui/passwords/password_manager_presenter_unittest.cc |
| diff --git a/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc b/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc |
| index f81376906dae98c25a7652049356f26640ec2a83..b8312c81a07b3ccba023dac7f2a9b362433e5357 100644 |
| --- a/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc |
| +++ b/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc |
| @@ -137,7 +137,7 @@ void PasswordManagerPresenterTest::SortAndCheckPositions( |
| const SortEntry& entry = test_entries[i]; |
| std::unique_ptr<autofill::PasswordForm> form(new autofill::PasswordForm()); |
| form->signon_realm = entry.origin; |
| - form->origin = GURL(base::ASCIIToUTF16(entry.origin)); |
| + form->origin = GURL(entry.origin); |
| if (entry_type == PasswordEntryType::SAVED) { |
| form->username_value = base::ASCIIToUTF16(entry.username); |
| form->password_value = base::ASCIIToUTF16(entry.password); |
| @@ -163,8 +163,7 @@ void PasswordManagerPresenterTest::SortAndCheckPositions( |
| if (entry.expected_position >= 0) { |
| SCOPED_TRACE(testing::Message("position in sorted list: ") |
| << entry.expected_position); |
| - EXPECT_EQ(GURL(base::ASCIIToUTF16(entry.origin)), |
| - list[entry.expected_position]->origin); |
| + EXPECT_EQ(GURL(entry.origin), list[entry.expected_position]->origin); |
| if (entry_type == PasswordEntryType::SAVED) { |
| EXPECT_EQ(base::ASCIIToUTF16(entry.username), |
| list[entry.expected_position]->username_value); |
| @@ -268,6 +267,20 @@ TEST_F(PasswordManagerPresenterTest, Sorting_HideDuplicates) { |
| PasswordEntryType::SAVED); |
| } |
| +TEST_F(PasswordManagerPresenterTest, Sorting_Subdomains) { |
| + const SortEntry test_cases[] = { |
| + {"http://example.com", "u", "p", nullptr, nullptr, 0}, |
| + {"http://b.example.com", "u", "p", nullptr, nullptr, 6}, |
| + {"http://a.example.com", "u", "p", nullptr, nullptr, 1}, |
| + {"http://1.a.example.com", "u", "p", nullptr, nullptr, 2}, |
| + {"http://2.a.example.com", "u", "p", nullptr, nullptr, 3}, |
| + {"http://x.2.a.example.com", "u", "p", nullptr, nullptr, 4}, |
| + {"http://y.2.a.example.com", "u", "p", nullptr, nullptr, 5}, |
| + }; |
| + SortAndCheckPositions(test_cases, arraysize(test_cases), |
| + PasswordEntryType::SAVED); |
| +} |
| + |
| TEST_F(PasswordManagerPresenterTest, Sorting_PasswordExceptions) { |
| const SortEntry test_cases[] = { |
| {"http://example-b.com", nullptr, nullptr, nullptr, nullptr, 1}, |
| @@ -305,4 +318,26 @@ TEST_F(PasswordManagerPresenterTest, Sorting_Federations) { |
| PasswordEntryType::SAVED); |
| } |
| +TEST_F(PasswordManagerPresenterTest, Sorting_SpecialCharacters) { |
| + // URLs with encoded special characters should not cause crash during sorting. |
| + LOG(INFO) << GURL("http://abč.com"); |
|
kolos1
2016/11/15 12:50:53
Hi Vaclav,
Is it your intention to output these U
vabr (Chromium)
2016/11/15 17:55:20
Oops, definitely unintentional. Thanks for spottin
|
| + LOG(INFO) << GURL("http://abc.com"); |
| + LOG(INFO) << GURL("http://ábc.com"); |
| + LOG(INFO) << GURL("http://uoy.com"); |
| + LOG(INFO) << GURL("http://üöÿ.com"); |
| + LOG(INFO) << GURL("http://zrc.com"); |
| + LOG(INFO) << GURL("http://žřč.com"); |
| + const SortEntry test_cases[] = { |
| + {"https://xn--bea5m6d.com/", "user_a", "pwd", nullptr, nullptr, 4}, |
| + {"https://uoy.com/", "user_a", "pwd", nullptr, nullptr, 1}, |
| + {"https://zrc.com/", "user_a", "pwd", nullptr, nullptr, 6}, |
| + {"https://abc.com/", "user_a", "pwd", nullptr, nullptr, 0}, |
| + {"https://xn--ab-fma.com/", "user_a", "pwd", nullptr, nullptr, 2}, |
| + {"https://xn--bc-lia.com/", "user_a", "pwd", nullptr, nullptr, 3}, |
| + {"https://xn--ndalk.com/", "user_a", "pwd", nullptr, nullptr, 5}, |
| + }; |
| + SortAndCheckPositions(test_cases, arraysize(test_cases), |
| + PasswordEntryType::SAVED); |
| +} |
| + |
| } // namespace |