| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 scoped_refptr<MockPasswordStore> password_store_; | 326 scoped_refptr<MockPasswordStore> password_store_; |
| 327 content::NotificationRegistrar registrar_; | 327 content::NotificationRegistrar registrar_; |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test, | 330 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test, |
| 331 const std::vector<PasswordForm>& entries) { | 331 const std::vector<PasswordForm>& entries) { |
| 332 for (size_t i = 0; i < entries.size(); ++i) | 332 for (size_t i = 0; i < entries.size(); ++i) |
| 333 test->AddPasswordSyncNode(entries[i]); | 333 test->AddPasswordSyncNode(entries[i]); |
| 334 } | 334 } |
| 335 | 335 |
| 336 TEST_F(ProfileSyncServicePasswordTest, FailModelAssociation) { | 336 // Flaky on mac_rel. See http://crbug.com/228943 |
| 337 #if defined(OS_MACOSX) |
| 338 #define MAYBE_EmptyNativeEmptySync DISABLED_EmptyNativeEmptySync |
| 339 #define MAYBE_EnsureNoTransactions DISABLED_EnsureNoTransactions |
| 340 #define MAYBE_FailModelAssociation DISABLED_FailModelAssociation |
| 341 #define MAYBE_FailPasswordStoreLoad DISABLED_FailPasswordStoreLoad |
| 342 #define MAYBE_HasNativeEntriesEmptySync DISABLED_HasNativeEntriesEmptySync |
| 343 #define MAYBE_HasNativeEntriesEmptySyncSameUsername \ |
| 344 DISABLED_HasNativeEntriesEmptySyncSameUsername |
| 345 #define MAYBE_HasNativeHasSyncMergeEntry DISABLED_HasNativeHasSyncMergeEntry |
| 346 #define MAYBE_HasNativeHasSyncNoMerge DISABLED_HasNativeHasSyncNoMerge |
| 347 #else |
| 348 #define MAYBE_EmptyNativeEmptySync EmptyNativeEmptySync |
| 349 #define MAYBE_EnsureNoTransactions EnsureNoTransactions |
| 350 #define MAYBE_FailModelAssociation FailModelAssociation |
| 351 #define MAYBE_FailPasswordStoreLoad FailPasswordStoreLoad |
| 352 #define MAYBE_HasNativeEntriesEmptySync HasNativeEntriesEmptySync |
| 353 #define MAYBE_HasNativeEntriesEmptySyncSameUsername \ |
| 354 HasNativeEntriesEmptySyncSameUsername |
| 355 #define MAYBE_HasNativeHasSyncMergeEntry HasNativeHasSyncMergeEntry |
| 356 #define MAYBE_HasNativeHasSyncNoMerge HasNativeHasSyncNoMerge |
| 357 #endif |
| 358 |
| 359 TEST_F(ProfileSyncServicePasswordTest, MAYBE_FailModelAssociation) { |
| 337 StartSyncService(base::Closure(), base::Closure()); | 360 StartSyncService(base::Closure(), base::Closure()); |
| 338 EXPECT_TRUE(sync_service_->HasUnrecoverableError()); | 361 EXPECT_TRUE(sync_service_->HasUnrecoverableError()); |
| 339 } | 362 } |
| 340 | 363 |
| 341 TEST_F(ProfileSyncServicePasswordTest, FailPasswordStoreLoad) { | 364 TEST_F(ProfileSyncServicePasswordTest, MAYBE_FailPasswordStoreLoad) { |
| 342 password_store_ = static_cast<NullPasswordStore*>( | 365 password_store_ = static_cast<NullPasswordStore*>( |
| 343 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 366 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
| 344 &profile_, NullPasswordStore::Build).get()); | 367 &profile_, NullPasswordStore::Build).get()); |
| 345 StartSyncService(base::Closure(), base::Closure()); | 368 StartSyncService(base::Closure(), base::Closure()); |
| 346 EXPECT_FALSE(sync_service_->HasUnrecoverableError()); | 369 EXPECT_FALSE(sync_service_->HasUnrecoverableError()); |
| 347 syncer::ModelTypeSet failed_types = | 370 syncer::ModelTypeSet failed_types = |
| 348 sync_service_->failed_datatypes_handler().GetFailedTypes(); | 371 sync_service_->failed_datatypes_handler().GetFailedTypes(); |
| 349 EXPECT_TRUE(failed_types.Equals(syncer::ModelTypeSet(syncer::PASSWORDS))); | 372 EXPECT_TRUE(failed_types.Equals(syncer::ModelTypeSet(syncer::PASSWORDS))); |
| 350 } | 373 } |
| 351 | 374 |
| 352 TEST_F(ProfileSyncServicePasswordTest, EmptyNativeEmptySync) { | 375 TEST_F(ProfileSyncServicePasswordTest, MAYBE_EmptyNativeEmptySync) { |
| 353 EXPECT_CALL(*password_store_, FillAutofillableLogins(_)) | 376 EXPECT_CALL(*password_store_, FillAutofillableLogins(_)) |
| 354 .WillOnce(Return(true)); | 377 .WillOnce(Return(true)); |
| 355 EXPECT_CALL(*password_store_, FillBlacklistLogins(_)) | 378 EXPECT_CALL(*password_store_, FillBlacklistLogins(_)) |
| 356 .WillOnce(Return(true)); | 379 .WillOnce(Return(true)); |
| 357 SetIdleChangeProcessorExpectations(); | 380 SetIdleChangeProcessorExpectations(); |
| 358 CreateRootHelper create_root(this, syncer::PASSWORDS); | 381 CreateRootHelper create_root(this, syncer::PASSWORDS); |
| 359 StartSyncService(create_root.callback(), base::Closure()); | 382 StartSyncService(create_root.callback(), base::Closure()); |
| 360 std::vector<PasswordForm> sync_entries; | 383 std::vector<PasswordForm> sync_entries; |
| 361 GetPasswordEntriesFromSyncDB(&sync_entries); | 384 GetPasswordEntriesFromSyncDB(&sync_entries); |
| 362 EXPECT_EQ(0U, sync_entries.size()); | 385 EXPECT_EQ(0U, sync_entries.size()); |
| 363 } | 386 } |
| 364 | 387 |
| 365 TEST_F(ProfileSyncServicePasswordTest, HasNativeEntriesEmptySync) { | 388 TEST_F(ProfileSyncServicePasswordTest, MAYBE_HasNativeEntriesEmptySync) { |
| 366 std::vector<PasswordForm*> forms; | 389 std::vector<PasswordForm*> forms; |
| 367 std::vector<PasswordForm> expected_forms; | 390 std::vector<PasswordForm> expected_forms; |
| 368 PasswordForm* new_form = new PasswordForm; | 391 PasswordForm* new_form = new PasswordForm; |
| 369 new_form->scheme = PasswordForm::SCHEME_HTML; | 392 new_form->scheme = PasswordForm::SCHEME_HTML; |
| 370 new_form->signon_realm = "pie"; | 393 new_form->signon_realm = "pie"; |
| 371 new_form->origin = GURL("http://pie.com"); | 394 new_form->origin = GURL("http://pie.com"); |
| 372 new_form->action = GURL("http://pie.com/submit"); | 395 new_form->action = GURL("http://pie.com/submit"); |
| 373 new_form->username_element = UTF8ToUTF16("name"); | 396 new_form->username_element = UTF8ToUTF16("name"); |
| 374 new_form->username_value = UTF8ToUTF16("tom"); | 397 new_form->username_value = UTF8ToUTF16("tom"); |
| 375 new_form->password_element = UTF8ToUTF16("cork"); | 398 new_form->password_element = UTF8ToUTF16("cork"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 386 .WillOnce(Return(true)); | 409 .WillOnce(Return(true)); |
| 387 SetIdleChangeProcessorExpectations(); | 410 SetIdleChangeProcessorExpectations(); |
| 388 CreateRootHelper create_root(this, syncer::PASSWORDS); | 411 CreateRootHelper create_root(this, syncer::PASSWORDS); |
| 389 StartSyncService(create_root.callback(), base::Closure()); | 412 StartSyncService(create_root.callback(), base::Closure()); |
| 390 std::vector<PasswordForm> sync_forms; | 413 std::vector<PasswordForm> sync_forms; |
| 391 GetPasswordEntriesFromSyncDB(&sync_forms); | 414 GetPasswordEntriesFromSyncDB(&sync_forms); |
| 392 ASSERT_EQ(1U, sync_forms.size()); | 415 ASSERT_EQ(1U, sync_forms.size()); |
| 393 EXPECT_TRUE(ComparePasswords(expected_forms[0], sync_forms[0])); | 416 EXPECT_TRUE(ComparePasswords(expected_forms[0], sync_forms[0])); |
| 394 } | 417 } |
| 395 | 418 |
| 396 TEST_F(ProfileSyncServicePasswordTest, HasNativeEntriesEmptySyncSameUsername) { | 419 TEST_F(ProfileSyncServicePasswordTest, |
| 420 MAYBE_HasNativeEntriesEmptySyncSameUsername) { |
| 397 std::vector<PasswordForm*> forms; | 421 std::vector<PasswordForm*> forms; |
| 398 std::vector<PasswordForm> expected_forms; | 422 std::vector<PasswordForm> expected_forms; |
| 399 | 423 |
| 400 { | 424 { |
| 401 PasswordForm* new_form = new PasswordForm; | 425 PasswordForm* new_form = new PasswordForm; |
| 402 new_form->scheme = PasswordForm::SCHEME_HTML; | 426 new_form->scheme = PasswordForm::SCHEME_HTML; |
| 403 new_form->signon_realm = "pie"; | 427 new_form->signon_realm = "pie"; |
| 404 new_form->origin = GURL("http://pie.com"); | 428 new_form->origin = GURL("http://pie.com"); |
| 405 new_form->action = GURL("http://pie.com/submit"); | 429 new_form->action = GURL("http://pie.com/submit"); |
| 406 new_form->username_element = UTF8ToUTF16("name"); | 430 new_form->username_element = UTF8ToUTF16("name"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 SetIdleChangeProcessorExpectations(); | 463 SetIdleChangeProcessorExpectations(); |
| 440 CreateRootHelper create_root(this, syncer::PASSWORDS); | 464 CreateRootHelper create_root(this, syncer::PASSWORDS); |
| 441 StartSyncService(create_root.callback(), base::Closure()); | 465 StartSyncService(create_root.callback(), base::Closure()); |
| 442 std::vector<PasswordForm> sync_forms; | 466 std::vector<PasswordForm> sync_forms; |
| 443 GetPasswordEntriesFromSyncDB(&sync_forms); | 467 GetPasswordEntriesFromSyncDB(&sync_forms); |
| 444 ASSERT_EQ(2U, sync_forms.size()); | 468 ASSERT_EQ(2U, sync_forms.size()); |
| 445 EXPECT_TRUE(ComparePasswords(expected_forms[0], sync_forms[1])); | 469 EXPECT_TRUE(ComparePasswords(expected_forms[0], sync_forms[1])); |
| 446 EXPECT_TRUE(ComparePasswords(expected_forms[1], sync_forms[0])); | 470 EXPECT_TRUE(ComparePasswords(expected_forms[1], sync_forms[0])); |
| 447 } | 471 } |
| 448 | 472 |
| 449 TEST_F(ProfileSyncServicePasswordTest, HasNativeHasSyncNoMerge) { | 473 TEST_F(ProfileSyncServicePasswordTest, MAYBE_HasNativeHasSyncNoMerge) { |
| 450 std::vector<PasswordForm*> native_forms; | 474 std::vector<PasswordForm*> native_forms; |
| 451 std::vector<PasswordForm> sync_forms; | 475 std::vector<PasswordForm> sync_forms; |
| 452 std::vector<PasswordForm> expected_forms; | 476 std::vector<PasswordForm> expected_forms; |
| 453 { | 477 { |
| 454 PasswordForm* new_form = new PasswordForm; | 478 PasswordForm* new_form = new PasswordForm; |
| 455 new_form->scheme = PasswordForm::SCHEME_HTML; | 479 new_form->scheme = PasswordForm::SCHEME_HTML; |
| 456 new_form->signon_realm = "pie"; | 480 new_form->signon_realm = "pie"; |
| 457 new_form->origin = GURL("http://pie.com"); | 481 new_form->origin = GURL("http://pie.com"); |
| 458 new_form->action = GURL("http://pie.com/submit"); | 482 new_form->action = GURL("http://pie.com/submit"); |
| 459 new_form->username_element = UTF8ToUTF16("name"); | 483 new_form->username_element = UTF8ToUTF16("name"); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 std::vector<PasswordForm> new_sync_forms; | 523 std::vector<PasswordForm> new_sync_forms; |
| 500 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 524 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 501 | 525 |
| 502 EXPECT_EQ(2U, new_sync_forms.size()); | 526 EXPECT_EQ(2U, new_sync_forms.size()); |
| 503 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 527 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 504 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[1])); | 528 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[1])); |
| 505 } | 529 } |
| 506 | 530 |
| 507 // Same as HasNativeHasEmptyNoMerge, but we attempt to aquire a sync transaction | 531 // Same as HasNativeHasEmptyNoMerge, but we attempt to aquire a sync transaction |
| 508 // every time the password store is accessed. | 532 // every time the password store is accessed. |
| 509 TEST_F(ProfileSyncServicePasswordTest, EnsureNoTransactions) { | 533 TEST_F(ProfileSyncServicePasswordTest, MAYBE_EnsureNoTransactions) { |
| 510 std::vector<PasswordForm*> native_forms; | 534 std::vector<PasswordForm*> native_forms; |
| 511 std::vector<PasswordForm> sync_forms; | 535 std::vector<PasswordForm> sync_forms; |
| 512 std::vector<PasswordForm> expected_forms; | 536 std::vector<PasswordForm> expected_forms; |
| 513 { | 537 { |
| 514 PasswordForm* new_form = new PasswordForm; | 538 PasswordForm* new_form = new PasswordForm; |
| 515 new_form->scheme = PasswordForm::SCHEME_HTML; | 539 new_form->scheme = PasswordForm::SCHEME_HTML; |
| 516 new_form->signon_realm = "pie"; | 540 new_form->signon_realm = "pie"; |
| 517 new_form->origin = GURL("http://pie.com"); | 541 new_form->origin = GURL("http://pie.com"); |
| 518 new_form->action = GURL("http://pie.com/submit"); | 542 new_form->action = GURL("http://pie.com/submit"); |
| 519 new_form->username_element = UTF8ToUTF16("name"); | 543 new_form->username_element = UTF8ToUTF16("name"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 586 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
| 563 | 587 |
| 564 std::vector<PasswordForm> new_sync_forms; | 588 std::vector<PasswordForm> new_sync_forms; |
| 565 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 589 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 566 | 590 |
| 567 EXPECT_EQ(2U, new_sync_forms.size()); | 591 EXPECT_EQ(2U, new_sync_forms.size()); |
| 568 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 592 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 569 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[1])); | 593 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[1])); |
| 570 } | 594 } |
| 571 | 595 |
| 572 TEST_F(ProfileSyncServicePasswordTest, HasNativeHasSyncMergeEntry) { | 596 TEST_F(ProfileSyncServicePasswordTest, MAYBE_HasNativeHasSyncMergeEntry) { |
| 573 std::vector<PasswordForm*> native_forms; | 597 std::vector<PasswordForm*> native_forms; |
| 574 std::vector<PasswordForm> sync_forms; | 598 std::vector<PasswordForm> sync_forms; |
| 575 std::vector<PasswordForm> expected_forms; | 599 std::vector<PasswordForm> expected_forms; |
| 576 { | 600 { |
| 577 PasswordForm* new_form = new PasswordForm; | 601 PasswordForm* new_form = new PasswordForm; |
| 578 new_form->scheme = PasswordForm::SCHEME_HTML; | 602 new_form->scheme = PasswordForm::SCHEME_HTML; |
| 579 new_form->signon_realm = "pie"; | 603 new_form->signon_realm = "pie"; |
| 580 new_form->origin = GURL("http://pie.com"); | 604 new_form->origin = GURL("http://pie.com"); |
| 581 new_form->action = GURL("http://pie.com/submit"); | 605 new_form->action = GURL("http://pie.com/submit"); |
| 582 new_form->username_element = UTF8ToUTF16("name"); | 606 new_form->username_element = UTF8ToUTF16("name"); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 CreateRootHelper create_root(this, syncer::PASSWORDS); | 657 CreateRootHelper create_root(this, syncer::PASSWORDS); |
| 634 StartSyncService(create_root.callback(), | 658 StartSyncService(create_root.callback(), |
| 635 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 659 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
| 636 | 660 |
| 637 std::vector<PasswordForm> new_sync_forms; | 661 std::vector<PasswordForm> new_sync_forms; |
| 638 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 662 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 639 | 663 |
| 640 EXPECT_EQ(1U, new_sync_forms.size()); | 664 EXPECT_EQ(1U, new_sync_forms.size()); |
| 641 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 665 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 642 } | 666 } |
| OLD | NEW |