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