| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/passwords/password_manager_presenter.h" | 5 #include "chrome/browser/ui/passwords/password_manager_presenter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 TEST_F(PasswordManagerPresenterTest, Sorting_DifferentPasswords) { | 246 TEST_F(PasswordManagerPresenterTest, Sorting_DifferentPasswords) { |
| 247 const SortEntry test_cases[] = { | 247 const SortEntry test_cases[] = { |
| 248 {"http://example.com", "user_a", "1", nullptr, nullptr, 0}, | 248 {"http://example.com", "user_a", "1", nullptr, nullptr, 0}, |
| 249 {"http://example.com", "user_a", "2", nullptr, nullptr, 1}, | 249 {"http://example.com", "user_a", "2", nullptr, nullptr, 1}, |
| 250 {"http://example.com", "user_a", "3", nullptr, nullptr, 2}}; | 250 {"http://example.com", "user_a", "3", nullptr, nullptr, 2}}; |
| 251 SortAndCheckPositions(test_cases, arraysize(test_cases), | 251 SortAndCheckPositions(test_cases, arraysize(test_cases), |
| 252 PasswordEntryType::SAVED); | 252 PasswordEntryType::SAVED); |
| 253 } | 253 } |
| 254 | 254 |
| 255 TEST_F(PasswordManagerPresenterTest, Sorting_DifferentSchemes) { |
| 256 const SortEntry test_cases[] = { |
| 257 {"https://example.com", "user", "1", nullptr, nullptr, 1}, |
| 258 {"https://example.com", "user", "1", nullptr, nullptr, -1}, // Hide it. |
| 259 {"http://example.com", "user", "1", nullptr, nullptr, 0}}; |
| 260 SortAndCheckPositions(test_cases, arraysize(test_cases), |
| 261 PasswordEntryType::SAVED); |
| 262 } |
| 263 |
| 255 TEST_F(PasswordManagerPresenterTest, Sorting_HideDuplicates) { | 264 TEST_F(PasswordManagerPresenterTest, Sorting_HideDuplicates) { |
| 256 const SortEntry test_cases[] = { | 265 const SortEntry test_cases[] = { |
| 257 {"http://example.com", "user_a", "pwd", nullptr, nullptr, 0}, | 266 {"http://example.com", "user_a", "pwd", nullptr, nullptr, 0}, |
| 258 // Different username. | 267 // Different username. |
| 259 {"http://example.com", "user_b", "pwd", nullptr, nullptr, 2}, | 268 {"http://example.com", "user_b", "pwd", nullptr, nullptr, 2}, |
| 260 // Different password. | 269 // Different password. |
| 261 {"http://example.com", "user_a", "secret", nullptr, nullptr, 1}, | 270 {"http://example.com", "user_a", "secret", nullptr, nullptr, 1}, |
| 262 // Different origin. | 271 // Different origin. |
| 263 {"http://sub1.example.com", "user_a", "pwd", nullptr, nullptr, 3}, | 272 {"http://sub1.example.com", "user_a", "pwd", nullptr, nullptr, 3}, |
| 264 {"http://example.com", "user_a", "pwd", nullptr, nullptr, -1} // Hide it. | 273 {"http://example.com", "user_a", "pwd", nullptr, nullptr, -1} // Hide it. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 287 {"http://example-a.com", nullptr, nullptr, nullptr, nullptr, 0}, | 296 {"http://example-a.com", nullptr, nullptr, nullptr, nullptr, 0}, |
| 288 {"http://example-a.com", nullptr, nullptr, nullptr, nullptr, | 297 {"http://example-a.com", nullptr, nullptr, nullptr, nullptr, |
| 289 -1}, // Hide it. | 298 -1}, // Hide it. |
| 290 {"http://example-c.com", nullptr, nullptr, nullptr, nullptr, 2}}; | 299 {"http://example-c.com", nullptr, nullptr, nullptr, nullptr, 2}}; |
| 291 SortAndCheckPositions(test_cases, arraysize(test_cases), | 300 SortAndCheckPositions(test_cases, arraysize(test_cases), |
| 292 PasswordEntryType::BLACKLISTED); | 301 PasswordEntryType::BLACKLISTED); |
| 293 } | 302 } |
| 294 | 303 |
| 295 TEST_F(PasswordManagerPresenterTest, Sorting_AndroidCredentials) { | 304 TEST_F(PasswordManagerPresenterTest, Sorting_AndroidCredentials) { |
| 296 const SortEntry test_cases[] = { | 305 const SortEntry test_cases[] = { |
| 297 {"https://alpha.com", "user", "secret", nullptr, nullptr, 0}, | 306 {"https://alpha.com", "user", "secret", nullptr, nullptr, 1}, |
| 298 {"android://hash@com.alpha", "user", "secret", "https://alpha.com", | 307 {"android://hash@com.alpha", "user", "secret", "https://alpha.com", |
| 299 nullptr, 1}, | 308 nullptr, 0}, |
| 300 {"android://hash@com.alpha", "user", "secret", "https://alpha.com", | 309 {"android://hash@com.alpha", "user", "secret", "https://alpha.com", |
| 301 nullptr, -1}, | 310 nullptr, -1}, |
| 302 {"android://hash@com.alpha", "user", "secret", nullptr, nullptr, 2}, | 311 {"android://hash@com.alpha", "user", "secret", nullptr, nullptr, 2}, |
| 303 {"android://hash@com.betta.android", "user", "secret", | 312 {"android://hash@com.betta.android", "user", "secret", |
| 304 "https://betta.com", nullptr, 3}, | 313 "https://betta.com", nullptr, 3}, |
| 305 {"android://hash@com.betta.android", "user", "secret", nullptr, nullptr, | 314 {"android://hash@com.betta.android", "user", "secret", nullptr, nullptr, |
| 306 4}}; | 315 4}}; |
| 307 SortAndCheckPositions(test_cases, arraysize(test_cases), | 316 SortAndCheckPositions(test_cases, arraysize(test_cases), |
| 308 PasswordEntryType::SAVED); | 317 PasswordEntryType::SAVED); |
| 309 } | 318 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 334 {"https://abc.com/", "user_a", "pwd", nullptr, nullptr, 0}, | 343 {"https://abc.com/", "user_a", "pwd", nullptr, nullptr, 0}, |
| 335 {"https://xn--ab-fma.com/", "user_a", "pwd", nullptr, nullptr, 2}, | 344 {"https://xn--ab-fma.com/", "user_a", "pwd", nullptr, nullptr, 2}, |
| 336 {"https://xn--bc-lia.com/", "user_a", "pwd", nullptr, nullptr, 3}, | 345 {"https://xn--bc-lia.com/", "user_a", "pwd", nullptr, nullptr, 3}, |
| 337 {"https://xn--ndalk.com/", "user_a", "pwd", nullptr, nullptr, 5}, | 346 {"https://xn--ndalk.com/", "user_a", "pwd", nullptr, nullptr, 5}, |
| 338 }; | 347 }; |
| 339 SortAndCheckPositions(test_cases, arraysize(test_cases), | 348 SortAndCheckPositions(test_cases, arraysize(test_cases), |
| 340 PasswordEntryType::SAVED); | 349 PasswordEntryType::SAVED); |
| 341 } | 350 } |
| 342 | 351 |
| 343 } // namespace | 352 } // namespace |
| OLD | NEW |