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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 WriteTransaction trans(FROM_HERE, UNITTEST, &dir); | 200 WriteTransaction trans(FROM_HERE, UNITTEST, &dir); |
201 MutableEntry e(&trans, GET_BY_HANDLE, written_metahandle); | 201 MutableEntry e(&trans, GET_BY_HANDLE, written_metahandle); |
202 e.Put(IS_DEL, true); | 202 e.Put(IS_DEL, true); |
203 | 203 |
204 EXPECT_EQ(0, CountEntriesWithName(&trans, trans.root_id(), name)); | 204 EXPECT_EQ(0, CountEntriesWithName(&trans, trans.root_id(), name)); |
205 } | 205 } |
206 | 206 |
207 dir.SaveChanges(); | 207 dir.SaveChanges(); |
208 } | 208 } |
209 | 209 |
210 TEST_F(SyncableGeneralTest, ChildrenOps) { | |
211 Directory dir; | |
212 dir.Open(db_path_, "SimpleTest", &delegate_); | |
213 | |
214 int64 root_metahandle; | |
215 { | |
216 ReadTransaction rtrans(FROM_HERE, &dir); | |
217 Entry e(&rtrans, GET_BY_ID, rtrans.root_id()); | |
218 ASSERT_TRUE(e.good()); | |
219 root_metahandle = e.Get(META_HANDLE); | |
220 } | |
221 | |
222 int64 written_metahandle; | |
223 const Id id = TestIdFactory::FromNumber(99); | |
224 std::string name = "Jeff"; | |
225 { | |
226 ReadTransaction rtrans(FROM_HERE, &dir); | |
227 Entry e(&rtrans, GET_BY_ID, id); | |
228 ASSERT_FALSE(e.good()); // Hasn't been written yet. | |
229 | |
230 EXPECT_FALSE(dir.HasChildren(&rtrans, rtrans.root_id())); | |
231 EXPECT_TRUE(dir.GetFirstChildId(&rtrans, rtrans.root_id()).IsRoot()); | |
232 } | |
233 | |
234 { | |
235 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); | |
236 MutableEntry me(&wtrans, CREATE, wtrans.root_id(), name); | |
237 ASSERT_TRUE(me.good()); | |
238 me.Put(ID, id); | |
239 me.Put(BASE_VERSION, 1); | |
240 written_metahandle = me.Get(META_HANDLE); | |
241 } | |
242 | |
243 // Test children ops after something is now in the DB. | |
244 { | |
245 ReadTransaction rtrans(FROM_HERE, &dir); | |
246 Entry e(&rtrans, GET_BY_ID, id); | |
247 ASSERT_TRUE(e.good()); | |
248 | |
249 Entry child(&rtrans, GET_BY_HANDLE, written_metahandle); | |
250 ASSERT_TRUE(child.good()); | |
251 | |
252 EXPECT_TRUE(dir.HasChildren(&rtrans, rtrans.root_id())); | |
253 EXPECT_EQ(e.Get(ID), dir.GetFirstChildId(&rtrans, rtrans.root_id())); | |
254 } | |
Nicolas Zea
2011/10/26 22:21:35
may as well add another case with id 97 has PREV_I
akalin
2011/10/27 00:19:21
Done.
| |
255 | |
256 dir.SaveChanges(); | |
257 } | |
258 | |
210 TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) { | 259 TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) { |
211 int64 written_metahandle; | 260 int64 written_metahandle; |
212 TestIdFactory factory; | 261 TestIdFactory factory; |
213 const Id id = factory.NewServerId(); | 262 const Id id = factory.NewServerId(); |
214 std::string name = "cheesepuffs"; | 263 std::string name = "cheesepuffs"; |
215 std::string tag = "dietcoke"; | 264 std::string tag = "dietcoke"; |
216 | 265 |
217 // Test creating a new meta entry. | 266 // Test creating a new meta entry. |
218 { | 267 { |
219 Directory dir; | 268 Directory dir; |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1815 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { | 1864 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { |
1816 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1865 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
1817 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1866 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
1818 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 1867 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
1819 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 1868 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
1820 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 1869 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
1821 } | 1870 } |
1822 | 1871 |
1823 } // namespace | 1872 } // namespace |
1824 } // namespace syncable | 1873 } // namespace syncable |
OLD | NEW |