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

Unified Diff: components/arc/ime/arc_ime_bridge_unittest.cc

Issue 1605273002: ARC: Show virtual keyboard when necessary on text input type change events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Filed BUG and added a TODO comment. Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/ime/arc_ime_bridge.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/ime/arc_ime_bridge_unittest.cc
diff --git a/components/arc/ime/arc_ime_bridge_unittest.cc b/components/arc/ime/arc_ime_bridge_unittest.cc
index 06775260d7927d0f00fc7466268edd8e469132c4..bddb887d834573039db1e1317c59dc1a0920c02f 100644
--- a/components/arc/ime/arc_ime_bridge_unittest.cc
+++ b/components/arc/ime/arc_ime_bridge_unittest.cc
@@ -11,6 +11,7 @@
#include "components/arc/test/fake_arc_bridge_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ime/composition_text.h"
+#include "ui/base/ime/dummy_input_method.h"
namespace arc {
@@ -26,6 +27,31 @@ class FakeArcImeIpcHost : public ArcImeIpcHost {
}
};
+class FakeInputMethod : public ui::DummyInputMethod {
+ public:
+ FakeInputMethod() : client_(nullptr), count_show_ime_if_needed_(0) {}
+
+ void SetFocusedTextInputClient(ui::TextInputClient* client) override {
+ client_ = client;
+ }
+
+ ui::TextInputClient* GetTextInputClient() const override {
+ return client_;
+ }
+
+ void ShowImeIfNeeded() override {
+ count_show_ime_if_needed_++;
+ }
+
+ int count_show_ime_if_needed() const {
+ return count_show_ime_if_needed_;
+ }
+
+ private:
+ ui::TextInputClient* client_;
+ int count_show_ime_if_needed_;
+};
+
} // namespace
class ArcImeBridgeTest : public testing::Test {
@@ -34,6 +60,7 @@ class ArcImeBridgeTest : public testing::Test {
protected:
scoped_ptr<FakeArcBridgeService> fake_arc_bridge_service_;
+ scoped_ptr<FakeInputMethod> fake_input_method_;
scoped_ptr<ArcImeBridge> instance_;
private:
@@ -41,6 +68,9 @@ class ArcImeBridgeTest : public testing::Test {
fake_arc_bridge_service_.reset(new FakeArcBridgeService);
instance_.reset(new ArcImeBridge(fake_arc_bridge_service_.get()));
instance_->SetIpcHostForTesting(make_scoped_ptr(new FakeArcImeIpcHost));
+
+ fake_input_method_.reset(new FakeInputMethod);
+ instance_->SetInputMethodForTesting(fake_input_method_.get());
}
void TearDown() override {
@@ -76,4 +106,24 @@ TEST_F(ArcImeBridgeTest, HasCompositionText) {
EXPECT_FALSE(instance_->HasCompositionText());
}
+TEST_F(ArcImeBridgeTest, ShowImeIfNeeded) {
+ fake_input_method_->SetFocusedTextInputClient(instance_.get());
+ instance_->OnTextInputTypeChanged(ui::TEXT_INPUT_TYPE_NONE);
+ ASSERT_EQ(0, fake_input_method_->count_show_ime_if_needed());
+
+ instance_->OnTextInputTypeChanged(ui::TEXT_INPUT_TYPE_TEXT);
+ EXPECT_EQ(1, fake_input_method_->count_show_ime_if_needed());
+
+ // The type is not changing, hence no call.
+ instance_->OnTextInputTypeChanged(ui::TEXT_INPUT_TYPE_TEXT);
+ EXPECT_EQ(1, fake_input_method_->count_show_ime_if_needed());
+
+ instance_->OnTextInputTypeChanged(ui::TEXT_INPUT_TYPE_SEARCH);
+ EXPECT_EQ(2, fake_input_method_->count_show_ime_if_needed());
+
+ // Change to NONE should not trigger the showing event.
+ instance_->OnTextInputTypeChanged(ui::TEXT_INPUT_TYPE_NONE);
+ EXPECT_EQ(2, fake_input_method_->count_show_ime_if_needed());
+}
+
} // namespace arc
« no previous file with comments | « components/arc/ime/arc_ime_bridge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698