| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/bookmarks/bookmark_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" | 12 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" | 14 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" |
| 15 #include "chrome/test/base/test_browser_window.h" | 15 #include "chrome/test/base/test_browser_window.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "content/public/test/test_renderer_host.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 // Dummy implementation that's good enough for the tests; we don't test | 21 // Dummy implementation that's good enough for the tests; we don't test |
| 21 // rendering here so all we need is a non-NULL object. | 22 // rendering here so all we need is a non-NULL object. |
| 22 class EmptyTabstripOriginProvider : public TabstripOriginProvider { | 23 class EmptyTabstripOriginProvider : public TabstripOriginProvider { |
| 23 public: | 24 public: |
| 24 virtual gfx::Point GetTabStripOriginForWidget(GtkWidget* widget) OVERRIDE { | 25 virtual gfx::Point GetTabStripOriginForWidget(GtkWidget* widget) OVERRIDE { |
| 25 return gfx::Point(0, 0); | 26 return gfx::Point(0, 0); |
| 26 } | 27 } |
| 27 }; | 28 }; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 49 bookmark_bar_.reset(); | 50 bookmark_bar_.reset(); |
| 50 origin_provider_.reset(); | 51 origin_provider_.reset(); |
| 51 browser_.reset(); | 52 browser_.reset(); |
| 52 profile_.reset(); | 53 profile_.reset(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 BookmarkModel* model_; | 56 BookmarkModel* model_; |
| 56 | 57 |
| 57 content::TestBrowserThreadBundle thread_bundle_; | 58 content::TestBrowserThreadBundle thread_bundle_; |
| 58 | 59 |
| 60 // The existence of this object enables tests via RenderViewHostTester. |
| 61 content::RenderViewHostTestEnabler rvh_test_enabler_; |
| 62 |
| 59 scoped_ptr<TestingProfile> profile_; | 63 scoped_ptr<TestingProfile> profile_; |
| 60 scoped_ptr<Browser> browser_; | 64 scoped_ptr<Browser> browser_; |
| 61 scoped_ptr<TabstripOriginProvider> origin_provider_; | 65 scoped_ptr<TabstripOriginProvider> origin_provider_; |
| 62 scoped_ptr<BookmarkBarGtk> bookmark_bar_; | 66 scoped_ptr<BookmarkBarGtk> bookmark_bar_; |
| 63 }; | 67 }; |
| 64 | 68 |
| 65 TEST_F(BookmarkBarGtkUnittest, DisplaysHelpMessageOnEmpty) { | 69 TEST_F(BookmarkBarGtkUnittest, DisplaysHelpMessageOnEmpty) { |
| 66 bookmark_bar_->Loaded(model_, false); | 70 bookmark_bar_->Loaded(model_, false); |
| 67 | 71 |
| 68 // There are no bookmarks in the model by default. Expect that the | 72 // There are no bookmarks in the model by default. Expect that the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 87 ASCIIToUTF16("other"), GURL("http://two.com")); | 91 ASCIIToUTF16("other"), GURL("http://two.com")); |
| 88 | 92 |
| 89 bookmark_bar_->Loaded(model_, false); | 93 bookmark_bar_->Loaded(model_, false); |
| 90 | 94 |
| 91 // We should expect two children to the bookmark bar's toolbar. | 95 // We should expect two children to the bookmark bar's toolbar. |
| 92 GList* children = gtk_container_get_children( | 96 GList* children = gtk_container_get_children( |
| 93 GTK_CONTAINER(bookmark_bar_->bookmark_toolbar_.get())); | 97 GTK_CONTAINER(bookmark_bar_->bookmark_toolbar_.get())); |
| 94 EXPECT_EQ(2U, g_list_length(children)); | 98 EXPECT_EQ(2U, g_list_length(children)); |
| 95 g_list_free(children); | 99 g_list_free(children); |
| 96 } | 100 } |
| OLD | NEW |