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

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

Issue 312623003: Convert Sync enable/disable test to use FakeServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months 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 | no next file » | 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 "chrome/browser/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.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 "sync/internal_api/public/base/model_type.h" 8 #include "sync/internal_api/public/base/model_type.h"
9 #include "sync/internal_api/public/read_node.h" 9 #include "sync/internal_api/public/read_node.h"
10 #include "sync/internal_api/public/read_transaction.h" 10 #include "sync/internal_api/public/read_transaction.h"
11 11
12 // This file contains tests that exercise enabling and disabling data 12 // This file contains tests that exercise enabling and disabling data
13 // types. 13 // types.
14 14
15 namespace { 15 namespace {
16 16
17 class EnableDisableSingleClientTest : public SyncTest { 17 class EnableDisableSingleClientTest : public SyncTest {
18 public: 18 public:
19 // TODO(pvalenzuela): Switch to SINGLE_CLIENT once FakeServer 19 EnableDisableSingleClientTest() : SyncTest(SINGLE_CLIENT) {}
20 // supports this scenario.
21 EnableDisableSingleClientTest() : SyncTest(SINGLE_CLIENT_LEGACY) {}
22 virtual ~EnableDisableSingleClientTest() {} 20 virtual ~EnableDisableSingleClientTest() {}
21
22 // Don't use self-notifications as they can trigger additional sync cycles.
23 virtual bool TestUsesSelfNotifications() OVERRIDE { return false; }
23 private: 24 private:
24 DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest); 25 DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest);
25 }; 26 };
26 27
27 bool DoesTopLevelNodeExist(syncer::UserShare* user_share, 28 bool DoesTopLevelNodeExist(syncer::UserShare* user_share,
28 syncer::ModelType type) { 29 syncer::ModelType type) {
29 syncer::ReadTransaction trans(FROM_HERE, user_share); 30 syncer::ReadTransaction trans(FROM_HERE, user_share);
30 syncer::ReadNode node(&trans); 31 syncer::ReadNode node(&trans);
31 return node.InitByTagLookup(syncer::ModelTypeToRootTag(type)) == 32 return node.InitByTagLookup(syncer::ModelTypeToRootTag(type)) ==
32 syncer::BaseNode::INIT_OK; 33 syncer::BaseNode::INIT_OK;
33 } 34 }
34 35
35 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) { 36 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) {
36 ASSERT_TRUE(SetupClients()); 37 ASSERT_TRUE(SetupClients());
37 38
38 // Setup sync with no enabled types. 39 // Setup sync with no enabled types.
39 ASSERT_TRUE(GetClient(0)->SetupSync(syncer::ModelTypeSet())); 40 ASSERT_TRUE(GetClient(0)->SetupSync(syncer::ModelTypeSet()));
40 41
41 // TODO(rlarocque, 97780): It should be possible to disable notifications
42 // before calling SetupSync(). We should move this line back to the top
43 // of this function when this is supported.
44 DisableNotifications();
45
46 const syncer::ModelTypeSet registered_types = 42 const syncer::ModelTypeSet registered_types =
47 GetSyncService((0))->GetRegisteredDataTypes(); 43 GetSyncService((0))->GetRegisteredDataTypes();
48 syncer::UserShare* user_share = GetSyncService((0))->GetUserShare(); 44 syncer::UserShare* user_share = GetSyncService((0))->GetUserShare();
49 for (syncer::ModelTypeSet::Iterator it = registered_types.First(); 45 for (syncer::ModelTypeSet::Iterator it = registered_types.First();
50 it.Good(); it.Inc()) { 46 it.Good(); it.Inc()) {
51 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get())); 47 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(it.Get()));
52 48
53 // AUTOFILL_PROFILE is lumped together with AUTOFILL. 49 // AUTOFILL_PROFILE is lumped together with AUTOFILL.
54 // SESSIONS is lumped together with PROXY_TABS and 50 // SESSIONS is lumped together with PROXY_TABS and
55 // HISTORY_DELETE_DIRECTIVES. 51 // HISTORY_DELETE_DIRECTIVES.
(...skipping 11 matching lines...) Expand all
67 // AUTOFILL_PROFILE is lumped together with AUTOFILL. 63 // AUTOFILL_PROFILE is lumped together with AUTOFILL.
68 if (it.Get() == syncer::AUTOFILL) { 64 if (it.Get() == syncer::AUTOFILL) {
69 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, 65 ASSERT_TRUE(DoesTopLevelNodeExist(user_share,
70 syncer::AUTOFILL_PROFILE)); 66 syncer::AUTOFILL_PROFILE));
71 } else if (it.Get() == syncer::HISTORY_DELETE_DIRECTIVES || 67 } else if (it.Get() == syncer::HISTORY_DELETE_DIRECTIVES ||
72 it.Get() == syncer::PROXY_TABS) { 68 it.Get() == syncer::PROXY_TABS) {
73 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, 69 ASSERT_TRUE(DoesTopLevelNodeExist(user_share,
74 syncer::SESSIONS)); 70 syncer::SESSIONS));
75 } 71 }
76 } 72 }
77
78 EnableNotifications();
79 } 73 }
80 74
81 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) { 75 IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) {
82 ASSERT_TRUE(SetupClients()); 76 ASSERT_TRUE(SetupClients());
83 77
84 // Setup sync with no disabled types. 78 // Setup sync with no disabled types.
85 ASSERT_TRUE(GetClient(0)->SetupSync()); 79 ASSERT_TRUE(GetClient(0)->SetupSync());
86 80
87 // TODO(rlarocque, 97780): It should be possible to disable notifications
88 // before calling SetupSync(). We should move this line back to the top
89 // of this function when this is supported.
90 DisableNotifications();
91
92 const syncer::ModelTypeSet registered_types = 81 const syncer::ModelTypeSet registered_types =
93 GetSyncService((0))->GetRegisteredDataTypes(); 82 GetSyncService((0))->GetRegisteredDataTypes();
94 83
95 syncer::UserShare* user_share = GetSyncService((0))->GetUserShare(); 84 syncer::UserShare* user_share = GetSyncService((0))->GetUserShare();
96 85
97 // Make sure all top-level nodes exist first. 86 // Make sure all top-level nodes exist first.
98 for (syncer::ModelTypeSet::Iterator it = registered_types.First(); 87 for (syncer::ModelTypeSet::Iterator it = registered_types.First();
99 it.Good(); it.Inc()) { 88 it.Good(); it.Inc()) {
100 if (!syncer::ProxyTypes().Has(it.Get())) { 89 if (!syncer::ProxyTypes().Has(it.Get())) {
101 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get())); 90 ASSERT_TRUE(DoesTopLevelNodeExist(user_share, it.Get()));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 DoesTopLevelNodeExist(user_share, syncer::SESSIONS)); 134 DoesTopLevelNodeExist(user_share, syncer::SESSIONS));
146 } else if (it.Get() == syncer::PROXY_TABS) { 135 } else if (it.Get() == syncer::PROXY_TABS) {
147 // SESSIONS should be enabled only if TYPED_URLS is. 136 // SESSIONS should be enabled only if TYPED_URLS is.
148 ASSERT_EQ(GetClient(0)->IsTypePreferred(syncer::TYPED_URLS), 137 ASSERT_EQ(GetClient(0)->IsTypePreferred(syncer::TYPED_URLS),
149 DoesTopLevelNodeExist(user_share, syncer::SESSIONS)); 138 DoesTopLevelNodeExist(user_share, syncer::SESSIONS));
150 } else if (it.Get() == syncer::PREFERENCES) { 139 } else if (it.Get() == syncer::PREFERENCES) {
151 ASSERT_FALSE(DoesTopLevelNodeExist(user_share, 140 ASSERT_FALSE(DoesTopLevelNodeExist(user_share,
152 syncer::PRIORITY_PREFERENCES)); 141 syncer::PRIORITY_PREFERENCES));
153 } 142 }
154 } 143 }
155
156 EnableNotifications();
157 } 144 }
158 145
159 } // namespace 146 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698