summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-09 05:24:22 +0000
committerscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-09 05:24:22 +0000
commit423ef49d445c031cfc6af630a6599c7ef2e1c7e6 (patch)
treebb4ffa128bb7709353017539636d3d1ea4ef9c40 /chromeos
parent4600b62e7fa81e326513f5fe581868721022c976 (diff)
downloadchromium_src-423ef49d445c031cfc6af630a6599c7ef2e1c7e6.zip
chromium_src-423ef49d445c031cfc6af630a6599c7ef2e1c7e6.tar.gz
chromium_src-423ef49d445c031cfc6af630a6599c7ef2e1c7e6.tar.bz2
Revert 243777 "Moves CandidateWindow model to ui/base/ime."
Most CrOS failing similar to this: FAILED: c++ -MMD -MF obj/chrome/browser/chromeos/input_method/test_support_common.mock_input_method_engine.o.d -DV8_DEPRECATION_WARNINGS -D_FILE_OFFSET_BITS=64 -DCHROMIUM_BUILD -DTOOLKIT_VIEWS=1 -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_ASH=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_DEFAULT_RENDER_THEME=1 -DUSE_NSS=1 -DUSE_X11=1 -DOS_CHROMEOS=1 -DUSE_XI2_MT=2 -DFILE_MANAGER_EXTENSION=1 -DIMAGE_LOADER_EXTENSION=1 -DENABLE_REMOTING=1 -DENABLE_WEBRTC=1 -DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_INPUT_SPEECH -DENABLE_NOTIFICATIONS -DENABLE_HIDPI=1 -DUSE_UDEV -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC -DENABLE_EGLIMAGE=1 -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_AUTOMATION=1 -DENABLE_GOOGLE_NOW=1 -DCLD_VERSION=2 -DENABLE_FULL_PRINTING=1 -DENABLE_PRINTING=1 -DENABLE_SPELLCHECK=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_MANAGED_USERS=1 -DENABLE_MDNS=1 -DGL_GLEXT_PROTOTYPES -DLIBPEERCONNECTION_LIB=1 -DUSE_BRLAPI -DGTEST_HAS_POSIX_RE=0 -DNACL_WINDOWS=0 -DNACL_LINUX=1 -DNACL_OSX=0 -DNACL_TARGET_SUBARCH=64 -DNACL_TARGET_ARCH=x86 -DNACL_BUILD_SUBARCH=64 -DNACL_BUILD_ARCH=x86 -DPROTOBUF_USE_DLLS -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DU_USING_ICU_NAMESPACE=0 -DU_STATIC_IMPLEMENTATION -DCHROME_PNG_WRITE_SUPPORT -DPNG_USER_CONFIG -DSK_ENABLE_INST_COUNT=0 -DSK_SUPPORT_GPU=1 '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' -DSK_ENABLE_LEGACY_API_ALIASING=1 -DSK_ATTR_DEPRECATED=SK_NOTHING_ARG1 -DSK_SUPPORT_LEGACY_COLORTYPE=1 -DGR_GL_IGNORE_ES3_MSAA=0 -DSK_SUPPORT_LEGACY_SK64 -DSK_SUPPORT_LEGACY_ONLOCKPIXELS -DSK_USE_POSIX_THREADS -DSK_DEFERRED_CANVAS_USES_FACTORIES=1 -DFEATURE_ENABLE_SSL -DFEATURE_ENABLE_VOICEMAIL -DEXPAT_RELATIVE_PATH -DGTEST_RELATIVE_PATH -DJSONCPP_RELATIVE_PATH -DNO_MAIN_THREAD_WRAPPING -DNO_SOUND_SYSTEM -DLINUX -DPOSIX -DCHROMEOS -DUNIT_TEST -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D_FORTIFY_SOURCE=2 -I../.. -I../../skia/config -I../../third_party/khronos -I../../gpu -I../../third_party/WebKit/Source -Igen -Igen/chrome -Igen/protoc_out -I../../third_party/protobuf -I../../third_party/protobuf/src -I../../third_party/WebKit -I../../third_party/icu/source/common -I../../third_party/npapi -I../../third_party/npapi/bindings -I../../v8/include -I../../third_party/libpng -I../../third_party/libwebp -I../../third_party/ots/include -I../../third_party/qcms/src -I../../third_party/iccjpeg -I../../third_party/libjpeg -I../../third_party/skia/src/core -I../../third_party/skia/include/core -I../../third_party/skia/include/effects -I../../third_party/skia/include/pdf -I../../third_party/skia/include/gpu -I../../third_party/skia/include/lazy -I../../third_party/skia/include/pathops -I../../third_party/skia/include/pipe -I../../third_party/skia/include/ports -I../../third_party/skia/include/utils -I../../skia/ext -I../../third_party/libjingle/overrides -I../../third_party/libjingle/source -I../../testing/gtest/include -I../../third_party -I../../third_party/webrtc -I../../third_party/jsoncpp/overrides/include -I../../third_party/jsoncpp/source/include -I../../third_party/cacheinvalidation/overrides -I../../third_party/cacheinvalidation/src -I../../testing/gmock/include -I../../third_party/zlib -I../../third_party/leveldatabase/src/include -I../../third_party/leveldatabase/src -I../../third_party/leveldatabase -Igen/policy -I../../net/third_party/nss/ssl -Werror -pthread -fno-exceptions -fno-strict-aliasing -Wall -Wno-unused-parameter -Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/nss -I/usr/include/nspr -O2 -fno-ident -fdata-sections -ffunction-sections -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -Wsign-compare -c ../../chrome/browser/chromeos/input_method/mock_input_method_engine.cc -o obj/chrome/browser/chromeos/input_method/test_support_common.mock_input_method_engine.o ../../chrome/browser/chromeos/input_method/mock_input_method_engine.cc:14:43: fatalerror: chromeos/ime/candidate_window.h: No such file or directory compilation terminated. ninja: build stopped: subcommand failed. > Moves CandidateWindow model to ui/base/ime. > > BUG=325813 > R=komatsu@chromium.org > TEST=build passes > > Review URL: https://codereview.chromium.org/126363002 TBR=mukai@chromium.org Review URL: https://codereview.chromium.org/130833002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/chromeos.gyp3
-rw-r--r--chromeos/ime/candidate_window.cc78
-rw-r--r--chromeos/ime/candidate_window.h127
-rw-r--r--chromeos/ime/candidate_window_unittest.cc140
4 files changed, 348 insertions, 0 deletions
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
index 14ef3f9..e85f255 100644
--- a/chromeos/chromeos.gyp
+++ b/chromeos/chromeos.gyp
@@ -210,6 +210,8 @@
'display/output_util.h',
'display/real_output_configurator_delegate.cc',
'display/real_output_configurator_delegate.h',
+ 'ime/candidate_window.cc',
+ 'ime/candidate_window.h',
'ime/component_extension_ime_manager.cc',
'ime/component_extension_ime_manager.h',
'ime/extension_ime_util.cc',
@@ -487,6 +489,7 @@
'disks/disk_mount_manager_unittest.cc',
'display/output_configurator_unittest.cc',
'display/output_util_unittest.cc',
+ 'ime/candidate_window_unittest.cc',
'ime/component_extension_ime_manager_unittest.cc',
'ime/extension_ime_util_unittest.cc',
'ime/ibus_text_unittest.cc',
diff --git a/chromeos/ime/candidate_window.cc b/chromeos/ime/candidate_window.cc
new file mode 100644
index 0000000..9fb22ea
--- /dev/null
+++ b/chromeos/ime/candidate_window.cc
@@ -0,0 +1,78 @@
+// 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/candidate_window.h"
+
+#include <string>
+#include "base/logging.h"
+#include "base/values.h"
+
+namespace chromeos {
+namespace input_method {
+
+namespace {
+// The default entry number of a page in CandidateWindow.
+const int kDefaultPageSize = 9;
+} // namespace
+
+CandidateWindow::CandidateWindow()
+ : property_(new CandidateWindowProperty) {
+}
+
+CandidateWindow::~CandidateWindow() {
+}
+
+bool CandidateWindow::IsEqual(const CandidateWindow& cw) const {
+ if (page_size() != cw.page_size() ||
+ cursor_position() != cw.cursor_position() ||
+ is_cursor_visible() != cw.is_cursor_visible() ||
+ orientation() != cw.orientation() ||
+ show_window_at_composition() != cw.show_window_at_composition() ||
+ is_auxiliary_text_visible() != cw.is_auxiliary_text_visible() ||
+ auxiliary_text() != cw.auxiliary_text() ||
+ candidates_.size() != cw.candidates_.size())
+ return false;
+
+ for (size_t i = 0; i < candidates_.size(); ++i) {
+ const Entry& left = candidates_[i];
+ const Entry& right = cw.candidates_[i];
+ if (left.value != right.value ||
+ left.label != right.label ||
+ left.annotation != right.annotation ||
+ left.description_title != right.description_title ||
+ left.description_body != right.description_body)
+ return false;
+ }
+ return true;
+}
+
+void CandidateWindow::CopyFrom(const CandidateWindow& cw) {
+ SetProperty(cw.GetProperty());
+ candidates_.clear();
+ candidates_ = cw.candidates_;
+}
+
+
+// When the default values are changed, please modify
+// InputMethodEngineInterface::CandidateWindowProperty too.
+CandidateWindow::CandidateWindowProperty::CandidateWindowProperty()
+ : page_size(kDefaultPageSize),
+ cursor_position(0),
+ is_cursor_visible(true),
+ is_vertical(false),
+ show_window_at_composition(false),
+ is_auxiliary_text_visible(false) {
+}
+
+CandidateWindow::CandidateWindowProperty::~CandidateWindowProperty() {
+}
+
+CandidateWindow::Entry::Entry() {
+}
+
+CandidateWindow::Entry::~Entry() {
+}
+
+} // namespace input_method
+} // namespace chromeos
diff --git a/chromeos/ime/candidate_window.h b/chromeos/ime/candidate_window.h
new file mode 100644
index 0000000..d0f5f89
--- /dev/null
+++ b/chromeos/ime/candidate_window.h
@@ -0,0 +1,127 @@
+// 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_CANDIDATE_WINDOW_H_
+#define CHROMEOS_IME_CANDIDATE_WINDOW_H_
+
+#include <string>
+#include <vector>
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "chromeos/chromeos_export.h"
+
+namespace chromeos {
+namespace input_method {
+
+// CandidateWindow represents the structure of candidates generated from IME.
+class CHROMEOS_EXPORT CandidateWindow {
+ public:
+ enum Orientation {
+ HORIZONTAL = 0,
+ VERTICAL = 1,
+ };
+
+ struct CandidateWindowProperty {
+ CandidateWindowProperty();
+ virtual ~CandidateWindowProperty();
+ int page_size;
+ int cursor_position;
+ bool is_cursor_visible;
+ bool is_vertical;
+ bool show_window_at_composition;
+
+ // Auxiliary text is typically displayed in the footer of the candidate
+ // window.
+ std::string auxiliary_text;
+ bool is_auxiliary_text_visible;
+ };
+
+ // Represents a candidate entry.
+ struct Entry {
+ Entry();
+ virtual ~Entry();
+ std::string value;
+ std::string label;
+ std::string annotation;
+ std::string description_title;
+ std::string description_body;
+ };
+
+ CandidateWindow();
+ virtual ~CandidateWindow();
+
+ // Returns true if the given |candidate_window| is equal to myself.
+ bool IsEqual(const CandidateWindow& candidate_window) const;
+
+ // Copies |candidate_window| to myself.
+ void CopyFrom(const CandidateWindow& candidate_window);
+
+ const CandidateWindowProperty& GetProperty() const {
+ return *property_;
+ }
+ void SetProperty(const CandidateWindowProperty& property) {
+ *property_ = property;
+ }
+
+ // Returns the number of candidates in one page.
+ uint32 page_size() const { return property_->page_size; }
+ void set_page_size(uint32 page_size) { property_->page_size = page_size; }
+
+ // Returns the cursor index of the currently selected candidate.
+ uint32 cursor_position() const { return property_->cursor_position; }
+ void set_cursor_position(uint32 cursor_position) {
+ property_->cursor_position = cursor_position;
+ }
+
+ // Returns true if the cursor is visible.
+ bool is_cursor_visible() const { return property_->is_cursor_visible; }
+ void set_is_cursor_visible(bool is_cursor_visible) {
+ property_->is_cursor_visible = is_cursor_visible;
+ }
+
+ // Returns the orientation of the candidate window.
+ Orientation orientation() const {
+ return property_->is_vertical ? VERTICAL : HORIZONTAL;
+ }
+ void set_orientation(Orientation orientation) {
+ property_->is_vertical = (orientation == VERTICAL);
+ }
+
+ // Returns true if the auxiliary text is visible.
+ bool is_auxiliary_text_visible() const {
+ return property_->is_auxiliary_text_visible;
+ }
+ void set_is_auxiliary_text_visible(bool is_auxiliary_text_visible) const {
+ property_->is_auxiliary_text_visible = is_auxiliary_text_visible;
+ }
+
+ // Accessors of auxiliary_text.
+ const std::string& auxiliary_text() const {
+ return property_->auxiliary_text;
+ }
+ void set_auxiliary_text(const std::string& auxiliary_text) const {
+ property_->auxiliary_text = auxiliary_text;
+ }
+
+ const std::vector<Entry>& candidates() const { return candidates_; }
+ std::vector<Entry>* mutable_candidates() { return &candidates_; }
+
+ bool show_window_at_composition() const {
+ return property_->show_window_at_composition;
+ }
+ void set_show_window_at_composition(bool show_window_at_composition) {
+ property_->show_window_at_composition = show_window_at_composition;
+ }
+
+ private:
+ scoped_ptr<CandidateWindowProperty> property_;
+ std::vector<Entry> candidates_;
+
+ DISALLOW_COPY_AND_ASSIGN(CandidateWindow);
+};
+
+} // namespace input_method
+} // namespace chromeos
+
+#endif // CHROMEOS_IME_CANDIDATE_WINDOW_H_
diff --git a/chromeos/ime/candidate_window_unittest.cc b/chromeos/ime/candidate_window_unittest.cc
new file mode 100644
index 0000000..62166f8
--- /dev/null
+++ b/chromeos/ime/candidate_window_unittest.cc
@@ -0,0 +1,140 @@
+// 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/candidate_window.h"
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+namespace input_method {
+
+TEST(CandidateWindow, IsEqualTest) {
+ CandidateWindow cw1;
+ CandidateWindow cw2;
+
+ const char kSampleString1[] = "Sample 1";
+ const char kSampleString2[] = "Sample 2";
+
+ EXPECT_TRUE(cw1.IsEqual(cw2));
+ EXPECT_TRUE(cw2.IsEqual(cw1));
+
+ cw1.set_page_size(1);
+ cw2.set_page_size(2);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw2.set_page_size(1);
+
+ cw1.set_cursor_position(1);
+ cw2.set_cursor_position(2);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw2.set_cursor_position(1);
+
+ cw1.set_is_cursor_visible(true);
+ cw2.set_is_cursor_visible(false);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw2.set_is_cursor_visible(true);
+
+ cw1.set_orientation(CandidateWindow::HORIZONTAL);
+ cw2.set_orientation(CandidateWindow::VERTICAL);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw2.set_orientation(CandidateWindow::HORIZONTAL);
+
+ cw1.set_show_window_at_composition(true);
+ cw2.set_show_window_at_composition(false);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw2.set_show_window_at_composition(true);
+
+ // Check equality for candidates member variable.
+ CandidateWindow::Entry entry1;
+ CandidateWindow::Entry entry2;
+
+ cw1.mutable_candidates()->push_back(entry1);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw2.mutable_candidates()->push_back(entry2);
+ EXPECT_TRUE(cw1.IsEqual(cw2));
+ EXPECT_TRUE(cw2.IsEqual(cw1));
+
+ entry1.value = kSampleString1;
+ entry2.value = kSampleString2;
+ cw1.mutable_candidates()->push_back(entry1);
+ cw2.mutable_candidates()->push_back(entry2);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw1.mutable_candidates()->clear();
+ cw2.mutable_candidates()->clear();
+
+ entry1.label = kSampleString1;
+ entry2.label = kSampleString2;
+ cw1.mutable_candidates()->push_back(entry1);
+ cw2.mutable_candidates()->push_back(entry2);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw1.mutable_candidates()->clear();
+ cw2.mutable_candidates()->clear();
+
+ entry1.annotation = kSampleString1;
+ entry2.annotation = kSampleString2;
+ cw1.mutable_candidates()->push_back(entry1);
+ cw2.mutable_candidates()->push_back(entry2);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw1.mutable_candidates()->clear();
+ cw2.mutable_candidates()->clear();
+
+ entry1.description_title = kSampleString1;
+ entry2.description_title = kSampleString2;
+ cw1.mutable_candidates()->push_back(entry1);
+ cw2.mutable_candidates()->push_back(entry2);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw1.mutable_candidates()->clear();
+ cw2.mutable_candidates()->clear();
+
+ entry1.description_body = kSampleString1;
+ entry2.description_body = kSampleString2;
+ cw1.mutable_candidates()->push_back(entry1);
+ cw2.mutable_candidates()->push_back(entry2);
+ EXPECT_FALSE(cw1.IsEqual(cw2));
+ EXPECT_FALSE(cw2.IsEqual(cw1));
+ cw1.mutable_candidates()->clear();
+ cw2.mutable_candidates()->clear();
+}
+
+TEST(CandidateWindow, CopyFromTest) {
+ CandidateWindow cw1;
+ CandidateWindow cw2;
+
+ const char kSampleString[] = "Sample";
+
+ cw1.set_page_size(1);
+ cw1.set_cursor_position(2);
+ cw1.set_is_cursor_visible(false);
+ cw1.set_orientation(CandidateWindow::HORIZONTAL);
+ cw1.set_show_window_at_composition(false);
+
+ CandidateWindow::Entry entry;
+ entry.value = kSampleString;
+ entry.label = kSampleString;
+ entry.annotation = kSampleString;
+ entry.description_title = kSampleString;
+ entry.description_body = kSampleString;
+ cw1.mutable_candidates()->push_back(entry);
+
+ cw2.CopyFrom(cw1);
+ EXPECT_TRUE(cw1.IsEqual(cw2));
+}
+
+} // namespace input_method
+} // namespace chromeos