OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "chrome/browser/sync/glue/data_type_controller.h" | 11 #include "chrome/browser/sync/glue/data_type_controller.h" |
12 #include "chrome/browser/sync/profile_sync_factory_impl.h" | 12 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
13 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "content/test/test_browser_thread.h" | 16 #include "content/test/test_browser_thread.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 using browser_sync::DataTypeController; | 19 using browser_sync::DataTypeController; |
20 using content::BrowserThread; | 20 using content::BrowserThread; |
21 | 21 |
22 class ProfileSyncFactoryImplTest : public testing::Test { | 22 class ProfileSyncComponentsFactoryImplTest : public testing::Test { |
23 protected: | 23 protected: |
24 ProfileSyncFactoryImplTest() | 24 ProfileSyncComponentsFactoryImplTest() |
25 : ui_thread_(BrowserThread::UI, &message_loop_) {} | 25 : ui_thread_(BrowserThread::UI, &message_loop_) {} |
26 | 26 |
27 virtual void SetUp() { | 27 virtual void SetUp() { |
28 profile_.reset(new TestingProfile()); | 28 profile_.reset(new TestingProfile()); |
29 FilePath program_path(FILE_PATH_LITERAL("chrome.exe")); | 29 FilePath program_path(FILE_PATH_LITERAL("chrome.exe")); |
30 command_line_.reset(new CommandLine(program_path)); | 30 command_line_.reset(new CommandLine(program_path)); |
31 profile_sync_service_factory_.reset( | 31 profile_sync_service_factory_.reset( |
32 new ProfileSyncFactoryImpl(profile_.get(), command_line_.get())); | 32 new ProfileSyncComponentsFactoryImpl(profile_.get(), |
| 33 command_line_.get())); |
33 } | 34 } |
34 | 35 |
35 // Returns the collection of default datatypes. | 36 // Returns the collection of default datatypes. |
36 static std::vector<syncable::ModelType> DefaultDatatypes() { | 37 static std::vector<syncable::ModelType> DefaultDatatypes() { |
37 std::vector<syncable::ModelType> datatypes; | 38 std::vector<syncable::ModelType> datatypes; |
38 datatypes.push_back(syncable::BOOKMARKS); | 39 datatypes.push_back(syncable::BOOKMARKS); |
39 datatypes.push_back(syncable::PREFERENCES); | 40 datatypes.push_back(syncable::PREFERENCES); |
40 datatypes.push_back(syncable::AUTOFILL); | 41 datatypes.push_back(syncable::AUTOFILL); |
41 datatypes.push_back(syncable::THEMES); | 42 datatypes.push_back(syncable::THEMES); |
42 datatypes.push_back(syncable::EXTENSIONS); | 43 datatypes.push_back(syncable::EXTENSIONS); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 DataTypeController::StateMap controller_states; | 84 DataTypeController::StateMap controller_states; |
84 pss->GetDataTypeControllerStates(&controller_states); | 85 pss->GetDataTypeControllerStates(&controller_states); |
85 EXPECT_EQ(DefaultDatatypesCount() - 1, controller_states.size()); | 86 EXPECT_EQ(DefaultDatatypesCount() - 1, controller_states.size()); |
86 CheckDefaultDatatypesInMapExcept(&controller_states, type); | 87 CheckDefaultDatatypesInMapExcept(&controller_states, type); |
87 } | 88 } |
88 | 89 |
89 MessageLoop message_loop_; | 90 MessageLoop message_loop_; |
90 content::TestBrowserThread ui_thread_; | 91 content::TestBrowserThread ui_thread_; |
91 scoped_ptr<Profile> profile_; | 92 scoped_ptr<Profile> profile_; |
92 scoped_ptr<CommandLine> command_line_; | 93 scoped_ptr<CommandLine> command_line_; |
93 scoped_ptr<ProfileSyncFactoryImpl> profile_sync_service_factory_; | 94 scoped_ptr<ProfileSyncComponentsFactoryImpl> profile_sync_service_factory_; |
94 }; | 95 }; |
95 | 96 |
96 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDefault) { | 97 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDefault) { |
97 scoped_ptr<ProfileSyncService> pss( | 98 scoped_ptr<ProfileSyncService> pss( |
98 profile_sync_service_factory_->CreateProfileSyncService("")); | 99 profile_sync_service_factory_->CreateProfileSyncService("")); |
99 profile_sync_service_factory_->RegisterDataTypes(pss.get()); | 100 profile_sync_service_factory_->RegisterDataTypes(pss.get()); |
100 DataTypeController::StateMap controller_states; | 101 DataTypeController::StateMap controller_states; |
101 pss->GetDataTypeControllerStates(&controller_states); | 102 pss->GetDataTypeControllerStates(&controller_states); |
102 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size()); | 103 EXPECT_EQ(DefaultDatatypesCount(), controller_states.size()); |
103 CheckDefaultDatatypesInMapExcept(&controller_states, syncable::UNSPECIFIED); | 104 CheckDefaultDatatypesInMapExcept(&controller_states, syncable::UNSPECIFIED); |
104 } | 105 } |
105 | 106 |
106 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisableAutofill) { | 107 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableAutofill) { |
107 TestSwitchDisablesType(switches::kDisableSyncAutofill, | 108 TestSwitchDisablesType(switches::kDisableSyncAutofill, |
108 syncable::AUTOFILL); | 109 syncable::AUTOFILL); |
109 } | 110 } |
110 | 111 |
111 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisableBookmarks) { | 112 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableBookmarks) { |
112 TestSwitchDisablesType(switches::kDisableSyncBookmarks, | 113 TestSwitchDisablesType(switches::kDisableSyncBookmarks, |
113 syncable::BOOKMARKS); | 114 syncable::BOOKMARKS); |
114 } | 115 } |
115 | 116 |
116 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisablePreferences) { | 117 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisablePreferences) { |
117 TestSwitchDisablesType(switches::kDisableSyncPreferences, | 118 TestSwitchDisablesType(switches::kDisableSyncPreferences, |
118 syncable::PREFERENCES); | 119 syncable::PREFERENCES); |
119 } | 120 } |
120 | 121 |
121 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisableThemes) { | 122 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableThemes) { |
122 TestSwitchDisablesType(switches::kDisableSyncThemes, | 123 TestSwitchDisablesType(switches::kDisableSyncThemes, |
123 syncable::THEMES); | 124 syncable::THEMES); |
124 } | 125 } |
125 | 126 |
126 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisableExtensions) { | 127 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableExtensions) { |
127 TestSwitchDisablesType(switches::kDisableSyncExtensions, | 128 TestSwitchDisablesType(switches::kDisableSyncExtensions, |
128 syncable::EXTENSIONS); | 129 syncable::EXTENSIONS); |
129 } | 130 } |
130 | 131 |
131 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisableApps) { | 132 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableApps) { |
132 TestSwitchDisablesType(switches::kDisableSyncApps, | 133 TestSwitchDisablesType(switches::kDisableSyncApps, |
133 syncable::APPS); | 134 syncable::APPS); |
134 } | 135 } |
135 | 136 |
136 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisableAutofillProfile) { | 137 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableAutofillProfile) { |
137 TestSwitchDisablesType(switches::kDisableSyncAutofillProfile, | 138 TestSwitchDisablesType(switches::kDisableSyncAutofillProfile, |
138 syncable::AUTOFILL_PROFILE); | 139 syncable::AUTOFILL_PROFILE); |
139 } | 140 } |
140 | 141 |
141 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDisablePasswords) { | 142 TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisablePasswords) { |
142 TestSwitchDisablesType(switches::kDisableSyncPasswords, | 143 TestSwitchDisablesType(switches::kDisableSyncPasswords, |
143 syncable::PASSWORDS); | 144 syncable::PASSWORDS); |
144 } | 145 } |
OLD | NEW |