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

Side by Side Diff: ui/views/bubble/bubble_delegate_unittest.cc

Issue 1637383003: MacViews: Fix views_unittests BubbleDelegateTest.CloseReasons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
tapted 2016/01/28 02:50:53 Don't forget to wrap the CL description. It should
Patti Lor 2016/03/01 00:30:47 Done.
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "ui/base/hit_test.h" 8 #include "ui/base/hit_test.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/views/bubble/bubble_delegate.h" 10 #include "ui/views/bubble/bubble_delegate.h"
11 #include "ui/views/bubble/bubble_frame_view.h" 11 #include "ui/views/bubble/bubble_frame_view.h"
12 #include "ui/views/controls/button/label_button.h" 12 #include "ui/views/controls/button/label_button.h"
13 #include "ui/views/test/test_widget_observer.h" 13 #include "ui/views/test/test_widget_observer.h"
14 #include "ui/views/test/views_test_base.h" 14 #include "ui/views/test/views_test_base.h"
15 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
16 #include "ui/views/widget/widget_observer.h" 16 #include "ui/views/widget/widget_observer.h"
17 17
18 #if defined(OS_MACOSX)
19 #include "ui/base/test/scoped_fake_nswindow_focus.h"
20 #endif
21
18 namespace views { 22 namespace views {
19 23
20 namespace { 24 namespace {
21 25
22 class TestBubbleDelegateView : public BubbleDelegateView { 26 class TestBubbleDelegateView : public BubbleDelegateView {
23 public: 27 public:
24 TestBubbleDelegateView(View* anchor_view) 28 TestBubbleDelegateView(View* anchor_view)
25 : BubbleDelegateView(anchor_view, BubbleBorder::TOP_LEFT), 29 : BubbleDelegateView(anchor_view, BubbleBorder::TOP_LEFT),
26 view_(new View()) { 30 view_(new View()) {
27 view_->SetFocusable(true); 31 view_->SetFocusable(true);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 EXPECT_FALSE(bubble_widget->CanActivate()); 274 EXPECT_FALSE(bubble_widget->CanActivate());
271 } 275 }
272 276
273 TEST_F(BubbleDelegateTest, CloseReasons) { 277 TEST_F(BubbleDelegateTest, CloseReasons) {
274 { 278 {
275 scoped_ptr<Widget> anchor_widget(CreateTestWidget()); 279 scoped_ptr<Widget> anchor_widget(CreateTestWidget());
276 BubbleDelegateView* bubble_delegate = new BubbleDelegateView( 280 BubbleDelegateView* bubble_delegate = new BubbleDelegateView(
277 anchor_widget->GetContentsView(), BubbleBorder::NONE); 281 anchor_widget->GetContentsView(), BubbleBorder::NONE);
278 bubble_delegate->set_close_on_deactivate(true); 282 bubble_delegate->set_close_on_deactivate(true);
279 Widget* bubble_widget = BubbleDelegateView::CreateBubble(bubble_delegate); 283 Widget* bubble_widget = BubbleDelegateView::CreateBubble(bubble_delegate);
284 #if defined(OS_MACOSX)
285 // Bubble widget will not show unless anchor widget is activated in the
286 // first place, which doesn't happen by default on Mac.
287 ui::test::ScopedFakeNSWindowFocus fake_focus;
288 anchor_widget->Activate();
289 #endif
280 bubble_widget->Show(); 290 bubble_widget->Show();
tapted 2016/01/28 02:50:53 I think the fix should be to call anchor_widget->S
Patti Lor 2016/03/01 00:30:47 So as discussed offline, this isn't actually the c
281 anchor_widget->Activate(); 291 anchor_widget->Activate();
282 EXPECT_TRUE(bubble_widget->IsClosed()); 292 EXPECT_TRUE(bubble_widget->IsClosed());
283 EXPECT_EQ(BubbleDelegateView::CloseReason::DEACTIVATION, 293 EXPECT_EQ(BubbleDelegateView::CloseReason::DEACTIVATION,
284 bubble_delegate->close_reason()); 294 bubble_delegate->close_reason());
285 } 295 }
286 296
287 { 297 {
288 scoped_ptr<Widget> anchor_widget(CreateTestWidget()); 298 scoped_ptr<Widget> anchor_widget(CreateTestWidget());
289 BubbleDelegateView* bubble_delegate = new BubbleDelegateView( 299 BubbleDelegateView* bubble_delegate = new BubbleDelegateView(
290 anchor_widget->GetContentsView(), BubbleBorder::NONE); 300 anchor_widget->GetContentsView(), BubbleBorder::NONE);
(...skipping 22 matching lines...) Expand all
313 close_button, 323 close_button,
314 ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 324 ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0),
315 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); 325 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE));
316 EXPECT_TRUE(bubble_widget->IsClosed()); 326 EXPECT_TRUE(bubble_widget->IsClosed());
317 EXPECT_EQ(BubbleDelegateView::CloseReason::CLOSE_BUTTON, 327 EXPECT_EQ(BubbleDelegateView::CloseReason::CLOSE_BUTTON,
318 bubble_delegate->close_reason()); 328 bubble_delegate->close_reason());
319 } 329 }
320 } 330 }
321 331
322 } // namespace views 332 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698