Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc

Issue 1578173005: Move Autofill Payments integration checkbox to the sync settings page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add "Learn more" link Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/sync_setup_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 syncer::ModelTypeSet GetAllTypes() { 55 syncer::ModelTypeSet GetAllTypes() {
56 return syncer::UserSelectableTypes(); 56 return syncer::UserSelectableTypes();
57 } 57 }
58 58
59 enum SyncAllDataConfig { 59 enum SyncAllDataConfig {
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 {
brettw 2016/01/15 20:30:41 The existing system seems to be explicitly trying
Justin Donnelly 2016/01/15 21:16:51 Good point. Done.
66 ENCRYPT_ALL_DATA, 66 ENCRYPT_ALL_DATA,
67 ENCRYPT_PASSWORDS 67 ENCRYPT_PASSWORDS
68 }; 68 };
69 69
70 // Create a json-format string with the key/value pairs appropriate for a call 70 // 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 71 // to HandleConfigure(). If |extra_values| is non-null, then the values from
72 // the passed dictionary are added to the json. 72 // the passed dictionary are added to the json.
73 std::string GetConfiguration(const base::DictionaryValue* extra_values, 73 std::string GetConfiguration(const base::DictionaryValue* extra_values,
74 SyncAllDataConfig sync_all, 74 SyncAllDataConfig sync_all,
75 syncer::ModelTypeSet types, 75 syncer::ModelTypeSet types,
76 const std::string& passphrase, 76 const std::string& passphrase,
77 EncryptAllConfig encrypt_all) { 77 EncryptAllConfig encrypt_all,
78 bool payments_integration_enabled) {
78 base::DictionaryValue result; 79 base::DictionaryValue result;
79 if (extra_values) 80 if (extra_values)
80 result.MergeDictionary(extra_values); 81 result.MergeDictionary(extra_values);
81 result.SetBoolean("syncAllDataTypes", sync_all == SYNC_ALL_DATA); 82 result.SetBoolean("syncAllDataTypes", sync_all == SYNC_ALL_DATA);
82 result.SetBoolean("syncNothing", sync_all == SYNC_NOTHING); 83 result.SetBoolean("syncNothing", sync_all == SYNC_NOTHING);
83 result.SetBoolean("encryptAllData", encrypt_all == ENCRYPT_ALL_DATA); 84 result.SetBoolean("encryptAllData", encrypt_all == ENCRYPT_ALL_DATA);
84 result.SetBoolean("usePassphrase", !passphrase.empty()); 85 result.SetBoolean("usePassphrase", !passphrase.empty());
85 if (!passphrase.empty()) 86 if (!passphrase.empty())
86 result.SetString("passphrase", passphrase); 87 result.SetString("passphrase", passphrase);
87 // Add all of our data types. 88 // Add all of our data types.
88 result.SetBoolean("appsSynced", types.Has(syncer::APPS)); 89 result.SetBoolean("appsSynced", types.Has(syncer::APPS));
89 result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL)); 90 result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL));
90 result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS)); 91 result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS));
91 result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS)); 92 result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS));
92 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS)); 93 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS));
93 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES)); 94 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES));
94 result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS)); 95 result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS));
95 result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); 96 result.SetBoolean("themesSynced", types.Has(syncer::THEMES));
96 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); 97 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS));
97 result.SetBoolean("wifiCredentialsSynced", 98 result.SetBoolean("wifiCredentialsSynced",
98 types.Has(syncer::WIFI_CREDENTIALS)); 99 types.Has(syncer::WIFI_CREDENTIALS));
100 result.SetBoolean("paymentsIntegrationEnabled", payments_integration_enabled);
99 std::string args; 101 std::string args;
100 base::JSONWriter::Write(result, &args); 102 base::JSONWriter::Write(result, &args);
101 return args; 103 return args;
102 } 104 }
103 105
104 // Checks whether the passed |dictionary| contains a |key| with the given 106 // 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 107 // |expected_value|. If |omit_if_false| is true, then the value should only
106 // be present if |expected_value| is true. 108 // be present if |expected_value| is true.
107 void CheckBool(const base::DictionaryValue* dictionary, 109 void CheckBool(const base::DictionaryValue* dictionary,
108 const std::string& key, 110 const std::string& key,
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 .WillRepeatedly(Return(false)); 513 .WillRepeatedly(Return(false));
512 // Open the web UI. 514 // Open the web UI.
513 handler_->OpenSyncSetup(nullptr); 515 handler_->OpenSyncSetup(nullptr);
514 516
515 ASSERT_FALSE(handler_->is_configuring_sync()); 517 ASSERT_FALSE(handler_->is_configuring_sync());
516 } 518 }
517 519
518 #endif // #if !defined(OS_CHROMEOS) 520 #endif // #if !defined(OS_CHROMEOS)
519 521
520 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { 522 TEST_F(SyncSetupHandlerTest, TestSyncEverything) {
521 std::string args = GetConfiguration( 523 std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(),
522 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); 524 std::string(), ENCRYPT_PASSWORDS, true);
523 base::ListValue list_args; 525 base::ListValue list_args;
524 list_args.Append(new base::StringValue(args)); 526 list_args.Append(new base::StringValue(args));
525 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 527 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
526 .WillRepeatedly(Return(false)); 528 .WillRepeatedly(Return(false));
527 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 529 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
528 .WillRepeatedly(Return(false)); 530 .WillRepeatedly(Return(false));
529 SetupInitializedProfileSyncService(); 531 SetupInitializedProfileSyncService();
530 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 532 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
531 handler_->HandleConfigure(&list_args); 533 handler_->HandleConfigure(&list_args);
532 534
533 // Ensure that we navigated to the "done" state since we don't need a 535 // Ensure that we navigated to the "done" state since we don't need a
534 // passphrase. 536 // passphrase.
535 ExpectDone(); 537 ExpectDone();
536 } 538 }
537 539
538 TEST_F(SyncSetupHandlerTest, TestSyncNothing) { 540 TEST_F(SyncSetupHandlerTest, TestSyncNothing) {
539 std::string args = GetConfiguration( 541 std::string args = GetConfiguration(NULL, SYNC_NOTHING, GetAllTypes(),
540 NULL, SYNC_NOTHING, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); 542 std::string(), ENCRYPT_PASSWORDS, true);
541 base::ListValue list_args; 543 base::ListValue list_args;
542 list_args.Append(new base::StringValue(args)); 544 list_args.Append(new base::StringValue(args));
543 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); 545 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA));
544 SetupInitializedProfileSyncService(); 546 SetupInitializedProfileSyncService();
545 handler_->HandleConfigure(&list_args); 547 handler_->HandleConfigure(&list_args);
546 548
547 // We expect a call to SyncSetupOverlay.showSyncSetupPage. 549 // We expect a call to SyncSetupOverlay.showSyncSetupPage.
548 ASSERT_EQ(1U, web_ui_.call_data().size()); 550 ASSERT_EQ(1U, web_ui_.call_data().size());
549 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 551 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
550 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); 552 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name());
551 } 553 }
552 554
553 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { 555 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) {
554 std::string args = GetConfiguration( 556 std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(),
555 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); 557 std::string(), ENCRYPT_ALL_DATA, true);
556 base::ListValue list_args; 558 base::ListValue list_args;
557 list_args.Append(new base::StringValue(args)); 559 list_args.Append(new base::StringValue(args));
558 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 560 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
559 .WillRepeatedly(Return(false)); 561 .WillRepeatedly(Return(false));
560 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 562 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
561 .WillRepeatedly(Return(false)); 563 .WillRepeatedly(Return(false));
562 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 564 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
563 .WillRepeatedly(Return(true)); 565 .WillRepeatedly(Return(true));
564 SetupInitializedProfileSyncService(); 566 SetupInitializedProfileSyncService();
565 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); 567 EXPECT_CALL(*mock_pss_, EnableEncryptEverything());
566 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 568 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
567 handler_->HandleConfigure(&list_args); 569 handler_->HandleConfigure(&list_args);
568 570
569 // Ensure that we navigated to the "done" state since we don't need a 571 // Ensure that we navigated to the "done" state since we don't need a
570 // passphrase. 572 // passphrase.
571 ExpectDone(); 573 ExpectDone();
572 } 574 }
573 575
574 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { 576 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) {
575 std::string args = GetConfiguration( 577 std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(),
576 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); 578 std::string(), ENCRYPT_PASSWORDS, true);
577 base::ListValue list_args; 579 base::ListValue list_args;
578 list_args.Append(new base::StringValue(args)); 580 list_args.Append(new base::StringValue(args));
579 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 581 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
580 .WillRepeatedly(Return(true)); 582 .WillRepeatedly(Return(true));
581 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 583 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
582 .WillRepeatedly(Return(true)); 584 .WillRepeatedly(Return(true));
583 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 585 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
584 .WillRepeatedly(Return(false)); 586 .WillRepeatedly(Return(false));
585 SetupInitializedProfileSyncService(); 587 SetupInitializedProfileSyncService();
586 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 588 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
587 SetDefaultExpectationsForConfigPage(); 589 SetDefaultExpectationsForConfigPage();
588 590
589 // We should navigate back to the configure page since we need a passphrase. 591 // We should navigate back to the configure page since we need a passphrase.
590 handler_->HandleConfigure(&list_args); 592 handler_->HandleConfigure(&list_args);
591 593
592 ExpectConfig(); 594 ExpectConfig();
593 } 595 }
594 596
595 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { 597 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) {
596 base::DictionaryValue dict; 598 base::DictionaryValue dict;
597 dict.SetBoolean("isGooglePassphrase", true); 599 dict.SetBoolean("isGooglePassphrase", true);
598 std::string args = GetConfiguration(&dict, 600 std::string args =
599 SYNC_ALL_DATA, 601 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "gaiaPassphrase",
600 GetAllTypes(), 602 ENCRYPT_PASSWORDS, true);
601 "gaiaPassphrase",
602 ENCRYPT_PASSWORDS);
603 base::ListValue list_args; 603 base::ListValue list_args;
604 list_args.Append(new base::StringValue(args)); 604 list_args.Append(new base::StringValue(args));
605 // Act as if an encryption passphrase is required the first time, then never 605 // Act as if an encryption passphrase is required the first time, then never
606 // again after that. 606 // again after that.
607 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); 607 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true));
608 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 608 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
609 .WillRepeatedly(Return(false)); 609 .WillRepeatedly(Return(false));
610 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 610 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
611 .WillRepeatedly(Return(false)); 611 .WillRepeatedly(Return(false));
612 SetupInitializedProfileSyncService(); 612 SetupInitializedProfileSyncService();
613 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 613 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
614 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). 614 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")).
615 WillOnce(Return(true)); 615 WillOnce(Return(true));
616 616
617 handler_->HandleConfigure(&list_args); 617 handler_->HandleConfigure(&list_args);
618 // We should navigate to "done" page since we finished configuring. 618 // We should navigate to "done" page since we finished configuring.
619 ExpectDone(); 619 ExpectDone();
620 } 620 }
621 621
622 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { 622 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) {
623 base::DictionaryValue dict; 623 base::DictionaryValue dict;
624 dict.SetBoolean("isGooglePassphrase", false); 624 dict.SetBoolean("isGooglePassphrase", false);
625 std::string args = GetConfiguration(&dict, 625 std::string args =
626 SYNC_ALL_DATA, 626 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "custom_passphrase",
627 GetAllTypes(), 627 ENCRYPT_PASSWORDS, true);
628 "custom_passphrase",
629 ENCRYPT_PASSWORDS);
630 base::ListValue list_args; 628 base::ListValue list_args;
631 list_args.Append(new base::StringValue(args)); 629 list_args.Append(new base::StringValue(args));
632 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 630 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
633 .WillRepeatedly(Return(false)); 631 .WillRepeatedly(Return(false));
634 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 632 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
635 .WillRepeatedly(Return(false)); 633 .WillRepeatedly(Return(false));
636 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 634 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
637 .WillRepeatedly(Return(false)); 635 .WillRepeatedly(Return(false));
638 SetupInitializedProfileSyncService(); 636 SetupInitializedProfileSyncService();
639 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 637 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
640 EXPECT_CALL(*mock_pss_, 638 EXPECT_CALL(*mock_pss_,
641 SetEncryptionPassphrase("custom_passphrase", 639 SetEncryptionPassphrase("custom_passphrase",
642 ProfileSyncService::EXPLICIT)); 640 ProfileSyncService::EXPLICIT));
643 641
644 handler_->HandleConfigure(&list_args); 642 handler_->HandleConfigure(&list_args);
645 // We should navigate to "done" page since we finished configuring. 643 // We should navigate to "done" page since we finished configuring.
646 ExpectDone(); 644 ExpectDone();
647 } 645 }
648 646
649 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { 647 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) {
650 base::DictionaryValue dict; 648 base::DictionaryValue dict;
651 dict.SetBoolean("isGooglePassphrase", true); 649 dict.SetBoolean("isGooglePassphrase", true);
652 std::string args = GetConfiguration(&dict, 650 std::string args =
653 SYNC_ALL_DATA, 651 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
654 GetAllTypes(), 652 "invalid_passphrase", ENCRYPT_PASSWORDS, true);
655 "invalid_passphrase",
656 ENCRYPT_PASSWORDS);
657 base::ListValue list_args; 653 base::ListValue list_args;
658 list_args.Append(new base::StringValue(args)); 654 list_args.Append(new base::StringValue(args));
659 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 655 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
660 .WillRepeatedly(Return(true)); 656 .WillRepeatedly(Return(true));
661 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 657 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
662 .WillRepeatedly(Return(true)); 658 .WillRepeatedly(Return(true));
663 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 659 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
664 .WillRepeatedly(Return(false)); 660 .WillRepeatedly(Return(false));
665 SetupInitializedProfileSyncService(); 661 SetupInitializedProfileSyncService();
666 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 662 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
(...skipping 15 matching lines...) Expand all
682 } 678 }
683 679
684 // Walks through each user selectable type, and tries to sync just that single 680 // Walks through each user selectable type, and tries to sync just that single
685 // data type. 681 // data type.
686 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { 682 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) {
687 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); 683 syncer::ModelTypeSet user_selectable_types = GetAllTypes();
688 syncer::ModelTypeSet::Iterator it; 684 syncer::ModelTypeSet::Iterator it;
689 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { 685 for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
690 syncer::ModelTypeSet type_to_set; 686 syncer::ModelTypeSet type_to_set;
691 type_to_set.Put(it.Get()); 687 type_to_set.Put(it.Get());
692 std::string args = GetConfiguration(NULL, 688 std::string args = GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, type_to_set,
693 CHOOSE_WHAT_TO_SYNC, 689 std::string(), ENCRYPT_PASSWORDS, true);
694 type_to_set,
695 std::string(),
696 ENCRYPT_PASSWORDS);
697 base::ListValue list_args; 690 base::ListValue list_args;
698 list_args.Append(new base::StringValue(args)); 691 list_args.Append(new base::StringValue(args));
699 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 692 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
700 .WillRepeatedly(Return(false)); 693 .WillRepeatedly(Return(false));
701 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 694 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
702 .WillRepeatedly(Return(false)); 695 .WillRepeatedly(Return(false));
703 SetupInitializedProfileSyncService(); 696 SetupInitializedProfileSyncService();
704 EXPECT_CALL(*mock_pss_, 697 EXPECT_CALL(*mock_pss_,
705 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); 698 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set)));
706 handler_->HandleConfigure(&list_args); 699 handler_->HandleConfigure(&list_args);
707 700
708 ExpectDone(); 701 ExpectDone();
709 Mock::VerifyAndClearExpectations(mock_pss_); 702 Mock::VerifyAndClearExpectations(mock_pss_);
710 web_ui_.ClearTrackedCalls(); 703 web_ui_.ClearTrackedCalls();
711 } 704 }
712 } 705 }
713 706
714 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) { 707 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) {
715 std::string args = GetConfiguration(NULL, 708 std::string args = GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(),
716 CHOOSE_WHAT_TO_SYNC, 709 std::string(), ENCRYPT_PASSWORDS, true);
717 GetAllTypes(),
718 std::string(),
719 ENCRYPT_PASSWORDS);
720 base::ListValue list_args; 710 base::ListValue list_args;
721 list_args.Append(new base::StringValue(args)); 711 list_args.Append(new base::StringValue(args));
722 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 712 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
723 .WillRepeatedly(Return(false)); 713 .WillRepeatedly(Return(false));
724 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 714 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
725 .WillRepeatedly(Return(false)); 715 .WillRepeatedly(Return(false));
726 SetupInitializedProfileSyncService(); 716 SetupInitializedProfileSyncService();
727 EXPECT_CALL(*mock_pss_, 717 EXPECT_CALL(*mock_pss_,
728 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); 718 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes())));
729 handler_->HandleConfigure(&list_args); 719 handler_->HandleConfigure(&list_args);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 CheckBool(dictionary, "appsRegistered", true); 793 CheckBool(dictionary, "appsRegistered", true);
804 CheckBool(dictionary, "autofillRegistered", true); 794 CheckBool(dictionary, "autofillRegistered", true);
805 CheckBool(dictionary, "bookmarksRegistered", true); 795 CheckBool(dictionary, "bookmarksRegistered", true);
806 CheckBool(dictionary, "extensionsRegistered", true); 796 CheckBool(dictionary, "extensionsRegistered", true);
807 CheckBool(dictionary, "passwordsRegistered", true); 797 CheckBool(dictionary, "passwordsRegistered", true);
808 CheckBool(dictionary, "preferencesRegistered", true); 798 CheckBool(dictionary, "preferencesRegistered", true);
809 CheckBool(dictionary, "wifiCredentialsRegistered", true); 799 CheckBool(dictionary, "wifiCredentialsRegistered", true);
810 CheckBool(dictionary, "tabsRegistered", true); 800 CheckBool(dictionary, "tabsRegistered", true);
811 CheckBool(dictionary, "themesRegistered", true); 801 CheckBool(dictionary, "themesRegistered", true);
812 CheckBool(dictionary, "typedUrlsRegistered", true); 802 CheckBool(dictionary, "typedUrlsRegistered", true);
803 CheckBool(dictionary, "paymentsIntegrationEnabled", true);
813 CheckBool(dictionary, "showPassphrase", false); 804 CheckBool(dictionary, "showPassphrase", false);
814 CheckBool(dictionary, "usePassphrase", false); 805 CheckBool(dictionary, "usePassphrase", false);
815 CheckBool(dictionary, "passphraseFailed", false); 806 CheckBool(dictionary, "passphraseFailed", false);
816 CheckBool(dictionary, "encryptAllData", false); 807 CheckBool(dictionary, "encryptAllData", false);
817 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); 808 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes());
818 } 809 }
819 810
820 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { 811 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) {
821 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 812 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
822 .WillRepeatedly(Return(false)); 813 .WillRepeatedly(Return(false));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 938
948 ExpectConfig(); 939 ExpectConfig();
949 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 940 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
950 const base::DictionaryValue* dictionary = nullptr; 941 const base::DictionaryValue* dictionary = nullptr;
951 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 942 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
952 CheckBool(dictionary, "encryptAllData", false); 943 CheckBool(dictionary, "encryptAllData", false);
953 CheckBool(dictionary, "encryptAllDataAllowed", false); 944 CheckBool(dictionary, "encryptAllDataAllowed", false);
954 } 945 }
955 946
956 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { 947 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) {
957 std::string args = GetConfiguration( 948 std::string args = GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(),
958 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); 949 std::string(), ENCRYPT_ALL_DATA, true);
959 base::ListValue list_args; 950 base::ListValue list_args;
960 list_args.Append(new base::StringValue(args)); 951 list_args.Append(new base::StringValue(args));
961 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 952 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
962 .WillRepeatedly(Return(false)); 953 .WillRepeatedly(Return(false));
963 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 954 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
964 .WillRepeatedly(Return(false)); 955 .WillRepeatedly(Return(false));
965 SetupInitializedProfileSyncService(); 956 SetupInitializedProfileSyncService();
966 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 957 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
967 .WillRepeatedly(Return(false)); 958 .WillRepeatedly(Return(false));
968 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); 959 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
969 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 960 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
970 handler_->HandleConfigure(&list_args); 961 handler_->HandleConfigure(&list_args);
971 962
972 // Ensure that we navigated to the "done" state since we don't need a 963 // Ensure that we navigated to the "done" state since we don't need a
973 // passphrase. 964 // passphrase.
974 ExpectDone(); 965 ExpectDone();
975 } 966 }
976 967
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/sync_setup_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698