Flutter iOS Embedder
text_editing_delta_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 
6 
7 #include "gtest/gtest.h"
8 
9 namespace flutter {
10 
11 TEST(TextEditingDeltaTest, TestTextEditingDeltaConstructor) {
12  // Here we are simulating inserting an "o" at the end of "hell".
13  std::string old_text = "hell";
14  std::string replacement_text = "hello";
15  TextRange range(0, 4);
16 
17  TextEditingDelta delta = TextEditingDelta(old_text, range, replacement_text);
18 
19  EXPECT_EQ(delta.old_text(), old_text);
20  EXPECT_EQ(delta.delta_text(), "hello");
21  EXPECT_EQ(delta.delta_start(), 0);
22  EXPECT_EQ(delta.delta_end(), 4);
23 }
24 
25 TEST(TextEditingDeltaTest, TestTextEditingDeltaNonTextConstructor) {
26  // Here we are simulating inserting an "o" at the end of "hell".
27  std::string old_text = "hello";
28 
29  TextEditingDelta delta = TextEditingDelta(old_text);
30 
31  EXPECT_EQ(delta.old_text(), old_text);
32  EXPECT_EQ(delta.delta_text(), "");
33  EXPECT_EQ(delta.delta_start(), -1);
34  EXPECT_EQ(delta.delta_end(), -1);
35 }
36 
37 } // namespace flutter
flutter::TEST
TEST(BasicMessageChannelTest, Registration)
Definition: basic_message_channel_unittests.cc:58
flutter::TextEditingDelta::delta_start
int delta_start() const
Get the delta_start_ value.
Definition: text_editing_delta.h:42
flutter::TextRange
Definition: text_range.h:19
flutter::TextEditingDelta::delta_text
std::string delta_text() const
Definition: text_editing_delta.h:39
flutter::TextEditingDelta::old_text
std::string old_text() const
Definition: text_editing_delta.h:34
flutter
Definition: accessibility_bridge.h:28
text_editing_delta.h
flutter::TextEditingDelta
A change in the state of an input field.
Definition: text_editing_delta.h:16
flutter::TextEditingDelta::delta_end
int delta_end() const
Get the delta_end_ value.
Definition: text_editing_delta.h:45