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

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

Issue 23875014: Simplify InputMethodBridgeUnitTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary blank line at the end of file Created 7 years, 3 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 | « ui/base/ime/ime.gypi ('k') | 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 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" 5 #include "ui/aura/client/aura_constants.h"
6 #include "ui/aura/window.h" 6 #include "ui/aura/window.h"
7 #include "ui/base/ime/dummy_input_method.h" 7 #include "ui/base/ime/dummy_input_method_delegate.h"
8 #include "ui/base/ime/fake_input_method.h"
8 #include "ui/base/ime/text_input_client.h" 9 #include "ui/base/ime/text_input_client.h"
9 #include "ui/views/ime/input_method.h" 10 #include "ui/views/ime/input_method.h"
10 #include "ui/views/test/views_test_base.h" 11 #include "ui/views/test/views_test_base.h"
11 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 12 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
12 #include "ui/views/widget/native_widget_aura.h" 13 #include "ui/views/widget/native_widget_aura.h"
13 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
14 15
15 namespace views { 16 namespace views {
16 17
17 typedef ViewsTestBase InputMethodBridgeTest; 18 typedef ViewsTestBase InputMethodBridgeTest;
18 19
19 namespace { 20 TEST_F(InputMethodBridgeTest, DestructTest) {
21 ui::internal::DummyInputMethodDelegate input_method_delegate;
22 ui::FakeInputMethod input_method(&input_method_delegate);
20 23
21 class TestInputMethod : public ui::DummyInputMethod {
22 public:
23 TestInputMethod();
24 virtual ~TestInputMethod();
25
26 virtual void SetFocusedTextInputClient(ui::TextInputClient* client) OVERRIDE;
27 virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE;
28
29 private:
30 ui::TextInputClient* text_input_client_;
31
32 DISALLOW_COPY_AND_ASSIGN(TestInputMethod);
33 };
34
35 TestInputMethod::TestInputMethod() : text_input_client_(NULL) {}
36
37 TestInputMethod::~TestInputMethod() {}
38
39 void TestInputMethod::SetFocusedTextInputClient(ui::TextInputClient* client) {
40 // This simulates what the real InputMethod implementation does.
41 if (text_input_client_)
42 text_input_client_->GetTextInputType();
43 text_input_client_ = client;
44 }
45
46 ui::TextInputClient* TestInputMethod::GetTextInputClient() const {
47 return text_input_client_;
48 }
49
50 } // namespace
51
52 TEST_F(InputMethodBridgeTest, DestructTest) {
53 TestInputMethod input_method;
54 GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey, 24 GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey,
55 static_cast<ui::InputMethod*>(&input_method)); 25 static_cast<ui::InputMethod*>(&input_method));
56 26
57 Widget* toplevel = new Widget; 27 Widget* toplevel = new Widget;
58 Widget::InitParams toplevel_params = 28 Widget::InitParams toplevel_params =
59 CreateParams(Widget::InitParams::TYPE_WINDOW); 29 CreateParams(Widget::InitParams::TYPE_WINDOW);
60 // |child| owns |native_widget|. 30 // |child| owns |native_widget|.
61 toplevel_params.native_widget = new DesktopNativeWidgetAura(toplevel); 31 toplevel_params.native_widget = new DesktopNativeWidgetAura(toplevel);
62 toplevel->Init(toplevel_params); 32 toplevel->Init(toplevel_params);
63 33
64 Widget* child = new Widget; 34 Widget* child = new Widget;
65 Widget::InitParams child_params = 35 Widget::InitParams child_params =
66 CreateParams(Widget::InitParams::TYPE_POPUP); 36 CreateParams(Widget::InitParams::TYPE_POPUP);
67 child_params.parent = toplevel->GetNativeView(); 37 child_params.parent = toplevel->GetNativeView();
68 // |child| owns |native_widget|. 38 // |child| owns |native_widget|.
69 child_params.native_widget = new NativeWidgetAura(child); 39 child_params.native_widget = new NativeWidgetAura(child);
70 child->Init(child_params); 40 child->Init(child_params);
71 41
72 child->GetInputMethod()->OnFocus(); 42 child->GetInputMethod()->OnFocus();
73 43
74 toplevel->CloseNow(); 44 toplevel->CloseNow();
75 45
76 GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey, 46 GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey,
77 static_cast<ui::InputMethod*>(NULL)); 47 static_cast<ui::InputMethod*>(NULL));
78 } 48 }
79 49
80 } // namespace views 50 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/ime/ime.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698