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

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

Issue 2030013003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 ASSERT_FALSE(handler_->is_configuring_sync()); 511 ASSERT_FALSE(handler_->is_configuring_sync());
512 } 512 }
513 513
514 #endif // #if !defined(OS_CHROMEOS) 514 #endif // #if !defined(OS_CHROMEOS)
515 515
516 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { 516 TEST_F(SyncSetupHandlerTest, TestSyncEverything) {
517 std::string args = 517 std::string args =
518 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), 518 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(),
519 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); 519 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED);
520 base::ListValue list_args; 520 base::ListValue list_args;
521 list_args.Append(new base::StringValue(args)); 521 list_args.AppendString(args);
522 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 522 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
523 .WillRepeatedly(Return(false)); 523 .WillRepeatedly(Return(false));
524 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 524 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
525 .WillRepeatedly(Return(false)); 525 .WillRepeatedly(Return(false));
526 SetupInitializedProfileSyncService(); 526 SetupInitializedProfileSyncService();
527 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 527 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
528 handler_->HandleConfigure(&list_args); 528 handler_->HandleConfigure(&list_args);
529 529
530 // Ensure that we navigated to the "done" state since we don't need a 530 // Ensure that we navigated to the "done" state since we don't need a
531 // passphrase. 531 // passphrase.
532 ExpectDone(); 532 ExpectDone();
533 } 533 }
534 534
535 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { 535 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) {
536 std::string args = 536 std::string args =
537 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), 537 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(),
538 ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED); 538 ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED);
539 base::ListValue list_args; 539 base::ListValue list_args;
540 list_args.Append(new base::StringValue(args)); 540 list_args.AppendString(args);
541 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 541 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
542 .WillRepeatedly(Return(false)); 542 .WillRepeatedly(Return(false));
543 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 543 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
544 .WillRepeatedly(Return(false)); 544 .WillRepeatedly(Return(false));
545 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 545 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
546 .WillRepeatedly(Return(true)); 546 .WillRepeatedly(Return(true));
547 SetupInitializedProfileSyncService(); 547 SetupInitializedProfileSyncService();
548 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); 548 EXPECT_CALL(*mock_pss_, EnableEncryptEverything());
549 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 549 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
550 handler_->HandleConfigure(&list_args); 550 handler_->HandleConfigure(&list_args);
551 551
552 // Ensure that we navigated to the "done" state since we don't need a 552 // Ensure that we navigated to the "done" state since we don't need a
553 // passphrase. 553 // passphrase.
554 ExpectDone(); 554 ExpectDone();
555 } 555 }
556 556
557 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { 557 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) {
558 std::string args = 558 std::string args =
559 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), 559 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(),
560 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); 560 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED);
561 base::ListValue list_args; 561 base::ListValue list_args;
562 list_args.Append(new base::StringValue(args)); 562 list_args.AppendString(args);
563 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 563 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
564 .WillRepeatedly(Return(true)); 564 .WillRepeatedly(Return(true));
565 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 565 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
566 .WillRepeatedly(Return(true)); 566 .WillRepeatedly(Return(true));
567 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 567 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
568 .WillRepeatedly(Return(false)); 568 .WillRepeatedly(Return(false));
569 SetupInitializedProfileSyncService(); 569 SetupInitializedProfileSyncService();
570 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 570 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
571 SetDefaultExpectationsForConfigPage(); 571 SetDefaultExpectationsForConfigPage();
572 572
573 // We should navigate back to the configure page since we need a passphrase. 573 // We should navigate back to the configure page since we need a passphrase.
574 handler_->HandleConfigure(&list_args); 574 handler_->HandleConfigure(&list_args);
575 575
576 ExpectConfig(); 576 ExpectConfig();
577 } 577 }
578 578
579 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { 579 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) {
580 base::DictionaryValue dict; 580 base::DictionaryValue dict;
581 dict.SetBoolean("isGooglePassphrase", true); 581 dict.SetBoolean("isGooglePassphrase", true);
582 std::string args = 582 std::string args =
583 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "gaiaPassphrase", 583 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "gaiaPassphrase",
584 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); 584 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED);
585 base::ListValue list_args; 585 base::ListValue list_args;
586 list_args.Append(new base::StringValue(args)); 586 list_args.AppendString(args);
587 // Act as if an encryption passphrase is required the first time, then never 587 // Act as if an encryption passphrase is required the first time, then never
588 // again after that. 588 // again after that.
589 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); 589 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true));
590 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 590 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
591 .WillRepeatedly(Return(false)); 591 .WillRepeatedly(Return(false));
592 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 592 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
593 .WillRepeatedly(Return(false)); 593 .WillRepeatedly(Return(false));
594 SetupInitializedProfileSyncService(); 594 SetupInitializedProfileSyncService();
595 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 595 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
596 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). 596 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")).
597 WillOnce(Return(true)); 597 WillOnce(Return(true));
598 598
599 handler_->HandleConfigure(&list_args); 599 handler_->HandleConfigure(&list_args);
600 // We should navigate to "done" page since we finished configuring. 600 // We should navigate to "done" page since we finished configuring.
601 ExpectDone(); 601 ExpectDone();
602 } 602 }
603 603
604 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { 604 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) {
605 base::DictionaryValue dict; 605 base::DictionaryValue dict;
606 dict.SetBoolean("isGooglePassphrase", false); 606 dict.SetBoolean("isGooglePassphrase", false);
607 std::string args = 607 std::string args =
608 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "custom_passphrase", 608 GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), "custom_passphrase",
609 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); 609 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED);
610 base::ListValue list_args; 610 base::ListValue list_args;
611 list_args.Append(new base::StringValue(args)); 611 list_args.AppendString(args);
612 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 612 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
613 .WillRepeatedly(Return(false)); 613 .WillRepeatedly(Return(false));
614 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 614 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
615 .WillRepeatedly(Return(false)); 615 .WillRepeatedly(Return(false));
616 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 616 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
617 .WillRepeatedly(Return(false)); 617 .WillRepeatedly(Return(false));
618 SetupInitializedProfileSyncService(); 618 SetupInitializedProfileSyncService();
619 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 619 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
620 EXPECT_CALL(*mock_pss_, 620 EXPECT_CALL(*mock_pss_,
621 SetEncryptionPassphrase("custom_passphrase", 621 SetEncryptionPassphrase("custom_passphrase",
622 ProfileSyncService::EXPLICIT)); 622 ProfileSyncService::EXPLICIT));
623 623
624 handler_->HandleConfigure(&list_args); 624 handler_->HandleConfigure(&list_args);
625 // We should navigate to "done" page since we finished configuring. 625 // We should navigate to "done" page since we finished configuring.
626 ExpectDone(); 626 ExpectDone();
627 } 627 }
628 628
629 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { 629 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) {
630 base::DictionaryValue dict; 630 base::DictionaryValue dict;
631 dict.SetBoolean("isGooglePassphrase", true); 631 dict.SetBoolean("isGooglePassphrase", true);
632 std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), 632 std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
633 "invalid_passphrase", ENCRYPT_PASSWORDS, 633 "invalid_passphrase", ENCRYPT_PASSWORDS,
634 PAYMENTS_INTEGRATION_ENABLED); 634 PAYMENTS_INTEGRATION_ENABLED);
635 base::ListValue list_args; 635 base::ListValue list_args;
636 list_args.Append(new base::StringValue(args)); 636 list_args.AppendString(args);
637 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 637 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
638 .WillRepeatedly(Return(true)); 638 .WillRepeatedly(Return(true));
639 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 639 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
640 .WillRepeatedly(Return(true)); 640 .WillRepeatedly(Return(true));
641 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 641 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
642 .WillRepeatedly(Return(false)); 642 .WillRepeatedly(Return(false));
643 SetupInitializedProfileSyncService(); 643 SetupInitializedProfileSyncService();
644 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); 644 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
645 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("invalid_passphrase")). 645 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("invalid_passphrase")).
646 WillOnce(Return(false)); 646 WillOnce(Return(false));
(...skipping 17 matching lines...) Expand all
664 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { 664 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) {
665 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); 665 syncer::ModelTypeSet user_selectable_types = GetAllTypes();
666 syncer::ModelTypeSet::Iterator it; 666 syncer::ModelTypeSet::Iterator it;
667 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { 667 for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
668 syncer::ModelTypeSet type_to_set; 668 syncer::ModelTypeSet type_to_set;
669 type_to_set.Put(it.Get()); 669 type_to_set.Put(it.Get());
670 std::string args = 670 std::string args =
671 GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, type_to_set, std::string(), 671 GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, type_to_set, std::string(),
672 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); 672 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED);
673 base::ListValue list_args; 673 base::ListValue list_args;
674 list_args.Append(new base::StringValue(args)); 674 list_args.AppendString(args);
675 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 675 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
676 .WillRepeatedly(Return(false)); 676 .WillRepeatedly(Return(false));
677 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 677 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
678 .WillRepeatedly(Return(false)); 678 .WillRepeatedly(Return(false));
679 SetupInitializedProfileSyncService(); 679 SetupInitializedProfileSyncService();
680 EXPECT_CALL(*mock_pss_, 680 EXPECT_CALL(*mock_pss_,
681 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); 681 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set)));
682 handler_->HandleConfigure(&list_args); 682 handler_->HandleConfigure(&list_args);
683 683
684 ExpectDone(); 684 ExpectDone();
685 Mock::VerifyAndClearExpectations(mock_pss_); 685 Mock::VerifyAndClearExpectations(mock_pss_);
686 web_ui_.ClearTrackedCalls(); 686 web_ui_.ClearTrackedCalls();
687 } 687 }
688 } 688 }
689 689
690 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) { 690 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) {
691 std::string args = 691 std::string args =
692 GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(), std::string(), 692 GetConfiguration(NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(), std::string(),
693 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED); 693 ENCRYPT_PASSWORDS, PAYMENTS_INTEGRATION_ENABLED);
694 base::ListValue list_args; 694 base::ListValue list_args;
695 list_args.Append(new base::StringValue(args)); 695 list_args.AppendString(args);
696 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 696 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
697 .WillRepeatedly(Return(false)); 697 .WillRepeatedly(Return(false));
698 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 698 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
699 .WillRepeatedly(Return(false)); 699 .WillRepeatedly(Return(false));
700 SetupInitializedProfileSyncService(); 700 SetupInitializedProfileSyncService();
701 EXPECT_CALL(*mock_pss_, 701 EXPECT_CALL(*mock_pss_,
702 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); 702 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes())));
703 handler_->HandleConfigure(&list_args); 703 handler_->HandleConfigure(&list_args);
704 704
705 ExpectDone(); 705 ExpectDone();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 925 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
926 CheckBool(dictionary, "encryptAllData", false); 926 CheckBool(dictionary, "encryptAllData", false);
927 CheckBool(dictionary, "encryptAllDataAllowed", false); 927 CheckBool(dictionary, "encryptAllDataAllowed", false);
928 } 928 }
929 929
930 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { 930 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) {
931 std::string args = 931 std::string args =
932 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), 932 GetConfiguration(NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(),
933 ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED); 933 ENCRYPT_ALL_DATA, PAYMENTS_INTEGRATION_ENABLED);
934 base::ListValue list_args; 934 base::ListValue list_args;
935 list_args.Append(new base::StringValue(args)); 935 list_args.AppendString(args);
936 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 936 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
937 .WillRepeatedly(Return(false)); 937 .WillRepeatedly(Return(false));
938 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 938 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
939 .WillRepeatedly(Return(false)); 939 .WillRepeatedly(Return(false));
940 SetupInitializedProfileSyncService(); 940 SetupInitializedProfileSyncService();
941 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) 941 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
942 .WillRepeatedly(Return(false)); 942 .WillRepeatedly(Return(false));
943 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); 943 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
944 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 944 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
945 handler_->HandleConfigure(&list_args); 945 handler_->HandleConfigure(&list_args);
946 946
947 // Ensure that we navigated to the "done" state since we don't need a 947 // Ensure that we navigated to the "done" state since we don't need a
948 // passphrase. 948 // passphrase.
949 ExpectDone(); 949 ExpectDone();
950 } 950 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/supervised_user_import_handler.cc ('k') | chrome/browser/ui/webui/policy_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698