#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "chrome/browser/signin/profile_oauth2_token_service.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/sync/profile_sync_components_factory_impl.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/sync_driver/data_type_controller.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/app_list/app_list_switches.h"
using browser_sync::DataTypeController;
using content::BrowserThread;
static 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::FAVICON_TRACKING);
datatypes.push_back(syncer::FAVICON_IMAGES);
datatypes.push_back(syncer::SYNCED_NOTIFICATIONS);
+ // TODO(petewil): Enable on stable when the feature is ready.
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
+ if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||
+ channel == chrome::VersionInfo::CHANNEL_DEV ||
+ channel == chrome::VersionInfo::CHANNEL_CANARY) {
+ datatypes.push_back(syncer::SYNCED_NOTIFICATION_APP_INFO);
+ }
datatypes.push_back(syncer::MANAGED_USERS);
datatypes.push_back(syncer::MANAGED_USER_SHARED_SETTINGS);
// not be in |map|.
static void CheckDefaultDatatypesInMapExcept(
DataTypeController::StateMap* map,
- syncer::ModelType exception_type) {
+ 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_type != syncer::UNSPECIFIED && exception_type == *iter)
+ if (exception_types.Has(*iter))
EXPECT_EQ(0U, map->count(*iter))
<< *iter << " found in dataypes map, shouldn't be there.";
else
}
}
- // Asserts that if you apply the command line switch |cmd_switch|,
- // all types are enabled except for |type|, which is disabled.
- void TestSwitchDisablesType(const char* cmd_switch,
- syncer::ModelType type) {
- command_line_->AppendSwitch(cmd_switch);
+ // Asserts that if you disable types via the command line, all other types
+ // are enabled.
+ void TestSwitchDisablesType(syncer::ModelTypeSet types) {
+ command_line_->AppendSwitchASCII(switches::kDisableSyncTypes,
+ syncer::ModelTypeSetToString(types));
scoped_ptr<ProfileSyncService> pss(
new ProfileSyncService(
new ProfileSyncComponentsFactoryImpl(profile_.get(),
profile_.get(),
NULL,
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()),
- ProfileSyncService::MANUAL_START));
+ browser_sync::MANUAL_START));
pss->factory()->RegisterDataTypes(pss.get());
DataTypeController::StateMap controller_states;
pss->GetDataTypeControllerStates(&controller_states);
- EXPECT_EQ(DefaultDatatypesCount() - 1, controller_states.size());
- CheckDefaultDatatypesInMapExcept(&controller_states, type);
+ EXPECT_EQ(DefaultDatatypesCount() - types.Size(), controller_states.size());
+ CheckDefaultDatatypesInMapExcept(&controller_states, types);
}
base::MessageLoop message_loop_;
profile_.get(),
NULL,
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()),
- ProfileSyncService::MANUAL_START));
+ browser_sync::MANUAL_START));
pss->factory()->RegisterDataTypes(pss.get());
DataTypeController::StateMap controller_states;
pss->GetDataTypeControllerStates(&controller_states);
EXPECT_EQ(DefaultDatatypesCount(), controller_states.size());
- CheckDefaultDatatypesInMapExcept(&controller_states, syncer::UNSPECIFIED);
-}
-
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableAutofill) {
- TestSwitchDisablesType(switches::kDisableSyncAutofill,
- syncer::AUTOFILL);
-}
-
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableBookmarks) {
- TestSwitchDisablesType(switches::kDisableSyncBookmarks,
- syncer::BOOKMARKS);
-}
-
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisablePreferences) {
- TestSwitchDisablesType(switches::kDisableSyncPreferences,
- syncer::PREFERENCES);
-}
-
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableThemes) {
- TestSwitchDisablesType(switches::kDisableSyncThemes,
- syncer::THEMES);
-}
-
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableExtensions) {
- TestSwitchDisablesType(switches::kDisableSyncExtensions,
- syncer::EXTENSIONS);
-}
-
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableApps) {
- TestSwitchDisablesType(switches::kDisableSyncApps,
- syncer::APPS);
+ CheckDefaultDatatypesInMapExcept(&controller_states, syncer::ModelTypeSet());
}
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableAutofillProfile) {
- TestSwitchDisablesType(switches::kDisableSyncAutofillProfile,
- syncer::AUTOFILL_PROFILE);
+TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableOne) {
+ TestSwitchDisablesType(syncer::ModelTypeSet(syncer::AUTOFILL));
}
-TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisablePasswords) {
- TestSwitchDisablesType(switches::kDisableSyncPasswords,
- syncer::PASSWORDS);
+TEST_F(ProfileSyncComponentsFactoryImplTest, CreatePSSDisableMultiple) {
+ TestSwitchDisablesType(
+ syncer::ModelTypeSet(syncer::AUTOFILL_PROFILE, syncer::BOOKMARKS));
}