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

Side by Side Diff: chromeos/dbus/ibus/ibus_lookup_table_unittest.cc

Issue 10392039: Implement IBusLookupTable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 8 years, 7 months 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/dbus/ibus/ibus_lookup_table.h"
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chromeos/dbus/ibus/ibus_object.h"
14 #include "dbus/message.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace chromeos {
19
20 TEST(IBusLookupTable, WriteReadTest) {
21 const char kSampleText1[] = "Sample Text 1";
22 const char kSampleText2[] = "Sample Text 2";
23 const char kSampleLabel1[] = "Sample Label 1";
24 const char kSampleLabel2[] = "Sample Label 2";
25 const uint32 kPageSize = 11;
26 const uint32 kCursorPosition = 12;
27 const bool kIsCursorVisible = true;
28 const IBusLookupTable::Orientation kOrientation =
29 IBusLookupTable::IBUS_LOOKUP_TABLE_ORIENTATION_VERTICAL;
30
31 // Create IBusLookupTable.
32 IBusLookupTable lookup_table;
33 lookup_table.set_page_size(kPageSize);
34 lookup_table.set_cursor_position(kCursorPosition);
35 lookup_table.set_is_cursor_visible(kIsCursorVisible);
36 lookup_table.set_orientation(kOrientation);
37 std::vector<std::string>* candidates = lookup_table.mutable_candidates();
38 candidates->push_back(kSampleText1);
39 candidates->push_back(kSampleText2);
40 std::vector<std::string>* labels = lookup_table.mutable_labels();
41 labels->push_back(kSampleLabel1);
42 labels->push_back(kSampleLabel2);
43
44 // Write IBusLookupTable.
45 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
46 dbus::MessageWriter writer(response.get());
47 AppendIBusLookupTable(lookup_table, &writer);
48
49 // Read IBusLookupTable.
50 IBusLookupTable target_lookup_table;
51 dbus::MessageReader reader(response.get());
52 PopIBusLookupTable(&reader, &target_lookup_table);
53
54 // Check values.
55 EXPECT_EQ(kPageSize, target_lookup_table.page_size());
56 EXPECT_EQ(kCursorPosition, target_lookup_table.cursor_position());
57 EXPECT_EQ(kIsCursorVisible, target_lookup_table.is_cursor_visible());
58 EXPECT_EQ(kOrientation, target_lookup_table.orientation());
59 EXPECT_EQ(kSampleText1, target_lookup_table.candidates().at(0));
satorux1 2012/05/11 22:55:29 We should ASSERT_EQ(2U, arget_lookup_table.candida
Seigo Nonaka 2012/05/18 17:57:46 Done.
60 EXPECT_EQ(kSampleText2, target_lookup_table.candidates().at(1));
61 EXPECT_EQ(kSampleLabel1, target_lookup_table.labels().at(0));
62 EXPECT_EQ(kSampleLabel2, target_lookup_table.labels().at(1));
63 }
64
65 } // namespace chromeos
OLDNEW
« chromeos/dbus/ibus/ibus_lookup_table.cc ('K') | « chromeos/dbus/ibus/ibus_lookup_table.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698