Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: chrome/browser/sync/test/integration/enable_disable_test.cc

Issue 2568543004: [Sync] Enable USS DeviceInfo for bots. (Closed)
Patch Set: Actually rebasing this time. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/sync/tools/testserver/chromiumsync.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/macros.h" 5 #include "base/macros.h"
6 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 6 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
7 #include "chrome/browser/sync/test/integration/sync_test.h" 7 #include "chrome/browser/sync/test/integration/sync_test.h"
8 #include "components/browser_sync/profile_sync_service.h" 8 #include "components/browser_sync/profile_sync_service.h"
9 #include "components/sync/base/model_type.h" 9 #include "components/sync/base/model_type.h"
10 #include "components/sync/driver/sync_driver_switches.h"
10 #include "components/sync/syncable/read_node.h" 11 #include "components/sync/syncable/read_node.h"
11 #include "components/sync/syncable/read_transaction.h" 12 #include "components/sync/syncable/read_transaction.h"
12 13
13 // This file contains tests that exercise enabling and disabling data 14 // This file contains tests that exercise enabling and disabling data
14 // types. 15 // types.
15 16
16 namespace { 17 namespace {
17 18
19 using base::FeatureList;
20 using syncer::ModelTypeSet;
21
18 class EnableDisableSingleClientTest : public SyncTest { 22 class EnableDisableSingleClientTest : public SyncTest {
19 public: 23 public:
20 EnableDisableSingleClientTest() : SyncTest(SINGLE_CLIENT) {} 24 EnableDisableSingleClientTest() : SyncTest(SINGLE_CLIENT) {}
21 ~EnableDisableSingleClientTest() override {} 25 ~EnableDisableSingleClientTest() override {}
22 26
23 // Don't use self-notifications as they can trigger additional sync cycles. 27 // Don't use self-notifications as they can trigger additional sync cycles.
24 bool TestUsesSelfNotifications() override { return false; } 28 bool TestUsesSelfNotifications() override { return false; }
25 29
26 private: 30 private:
27 DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest); 31 DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest);
28 }; 32 };
29 33
30 bool DoesTopLevelNodeExist(syncer::UserShare* user_share, 34 bool DoesTopLevelNodeExist(syncer::UserShare* user_share,
31 syncer::ModelType type) { 35 syncer::ModelType type) {
32 syncer::ReadTransaction trans(FROM_HERE, user_share); 36 syncer::ReadTransaction trans(FROM_HERE, user_share);
33 syncer::ReadNode node(&trans); 37 syncer::ReadNode node(&trans);
34 return node.InitTypeRoot(type) == syncer::BaseNode::INIT_OK; 38 return node.InitTypeRoot(type) == syncer::BaseNode::INIT_OK;
35 } 39 }
36 40
37 bool IsUnready(const syncer::DataTypeStatusTable& data_type_status_table, 41 bool IsUnready(const syncer::DataTypeStatusTable& data_type_status_table,
38 syncer::ModelType type) { 42 syncer::ModelType type) {
39 return data_type_status_table.GetUnreadyErrorTypes().Has(type); 43 return data_type_status_table.GetUnreadyErrorTypes().Has(type);
40 } 44 }
41 45
46 // The current approach this test class takes is to examine the Directory and
47 // check for root nodes to see if a type is currently enabled. While this works
48 // for things in the directory, it does not work for USS types. USS does not
49 // have any general data access mechanism, at least yet. Until that exists,
50 // simply omit types that may be USS from these cases.
51 ModelTypeSet UnifiedSyncServiceTypes() {
52 ModelTypeSet set;
53 if (FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) {
54 set.Put(syncer::DEVICE_INFO);
55 }
56 return set;
57 }
58
42 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) { 59 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) {
43 ASSERT_TRUE(SetupClients()); 60 ASSERT_TRUE(SetupClients());
44 61
45 // Setup sync with no enabled types. 62 // Setup sync with no enabled types.
46 ASSERT_TRUE(GetClient(0)->SetupSync(syncer::ModelTypeSet())); 63 ASSERT_TRUE(GetClient(0)->SetupSync(ModelTypeSet()));
47 64
48 syncer::UserShare* user_share = GetSyncService(0)->GetUserShare(); 65 syncer::UserShare* user_share = GetSyncService(0)->GetUserShare();
49 const syncer::DataTypeStatusTable& data_type_status_table = 66 const syncer::DataTypeStatusTable& data_type_status_table =
50 GetSyncService(0)->data_type_status_table(); 67 GetSyncService(0)->data_type_status_table();
51 68
52 const syncer::ModelTypeSet registered_types = 69 const ModelTypeSet registered_types =
53 GetSyncService(0)->GetRegisteredDataTypes(); 70 GetSyncService(0)->GetRegisteredDataTypes();
54 const syncer::ModelTypeSet registered_user_types = 71 const ModelTypeSet registered_directory_types =
72 Difference(registered_types, UnifiedSyncServiceTypes());
73 const ModelTypeSet registered_directory_user_types =
55 Intersection(registered_types, syncer::UserSelectableTypes()); 74 Intersection(registered_types, syncer::UserSelectableTypes());
56 for (syncer::ModelTypeSet::Iterator it = registered_user_types.First(); 75 for (ModelTypeSet::Iterator it = registered_directory_user_types.First();
57 it.Good(); it.Inc()) { 76 it.Good(); it.Inc()) {
58 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get())); 77 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get()));
59 78
60 // AUTOFILL_PROFILE is lumped together with AUTOFILL. 79 // AUTOFILL_PROFILE is lumped together with AUTOFILL.
61 // SESSIONS is lumped together with PROXY_TABS and 80 // SESSIONS is lumped together with PROXY_TABS and
62 // HISTORY_DELETE_DIRECTIVES. 81 // HISTORY_DELETE_DIRECTIVES.
63 // Favicons are lumped together with PROXY_TABS and 82 // Favicons are lumped together with PROXY_TABS and
64 // HISTORY_DELETE_DIRECTIVES. 83 // HISTORY_DELETE_DIRECTIVES.
65 if (it.Get() == syncer::AUTOFILL_PROFILE || it.Get() == syncer::SESSIONS) { 84 if (it.Get() == syncer::AUTOFILL_PROFILE || it.Get() == syncer::SESSIONS) {
66 continue; 85 continue;
(...skipping 16 matching lines...) Expand all
83 } 102 }
84 } 103 }
85 } 104 }
86 105
87 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) { 106 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) {
88 ASSERT_TRUE(SetupClients()); 107 ASSERT_TRUE(SetupClients());
89 108
90 // Setup sync with no disabled types. 109 // Setup sync with no disabled types.
91 ASSERT_TRUE(GetClient(0)->SetupSync()); 110 ASSERT_TRUE(GetClient(0)->SetupSync());
92 111
93 const syncer::ModelTypeSet registered_types = 112 const ModelTypeSet registered_types =
94 GetSyncService(0)->GetRegisteredDataTypes(); 113 GetSyncService(0)->GetRegisteredDataTypes();
114 const ModelTypeSet registered_directory_types =
115 Difference(registered_types, UnifiedSyncServiceTypes());
95 116
96 syncer::UserShare* user_share = GetSyncService(0)->GetUserShare(); 117 syncer::UserShare* user_share = GetSyncService(0)->GetUserShare();
97 118
98 const syncer::DataTypeStatusTable& data_type_status_table = 119 const syncer::DataTypeStatusTable& data_type_status_table =
99 GetSyncService(0)->data_type_status_table(); 120 GetSyncService(0)->data_type_status_table();
100 121
101 // Make sure all top-level nodes exist first. 122 // Make sure all top-level nodes exist first.
102 for (syncer::ModelTypeSet::Iterator it = registered_types.First(); 123 for (ModelTypeSet::Iterator it = registered_directory_types.First();
103 it.Good(); it.Inc()) { 124 it.Good(); it.Inc()) {
104 if (!syncer::ProxyTypes().Has(it.Get())) { 125 if (!syncer::ProxyTypes().Has(it.Get())) {
105 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get()) || 126 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get()) ||
106 IsUnready(data_type_status_table, it.Get())); 127 IsUnready(data_type_status_table, it.Get()));
107 } 128 }
108 } 129 }
109 130
110 for (syncer::ModelTypeSet::Iterator it = registered_types.First(); 131 for (ModelTypeSet::Iterator it = registered_directory_types.First();
111 it.Good(); it.Inc()) { 132 it.Good(); it.Inc()) {
112 // SUPERVISED_USERS and SUPERVISED_USER_SHARED_SETTINGS are always synced. 133 // SUPERVISED_USERS and SUPERVISED_USER_SHARED_SETTINGS are always synced.
113 if (it.Get() == syncer::SUPERVISED_USERS || 134 if (it.Get() == syncer::SUPERVISED_USERS ||
114 it.Get() == syncer::SUPERVISED_USER_SHARED_SETTINGS || 135 it.Get() == syncer::SUPERVISED_USER_SHARED_SETTINGS ||
115 it.Get() == syncer::SYNCED_NOTIFICATIONS || 136 it.Get() == syncer::SYNCED_NOTIFICATIONS ||
116 it.Get() == syncer::SYNCED_NOTIFICATION_APP_INFO) 137 it.Get() == syncer::SYNCED_NOTIFICATION_APP_INFO)
117 continue; 138 continue;
118 139
119 // Device info cannot be disabled. 140 // Device info cannot be disabled.
120 if (it.Get() == syncer::DEVICE_INFO) 141 if (it.Get() == syncer::DEVICE_INFO)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ASSERT_EQ(GetClient(0)->IsTypePreferred(syncer::TYPED_URLS), 178 ASSERT_EQ(GetClient(0)->IsTypePreferred(syncer::TYPED_URLS),
158 DoesTopLevelNodeExist(user_share, syncer::SESSIONS)); 179 DoesTopLevelNodeExist(user_share, syncer::SESSIONS));
159 } else if (it.Get() == syncer::PREFERENCES) { 180 } else if (it.Get() == syncer::PREFERENCES) {
160 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, 181 ASSERT_FALSE(DoesTopLevelNodeExist(user_share,
161 syncer::PRIORITY_PREFERENCES)); 182 syncer::PRIORITY_PREFERENCES));
162 } 183 }
163 } 184 }
164 } 185 }
165 186
166 } // namespace 187 } // namespace
OLDNEW
« no previous file with comments | « no previous file | components/sync/tools/testserver/chromiumsync.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698