Chromium Code Reviews| Index: views/ime/character_composer_unittest.cc |
| diff --git a/views/ime/character_composer_unittest.cc b/views/ime/character_composer_unittest.cc |
| index 05dc3c11618b74f2382f8aa93bf8d679c2e2786b..ee606b31d47d959798f435de791dbe6483825231 100644 |
| --- a/views/ime/character_composer_unittest.cc |
| +++ b/views/ime/character_composer_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "views/ime/character_composer.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/base/gtk/gtk_integers.h" |
|
Yusuke Sato
2011/07/07 06:54:32
alphabetical order.
hashimoto
2011/07/07 07:24:09
Fixed
|
| #include "third_party/gtk+/gdk/gdkkeysyms.h" |
| namespace views { |
| @@ -146,4 +147,50 @@ TEST(CharacterComposerTest, CompositionStateIsClearedAfterReset) { |
| EXPECT_TRUE(character_composer.GetComposedCharacter().empty()); |
| } |
| +// ComposeCheckerWithCompactTable in character_composer.cc is depending on the |
| +// assumption that the data in gtkimcontextsimpleseqs.h is correctly ordered. |
| +TEST(CharacterComposerTest, MainTableIsCorrectlyOrdered) { |
| + // This file is included here intentionally, instead of the top of the file, |
|
Yusuke Sato
2011/07/07 06:54:32
then, can't we fix the generator script? if you ag
hashimoto
2011/07/07 07:24:09
Filed http://crosbug.com/17328
|
| + // because including this file at the top of the file will define a |
| + // global constant and contaminate the global namespace. |
| +#include "third_party/gtk+/gtk/gtkimcontextsimpleseqs.h" |
| + const int index_size = 26; |
|
Yusuke Sato
2011/07/07 06:54:32
wondering why these constants are not in the gener
hashimoto
2011/07/07 07:24:09
Also filed in http://crosbug.com/17328
|
| + const int index_stride = 6; |
| + |
| + // Verify that the index is correctly ordered |
| + for (int i = 1; i < index_size; ++i) { |
| + const int index_key_prev = gtk_compose_seqs_compact[(i - 1)*index_stride]; |
| + const int index_key = gtk_compose_seqs_compact[i*index_stride]; |
| + EXPECT_TRUE(index_key > index_key_prev); |
| + } |
| + |
| + // Verify that the sequenes are correctly ordered |
| + struct { |
| + int operator()(const uint16* l, const uint16* r, int length) const{ |
| + for (int i = 0; i < length; ++i) { |
| + if (l[i] > r[i]) |
| + return 1; |
| + if (l[i] < r[i]) |
| + return -1; |
| + } |
| + return 0; |
| + } |
| + } compare_sequence; |
| + |
| + for (int i = 0; i < index_size; ++i) { |
| + for (int length = 1; length < index_stride - 1; ++length) { |
| + const int index_begin = gtk_compose_seqs_compact[i*index_stride + length]; |
| + const int index_end = |
| + gtk_compose_seqs_compact[i*index_stride + length + 1]; |
| + const int stride = length + 1; |
| + for (int index = index_begin + stride; index < index_end; |
| + index += stride) { |
| + const uint16* sequence = >k_compose_seqs_compact[index]; |
| + const uint16* sequence_prev = sequence - stride; |
| + EXPECT_EQ(compare_sequence(sequence, sequence_prev, length), 1); |
| + } |
| + } |
| + } |
| +} |
| + |
| } // namespace views |