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