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

Side by Side Diff: ui/base/ime/chromeos/character_composer_unittest.cc

Issue 324903002: Remoes X11 dependency in InputMethodEngine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits. Created 6 years, 6 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
« no previous file with comments | « ui/base/ime/chromeos/character_composer.cc ('k') | ui/base/ime/chromeos/ime_keymap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/ime/chromeos/character_composer.h" 5 #include "ui/base/ime/chromeos/character_composer.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/gtk+/gdk/gdkkeysyms.h" 9 #include "third_party/gtk+/gdk/gdkkeysyms.h"
10 #include "ui/base/glib/glib_integers.h" 10 #include "ui/base/glib/glib_integers.h"
11 #include "ui/events/event_constants.h" 11 #include "ui/events/event_constants.h"
12 #include "ui/events/keycodes/keyboard_codes.h"
12 13
13 using base::ASCIIToUTF16; 14 using base::ASCIIToUTF16;
14 15
15 namespace ui { 16 namespace ui {
16 17
17 class CharacterComposerTest : public testing::Test { 18 class CharacterComposerTest : public testing::Test {
18 protected: 19 protected:
19 bool FilterKeyPress(CharacterComposer* character_composer, 20 bool FilterKeyPress(CharacterComposer* character_composer,
20 uint key, 21 uint key,
21 uint keycode, 22 uint keycode,
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 ExpectKeyNotFiltered(&character_composer, GDK_KEY_3, 0); 420 ExpectKeyNotFiltered(&character_composer, GDK_KEY_3, 0);
420 } 421 }
421 422
422 TEST_F(CharacterComposerTest, HexadecimalCompositionPreeditWithModifierPressed) 423 TEST_F(CharacterComposerTest, HexadecimalCompositionPreeditWithModifierPressed)
423 { 424 {
424 // This test case supposes X Window System uses 101 keyboard layout. 425 // This test case supposes X Window System uses 101 keyboard layout.
425 CharacterComposer character_composer; 426 CharacterComposer character_composer;
426 const int control_shift = EF_CONTROL_DOWN | EF_SHIFT_DOWN; 427 const int control_shift = EF_CONTROL_DOWN | EF_SHIFT_DOWN;
427 // HIRAGANA LETTER A (U+3042) 428 // HIRAGANA LETTER A (U+3042)
428 ExpectKeyFilteredWithKeycode(&character_composer, 429 ExpectKeyFilteredWithKeycode(&character_composer,
429 GDK_KEY_U, 30, control_shift); 430 GDK_KEY_U, ui::VKEY_U, control_shift);
430 EXPECT_EQ(ASCIIToUTF16("u"), character_composer.preedit_string()); 431 EXPECT_EQ(ASCIIToUTF16("u"), character_composer.preedit_string());
431 ExpectKeyFilteredWithKeycode(&character_composer, 432 ExpectKeyFilteredWithKeycode(&character_composer,
432 GDK_KEY_numbersign, 12, control_shift); 433 GDK_KEY_numbersign, ui::VKEY_3, control_shift);
433 EXPECT_EQ(ASCIIToUTF16("u3"), character_composer.preedit_string()); 434 EXPECT_EQ(ASCIIToUTF16("u3"), character_composer.preedit_string());
434 ExpectKeyFilteredWithKeycode(&character_composer, 435 ExpectKeyFilteredWithKeycode(&character_composer,
435 GDK_KEY_parenright, 19, control_shift); 436 GDK_KEY_parenright, ui::VKEY_0, control_shift);
436 EXPECT_EQ(ASCIIToUTF16("u30"), character_composer.preedit_string()); 437 EXPECT_EQ(ASCIIToUTF16("u30"), character_composer.preedit_string());
437 ExpectKeyFilteredWithKeycode(&character_composer, 438 ExpectKeyFilteredWithKeycode(&character_composer,
438 GDK_KEY_dollar, 13, control_shift); 439 GDK_KEY_dollar, ui::VKEY_4, control_shift);
439 EXPECT_EQ(ASCIIToUTF16("u304"), character_composer.preedit_string()); 440 EXPECT_EQ(ASCIIToUTF16("u304"), character_composer.preedit_string());
440 ExpectKeyFilteredWithKeycode(&character_composer, 441 ExpectKeyFilteredWithKeycode(&character_composer,
441 GDK_KEY_A, 38, control_shift); 442 GDK_KEY_A, ui::VKEY_A, control_shift);
442 EXPECT_EQ(ASCIIToUTF16("u304a"), character_composer.preedit_string()); 443 EXPECT_EQ(ASCIIToUTF16("u304a"), character_composer.preedit_string());
443 ExpectKeyFilteredWithKeycode(&character_composer, 444 ExpectKeyFilteredWithKeycode(&character_composer,
444 GDK_KEY_BackSpace, 22, control_shift); 445 GDK_KEY_BackSpace, ui::VKEY_BACK, control_shift);
445 EXPECT_EQ(ASCIIToUTF16("u304"), character_composer.preedit_string()); 446 EXPECT_EQ(ASCIIToUTF16("u304"), character_composer.preedit_string());
446 ExpectKeyFilteredWithKeycode(&character_composer, 447 ExpectKeyFilteredWithKeycode(&character_composer,
447 GDK_KEY_at, 11, control_shift); 448 GDK_KEY_at, ui::VKEY_2, control_shift);
448 EXPECT_EQ(ASCIIToUTF16("u3042"), character_composer.preedit_string()); 449 EXPECT_EQ(ASCIIToUTF16("u3042"), character_composer.preedit_string());
449 ExpectCharacterComposedWithKeyCode(&character_composer, 450 ExpectCharacterComposedWithKeyCode(&character_composer,
450 GDK_KEY_Return, 36, 451 GDK_KEY_Return, ui::VKEY_RETURN,
451 control_shift, 452 control_shift,
452 base::string16(1, 0x3042)); 453 base::string16(1, 0x3042));
453 EXPECT_EQ(ASCIIToUTF16(""), character_composer.preedit_string()); 454 EXPECT_EQ(ASCIIToUTF16(""), character_composer.preedit_string());
454 455
455 // Sequence with an ignored character (control + shift + 'x') and Escape. 456 // Sequence with an ignored character (control + shift + 'x') and Escape.
456 ExpectKeyFilteredWithKeycode(&character_composer, 457 ExpectKeyFilteredWithKeycode(&character_composer,
457 GDK_KEY_U, 30, control_shift); 458 GDK_KEY_U, ui::VKEY_U, control_shift);
458 EXPECT_EQ(ASCIIToUTF16("u"), character_composer.preedit_string()); 459 EXPECT_EQ(ASCIIToUTF16("u"), character_composer.preedit_string());
459 ExpectKeyFilteredWithKeycode(&character_composer, 460 ExpectKeyFilteredWithKeycode(&character_composer,
460 GDK_KEY_numbersign, 12, control_shift); 461 GDK_KEY_numbersign, ui::VKEY_3, control_shift);
461 EXPECT_EQ(ASCIIToUTF16("u3"), character_composer.preedit_string()); 462 EXPECT_EQ(ASCIIToUTF16("u3"), character_composer.preedit_string());
462 ExpectKeyFilteredWithKeycode(&character_composer, 463 ExpectKeyFilteredWithKeycode(&character_composer,
463 GDK_KEY_parenright, 19, control_shift); 464 GDK_KEY_parenright, ui::VKEY_0, control_shift);
464 EXPECT_EQ(ASCIIToUTF16("u30"), character_composer.preedit_string()); 465 EXPECT_EQ(ASCIIToUTF16("u30"), character_composer.preedit_string());
465 ExpectKeyFilteredWithKeycode(&character_composer, 466 ExpectKeyFilteredWithKeycode(&character_composer,
466 GDK_KEY_X, 53, control_shift); 467 GDK_KEY_X, ui::VKEY_X, control_shift);
467 EXPECT_EQ(ASCIIToUTF16("u30"), character_composer.preedit_string()); 468 EXPECT_EQ(ASCIIToUTF16("u30"), character_composer.preedit_string());
468 ExpectKeyFilteredWithKeycode(&character_composer, 469 ExpectKeyFilteredWithKeycode(&character_composer,
469 GDK_KEY_dollar, 13, control_shift); 470 GDK_KEY_dollar, ui::VKEY_4, control_shift);
470 EXPECT_EQ(ASCIIToUTF16("u304"), character_composer.preedit_string()); 471 EXPECT_EQ(ASCIIToUTF16("u304"), character_composer.preedit_string());
471 ExpectKeyFilteredWithKeycode(&character_composer, 472 ExpectKeyFilteredWithKeycode(&character_composer,
472 GDK_KEY_at, 11, control_shift); 473 GDK_KEY_at, ui::VKEY_2, control_shift);
473 EXPECT_EQ(ASCIIToUTF16("u3042"), character_composer.preedit_string()); 474 EXPECT_EQ(ASCIIToUTF16("u3042"), character_composer.preedit_string());
474 ExpectKeyFilteredWithKeycode(&character_composer, 475 ExpectKeyFilteredWithKeycode(&character_composer,
475 GDK_KEY_Escape, 9, control_shift); 476 GDK_KEY_Escape, ui::VKEY_ESCAPE, control_shift);
476 EXPECT_EQ(ASCIIToUTF16(""), character_composer.preedit_string()); 477 EXPECT_EQ(ASCIIToUTF16(""), character_composer.preedit_string());
477 } 478 }
478 479
479 TEST_F(CharacterComposerTest, InvalidHexadecimalSequence) { 480 TEST_F(CharacterComposerTest, InvalidHexadecimalSequence) {
480 CharacterComposer character_composer; 481 CharacterComposer character_composer;
481 // U+FFFFFFFF 482 // U+FFFFFFFF
482 ExpectKeyFiltered(&character_composer, GDK_KEY_U, 483 ExpectKeyFiltered(&character_composer, GDK_KEY_U,
483 EF_SHIFT_DOWN | EF_CONTROL_DOWN); 484 EF_SHIFT_DOWN | EF_CONTROL_DOWN);
484 for (int i = 0; i < 8; ++i) 485 for (int i = 0; i < 8; ++i)
485 ExpectKeyFiltered(&character_composer, GDK_KEY_f, 0); 486 ExpectKeyFiltered(&character_composer, GDK_KEY_f, 0);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 533
533 TEST_F(CharacterComposerTest, BlacklistedKeyeventsTest) { 534 TEST_F(CharacterComposerTest, BlacklistedKeyeventsTest) {
534 CharacterComposer character_composer; 535 CharacterComposer character_composer;
535 EXPECT_TRUE(FilterKeyPress(&character_composer, GDK_KEY_dead_acute, 0, 0)); 536 EXPECT_TRUE(FilterKeyPress(&character_composer, GDK_KEY_dead_acute, 0, 0));
536 EXPECT_FALSE(FilterKeyPress(&character_composer, GDK_KEY_s, 0, 0)); 537 EXPECT_FALSE(FilterKeyPress(&character_composer, GDK_KEY_s, 0, 0));
537 ASSERT_EQ(1U, character_composer.composed_character().size()); 538 ASSERT_EQ(1U, character_composer.composed_character().size());
538 EXPECT_EQ(GDK_KEY_apostrophe, character_composer.composed_character().at(0)); 539 EXPECT_EQ(GDK_KEY_apostrophe, character_composer.composed_character().at(0));
539 } 540 }
540 541
541 } // namespace ui 542 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/chromeos/character_composer.cc ('k') | ui/base/ime/chromeos/ime_keymap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698