Commit 5bd3615f authored by nona@chromium.org's avatar nona@chromium.org

Remove operator function.

To making InputMethodDescriptor simple, let me remove operators.
Also remove operator related tests because operator had been used only in tests.

BUG=None
TEST=ran all unit_tests.

Review URL: https://codereview.chromium.org/14123005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195408 0039d316-1c4b-4281-b951-d872f2087c98
parent ebc60b7e
...@@ -31,6 +31,16 @@ namespace chromeos { ...@@ -31,6 +31,16 @@ namespace chromeos {
namespace input_method { namespace input_method {
namespace { namespace {
// Returns true if |descriptors| contain |target|.
bool Contain(const InputMethodDescriptors& descriptors,
const InputMethodDescriptor& target) {
for (size_t i = 0; i < descriptors.size(); ++i) {
if (descriptors[i].id() == target.id())
return true;
}
return false;
}
class InputMethodManagerImplTest : public testing::Test { class InputMethodManagerImplTest : public testing::Test {
public: public:
InputMethodManagerImplTest() InputMethodManagerImplTest()
...@@ -244,22 +254,18 @@ TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { ...@@ -244,22 +254,18 @@ TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) {
// correct. // correct.
const InputMethodDescriptor* id_to_find = const InputMethodDescriptor* id_to_find =
manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId("mozc"); manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId("mozc");
EXPECT_NE(methods->end(),
std::find(methods->begin(), methods->end(), *id_to_find));
id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
"mozc-chewing"); "mozc-chewing");
EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
"xkb:us::eng"); "xkb:us::eng");
EXPECT_NE(methods->end(), EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
std::find(methods->begin(), methods->end(), *id_to_find));
id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
"xkb:us:dvorak:eng"); "xkb:us:dvorak:eng");
EXPECT_NE(methods->end(), EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
std::find(methods->begin(), methods->end(), *id_to_find));
id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
"xkb:fr::fra"); "xkb:fr::fra");
EXPECT_NE(methods->end(), EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
std::find(methods->begin(), methods->end(), *id_to_find));
} }
TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { TEST_F(InputMethodManagerImplTest, TestEnableLayouts) {
...@@ -275,8 +281,7 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { ...@@ -275,8 +281,7 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayouts) {
const InputMethodDescriptor* id_to_find = const InputMethodDescriptor* id_to_find =
manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
"english-m"); // The "English Mystery" IME. "english-m"); // The "English Mystery" IME.
EXPECT_EQ(methods->end(), EXPECT_FALSE(Contain(*methods.get(), *id_to_find));
std::find(methods->begin(), methods->end(), *id_to_find));
} }
// For http://crbug.com/19655#c11 - (2) // For http://crbug.com/19655#c11 - (2)
EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count());
...@@ -310,12 +315,10 @@ TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { ...@@ -310,12 +315,10 @@ TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) {
const InputMethodDescriptor* id_to_find = const InputMethodDescriptor* id_to_find =
manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
"xkb:us::eng"); "xkb:us::eng");
EXPECT_NE(methods->end(), EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
std::find(methods->begin(), methods->end(), *id_to_find));
id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId(
"xkb:kr:kr104:kor"); "xkb:kr:kr104:kor");
EXPECT_NE(methods->end(), EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
std::find(methods->begin(), methods->end(), *id_to_find));
} }
TEST_F(InputMethodManagerImplTest, TestSetInputMethodConfig) { TEST_F(InputMethodManagerImplTest, TestSetInputMethodConfig) {
......
...@@ -452,7 +452,6 @@ ...@@ -452,7 +452,6 @@
'disks/disk_mount_manager_unittest.cc', 'disks/disk_mount_manager_unittest.cc',
'ime/component_extension_ime_manager_unittest.cc', 'ime/component_extension_ime_manager_unittest.cc',
'ime/extension_ime_util_unittest.cc', 'ime/extension_ime_util_unittest.cc',
'ime/input_method_descriptor_unittest.cc',
'ime/input_method_property_unittest.cc', 'ime/input_method_property_unittest.cc',
'ime/input_method_whitelist_unittest.cc', 'ime/input_method_whitelist_unittest.cc',
'ime/xkeyboard_unittest.cc', 'ime/xkeyboard_unittest.cc',
......
...@@ -31,15 +31,5 @@ InputMethodDescriptor::InputMethodDescriptor() { ...@@ -31,15 +31,5 @@ InputMethodDescriptor::InputMethodDescriptor() {
InputMethodDescriptor::~InputMethodDescriptor() { InputMethodDescriptor::~InputMethodDescriptor() {
} }
bool InputMethodDescriptor::operator==(
const InputMethodDescriptor& other) const {
return id() == other.id();
}
bool InputMethodDescriptor::operator!=(
const InputMethodDescriptor& other) const {
return !(*this == other);
}
} // namespace input_method } // namespace input_method
} // namespace chromeos } // namespace chromeos
...@@ -27,9 +27,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor { ...@@ -27,9 +27,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor {
const std::string& options_page_url); const std::string& options_page_url);
~InputMethodDescriptor(); ~InputMethodDescriptor();
bool operator==(const InputMethodDescriptor& other) const;
bool operator!=(const InputMethodDescriptor& other) const;
const std::string& id() const { return id_; } const std::string& id() const { return id_; }
const std::string& name() const { return name_; } const std::string& name() const { return name_; }
const std::string& keyboard_layout() const { return keyboard_layout_; } const std::string& keyboard_layout() const { return keyboard_layout_; }
......
// Copyright (c) 2012 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 "base/logging.h"
#include "chromeos/ime/input_method_descriptor.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace input_method {
namespace {
const char kFallbackLayout[] = "us";
class InputMethodDescriptorTest : public testing::Test {
public:
InputMethodDescriptorTest() {
}
protected:
InputMethodDescriptor GetDescById(const std::string& id) {
return InputMethodDescriptor(id,
"", // name
"us",
"language_code",
"");
}
};
} // namespace
TEST_F(InputMethodDescriptorTest, TestOperatorEqual) {
EXPECT_EQ(GetDescById("xkb:us::eng"), GetDescById("xkb:us::eng"));
EXPECT_NE(GetDescById("xkb:us::eng"), GetDescById("xkb:us:dvorak:eng"));
EXPECT_NE(GetDescById("xkb:fr::fra"), GetDescById("xkb:us::eng"));
}
} // namespace input_method
} // namespace chromeos
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment