| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/bookmark_bar_gtk.h" | 5 #include "chrome/browser/gtk/bookmark_bar_gtk.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/chrome_thread.h" |
| 8 #include "chrome/browser/gtk/tabstrip_origin_provider.h" | 9 #include "chrome/browser/gtk/tabstrip_origin_provider.h" |
| 9 #include "base/task.h" | 10 #include "base/task.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "chrome/test/testing_profile.h" | 12 #include "chrome/test/testing_profile.h" |
| 12 | 13 |
| 13 // Dummy implementation that's good enough for the tests; we don't test | 14 // Dummy implementation that's good enough for the tests; we don't test |
| 14 // rendering here so all we need is a non-NULL object. | 15 // rendering here so all we need is a non-NULL object. |
| 15 class EmptyTabstripOriginProvider : public TabstripOriginProvider { | 16 class EmptyTabstripOriginProvider : public TabstripOriginProvider { |
| 16 public: | 17 public: |
| 17 virtual gfx::Point GetTabStripOriginForWidget(GtkWidget* widget) { | 18 virtual gfx::Point GetTabStripOriginForWidget(GtkWidget* widget) { |
| 18 return gfx::Point(0, 0); | 19 return gfx::Point(0, 0); |
| 19 } | 20 } |
| 20 }; | 21 }; |
| 21 | 22 |
| 22 class BookmarkBarGtkUnittest : public ::testing::Test { | 23 class BookmarkBarGtkUnittest : public ::testing::Test { |
| 23 protected: | 24 protected: |
| 24 BookmarkBarGtkUnittest() { | 25 BookmarkBarGtkUnittest() |
| 26 : ui_thread_(ChromeThread::UI, &message_loop_), |
| 27 file_thread_(ChromeThread::FILE, &message_loop_) { |
| 25 profile_.reset(new TestingProfile()); | 28 profile_.reset(new TestingProfile()); |
| 26 profile_->CreateBookmarkModel(true); | 29 profile_->CreateBookmarkModel(true); |
| 30 profile_->BlockUntilBookmarkModelLoaded(); |
| 27 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); | 31 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); |
| 28 | 32 |
| 29 origin_provider_.reset(new EmptyTabstripOriginProvider); | 33 origin_provider_.reset(new EmptyTabstripOriginProvider); |
| 30 bookmark_bar_.reset(new BookmarkBarGtk(NULL, profile_.get(), browser_.get(), | 34 bookmark_bar_.reset(new BookmarkBarGtk(NULL, profile_.get(), browser_.get(), |
| 31 origin_provider_.get())); | 35 origin_provider_.get())); |
| 32 } | 36 } |
| 33 | 37 |
| 34 scoped_ptr<TestingProfile> profile_; | 38 scoped_ptr<TestingProfile> profile_; |
| 35 scoped_ptr<Browser> browser_; | 39 scoped_ptr<Browser> browser_; |
| 36 scoped_ptr<TabstripOriginProvider> origin_provider_; | 40 scoped_ptr<TabstripOriginProvider> origin_provider_; |
| 37 scoped_ptr<BookmarkBarGtk> bookmark_bar_; | 41 scoped_ptr<BookmarkBarGtk> bookmark_bar_; |
| 42 MessageLoopForUI message_loop_; |
| 43 ChromeThread ui_thread_; |
| 44 ChromeThread file_thread_; |
| 38 }; | 45 }; |
| 39 | 46 |
| 40 TEST_F(BookmarkBarGtkUnittest, DisplaysHelpMessageOnEmpty) { | 47 TEST_F(BookmarkBarGtkUnittest, DisplaysHelpMessageOnEmpty) { |
| 41 BookmarkModel* model = profile_->GetBookmarkModel(); | 48 BookmarkModel* model = profile_->GetBookmarkModel(); |
| 42 bookmark_bar_->Loaded(model); | 49 bookmark_bar_->Loaded(model); |
| 43 | 50 |
| 44 // There are no bookmarks in the model by default. Expect that the | 51 // There are no bookmarks in the model by default. Expect that the |
| 45 // |instructions_label| is shown. | 52 // |instructions_label| is shown. |
| 46 EXPECT_TRUE(bookmark_bar_->show_instructions_); | 53 EXPECT_TRUE(bookmark_bar_->show_instructions_); |
| 47 } | 54 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 67 L"other", GURL("http://two.com")); | 74 L"other", GURL("http://two.com")); |
| 68 | 75 |
| 69 bookmark_bar_->Loaded(model); | 76 bookmark_bar_->Loaded(model); |
| 70 | 77 |
| 71 // We should expect two children to the bookmark bar's toolbar. | 78 // We should expect two children to the bookmark bar's toolbar. |
| 72 GList* children = gtk_container_get_children( | 79 GList* children = gtk_container_get_children( |
| 73 GTK_CONTAINER(bookmark_bar_->bookmark_toolbar_.get())); | 80 GTK_CONTAINER(bookmark_bar_->bookmark_toolbar_.get())); |
| 74 EXPECT_EQ(2U, g_list_length(children)); | 81 EXPECT_EQ(2U, g_list_length(children)); |
| 75 g_list_free(children); | 82 g_list_free(children); |
| 76 } | 83 } |
| OLD | NEW |