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