Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chromeos/ime/composition_text_unittest.cc

Issue 727143002: Moves code from chromeos/ime to ui/base/ime/chromeos. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/ime/composition_text.cc ('k') | chromeos/ime/extension_ime_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 // TODO(nona): Add more tests.
5
6 #include "chromeos/ime/composition_text.h"
7
8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace chromeos {
12
13 TEST(CompositionTextTest, CopyTest) {
14 const base::string16 kSampleText = base::UTF8ToUTF16("Sample Text");
15 const CompositionText::UnderlineAttribute kSampleUnderlineAttribute1 = {
16 CompositionText::COMPOSITION_TEXT_UNDERLINE_SINGLE, 10, 20};
17
18 const CompositionText::UnderlineAttribute kSampleUnderlineAttribute2 = {
19 CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE, 11, 21};
20
21 const CompositionText::UnderlineAttribute kSampleUnderlineAttribute3 = {
22 CompositionText::COMPOSITION_TEXT_UNDERLINE_ERROR, 12, 22};
23
24 // Make CompositionText
25 CompositionText text;
26 text.set_text(kSampleText);
27 std::vector<CompositionText::UnderlineAttribute>* underline_attributes =
28 text.mutable_underline_attributes();
29 underline_attributes->push_back(kSampleUnderlineAttribute1);
30 underline_attributes->push_back(kSampleUnderlineAttribute2);
31 underline_attributes->push_back(kSampleUnderlineAttribute3);
32 text.set_selection_start(30);
33 text.set_selection_end(40);
34
35 CompositionText text2;
36 text2.CopyFrom(text);
37
38 EXPECT_EQ(text.text(), text2.text());
39 EXPECT_EQ(text.underline_attributes().size(),
40 text2.underline_attributes().size());
41 for (size_t i = 0; i < text.underline_attributes().size(); ++i) {
42 EXPECT_EQ(text.underline_attributes()[i].type,
43 text2.underline_attributes()[i].type);
44 EXPECT_EQ(text.underline_attributes()[i].start_index,
45 text2.underline_attributes()[i].start_index);
46 EXPECT_EQ(text.underline_attributes()[i].end_index,
47 text2.underline_attributes()[i].end_index);
48 }
49
50 EXPECT_EQ(text.selection_start(), text2.selection_start());
51 EXPECT_EQ(text.selection_end(), text2.selection_end());
52 }
53
54 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/ime/composition_text.cc ('k') | chromeos/ime/extension_ime_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698