| OLD | NEW |
| 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_bubble_delegate.h" | 7 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_bubble_delegate.h" |
| 8 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" | 8 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/events/test/event_generator.h" | 10 #include "ui/events/test/event_generator.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 EXPECT_FALSE(delegate.close_action()); | 150 EXPECT_FALSE(delegate.close_action()); |
| 151 // Close the bubble by activating another widget. The delegate should be | 151 // Close the bubble by activating another widget. The delegate should be |
| 152 // told it was dismissed. | 152 // told it was dismissed. |
| 153 anchor_widget->Activate(); | 153 anchor_widget->Activate(); |
| 154 base::RunLoop().RunUntilIdle(); | 154 base::RunLoop().RunUntilIdle(); |
| 155 ASSERT_TRUE(delegate.close_action()); | 155 ASSERT_TRUE(delegate.close_action()); |
| 156 EXPECT_EQ(ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION, | 156 EXPECT_EQ(ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION, |
| 157 *delegate.close_action()); | 157 *delegate.close_action()); |
| 158 EXPECT_TRUE(bubble_observer.widget_closed()); | 158 EXPECT_TRUE(bubble_observer.widget_closed()); |
| 159 } | 159 } |
| 160 |
| 161 TEST_F(ToolbarActionsBarBubbleViewsTest, TestDontCloseOnDeactivation) { |
| 162 scoped_ptr<views::Widget> anchor_widget = CreateAnchorWidget(); |
| 163 TestToolbarActionsBarBubbleDelegate delegate(HeadingString(), BodyString(), |
| 164 ActionString()); |
| 165 delegate.set_dismiss_button_text(DismissString()); |
| 166 delegate.set_close_on_deactivate(false); |
| 167 ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews( |
| 168 anchor_widget->GetContentsView(), delegate.GetDelegate()); |
| 169 views::Widget* bubble_widget = |
| 170 views::BubbleDelegateView::CreateBubble(bubble); |
| 171 views::test::TestWidgetObserver bubble_observer(bubble_widget); |
| 172 bubble->Show(); |
| 173 |
| 174 EXPECT_FALSE(delegate.close_action()); |
| 175 // Activate another widget. The bubble shouldn't close. |
| 176 anchor_widget->Activate(); |
| 177 base::RunLoop().RunUntilIdle(); |
| 178 EXPECT_FALSE(delegate.close_action()); |
| 179 bubble_widget->Close(); |
| 180 base::RunLoop().RunUntilIdle(); |
| 181 } |
| OLD | NEW |