• 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 "base/utf_string_conversions.h"
6 #include "chrome/browser/bookmarks/bookmark_model.h"
7 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
8 #include "chrome/test/browser_with_test_window_test.h"
9 #include "chrome/test/testing_profile.h"
10 #include "content/browser/browser_thread.h"
11 
12 typedef BrowserWithTestWindowTest BookmarkBarViewTest;
13 
TEST_F(BookmarkBarViewTest,SwitchProfile)14 TEST_F(BookmarkBarViewTest, SwitchProfile) {
15   profile()->CreateBookmarkModel(true);
16   profile()->BlockUntilBookmarkModelLoaded();
17 
18   profile()->GetBookmarkModel()->AddURL(
19       profile()->GetBookmarkModel()->GetBookmarkBarNode(),
20       0,
21       ASCIIToUTF16("blah"),
22       GURL("http://www.google.com"));
23 
24   BookmarkBarView bookmark_bar(profile(), browser());
25 
26   EXPECT_EQ(1, bookmark_bar.GetBookmarkButtonCount());
27 
28   TestingProfile profile2;
29   profile2.CreateBookmarkModel(true);
30   profile2.BlockUntilBookmarkModelLoaded();
31 
32   bookmark_bar.SetProfile(&profile2);
33 
34   EXPECT_EQ(0, bookmark_bar.GetBookmarkButtonCount());
35 
36   bookmark_bar.SetProfile(profile());
37   EXPECT_EQ(1, bookmark_bar.GetBookmarkButtonCount());
38 }
39