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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/views/widget/desktop_aura/desktop_focus_rules.h" 5 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
6 6
7 #include "ui/aura/client/focus_client.h" 7 #include "ui/aura/client/focus_client.h"
8 #include "ui/aura/test/test_window_delegate.h" 8 #include "ui/aura/test/test_window_delegate.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
11 #include "ui/views/test/views_test_base.h" 11 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 12 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
13 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
14 #include "ui/wm/core/window_util.h" 14 #include "ui/wm/core/window_util.h"
15 15
16 namespace views { 16 namespace views {
17 17
18 namespace { 18 namespace {
19 19
20 scoped_ptr<Widget> CreateDesktopWidget() { 20 std::unique_ptr<Widget> CreateDesktopWidget() {
21 scoped_ptr<Widget> widget(new Widget); 21 std::unique_ptr<Widget> widget(new Widget);
22 Widget::InitParams params = Widget::InitParams( 22 Widget::InitParams params = Widget::InitParams(
23 Widget::InitParams::TYPE_WINDOW); 23 Widget::InitParams::TYPE_WINDOW);
24 params.bounds = gfx::Rect(0, 0, 200, 200); 24 params.bounds = gfx::Rect(0, 0, 200, 200);
25 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 25 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
26 params.native_widget = new DesktopNativeWidgetAura(widget.get()); 26 params.native_widget = new DesktopNativeWidgetAura(widget.get());
27 widget->Init(params); 27 widget->Init(params);
28 return widget; 28 return widget;
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 typedef ViewsTestBase DesktopFocusRulesTest; 33 typedef ViewsTestBase DesktopFocusRulesTest;
34 34
35 // Verifies we don't attempt to activate a window in another widget. 35 // Verifies we don't attempt to activate a window in another widget.
36 TEST_F(DesktopFocusRulesTest, DontFocusWindowsInOtherHierarchies) { 36 TEST_F(DesktopFocusRulesTest, DontFocusWindowsInOtherHierarchies) {
37 // Two widgets (each with a DesktopNativeWidgetAura). |w2| has a child Window 37 // Two widgets (each with a DesktopNativeWidgetAura). |w2| has a child Window
38 // |w2_child| that is not focusable. |w2_child|'s has a transient parent in 38 // |w2_child| that is not focusable. |w2_child|'s has a transient parent in
39 // |w1|. 39 // |w1|.
40 scoped_ptr<views::Widget> w1(CreateDesktopWidget()); 40 std::unique_ptr<views::Widget> w1(CreateDesktopWidget());
41 scoped_ptr<views::Widget> w2(CreateDesktopWidget()); 41 std::unique_ptr<views::Widget> w2(CreateDesktopWidget());
42 aura::test::TestWindowDelegate w2_child_delegate; 42 aura::test::TestWindowDelegate w2_child_delegate;
43 w2_child_delegate.set_can_focus(false); 43 w2_child_delegate.set_can_focus(false);
44 aura::Window* w2_child = new aura::Window(&w2_child_delegate); 44 aura::Window* w2_child = new aura::Window(&w2_child_delegate);
45 w2_child->Init(ui::LAYER_SOLID_COLOR); 45 w2_child->Init(ui::LAYER_SOLID_COLOR);
46 w2->GetNativeView()->AddChild(w2_child); 46 w2->GetNativeView()->AddChild(w2_child);
47 wm::AddTransientChild(w1->GetNativeView(), w2_child); 47 wm::AddTransientChild(w1->GetNativeView(), w2_child);
48 aura::client::GetFocusClient(w2->GetNativeView())->FocusWindow(w2_child); 48 aura::client::GetFocusClient(w2->GetNativeView())->FocusWindow(w2_child);
49 aura::Window* focused = 49 aura::Window* focused =
50 aura::client::GetFocusClient(w2->GetNativeView())->GetFocusedWindow(); 50 aura::client::GetFocusClient(w2->GetNativeView())->GetFocusedWindow();
51 EXPECT_TRUE((focused == NULL) || w2->GetNativeView()->Contains(focused)); 51 EXPECT_TRUE((focused == NULL) || w2->GetNativeView()->Contains(focused));
52 wm::RemoveTransientChild(w1->GetNativeView(), w2_child); 52 wm::RemoveTransientChild(w1->GetNativeView(), w2_child);
53 w1.reset(); 53 w1.reset();
54 w2.reset(); 54 w2.reset();
55 } 55 }
56 56
57 } // namespace views 57 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_drop_target_win.cc ('k') | ui/views/widget/desktop_aura/desktop_native_cursor_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698