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

Unified Diff: chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc

Issue 319543003: Create the managed_node at the ChromeBookmarkClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
diff --git a/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
index 31021587d3bba1ac5d9d11710b49d394d8d05ec1..9327fbb66894fdb809c07a51d74ddeedd1497f17 100644
--- a/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_context_menu_controller_unittest.cc
@@ -52,19 +52,12 @@ class BookmarkContextMenuControllerTest : public testing::Test {
}
virtual void SetUp() OVERRIDE {
- Reset(false);
- }
- void Reset(bool incognito) {
TestingProfile::Builder builder;
- if (incognito)
- builder.SetIncognito();
profile_ = builder.Build();
profile_->CreateBookmarkModel(true);
-
model_ = BookmarkModelFactory::GetForProfile(profile_.get());
test::WaitForBookmarkModelToLoad(model_);
-
- AddTestData();
+ AddTestData(model_);
}
virtual void TearDown() OVERRIDE {
@@ -74,15 +67,6 @@ class BookmarkContextMenuControllerTest : public testing::Test {
message_loop_.RunUntilIdle();
}
- protected:
- base::MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_thread_;
- scoped_ptr<TestingProfile> profile_;
- BookmarkModel* model_;
- TestingPageNavigator navigator_;
-
- private:
// Creates the following structure:
// a
// F1
@@ -93,19 +77,27 @@ class BookmarkContextMenuControllerTest : public testing::Test {
// F3
// F4
// f4a
- void AddTestData() {
- const BookmarkNode* bb_node = model_->bookmark_bar_node();
+ static void AddTestData(BookmarkModel* model) {
+ const BookmarkNode* bb_node = model->bookmark_bar_node();
std::string test_base = "file:///c:/tmp/";
- model_->AddURL(bb_node, 0, ASCIIToUTF16("a"), GURL(test_base + "a"));
- const BookmarkNode* f1 = model_->AddFolder(bb_node, 1, ASCIIToUTF16("F1"));
- model_->AddURL(f1, 0, ASCIIToUTF16("f1a"), GURL(test_base + "f1a"));
- const BookmarkNode* f11 = model_->AddFolder(f1, 1, ASCIIToUTF16("F11"));
- model_->AddURL(f11, 0, ASCIIToUTF16("f11a"), GURL(test_base + "f11a"));
- model_->AddFolder(bb_node, 2, ASCIIToUTF16("F2"));
- model_->AddFolder(bb_node, 3, ASCIIToUTF16("F3"));
- const BookmarkNode* f4 = model_->AddFolder(bb_node, 4, ASCIIToUTF16("F4"));
- model_->AddURL(f4, 0, ASCIIToUTF16("f4a"), GURL(test_base + "f4a"));
+ model->AddURL(bb_node, 0, ASCIIToUTF16("a"), GURL(test_base + "a"));
+ const BookmarkNode* f1 = model->AddFolder(bb_node, 1, ASCIIToUTF16("F1"));
+ model->AddURL(f1, 0, ASCIIToUTF16("f1a"), GURL(test_base + "f1a"));
+ const BookmarkNode* f11 = model->AddFolder(f1, 1, ASCIIToUTF16("F11"));
+ model->AddURL(f11, 0, ASCIIToUTF16("f11a"), GURL(test_base + "f11a"));
+ model->AddFolder(bb_node, 2, ASCIIToUTF16("F2"));
+ model->AddFolder(bb_node, 3, ASCIIToUTF16("F3"));
+ const BookmarkNode* f4 = model->AddFolder(bb_node, 4, ASCIIToUTF16("F4"));
+ model->AddURL(f4, 0, ASCIIToUTF16("f4a"), GURL(test_base + "f4a"));
}
+
+ protected:
+ base::MessageLoopForUI message_loop_;
+ content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread file_thread_;
+ scoped_ptr<TestingProfile> profile_;
+ BookmarkModel* model_;
+ TestingPageNavigator navigator_;
};
// Tests Deleting from the menu.
@@ -249,12 +241,24 @@ TEST_F(BookmarkContextMenuControllerTest, MultipleFoldersWithURLs) {
// Tests the enabled state of open incognito.
TEST_F(BookmarkContextMenuControllerTest, DisableIncognito) {
- // Create a new incognito profile.
- Reset(true);
+ // Create an incognito Profile. It must be associated with the original
+ // Profile, so that GetOriginalProfile() works as expected.
+ TestingProfile::Builder builder;
+ builder.SetIncognito();
+ scoped_ptr<TestingProfile> testing_incognito = builder.Build();
+ testing_incognito->SetOriginalProfile(profile_.get());
+ TestingProfile* incognito = testing_incognito.get();
+ profile_->SetOffTheRecordProfile(testing_incognito.PassAs<Profile>());
+
+ incognito->CreateBookmarkModel(true);
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(incognito);
+ test::WaitForBookmarkModelToLoad(model);
+ AddTestData(model);
+
std::vector<const BookmarkNode*> nodes;
- nodes.push_back(model_->bookmark_bar_node()->GetChild(0));
+ nodes.push_back(model->bookmark_bar_node()->GetChild(0));
BookmarkContextMenuController controller(
- NULL, NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes);
+ NULL, NULL, NULL, incognito, NULL, nodes[0]->parent(), nodes);
EXPECT_FALSE(controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_INCOGNITO));
EXPECT_FALSE(
controller.IsCommandIdEnabled(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO));

Powered by Google App Engine
This is Rietveld 408576698