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

Unified Diff: extensions/shell/browser/shell_desktop_controller_aura_unittest.cc

Issue 2580733002: AppShell: Create input method and handle key events (Closed)
Patch Set: nits Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/shell/browser/shell_desktop_controller_aura.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
diff --git a/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc b/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
index d83b97757cbd7ec096bb23b658971bfcdc68f9a7..fc38287c7c855d3c3d21f0166d91a6d36bd46142 100644
--- a/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
+++ b/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
@@ -9,8 +9,14 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/time/time.h"
-#include "build/build_config.h"
#include "ui/aura/test/aura_test_base.h"
+#include "ui/base/ime/dummy_text_input_client.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/input_method_factory.h"
+#include "ui/base/ime/input_method_minimal.h"
+#include "ui/events/event.h"
+#include "ui/events/event_dispatcher.h"
+#include "ui/events/keycodes/keyboard_codes.h"
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -19,6 +25,8 @@
namespace extensions {
+// TODO(michaelpg): Why do we use AuraTestBase when ShellDesktopControllerAura
+// already creates a screen and root window host itself?
class ShellDesktopControllerAuraTest : public aura::test::AuraTestBase {
public:
ShellDesktopControllerAuraTest()
@@ -37,6 +45,11 @@ class ShellDesktopControllerAuraTest : public aura::test::AuraTestBase {
dbus_setter->SetPowerManagerClient(base::WrapUnique(power_manager_client_));
#endif
aura::test::AuraTestBase::SetUp();
+
+ // The input method will be used for the next CreateInputMethod call,
+ // causing the host to take ownership.
+ ui::SetUpInputMethodForTesting(new ui::InputMethodMinimal(nullptr));
+
controller_.reset(new ShellDesktopControllerAura());
}
@@ -75,4 +88,29 @@ TEST_F(ShellDesktopControllerAuraTest, PowerButton) {
}
#endif
+// Tests that basic input events are handled and forwarded to the host.
+// TODO(michaelpg): Test other types of input.
+TEST_F(ShellDesktopControllerAuraTest, InputEvents) {
+ ui::InputMethod* input_method = controller_->host_->GetInputMethod();
+ ASSERT_TRUE(input_method);
+
+ // Set up a focused text input to receive the keypress event.
+ ui::DummyTextInputClient client(ui::TEXT_INPUT_TYPE_TEXT);
+ input_method->SetFocusedTextInputClient(&client);
+ EXPECT_EQ(0, client.insert_char_count());
+
+ // Dispatch a keypress on the window tree host to verify it is processed.
+ ui::KeyEvent key_press(base::char16(97), ui::VKEY_A, ui::EF_NONE);
+ ui::EventDispatchDetails details =
+ controller_->host_->dispatcher()->DispatchEvent(
+ controller_->host_->window(), &key_press);
+ EXPECT_FALSE(details.dispatcher_destroyed);
+ EXPECT_FALSE(details.target_destroyed);
+ EXPECT_TRUE(key_press.handled());
+ EXPECT_EQ(1, client.insert_char_count());
+
+ // Clean up.
+ input_method->DetachTextInputClient(&client);
+}
+
} // namespace extensions
« no previous file with comments | « extensions/shell/browser/shell_desktop_controller_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698