• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "chrome/browser/bookmarks/bookmark_model_test_utils.h"
6 
7 #include "chrome/browser/bookmarks/bookmark_model.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 
10 // static
AssertNodesEqual(const BookmarkNode * expected,const BookmarkNode * actual,bool check_ids)11 void BookmarkModelTestUtils::AssertNodesEqual(const BookmarkNode* expected,
12                                               const BookmarkNode* actual,
13                                               bool check_ids) {
14   ASSERT_TRUE(expected);
15   ASSERT_TRUE(actual);
16   if (check_ids)
17     EXPECT_EQ(expected->id(), actual->id());
18   EXPECT_EQ(expected->GetTitle(), actual->GetTitle());
19   EXPECT_EQ(expected->type(), actual->type());
20   EXPECT_TRUE(expected->date_added() == actual->date_added());
21   if (expected->type() == BookmarkNode::URL) {
22     EXPECT_EQ(expected->GetURL(), actual->GetURL());
23   } else {
24     EXPECT_TRUE(expected->date_folder_modified() ==
25                 actual->date_folder_modified());
26     ASSERT_EQ(expected->child_count(), actual->child_count());
27     for (int i = 0; i < expected->child_count(); ++i)
28       AssertNodesEqual(expected->GetChild(i), actual->GetChild(i), check_ids);
29   }
30 }
31 
32 // static
AssertModelsEqual(BookmarkModel * expected,BookmarkModel * actual,bool check_ids)33 void BookmarkModelTestUtils::AssertModelsEqual(BookmarkModel* expected,
34                                                BookmarkModel* actual,
35                                                bool check_ids) {
36   AssertNodesEqual(expected->GetBookmarkBarNode(),
37                    actual->GetBookmarkBarNode(),
38                    check_ids);
39   AssertNodesEqual(expected->other_node(),
40                    actual->other_node(),
41                    check_ids);
42 }
43 
44