| Index: chrome/browser/sync/profile_sync_service_factory_unittest.cc | 
| diff --git a/chrome/browser/sync/profile_sync_service_factory_unittest.cc b/chrome/browser/sync/profile_sync_service_factory_unittest.cc | 
| index 963d824d5e672eb7422a62b33365d17b6ecd1a91..4fcc4311169ee17125989056581c10f42683eec6 100644 | 
| --- a/chrome/browser/sync/profile_sync_service_factory_unittest.cc | 
| +++ b/chrome/browser/sync/profile_sync_service_factory_unittest.cc | 
| @@ -5,20 +5,89 @@ | 
| #include "base/command_line.h" | 
| #include "base/memory/scoped_ptr.h" | 
| #include "chrome/browser/sync/profile_sync_service_factory.h" | 
| -#include "chrome/common/chrome_switches.h" | 
| #include "chrome/test/base/testing_profile.h" | 
| +#include "components/browser_sync/browser/profile_sync_service.h" | 
| #include "components/browser_sync/common/browser_sync_switches.h" | 
| +#include "components/sync_driver/data_type_controller.h" | 
| #include "content/public/test/test_browser_thread_bundle.h" | 
| +#include "sync/internal_api/public/base/model_type.h" | 
| #include "testing/gtest/include/gtest/gtest.h" | 
| +#include "ui/app_list/app_list_switches.h" | 
| + | 
| +using sync_driver::DataTypeController; | 
|  | 
| class ProfileSyncServiceFactoryTest : public testing::Test { | 
| protected: | 
| -  ProfileSyncServiceFactoryTest() {} | 
| +  ProfileSyncServiceFactoryTest() : profile_(new TestingProfile()) {} | 
| + | 
| +  // Returns the collection of default datatypes. | 
| +  std::vector<syncer::ModelType> DefaultDatatypes() { | 
| +    std::vector<syncer::ModelType> datatypes; | 
| +    datatypes.push_back(syncer::APPS); | 
| +#if defined(ENABLE_APP_LIST) | 
| +    if (app_list::switches::IsAppListSyncEnabled()) | 
| +      datatypes.push_back(syncer::APP_LIST); | 
| +#endif | 
| +    datatypes.push_back(syncer::APP_SETTINGS); | 
| +    datatypes.push_back(syncer::AUTOFILL); | 
| +    datatypes.push_back(syncer::AUTOFILL_PROFILE); | 
| +    datatypes.push_back(syncer::AUTOFILL_WALLET_DATA); | 
| +    datatypes.push_back(syncer::AUTOFILL_WALLET_METADATA); | 
| +    datatypes.push_back(syncer::BOOKMARKS); | 
| +    datatypes.push_back(syncer::DEVICE_INFO); | 
| +#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_CHROMEOS) | 
| +    datatypes.push_back(syncer::DICTIONARY); | 
| +#endif | 
| +    datatypes.push_back(syncer::EXTENSIONS); | 
| +    datatypes.push_back(syncer::EXTENSION_SETTINGS); | 
| +    datatypes.push_back(syncer::HISTORY_DELETE_DIRECTIVES); | 
| +    datatypes.push_back(syncer::PASSWORDS); | 
| +    datatypes.push_back(syncer::PREFERENCES); | 
| +    datatypes.push_back(syncer::PRIORITY_PREFERENCES); | 
| +    datatypes.push_back(syncer::SEARCH_ENGINES); | 
| +    datatypes.push_back(syncer::SESSIONS); | 
| +    datatypes.push_back(syncer::PROXY_TABS); | 
| +    datatypes.push_back(syncer::THEMES); | 
| +    datatypes.push_back(syncer::TYPED_URLS); | 
| +    datatypes.push_back(syncer::FAVICON_TRACKING); | 
| +    datatypes.push_back(syncer::FAVICON_IMAGES); | 
| +    datatypes.push_back(syncer::SUPERVISED_USERS); | 
| +    datatypes.push_back(syncer::SUPERVISED_USER_SETTINGS); | 
| +    datatypes.push_back(syncer::SUPERVISED_USER_SHARED_SETTINGS); | 
| +    datatypes.push_back(syncer::SUPERVISED_USER_WHITELISTS); | 
| + | 
| +    return datatypes; | 
| +  } | 
| + | 
| +  // Returns the number of default datatypes. | 
| +  size_t DefaultDatatypesCount() { return DefaultDatatypes().size(); } | 
| + | 
| +  // Asserts that all the default datatypes are in |map|, except | 
| +  // for |exception_type|, which unless it is UNDEFINED, is asserted to | 
| +  // not be in |map|. | 
| +  void CheckDefaultDatatypesInMapExcept(DataTypeController::StateMap* map, | 
| +                                        syncer::ModelTypeSet exception_types) { | 
| +    std::vector<syncer::ModelType> defaults = DefaultDatatypes(); | 
| +    std::vector<syncer::ModelType>::iterator iter; | 
| +    for (iter = defaults.begin(); iter != defaults.end(); ++iter) { | 
| +      if (exception_types.Has(*iter)) | 
| +        EXPECT_EQ(0U, map->count(*iter)) | 
| +            << *iter << " found in dataypes map, shouldn't be there."; | 
| +      else | 
| +        EXPECT_EQ(1U, map->count(*iter)) << *iter | 
| +                                         << " not found in datatypes map"; | 
| +    } | 
| +  } | 
|  | 
| -  void SetUp() override { | 
| -    profile_.reset(new TestingProfile()); | 
| +  void SetDisabledTypes(syncer::ModelTypeSet disabled_types) { | 
| +    base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 
| +        switches::kDisableSyncTypes, | 
| +        syncer::ModelTypeSetToString(disabled_types)); | 
| } | 
|  | 
| +  Profile* profile() { return profile_.get(); } | 
| + | 
| + private: | 
| content::TestBrowserThreadBundle thread_bundle_; | 
| scoped_ptr<Profile> profile_; | 
| }; | 
| @@ -26,5 +95,42 @@ class ProfileSyncServiceFactoryTest : public testing::Test { | 
| // Verify that the disable sync flag disables creation of the sync service. | 
| TEST_F(ProfileSyncServiceFactoryTest, DisableSyncFlag) { | 
| base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync); | 
| -  EXPECT_EQ(nullptr, ProfileSyncServiceFactory::GetForProfile(profile_.get())); | 
| +  EXPECT_EQ(nullptr, ProfileSyncServiceFactory::GetForProfile(profile())); | 
| +} | 
| + | 
| +// Verify that a normal (no command line flags) PSS can be created and | 
| +// properly initialized. | 
| +TEST_F(ProfileSyncServiceFactoryTest, CreatePSSDefault) { | 
| +  ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile()); | 
| +  DataTypeController::StateMap controller_states; | 
| +  pss->GetDataTypeControllerStates(&controller_states); | 
| +  EXPECT_EQ(DefaultDatatypesCount(), controller_states.size()); | 
| +  CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet()); | 
| +} | 
| + | 
| +// Verify that a PSS with a disabled datatype can be created and properly | 
| +// initialized. | 
| +TEST_F(ProfileSyncServiceFactoryTest, CreatePSSDisableOne) { | 
| +  syncer::ModelTypeSet disabled_types(syncer::AUTOFILL); | 
| +  SetDisabledTypes(disabled_types); | 
| +  ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile()); | 
| +  DataTypeController::StateMap controller_states; | 
| +  pss->GetDataTypeControllerStates(&controller_states); | 
| +  EXPECT_EQ(DefaultDatatypesCount() - disabled_types.Size(), | 
| +            controller_states.size()); | 
| +  CheckDefaultDatatypesInMapExcept(&controller_states, disabled_types); | 
| +} | 
| + | 
| +// Verify that a PSS with multiple disabled datatypes can be created and | 
| +// properly initialized. | 
| +TEST_F(ProfileSyncServiceFactoryTest, CreatePSSDisableMultiple) { | 
| +  syncer::ModelTypeSet disabled_types(syncer::AUTOFILL_PROFILE, | 
| +                                      syncer::BOOKMARKS); | 
| +  SetDisabledTypes(disabled_types); | 
| +  ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile()); | 
| +  DataTypeController::StateMap controller_states; | 
| +  pss->GetDataTypeControllerStates(&controller_states); | 
| +  EXPECT_EQ(DefaultDatatypesCount() - disabled_types.Size(), | 
| +            controller_states.size()); | 
| +  CheckDefaultDatatypesInMapExcept(&controller_states, disabled_types); | 
| } | 
|  |