| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test/integration/sync_test.h" | 5 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 8 #include "sync/internal_api/public/read_node.h" | 8 #include "sync/internal_api/public/read_node.h" |
| 9 #include "sync/internal_api/public/read_transaction.h" | 9 #include "sync/internal_api/public/read_transaction.h" |
| 10 #include "sync/internal_api/public/syncable/model_type.h" | 10 #include "sync/internal_api/public/syncable/model_type.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 class EnableDisableSingleClientTest : public EnableDisableTest { | 25 class EnableDisableSingleClientTest : public EnableDisableTest { |
| 26 public: | 26 public: |
| 27 EnableDisableSingleClientTest() : EnableDisableTest(SINGLE_CLIENT) {} | 27 EnableDisableSingleClientTest() : EnableDisableTest(SINGLE_CLIENT) {} |
| 28 virtual ~EnableDisableSingleClientTest() {} | 28 virtual ~EnableDisableSingleClientTest() {} |
| 29 private: | 29 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest); | 30 DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest); |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 bool DoesTopLevelNodeExist(csync::UserShare* user_share, | 33 bool DoesTopLevelNodeExist(syncer::UserShare* user_share, |
| 34 syncable::ModelType type) { | 34 syncable::ModelType type) { |
| 35 csync::ReadTransaction trans(FROM_HERE, user_share); | 35 syncer::ReadTransaction trans(FROM_HERE, user_share); |
| 36 csync::ReadNode node(&trans); | 36 syncer::ReadNode node(&trans); |
| 37 return node.InitByTagLookup(syncable::ModelTypeToRootTag(type)) == | 37 return node.InitByTagLookup(syncable::ModelTypeToRootTag(type)) == |
| 38 csync::BaseNode::INIT_OK; | 38 syncer::BaseNode::INIT_OK; |
| 39 } | 39 } |
| 40 | 40 |
| 41 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) { | 41 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) { |
| 42 ASSERT_TRUE(SetupClients()); | 42 ASSERT_TRUE(SetupClients()); |
| 43 | 43 |
| 44 // Setup sync with no enabled types. | 44 // Setup sync with no enabled types. |
| 45 ASSERT_TRUE(GetClient(0)->SetupSync(syncable::ModelTypeSet())); | 45 ASSERT_TRUE(GetClient(0)->SetupSync(syncable::ModelTypeSet())); |
| 46 | 46 |
| 47 // TODO(rlarocque, 97780): It should be possible to disable notifications | 47 // TODO(rlarocque, 97780): It should be possible to disable notifications |
| 48 // before calling SetupSync(). We should move this line back to the top | 48 // before calling SetupSync(). We should move this line back to the top |
| 49 // of this function when this is supported. | 49 // of this function when this is supported. |
| 50 DisableNotifications(); | 50 DisableNotifications(); |
| 51 | 51 |
| 52 const syncable::ModelTypeSet registered_types = | 52 const syncable::ModelTypeSet registered_types = |
| 53 GetClient(0)->service()->GetRegisteredDataTypes(); | 53 GetClient(0)->service()->GetRegisteredDataTypes(); |
| 54 csync::UserShare* user_share = GetClient(0)->service()->GetUserShare(); | 54 syncer::UserShare* user_share = GetClient(0)->service()->GetUserShare(); |
| 55 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); | 55 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); |
| 56 it.Good(); it.Inc()) { | 56 it.Good(); it.Inc()) { |
| 57 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get())); | 57 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get())); |
| 58 | 58 |
| 59 // AUTOFILL_PROFILE is lumped together with AUTOFILL. | 59 // AUTOFILL_PROFILE is lumped together with AUTOFILL. |
| 60 if (it.Get() == syncable::AUTOFILL_PROFILE) { | 60 if (it.Get() == syncable::AUTOFILL_PROFILE) { |
| 61 continue; | 61 continue; |
| 62 } | 62 } |
| 63 | 63 |
| 64 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())) | 64 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 81 ASSERT_TRUE(GetClient(0)->SetupSync()); | 81 ASSERT_TRUE(GetClient(0)->SetupSync()); |
| 82 | 82 |
| 83 // TODO(rlarocque, 97780): It should be possible to disable notifications | 83 // TODO(rlarocque, 97780): It should be possible to disable notifications |
| 84 // before calling SetupSync(). We should move this line back to the top | 84 // before calling SetupSync(). We should move this line back to the top |
| 85 // of this function when this is supported. | 85 // of this function when this is supported. |
| 86 DisableNotifications(); | 86 DisableNotifications(); |
| 87 | 87 |
| 88 const syncable::ModelTypeSet registered_types = | 88 const syncable::ModelTypeSet registered_types = |
| 89 GetClient(0)->service()->GetRegisteredDataTypes(); | 89 GetClient(0)->service()->GetRegisteredDataTypes(); |
| 90 | 90 |
| 91 csync::UserShare* user_share = GetClient(0)->service()->GetUserShare(); | 91 syncer::UserShare* user_share = GetClient(0)->service()->GetUserShare(); |
| 92 | 92 |
| 93 // Make sure all top-level nodes exist first. | 93 // Make sure all top-level nodes exist first. |
| 94 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); | 94 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); |
| 95 it.Good(); it.Inc()) { | 95 it.Good(); it.Inc()) { |
| 96 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())); | 96 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())); |
| 97 } | 97 } |
| 98 | 98 |
| 99 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); | 99 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); |
| 100 it.Good(); it.Inc()) { | 100 it.Good(); it.Inc()) { |
| 101 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(it.Get())); | 101 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(it.Get())); |
| 102 | 102 |
| 103 // AUTOFILL_PROFILE is lumped together with AUTOFILL. | 103 // AUTOFILL_PROFILE is lumped together with AUTOFILL. |
| 104 if (it.Get() == syncable::AUTOFILL_PROFILE) { | 104 if (it.Get() == syncable::AUTOFILL_PROFILE) { |
| 105 continue; | 105 continue; |
| 106 } | 106 } |
| 107 | 107 |
| 108 csync::UserShare* user_share = | 108 syncer::UserShare* user_share = |
| 109 GetClient(0)->service()->GetUserShare(); | 109 GetClient(0)->service()->GetUserShare(); |
| 110 | 110 |
| 111 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, it.Get())) | 111 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, it.Get())) |
| 112 << syncable::ModelTypeToString(it.Get()); | 112 << syncable::ModelTypeToString(it.Get()); |
| 113 | 113 |
| 114 // AUTOFILL_PROFILE is lumped together with AUTOFILL. | 114 // AUTOFILL_PROFILE is lumped together with AUTOFILL. |
| 115 if (it.Get() == syncable::AUTOFILL) { | 115 if (it.Get() == syncable::AUTOFILL) { |
| 116 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, | 116 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, |
| 117 syncable::AUTOFILL_PROFILE)); | 117 syncable::AUTOFILL_PROFILE)); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 EnableNotifications(); | 121 EnableNotifications(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace | 124 } // namespace |
| OLD | NEW |