diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-09 04:51:40 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-09 04:51:40 +0000 |
commit | bf2997f67e598cedd0c28235bfe15764e5d59b2c (patch) | |
tree | 5a587d4a2fff2b54a9d4616806a13aa170d53dcc /chromeos | |
parent | 31c353b75095119fc452e197c517fe3c8384f7db (diff) | |
download | chromium_src-bf2997f67e598cedd0c28235bfe15764e5d59b2c.zip chromium_src-bf2997f67e598cedd0c28235bfe15764e5d59b2c.tar.gz chromium_src-bf2997f67e598cedd0c28235bfe15764e5d59b2c.tar.bz2 |
Moves CandidateWindow model to ui/base/ime.
BUG=325813
R=komatsu@chromium.org
TEST=build passes
Review URL: https://codereview.chromium.org/126363002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/chromeos.gyp | 3 | ||||
-rw-r--r-- | chromeos/ime/candidate_window.cc | 78 | ||||
-rw-r--r-- | chromeos/ime/candidate_window.h | 127 | ||||
-rw-r--r-- | chromeos/ime/candidate_window_unittest.cc | 140 |
4 files changed, 0 insertions, 348 deletions
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index e85f255..14ef3f9 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -210,8 +210,6 @@ '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', @@ -489,7 +487,6 @@ '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 deleted file mode 100644 index 9fb22ea..0000000 --- a/chromeos/ime/candidate_window.cc +++ /dev/null @@ -1,78 +0,0 @@ -// 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 deleted file mode 100644 index d0f5f89..0000000 --- a/chromeos/ime/candidate_window.h +++ /dev/null @@ -1,127 +0,0 @@ -// 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 deleted file mode 100644 index 62166f8..0000000 --- a/chromeos/ime/candidate_window_unittest.cc +++ /dev/null @@ -1,140 +0,0 @@ -// 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 |