Home | History | Annotate | Download | only in bookmarks
      1 // Copyright (c) 2006-2009 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 CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_TEST_UTILS_H_
      6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_TEST_UTILS_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 
     12 class BookmarkModel;
     13 class BookmarkNode;
     14 
     15 // Contains utilities for bookmark model related tests.
     16 class BookmarkModelTestUtils {
     17  public:
     18   // Verifies that the two given bookmark models are the same.
     19   // The IDs of the bookmark nodes are compared only if check_ids is true.
     20   static void AssertModelsEqual(BookmarkModel* expected,
     21                                 BookmarkModel* actual,
     22                                 bool check_ids);
     23 
     24   // Return the descendants of |node| as a string useful for verifying node
     25   // modifications. The format of the resulting string is:
     26   //
     27   //           result = node " " , { node " " }
     28   //             node = bookmark title | folder
     29   //           folder = folder title ":[ " { node " " } "]"
     30   //   bookmark title = (* string with no spaces *)
     31   //     folder title = (* string with no spaces *)
     32   //
     33   // Example: "a f1:[ b d c ] d f2:[ e f g ] h "
     34   //
     35   // (Logically, we should use |string16|s, but it's more convenient for test
     36   // purposes to use (UTF-8) |std::string|s.)
     37   static std::string ModelStringFromNode(const BookmarkNode* node);
     38 
     39   // Create and add the node hierarchy specified by |nodeString| to the
     40   // bookmark node given by |node|. The string has the same format as
     41   // specified for ModelStringFromNode. The new nodes added to |node|
     42   // are appended to the end of node's existing subnodes, if any.
     43   // |model| must be the model of which |node| is a member.
     44   // NOTE: The string format is very rigid and easily broken if not followed
     45   //       exactly (since we're using a very simple parser).
     46   static void AddNodesFromModelString(BookmarkModel* model,
     47                                       const BookmarkNode* node,
     48                                       const std::string& model_string);
     49 
     50  private:
     51   DISALLOW_IMPLICIT_CONSTRUCTORS(BookmarkModelTestUtils);
     52 };
     53 
     54 #endif  // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_TEST_UTILS_H_
     55