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

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: updated test 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..56100c4d1eebda3e772b4c4b421695107410d077 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,8 @@
#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/test/native_widget_factory.h"
+#include "ui/views/widget/widget.h"
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
@@ -101,6 +103,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 +359,34 @@ TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) {
EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible());
}
#endif
+
+TEST_F(BookmarkBarViewTest, UpdateTooltipText) {
+ 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;
+ params.native_widget = views::test::CreatePlatformDesktopNativeWidgetImpl(
+ params, &widget, nullptr);
oshima 2017/02/17 17:30:25 looks like this is how views unit test should do f
+ 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);
+
+ widget.CloseNow();
+}
« 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