This source file includes following definitions.
- TEST_F
- TEST_F
#include "ui/wm/core/input_method_event_filter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/test/test_event_handler.h"
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/public/activation_client.h"
#if !defined(OS_WIN) && !defined(USE_X11)
#define TestInputMethodKeyEventPropagation \
DISABLED_TestInputMethodKeyEventPropagation
#endif
namespace wm {
typedef aura::test::AuraTestBase InputMethodEventFilterTest;
TEST_F(InputMethodEventFilterTest, TestInputMethodProperty) {
CompoundEventFilter* root_filter = new CompoundEventFilter;
root_window()->SetEventFilter(root_filter);
InputMethodEventFilter input_method_event_filter(
host()->GetAcceleratedWidget());
root_filter->AddHandler(&input_method_event_filter);
EXPECT_TRUE(root_window()->GetProperty(
aura::client::kRootWindowInputMethodKey));
root_filter->RemoveHandler(&input_method_event_filter);
}
TEST_F(InputMethodEventFilterTest, TestInputMethodKeyEventPropagation) {
CompoundEventFilter* root_filter = new CompoundEventFilter;
root_window()->SetEventFilter(root_filter);
InputMethodEventFilter input_method_event_filter(
host()->GetAcceleratedWidget());
root_filter->AddHandler(&input_method_event_filter);
ui::test::TestEventHandler test_filter;
root_filter->AddHandler(&test_filter);
aura::test::TestWindowDelegate test_delegate;
scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
&test_delegate,
-1,
gfx::Rect(),
root_window()));
aura::client::GetActivationClient(root_window())->ActivateWindow(
window.get());
aura::test::EventGenerator generator(root_window());
EXPECT_EQ(0, test_filter.num_key_events());
generator.PressKey(ui::VKEY_SPACE, 0);
EXPECT_EQ(1, test_filter.num_key_events());
generator.ReleaseKey(ui::VKEY_SPACE, 0);
EXPECT_EQ(2, test_filter.num_key_events());
root_filter->RemoveHandler(&input_method_event_filter);
root_filter->RemoveHandler(&test_filter);
window.reset();
}
}