diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 07:41:01 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 07:41:01 +0000 |
commit | f638242882ecbc6d41c4197ceb77f52adec974d4 (patch) | |
tree | 2759a8d1b5db9ea4c2c010705e137be0f1bdb85e /views/ime | |
parent | bacfde6fe155d165c4e138099660fd36eebc3dca (diff) | |
download | chromium_src-f638242882ecbc6d41c4197ceb77f52adec974d4.zip chromium_src-f638242882ecbc6d41c4197ceb77f52adec974d4.tar.gz chromium_src-f638242882ecbc6d41c4197ceb77f52adec974d4.tar.bz2 |
Add a test to verify that the data in gtkimcontextsimpleseqs.h is correctly ordered
BUG=chromium-os:17307
TEST=views_unittests success
Review URL: http://codereview.chromium.org/7307016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/ime')
-rw-r--r-- | views/ime/character_composer_unittest.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/views/ime/character_composer_unittest.cc b/views/ime/character_composer_unittest.cc index 05dc3c1..ed2b4d1 100644 --- a/views/ime/character_composer_unittest.cc +++ b/views/ime/character_composer_unittest.cc @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/gtk+/gdk/gdkkeysyms.h" +#include "ui/base/gtk/gtk_integers.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, + // 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; + 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 |