Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / bookmarks / test / bookmark_test_helpers.h
1 // Copyright 2014 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 #ifndef COMPONENTS_BOOKMARKS_TEST_BOOKMARK_TEST_HELPERS_H_
6 #define COMPONENTS_BOOKMARKS_TEST_BOOKMARK_TEST_HELPERS_H_
7
8 #include <string>
9
10 class BookmarkModel;
11 class BookmarkNode;
12
13 namespace bookmarks {
14 namespace test {
15
16 // Blocks until |model| finishes loading.
17 void WaitForBookmarkModelToLoad(BookmarkModel* model);
18
19 // Return the descendants of |node| as a string useful for verifying node
20 // modifications. The format of the resulting string is:
21 //
22 //           result = node " " , { node " " }
23 //             node = bookmark title | folder
24 //           folder = folder title ":[ " { node " " } "]"
25 //   bookmark title = (* string with no spaces *)
26 //     folder title = (* string with no spaces *)
27 //
28 // Example: "a f1:[ b d c ] d f2:[ e f g ] h "
29 //
30 // (Logically, we should use |string16|s, but it's more convenient for test
31 // purposes to use (UTF-8) |std::string|s.)
32 std::string ModelStringFromNode(const BookmarkNode* node);
33
34 // Create and add the node hierarchy specified by |model_string| to the
35 // bookmark node given by |node|. The string has the same format as
36 // specified for ModelStringFromNode(). The new nodes added to |node|
37 // are appended to the end of node's existing subnodes, if any.
38 // |model| must be the model of which |node| is a member.
39 // NOTE: The string format is very rigid and easily broken if not followed
40 //       exactly (since we're using a very simple parser).
41 void AddNodesFromModelString(BookmarkModel* model,
42                              const BookmarkNode* node,
43                              const std::string& model_string);
44
45 }  // namespace test
46 }  // namespace bookmarks
47
48 #endif  // COMPONENTS_BOOKMARKS_TEST_BOOKMARK_TEST_HELPERS_H_