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/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 int64 written_metahandle; | 222 int64 written_metahandle; |
223 const Id id = TestIdFactory::FromNumber(99); | 223 const Id id = TestIdFactory::FromNumber(99); |
224 std::string name = "Jeff"; | 224 std::string name = "Jeff"; |
225 { | 225 { |
226 ReadTransaction rtrans(FROM_HERE, &dir); | 226 ReadTransaction rtrans(FROM_HERE, &dir); |
227 Entry e(&rtrans, GET_BY_ID, id); | 227 Entry e(&rtrans, GET_BY_ID, id); |
228 ASSERT_FALSE(e.good()); // Hasn't been written yet. | 228 ASSERT_FALSE(e.good()); // Hasn't been written yet. |
229 | 229 |
230 EXPECT_FALSE(dir.HasChildren(&rtrans, rtrans.root_id())); | 230 EXPECT_FALSE(dir.HasChildren(&rtrans, rtrans.root_id())); |
231 EXPECT_TRUE(dir.GetFirstChildId(&rtrans, rtrans.root_id()).IsRoot()); | 231 Id child_id; |
| 232 EXPECT_TRUE(dir.GetFirstChildId(&rtrans, rtrans.root_id(), &child_id)); |
| 233 EXPECT_TRUE(child_id.IsRoot()); |
232 } | 234 } |
233 | 235 |
234 { | 236 { |
235 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); | 237 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); |
236 MutableEntry me(&wtrans, CREATE, wtrans.root_id(), name); | 238 MutableEntry me(&wtrans, CREATE, wtrans.root_id(), name); |
237 ASSERT_TRUE(me.good()); | 239 ASSERT_TRUE(me.good()); |
238 me.Put(ID, id); | 240 me.Put(ID, id); |
239 me.Put(BASE_VERSION, 1); | 241 me.Put(BASE_VERSION, 1); |
240 written_metahandle = me.Get(META_HANDLE); | 242 written_metahandle = me.Get(META_HANDLE); |
241 } | 243 } |
242 | 244 |
243 // Test children ops after something is now in the DB. | 245 // Test children ops after something is now in the DB. |
244 { | 246 { |
245 ReadTransaction rtrans(FROM_HERE, &dir); | 247 ReadTransaction rtrans(FROM_HERE, &dir); |
246 Entry e(&rtrans, GET_BY_ID, id); | 248 Entry e(&rtrans, GET_BY_ID, id); |
247 ASSERT_TRUE(e.good()); | 249 ASSERT_TRUE(e.good()); |
248 | 250 |
249 Entry child(&rtrans, GET_BY_HANDLE, written_metahandle); | 251 Entry child(&rtrans, GET_BY_HANDLE, written_metahandle); |
250 ASSERT_TRUE(child.good()); | 252 ASSERT_TRUE(child.good()); |
251 | 253 |
252 EXPECT_TRUE(dir.HasChildren(&rtrans, rtrans.root_id())); | 254 EXPECT_TRUE(dir.HasChildren(&rtrans, rtrans.root_id())); |
253 EXPECT_EQ(e.Get(ID), dir.GetFirstChildId(&rtrans, rtrans.root_id())); | 255 Id child_id; |
| 256 EXPECT_TRUE(dir.GetFirstChildId(&rtrans, rtrans.root_id(), &child_id)); |
| 257 EXPECT_EQ(e.Get(ID), child_id); |
254 } | 258 } |
255 | 259 |
256 { | 260 { |
257 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); | 261 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); |
258 MutableEntry me(&wtrans, GET_BY_HANDLE, written_metahandle); | 262 MutableEntry me(&wtrans, GET_BY_HANDLE, written_metahandle); |
259 ASSERT_TRUE(me.good()); | 263 ASSERT_TRUE(me.good()); |
260 me.Put(IS_DEL, true); | 264 me.Put(IS_DEL, true); |
261 } | 265 } |
262 | 266 |
263 // Test children ops after the children have been deleted. | 267 // Test children ops after the children have been deleted. |
264 { | 268 { |
265 ReadTransaction rtrans(FROM_HERE, &dir); | 269 ReadTransaction rtrans(FROM_HERE, &dir); |
266 Entry e(&rtrans, GET_BY_ID, id); | 270 Entry e(&rtrans, GET_BY_ID, id); |
267 ASSERT_TRUE(e.good()); | 271 ASSERT_TRUE(e.good()); |
268 | 272 |
269 EXPECT_FALSE(dir.HasChildren(&rtrans, rtrans.root_id())); | 273 EXPECT_FALSE(dir.HasChildren(&rtrans, rtrans.root_id())); |
270 EXPECT_TRUE(dir.GetFirstChildId(&rtrans, rtrans.root_id()).IsRoot()); | 274 Id child_id; |
| 275 EXPECT_TRUE(dir.GetFirstChildId(&rtrans, rtrans.root_id(), &child_id)); |
| 276 EXPECT_TRUE(child_id.IsRoot()); |
271 } | 277 } |
272 | 278 |
273 dir.SaveChanges(); | 279 dir.SaveChanges(); |
274 } | 280 } |
275 | 281 |
276 TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) { | 282 TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) { |
277 int64 written_metahandle; | 283 int64 written_metahandle; |
278 TestIdFactory factory; | 284 TestIdFactory factory; |
279 const Id id = factory.NewServerId(); | 285 const Id id = factory.NewServerId(); |
280 std::string name = "cheesepuffs"; | 286 std::string name = "cheesepuffs"; |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { | 1887 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { |
1882 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1888 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
1883 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1889 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
1884 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 1890 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
1885 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 1891 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
1886 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 1892 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
1887 } | 1893 } |
1888 | 1894 |
1889 } // namespace | 1895 } // namespace |
1890 } // namespace syncable | 1896 } // namespace syncable |
OLD | NEW |