OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" | 5 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
10 #include "content/public/test/test_browser_thread.h" | 11 #include "content/public/test/test_browser_thread.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 using content::BrowserThread; | 14 using content::BrowserThread; |
14 | 15 |
15 class BookmarkExpandedStateTrackerTest : public testing::Test { | 16 class BookmarkExpandedStateTrackerTest : public testing::Test { |
16 public: | 17 public: |
17 BookmarkExpandedStateTrackerTest(); | 18 BookmarkExpandedStateTrackerTest(); |
18 | 19 |
(...skipping 17 matching lines...) Expand all Loading... |
36 file_thread_(BrowserThread::FILE, &message_loop_) { | 37 file_thread_(BrowserThread::FILE, &message_loop_) { |
37 } | 38 } |
38 | 39 |
39 void BookmarkExpandedStateTrackerTest::SetUp() { | 40 void BookmarkExpandedStateTrackerTest::SetUp() { |
40 profile_.reset(new TestingProfile); | 41 profile_.reset(new TestingProfile); |
41 profile_->CreateBookmarkModel(true); | 42 profile_->CreateBookmarkModel(true); |
42 profile_->BlockUntilBookmarkModelLoaded(); | 43 profile_->BlockUntilBookmarkModelLoaded(); |
43 } | 44 } |
44 | 45 |
45 BookmarkModel* BookmarkExpandedStateTrackerTest::GetModel() { | 46 BookmarkModel* BookmarkExpandedStateTrackerTest::GetModel() { |
46 return profile_->GetBookmarkModel(); | 47 return BookmarkModelFactory::GetForProfile(profile_.get()); |
47 } | 48 } |
48 | 49 |
49 void BookmarkExpandedStateTrackerTest::TearDown() { | 50 void BookmarkExpandedStateTrackerTest::TearDown() { |
50 profile_.reset(NULL); | 51 profile_.reset(NULL); |
51 } | 52 } |
52 | 53 |
53 // Various assertions for SetExpandedNodes. | 54 // Various assertions for SetExpandedNodes. |
54 TEST_F(BookmarkExpandedStateTrackerTest, SetExpandedNodes) { | 55 TEST_F(BookmarkExpandedStateTrackerTest, SetExpandedNodes) { |
55 BookmarkModel* model = GetModel(); | 56 BookmarkModel* model = GetModel(); |
56 BookmarkExpandedStateTracker* tracker = model->expanded_state_tracker(); | 57 BookmarkExpandedStateTracker* tracker = model->expanded_state_tracker(); |
(...skipping 12 matching lines...) Expand all Loading... |
69 nodes.insert(n1); | 70 nodes.insert(n1); |
70 tracker->SetExpandedNodes(nodes); | 71 tracker->SetExpandedNodes(nodes); |
71 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); | 72 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); |
72 | 73 |
73 // Remove the folder, which should remove it from the list of expanded nodes. | 74 // Remove the folder, which should remove it from the list of expanded nodes. |
74 model->Remove(model->bookmark_bar_node(), 0); | 75 model->Remove(model->bookmark_bar_node(), 0); |
75 nodes.erase(n1); | 76 nodes.erase(n1); |
76 n1 = NULL; | 77 n1 = NULL; |
77 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); | 78 EXPECT_EQ(nodes, tracker->GetExpandedNodes()); |
78 } | 79 } |
OLD | NEW |