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/recently_used_folders_combo_model.h" | 5 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.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 RecentlyUsedFoldersComboModelTest : public testing::Test { | 16 class RecentlyUsedFoldersComboModelTest : public testing::Test { |
16 public: | 17 public: |
17 RecentlyUsedFoldersComboModelTest(); | 18 RecentlyUsedFoldersComboModelTest(); |
18 | 19 |
(...skipping 22 matching lines...) Expand all Loading... |
41 profile_->BlockUntilBookmarkModelLoaded(); | 42 profile_->BlockUntilBookmarkModelLoaded(); |
42 } | 43 } |
43 | 44 |
44 void RecentlyUsedFoldersComboModelTest::TearDown() { | 45 void RecentlyUsedFoldersComboModelTest::TearDown() { |
45 // Flush the message loop to make application verifiers happy. | 46 // Flush the message loop to make application verifiers happy. |
46 message_loop_.RunAllPending(); | 47 message_loop_.RunAllPending(); |
47 } | 48 } |
48 | 49 |
49 // Verifies there are no duplicate nodes in the model. | 50 // Verifies there are no duplicate nodes in the model. |
50 TEST_F(RecentlyUsedFoldersComboModelTest, NoDups) { | 51 TEST_F(RecentlyUsedFoldersComboModelTest, NoDups) { |
51 BookmarkModel* bookmark_model = profile_->GetBookmarkModel(); | 52 BookmarkModel* bookmark_model = |
| 53 BookmarkModelFactory::GetForProfile(profile_.get()); |
52 const BookmarkNode* new_node = bookmark_model->AddURL( | 54 const BookmarkNode* new_node = bookmark_model->AddURL( |
53 bookmark_model->bookmark_bar_node(), 0, ASCIIToUTF16("a"), | 55 bookmark_model->bookmark_bar_node(), 0, ASCIIToUTF16("a"), |
54 GURL("http://a")); | 56 GURL("http://a")); |
55 RecentlyUsedFoldersComboModel model(bookmark_model, new_node); | 57 RecentlyUsedFoldersComboModel model(bookmark_model, new_node); |
56 std::set<const BookmarkNode*> nodes; | 58 std::set<const BookmarkNode*> nodes; |
57 for (int i = 0; i < model.GetItemCount(); ++i) { | 59 for (int i = 0; i < model.GetItemCount(); ++i) { |
58 const BookmarkNode* node = model.GetNodeAt(i); | 60 const BookmarkNode* node = model.GetNodeAt(i); |
59 EXPECT_EQ(0u, nodes.count(node)); | 61 EXPECT_EQ(0u, nodes.count(node)); |
60 nodes.insert(node); | 62 nodes.insert(node); |
61 } | 63 } |
62 } | 64 } |
OLD | NEW |