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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views_unittest.cc

Issue 2630473003: MacViews: Harmony for toolbar actions bubbles. (Closed)
Patch Set: respond to comments Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/views/toolbar/toolbar_actions_bar_bubble_views.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 56 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
57 anchor_widget->Init(params); 57 anchor_widget->Init(params);
58 return anchor_widget; 58 return anchor_widget;
59 } 59 }
60 60
61 void ShowBubble(TestToolbarActionsBarBubbleDelegate* delegate) { 61 void ShowBubble(TestToolbarActionsBarBubbleDelegate* delegate) {
62 ASSERT_TRUE(delegate); 62 ASSERT_TRUE(delegate);
63 ASSERT_FALSE(bubble_widget_); 63 ASSERT_FALSE(bubble_widget_);
64 ASSERT_FALSE(bubble_); 64 ASSERT_FALSE(bubble_);
65 anchor_widget_ = CreateAnchorWidget(); 65 anchor_widget_ = CreateAnchorWidget();
66 bool anchored_to_action = false;
66 bubble_ = new ToolbarActionsBarBubbleViews( 67 bubble_ = new ToolbarActionsBarBubbleViews(
67 anchor_widget_->GetContentsView(), delegate->GetDelegate()); 68 anchor_widget_->GetContentsView(), gfx::Point(), anchored_to_action,
69 delegate->GetDelegate());
68 bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_); 70 bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_);
69 bubble_->Show(); 71 bubble_->Show();
70 } 72 }
71 73
72 void CloseBubble() { 74 void CloseBubble() {
73 ASSERT_TRUE(bubble_); 75 ASSERT_TRUE(bubble_);
74 bubble_->GetWidget()->Close(); 76 bubble_->GetWidget()->Close();
75 base::RunLoop().RunUntilIdle(); 77 base::RunLoop().RunUntilIdle();
76 bubble_ = nullptr; 78 bubble_ = nullptr;
77 bubble_widget_ = nullptr; 79 bubble_widget_ = nullptr;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 204
203 CloseBubble(); 205 CloseBubble();
204 } 206 }
205 207
206 TEST_F(ToolbarActionsBarBubbleViewsTest, TestShowAndCloseBubble) { 208 TEST_F(ToolbarActionsBarBubbleViewsTest, TestShowAndCloseBubble) {
207 std::unique_ptr<views::Widget> anchor_widget = CreateAnchorWidget(); 209 std::unique_ptr<views::Widget> anchor_widget = CreateAnchorWidget();
208 TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(), 210 TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(),
209 ActionString()); 211 ActionString());
210 delegate.set_dismiss_button_text(DismissString()); 212 delegate.set_dismiss_button_text(DismissString());
211 ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews( 213 ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews(
212 anchor_widget->GetContentsView(), delegate.GetDelegate()); 214 anchor_widget->GetContentsView(), gfx::Point(), false,
215 delegate.GetDelegate());
213 216
214 EXPECT_FALSE(delegate.shown()); 217 EXPECT_FALSE(delegate.shown());
215 EXPECT_FALSE(delegate.close_action()); 218 EXPECT_FALSE(delegate.close_action());
216 views::Widget* bubble_widget = 219 views::Widget* bubble_widget =
217 views::BubbleDialogDelegateView::CreateBubble(bubble); 220 views::BubbleDialogDelegateView::CreateBubble(bubble);
218 views::test::TestWidgetObserver bubble_observer(bubble_widget); 221 views::test::TestWidgetObserver bubble_observer(bubble_widget);
219 bubble->Show(); 222 bubble->Show();
220 EXPECT_TRUE(delegate.shown()); 223 EXPECT_TRUE(delegate.shown());
221 EXPECT_FALSE(delegate.close_action()); 224 EXPECT_FALSE(delegate.close_action());
222 225
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } else { 408 } else {
406 EXPECT_TRUE(gfx::test::AreImagesEqual( 409 EXPECT_TRUE(gfx::test::AreImagesEqual(
407 gfx::Image(static_cast<const views::ImageView*>(v)->GetImage()), 410 gfx::Image(static_cast<const views::ImageView*>(v)->GetImage()),
408 gfx::Image(gfx::CreateVectorIcon(gfx::VectorIconId::BUSINESS, 411 gfx::Image(gfx::CreateVectorIcon(gfx::VectorIconId::BUSINESS,
409 kIconSize, gfx::kChromeIconGrey)))); 412 kIconSize, gfx::kChromeIconGrey))));
410 } 413 }
411 } 414 }
412 415
413 CloseBubble(); 416 CloseBubble();
414 } 417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698