Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: chrome/browser/views/bookmark_editor_view_unittest.cc

Issue 342068: Third patch in getting rid of caching MessageLoop pointers and always using C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/message_loop.h"
5 #include "base/string_util.h" 6 #include "base/string_util.h"
6 #include "chrome/browser/bookmarks/bookmark_model.h" 7 #include "chrome/browser/bookmarks/bookmark_model.h"
8 #include "chrome/browser/chrome_thread.h"
7 #include "chrome/browser/profile.h" 9 #include "chrome/browser/profile.h"
8 #include "chrome/browser/views/bookmark_editor_view.h" 10 #include "chrome/browser/views/bookmark_editor_view.h"
9 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
10 #include "chrome/common/pref_service.h" 12 #include "chrome/common/pref_service.h"
11 #include "chrome/test/testing_profile.h" 13 #include "chrome/test/testing_profile.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 using base::Time; 16 using base::Time;
15 using base::TimeDelta; 17 using base::TimeDelta;
16 18
17 // Base class for bookmark editor tests. Creates a BookmarkModel and populates 19 // Base class for bookmark editor tests. Creates a BookmarkModel and populates
18 // it with test data. 20 // it with test data.
19 class BookmarkEditorViewTest : public testing::Test { 21 class BookmarkEditorViewTest : public testing::Test {
20 public: 22 public:
21 BookmarkEditorViewTest() : model_(NULL) { 23 BookmarkEditorViewTest()
24 : model_(NULL),
25 ui_thread_(ChromeThread::UI, &message_loop_),
26 file_thread_(ChromeThread::FILE, &message_loop_) {
22 } 27 }
23 28
24 virtual void SetUp() { 29 virtual void SetUp() {
25 profile_.reset(new TestingProfile()); 30 profile_.reset(new TestingProfile());
26 profile_->set_has_history_service(true); 31 profile_->set_has_history_service(true);
27 profile_->CreateBookmarkModel(true); 32 profile_->CreateBookmarkModel(true);
28 33
29 model_ = profile_->GetBookmarkModel(); 34 model_ = profile_->GetBookmarkModel();
35 profile_->BlockUntilBookmarkModelLoaded();
30 36
31 AddTestData(); 37 AddTestData();
32 } 38 }
33 39
34 virtual void TearDown() { 40 virtual void TearDown() {
35 } 41 }
36 42
37 protected: 43 protected:
38 MessageLoopForUI message_loop_; 44 MessageLoopForUI message_loop_;
39 BookmarkModel* model_; 45 BookmarkModel* model_;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 116
111 // Children of the other node. 117 // Children of the other node.
112 model_->AddURL(model_->other_node(), 0, L"oa", 118 model_->AddURL(model_->other_node(), 0, L"oa",
113 GURL(test_base + "oa")); 119 GURL(test_base + "oa"));
114 const BookmarkNode* of1 = 120 const BookmarkNode* of1 =
115 model_->AddGroup(model_->other_node(), 1, L"OF1"); 121 model_->AddGroup(model_->other_node(), 1, L"OF1");
116 model_->AddURL(of1, 0, L"of1a", GURL(test_base + "of1a")); 122 model_->AddURL(of1, 0, L"of1a", GURL(test_base + "of1a"));
117 } 123 }
118 124
119 scoped_ptr<BookmarkEditorView> editor_; 125 scoped_ptr<BookmarkEditorView> editor_;
126 ChromeThread ui_thread_;
127 ChromeThread file_thread_;
120 }; 128 };
121 129
122 // Makes sure the tree model matches that of the bookmark bar model. 130 // Makes sure the tree model matches that of the bookmark bar model.
123 TEST_F(BookmarkEditorViewTest, ModelsMatch) { 131 TEST_F(BookmarkEditorViewTest, ModelsMatch) {
124 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(), 132 CreateEditor(profile_.get(), NULL, BookmarkEditor::EditDetails(),
125 BookmarkEditorView::SHOW_TREE, NULL); 133 BookmarkEditorView::SHOW_TREE, NULL);
126 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot(); 134 BookmarkEditorView::EditorNode* editor_root = editor_tree_model()->GetRoot();
127 // The root should have two children, one for the bookmark bar node, 135 // The root should have two children, one for the bookmark bar node,
128 // the other for the 'other bookmarks' folder. 136 // the other for the 'other bookmarks' folder.
129 ASSERT_EQ(2, editor_root->GetChildCount()); 137 ASSERT_EQ(2, editor_root->GetChildCount());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type()); 355 EXPECT_EQ(BookmarkNode::FOLDER, new_node->type());
348 EXPECT_EQ(L"new_F", new_node->GetTitle()); 356 EXPECT_EQ(L"new_F", new_node->GetTitle());
349 // The node should have one child. 357 // The node should have one child.
350 ASSERT_EQ(1, new_node->GetChildCount()); 358 ASSERT_EQ(1, new_node->GetChildCount());
351 const BookmarkNode* new_child = new_node->GetChild(0); 359 const BookmarkNode* new_child = new_node->GetChild(0);
352 // Make sure the child url/title match. 360 // Make sure the child url/title match.
353 EXPECT_EQ(BookmarkNode::URL, new_child->type()); 361 EXPECT_EQ(BookmarkNode::URL, new_child->type());
354 EXPECT_EQ(details.urls[0].second, new_child->GetTitle()); 362 EXPECT_EQ(details.urls[0].second, new_child->GetTitle());
355 EXPECT_TRUE(details.urls[0].first == new_child->GetURL()); 363 EXPECT_TRUE(details.urls[0].first == new_child->GetURL());
356 } 364 }
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_context_menu_test.cc ('k') | chrome/browser/views/bookmark_manager_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698