Skip to content

Commit

Permalink
MacViews: Fix views_unittests BubbleDelegateTest.CloseReasons
Browse files Browse the repository at this point in the history
Test added in r360848, fails on Mac as the bubble's parent anchor is not being
shown before the bubble is expected to appear - this causes the bubble to be
treated as 'hidden' as its parent is not visible. This should actually be
expected behaviour on all platforms, so the failure is actually indicating
there's a bug on Aura (see http://crbug/590957).

Workaround this for now by showing the bubble's anchor widget first to allow
this to pass for all platforms.

Also add ScopedFakeNSWindowFocus to all tests to simulate focus on the parent,
as well as defend against test flakiness which might be caused by window
activation issues.

BUG=579380,590957

Review URL: https://codereview.chromium.org/1637383003

Cr-Commit-Position: refs/heads/master@{#379499}
  • Loading branch information
plorcupine authored and Commit bot committed Mar 6, 2016
1 parent d3c78c0 commit 71d4b0f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/views/bubble/bubble_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"

#if defined(OS_MACOSX)
#include "ui/base/test/scoped_fake_nswindow_focus.h"
#endif

namespace views {

namespace {
Expand Down Expand Up @@ -66,6 +70,11 @@ class BubbleDelegateTest : public ViewsTestBase {
}

private:
#if defined(OS_MACOSX)
// Ensure tests running in parallel don't steal focus from the Widget on Mac.
ui::test::ScopedFakeNSWindowFocus fake_focus_;
#endif

DISALLOW_COPY_AND_ASSIGN(BubbleDelegateTest);
};

Expand Down Expand Up @@ -277,6 +286,7 @@ TEST_F(BubbleDelegateTest, CloseReasons) {
anchor_widget->GetContentsView(), BubbleBorder::NONE);
bubble_delegate->set_close_on_deactivate(true);
Widget* bubble_widget = BubbleDelegateView::CreateBubble(bubble_delegate);
anchor_widget->Show();
bubble_widget->Show();
anchor_widget->Activate();
EXPECT_TRUE(bubble_widget->IsClosed());
Expand Down

0 comments on commit 71d4b0f

Please sign in to comment.