| OLD | NEW |
| 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 // Utilities to verify the state of items in unit tests. | 5 // Utilities to verify the state of items in unit tests. |
| 6 | 6 |
| 7 #include "sync/test/engine/test_syncable_utils.h" | 7 #include "sync/test/engine/test_syncable_utils.h" |
| 8 | 8 |
| 9 #include "sync/syncable/base_transaction.h" | 9 #include "sync/syncable/base_transaction.h" |
| 10 #include "sync/syncable/directory.h" | 10 #include "sync/syncable/directory.h" |
| 11 #include "sync/syncable/entry.h" | 11 #include "sync/syncable/entry.h" |
| 12 | 12 |
| 13 using std::string; | 13 using std::string; |
| 14 | 14 |
| 15 namespace syncer { |
| 15 namespace syncable { | 16 namespace syncable { |
| 16 | 17 |
| 17 int CountEntriesWithName(BaseTransaction* rtrans, | 18 int CountEntriesWithName(BaseTransaction* rtrans, |
| 18 const syncable::Id& parent_id, | 19 const syncable::Id& parent_id, |
| 19 const string& name) { | 20 const string& name) { |
| 20 Directory::ChildHandles child_handles; | 21 Directory::ChildHandles child_handles; |
| 21 rtrans->directory()->GetChildHandlesById(rtrans, parent_id, &child_handles); | 22 rtrans->directory()->GetChildHandlesById(rtrans, parent_id, &child_handles); |
| 22 if (child_handles.size() <= 0) { | 23 if (child_handles.size() <= 0) { |
| 23 return 0; | 24 return 0; |
| 24 } | 25 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 55 } | 56 } |
| 56 | 57 |
| 57 Id GetOnlyEntryWithName(BaseTransaction* rtrans, | 58 Id GetOnlyEntryWithName(BaseTransaction* rtrans, |
| 58 const syncable::Id& parent_id, | 59 const syncable::Id& parent_id, |
| 59 const string& name) { | 60 const string& name) { |
| 60 CHECK(1 == CountEntriesWithName(rtrans, parent_id, name)); | 61 CHECK(1 == CountEntriesWithName(rtrans, parent_id, name)); |
| 61 return GetFirstEntryWithName(rtrans, parent_id, name); | 62 return GetFirstEntryWithName(rtrans, parent_id, name); |
| 62 } | 63 } |
| 63 | 64 |
| 64 } // namespace syncable | 65 } // namespace syncable |
| 66 } // namespace syncer |
| OLD | NEW |