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

Side by Side Diff: ui/views/ime/input_method_bridge_unittest.cc

Issue 1155013005: Refactoring the ownership of ui::InputMethod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed. Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/aura/client/aura_constants.h"
6 #include "ui/aura/window.h" 5 #include "ui/aura/window.h"
7 #include "ui/base/ime/dummy_input_method_delegate.h" 6 #include "ui/base/ime/dummy_input_method_delegate.h"
8 #include "ui/base/ime/input_method_minimal.h" 7 #include "ui/base/ime/input_method_minimal.h"
9 #include "ui/base/ime/text_input_client.h" 8 #include "ui/base/ime/text_input_client.h"
10 #include "ui/views/ime/input_method.h" 9 #include "ui/views/ime/input_method.h"
11 #include "ui/views/test/views_test_base.h" 10 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 11 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
13 #include "ui/views/widget/native_widget_aura.h" 12 #include "ui/views/widget/native_widget_aura.h"
14 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
15 14
16 namespace views { 15 namespace views {
17 16
18 typedef ViewsTestBase InputMethodBridgeTest; 17 typedef ViewsTestBase InputMethodBridgeTest;
19 18
20 TEST_F(InputMethodBridgeTest, DestructTest) { 19 TEST_F(InputMethodBridgeTest, DestructTest) {
21 ui::internal::DummyInputMethodDelegate input_method_delegate; 20 ui::internal::DummyInputMethodDelegate input_method_delegate;
22 ui::InputMethodMinimal input_method(&input_method_delegate); 21 ui::InputMethodMinimal input_method(&input_method_delegate);
23 22
24 GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey,
25 static_cast<ui::InputMethod*>(&input_method));
26
27 Widget* toplevel = new Widget; 23 Widget* toplevel = new Widget;
28 Widget::InitParams toplevel_params = 24 Widget::InitParams toplevel_params =
29 CreateParams(Widget::InitParams::TYPE_WINDOW); 25 CreateParams(Widget::InitParams::TYPE_WINDOW);
30 // |child| owns |native_widget|. 26 // |child| owns |native_widget|.
31 toplevel_params.native_widget = new DesktopNativeWidgetAura(toplevel); 27 toplevel_params.native_widget = new DesktopNativeWidgetAura(toplevel);
32 toplevel->Init(toplevel_params); 28 toplevel->Init(toplevel_params);
33 29
34 Widget* child = new Widget; 30 Widget* child = new Widget;
35 Widget::InitParams child_params = 31 Widget::InitParams child_params =
36 CreateParams(Widget::InitParams::TYPE_POPUP); 32 CreateParams(Widget::InitParams::TYPE_POPUP);
37 child_params.parent = toplevel->GetNativeView(); 33 child_params.parent = toplevel->GetNativeView();
38 // |child| owns |native_widget|. 34 // |child| owns |native_widget|.
39 child_params.native_widget = new NativeWidgetAura(child); 35 child_params.native_widget = new NativeWidgetAura(child);
40 child->Init(child_params); 36 child->Init(child_params);
41 37
42 child->GetInputMethod()->OnFocus(); 38 child->GetInputMethod()->OnFocus();
43 39
44 toplevel->CloseNow(); 40 toplevel->CloseNow();
45
46 GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey,
47 static_cast<ui::InputMethod*>(NULL));
48 } 41 }
49 42
50 } // namespace views 43 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698