Flutter macOS Embedder
flutter Namespace Reference

Namespaces

 internal
 
 testing
 

Classes

class  AccessibilityBridgeMac
 
struct  BackingStoreLayer
 
class  FlutterCompositor
 
struct  LayoutClue
 
class  PlatformViewLayer
 Represents a platform view layer, including all mutations. More...
 
class  FlutterPlatformNodeDelegateMac
 
class  FlutterTextPlatformNode
 The ax platform node for a text field. More...
 
struct  LayoutGoal
 
class  AccessibilityBridge
 
class  AlertPlatformNodeDelegate
 
class  BinaryMessengerImpl
 
class  ByteBufferStreamReader
 
class  ByteBufferStreamWriter
 
class  TestCustomValue
 
class  BasicMessageChannel
 
class  BinaryMessenger
 
class  ByteStreamReader
 
class  ByteStreamWriter
 
class  CustomEncodableValue
 
class  EncodableValue
 
class  EngineMethodResult
 
class  EventChannel
 
class  EventSink
 
struct  StreamHandlerError
 
class  StreamHandler
 
class  StreamHandlerFunctions
 
class  MessageCodec
 
class  MethodCall
 
class  MethodChannel
 
class  MethodCodec
 
class  MethodResult
 
class  MethodResultFunctions
 
class  PluginRegistrar
 
class  Plugin
 
class  PluginRegistrarManager
 
class  PluginRegistry
 
class  StandardCodecSerializer
 
class  StandardMessageCodec
 
class  StandardMethodCodec
 
class  PixelBufferTexture
 
class  GpuSurfaceTexture
 
class  TextureRegistrar
 
class  TextureRegistrarImpl
 
class  FlutterPlatformNodeDelegate
 
class  IncomingMessageDispatcher
 
class  Isolate
 
class  IsolateScope
 
class  JsonMessageCodec
 
class  JsonMethodCodec
 
class  TestAccessibilityBridge
 
struct  TextEditingDelta
 A change in the state of an input field. More...
 
class  TextInputModel
 
class  TextRange
 

Typedefs

using LayerVariant = std::variant< PlatformViewLayer, BackingStoreLayer >
 
using ProductVersion = std::tuple< int32_t, int32_t, int32_t >
 
template<typename T >
using MessageReply = std::function< void(const T &reply)>
 
template<typename T >
using MessageHandler = std::function< void(const T &message, const MessageReply< T > &reply)>
 
typedef std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply
 
typedef std::function< void(const uint8_t *message, size_t message_size, BinaryReply reply)> BinaryMessageHandler
 
using EncodableList = std::vector< EncodableValue >
 
using EncodableMap = std::map< EncodableValue, EncodableValue >
 
template<typename T >
using StreamHandlerListen = std::function< std::unique_ptr< StreamHandlerError< T > >(const T *arguments, std::unique_ptr< EventSink< T > > &&events)>
 
template<typename T >
using StreamHandlerCancel = std::function< std::unique_ptr< StreamHandlerError< T > >(const T *arguments)>
 
template<typename T >
using MethodCallHandler = std::function< void(const MethodCall< T > &call, std::unique_ptr< MethodResult< T > > result)>
 
template<typename T >
using ResultHandlerSuccess = std::function< void(const T *result)>
 
template<typename T >
using ResultHandlerError = std::function< void(const std::string &error_code, const std::string &error_message, const T *error_details)>
 
template<typename T >
using ResultHandlerNotImplemented = std::function< void()>
 
typedef std::variant< PixelBufferTexture, GpuSurfaceTexture > TextureVariant
 
typedef ui::AXNode::AXID AccessibilityNodeId
 

Enumerations

enum  ModifierFlag {
  kModifierFlagControlLeft = 0x1 ,
  kModifierFlagShiftLeft = 0x2 ,
  kModifierFlagShiftRight = 0x4 ,
  kModifierFlagMetaLeft = 0x8 ,
  kModifierFlagMetaRight = 0x10 ,
  kModifierFlagAltLeft = 0x20 ,
  kModifierFlagAltRight = 0x40 ,
  kModifierFlagControlRight = 0x200
}
 
enum class  AppLifecycleState {
  kDetached ,
  kResumed ,
  kInactive ,
  kHidden ,
  kPaused
}
 
enum class  PlatformProvidedMenu {
  kAbout ,
  kQuit ,
  kServicesSubmenu ,
  kHide ,
  kHideOtherApplications ,
  kShowAllApplications ,
  kStartSpeaking ,
  kStopSpeaking ,
  kToggleFullScreen ,
  kMinimizeWindow ,
  kZoomWindow ,
  kArrangeWindowsInFront
}
 
enum class  WindowArchetype {
  kRegular ,
  kDialog ,
  kTooltip ,
  kPopup ,
  kSatellite
}
 

Functions

bool operator== (const LayoutGoal &a, const LayoutGoal &b)
 
std::optional< ProductVersion > ProductVersionFromSystemVersionPList ()
 
bool IsEncodedVersionLessThanOrSame (uint32_t encoded_lhs, ProductVersion rhs)
 
fml::MallocMapping CopyNSDataToMapping (NSData *data)
 
NSData * ConvertMappingToNSData (fml::MallocMapping buffer)
 
std::unique_ptr< fml::Mapping > ConvertNSDataToMappingPtr (NSData *data)
 
NSData * CopyMappingPtrToNSData (std::unique_ptr< fml::Mapping > mapping)
 
fml::CommandLine CommandLineFromNSProcessInfo (NSProcessInfo *processInfoOrNil=nil)
 
FlutterStandardField FlutterStandardFieldForDataType (FlutterStandardDataType type)
 
FlutterStandardDataType FlutterStandardDataTypeForField (FlutterStandardField field)
 
UInt8 elementSizeForFlutterStandardDataType (FlutterStandardDataType type)
 
constexpr const char * AppLifecycleStateToString (AppLifecycleState state)
 
 TEST (BasicMessageChannelTest, Registration)
 
 TEST (BasicMessageChannelTest, Unregistration)
 
 TEST (BasicMessageChannelTest, Resize)
 
 TEST (BasicMessageChannelTest, SetWarnsOnOverflow)
 
 TEST (EncodableValueTest, Null)
 
 TEST (EncodableValueTest, Bool)
 
 TEST (EncodableValueTest, Int)
 
 TEST (EncodableValueTest, LongValue)
 
 TEST (EncodableValueTest, Long)
 
 TEST (EncodableValueTest, Double)
 
 TEST (EncodableValueTest, String)
 
 TEST (EncodableValueTest, CString)
 
 TEST (EncodableValueTest, UInt8List)
 
 TEST (EncodableValueTest, Int32List)
 
 TEST (EncodableValueTest, Int64List)
 
 TEST (EncodableValueTest, DoubleList)
 
 TEST (EncodableValueTest, List)
 
 TEST (EncodableValueTest, Map)
 
 TEST (EncodableValueTest, Comparison)
 
 TEST (EncodableValueTest, DeepCopy)
 
 TEST (EncodableValueTest, TypeIndexesCorrect)
 
 TEST (EventChannelTest, Registration)
 
 TEST (EventChannelTest, Unregistration)
 
 TEST (EventChannelTest, Cancel)
 
 TEST (EventChannelTest, ListenNotCancel)
 
 TEST (EventChannelTest, ReRegistration)
 
 TEST (EventChannelTest, HandlerOutlivesEventChannel)
 
 TEST (EventChannelTest, StreamHandlerErrorPassByValue)
 
 TEST (EventChannelTest, StreamHandlerErrorNullptr)
 
 TEST (MethodCallTest, Basic)
 
 TEST (MethodChannelTest, Registration)
 
 TEST (MethodChannelTest, Unregistration)
 
 TEST (MethodChannelTest, InvokeWithoutResponse)
 
 TEST (MethodChannelTest, InvokeWithResponse)
 
 TEST (MethodChannelTest, InvokeNotImplemented)
 
 TEST (MethodChannelTest, Resize)
 
 TEST (MethodChannelTest, SetWarnsOnOverflow)
 
 TEST (MethodChannelTest, NoHandlers)
 
 TEST (MethodChannelTest, Success)
 
 TEST (MethodChannelTest, Error)
 
 TEST (MethodChannelTest, NotImplemented)
 
 TEST (PluginRegistrarTest, PluginDestroyedBeforeRegistrar)
 
 TEST (PluginRegistrarTest, MessengerSend)
 
 TEST (PluginRegistrarTest, MessengerSetMessageHandler)
 
 TEST (PluginRegistrarTest, ManagerSameInstance)
 
 TEST (PluginRegistrarTest, ManagerDifferentInstances)
 
 TEST (PluginRegistrarTest, ManagerRemovesOnDestruction)
 
 TEST (PluginRegistrarTest, TextureRegistrarNotNull)
 
static void CheckEncodeDecode (const EncodableValue &value, const std::vector< uint8_t > &expected_encoding, const StandardCodecSerializer *serializer=nullptr, const std::function< bool(const EncodableValue &a, const EncodableValue &b)> &custom_comparator=nullptr)
 
static void CheckEncodeDecodeWithEncodePrefix (const EncodableValue &value, const std::vector< uint8_t > &expected_encoding_prefix, size_t expected_encoding_length)
 
 TEST (StandardMessageCodec, GetInstanceCachesInstance)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeNull)
 
 TEST (StandardMessageCodec, CanDecodeEmptyBytesAsNullWithoutCallingSerializer)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeTrue)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeFalse)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeInt32)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeInt64)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeDouble)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeString)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeStringWithNonAsciiCodePoint)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeStringWithNonBMPCodePoint)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeEmptyString)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeList)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeEmptyList)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeMap)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeByteArray)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeInt32Array)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeInt64Array)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeFloat32Array)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeFloat64Array)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeSimpleCustomType)
 
 TEST (StandardMessageCodec, CanEncodeAndDecodeVariableLengthCustomType)
 
 TEST (StandardMethodCodec, GetInstanceCachesInstance)
 
 TEST (StandardMethodCodec, HandlesMethodCallsWithNullArguments)
 
 TEST (StandardMethodCodec, HandlesMethodCallsWithArgument)
 
 TEST (StandardMethodCodec, HandlesSuccessEnvelopesWithNullResult)
 
 TEST (StandardMethodCodec, HandlesSuccessEnvelopesWithResult)
 
 TEST (StandardMethodCodec, HandlesErrorEnvelopesWithNulls)
 
 TEST (StandardMethodCodec, HandlesErrorEnvelopesWithDetails)
 
 TEST (StandardMethodCodec, HandlesCustomTypeArguments)
 
 TEST (TextureRegistrarTest, RegisterUnregisterTexture)
 
 TEST (TextureRegistrarTest, UnregisterInvalidTexture)
 
 TEST (TextureRegistrarTest, MarkFrameAvailableInvalidTexture)
 
std::vector< std::string > GetSwitchesFromEnvironment ()
 
 TEST (FlutterProjectBundle, SwitchesEmpty)
 
 TEST (FlutterProjectBundle, Switches)
 
 TEST (FlutterProjectBundle, SwitchesExtraValues)
 
 TEST (FlutterProjectBundle, SwitchesMissingValues)
 
 TEST (IncomingMessageDispatcher, SetHandle)
 
 TEST (IncomingMessageDispatcher, BlockInputFalse)
 
 TEST (IncomingMessageDispatcher, BlockInputTrue)
 
 TEST (JsonMessageCodec, EncodeDecode)
 
 TEST (JsonMethodCodec, HandlesMethodCallsWithNullArguments)
 
 TEST (JsonMethodCodec, HandlesMethodCallsWithArgument)
 
 TEST (JsonMethodCodec, HandlesSuccessEnvelopesWithNullResult)
 
 TEST (JsonMethodCodec, HandlesSuccessEnvelopesWithResult)
 
 TEST (JsonMethodCodec, HandlesErrorEnvelopesWithNulls)
 
 TEST (JsonMethodCodec, HandlesErrorEnvelopesWithDetails)
 
std::filesystem::path GetExecutableDirectory ()
 
 TEST (PathUtilsTest, ExecutableDirector)
 
 TEST (TextEditingDeltaTest, TestTextEditingDeltaConstructor)
 
 TEST (TextEditingDeltaTest, TestTextEditingDeltaNonTextConstructor)
 
 TEST (TextInputModel, SetText)
 
 TEST (TextInputModel, SetTextWideCharacters)
 
 TEST (TextInputModel, SetTextEmpty)
 
 TEST (TextInputModel, SetTextReplaceText)
 
 TEST (TextInputModel, SetTextResetsSelection)
 
 TEST (TextInputModel, SetTextRejectingSelectionLeavesModelUnchanged)
 
 TEST (TextInputModel, SetTextRejectingComposingRangeLeavesModelUnchanged)
 
 TEST (TextInputModel, UpdateComposingTextWithSelectionPastComposingText)
 
 TEST (TextInputModel, SetSelectionStart)
 
 TEST (TextInputModel, SetSelectionComposingStart)
 
 TEST (TextInputModel, SetSelectionMiddle)
 
 TEST (TextInputModel, SetSelectionComposingMiddle)
 
 TEST (TextInputModel, SetSelectionEnd)
 
 TEST (TextInputModel, SetSelectionComposingEnd)
 
 TEST (TextInputModel, SetSelectionWthExtent)
 
 TEST (TextInputModel, SetSelectionWthExtentComposing)
 
 TEST (TextInputModel, SetSelectionReverseExtent)
 
 TEST (TextInputModel, SetSelectionReverseExtentComposing)
 
 TEST (TextInputModel, SetSelectionOutsideString)
 
 TEST (TextInputModel, SetSelectionOutsideComposingRange)
 
 TEST (TextInputModel, SetComposingRangeStart)
 
 TEST (TextInputModel, SetComposingRangeMiddle)
 
 TEST (TextInputModel, SetComposingRangeEnd)
 
 TEST (TextInputModel, SetComposingRangeWithExtent)
 
 TEST (TextInputModel, SetComposingRangeReverseExtent)
 
 TEST (TextInputModel, SetComposingRangeWithOffsetOutsideString)
 
 TEST (TextInputModel, SetComposingRangeOutsideString)
 
 TEST (TextInputModel, CommitComposingNoTextWithNoSelection)
 
 TEST (TextInputModel, CommitComposingNoTextWithSelection)
 
 TEST (TextInputModel, CommitComposingTextWithNoSelection)
 
 TEST (TextInputModel, CommitComposingTextWithSelection)
 
 TEST (TextInputModel, UpdateComposingRemovesLastComposingCharacter)
 
 TEST (TextInputModel, UpdateSelectionWhileComposing)
 
 TEST (TextInputModel, AddCodePoint)
 
 TEST (TextInputModel, AddCodePointSelection)
 
 TEST (TextInputModel, AddCodePointReverseSelection)
 
 TEST (TextInputModel, AddCodePointSelectionWideCharacter)
 
 TEST (TextInputModel, AddCodePointReverseSelectionWideCharacter)
 
 TEST (TextInputModel, AddText)
 
 TEST (TextInputModel, AddTextSelection)
 
 TEST (TextInputModel, AddTextReverseSelection)
 
 TEST (TextInputModel, AddTextSelectionWideCharacter)
 
 TEST (TextInputModel, AddTextReverseSelectionWideCharacter)
 
 TEST (TextInputModel, DeleteStart)
 
 TEST (TextInputModel, DeleteMiddle)
 
 TEST (TextInputModel, DeleteEnd)
 
 TEST (TextInputModel, DeleteWideCharacters)
 
 TEST (TextInputModel, DeleteSelection)
 
 TEST (TextInputModel, DeleteReverseSelection)
 
 TEST (TextInputModel, DeleteStartComposing)
 
 TEST (TextInputModel, DeleteStartReverseComposing)
 
 TEST (TextInputModel, DeleteMiddleComposing)
 
 TEST (TextInputModel, DeleteMiddleReverseComposing)
 
 TEST (TextInputModel, DeleteEndComposing)
 
 TEST (TextInputModel, DeleteEndReverseComposing)
 
 TEST (TextInputModel, DeleteSurroundingAtCursor)
 
 TEST (TextInputModel, DeleteSurroundingAtCursorComposing)
 
 TEST (TextInputModel, DeleteSurroundingAtCursorAll)
 
 TEST (TextInputModel, DeleteSurroundingAtCursorAllComposing)
 
 TEST (TextInputModel, DeleteSurroundingAtCursorGreedy)
 
 TEST (TextInputModel, DeleteSurroundingAtCursorGreedyComposing)
 
 TEST (TextInputModel, DeleteSurroundingBeforeCursor)
 
 TEST (TextInputModel, DeleteSurroundingBeforeCursorComposing)
 
 TEST (TextInputModel, DeleteSurroundingBeforeCursorAll)
 
 TEST (TextInputModel, DeleteSurroundingBeforeCursorAllComposing)
 
 TEST (TextInputModel, DeleteSurroundingBeforeCursorGreedy)
 
 TEST (TextInputModel, DeleteSurroundingBeforeCursorGreedyComposing)
 
 TEST (TextInputModel, DeleteSurroundingAfterCursor)
 
 TEST (TextInputModel, DeleteSurroundingAfterCursorComposing)
 
 TEST (TextInputModel, DeleteSurroundingAfterCursorAll)
 
 TEST (TextInputModel, DeleteSurroundingAfterCursorAllComposing)
 
 TEST (TextInputModel, DeleteSurroundingAfterCursorGreedy)
 
 TEST (TextInputModel, DeleteSurroundingAfterCursorGreedyComposing)
 
 TEST (TextInputModel, DeleteSurroundingSelection)
 
 TEST (TextInputModel, DeleteSurroundingReverseSelection)
 
 TEST (TextInputModel, DeleteSurroundingWideCharacterAfterCursor)
 
 TEST (TextInputModel, DeleteSurroundingWideCharacterBeforeCursor)
 
 TEST (TextInputModel, DeleteSurroundingWideCharacterFirst)
 
 TEST (TextInputModel, DeleteSurroundingWideCharactersAfterCursorOffset)
 
 TEST (TextInputModel, DeleteSurroundingWideCharacterGreedy)
 
 TEST (TextInputModel, DeleteSurroundingWideCharacterComposing)
 
 TEST (TextInputModel, DeleteSurroundingGuardStopsAtComposingEnd)
 
 TEST (TextInputModel, DeleteSurroundingGuardStopsAtComposingStart)
 
 TEST (TextInputModel, BackspaceStart)
 
 TEST (TextInputModel, BackspaceMiddle)
 
 TEST (TextInputModel, BackspaceEnd)
 
 TEST (TextInputModel, BackspaceWideCharacters)
 
 TEST (TextInputModel, BackspaceSelection)
 
 TEST (TextInputModel, BackspaceReverseSelection)
 
 TEST (TextInputModel, BackspaceStartComposing)
 
 TEST (TextInputModel, BackspaceStartReverseComposing)
 
 TEST (TextInputModel, BackspaceMiddleComposing)
 
 TEST (TextInputModel, BackspaceMiddleReverseComposing)
 
 TEST (TextInputModel, BackspaceEndComposing)
 
 TEST (TextInputModel, BackspaceEndReverseComposing)
 
 TEST (TextInputModel, MoveCursorForwardStart)
 
 TEST (TextInputModel, MoveCursorForwardMiddle)
 
 TEST (TextInputModel, MoveCursorForwardEnd)
 
 TEST (TextInputModel, MoveCursorForwardWideCharacters)
 
 TEST (TextInputModel, MoveCursorForwardSelection)
 
 TEST (TextInputModel, MoveCursorForwardReverseSelection)
 
 TEST (TextInputModel, MoveCursorForwardStartComposing)
 
 TEST (TextInputModel, MoveCursorForwardStartReverseComposing)
 
 TEST (TextInputModel, MoveCursorForwardMiddleComposing)
 
 TEST (TextInputModel, MoveCursorForwardMiddleReverseComposing)
 
 TEST (TextInputModel, MoveCursorForwardEndComposing)
 
 TEST (TextInputModel, MoveCursorForwardEndReverseComposing)
 
 TEST (TextInputModel, MoveCursorBackStart)
 
 TEST (TextInputModel, MoveCursorBackMiddle)
 
 TEST (TextInputModel, MoveCursorBackEnd)
 
 TEST (TextInputModel, MoveCursorBackWideCharacters)
 
 TEST (TextInputModel, MoveCursorBackSelection)
 
 TEST (TextInputModel, MoveCursorBackReverseSelection)
 
 TEST (TextInputModel, MoveCursorBackStartComposing)
 
 TEST (TextInputModel, MoveCursorBackStartReverseComposing)
 
 TEST (TextInputModel, MoveCursorBackMiddleComposing)
 
 TEST (TextInputModel, MoveCursorBackMiddleReverseComposing)
 
 TEST (TextInputModel, MoveCursorBackEndComposing)
 
 TEST (TextInputModel, MoveCursorBackEndReverseComposing)
 
 TEST (TextInputModel, MoveCursorToBeginningStart)
 
 TEST (TextInputModel, SelectToBeginningStart)
 
 TEST (TextInputModel, MoveCursorToBeginningMiddle)
 
 TEST (TextInputModel, SelectToBeginningMiddle)
 
 TEST (TextInputModel, MoveCursorToBeginningEnd)
 
 TEST (TextInputModel, SelectToBeginningEnd)
 
 TEST (TextInputModel, MoveCursorToBeginningSelection)
 
 TEST (TextInputModel, SelectToBeginningSelection)
 
 TEST (TextInputModel, MoveCursorToBeginningReverseSelection)
 
 TEST (TextInputModel, SelectToBeginningReverseSelection)
 
 TEST (TextInputModel, MoveCursorToBeginningStartComposing)
 
 TEST (TextInputModel, SelectToBeginningStartComposing)
 
 TEST (TextInputModel, MoveCursorToBeginningStartReverseComposing)
 
 TEST (TextInputModel, SelectToBeginningStartReverseComposing)
 
 TEST (TextInputModel, MoveCursorToBeginningMiddleComposing)
 
 TEST (TextInputModel, SelectToBeginningMiddleComposing)
 
 TEST (TextInputModel, MoveCursorToBeginningMiddleReverseComposing)
 
 TEST (TextInputModel, SelectToBeginningMiddleReverseComposing)
 
 TEST (TextInputModel, MoveCursorToBeginningEndComposing)
 
 TEST (TextInputModel, SelectToBeginningEndComposing)
 
 TEST (TextInputModel, MoveCursorToBeginningEndReverseComposing)
 
 TEST (TextInputModel, SelectToBeginningEndReverseComposing)
 
 TEST (TextInputModel, MoveCursorToEndStart)
 
 TEST (TextInputModel, SelectToEndStart)
 
 TEST (TextInputModel, MoveCursorToEndMiddle)
 
 TEST (TextInputModel, SelectToEndMiddle)
 
 TEST (TextInputModel, MoveCursorToEndEnd)
 
 TEST (TextInputModel, SelectToEndEnd)
 
 TEST (TextInputModel, MoveCursorToEndSelection)
 
 TEST (TextInputModel, SelectToEndSelection)
 
 TEST (TextInputModel, MoveCursorToEndReverseSelection)
 
 TEST (TextInputModel, SelectToEndReverseSelection)
 
 TEST (TextInputModel, MoveCursorToEndStartComposing)
 
 TEST (TextInputModel, SelectToEndStartComposing)
 
 TEST (TextInputModel, MoveCursorToEndStartReverseComposing)
 
 TEST (TextInputModel, SelectToEndStartReverseComposing)
 
 TEST (TextInputModel, MoveCursorToEndMiddleComposing)
 
 TEST (TextInputModel, SelectToEndMiddleComposing)
 
 TEST (TextInputModel, MoveCursorToEndMiddleReverseComposing)
 
 TEST (TextInputModel, SelectToEndMiddleReverseComposing)
 
 TEST (TextInputModel, MoveCursorToEndEndComposing)
 
 TEST (TextInputModel, SelectToEndEndComposing)
 
 TEST (TextInputModel, MoveCursorToEndEndReverseComposing)
 
 TEST (TextInputModel, SelectToEndEndReverseComposing)
 
 TEST (TextInputModel, GetCursorOffset)
 
 TEST (TextInputModel, GetCursorOffsetSelection)
 
 TEST (TextInputModel, GetCursorOffsetReverseSelection)
 
 TEST (TextRange, TextRangeFromPositionZero)
 
 TEST (TextRange, TextRangeFromPositionNonZero)
 
 TEST (TextRange, TextRangeFromRange)
 
 TEST (TextRange, TextRangeFromReversedRange)
 
 TEST (TextRange, SetBase)
 
 TEST (TextRange, SetBaseReversed)
 
 TEST (TextRange, SetExtent)
 
 TEST (TextRange, SetExtentReversed)
 
 TEST (TextRange, SetStart)
 
 TEST (TextRange, SetStartReversed)
 
 TEST (TextRange, SetEnd)
 
 TEST (TextRange, SetEndReversed)
 
 TEST (TextRange, ContainsPreStartPosition)
 
 TEST (TextRange, ContainsStartPosition)
 
 TEST (TextRange, ContainsMiddlePosition)
 
 TEST (TextRange, ContainsEndPosition)
 
 TEST (TextRange, ContainsPostEndPosition)
 
 TEST (TextRange, ContainsPreStartPositionReversed)
 
 TEST (TextRange, ContainsStartPositionReversed)
 
 TEST (TextRange, ContainsMiddlePositionReversed)
 
 TEST (TextRange, ContainsEndPositionReversed)
 
 TEST (TextRange, ContainsPostEndPositionReversed)
 
 TEST (TextRange, ContainsRangePreStartPosition)
 
 TEST (TextRange, ContainsRangeSpanningStartPosition)
 
 TEST (TextRange, ContainsRangeStartPosition)
 
 TEST (TextRange, ContainsRangeMiddlePosition)
 
 TEST (TextRange, ContainsRangeEndPosition)
 
 TEST (TextRange, ContainsRangeSpanningEndPosition)
 
 TEST (TextRange, ContainsRangePostEndPosition)
 
 TEST (TextRange, ContainsRangePreStartPositionReversed)
 
 TEST (TextRange, ContainsRangeSpanningStartPositionReversed)
 
 TEST (TextRange, ContainsRangeStartPositionReversed)
 
 TEST (TextRange, ContainsRangeMiddlePositionReversed)
 
 TEST (TextRange, ContainsRangeSpanningEndPositionReversed)
 
 TEST (TextRange, ContainsRangeEndPositionReversed)
 
 TEST (TextRange, ContainsRangePostEndPositionReversed)
 
 TEST (TextRange, ReversedForwardRange)
 
 TEST (TextRange, ReversedCollapsedRange)
 
 TEST (TextRange, ReversedReversedRange)
 
 TEST (TextRange, ClampedToLongerLength)
 
 TEST (TextRange, ClampedToShorterLength)
 
 TEST (TextRange, ClampedToShorterLengthReversed)
 

Variables

static NSString *const kAccessibilityLoadCompleteNotification = @"@"AXLoadComplete"
 
static NSString *const kAccessibilityInvalidStatusChangedNotification = @"@"AXInvalidStatusChanged"
 
static NSString *const kAccessibilityLiveRegionCreatedNotification = @"@"AXLiveRegionCreated"
 
static NSString *const kAccessibilityLiveRegionChangedNotification = @"@"AXLiveRegionChanged"
 
static NSString *const kAccessibilityExpandedChanged = @"@"AXExpandedChanged"
 
static NSString *const kAccessibilityMenuItemSelectedNotification = @"@"AXMenuItemSelected"
 
const uint64_t kValueMask = 0x000ffffffff
 
const uint64_t kUnicodePlane = 0x00000000000
 
const uint64_t kMacosPlane = 0x01400000000
 
const NSDictionary * keyCodeToPhysicalKey
 
const NSDictionary * keyCodeToLogicalKey
 
const NSDictionary * keyCodeToModifierFlag
 
const NSDictionary * modifierFlagToKeyCode
 
const uint64_t kCapsLockPhysicalKey = 0x00070039
 
const uint64_t kCapsLockLogicalKey = 0x100000104
 
const std::vector< LayoutGoal > kLayoutGoals
 
constexpr int kHasScrollingAction
 

Typedef Documentation

◆ AccessibilityNodeId

typedef ui::AXNode::AXID flutter::AccessibilityNodeId

Definition at line 15 of file flutter_platform_node_delegate.h.

◆ BinaryMessageHandler

typedef std::function< void(const uint8_t* message, size_t message_size, BinaryReply reply)> flutter::BinaryMessageHandler

Definition at line 25 of file binary_messenger.h.

◆ BinaryReply

typedef std::function<void(const uint8_t* reply, size_t reply_size)> flutter::BinaryReply

Definition at line 18 of file binary_messenger.h.

◆ EncodableList

using flutter::EncodableList = typedef std::vector<EncodableValue>

Definition at line 95 of file encodable_value.h.

◆ EncodableMap

Definition at line 96 of file encodable_value.h.

◆ LayerVariant

Definition at line 29 of file FlutterCompositor.h.

◆ MessageHandler

template<typename T >
using flutter::MessageHandler = typedef std::function<void(const T& message, const MessageReply<T>& reply)>

Definition at line 50 of file basic_message_channel.h.

◆ MessageReply

template<typename T >
using flutter::MessageReply = typedef std::function<void(const T& reply)>

Definition at line 43 of file basic_message_channel.h.

◆ MethodCallHandler

template<typename T >
using flutter::MethodCallHandler = typedef std::function<void(const MethodCall<T>& call, std::unique_ptr<MethodResult<T> > result)>

Definition at line 27 of file method_channel.h.

◆ ProductVersion

using flutter::ProductVersion = typedef std::tuple<int32_t , int32_t , int32_t >

Definition at line 14 of file availability_version_check.h.

◆ ResultHandlerError

template<typename T >
using flutter::ResultHandlerError = typedef std::function<void(const std::string& error_code, const std::string& error_message, const T* error_details)>

Definition at line 22 of file method_result_functions.h.

◆ ResultHandlerNotImplemented

template<typename T >
using flutter::ResultHandlerNotImplemented = typedef std::function<void()>

Definition at line 26 of file method_result_functions.h.

◆ ResultHandlerSuccess

template<typename T >
using flutter::ResultHandlerSuccess = typedef std::function<void(const T* result)>

Definition at line 20 of file method_result_functions.h.

◆ StreamHandlerCancel

template<typename T >
using flutter::StreamHandlerCancel = typedef std::function<std::unique_ptr<StreamHandlerError<T> >(const T* arguments)>

Definition at line 26 of file event_stream_handler_functions.h.

◆ StreamHandlerListen

template<typename T >
using flutter::StreamHandlerListen = typedef std::function<std::unique_ptr<StreamHandlerError<T> >( const T* arguments, std::unique_ptr<EventSink<T> >&& events)>

Definition at line 20 of file event_stream_handler_functions.h.

◆ TextureVariant

Definition at line 79 of file texture_registrar.h.

Enumeration Type Documentation

◆ AppLifecycleState

These constants describe the possible lifecycle states of the application. They must be kept up to date with changes in the framework's AppLifecycleState enum. They are passed to the embedder's |SetLifecycleState| function.

States not supported on a platform will be synthesized by the framework when transitioning between states which are supported, so that all implementations share the same state machine.

Here is the state machine:

+-----------+                               +-----------+
| detached  |------------------------------>|  resumed  |
+-----------+                               +-----------+
     ^                                              ^
     |                                              |
     |                                              v
+-----------+        +--------------+       +-----------+
| paused    |<------>|    hidden    |<----->|  inactive |
+-----------+        +--------------+       +-----------+
Enumerator
kDetached 

Corresponds to the Framework's AppLifecycleState.detached: The initial state of the state machine. On Android, iOS, and web, also the final state of the state machine when all views are detached. Other platforms do not re-enter this state after initially leaving it.

kResumed 

Corresponds to the Framework's AppLifecycleState.resumed: The nominal "running" state of the application. The application is visible, has input focus, and is running.

kInactive 

Corresponds to the Framework's AppLifecycleState.inactive: At least one view of the application is visible, but none have input focus. The application is otherwise running normally.

kHidden 

Corresponds to the Framework's AppLifecycleState.hidden: All views of an application are hidden, either because the application is being stopped (on iOS and Android), or because it is being minimized or on a desktop that is no longer visible (on desktop), or on a tab that is no longer visible (on web).

kPaused 

Corresponds to the Framework's AppLifecycleState.paused: The application is not running, and can be detached or started again at any time. This state is typically only entered into on iOS and Android.

Definition at line 32 of file app_lifecycle_state.h.

32  {
33  /**
34  * Corresponds to the Framework's AppLifecycleState.detached: The initial
35  * state of the state machine. On Android, iOS, and web, also the final state
36  * of the state machine when all views are detached. Other platforms do not
37  * re-enter this state after initially leaving it.
38  */
39  kDetached,
40 
41  /**
42  * Corresponds to the Framework's AppLifecycleState.resumed: The nominal
43  * "running" state of the application. The application is visible, has input
44  * focus, and is running.
45  */
46  kResumed,
47 
48  /**
49  * Corresponds to the Framework's AppLifecycleState.inactive: At least one
50  * view of the application is visible, but none have input focus. The
51  * application is otherwise running normally.
52  */
53  kInactive,
54 
55  /**
56  * Corresponds to the Framework's AppLifecycleState.hidden: All views of an
57  * application are hidden, either because the application is being stopped (on
58  * iOS and Android), or because it is being minimized or on a desktop that is
59  * no longer visible (on desktop), or on a tab that is no longer visible (on
60  * web).
61  */
62  kHidden,
63 
64  /**
65  * Corresponds to the Framework's AppLifecycleState.paused: The application is
66  * not running, and can be detached or started again at any time. This state
67  * is typically only entered into on iOS and Android.
68  */
69  kPaused,
70 };

◆ ModifierFlag

Bits in |NSEvent.modifierFlags| indicating whether a modifier key is pressed.

These constants are not written in the official documentation, but derived from experiments. This is currently the only way to know whether a one-side modifier key (such as ShiftLeft) is pressed, instead of the general combined modifier state (such as Shift).

Enumerator
kModifierFlagControlLeft 
kModifierFlagShiftLeft 
kModifierFlagShiftRight 
kModifierFlagMetaLeft 
kModifierFlagMetaRight 
kModifierFlagAltLeft 
kModifierFlagAltRight 
kModifierFlagControlRight 

Definition at line 79 of file KeyCodeMap_Internal.h.

◆ PlatformProvidedMenu

Enumerator
kAbout 
kQuit 
kServicesSubmenu 
kHide 
kHideOtherApplications 
kShowAllApplications 
kStartSpeaking 
kStopSpeaking 
kToggleFullScreen 
kMinimizeWindow 
kZoomWindow 
kArrangeWindowsInFront 

Definition at line 12 of file platform_provided_menu.h.

12  {
13  // orderFrontStandardAboutPanel macOS provided menu
14  kAbout,
15 
16  // terminate macOS provided menu
17  kQuit,
18 
19  // Services macOS provided submenu.
21 
22  // hide macOS provided menu
23  kHide,
24 
25  // hideOtherApplications macOS provided menu
27 
28  // unhideAllApplications macOS provided menu
30 
31  // startSpeaking macOS provided menu
33 
34  // stopSpeaking macOS provided menu
36 
37  // toggleFullScreen macOS provided menu
39 
40  // performMiniaturize macOS provided menu
42 
43  // performZoom macOS provided menu
45 
46  // arrangeInFront macOS provided menu
48 };

◆ WindowArchetype

Enumerator
kRegular 
kDialog 
kTooltip 
kPopup 
kSatellite 

Definition at line 11 of file windowing.h.

11  {
12  // Regular top-level window.
13  kRegular,
14 
15  // Dialog window.
16  kDialog,
17 
18  // Tooltip window.
19  kTooltip,
20 
21  // Popup window.
22  kPopup,
23 
24  // Satellite window.
25  kSatellite,
26 };

Function Documentation

◆ AppLifecycleStateToString()

constexpr const char* flutter::AppLifecycleStateToString ( AppLifecycleState  state)
constexpr

Definition at line 72 of file app_lifecycle_state.h.

72  {
73  switch (state) {
74  case AppLifecycleState::kDetached:
75  return "AppLifecycleState.detached";
76  case AppLifecycleState::kResumed:
77  return "AppLifecycleState.resumed";
78  case AppLifecycleState::kInactive:
79  return "AppLifecycleState.inactive";
80  case AppLifecycleState::kHidden:
81  return "AppLifecycleState.hidden";
82  case AppLifecycleState::kPaused:
83  return "AppLifecycleState.paused";
84  }
85 }

References kDetached, kHidden, kInactive, kPaused, and kResumed.

◆ CheckEncodeDecode()

static void flutter::CheckEncodeDecode ( const EncodableValue &  value,
const std::vector< uint8_t > &  expected_encoding,
const StandardCodecSerializer *  serializer = nullptr,
const std::function< bool(const EncodableValue &a, const EncodableValue &b)> &  custom_comparator = nullptr 
)
static

Definition at line 37 of file standard_message_codec_unittests.cc.

42  {
43  const StandardMessageCodec& codec =
44  StandardMessageCodec::GetInstance(serializer);
45  auto encoded = codec.EncodeMessage(value);
46  ASSERT_TRUE(encoded);
47  EXPECT_EQ(*encoded, expected_encoding);
48 
49  auto decoded = codec.DecodeMessage(*encoded);
50  if (custom_comparator) {
51  EXPECT_TRUE(custom_comparator(value, *decoded));
52  } else {
53  EXPECT_EQ(value, *decoded);
54  }
55 }

References flutter::MessageCodec< T >::DecodeMessage(), flutter::MessageCodec< T >::EncodeMessage(), and flutter::StandardMessageCodec::GetInstance().

Referenced by TEST().

◆ CheckEncodeDecodeWithEncodePrefix()

static void flutter::CheckEncodeDecodeWithEncodePrefix ( const EncodableValue &  value,
const std::vector< uint8_t > &  expected_encoding_prefix,
size_t  expected_encoding_length 
)
static

Definition at line 62 of file standard_message_codec_unittests.cc.

65  {
66  EXPECT_TRUE(std::holds_alternative<EncodableMap>(value));
67  const StandardMessageCodec& codec = StandardMessageCodec::GetInstance();
68  auto encoded = codec.EncodeMessage(value);
69  ASSERT_TRUE(encoded);
70 
71  EXPECT_EQ(encoded->size(), expected_encoding_length);
72  ASSERT_GT(encoded->size(), expected_encoding_prefix.size());
73  EXPECT_TRUE(std::equal(
74  encoded->begin(), encoded->begin() + expected_encoding_prefix.size(),
75  expected_encoding_prefix.begin(), expected_encoding_prefix.end()));
76 
77  auto decoded = codec.DecodeMessage(*encoded);
78 
79  EXPECT_EQ(value, *decoded);
80 }

References flutter::MessageCodec< T >::DecodeMessage(), flutter::MessageCodec< T >::EncodeMessage(), and flutter::StandardMessageCodec::GetInstance().

Referenced by TEST().

◆ CommandLineFromNSProcessInfo()

fml::CommandLine flutter::CommandLineFromNSProcessInfo ( NSProcessInfo *  processInfoOrNil = nil)

Definition at line 13 of file command_line.mm.

13  {
14  std::vector<std::string> args_vector;
15  auto processInfo = processInfoOrNil ? processInfoOrNil : [NSProcessInfo processInfo];
16 
17  for (NSString* arg in processInfo.arguments) {
18  args_vector.emplace_back(arg.UTF8String);
19  }
20 
21  return fml::CommandLineFromIterators(args_vector.begin(), args_vector.end());
22 }

◆ ConvertMappingToNSData()

NSData * flutter::ConvertMappingToNSData ( fml::MallocMapping  buffer)

Definition at line 34 of file buffer_conversions.mm.

34  {
35  size_t size = buffer.GetSize();
36  return [NSData dataWithBytesNoCopy:buffer.Release() length:size];
37 }

◆ ConvertNSDataToMappingPtr()

std::unique_ptr< fml::Mapping > flutter::ConvertNSDataToMappingPtr ( NSData *  data)

Definition at line 39 of file buffer_conversions.mm.

39  {
40  return std::make_unique<NSDataMapping>(data);
41 }

◆ CopyMappingPtrToNSData()

NSData * flutter::CopyMappingPtrToNSData ( std::unique_ptr< fml::Mapping >  mapping)

Definition at line 43 of file buffer_conversions.mm.

43  {
44  return [NSData dataWithBytes:mapping->GetMapping() length:mapping->GetSize()];
45 }

◆ CopyNSDataToMapping()

fml::MallocMapping flutter::CopyNSDataToMapping ( NSData *  data)

Definition at line 29 of file buffer_conversions.mm.

29  {
30  const uint8_t* bytes = static_cast<const uint8_t*>(data.bytes);
31  return fml::MallocMapping::Copy(bytes, data.length);
32 }

◆ elementSizeForFlutterStandardDataType()

UInt8 flutter::elementSizeForFlutterStandardDataType ( FlutterStandardDataType  type)

Definition at line 45 of file FlutterStandardCodec_Internal.h.

45  {
46  switch (type) {
47  case FlutterStandardDataTypeUInt8:
48  return 1;
49  case FlutterStandardDataTypeInt32:
50  return 4;
51  case FlutterStandardDataTypeInt64:
52  return 8;
53  case FlutterStandardDataTypeFloat32:
54  return 4;
55  case FlutterStandardDataTypeFloat64:
56  return 8;
57  }
58 }

Referenced by FlutterStandardReaderWriter::readerWithData:.

◆ FlutterStandardDataTypeForField()

FlutterStandardDataType flutter::FlutterStandardDataTypeForField ( FlutterStandardField  field)

Definition at line 27 of file FlutterStandardCodec_Internal.h.

28  {
29  switch (field) {
31  return FlutterStandardDataTypeUInt8;
33  return FlutterStandardDataTypeInt32;
35  return FlutterStandardDataTypeInt64;
37  return FlutterStandardDataTypeFloat32;
39  return FlutterStandardDataTypeFloat64;
40  default:
41  return FlutterStandardDataTypeUInt8;
42  }
43 }
@ FlutterStandardFieldUInt8Data
@ FlutterStandardFieldFloat32Data
@ FlutterStandardFieldInt64Data
@ FlutterStandardFieldInt32Data
@ FlutterStandardFieldFloat64Data

References FlutterStandardFieldFloat32Data, FlutterStandardFieldFloat64Data, FlutterStandardFieldInt32Data, FlutterStandardFieldInt64Data, and FlutterStandardFieldUInt8Data.

Referenced by FlutterStandardReaderWriter::readerWithData:.

◆ FlutterStandardFieldForDataType()

FlutterStandardField flutter::FlutterStandardFieldForDataType ( FlutterStandardDataType  type)

Definition at line 12 of file FlutterStandardCodec_Internal.h.

13  {
14  switch (type) {
15  case FlutterStandardDataTypeUInt8:
17  case FlutterStandardDataTypeInt32:
19  case FlutterStandardDataTypeInt64:
21  case FlutterStandardDataTypeFloat32:
23  case FlutterStandardDataTypeFloat64:
25  }
26 }

References FlutterStandardFieldFloat32Data, FlutterStandardFieldFloat64Data, FlutterStandardFieldInt32Data, FlutterStandardFieldInt64Data, and FlutterStandardFieldUInt8Data.

Referenced by FlutterStandardWriter::writeValue:.

◆ GetExecutableDirectory()

std::filesystem::path flutter::GetExecutableDirectory ( )

Definition at line 16 of file path_utils.cc.

16  {
17 #if defined(_WIN32)
18  wchar_t buffer[MAX_PATH];
19  if (GetModuleFileName(nullptr, buffer, MAX_PATH) == 0) {
20  return std::filesystem::path();
21  }
22  std::filesystem::path executable_path(buffer);
23  return executable_path.remove_filename();
24 #elif defined(__linux__)
25  char buffer[PATH_MAX];
26  ssize_t length = readlink("/proc/self/exe", buffer, sizeof(buffer));
27  if (length < 0) {
28  return std::filesystem::path();
29  }
30  std::filesystem::path executable_path(std::string(buffer, length));
31  return executable_path.remove_filename();
32 #else
33  return std::filesystem::path();
34 #endif
35 }

Referenced by TEST().

◆ GetSwitchesFromEnvironment()

std::vector< std::string > flutter::GetSwitchesFromEnvironment ( )

Definition at line 14 of file engine_switches.cc.

14  {
15  std::vector<std::string> switches;
16  // Read engine switches from the environment in debug/profile. If release mode
17  // support is needed in the future, it should likely use a whitelist.
18 #ifndef FLUTTER_RELEASE
19  const char* switch_count_key = "FLUTTER_ENGINE_SWITCHES";
20  const int kMaxSwitchCount = 50;
21  const char* switch_count_string = std::getenv(switch_count_key);
22  if (!switch_count_string) {
23  return switches;
24  }
25  int switch_count = std::min(kMaxSwitchCount, atoi(switch_count_string));
26  for (int i = 1; i <= switch_count; ++i) {
27  std::ostringstream switch_key;
28  switch_key << "FLUTTER_ENGINE_SWITCH_" << i;
29  const char* switch_value = std::getenv(switch_key.str().c_str());
30  if (switch_value) {
31  std::ostringstream switch_value_as_flag;
32  switch_value_as_flag << "--" << switch_value;
33  switches.push_back(switch_value_as_flag.str());
34  } else {
35  std::cerr << switch_count << " keys expected from " << switch_count_key
36  << ", but " << switch_key.str() << " is missing." << std::endl;
37  }
38  }
39 #endif // !FLUTTER_RELEASE
40  return switches;
41 }

Referenced by TEST().

◆ IsEncodedVersionLessThanOrSame()

bool flutter::IsEncodedVersionLessThanOrSame ( uint32_t  encoded_lhs,
ProductVersion  rhs 
)

Definition at line 122 of file availability_version_check.cc.

122  {
123  // Parse the values out of encoded_lhs, then compare against rhs.
124  const int32_t major = (encoded_lhs >> 16) & 0xffff;
125  const int32_t minor = (encoded_lhs >> 8) & 0xff;
126  const int32_t subminor = encoded_lhs & 0xff;
127  auto lhs = ProductVersion{major, minor, subminor};
128 
129  return lhs <= rhs;
130 }
std::tuple< int32_t, int32_t, int32_t > ProductVersion

Referenced by TEST().

◆ operator==()

bool flutter::operator== ( const LayoutGoal &  a,
const LayoutGoal &  b 
)

Definition at line 12 of file KeyCodeMapTest.mm.

12  {
13  return a.keyCode == b.keyCode && a.keyChar == b.keyChar && a.mandatory == b.mandatory;
14 }

References flutter::LayoutGoal::keyChar, flutter::LayoutGoal::keyCode, and flutter::LayoutGoal::mandatory.

◆ ProductVersionFromSystemVersionPList()

std::optional< ProductVersion > flutter::ProductVersionFromSystemVersionPList ( )

Definition at line 53 of file availability_version_check.cc.

53  {
54  std::string plist_path = "/System/Library/CoreServices/SystemVersion.plist";
55 #if FML_OS_IOS_SIMULATOR
56  char* plist_path_prefix = getenv("IPHONE_SIMULATOR_ROOT");
57  if (!plist_path_prefix) {
58  FML_DLOG(ERROR) << "Failed to getenv IPHONE_SIMULATOR_ROOT";
59  return std::nullopt;
60  }
61  plist_path = std::string(plist_path_prefix) + plist_path;
62 #endif // FML_OS_IOS_SIMULATOR
63 
64  auto plist_mapping = fml::FileMapping::CreateReadOnly(plist_path);
65 
66  // Get the file buffer into CF's format. We pass in a null allocator here *
67  // because we free PListBuf ourselves
68  auto file_contents = fml::CFRef<CFDataRef>(CFDataCreateWithBytesNoCopy(
69  nullptr, plist_mapping->GetMapping(),
70  static_cast<CFIndex>(plist_mapping->GetSize()), kCFAllocatorNull));
71  if (!file_contents) {
72  FML_DLOG(ERROR) << "Failed to CFDataCreateWithBytesNoCopyFunc";
73  return std::nullopt;
74  }
75 
76  auto plist = fml::CFRef<CFDictionaryRef>(
77  reinterpret_cast<CFDictionaryRef>(CFPropertyListCreateWithData(
78  nullptr, file_contents, CF_PROPERTY_LIST_IMMUTABLE, nullptr,
79  nullptr)));
80  if (!plist) {
81  FML_DLOG(ERROR) << "Failed to CFPropertyListCreateWithDataFunc or "
82  "CFPropertyListCreateFromXMLDataFunc";
83  return std::nullopt;
84  }
85 
86  auto product_version =
87  fml::CFRef<CFStringRef>(CFStringCreateWithCStringNoCopy(
88  nullptr, "ProductVersion", kCFStringEncodingASCII, kCFAllocatorNull));
89  if (!product_version) {
90  FML_DLOG(ERROR) << "Failed to CFStringCreateWithCStringNoCopyFunc";
91  return std::nullopt;
92  }
93  CFTypeRef opaque_value = CFDictionaryGetValue(plist, product_version);
94  if (!opaque_value || CFGetTypeID(opaque_value) != CFStringGetTypeID()) {
95  FML_DLOG(ERROR) << "Failed to CFDictionaryGetValueFunc";
96  return std::nullopt;
97  }
98 
99  char version_str[32];
100  if (!CFStringGetCString(reinterpret_cast<CFStringRef>(opaque_value),
101  version_str, sizeof(version_str),
102  kCFStringEncodingUTF8)) {
103  FML_DLOG(ERROR) << "Failed to CFStringGetCStringFunc";
104  return std::nullopt;
105  }
106 
107  int32_t major = 0;
108  int32_t minor = 0;
109  int32_t subminor = 0;
110  int matches = sscanf(version_str, "%d.%d.%d", &major, &minor, &subminor);
111  // A major version number is sufficient. The minor and subminor numbers might
112  // not be present.
113  if (matches < 1) {
114  FML_DLOG(ERROR) << "Failed to match product version string: "
115  << version_str;
116  return std::nullopt;
117  }
118 
119  return ProductVersion{major, minor, subminor};
120 }
#define CF_PROPERTY_LIST_IMMUTABLE

References CF_PROPERTY_LIST_IMMUTABLE.

Referenced by TEST().

◆ TEST() [1/306]

flutter::TEST ( BasicMessageChannelTest  ,
Registration   
)

Definition at line 58 of file basic_message_channel_unittests.cc.

58  {
59  TestBinaryMessenger messenger;
60  const std::string channel_name("some_channel");
61  const StandardMessageCodec& codec = StandardMessageCodec::GetInstance();
62  BasicMessageChannel channel(&messenger, channel_name, &codec);
63 
64  bool callback_called = false;
65  const std::string message_value("hello");
66  channel.SetMessageHandler([&callback_called, message_value](
67  const auto& message, const auto& reply) {
68  callback_called = true;
69  // Ensure that the wrapper received a correctly decoded message and a
70  // reply.
71  EXPECT_EQ(std::get<std::string>(message), message_value);
72  EXPECT_NE(reply, nullptr);
73  });
74  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
75  EXPECT_NE(messenger.last_message_handler(), nullptr);
76  // Send a test message to trigger the handler test assertions.
77  auto message = codec.EncodeMessage(EncodableValue(message_value));
78 
79  messenger.last_message_handler()(
80  message->data(), message->size(),
81  [](const uint8_t* reply, const size_t reply_size) {});
82  EXPECT_EQ(callback_called, true);
83 }

References flutter::MessageCodec< T >::EncodeMessage(), flutter::StandardMessageCodec::GetInstance(), and flutter::BasicMessageChannel< T >::SetMessageHandler().

◆ TEST() [2/306]

flutter::TEST ( BasicMessageChannelTest  ,
Resize   
)

Definition at line 103 of file basic_message_channel_unittests.cc.

103  {
104  TestBinaryMessenger messenger;
105  const std::string channel_name("flutter/test");
106  BasicMessageChannel channel(&messenger, channel_name,
108 
109  channel.Resize(3);
110 
111  // Because the Dart implementation for the control channel implements its own
112  // custom deserialization logic, this test compares the generated bytes array
113  // to the expected one (for instance, the deserialization logic expects the
114  // size parameter of the resize method call to be an uint32).
115  //
116  // The expected content was created from the following Dart code:
117  // MethodCall call = MethodCall('resize', ['flutter/test',3]);
118  // StandardMethodCodec().encodeMethodCall(call).buffer.asUint8List();
119  const int expected_message_size = 29;
120 
121  EXPECT_EQ(messenger.send_called(), true);
122  EXPECT_EQ(static_cast<int>(messenger.last_message().size()),
123  expected_message_size);
124 
125  int expected[expected_message_size] = {
126  7, 6, 114, 101, 115, 105, 122, 101, 12, 2, 7, 12, 102, 108, 117,
127  116, 116, 101, 114, 47, 116, 101, 115, 116, 3, 3, 0, 0, 0};
128  for (int i = 0; i < expected_message_size; i++) {
129  EXPECT_EQ(messenger.last_message()[i], expected[i]);
130  }
131 }
static const StandardMessageCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)

References flutter::StandardMessageCodec::GetInstance(), and flutter::BasicMessageChannel< T >::Resize().

◆ TEST() [3/306]

flutter::TEST ( BasicMessageChannelTest  ,
SetWarnsOnOverflow   
)

Definition at line 135 of file basic_message_channel_unittests.cc.

135  {
136  TestBinaryMessenger messenger;
137 
138  const std::string channel_name("flutter/test");
139  BasicMessageChannel channel(&messenger, channel_name,
141 
142  channel.SetWarnsOnOverflow(false);
143 
144  // Because the Dart implementation for the control channel implements its own
145  // custom deserialization logic, this test compares the generated bytes array
146  // to the expected one.
147  //
148  // The expected content was created from the following Dart code:
149  // MethodCall call = MethodCall('overflow',['flutter/test', true]);
150  // StandardMethodCodec().encodeMethodCall(call).buffer.asUint8List();
151  const int expected_message_size = 27;
152 
153  EXPECT_EQ(messenger.send_called(), true);
154  EXPECT_EQ(static_cast<int>(messenger.last_message().size()),
155  expected_message_size);
156 
157  int expected[expected_message_size] = {
158  7, 8, 111, 118, 101, 114, 102, 108, 111, 119, 12, 2, 7, 12,
159  102, 108, 117, 116, 116, 101, 114, 47, 116, 101, 115, 116, 1};
160  for (int i = 0; i < expected_message_size; i++) {
161  EXPECT_EQ(messenger.last_message()[i], expected[i]);
162  }
163 }

References flutter::StandardMessageCodec::GetInstance(), and flutter::BasicMessageChannel< T >::SetWarnsOnOverflow().

◆ TEST() [4/306]

flutter::TEST ( BasicMessageChannelTest  ,
Unregistration   
)

Definition at line 86 of file basic_message_channel_unittests.cc.

86  {
87  TestBinaryMessenger messenger;
88  const std::string channel_name("some_channel");
89  BasicMessageChannel channel(&messenger, channel_name,
91 
92  channel.SetMessageHandler([](const auto& message, const auto& reply) {});
93  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
94  EXPECT_NE(messenger.last_message_handler(), nullptr);
95 
96  channel.SetMessageHandler(nullptr);
97  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
98  EXPECT_EQ(messenger.last_message_handler(), nullptr);
99 }

References flutter::StandardMessageCodec::GetInstance(), and flutter::BasicMessageChannel< T >::SetMessageHandler().

◆ TEST() [5/306]

flutter::TEST ( EncodableValueTest  ,
Bool   
)

Definition at line 18 of file encodable_value_unittests.cc.

18  {
19  EncodableValue value(false);
20 
21  EXPECT_FALSE(std::get<bool>(value));
22  value = true;
23  EXPECT_TRUE(std::get<bool>(value));
24 }

◆ TEST() [6/306]

flutter::TEST ( EncodableValueTest  ,
Comparison   
)

Definition at line 177 of file encodable_value_unittests.cc.

177  {
178  EncodableList values = {
179  // Null
180  EncodableValue(),
181  // Bool
182  EncodableValue(true),
183  EncodableValue(false),
184  // Int
185  EncodableValue(-7),
186  EncodableValue(0),
187  EncodableValue(100),
188  // Long
189  EncodableValue(INT64_C(-7)),
190  EncodableValue(INT64_C(0)),
191  EncodableValue(INT64_C(100)),
192  // Double
193  EncodableValue(-7.0),
194  EncodableValue(0.0),
195  EncodableValue(100.0),
196  // String
197  EncodableValue("one"),
198  EncodableValue("two"),
199  // ByteList
200  EncodableValue(std::vector<uint8_t>{0, 1}),
201  EncodableValue(std::vector<uint8_t>{0, 10}),
202  // IntList
203  EncodableValue(std::vector<int32_t>{0, 1}),
204  EncodableValue(std::vector<int32_t>{0, 100}),
205  // LongList
206  EncodableValue(std::vector<int64_t>{0, INT64_C(1)}),
207  EncodableValue(std::vector<int64_t>{0, INT64_C(100)}),
208  // DoubleList
209  EncodableValue(std::vector<double>{0, INT64_C(1)}),
210  EncodableValue(std::vector<double>{0, INT64_C(100)}),
211  // List
212  EncodableValue(EncodableList{EncodableValue(), EncodableValue(true)}),
213  EncodableValue(EncodableList{EncodableValue(), EncodableValue(1.0)}),
214  // Map
215  EncodableValue(EncodableMap{{EncodableValue(), EncodableValue(true)},
216  {EncodableValue(7), EncodableValue(7.0)}}),
217  EncodableValue(
218  EncodableMap{{EncodableValue(), EncodableValue(1.0)},
219  {EncodableValue("key"), EncodableValue("value")}}),
220  // FloatList
221  EncodableValue(std::vector<float>{0, 1}),
222  EncodableValue(std::vector<float>{0, 100}),
223  };
224 
225  for (size_t i = 0; i < values.size(); ++i) {
226  const auto& a = values[i];
227  for (size_t j = 0; j < values.size(); ++j) {
228  const auto& b = values[j];
229  if (i == j) {
230  // Identical objects should always be equal.
231  EXPECT_FALSE(a < b);
232  EXPECT_FALSE(b < a);
233  } else {
234  // All other comparisons should be consistent, but the direction doesn't
235  // matter.
236  EXPECT_NE(a < b, b < a) << "Indexes: " << i << ", " << j;
237  }
238  }
239 
240  // Copies should always be equal.
241  EncodableValue copy(a);
242  EXPECT_FALSE(a < copy || copy < a);
243  }
244 }
std::vector< EncodableValue > EncodableList
std::map< EncodableValue, EncodableValue > EncodableMap

◆ TEST() [7/306]

flutter::TEST ( EncodableValueTest  ,
CString   
)

Definition at line 68 of file encodable_value_unittests.cc.

68  {
69  const char* hello = "Hello, world!";
70  EncodableValue value(hello);
71 
72  EXPECT_EQ(std::get<std::string>(value), hello);
73  value = "Goodbye";
74  EXPECT_EQ(std::get<std::string>(value), "Goodbye");
75 }

◆ TEST() [8/306]

flutter::TEST ( EncodableValueTest  ,
DeepCopy   
)

Definition at line 247 of file encodable_value_unittests.cc.

247  {
248  EncodableList original = {
249  EncodableValue(EncodableMap{
250  {EncodableValue(), EncodableValue(std::vector<int32_t>{1, 2, 3})},
251  {EncodableValue(1), EncodableValue(INT64_C(0000))},
252  {EncodableValue("two"), EncodableValue(7)},
253  }),
254  EncodableValue(EncodableList{
255  EncodableValue(),
256  EncodableValue(),
257  EncodableValue(
258  EncodableMap{{EncodableValue("a"), EncodableValue("b")}}),
259  }),
260  };
261 
262  EncodableValue copy(original);
263  ASSERT_TRUE(std::holds_alternative<EncodableList>(copy));
264 
265  // Spot-check innermost collection values.
266  auto& root_list = std::get<EncodableList>(copy);
267  auto& first_child = std::get<EncodableMap>(root_list[0]);
268  EXPECT_EQ(std::get<int32_t>(first_child[EncodableValue("two")]), 7);
269  auto& second_child = std::get<EncodableList>(root_list[1]);
270  auto& innermost_map = std::get<EncodableMap>(second_child[2]);
271  EXPECT_EQ(std::get<std::string>(innermost_map[EncodableValue("a")]), "b");
272 
273  // Modify those values in the original structure.
274  first_child[EncodableValue("two")] = EncodableValue();
275  innermost_map[EncodableValue("a")] = 99;
276 
277  // Re-check innermost collection values of the original to ensure that they
278  // haven't changed.
279  first_child = std::get<EncodableMap>(original[0]);
280  EXPECT_EQ(std::get<int32_t>(first_child[EncodableValue("two")]), 7);
281  second_child = std::get<EncodableList>(original[1]);
282  innermost_map = std::get<EncodableMap>(second_child[2]);
283  EXPECT_EQ(std::get<std::string>(innermost_map[EncodableValue("a")]), "b");
284 }

◆ TEST() [9/306]

flutter::TEST ( EncodableValueTest  ,
Double   
)

Definition at line 50 of file encodable_value_unittests.cc.

50  {
51  EncodableValue value(3.14);
52 
53  EXPECT_EQ(std::get<double>(value), 3.14);
54  value = std::numeric_limits<double>::max();
55  EXPECT_EQ(std::get<double>(value), std::numeric_limits<double>::max());
56 }

◆ TEST() [10/306]

flutter::TEST ( EncodableValueTest  ,
DoubleList   
)

Definition at line 119 of file encodable_value_unittests.cc.

119  {
120  std::vector<double> data = {-10.0, 2.0};
121  EncodableValue value(data);
122 
123  auto& list_value = std::get<std::vector<double>>(value);
124  list_value.push_back(std::numeric_limits<double>::max());
125  EXPECT_EQ(list_value[0], -10.0);
126  EXPECT_EQ(list_value[1], 2.0);
127 
128  ASSERT_EQ(list_value.size(), 3u);
129  EXPECT_EQ(data.size(), 2u);
130  EXPECT_EQ(list_value[2], std::numeric_limits<double>::max());
131 }

◆ TEST() [11/306]

flutter::TEST ( EncodableValueTest  ,
Int   
)

Definition at line 26 of file encodable_value_unittests.cc.

26  {
27  EncodableValue value(42);
28 
29  EXPECT_EQ(std::get<int32_t>(value), 42);
30  value = std::numeric_limits<int32_t>::max();
31  EXPECT_EQ(std::get<int32_t>(value), std::numeric_limits<int32_t>::max());
32 }

◆ TEST() [12/306]

flutter::TEST ( EncodableValueTest  ,
Int32List   
)

Definition at line 91 of file encodable_value_unittests.cc.

91  {
92  std::vector<int32_t> data = {-10, 2};
93  EncodableValue value(data);
94 
95  auto& list_value = std::get<std::vector<int32_t>>(value);
96  list_value.push_back(std::numeric_limits<int32_t>::max());
97  EXPECT_EQ(list_value[0], -10);
98  EXPECT_EQ(list_value[1], 2);
99 
100  ASSERT_EQ(list_value.size(), 3u);
101  EXPECT_EQ(data.size(), 2u);
102  EXPECT_EQ(list_value[2], std::numeric_limits<int32_t>::max());
103 }

◆ TEST() [13/306]

flutter::TEST ( EncodableValueTest  ,
Int64List   
)

Definition at line 105 of file encodable_value_unittests.cc.

105  {
106  std::vector<int64_t> data = {-10, 2};
107  EncodableValue value(data);
108 
109  auto& list_value = std::get<std::vector<int64_t>>(value);
110  list_value.push_back(std::numeric_limits<int64_t>::max());
111  EXPECT_EQ(list_value[0], -10);
112  EXPECT_EQ(list_value[1], 2);
113 
114  ASSERT_EQ(list_value.size(), 3u);
115  EXPECT_EQ(data.size(), 2u);
116  EXPECT_EQ(list_value[2], std::numeric_limits<int64_t>::max());
117 }

◆ TEST() [14/306]

flutter::TEST ( EncodableValueTest  ,
List   
)

Definition at line 133 of file encodable_value_unittests.cc.

133  {
134  EncodableList encodables = {
135  EncodableValue(1),
136  EncodableValue(2.0),
137  EncodableValue("Three"),
138  };
139  EncodableValue value(encodables);
140 
141  auto& list_value = std::get<EncodableList>(value);
142  EXPECT_EQ(std::get<int32_t>(list_value[0]), 1);
143  EXPECT_EQ(std::get<double>(list_value[1]), 2.0);
144  EXPECT_EQ(std::get<std::string>(list_value[2]), "Three");
145 
146  // Ensure that it's a modifiable copy of the original array.
147  list_value.push_back(EncodableValue(true));
148  ASSERT_EQ(list_value.size(), 4u);
149  EXPECT_EQ(encodables.size(), 3u);
150  EXPECT_EQ(std::get<bool>(std::get<EncodableList>(value)[3]), true);
151 }

◆ TEST() [15/306]

flutter::TEST ( EncodableValueTest  ,
Long   
)

Definition at line 42 of file encodable_value_unittests.cc.

42  {
43  EncodableValue value(INT64_C(42));
44 
45  EXPECT_EQ(std::get<int64_t>(value), 42);
46  value = std::numeric_limits<int64_t>::max();
47  EXPECT_EQ(std::get<int64_t>(value), std::numeric_limits<int64_t>::max());
48 }

◆ TEST() [16/306]

flutter::TEST ( EncodableValueTest  ,
LongValue   
)

Definition at line 35 of file encodable_value_unittests.cc.

35  {
36  const EncodableValue int_value(std::numeric_limits<int32_t>::max());
37  EXPECT_EQ(int_value.LongValue(), std::numeric_limits<int32_t>::max());
38  const EncodableValue long_value(std::numeric_limits<int64_t>::max());
39  EXPECT_EQ(long_value.LongValue(), std::numeric_limits<int64_t>::max());
40 }

References flutter::EncodableValue::LongValue().

◆ TEST() [17/306]

flutter::TEST ( EncodableValueTest  ,
Map   
)

Definition at line 153 of file encodable_value_unittests.cc.

153  {
154  EncodableMap encodables = {
155  {EncodableValue(), EncodableValue(std::vector<int32_t>{1, 2, 3})},
156  {EncodableValue(1), EncodableValue(INT64_C(10000))},
157  {EncodableValue("two"), EncodableValue(7)},
158  };
159  EncodableValue value(encodables);
160 
161  auto& map_value = std::get<EncodableMap>(value);
162  EXPECT_EQ(
163  std::holds_alternative<std::vector<int32_t>>(map_value[EncodableValue()]),
164  true);
165  EXPECT_EQ(std::get<int64_t>(map_value[EncodableValue(1)]), INT64_C(10000));
166  EXPECT_EQ(std::get<int32_t>(map_value[EncodableValue("two")]), 7);
167 
168  // Ensure that it's a modifiable copy of the original map.
169  map_value[EncodableValue(true)] = EncodableValue(false);
170  ASSERT_EQ(map_value.size(), 4u);
171  EXPECT_EQ(encodables.size(), 3u);
172  EXPECT_EQ(std::get<bool>(map_value[EncodableValue(true)]), false);
173 }

◆ TEST() [18/306]

flutter::TEST ( EncodableValueTest  ,
Null   
)

Definition at line 13 of file encodable_value_unittests.cc.

13  {
14  EncodableValue value;
15  value.IsNull();
16 }

References flutter::EncodableValue::IsNull().

◆ TEST() [19/306]

flutter::TEST ( EncodableValueTest  ,
String   
)

Definition at line 58 of file encodable_value_unittests.cc.

58  {
59  std::string hello("Hello, world!");
60  EncodableValue value(hello);
61 
62  EXPECT_EQ(std::get<std::string>(value), hello);
63  value = std::string("Goodbye");
64  EXPECT_EQ(std::get<std::string>(value), "Goodbye");
65 }

◆ TEST() [20/306]

flutter::TEST ( EncodableValueTest  ,
TypeIndexesCorrect   
)

Definition at line 301 of file encodable_value_unittests.cc.

301  {
302  // Null
303  EXPECT_EQ(EncodableValue().index(), 0u);
304  // Bool
305  EXPECT_EQ(EncodableValue(true).index(), 1u);
306  // Int32
307  EXPECT_EQ(EncodableValue(100).index(), 2u);
308  // Int64
309  EXPECT_EQ(EncodableValue(INT64_C(100)).index(), 3u);
310  // Double
311  EXPECT_EQ(EncodableValue(7.0).index(), 4u);
312  // String
313  EXPECT_EQ(EncodableValue("one").index(), 5u);
314  // ByteList
315  EXPECT_EQ(EncodableValue(std::vector<uint8_t>()).index(), 6u);
316  // IntList
317  EXPECT_EQ(EncodableValue(std::vector<int32_t>()).index(), 7u);
318  // LongList
319  EXPECT_EQ(EncodableValue(std::vector<int64_t>()).index(), 8u);
320  // DoubleList
321  EXPECT_EQ(EncodableValue(std::vector<double>()).index(), 9u);
322  // List
323  EXPECT_EQ(EncodableValue(EncodableList()).index(), 10u);
324  // Map
325  EXPECT_EQ(EncodableValue(EncodableMap()).index(), 11u);
326  // Custom type
327  TestCustomValue customValue;
328  EXPECT_EQ(((EncodableValue)CustomEncodableValue(customValue)).index(), 12u);
329  // FloatList
330  EXPECT_EQ(EncodableValue(std::vector<float>()).index(), 13u);
331 } // namespace flutter

◆ TEST() [21/306]

flutter::TEST ( EncodableValueTest  ,
UInt8List   
)

Definition at line 77 of file encodable_value_unittests.cc.

77  {
78  std::vector<uint8_t> data = {0, 2};
79  EncodableValue value(data);
80 
81  auto& list_value = std::get<std::vector<uint8_t>>(value);
82  list_value.push_back(std::numeric_limits<uint8_t>::max());
83  EXPECT_EQ(list_value[0], 0);
84  EXPECT_EQ(list_value[1], 2);
85 
86  ASSERT_EQ(list_value.size(), 3u);
87  EXPECT_EQ(data.size(), 2u);
88  EXPECT_EQ(list_value[2], std::numeric_limits<uint8_t>::max());
89 }

◆ TEST() [22/306]

flutter::TEST ( EventChannelTest  ,
Cancel   
)

Definition at line 102 of file event_channel_unittests.cc.

102  {
103  TestBinaryMessenger messenger;
104  const std::string channel_name("some_channel");
105  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
106  EventChannel channel(&messenger, channel_name, &codec);
107 
108  bool on_listen_called = false;
109  bool on_cancel_called = false;
110  auto handler = std::make_unique<StreamHandlerFunctions<>>(
111  [&on_listen_called](const EncodableValue* arguments,
112  std::unique_ptr<EventSink<>>&& events)
113  -> std::unique_ptr<StreamHandlerError<>> {
114  on_listen_called = true;
115  return nullptr;
116  },
117  [&on_cancel_called](const EncodableValue* arguments)
118  -> std::unique_ptr<StreamHandlerError<>> {
119  on_cancel_called = true;
120  return nullptr;
121  });
122  channel.SetStreamHandler(std::move(handler));
123  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
124  EXPECT_NE(messenger.last_message_handler(), nullptr);
125 
126  // Send test listen message.
127  MethodCall<> call_listen("listen", nullptr);
128  auto message = codec.EncodeMethodCall(call_listen);
129  messenger.last_message_handler()(
130  message->data(), message->size(),
131  [](const uint8_t* reply, const size_t reply_size) {});
132  EXPECT_EQ(on_listen_called, true);
133 
134  // Send test cancel message.
135  MethodCall<> call_cancel("cancel", nullptr);
136  message = codec.EncodeMethodCall(call_cancel);
137  messenger.last_message_handler()(
138  message->data(), message->size(),
139  [](const uint8_t* reply, const size_t reply_size) {});
140 
141  // Check results.
142  EXPECT_EQ(on_cancel_called, true);
143 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::StandardMethodCodec::GetInstance(), and flutter::EventChannel< T >::SetStreamHandler().

◆ TEST() [23/306]

flutter::TEST ( EventChannelTest  ,
HandlerOutlivesEventChannel   
)

Definition at line 232 of file event_channel_unittests.cc.

232  {
233  TestBinaryMessenger messenger;
234  const std::string channel_name("some_channel");
235  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
236 
237  bool on_listen_called = false;
238  bool on_cancel_called = false;
239  {
240  EventChannel channel(&messenger, channel_name, &codec);
241  auto handler = std::make_unique<StreamHandlerFunctions<>>(
242  [&on_listen_called](const EncodableValue* arguments,
243  std::unique_ptr<EventSink<>>&& events)
244  -> std::unique_ptr<StreamHandlerError<>> {
245  on_listen_called = true;
246  return nullptr;
247  },
248  [&on_cancel_called](const EncodableValue* arguments)
249  -> std::unique_ptr<StreamHandlerError<>> {
250  on_cancel_called = true;
251  return nullptr;
252  });
253  channel.SetStreamHandler(std::move(handler));
254  }
255 
256  // The event channel was destroyed but the handler should still be alive.
257  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
258  EXPECT_NE(messenger.last_message_handler(), nullptr);
259 
260  // Send test listen message.
261  MethodCall<> call_listen("listen", nullptr);
262  auto message = codec.EncodeMethodCall(call_listen);
263  messenger.last_message_handler()(
264  message->data(), message->size(),
265  [](const uint8_t* reply, const size_t reply_size) {});
266  EXPECT_EQ(on_listen_called, true);
267 
268  // Send test cancel message.
269  MethodCall<> call_cancel("cancel", nullptr);
270  message = codec.EncodeMethodCall(call_cancel);
271  messenger.last_message_handler()(
272  message->data(), message->size(),
273  [](const uint8_t* reply, const size_t reply_size) {});
274  EXPECT_EQ(on_cancel_called, true);
275 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::StandardMethodCodec::GetInstance(), and flutter::EventChannel< T >::SetStreamHandler().

◆ TEST() [24/306]

flutter::TEST ( EventChannelTest  ,
ListenNotCancel   
)

Definition at line 146 of file event_channel_unittests.cc.

146  {
147  TestBinaryMessenger messenger;
148  const std::string channel_name("some_channel");
149  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
150  EventChannel channel(&messenger, channel_name, &codec);
151 
152  bool on_listen_called = false;
153  bool on_cancel_called = false;
154  auto handler = std::make_unique<StreamHandlerFunctions<>>(
155  [&on_listen_called](const EncodableValue* arguments,
156  std::unique_ptr<EventSink<>>&& events)
157  -> std::unique_ptr<StreamHandlerError<>> {
158  on_listen_called = true;
159  return nullptr;
160  },
161  [&on_cancel_called](const EncodableValue* arguments)
162  -> std::unique_ptr<StreamHandlerError<>> {
163  on_cancel_called = true;
164  return nullptr;
165  });
166  channel.SetStreamHandler(std::move(handler));
167  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
168  EXPECT_NE(messenger.last_message_handler(), nullptr);
169 
170  // Send test listen message.
171  MethodCall<> call_listen("listen", nullptr);
172  auto message = codec.EncodeMethodCall(call_listen);
173  messenger.last_message_handler()(
174  message->data(), message->size(),
175  [](const uint8_t* reply, const size_t reply_size) {});
176 
177  // Check results.
178  EXPECT_EQ(on_listen_called, true);
179  EXPECT_EQ(on_cancel_called, false);
180 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::StandardMethodCodec::GetInstance(), and flutter::EventChannel< T >::SetStreamHandler().

◆ TEST() [25/306]

flutter::TEST ( EventChannelTest  ,
Registration   
)

Definition at line 49 of file event_channel_unittests.cc.

49  {
50  TestBinaryMessenger messenger;
51  const std::string channel_name("some_channel");
52  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
53  EventChannel channel(&messenger, channel_name, &codec);
54 
55  bool on_listen_called = false;
56  auto handler = std::make_unique<StreamHandlerFunctions<>>(
57  [&on_listen_called](const EncodableValue* arguments,
58  std::unique_ptr<EventSink<>>&& events)
59  -> std::unique_ptr<StreamHandlerError<>> {
60  on_listen_called = true;
61  return nullptr;
62  },
63  [](const EncodableValue* arguments)
64  -> std::unique_ptr<StreamHandlerError<>> { return nullptr; });
65  channel.SetStreamHandler(std::move(handler));
66  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
67  EXPECT_NE(messenger.last_message_handler(), nullptr);
68 
69  // Send test listen message.
70  MethodCall<> call("listen", nullptr);
71  auto message = codec.EncodeMethodCall(call);
72  messenger.last_message_handler()(
73  message->data(), message->size(),
74  [](const uint8_t* reply, const size_t reply_size) {});
75 
76  // Check results.
77  EXPECT_EQ(on_listen_called, true);
78 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::StandardMethodCodec::GetInstance(), and flutter::EventChannel< T >::SetStreamHandler().

◆ TEST() [26/306]

flutter::TEST ( EventChannelTest  ,
ReRegistration   
)

Definition at line 186 of file event_channel_unittests.cc.

186  {
187  TestBinaryMessenger messenger;
188  const std::string channel_name("some_channel");
189  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
190  EventChannel channel(&messenger, channel_name, &codec);
191 
192  bool on_listen_called = false;
193  bool on_cancel_called = false;
194  auto handler = std::make_unique<StreamHandlerFunctions<>>(
195  [&on_listen_called](const EncodableValue* arguments,
196  std::unique_ptr<EventSink<>>&& events)
197  -> std::unique_ptr<StreamHandlerError<>> {
198  on_listen_called = true;
199  return nullptr;
200  },
201  [&on_cancel_called](const EncodableValue* arguments)
202  -> std::unique_ptr<StreamHandlerError<>> {
203  on_cancel_called = true;
204  return nullptr;
205  });
206  channel.SetStreamHandler(std::move(handler));
207  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
208  EXPECT_NE(messenger.last_message_handler(), nullptr);
209 
210  // Send test listen message.
211  MethodCall<> call("listen", nullptr);
212  auto message = codec.EncodeMethodCall(call);
213  messenger.last_message_handler()(
214  message->data(), message->size(),
215  [](const uint8_t* reply, const size_t reply_size) {});
216  EXPECT_EQ(on_listen_called, true);
217 
218  // Send second test message to test StreamHandler's OnCancel
219  // method is called before OnListen method is called.
220  on_listen_called = false;
221  message = codec.EncodeMethodCall(call);
222  messenger.last_message_handler()(
223  message->data(), message->size(),
224  [](const uint8_t* reply, const size_t reply_size) {});
225 
226  // Check results.
227  EXPECT_EQ(on_cancel_called, true);
228  EXPECT_EQ(on_listen_called, true);
229 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::StandardMethodCodec::GetInstance(), and flutter::EventChannel< T >::SetStreamHandler().

◆ TEST() [27/306]

flutter::TEST ( EventChannelTest  ,
StreamHandlerErrorNullptr   
)

Definition at line 295 of file event_channel_unittests.cc.

295  {
296  std::unique_ptr<StreamHandlerError<>> error =
297  std::make_unique<StreamHandlerError<>>("Code", "Message", nullptr);
298 
299  ASSERT_NE(error.get(), nullptr);
300  EXPECT_FALSE(error->error_details);
301 }

◆ TEST() [28/306]

flutter::TEST ( EventChannelTest  ,
StreamHandlerErrorPassByValue   
)

Definition at line 277 of file event_channel_unittests.cc.

277  {
278  std::unique_ptr<StreamHandlerError<>> error = nullptr;
279 
280  {
281  std::string code = "Code";
282  std::string msg = "Message";
283  std::unique_ptr<EncodableValue> details =
284  std::make_unique<EncodableValue>("Details");
285  error =
286  std::make_unique<StreamHandlerError<>>(code, msg, std::move(details));
287  }
288 
289  ASSERT_NE(error.get(), nullptr);
290  EXPECT_EQ(error->error_code, "Code");
291  EXPECT_EQ(error->error_message, "Message");
292  EXPECT_EQ(std::get<std::string>(*error->error_details), "Details");
293 }

◆ TEST() [29/306]

flutter::TEST ( EventChannelTest  ,
Unregistration   
)

Definition at line 81 of file event_channel_unittests.cc.

81  {
82  TestBinaryMessenger messenger;
83  const std::string channel_name("some_channel");
84  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
85  EventChannel channel(&messenger, channel_name, &codec);
86 
87  auto handler = std::make_unique<StreamHandlerFunctions<>>(
88  [](const EncodableValue* arguments, std::unique_ptr<EventSink<>>&& events)
89  -> std::unique_ptr<StreamHandlerError<>> { return nullptr; },
90  [](const EncodableValue* arguments)
91  -> std::unique_ptr<StreamHandlerError<>> { return nullptr; });
92  channel.SetStreamHandler(std::move(handler));
93  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
94  EXPECT_NE(messenger.last_message_handler(), nullptr);
95 
96  channel.SetStreamHandler(nullptr);
97  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
98  EXPECT_EQ(messenger.last_message_handler(), nullptr);
99 }

References flutter::StandardMethodCodec::GetInstance(), and flutter::EventChannel< T >::SetStreamHandler().

◆ TEST() [30/306]

flutter::TEST ( FlutterProjectBundle  ,
Switches   
)

Definition at line 50 of file engine_switches_unittests.cc.

50  {
51  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCHES", "2");
52  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCH_1", "abc");
53  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"");
54 
55  std::vector<std::string> switches = GetSwitchesFromEnvironment();
56  EXPECT_EQ(switches.size(), 2U);
57  EXPECT_EQ(switches[0], "--abc");
58  EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
59 }
std::vector< std::string > GetSwitchesFromEnvironment()

References GetSwitchesFromEnvironment().

◆ TEST() [31/306]

flutter::TEST ( FlutterProjectBundle  ,
SwitchesEmpty   
)

Definition at line 31 of file engine_switches_unittests.cc.

31  {
32  // Clear the main environment variable, since test order is not guaranteed.
33  ClearEnvironmentVariable("FLUTTER_ENGINE_SWITCHES");
34 
35  EXPECT_EQ(GetSwitchesFromEnvironment().size(), 0U);
36 }

References GetSwitchesFromEnvironment().

◆ TEST() [32/306]

flutter::TEST ( FlutterProjectBundle  ,
SwitchesExtraValues   
)

Definition at line 61 of file engine_switches_unittests.cc.

61  {
62  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCHES", "1");
63  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCH_1", "abc");
64  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"");
65 
66  std::vector<std::string> switches = GetSwitchesFromEnvironment();
67  EXPECT_EQ(switches.size(), 1U);
68  EXPECT_EQ(switches[0], "--abc");
69 }

References GetSwitchesFromEnvironment().

◆ TEST() [33/306]

flutter::TEST ( FlutterProjectBundle  ,
SwitchesMissingValues   
)

Definition at line 71 of file engine_switches_unittests.cc.

71  {
72  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCHES", "4");
73  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCH_1", "abc");
74  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"");
75  ClearEnvironmentVariable("FLUTTER_ENGINE_SWITCH_3");
76  SetEnvironmentVariable("FLUTTER_ENGINE_SWITCH_4", "oops");
77 
78  std::vector<std::string> switches = GetSwitchesFromEnvironment();
79  EXPECT_EQ(switches.size(), 3U);
80  EXPECT_EQ(switches[0], "--abc");
81  EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
82  // The missing switch should be skipped, leaving SWITCH_4 as the third
83  // switch in the array.
84  EXPECT_EQ(switches[2], "--oops");
85 }

References GetSwitchesFromEnvironment().

◆ TEST() [34/306]

flutter::TEST ( IncomingMessageDispatcher  ,
BlockInputFalse   
)

Definition at line 39 of file incoming_message_dispatcher_unittests.cc.

39  {
40  FlutterDesktopMessengerRef messenger = nullptr;
41  auto dispatcher = std::make_unique<IncomingMessageDispatcher>(messenger);
42  bool did_call[3] = {false, false, false};
43  dispatcher->SetMessageCallback(
44  "hello",
45  [](FlutterDesktopMessengerRef messenger,
46  const FlutterDesktopMessage* message,
47  void* user_data) { reinterpret_cast<bool*>(user_data)[0] = true; },
48  &did_call);
49  FlutterDesktopMessage message = {
51  .channel = "hello",
52  .message = nullptr,
53  .message_size = 0,
54  .response_handle = nullptr,
55  };
56  dispatcher->HandleMessage(
57  message, [&did_call] { did_call[1] = true; },
58  [&did_call] { did_call[2] = true; });
59  EXPECT_TRUE(did_call[0]);
60  EXPECT_FALSE(did_call[1]);
61  EXPECT_FALSE(did_call[2]);
62 }
struct FlutterDesktopMessenger * FlutterDesktopMessengerRef
void * user_data

References FlutterDesktopMessage::struct_size, and user_data.

◆ TEST() [35/306]

flutter::TEST ( IncomingMessageDispatcher  ,
BlockInputTrue   
)

Definition at line 64 of file incoming_message_dispatcher_unittests.cc.

64  {
65  FlutterDesktopMessengerRef messenger = nullptr;
66  auto dispatcher = std::make_unique<IncomingMessageDispatcher>(messenger);
67  static int counter = 0;
68  int did_call[3] = {-1, -1, -1};
69  dispatcher->EnableInputBlockingForChannel("hello");
70  dispatcher->SetMessageCallback(
71  "hello",
72  [](FlutterDesktopMessengerRef messenger,
73  const FlutterDesktopMessage* message,
74  void* user_data) { reinterpret_cast<int*>(user_data)[counter++] = 1; },
75  &did_call);
76  FlutterDesktopMessage message = {
78  .channel = "hello",
79  .message = nullptr,
80  .message_size = 0,
81  .response_handle = nullptr,
82  };
83  dispatcher->HandleMessage(
84  message, [&did_call] { did_call[counter++] = 0; },
85  [&did_call] { did_call[counter++] = 2; });
86  EXPECT_EQ(did_call[0], 0);
87  EXPECT_EQ(did_call[1], 1);
88  EXPECT_EQ(did_call[2], 2);
89 }

References FlutterDesktopMessage::struct_size, and user_data.

◆ TEST() [36/306]

flutter::TEST ( IncomingMessageDispatcher  ,
SetHandle   
)

Definition at line 10 of file incoming_message_dispatcher_unittests.cc.

10  {
11  FlutterDesktopMessengerRef messenger =
12  reinterpret_cast<FlutterDesktopMessengerRef>(0xfeedface);
13  const uint8_t* message_data = reinterpret_cast<const uint8_t*>(0xcafebabe);
14  auto dispatcher = std::make_unique<IncomingMessageDispatcher>(messenger);
15  bool did_call = false;
16  dispatcher->SetMessageCallback(
17  "hello",
18  [](FlutterDesktopMessengerRef messenger,
19  const FlutterDesktopMessage* message, void* user_data) {
20  EXPECT_EQ(messenger,
21  reinterpret_cast<FlutterDesktopMessengerRef>(0xfeedface));
22  EXPECT_EQ(message->message,
23  reinterpret_cast<const uint8_t*>(0xcafebabe));
24  EXPECT_EQ(message->message_size, 123u);
25  *reinterpret_cast<bool*>(user_data) = true;
26  },
27  &did_call);
28  FlutterDesktopMessage message = {
30  .channel = "hello",
31  .message = message_data,
32  .message_size = 123,
33  .response_handle = nullptr,
34  };
35  dispatcher->HandleMessage(message);
36  EXPECT_TRUE(did_call);
37 }
const uint8_t * message

References FlutterDesktopMessage::message, FlutterDesktopMessage::message_size, FlutterDesktopMessage::struct_size, and user_data.

◆ TEST() [37/306]

flutter::TEST ( JsonMessageCodec  ,
EncodeDecode   
)

Definition at line 29 of file json_message_codec_unittests.cc.

29  {
30  // NOLINTNEXTLINE(clang-analyzer-core.NullDereference)
31  rapidjson::Document array(rapidjson::kArrayType);
32  auto& allocator = array.GetAllocator();
33 
34  array.PushBack("string", allocator);
35 
36  rapidjson::Value map(rapidjson::kObjectType);
37  map.AddMember("a", -7, allocator);
38  map.AddMember("b", std::numeric_limits<int>::max(), allocator);
39  map.AddMember("c", 3.14159, allocator);
40  map.AddMember("d", true, allocator);
41  map.AddMember("e", rapidjson::Value(), allocator);
42  array.PushBack(map, allocator);
43 
44  CheckEncodeDecode(array);
45 }
static void CheckEncodeDecode(id value, NSData *expectedEncoding)

References CheckEncodeDecode().

◆ TEST() [38/306]

flutter::TEST ( JsonMethodCodec  ,
HandlesErrorEnvelopesWithDetails   
)

Definition at line 125 of file json_method_codec_unittests.cc.

125  {
126  const JsonMethodCodec& codec = JsonMethodCodec::GetInstance();
127  // NOLINTNEXTLINE(clang-analyzer-core.NullDereference)
128  rapidjson::Document details(rapidjson::kArrayType);
129  auto& allocator = details.GetAllocator();
130  details.PushBack("a", allocator);
131  details.PushBack(42, allocator);
132  auto encoded =
133  codec.EncodeErrorEnvelope("errorCode", "something failed", &details);
134  ASSERT_NE(encoded.get(), nullptr);
135  std::vector<uint8_t> bytes = {
136  '[', '"', 'e', 'r', 'r', 'o', 'r', 'C', 'o', 'd', 'e', '"', ',', '"',
137  's', 'o', 'm', 'e', 't', 'h', 'i', 'n', 'g', ' ', 'f', 'a', 'i', 'l',
138  'e', 'd', '"', ',', '[', '"', 'a', '"', ',', '4', '2', ']', ']',
139  };
140  EXPECT_EQ(*encoded, bytes);
141 
142  bool decoded_successfully = false;
143  MethodResultFunctions<rapidjson::Document> result_handler(
144  nullptr,
145  [&decoded_successfully](const std::string& code,
146  const std::string& message,
147  const rapidjson::Document* details) {
148  decoded_successfully = true;
149  EXPECT_EQ(code, "errorCode");
150  EXPECT_EQ(message, "something failed");
151  EXPECT_TRUE(details->IsArray());
152  EXPECT_EQ(std::string((*details)[0].GetString()), "a");
153  EXPECT_EQ((*details)[1].GetInt(), 42);
154  },
155  nullptr);
156  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
157  &result_handler);
158  EXPECT_TRUE(decoded_successfully);
159 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeErrorEnvelope(), and flutter::JsonMethodCodec::GetInstance().

◆ TEST() [39/306]

flutter::TEST ( JsonMethodCodec  ,
HandlesErrorEnvelopesWithNulls   
)

Definition at line 98 of file json_method_codec_unittests.cc.

98  {
99  const JsonMethodCodec& codec = JsonMethodCodec::GetInstance();
100  auto encoded = codec.EncodeErrorEnvelope("errorCode");
101  ASSERT_TRUE(encoded);
102  std::vector<uint8_t> bytes = {
103  '[', '"', 'e', 'r', 'r', 'o', 'r', 'C', 'o', 'd', 'e',
104  '"', ',', '"', '"', ',', 'n', 'u', 'l', 'l', ']',
105  };
106  EXPECT_EQ(*encoded, bytes);
107 
108  bool decoded_successfully = false;
109  MethodResultFunctions<rapidjson::Document> result_handler(
110  nullptr,
111  [&decoded_successfully](const std::string& code,
112  const std::string& message,
113  const rapidjson::Document* details) {
114  decoded_successfully = true;
115  EXPECT_EQ(code, "errorCode");
116  EXPECT_EQ(message, "");
117  EXPECT_EQ(details, nullptr);
118  },
119  nullptr);
120  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
121  &result_handler);
122  EXPECT_TRUE(decoded_successfully);
123 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeErrorEnvelope(), and flutter::JsonMethodCodec::GetInstance().

◆ TEST() [40/306]

flutter::TEST ( JsonMethodCodec  ,
HandlesMethodCallsWithArgument   
)

Definition at line 42 of file json_method_codec_unittests.cc.

42  {
43  const JsonMethodCodec& codec = JsonMethodCodec::GetInstance();
44 
45  auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
46  auto& allocator = arguments->GetAllocator();
47  arguments->PushBack(42, allocator);
48  arguments->PushBack("world", allocator);
49  MethodCall<rapidjson::Document> call("hello", std::move(arguments));
50  auto encoded = codec.EncodeMethodCall(call);
51  ASSERT_TRUE(encoded);
52  std::unique_ptr<MethodCall<rapidjson::Document>> decoded =
53  codec.DecodeMethodCall(*encoded);
54  ASSERT_TRUE(decoded);
55  EXPECT_TRUE(MethodCallsAreEqual(call, *decoded));
56 }

References flutter::MethodCodec< T >::DecodeMethodCall(), flutter::MethodCodec< T >::EncodeMethodCall(), and flutter::JsonMethodCodec::GetInstance().

◆ TEST() [41/306]

flutter::TEST ( JsonMethodCodec  ,
HandlesMethodCallsWithNullArguments   
)

Definition at line 31 of file json_method_codec_unittests.cc.

31  {
32  const JsonMethodCodec& codec = JsonMethodCodec::GetInstance();
33  MethodCall<rapidjson::Document> call("hello", nullptr);
34  auto encoded = codec.EncodeMethodCall(call);
35  ASSERT_TRUE(encoded);
36  std::unique_ptr<MethodCall<rapidjson::Document>> decoded =
37  codec.DecodeMethodCall(*encoded);
38  ASSERT_TRUE(decoded);
39  EXPECT_TRUE(MethodCallsAreEqual(call, *decoded));
40 }

References flutter::MethodCodec< T >::DecodeMethodCall(), flutter::MethodCodec< T >::EncodeMethodCall(), and flutter::JsonMethodCodec::GetInstance().

◆ TEST() [42/306]

flutter::TEST ( JsonMethodCodec  ,
HandlesSuccessEnvelopesWithNullResult   
)

Definition at line 58 of file json_method_codec_unittests.cc.

58  {
59  const JsonMethodCodec& codec = JsonMethodCodec::GetInstance();
60  auto encoded = codec.EncodeSuccessEnvelope();
61  ASSERT_TRUE(encoded);
62  std::vector<uint8_t> bytes = {'[', 'n', 'u', 'l', 'l', ']'};
63  EXPECT_EQ(*encoded, bytes);
64 
65  bool decoded_successfully = false;
66  MethodResultFunctions<rapidjson::Document> result_handler(
67  [&decoded_successfully](const rapidjson::Document* result) {
68  decoded_successfully = true;
69  EXPECT_EQ(result, nullptr);
70  },
71  nullptr, nullptr);
72  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
73  &result_handler);
74  EXPECT_TRUE(decoded_successfully);
75 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeSuccessEnvelope(), and flutter::JsonMethodCodec::GetInstance().

◆ TEST() [43/306]

flutter::TEST ( JsonMethodCodec  ,
HandlesSuccessEnvelopesWithResult   
)

Definition at line 77 of file json_method_codec_unittests.cc.

77  {
78  const JsonMethodCodec& codec = JsonMethodCodec::GetInstance();
79  rapidjson::Document result;
80  result.SetInt(42);
81  auto encoded = codec.EncodeSuccessEnvelope(&result);
82  ASSERT_TRUE(encoded);
83  std::vector<uint8_t> bytes = {'[', '4', '2', ']'};
84  EXPECT_EQ(*encoded, bytes);
85 
86  bool decoded_successfully = false;
87  MethodResultFunctions<rapidjson::Document> result_handler(
88  [&decoded_successfully](const rapidjson::Document* result) {
89  decoded_successfully = true;
90  EXPECT_EQ(result->GetInt(), 42);
91  },
92  nullptr, nullptr);
93  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
94  &result_handler);
95  EXPECT_TRUE(decoded_successfully);
96 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeSuccessEnvelope(), and flutter::JsonMethodCodec::GetInstance().

◆ TEST() [44/306]

flutter::TEST ( MethodCallTest  ,
Basic   
)

Definition at line 14 of file method_call_unittests.cc.

14  {
15  const std::string method_name("method_name");
16  const int argument = 42;
17  MethodCall<int> method_call(method_name, std::make_unique<int>(argument));
18  EXPECT_EQ(method_call.method_name(), method_name);
19  ASSERT_NE(method_call.arguments(), nullptr);
20  EXPECT_EQ(*method_call.arguments(), 42);
21 }

References flutter::MethodCall< T >::arguments(), and flutter::MethodCall< T >::method_name().

◆ TEST() [45/306]

flutter::TEST ( MethodChannelTest  ,
Error   
)

Definition at line 37 of file method_result_functions_unittests.cc.

37  {
38  bool called = false;
39  std::string error_code = "a";
40  std::string error_message = "b";
41  int error_details = 1;
42  MethodResultFunctions<int> result(
43  nullptr,
44  [&called, error_code, error_message, error_details](
45  const std::string& code, const std::string& message,
46  const int* details) {
47  called = true;
48  EXPECT_EQ(code, error_code);
49  EXPECT_EQ(message, error_message);
50  EXPECT_EQ(*details, error_details);
51  },
52  nullptr);
53  result.Error(error_code, error_message, error_details);
54  EXPECT_TRUE(called);
55 }

References flutter::MethodResult< T >::Error().

◆ TEST() [46/306]

flutter::TEST ( MethodChannelTest  ,
InvokeNotImplemented   
)

Definition at line 145 of file method_channel_unittests.cc.

145  {
146  TestBinaryMessenger messenger;
147  const std::string channel_name("some_channel");
148  MethodChannel channel(&messenger, channel_name,
149  &StandardMethodCodec::GetInstance());
150 
151  bool received_not_implemented = false;
152  auto result_handler = std::make_unique<MethodResultFunctions<>>(
153  nullptr, nullptr,
154  [&received_not_implemented]() { received_not_implemented = true; });
155 
156  channel.InvokeMethod("foo", nullptr, std::move(result_handler));
157  EXPECT_EQ(messenger.send_called(), true);
158  ASSERT_NE(messenger.last_reply_handler(), nullptr);
159 
160  // Call the underlying reply handler to ensure it's reported as unimplemented.
161  messenger.last_reply_handler()(nullptr, 0);
162  EXPECT_TRUE(received_not_implemented);
163 }

References flutter::StandardMethodCodec::GetInstance(), and flutter::MethodChannel< T >::InvokeMethod().

◆ TEST() [47/306]

flutter::TEST ( MethodChannelTest  ,
InvokeWithoutResponse   
)

Definition at line 107 of file method_channel_unittests.cc.

107  {
108  TestBinaryMessenger messenger;
109  const std::string channel_name("some_channel");
110  MethodChannel channel(&messenger, channel_name,
111  &StandardMethodCodec::GetInstance());
112 
113  channel.InvokeMethod("foo", nullptr);
114  EXPECT_TRUE(messenger.send_called());
115  EXPECT_EQ(messenger.last_reply_handler(), nullptr);
116 }

References flutter::StandardMethodCodec::GetInstance(), and flutter::MethodChannel< T >::InvokeMethod().

◆ TEST() [48/306]

flutter::TEST ( MethodChannelTest  ,
InvokeWithResponse   
)

Definition at line 118 of file method_channel_unittests.cc.

118  {
119  TestBinaryMessenger messenger;
120  const std::string channel_name("some_channel");
121  MethodChannel channel(&messenger, channel_name,
122  &StandardMethodCodec::GetInstance());
123 
124  bool received_reply = false;
125  const std::string reply = "bar";
126  auto result_handler = std::make_unique<MethodResultFunctions<>>(
127  [&received_reply, reply](const EncodableValue* success_value) {
128  received_reply = true;
129  EXPECT_EQ(std::get<std::string>(*success_value), reply);
130  },
131  nullptr, nullptr);
132 
133  channel.InvokeMethod("foo", nullptr, std::move(result_handler));
134  EXPECT_TRUE(messenger.send_called());
135  ASSERT_NE(messenger.last_reply_handler(), nullptr);
136 
137  // Call the underlying reply handler to ensure it's processed correctly.
138  EncodableValue reply_value(reply);
139  std::unique_ptr<std::vector<uint8_t>> encoded_reply =
140  StandardMethodCodec::GetInstance().EncodeSuccessEnvelope(&reply_value);
141  messenger.last_reply_handler()(encoded_reply->data(), encoded_reply->size());
142  EXPECT_TRUE(received_reply);
143 }

References flutter::MethodCodec< T >::EncodeSuccessEnvelope(), flutter::StandardMethodCodec::GetInstance(), and flutter::MethodChannel< T >::InvokeMethod().

◆ TEST() [49/306]

flutter::TEST ( MethodChannelTest  ,
NoHandlers   
)

Definition at line 15 of file method_result_functions_unittests.cc.

15  {
16  MethodResultFunctions<int> result(nullptr, nullptr, nullptr);
17  result.Success();
18  result.Error("error");
19  result.NotImplemented();
20 }

References flutter::MethodResult< T >::Error(), flutter::MethodResult< T >::NotImplemented(), and flutter::MethodResult< T >::Success().

◆ TEST() [50/306]

flutter::TEST ( MethodChannelTest  ,
NotImplemented   
)

Definition at line 58 of file method_result_functions_unittests.cc.

58  {
59  bool called = false;
60  MethodResultFunctions<int> result(nullptr, nullptr,
61  [&called]() { called = true; });
62  result.NotImplemented();
63  EXPECT_TRUE(called);
64 }

References flutter::MethodResult< T >::NotImplemented().

◆ TEST() [51/306]

flutter::TEST ( MethodChannelTest  ,
Registration   
)

Definition at line 62 of file method_channel_unittests.cc.

62  {
63  TestBinaryMessenger messenger;
64  const std::string channel_name("some_channel");
65  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
66  MethodChannel channel(&messenger, channel_name, &codec);
67 
68  bool callback_called = false;
69  const std::string method_name("hello");
70  channel.SetMethodCallHandler(
71  [&callback_called, method_name](const auto& call, auto result) {
72  callback_called = true;
73  // Ensure that the wrapper received a correctly decoded call and a
74  // result.
75  EXPECT_EQ(call.method_name(), method_name);
76  EXPECT_NE(result, nullptr);
77  result->Success();
78  });
79  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
80  EXPECT_NE(messenger.last_message_handler(), nullptr);
81  // Send a test message to trigger the handler test assertions.
82  MethodCall<> call(method_name, nullptr);
83  auto message = codec.EncodeMethodCall(call);
84 
85  messenger.last_message_handler()(
86  message->data(), message->size(),
87  [](const uint8_t* reply, size_t reply_size) {});
88  EXPECT_TRUE(callback_called);
89 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::StandardMethodCodec::GetInstance(), and flutter::MethodChannel< T >::SetMethodCallHandler().

◆ TEST() [52/306]

flutter::TEST ( MethodChannelTest  ,
Resize   
)

Definition at line 167 of file method_channel_unittests.cc.

167  {
168  TestBinaryMessenger messenger;
169  const std::string channel_name("flutter/test");
170  MethodChannel channel(&messenger, channel_name,
171  &StandardMethodCodec::GetInstance());
172 
173  channel.Resize(3);
174 
175  // Because the Dart implementation for the control channel implements its own
176  // custom deserialization logic, this test compares the generated bytes array
177  // to the expected one (for instance, the deserialization logic expects the
178  // size parameter of the resize method call to be an uint32).
179  //
180  // The expected content was created from the following Dart code:
181  // MethodCall call = MethodCall('resize', ['flutter/test',3]);
182  // StandardMethodCodec().encodeMethodCall(call).buffer.asUint8List();
183  const int expected_message_size = 29;
184 
185  EXPECT_EQ(messenger.send_called(), true);
186  EXPECT_EQ(static_cast<int>(messenger.last_message().size()),
187  expected_message_size);
188 
189  int expected[expected_message_size] = {
190  7, 6, 114, 101, 115, 105, 122, 101, 12, 2, 7, 12, 102, 108, 117,
191  116, 116, 101, 114, 47, 116, 101, 115, 116, 3, 3, 0, 0, 0};
192  for (int i = 0; i < expected_message_size; i++) {
193  EXPECT_EQ(messenger.last_message()[i], expected[i]);
194  }
195 }

References flutter::StandardMethodCodec::GetInstance(), and flutter::MethodChannel< T >::Resize().

◆ TEST() [53/306]

flutter::TEST ( MethodChannelTest  ,
SetWarnsOnOverflow   
)

Definition at line 199 of file method_channel_unittests.cc.

199  {
200  TestBinaryMessenger messenger;
201 
202  const std::string channel_name("flutter/test");
203  MethodChannel channel(&messenger, channel_name,
204  &StandardMethodCodec::GetInstance());
205 
206  channel.SetWarnsOnOverflow(false);
207 
208  // The expected content was created from the following Dart code:
209  // MethodCall call = MethodCall('overflow',['flutter/test', true]);
210  // StandardMethodCodec().encodeMethodCall(call).buffer.asUint8List();
211  const int expected_message_size = 27;
212 
213  EXPECT_EQ(messenger.send_called(), true);
214  EXPECT_EQ(static_cast<int>(messenger.last_message().size()),
215  expected_message_size);
216 
217  int expected[expected_message_size] = {
218  7, 8, 111, 118, 101, 114, 102, 108, 111, 119, 12, 2, 7, 12,
219  102, 108, 117, 116, 116, 101, 114, 47, 116, 101, 115, 116, 1};
220  for (int i = 0; i < expected_message_size; i++) {
221  EXPECT_EQ(messenger.last_message()[i], expected[i]);
222  }
223 }

References flutter::StandardMethodCodec::GetInstance(), and flutter::MethodChannel< T >::SetWarnsOnOverflow().

◆ TEST() [54/306]

flutter::TEST ( MethodChannelTest  ,
Success   
)

Definition at line 23 of file method_result_functions_unittests.cc.

23  {
24  bool called = false;
25  int value = 1;
26  MethodResultFunctions<int> result(
27  [&called, value](const int* i) {
28  called = true;
29  EXPECT_EQ(*i, value);
30  },
31  nullptr, nullptr);
32  result.Success(value);
33  EXPECT_TRUE(called);
34 }

References flutter::MethodResult< T >::Success().

◆ TEST() [55/306]

flutter::TEST ( MethodChannelTest  ,
Unregistration   
)

Definition at line 92 of file method_channel_unittests.cc.

92  {
93  TestBinaryMessenger messenger;
94  const std::string channel_name("some_channel");
95  MethodChannel channel(&messenger, channel_name,
96  &StandardMethodCodec::GetInstance());
97 
98  channel.SetMethodCallHandler([](const auto& call, auto result) {});
99  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
100  EXPECT_NE(messenger.last_message_handler(), nullptr);
101 
102  channel.SetMethodCallHandler(nullptr);
103  EXPECT_EQ(messenger.last_message_handler_channel(), channel_name);
104  EXPECT_EQ(messenger.last_message_handler(), nullptr);
105 }

References flutter::StandardMethodCodec::GetInstance(), and flutter::MethodChannel< T >::SetMethodCallHandler().

◆ TEST() [56/306]

flutter::TEST ( PathUtilsTest  ,
ExecutableDirector   
)

Definition at line 12 of file path_utils_unittests.cc.

12  {
13  std::filesystem::path exe_directory = GetExecutableDirectory();
14 #if defined(__linux__) || defined(_WIN32)
15  EXPECT_EQ(exe_directory.empty(), false);
16  EXPECT_EQ(exe_directory.is_absolute(), true);
17 #else
18  // On platforms where it's not implemented, it should indicate that
19  // by returning an empty path.
20  EXPECT_EQ(exe_directory.empty(), true);
21 #endif
22 }
std::filesystem::path GetExecutableDirectory()
Definition: path_utils.cc:16

References GetExecutableDirectory().

◆ TEST() [57/306]

flutter::TEST ( PluginRegistrarTest  ,
ManagerDifferentInstances   
)

Definition at line 175 of file plugin_registrar_unittests.cc.

175  {
176  PluginRegistrarManager* manager = PluginRegistrarManager::GetInstance();
177  manager->Reset();
178 
179  testing::ScopedStubFlutterApi scoped_api_stub(std::make_unique<TestApi>());
180 
181  auto dummy_registrar_handle_a =
182  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
183  auto dummy_registrar_handle_b =
184  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(2);
185 
186  EXPECT_NE(manager->GetRegistrar<PluginRegistrar>(dummy_registrar_handle_a),
187  manager->GetRegistrar<PluginRegistrar>(dummy_registrar_handle_b));
188 }
struct FlutterDesktopPluginRegistrar * FlutterDesktopPluginRegistrarRef

References flutter::PluginRegistrarManager::GetInstance(), flutter::PluginRegistrarManager::GetRegistrar(), and flutter::PluginRegistrarManager::Reset().

◆ TEST() [58/306]

flutter::TEST ( PluginRegistrarTest  ,
ManagerRemovesOnDestruction   
)

Definition at line 192 of file plugin_registrar_unittests.cc.

192  {
193  PluginRegistrarManager* manager = PluginRegistrarManager::GetInstance();
194  manager->Reset();
195 
196  testing::ScopedStubFlutterApi scoped_api_stub(std::make_unique<TestApi>());
197  auto test_api = static_cast<TestApi*>(scoped_api_stub.stub());
198 
199  auto dummy_registrar_handle =
200  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
201  auto* wrapper =
202  manager->GetRegistrar<TestPluginRegistrar>(dummy_registrar_handle);
203 
204  // Simulate destruction of the reference, and ensure that the wrapper
205  // is destroyed.
206  EXPECT_NE(test_api->last_destruction_callback_set(), nullptr);
207  bool destroyed = false;
208  wrapper->SetDestructionCallback([&destroyed]() { destroyed = true; });
209  test_api->last_destruction_callback_set()(dummy_registrar_handle);
210  EXPECT_EQ(destroyed, true);
211 
212  // Requesting the wrapper should now create a new object.
213  EXPECT_NE(manager->GetRegistrar<TestPluginRegistrar>(dummy_registrar_handle),
214  nullptr);
215 }

References flutter::PluginRegistrarManager::GetInstance(), flutter::PluginRegistrarManager::GetRegistrar(), and flutter::PluginRegistrarManager::Reset().

◆ TEST() [59/306]

flutter::TEST ( PluginRegistrarTest  ,
ManagerSameInstance   
)

Definition at line 160 of file plugin_registrar_unittests.cc.

160  {
161  PluginRegistrarManager* manager = PluginRegistrarManager::GetInstance();
162  manager->Reset();
163 
164  testing::ScopedStubFlutterApi scoped_api_stub(std::make_unique<TestApi>());
165 
166  auto dummy_registrar_handle =
167  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
168 
169  EXPECT_EQ(manager->GetRegistrar<PluginRegistrar>(dummy_registrar_handle),
170  manager->GetRegistrar<PluginRegistrar>(dummy_registrar_handle));
171 }

References flutter::PluginRegistrarManager::GetInstance(), flutter::PluginRegistrarManager::GetRegistrar(), and flutter::PluginRegistrarManager::Reset().

◆ TEST() [60/306]

flutter::TEST ( PluginRegistrarTest  ,
MessengerSend   
)

Definition at line 120 of file plugin_registrar_unittests.cc.

120  {
121  testing::ScopedStubFlutterApi scoped_api_stub(std::make_unique<TestApi>());
122  auto test_api = static_cast<TestApi*>(scoped_api_stub.stub());
123 
124  auto dummy_registrar_handle =
125  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
126  PluginRegistrar registrar(dummy_registrar_handle);
127  BinaryMessenger* messenger = registrar.messenger();
128 
129  std::vector<uint8_t> message = {1, 2, 3, 4};
130  messenger->Send("some_channel", &message[0], message.size());
131  EXPECT_EQ(test_api->last_data_sent(), &message[0]);
132 }

References flutter::PluginRegistrar::messenger(), and flutter::BinaryMessenger::Send().

◆ TEST() [61/306]

flutter::TEST ( PluginRegistrarTest  ,
MessengerSetMessageHandler   
)

Definition at line 136 of file plugin_registrar_unittests.cc.

136  {
137  testing::ScopedStubFlutterApi scoped_api_stub(std::make_unique<TestApi>());
138  auto test_api = static_cast<TestApi*>(scoped_api_stub.stub());
139 
140  auto dummy_registrar_handle =
141  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
142  PluginRegistrar registrar(dummy_registrar_handle);
143  BinaryMessenger* messenger = registrar.messenger();
144  const std::string channel_name("foo");
145 
146  // Register.
147  BinaryMessageHandler binary_handler = [](const uint8_t* message,
148  const size_t message_size,
149  const BinaryReply& reply) {};
150  messenger->SetMessageHandler(channel_name, std::move(binary_handler));
151  EXPECT_NE(test_api->last_message_callback_set(), nullptr);
152 
153  // Unregister.
154  messenger->SetMessageHandler(channel_name, nullptr);
155  EXPECT_EQ(test_api->last_message_callback_set(), nullptr);
156 }
std::function< void(const uint8_t *message, size_t message_size, BinaryReply reply)> BinaryMessageHandler
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply

References flutter::PluginRegistrar::messenger(), and flutter::BinaryMessenger::SetMessageHandler().

◆ TEST() [62/306]

flutter::TEST ( PluginRegistrarTest  ,
PluginDestroyedBeforeRegistrar   
)

Definition at line 104 of file plugin_registrar_unittests.cc.

104  {
105  auto dummy_registrar_handle =
106  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
107  bool registrar_valid_at_destruction = false;
108  {
109  PluginRegistrar registrar(dummy_registrar_handle);
110 
111  auto plugin = std::make_unique<TestPlugin>(&registrar,
112  &registrar_valid_at_destruction);
113  registrar.AddPlugin(std::move(plugin));
114  }
115  EXPECT_TRUE(registrar_valid_at_destruction);
116 }

References flutter::PluginRegistrar::AddPlugin().

◆ TEST() [63/306]

flutter::TEST ( PluginRegistrarTest  ,
TextureRegistrarNotNull   
)

Definition at line 218 of file plugin_registrar_unittests.cc.

218  {
219  auto dummy_registrar_handle =
220  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
221  PluginRegistrar registrar(dummy_registrar_handle);
222 
223  TextureRegistrar* texture_registrar = registrar.texture_registrar();
224 
225  ASSERT_NE(texture_registrar, nullptr);
226 }

References flutter::PluginRegistrar::texture_registrar().

◆ TEST() [64/306]

flutter::TEST ( StandardMessageCodec  ,
CanDecodeEmptyBytesAsNullWithoutCallingSerializer   
)

Definition at line 95 of file standard_message_codec_unittests.cc.

95  {
96  std::vector<uint8_t> bytes = {};
97  const MockStandardCodecSerializer serializer;
98  const StandardMessageCodec& codec =
99  StandardMessageCodec::GetInstance(&serializer);
100 
101  auto decoded = codec.DecodeMessage(bytes);
102 
103  EXPECT_EQ(EncodableValue(), *decoded);
104  EXPECT_CALL(serializer, ReadValueOfType(::testing::_, ::testing::_)).Times(0);
105 }

References flutter::MessageCodec< T >::DecodeMessage(), and flutter::StandardMessageCodec::GetInstance().

◆ TEST() [65/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeByteArray   
)

Definition at line 193 of file standard_message_codec_unittests.cc.

193  {
194  std::vector<uint8_t> bytes = {0x08, 0x04, 0xba, 0x5e, 0xba, 0x11};
195  EncodableValue value(std::vector<uint8_t>{0xba, 0x5e, 0xba, 0x11});
196  CheckEncodeDecode(value, bytes);
197 }
static void CheckEncodeDecode(const EncodableValue &value, const std::vector< uint8_t > &expected_encoding, const StandardCodecSerializer *serializer=nullptr, const std::function< bool(const EncodableValue &a, const EncodableValue &b)> &custom_comparator=nullptr)

References CheckEncodeDecode().

◆ TEST() [66/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeDouble   
)

Definition at line 128 of file standard_message_codec_unittests.cc.

128  {
129  std::vector<uint8_t> bytes = {0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
130  0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40};
131  CheckEncodeDecode(EncodableValue(3.14159265358979311599796346854), bytes);
132 }

References CheckEncodeDecode().

◆ TEST() [67/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeEmptyList   
)

Definition at line 175 of file standard_message_codec_unittests.cc.

175  {
176  std::vector<uint8_t> bytes = {0x0c, 0x00};
177  CheckEncodeDecode(EncodableValue(EncodableList{}), bytes);
178 }

References CheckEncodeDecode().

◆ TEST() [68/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeEmptyString   
)

Definition at line 150 of file standard_message_codec_unittests.cc.

150  {
151  std::vector<uint8_t> bytes = {0x07, 0x00};
152  CheckEncodeDecode(EncodableValue(""), bytes);
153 }

References CheckEncodeDecode().

◆ TEST() [69/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeFalse   
)

Definition at line 112 of file standard_message_codec_unittests.cc.

112  {
113  std::vector<uint8_t> bytes = {0x02};
114  CheckEncodeDecode(EncodableValue(false), bytes);
115 }

References CheckEncodeDecode().

◆ TEST() [70/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeFloat32Array   
)

Definition at line 214 of file standard_message_codec_unittests.cc.

214  {
215  std::vector<uint8_t> bytes = {0x0e, 0x02, 0x00, 0x00, 0xd8, 0x0f,
216  0x49, 0x40, 0x00, 0x00, 0x7a, 0x44};
217  EncodableValue value(std::vector<float>{3.1415920257568359375f, 1000.0f});
218  CheckEncodeDecode(value, bytes);
219 }

References CheckEncodeDecode().

◆ TEST() [71/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeFloat64Array   
)

Definition at line 221 of file standard_message_codec_unittests.cc.

221  {
222  std::vector<uint8_t> bytes = {0x0b, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223  0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40,
224  0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x8f, 0x40};
225  EncodableValue value(
226  std::vector<double>{3.14159265358979311599796346854, 1000.0});
227  CheckEncodeDecode(value, bytes);
228 }

References CheckEncodeDecode().

◆ TEST() [72/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeInt32   
)

Definition at line 117 of file standard_message_codec_unittests.cc.

117  {
118  std::vector<uint8_t> bytes = {0x03, 0x78, 0x56, 0x34, 0x12};
119  CheckEncodeDecode(EncodableValue(0x12345678), bytes);
120 }

References CheckEncodeDecode().

◆ TEST() [73/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeInt32Array   
)

Definition at line 199 of file standard_message_codec_unittests.cc.

199  {
200  std::vector<uint8_t> bytes = {0x09, 0x03, 0x00, 0x00, 0x78, 0x56, 0x34, 0x12,
201  0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};
202  EncodableValue value(std::vector<int32_t>{0x12345678, -1, 0});
203  CheckEncodeDecode(value, bytes);
204 }

References CheckEncodeDecode().

◆ TEST() [74/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeInt64   
)

Definition at line 122 of file standard_message_codec_unittests.cc.

122  {
123  std::vector<uint8_t> bytes = {0x04, 0xef, 0xcd, 0xab, 0x90,
124  0x78, 0x56, 0x34, 0x12};
125  CheckEncodeDecode(EncodableValue(INT64_C(0x1234567890abcdef)), bytes);
126 }

References CheckEncodeDecode().

◆ TEST() [75/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeInt64Array   
)

Definition at line 206 of file standard_message_codec_unittests.cc.

206  {
207  std::vector<uint8_t> bytes = {0x0a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208  0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12,
209  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
210  EncodableValue value(std::vector<int64_t>{0x1234567890abcdef, -1});
211  CheckEncodeDecode(value, bytes);
212 }

References CheckEncodeDecode().

◆ TEST() [76/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeList   
)

Definition at line 155 of file standard_message_codec_unittests.cc.

155  {
156  std::vector<uint8_t> bytes = {
157  0x0c, 0x05, 0x00, 0x07, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x06,
158  0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x85, 0xeb, 0x51, 0xb8, 0x1e,
159  0x09, 0x40, 0x03, 0x2f, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x03, 0x2a,
160  0x00, 0x00, 0x00, 0x07, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64,
161  };
162  EncodableValue value(EncodableList{
163  EncodableValue(),
164  EncodableValue("hello"),
165  EncodableValue(3.14),
166  EncodableValue(47),
167  EncodableValue(EncodableList{
168  EncodableValue(42),
169  EncodableValue("nested"),
170  }),
171  });
172  CheckEncodeDecode(value, bytes);
173 }

References CheckEncodeDecode().

◆ TEST() [77/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeMap   
)

Definition at line 180 of file standard_message_codec_unittests.cc.

180  {
181  std::vector<uint8_t> bytes_prefix = {0x0d, 0x04};
182  EncodableValue value(EncodableMap{
183  {EncodableValue("a"), EncodableValue(3.14)},
184  {EncodableValue("b"), EncodableValue(47)},
185  {EncodableValue(), EncodableValue()},
186  {EncodableValue(3.14), EncodableValue(EncodableList{
187  EncodableValue("nested"),
188  })},
189  });
190  CheckEncodeDecodeWithEncodePrefix(value, bytes_prefix, 48);
191 }
static void CheckEncodeDecodeWithEncodePrefix(const EncodableValue &value, const std::vector< uint8_t > &expected_encoding_prefix, size_t expected_encoding_length)

References CheckEncodeDecodeWithEncodePrefix().

◆ TEST() [78/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeNull   
)

Definition at line 90 of file standard_message_codec_unittests.cc.

90  {
91  std::vector<uint8_t> bytes = {0x00};
92  CheckEncodeDecode(EncodableValue(), bytes);
93 }

References CheckEncodeDecode().

◆ TEST() [79/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeSimpleCustomType   
)

Definition at line 230 of file standard_message_codec_unittests.cc.

230  {
231  std::vector<uint8_t> bytes = {0x80, 0x09, 0x00, 0x00, 0x00,
232  0x10, 0x00, 0x00, 0x00};
233  auto point_comparator = [](const EncodableValue& a, const EncodableValue& b) {
234  const Point& a_point =
235  std::any_cast<Point>(std::get<CustomEncodableValue>(a));
236  const Point& b_point =
237  std::any_cast<Point>(std::get<CustomEncodableValue>(b));
238  return a_point == b_point;
239  };
240  CheckEncodeDecode(CustomEncodableValue(Point(9, 16)), bytes,
241  &PointExtensionSerializer::GetInstance(), point_comparator);
242 }

References CheckEncodeDecode().

◆ TEST() [80/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeString   
)

Definition at line 134 of file standard_message_codec_unittests.cc.

134  {
135  std::vector<uint8_t> bytes = {0x07, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
136  0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64};
137  CheckEncodeDecode(EncodableValue("hello world"), bytes);
138 }

References CheckEncodeDecode().

◆ TEST() [81/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeStringWithNonAsciiCodePoint   
)

Definition at line 140 of file standard_message_codec_unittests.cc.

140  {
141  std::vector<uint8_t> bytes = {0x07, 0x05, 0x68, 0xe2, 0x98, 0xba, 0x77};
142  CheckEncodeDecode(EncodableValue("h\u263Aw"), bytes);
143 }

References CheckEncodeDecode().

◆ TEST() [82/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeStringWithNonBMPCodePoint   
)

Definition at line 145 of file standard_message_codec_unittests.cc.

145  {
146  std::vector<uint8_t> bytes = {0x07, 0x06, 0x68, 0xf0, 0x9f, 0x98, 0x82, 0x77};
147  CheckEncodeDecode(EncodableValue("h\U0001F602w"), bytes);
148 }

References CheckEncodeDecode().

◆ TEST() [83/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeTrue   
)

Definition at line 107 of file standard_message_codec_unittests.cc.

107  {
108  std::vector<uint8_t> bytes = {0x01};
109  CheckEncodeDecode(EncodableValue(true), bytes);
110 }

References CheckEncodeDecode().

◆ TEST() [84/306]

flutter::TEST ( StandardMessageCodec  ,
CanEncodeAndDecodeVariableLengthCustomType   
)

Definition at line 244 of file standard_message_codec_unittests.cc.

244  {
245  std::vector<uint8_t> bytes = {
246  0x81, // custom type
247  0x06, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, // data
248  0x07, 0x04, // string type and length
249  0x74, 0x65, 0x73, 0x74 // string characters
250  };
251  auto some_data_comparator = [](const EncodableValue& a,
252  const EncodableValue& b) {
253  const SomeData& data_a =
254  std::any_cast<SomeData>(std::get<CustomEncodableValue>(a));
255  const SomeData& data_b =
256  std::any_cast<SomeData>(std::get<CustomEncodableValue>(b));
257  return data_a.data() == data_b.data() && data_a.label() == data_b.label();
258  };
259  CheckEncodeDecode(CustomEncodableValue(
260  SomeData("test", {0x00, 0x01, 0x02, 0x03, 0x04, 0x05})),
261  bytes, &SomeDataExtensionSerializer::GetInstance(),
262  some_data_comparator);
263 }

References CheckEncodeDecode().

◆ TEST() [85/306]

flutter::TEST ( StandardMessageCodec  ,
GetInstanceCachesInstance   
)

Definition at line 82 of file standard_message_codec_unittests.cc.

82  {
83  const StandardMessageCodec& codec_a =
84  StandardMessageCodec::GetInstance(nullptr);
85  const StandardMessageCodec& codec_b =
86  StandardMessageCodec::GetInstance(nullptr);
87  EXPECT_EQ(&codec_a, &codec_b);
88 }

References flutter::StandardMessageCodec::GetInstance().

◆ TEST() [86/306]

flutter::TEST ( StandardMethodCodec  ,
GetInstanceCachesInstance   
)

Definition at line 35 of file standard_method_codec_unittests.cc.

35  {
36  const StandardMethodCodec& codec_a =
37  StandardMethodCodec::GetInstance(nullptr);
38  const StandardMethodCodec& codec_b =
39  StandardMethodCodec::GetInstance(nullptr);
40  EXPECT_EQ(&codec_a, &codec_b);
41 }

References flutter::StandardMethodCodec::GetInstance().

◆ TEST() [87/306]

flutter::TEST ( StandardMethodCodec  ,
HandlesCustomTypeArguments   
)

Definition at line 167 of file standard_method_codec_unittests.cc.

167  {
168  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance(
169  &PointExtensionSerializer::GetInstance());
170  Point point(7, 9);
171  MethodCall<> call(
172  "hello", std::make_unique<EncodableValue>(CustomEncodableValue(point)));
173  auto encoded = codec.EncodeMethodCall(call);
174  ASSERT_NE(encoded.get(), nullptr);
175  std::unique_ptr<MethodCall<>> decoded = codec.DecodeMethodCall(*encoded);
176  ASSERT_NE(decoded.get(), nullptr);
177 
178  const Point& decoded_point = std::any_cast<Point>(
179  std::get<CustomEncodableValue>(*decoded->arguments()));
180  EXPECT_EQ(point, decoded_point);
181 };

References flutter::MethodCodec< T >::DecodeMethodCall(), flutter::MethodCodec< T >::EncodeMethodCall(), and flutter::StandardMethodCodec::GetInstance().

◆ TEST() [88/306]

flutter::TEST ( StandardMethodCodec  ,
HandlesErrorEnvelopesWithDetails   
)

Definition at line 130 of file standard_method_codec_unittests.cc.

130  {
131  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
132  EncodableValue details(EncodableList{
133  EncodableValue("a"),
134  EncodableValue(42),
135  });
136  auto encoded =
137  codec.EncodeErrorEnvelope("errorCode", "something failed", &details);
138  ASSERT_NE(encoded.get(), nullptr);
139  std::vector<uint8_t> bytes = {
140  0x01, 0x07, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f,
141  0x64, 0x65, 0x07, 0x10, 0x73, 0x6f, 0x6d, 0x65, 0x74, 0x68,
142  0x69, 0x6e, 0x67, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64,
143  0x0c, 0x02, 0x07, 0x01, 0x61, 0x03, 0x2a, 0x00, 0x00, 0x00,
144  };
145  EXPECT_EQ(*encoded, bytes);
146 
147  bool decoded_successfully = false;
148  MethodResultFunctions<> result_handler(
149  nullptr,
150  [&decoded_successfully](const std::string& code,
151  const std::string& message,
152  const EncodableValue* details) {
153  decoded_successfully = true;
154  EXPECT_EQ(code, "errorCode");
155  EXPECT_EQ(message, "something failed");
156  const auto* details_list = std::get_if<EncodableList>(details);
157  ASSERT_NE(details_list, nullptr);
158  EXPECT_EQ(std::get<std::string>((*details_list)[0]), "a");
159  EXPECT_EQ(std::get<int32_t>((*details_list)[1]), 42);
160  },
161  nullptr);
162  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
163  &result_handler);
164  EXPECT_TRUE(decoded_successfully);
165 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeErrorEnvelope(), and flutter::StandardMethodCodec::GetInstance().

◆ TEST() [89/306]

flutter::TEST ( StandardMethodCodec  ,
HandlesErrorEnvelopesWithNulls   
)

Definition at line 105 of file standard_method_codec_unittests.cc.

105  {
106  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
107  auto encoded = codec.EncodeErrorEnvelope("errorCode");
108  ASSERT_NE(encoded.get(), nullptr);
109  std::vector<uint8_t> bytes = {0x01, 0x07, 0x09, 0x65, 0x72, 0x72, 0x6f,
110  0x72, 0x43, 0x6f, 0x64, 0x65, 0x00, 0x00};
111  EXPECT_EQ(*encoded, bytes);
112 
113  bool decoded_successfully = false;
114  MethodResultFunctions<> result_handler(
115  nullptr,
116  [&decoded_successfully](const std::string& code,
117  const std::string& message,
118  const EncodableValue* details) {
119  decoded_successfully = true;
120  EXPECT_EQ(code, "errorCode");
121  EXPECT_EQ(message, "");
122  EXPECT_EQ(details, nullptr);
123  },
124  nullptr);
125  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
126  &result_handler);
127  EXPECT_TRUE(decoded_successfully);
128 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeErrorEnvelope(), and flutter::StandardMethodCodec::GetInstance().

◆ TEST() [90/306]

flutter::TEST ( StandardMethodCodec  ,
HandlesMethodCallsWithArgument   
)

Definition at line 53 of file standard_method_codec_unittests.cc.

53  {
54  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
55  MethodCall<> call("hello", std::make_unique<EncodableValue>(EncodableList{
56  EncodableValue(42),
57  EncodableValue("world"),
58  }));
59  auto encoded = codec.EncodeMethodCall(call);
60  ASSERT_NE(encoded.get(), nullptr);
61  std::unique_ptr<MethodCall<>> decoded = codec.DecodeMethodCall(*encoded);
62  ASSERT_NE(decoded.get(), nullptr);
63  EXPECT_TRUE(MethodCallsAreEqual(call, *decoded));
64 }

References flutter::MethodCodec< T >::DecodeMethodCall(), flutter::MethodCodec< T >::EncodeMethodCall(), and flutter::StandardMethodCodec::GetInstance().

◆ TEST() [91/306]

flutter::TEST ( StandardMethodCodec  ,
HandlesMethodCallsWithNullArguments   
)

Definition at line 43 of file standard_method_codec_unittests.cc.

43  {
44  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
45  MethodCall<> call("hello", nullptr);
46  auto encoded = codec.EncodeMethodCall(call);
47  ASSERT_NE(encoded.get(), nullptr);
48  std::unique_ptr<MethodCall<>> decoded = codec.DecodeMethodCall(*encoded);
49  ASSERT_NE(decoded.get(), nullptr);
50  EXPECT_TRUE(MethodCallsAreEqual(call, *decoded));
51 }

References flutter::MethodCodec< T >::DecodeMethodCall(), flutter::MethodCodec< T >::EncodeMethodCall(), and flutter::StandardMethodCodec::GetInstance().

◆ TEST() [92/306]

flutter::TEST ( StandardMethodCodec  ,
HandlesSuccessEnvelopesWithNullResult   
)

Definition at line 66 of file standard_method_codec_unittests.cc.

66  {
67  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
68  auto encoded = codec.EncodeSuccessEnvelope();
69  ASSERT_NE(encoded.get(), nullptr);
70  std::vector<uint8_t> bytes = {0x00, 0x00};
71  EXPECT_EQ(*encoded, bytes);
72 
73  bool decoded_successfully = false;
74  MethodResultFunctions<> result_handler(
75  [&decoded_successfully](const EncodableValue* result) {
76  decoded_successfully = true;
77  EXPECT_EQ(result, nullptr);
78  },
79  nullptr, nullptr);
80  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
81  &result_handler);
82  EXPECT_TRUE(decoded_successfully);
83 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeSuccessEnvelope(), and flutter::StandardMethodCodec::GetInstance().

◆ TEST() [93/306]

flutter::TEST ( StandardMethodCodec  ,
HandlesSuccessEnvelopesWithResult   
)

Definition at line 85 of file standard_method_codec_unittests.cc.

85  {
86  const StandardMethodCodec& codec = StandardMethodCodec::GetInstance();
87  EncodableValue result(42);
88  auto encoded = codec.EncodeSuccessEnvelope(&result);
89  ASSERT_NE(encoded.get(), nullptr);
90  std::vector<uint8_t> bytes = {0x00, 0x03, 0x2a, 0x00, 0x00, 0x00};
91  EXPECT_EQ(*encoded, bytes);
92 
93  bool decoded_successfully = false;
94  MethodResultFunctions<> result_handler(
95  [&decoded_successfully](const EncodableValue* result) {
96  decoded_successfully = true;
97  EXPECT_EQ(std::get<int32_t>(*result), 42);
98  },
99  nullptr, nullptr);
100  codec.DecodeAndProcessResponseEnvelope(encoded->data(), encoded->size(),
101  &result_handler);
102  EXPECT_TRUE(decoded_successfully);
103 }

References flutter::MethodCodec< T >::DecodeAndProcessResponseEnvelope(), flutter::MethodCodec< T >::EncodeSuccessEnvelope(), and flutter::StandardMethodCodec::GetInstance().

◆ TEST() [94/306]

flutter::TEST ( TextEditingDeltaTest  ,
TestTextEditingDeltaConstructor   
)

Definition at line 11 of file text_editing_delta_unittests.cc.

11  {
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 }

References flutter::TextEditingDelta::delta_end(), flutter::TextEditingDelta::delta_start(), flutter::TextEditingDelta::delta_text(), and flutter::TextEditingDelta::old_text().

◆ TEST() [95/306]

flutter::TEST ( TextEditingDeltaTest  ,
TestTextEditingDeltaNonTextConstructor   
)

Definition at line 25 of file text_editing_delta_unittests.cc.

25  {
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 }

References flutter::TextEditingDelta::delta_end(), flutter::TextEditingDelta::delta_start(), flutter::TextEditingDelta::delta_text(), and flutter::TextEditingDelta::old_text().

◆ TEST() [96/306]

flutter::TEST ( TextInputModel  ,
AddCodePoint   
)

Definition at line 477 of file text_input_model_unittests.cc.

477  {
478  auto model = std::make_unique<TextInputModel>();
479  model->AddCodePoint('A');
480  model->AddCodePoint('B');
481  model->AddCodePoint(0x1f604);
482  model->AddCodePoint('D');
483  model->AddCodePoint('E');
484  EXPECT_EQ(model->selection(), TextRange(6));
485  EXPECT_EQ(model->composing_range(), TextRange(0));
486  EXPECT_STREQ(model->GetText().c_str(), "AB😄DE");
487 }

◆ TEST() [97/306]

flutter::TEST ( TextInputModel  ,
AddCodePointReverseSelection   
)

Definition at line 499 of file text_input_model_unittests.cc.

499  {
500  auto model = std::make_unique<TextInputModel>();
501  model->SetText("ABCDE");
502  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
503  model->AddCodePoint('x');
504  EXPECT_EQ(model->selection(), TextRange(2));
505  EXPECT_EQ(model->composing_range(), TextRange(0));
506  EXPECT_STREQ(model->GetText().c_str(), "AxE");
507 }

◆ TEST() [98/306]

flutter::TEST ( TextInputModel  ,
AddCodePointReverseSelectionWideCharacter   
)

Definition at line 519 of file text_input_model_unittests.cc.

519  {
520  auto model = std::make_unique<TextInputModel>();
521  model->SetText("ABCDE");
522  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
523  model->AddCodePoint(0x1f604);
524  EXPECT_EQ(model->selection(), TextRange(3));
525  EXPECT_EQ(model->composing_range(), TextRange(0));
526  EXPECT_STREQ(model->GetText().c_str(), "A😄E");
527 }

◆ TEST() [99/306]

flutter::TEST ( TextInputModel  ,
AddCodePointSelection   
)

Definition at line 489 of file text_input_model_unittests.cc.

489  {
490  auto model = std::make_unique<TextInputModel>();
491  model->SetText("ABCDE");
492  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
493  model->AddCodePoint('x');
494  EXPECT_EQ(model->selection(), TextRange(2));
495  EXPECT_EQ(model->composing_range(), TextRange(0));
496  EXPECT_STREQ(model->GetText().c_str(), "AxE");
497 }

◆ TEST() [100/306]

flutter::TEST ( TextInputModel  ,
AddCodePointSelectionWideCharacter   
)

Definition at line 509 of file text_input_model_unittests.cc.

509  {
510  auto model = std::make_unique<TextInputModel>();
511  model->SetText("ABCDE");
512  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
513  model->AddCodePoint(0x1f604);
514  EXPECT_EQ(model->selection(), TextRange(3));
515  EXPECT_EQ(model->composing_range(), TextRange(0));
516  EXPECT_STREQ(model->GetText().c_str(), "A😄E");
517 }

◆ TEST() [101/306]

flutter::TEST ( TextInputModel  ,
AddText   
)

Definition at line 529 of file text_input_model_unittests.cc.

529  {
530  auto model = std::make_unique<TextInputModel>();
531  model->AddText(u"ABCDE");
532  model->AddText("😄");
533  model->AddText("FGHIJ");
534  EXPECT_EQ(model->selection(), TextRange(12));
535  EXPECT_EQ(model->composing_range(), TextRange(0));
536  EXPECT_STREQ(model->GetText().c_str(), "ABCDE😄FGHIJ");
537 }

◆ TEST() [102/306]

flutter::TEST ( TextInputModel  ,
AddTextReverseSelection   
)

Definition at line 549 of file text_input_model_unittests.cc.

549  {
550  auto model = std::make_unique<TextInputModel>();
551  model->SetText("ABCDE");
552  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
553  model->AddText("xy");
554  EXPECT_EQ(model->selection(), TextRange(3));
555  EXPECT_EQ(model->composing_range(), TextRange(0));
556  EXPECT_STREQ(model->GetText().c_str(), "AxyE");
557 }

◆ TEST() [103/306]

flutter::TEST ( TextInputModel  ,
AddTextReverseSelectionWideCharacter   
)

Definition at line 569 of file text_input_model_unittests.cc.

569  {
570  auto model = std::make_unique<TextInputModel>();
571  model->SetText("ABCDE");
572  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
573  model->AddText(u"😄🙃");
574  EXPECT_EQ(model->selection(), TextRange(5));
575  EXPECT_EQ(model->composing_range(), TextRange(0));
576  EXPECT_STREQ(model->GetText().c_str(), "A😄🙃E");
577 }

◆ TEST() [104/306]

flutter::TEST ( TextInputModel  ,
AddTextSelection   
)

Definition at line 539 of file text_input_model_unittests.cc.

539  {
540  auto model = std::make_unique<TextInputModel>();
541  model->SetText("ABCDE");
542  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
543  model->AddText("xy");
544  EXPECT_EQ(model->selection(), TextRange(3));
545  EXPECT_EQ(model->composing_range(), TextRange(0));
546  EXPECT_STREQ(model->GetText().c_str(), "AxyE");
547 }

◆ TEST() [105/306]

flutter::TEST ( TextInputModel  ,
AddTextSelectionWideCharacter   
)

Definition at line 559 of file text_input_model_unittests.cc.

559  {
560  auto model = std::make_unique<TextInputModel>();
561  model->SetText("ABCDE");
562  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
563  model->AddText(u"😄🙃");
564  EXPECT_EQ(model->selection(), TextRange(5));
565  EXPECT_EQ(model->composing_range(), TextRange(0));
566  EXPECT_STREQ(model->GetText().c_str(), "A😄🙃E");
567 }

◆ TEST() [106/306]

flutter::TEST ( TextInputModel  ,
BackspaceEnd   
)

Definition at line 1040 of file text_input_model_unittests.cc.

1040  {
1041  auto model = std::make_unique<TextInputModel>();
1042  model->SetText("ABCDE");
1043  EXPECT_TRUE(model->SetSelection(TextRange(5)));
1044  ASSERT_TRUE(model->Backspace());
1045  EXPECT_EQ(model->selection(), TextRange(4));
1046  EXPECT_EQ(model->composing_range(), TextRange(0));
1047  EXPECT_STREQ(model->GetText().c_str(), "ABCD");
1048 }

◆ TEST() [107/306]

flutter::TEST ( TextInputModel  ,
BackspaceEndComposing   
)

Definition at line 1124 of file text_input_model_unittests.cc.

1124  {
1125  auto model = std::make_unique<TextInputModel>();
1126  model->SetText("ABCDE");
1127  model->BeginComposing();
1128  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
1129  ASSERT_TRUE(model->Backspace());
1130  EXPECT_EQ(model->selection(), TextRange(3));
1131  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
1132  EXPECT_STREQ(model->GetText().c_str(), "ABCE");
1133 }

◆ TEST() [108/306]

flutter::TEST ( TextInputModel  ,
BackspaceEndReverseComposing   
)

Definition at line 1135 of file text_input_model_unittests.cc.

1135  {
1136  auto model = std::make_unique<TextInputModel>();
1137  model->SetText("ABCDE");
1138  model->BeginComposing();
1139  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
1140  ASSERT_TRUE(model->Backspace());
1141  EXPECT_EQ(model->selection(), TextRange(3));
1142  EXPECT_EQ(model->composing_range(), TextRange(3, 1));
1143  EXPECT_STREQ(model->GetText().c_str(), "ABCE");
1144 }

◆ TEST() [109/306]

flutter::TEST ( TextInputModel  ,
BackspaceMiddle   
)

Definition at line 1030 of file text_input_model_unittests.cc.

1030  {
1031  auto model = std::make_unique<TextInputModel>();
1032  model->SetText("ABCDE");
1033  EXPECT_TRUE(model->SetSelection(TextRange(2)));
1034  ASSERT_TRUE(model->Backspace());
1035  EXPECT_EQ(model->selection(), TextRange(1));
1036  EXPECT_EQ(model->composing_range(), TextRange(0));
1037  EXPECT_STREQ(model->GetText().c_str(), "ACDE");
1038 }

◆ TEST() [110/306]

flutter::TEST ( TextInputModel  ,
BackspaceMiddleComposing   
)

Definition at line 1102 of file text_input_model_unittests.cc.

1102  {
1103  auto model = std::make_unique<TextInputModel>();
1104  model->SetText("ABCDE");
1105  model->BeginComposing();
1106  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
1107  ASSERT_TRUE(model->Backspace());
1108  EXPECT_EQ(model->selection(), TextRange(1));
1109  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
1110  EXPECT_STREQ(model->GetText().c_str(), "ACDE");
1111 }

◆ TEST() [111/306]

flutter::TEST ( TextInputModel  ,
BackspaceMiddleReverseComposing   
)

Definition at line 1113 of file text_input_model_unittests.cc.

1113  {
1114  auto model = std::make_unique<TextInputModel>();
1115  model->SetText("ABCDE");
1116  model->BeginComposing();
1117  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
1118  ASSERT_TRUE(model->Backspace());
1119  EXPECT_EQ(model->selection(), TextRange(1));
1120  EXPECT_EQ(model->composing_range(), TextRange(3, 1));
1121  EXPECT_STREQ(model->GetText().c_str(), "ACDE");
1122 }

◆ TEST() [112/306]

flutter::TEST ( TextInputModel  ,
BackspaceReverseSelection   
)

Definition at line 1070 of file text_input_model_unittests.cc.

1070  {
1071  auto model = std::make_unique<TextInputModel>();
1072  model->SetText("ABCDE");
1073  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1074  ASSERT_TRUE(model->Delete());
1075  EXPECT_EQ(model->selection(), TextRange(1));
1076  EXPECT_EQ(model->composing_range(), TextRange(0));
1077  EXPECT_STREQ(model->GetText().c_str(), "AE");
1078 }

◆ TEST() [113/306]

flutter::TEST ( TextInputModel  ,
BackspaceSelection   
)

Definition at line 1060 of file text_input_model_unittests.cc.

1060  {
1061  auto model = std::make_unique<TextInputModel>();
1062  model->SetText("ABCDE");
1063  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1064  ASSERT_TRUE(model->Delete());
1065  EXPECT_EQ(model->selection(), TextRange(1));
1066  EXPECT_EQ(model->composing_range(), TextRange(0));
1067  EXPECT_STREQ(model->GetText().c_str(), "AE");
1068 }

◆ TEST() [114/306]

flutter::TEST ( TextInputModel  ,
BackspaceStart   
)

Definition at line 1020 of file text_input_model_unittests.cc.

1020  {
1021  auto model = std::make_unique<TextInputModel>();
1022  model->SetText("ABCDE");
1023  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1024  ASSERT_FALSE(model->Backspace());
1025  EXPECT_EQ(model->selection(), TextRange(0));
1026  EXPECT_EQ(model->composing_range(), TextRange(0));
1027  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1028 }

◆ TEST() [115/306]

flutter::TEST ( TextInputModel  ,
BackspaceStartComposing   
)

Definition at line 1080 of file text_input_model_unittests.cc.

1080  {
1081  auto model = std::make_unique<TextInputModel>();
1082  model->SetText("ABCDE");
1083  model->BeginComposing();
1084  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1085  ASSERT_FALSE(model->Backspace());
1086  EXPECT_EQ(model->selection(), TextRange(1));
1087  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1088  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1089 }

◆ TEST() [116/306]

flutter::TEST ( TextInputModel  ,
BackspaceStartReverseComposing   
)

Definition at line 1091 of file text_input_model_unittests.cc.

1091  {
1092  auto model = std::make_unique<TextInputModel>();
1093  model->SetText("ABCDE");
1094  model->BeginComposing();
1095  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 0));
1096  ASSERT_FALSE(model->Backspace());
1097  EXPECT_EQ(model->selection(), TextRange(1));
1098  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1099  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1100 }

◆ TEST() [117/306]

flutter::TEST ( TextInputModel  ,
BackspaceWideCharacters   
)

Definition at line 1050 of file text_input_model_unittests.cc.

1050  {
1051  auto model = std::make_unique<TextInputModel>();
1052  model->SetText("😄🙃🤪🧐");
1053  EXPECT_TRUE(model->SetSelection(TextRange(4)));
1054  ASSERT_TRUE(model->Backspace());
1055  EXPECT_EQ(model->selection(), TextRange(2));
1056  EXPECT_EQ(model->composing_range(), TextRange(0));
1057  EXPECT_STREQ(model->GetText().c_str(), "😄🤪🧐");
1058 }

◆ TEST() [118/306]

flutter::TEST ( TextInputModel  ,
CommitComposingNoTextWithNoSelection   
)

Definition at line 290 of file text_input_model_unittests.cc.

290  {
291  auto model = std::make_unique<TextInputModel>();
292  model->SetText("ABCDE");
293  model->SetSelection(TextRange(0));
294 
295  // Verify no changes on BeginComposing.
296  model->BeginComposing();
297  EXPECT_EQ(model->selection(), TextRange(0));
298  EXPECT_EQ(model->composing_range(), TextRange(0));
299  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
300 
301  // Verify no changes on CommitComposing.
302  model->CommitComposing();
303  EXPECT_EQ(model->selection(), TextRange(0));
304  EXPECT_EQ(model->composing_range(), TextRange(0));
305  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
306 
307  // Verify no changes on CommitComposing.
308  model->EndComposing();
309  EXPECT_EQ(model->selection(), TextRange(0));
310  EXPECT_EQ(model->composing_range(), TextRange(0));
311  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
312 }

◆ TEST() [119/306]

flutter::TEST ( TextInputModel  ,
CommitComposingNoTextWithSelection   
)

Definition at line 315 of file text_input_model_unittests.cc.

315  {
316  auto model = std::make_unique<TextInputModel>();
317  model->SetText("ABCDE");
318  model->SetSelection(TextRange(1, 3));
319 
320  // Verify no changes on BeginComposing.
321  model->BeginComposing();
322  EXPECT_EQ(model->selection(), TextRange(1, 3));
323  EXPECT_EQ(model->composing_range(), TextRange(1));
324  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
325 
326  // Verify no changes on CommitComposing.
327  model->CommitComposing();
328  EXPECT_EQ(model->selection(), TextRange(1, 3));
329  EXPECT_EQ(model->composing_range(), TextRange(1));
330  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
331 
332  // Verify no changes on CommitComposing.
333  model->EndComposing();
334  EXPECT_EQ(model->selection(), TextRange(1, 3));
335  EXPECT_EQ(model->composing_range(), TextRange(0));
336  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
337 }

◆ TEST() [120/306]

flutter::TEST ( TextInputModel  ,
CommitComposingTextWithNoSelection   
)

Definition at line 340 of file text_input_model_unittests.cc.

340  {
341  auto model = std::make_unique<TextInputModel>();
342  model->SetText("ABCDE");
343  model->SetSelection(TextRange(1));
344 
345  // Verify no changes on BeginComposing.
346  model->BeginComposing();
347  EXPECT_EQ(model->selection(), TextRange(1));
348  EXPECT_EQ(model->composing_range(), TextRange(1));
349  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
350 
351  // Verify selection base, extent and composing extent increment as text is
352  // entered. Verify composing base does not change.
353  model->UpdateComposingText("つ");
354  EXPECT_EQ(model->selection(), TextRange(2));
355  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
356  EXPECT_STREQ(model->GetText().c_str(), "AつBCDE");
357  model->UpdateComposingText("つる");
358  EXPECT_EQ(model->selection(), TextRange(3));
359  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
360  EXPECT_STREQ(model->GetText().c_str(), "AつるBCDE");
361 
362  // Verify that cursor position is set to correct offset from composing base.
363  model->UpdateComposingText("鶴");
364  EXPECT_TRUE(model->SetSelection(TextRange(1)));
365  EXPECT_EQ(model->selection(), TextRange(1));
366  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
367  EXPECT_STREQ(model->GetText().c_str(), "A鶴BCDE");
368 
369  // Verify composing base is set to composing extent on commit.
370  model->CommitComposing();
371  EXPECT_EQ(model->selection(), TextRange(2));
372  EXPECT_EQ(model->composing_range(), TextRange(2));
373  EXPECT_STREQ(model->GetText().c_str(), "A鶴BCDE");
374 
375  // Verify that further text entry increments the selection base, extent and
376  // the composing extent. Verify that composing base does not change.
377  model->UpdateComposingText("が");
378  EXPECT_EQ(model->selection(), TextRange(3));
379  EXPECT_EQ(model->composing_range(), TextRange(2, 3));
380  EXPECT_STREQ(model->GetText().c_str(), "A鶴がBCDE");
381 
382  // Verify composing base is set to composing extent on commit.
383  model->CommitComposing();
384  EXPECT_EQ(model->selection(), TextRange(3));
385  EXPECT_EQ(model->composing_range(), TextRange(3));
386  EXPECT_STREQ(model->GetText().c_str(), "A鶴がBCDE");
387 
388  // Verify no changes on EndComposing.
389  model->EndComposing();
390  EXPECT_EQ(model->selection(), TextRange(3));
391  EXPECT_EQ(model->composing_range(), TextRange(0));
392  EXPECT_STREQ(model->GetText().c_str(), "A鶴がBCDE");
393 }

◆ TEST() [121/306]

flutter::TEST ( TextInputModel  ,
CommitComposingTextWithSelection   
)

Definition at line 396 of file text_input_model_unittests.cc.

396  {
397  auto model = std::make_unique<TextInputModel>();
398  model->SetText("ABCDE");
399  model->SetSelection(TextRange(1, 3));
400 
401  // Verify no changes on BeginComposing.
402  model->BeginComposing();
403  EXPECT_EQ(model->selection(), TextRange(1, 3));
404  EXPECT_EQ(model->composing_range(), TextRange(1));
405  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
406 
407  // Verify selection is replaced and selection base, extent and composing
408  // extent increment to the position immediately after the composing text.
409  // Verify composing base does not change.
410  model->UpdateComposingText("つ");
411  EXPECT_EQ(model->selection(), TextRange(2));
412  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
413  EXPECT_STREQ(model->GetText().c_str(), "AつDE");
414 
415  // Verify that further text entry increments the selection base, extent and
416  // the composing extent. Verify that composing base does not change.
417  model->UpdateComposingText("つる");
418  EXPECT_EQ(model->selection(), TextRange(3));
419  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
420  EXPECT_STREQ(model->GetText().c_str(), "AつるDE");
421 
422  // Verify that cursor position is set to correct offset from composing base.
423  model->UpdateComposingText("鶴");
424  EXPECT_TRUE(model->SetSelection(TextRange(1)));
425  EXPECT_EQ(model->selection(), TextRange(1));
426  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
427  EXPECT_STREQ(model->GetText().c_str(), "A鶴DE");
428 
429  // Verify composing base is set to composing extent on commit.
430  model->CommitComposing();
431  EXPECT_EQ(model->selection(), TextRange(2));
432  EXPECT_EQ(model->composing_range(), TextRange(2));
433  EXPECT_STREQ(model->GetText().c_str(), "A鶴DE");
434 
435  // Verify that further text entry increments the selection base, extent and
436  // the composing extent. Verify that composing base does not change.
437  model->UpdateComposingText("が");
438  EXPECT_EQ(model->selection(), TextRange(3));
439  EXPECT_EQ(model->composing_range(), TextRange(2, 3));
440  EXPECT_STREQ(model->GetText().c_str(), "A鶴がDE");
441 
442  // Verify composing base is set to composing extent on commit.
443  model->CommitComposing();
444  EXPECT_EQ(model->selection(), TextRange(3));
445  EXPECT_EQ(model->composing_range(), TextRange(3));
446  EXPECT_STREQ(model->GetText().c_str(), "A鶴がDE");
447 
448  // Verify no changes on EndComposing.
449  model->EndComposing();
450  EXPECT_EQ(model->selection(), TextRange(3));
451  EXPECT_EQ(model->composing_range(), TextRange(0));
452  EXPECT_STREQ(model->GetText().c_str(), "A鶴がDE");
453 }

◆ TEST() [122/306]

flutter::TEST ( TextInputModel  ,
DeleteEnd   
)

Definition at line 599 of file text_input_model_unittests.cc.

599  {
600  auto model = std::make_unique<TextInputModel>();
601  model->SetText("ABCDE");
602  EXPECT_TRUE(model->SetSelection(TextRange(5)));
603  ASSERT_FALSE(model->Delete());
604  EXPECT_EQ(model->selection(), TextRange(5));
605  EXPECT_EQ(model->composing_range(), TextRange(0));
606  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
607 }

◆ TEST() [123/306]

flutter::TEST ( TextInputModel  ,
DeleteEndComposing   
)

Definition at line 687 of file text_input_model_unittests.cc.

687  {
688  auto model = std::make_unique<TextInputModel>();
689  model->SetText("ABCDE");
690  model->BeginComposing();
691  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
692  ASSERT_FALSE(model->Delete());
693  EXPECT_EQ(model->selection(), TextRange(4));
694  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
695  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
696 }

◆ TEST() [124/306]

flutter::TEST ( TextInputModel  ,
DeleteEndReverseComposing   
)

Definition at line 698 of file text_input_model_unittests.cc.

698  {
699  auto model = std::make_unique<TextInputModel>();
700  model->SetText("ABCDE");
701  model->BeginComposing();
702  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
703  ASSERT_FALSE(model->Delete());
704  EXPECT_EQ(model->selection(), TextRange(4));
705  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
706  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
707 }

◆ TEST() [125/306]

flutter::TEST ( TextInputModel  ,
DeleteMiddle   
)

Definition at line 589 of file text_input_model_unittests.cc.

589  {
590  auto model = std::make_unique<TextInputModel>();
591  model->SetText("ABCDE");
592  EXPECT_TRUE(model->SetSelection(TextRange(2)));
593  ASSERT_TRUE(model->Delete());
594  EXPECT_EQ(model->selection(), TextRange(2));
595  EXPECT_EQ(model->composing_range(), TextRange(0));
596  EXPECT_STREQ(model->GetText().c_str(), "ABDE");
597 }

◆ TEST() [126/306]

flutter::TEST ( TextInputModel  ,
DeleteMiddleComposing   
)

Definition at line 665 of file text_input_model_unittests.cc.

665  {
666  auto model = std::make_unique<TextInputModel>();
667  model->SetText("ABCDE");
668  model->BeginComposing();
669  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
670  ASSERT_TRUE(model->Delete());
671  EXPECT_EQ(model->selection(), TextRange(2));
672  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
673  EXPECT_STREQ(model->GetText().c_str(), "ABDE");
674 }

◆ TEST() [127/306]

flutter::TEST ( TextInputModel  ,
DeleteMiddleReverseComposing   
)

Definition at line 676 of file text_input_model_unittests.cc.

676  {
677  auto model = std::make_unique<TextInputModel>();
678  model->SetText("ABCDE");
679  model->BeginComposing();
680  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
681  ASSERT_TRUE(model->Delete());
682  EXPECT_EQ(model->selection(), TextRange(2));
683  EXPECT_EQ(model->composing_range(), TextRange(3, 1));
684  EXPECT_STREQ(model->GetText().c_str(), "ABDE");
685 }

◆ TEST() [128/306]

flutter::TEST ( TextInputModel  ,
DeleteReverseSelection   
)

Definition at line 629 of file text_input_model_unittests.cc.

629  {
630  auto model = std::make_unique<TextInputModel>();
631  model->SetText("ABCDE");
632  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
633  ASSERT_TRUE(model->Delete());
634  EXPECT_EQ(model->selection(), TextRange(1));
635  EXPECT_EQ(model->composing_range(), TextRange(0));
636  EXPECT_STREQ(model->GetText().c_str(), "AE");
637 }

◆ TEST() [129/306]

flutter::TEST ( TextInputModel  ,
DeleteSelection   
)

Definition at line 619 of file text_input_model_unittests.cc.

619  {
620  auto model = std::make_unique<TextInputModel>();
621  model->SetText("ABCDE");
622  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
623  ASSERT_TRUE(model->Delete());
624  EXPECT_EQ(model->selection(), TextRange(1));
625  EXPECT_EQ(model->composing_range(), TextRange(0));
626  EXPECT_STREQ(model->GetText().c_str(), "AE");
627 }

◆ TEST() [130/306]

flutter::TEST ( TextInputModel  ,
DeleteStart   
)

Definition at line 579 of file text_input_model_unittests.cc.

579  {
580  auto model = std::make_unique<TextInputModel>();
581  model->SetText("ABCDE");
582  EXPECT_TRUE(model->SetSelection(TextRange(0)));
583  ASSERT_TRUE(model->Delete());
584  EXPECT_EQ(model->selection(), TextRange(0));
585  EXPECT_EQ(model->composing_range(), TextRange(0));
586  EXPECT_STREQ(model->GetText().c_str(), "BCDE");
587 }

◆ TEST() [131/306]

flutter::TEST ( TextInputModel  ,
DeleteStartComposing   
)

Definition at line 639 of file text_input_model_unittests.cc.

639  {
640  auto model = std::make_unique<TextInputModel>();
641  model->SetText("ABCDE");
642  model->BeginComposing();
643  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
644  EXPECT_EQ(model->selection(), TextRange(1));
645  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
646  ASSERT_TRUE(model->Delete());
647  EXPECT_EQ(model->selection(), TextRange(1));
648  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
649  EXPECT_STREQ(model->GetText().c_str(), "ACDE");
650 }

◆ TEST() [132/306]

flutter::TEST ( TextInputModel  ,
DeleteStartReverseComposing   
)

Definition at line 652 of file text_input_model_unittests.cc.

652  {
653  auto model = std::make_unique<TextInputModel>();
654  model->SetText("ABCDE");
655  model->BeginComposing();
656  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 0));
657  EXPECT_EQ(model->selection(), TextRange(1));
658  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
659  ASSERT_TRUE(model->Delete());
660  EXPECT_EQ(model->selection(), TextRange(1));
661  EXPECT_EQ(model->composing_range(), TextRange(3, 1));
662  EXPECT_STREQ(model->GetText().c_str(), "ACDE");
663 }

◆ TEST() [133/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAfterCursor   
)

Definition at line 835 of file text_input_model_unittests.cc.

835  {
836  auto model = std::make_unique<TextInputModel>();
837  model->SetText("ABCDE");
838  EXPECT_TRUE(model->SetSelection(TextRange(2)));
839  EXPECT_TRUE(model->DeleteSurrounding(1, 1));
840  EXPECT_EQ(model->selection(), TextRange(2));
841  EXPECT_EQ(model->composing_range(), TextRange(0));
842  EXPECT_STREQ(model->GetText().c_str(), "ABCE");
843 }

◆ TEST() [134/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAfterCursorAll   
)

Definition at line 856 of file text_input_model_unittests.cc.

856  {
857  auto model = std::make_unique<TextInputModel>();
858  model->SetText("ABCDE");
859  EXPECT_TRUE(model->SetSelection(TextRange(2)));
860  EXPECT_TRUE(model->DeleteSurrounding(1, 2));
861  EXPECT_EQ(model->selection(), TextRange(2));
862  EXPECT_EQ(model->composing_range(), TextRange(0));
863  EXPECT_STREQ(model->GetText().c_str(), "ABC");
864 }

◆ TEST() [135/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAfterCursorAllComposing   
)

Definition at line 866 of file text_input_model_unittests.cc.

866  {
867  auto model = std::make_unique<TextInputModel>();
868  model->SetText("ABCDE");
869  model->BeginComposing();
870  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
871  EXPECT_TRUE(model->DeleteSurrounding(1, 2));
872  EXPECT_EQ(model->selection(), TextRange(1));
873  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
874  EXPECT_STREQ(model->GetText().c_str(), "ABE");
875 }

◆ TEST() [136/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAfterCursorComposing   
)

Definition at line 845 of file text_input_model_unittests.cc.

845  {
846  auto model = std::make_unique<TextInputModel>();
847  model->SetText("ABCDE");
848  model->BeginComposing();
849  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
850  EXPECT_TRUE(model->DeleteSurrounding(1, 1));
851  EXPECT_EQ(model->selection(), TextRange(1));
852  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
853  EXPECT_STREQ(model->GetText().c_str(), "ABDE");
854 }

◆ TEST() [137/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAfterCursorGreedy   
)

Definition at line 877 of file text_input_model_unittests.cc.

877  {
878  auto model = std::make_unique<TextInputModel>();
879  model->SetText("ABCDE");
880  EXPECT_TRUE(model->SetSelection(TextRange(2)));
881  EXPECT_TRUE(model->DeleteSurrounding(1, 3));
882  EXPECT_EQ(model->selection(), TextRange(2));
883  EXPECT_EQ(model->composing_range(), TextRange(0));
884  EXPECT_STREQ(model->GetText().c_str(), "ABC");
885 }

◆ TEST() [138/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAfterCursorGreedyComposing   
)

Definition at line 887 of file text_input_model_unittests.cc.

887  {
888  auto model = std::make_unique<TextInputModel>();
889  model->SetText("ABCDE");
890  model->BeginComposing();
891  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
892  EXPECT_TRUE(model->DeleteSurrounding(1, 3));
893  EXPECT_EQ(model->selection(), TextRange(1));
894  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
895  EXPECT_STREQ(model->GetText().c_str(), "ABE");
896 }

◆ TEST() [139/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAtCursor   
)

Definition at line 709 of file text_input_model_unittests.cc.

709  {
710  auto model = std::make_unique<TextInputModel>();
711  model->SetText("ABCDE");
712  EXPECT_TRUE(model->SetSelection(TextRange(2)));
713  EXPECT_TRUE(model->DeleteSurrounding(0, 1));
714  EXPECT_EQ(model->selection(), TextRange(2));
715  EXPECT_EQ(model->composing_range(), TextRange(0));
716  EXPECT_STREQ(model->GetText().c_str(), "ABDE");
717 }

◆ TEST() [140/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAtCursorAll   
)

Definition at line 730 of file text_input_model_unittests.cc.

730  {
731  auto model = std::make_unique<TextInputModel>();
732  model->SetText("ABCDE");
733  EXPECT_TRUE(model->SetSelection(TextRange(2)));
734  EXPECT_TRUE(model->DeleteSurrounding(0, 3));
735  EXPECT_EQ(model->selection(), TextRange(2));
736  EXPECT_EQ(model->composing_range(), TextRange(0));
737  EXPECT_STREQ(model->GetText().c_str(), "AB");
738 }

◆ TEST() [141/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAtCursorAllComposing   
)

Definition at line 740 of file text_input_model_unittests.cc.

740  {
741  auto model = std::make_unique<TextInputModel>();
742  model->SetText("ABCDE");
743  model->BeginComposing();
744  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
745  EXPECT_TRUE(model->DeleteSurrounding(0, 2));
746  EXPECT_EQ(model->selection(), TextRange(2));
747  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
748  EXPECT_STREQ(model->GetText().c_str(), "ABE");
749 }

◆ TEST() [142/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAtCursorComposing   
)

Definition at line 719 of file text_input_model_unittests.cc.

719  {
720  auto model = std::make_unique<TextInputModel>();
721  model->SetText("ABCDE");
722  model->BeginComposing();
723  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
724  EXPECT_TRUE(model->DeleteSurrounding(0, 1));
725  EXPECT_EQ(model->selection(), TextRange(2));
726  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
727  EXPECT_STREQ(model->GetText().c_str(), "ABDE");
728 }

◆ TEST() [143/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAtCursorGreedy   
)

Definition at line 751 of file text_input_model_unittests.cc.

751  {
752  auto model = std::make_unique<TextInputModel>();
753  model->SetText("ABCDE");
754  EXPECT_TRUE(model->SetSelection(TextRange(2)));
755  EXPECT_TRUE(model->DeleteSurrounding(0, 4));
756  EXPECT_EQ(model->selection(), TextRange(2));
757  EXPECT_EQ(model->composing_range(), TextRange(0));
758  EXPECT_STREQ(model->GetText().c_str(), "AB");
759 }

◆ TEST() [144/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingAtCursorGreedyComposing   
)

Definition at line 761 of file text_input_model_unittests.cc.

761  {
762  auto model = std::make_unique<TextInputModel>();
763  model->SetText("ABCDE");
764  model->BeginComposing();
765  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
766  EXPECT_TRUE(model->DeleteSurrounding(0, 4));
767  EXPECT_EQ(model->selection(), TextRange(2));
768  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
769  EXPECT_STREQ(model->GetText().c_str(), "ABE");
770 }

◆ TEST() [145/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingBeforeCursor   
)

Definition at line 772 of file text_input_model_unittests.cc.

772  {
773  auto model = std::make_unique<TextInputModel>();
774  model->SetText("ABCDE");
775  EXPECT_TRUE(model->SetSelection(TextRange(2)));
776  EXPECT_TRUE(model->DeleteSurrounding(-1, 1));
777  EXPECT_EQ(model->selection(), TextRange(1));
778  EXPECT_EQ(model->composing_range(), TextRange(0));
779  EXPECT_STREQ(model->GetText().c_str(), "ACDE");
780 }

◆ TEST() [146/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingBeforeCursorAll   
)

Definition at line 793 of file text_input_model_unittests.cc.

793  {
794  auto model = std::make_unique<TextInputModel>();
795  model->SetText("ABCDE");
796  EXPECT_TRUE(model->SetSelection(TextRange(2)));
797  EXPECT_TRUE(model->DeleteSurrounding(-2, 2));
798  EXPECT_EQ(model->selection(), TextRange(0));
799  EXPECT_EQ(model->composing_range(), TextRange(0));
800  EXPECT_STREQ(model->GetText().c_str(), "CDE");
801 }

◆ TEST() [147/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingBeforeCursorAllComposing   
)

Definition at line 803 of file text_input_model_unittests.cc.

803  {
804  auto model = std::make_unique<TextInputModel>();
805  model->SetText("ABCDE");
806  model->BeginComposing();
807  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 2));
808  EXPECT_TRUE(model->DeleteSurrounding(-2, 2));
809  EXPECT_EQ(model->selection(), TextRange(1));
810  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
811  EXPECT_STREQ(model->GetText().c_str(), "ADE");
812 }

◆ TEST() [148/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingBeforeCursorComposing   
)

Definition at line 782 of file text_input_model_unittests.cc.

782  {
783  auto model = std::make_unique<TextInputModel>();
784  model->SetText("ABCDE");
785  model->BeginComposing();
786  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 2));
787  EXPECT_TRUE(model->DeleteSurrounding(-1, 1));
788  EXPECT_EQ(model->selection(), TextRange(2));
789  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
790  EXPECT_STREQ(model->GetText().c_str(), "ABDE");
791 }

◆ TEST() [149/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingBeforeCursorGreedy   
)

Definition at line 814 of file text_input_model_unittests.cc.

814  {
815  auto model = std::make_unique<TextInputModel>();
816  model->SetText("ABCDE");
817  EXPECT_TRUE(model->SetSelection(TextRange(2)));
818  EXPECT_TRUE(model->DeleteSurrounding(-3, 3));
819  EXPECT_EQ(model->selection(), TextRange(0));
820  EXPECT_EQ(model->composing_range(), TextRange(0));
821  EXPECT_STREQ(model->GetText().c_str(), "CDE");
822 }

◆ TEST() [150/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingBeforeCursorGreedyComposing   
)

Definition at line 824 of file text_input_model_unittests.cc.

824  {
825  auto model = std::make_unique<TextInputModel>();
826  model->SetText("ABCDE");
827  model->BeginComposing();
828  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 2));
829  EXPECT_TRUE(model->DeleteSurrounding(-3, 3));
830  EXPECT_EQ(model->selection(), TextRange(1));
831  EXPECT_EQ(model->composing_range(), TextRange(1, 2));
832  EXPECT_STREQ(model->GetText().c_str(), "ADE");
833 }

◆ TEST() [151/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingGuardStopsAtComposingEnd   
)

Definition at line 990 of file text_input_model_unittests.cc.

990  {
991  auto model = std::make_unique<TextInputModel>();
992  model->SetText("A😄B");
993  model->BeginComposing();
994  // Composing range deliberately ends in the middle of the surrogate pair.
995  EXPECT_TRUE(model->SetComposingRange(TextRange(0, 2), 0));
996  EXPECT_TRUE(model->DeleteSurrounding(0, 3));
997  EXPECT_EQ(model->selection(), TextRange(0));
998  EXPECT_EQ(model->composing_range(), TextRange(0, 0));
999  EXPECT_STREQ(model->GetText().c_str(), "B");
1000 }

◆ TEST() [152/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingGuardStopsAtComposingStart   
)

Definition at line 1008 of file text_input_model_unittests.cc.

1008  {
1009  auto model = std::make_unique<TextInputModel>();
1010  model->SetText("A😄B");
1011  model->BeginComposing();
1012  // Composing range deliberately starts in the middle of the surrogate pair.
1013  EXPECT_TRUE(model->SetComposingRange(TextRange(2, 4), 2));
1014  EXPECT_TRUE(model->DeleteSurrounding(-3, 1));
1015  EXPECT_EQ(model->selection(), TextRange(1));
1016  EXPECT_EQ(model->composing_range(), TextRange(1, 1));
1017  EXPECT_STREQ(model->GetText().c_str(), "A");
1018 }

◆ TEST() [153/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingReverseSelection   
)

Definition at line 908 of file text_input_model_unittests.cc.

908  {
909  auto model = std::make_unique<TextInputModel>();
910  model->SetText("ABCDE");
911  EXPECT_TRUE(model->SetSelection(TextRange(4, 3)));
912  EXPECT_TRUE(model->DeleteSurrounding(0, 1));
913  EXPECT_EQ(model->selection(), TextRange(3));
914  EXPECT_EQ(model->composing_range(), TextRange(0));
915  EXPECT_STREQ(model->GetText().c_str(), "ABCE");
916 }

◆ TEST() [154/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingSelection   
)

Definition at line 898 of file text_input_model_unittests.cc.

898  {
899  auto model = std::make_unique<TextInputModel>();
900  model->SetText("ABCDE");
901  EXPECT_TRUE(model->SetSelection(TextRange(2, 3)));
902  EXPECT_TRUE(model->DeleteSurrounding(0, 1));
903  EXPECT_EQ(model->selection(), TextRange(3));
904  EXPECT_EQ(model->composing_range(), TextRange(0));
905  EXPECT_STREQ(model->GetText().c_str(), "ABCE");
906 }

◆ TEST() [155/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingWideCharacterAfterCursor   
)

Definition at line 921 of file text_input_model_unittests.cc.

921  {
922  auto model = std::make_unique<TextInputModel>();
923  model->SetText("A😄B");
924  EXPECT_TRUE(model->SetSelection(TextRange(0)));
925  EXPECT_TRUE(model->DeleteSurrounding(0, 2));
926  EXPECT_EQ(model->selection(), TextRange(0));
927  EXPECT_EQ(model->composing_range(), TextRange(0));
928  EXPECT_STREQ(model->GetText().c_str(), "B");
929 }

◆ TEST() [156/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingWideCharacterBeforeCursor   
)

Definition at line 931 of file text_input_model_unittests.cc.

931  {
932  auto model = std::make_unique<TextInputModel>();
933  model->SetText("A😄");
934  EXPECT_TRUE(model->SetSelection(TextRange(3)));
935  EXPECT_TRUE(model->DeleteSurrounding(-2, 2));
936  EXPECT_EQ(model->selection(), TextRange(0));
937  EXPECT_EQ(model->composing_range(), TextRange(0));
938  EXPECT_STREQ(model->GetText().c_str(), "");
939 }

◆ TEST() [157/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingWideCharacterComposing   
)

Definition at line 973 of file text_input_model_unittests.cc.

973  {
974  auto model = std::make_unique<TextInputModel>();
975  model->SetText("A😄B");
976  model->BeginComposing();
977  EXPECT_TRUE(model->SetComposingRange(TextRange(0, 3), 0));
978  EXPECT_TRUE(model->DeleteSurrounding(0, 2));
979  EXPECT_EQ(model->selection(), TextRange(0));
980  EXPECT_EQ(model->composing_range(), TextRange(0, 0));
981  EXPECT_STREQ(model->GetText().c_str(), "B");
982 }

◆ TEST() [158/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingWideCharacterFirst   
)

Definition at line 943 of file text_input_model_unittests.cc.

943  {
944  auto model = std::make_unique<TextInputModel>();
945  model->SetText("😄AB");
946  EXPECT_TRUE(model->SetSelection(TextRange(0)));
947  EXPECT_TRUE(model->DeleteSurrounding(0, 2));
948  EXPECT_EQ(model->selection(), TextRange(0));
949  EXPECT_EQ(model->composing_range(), TextRange(0));
950  EXPECT_STREQ(model->GetText().c_str(), "B");
951 }

◆ TEST() [159/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingWideCharacterGreedy   
)

Definition at line 963 of file text_input_model_unittests.cc.

963  {
964  auto model = std::make_unique<TextInputModel>();
965  model->SetText("A😄");
966  EXPECT_TRUE(model->SetSelection(TextRange(0)));
967  EXPECT_TRUE(model->DeleteSurrounding(0, 5));
968  EXPECT_EQ(model->selection(), TextRange(0));
969  EXPECT_EQ(model->composing_range(), TextRange(0));
970  EXPECT_STREQ(model->GetText().c_str(), "");
971 }

◆ TEST() [160/306]

flutter::TEST ( TextInputModel  ,
DeleteSurroundingWideCharactersAfterCursorOffset   
)

Definition at line 953 of file text_input_model_unittests.cc.

953  {
954  auto model = std::make_unique<TextInputModel>();
955  model->SetText("A😄🙃B");
956  EXPECT_TRUE(model->SetSelection(TextRange(0)));
957  EXPECT_TRUE(model->DeleteSurrounding(1, 2));
958  EXPECT_EQ(model->selection(), TextRange(0));
959  EXPECT_EQ(model->composing_range(), TextRange(0));
960  EXPECT_STREQ(model->GetText().c_str(), "AB");
961 }

◆ TEST() [161/306]

flutter::TEST ( TextInputModel  ,
DeleteWideCharacters   
)

Definition at line 609 of file text_input_model_unittests.cc.

609  {
610  auto model = std::make_unique<TextInputModel>();
611  model->SetText("😄🙃🤪🧐");
612  EXPECT_TRUE(model->SetSelection(TextRange(4)));
613  ASSERT_TRUE(model->Delete());
614  EXPECT_EQ(model->selection(), TextRange(4));
615  EXPECT_EQ(model->composing_range(), TextRange(0));
616  EXPECT_STREQ(model->GetText().c_str(), "😄🙃🧐");
617 }

◆ TEST() [162/306]

flutter::TEST ( TextInputModel  ,
GetCursorOffset   
)

Definition at line 1864 of file text_input_model_unittests.cc.

1864  {
1865  auto model = std::make_unique<TextInputModel>();
1866  // These characters take 1, 2, 3 and 4 bytes in UTF-8.
1867  model->SetText("$¢€𐍈");
1868  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1869  EXPECT_EQ(model->GetCursorOffset(), 0);
1870  EXPECT_TRUE(model->MoveCursorForward());
1871  EXPECT_EQ(model->GetCursorOffset(), 1);
1872  EXPECT_TRUE(model->MoveCursorForward());
1873  EXPECT_EQ(model->GetCursorOffset(), 3);
1874  EXPECT_TRUE(model->MoveCursorForward());
1875  EXPECT_EQ(model->GetCursorOffset(), 6);
1876  EXPECT_TRUE(model->MoveCursorForward());
1877  EXPECT_EQ(model->GetCursorOffset(), 10);
1878 }

◆ TEST() [163/306]

flutter::TEST ( TextInputModel  ,
GetCursorOffsetReverseSelection   
)

Definition at line 1887 of file text_input_model_unittests.cc.

1887  {
1888  auto model = std::make_unique<TextInputModel>();
1889  model->SetText("ABCDE");
1890  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1891  EXPECT_EQ(model->GetCursorOffset(), 1);
1892 }

◆ TEST() [164/306]

flutter::TEST ( TextInputModel  ,
GetCursorOffsetSelection   
)

Definition at line 1880 of file text_input_model_unittests.cc.

1880  {
1881  auto model = std::make_unique<TextInputModel>();
1882  model->SetText("ABCDE");
1883  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1884  EXPECT_EQ(model->GetCursorOffset(), 4);
1885 }

◆ TEST() [165/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackEnd   
)

Definition at line 1292 of file text_input_model_unittests.cc.

1292  {
1293  auto model = std::make_unique<TextInputModel>();
1294  model->SetText("ABCDE");
1295  EXPECT_TRUE(model->SetSelection(TextRange(5)));
1296  EXPECT_TRUE(model->MoveCursorBack());
1297  EXPECT_EQ(model->selection(), TextRange(4));
1298  EXPECT_EQ(model->composing_range(), TextRange(0));
1299  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1300 }

◆ TEST() [166/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackEndComposing   
)

Definition at line 1378 of file text_input_model_unittests.cc.

1378  {
1379  auto model = std::make_unique<TextInputModel>();
1380  model->SetText("ABCDE");
1381  model->BeginComposing();
1382  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
1383  EXPECT_TRUE(model->MoveCursorBack());
1384  EXPECT_EQ(model->selection(), TextRange(3));
1385  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1386  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1387 }

◆ TEST() [167/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackEndReverseComposing   
)

Definition at line 1389 of file text_input_model_unittests.cc.

1389  {
1390  auto model = std::make_unique<TextInputModel>();
1391  model->SetText("ABCDE");
1392  model->BeginComposing();
1393  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
1394  EXPECT_TRUE(model->MoveCursorBack());
1395  EXPECT_EQ(model->selection(), TextRange(3));
1396  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1397  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1398 }

◆ TEST() [168/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackMiddle   
)

Definition at line 1282 of file text_input_model_unittests.cc.

1282  {
1283  auto model = std::make_unique<TextInputModel>();
1284  model->SetText("ABCDE");
1285  EXPECT_TRUE(model->SetSelection(TextRange(2)));
1286  EXPECT_TRUE(model->MoveCursorBack());
1287  EXPECT_EQ(model->selection(), TextRange(1));
1288  EXPECT_EQ(model->composing_range(), TextRange(0));
1289  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1290 }

◆ TEST() [169/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackMiddleComposing   
)

Definition at line 1356 of file text_input_model_unittests.cc.

1356  {
1357  auto model = std::make_unique<TextInputModel>();
1358  model->SetText("ABCDE");
1359  model->BeginComposing();
1360  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
1361  EXPECT_TRUE(model->MoveCursorBack());
1362  EXPECT_EQ(model->selection(), TextRange(1));
1363  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1364  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1365 }

◆ TEST() [170/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackMiddleReverseComposing   
)

Definition at line 1367 of file text_input_model_unittests.cc.

1367  {
1368  auto model = std::make_unique<TextInputModel>();
1369  model->SetText("ABCDE");
1370  model->BeginComposing();
1371  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
1372  EXPECT_TRUE(model->MoveCursorBack());
1373  EXPECT_EQ(model->selection(), TextRange(1));
1374  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1375  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1376 }

◆ TEST() [171/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackReverseSelection   
)

Definition at line 1322 of file text_input_model_unittests.cc.

1322  {
1323  auto model = std::make_unique<TextInputModel>();
1324  model->SetText("ABCDE");
1325  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1326  EXPECT_TRUE(model->MoveCursorBack());
1327  EXPECT_EQ(model->selection(), TextRange(1));
1328  EXPECT_EQ(model->composing_range(), TextRange(0));
1329  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1330 }

◆ TEST() [172/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackSelection   
)

Definition at line 1312 of file text_input_model_unittests.cc.

1312  {
1313  auto model = std::make_unique<TextInputModel>();
1314  model->SetText("ABCDE");
1315  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1316  EXPECT_TRUE(model->MoveCursorBack());
1317  EXPECT_EQ(model->selection(), TextRange(1));
1318  EXPECT_EQ(model->composing_range(), TextRange(0));
1319  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1320 }

◆ TEST() [173/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackStart   
)

Definition at line 1272 of file text_input_model_unittests.cc.

1272  {
1273  auto model = std::make_unique<TextInputModel>();
1274  model->SetText("ABCDE");
1275  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1276  EXPECT_FALSE(model->MoveCursorBack());
1277  EXPECT_EQ(model->selection(), TextRange(0));
1278  EXPECT_EQ(model->composing_range(), TextRange(0));
1279  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1280 }

◆ TEST() [174/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackStartComposing   
)

Definition at line 1332 of file text_input_model_unittests.cc.

1332  {
1333  auto model = std::make_unique<TextInputModel>();
1334  model->SetText("ABCDE");
1335  model->BeginComposing();
1336  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1337  EXPECT_TRUE(model->SetSelection(TextRange(1)));
1338  EXPECT_FALSE(model->MoveCursorBack());
1339  EXPECT_EQ(model->selection(), TextRange(1));
1340  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1341  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1342 }

◆ TEST() [175/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackStartReverseComposing   
)

Definition at line 1344 of file text_input_model_unittests.cc.

1344  {
1345  auto model = std::make_unique<TextInputModel>();
1346  model->SetText("ABCDE");
1347  model->BeginComposing();
1348  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 0));
1349  EXPECT_TRUE(model->SetSelection(TextRange(1)));
1350  EXPECT_FALSE(model->MoveCursorBack());
1351  EXPECT_EQ(model->selection(), TextRange(1));
1352  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1353  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1354 }

◆ TEST() [176/306]

flutter::TEST ( TextInputModel  ,
MoveCursorBackWideCharacters   
)

Definition at line 1302 of file text_input_model_unittests.cc.

1302  {
1303  auto model = std::make_unique<TextInputModel>();
1304  model->SetText("😄🙃🤪🧐");
1305  EXPECT_TRUE(model->SetSelection(TextRange(4)));
1306  ASSERT_TRUE(model->MoveCursorBack());
1307  EXPECT_EQ(model->selection(), TextRange(2));
1308  EXPECT_EQ(model->composing_range(), TextRange(0));
1309  EXPECT_STREQ(model->GetText().c_str(), "😄🙃🤪🧐");
1310 }

◆ TEST() [177/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardEnd   
)

Definition at line 1166 of file text_input_model_unittests.cc.

1166  {
1167  auto model = std::make_unique<TextInputModel>();
1168  model->SetText("ABCDE");
1169  EXPECT_TRUE(model->SetSelection(TextRange(5)));
1170  EXPECT_FALSE(model->MoveCursorForward());
1171  EXPECT_EQ(model->selection(), TextRange(5));
1172  EXPECT_EQ(model->composing_range(), TextRange(0));
1173  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1174 }

◆ TEST() [178/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardEndComposing   
)

Definition at line 1250 of file text_input_model_unittests.cc.

1250  {
1251  auto model = std::make_unique<TextInputModel>();
1252  model->SetText("ABCDE");
1253  model->BeginComposing();
1254  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
1255  EXPECT_FALSE(model->MoveCursorForward());
1256  EXPECT_EQ(model->selection(), TextRange(4));
1257  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1258  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1259 }

◆ TEST() [179/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardEndReverseComposing   
)

Definition at line 1261 of file text_input_model_unittests.cc.

1261  {
1262  auto model = std::make_unique<TextInputModel>();
1263  model->SetText("ABCDE");
1264  model->BeginComposing();
1265  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
1266  EXPECT_FALSE(model->MoveCursorForward());
1267  EXPECT_EQ(model->selection(), TextRange(4));
1268  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1269  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1270 }

◆ TEST() [180/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardMiddle   
)

Definition at line 1156 of file text_input_model_unittests.cc.

1156  {
1157  auto model = std::make_unique<TextInputModel>();
1158  model->SetText("ABCDE");
1159  EXPECT_TRUE(model->SetSelection(TextRange(2)));
1160  EXPECT_TRUE(model->MoveCursorForward());
1161  EXPECT_EQ(model->selection(), TextRange(3));
1162  EXPECT_EQ(model->composing_range(), TextRange(0));
1163  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1164 }

◆ TEST() [181/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardMiddleComposing   
)

Definition at line 1228 of file text_input_model_unittests.cc.

1228  {
1229  auto model = std::make_unique<TextInputModel>();
1230  model->SetText("ABCDE");
1231  model->BeginComposing();
1232  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
1233  EXPECT_TRUE(model->MoveCursorForward());
1234  EXPECT_EQ(model->selection(), TextRange(3));
1235  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1236  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1237 }

◆ TEST() [182/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardMiddleReverseComposing   
)

Definition at line 1239 of file text_input_model_unittests.cc.

1239  {
1240  auto model = std::make_unique<TextInputModel>();
1241  model->SetText("ABCDE");
1242  model->BeginComposing();
1243  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
1244  EXPECT_TRUE(model->MoveCursorForward());
1245  EXPECT_EQ(model->selection(), TextRange(3));
1246  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1247  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1248 }

◆ TEST() [183/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardReverseSelection   
)

Definition at line 1196 of file text_input_model_unittests.cc.

1196  {
1197  auto model = std::make_unique<TextInputModel>();
1198  model->SetText("ABCDE");
1199  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1200  EXPECT_TRUE(model->MoveCursorForward());
1201  EXPECT_EQ(model->selection(), TextRange(4));
1202  EXPECT_EQ(model->composing_range(), TextRange(0));
1203  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1204 }

◆ TEST() [184/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardSelection   
)

Definition at line 1186 of file text_input_model_unittests.cc.

1186  {
1187  auto model = std::make_unique<TextInputModel>();
1188  model->SetText("ABCDE");
1189  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1190  EXPECT_TRUE(model->MoveCursorForward());
1191  EXPECT_EQ(model->selection(), TextRange(4));
1192  EXPECT_EQ(model->composing_range(), TextRange(0));
1193  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1194 }

◆ TEST() [185/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardStart   
)

Definition at line 1146 of file text_input_model_unittests.cc.

1146  {
1147  auto model = std::make_unique<TextInputModel>();
1148  model->SetText("ABCDE");
1149  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1150  EXPECT_TRUE(model->MoveCursorForward());
1151  EXPECT_EQ(model->selection(), TextRange(1));
1152  EXPECT_EQ(model->composing_range(), TextRange(0));
1153  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1154 }

◆ TEST() [186/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardStartComposing   
)

Definition at line 1206 of file text_input_model_unittests.cc.

1206  {
1207  auto model = std::make_unique<TextInputModel>();
1208  model->SetText("ABCDE");
1209  model->BeginComposing();
1210  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1211  EXPECT_TRUE(model->MoveCursorForward());
1212  EXPECT_EQ(model->selection(), TextRange(2));
1213  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1214  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1215 }

◆ TEST() [187/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardStartReverseComposing   
)

Definition at line 1217 of file text_input_model_unittests.cc.

1217  {
1218  auto model = std::make_unique<TextInputModel>();
1219  model->SetText("ABCDE");
1220  model->BeginComposing();
1221  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 0));
1222  EXPECT_TRUE(model->MoveCursorForward());
1223  EXPECT_EQ(model->selection(), TextRange(2));
1224  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1225  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1226 }

◆ TEST() [188/306]

flutter::TEST ( TextInputModel  ,
MoveCursorForwardWideCharacters   
)

Definition at line 1176 of file text_input_model_unittests.cc.

1176  {
1177  auto model = std::make_unique<TextInputModel>();
1178  model->SetText("😄🙃🤪🧐");
1179  EXPECT_TRUE(model->SetSelection(TextRange(4)));
1180  ASSERT_TRUE(model->MoveCursorForward());
1181  EXPECT_EQ(model->selection(), TextRange(6));
1182  EXPECT_EQ(model->composing_range(), TextRange(0));
1183  EXPECT_STREQ(model->GetText().c_str(), "😄🙃🤪🧐");
1184 }

◆ TEST() [189/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningEnd   
)

Definition at line 1440 of file text_input_model_unittests.cc.

1440  {
1441  auto model = std::make_unique<TextInputModel>();
1442  model->SetText("ABCDE");
1443  EXPECT_TRUE(model->SetSelection(TextRange(5)));
1444  EXPECT_TRUE(model->MoveCursorToBeginning());
1445  EXPECT_EQ(model->selection(), TextRange(0));
1446  EXPECT_EQ(model->composing_range(), TextRange(0));
1447  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1448 }

◆ TEST() [190/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningEndComposing   
)

Definition at line 1588 of file text_input_model_unittests.cc.

1588  {
1589  auto model = std::make_unique<TextInputModel>();
1590  model->SetText("ABCDE");
1591  model->BeginComposing();
1592  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
1593  EXPECT_TRUE(model->MoveCursorToBeginning());
1594  EXPECT_EQ(model->selection(), TextRange(1));
1595  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1596  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1597 }

◆ TEST() [191/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningEndReverseComposing   
)

Definition at line 1610 of file text_input_model_unittests.cc.

1610  {
1611  auto model = std::make_unique<TextInputModel>();
1612  model->SetText("ABCDE");
1613  model->BeginComposing();
1614  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
1615  EXPECT_TRUE(model->MoveCursorToBeginning());
1616  EXPECT_EQ(model->selection(), TextRange(1));
1617  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1618  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1619 }

◆ TEST() [192/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningMiddle   
)

Definition at line 1420 of file text_input_model_unittests.cc.

1420  {
1421  auto model = std::make_unique<TextInputModel>();
1422  model->SetText("ABCDE");
1423  EXPECT_TRUE(model->SetSelection(TextRange(2)));
1424  EXPECT_TRUE(model->MoveCursorToBeginning());
1425  EXPECT_EQ(model->selection(), TextRange(0));
1426  EXPECT_EQ(model->composing_range(), TextRange(0));
1427  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1428 }

◆ TEST() [193/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningMiddleComposing   
)

Definition at line 1544 of file text_input_model_unittests.cc.

1544  {
1545  auto model = std::make_unique<TextInputModel>();
1546  model->SetText("ABCDE");
1547  model->BeginComposing();
1548  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
1549  EXPECT_TRUE(model->MoveCursorToBeginning());
1550  EXPECT_EQ(model->selection(), TextRange(1));
1551  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1552  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1553 }

◆ TEST() [194/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningMiddleReverseComposing   
)

Definition at line 1566 of file text_input_model_unittests.cc.

1566  {
1567  auto model = std::make_unique<TextInputModel>();
1568  model->SetText("ABCDE");
1569  model->BeginComposing();
1570  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
1571  EXPECT_TRUE(model->MoveCursorToBeginning());
1572  EXPECT_EQ(model->selection(), TextRange(1));
1573  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1574  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1575 }

◆ TEST() [195/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningReverseSelection   
)

Definition at line 1480 of file text_input_model_unittests.cc.

1480  {
1481  auto model = std::make_unique<TextInputModel>();
1482  model->SetText("ABCDE");
1483  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1484  EXPECT_TRUE(model->MoveCursorToBeginning());
1485  EXPECT_EQ(model->selection(), TextRange(0));
1486  EXPECT_EQ(model->composing_range(), TextRange(0));
1487  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1488 }

◆ TEST() [196/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningSelection   
)

Definition at line 1460 of file text_input_model_unittests.cc.

1460  {
1461  auto model = std::make_unique<TextInputModel>();
1462  model->SetText("ABCDE");
1463  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1464  EXPECT_TRUE(model->MoveCursorToBeginning());
1465  EXPECT_EQ(model->selection(), TextRange(0));
1466  EXPECT_EQ(model->composing_range(), TextRange(0));
1467  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1468 }

◆ TEST() [197/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningStart   
)

Definition at line 1400 of file text_input_model_unittests.cc.

1400  {
1401  auto model = std::make_unique<TextInputModel>();
1402  model->SetText("ABCDE");
1403  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1404  EXPECT_FALSE(model->MoveCursorToBeginning());
1405  EXPECT_EQ(model->selection(), TextRange(0));
1406  EXPECT_EQ(model->composing_range(), TextRange(0));
1407  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1408 }

◆ TEST() [198/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningStartComposing   
)

Definition at line 1500 of file text_input_model_unittests.cc.

1500  {
1501  auto model = std::make_unique<TextInputModel>();
1502  model->SetText("ABCDE");
1503  model->BeginComposing();
1504  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1505  EXPECT_FALSE(model->MoveCursorToBeginning());
1506  EXPECT_EQ(model->selection(), TextRange(1));
1507  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1508  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1509 }

◆ TEST() [199/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToBeginningStartReverseComposing   
)

Definition at line 1522 of file text_input_model_unittests.cc.

1522  {
1523  auto model = std::make_unique<TextInputModel>();
1524  model->SetText("ABCDE");
1525  model->BeginComposing();
1526  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 0));
1527  EXPECT_FALSE(model->MoveCursorToBeginning());
1528  EXPECT_EQ(model->selection(), TextRange(1));
1529  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1530  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1531 }

◆ TEST() [200/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndEnd   
)

Definition at line 1672 of file text_input_model_unittests.cc.

1672  {
1673  auto model = std::make_unique<TextInputModel>();
1674  model->SetText("ABCDE");
1675  EXPECT_TRUE(model->SetSelection(TextRange(5)));
1676  EXPECT_FALSE(model->MoveCursorToEnd());
1677  EXPECT_EQ(model->selection(), TextRange(5));
1678  EXPECT_EQ(model->composing_range(), TextRange(0));
1679  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1680 }

◆ TEST() [201/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndEndComposing   
)

Definition at line 1820 of file text_input_model_unittests.cc.

1820  {
1821  auto model = std::make_unique<TextInputModel>();
1822  model->SetText("ABCDE");
1823  model->BeginComposing();
1824  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
1825  EXPECT_FALSE(model->MoveCursorToEnd());
1826  EXPECT_EQ(model->selection(), TextRange(4));
1827  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1828  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1829 }

◆ TEST() [202/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndEndReverseComposing   
)

Definition at line 1842 of file text_input_model_unittests.cc.

1842  {
1843  auto model = std::make_unique<TextInputModel>();
1844  model->SetText("ABCDE");
1845  model->BeginComposing();
1846  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
1847  EXPECT_FALSE(model->MoveCursorToEnd());
1848  EXPECT_EQ(model->selection(), TextRange(4));
1849  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1850  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1851 }

◆ TEST() [203/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndMiddle   
)

Definition at line 1652 of file text_input_model_unittests.cc.

1652  {
1653  auto model = std::make_unique<TextInputModel>();
1654  model->SetText("ABCDE");
1655  EXPECT_TRUE(model->SetSelection(TextRange(2)));
1656  EXPECT_TRUE(model->MoveCursorToEnd());
1657  EXPECT_EQ(model->selection(), TextRange(5));
1658  EXPECT_EQ(model->composing_range(), TextRange(0));
1659  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1660 }

◆ TEST() [204/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndMiddleComposing   
)

Definition at line 1776 of file text_input_model_unittests.cc.

1776  {
1777  auto model = std::make_unique<TextInputModel>();
1778  model->SetText("ABCDE");
1779  model->BeginComposing();
1780  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
1781  EXPECT_TRUE(model->MoveCursorToEnd());
1782  EXPECT_EQ(model->selection(), TextRange(4));
1783  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1784  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1785 }

◆ TEST() [205/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndMiddleReverseComposing   
)

Definition at line 1798 of file text_input_model_unittests.cc.

1798  {
1799  auto model = std::make_unique<TextInputModel>();
1800  model->SetText("ABCDE");
1801  model->BeginComposing();
1802  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
1803  EXPECT_TRUE(model->MoveCursorToEnd());
1804  EXPECT_EQ(model->selection(), TextRange(4));
1805  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1806  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1807 }

◆ TEST() [206/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndReverseSelection   
)

Definition at line 1712 of file text_input_model_unittests.cc.

1712  {
1713  auto model = std::make_unique<TextInputModel>();
1714  model->SetText("ABCDE");
1715  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1716  EXPECT_TRUE(model->MoveCursorToEnd());
1717  EXPECT_EQ(model->selection(), TextRange(5));
1718  EXPECT_EQ(model->composing_range(), TextRange(0));
1719  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1720 }

◆ TEST() [207/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndSelection   
)

Definition at line 1692 of file text_input_model_unittests.cc.

1692  {
1693  auto model = std::make_unique<TextInputModel>();
1694  model->SetText("ABCDE");
1695  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1696  EXPECT_TRUE(model->MoveCursorToEnd());
1697  EXPECT_EQ(model->selection(), TextRange(5));
1698  EXPECT_EQ(model->composing_range(), TextRange(0));
1699  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1700 }

◆ TEST() [208/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndStart   
)

Definition at line 1632 of file text_input_model_unittests.cc.

1632  {
1633  auto model = std::make_unique<TextInputModel>();
1634  model->SetText("ABCDE");
1635  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1636  EXPECT_TRUE(model->MoveCursorToEnd());
1637  EXPECT_EQ(model->selection(), TextRange(5));
1638  EXPECT_EQ(model->composing_range(), TextRange(0));
1639  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1640 }

◆ TEST() [209/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndStartComposing   
)

Definition at line 1732 of file text_input_model_unittests.cc.

1732  {
1733  auto model = std::make_unique<TextInputModel>();
1734  model->SetText("ABCDE");
1735  model->BeginComposing();
1736  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1737  EXPECT_TRUE(model->MoveCursorToEnd());
1738  EXPECT_EQ(model->selection(), TextRange(4));
1739  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1740  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1741 }

◆ TEST() [210/306]

flutter::TEST ( TextInputModel  ,
MoveCursorToEndStartReverseComposing   
)

Definition at line 1754 of file text_input_model_unittests.cc.

1754  {
1755  auto model = std::make_unique<TextInputModel>();
1756  model->SetText("ABCDE");
1757  model->BeginComposing();
1758  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1759  EXPECT_TRUE(model->MoveCursorToEnd());
1760  EXPECT_EQ(model->selection(), TextRange(4));
1761  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1762  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1763 }

◆ TEST() [211/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningEnd   
)

Definition at line 1450 of file text_input_model_unittests.cc.

1450  {
1451  auto model = std::make_unique<TextInputModel>();
1452  model->SetText("ABCDE");
1453  EXPECT_TRUE(model->SetSelection(TextRange(5)));
1454  EXPECT_TRUE(model->SelectToBeginning());
1455  EXPECT_EQ(model->selection(), TextRange(5, 0));
1456  EXPECT_EQ(model->composing_range(), TextRange(0));
1457  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1458 }

◆ TEST() [212/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningEndComposing   
)

Definition at line 1599 of file text_input_model_unittests.cc.

1599  {
1600  auto model = std::make_unique<TextInputModel>();
1601  model->SetText("ABCDE");
1602  model->BeginComposing();
1603  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
1604  EXPECT_TRUE(model->MoveCursorToBeginning());
1605  EXPECT_EQ(model->selection(), TextRange(1));
1606  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1607  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1608 }

◆ TEST() [213/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningEndReverseComposing   
)

Definition at line 1621 of file text_input_model_unittests.cc.

1621  {
1622  auto model = std::make_unique<TextInputModel>();
1623  model->SetText("ABCDE");
1624  model->BeginComposing();
1625  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
1626  EXPECT_TRUE(model->SelectToBeginning());
1627  EXPECT_EQ(model->selection(), TextRange(4, 1));
1628  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1629  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1630 }

◆ TEST() [214/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningMiddle   
)

Definition at line 1430 of file text_input_model_unittests.cc.

1430  {
1431  auto model = std::make_unique<TextInputModel>();
1432  model->SetText("ABCDE");
1433  EXPECT_TRUE(model->SetSelection(TextRange(2)));
1434  EXPECT_TRUE(model->SelectToBeginning());
1435  EXPECT_EQ(model->selection(), TextRange(2, 0));
1436  EXPECT_EQ(model->composing_range(), TextRange(0));
1437  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1438 }

◆ TEST() [215/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningMiddleComposing   
)

Definition at line 1555 of file text_input_model_unittests.cc.

1555  {
1556  auto model = std::make_unique<TextInputModel>();
1557  model->SetText("ABCDE");
1558  model->BeginComposing();
1559  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
1560  EXPECT_TRUE(model->SelectToBeginning());
1561  EXPECT_EQ(model->selection(), TextRange(2, 1));
1562  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1563  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1564 }

◆ TEST() [216/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningMiddleReverseComposing   
)

Definition at line 1577 of file text_input_model_unittests.cc.

1577  {
1578  auto model = std::make_unique<TextInputModel>();
1579  model->SetText("ABCDE");
1580  model->BeginComposing();
1581  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
1582  EXPECT_TRUE(model->SelectToBeginning());
1583  EXPECT_EQ(model->selection(), TextRange(2, 1));
1584  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1585  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1586 }

◆ TEST() [217/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningReverseSelection   
)

Definition at line 1490 of file text_input_model_unittests.cc.

1490  {
1491  auto model = std::make_unique<TextInputModel>();
1492  model->SetText("ABCDE");
1493  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1494  EXPECT_TRUE(model->SelectToBeginning());
1495  EXPECT_EQ(model->selection(), TextRange(4, 0));
1496  EXPECT_EQ(model->composing_range(), TextRange(0));
1497  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1498 }

◆ TEST() [218/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningSelection   
)

Definition at line 1470 of file text_input_model_unittests.cc.

1470  {
1471  auto model = std::make_unique<TextInputModel>();
1472  model->SetText("ABCDE");
1473  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1474  EXPECT_TRUE(model->SelectToBeginning());
1475  EXPECT_EQ(model->selection(), TextRange(1, 0));
1476  EXPECT_EQ(model->composing_range(), TextRange(0));
1477  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1478 }

◆ TEST() [219/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningStart   
)

Definition at line 1410 of file text_input_model_unittests.cc.

1410  {
1411  auto model = std::make_unique<TextInputModel>();
1412  model->SetText("ABCDE");
1413  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1414  EXPECT_FALSE(model->SelectToBeginning());
1415  EXPECT_EQ(model->selection(), TextRange(0));
1416  EXPECT_EQ(model->composing_range(), TextRange(0));
1417  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1418 }

◆ TEST() [220/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningStartComposing   
)

Definition at line 1511 of file text_input_model_unittests.cc.

1511  {
1512  auto model = std::make_unique<TextInputModel>();
1513  model->SetText("ABCDE");
1514  model->BeginComposing();
1515  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1516  EXPECT_FALSE(model->SelectToBeginning());
1517  EXPECT_EQ(model->selection(), TextRange(1));
1518  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1519  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1520 }

◆ TEST() [221/306]

flutter::TEST ( TextInputModel  ,
SelectToBeginningStartReverseComposing   
)

Definition at line 1533 of file text_input_model_unittests.cc.

1533  {
1534  auto model = std::make_unique<TextInputModel>();
1535  model->SetText("ABCDE");
1536  model->BeginComposing();
1537  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 0));
1538  EXPECT_FALSE(model->SelectToBeginning());
1539  EXPECT_EQ(model->selection(), TextRange(1));
1540  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1541  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1542 }

◆ TEST() [222/306]

flutter::TEST ( TextInputModel  ,
SelectToEndEnd   
)

Definition at line 1682 of file text_input_model_unittests.cc.

1682  {
1683  auto model = std::make_unique<TextInputModel>();
1684  model->SetText("ABCDE");
1685  EXPECT_TRUE(model->SetSelection(TextRange(5)));
1686  EXPECT_FALSE(model->SelectToEnd());
1687  EXPECT_EQ(model->selection(), TextRange(5));
1688  EXPECT_EQ(model->composing_range(), TextRange(0));
1689  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1690 }

◆ TEST() [223/306]

flutter::TEST ( TextInputModel  ,
SelectToEndEndComposing   
)

Definition at line 1831 of file text_input_model_unittests.cc.

1831  {
1832  auto model = std::make_unique<TextInputModel>();
1833  model->SetText("ABCDE");
1834  model->BeginComposing();
1835  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
1836  EXPECT_FALSE(model->SelectToEnd());
1837  EXPECT_EQ(model->selection(), TextRange(4));
1838  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1839  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1840 }

◆ TEST() [224/306]

flutter::TEST ( TextInputModel  ,
SelectToEndEndReverseComposing   
)

Definition at line 1853 of file text_input_model_unittests.cc.

1853  {
1854  auto model = std::make_unique<TextInputModel>();
1855  model->SetText("ABCDE");
1856  model->BeginComposing();
1857  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
1858  EXPECT_FALSE(model->SelectToEnd());
1859  EXPECT_EQ(model->selection(), TextRange(4));
1860  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1861  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1862 }

◆ TEST() [225/306]

flutter::TEST ( TextInputModel  ,
SelectToEndMiddle   
)

Definition at line 1662 of file text_input_model_unittests.cc.

1662  {
1663  auto model = std::make_unique<TextInputModel>();
1664  model->SetText("ABCDE");
1665  EXPECT_TRUE(model->SetSelection(TextRange(2)));
1666  EXPECT_TRUE(model->SelectToEnd());
1667  EXPECT_EQ(model->selection(), TextRange(2, 5));
1668  EXPECT_EQ(model->composing_range(), TextRange(0));
1669  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1670 }

◆ TEST() [226/306]

flutter::TEST ( TextInputModel  ,
SelectToEndMiddleComposing   
)

Definition at line 1787 of file text_input_model_unittests.cc.

1787  {
1788  auto model = std::make_unique<TextInputModel>();
1789  model->SetText("ABCDE");
1790  model->BeginComposing();
1791  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 1));
1792  EXPECT_TRUE(model->SelectToEnd());
1793  EXPECT_EQ(model->selection(), TextRange(2, 4));
1794  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1795  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1796 }

◆ TEST() [227/306]

flutter::TEST ( TextInputModel  ,
SelectToEndMiddleReverseComposing   
)

Definition at line 1809 of file text_input_model_unittests.cc.

1809  {
1810  auto model = std::make_unique<TextInputModel>();
1811  model->SetText("ABCDE");
1812  model->BeginComposing();
1813  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 1));
1814  EXPECT_TRUE(model->SelectToEnd());
1815  EXPECT_EQ(model->selection(), TextRange(2, 4));
1816  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
1817  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1818 }

◆ TEST() [228/306]

flutter::TEST ( TextInputModel  ,
SelectToEndReverseSelection   
)

Definition at line 1722 of file text_input_model_unittests.cc.

1722  {
1723  auto model = std::make_unique<TextInputModel>();
1724  model->SetText("ABCDE");
1725  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
1726  EXPECT_TRUE(model->SelectToEnd());
1727  EXPECT_EQ(model->selection(), TextRange(4, 5));
1728  EXPECT_EQ(model->composing_range(), TextRange(0));
1729  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1730 }

◆ TEST() [229/306]

flutter::TEST ( TextInputModel  ,
SelectToEndSelection   
)

Definition at line 1702 of file text_input_model_unittests.cc.

1702  {
1703  auto model = std::make_unique<TextInputModel>();
1704  model->SetText("ABCDE");
1705  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
1706  EXPECT_TRUE(model->SelectToEnd());
1707  EXPECT_EQ(model->selection(), TextRange(1, 5));
1708  EXPECT_EQ(model->composing_range(), TextRange(0));
1709  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1710 }

◆ TEST() [230/306]

flutter::TEST ( TextInputModel  ,
SelectToEndStart   
)

Definition at line 1642 of file text_input_model_unittests.cc.

1642  {
1643  auto model = std::make_unique<TextInputModel>();
1644  model->SetText("ABCDE");
1645  EXPECT_TRUE(model->SetSelection(TextRange(0)));
1646  EXPECT_TRUE(model->SelectToEnd());
1647  EXPECT_EQ(model->selection(), TextRange(0, 5));
1648  EXPECT_EQ(model->composing_range(), TextRange(0));
1649  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1650 }

◆ TEST() [231/306]

flutter::TEST ( TextInputModel  ,
SelectToEndStartComposing   
)

Definition at line 1743 of file text_input_model_unittests.cc.

1743  {
1744  auto model = std::make_unique<TextInputModel>();
1745  model->SetText("ABCDE");
1746  model->BeginComposing();
1747  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1748  EXPECT_TRUE(model->SelectToEnd());
1749  EXPECT_EQ(model->selection(), TextRange(1, 4));
1750  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1751  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1752 }

◆ TEST() [232/306]

flutter::TEST ( TextInputModel  ,
SelectToEndStartReverseComposing   
)

Definition at line 1765 of file text_input_model_unittests.cc.

1765  {
1766  auto model = std::make_unique<TextInputModel>();
1767  model->SetText("ABCDE");
1768  model->BeginComposing();
1769  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
1770  EXPECT_TRUE(model->SelectToEnd());
1771  EXPECT_EQ(model->selection(), TextRange(1, 4));
1772  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
1773  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
1774 }

◆ TEST() [233/306]

flutter::TEST ( TextInputModel  ,
SetComposingRangeEnd   
)

Definition at line 237 of file text_input_model_unittests.cc.

237  {
238  auto model = std::make_unique<TextInputModel>();
239  model->SetText("ABCDE");
240  model->BeginComposing();
241  EXPECT_TRUE(model->SetComposingRange(TextRange(5, 5), 0));
242  EXPECT_EQ(model->selection(), TextRange(5));
243  EXPECT_EQ(model->composing_range(), TextRange(5));
244  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
245 }

◆ TEST() [234/306]

flutter::TEST ( TextInputModel  ,
SetComposingRangeMiddle   
)

Definition at line 227 of file text_input_model_unittests.cc.

227  {
228  auto model = std::make_unique<TextInputModel>();
229  model->SetText("ABCDE");
230  model->BeginComposing();
231  EXPECT_TRUE(model->SetComposingRange(TextRange(2, 2), 0));
232  EXPECT_EQ(model->selection(), TextRange(2));
233  EXPECT_EQ(model->composing_range(), TextRange(2));
234  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
235 }

◆ TEST() [235/306]

flutter::TEST ( TextInputModel  ,
SetComposingRangeOutsideString   
)

Definition at line 280 of file text_input_model_unittests.cc.

280  {
281  auto model = std::make_unique<TextInputModel>();
282  model->SetText("ABCDE");
283  model->BeginComposing();
284  EXPECT_FALSE(model->SetComposingRange(TextRange(4, 6), 0));
285  EXPECT_FALSE(model->SetComposingRange(TextRange(5, 6), 0));
286  EXPECT_FALSE(model->SetComposingRange(TextRange(6, 6), 0));
287 }

◆ TEST() [236/306]

flutter::TEST ( TextInputModel  ,
SetComposingRangeReverseExtent   
)

Definition at line 257 of file text_input_model_unittests.cc.

257  {
258  auto model = std::make_unique<TextInputModel>();
259  model->SetText("ABCDE");
260  model->BeginComposing();
261  EXPECT_TRUE(model->SetComposingRange(TextRange(4, 1), 3));
262  EXPECT_EQ(model->selection(), TextRange(4));
263  EXPECT_EQ(model->composing_range(), TextRange(4, 1));
264  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
265 }

◆ TEST() [237/306]

flutter::TEST ( TextInputModel  ,
SetComposingRangeStart   
)

Definition at line 217 of file text_input_model_unittests.cc.

217  {
218  auto model = std::make_unique<TextInputModel>();
219  model->SetText("ABCDE");
220  model->BeginComposing();
221  EXPECT_TRUE(model->SetComposingRange(TextRange(0, 0), 0));
222  EXPECT_EQ(model->selection(), TextRange(0));
223  EXPECT_EQ(model->composing_range(), TextRange(0));
224  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
225 }

◆ TEST() [238/306]

flutter::TEST ( TextInputModel  ,
SetComposingRangeWithExtent   
)

Definition at line 247 of file text_input_model_unittests.cc.

247  {
248  auto model = std::make_unique<TextInputModel>();
249  model->SetText("ABCDE");
250  model->BeginComposing();
251  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 3));
252  EXPECT_EQ(model->selection(), TextRange(4));
253  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
254  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
255 }

◆ TEST() [239/306]

flutter::TEST ( TextInputModel  ,
SetComposingRangeWithOffsetOutsideString   
)

Definition at line 267 of file text_input_model_unittests.cc.

267  {
268  auto model = std::make_unique<TextInputModel>();
269  model->SetText("ABCDE");
270  model->BeginComposing();
271  // The offset positions the caret relative to the composing range, and reaches
272  // the text as an index. An offset that runs past the end of the text must be
273  // rejected rather than stored as a selection.
274  EXPECT_FALSE(model->SetComposingRange(TextRange(1, 4), 5));
275  EXPECT_EQ(model->selection(), TextRange(0));
276  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 4));
277  EXPECT_EQ(model->selection(), TextRange(5));
278 }

◆ TEST() [240/306]

flutter::TEST ( TextInputModel  ,
SetSelectionComposingEnd   
)

Definition at line 146 of file text_input_model_unittests.cc.

146  {
147  auto model = std::make_unique<TextInputModel>();
148  model->SetText("ABCDE");
149  model->BeginComposing();
150  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
151  EXPECT_TRUE(model->SetSelection(TextRange(4)));
152  EXPECT_EQ(model->selection(), TextRange(4));
153  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
154  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
155 }

◆ TEST() [241/306]

flutter::TEST ( TextInputModel  ,
SetSelectionComposingMiddle   
)

Definition at line 126 of file text_input_model_unittests.cc.

126  {
127  auto model = std::make_unique<TextInputModel>();
128  model->SetText("ABCDE");
129  model->BeginComposing();
130  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
131  EXPECT_TRUE(model->SetSelection(TextRange(2)));
132  EXPECT_EQ(model->selection(), TextRange(2));
133  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
134  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
135 }

◆ TEST() [242/306]

flutter::TEST ( TextInputModel  ,
SetSelectionComposingStart   
)

Definition at line 106 of file text_input_model_unittests.cc.

106  {
107  auto model = std::make_unique<TextInputModel>();
108  model->SetText("ABCDE");
109  model->BeginComposing();
110  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
111  EXPECT_TRUE(model->SetSelection(TextRange(1)));
112  EXPECT_EQ(model->selection(), TextRange(1));
113  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
114  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
115 }

◆ TEST() [243/306]

flutter::TEST ( TextInputModel  ,
SetSelectionEnd   
)

Definition at line 137 of file text_input_model_unittests.cc.

137  {
138  auto model = std::make_unique<TextInputModel>();
139  model->SetText("ABCDE");
140  EXPECT_TRUE(model->SetSelection(TextRange(5)));
141  EXPECT_EQ(model->selection(), TextRange(5));
142  EXPECT_EQ(model->composing_range(), TextRange(0));
143  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
144 }

◆ TEST() [244/306]

flutter::TEST ( TextInputModel  ,
SetSelectionMiddle   
)

Definition at line 117 of file text_input_model_unittests.cc.

117  {
118  auto model = std::make_unique<TextInputModel>();
119  model->SetText("ABCDE");
120  EXPECT_TRUE(model->SetSelection(TextRange(2)));
121  EXPECT_EQ(model->selection(), TextRange(2));
122  EXPECT_EQ(model->composing_range(), TextRange(0));
123  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
124 }

◆ TEST() [245/306]

flutter::TEST ( TextInputModel  ,
SetSelectionOutsideComposingRange   
)

Definition at line 205 of file text_input_model_unittests.cc.

205  {
206  auto model = std::make_unique<TextInputModel>();
207  model->SetText("ABCDE");
208  model->BeginComposing();
209  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
210  EXPECT_FALSE(model->SetSelection(TextRange(0)));
211  EXPECT_EQ(model->selection(), TextRange(1));
212  EXPECT_FALSE(model->SetSelection(TextRange(5)));
213  EXPECT_EQ(model->selection(), TextRange(1));
214  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
215 }

◆ TEST() [246/306]

flutter::TEST ( TextInputModel  ,
SetSelectionOutsideString   
)

Definition at line 197 of file text_input_model_unittests.cc.

197  {
198  auto model = std::make_unique<TextInputModel>();
199  model->SetText("ABCDE");
200  EXPECT_FALSE(model->SetSelection(TextRange(4, 6)));
201  EXPECT_FALSE(model->SetSelection(TextRange(5, 6)));
202  EXPECT_FALSE(model->SetSelection(TextRange(6)));
203 }

◆ TEST() [247/306]

flutter::TEST ( TextInputModel  ,
SetSelectionReverseExtent   
)

Definition at line 177 of file text_input_model_unittests.cc.

177  {
178  auto model = std::make_unique<TextInputModel>();
179  model->SetText("ABCDE");
180  EXPECT_TRUE(model->SetSelection(TextRange(4, 1)));
181  EXPECT_EQ(model->selection(), TextRange(4, 1));
182  EXPECT_EQ(model->composing_range(), TextRange(0));
183  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
184 }

◆ TEST() [248/306]

flutter::TEST ( TextInputModel  ,
SetSelectionReverseExtentComposing   
)

Definition at line 186 of file text_input_model_unittests.cc.

186  {
187  auto model = std::make_unique<TextInputModel>();
188  model->SetText("ABCDE");
189  model->BeginComposing();
190  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
191  EXPECT_FALSE(model->SetSelection(TextRange(4, 1)));
192  EXPECT_EQ(model->selection(), TextRange(1));
193  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
194  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
195 }

◆ TEST() [249/306]

flutter::TEST ( TextInputModel  ,
SetSelectionStart   
)

Definition at line 97 of file text_input_model_unittests.cc.

97  {
98  auto model = std::make_unique<TextInputModel>();
99  model->SetText("ABCDE");
100  EXPECT_TRUE(model->SetSelection(TextRange(0)));
101  EXPECT_EQ(model->selection(), TextRange(0));
102  EXPECT_EQ(model->composing_range(), TextRange(0));
103  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
104 }

◆ TEST() [250/306]

flutter::TEST ( TextInputModel  ,
SetSelectionWthExtent   
)

Definition at line 157 of file text_input_model_unittests.cc.

157  {
158  auto model = std::make_unique<TextInputModel>();
159  model->SetText("ABCDE");
160  EXPECT_TRUE(model->SetSelection(TextRange(1, 4)));
161  EXPECT_EQ(model->selection(), TextRange(1, 4));
162  EXPECT_EQ(model->composing_range(), TextRange(0));
163  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
164 }

◆ TEST() [251/306]

flutter::TEST ( TextInputModel  ,
SetSelectionWthExtentComposing   
)

Definition at line 166 of file text_input_model_unittests.cc.

166  {
167  auto model = std::make_unique<TextInputModel>();
168  model->SetText("ABCDE");
169  model->BeginComposing();
170  EXPECT_TRUE(model->SetComposingRange(TextRange(1, 4), 0));
171  EXPECT_FALSE(model->SetSelection(TextRange(1, 4)));
172  EXPECT_EQ(model->selection(), TextRange(1));
173  EXPECT_EQ(model->composing_range(), TextRange(1, 4));
174  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
175 }

◆ TEST() [252/306]

flutter::TEST ( TextInputModel  ,
SetText   
)

Definition at line 15 of file text_input_model_unittests.cc.

15  {
16  auto model = std::make_unique<TextInputModel>();
17  model->SetText("ABCDE");
18  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
19 }

◆ TEST() [253/306]

flutter::TEST ( TextInputModel  ,
SetTextEmpty   
)

Definition at line 27 of file text_input_model_unittests.cc.

27  {
28  auto model = std::make_unique<TextInputModel>();
29  model->SetText("");
30  EXPECT_STREQ(model->GetText().c_str(), "");
31 }

◆ TEST() [254/306]

flutter::TEST ( TextInputModel  ,
SetTextRejectingComposingRangeLeavesModelUnchanged   
)

Definition at line 62 of file text_input_model_unittests.cc.

62  {
63  auto model = std::make_unique<TextInputModel>();
64  EXPECT_TRUE(model->SetText("ABCDE", TextRange(2), TextRange(1, 3)));
65  EXPECT_FALSE(model->SetText("AB", TextRange(2), TextRange(1, 3)));
66  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
67  EXPECT_EQ(model->selection(), TextRange(2));
68  EXPECT_EQ(model->composing_range(), TextRange(1, 3));
69  EXPECT_TRUE(model->composing());
70 }

◆ TEST() [255/306]

flutter::TEST ( TextInputModel  ,
SetTextRejectingSelectionLeavesModelUnchanged   
)

Definition at line 50 of file text_input_model_unittests.cc.

50  {
51  auto model = std::make_unique<TextInputModel>();
52  EXPECT_TRUE(model->SetText("ABCDE", TextRange(3), TextRange(0)));
53  // A rejected update must not apply the text either. Applying it alone would
54  // leave the selection pointing past the end of the new text, and every
55  // subsequent edit indexes into the text with that selection.
56  EXPECT_FALSE(model->SetText("AB", TextRange(5), TextRange(0)));
57  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
58  EXPECT_EQ(model->selection(), TextRange(3));
59  EXPECT_EQ(model->composing_range(), TextRange(0));
60 }

◆ TEST() [256/306]

flutter::TEST ( TextInputModel  ,
SetTextReplaceText   
)

Definition at line 33 of file text_input_model_unittests.cc.

33  {
34  auto model = std::make_unique<TextInputModel>();
35  model->SetText("ABCDE");
36  EXPECT_STREQ(model->GetText().c_str(), "ABCDE");
37  model->SetText("");
38  EXPECT_STREQ(model->GetText().c_str(), "");
39 }

◆ TEST() [257/306]

flutter::TEST ( TextInputModel  ,
SetTextResetsSelection   
)

Definition at line 41 of file text_input_model_unittests.cc.

41  {
42  auto model = std::make_unique<TextInputModel>();
43  model->SetText("ABCDE");
44  EXPECT_TRUE(model->SetSelection(TextRange(3)));
45  EXPECT_EQ(model->selection(), TextRange(3));
46  model->SetText("FGHJI");
47  EXPECT_EQ(model->selection(), TextRange(0));
48 }

◆ TEST() [258/306]

flutter::TEST ( TextInputModel  ,
SetTextWideCharacters   
)

Definition at line 21 of file text_input_model_unittests.cc.

21  {
22  auto model = std::make_unique<TextInputModel>();
23  model->SetText("😄🙃🤪🧐");
24  EXPECT_STREQ(model->GetText().c_str(), "😄🙃🤪🧐");
25 }

◆ TEST() [259/306]

flutter::TEST ( TextInputModel  ,
UpdateComposingRemovesLastComposingCharacter   
)

Definition at line 455 of file text_input_model_unittests.cc.

455  {
456  auto model = std::make_unique<TextInputModel>();
457  model->SetText("ABCDE");
458  model->BeginComposing();
459  model->SetComposingRange(TextRange(1, 2), 1);
460  model->UpdateComposingText("");
461  EXPECT_EQ(model->selection(), TextRange(1));
462  EXPECT_EQ(model->composing_range(), TextRange(1));
463  model->SetText("ACDE");
464 }

◆ TEST() [260/306]

flutter::TEST ( TextInputModel  ,
UpdateComposingTextWithSelectionPastComposingText   
)

Definition at line 72 of file text_input_model_unittests.cc.

72  {
73  auto model = std::make_unique<TextInputModel>();
74  EXPECT_TRUE(model->SetText("ABCDE", TextRange(5), TextRange(0)));
75  model->BeginComposing();
76 
77  // The selection accompanying composing text is relative to that text, but an
78  // input method is free to report one that does not fit inside it. The offset
79  // must not reach the text buffer, where a later edit would index out of
80  // bounds and abort the process from inside the standard library.
81  model->UpdateComposingText(u"n", TextRange(99));
82  EXPECT_STREQ(model->GetText().c_str(), "ABCDEn");
83  EXPECT_EQ(model->selection(), TextRange(6));
84  EXPECT_EQ(model->composing_range(), TextRange(5, 6));
85 
86  // Clearing the composing text collapses the composing range, which makes the
87  // next update replace the selection instead. This is the point at which an
88  // unclamped offset becomes an out of bounds index into the text.
89  model->UpdateComposingText(u"", TextRange(99));
90  EXPECT_EQ(model->composing_range(), TextRange(5));
91  EXPECT_EQ(model->selection(), TextRange(5));
92  model->UpdateComposingText(u"m", TextRange(1));
93  EXPECT_STREQ(model->GetText().c_str(), "ABCDEm");
94  EXPECT_EQ(model->selection(), TextRange(6));
95 }

◆ TEST() [261/306]

flutter::TEST ( TextInputModel  ,
UpdateSelectionWhileComposing   
)

Definition at line 466 of file text_input_model_unittests.cc.

466  {
467  auto model = std::make_unique<TextInputModel>();
468  model->SetText("ABCDE");
469  model->BeginComposing();
470  model->SetComposingRange(TextRange(4, 5), 1);
471  model->UpdateComposingText(u"ぴょんぴょん", TextRange(3, 6));
472  EXPECT_STREQ(model->GetText().c_str(), "ABCDぴょんぴょん");
473  EXPECT_EQ(model->selection(), TextRange(7, 10));
474  EXPECT_EQ(model->composing_range(), TextRange(4, 10));
475 }

◆ TEST() [262/306]

flutter::TEST ( TextRange  ,
ClampedToLongerLength   
)

Definition at line 248 of file text_range_unittests.cc.

248  {
249  EXPECT_EQ(TextRange(2, 6).ClampedTo(10), TextRange(2, 6));
250 }

◆ TEST() [263/306]

flutter::TEST ( TextRange  ,
ClampedToShorterLength   
)

Definition at line 252 of file text_range_unittests.cc.

252  {
253  EXPECT_EQ(TextRange(2, 6).ClampedTo(4), TextRange(2, 4));
254 }

◆ TEST() [264/306]

flutter::TEST ( TextRange  ,
ClampedToShorterLengthReversed   
)

Definition at line 256 of file text_range_unittests.cc.

256  {
257  // A reversed range must stay reversed: callers derive the cursor position
258  // from the extent, not from the lesser endpoint.
259  EXPECT_EQ(TextRange(6, 2).ClampedTo(4), TextRange(4, 2));
260 }

◆ TEST() [265/306]

flutter::TEST ( TextRange  ,
ContainsEndPosition   
)

Definition at line 125 of file text_range_unittests.cc.

125  {
126  TextRange range(2, 6);
127  EXPECT_TRUE(range.Contains(6));
128 }

References flutter::TextRange::Contains().

◆ TEST() [266/306]

flutter::TEST ( TextRange  ,
ContainsEndPositionReversed   
)

Definition at line 151 of file text_range_unittests.cc.

151  {
152  TextRange range(6, 2);
153  EXPECT_TRUE(range.Contains(6));
154 }

References flutter::TextRange::Contains().

◆ TEST() [267/306]

flutter::TEST ( TextRange  ,
ContainsMiddlePosition   
)

Definition at line 119 of file text_range_unittests.cc.

119  {
120  TextRange range(2, 6);
121  EXPECT_TRUE(range.Contains(3));
122  EXPECT_TRUE(range.Contains(4));
123 }

References flutter::TextRange::Contains().

◆ TEST() [268/306]

flutter::TEST ( TextRange  ,
ContainsMiddlePositionReversed   
)

Definition at line 145 of file text_range_unittests.cc.

145  {
146  TextRange range(6, 2);
147  EXPECT_TRUE(range.Contains(3));
148  EXPECT_TRUE(range.Contains(4));
149 }

References flutter::TextRange::Contains().

◆ TEST() [269/306]

flutter::TEST ( TextRange  ,
ContainsPostEndPosition   
)

Definition at line 130 of file text_range_unittests.cc.

130  {
131  TextRange range(2, 6);
132  EXPECT_FALSE(range.Contains(7));
133 }

References flutter::TextRange::Contains().

◆ TEST() [270/306]

flutter::TEST ( TextRange  ,
ContainsPostEndPositionReversed   
)

Definition at line 156 of file text_range_unittests.cc.

156  {
157  TextRange range(6, 2);
158  EXPECT_FALSE(range.Contains(7));
159 }

References flutter::TextRange::Contains().

◆ TEST() [271/306]

flutter::TEST ( TextRange  ,
ContainsPreStartPosition   
)

Definition at line 109 of file text_range_unittests.cc.

109  {
110  TextRange range(2, 6);
111  EXPECT_FALSE(range.Contains(1));
112 }

References flutter::TextRange::Contains().

◆ TEST() [272/306]

flutter::TEST ( TextRange  ,
ContainsPreStartPositionReversed   
)

Definition at line 135 of file text_range_unittests.cc.

135  {
136  TextRange range(6, 2);
137  EXPECT_FALSE(range.Contains(1));
138 }

References flutter::TextRange::Contains().

◆ TEST() [273/306]

flutter::TEST ( TextRange  ,
ContainsRangeEndPosition   
)

Definition at line 182 of file text_range_unittests.cc.

182  {
183  TextRange range(2, 6);
184  EXPECT_TRUE(range.Contains(TextRange(6)));
185 }

References flutter::TextRange::Contains().

◆ TEST() [274/306]

flutter::TEST ( TextRange  ,
ContainsRangeEndPositionReversed   
)

Definition at line 223 of file text_range_unittests.cc.

223  {
224  TextRange range(6, 2);
225  EXPECT_TRUE(range.Contains(TextRange(5)));
226 }

References flutter::TextRange::Contains().

◆ TEST() [275/306]

flutter::TEST ( TextRange  ,
ContainsRangeMiddlePosition   
)

Definition at line 176 of file text_range_unittests.cc.

176  {
177  TextRange range(2, 6);
178  EXPECT_TRUE(range.Contains(TextRange(3, 4)));
179  EXPECT_TRUE(range.Contains(TextRange(4, 5)));
180 }

References flutter::TextRange::Contains().

◆ TEST() [276/306]

flutter::TEST ( TextRange  ,
ContainsRangeMiddlePositionReversed   
)

Definition at line 212 of file text_range_unittests.cc.

212  {
213  TextRange range(6, 2);
214  EXPECT_TRUE(range.Contains(TextRange(3, 4)));
215  EXPECT_TRUE(range.Contains(TextRange(4, 5)));
216 }

References flutter::TextRange::Contains().

◆ TEST() [277/306]

flutter::TEST ( TextRange  ,
ContainsRangePostEndPosition   
)

Definition at line 192 of file text_range_unittests.cc.

192  {
193  TextRange range(2, 6);
194  EXPECT_FALSE(range.Contains(TextRange(6, 7)));
195 }

References flutter::TextRange::Contains().

◆ TEST() [278/306]

flutter::TEST ( TextRange  ,
ContainsRangePostEndPositionReversed   
)

Definition at line 228 of file text_range_unittests.cc.

228  {
229  TextRange range(6, 2);
230  EXPECT_FALSE(range.Contains(TextRange(6, 7)));
231 }

References flutter::TextRange::Contains().

◆ TEST() [279/306]

flutter::TEST ( TextRange  ,
ContainsRangePreStartPosition   
)

Definition at line 161 of file text_range_unittests.cc.

161  {
162  TextRange range(2, 6);
163  EXPECT_FALSE(range.Contains(TextRange(0, 1)));
164 }

References flutter::TextRange::Contains().

◆ TEST() [280/306]

flutter::TEST ( TextRange  ,
ContainsRangePreStartPositionReversed   
)

Definition at line 197 of file text_range_unittests.cc.

197  {
198  TextRange range(6, 2);
199  EXPECT_FALSE(range.Contains(TextRange(0, 1)));
200 }

References flutter::TextRange::Contains().

◆ TEST() [281/306]

flutter::TEST ( TextRange  ,
ContainsRangeSpanningEndPosition   
)

Definition at line 187 of file text_range_unittests.cc.

187  {
188  TextRange range(2, 6);
189  EXPECT_FALSE(range.Contains(TextRange(5, 7)));
190 }

References flutter::TextRange::Contains().

◆ TEST() [282/306]

flutter::TEST ( TextRange  ,
ContainsRangeSpanningEndPositionReversed   
)

Definition at line 218 of file text_range_unittests.cc.

218  {
219  TextRange range(6, 2);
220  EXPECT_FALSE(range.Contains(TextRange(5, 7)));
221 }

References flutter::TextRange::Contains().

◆ TEST() [283/306]

flutter::TEST ( TextRange  ,
ContainsRangeSpanningStartPosition   
)

Definition at line 166 of file text_range_unittests.cc.

166  {
167  TextRange range(2, 6);
168  EXPECT_FALSE(range.Contains(TextRange(1, 3)));
169 }

References flutter::TextRange::Contains().

◆ TEST() [284/306]

flutter::TEST ( TextRange  ,
ContainsRangeSpanningStartPositionReversed   
)

Definition at line 202 of file text_range_unittests.cc.

202  {
203  TextRange range(6, 2);
204  EXPECT_FALSE(range.Contains(TextRange(1, 3)));
205 }

References flutter::TextRange::Contains().

◆ TEST() [285/306]

flutter::TEST ( TextRange  ,
ContainsRangeStartPosition   
)

Definition at line 171 of file text_range_unittests.cc.

171  {
172  TextRange range(2, 6);
173  EXPECT_TRUE(range.Contains(TextRange(2)));
174 }

References flutter::TextRange::Contains().

◆ TEST() [286/306]

flutter::TEST ( TextRange  ,
ContainsRangeStartPositionReversed   
)

Definition at line 207 of file text_range_unittests.cc.

207  {
208  TextRange range(6, 2);
209  EXPECT_TRUE(range.Contains(TextRange(2)));
210 }

References flutter::TextRange::Contains().

◆ TEST() [287/306]

flutter::TEST ( TextRange  ,
ContainsStartPosition   
)

Definition at line 114 of file text_range_unittests.cc.

114  {
115  TextRange range(2, 6);
116  EXPECT_TRUE(range.Contains(2));
117 }

References flutter::TextRange::Contains().

◆ TEST() [288/306]

flutter::TEST ( TextRange  ,
ContainsStartPositionReversed   
)

Definition at line 140 of file text_range_unittests.cc.

140  {
141  TextRange range(6, 2);
142  EXPECT_TRUE(range.Contains(2));
143 }

References flutter::TextRange::Contains().

◆ TEST() [289/306]

flutter::TEST ( TextRange  ,
ReversedCollapsedRange   
)

Definition at line 238 of file text_range_unittests.cc.

238  {
239  TextRange range(2, 2);
240  EXPECT_FALSE(range.reversed());
241 }

References flutter::TextRange::reversed().

◆ TEST() [290/306]

flutter::TEST ( TextRange  ,
ReversedForwardRange   
)

Definition at line 233 of file text_range_unittests.cc.

233  {
234  TextRange range(2, 6);
235  EXPECT_FALSE(range.reversed());
236 }

References flutter::TextRange::reversed().

◆ TEST() [291/306]

flutter::TEST ( TextRange  ,
ReversedReversedRange   
)

Definition at line 243 of file text_range_unittests.cc.

243  {
244  TextRange range(6, 2);
245  EXPECT_TRUE(range.reversed());
246 }

References flutter::TextRange::reversed().

◆ TEST() [292/306]

flutter::TEST ( TextRange  ,
SetBase   
)

Definition at line 53 of file text_range_unittests.cc.

53  {
54  TextRange range(3, 7);
55  range.set_base(4);
56  EXPECT_EQ(range.base(), size_t(4));
57  EXPECT_EQ(range.extent(), size_t(7));
58 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_base().

◆ TEST() [293/306]

flutter::TEST ( TextRange  ,
SetBaseReversed   
)

Definition at line 60 of file text_range_unittests.cc.

60  {
61  TextRange range(7, 3);
62  range.set_base(5);
63  EXPECT_EQ(range.base(), size_t(5));
64  EXPECT_EQ(range.extent(), size_t(3));
65 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_base().

◆ TEST() [294/306]

flutter::TEST ( TextRange  ,
SetEnd   
)

Definition at line 95 of file text_range_unittests.cc.

95  {
96  TextRange range(3, 7);
97  range.set_end(6);
98  EXPECT_EQ(range.base(), size_t(3));
99  EXPECT_EQ(range.extent(), size_t(6));
100 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_end().

◆ TEST() [295/306]

flutter::TEST ( TextRange  ,
SetEndReversed   
)

Definition at line 102 of file text_range_unittests.cc.

102  {
103  TextRange range(7, 3);
104  range.set_end(5);
105  EXPECT_EQ(range.base(), size_t(5));
106  EXPECT_EQ(range.extent(), size_t(3));
107 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_end().

◆ TEST() [296/306]

flutter::TEST ( TextRange  ,
SetExtent   
)

Definition at line 67 of file text_range_unittests.cc.

67  {
68  TextRange range(3, 7);
69  range.set_extent(6);
70  EXPECT_EQ(range.base(), size_t(3));
71  EXPECT_EQ(range.extent(), size_t(6));
72 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_extent().

◆ TEST() [297/306]

flutter::TEST ( TextRange  ,
SetExtentReversed   
)

Definition at line 74 of file text_range_unittests.cc.

74  {
75  TextRange range(7, 3);
76  range.set_extent(4);
77  EXPECT_EQ(range.base(), size_t(7));
78  EXPECT_EQ(range.extent(), size_t(4));
79 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_extent().

◆ TEST() [298/306]

flutter::TEST ( TextRange  ,
SetStart   
)

Definition at line 81 of file text_range_unittests.cc.

81  {
82  TextRange range(3, 7);
83  range.set_start(5);
84  EXPECT_EQ(range.base(), size_t(5));
85  EXPECT_EQ(range.extent(), size_t(7));
86 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_start().

◆ TEST() [299/306]

flutter::TEST ( TextRange  ,
SetStartReversed   
)

Definition at line 88 of file text_range_unittests.cc.

88  {
89  TextRange range(7, 3);
90  range.set_start(5);
91  EXPECT_EQ(range.base(), size_t(7));
92  EXPECT_EQ(range.extent(), size_t(5));
93 }

References flutter::TextRange::base(), flutter::TextRange::extent(), and flutter::TextRange::set_start().

◆ TEST() [300/306]

flutter::TEST ( TextRange  ,
TextRangeFromPositionNonZero   
)

Definition at line 22 of file text_range_unittests.cc.

22  {
23  TextRange range(3);
24  EXPECT_EQ(range.base(), size_t(3));
25  EXPECT_EQ(range.extent(), size_t(3));
26  EXPECT_EQ(range.start(), size_t(3));
27  EXPECT_EQ(range.end(), size_t(3));
28  EXPECT_EQ(range.length(), size_t(0));
29  EXPECT_EQ(range.position(), size_t(3));
30  EXPECT_TRUE(range.collapsed());
31 }

References flutter::TextRange::base(), flutter::TextRange::collapsed(), flutter::TextRange::end(), flutter::TextRange::extent(), flutter::TextRange::length(), flutter::TextRange::position(), and flutter::TextRange::start().

◆ TEST() [301/306]

flutter::TEST ( TextRange  ,
TextRangeFromPositionZero   
)

Definition at line 11 of file text_range_unittests.cc.

11  {
12  TextRange range(0);
13  EXPECT_EQ(range.base(), size_t(0));
14  EXPECT_EQ(range.extent(), size_t(0));
15  EXPECT_EQ(range.start(), size_t(0));
16  EXPECT_EQ(range.end(), size_t(0));
17  EXPECT_EQ(range.length(), size_t(0));
18  EXPECT_EQ(range.position(), size_t(0));
19  EXPECT_TRUE(range.collapsed());
20 }

References flutter::TextRange::base(), flutter::TextRange::collapsed(), flutter::TextRange::end(), flutter::TextRange::extent(), flutter::TextRange::length(), flutter::TextRange::position(), and flutter::TextRange::start().

◆ TEST() [302/306]

flutter::TEST ( TextRange  ,
TextRangeFromRange   
)

Definition at line 33 of file text_range_unittests.cc.

33  {
34  TextRange range(3, 7);
35  EXPECT_EQ(range.base(), size_t(3));
36  EXPECT_EQ(range.extent(), size_t(7));
37  EXPECT_EQ(range.start(), size_t(3));
38  EXPECT_EQ(range.end(), size_t(7));
39  EXPECT_EQ(range.length(), size_t(4));
40  EXPECT_FALSE(range.collapsed());
41 }

References flutter::TextRange::base(), flutter::TextRange::collapsed(), flutter::TextRange::end(), flutter::TextRange::extent(), flutter::TextRange::length(), and flutter::TextRange::start().

◆ TEST() [303/306]

flutter::TEST ( TextRange  ,
TextRangeFromReversedRange   
)

Definition at line 43 of file text_range_unittests.cc.

43  {
44  TextRange range(7, 3);
45  EXPECT_EQ(range.base(), size_t(7));
46  EXPECT_EQ(range.extent(), size_t(3));
47  EXPECT_EQ(range.start(), size_t(3));
48  EXPECT_EQ(range.end(), size_t(7));
49  EXPECT_EQ(range.length(), size_t(4));
50  EXPECT_FALSE(range.collapsed());
51 }

References flutter::TextRange::base(), flutter::TextRange::collapsed(), flutter::TextRange::end(), flutter::TextRange::extent(), flutter::TextRange::length(), and flutter::TextRange::start().

◆ TEST() [304/306]

flutter::TEST ( TextureRegistrarTest  ,
MarkFrameAvailableInvalidTexture   
)

Definition at line 143 of file texture_registrar_unittests.cc.

143  {
144  auto dummy_registrar_handle =
145  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
146  PluginRegistrar registrar(dummy_registrar_handle);
147 
148  TextureRegistrar* textures = registrar.texture_registrar();
149 
150  bool success = textures->MarkTextureFrameAvailable(42);
151  EXPECT_FALSE(success);
152 }

References flutter::TextureRegistrar::MarkTextureFrameAvailable(), and flutter::PluginRegistrar::texture_registrar().

◆ TEST() [305/306]

flutter::TEST ( TextureRegistrarTest  ,
RegisterUnregisterTexture   
)

Definition at line 87 of file texture_registrar_unittests.cc.

87  {
88  testing::ScopedStubFlutterApi scoped_api_stub(std::make_unique<TestApi>());
89  auto test_api = static_cast<TestApi*>(scoped_api_stub.stub());
90 
91  auto dummy_registrar_handle =
92  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
93  PluginRegistrar registrar(dummy_registrar_handle);
94  TextureRegistrar* textures = registrar.texture_registrar();
95  ASSERT_NE(textures, nullptr);
96 
97  EXPECT_EQ(test_api->last_texture_id(), -1);
98  auto texture = test_api->GetFakeTexture(0);
99  EXPECT_EQ(texture, nullptr);
100 
101  auto pixel_buffer_texture = std::make_unique<TextureVariant>(
102  PixelBufferTexture([](size_t width, size_t height) { return nullptr; }));
103  int64_t texture_id = textures->RegisterTexture(pixel_buffer_texture.get());
104  EXPECT_EQ(test_api->last_texture_id(), texture_id);
105  EXPECT_EQ(test_api->textures_size(), static_cast<size_t>(1));
106 
107  texture = test_api->GetFakeTexture(texture_id);
108  EXPECT_EQ(texture->texture_id, texture_id);
109  EXPECT_EQ(texture->user_data,
110  std::get_if<PixelBufferTexture>(pixel_buffer_texture.get()));
111 
112  textures->MarkTextureFrameAvailable(texture_id);
113  textures->MarkTextureFrameAvailable(texture_id);
114  bool success = textures->MarkTextureFrameAvailable(texture_id);
115  EXPECT_TRUE(success);
116  EXPECT_EQ(texture->mark_count, 3);
117 
118  fml::AutoResetWaitableEvent unregister_latch;
119  textures->UnregisterTexture(texture_id, [&]() { unregister_latch.Signal(); });
120  unregister_latch.Wait();
121 
122  texture = test_api->GetFakeTexture(texture_id);
123  EXPECT_EQ(texture, nullptr);
124  EXPECT_EQ(test_api->textures_size(), static_cast<size_t>(0));
125 }
int64_t texture_id

References flutter::TextureRegistrar::MarkTextureFrameAvailable(), flutter::TextureRegistrar::RegisterTexture(), texture_id, flutter::PluginRegistrar::texture_registrar(), and flutter::TextureRegistrar::UnregisterTexture().

◆ TEST() [306/306]

flutter::TEST ( TextureRegistrarTest  ,
UnregisterInvalidTexture   
)

Definition at line 129 of file texture_registrar_unittests.cc.

129  {
130  auto dummy_registrar_handle =
131  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(1);
132  PluginRegistrar registrar(dummy_registrar_handle);
133 
134  TextureRegistrar* textures = registrar.texture_registrar();
135 
136  fml::AutoResetWaitableEvent latch;
137  textures->UnregisterTexture(42, [&]() { latch.Signal(); });
138  latch.Wait();
139 }

References flutter::PluginRegistrar::texture_registrar(), and flutter::TextureRegistrar::UnregisterTexture().

Variable Documentation

◆ kAccessibilityExpandedChanged

NSString* const flutter::kAccessibilityExpandedChanged = @"@"AXExpandedChanged"
static

Definition at line 20 of file AccessibilityBridgeMac.mm.

◆ kAccessibilityInvalidStatusChangedNotification

NSString* const flutter::kAccessibilityInvalidStatusChangedNotification = @"@"AXInvalidStatusChanged"
static

Definition at line 17 of file AccessibilityBridgeMac.mm.

◆ kAccessibilityLiveRegionChangedNotification

NSString* const flutter::kAccessibilityLiveRegionChangedNotification = @"@"AXLiveRegionChanged"
static

Definition at line 19 of file AccessibilityBridgeMac.mm.

◆ kAccessibilityLiveRegionCreatedNotification

NSString* const flutter::kAccessibilityLiveRegionCreatedNotification = @"@"AXLiveRegionCreated"
static

Definition at line 18 of file AccessibilityBridgeMac.mm.

◆ kAccessibilityLoadCompleteNotification

NSString* const flutter::kAccessibilityLoadCompleteNotification = @"@"AXLoadComplete"
static

Definition at line 16 of file AccessibilityBridgeMac.mm.

◆ kAccessibilityMenuItemSelectedNotification

NSString* const flutter::kAccessibilityMenuItemSelectedNotification = @"@"AXMenuItemSelected"
static

Definition at line 21 of file AccessibilityBridgeMac.mm.

◆ kCapsLockLogicalKey

const uint64_t flutter::kCapsLockLogicalKey = 0x100000104

The logical key for CapsLock, which needs special handling.

Definition at line 246 of file KeyCodeMap.g.mm.

◆ kCapsLockPhysicalKey

const uint64_t flutter::kCapsLockPhysicalKey = 0x00070039

The physical key for CapsLock, which needs special handling.

Definition at line 245 of file KeyCodeMap.g.mm.

◆ keyCodeToLogicalKey

const NSDictionary * flutter::keyCodeToLogicalKey

A map from macOS key codes to Flutter's logical key values.

This is used to derive logical keys that can't or shouldn't be derived from |charactersIgnoringModifiers|.

Definition at line 149 of file KeyCodeMap.g.mm.

◆ keyCodeToModifierFlag

const NSDictionary * flutter::keyCodeToModifierFlag
Initial value:
= @{
@0x00000038 : @(kModifierFlagShiftLeft),
@0x0000003c : @(kModifierFlagShiftRight),
@0x0000003b : @(kModifierFlagControlLeft),
@0x0000003e : @(kModifierFlagControlRight),
@0x0000003a : @(kModifierFlagAltLeft),
@0x0000003d : @(kModifierFlagAltRight),
@0x00000037 : @(kModifierFlagMetaLeft),
@0x00000036 : @(kModifierFlagMetaRight),
}

Map |NSEvent.keyCode| to its corresponding bitmask of NSEventModifierFlags.

This does not include CapsLock, for it is handled specially.

Definition at line 223 of file KeyCodeMap.g.mm.

◆ keyCodeToPhysicalKey

const NSDictionary * flutter::keyCodeToPhysicalKey

Maps macOS-specific key code values representing |PhysicalKeyboardKey|.

MacOS doesn't provide a scan code, but a virtual keycode to represent a physical key.

Definition at line 26 of file KeyCodeMap.g.mm.

◆ kHasScrollingAction

constexpr int flutter::kHasScrollingAction
constexpr
Initial value:
=
FlutterSemanticsAction::kFlutterSemanticsActionScrollLeft |
FlutterSemanticsAction::kFlutterSemanticsActionScrollRight |
FlutterSemanticsAction::kFlutterSemanticsActionScrollUp |
FlutterSemanticsAction::kFlutterSemanticsActionScrollDown

Definition at line 16 of file accessibility_bridge.cc.

◆ kLayoutGoals

const std::vector< LayoutGoal > flutter::kLayoutGoals

All keys that Flutter wants to derive layout for, and guides on how to derive them.

Definition at line 248 of file KeyCodeMap.g.mm.

Referenced by flutter::testing::TEST().

◆ kMacosPlane

const uint64_t flutter::kMacosPlane = 0x01400000000

The plane value for the private keys defined by the macOS embedding.

Definition at line 24 of file KeyCodeMap.g.mm.

◆ kUnicodePlane

const uint64_t flutter::kUnicodePlane = 0x00000000000

The plane value for keys which have a Unicode representation.

Definition at line 23 of file KeyCodeMap.g.mm.

◆ kValueMask

const uint64_t flutter::kValueMask = 0x000ffffffff

Mask for the 32-bit value portion of the key code.

Definition at line 22 of file KeyCodeMap.g.mm.

◆ modifierFlagToKeyCode

const NSDictionary * flutter::modifierFlagToKeyCode
Initial value:
= @{
@(kModifierFlagShiftLeft) : @0x00000038,
@(kModifierFlagShiftRight) : @0x0000003c,
@(kModifierFlagControlLeft) : @0x0000003b,
@(kModifierFlagControlRight) : @0x0000003e,
@(kModifierFlagAltLeft) : @0x0000003a,
@(kModifierFlagAltRight) : @0x0000003d,
@(kModifierFlagMetaLeft) : @0x00000037,
@(kModifierFlagMetaRight) : @0x00000036,
}

Map a bit of bitmask of NSEventModifierFlags to its corresponding |NSEvent.keyCode|.

This does not include CapsLock, for it is handled specially.

Definition at line 234 of file KeyCodeMap.g.mm.