OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/sync/profile_sync_service_factory.h" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 | 8 |
| 9 #include <memory> |
| 10 |
7 #include "base/command_line.h" | 11 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "build/build_config.h" | 12 #include "build/build_config.h" |
10 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
11 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
12 #include "components/browser_sync/browser/profile_sync_service.h" | 14 #include "components/browser_sync/browser/profile_sync_service.h" |
13 #include "components/browser_sync/common/browser_sync_switches.h" | 15 #include "components/browser_sync/common/browser_sync_switches.h" |
14 #include "components/sync_driver/data_type_controller.h" | 16 #include "components/sync_driver/data_type_controller.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "sync/internal_api/public/base/model_type.h" | 18 #include "sync/internal_api/public/base/model_type.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "ui/app_list/app_list_switches.h" | 20 #include "ui/app_list/app_list_switches.h" |
19 | 21 |
20 using sync_driver::DataTypeController; | 22 using sync_driver::DataTypeController; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void SetDisabledTypes(syncer::ModelTypeSet disabled_types) { | 93 void SetDisabledTypes(syncer::ModelTypeSet disabled_types) { |
92 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 94 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
93 switches::kDisableSyncTypes, | 95 switches::kDisableSyncTypes, |
94 syncer::ModelTypeSetToString(disabled_types)); | 96 syncer::ModelTypeSetToString(disabled_types)); |
95 } | 97 } |
96 | 98 |
97 Profile* profile() { return profile_.get(); } | 99 Profile* profile() { return profile_.get(); } |
98 | 100 |
99 private: | 101 private: |
100 content::TestBrowserThreadBundle thread_bundle_; | 102 content::TestBrowserThreadBundle thread_bundle_; |
101 scoped_ptr<Profile> profile_; | 103 std::unique_ptr<Profile> profile_; |
102 }; | 104 }; |
103 | 105 |
104 // Verify that the disable sync flag disables creation of the sync service. | 106 // Verify that the disable sync flag disables creation of the sync service. |
105 TEST_F(ProfileSyncServiceFactoryTest, DisableSyncFlag) { | 107 TEST_F(ProfileSyncServiceFactoryTest, DisableSyncFlag) { |
106 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync); | 108 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync); |
107 EXPECT_EQ(nullptr, ProfileSyncServiceFactory::GetForProfile(profile())); | 109 EXPECT_EQ(nullptr, ProfileSyncServiceFactory::GetForProfile(profile())); |
108 } | 110 } |
109 | 111 |
110 // Verify that a normal (no command line flags) PSS can be created and | 112 // Verify that a normal (no command line flags) PSS can be created and |
111 // properly initialized. | 113 // properly initialized. |
(...skipping 24 matching lines...) Expand all Loading... |
136 syncer::ModelTypeSet disabled_types(syncer::AUTOFILL_PROFILE, | 138 syncer::ModelTypeSet disabled_types(syncer::AUTOFILL_PROFILE, |
137 syncer::BOOKMARKS); | 139 syncer::BOOKMARKS); |
138 SetDisabledTypes(disabled_types); | 140 SetDisabledTypes(disabled_types); |
139 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile()); | 141 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile()); |
140 DataTypeController::StateMap controller_states; | 142 DataTypeController::StateMap controller_states; |
141 pss->GetDataTypeControllerStates(&controller_states); | 143 pss->GetDataTypeControllerStates(&controller_states); |
142 EXPECT_EQ(DefaultDatatypesCount() - disabled_types.Size(), | 144 EXPECT_EQ(DefaultDatatypesCount() - disabled_types.Size(), |
143 controller_states.size()); | 145 controller_states.size()); |
144 CheckDefaultDatatypesInMapExcept(&controller_states, disabled_types); | 146 CheckDefaultDatatypesInMapExcept(&controller_states, disabled_types); |
145 } | 147 } |
OLD | NEW |