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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory>
10
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/events/event.h" 14 #include "ui/events/event.h"
14 #include "ui/events/event_constants.h" 15 #include "ui/events/event_constants.h"
15 #include "ui/events/event_utils.h" 16 #include "ui/events/event_utils.h"
16 #include "ui/events/keycodes/dom/dom_code.h" 17 #include "ui/events/keycodes/dom/dom_code.h"
17 #include "ui/events/keycodes/dom/dom_key.h" 18 #include "ui/events/keycodes/dom/dom_key.h"
18 #include "ui/events/keycodes/keyboard_code_conversion.h" 19 #include "ui/events/keycodes/keyboard_code_conversion.h"
19 #include "ui/events/keycodes/keyboard_codes.h" 20 #include "ui/events/keycodes/keyboard_codes.h"
20 21
(...skipping 16 matching lines...) Expand all
37 KeyEvent* DeadKeyPress(base::char16 combining_character) const { 38 KeyEvent* DeadKeyPress(base::char16 combining_character) const {
38 KeyEvent* event = 39 KeyEvent* event =
39 new KeyEvent(ET_KEY_PRESSED, VKEY_UNKNOWN, DomCode::NONE, EF_NONE, 40 new KeyEvent(ET_KEY_PRESSED, VKEY_UNKNOWN, DomCode::NONE, EF_NONE,
40 DomKey::DeadKeyFromCombiningCharacter(combining_character), 41 DomKey::DeadKeyFromCombiningCharacter(combining_character),
41 EventTimeForNow()); 42 EventTimeForNow());
42 return event; 43 return event;
43 } 44 }
44 45
45 // Expects key is filtered and no character is composed. 46 // Expects key is filtered and no character is composed.
46 void ExpectDeadKeyFiltered(base::char16 combining_character) { 47 void ExpectDeadKeyFiltered(base::char16 combining_character) {
47 scoped_ptr<KeyEvent> event(DeadKeyPress(combining_character)); 48 std::unique_ptr<KeyEvent> event(DeadKeyPress(combining_character));
48 EXPECT_TRUE(character_composer_.FilterKeyPress(*event)); 49 EXPECT_TRUE(character_composer_.FilterKeyPress(*event));
49 EXPECT_TRUE(character_composer_.composed_character().empty()); 50 EXPECT_TRUE(character_composer_.composed_character().empty());
50 } 51 }
51 52
52 // Expects key is filtered and the given character is composed. 53 // Expects key is filtered and the given character is composed.
53 void ExpectDeadKeyComposed(base::char16 combining_character, 54 void ExpectDeadKeyComposed(base::char16 combining_character,
54 const base::string16& expected_character) { 55 const base::string16& expected_character) {
55 scoped_ptr<KeyEvent> event(DeadKeyPress(combining_character)); 56 std::unique_ptr<KeyEvent> event(DeadKeyPress(combining_character));
56 EXPECT_TRUE(character_composer_.FilterKeyPress(*event)); 57 EXPECT_TRUE(character_composer_.FilterKeyPress(*event));
57 EXPECT_EQ(expected_character, character_composer_.composed_character()); 58 EXPECT_EQ(expected_character, character_composer_.composed_character());
58 } 59 }
59 60
60 // Returns a |KeyEvent| for a character key press. 61 // Returns a |KeyEvent| for a character key press.
61 KeyEvent* UnicodeKeyPress(KeyboardCode vkey, 62 KeyEvent* UnicodeKeyPress(KeyboardCode vkey,
62 DomCode code, 63 DomCode code,
63 int flags, 64 int flags,
64 base::char16 character) const { 65 base::char16 character) const {
65 KeyEvent* event = new KeyEvent(ET_KEY_PRESSED, vkey, code, flags, 66 KeyEvent* event = new KeyEvent(ET_KEY_PRESSED, vkey, code, flags,
66 DomKey::FromCharacter(character), 67 DomKey::FromCharacter(character),
67 EventTimeForNow()); 68 EventTimeForNow());
68 return event; 69 return event;
69 } 70 }
70 71
71 // Expects key is not filtered and no character is composed. 72 // Expects key is not filtered and no character is composed.
72 void ExpectUnicodeKeyNotFiltered(KeyboardCode vkey, 73 void ExpectUnicodeKeyNotFiltered(KeyboardCode vkey,
73 DomCode code, 74 DomCode code,
74 int flags, 75 int flags,
75 base::char16 character) { 76 base::char16 character) {
76 scoped_ptr<KeyEvent> event(UnicodeKeyPress(vkey, code, flags, character)); 77 std::unique_ptr<KeyEvent> event(
78 UnicodeKeyPress(vkey, code, flags, character));
77 EXPECT_FALSE(character_composer_.FilterKeyPress(*event)); 79 EXPECT_FALSE(character_composer_.FilterKeyPress(*event));
78 EXPECT_TRUE(character_composer_.composed_character().empty()); 80 EXPECT_TRUE(character_composer_.composed_character().empty());
79 } 81 }
80 82
81 // Expects key is filtered and no character is composed. 83 // Expects key is filtered and no character is composed.
82 void ExpectUnicodeKeyFiltered(KeyboardCode vkey, 84 void ExpectUnicodeKeyFiltered(KeyboardCode vkey,
83 DomCode code, 85 DomCode code,
84 int flags, 86 int flags,
85 base::char16 character) { 87 base::char16 character) {
86 scoped_ptr<KeyEvent> event(UnicodeKeyPress(vkey, code, flags, character)); 88 std::unique_ptr<KeyEvent> event(
89 UnicodeKeyPress(vkey, code, flags, character));
87 EXPECT_TRUE(character_composer_.FilterKeyPress(*event)); 90 EXPECT_TRUE(character_composer_.FilterKeyPress(*event));
88 EXPECT_TRUE(character_composer_.composed_character().empty()); 91 EXPECT_TRUE(character_composer_.composed_character().empty());
89 } 92 }
90 93
91 // Expects key is filtered and the given character is composed. 94 // Expects key is filtered and the given character is composed.
92 void ExpectUnicodeKeyComposed(KeyboardCode vkey, 95 void ExpectUnicodeKeyComposed(KeyboardCode vkey,
93 DomCode code, 96 DomCode code,
94 int flags, 97 int flags,
95 base::char16 character, 98 base::char16 character,
96 const base::string16& expected_character) { 99 const base::string16& expected_character) {
97 scoped_ptr<KeyEvent> event(UnicodeKeyPress(vkey, code, flags, character)); 100 std::unique_ptr<KeyEvent> event(
101 UnicodeKeyPress(vkey, code, flags, character));
98 EXPECT_TRUE(character_composer_.FilterKeyPress(*event)); 102 EXPECT_TRUE(character_composer_.FilterKeyPress(*event));
99 EXPECT_EQ(expected_character, character_composer_.composed_character()); 103 EXPECT_EQ(expected_character, character_composer_.composed_character());
100 } 104 }
101 105
102 CharacterComposer character_composer_; 106 CharacterComposer character_composer_;
103 }; 107 };
104 108
105 TEST_F(CharacterComposerTest, InitialState) { 109 TEST_F(CharacterComposerTest, InitialState) {
106 EXPECT_TRUE(character_composer_.composed_character().empty()); 110 EXPECT_TRUE(character_composer_.composed_character().empty());
107 } 111 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 ExpectUnicodeKeyFiltered(VKEY_3, DomCode::DIGIT3, EF_NONE, '3'); 509 ExpectUnicodeKeyFiltered(VKEY_3, DomCode::DIGIT3, EF_NONE, '3');
506 ExpectUnicodeKeyFiltered(VKEY_0, DomCode::DIGIT0, EF_NONE, '0'); 510 ExpectUnicodeKeyFiltered(VKEY_0, DomCode::DIGIT0, EF_NONE, '0');
507 ExpectDeadKeyFiltered(kCombiningAcute); 511 ExpectDeadKeyFiltered(kCombiningAcute);
508 ExpectUnicodeKeyFiltered(VKEY_4, DomCode::DIGIT4, EF_NONE, '4'); 512 ExpectUnicodeKeyFiltered(VKEY_4, DomCode::DIGIT4, EF_NONE, '4');
509 ExpectUnicodeKeyFiltered(VKEY_2, DomCode::DIGIT2, EF_NONE, '2'); 513 ExpectUnicodeKeyFiltered(VKEY_2, DomCode::DIGIT2, EF_NONE, '2');
510 ExpectUnicodeKeyComposed(VKEY_SPACE, DomCode::SPACE, EF_NONE, ' ', 514 ExpectUnicodeKeyComposed(VKEY_SPACE, DomCode::SPACE, EF_NONE, ' ',
511 base::string16(1, 0x3042)); 515 base::string16(1, 0x3042));
512 } 516 }
513 517
514 } // namespace ui 518 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/candidate_window_unittest.cc ('k') | ui/base/ime/chromeos/component_extension_ime_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698