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

Unified Diff: ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc

Issue 186733011: Fixes bug that resulted in status bubble getting hidden (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_focus_rules.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc
diff --git a/ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc b/ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..596750823dc365664c1c97a4d72ac641f113c051
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
+
+#include "ui/aura/client/focus_client.h"
+#include "ui/aura/test/test_window_delegate.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_layer_type.h"
+#include "ui/views/corewm/window_util.h"
+#include "ui/views/test/views_test_base.h"
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+#include "ui/views/widget/widget.h"
+
+namespace views {
+
+namespace {
+
+scoped_ptr<Widget> CreateDesktopWidget() {
+ scoped_ptr<Widget> widget(new Widget);
+ Widget::InitParams params = Widget::InitParams(
+ Widget::InitParams::TYPE_WINDOW);
+ params.bounds = gfx::Rect(0, 0, 200, 200);
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.native_widget = new DesktopNativeWidgetAura(widget.get());
+ widget->Init(params);
+ return widget.Pass();
+}
+
+} // namespace
+
+typedef ViewsTestBase DesktopFocusRulesTest;
+
+// Verifies we don't attempt to activate a window in another widget.
+TEST_F(DesktopFocusRulesTest, DontFocusWindowsInOtherHierarchies) {
+ // Two widgets (each with a DesktopNativeWidgetAura). |w2| has a child Window
+ // |w2_child| that is not focusable. |w2_child|'s has a transient parent in
+ // |w1|.
+ scoped_ptr<views::Widget> w1(CreateDesktopWidget());
+ scoped_ptr<views::Widget> w2(CreateDesktopWidget());
+ aura::test::TestWindowDelegate w2_child_delegate;
+ w2_child_delegate.set_can_focus(false);
+ aura::Window* w2_child = new aura::Window(&w2_child_delegate);
+ w2_child->Init(aura::WINDOW_LAYER_SOLID_COLOR);
+ w2->GetNativeView()->AddChild(w2_child);
+ views::corewm::AddTransientChild(w1->GetNativeView(), w2_child);
+ aura::client::GetFocusClient(w2->GetNativeView())->FocusWindow(w2_child);
+ aura::Window* focused =
+ aura::client::GetFocusClient(w2->GetNativeView())->GetFocusedWindow();
+ EXPECT_TRUE((focused == NULL) || w2->GetNativeView()->Contains(focused));
+ views::corewm::RemoveTransientChild(w1->GetNativeView(), w2_child);
+ w1.reset();
+ w2.reset();
+}
+
+} // namespace views
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_focus_rules.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698