This source file includes following definitions.
- DoesTopLevelNodeExist
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/read_node.h"
#include "sync/internal_api/public/read_transaction.h"
namespace {
class EnableDisableSingleClientTest : public SyncTest {
public:
EnableDisableSingleClientTest() : SyncTest(SINGLE_CLIENT_LEGACY) {}
virtual ~EnableDisableSingleClientTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest);
};
bool DoesTopLevelNodeExist(syncer::UserShare* user_share,
syncer::ModelType type) {
syncer::ReadTransaction trans(FROM_HERE, user_share);
syncer::ReadNode node(&trans);
return node.InitByTagLookup(syncer::ModelTypeToRootTag(type)) ==
syncer::BaseNode::INIT_OK;
}
IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) {
ASSERT_TRUE(SetupClients());
ASSERT_TRUE(GetClient(0)->SetupSync(syncer::ModelTypeSet()));
DisableNotifications();
const syncer::ModelTypeSet registered_types =
GetSyncService((0))->GetRegisteredDataTypes();
syncer::UserShare* user_share = GetSyncService((0))->GetUserShare();
for (syncer::ModelTypeSet::Iterator it = registered_types.First();
it.Good(); it.Inc()) {
ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get()));
if (it.Get() == syncer::AUTOFILL_PROFILE || it.Get() == syncer::SESSIONS) {
continue;
}
if (!syncer::ProxyTypes().Has(it.Get())) {
ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get()))
<< syncer::ModelTypeToString(it.Get());
}
if (it.Get() == syncer::AUTOFILL) {
ASSERT_TRUE(DoesTopLevelNodeExist(user_share,
syncer::AUTOFILL_PROFILE));
} else if (it.Get() == syncer::HISTORY_DELETE_DIRECTIVES ||
it.Get() == syncer::PROXY_TABS) {
ASSERT_TRUE(DoesTopLevelNodeExist(user_share,
syncer::SESSIONS));
}
}
EnableNotifications();
}
IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) {
ASSERT_TRUE(SetupClients());
ASSERT_TRUE(GetClient(0)->SetupSync());
DisableNotifications();
const syncer::ModelTypeSet registered_types =
GetSyncService((0))->GetRegisteredDataTypes();
syncer::UserShare* user_share = GetSyncService((0))->GetUserShare();
for (syncer::ModelTypeSet::Iterator it = registered_types.First();
it.Good(); it.Inc()) {
if (!syncer::ProxyTypes().Has(it.Get())) {
ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get()));
}
}
for (syncer::ModelTypeSet::Iterator it = registered_types.First();
it.Good(); it.Inc()) {
if (it.Get() == syncer::MANAGED_USERS ||
it.Get() == syncer::MANAGED_USER_SHARED_SETTINGS ||
it.Get() == syncer::SYNCED_NOTIFICATIONS ||
it.Get() == syncer::SYNCED_NOTIFICATION_APP_INFO)
continue;
ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(it.Get()));
if (it.Get() == syncer::AUTOFILL_PROFILE ||
it.Get() == syncer::SESSIONS ||
it.Get() == syncer::HISTORY_DELETE_DIRECTIVES ||
it.Get() == syncer::PRIORITY_PREFERENCES ||
it.Get() == syncer::FAVICON_IMAGES ||
it.Get() == syncer::FAVICON_TRACKING) {
continue;
}
syncer::UserShare* user_share =
GetSyncService((0))->GetUserShare();
ASSERT_FALSE(DoesTopLevelNodeExist(user_share, it.Get()))
<< syncer::ModelTypeToString(it.Get());
if (it.Get() == syncer::AUTOFILL) {
ASSERT_FALSE(DoesTopLevelNodeExist(user_share, syncer::AUTOFILL_PROFILE));
} else if (it.Get() == syncer::TYPED_URLS) {
ASSERT_FALSE(DoesTopLevelNodeExist(user_share,
syncer::HISTORY_DELETE_DIRECTIVES));
ASSERT_EQ(GetClient(0)->IsTypePreferred(syncer::PROXY_TABS),
DoesTopLevelNodeExist(user_share, syncer::SESSIONS));
} else if (it.Get() == syncer::PROXY_TABS) {
ASSERT_EQ(GetClient(0)->IsTypePreferred(syncer::TYPED_URLS),
DoesTopLevelNodeExist(user_share, syncer::SESSIONS));
} else if (it.Get() == syncer::PREFERENCES) {
ASSERT_FALSE(DoesTopLevelNodeExist(user_share,
syncer::PRIORITY_PREFERENCES));
}
}
EnableNotifications();
}
}