Chromium Code Reviews| Index: chromeos/ime/ibus_text_unittest.cc |
| diff --git a/chromeos/ime/ibus_text_unittest.cc b/chromeos/ime/ibus_text_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a2a143e1f5a87635a8187d55adcc2eec13dd9f08 |
| --- /dev/null |
| +++ b/chromeos/ime/ibus_text_unittest.cc |
| @@ -0,0 +1,78 @@ |
| +// 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. |
| +// TODO(nona): Add more tests. |
| + |
| +#include "chromeos/ime/ibus_text.h" |
| + |
| +#include <string> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
|
Seigo Nonaka
2013/11/13 14:09:52
Seems no longer using gmock.
Hiro Komatsu
2013/11/14 02:55:01
Done.
|
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace chromeos { |
| + |
| +TEST(IBusTextTest, WriteReadTest) { |
|
Seigo Nonaka
2013/11/13 14:09:52
This is not your fault but seems "CopyTest" is app
Hiro Komatsu
2013/11/14 02:55:01
Done.
|
| + 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 |