summaryrefslogtreecommitdiffstats
path: root/chromeos/ime
diff options
context:
space:
mode:
authorkomatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 12:58:21 +0000
committerkomatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 12:58:21 +0000
commit35adb3f605b817a4e8b8448826d7f5137298a5cc (patch)
tree80221ddfe3b9d40c8d448482951b6a9a86000f8c /chromeos/ime
parent6f6a49447982e0dc1484b2dd983cbcfb50322582 (diff)
downloadchromium_src-35adb3f605b817a4e8b8448826d7f5137298a5cc.zip
chromium_src-35adb3f605b817a4e8b8448826d7f5137298a5cc.tar.gz
chromium_src-35adb3f605b817a4e8b8448826d7f5137298a5cc.tar.bz2
Delete ibus_object and move ibus_text to chromeos/ime.
This patch focuses on the deletion and relocation keeping the logic as-is. BUG=275262 Review URL: https://codereview.chromium.org/61003004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/ime')
-rw-r--r--chromeos/ime/ibus_text.cc22
-rw-r--r--chromeos/ime/ibus_text.h86
-rw-r--r--chromeos/ime/ibus_text_unittest.cc72
-rw-r--r--chromeos/ime/mock_ime_input_context_handler.cc2
-rw-r--r--chromeos/ime/mock_ime_input_context_handler.h2
5 files changed, 182 insertions, 2 deletions
diff --git a/chromeos/ime/ibus_text.cc b/chromeos/ime/ibus_text.cc
new file mode 100644
index 0000000..ffdbfaf
--- /dev/null
+++ b/chromeos/ime/ibus_text.cc
@@ -0,0 +1,22 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromeos/ime/ibus_text.h"
+
+namespace chromeos {
+
+IBusText::IBusText() {}
+
+IBusText::~IBusText() {}
+
+void IBusText::CopyFrom(const IBusText& obj) {
+ text_ = obj.text();
+ annotation_ = obj.annotation();
+ description_title_ = obj.description_title();
+ description_body_ = obj.description_body();
+ underline_attributes_ = obj.underline_attributes();
+ selection_attributes_ = obj.selection_attributes();
+}
+
+} // namespace chromeos
diff --git a/chromeos/ime/ibus_text.h b/chromeos/ime/ibus_text.h
new file mode 100644
index 0000000..8d98a16
--- /dev/null
+++ b/chromeos/ime/ibus_text.h
@@ -0,0 +1,86 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_IME_IBUS_TEXT_H_
+#define CHROMEOS_IME_IBUS_TEXT_H_
+
+#include <string>
+#include <vector>
+#include "base/basictypes.h"
+#include "chromeos/chromeos_export.h"
+
+namespace chromeos {
+
+class CHROMEOS_EXPORT IBusText {
+ public:
+ enum IBusTextUnderlineType {
+ IBUS_TEXT_UNDERLINE_SINGLE = 1,
+ IBUS_TEXT_UNDERLINE_DOUBLE = 2,
+ IBUS_TEXT_UNDERLINE_ERROR = 4,
+ };
+
+ struct UnderlineAttribute {
+ IBusTextUnderlineType type;
+ uint32 start_index; // The inclusive start index.
+ uint32 end_index; // The exclusive end index.
+ };
+
+ struct SelectionAttribute {
+ uint32 start_index; // The inclusive start index.
+ uint32 end_index; // The exclusive end index.
+ };
+
+ // Accessors
+ IBusText();
+ virtual ~IBusText();
+
+ const std::string& text() const { return text_; }
+ void set_text(const std::string& text) { text_ = text; }
+
+ const std::string& annotation() const { return annotation_; }
+ void set_annotation(const std::string& annotation) {
+ annotation_ = annotation;
+ }
+
+ const std::string& description_title() const { return description_title_; }
+ void set_description_title(const std::string& title) {
+ description_title_ = title;
+ }
+
+ const std::string& description_body() const { return description_body_; }
+ void set_description_body(const std::string& body) {
+ description_body_ = body;
+ }
+
+ const std::vector<UnderlineAttribute>& underline_attributes() const {
+ return underline_attributes_;
+ }
+
+ std::vector<UnderlineAttribute>* mutable_underline_attributes() {
+ return &underline_attributes_;
+ }
+
+ const std::vector<SelectionAttribute>& selection_attributes() const {
+ return selection_attributes_;
+ }
+ std::vector<SelectionAttribute>* mutable_selection_attributes() {
+ return &selection_attributes_;
+ }
+
+ void CopyFrom(const IBusText& obj);
+
+ private:
+ std::string text_;
+ std::string annotation_;
+ std::string description_title_;
+ std::string description_body_;
+ std::vector<UnderlineAttribute> underline_attributes_;
+ std::vector<SelectionAttribute> selection_attributes_;
+
+ DISALLOW_COPY_AND_ASSIGN(IBusText);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_IME_IBUS_TEXT_H_
diff --git a/chromeos/ime/ibus_text_unittest.cc b/chromeos/ime/ibus_text_unittest.cc
new file mode 100644
index 0000000..bcbd639
--- /dev/null
+++ b/chromeos/ime/ibus_text_unittest.cc
@@ -0,0 +1,72 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+// TODO(nona): Add more tests.
+
+#include "chromeos/ime/ibus_text.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+
+TEST(IBusTextTest, CopyTest) {
+ const char kSampleText[] = "Sample Text";
+ const char kAnnotation[] = "Annotation";
+ const char kDescriptionTitle[] = "Description Title";
+ const char kDescriptionBody[] = "Description Body";
+ const IBusText::UnderlineAttribute kSampleUnderlineAttribute1 = {
+ IBusText::IBUS_TEXT_UNDERLINE_SINGLE, 10, 20};
+
+ const IBusText::UnderlineAttribute kSampleUnderlineAttribute2 = {
+ IBusText::IBUS_TEXT_UNDERLINE_DOUBLE, 11, 21};
+
+ const IBusText::UnderlineAttribute kSampleUnderlineAttribute3 = {
+ IBusText::IBUS_TEXT_UNDERLINE_ERROR, 12, 22};
+
+ const IBusText::SelectionAttribute kSampleSelectionAttribute = {30, 40};
+
+ // Make IBusText
+ IBusText text;
+ text.set_text(kSampleText);
+ text.set_annotation(kAnnotation);
+ text.set_description_title(kDescriptionTitle);
+ text.set_description_body(kDescriptionBody);
+ std::vector<IBusText::UnderlineAttribute>* underline_attributes =
+ text.mutable_underline_attributes();
+ underline_attributes->push_back(kSampleUnderlineAttribute1);
+ underline_attributes->push_back(kSampleUnderlineAttribute2);
+ underline_attributes->push_back(kSampleUnderlineAttribute3);
+ std::vector<IBusText::SelectionAttribute>* selection_attributes =
+ text.mutable_selection_attributes();
+ selection_attributes->push_back(kSampleSelectionAttribute);
+
+ IBusText text2;
+ text2.CopyFrom(text);
+
+ EXPECT_EQ(text.text(), text2.text());
+ EXPECT_EQ(text.annotation(), text2.annotation());
+ EXPECT_EQ(text.description_title(), text2.description_title());
+ EXPECT_EQ(text.description_body(), text2.description_body());
+
+ EXPECT_EQ(text.underline_attributes().size(),
+ text2.underline_attributes().size());
+ for (size_t i = 0; i < text.underline_attributes().size(); ++i) {
+ EXPECT_EQ(text.underline_attributes()[i].type,
+ text2.underline_attributes()[i].type);
+ EXPECT_EQ(text.underline_attributes()[i].start_index,
+ text2.underline_attributes()[i].start_index);
+ EXPECT_EQ(text.underline_attributes()[i].end_index,
+ text2.underline_attributes()[i].end_index);
+ }
+
+ EXPECT_EQ(text.selection_attributes().size(),
+ text2.selection_attributes().size());
+ for (size_t i = 0; i < text.selection_attributes().size(); ++i) {
+ EXPECT_EQ(text.selection_attributes()[i].start_index,
+ text2.selection_attributes()[i].start_index);
+ EXPECT_EQ(text.selection_attributes()[i].end_index,
+ text2.selection_attributes()[i].end_index);
+ }
+}
+
+} // namespace chromeos
diff --git a/chromeos/ime/mock_ime_input_context_handler.cc b/chromeos/ime/mock_ime_input_context_handler.cc
index 135e0f6..43f1c7c 100644
--- a/chromeos/ime/mock_ime_input_context_handler.cc
+++ b/chromeos/ime/mock_ime_input_context_handler.cc
@@ -4,7 +4,7 @@
#include "chromeos/ime/mock_ime_input_context_handler.h"
-#include "chromeos/dbus/ibus/ibus_text.h"
+#include "chromeos/ime/ibus_text.h"
namespace chromeos {
diff --git a/chromeos/ime/mock_ime_input_context_handler.h b/chromeos/ime/mock_ime_input_context_handler.h
index 6d5630a..bb4a34d 100644
--- a/chromeos/ime/mock_ime_input_context_handler.h
+++ b/chromeos/ime/mock_ime_input_context_handler.h
@@ -5,8 +5,8 @@
#ifndef CHROMEOS_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_
#define CHROMEOS_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_
-#include "chromeos/dbus/ibus/ibus_text.h"
#include "chromeos/ime/ibus_bridge.h"
+#include "chromeos/ime/ibus_text.h"
namespace chromeos {