| 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 "chrome/browser/ui/webui/options/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/options/sync_setup_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 SYNC_ALL_DATA, | 60 SYNC_ALL_DATA, |
| 61 CHOOSE_WHAT_TO_SYNC, | 61 CHOOSE_WHAT_TO_SYNC, |
| 62 SYNC_NOTHING | 62 SYNC_NOTHING |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 enum EncryptAllConfig { | 65 enum EncryptAllConfig { |
| 66 ENCRYPT_ALL_DATA, | 66 ENCRYPT_ALL_DATA, |
| 67 ENCRYPT_PASSWORDS | 67 ENCRYPT_PASSWORDS |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 enum PaymentsIntegrationConfig { |
| 71 PAYMENTS_INTEGRATION_ENABLED, |
| 72 PAYMENTS_INTEGRATION_DISABLED |
| 73 }; |
| 74 |
| 70 // Create a json-format string with the key/value pairs appropriate for a call | 75 // Create a json-format string with the key/value pairs appropriate for a call |
| 71 // to HandleConfigure(). If |extra_values| is non-null, then the values from | 76 // to HandleConfigure(). If |extra_values| is non-null, then the values from |
| 72 // the passed dictionary are added to the json. | 77 // the passed dictionary are added to the json. |
| 73 std::string GetConfiguration(const base::DictionaryValue* extra_values, | 78 std::string GetConfiguration(const base::DictionaryValue* extra_values, |
| 74 SyncAllDataConfig sync_all, | 79 SyncAllDataConfig sync_all, |
| 75 syncer::ModelTypeSet types, | 80 syncer::ModelTypeSet types, |
| 76 const std::string& passphrase, | 81 const std::string& passphrase, |
| 77 EncryptAllConfig encrypt_all) { | 82 EncryptAllConfig encrypt_all, |
| 83 PaymentsIntegrationConfig payments_integration) { |
| 78 base::DictionaryValue result; | 84 base::DictionaryValue result; |
| 79 if (extra_values) | 85 if (extra_values) |
| 80 result.MergeDictionary(extra_values); | 86 result.MergeDictionary(extra_values); |
| 81 result.SetBoolean("syncAllDataTypes", sync_all == SYNC_ALL_DATA); | 87 result.SetBoolean("syncAllDataTypes", sync_all == SYNC_ALL_DATA); |
| 82 result.SetBoolean("syncNothing", sync_all == SYNC_NOTHING); | 88 result.SetBoolean("syncNothing", sync_all == SYNC_NOTHING); |
| 83 result.SetBoolean("encryptAllData", encrypt_all == ENCRYPT_ALL_DATA); | 89 result.SetBoolean("encryptAllData", encrypt_all == ENCRYPT_ALL_DATA); |
| 84 result.SetBoolean("usePassphrase", !passphrase.empty()); | 90 result.SetBoolean("usePassphrase", !passphrase.empty()); |
| 85 if (!passphrase.empty()) | 91 if (!passphrase.empty()) |
| 86 result.SetString("passphrase", passphrase); | 92 result.SetString("passphrase", passphrase); |
| 87 // Add all of our data types. | 93 // Add all of our data types. |
| 88 result.SetBoolean("appsSynced", types.Has(syncer::APPS)); | 94 result.SetBoolean("appsSynced", types.Has(syncer::APPS)); |
| 89 result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL)); | 95 result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL)); |
| 90 result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS)); | 96 result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS)); |
| 91 result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS)); | 97 result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS)); |
| 92 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS)); | 98 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS)); |
| 93 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES)); | 99 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES)); |
| 94 result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS)); | 100 result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS)); |
| 95 result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); | 101 result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); |
| 96 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); | 102 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); |
| 97 result.SetBoolean("wifiCredentialsSynced", | 103 result.SetBoolean("wifiCredentialsSynced", |
| 98 types.Has(syncer::WIFI_CREDENTIALS)); | 104 types.Has(syncer::WIFI_CREDENTIALS)); |
| 105 result.SetBoolean("paymentsIntegrationEnabled", |
| 106 payments_integration == PAYMENTS_INTEGRATION_ENABLED); |
| 99 std::string args; | 107 std::string args; |
| 100 base::JSONWriter::Write(result, &args); | 108 base::JSONWriter::Write(result, &args); |
| 101 return args; | 109 return args; |
| 102 } | 110 } |
| 103 | 111 |
| 104 // Checks whether the passed |dictionary| contains a |key| with the given | 112 // Checks whether the passed |dictionary| contains a |key| with the given |
| 105 // |expected_value|. If |omit_if_false| is true, then the value should only | 113 // |expected_value|. If |omit_if_false| is true, then the value should only |
| 106 // be present if |expected_value| is true. | 114 // be present if |expected_value| is true. |
| 107 void CheckBool(const base::DictionaryValue* dictionary, | 115 void CheckBool(const base::DictionaryValue* dictionary, |
| 108 const std::string& key, | 116 const std::string& key, |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 .WillRepeatedly(Return(false)); | 519 .WillRepeatedly(Return(false)); |
| 512 // Open the web UI. | 520 // Open the web UI. |
| 513 handler_->OpenSyncSetup(nullptr); | 521 handler_->OpenSyncSetup(nullptr); |
| 514 | 522 |
| 515 ASSERT_FALSE(handler_->is_configuring_sync()); | 523 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 516 } | 524 } |
| 517 | 525 |
| 518 #endif // #if !defined(OS_CHROMEOS) | 526 #endif // #if !defined(OS_CHROMEOS) |
| 519 | 527 |
| 520 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { | 528 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { |
| 521 std::string args = GetConfiguration( | 529 std::string args = |
| 522 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 530 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), |
| 531 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| 523 base::ListValue list_args; | 532 base::ListValue list_args; |
| 524 list_args.Append(new base::StringValue(args)); | 533 list_args.Append(new base::StringValue(args)); |
| 525 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 534 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 526 .WillRepeatedly(Return(false)); | 535 .WillRepeatedly(Return(false)); |
| 527 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 536 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 528 .WillRepeatedly(Return(false)); | 537 .WillRepeatedly(Return(false)); |
| 529 SetupInitializedProfileSyncService(); | 538 SetupInitializedProfileSyncService(); |
| 530 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 539 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
| 531 handler_->HandleConfigure(&list_args); | 540 handler_->HandleConfigure(&list_args); |
| 532 | 541 |
| 533 // Ensure that we navigated to the "done" state since we don't need a | 542 // Ensure that we navigated to the "done" state since we don't need a |
| 534 // passphrase. | 543 // passphrase. |
| 535 ExpectDone(); | 544 ExpectDone(); |
| 536 } | 545 } |
| 537 | 546 |
| 538 TEST_F(SyncSetupHandlerTest, TestSyncNothing) { | 547 TEST_F(SyncSetupHandlerTest, TestSyncNothing) { |
| 539 std::string args = GetConfiguration( | 548 std::string args = |
| 540 NULL, SYNC_NOTHING, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 549 GetConfiguration(NULL, SYNC_NOTHING, GetAllTypes(), std::string(), |
| 550 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| 541 base::ListValue list_args; | 551 base::ListValue list_args; |
| 542 list_args.Append(new base::StringValue(args)); | 552 list_args.Append(new base::StringValue(args)); |
| 543 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); | 553 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); |
| 544 SetupInitializedProfileSyncService(); | 554 SetupInitializedProfileSyncService(); |
| 545 handler_->HandleConfigure(&list_args); | 555 handler_->HandleConfigure(&list_args); |
| 546 | 556 |
| 547 // We expect a call to SyncSetupOverlay.showSyncSetupPage. | 557 // We expect a call to SyncSetupOverlay.showSyncSetupPage. |
| 548 ASSERT_EQ(1U, web_ui_.call_data().size()); | 558 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 549 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 559 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 550 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); | 560 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); |
| 551 } | 561 } |
| 552 | 562 |
| 553 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { | 563 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { |
| 554 std::string args = GetConfiguration( | 564 std::string args = |
| 555 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); | 565 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), |
| 566 ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED); |
| 556 base::ListValue list_args; | 567 base::ListValue list_args; |
| 557 list_args.Append(new base::StringValue(args)); | 568 list_args.Append(new base::StringValue(args)); |
| 558 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 569 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 559 .WillRepeatedly(Return(false)); | 570 .WillRepeatedly(Return(false)); |
| 560 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 571 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 561 .WillRepeatedly(Return(false)); | 572 .WillRepeatedly(Return(false)); |
| 562 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 573 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| 563 .WillRepeatedly(Return(true)); | 574 .WillRepeatedly(Return(true)); |
| 564 SetupInitializedProfileSyncService(); | 575 SetupInitializedProfileSyncService(); |
| 565 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); | 576 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); |
| 566 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 577 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
| 567 handler_->HandleConfigure(&list_args); | 578 handler_->HandleConfigure(&list_args); |
| 568 | 579 |
| 569 // Ensure that we navigated to the "done" state since we don't need a | 580 // Ensure that we navigated to the "done" state since we don't need a |
| 570 // passphrase. | 581 // passphrase. |
| 571 ExpectDone(); | 582 ExpectDone(); |
| 572 } | 583 } |
| 573 | 584 |
| 574 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { | 585 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { |
| 575 std::string args = GetConfiguration( | 586 std::string args = |
| 576 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 587 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), |
| 588 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| 577 base::ListValue list_args; | 589 base::ListValue list_args; |
| 578 list_args.Append(new base::StringValue(args)); | 590 list_args.Append(new base::StringValue(args)); |
| 579 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 591 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 580 .WillRepeatedly(Return(true)); | 592 .WillRepeatedly(Return(true)); |
| 581 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 593 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 582 .WillRepeatedly(Return(true)); | 594 .WillRepeatedly(Return(true)); |
| 583 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 595 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 584 .WillRepeatedly(Return(false)); | 596 .WillRepeatedly(Return(false)); |
| 585 SetupInitializedProfileSyncService(); | 597 SetupInitializedProfileSyncService(); |
| 586 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 598 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
| 587 SetDefaultExpectationsForConfigPage(); | 599 SetDefaultExpectationsForConfigPage(); |
| 588 | 600 |
| 589 // We should navigate back to the configure page since we need a passphrase. | 601 // We should navigate back to the configure page since we need a passphrase. |
| 590 handler_->HandleConfigure(&list_args); | 602 handler_->HandleConfigure(&list_args); |
| 591 | 603 |
| 592 ExpectConfig(); | 604 ExpectConfig(); |
| 593 } | 605 } |
| 594 | 606 |
| 595 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { | 607 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { |
| 596 base::DictionaryValue dict; | 608 base::DictionaryValue dict; |
| 597 dict.SetBoolean("isGooglePassphrase", true); | 609 dict.SetBoolean("isGooglePassphrase", true); |
| 598 std::string args = GetConfiguration(&dict, | 610 std::string args = |
| 599 SYNC_ALL_DATA, | 611 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "gaiaPassphrase", |
| 600 GetAllTypes(), | 612 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| 601 "gaiaPassphrase", | |
| 602 ENCRYPT_PASSWORDS); | |
| 603 base::ListValue list_args; | 613 base::ListValue list_args; |
| 604 list_args.Append(new base::StringValue(args)); | 614 list_args.Append(new base::StringValue(args)); |
| 605 // Act as if an encryption passphrase is required the first time, then never | 615 // Act as if an encryption passphrase is required the first time, then never |
| 606 // again after that. | 616 // again after that. |
| 607 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); | 617 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); |
| 608 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 618 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 609 .WillRepeatedly(Return(false)); | 619 .WillRepeatedly(Return(false)); |
| 610 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 620 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 611 .WillRepeatedly(Return(false)); | 621 .WillRepeatedly(Return(false)); |
| 612 SetupInitializedProfileSyncService(); | 622 SetupInitializedProfileSyncService(); |
| 613 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 623 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
| 614 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). | 624 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). |
| 615 WillOnce(Return(true)); | 625 WillOnce(Return(true)); |
| 616 | 626 |
| 617 handler_->HandleConfigure(&list_args); | 627 handler_->HandleConfigure(&list_args); |
| 618 // We should navigate to "done" page since we finished configuring. | 628 // We should navigate to "done" page since we finished configuring. |
| 619 ExpectDone(); | 629 ExpectDone(); |
| 620 } | 630 } |
| 621 | 631 |
| 622 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { | 632 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { |
| 623 base::DictionaryValue dict; | 633 base::DictionaryValue dict; |
| 624 dict.SetBoolean("isGooglePassphrase", false); | 634 dict.SetBoolean("isGooglePassphrase", false); |
| 625 std::string args = GetConfiguration(&dict, | 635 std::string args = |
| 626 SYNC_ALL_DATA, | 636 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "custom_passphrase", |
| 627 GetAllTypes(), | 637 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| 628 "custom_passphrase", | |
| 629 ENCRYPT_PASSWORDS); | |
| 630 base::ListValue list_args; | 638 base::ListValue list_args; |
| 631 list_args.Append(new base::StringValue(args)); | 639 list_args.Append(new base::StringValue(args)); |
| 632 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 640 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 633 .WillRepeatedly(Return(false)); | 641 .WillRepeatedly(Return(false)); |
| 634 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 642 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 635 .WillRepeatedly(Return(false)); | 643 .WillRepeatedly(Return(false)); |
| 636 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 644 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 637 .WillRepeatedly(Return(false)); | 645 .WillRepeatedly(Return(false)); |
| 638 SetupInitializedProfileSyncService(); | 646 SetupInitializedProfileSyncService(); |
| 639 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 647 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
| 640 EXPECT_CALL(*mock_pss_, | 648 EXPECT_CALL(*mock_pss_, |
| 641 SetEncryptionPassphrase("custom_passphrase", | 649 SetEncryptionPassphrase("custom_passphrase", |
| 642 ProfileSyncService::EXPLICIT)); | 650 ProfileSyncService::EXPLICIT)); |
| 643 | 651 |
| 644 handler_->HandleConfigure(&list_args); | 652 handler_->HandleConfigure(&list_args); |
| 645 // We should navigate to "done" page since we finished configuring. | 653 // We should navigate to "done" page since we finished configuring. |
| 646 ExpectDone(); | 654 ExpectDone(); |
| 647 } | 655 } |
| 648 | 656 |
| 649 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { | 657 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { |
| 650 base::DictionaryValue dict; | 658 base::DictionaryValue dict; |
| 651 dict.SetBoolean("isGooglePassphrase", true); | 659 dict.SetBoolean("isGooglePassphrase", true); |
| 652 std::string args = GetConfiguration(&dict, | 660 std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), |
| 653 SYNC_ALL_DATA, | 661 "invalid_passphrase", ENCRYPT_PASSWORDS, |
| 654 GetAllTypes(), | 662 PAYMENTS_INTEGRATION_ENABLED); |
| 655 "invalid_passphrase", | |
| 656 ENCRYPT_PASSWORDS); | |
| 657 base::ListValue list_args; | 663 base::ListValue list_args; |
| 658 list_args.Append(new base::StringValue(args)); | 664 list_args.Append(new base::StringValue(args)); |
| 659 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 665 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 660 .WillRepeatedly(Return(true)); | 666 .WillRepeatedly(Return(true)); |
| 661 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 667 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 662 .WillRepeatedly(Return(true)); | 668 .WillRepeatedly(Return(true)); |
| 663 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 669 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 664 .WillRepeatedly(Return(false)); | 670 .WillRepeatedly(Return(false)); |
| 665 SetupInitializedProfileSyncService(); | 671 SetupInitializedProfileSyncService(); |
| 666 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 672 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 682 } | 688 } |
| 683 | 689 |
| 684 // Walks through each user selectable type, and tries to sync just that single | 690 // Walks through each user selectable type, and tries to sync just that single |
| 685 // data type. | 691 // data type. |
| 686 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { | 692 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { |
| 687 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 693 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
| 688 syncer::ModelTypeSet::Iterator it; | 694 syncer::ModelTypeSet::Iterator it; |
| 689 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 695 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
| 690 syncer::ModelTypeSet type_to_set; | 696 syncer::ModelTypeSet type_to_set; |
| 691 type_to_set.Put(it.Get()); | 697 type_to_set.Put(it.Get()); |
| 692 std::string args = GetConfiguration(NULL, | 698 std::string args = |
| 693 CHOOSE_WHAT_TO_SYNC, | 699 GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, type_to_set, std::string(), |
| 694 type_to_set, | 700 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| 695 std::string(), | |
| 696 ENCRYPT_PASSWORDS); | |
| 697 base::ListValue list_args; | 701 base::ListValue list_args; |
| 698 list_args.Append(new base::StringValue(args)); | 702 list_args.Append(new base::StringValue(args)); |
| 699 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 703 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 700 .WillRepeatedly(Return(false)); | 704 .WillRepeatedly(Return(false)); |
| 701 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 705 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 702 .WillRepeatedly(Return(false)); | 706 .WillRepeatedly(Return(false)); |
| 703 SetupInitializedProfileSyncService(); | 707 SetupInitializedProfileSyncService(); |
| 704 EXPECT_CALL(*mock_pss_, | 708 EXPECT_CALL(*mock_pss_, |
| 705 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); | 709 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); |
| 706 handler_->HandleConfigure(&list_args); | 710 handler_->HandleConfigure(&list_args); |
| 707 | 711 |
| 708 ExpectDone(); | 712 ExpectDone(); |
| 709 Mock::VerifyAndClearExpectations(mock_pss_); | 713 Mock::VerifyAndClearExpectations(mock_pss_); |
| 710 web_ui_.ClearTrackedCalls(); | 714 web_ui_.ClearTrackedCalls(); |
| 711 } | 715 } |
| 712 } | 716 } |
| 713 | 717 |
| 714 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) { | 718 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) { |
| 715 std::string args = GetConfiguration(NULL, | 719 std::string args = |
| 716 CHOOSE_WHAT_TO_SYNC, | 720 GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(), std::string(), |
| 717 GetAllTypes(), | 721 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); |
| 718 std::string(), | |
| 719 ENCRYPT_PASSWORDS); | |
| 720 base::ListValue list_args; | 722 base::ListValue list_args; |
| 721 list_args.Append(new base::StringValue(args)); | 723 list_args.Append(new base::StringValue(args)); |
| 722 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 724 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 723 .WillRepeatedly(Return(false)); | 725 .WillRepeatedly(Return(false)); |
| 724 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 726 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 725 .WillRepeatedly(Return(false)); | 727 .WillRepeatedly(Return(false)); |
| 726 SetupInitializedProfileSyncService(); | 728 SetupInitializedProfileSyncService(); |
| 727 EXPECT_CALL(*mock_pss_, | 729 EXPECT_CALL(*mock_pss_, |
| 728 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); | 730 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); |
| 729 handler_->HandleConfigure(&list_args); | 731 handler_->HandleConfigure(&list_args); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 CheckBool(dictionary, "appsRegistered", true); | 805 CheckBool(dictionary, "appsRegistered", true); |
| 804 CheckBool(dictionary, "autofillRegistered", true); | 806 CheckBool(dictionary, "autofillRegistered", true); |
| 805 CheckBool(dictionary, "bookmarksRegistered", true); | 807 CheckBool(dictionary, "bookmarksRegistered", true); |
| 806 CheckBool(dictionary, "extensionsRegistered", true); | 808 CheckBool(dictionary, "extensionsRegistered", true); |
| 807 CheckBool(dictionary, "passwordsRegistered", true); | 809 CheckBool(dictionary, "passwordsRegistered", true); |
| 808 CheckBool(dictionary, "preferencesRegistered", true); | 810 CheckBool(dictionary, "preferencesRegistered", true); |
| 809 CheckBool(dictionary, "wifiCredentialsRegistered", true); | 811 CheckBool(dictionary, "wifiCredentialsRegistered", true); |
| 810 CheckBool(dictionary, "tabsRegistered", true); | 812 CheckBool(dictionary, "tabsRegistered", true); |
| 811 CheckBool(dictionary, "themesRegistered", true); | 813 CheckBool(dictionary, "themesRegistered", true); |
| 812 CheckBool(dictionary, "typedUrlsRegistered", true); | 814 CheckBool(dictionary, "typedUrlsRegistered", true); |
| 815 CheckBool(dictionary, "paymentsIntegrationEnabled", true); |
| 813 CheckBool(dictionary, "showPassphrase", false); | 816 CheckBool(dictionary, "showPassphrase", false); |
| 814 CheckBool(dictionary, "usePassphrase", false); | 817 CheckBool(dictionary, "usePassphrase", false); |
| 815 CheckBool(dictionary, "passphraseFailed", false); | 818 CheckBool(dictionary, "passphraseFailed", false); |
| 816 CheckBool(dictionary, "encryptAllData", false); | 819 CheckBool(dictionary, "encryptAllData", false); |
| 817 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); | 820 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); |
| 818 } | 821 } |
| 819 | 822 |
| 820 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { | 823 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { |
| 821 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 824 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 822 .WillRepeatedly(Return(false)); | 825 .WillRepeatedly(Return(false)); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 | 950 |
| 948 ExpectConfig(); | 951 ExpectConfig(); |
| 949 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 952 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
| 950 const base::DictionaryValue* dictionary = nullptr; | 953 const base::DictionaryValue* dictionary = nullptr; |
| 951 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 954 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
| 952 CheckBool(dictionary, "encryptAllData", false); | 955 CheckBool(dictionary, "encryptAllData", false); |
| 953 CheckBool(dictionary, "encryptAllDataAllowed", false); | 956 CheckBool(dictionary, "encryptAllDataAllowed", false); |
| 954 } | 957 } |
| 955 | 958 |
| 956 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { | 959 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { |
| 957 std::string args = GetConfiguration( | 960 std::string args = |
| 958 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); | 961 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), |
| 962 ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED); |
| 959 base::ListValue list_args; | 963 base::ListValue list_args; |
| 960 list_args.Append(new base::StringValue(args)); | 964 list_args.Append(new base::StringValue(args)); |
| 961 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 965 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
| 962 .WillRepeatedly(Return(false)); | 966 .WillRepeatedly(Return(false)); |
| 963 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 967 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 964 .WillRepeatedly(Return(false)); | 968 .WillRepeatedly(Return(false)); |
| 965 SetupInitializedProfileSyncService(); | 969 SetupInitializedProfileSyncService(); |
| 966 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 970 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
| 967 .WillRepeatedly(Return(false)); | 971 .WillRepeatedly(Return(false)); |
| 968 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); | 972 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); |
| 969 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 973 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
| 970 handler_->HandleConfigure(&list_args); | 974 handler_->HandleConfigure(&list_args); |
| 971 | 975 |
| 972 // Ensure that we navigated to the "done" state since we don't need a | 976 // Ensure that we navigated to the "done" state since we don't need a |
| 973 // passphrase. | 977 // passphrase. |
| 974 ExpectDone(); | 978 ExpectDone(); |
| 975 } | 979 } |
| 976 | 980 |
| OLD | NEW |