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
3// found in the LICENSE file.
4
5#include "ui/aura/client/aura_constants.h"
6#include "ui/aura/window.h"
7#include "ui/base/ime/dummy_input_method_delegate.h"
8#include "ui/base/ime/input_method_minimal.h"
9#include "ui/base/ime/text_input_client.h"
10#include "ui/views/ime/input_method.h"
11#include "ui/views/test/views_test_base.h"
12#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
13#include "ui/views/widget/native_widget_aura.h"
14#include "ui/views/widget/widget.h"
15
16namespace views {
17
18typedef ViewsTestBase InputMethodBridgeTest;
19
20TEST_F(InputMethodBridgeTest, DestructTest) {
21  ui::internal::DummyInputMethodDelegate input_method_delegate;
22  ui::InputMethodMinimal input_method(&input_method_delegate);
23
24  GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey,
25                            static_cast<ui::InputMethod*>(&input_method));
26
27  Widget* toplevel = new Widget;
28  Widget::InitParams toplevel_params =
29      CreateParams(Widget::InitParams::TYPE_WINDOW);
30  // |child| owns |native_widget|.
31  toplevel_params.native_widget = new DesktopNativeWidgetAura(toplevel);
32  toplevel->Init(toplevel_params);
33
34  Widget* child = new Widget;
35  Widget::InitParams child_params =
36      CreateParams(Widget::InitParams::TYPE_POPUP);
37  child_params.parent = toplevel->GetNativeView();
38  // |child| owns |native_widget|.
39  child_params.native_widget = new NativeWidgetAura(child);
40  child->Init(child_params);
41
42  child->GetInputMethod()->OnFocus();
43
44  toplevel->CloseNow();
45
46  GetContext()->SetProperty(aura::client::kRootWindowInputMethodKey,
47                            static_cast<ui::InputMethod*>(NULL));
48}
49
50}  // namespace views
51