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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/sync_setup_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
index aeaeb5a76740481572623337e87aec833b45387a..ffede4b8fdd2098ded34388d48243335e677e7f3 100644
--- a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
@@ -304,6 +304,8 @@ class SyncSetupHandlerTest : public testing::Test {
WillRepeatedly(Return(GetAllTypes()));
EXPECT_CALL(*mock_pss_, GetActiveDataTypes()).
WillRepeatedly(Return(GetAllTypes()));
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
+ WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()).
WillRepeatedly(Return(false));
}
@@ -510,6 +512,7 @@ TEST_F(SyncSetupHandlerTest,
CheckBool(dictionary, "passphraseFailed", false);
CheckBool(dictionary, "showSyncEverythingPage", false);
CheckBool(dictionary, "syncAllDataTypes", true);
+ CheckBool(dictionary, "encryptAllDataAllowed", true);
CheckBool(dictionary, "encryptAllData", false);
CheckBool(dictionary, "usePassphrase", false);
}
@@ -668,6 +671,8 @@ TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) {
.WillRepeatedly(Return(false));
EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
.WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed())
+ .WillRepeatedly(Return(true));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_, EnableEncryptEverything());
EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
@@ -1042,3 +1047,46 @@ TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) {
ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
CheckBool(dictionary, "encryptAllData", true);
}
+
+TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) {
+ EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillRepeatedly(Return(false));
+ SetupInitializedProfileSyncService();
+ SetDefaultExpectationsForConfigPage();
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
+ WillRepeatedly(Return(false));
+
+ // This should display the sync setup dialog (not login).
+ handler_->OpenSyncSetup();
+
+ ExpectConfig();
+ const TestWebUI::CallData& data = web_ui_.call_data()[0];
+ base::DictionaryValue* dictionary;
+ ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
+ CheckBool(dictionary, "encryptAllData", false);
+ CheckBool(dictionary, "encryptAllDataAllowed", false);
+}
+
+TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) {
+ std::string args = GetConfiguration(
+ NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
+ base::ListValue list_args;
+ list_args.Append(new base::StringValue(args));
+ EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
+ .WillRepeatedly(Return(false));
+ SetupInitializedProfileSyncService();
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
+ WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
+ EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
+ handler_->HandleConfigure(&list_args);
+
+ // Ensure that we navigated to the "done" state since we don't need a
+ // passphrase.
+ ExpectDone();
+}
+
« 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