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

Side by Side Diff: chrome/browser/sync/test/engine/test_syncable_utils.cc

Issue 9699057: [Sync] Move 'sync' target to sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Utilities to verify the state of items in unit tests.
6
7 #include "chrome/browser/sync/test/engine/test_syncable_utils.h"
8
9 #include "chrome/browser/sync/syncable/syncable.h"
10
11 using std::string;
12
13 namespace syncable {
14
15 int CountEntriesWithName(BaseTransaction* rtrans,
16 const syncable::Id& parent_id,
17 const string& name) {
18 Directory::ChildHandles child_handles;
19 rtrans->directory()->GetChildHandlesById(rtrans, parent_id, &child_handles);
20 if (child_handles.size() <= 0) {
21 return 0;
22 }
23
24 int number_of_entries_with_name = 0;
25 for (Directory::ChildHandles::iterator i = child_handles.begin();
26 i != child_handles.end(); ++i) {
27 Entry e(rtrans, GET_BY_HANDLE, *i);
28 CHECK(e.good());
29 if (e.Get(NON_UNIQUE_NAME) == name) {
30 ++number_of_entries_with_name;
31 }
32 }
33 return number_of_entries_with_name;
34 }
35
36 Id GetFirstEntryWithName(BaseTransaction* rtrans,
37 const syncable::Id& parent_id,
38 const string& name) {
39 Directory::ChildHandles child_handles;
40 rtrans->directory()->GetChildHandlesById(rtrans, parent_id, &child_handles);
41
42 for (Directory::ChildHandles::iterator i = child_handles.begin();
43 i != child_handles.end(); ++i) {
44 Entry e(rtrans, GET_BY_HANDLE, *i);
45 CHECK(e.good());
46 if (e.Get(NON_UNIQUE_NAME) == name) {
47 return e.Get(ID);
48 }
49 }
50
51 CHECK(false);
52 return Id();
53 }
54
55 Id GetOnlyEntryWithName(BaseTransaction* rtrans,
56 const syncable::Id& parent_id,
57 const string& name) {
58 CHECK(1 == CountEntriesWithName(rtrans, parent_id, name));
59 return GetFirstEntryWithName(rtrans, parent_id, name);
60 }
61
62 } // namespace syncable
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/engine/test_syncable_utils.h ('k') | chrome/browser/sync/test/engine/test_user_share.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698