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

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

Issue 665223007: Add a flag to ProfileSyncService that says whether encrypting all data is allowed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 1 month 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/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/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/sync_setup_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // Setup the expectations for calls made when displaying the config page. 297 // Setup the expectations for calls made when displaying the config page.
298 void SetDefaultExpectationsForConfigPage() { 298 void SetDefaultExpectationsForConfigPage() {
299 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()). 299 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()).
300 WillRepeatedly(Return(true)); 300 WillRepeatedly(Return(true));
301 EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes()). 301 EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes()).
302 WillRepeatedly(Return(GetAllTypes())); 302 WillRepeatedly(Return(GetAllTypes()));
303 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). 303 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()).
304 WillRepeatedly(Return(GetAllTypes())); 304 WillRepeatedly(Return(GetAllTypes()));
305 EXPECT_CALL(*mock_pss_, GetActiveDataTypes()). 305 EXPECT_CALL(*mock_pss_, GetActiveDataTypes()).
306 WillRepeatedly(Return(GetAllTypes())); 306 WillRepeatedly(Return(GetAllTypes()));
307 EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
308 WillRepeatedly(Return(true));
307 EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()). 309 EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()).
308 WillRepeatedly(Return(false)); 310 WillRepeatedly(Return(false));
309 } 311 }
310 312
311 void SetupInitializedProfileSyncService() { 313 void SetupInitializedProfileSyncService() {
312 // An initialized ProfileSyncService will have already completed sync setup 314 // An initialized ProfileSyncService will have already completed sync setup
313 // and will have an initialized sync backend. 315 // and will have an initialized sync backend.
314 ASSERT_TRUE(mock_signin_->IsInitialized()); 316 ASSERT_TRUE(mock_signin_->IsInitialized());
315 EXPECT_CALL(*mock_pss_, backend_initialized()).WillRepeatedly(Return(true)); 317 EXPECT_CALL(*mock_pss_, backend_initialized()).WillRepeatedly(Return(true));
316 } 318 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 EXPECT_EQ(2U, web_ui_.call_data().size()); 505 EXPECT_EQ(2U, web_ui_.call_data().size());
504 const TestWebUI::CallData& data1 = web_ui_.call_data().back(); 506 const TestWebUI::CallData& data1 = web_ui_.call_data().back();
505 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data1.function_name); 507 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data1.function_name);
506 ASSERT_TRUE(data1.arg1->GetAsString(&page)); 508 ASSERT_TRUE(data1.arg1->GetAsString(&page));
507 EXPECT_EQ(page, "configure"); 509 EXPECT_EQ(page, "configure");
508 base::DictionaryValue* dictionary; 510 base::DictionaryValue* dictionary;
509 ASSERT_TRUE(data1.arg2->GetAsDictionary(&dictionary)); 511 ASSERT_TRUE(data1.arg2->GetAsDictionary(&dictionary));
510 CheckBool(dictionary, "passphraseFailed", false); 512 CheckBool(dictionary, "passphraseFailed", false);
511 CheckBool(dictionary, "showSyncEverythingPage", false); 513 CheckBool(dictionary, "showSyncEverythingPage", false);
512 CheckBool(dictionary, "syncAllDataTypes", true); 514 CheckBool(dictionary, "syncAllDataTypes", true);
515 CheckBool(dictionary, "encryptAllDataAllowed", true);
513 CheckBool(dictionary, "encryptAllData", false); 516 CheckBool(dictionary, "encryptAllData", false);
514 CheckBool(dictionary, "usePassphrase", false); 517 CheckBool(dictionary, "usePassphrase", false);
515 } 518 }
516 519
517 // Verifies the case where the user cancels after the sync backend has 520 // Verifies the case where the user cancels after the sync backend has
518 // initialized (meaning it already transitioned from the spinner to a proper 521 // initialized (meaning it already transitioned from the spinner to a proper
519 // configuration page, tested by 522 // configuration page, tested by
520 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user 523 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user
521 // before the user has continued on. 524 // before the user has continued on.
522 TEST_F(SyncSetupHandlerTest, 525 TEST_F(SyncSetupHandlerTest,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 664
662 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { 665 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) {
663 std::string args = GetConfiguration( 666 std::string args = GetConfiguration(
664 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); 667 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
665 base::ListValue list_args; 668 base::ListValue list_args;
666 list_args.Append(new base::StringValue(args)); 669 list_args.Append(new base::StringValue(args));
667 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) 670 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
668 .WillRepeatedly(Return(false)); 671 .WillRepeatedly(Return(false));
669 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 672 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
670 .WillRepeatedly(Return(false)); 673 .WillRepeatedly(Return(false));
674 EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed())
675 .WillRepeatedly(Return(true));
671 SetupInitializedProfileSyncService(); 676 SetupInitializedProfileSyncService();
672 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); 677 EXPECT_CALL(*mock_pss_, EnableEncryptEverything());
673 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 678 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
674 handler_->HandleConfigure(&list_args); 679 handler_->HandleConfigure(&list_args);
675 680
676 // Ensure that we navigated to the "done" state since we don't need a 681 // Ensure that we navigated to the "done" state since we don't need a
677 // passphrase. 682 // passphrase.
678 ExpectDone(); 683 ExpectDone();
679 } 684 }
680 685
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 1040
1036 // This should display the sync setup dialog (not login). 1041 // This should display the sync setup dialog (not login).
1037 handler_->OpenSyncSetup(); 1042 handler_->OpenSyncSetup();
1038 1043
1039 ExpectConfig(); 1044 ExpectConfig();
1040 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 1045 const TestWebUI::CallData& data = web_ui_.call_data()[0];
1041 base::DictionaryValue* dictionary; 1046 base::DictionaryValue* dictionary;
1042 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); 1047 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
1043 CheckBool(dictionary, "encryptAllData", true); 1048 CheckBool(dictionary, "encryptAllData", true);
1044 } 1049 }
1050
1051 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) {
1052 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
1053 .WillRepeatedly(Return(false));
1054 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
1055 .WillRepeatedly(Return(false));
1056 SetupInitializedProfileSyncService();
1057 SetDefaultExpectationsForConfigPage();
1058 EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
1059 WillRepeatedly(Return(false));
1060
1061 // This should display the sync setup dialog (not login).
1062 handler_->OpenSyncSetup();
1063
1064 ExpectConfig();
1065 const TestWebUI::CallData& data = web_ui_.call_data()[0];
1066 base::DictionaryValue* dictionary;
1067 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
1068 CheckBool(dictionary, "encryptAllData", false);
1069 CheckBool(dictionary, "encryptAllDataAllowed", false);
1070 }
1071
1072 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) {
1073 std::string args = GetConfiguration(
1074 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
1075 base::ListValue list_args;
1076 list_args.Append(new base::StringValue(args));
1077 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
1078 .WillRepeatedly(Return(false));
1079 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
1080 .WillRepeatedly(Return(false));
1081 SetupInitializedProfileSyncService();
1082 EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
1083 WillRepeatedly(Return(false));
1084 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
1085 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
1086 handler_->HandleConfigure(&list_args);
1087
1088 // Ensure that we navigated to the "done" state since we don't need a
1089 // passphrase.
1090 ExpectDone();
1091 }
1092
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698