OLD | NEW |
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.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
19 #include "chrome/browser/signin/signin_manager.h" | 19 #include "chrome/browser/signin/signin_manager.h" |
20 #include "chrome/browser/signin/signin_manager_factory.h" | 20 #include "chrome/browser/signin/signin_manager_factory.h" |
21 #include "chrome/browser/sync/profile_sync_service_factory.h" | 21 #include "chrome/browser/sync/profile_sync_service_factory.h" |
22 #include "chrome/browser/sync/profile_sync_service_mock.h" | 22 #include "chrome/browser/sync/profile_sync_service_mock.h" |
23 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 23 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
24 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 24 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
28 #include "chrome/test/base/testing_browser_process.h" | 28 #include "chrome/test/base/testing_browser_process.h" |
29 #include "chrome/test/base/scoped_testing_local_state.h" | 29 #include "chrome/test/base/scoped_testing_local_state.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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 CheckBool(dictionary, "encryptAllData", false); | 924 CheckBool(dictionary, "encryptAllData", false); |
924 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); | 925 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); |
925 } | 926 } |
926 | 927 |
927 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { | 928 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { |
928 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 929 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
929 .WillRepeatedly(Return(false)); | 930 .WillRepeatedly(Return(false)); |
930 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 931 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
931 .WillRepeatedly(Return(false)); | 932 .WillRepeatedly(Return(false)); |
932 SetupInitializedProfileSyncService(); | 933 SetupInitializedProfileSyncService(); |
933 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); | 934 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
934 sync_prefs.SetKeepEverythingSynced(false); | 935 sync_prefs.SetKeepEverythingSynced(false); |
935 SetDefaultExpectationsForConfigPage(); | 936 SetDefaultExpectationsForConfigPage(); |
936 // This should display the sync setup dialog (not login). | 937 // This should display the sync setup dialog (not login). |
937 handler_->OpenSyncSetup(); | 938 handler_->OpenSyncSetup(); |
938 | 939 |
939 ExpectConfig(); | 940 ExpectConfig(); |
940 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 941 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
941 base::DictionaryValue* dictionary; | 942 base::DictionaryValue* dictionary; |
942 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 943 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
943 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); | 944 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
944 } | 945 } |
945 | 946 |
946 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { | 947 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
947 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 948 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
948 syncer::ModelTypeSet::Iterator it; | 949 syncer::ModelTypeSet::Iterator it; |
949 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 950 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
950 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 951 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
951 .WillRepeatedly(Return(false)); | 952 .WillRepeatedly(Return(false)); |
952 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 953 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
953 .WillRepeatedly(Return(false)); | 954 .WillRepeatedly(Return(false)); |
954 SetupInitializedProfileSyncService(); | 955 SetupInitializedProfileSyncService(); |
955 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); | 956 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
956 sync_prefs.SetKeepEverythingSynced(false); | 957 sync_prefs.SetKeepEverythingSynced(false); |
957 SetDefaultExpectationsForConfigPage(); | 958 SetDefaultExpectationsForConfigPage(); |
958 syncer::ModelTypeSet types; | 959 syncer::ModelTypeSet types; |
959 types.Put(it.Get()); | 960 types.Put(it.Get()); |
960 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). | 961 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
961 WillRepeatedly(Return(types)); | 962 WillRepeatedly(Return(types)); |
962 | 963 |
963 // This should display the sync setup dialog (not login). | 964 // This should display the sync setup dialog (not login). |
964 handler_->OpenSyncSetup(); | 965 handler_->OpenSyncSetup(); |
965 | 966 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 | 1032 |
1032 // This should display the sync setup dialog (not login). | 1033 // This should display the sync setup dialog (not login). |
1033 handler_->OpenSyncSetup(); | 1034 handler_->OpenSyncSetup(); |
1034 | 1035 |
1035 ExpectConfig(); | 1036 ExpectConfig(); |
1036 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1037 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1037 base::DictionaryValue* dictionary; | 1038 base::DictionaryValue* dictionary; |
1038 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1039 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1039 CheckBool(dictionary, "encryptAllData", true); | 1040 CheckBool(dictionary, "encryptAllData", true); |
1040 } | 1041 } |
OLD | NEW |