OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/internal_api/read_node.h" | 8 #include "chrome/browser/sync/internal_api/read_node.h" |
9 #include "chrome/browser/sync/internal_api/read_transaction.h" | 9 #include "chrome/browser/sync/internal_api/read_transaction.h" |
10 #include "chrome/browser/sync/syncable/model_type.h" | 10 #include "chrome/browser/sync/syncable/model_type.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 bool DoesTopLevelNodeExist(sync_api::UserShare* user_share, | 33 bool DoesTopLevelNodeExist(sync_api::UserShare* user_share, |
34 syncable::ModelType type) { | 34 syncable::ModelType type) { |
35 sync_api::ReadTransaction trans(FROM_HERE, user_share); | 35 sync_api::ReadTransaction trans(FROM_HERE, user_share); |
36 sync_api::ReadNode node(&trans); | 36 sync_api::ReadNode node(&trans); |
37 return node.InitByTagLookup(syncable::ModelTypeToRootTag(type)); | 37 return node.InitByTagLookup(syncable::ModelTypeToRootTag(type)); |
38 } | 38 } |
39 | 39 |
40 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) { | 40 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) { |
41 ASSERT_TRUE(SetupClients()); | 41 ASSERT_TRUE(SetupClients()); |
42 | 42 |
43 DisableNotifications(); | |
44 | |
45 // Setup sync with no enabled types. | 43 // Setup sync with no enabled types. |
46 ASSERT_TRUE(GetClient(0)->SetupSync(syncable::ModelTypeSet())); | 44 ASSERT_TRUE(GetClient(0)->SetupSync(syncable::ModelTypeSet())); |
47 | 45 |
| 46 // TODO(rlarocque, 97780): It should be possible to disable notifications |
| 47 // before calling SetupSync(). We should move this line back to the top |
| 48 // of this function when this is supported. |
| 49 DisableNotifications(); |
| 50 |
48 const syncable::ModelTypeSet registered_types = | 51 const syncable::ModelTypeSet registered_types = |
49 GetClient(0)->service()->GetRegisteredDataTypes(); | 52 GetClient(0)->service()->GetRegisteredDataTypes(); |
50 sync_api::UserShare* user_share = GetClient(0)->service()->GetUserShare(); | 53 sync_api::UserShare* user_share = GetClient(0)->service()->GetUserShare(); |
51 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); | 54 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); |
52 it.Good(); it.Inc()) { | 55 it.Good(); it.Inc()) { |
53 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get())); | 56 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get())); |
54 | 57 |
55 // AUTOFILL_PROFILE is lumped together with AUTOFILL. | 58 // AUTOFILL_PROFILE is lumped together with AUTOFILL. |
56 if (it.Get() == syncable::AUTOFILL_PROFILE) { | 59 if (it.Get() == syncable::AUTOFILL_PROFILE) { |
57 continue; | 60 continue; |
58 } | 61 } |
59 | 62 |
60 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())) | 63 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())) |
61 << syncable::ModelTypeToString(it.Get()); | 64 << syncable::ModelTypeToString(it.Get()); |
62 | 65 |
63 // AUTOFILL_PROFILE is lumped together with AUTOFILL. | 66 // AUTOFILL_PROFILE is lumped together with AUTOFILL. |
64 if (it.Get() == syncable::AUTOFILL) { | 67 if (it.Get() == syncable::AUTOFILL) { |
65 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, | 68 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, |
66 syncable::AUTOFILL_PROFILE)); | 69 syncable::AUTOFILL_PROFILE)); |
67 } | 70 } |
68 } | 71 } |
69 | 72 |
70 EnableNotifications(); | 73 EnableNotifications(); |
71 } | 74 } |
72 | 75 |
73 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) { | 76 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) { |
74 ASSERT_TRUE(SetupClients()); | 77 ASSERT_TRUE(SetupClients()); |
75 | 78 |
76 DisableNotifications(); | |
77 | |
78 // Setup sync with no disabled types. | 79 // Setup sync with no disabled types. |
79 ASSERT_TRUE(GetClient(0)->SetupSync()); | 80 ASSERT_TRUE(GetClient(0)->SetupSync()); |
80 | 81 |
| 82 // TODO(rlarocque, 97780): It should be possible to disable notifications |
| 83 // before calling SetupSync(). We should move this line back to the top |
| 84 // of this function when this is supported. |
| 85 DisableNotifications(); |
| 86 |
81 const syncable::ModelTypeSet registered_types = | 87 const syncable::ModelTypeSet registered_types = |
82 GetClient(0)->service()->GetRegisteredDataTypes(); | 88 GetClient(0)->service()->GetRegisteredDataTypes(); |
83 | 89 |
84 sync_api::UserShare* user_share = GetClient(0)->service()->GetUserShare(); | 90 sync_api::UserShare* user_share = GetClient(0)->service()->GetUserShare(); |
85 | 91 |
86 // Make sure all top-level nodes exist first. | 92 // Make sure all top-level nodes exist first. |
87 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); | 93 for (syncable::ModelTypeSet::Iterator it = registered_types.First(); |
88 it.Good(); it.Inc()) { | 94 it.Good(); it.Inc()) { |
89 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())); | 95 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())); |
90 } | 96 } |
(...skipping 17 matching lines...) Expand all Loading... |
108 if (it.Get() == syncable::AUTOFILL) { | 114 if (it.Get() == syncable::AUTOFILL) { |
109 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, | 115 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, |
110 syncable::AUTOFILL_PROFILE)); | 116 syncable::AUTOFILL_PROFILE)); |
111 } | 117 } |
112 } | 118 } |
113 | 119 |
114 EnableNotifications(); | 120 EnableNotifications(); |
115 } | 121 } |
116 | 122 |
117 } // namespace | 123 } // namespace |
OLD | NEW |