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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc

Issue 2687893002: Clear the text cache when the tooltip text is updated. (Closed)
Patch Set: desktop aura Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
index 782b7d2b4db89d6651794f5a067b70d9f32d3f72..04e982968088a08d95c3c83284588ee9f9305cb7 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
@@ -30,6 +30,13 @@
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/menu_button.h"
+#include "ui/views/widget/widget.h"
+
+#if !defined(USE_ASH)
+#include "ui/views/test/scoped_views_test_helper.h"
+#include "ui/views/test/test_views_delegate.h"
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+#endif
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
@@ -101,6 +108,7 @@ class BookmarkBarViewTest : public BrowserWithTestWindowTest {
// need to create the BookmarkBarView after the model has populated.
void CreateBookmarkBarView() {
bookmark_bar_view_.reset(new BookmarkBarView(browser(), nullptr));
+ bookmark_bar_view_->set_owned_by_client();
test_helper_.reset(new BookmarkBarViewTestHelper(bookmark_bar_view_.get()));
}
@@ -356,3 +364,41 @@ TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) {
EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible());
}
#endif
+
+TEST_F(BookmarkBarViewTest, UpdateTooltipText) {
sky 2017/02/14 17:58:04 Would it make more sense to have this test extend
+#if !defined(USE_ASH)
+ // Setup environment for desktop aura.
+ std::unique_ptr<views::TestViewsDelegate> views_delegate_for_setup =
+ base::MakeUnique<views::TestViewsDelegate>();
+ views::ScopedViewsTestHelper helper(std::move(views_delegate_for_setup));
oshima 2017/02/14 05:14:33 Looks like I need to set up these for desktop aura
+#endif
+ CreateBookmarkModelAndBookmarkBarView();
+ // Create a widget who creates and owns a views::ToolipManager.
+ views::Widget widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+#if !defined(USE_ASH)
+ params.native_widget = new views::DesktopNativeWidgetAura(&widget);
+ params.context = helper.GetContext();
+#endif
+ widget.Init(params);
+ widget.Show();
+
+ widget.GetRootView()->AddChildView(bookmark_bar_view_.get());
+
+ BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
+ bookmarks::test::AddNodesFromModelString(model, model->bookmark_bar_node(),
+ "a b");
+ SizeUntilButtonsVisible(1);
+ ASSERT_EQ(1, test_helper_->GetBookmarkButtonCount());
+
+ views::LabelButton* button = test_helper_->GetBookmarkButton(0);
+ ASSERT_TRUE(button);
+ gfx::Point p;
+ base::string16 text;
+ button->GetTooltipText(p, &text);
+ EXPECT_EQ(base::ASCIIToUTF16("a\na.com"), text);
+ button->SetText(base::ASCIIToUTF16("new title"));
+ button->GetTooltipText(p, &text);
+ EXPECT_EQ(base::ASCIIToUTF16("new title\na.com"), text);
+}
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698