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

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

Issue 195873020: [Sync] Move SyncPrefs into sync_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rerererebase Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | 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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/signin/fake_auth_status_provider.h" 15 #include "chrome/browser/signin/fake_auth_status_provider.h"
16 #include "chrome/browser/signin/fake_signin_manager.h" 16 #include "chrome/browser/signin/fake_signin_manager.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_manager.h" 18 #include "chrome/browser/signin/signin_manager.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 20 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/sync/profile_sync_service_mock.h" 21 #include "chrome/browser/sync/profile_sync_service_mock.h"
22 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 22 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/test/base/scoped_testing_local_state.h" 26 #include "chrome/test/base/scoped_testing_local_state.h"
27 #include "chrome/test/base/testing_browser_process.h" 27 #include "chrome/test/base/testing_browser_process.h"
28 #include "chrome/test/base/testing_profile.h" 28 #include "chrome/test/base/testing_profile.h"
29 #include "components/signin/core/profile_oauth2_token_service.h" 29 #include "components/signin/core/profile_oauth2_token_service.h"
30 #include "components/sync_driver/sync_prefs.h"
30 #include "content/public/browser/web_ui.h" 31 #include "content/public/browser/web_ui.h"
31 #include "content/public/test/test_browser_thread.h" 32 #include "content/public/test/test_browser_thread.h"
32 #include "content/public/test/test_browser_thread_bundle.h" 33 #include "content/public/test/test_browser_thread_bundle.h"
33 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
36 #include "ui/base/layout.h" 37 #include "ui/base/layout.h"
37 38
38 using ::testing::_; 39 using ::testing::_;
39 using ::testing::Mock; 40 using ::testing::Mock;
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 CheckBool(dictionary, "encryptAllData", false); 925 CheckBool(dictionary, "encryptAllData", false);
925 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); 926 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes());
926 } 927 }
927 928
928 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { 929 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) {
929 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 930 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
930 .WillRepeatedly(Return(false)); 931 .WillRepeatedly(Return(false));
931 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 932 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
932 .WillRepeatedly(Return(false)); 933 .WillRepeatedly(Return(false));
933 SetupInitializedProfileSyncService(); 934 SetupInitializedProfileSyncService();
934 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); 935 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
935 sync_prefs.SetKeepEverythingSynced(false); 936 sync_prefs.SetKeepEverythingSynced(false);
936 SetDefaultExpectationsForConfigPage(); 937 SetDefaultExpectationsForConfigPage();
937 // This should display the sync setup dialog (not login). 938 // This should display the sync setup dialog (not login).
938 handler_->OpenSyncSetup(); 939 handler_->OpenSyncSetup();
939 940
940 ExpectConfig(); 941 ExpectConfig();
941 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 942 const TestWebUI::CallData& data = web_ui_.call_data()[0];
942 base::DictionaryValue* dictionary; 943 base::DictionaryValue* dictionary;
943 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); 944 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
944 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); 945 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes());
945 } 946 }
946 947
947 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { 948 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) {
948 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); 949 syncer::ModelTypeSet user_selectable_types = GetAllTypes();
949 syncer::ModelTypeSet::Iterator it; 950 syncer::ModelTypeSet::Iterator it;
950 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { 951 for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
951 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 952 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
952 .WillRepeatedly(Return(false)); 953 .WillRepeatedly(Return(false));
953 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 954 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
954 .WillRepeatedly(Return(false)); 955 .WillRepeatedly(Return(false));
955 SetupInitializedProfileSyncService(); 956 SetupInitializedProfileSyncService();
956 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); 957 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
957 sync_prefs.SetKeepEverythingSynced(false); 958 sync_prefs.SetKeepEverythingSynced(false);
958 SetDefaultExpectationsForConfigPage(); 959 SetDefaultExpectationsForConfigPage();
959 syncer::ModelTypeSet types; 960 syncer::ModelTypeSet types;
960 types.Put(it.Get()); 961 types.Put(it.Get());
961 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). 962 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()).
962 WillRepeatedly(Return(types)); 963 WillRepeatedly(Return(types));
963 964
964 // This should display the sync setup dialog (not login). 965 // This should display the sync setup dialog (not login).
965 handler_->OpenSyncSetup(); 966 handler_->OpenSyncSetup();
966 967
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 1033
1033 // This should display the sync setup dialog (not login). 1034 // This should display the sync setup dialog (not login).
1034 handler_->OpenSyncSetup(); 1035 handler_->OpenSyncSetup();
1035 1036
1036 ExpectConfig(); 1037 ExpectConfig();
1037 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 1038 const TestWebUI::CallData& data = web_ui_.call_data()[0];
1038 base::DictionaryValue* dictionary; 1039 base::DictionaryValue* dictionary;
1039 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); 1040 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
1040 CheckBool(dictionary, "encryptAllData", true); 1041 CheckBool(dictionary, "encryptAllData", true);
1041 } 1042 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698