Flutter Windows Embedder
flutter::testing Namespace Reference

Classes

class  AccessibilityPluginTest
 
class  CursorHandlerTest
 
class  MockIDirectManipulationViewport
 
class  MockIDirectManipulationContent
 
class  DisplayManagerWin32Test
 
class  FlutterWindowsEngineTest
 
class  MockFlutterWindowsView
 
class  MockWindowsLifecycleManager
 
class  PlatformHandlerTest
 
class  TestTaskRunnerWindow
 
class  TextInputPluginTest
 
class  WindowsLifecycleManagerTest
 

Functions

 TEST (AccessibilityBridgeWindows, GetParent)
 
 TEST (AccessibilityBridgeWindows, GetParentOnRootRetunsNullptr)
 
 TEST (AccessibilityBridgeWindows, DispatchAccessibilityAction)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventAlert)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventChildrenChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventFocusChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventIgnoredChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityImageAnnotationChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityLiveRegionChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityNameChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityHScrollPosChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityVScrollPosChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilitySelectedChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilitySelectedChildrenChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilitySubtreeCreated)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityValueChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityStateChanged)
 
 TEST (AccessibilityBridgeWindows, OnDocumentSelectionChanged)
 
 TEST_F (AccessibilityPluginTest, DirectAnnounceCall)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithInt32ViewId)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithInt64ViewId)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithInvalidViewIdType)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithMissingMessage)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStore)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreImpellerNoMSAA)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreImpellerMSAA)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreImpellerOffscreenMSAA)
 
 TEST_F (CompositorOpenGLTest, InitializationFailure)
 
 TEST_F (CompositorOpenGLTest, InitializationRequiresBlit)
 
 TEST_F (CompositorOpenGLTest, Present)
 
 TEST_F (CompositorOpenGLTest, PresentEmpty)
 
 TEST_F (CompositorOpenGLTest, NoSurfaceIgnored)
 
 TEST_F (CompositorOpenGLTest, PresentUsingANGLEBlitExtension)
 
 TEST_F (CompositorSoftwareTest, CreateBackingStore)
 
 TEST_F (CompositorSoftwareTest, Present)
 
 TEST_F (CompositorSoftwareTest, PresentEmpty)
 
 TEST_F (CompositorSoftwareTest, PresentMultiLayers)
 
 TEST_F (CompositorSoftwareTest, PresentOffsetLayers)
 
 TEST_F (CursorHandlerTest, ActivateSystemCursor)
 
 TEST_F (CursorHandlerTest, CreateCustomCursor)
 
 TEST_F (CursorHandlerTest, SetCustomCursor)
 
 TEST_F (CursorHandlerTest, SetNonexistentCustomCursor)
 
 TEST_F (CursorHandlerTest, DeleteCustomCursor)
 
 TEST_F (CursorHandlerTest, DeleteNonexistentCustomCursor)
 
 TEST (DirectManipulationTest, TestGesture)
 
 TEST (DirectManipulationTest, TestRounding)
 
 TEST (DirectManipulationTest, TestInertiaCancelSentForUserCancel)
 
 TEST (DirectManipulationTest, TestInertiaCamcelNotSentAtInertiaEnd)
 
 TEST (DirectManipulationTest, TestGestureWithInitialData)
 
 TEST_F (DisplayManagerWin32Test, MultipleMonitors)
 
 TEST_F (DisplayManagerWin32Test, HandleDisplayChangeMessage)
 
 TEST (DpiUtilsTest, NonZero)
 
 TEST (DpiUtilsTest, NullHwndUsesPrimaryMonitor)
 
 TEST (FlutterProjectBundle, BasicPropertiesAbsolutePaths)
 
 TEST (FlutterProjectBundle, BasicPropertiesRelativePaths)
 
 TEST (FlutterProjectBundle, SwitchesEmpty)
 
 TEST (FlutterProjectBundle, DartEntrypointArguments)
 
 TEST (FlutterProjectBundle, Switches)
 
 TEST_F (FlutterWindowTest, CreateDestroy)
 
 TEST_F (FlutterWindowTest, OnBitmapSurfaceUpdated)
 
 TEST_F (FlutterWindowTest, OnCursorRectUpdatedRegularDPI)
 
 TEST_F (FlutterWindowTest, OnCursorRectUpdatedHighDPI)
 
 TEST_F (FlutterWindowTest, OnPointerStarSendsDeviceType)
 
 TEST_F (FlutterWindowTest, OnStylusPointerDown)
 
 TEST_F (FlutterWindowTest, OnStylusPointerMove)
 
 TEST_F (FlutterWindowTest, OnStylusPointerUp)
 
 TEST_F (FlutterWindowTest, OnStylusPointerLeave)
 
 TEST_F (FlutterWindowTest, OnStylusPointerHover)
 
 TEST_F (FlutterWindowTest, OnStylusHoverAfterPointerUp)
 
 TEST_F (FlutterWindowTest, OnStylusBarrelButtonUsesPenFlags)
 
 TEST_F (FlutterWindowTest, OnStylusEraserButtonUsesPenFlags)
 
 TEST_F (FlutterWindowTest, OnInvertedStylusPointerDownUsesDeviceKind)
 
 TEST_F (FlutterWindowTest, OnStylusBarrelButtonUpdateMovesWithUpdatedButtons)
 
 TEST_F (FlutterWindowTest, OnStylusBarrelButtonUpdateMovesWithReleasedButton)
 
 TEST_F (FlutterWindowTest, OnMousePointerDown)
 
 TEST_F (FlutterWindowTest, OnTouchPointerDown)
 
 TEST_F (FlutterWindowTest, PointerMessageScreenCoordinatesAreConvertedToClient)
 
 TEST_F (FlutterWindowTest, OnScrollCallsGetScrollOffsetMultiplier)
 
 TEST_F (FlutterWindowTest, OnWindowRepaint)
 
 TEST_F (FlutterWindowTest, OnThemeChange)
 
 TEST_F (FlutterWindowTest, AccessibilityNodeWithoutView)
 
 TEST_F (FlutterWindowTest, AlertNode)
 
 TEST_F (FlutterWindowTest, LifecycleFocusMessages)
 
 TEST_F (FlutterWindowTest, CachedLifecycleMessage)
 
 TEST_F (FlutterWindowsEngineTest, RunHeadless)
 
 TEST_F (FlutterWindowsEngineTest, TaskRunnerDelayedTask)
 
 TEST_F (FlutterWindowsEngineTest, TaskRunnerDoesNotDeadlock)
 
 TEST_F (FlutterWindowsEngineTest, RunDoesExpectedInitialization)
 
 TEST_F (FlutterWindowsEngineTest, ConfiguresFrameVsync)
 
 TEST_F (FlutterWindowsEngineTest, RunSkiaWithoutANGLEUsesSoftware)
 
 TEST_F (FlutterWindowsEngineTest, RunWithoutANGLEOnImpellerFailsToStart)
 
 TEST_F (FlutterWindowsEngineTest, RunWithDefaultEnablesImpeller)
 
 TEST_F (FlutterWindowsEngineTest, RunWithProjectFlagEnableImpeller)
 
 TEST_F (FlutterWindowsEngineTest, RunWithProjectFlagDisableImpeller)
 
 TEST_F (FlutterWindowsEngineTest, RunWithCommandLineDisableImpeller)
 
 TEST_F (FlutterWindowsEngineTest, SendPlatformMessageWithoutResponse)
 
 TEST_F (FlutterWindowsEngineTest, PlatformMessageRoundTrip)
 
 TEST_F (FlutterWindowsEngineTest, PlatformMessageRespondOnDifferentThread)
 
 TEST_F (FlutterWindowsEngineTest, SendPlatformMessageWithResponse)
 
 TEST_F (FlutterWindowsEngineTest, DispatchSemanticsAction)
 
 TEST_F (FlutterWindowsEngineTest, SetsThreadPriority)
 
 TEST_F (FlutterWindowsEngineTest, AddPluginRegistrarDestructionCallback)
 
 TEST_F (FlutterWindowsEngineTest, ScheduleFrame)
 
 TEST_F (FlutterWindowsEngineTest, SetNextFrameCallback)
 
 TEST_F (FlutterWindowsEngineTest, GetExecutableName)
 
 TEST_F (FlutterWindowsEngineTest, UpdateHighContrastFeature)
 
 TEST_F (FlutterWindowsEngineTest, PostRasterThreadTask)
 
 TEST_F (FlutterWindowsEngineTest, AccessibilityAnnouncement)
 
 TEST_F (FlutterWindowsEngineTest, AccessibilityAnnouncementHeadless)
 
 TEST_F (FlutterWindowsEngineTest, AccessibilityTooltip)
 
 TEST_F (FlutterWindowsEngineTest, TestExit)
 
 TEST_F (FlutterWindowsEngineTest, TestExitCancel)
 
 TEST_F (FlutterWindowsEngineTest, TestExitSecondCloseMessage)
 
 TEST_F (FlutterWindowsEngineTest, TestExitCloseMultiWindow)
 
 TEST_F (FlutterWindowsEngineTest, LifecycleManagerDisabledByDefault)
 
 TEST_F (FlutterWindowsEngineTest, EnableApplicationLifecycle)
 
 TEST_F (FlutterWindowsEngineTest, ApplicationLifecycleExternalWindow)
 
 TEST_F (FlutterWindowsEngineTest, LifecycleStateTransition)
 
 TEST_F (FlutterWindowsEngineTest, ExternalWindowMessage)
 
 TEST_F (FlutterWindowsEngineTest, InnerWindowHidden)
 
 TEST_F (FlutterWindowsEngineTest, EnableLifecycleState)
 
 TEST_F (FlutterWindowsEngineTest, LifecycleStateToFrom)
 
 TEST_F (FlutterWindowsEngineTest, ChannelListenedTo)
 
 TEST_F (FlutterWindowsEngineTest, ReceivePlatformViewMessage)
 
 TEST_F (FlutterWindowsEngineTest, AddViewFailureDoesNotHang)
 
 TEST_F (FlutterWindowsEngineTest, RemoveViewFailureDoesNotHang)
 
 TEST_F (FlutterWindowsEngineTest, MergedUIThread)
 
 TEST_F (FlutterWindowsEngineTest, OnViewFocusChangeRequest)
 
 TEST_F (FlutterWindowsEngineTest, UpdateSemanticsMultiView)
 
 TEST (FlutterWindowsTextureRegistrarTest, CreateDestroy)
 
 TEST (FlutterWindowsTextureRegistrarTest, RegisterUnregisterTexture)
 
 TEST (FlutterWindowsTextureRegistrarTest, RegisterUnknownTextureType)
 
 TEST (FlutterWindowsTextureRegistrarTest, PopulatePixelBufferTexture)
 
 TEST (FlutterWindowsTextureRegistrarTest, PopulateD3dTextureWithHandle)
 
 TEST (FlutterWindowsTextureRegistrarTest, PopulateD3dTexture)
 
 TEST (FlutterWindowsTextureRegistrarTest, PopulateInvalidTexture)
 
 TEST (FlutterWindowsTextureRegistrarTest, UnregisterTextureWithEngineDownInvokesCallback)
 
 TEST (WindowsNoFixtureTest, GetTextureRegistrar)
 
 TEST_F (WindowsTest, LaunchMain)
 
 TEST_F (WindowsTest, LaunchMainHasNoOutput)
 
 TEST_F (WindowsTest, LaunchCustomEntrypoint)
 
 TEST_F (WindowsTest, LaunchCustomEntrypointInEngineRunInvocation)
 
 TEST_F (WindowsTest, LaunchHeadlessEngine)
 
 TEST_F (WindowsTest, EngineCanTransitionToHeadless)
 
 TEST_F (WindowsTest, LaunchRefreshesAccessibility)
 
 TEST_F (WindowsTest, LaunchConflictingCustomEntrypoints)
 
 TEST_F (WindowsTest, VerifyNativeFunction)
 
 TEST_F (WindowsTest, VerifyNativeFunctionWithParameters)
 
 TEST_F (WindowsTest, PlatformExecutable)
 
 TEST_F (WindowsTest, VerifyNativeFunctionWithReturn)
 
 TEST_F (WindowsTest, NextFrameCallback)
 
 TEST_F (WindowsTest, PresentHeadless)
 
 TEST_F (WindowsTest, IsPlatformThread)
 
 TEST_F (WindowsTest, IsNotPlatformThread)
 
 TEST_F (WindowsTest, PostPlatformThreadTaskFromPlatformThread)
 
 TEST_F (WindowsTest, PostPlatformThreadTaskFromBackgroundThread)
 
 TEST_F (WindowsTest, PostPlatformThreadTaskCancelledOnEngineDestroy)
 
 TEST_F (WindowsTest, GetViewId)
 
 TEST_F (WindowsTest, GetGraphicsAdapter)
 
 TEST_F (WindowsTest, GetEngineGraphicsAdapter)
 
 TEST_F (WindowsTest, GetGraphicsAdapterWithLowPowerPreference)
 
 TEST_F (WindowsTest, GetGraphicsAdapterWithHighPerformancePreference)
 
 TEST_F (WindowsTest, GetEngineGraphicsAdapterWithLowPowerPreference)
 
 TEST_F (WindowsTest, GetEngineGraphicsAdapterWithHighPerformancePreference)
 
 TEST_F (WindowsTest, PluginRegistrarGetImplicitView)
 
 TEST_F (WindowsTest, PluginRegistrarGetView)
 
 TEST_F (WindowsTest, PluginRegistrarGetViewHeadless)
 
 TEST_F (WindowsTest, SurfaceOptional)
 
 TEST_F (WindowsTest, Lifecycle)
 
 TEST_F (WindowsTest, GetKeyboardStateHeadless)
 
 TEST_F (WindowsTest, AddRemoveView)
 
 TEST_F (WindowsTest, EngineId)
 
 TEST_F (WindowsTest, EnableIAccessible)
 
 TEST_F (WindowsTest, EnableIAccessibleEx)
 
 TEST (FlutterWindowsViewTest, SubMenuExpandedState)
 
 TEST (FlutterWindowsViewTest, Shutdown)
 
 TEST (FlutterWindowsViewTest, KeySequence)
 
 TEST (FlutterWindowsViewTest, KeyEventCallback)
 
 TEST (FlutterWindowsViewTest, EnableSemantics)
 
 TEST (FlutterWindowsViewTest, AddSemanticsNodeUpdate)
 
 TEST (FlutterWindowsViewTest, AddSemanticsNodeUpdateWithChildren)
 
 TEST (FlutterWindowsViewTest, NonZeroSemanticsRoot)
 
 TEST (FlutterWindowsViewTest, AccessibilityHitTesting)
 
 TEST (FlutterWindowsViewTest, WindowResizeTests)
 
 TEST (FlutterWindowsViewTest, TestEmptyFrameResizes)
 
 TEST (FlutterWindowsViewTest, WindowResizeRace)
 
 TEST (FlutterWindowsViewTest, WindowResizeInvalidSurface)
 
 TEST (FlutterWindowsViewTest, WindowResizeWithoutSurface)
 
 TEST (FlutterWindowsViewTest, WindowRepaintTests)
 
 TEST (FlutterWindowsViewTest, CheckboxNativeState)
 
 TEST (FlutterWindowsViewTest, SwitchNativeState)
 
 TEST (FlutterWindowsViewTest, TooltipNodeData)
 
 TEST (FlutterWindowsViewTest, DisablesVSyncAtStartup)
 
 TEST (FlutterWindowsViewTest, EnablesVSyncAtStartup)
 
 TEST (FlutterWindowsViewTest, DisablesVSyncAfterStartup)
 
 TEST (FlutterWindowsViewTest, EnablesVSyncAfterStartup)
 
 TEST (FlutterWindowsViewTest, UpdatesVSyncOnDwmUpdates)
 
 TEST (FlutterWindowsViewTest, FocusTriggersWindowFocus)
 
 TEST (FlutterWindowsViewTest, OnFocusTriggersSendFocusViewEvent)
 
 TEST (FlutterWindowsViewTest, WindowMetricsEventContainsDisplayId)
 
 TEST (FlutterWindowsViewTest, SizeChangeTriggersMetricsEventWhichHasDisplayId)
 
 TEST (FlutterWindowsViewTest, FirstFrameCallbackFiresOnFramePresented)
 
 TEST (FlutterWindowsViewTest, FirstFrameCallbackFiresOnSoftwareBitmapPresent)
 
 TEST (FlutterWindowsViewTest, FirstFrameCallbackFiresOnlyOnce)
 
 TEST (FlutterWindowsViewTest, FirstFrameCallbackSkippedOnFailedSoftwarePresent)
 
 TEST (KeyboardKeyChannelHandlerTest, KeyboardHookHandling)
 
 TEST (KeyboardKeyChannelHandlerTest, ExtendedKeysAreSentToRedispatch)
 
 TEST (KeyboardKeyChannelHandlerTest, DeadKeysDoNotCrash)
 
 TEST (KeyboardKeyChannelHandlerTest, EmptyResponsesDoNotCrash)
 
 TEST (KeyboardKeyEmbedderHandlerTest, ConvertChar32ToUtf8)
 
 TEST (KeyboardKeyEmbedderHandlerTest, BasicKeyPressingAndHolding)
 
 TEST (KeyboardKeyEmbedderHandlerTest, ToggleNumLockDuringNumpadPress)
 
 TEST (KeyboardKeyEmbedderHandlerTest, ImeEventsAreIgnored)
 
 TEST (KeyboardKeyEmbedderHandlerTest, ModifierKeysByExtendedBit)
 
 TEST (KeyboardKeyEmbedderHandlerTest, ModifierKeysByVirtualKey)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SynthesizeModifierLeftKeyDownWhenNotPressed)
 
 TEST (KeyboardKeyEmbedderHandlerTest, DoNotSynthesizeModifierDownWhenPressed)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SynthesizeModifierUpWhenPressed)
 
 TEST (KeyboardKeyEmbedderHandlerTest, DoNotSynthesizeModifierUpWhenNotPressed)
 
 TEST (KeyboardKeyEmbedderHandlerTest, RepeatedDownIsIgnored)
 
 TEST (KeyboardKeyEmbedderHandlerTest, AbruptRepeatIsConvertedToDown)
 
 TEST (KeyboardKeyEmbedderHandlerTest, AbruptUpIsIgnored)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncPressingState)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncToggledState)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncToggledStateByItselfsUp)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncToggledStateByItselfsDown)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SynthesizeWithInitialTogglingState)
 
 TEST (KeyboardKeyEmbedderHandlerTest, SysKeyPress)
 
 TEST (KeyboardKeyHandlerTest, SingleDelegateWithAsyncResponds)
 
 TEST (KeyboardKeyHandlerTest, SingleDelegateWithSyncResponds)
 
 TEST (KeyboardKeyHandlerTest, HandlerGetPressedState)
 
 TEST (KeyboardKeyHandlerTest, KeyboardChannelGetPressedState)
 
 TEST_F (KeyboardTest, LowerCaseAHandled)
 
 TEST_F (KeyboardTest, LowerCaseAUnhandled)
 
 TEST_F (KeyboardTest, ArrowLeftHandled)
 
 TEST_F (KeyboardTest, ArrowLeftUnhandled)
 
 TEST_F (KeyboardTest, ShiftLeftUnhandled)
 
 TEST_F (KeyboardTest, ShiftRightUnhandled)
 
 TEST_F (KeyboardTest, CtrlLeftUnhandled)
 
 TEST_F (KeyboardTest, CtrlRightUnhandled)
 
 TEST_F (KeyboardTest, AltLeftUnhandled)
 
 TEST_F (KeyboardTest, AltRightUnhandled)
 
 TEST_F (KeyboardTest, MetaLeftUnhandled)
 
 TEST_F (KeyboardTest, MetaRightUnhandled)
 
 TEST_F (KeyboardTest, RepeatA)
 
 TEST_F (KeyboardTest, RestartClearsKeyboardState)
 
 TEST_F (KeyboardTest, FreshKeyDownAfterMissedUpIsDelivered)
 
 TEST_F (KeyboardTest, ShiftLeftKeyA)
 
 TEST_F (KeyboardTest, CtrlLeftKeyA)
 
 TEST_F (KeyboardTest, CtrlLeftDigit1)
 
 TEST_F (KeyboardTest, Digit1OnFrenchLayout)
 
 TEST_F (KeyboardTest, AltGrModifiedKey)
 
 TEST_F (KeyboardTest, AltGrTwice)
 
 TEST_F (KeyboardTest, DeadKeyThatCombines)
 
 TEST_F (KeyboardTest, DeadKeyWithoutDeadMaskThatCombines)
 
 TEST_F (KeyboardTest, DeadKeyThatDoesNotCombine)
 
 TEST_F (KeyboardTest, DeadKeyTwiceThenLetter)
 
 TEST_F (KeyboardTest, MultibyteCharacter)
 
 TEST_F (KeyboardTest, SynthesizeModifiers)
 
 TEST_F (KeyboardTest, ImeExtendedEventsAreIgnored)
 
 TEST_F (KeyboardTest, UpOnlyImeEventsAreCorrectlyHandled)
 
 TEST_F (KeyboardTest, SlowFrameworkResponse)
 
 TEST_F (KeyboardTest, SlowFrameworkResponseForIdenticalEvents)
 
 TEST_F (KeyboardTest, TextInputSubmit)
 
 TEST_F (KeyboardTest, VietnameseTelexAddDiacriticWithFastResponse)
 
void VietnameseTelexAddDiacriticWithSlowResponse (WindowsTestContext &context, bool backspace_response)
 
 TEST_F (KeyboardTest, VietnameseTelexAddDiacriticWithSlowFalseResponse)
 
 TEST_F (KeyboardTest, VietnameseTelexAddDiacriticWithSlowTrueResponse)
 
 TEST_F (KeyboardTest, DoubleCapsLock)
 
 TEST (KeyboardWin32CommonTest, EncodeUtf16)
 
 TEST_F (PlatformHandlerTest, GetClipboardData)
 
 TEST_F (PlatformHandlerTest, GetClipboardDataRejectsUnknownContentType)
 
 TEST_F (PlatformHandlerTest, GetClipboardDataReportsOpenFailure)
 
 TEST_F (PlatformHandlerTest, GetClipboardDataReportsGetDataFailure)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStrings)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsReturnsFalse)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsRejectsUnknownContentType)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsIgnoresPermissionErrors)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsReportsErrors)
 
 TEST_F (PlatformHandlerTest, ClipboardSetData)
 
 TEST_F (PlatformHandlerTest, ClipboardSetDataTextMustBeString)
 
 TEST_F (PlatformHandlerTest, ClipboardSetDataUnknownType)
 
 TEST_F (PlatformHandlerTest, ClipboardSetDataReportsOpenFailure)
 
 TEST_F (PlatformHandlerTest, ClipboardSetDataReportsSetDataFailure)
 
 TEST_F (PlatformHandlerTest, PlaySystemSound)
 
 TEST_F (PlatformHandlerTest, SystemExitApplicationRequired)
 
 TEST_F (PlatformHandlerTest, SystemExitApplicationCancelableCancel)
 
 TEST_F (PlatformHandlerTest, SystemExitApplicationCancelableExit)
 
 TEST (SequentialIdGeneratorTest, RemoveMultipleNumbers)
 
 TEST (SequentialIdGeneratorTest, MaybeRemoveNumbers)
 
 TEST (SettingsPluginTest, SendSettingsSendsMessage)
 
 TEST (SettingsPluginTest, SendSettingsGetsSettings)
 
 TEST (SettingsPluginTest, StartWatchingStartsWatchingChanges)
 
 TEST (SettingsPluginTest, HighContrastModeHonored)
 
 TEST (SystemUtils, GetPreferredLanguageInfo)
 
 TEST (SystemUtils, GetPreferredLanguages)
 
 TEST (SystemUtils, ParseLanguageNameGeneric)
 
 TEST (SystemUtils, ParseLanguageNameWithRegion)
 
 TEST (SystemUtils, ParseLanguageNameWithScript)
 
 TEST (SystemUtils, ParseLanguageNameWithRegionAndScript)
 
 TEST (SystemUtils, ParseLanguageNameWithSuplementalLanguage)
 
 TEST (SystemUtils, ParseLanguageNameWithThreeCharacterLanguage)
 
 TEST (SystemUtils, GetUserTimeFormat)
 
 TEST (SystemUtils, Prefer24HourTimeHandlesEmptyFormat)
 
 TEST (SystemUtils, Prefer24HourTimeHandles12Hour)
 
 TEST (SystemUtils, Prefer24HourTimeHandles24Hour)
 
 TEST (TaskRunnerTest, MaybeExecuteTaskWithExactOrder)
 
 TEST (TaskRunnerTest, MaybeExecuteTaskOnlyExpired)
 
 TEST (TaskRunnerTest, TimerThreadDoesNotCancelEarlierScheduledTasks)
 
 TEST (TaskRunnerTest, EmptyTaskRunnerReturnsNanoSecondsMax)
 
 TEST (TaskRunnerTest, TaskRunnerWindowCoalescesWakeUpMessages)
 
 TEST_F (TextInputPluginTest, TextMethodsWorksWithEmptyModel)
 
 TEST_F (TextInputPluginTest, ClearClientResetsComposing)
 
 TEST_F (TextInputPluginTest, ClearClientRequiresView)
 
 TEST_F (TextInputPluginTest, VerifyComposingSendStateUpdate)
 
 TEST_F (TextInputPluginTest, VerifyInputActionNewlineInsertNewLine)
 
 TEST_F (TextInputPluginTest, VerifyInputActionSendDoesNotInsertNewLine)
 
 TEST_F (TextInputPluginTest, SetClientRequiresViewId)
 
 TEST_F (TextInputPluginTest, SetClientRequiresViewIdToBeInteger)
 
 TEST_F (TextInputPluginTest, TextEditingWorksWithDeltaModel)
 
 TEST_F (TextInputPluginTest, CompositionCursorPos)
 
 TEST_F (TextInputPluginTest, TransformCursorRect)
 
 TEST_F (TextInputPluginTest, SetMarkedTextRectRequiresView)
 
 TEST_F (TextInputPluginTest, SetAndUseMultipleClients)
 
 TEST_F (TextInputPluginTest, OnViewRemovedResetsActiveView)
 
 TEST_F (TextInputPluginTest, OnViewRemovedIgnoresNonActiveView)
 
 TEST_F (TextInputPluginTest, OnViewRemovedIgnoresImplicitView)
 
 TEST_F (WindowManagerTest, WindowingInitialize)
 
 TEST_F (WindowManagerTest, CreateRegularWindow)
 
 TEST_F (WindowManagerTest, GetWindowHandle)
 
 TEST_F (WindowManagerTest, GetWindowSize)
 
 TEST_F (WindowManagerTest, SetWindowSize)
 
 TEST_F (WindowManagerTest, CanConstrainByMinimiumSize)
 
 TEST_F (WindowManagerTest, CanConstrainByMaximumSize)
 
 TEST_F (WindowManagerTest, CanFullscreenWindow)
 
 TEST_F (WindowManagerTest, CanUnfullscreenWindow)
 
 TEST_F (WindowManagerTest, CanSetWindowSizeWhileFullscreen)
 
 TEST_F (WindowManagerTest, CanSetWindowConstraintsWhileFullscreen)
 
 TEST_F (WindowManagerTest, CreateModelessDialogWindow)
 
 TEST_F (WindowManagerTest, CreateModalDialogWindow)
 
 TEST_F (WindowManagerTest, DeactivatedRegularWindowDoesNotReactivateItself)
 
 TEST_F (WindowManagerTest, DialogCanNeverBeFullscreen)
 
 TEST_F (WindowManagerTest, CreateTooltipWindow)
 
 TEST_F (WindowManagerTest, TooltipWindowHasNoActivateStyle)
 
 TEST_F (WindowManagerTest, TooltipWindowDoesNotStealFocus)
 
 TEST_F (WindowManagerTest, TooltipWindowReturnsNoActivateOnMouseClick)
 
 TEST_F (WindowManagerTest, TooltipWindowUpdatesPositionOnViewSizeChange)
 
 TEST_F (WindowManagerTest, CreatePopupWindow)
 
 TEST_F (WindowManagerTest, PopupWindowHasNoActivateStyle)
 
 TEST_F (WindowManagerTest, PopupWindowDoesNotStealFocus)
 
 TEST_F (WindowManagerTest, PopupWindowUpdatesPositionOnViewSizeChange)
 
 TEST_F (WindowManagerTest, CreateRegularWindowSizedToContent)
 
 TEST_F (WindowManagerTest, RegularWindowSizedToContentResizesToContent)
 
 TEST_F (WindowManagerTest, RegularWindowSizedToContentNonResizableHasNoThickFrame)
 
 TEST_F (WindowManagerTest, RegularWindowSizedToContentResizableHasThickFrame)
 
 TEST_F (WindowManagerTest, RegularWindowSizedToContentResizableStopsTrackingAfterFirstFrame)
 
 TEST_F (WindowManagerTest, CreateModelessDialogSizedToContent)
 
 TEST_F (WindowManagerTest, CreateModalDialogSizedToContent)
 
 TEST_F (WindowManagerTest, DialogWindowSizedToContentResizesToContent)
 
 TEST_F (WindowManagerTest, DialogWindowSizedToContentNonResizableHasNoThickFrame)
 
 TEST (WindowProcDelegateManagerTest, CallsCorrectly)
 
 TEST (WindowProcDelegateManagerTest, ReplacementRegister)
 
 TEST (WindowProcDelegateManagerTest, RegisterMultiple)
 
 TEST (WindowProcDelegateManagerTest, Ordered)
 
 TEST (WindowProcDelegateManagerTest, ConflictingDelegates)
 
 TEST (WindowProcDelegateManagerTest, Unregister)
 
 TEST (MockWindow, CreateDestroy)
 
 TEST (MockWindow, GetDpiAfterCreate)
 
 TEST (MockWindow, VerticalScroll)
 
 TEST (MockWindow, OnImeCompositionCompose)
 
 TEST (MockWindow, OnImeCompositionDefaultsKoreanCursorToCompositionEnd)
 
 TEST (MockWindow, OnImeCompositionResult)
 
 TEST (MockWindow, OnImeCompositionResultAndCompose)
 
 TEST (MockWindow, OnImeCompositionUsesCursorPositionWhenProvided)
 
 TEST (MockWindow, OnImeCompositionFallsBackToTextEndForInvalidCursorPosition)
 
 TEST (MockWindow, OnImeCompositionClearChange)
 
 TEST (MockWindow, HorizontalScroll)
 
 TEST (MockWindow, MouseLeave)
 
 TEST (MockWindow, KeyDown)
 
 TEST (MockWindow, KeyUp)
 
 TEST (MockWindow, SysKeyDown)
 
 TEST (MockWindow, SysKeyUp)
 
 TEST (MockWindow, KeyDownPrintable)
 
 TEST (MockWindow, KeyDownWithCtrl)
 
 TEST (MockWindow, KeyDownWithCtrlToggled)
 
 TEST (MockWindow, Paint)
 
 TEST (MockWindow, PointerHitTest)
 
 TEST (MockWindow, TouchPadHitTest)
 
 TEST (MockWindow, UnknownPointerTypeSkipsDirectManipulation)
 
 TEST (MockWindow, DISABLED_GetObjectUia)
 
static void WaitUntilUpdated (const WindowsLifecycleManager &manager)
 
 TEST_F (WindowsLifecycleManagerTest, StateTransitions)
 
FlutterSemanticsNode2 CreateSemanticsNode (int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)
 
 TEST (AccessibilityBridgeTest, BasicTest)
 
 TEST (AccessibilityBridgeTest, AccessibilityRootId)
 
 TEST (AccessibilityBridgeTest, AddOrder)
 
 TEST (AccessibilityBridgeTest, CanFireChildrenChangedCorrectly)
 
 TEST (AccessibilityBridgeTest, CanHandleSelectionChangeCorrectly)
 
 TEST (AccessibilityBridgeTest, DoesNotAssignEditableRootToSelectableText)
 
 TEST (AccessibilityBridgeTest, SwitchHasSwitchRole)
 
 TEST (AccessibilityBridgeTest, SliderHasSliderRole)
 
 TEST (AccessibilityBridgeTest, CanSetCheckboxChecked)
 
 TEST (AccessibilityBridgeTest, CanReparentNode)
 
 TEST (AccessibilityBridgeTest, CanReparentMultipleNodes)
 
 TEST (AccessibilityBridgeTest, CanReparentNodeWithChild)
 
 TEST (AccessibilityBridgeTest, AXTreeManagerTest)
 
 TEST (AccessibilityBridgeTest, LineBreakingObjectTest)
 
 TEST (AccessibilityBridgeTest, IsSelectedAttribute)
 
 TEST (FlutterPlatformNodeDelegateTest, NodeDelegateHasUniqueId)
 
 TEST (FlutterPlatformNodeDelegateTest, canPerfomActions)
 
 TEST (FlutterPlatformNodeDelegateTest, canGetAXNode)
 
 TEST (FlutterPlatformNodeDelegateTest, canCalculateBoundsCorrectly)
 
 TEST (FlutterPlatformNodeDelegateTest, canCalculateOffScreenBoundsCorrectly)
 
 TEST (FlutterPlatformNodeDelegateTest, canUseOwnerBridge)
 
 TEST (FlutterPlatformNodeDelegateTest, selfIsLowestPlatformAncestor)
 
 TEST (FlutterPlatformNodeDelegateTest, canGetFromNodeID)
 

Variables

constexpr uint64_t kScanCodeKeyA = 0x1e
 
constexpr uint64_t kVirtualKeyA = 0x41
 
FlutterSemanticsFlags kEmptyFlags = FlutterSemanticsFlags{}
 

Function Documentation

◆ CreateSemanticsNode()

FlutterSemanticsNode2 flutter::testing::CreateSemanticsNode ( int32_t  id,
const char *  label,
const std::vector< int32_t > *  children = nullptr 
)

Definition at line 20 of file accessibility_bridge_unittests.cc.

23  {
24  return {
25  .id = id,
26  // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
27  .flags__deprecated__ = static_cast<FlutterSemanticsFlag>(0),
28  // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
29  .actions = static_cast<FlutterSemanticsAction>(0),
30  .text_selection_base = -1,
31  .text_selection_extent = -1,
32  .label = label,
33  .hint = "",
34  .value = "",
35  .increased_value = "",
36  .decreased_value = "",
37  .child_count = children ? children->size() : 0,
38  .children_in_traversal_order = children ? children->data() : nullptr,
39  .custom_accessibility_actions_count = 0,
40  .tooltip = "",
41  .flags2 = &kEmptyFlags,
42  };
43 }
FlutterSemanticsFlags kEmptyFlags

References kEmptyFlags.

Referenced by TEST().

◆ TEST() [1/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
AccessibilityRootId   
)

Definition at line 79 of file accessibility_bridge_unittests.cc.

79  {
80  std::shared_ptr<TestAccessibilityBridge> bridge =
81  std::make_shared<TestAccessibilityBridge>();
82 
83  std::vector<int32_t> children{456, 789};
84  FlutterSemanticsNode2 root = CreateSemanticsNode(123, "root", &children);
85  FlutterSemanticsNode2 child1 = CreateSemanticsNode(456, "child 1");
86  FlutterSemanticsNode2 child2 = CreateSemanticsNode(789, "child 2");
87 
88  bridge->AddFlutterSemanticsNodeUpdate(root);
89  bridge->AddFlutterSemanticsNodeUpdate(child1);
90  bridge->AddFlutterSemanticsNodeUpdate(child2);
91  bridge->CommitUpdates();
92 
93  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(123).lock();
94  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(456).lock();
95  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(789).lock();
96  auto fake_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
97 
98  EXPECT_EQ(bridge->GetRootAsAXNode()->id(), 123);
99  EXPECT_EQ(bridge->RootDelegate()->GetName(), "root");
100 
101  EXPECT_EQ(root_node->GetChildCount(), 2);
102  EXPECT_EQ(root_node->GetData().child_ids[0], 456);
103  EXPECT_EQ(root_node->GetData().child_ids[1], 789);
104  EXPECT_EQ(root_node->GetName(), "root");
105 
106  EXPECT_EQ(child1_node->GetChildCount(), 0);
107  EXPECT_EQ(child1_node->GetName(), "child 1");
108 
109  EXPECT_EQ(child2_node->GetChildCount(), 0);
110  EXPECT_EQ(child2_node->GetName(), "child 2");
111 
112  ASSERT_FALSE(fake_delegate);
113 }
FlutterSemanticsNode2 CreateSemanticsNode(int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)

References CreateSemanticsNode().

◆ TEST() [2/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
AddOrder   
)

Definition at line 116 of file accessibility_bridge_unittests.cc.

116  {
117  std::shared_ptr<TestAccessibilityBridge> bridge =
118  std::make_shared<TestAccessibilityBridge>();
119 
120  std::vector<int32_t> root_children{34, 56};
121  std::vector<int32_t> child2_children{78};
122  std::vector<int32_t> child3_children{90};
123  FlutterSemanticsNode2 root = CreateSemanticsNode(12, "root", &root_children);
124  FlutterSemanticsNode2 child1 = CreateSemanticsNode(34, "child 1");
125  FlutterSemanticsNode2 child2 =
126  CreateSemanticsNode(56, "child 2", &child2_children);
127  FlutterSemanticsNode2 child3 =
128  CreateSemanticsNode(78, "child 3", &child3_children);
129  FlutterSemanticsNode2 child4 = CreateSemanticsNode(90, "child 4");
130 
131  bridge->AddFlutterSemanticsNodeUpdate(child3);
132  bridge->AddFlutterSemanticsNodeUpdate(child2);
133  bridge->AddFlutterSemanticsNodeUpdate(root);
134  bridge->AddFlutterSemanticsNodeUpdate(child1);
135  bridge->AddFlutterSemanticsNodeUpdate(child4);
136  bridge->CommitUpdates();
137 
138  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(12).lock();
139  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(34).lock();
140  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(56).lock();
141  auto child3_node = bridge->GetFlutterPlatformNodeDelegateFromID(78).lock();
142  auto child4_node = bridge->GetFlutterPlatformNodeDelegateFromID(90).lock();
143 
144  EXPECT_EQ(bridge->GetRootAsAXNode()->id(), 12);
145  EXPECT_EQ(bridge->RootDelegate()->GetName(), "root");
146 
147  EXPECT_EQ(root_node->GetChildCount(), 2);
148  EXPECT_EQ(root_node->GetData().child_ids[0], 34);
149  EXPECT_EQ(root_node->GetData().child_ids[1], 56);
150  EXPECT_EQ(root_node->GetName(), "root");
151 
152  EXPECT_EQ(child1_node->GetChildCount(), 0);
153  EXPECT_EQ(child1_node->GetName(), "child 1");
154 
155  EXPECT_EQ(child2_node->GetChildCount(), 1);
156  EXPECT_EQ(child2_node->GetData().child_ids[0], 78);
157  EXPECT_EQ(child2_node->GetName(), "child 2");
158 
159  EXPECT_EQ(child3_node->GetChildCount(), 1);
160  EXPECT_EQ(child3_node->GetData().child_ids[0], 90);
161  EXPECT_EQ(child3_node->GetName(), "child 3");
162 
163  EXPECT_EQ(child4_node->GetChildCount(), 0);
164  EXPECT_EQ(child4_node->GetName(), "child 4");
165 }

References CreateSemanticsNode().

◆ TEST() [3/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
AXTreeManagerTest   
)

Definition at line 566 of file accessibility_bridge_unittests.cc.

566  {
567  std::shared_ptr<TestAccessibilityBridge> bridge =
568  std::make_shared<TestAccessibilityBridge>();
569 
570  ui::AXTreeID tree_id = bridge->GetTreeID();
571  ui::AXTreeManager* manager =
572  ui::AXTreeManagerMap::GetInstance().GetManager(tree_id);
573  ASSERT_EQ(manager, static_cast<ui::AXTreeManager*>(bridge.get()));
574 }

◆ TEST() [4/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
BasicTest   
)

Definition at line 45 of file accessibility_bridge_unittests.cc.

45  {
46  std::shared_ptr<TestAccessibilityBridge> bridge =
47  std::make_shared<TestAccessibilityBridge>();
48 
49  std::vector<int32_t> children{1, 2};
50  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &children);
51  root.identifier = "identifier";
52  FlutterSemanticsNode2 child1 = CreateSemanticsNode(1, "child 1");
53  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
54 
55  bridge->AddFlutterSemanticsNodeUpdate(root);
56  bridge->AddFlutterSemanticsNodeUpdate(child1);
57  bridge->AddFlutterSemanticsNodeUpdate(child2);
58  bridge->CommitUpdates();
59 
60  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
61  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
62  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
63  EXPECT_EQ(root_node->GetChildCount(), 2);
64  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
65  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
66  EXPECT_EQ(root_node->GetName(), "root");
67  EXPECT_EQ(root_node->GetAuthorUniqueId(), u"identifier");
68 
69  EXPECT_EQ(child1_node->GetChildCount(), 0);
70  EXPECT_EQ(child1_node->GetName(), "child 1");
71 
72  EXPECT_EQ(child2_node->GetChildCount(), 0);
73  EXPECT_EQ(child2_node->GetName(), "child 2");
74 }

References CreateSemanticsNode().

◆ TEST() [5/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanFireChildrenChangedCorrectly   
)

Definition at line 167 of file accessibility_bridge_unittests.cc.

167  {
168  std::shared_ptr<TestAccessibilityBridge> bridge =
169  std::make_shared<TestAccessibilityBridge>();
170 
171  std::vector<int32_t> children{1};
172  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &children);
173  FlutterSemanticsNode2 child1 = CreateSemanticsNode(1, "child 1");
174 
175  bridge->AddFlutterSemanticsNodeUpdate(root);
176  bridge->AddFlutterSemanticsNodeUpdate(child1);
177 
178  bridge->CommitUpdates();
179 
180  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
181  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
182  EXPECT_EQ(root_node->GetChildCount(), 1);
183  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
184  EXPECT_EQ(root_node->GetName(), "root");
185 
186  EXPECT_EQ(child1_node->GetChildCount(), 0);
187  EXPECT_EQ(child1_node->GetName(), "child 1");
188  bridge->accessibility_events.clear();
189 
190  // Add a child to root.
191  root.child_count = 2;
192  int32_t new_children[] = {1, 2};
193  root.children_in_traversal_order = new_children;
194 
195  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
196 
197  bridge->AddFlutterSemanticsNodeUpdate(root);
198  bridge->AddFlutterSemanticsNodeUpdate(child2);
199  bridge->CommitUpdates();
200 
201  root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
202 
203  EXPECT_EQ(root_node->GetChildCount(), 2);
204  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
205  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
206  EXPECT_EQ(bridge->accessibility_events.size(), size_t{2});
207  std::set<ui::AXEventGenerator::Event> actual_event{
208  bridge->accessibility_events.begin(), bridge->accessibility_events.end()};
209  EXPECT_THAT(actual_event,
210  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED));
211  EXPECT_THAT(actual_event,
212  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED));
213 }

References CreateSemanticsNode().

◆ TEST() [6/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanHandleSelectionChangeCorrectly   
)

Definition at line 215 of file accessibility_bridge_unittests.cc.

215  {
216  std::shared_ptr<TestAccessibilityBridge> bridge =
217  std::make_shared<TestAccessibilityBridge>();
218  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
219  auto flags = FlutterSemanticsFlags{
220  .is_focused = FlutterTristate::kFlutterTristateTrue,
221  .is_text_field = true,
222  };
223  root.flags2 = &flags;
224 
225  bridge->AddFlutterSemanticsNodeUpdate(root);
226  bridge->CommitUpdates();
227 
228  const ui::AXTreeData& tree = bridge->GetAXTreeData();
229  EXPECT_EQ(tree.sel_anchor_object_id, ui::AXNode::kInvalidAXID);
230  bridge->accessibility_events.clear();
231 
232  // Update the selection.
233  root.text_selection_base = 0;
234  root.text_selection_extent = 5;
235  bridge->AddFlutterSemanticsNodeUpdate(root);
236 
237  bridge->CommitUpdates();
238 
239  EXPECT_EQ(tree.sel_anchor_object_id, 0);
240  EXPECT_EQ(tree.sel_anchor_offset, 0);
241  EXPECT_EQ(tree.sel_focus_object_id, 0);
242  EXPECT_EQ(tree.sel_focus_offset, 5);
243  ASSERT_EQ(bridge->accessibility_events.size(), size_t{2});
244  EXPECT_EQ(bridge->accessibility_events[0],
245  ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED);
246  EXPECT_EQ(bridge->accessibility_events[1],
247  ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED);
248 }

References CreateSemanticsNode().

◆ TEST() [7/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanReparentMultipleNodes   
)

Definition at line 392 of file accessibility_bridge_unittests.cc.

392  {
393  std::shared_ptr<TestAccessibilityBridge> bridge =
394  std::make_shared<TestAccessibilityBridge>();
395 
396  int32_t root_id = 0;
397  int32_t intermediary1_id = 1;
398  int32_t intermediary2_id = 2;
399  int32_t leaf1_id = 3;
400  int32_t leaf2_id = 4;
401  int32_t leaf3_id = 5;
402 
403  std::vector<int32_t> root_children{intermediary1_id, intermediary2_id};
404  std::vector<int32_t> intermediary1_children{leaf1_id};
405  std::vector<int32_t> intermediary2_children{leaf2_id, leaf3_id};
406  FlutterSemanticsNode2 root =
407  CreateSemanticsNode(root_id, "root", &root_children);
408  FlutterSemanticsNode2 intermediary1 = CreateSemanticsNode(
409  intermediary1_id, "intermediary 1", &intermediary1_children);
410  FlutterSemanticsNode2 intermediary2 = CreateSemanticsNode(
411  intermediary2_id, "intermediary 2", &intermediary2_children);
412  FlutterSemanticsNode2 leaf1 = CreateSemanticsNode(leaf1_id, "leaf 1");
413  FlutterSemanticsNode2 leaf2 = CreateSemanticsNode(leaf2_id, "leaf 2");
414  FlutterSemanticsNode2 leaf3 = CreateSemanticsNode(leaf3_id, "leaf 3");
415 
416  bridge->AddFlutterSemanticsNodeUpdate(root);
417  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
418  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
419  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
420  bridge->AddFlutterSemanticsNodeUpdate(leaf2);
421  bridge->AddFlutterSemanticsNodeUpdate(leaf3);
422  bridge->CommitUpdates();
423  bridge->accessibility_events.clear();
424 
425  // Swap intermediary 1's and intermediary2's children.
426  int32_t new_intermediary1_children[] = {leaf2_id, leaf3_id};
427  intermediary1.child_count = 2;
428  intermediary1.children_in_traversal_order = new_intermediary1_children;
429 
430  int32_t new_intermediary2_children[] = {leaf1_id};
431  intermediary2.child_count = 1;
432  intermediary2.children_in_traversal_order = new_intermediary2_children;
433 
434  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
435  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
436  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
437  bridge->AddFlutterSemanticsNodeUpdate(leaf2);
438  bridge->AddFlutterSemanticsNodeUpdate(leaf3);
439  bridge->CommitUpdates();
440 
441  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
442  auto intermediary1_node =
443  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary1_id).lock();
444  auto intermediary2_node =
445  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary2_id).lock();
446  auto leaf1_node =
447  bridge->GetFlutterPlatformNodeDelegateFromID(leaf1_id).lock();
448  auto leaf2_node =
449  bridge->GetFlutterPlatformNodeDelegateFromID(leaf2_id).lock();
450  auto leaf3_node =
451  bridge->GetFlutterPlatformNodeDelegateFromID(leaf3_id).lock();
452 
453  EXPECT_EQ(root_node->GetChildCount(), 2);
454  EXPECT_EQ(root_node->GetData().child_ids[0], intermediary1_id);
455  EXPECT_EQ(root_node->GetData().child_ids[1], intermediary2_id);
456  EXPECT_EQ(root_node->GetName(), "root");
457 
458  EXPECT_EQ(intermediary1_node->GetChildCount(), 2);
459  EXPECT_EQ(intermediary1_node->GetData().child_ids[0], leaf2_id);
460  EXPECT_EQ(intermediary1_node->GetData().child_ids[1], leaf3_id);
461  EXPECT_EQ(intermediary1_node->GetName(), "intermediary 1");
462 
463  EXPECT_EQ(intermediary2_node->GetChildCount(), 1);
464  EXPECT_EQ(intermediary2_node->GetData().child_ids[0], leaf1_id);
465  EXPECT_EQ(intermediary2_node->GetName(), "intermediary 2");
466 
467  EXPECT_EQ(leaf1_node->GetChildCount(), 0);
468  EXPECT_EQ(leaf1_node->GetName(), "leaf 1");
469 
470  EXPECT_EQ(leaf2_node->GetChildCount(), 0);
471  EXPECT_EQ(leaf2_node->GetName(), "leaf 2");
472 
473  EXPECT_EQ(leaf3_node->GetChildCount(), 0);
474  EXPECT_EQ(leaf3_node->GetName(), "leaf 3");
475 
476  // Intermediary 1 and intermediary 2 have new children.
477  // Leaf 1, 2, and 3 are all moved.
478  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
479  EXPECT_THAT(bridge->accessibility_events,
480  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
481  EXPECT_THAT(bridge->accessibility_events,
482  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(3));
483 }

References CreateSemanticsNode().

◆ TEST() [8/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanReparentNode   
)

Definition at line 329 of file accessibility_bridge_unittests.cc.

329  {
330  std::shared_ptr<TestAccessibilityBridge> bridge =
331  std::make_shared<TestAccessibilityBridge>();
332 
333  std::vector<int32_t> root_children{1};
334  std::vector<int32_t> child1_children{2};
335  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &root_children);
336  FlutterSemanticsNode2 child1 =
337  CreateSemanticsNode(1, "child 1", &child1_children);
338  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
339 
340  bridge->AddFlutterSemanticsNodeUpdate(root);
341  bridge->AddFlutterSemanticsNodeUpdate(child1);
342  bridge->AddFlutterSemanticsNodeUpdate(child2);
343  bridge->CommitUpdates();
344  bridge->accessibility_events.clear();
345 
346  // Reparent child2 from child1 to the root.
347  child1.child_count = 0;
348  child1.children_in_traversal_order = nullptr;
349 
350  int32_t new_root_children[] = {1, 2};
351  root.child_count = 2;
352  root.children_in_traversal_order = new_root_children;
353 
354  bridge->AddFlutterSemanticsNodeUpdate(root);
355  bridge->AddFlutterSemanticsNodeUpdate(child1);
356  bridge->AddFlutterSemanticsNodeUpdate(child2);
357  bridge->CommitUpdates();
358 
359  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
360  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
361  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
362 
363  EXPECT_EQ(root_node->GetChildCount(), 2);
364  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
365  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
366  EXPECT_EQ(root_node->GetName(), "root");
367 
368  EXPECT_EQ(child1_node->GetChildCount(), 0);
369  EXPECT_EQ(child1_node->GetName(), "child 1");
370 
371  EXPECT_EQ(child2_node->GetChildCount(), 0);
372  EXPECT_EQ(child2_node->GetName(), "child 2");
373 
374  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
375 
376  // Child2 is moved from child1 to root.
377  EXPECT_THAT(bridge->accessibility_events,
378  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
379  EXPECT_THAT(bridge->accessibility_events,
380  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
381 
382  // Child1 is no longer a parent. It loses its group role and disables its
383  // 'clip children' attribute.
384  EXPECT_THAT(
385  bridge->accessibility_events,
386  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
387  EXPECT_THAT(bridge->accessibility_events,
388  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
389 }

References CreateSemanticsNode().

◆ TEST() [9/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanReparentNodeWithChild   
)

Definition at line 486 of file accessibility_bridge_unittests.cc.

486  {
487  std::shared_ptr<TestAccessibilityBridge> bridge =
488  std::make_shared<TestAccessibilityBridge>();
489 
490  int32_t root_id = 0;
491  int32_t intermediary1_id = 1;
492  int32_t intermediary2_id = 2;
493  int32_t leaf1_id = 3;
494 
495  std::vector<int32_t> root_children{intermediary1_id, intermediary2_id};
496  std::vector<int32_t> intermediary1_children{leaf1_id};
497  FlutterSemanticsNode2 root =
498  CreateSemanticsNode(root_id, "root", &root_children);
499  FlutterSemanticsNode2 intermediary1 = CreateSemanticsNode(
500  intermediary1_id, "intermediary 1", &intermediary1_children);
501  FlutterSemanticsNode2 intermediary2 =
502  CreateSemanticsNode(intermediary2_id, "intermediary 2");
503  FlutterSemanticsNode2 leaf1 = CreateSemanticsNode(leaf1_id, "leaf 1");
504 
505  bridge->AddFlutterSemanticsNodeUpdate(root);
506  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
507  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
508  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
509  bridge->CommitUpdates();
510  bridge->accessibility_events.clear();
511 
512  // Move intermediary1 from root to intermediary 2.
513  int32_t new_root_children[] = {intermediary2_id};
514  root.child_count = 1;
515  root.children_in_traversal_order = new_root_children;
516 
517  int32_t new_intermediary2_children[] = {intermediary1_id};
518  intermediary2.child_count = 1;
519  intermediary2.children_in_traversal_order = new_intermediary2_children;
520 
521  bridge->AddFlutterSemanticsNodeUpdate(root);
522  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
523  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
524  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
525  bridge->CommitUpdates();
526 
527  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
528  auto intermediary1_node =
529  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary1_id).lock();
530  auto intermediary2_node =
531  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary2_id).lock();
532  auto leaf1_node =
533  bridge->GetFlutterPlatformNodeDelegateFromID(leaf1_id).lock();
534 
535  EXPECT_EQ(root_node->GetChildCount(), 1);
536  EXPECT_EQ(root_node->GetData().child_ids[0], intermediary2_id);
537  EXPECT_EQ(root_node->GetName(), "root");
538 
539  EXPECT_EQ(intermediary2_node->GetChildCount(), 1);
540  EXPECT_EQ(intermediary2_node->GetData().child_ids[0], intermediary1_id);
541  EXPECT_EQ(intermediary2_node->GetName(), "intermediary 2");
542 
543  EXPECT_EQ(intermediary1_node->GetChildCount(), 1);
544  EXPECT_EQ(intermediary1_node->GetData().child_ids[0], leaf1_id);
545  EXPECT_EQ(intermediary1_node->GetName(), "intermediary 1");
546 
547  EXPECT_EQ(leaf1_node->GetChildCount(), 0);
548  EXPECT_EQ(leaf1_node->GetName(), "leaf 1");
549 
550  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
551 
552  EXPECT_THAT(bridge->accessibility_events,
553  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
554  EXPECT_THAT(bridge->accessibility_events,
555  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
556 
557  // Intermediary 2 becomes a parent node. It updates to group role and enables
558  // its 'clip children' attribute.
559  EXPECT_THAT(
560  bridge->accessibility_events,
561  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
562  EXPECT_THAT(bridge->accessibility_events,
563  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
564 }

References CreateSemanticsNode().

◆ TEST() [10/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
CanSetCheckboxChecked   
)

Definition at line 310 of file accessibility_bridge_unittests.cc.

310  {
311  std::shared_ptr<TestAccessibilityBridge> bridge =
312  std::make_shared<TestAccessibilityBridge>();
313  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
314  auto flags = FlutterSemanticsFlags{
315  .is_checked = FlutterCheckState::kFlutterCheckStateTrue,
316  };
317 
318  root.flags2 = &flags;
319  bridge->AddFlutterSemanticsNodeUpdate(root);
320  bridge->CommitUpdates();
321 
322  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
323  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
324  EXPECT_EQ(root_node->GetData().GetCheckedState(),
325  ax::mojom::CheckedState::kTrue);
326 }

References CreateSemanticsNode().

◆ TEST() [11/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
DoesNotAssignEditableRootToSelectableText   
)

Definition at line 250 of file accessibility_bridge_unittests.cc.

250  {
251  std::shared_ptr<TestAccessibilityBridge> bridge =
252  std::make_shared<TestAccessibilityBridge>();
253  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
254  auto flags = FlutterSemanticsFlags{
255  .is_text_field = true,
256  .is_read_only = true,
257  };
258  root.flags2 = &flags;
259 
260  bridge->AddFlutterSemanticsNodeUpdate(root);
261  bridge->CommitUpdates();
262 
263  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
264 
265  EXPECT_FALSE(root_node->GetData().GetBoolAttribute(
266  ax::mojom::BoolAttribute::kEditableRoot));
267 }

References CreateSemanticsNode().

◆ TEST() [12/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
IsSelectedAttribute   
)

Definition at line 595 of file accessibility_bridge_unittests.cc.

595  {
596  std::shared_ptr<TestAccessibilityBridge> bridge =
597  std::make_shared<TestAccessibilityBridge>();
598 
599  std::vector<int32_t> children{1, 2};
600  FlutterSemanticsNode2 node0 = CreateSemanticsNode(0, "node 0", &children);
601  auto flags0 = FlutterSemanticsFlags{
602  .is_selected = FlutterTristate::kFlutterTristateNone,
603  };
604  node0.flags2 = &flags0;
605 
606  FlutterSemanticsNode2 node1 = CreateSemanticsNode(1, "node 1");
607  auto flags1 = FlutterSemanticsFlags{
608  .is_selected = FlutterTristate::kFlutterTristateTrue,
609  };
610  node1.flags2 = &flags1;
611 
612  FlutterSemanticsNode2 node2 = CreateSemanticsNode(2, "node 2");
613  auto flags2 = FlutterSemanticsFlags{
614  .is_selected = FlutterTristate::kFlutterTristateFalse,
615  };
616  node2.flags2 = &flags2;
617 
618  bridge->AddFlutterSemanticsNodeUpdate(node0);
619  bridge->AddFlutterSemanticsNodeUpdate(node1);
620  bridge->AddFlutterSemanticsNodeUpdate(node2);
621  bridge->CommitUpdates();
622 
623  auto delegate0 = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
624  auto delegate1 = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
625  auto delegate2 = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
626 
627  // For kFlutterTristateNone, selected should be false.
628  EXPECT_FALSE(delegate0->GetData().GetBoolAttribute(
629  ax::mojom::BoolAttribute::kSelected));
630  // For kFlutterTristateTrue, selected should be true.
631  EXPECT_TRUE(delegate1->GetData().GetBoolAttribute(
632  ax::mojom::BoolAttribute::kSelected));
633  // For kFlutterTristateFalse, selected should be false.
634  EXPECT_FALSE(delegate2->GetData().GetBoolAttribute(
635  ax::mojom::BoolAttribute::kSelected));
636 }

References CreateSemanticsNode().

◆ TEST() [13/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
LineBreakingObjectTest   
)

Definition at line 576 of file accessibility_bridge_unittests.cc.

576  {
577  std::shared_ptr<TestAccessibilityBridge> bridge =
578  std::make_shared<TestAccessibilityBridge>();
579 
580  const int32_t root_id = 0;
581 
582  FlutterSemanticsNode2 root = CreateSemanticsNode(root_id, "root", {});
583 
584  bridge->AddFlutterSemanticsNodeUpdate(root);
585  bridge->CommitUpdates();
586 
587  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
588  auto root_data = root_node->GetData();
589  EXPECT_TRUE(root_data.HasBoolAttribute(
590  ax::mojom::BoolAttribute::kIsLineBreakingObject));
591  EXPECT_TRUE(root_data.GetBoolAttribute(
592  ax::mojom::BoolAttribute::kIsLineBreakingObject));
593 }

References CreateSemanticsNode().

◆ TEST() [14/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
SliderHasSliderRole   
)

Definition at line 286 of file accessibility_bridge_unittests.cc.

286  {
287  std::shared_ptr<TestAccessibilityBridge> bridge =
288  std::make_shared<TestAccessibilityBridge>();
289  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
290  auto flags = FlutterSemanticsFlags{
291  .is_enabled = FlutterTristate::kFlutterTristateTrue,
292  .is_focused = FlutterTristate::kFlutterTristateFalse,
293  .is_slider = true,
294  };
295 
296  root.flags2 = &flags;
297 
298  bridge->AddFlutterSemanticsNodeUpdate(root);
299  bridge->CommitUpdates();
300 
301  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
302  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSlider);
303 }

References CreateSemanticsNode().

◆ TEST() [15/174]

flutter::testing::TEST ( AccessibilityBridgeTest  ,
SwitchHasSwitchRole   
)

Definition at line 269 of file accessibility_bridge_unittests.cc.

269  {
270  std::shared_ptr<TestAccessibilityBridge> bridge =
271  std::make_shared<TestAccessibilityBridge>();
272  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
273  auto flags = FlutterSemanticsFlags{
274  .is_enabled = FlutterTristate::kFlutterTristateTrue,
275  .is_toggled = FlutterTristate::kFlutterTristateFalse,
276  };
277 
278  root.flags2 = &flags;
279  bridge->AddFlutterSemanticsNodeUpdate(root);
280  bridge->CommitUpdates();
281 
282  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
283  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSwitch);
284 }

References CreateSemanticsNode().

◆ TEST() [16/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
DispatchAccessibilityAction   
)

Definition at line 280 of file accessibility_bridge_windows_unittests.cc.

280  {
281  auto engine = GetTestEngine();
282  FlutterWindowsViewSpy view{
283  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
284  EngineModifier modifier{engine.get()};
285  modifier.SetImplicitView(&view);
286  view.OnUpdateSemanticsEnabled(true);
287 
288  auto bridge = view.accessibility_bridge().lock();
289  PopulateAXTree(bridge);
290 
291  FlutterSemanticsAction actual_action = kFlutterSemanticsActionTap;
292  modifier.embedder_api().SendSemanticsAction = MOCK_ENGINE_PROC(
293  SendSemanticsAction,
294  ([&actual_action](FLUTTER_API_SYMBOL(FlutterEngine) engine,
295  const FlutterSendSemanticsActionInfo* info) {
296  actual_action = info->action;
297  return kSuccess;
298  }));
299 
300  AccessibilityBridgeWindows delegate(&view);
301  delegate.DispatchAccessibilityAction(1, kFlutterSemanticsActionCopy, {});
302  EXPECT_EQ(actual_action, kFlutterSemanticsActionCopy);
303 }

References flutter::AccessibilityBridgeWindows::DispatchAccessibilityAction().

◆ TEST() [17/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
GetParent   
)

Definition at line 248 of file accessibility_bridge_windows_unittests.cc.

248  {
249  auto engine = GetTestEngine();
250  FlutterWindowsViewSpy view{
251  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
252  EngineModifier modifier{engine.get()};
253  modifier.SetImplicitView(&view);
254  view.OnUpdateSemanticsEnabled(true);
255 
256  auto bridge = view.accessibility_bridge().lock();
257  PopulateAXTree(bridge);
258 
259  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
260  auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
261  EXPECT_EQ(node0_delegate->GetNativeViewAccessible(),
262  node1_delegate->GetParent());
263 }

◆ TEST() [18/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
GetParentOnRootRetunsNullptr   
)

Definition at line 265 of file accessibility_bridge_windows_unittests.cc.

265  {
266  auto engine = GetTestEngine();
267  FlutterWindowsViewSpy view{
268  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
269  EngineModifier modifier{engine.get()};
270  modifier.SetImplicitView(&view);
271  view.OnUpdateSemanticsEnabled(true);
272 
273  auto bridge = view.accessibility_bridge().lock();
274  PopulateAXTree(bridge);
275 
276  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
277  ASSERT_TRUE(node0_delegate->GetParent() == nullptr);
278 }

◆ TEST() [19/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityEventAlert   
)

Definition at line 305 of file accessibility_bridge_windows_unittests.cc.

305  {
306  ExpectWinEventFromAXEvent(0, ui::AXEventGenerator::Event::ALERT,
307  ax::mojom::Event::kAlert);
308 }

◆ TEST() [20/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityEventChildrenChanged   
)

Definition at line 310 of file accessibility_bridge_windows_unittests.cc.

310  {
311  ExpectWinEventFromAXEvent(0, ui::AXEventGenerator::Event::CHILDREN_CHANGED,
312  ax::mojom::Event::kChildrenChanged);
313 }

◆ TEST() [21/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityEventFocusChanged   
)

Definition at line 315 of file accessibility_bridge_windows_unittests.cc.

315  {
316  auto engine = GetTestEngine();
317  FlutterWindowsViewSpy view{
318  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
319  EngineModifier modifier{engine.get()};
320  modifier.SetImplicitView(&view);
321  view.OnUpdateSemanticsEnabled(true);
322 
323  auto bridge = GetAccessibilityBridgeSpy(view);
324  PopulateAXTree(bridge);
325 
326  bridge->ResetRecords();
327  bridge->OnAccessibilityEvent({AXNodeFromID(bridge, 1),
328  {ui::AXEventGenerator::Event::FOCUS_CHANGED,
329  ax::mojom::EventFrom::kNone,
330  {}}});
331  ASSERT_EQ(bridge->dispatched_events().size(), 1);
332  EXPECT_EQ(bridge->dispatched_events()[0].event_type,
333  ax::mojom::Event::kFocus);
334 
335  ASSERT_EQ(bridge->focused_nodes().size(), 1);
336  EXPECT_EQ(bridge->focused_nodes()[0], 1);
337 }

◆ TEST() [22/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityEventIgnoredChanged   
)

Definition at line 339 of file accessibility_bridge_windows_unittests.cc.

339  {
340  // Static test nodes with no text, hint, or scrollability are ignored.
341  ExpectWinEventFromAXEvent(4, ui::AXEventGenerator::Event::IGNORED_CHANGED,
342  ax::mojom::Event::kHide);
343 }

◆ TEST() [23/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityHScrollPosChanged   
)

Definition at line 361 of file accessibility_bridge_windows_unittests.cc.

361  {
362  ExpectWinEventFromAXEvent(
363  1, ui::AXEventGenerator::Event::SCROLL_HORIZONTAL_POSITION_CHANGED,
364  ax::mojom::Event::kScrollPositionChanged);
365 }

◆ TEST() [24/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityImageAnnotationChanged   
)

Definition at line 345 of file accessibility_bridge_windows_unittests.cc.

345  {
346  ExpectWinEventFromAXEvent(
347  1, ui::AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED,
348  ax::mojom::Event::kTextChanged);
349 }

◆ TEST() [25/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityLiveRegionChanged   
)

Definition at line 351 of file accessibility_bridge_windows_unittests.cc.

351  {
352  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::LIVE_REGION_CHANGED,
353  ax::mojom::Event::kLiveRegionChanged);
354 }

◆ TEST() [26/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityNameChanged   
)

Definition at line 356 of file accessibility_bridge_windows_unittests.cc.

356  {
357  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::NAME_CHANGED,
358  ax::mojom::Event::kTextChanged);
359 }

◆ TEST() [27/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilitySelectedChanged   
)

Definition at line 373 of file accessibility_bridge_windows_unittests.cc.

373  {
374  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::SELECTED_CHANGED,
375  ax::mojom::Event::kValueChanged);
376 }

◆ TEST() [28/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilitySelectedChildrenChanged   
)

Definition at line 378 of file accessibility_bridge_windows_unittests.cc.

378  {
379  ExpectWinEventFromAXEvent(
380  2, ui::AXEventGenerator::Event::SELECTED_CHILDREN_CHANGED,
381  ax::mojom::Event::kSelectedChildrenChanged);
382 }

◆ TEST() [29/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityStateChanged   
)

Definition at line 394 of file accessibility_bridge_windows_unittests.cc.

394  {
395  ExpectWinEventFromAXEvent(
396  1, ui::AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
397  ax::mojom::Event::kStateChanged);
398 }

◆ TEST() [30/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilitySubtreeCreated   
)

Definition at line 384 of file accessibility_bridge_windows_unittests.cc.

384  {
385  ExpectWinEventFromAXEvent(0, ui::AXEventGenerator::Event::SUBTREE_CREATED,
386  ax::mojom::Event::kShow);
387 }

◆ TEST() [31/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityValueChanged   
)

Definition at line 389 of file accessibility_bridge_windows_unittests.cc.

389  {
390  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::VALUE_CHANGED,
391  ax::mojom::Event::kValueChanged);
392 }

◆ TEST() [32/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnAccessibilityVScrollPosChanged   
)

Definition at line 367 of file accessibility_bridge_windows_unittests.cc.

367  {
368  ExpectWinEventFromAXEvent(
369  1, ui::AXEventGenerator::Event::SCROLL_VERTICAL_POSITION_CHANGED,
370  ax::mojom::Event::kScrollPositionChanged);
371 }

◆ TEST() [33/174]

flutter::testing::TEST ( AccessibilityBridgeWindows  ,
OnDocumentSelectionChanged   
)

Definition at line 400 of file accessibility_bridge_windows_unittests.cc.

400  {
401  ExpectWinEventFromAXEventOnFocusNode(
402  1, ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED,
403  ax::mojom::Event::kDocumentSelectionChanged, 2);
404 }

◆ TEST() [34/174]

flutter::testing::TEST ( DirectManipulationTest  ,
TestGesture   
)

Definition at line 141 of file direct_manipulation_unittests.cc.

141  {
142  MockIDirectManipulationContent content;
143  MockWindowBindingHandlerDelegate delegate;
144  MockIDirectManipulationViewport viewport;
145  const float scale = 1.5;
146  const float pan_x = 32.0;
147  const float pan_y = 16.0;
148  const int DISPLAY_WIDTH = 800;
149  const int DISPLAY_HEIGHT = 600;
150  auto owner = std::make_unique<DirectManipulationOwner>(nullptr);
151  owner->SetBindingHandlerDelegate(&delegate);
152  auto handler =
153  fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
154  int32_t device_id = (int32_t)reinterpret_cast<int64_t>(handler.get());
155  EXPECT_CALL(viewport, GetPrimaryContent(_, _))
156  .WillOnce([&content](REFIID in, void** out) {
157  *out = &content;
158  return S_OK;
159  })
160  .RetiresOnSaturation();
161  EXPECT_CALL(content, GetContentTransform(_, 6))
162  .WillOnce([scale](float* transform, DWORD size) {
163  transform[0] = 1.0f;
164  transform[4] = 0.0;
165  transform[5] = 0.0;
166  return S_OK;
167  })
168  .RetiresOnSaturation();
169  EXPECT_CALL(delegate, OnPointerPanZoomStart(device_id));
170  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
171  DIRECTMANIPULATION_RUNNING,
172  DIRECTMANIPULATION_READY);
173  EXPECT_CALL(content, GetContentTransform(_, 6))
174  .WillOnce([scale, pan_x, pan_y](float* transform, DWORD size) {
175  transform[0] = scale;
176  transform[4] = pan_x;
177  transform[5] = pan_y;
178  return S_OK;
179  });
180  EXPECT_CALL(delegate,
181  OnPointerPanZoomUpdate(device_id, pan_x, pan_y, scale, 0));
182  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
183  (IDirectManipulationContent*)&content);
184  EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
185  EXPECT_CALL(viewport, GetViewportRect(_))
186  .WillOnce([DISPLAY_WIDTH, DISPLAY_HEIGHT](RECT* rect) {
187  rect->left = 0;
188  rect->top = 0;
189  rect->right = DISPLAY_WIDTH;
190  rect->bottom = DISPLAY_HEIGHT;
191  return S_OK;
192  });
193  EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, false))
194  .WillOnce(::testing::Return(S_OK));
195  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
196  DIRECTMANIPULATION_INERTIA,
197  DIRECTMANIPULATION_RUNNING);
198  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
199  DIRECTMANIPULATION_READY,
200  DIRECTMANIPULATION_INERTIA);
201 }
union flutter::testing::@104::KeyboardChange::@0 content

References content.

◆ TEST() [35/174]

flutter::testing::TEST ( DirectManipulationTest  ,
TestGestureWithInitialData   
)

Definition at line 393 of file direct_manipulation_unittests.cc.

393  {
394  MockIDirectManipulationContent content;
395  MockWindowBindingHandlerDelegate delegate;
396  MockIDirectManipulationViewport viewport;
397  const float scale = 1.5;
398  const float pan_x = 32.0;
399  const float pan_y = 16.0;
400  const int DISPLAY_WIDTH = 800;
401  const int DISPLAY_HEIGHT = 600;
402  auto owner = std::make_unique<DirectManipulationOwner>(nullptr);
403  owner->SetBindingHandlerDelegate(&delegate);
404  auto handler =
405  fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
406  int32_t device_id = (int32_t)reinterpret_cast<int64_t>(handler.get());
407  EXPECT_CALL(viewport, GetPrimaryContent(_, _))
408  .WillOnce([&content](REFIID in, void** out) {
409  *out = &content;
410  return S_OK;
411  })
412  .RetiresOnSaturation();
413  EXPECT_CALL(content, GetContentTransform(_, 6))
414  .WillOnce([scale](float* transform, DWORD size) {
415  transform[0] = 2.0f;
416  transform[4] = 234.0;
417  transform[5] = 345.0;
418  return S_OK;
419  })
420  .RetiresOnSaturation();
421  EXPECT_CALL(delegate, OnPointerPanZoomStart(device_id));
422  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
423  DIRECTMANIPULATION_RUNNING,
424  DIRECTMANIPULATION_READY);
425  EXPECT_CALL(content, GetContentTransform(_, 6))
426  .WillOnce([scale, pan_x, pan_y](float* transform, DWORD size) {
427  transform[0] = 2.0f * scale;
428  transform[4] = 234.0 + pan_x;
429  transform[5] = 345.0 + pan_y;
430  return S_OK;
431  });
432  EXPECT_CALL(delegate,
433  OnPointerPanZoomUpdate(device_id, pan_x, pan_y, scale, 0));
434  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
435  (IDirectManipulationContent*)&content);
436  EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
437  EXPECT_CALL(viewport, GetViewportRect(_))
438  .WillOnce([DISPLAY_WIDTH, DISPLAY_HEIGHT](RECT* rect) {
439  rect->left = 0;
440  rect->top = 0;
441  rect->right = DISPLAY_WIDTH;
442  rect->bottom = DISPLAY_HEIGHT;
443  return S_OK;
444  });
445  EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, false))
446  .WillOnce(::testing::Return(S_OK));
447  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
448  DIRECTMANIPULATION_INERTIA,
449  DIRECTMANIPULATION_RUNNING);
450  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
451  DIRECTMANIPULATION_READY,
452  DIRECTMANIPULATION_INERTIA);
453 }

References content.

◆ TEST() [36/174]

flutter::testing::TEST ( DirectManipulationTest  ,
TestInertiaCamcelNotSentAtInertiaEnd   
)

Definition at line 339 of file direct_manipulation_unittests.cc.

339  {
340  MockIDirectManipulationContent content;
341  MockWindowBindingHandlerDelegate delegate;
342  MockIDirectManipulationViewport viewport;
343  const int DISPLAY_WIDTH = 800;
344  const int DISPLAY_HEIGHT = 600;
345  auto owner = std::make_unique<DirectManipulationOwner>(nullptr);
346  owner->SetBindingHandlerDelegate(&delegate);
347  auto handler =
348  fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
349  int32_t device_id = (int32_t)reinterpret_cast<int64_t>(handler.get());
350  // No need to mock the actual gesture, just start at the end.
351  EXPECT_CALL(viewport, GetViewportRect(_))
352  .WillOnce([DISPLAY_WIDTH, DISPLAY_HEIGHT](RECT* rect) {
353  rect->left = 0;
354  rect->top = 0;
355  rect->right = DISPLAY_WIDTH;
356  rect->bottom = DISPLAY_HEIGHT;
357  return S_OK;
358  });
359  EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, false))
360  .WillOnce(::testing::Return(S_OK));
361  EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
362  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
363  DIRECTMANIPULATION_INERTIA,
364  DIRECTMANIPULATION_RUNNING);
365  // Have no change in pan between events.
366  EXPECT_CALL(content, GetContentTransform(_, 6))
367  .WillOnce([](float* transform, DWORD size) {
368  transform[0] = 1;
369  transform[4] = 0;
370  transform[5] = 140;
371  return S_OK;
372  });
373  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
374  (IDirectManipulationContent*)&content);
375  EXPECT_CALL(content, GetContentTransform(_, 6))
376  .WillOnce([](float* transform, DWORD size) {
377  transform[0] = 1;
378  transform[4] = 0;
379  transform[5] = 140;
380  return S_OK;
381  });
382  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
383  (IDirectManipulationContent*)&content);
384  // OnScrollInertiaCancel should not be called.
385  EXPECT_CALL(delegate, OnScrollInertiaCancel(device_id)).Times(0);
386  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
387  DIRECTMANIPULATION_READY,
388  DIRECTMANIPULATION_INERTIA);
389 }

References content.

◆ TEST() [37/174]

flutter::testing::TEST ( DirectManipulationTest  ,
TestInertiaCancelSentForUserCancel   
)

Definition at line 286 of file direct_manipulation_unittests.cc.

286  {
287  MockIDirectManipulationContent content;
288  MockWindowBindingHandlerDelegate delegate;
289  MockIDirectManipulationViewport viewport;
290  const int DISPLAY_WIDTH = 800;
291  const int DISPLAY_HEIGHT = 600;
292  auto owner = std::make_unique<DirectManipulationOwner>(nullptr);
293  owner->SetBindingHandlerDelegate(&delegate);
294  auto handler =
295  fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
296  int32_t device_id = (int32_t)reinterpret_cast<int64_t>(handler.get());
297  // No need to mock the actual gesture, just start at the end.
298  EXPECT_CALL(viewport, GetViewportRect(_))
299  .WillOnce([DISPLAY_WIDTH, DISPLAY_HEIGHT](RECT* rect) {
300  rect->left = 0;
301  rect->top = 0;
302  rect->right = DISPLAY_WIDTH;
303  rect->bottom = DISPLAY_HEIGHT;
304  return S_OK;
305  });
306  EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, false))
307  .WillOnce(::testing::Return(S_OK));
308  EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
309  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
310  DIRECTMANIPULATION_INERTIA,
311  DIRECTMANIPULATION_RUNNING);
312  // Have pan_y change by 10 between inertia updates.
313  EXPECT_CALL(content, GetContentTransform(_, 6))
314  .WillOnce([](float* transform, DWORD size) {
315  transform[0] = 1;
316  transform[4] = 0;
317  transform[5] = 100;
318  return S_OK;
319  });
320  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
321  (IDirectManipulationContent*)&content);
322  EXPECT_CALL(content, GetContentTransform(_, 6))
323  .WillOnce([](float* transform, DWORD size) {
324  transform[0] = 1;
325  transform[4] = 0;
326  transform[5] = 110;
327  return S_OK;
328  });
329  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
330  (IDirectManipulationContent*)&content);
331  // This looks like an interruption in the middle of synthetic inertia because
332  // of user input.
333  EXPECT_CALL(delegate, OnScrollInertiaCancel(device_id));
334  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
335  DIRECTMANIPULATION_READY,
336  DIRECTMANIPULATION_INERTIA);
337 }

References content.

◆ TEST() [38/174]

flutter::testing::TEST ( DirectManipulationTest  ,
TestRounding   
)

Definition at line 204 of file direct_manipulation_unittests.cc.

204  {
205  MockIDirectManipulationContent content;
206  MockWindowBindingHandlerDelegate delegate;
207  MockIDirectManipulationViewport viewport;
208  const float scale = 1.5;
209  const int DISPLAY_WIDTH = 800;
210  const int DISPLAY_HEIGHT = 600;
211  auto owner = std::make_unique<DirectManipulationOwner>(nullptr);
212  owner->SetBindingHandlerDelegate(&delegate);
213  auto handler =
214  fml::MakeRefCounted<DirectManipulationEventHandler>(owner.get());
215  int32_t device_id = (int32_t)reinterpret_cast<int64_t>(handler.get());
216  EXPECT_CALL(viewport, GetPrimaryContent(_, _))
217  .WillOnce([&content](REFIID in, void** out) {
218  *out = &content;
219  return S_OK;
220  })
221  .RetiresOnSaturation();
222  EXPECT_CALL(content, GetContentTransform(_, 6))
223  .WillOnce([scale](float* transform, DWORD size) {
224  transform[0] = 1.0f;
225  transform[4] = 0.0;
226  transform[5] = 0.0;
227  return S_OK;
228  })
229  .RetiresOnSaturation();
230  EXPECT_CALL(delegate, OnPointerPanZoomStart(device_id));
231  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
232  DIRECTMANIPULATION_RUNNING,
233  DIRECTMANIPULATION_READY);
234  EXPECT_CALL(content, GetContentTransform(_, 6))
235  .WillOnce([scale](float* transform, DWORD size) {
236  transform[0] = 1.5000001f;
237  transform[4] = 4.0;
238  transform[5] = 0.0;
239  return S_OK;
240  })
241  .RetiresOnSaturation();
242  EXPECT_CALL(delegate,
243  OnPointerPanZoomUpdate(device_id, 4.0, 0, 1.5000001f, 0))
244  .Times(0);
245  EXPECT_CALL(delegate, OnPointerPanZoomUpdate(device_id, 4.0, 0, 1.5f, 0))
246  .Times(1)
247  .RetiresOnSaturation();
248  EXPECT_CALL(content, GetContentTransform(_, 6))
249  .WillOnce([scale](float* transform, DWORD size) {
250  transform[0] = 1.50000065f;
251  transform[4] = 2.0;
252  transform[5] = 0.0;
253  return S_OK;
254  })
255  .RetiresOnSaturation();
256  EXPECT_CALL(delegate,
257  OnPointerPanZoomUpdate(device_id, 2.0, 0, 1.50000065f, 0))
258  .Times(0);
259  EXPECT_CALL(delegate,
260  OnPointerPanZoomUpdate(device_id, 2.0, 0, 1.50000047f, 0))
261  .Times(1)
262  .RetiresOnSaturation();
263  EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
264  EXPECT_CALL(viewport, GetViewportRect(_))
265  .WillOnce([DISPLAY_WIDTH, DISPLAY_HEIGHT](RECT* rect) {
266  rect->left = 0;
267  rect->top = 0;
268  rect->right = DISPLAY_WIDTH;
269  rect->bottom = DISPLAY_HEIGHT;
270  return S_OK;
271  });
272  EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, false))
273  .WillOnce(::testing::Return(S_OK));
274  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
275  (IDirectManipulationContent*)&content);
276  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
277  (IDirectManipulationContent*)&content);
278  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
279  DIRECTMANIPULATION_INERTIA,
280  DIRECTMANIPULATION_RUNNING);
281  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
282  DIRECTMANIPULATION_READY,
283  DIRECTMANIPULATION_INERTIA);
284 }

References content.

◆ TEST() [39/174]

flutter::testing::TEST ( DpiUtilsTest  ,
NonZero   
)

Definition at line 13 of file dpi_utils_unittests.cc.

13  {
14  ASSERT_GT(GetDpiForHWND(nullptr), 0);
15  ASSERT_GT(GetDpiForMonitor(nullptr), 0);
16 };
UINT GetDpiForHWND(HWND hwnd)
Definition: dpi_utils.cc:128
UINT GetDpiForMonitor(HMONITOR monitor)
Definition: dpi_utils.cc:132

References flutter::GetDpiForHWND(), and flutter::GetDpiForMonitor().

◆ TEST() [40/174]

flutter::testing::TEST ( DpiUtilsTest  ,
NullHwndUsesPrimaryMonitor   
)

Definition at line 18 of file dpi_utils_unittests.cc.

18  {
19  const POINT target_point = {0, 0};
20  HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTOPRIMARY);
21  ASSERT_EQ(GetDpiForHWND(nullptr), GetDpiForMonitor(monitor));
22 };

References flutter::GetDpiForHWND(), and flutter::GetDpiForMonitor().

◆ TEST() [41/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canCalculateBoundsCorrectly   
)

Definition at line 121 of file flutter_platform_node_delegate_unittests.cc.

121  {
122  std::shared_ptr<TestAccessibilityBridge> bridge =
123  std::make_shared<TestAccessibilityBridge>();
124  FlutterSemanticsFlags flags = FlutterSemanticsFlags{0};
125  FlutterSemanticsNode2 root;
126  root.id = 0;
127  root.label = "root";
128  root.hint = "";
129  root.value = "";
130  root.increased_value = "";
131  root.decreased_value = "";
132  root.tooltip = "";
133  root.child_count = 1;
134  root.flags2 = &flags;
135  int32_t children[] = {1};
136  root.children_in_traversal_order = children;
137  root.custom_accessibility_actions_count = 0;
138  root.identifier = "";
139  root.rect = {0, 0, 100, 100}; // LTRB
140  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
141  bridge->AddFlutterSemanticsNodeUpdate(root);
142 
143  FlutterSemanticsNode2 child1;
144  child1.id = 1;
145  child1.label = "child 1";
146  child1.hint = "";
147  child1.value = "";
148  child1.increased_value = "";
149  child1.decreased_value = "";
150  child1.tooltip = "";
151  child1.child_count = 0;
152  child1.flags2 = &flags;
153  child1.custom_accessibility_actions_count = 0;
154  child1.identifier = "";
155  child1.rect = {0, 0, 50, 50}; // LTRB
156  child1.transform = {0.5, 0, 0, 0, 0.5, 0, 0, 0, 1};
157  bridge->AddFlutterSemanticsNodeUpdate(child1);
158 
159  bridge->CommitUpdates();
160  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
161  ui::AXOffscreenResult result;
162  gfx::Rect bounds =
163  child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
164  ui::AXClippingBehavior::kClipped, &result);
165  EXPECT_EQ(bounds.x(), 0);
166  EXPECT_EQ(bounds.y(), 0);
167  EXPECT_EQ(bounds.width(), 25);
168  EXPECT_EQ(bounds.height(), 25);
169  EXPECT_EQ(result, ui::AXOffscreenResult::kOnscreen);
170 }

◆ TEST() [42/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canCalculateOffScreenBoundsCorrectly   
)

Definition at line 172 of file flutter_platform_node_delegate_unittests.cc.

172  {
173  std::shared_ptr<TestAccessibilityBridge> bridge =
174  std::make_shared<TestAccessibilityBridge>();
175  FlutterSemanticsFlags flags = FlutterSemanticsFlags{0};
176  FlutterSemanticsNode2 root;
177  root.id = 0;
178  root.label = "root";
179  root.hint = "";
180  root.value = "";
181  root.increased_value = "";
182  root.decreased_value = "";
183  root.tooltip = "";
184  root.child_count = 1;
185  root.flags2 = &flags;
186  int32_t children[] = {1};
187  root.children_in_traversal_order = children;
188  root.custom_accessibility_actions_count = 0;
189  root.identifier = "";
190  root.rect = {0, 0, 100, 100}; // LTRB
191  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
192  bridge->AddFlutterSemanticsNodeUpdate(root);
193 
194  FlutterSemanticsNode2 child1;
195  child1.id = 1;
196  child1.label = "child 1";
197  child1.hint = "";
198  child1.value = "";
199  child1.increased_value = "";
200  child1.decreased_value = "";
201  child1.tooltip = "";
202  child1.child_count = 0;
203  child1.flags2 = &flags;
204  child1.custom_accessibility_actions_count = 0;
205  child1.identifier = "";
206  child1.rect = {90, 90, 100, 100}; // LTRB
207  child1.transform = {2, 0, 0, 0, 2, 0, 0, 0, 1};
208  bridge->AddFlutterSemanticsNodeUpdate(child1);
209 
210  bridge->CommitUpdates();
211  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
212  ui::AXOffscreenResult result;
213  gfx::Rect bounds =
214  child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
215  ui::AXClippingBehavior::kUnclipped, &result);
216  EXPECT_EQ(bounds.x(), 180);
217  EXPECT_EQ(bounds.y(), 180);
218  EXPECT_EQ(bounds.width(), 20);
219  EXPECT_EQ(bounds.height(), 20);
220  EXPECT_EQ(result, ui::AXOffscreenResult::kOffscreen);
221 }

◆ TEST() [43/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canGetAXNode   
)

Definition at line 91 of file flutter_platform_node_delegate_unittests.cc.

91  {
92  // Set up a flutter accessibility node.
93  std::shared_ptr<TestAccessibilityBridge> bridge =
94  std::make_shared<TestAccessibilityBridge>();
95  FlutterSemanticsNode2 root;
96  root.id = 0;
97  FlutterSemanticsFlags flags = FlutterSemanticsFlags{0};
98  flags.is_text_field = true;
99  root.flags2 = &flags;
100  // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
101  root.actions = static_cast<FlutterSemanticsAction>(0);
102  root.text_selection_base = -1;
103  root.text_selection_extent = -1;
104  root.label = "root";
105  root.hint = "";
106  root.value = "";
107  root.increased_value = "";
108  root.decreased_value = "";
109  root.tooltip = "";
110  root.child_count = 0;
111  root.custom_accessibility_actions_count = 0;
112  root.identifier = "";
113  bridge->AddFlutterSemanticsNodeUpdate(root);
114 
115  bridge->CommitUpdates();
116 
117  auto accessibility = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
118  EXPECT_EQ(accessibility->GetData().id, 0);
119 }

◆ TEST() [44/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canGetFromNodeID   
)

Definition at line 300 of file flutter_platform_node_delegate_unittests.cc.

300  {
301  std::shared_ptr<TestAccessibilityBridge> bridge =
302  std::make_shared<TestAccessibilityBridge>();
303  FlutterSemanticsFlags flags = FlutterSemanticsFlags{0};
304  FlutterSemanticsNode2 root;
305  root.id = 0;
306  root.label = "root";
307  root.hint = "";
308  root.value = "";
309  root.increased_value = "";
310  root.decreased_value = "";
311  root.tooltip = "";
312  root.child_count = 1;
313  root.flags2 = &flags;
314  int32_t children[] = {1};
315  root.children_in_traversal_order = children;
316  root.custom_accessibility_actions_count = 0;
317  root.identifier = "";
318  bridge->AddFlutterSemanticsNodeUpdate(root);
319 
320  FlutterSemanticsNode2 child1;
321  child1.id = 1;
322  child1.label = "child 1";
323  child1.hint = "";
324  child1.value = "";
325  child1.increased_value = "";
326  child1.decreased_value = "";
327  child1.tooltip = "";
328  child1.child_count = 0;
329  child1.flags2 = &flags;
330  child1.custom_accessibility_actions_count = 0;
331  child1.identifier = "";
332  bridge->AddFlutterSemanticsNodeUpdate(child1);
333 
334  bridge->CommitUpdates();
335  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
336  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
337  auto node_by_id = root_node->GetFromNodeID(1);
338  EXPECT_EQ(child1_node->GetPlatformNode(), node_by_id);
339 }

◆ TEST() [45/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canPerfomActions   
)

Definition at line 43 of file flutter_platform_node_delegate_unittests.cc.

43  {
44  std::shared_ptr<TestAccessibilityBridge> bridge =
45  std::make_shared<TestAccessibilityBridge>();
46  FlutterSemanticsNode2 root;
47  root.id = 0;
48  FlutterSemanticsFlags flags = FlutterSemanticsFlags{0};
49  flags.is_text_field = true;
50  root.flags2 = &flags;
51  // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
52  root.actions = static_cast<FlutterSemanticsAction>(0);
53  root.text_selection_base = -1;
54  root.text_selection_extent = -1;
55  root.label = "root";
56  root.hint = "";
57  root.value = "";
58  root.increased_value = "";
59  root.decreased_value = "";
60  root.tooltip = "";
61  root.child_count = 0;
62  root.custom_accessibility_actions_count = 0;
63  root.identifier = "";
64  bridge->AddFlutterSemanticsNodeUpdate(root);
65 
66  bridge->CommitUpdates();
67 
68  auto accessibility = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
69  // Performs an AXAction.
70  ui::AXActionData action_data;
71  action_data.action = ax::mojom::Action::kDoDefault;
72  accessibility->AccessibilityPerformAction(action_data);
73  EXPECT_EQ(bridge->performed_actions.size(), size_t{1});
74  EXPECT_EQ(bridge->performed_actions[0],
75  FlutterSemanticsAction::kFlutterSemanticsActionTap);
76 
77  action_data.action = ax::mojom::Action::kFocus;
78  accessibility->AccessibilityPerformAction(action_data);
79  EXPECT_EQ(bridge->performed_actions.size(), size_t{2});
80  EXPECT_EQ(
81  bridge->performed_actions[1],
82  FlutterSemanticsAction::kFlutterSemanticsActionDidGainAccessibilityFocus);
83 
84  action_data.action = ax::mojom::Action::kScrollToMakeVisible;
85  accessibility->AccessibilityPerformAction(action_data);
86  EXPECT_EQ(bridge->performed_actions.size(), size_t{3});
87  EXPECT_EQ(bridge->performed_actions[2],
88  FlutterSemanticsAction::kFlutterSemanticsActionShowOnScreen);
89 }

◆ TEST() [46/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
canUseOwnerBridge   
)

Definition at line 223 of file flutter_platform_node_delegate_unittests.cc.

223  {
224  std::shared_ptr<TestAccessibilityBridge> bridge =
225  std::make_shared<TestAccessibilityBridge>();
226  FlutterSemanticsFlags flags = FlutterSemanticsFlags{0};
227  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
228  root.label = "root";
229  root.hint = "";
230  root.value = "";
231  root.increased_value = "";
232  root.decreased_value = "";
233  root.tooltip = "";
234  root.heading_level = 0;
235  root.child_count = 1;
236  root.flags2 = &flags;
237  int32_t children[] = {1};
238  root.children_in_traversal_order = children;
239  root.custom_accessibility_actions_count = 0;
240  root.identifier = "";
241  root.rect = {0, 0, 100, 100}; // LTRB
242  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
243  bridge->AddFlutterSemanticsNodeUpdate(root);
244 
245  FlutterSemanticsNode2 child1{sizeof(FlutterSemanticsNode2), 1};
246  child1.label = "child 1";
247  child1.hint = "";
248  child1.value = "";
249  child1.increased_value = "";
250  child1.decreased_value = "";
251  child1.tooltip = "";
252  child1.heading_level = 0;
253  child1.child_count = 0;
254  child1.flags2 = &flags;
255  child1.custom_accessibility_actions_count = 0;
256  child1.identifier = "";
257  child1.rect = {0, 0, 50, 50}; // LTRB
258  child1.transform = {0.5, 0, 0, 0, 0.5, 0, 0, 0, 1};
259  bridge->AddFlutterSemanticsNodeUpdate(child1);
260 
261  bridge->CommitUpdates();
262  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
263  auto owner_bridge = child1_node->GetOwnerBridge().lock();
264 
265  bool result = false;
266  gfx::RectF bounds = owner_bridge->RelativeToGlobalBounds(
267  child1_node->GetAXNode(), result, true);
268  EXPECT_EQ(bounds.x(), 0);
269  EXPECT_EQ(bounds.y(), 0);
270  EXPECT_EQ(bounds.width(), 25);
271  EXPECT_EQ(bounds.height(), 25);
272  EXPECT_EQ(result, false);
273 }

◆ TEST() [47/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
NodeDelegateHasUniqueId   
)

Definition at line 15 of file flutter_platform_node_delegate_unittests.cc.

15  {
16  std::shared_ptr<TestAccessibilityBridge> bridge =
17  std::make_shared<TestAccessibilityBridge>();
18 
19  // Add node 0: root.
20  FlutterSemanticsNode2 node0{sizeof(FlutterSemanticsNode2), 0};
21  std::vector<int32_t> node0_children{1};
22  FlutterSemanticsFlags emptyFlags = FlutterSemanticsFlags{};
23  node0.child_count = node0_children.size();
24  node0.children_in_traversal_order = node0_children.data();
25  node0.children_in_hit_test_order = node0_children.data();
26  node0.flags2 = &emptyFlags;
27 
28  // Add node 1: text child of node 0.
29  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
30  node1.label = "prefecture";
31  node1.value = "Kyoto";
32  node1.flags2 = &emptyFlags;
33 
34  bridge->AddFlutterSemanticsNodeUpdate(node0);
35  bridge->AddFlutterSemanticsNodeUpdate(node1);
36  bridge->CommitUpdates();
37 
38  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
39  auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
40  EXPECT_TRUE(node0_delegate->GetUniqueId() != node1_delegate->GetUniqueId());
41 }

◆ TEST() [48/174]

flutter::testing::TEST ( FlutterPlatformNodeDelegateTest  ,
selfIsLowestPlatformAncestor   
)

Definition at line 275 of file flutter_platform_node_delegate_unittests.cc.

275  {
276  std::shared_ptr<TestAccessibilityBridge> bridge =
277  std::make_shared<TestAccessibilityBridge>();
278  FlutterSemanticsFlags flags = FlutterSemanticsFlags{0};
279  FlutterSemanticsNode2 root;
280  root.id = 0;
281  root.label = "root";
282  root.hint = "";
283  root.value = "";
284  root.increased_value = "";
285  root.decreased_value = "";
286  root.tooltip = "";
287  root.child_count = 0;
288  root.flags2 = &flags;
289  root.children_in_traversal_order = nullptr;
290  root.custom_accessibility_actions_count = 0;
291  root.identifier = "";
292  bridge->AddFlutterSemanticsNodeUpdate(root);
293 
294  bridge->CommitUpdates();
295  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
296  auto lowest_platform_ancestor = root_node->GetLowestPlatformAncestor();
297  EXPECT_EQ(root_node->GetNativeViewAccessible(), lowest_platform_ancestor);
298 }

◆ TEST() [49/174]

flutter::testing::TEST ( FlutterProjectBundle  ,
BasicPropertiesAbsolutePaths   
)

Definition at line 11 of file flutter_project_bundle_unittests.cc.

11  {
12  FlutterDesktopEngineProperties properties = {};
13  properties.assets_path = L"C:\\foo\\flutter_assets";
14  properties.icu_data_path = L"C:\\foo\\icudtl.dat";
15 
16  FlutterProjectBundle project(properties);
17 
18  EXPECT_TRUE(project.HasValidPaths());
19  EXPECT_EQ(project.assets_path().string(), "C:\\foo\\flutter_assets");
20  EXPECT_EQ(project.icu_path().string(), "C:\\foo\\icudtl.dat");
21 }

References flutter::FlutterProjectBundle::assets_path(), FlutterDesktopEngineProperties::assets_path, flutter::FlutterProjectBundle::HasValidPaths(), FlutterDesktopEngineProperties::icu_data_path, and flutter::FlutterProjectBundle::icu_path().

◆ TEST() [50/174]

flutter::testing::TEST ( FlutterProjectBundle  ,
BasicPropertiesRelativePaths   
)

Definition at line 23 of file flutter_project_bundle_unittests.cc.

23  {
24  FlutterDesktopEngineProperties properties = {};
25  properties.assets_path = L"foo\\flutter_assets";
26  properties.icu_data_path = L"foo\\icudtl.dat";
27 
28  FlutterProjectBundle project(properties);
29 
30  EXPECT_TRUE(project.HasValidPaths());
31  EXPECT_TRUE(project.assets_path().is_absolute());
32  EXPECT_EQ(project.assets_path().filename().string(), "flutter_assets");
33  EXPECT_TRUE(project.icu_path().is_absolute());
34  EXPECT_EQ(project.icu_path().filename().string(), "icudtl.dat");
35 }

References flutter::FlutterProjectBundle::assets_path(), FlutterDesktopEngineProperties::assets_path, flutter::FlutterProjectBundle::HasValidPaths(), FlutterDesktopEngineProperties::icu_data_path, and flutter::FlutterProjectBundle::icu_path().

◆ TEST() [51/174]

flutter::testing::TEST ( FlutterProjectBundle  ,
DartEntrypointArguments   
)

Definition at line 50 of file flutter_project_bundle_unittests.cc.

50  {
51  FlutterDesktopEngineProperties properties = {};
52  properties.assets_path = L"foo\\flutter_assets";
53  properties.icu_data_path = L"foo\\icudtl.dat";
54 
55  std::vector<const char*> test_arguments = {"arg1", "arg2"};
56  properties.dart_entrypoint_argc = test_arguments.size();
57  properties.dart_entrypoint_argv = test_arguments.data();
58 
59  FlutterProjectBundle project(properties);
60 
61  std::vector<std::string> retrieved_arguments =
62  project.dart_entrypoint_arguments();
63  EXPECT_EQ(retrieved_arguments.size(), 2U);
64  EXPECT_EQ(retrieved_arguments[0], "arg1");
65  EXPECT_EQ(retrieved_arguments[1], "arg2");
66 }

References FlutterDesktopEngineProperties::assets_path, FlutterDesktopEngineProperties::dart_entrypoint_argc, flutter::FlutterProjectBundle::dart_entrypoint_arguments(), FlutterDesktopEngineProperties::dart_entrypoint_argv, and FlutterDesktopEngineProperties::icu_data_path.

◆ TEST() [52/174]

flutter::testing::TEST ( FlutterProjectBundle  ,
Switches   
)

Definition at line 69 of file flutter_project_bundle_unittests.cc.

69  {
70  FlutterDesktopEngineProperties properties = {};
71  properties.assets_path = L"foo\\flutter_assets";
72  properties.icu_data_path = L"foo\\icudtl.dat";
73 
74  _putenv_s("FLUTTER_ENGINE_SWITCHES", "2");
75  _putenv_s("FLUTTER_ENGINE_SWITCH_1", "abc");
76  _putenv_s("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"");
77 
78  FlutterProjectBundle project(properties);
79 
80  std::vector<std::string> switches = project.GetSwitches();
81  EXPECT_EQ(switches.size(), 2);
82  EXPECT_EQ(switches[0], "--abc");
83  EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
84 }

References FlutterDesktopEngineProperties::assets_path, flutter::FlutterProjectBundle::GetSwitches(), and FlutterDesktopEngineProperties::icu_data_path.

◆ TEST() [53/174]

flutter::testing::TEST ( FlutterProjectBundle  ,
SwitchesEmpty   
)

Definition at line 37 of file flutter_project_bundle_unittests.cc.

37  {
38  FlutterDesktopEngineProperties properties = {};
39  properties.assets_path = L"foo\\flutter_assets";
40  properties.icu_data_path = L"foo\\icudtl.dat";
41 
42  // Clear the main environment variable, since test order is not guaranteed.
43  _putenv_s("FLUTTER_ENGINE_SWITCHES", "");
44 
45  FlutterProjectBundle project(properties);
46 
47  EXPECT_EQ(project.GetSwitches().size(), 0);
48 }

References FlutterDesktopEngineProperties::assets_path, flutter::FlutterProjectBundle::GetSwitches(), and FlutterDesktopEngineProperties::icu_data_path.

◆ TEST() [54/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
CreateDestroy   
)

Definition at line 68 of file flutter_windows_texture_registrar_unittests.cc.

68  {
69  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
70  auto gl = std::make_shared<egl::MockProcTable>();
71  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
72 
73  EXPECT_TRUE(true);
74 }

◆ TEST() [55/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
PopulateD3dTexture   
)

Definition at line 268 of file flutter_windows_texture_registrar_unittests.cc.

268  {
269  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
270  auto gl = std::make_shared<egl::MockProcTable>();
271  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
272 
273  UINT width = 100;
274  UINT height = 100;
275  auto d3d_texture = CreateD3dTexture(engine.get(), width, height);
276  EXPECT_TRUE(d3d_texture);
277 
278  bool release_callback_called = false;
279  FlutterDesktopGpuSurfaceDescriptor surface_descriptor = {};
280  surface_descriptor.struct_size = sizeof(FlutterDesktopGpuSurfaceDescriptor);
281  surface_descriptor.handle = d3d_texture.Get();
282  surface_descriptor.width = surface_descriptor.visible_width = width;
283  surface_descriptor.height = surface_descriptor.visible_height = height;
284  surface_descriptor.release_context = &release_callback_called;
285  surface_descriptor.release_callback = [](void* release_context) {
286  bool* called = reinterpret_cast<bool*>(release_context);
287  *called = true;
288  };
289 
290  FlutterDesktopTextureInfo texture_info = {};
291  texture_info.type = kFlutterDesktopGpuSurfaceTexture;
292  texture_info.gpu_surface_config.struct_size =
294  texture_info.gpu_surface_config.type =
296  texture_info.gpu_surface_config.user_data = &surface_descriptor;
297  texture_info.gpu_surface_config.callback =
298  [](size_t width, size_t height,
300  return reinterpret_cast<const FlutterDesktopGpuSurfaceDescriptor*>(
301  user_data);
302  };
303 
304  FlutterOpenGLTexture flutter_texture = {};
305  auto texture_id = registrar.RegisterTexture(&texture_info);
306  EXPECT_NE(texture_id, -1);
307 
308  EXPECT_CALL(*gl.get(), GenTextures(1, _))
309  .Times(1)
310  .WillOnce([](GLsizei n, GLuint* textures) { textures[0] = 1; });
311  EXPECT_CALL(*gl.get(), BindTexture).Times(1);
312  EXPECT_CALL(*gl.get(), TexParameteri).Times(AtLeast(1));
313  EXPECT_CALL(*gl.get(), DeleteTextures(1, _)).Times(1);
314 
315  auto result =
316  registrar.PopulateTexture(texture_id, 640, 480, &flutter_texture);
317  EXPECT_TRUE(result);
318  EXPECT_EQ(flutter_texture.width, width);
319  EXPECT_EQ(flutter_texture.height, height);
320  EXPECT_EQ(flutter_texture.target, GL_TEXTURE_2D);
321  EXPECT_TRUE(release_callback_called);
322 }
uint32_t texture_id
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
@ kFlutterDesktopGpuSurfaceTexture
void(* release_callback)(void *release_context)
FlutterDesktopGpuSurfaceTextureCallback callback
FlutterDesktopGpuSurfaceTextureConfig gpu_surface_config
FlutterDesktopTextureType type

References FlutterDesktopGpuSurfaceTextureConfig::callback, FlutterDesktopTextureInfo::gpu_surface_config, FlutterDesktopGpuSurfaceDescriptor::handle, FlutterDesktopGpuSurfaceDescriptor::height, kFlutterDesktopGpuSurfaceTexture, kFlutterDesktopGpuSurfaceTypeD3d11Texture2D, flutter::FlutterWindowsTextureRegistrar::PopulateTexture(), flutter::FlutterWindowsTextureRegistrar::RegisterTexture(), FlutterDesktopGpuSurfaceDescriptor::release_callback, FlutterDesktopGpuSurfaceDescriptor::release_context, FlutterDesktopGpuSurfaceDescriptor::struct_size, FlutterDesktopGpuSurfaceTextureConfig::struct_size, texture_id, FlutterDesktopGpuSurfaceTextureConfig::type, FlutterDesktopTextureInfo::type, FlutterDesktopGpuSurfaceTextureConfig::user_data, user_data, FlutterDesktopGpuSurfaceDescriptor::visible_height, FlutterDesktopGpuSurfaceDescriptor::visible_width, and FlutterDesktopGpuSurfaceDescriptor::width.

◆ TEST() [56/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
PopulateD3dTextureWithHandle   
)

Definition at line 206 of file flutter_windows_texture_registrar_unittests.cc.

206  {
207  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
208  auto gl = std::make_shared<egl::MockProcTable>();
209  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
210 
211  UINT width = 100;
212  UINT height = 100;
213  auto d3d_texture = CreateD3dTexture(engine.get(), width, height);
214  EXPECT_TRUE(d3d_texture);
215 
216  ComPtr<IDXGIResource> shared_resource;
217  EXPECT_TRUE(SUCCEEDED(d3d_texture.As(&shared_resource)));
218 
219  HANDLE shared_handle;
220  EXPECT_TRUE(SUCCEEDED(shared_resource->GetSharedHandle(&shared_handle)));
221 
222  bool release_callback_called = false;
223  FlutterDesktopGpuSurfaceDescriptor surface_descriptor = {};
224  surface_descriptor.struct_size = sizeof(FlutterDesktopGpuSurfaceDescriptor);
225  surface_descriptor.handle = shared_handle;
226  surface_descriptor.width = surface_descriptor.visible_width = width;
227  surface_descriptor.height = surface_descriptor.visible_height = height;
228  surface_descriptor.release_context = &release_callback_called;
229  surface_descriptor.release_callback = [](void* release_context) {
230  bool* called = reinterpret_cast<bool*>(release_context);
231  *called = true;
232  };
233 
234  FlutterDesktopTextureInfo texture_info = {};
235  texture_info.type = kFlutterDesktopGpuSurfaceTexture;
236  texture_info.gpu_surface_config.struct_size =
238  texture_info.gpu_surface_config.type =
240  texture_info.gpu_surface_config.user_data = &surface_descriptor;
241  texture_info.gpu_surface_config.callback =
242  [](size_t width, size_t height,
244  return reinterpret_cast<const FlutterDesktopGpuSurfaceDescriptor*>(
245  user_data);
246  };
247 
248  FlutterOpenGLTexture flutter_texture = {};
249  auto texture_id = registrar.RegisterTexture(&texture_info);
250  EXPECT_NE(texture_id, -1);
251 
252  EXPECT_CALL(*gl.get(), GenTextures(1, _))
253  .Times(1)
254  .WillOnce([](GLsizei n, GLuint* textures) { textures[0] = 1; });
255  EXPECT_CALL(*gl.get(), BindTexture).Times(1);
256  EXPECT_CALL(*gl.get(), TexParameteri).Times(AtLeast(1));
257  EXPECT_CALL(*gl.get(), DeleteTextures(1, _)).Times(1);
258 
259  auto result =
260  registrar.PopulateTexture(texture_id, 640, 480, &flutter_texture);
261  EXPECT_TRUE(result);
262  EXPECT_EQ(flutter_texture.width, width);
263  EXPECT_EQ(flutter_texture.height, height);
264  EXPECT_EQ(flutter_texture.target, GL_TEXTURE_2D);
265  EXPECT_TRUE(release_callback_called);
266 }
@ kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle

References FlutterDesktopGpuSurfaceTextureConfig::callback, FlutterDesktopTextureInfo::gpu_surface_config, FlutterDesktopGpuSurfaceDescriptor::handle, FlutterDesktopGpuSurfaceDescriptor::height, kFlutterDesktopGpuSurfaceTexture, kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle, flutter::FlutterWindowsTextureRegistrar::PopulateTexture(), flutter::FlutterWindowsTextureRegistrar::RegisterTexture(), FlutterDesktopGpuSurfaceDescriptor::release_callback, FlutterDesktopGpuSurfaceDescriptor::release_context, FlutterDesktopGpuSurfaceDescriptor::struct_size, FlutterDesktopGpuSurfaceTextureConfig::struct_size, texture_id, FlutterDesktopGpuSurfaceTextureConfig::type, FlutterDesktopTextureInfo::type, FlutterDesktopGpuSurfaceTextureConfig::user_data, user_data, FlutterDesktopGpuSurfaceDescriptor::visible_height, FlutterDesktopGpuSurfaceDescriptor::visible_width, and FlutterDesktopGpuSurfaceDescriptor::width.

◆ TEST() [57/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
PopulateInvalidTexture   
)

Definition at line 324 of file flutter_windows_texture_registrar_unittests.cc.

324  {
325  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
326  auto gl = std::make_shared<egl::MockProcTable>();
327 
328  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
329 
330  auto result = registrar.PopulateTexture(1, 640, 480, nullptr);
331  EXPECT_FALSE(result);
332 }

References flutter::FlutterWindowsTextureRegistrar::PopulateTexture().

◆ TEST() [58/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
PopulatePixelBufferTexture   
)

Definition at line 155 of file flutter_windows_texture_registrar_unittests.cc.

155  {
156  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
157  auto gl = std::make_shared<egl::MockProcTable>();
158 
159  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
160 
161  bool release_callback_called = false;
162  size_t width = 100;
163  size_t height = 100;
164  std::unique_ptr<uint8_t[]> pixels =
165  std::make_unique<uint8_t[]>(width * height * 4);
166  FlutterDesktopPixelBuffer pixel_buffer = {};
167  pixel_buffer.width = width;
168  pixel_buffer.height = height;
169  pixel_buffer.buffer = pixels.get();
170  pixel_buffer.release_context = &release_callback_called;
171  pixel_buffer.release_callback = [](void* release_context) {
172  bool* called = reinterpret_cast<bool*>(release_context);
173  *called = true;
174  };
175 
176  FlutterDesktopTextureInfo texture_info = {};
178  texture_info.pixel_buffer_config.user_data = &pixel_buffer;
179  texture_info.pixel_buffer_config.callback =
180  [](size_t width, size_t height,
181  void* user_data) -> const FlutterDesktopPixelBuffer* {
182  return reinterpret_cast<const FlutterDesktopPixelBuffer*>(user_data);
183  };
184 
185  FlutterOpenGLTexture flutter_texture = {};
186  auto texture_id = registrar.RegisterTexture(&texture_info);
187  EXPECT_NE(texture_id, -1);
188 
189  EXPECT_CALL(*gl.get(), GenTextures(1, _))
190  .Times(1)
191  .WillOnce([](GLsizei n, GLuint* textures) { textures[0] = 1; });
192  EXPECT_CALL(*gl.get(), BindTexture).Times(1);
193  EXPECT_CALL(*gl.get(), TexParameteri).Times(AtLeast(1));
194  EXPECT_CALL(*gl.get(), TexImage2D).Times(1);
195  EXPECT_CALL(*gl.get(), DeleteTextures(1, _)).Times(1);
196 
197  auto result =
198  registrar.PopulateTexture(texture_id, 640, 480, &flutter_texture);
199  EXPECT_TRUE(result);
200  EXPECT_EQ(flutter_texture.width, width);
201  EXPECT_EQ(flutter_texture.height, height);
202  EXPECT_EQ(flutter_texture.target, GL_TEXTURE_2D);
203  EXPECT_TRUE(release_callback_called);
204 }
@ kFlutterDesktopPixelBufferTexture
void(* release_callback)(void *release_context)
FlutterDesktopPixelBufferTextureCallback callback
FlutterDesktopPixelBufferTextureConfig pixel_buffer_config

References FlutterDesktopPixelBuffer::buffer, FlutterDesktopPixelBufferTextureConfig::callback, FlutterDesktopPixelBuffer::height, kFlutterDesktopPixelBufferTexture, FlutterDesktopTextureInfo::pixel_buffer_config, flutter::FlutterWindowsTextureRegistrar::PopulateTexture(), flutter::FlutterWindowsTextureRegistrar::RegisterTexture(), FlutterDesktopPixelBuffer::release_callback, FlutterDesktopPixelBuffer::release_context, texture_id, FlutterDesktopTextureInfo::type, FlutterDesktopPixelBufferTextureConfig::user_data, user_data, and FlutterDesktopPixelBuffer::width.

◆ TEST() [59/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
RegisterUnknownTextureType   
)

Definition at line 141 of file flutter_windows_texture_registrar_unittests.cc.

141  {
142  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
143  auto gl = std::make_shared<egl::MockProcTable>();
144 
145  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
146 
147  FlutterDesktopTextureInfo texture_info = {};
148  texture_info.type = static_cast<FlutterDesktopTextureType>(1234);
149 
150  auto texture_id = registrar.RegisterTexture(&texture_info);
151 
152  EXPECT_EQ(texture_id, -1);
153 }
FlutterDesktopTextureType

References flutter::FlutterWindowsTextureRegistrar::RegisterTexture(), texture_id, and FlutterDesktopTextureInfo::type.

◆ TEST() [60/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
RegisterUnregisterTexture   
)

Definition at line 76 of file flutter_windows_texture_registrar_unittests.cc.

76  {
77  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
78  EngineModifier modifier(engine.get());
79  auto gl = std::make_shared<egl::MockProcTable>();
80 
81  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
82 
83  FlutterDesktopTextureInfo texture_info = {};
85  texture_info.pixel_buffer_config.callback =
86  [](size_t width, size_t height,
87  void* user_data) -> const FlutterDesktopPixelBuffer* {
88  return nullptr;
89  };
90 
91  int64_t registered_texture_id = 0;
92  bool register_called = false;
93  modifier.embedder_api().RegisterExternalTexture = MOCK_ENGINE_PROC(
94  RegisterExternalTexture, ([&register_called, &registered_texture_id](
95  auto engine, auto texture_id) {
96  register_called = true;
97  registered_texture_id = texture_id;
98  return kSuccess;
99  }));
100 
101  bool unregister_called = false;
102  modifier.embedder_api().UnregisterExternalTexture = MOCK_ENGINE_PROC(
103  UnregisterExternalTexture, ([&unregister_called, &registered_texture_id](
104  auto engine, auto texture_id) {
105  unregister_called = true;
106  EXPECT_EQ(registered_texture_id, texture_id);
107  return kSuccess;
108  }));
109 
110  bool mark_frame_available_called = false;
111  modifier.embedder_api().MarkExternalTextureFrameAvailable =
112  MOCK_ENGINE_PROC(MarkExternalTextureFrameAvailable,
113  ([&mark_frame_available_called, &registered_texture_id](
114  auto engine, auto texture_id) {
115  mark_frame_available_called = true;
116  EXPECT_EQ(registered_texture_id, texture_id);
117  return kSuccess;
118  }));
119 
120  modifier.embedder_api().PostRenderThreadTask =
121  MOCK_ENGINE_PROC(PostRenderThreadTask,
122  [](auto engine, auto callback, void* callback_data) {
123  callback(callback_data);
124  return kSuccess;
125  });
126 
127  auto texture_id = registrar.RegisterTexture(&texture_info);
128  EXPECT_TRUE(register_called);
129  EXPECT_NE(texture_id, -1);
130  EXPECT_EQ(texture_id, registered_texture_id);
131 
132  EXPECT_TRUE(registrar.MarkTextureFrameAvailable(texture_id));
133  EXPECT_TRUE(mark_frame_available_called);
134 
135  fml::AutoResetWaitableEvent latch;
136  registrar.UnregisterTexture(texture_id, [&]() { latch.Signal(); });
137  latch.Wait();
138  ASSERT_TRUE(unregister_called);
139 }
FlutterDesktopBinaryReply callback

References FlutterDesktopPixelBufferTextureConfig::callback, callback, kFlutterDesktopPixelBufferTexture, flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable(), FlutterDesktopTextureInfo::pixel_buffer_config, flutter::FlutterWindowsTextureRegistrar::RegisterTexture(), texture_id, FlutterDesktopTextureInfo::type, flutter::FlutterWindowsTextureRegistrar::UnregisterTexture(), and user_data.

◆ TEST() [61/174]

flutter::testing::TEST ( FlutterWindowsTextureRegistrarTest  ,
UnregisterTextureWithEngineDownInvokesCallback   
)

Definition at line 334 of file flutter_windows_texture_registrar_unittests.cc.

335  {
336  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
337  auto gl = std::make_shared<egl::MockProcTable>();
338 
339  FlutterWindowsTextureRegistrar registrar(engine.get(), gl);
340 
341  fml::AutoResetWaitableEvent latch;
342  registrar.UnregisterTexture(1234, [&]() { latch.Signal(); });
343  latch.Wait();
344 }

References flutter::FlutterWindowsTextureRegistrar::UnregisterTexture().

◆ TEST() [62/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
AccessibilityHitTesting   
)

Definition at line 854 of file flutter_windows_view_unittests.cc.

854  {
855  constexpr FlutterTransformation kIdentityTransform = {1, 0, 0, //
856  0, 1, 0, //
857  0, 0, 1};
858 
859  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
860  EngineModifier modifier(engine.get());
861  modifier.embedder_api().UpdateSemanticsEnabled =
862  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
863  return kSuccess;
864  };
865 
866  std::unique_ptr<FlutterWindowsView> view =
867  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
868  /*is_sized_to_content=*/false, BoxConstraints());
869 
870  // Enable semantics to instantiate accessibility bridge.
871  view->OnUpdateSemanticsEnabled(true);
872 
873  auto bridge = view->accessibility_bridge().lock();
874  ASSERT_TRUE(bridge);
875 
876  // Add root node at origin. Size 500x500.
877  FlutterSemanticsNode2 node0{sizeof(FlutterSemanticsNode2), 0};
878  auto empty_flags = FlutterSemanticsFlags{};
879  std::vector<int32_t> node0_children{1, 2};
880  node0.rect = {0, 0, 500, 500};
881  node0.transform = kIdentityTransform;
882  node0.child_count = node0_children.size();
883  node0.children_in_traversal_order = node0_children.data();
884  node0.children_in_hit_test_order = node0_children.data();
885  node0.flags2 = &empty_flags;
886 
887  // Add node 1 located at 0,0 relative to node 0. Size 250x500.
888  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
889  node1.rect = {0, 0, 250, 500};
890  node1.transform = kIdentityTransform;
891  node1.label = "prefecture";
892  node1.value = "Kyoto";
893  node1.flags2 = &empty_flags;
894 
895  // Add node 2 located at 250,0 relative to node 0. Size 250x500.
896  FlutterSemanticsNode2 node2{sizeof(FlutterSemanticsNode2), 2};
897  std::vector<int32_t> node2_children{3};
898  node2.rect = {0, 0, 250, 500};
899  node2.transform = {1, 0, 250, 0, 1, 0, 0, 0, 1};
900  node2.child_count = node2_children.size();
901  node2.children_in_traversal_order = node2_children.data();
902  node2.children_in_hit_test_order = node2_children.data();
903  node2.flags2 = &empty_flags;
904 
905  // Add node 3 located at 0,250 relative to node 2. Size 250, 250.
906  FlutterSemanticsNode2 node3{sizeof(FlutterSemanticsNode2), 3};
907  node3.rect = {0, 0, 250, 250};
908  node3.transform = {1, 0, 0, 0, 1, 250, 0, 0, 1};
909  node3.label = "city";
910  node3.value = "Uji";
911  node3.flags2 = &empty_flags;
912 
913  bridge->AddFlutterSemanticsNodeUpdate(node0);
914  bridge->AddFlutterSemanticsNodeUpdate(node1);
915  bridge->AddFlutterSemanticsNodeUpdate(node2);
916  bridge->AddFlutterSemanticsNodeUpdate(node3);
917  bridge->CommitUpdates();
918 
919  // Look up the root windows node delegate.
920  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
921  ASSERT_TRUE(node0_delegate);
922  auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
923  ASSERT_TRUE(node1_delegate);
924  auto node2_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
925  ASSERT_TRUE(node2_delegate);
926  auto node3_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(3).lock();
927  ASSERT_TRUE(node3_delegate);
928 
929  // Get the native IAccessible root object.
930  IAccessible* node0_accessible = node0_delegate->GetNativeViewAccessible();
931  ASSERT_TRUE(node0_accessible != nullptr);
932 
933  // Perform a hit test that should hit node 1.
934  VARIANT varchild{};
935  ASSERT_TRUE(SUCCEEDED(node0_accessible->accHitTest(150, 150, &varchild)));
936  EXPECT_EQ(varchild.vt, VT_DISPATCH);
937  EXPECT_EQ(varchild.pdispVal, node1_delegate->GetNativeViewAccessible());
938 
939  // Perform a hit test that should hit node 2.
940  varchild = {};
941  ASSERT_TRUE(SUCCEEDED(node0_accessible->accHitTest(450, 150, &varchild)));
942  EXPECT_EQ(varchild.vt, VT_DISPATCH);
943  EXPECT_EQ(varchild.pdispVal, node2_delegate->GetNativeViewAccessible());
944 
945  // Perform a hit test that should hit node 3.
946  varchild = {};
947  ASSERT_TRUE(SUCCEEDED(node0_accessible->accHitTest(450, 450, &varchild)));
948  EXPECT_EQ(varchild.vt, VT_DISPATCH);
949  EXPECT_EQ(varchild.pdispVal, node3_delegate->GetNativeViewAccessible());
950 }

References flutter::IAccessible.

◆ TEST() [63/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
AddSemanticsNodeUpdate   
)

Definition at line 421 of file flutter_windows_view_unittests.cc.

421  {
422  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
423  EngineModifier modifier(engine.get());
424  modifier.embedder_api().UpdateSemanticsEnabled =
425  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
426  return kSuccess;
427  };
428 
429  auto window_binding_handler =
430  std::make_unique<NiceMock<MockWindowBindingHandler>>();
431  std::unique_ptr<FlutterWindowsView> view =
432  engine->CreateView(std::move(window_binding_handler),
433  /*is_sized_to_content=*/false, BoxConstraints());
434 
435  // Enable semantics to instantiate accessibility bridge.
436  view->OnUpdateSemanticsEnabled(true);
437 
438  auto bridge = view->accessibility_bridge().lock();
439  ASSERT_TRUE(bridge);
440 
441  // Add root node.
442  FlutterSemanticsNode2 node{sizeof(FlutterSemanticsNode2), 0};
443  node.label = "name";
444  node.value = "value";
445  node.platform_view_id = -1;
446  auto flags = FlutterSemanticsFlags{};
447  node.flags2 = &flags;
448  bridge->AddFlutterSemanticsNodeUpdate(node);
449  bridge->CommitUpdates();
450 
451  // Look up the root windows node delegate.
452  auto node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
453  ASSERT_TRUE(node_delegate);
454  EXPECT_EQ(node_delegate->GetChildCount(), 0);
455 
456  // Get the native IAccessible object.
457  IAccessible* native_view = node_delegate->GetNativeViewAccessible();
458  ASSERT_TRUE(native_view != nullptr);
459 
460  // Property lookups will be made against this node itself.
461  VARIANT varchild{};
462  varchild.vt = VT_I4;
463  varchild.lVal = CHILDID_SELF;
464 
465  // Verify node name matches our label.
466  BSTR bname = nullptr;
467  ASSERT_EQ(native_view->get_accName(varchild, &bname), S_OK);
468  std::string name(_com_util::ConvertBSTRToString(bname));
469  EXPECT_EQ(name, "name");
470 
471  // Verify node value matches.
472  BSTR bvalue = nullptr;
473  ASSERT_EQ(native_view->get_accValue(varchild, &bvalue), S_OK);
474  std::string value(_com_util::ConvertBSTRToString(bvalue));
475  EXPECT_EQ(value, "value");
476 
477  // Verify node type is static text.
478  VARIANT varrole{};
479  varrole.vt = VT_I4;
480  ASSERT_EQ(native_view->get_accRole(varchild, &varrole), S_OK);
481  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
482 
483  // Get the IRawElementProviderFragment object.
484  IRawElementProviderSimple* uia_view;
485  native_view->QueryInterface(IID_PPV_ARGS(&uia_view));
486  ASSERT_TRUE(uia_view != nullptr);
487 
488  // Verify name property matches our label.
489  VARIANT varname{};
490  ASSERT_EQ(uia_view->GetPropertyValue(UIA_NamePropertyId, &varname), S_OK);
491  EXPECT_EQ(varname.vt, VT_BSTR);
492  name = _com_util::ConvertBSTRToString(varname.bstrVal);
493  EXPECT_EQ(name, "name");
494 
495  // Verify value property matches our label.
496  VARIANT varvalue{};
497  ASSERT_EQ(uia_view->GetPropertyValue(UIA_ValueValuePropertyId, &varvalue),
498  S_OK);
499  EXPECT_EQ(varvalue.vt, VT_BSTR);
500  value = _com_util::ConvertBSTRToString(varvalue.bstrVal);
501  EXPECT_EQ(value, "value");
502 
503  // Verify node control type is text.
504  varrole = {};
505  ASSERT_EQ(uia_view->GetPropertyValue(UIA_ControlTypePropertyId, &varrole),
506  S_OK);
507  EXPECT_EQ(varrole.vt, VT_I4);
508  EXPECT_EQ(varrole.lVal, UIA_TextControlTypeId);
509 }
std::shared_ptr< FlutterPlatformNodeDelegateWindows > node_delegate

References flutter::IAccessible, and node_delegate.

◆ TEST() [64/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
AddSemanticsNodeUpdateWithChildren   
)

Definition at line 523 of file flutter_windows_view_unittests.cc.

523  {
524  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
525  EngineModifier modifier(engine.get());
526  modifier.embedder_api().UpdateSemanticsEnabled =
527  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
528  return kSuccess;
529  };
530 
531  std::unique_ptr<FlutterWindowsView> view =
532  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
533  /*is_sized_to_content=*/false, BoxConstraints());
534 
535  // Enable semantics to instantiate accessibility bridge.
536  view->OnUpdateSemanticsEnabled(true);
537 
538  auto bridge = view->accessibility_bridge().lock();
539  ASSERT_TRUE(bridge);
540 
541  // Add root node.
542  FlutterSemanticsNode2 node0{sizeof(FlutterSemanticsNode2), 0};
543  std::vector<int32_t> node0_children{1, 2};
544  node0.child_count = node0_children.size();
545  node0.children_in_traversal_order = node0_children.data();
546  node0.children_in_hit_test_order = node0_children.data();
547  auto empty_flags = FlutterSemanticsFlags{};
548  node0.flags2 = &empty_flags;
549 
550  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
551  node1.label = "prefecture";
552  node1.value = "Kyoto";
553  node1.flags2 = &empty_flags;
554  FlutterSemanticsNode2 node2{sizeof(FlutterSemanticsNode2), 2};
555  std::vector<int32_t> node2_children{3};
556  node2.child_count = node2_children.size();
557  node2.children_in_traversal_order = node2_children.data();
558  node2.children_in_hit_test_order = node2_children.data();
559  node2.flags2 = &empty_flags;
560  FlutterSemanticsNode2 node3{sizeof(FlutterSemanticsNode2), 3};
561  node3.label = "city";
562  node3.value = "Uji";
563  node3.flags2 = &empty_flags;
564 
565  bridge->AddFlutterSemanticsNodeUpdate(node0);
566  bridge->AddFlutterSemanticsNodeUpdate(node1);
567  bridge->AddFlutterSemanticsNodeUpdate(node2);
568  bridge->AddFlutterSemanticsNodeUpdate(node3);
569  bridge->CommitUpdates();
570 
571  // Look up the root windows node delegate.
572  auto node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
573  ASSERT_TRUE(node_delegate);
574  EXPECT_EQ(node_delegate->GetChildCount(), 2);
575 
576  // Get the native IAccessible object.
577  IAccessible* node0_accessible = node_delegate->GetNativeViewAccessible();
578  ASSERT_TRUE(node0_accessible != nullptr);
579 
580  // Property lookups will be made against this node itself.
581  VARIANT varchild{};
582  varchild.vt = VT_I4;
583  varchild.lVal = CHILDID_SELF;
584 
585  // Verify node type is a group.
586  VARIANT varrole{};
587  varrole.vt = VT_I4;
588  ASSERT_EQ(node0_accessible->get_accRole(varchild, &varrole), S_OK);
589  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_GROUPING);
590 
591  // Verify child count.
592  long node0_child_count = 0;
593  ASSERT_EQ(node0_accessible->get_accChildCount(&node0_child_count), S_OK);
594  EXPECT_EQ(node0_child_count, 2);
595 
596  {
597  // Look up first child of node0 (node1), a static text node.
598  varchild.lVal = 1;
599  IDispatch* node1_dispatch = nullptr;
600  ASSERT_EQ(node0_accessible->get_accChild(varchild, &node1_dispatch), S_OK);
601  ASSERT_TRUE(node1_dispatch != nullptr);
602  IAccessible* node1_accessible = nullptr;
603  ASSERT_EQ(node1_dispatch->QueryInterface(
604  IID_IAccessible, reinterpret_cast<void**>(&node1_accessible)),
605  S_OK);
606  ASSERT_TRUE(node1_accessible != nullptr);
607 
608  // Verify node name matches our label.
609  varchild.lVal = CHILDID_SELF;
610  BSTR bname = nullptr;
611  ASSERT_EQ(node1_accessible->get_accName(varchild, &bname), S_OK);
612  std::string name(_com_util::ConvertBSTRToString(bname));
613  EXPECT_EQ(name, "prefecture");
614 
615  // Verify node value matches.
616  BSTR bvalue = nullptr;
617  ASSERT_EQ(node1_accessible->get_accValue(varchild, &bvalue), S_OK);
618  std::string value(_com_util::ConvertBSTRToString(bvalue));
619  EXPECT_EQ(value, "Kyoto");
620 
621  // Verify node type is static text.
622  VARIANT varrole{};
623  varrole.vt = VT_I4;
624  ASSERT_EQ(node1_accessible->get_accRole(varchild, &varrole), S_OK);
625  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
626 
627  // Verify the parent node is the root.
628  IDispatch* parent_dispatch;
629  node1_accessible->get_accParent(&parent_dispatch);
630  IAccessible* parent_accessible;
631  ASSERT_EQ(
632  parent_dispatch->QueryInterface(
633  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
634  S_OK);
635  EXPECT_EQ(parent_accessible, node0_accessible);
636  }
637 
638  // Look up second child of node0 (node2), a parent group for node3.
639  varchild.lVal = 2;
640  IDispatch* node2_dispatch = nullptr;
641  ASSERT_EQ(node0_accessible->get_accChild(varchild, &node2_dispatch), S_OK);
642  ASSERT_TRUE(node2_dispatch != nullptr);
643  IAccessible* node2_accessible = nullptr;
644  ASSERT_EQ(node2_dispatch->QueryInterface(
645  IID_IAccessible, reinterpret_cast<void**>(&node2_accessible)),
646  S_OK);
647  ASSERT_TRUE(node2_accessible != nullptr);
648 
649  {
650  // Verify child count.
651  long node2_child_count = 0;
652  ASSERT_EQ(node2_accessible->get_accChildCount(&node2_child_count), S_OK);
653  EXPECT_EQ(node2_child_count, 1);
654 
655  // Verify node type is static text.
656  varchild.lVal = CHILDID_SELF;
657  VARIANT varrole{};
658  varrole.vt = VT_I4;
659  ASSERT_EQ(node2_accessible->get_accRole(varchild, &varrole), S_OK);
660  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_GROUPING);
661 
662  // Verify the parent node is the root.
663  IDispatch* parent_dispatch;
664  node2_accessible->get_accParent(&parent_dispatch);
665  IAccessible* parent_accessible;
666  ASSERT_EQ(
667  parent_dispatch->QueryInterface(
668  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
669  S_OK);
670  EXPECT_EQ(parent_accessible, node0_accessible);
671  }
672 
673  {
674  // Look up only child of node2 (node3), a static text node.
675  varchild.lVal = 1;
676  IDispatch* node3_dispatch = nullptr;
677  ASSERT_EQ(node2_accessible->get_accChild(varchild, &node3_dispatch), S_OK);
678  ASSERT_TRUE(node3_dispatch != nullptr);
679  IAccessible* node3_accessible = nullptr;
680  ASSERT_EQ(node3_dispatch->QueryInterface(
681  IID_IAccessible, reinterpret_cast<void**>(&node3_accessible)),
682  S_OK);
683  ASSERT_TRUE(node3_accessible != nullptr);
684 
685  // Verify node name matches our label.
686  varchild.lVal = CHILDID_SELF;
687  BSTR bname = nullptr;
688  ASSERT_EQ(node3_accessible->get_accName(varchild, &bname), S_OK);
689  std::string name(_com_util::ConvertBSTRToString(bname));
690  EXPECT_EQ(name, "city");
691 
692  // Verify node value matches.
693  BSTR bvalue = nullptr;
694  ASSERT_EQ(node3_accessible->get_accValue(varchild, &bvalue), S_OK);
695  std::string value(_com_util::ConvertBSTRToString(bvalue));
696  EXPECT_EQ(value, "Uji");
697 
698  // Verify node type is static text.
699  VARIANT varrole{};
700  varrole.vt = VT_I4;
701  ASSERT_EQ(node3_accessible->get_accRole(varchild, &varrole), S_OK);
702  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
703 
704  // Verify the parent node is node2.
705  IDispatch* parent_dispatch;
706  node3_accessible->get_accParent(&parent_dispatch);
707  IAccessible* parent_accessible;
708  ASSERT_EQ(
709  parent_dispatch->QueryInterface(
710  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
711  S_OK);
712  EXPECT_EQ(parent_accessible, node2_accessible);
713  }
714 }

References flutter::IAccessible, and node_delegate.

◆ TEST() [65/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
CheckboxNativeState   
)

Definition at line 1219 of file flutter_windows_view_unittests.cc.

1219  {
1220  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1221  EngineModifier modifier(engine.get());
1222  modifier.embedder_api().UpdateSemanticsEnabled =
1223  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
1224  return kSuccess;
1225  };
1226 
1227  std::unique_ptr<FlutterWindowsView> view =
1228  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1229  /*is_sized_to_content=*/false, BoxConstraints());
1230 
1231  // Enable semantics to instantiate accessibility bridge.
1232  view->OnUpdateSemanticsEnabled(true);
1233 
1234  auto bridge = view->accessibility_bridge().lock();
1235  ASSERT_TRUE(bridge);
1236 
1237  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
1238  root.id = 0;
1239  root.label = "root";
1240  root.hint = "";
1241  root.value = "";
1242  root.increased_value = "";
1243  root.decreased_value = "";
1244  root.child_count = 0;
1245  root.custom_accessibility_actions_count = 0;
1246  auto flags = FlutterSemanticsFlags{
1247  .is_checked = FlutterCheckState::kFlutterCheckStateTrue,
1248  };
1249  root.flags2 = &flags;
1250  bridge->AddFlutterSemanticsNodeUpdate(root);
1251 
1252  bridge->CommitUpdates();
1253 
1254  {
1255  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1256  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
1257  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1258  ax::mojom::CheckedState::kTrue);
1259 
1260  // Get the IAccessible for the root node.
1261  IAccessible* native_view = root_node->GetNativeViewAccessible();
1262  ASSERT_TRUE(native_view != nullptr);
1263 
1264  // Look up against the node itself (not one of its children).
1265  VARIANT varchild = {};
1266  varchild.vt = VT_I4;
1267 
1268  // Verify the checkbox is checked.
1269  varchild.lVal = CHILDID_SELF;
1270  VARIANT native_state = {};
1271  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1272  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_CHECKED);
1273 
1274  // Perform similar tests for UIA value;
1275  IRawElementProviderSimple* uia_node;
1276  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1277  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1278  UIA_ToggleToggleStatePropertyId, &native_state)));
1279  EXPECT_EQ(native_state.lVal, ToggleState_On);
1280 
1281  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1282  UIA_AriaPropertiesPropertyId, &native_state)));
1283  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"checked=true"), nullptr);
1284  }
1285 
1286  // Test unchecked too.
1287  auto updated_flags = FlutterSemanticsFlags{
1288  .is_checked = FlutterCheckState::kFlutterCheckStateFalse,
1289  };
1290  root.flags2 = &updated_flags;
1291  bridge->AddFlutterSemanticsNodeUpdate(root);
1292  bridge->CommitUpdates();
1293 
1294  {
1295  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1296  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
1297  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1298  ax::mojom::CheckedState::kFalse);
1299 
1300  // Get the IAccessible for the root node.
1301  IAccessible* native_view = root_node->GetNativeViewAccessible();
1302  ASSERT_TRUE(native_view != nullptr);
1303 
1304  // Look up against the node itself (not one of its children).
1305  VARIANT varchild = {};
1306  varchild.vt = VT_I4;
1307 
1308  // Verify the checkbox is unchecked.
1309  varchild.lVal = CHILDID_SELF;
1310  VARIANT native_state = {};
1311  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1312  EXPECT_FALSE(native_state.lVal & STATE_SYSTEM_CHECKED);
1313 
1314  // Perform similar tests for UIA value;
1315  IRawElementProviderSimple* uia_node;
1316  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1317  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1318  UIA_ToggleToggleStatePropertyId, &native_state)));
1319  EXPECT_EQ(native_state.lVal, ToggleState_Off);
1320 
1321  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1322  UIA_AriaPropertiesPropertyId, &native_state)));
1323  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"checked=false"), nullptr);
1324  }
1325 
1326  // Now check mixed state.
1327  auto updated_mixe_flags = FlutterSemanticsFlags{
1328  .is_checked = FlutterCheckState::kFlutterCheckStateMixed,
1329  };
1330  root.flags2 = &updated_mixe_flags;
1331  bridge->AddFlutterSemanticsNodeUpdate(root);
1332  bridge->CommitUpdates();
1333 
1334  {
1335  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1336  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
1337  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1338  ax::mojom::CheckedState::kMixed);
1339 
1340  // Get the IAccessible for the root node.
1341  IAccessible* native_view = root_node->GetNativeViewAccessible();
1342  ASSERT_TRUE(native_view != nullptr);
1343 
1344  // Look up against the node itself (not one of its children).
1345  VARIANT varchild = {};
1346  varchild.vt = VT_I4;
1347 
1348  // Verify the checkbox is mixed.
1349  varchild.lVal = CHILDID_SELF;
1350  VARIANT native_state = {};
1351  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1352  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_MIXED);
1353 
1354  // Perform similar tests for UIA value;
1355  IRawElementProviderSimple* uia_node;
1356  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1357  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1358  UIA_ToggleToggleStatePropertyId, &native_state)));
1359  EXPECT_EQ(native_state.lVal, ToggleState_Indeterminate);
1360 
1361  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1362  UIA_AriaPropertiesPropertyId, &native_state)));
1363  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"checked=mixed"), nullptr);
1364  }
1365 }

References flutter::IAccessible.

◆ TEST() [66/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
DisablesVSyncAfterStartup   
)

Definition at line 1624 of file flutter_windows_view_unittests.cc.

1624  {
1625  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1626  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1627  auto egl_manager = std::make_unique<egl::MockManager>();
1628  egl::MockContext render_context;
1629  auto surface = std::make_unique<egl::MockWindowSurface>();
1630  auto surface_ptr = surface.get();
1631 
1632  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1633  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1634  .WillOnce(Return(true));
1635 
1636  EXPECT_CALL(*egl_manager.get(), render_context)
1637  .WillOnce(Return(&render_context));
1638  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1639 
1640  InSequence s;
1641  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1642  .WillOnce(Return(std::move(surface)));
1643  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1644  .WillOnce([](fml::closure callback) {
1645  callback();
1646  return true;
1647  });
1648  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1649  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1650  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1651  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1652  .WillOnce([](fml::closure callback) {
1653  callback();
1654  return true;
1655  });
1656  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1657 
1658  EngineModifier modifier{engine.get()};
1659  modifier.SetEGLManager(std::move(egl_manager));
1660 
1661  std::unique_ptr<FlutterWindowsView> view =
1662  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1663  /*is_sized_to_content=*/false, BoxConstraints());
1664 }

References callback.

◆ TEST() [67/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
DisablesVSyncAtStartup   
)

Definition at line 1551 of file flutter_windows_view_unittests.cc.

1551  {
1552  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1553  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1554  auto egl_manager = std::make_unique<egl::MockManager>();
1555  egl::MockContext render_context;
1556  auto surface = std::make_unique<egl::MockWindowSurface>();
1557  auto surface_ptr = surface.get();
1558 
1559  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(false));
1560  EXPECT_CALL(*engine.get(), PostRasterThreadTask).Times(0);
1561 
1562  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1563  .WillOnce(Return(true));
1564 
1565  EXPECT_CALL(*egl_manager.get(), render_context)
1566  .WillOnce(Return(&render_context));
1567  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1568 
1569  InSequence s;
1570  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1571  .WillOnce(Return(std::move(surface)));
1572  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1573  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1574  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1575 
1576  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1577 
1578  EngineModifier modifier{engine.get()};
1579  modifier.SetEGLManager(std::move(egl_manager));
1580 
1581  std::unique_ptr<FlutterWindowsView> view =
1582  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1583  /*is_sized_to_content=*/false, BoxConstraints());
1584 }

◆ TEST() [68/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
EnableSemantics   
)

Definition at line 398 of file flutter_windows_view_unittests.cc.

398  {
399  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
400  EngineModifier modifier(engine.get());
401 
402  bool semantics_enabled = false;
403  modifier.embedder_api().UpdateSemanticsEnabled = MOCK_ENGINE_PROC(
404  UpdateSemanticsEnabled,
405  [&semantics_enabled](FLUTTER_API_SYMBOL(FlutterEngine) engine,
406  bool enabled) {
407  semantics_enabled = enabled;
408  return kSuccess;
409  });
410 
411  auto window_binding_handler =
412  std::make_unique<NiceMock<MockWindowBindingHandler>>();
413  std::unique_ptr<FlutterWindowsView> view =
414  engine->CreateView(std::move(window_binding_handler),
415  /*is_sized_to_content=*/false, BoxConstraints());
416 
417  view->OnUpdateSemanticsEnabled(true);
418  EXPECT_TRUE(semantics_enabled);
419 }

◆ TEST() [69/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
EnablesVSyncAfterStartup   
)

Definition at line 1668 of file flutter_windows_view_unittests.cc.

1668  {
1669  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1670  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1671  auto egl_manager = std::make_unique<egl::MockManager>();
1672  egl::MockContext render_context;
1673  auto surface = std::make_unique<egl::MockWindowSurface>();
1674  auto surface_ptr = surface.get();
1675 
1676  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1677 
1678  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1679  .WillOnce(Return(false));
1680 
1681  EXPECT_CALL(*egl_manager.get(), render_context)
1682  .WillOnce(Return(&render_context));
1683  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1684 
1685  InSequence s;
1686  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1687  .WillOnce(Return(std::move(surface)));
1688  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1689  .WillOnce([](fml::closure callback) {
1690  callback();
1691  return true;
1692  });
1693 
1694  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1695  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1696  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1697 
1698  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1699  .WillOnce([](fml::closure callback) {
1700  callback();
1701  return true;
1702  });
1703  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1704 
1705  EngineModifier modifier{engine.get()};
1706  modifier.SetEGLManager(std::move(egl_manager));
1707 
1708  std::unique_ptr<FlutterWindowsView> view =
1709  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1710  /*is_sized_to_content=*/false, BoxConstraints());
1711 }

References callback.

◆ TEST() [70/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
EnablesVSyncAtStartup   
)

Definition at line 1588 of file flutter_windows_view_unittests.cc.

1588  {
1589  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1590  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1591  auto egl_manager = std::make_unique<egl::MockManager>();
1592  egl::MockContext render_context;
1593  auto surface = std::make_unique<egl::MockWindowSurface>();
1594  auto surface_ptr = surface.get();
1595 
1596  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(false));
1597  EXPECT_CALL(*engine.get(), PostRasterThreadTask).Times(0);
1598  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1599  .WillOnce(Return(false));
1600 
1601  EXPECT_CALL(*egl_manager.get(), render_context)
1602  .WillOnce(Return(&render_context));
1603  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1604 
1605  InSequence s;
1606  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1607  .WillOnce(Return(std::move(surface)));
1608  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1609  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1610  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1611 
1612  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1613 
1614  EngineModifier modifier{engine.get()};
1615  modifier.SetEGLManager(std::move(egl_manager));
1616 
1617  std::unique_ptr<FlutterWindowsView> view =
1618  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1619  /*is_sized_to_content=*/false, BoxConstraints());
1620 }

◆ TEST() [71/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
FirstFrameCallbackFiresOnFramePresented   
)

Definition at line 1857 of file flutter_windows_view_unittests.cc.

1857  {
1858  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1859 
1860  std::unique_ptr<FlutterWindowsView> view =
1861  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1862  /*is_sized_to_content=*/false, BoxConstraints());
1863 
1864  bool callback_fired = false;
1865  view->SetFirstFrameCallback([&callback_fired]() { callback_fired = true; });
1866 
1867  // Simulate the raster thread presenting a frame.
1868  view->OnFramePresented();
1869 
1870  // The callback is posted to the platform thread's task runner.
1871  // Process pending tasks to execute it.
1872  engine->task_runner()->ProcessTasks();
1873 
1874  EXPECT_TRUE(callback_fired);
1875 }

◆ TEST() [72/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
FirstFrameCallbackFiresOnlyOnce   
)

Definition at line 1906 of file flutter_windows_view_unittests.cc.

1906  {
1907  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1908 
1909  std::unique_ptr<FlutterWindowsView> view =
1910  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1911  /*is_sized_to_content=*/false, BoxConstraints());
1912 
1913  int callback_count = 0;
1914  view->SetFirstFrameCallback([&callback_count]() { callback_count++; });
1915 
1916  // Present two frames.
1917  view->OnFramePresented();
1918  view->OnFramePresented();
1919 
1920  // Process all pending tasks.
1921  engine->task_runner()->ProcessTasks();
1922 
1923  EXPECT_EQ(callback_count, 1);
1924 }

◆ TEST() [73/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
FirstFrameCallbackFiresOnSoftwareBitmapPresent   
)

Definition at line 1879 of file flutter_windows_view_unittests.cc.

1879  {
1880  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1881 
1882  auto window_binding_handler =
1883  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1884  EXPECT_CALL(*window_binding_handler, OnBitmapSurfaceUpdated)
1885  .WillOnce(Return(true));
1886 
1887  std::unique_ptr<FlutterWindowsView> view =
1888  engine->CreateView(std::move(window_binding_handler),
1889  /*is_sized_to_content=*/false, BoxConstraints());
1890 
1891  bool callback_fired = false;
1892  view->SetFirstFrameCallback([&callback_fired]() { callback_fired = true; });
1893 
1894  // Simulate software rendering presenting a bitmap.
1895  const uint32_t pixel = 0;
1896  view->PresentSoftwareBitmap(&pixel, sizeof(pixel), 1);
1897 
1898  // Process pending tasks.
1899  engine->task_runner()->ProcessTasks();
1900 
1901  EXPECT_TRUE(callback_fired);
1902 }

◆ TEST() [74/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
FirstFrameCallbackSkippedOnFailedSoftwarePresent   
)

Definition at line 1928 of file flutter_windows_view_unittests.cc.

1928  {
1929  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1930 
1931  auto window_binding_handler =
1932  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1933  EXPECT_CALL(*window_binding_handler, OnBitmapSurfaceUpdated)
1934  .WillOnce(Return(false));
1935 
1936  std::unique_ptr<FlutterWindowsView> view =
1937  engine->CreateView(std::move(window_binding_handler),
1938  /*is_sized_to_content=*/false, BoxConstraints());
1939 
1940  bool callback_fired = false;
1941  view->SetFirstFrameCallback([&callback_fired]() { callback_fired = true; });
1942 
1943  const uint32_t pixel = 0;
1944  view->PresentSoftwareBitmap(&pixel, sizeof(pixel), 1);
1945 
1946  engine->task_runner()->ProcessTasks();
1947 
1948  EXPECT_FALSE(callback_fired);
1949 }

◆ TEST() [75/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
FocusTriggersWindowFocus   
)

Definition at line 1778 of file flutter_windows_view_unittests.cc.

1778  {
1779  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1780  auto window_binding_handler =
1781  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1782  EXPECT_CALL(*window_binding_handler, Focus()).WillOnce(Return(true));
1783  std::unique_ptr<FlutterWindowsView> view =
1784  engine->CreateView(std::move(window_binding_handler),
1785  /*is_sized_to_content=*/false, BoxConstraints());
1786  EXPECT_TRUE(view->Focus());
1787 }

◆ TEST() [76/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
KeyEventCallback   
)

Definition at line 368 of file flutter_windows_view_unittests.cc.

368  {
369  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
370 
371  std::unique_ptr<FlutterWindowsView> view =
372  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
373  /*is_sized_to_content=*/false, BoxConstraints());
374 
375  class MockCallback {
376  public:
377  MOCK_METHOD(void, Call, ());
378  };
379 
380  NiceMock<MockCallback> callback_with_valid_view;
381  NiceMock<MockCallback> callback_with_invalid_view;
382 
383  auto trigger_key_event = [&](NiceMock<MockCallback>& callback) {
384  view->OnKey(kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
385  [&](bool) { callback.Call(); });
386  };
387 
388  EXPECT_CALL(callback_with_valid_view, Call()).Times(1);
389  EXPECT_CALL(callback_with_invalid_view, Call()).Times(0);
390 
391  trigger_key_event(callback_with_valid_view);
392  engine->RemoveView(view->view_id());
393  trigger_key_event(callback_with_invalid_view);
394 
395  key_event_logs.clear();
396 }

References callback, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST() [77/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
KeySequence   
)

Definition at line 349 of file flutter_windows_view_unittests.cc.

349  {
350  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
351 
352  test_response = false;
353 
354  std::unique_ptr<FlutterWindowsView> view =
355  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
356  /*is_sized_to_content=*/false, BoxConstraints());
357 
358  view->OnKey(kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
359  [](bool handled) {});
360 
361  EXPECT_EQ(key_event_logs.size(), 2);
362  EXPECT_EQ(key_event_logs[0], kKeyEventFromEmbedder);
363  EXPECT_EQ(key_event_logs[1], kKeyEventFromChannel);
364 
365  key_event_logs.clear();
366 }

References kScanCodeKeyA, and kVirtualKeyA.

◆ TEST() [78/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
NonZeroSemanticsRoot   
)

Definition at line 725 of file flutter_windows_view_unittests.cc.

725  {
726  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
727  EngineModifier modifier(engine.get());
728  modifier.embedder_api().UpdateSemanticsEnabled =
729  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
730  return kSuccess;
731  };
732 
733  std::unique_ptr<FlutterWindowsView> view =
734  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
735  /*is_sized_to_content=*/false, BoxConstraints());
736 
737  // Enable semantics to instantiate accessibility bridge.
738  view->OnUpdateSemanticsEnabled(true);
739 
740  auto bridge = view->accessibility_bridge().lock();
741  ASSERT_TRUE(bridge);
742 
743  // Add root node.
744  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
745  std::vector<int32_t> node1_children{2};
746  node1.child_count = node1_children.size();
747  node1.children_in_traversal_order = node1_children.data();
748  node1.children_in_hit_test_order = node1_children.data();
749  auto empty_flags = FlutterSemanticsFlags{};
750  node1.flags2 = &empty_flags;
751 
752  FlutterSemanticsNode2 node2{sizeof(FlutterSemanticsNode2), 2};
753  node2.label = "prefecture";
754  node2.value = "Kyoto";
755  node2.flags2 = &empty_flags;
756  bridge->AddFlutterSemanticsNodeUpdate(node1);
757  bridge->AddFlutterSemanticsNodeUpdate(node2);
758  bridge->CommitUpdates();
759 
760  // Look up the root windows node delegate.
761  auto root_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
762  ASSERT_TRUE(root_delegate);
763  EXPECT_EQ(root_delegate->GetChildCount(), 1);
764 
765  // Look up the child node delegate
766  auto child_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
767  ASSERT_TRUE(child_delegate);
768  EXPECT_EQ(child_delegate->GetChildCount(), 0);
769 
770  // Ensure a node with ID 0 does not exist.
771  auto fake_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
772  ASSERT_FALSE(fake_delegate);
773 
774  // Get the root's native IAccessible object.
775  IAccessible* node1_accessible = root_delegate->GetNativeViewAccessible();
776  ASSERT_TRUE(node1_accessible != nullptr);
777 
778  // Property lookups will be made against this node itself.
779  VARIANT varchild{};
780  varchild.vt = VT_I4;
781  varchild.lVal = CHILDID_SELF;
782 
783  // Verify node type is a group.
784  VARIANT varrole{};
785  varrole.vt = VT_I4;
786  ASSERT_EQ(node1_accessible->get_accRole(varchild, &varrole), S_OK);
787  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_GROUPING);
788 
789  // Verify child count.
790  long node1_child_count = 0;
791  ASSERT_EQ(node1_accessible->get_accChildCount(&node1_child_count), S_OK);
792  EXPECT_EQ(node1_child_count, 1);
793 
794  {
795  // Look up first child of node1 (node0), a static text node.
796  varchild.lVal = 1;
797  IDispatch* node2_dispatch = nullptr;
798  ASSERT_EQ(node1_accessible->get_accChild(varchild, &node2_dispatch), S_OK);
799  ASSERT_TRUE(node2_dispatch != nullptr);
800  IAccessible* node2_accessible = nullptr;
801  ASSERT_EQ(node2_dispatch->QueryInterface(
802  IID_IAccessible, reinterpret_cast<void**>(&node2_accessible)),
803  S_OK);
804  ASSERT_TRUE(node2_accessible != nullptr);
805 
806  // Verify node name matches our label.
807  varchild.lVal = CHILDID_SELF;
808  BSTR bname = nullptr;
809  ASSERT_EQ(node2_accessible->get_accName(varchild, &bname), S_OK);
810  std::string name(_com_util::ConvertBSTRToString(bname));
811  EXPECT_EQ(name, "prefecture");
812 
813  // Verify node value matches.
814  BSTR bvalue = nullptr;
815  ASSERT_EQ(node2_accessible->get_accValue(varchild, &bvalue), S_OK);
816  std::string value(_com_util::ConvertBSTRToString(bvalue));
817  EXPECT_EQ(value, "Kyoto");
818 
819  // Verify node type is static text.
820  VARIANT varrole{};
821  varrole.vt = VT_I4;
822  ASSERT_EQ(node2_accessible->get_accRole(varchild, &varrole), S_OK);
823  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
824 
825  // Verify the parent node is the root.
826  IDispatch* parent_dispatch;
827  node2_accessible->get_accParent(&parent_dispatch);
828  IAccessible* parent_accessible;
829  ASSERT_EQ(
830  parent_dispatch->QueryInterface(
831  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
832  S_OK);
833  EXPECT_EQ(parent_accessible, node1_accessible);
834  }
835 }

References flutter::IAccessible.

◆ TEST() [79/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
OnFocusTriggersSendFocusViewEvent   
)

Definition at line 1789 of file flutter_windows_view_unittests.cc.

1789  {
1790  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1791  auto window_binding_handler =
1792  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1793  std::unique_ptr<FlutterWindowsView> view =
1794  engine->CreateView(std::move(window_binding_handler),
1795  /*is_sized_to_content=*/false, BoxConstraints());
1796 
1797  EngineModifier modifier(engine.get());
1798  bool received_focus_event = false;
1799  modifier.embedder_api().SendViewFocusEvent = MOCK_ENGINE_PROC(
1800  SendViewFocusEvent, [&](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
1801  FlutterViewFocusEvent const* event) {
1802  EXPECT_EQ(event->state, FlutterViewFocusState::kFocused);
1803  EXPECT_EQ(event->direction, FlutterViewFocusDirection::kUndefined);
1804  EXPECT_EQ(event->view_id, view->view_id());
1805  EXPECT_EQ(event->struct_size, sizeof(FlutterViewFocusEvent));
1806  received_focus_event = true;
1807  return kSuccess;
1808  });
1809  view->OnFocus(FlutterViewFocusState::kFocused,
1810  FlutterViewFocusDirection::kUndefined);
1811  EXPECT_TRUE(received_focus_event);
1812 }

◆ TEST() [80/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
Shutdown   
)

Definition at line 298 of file flutter_windows_view_unittests.cc.

298  {
299  auto engine = std::make_unique<MockFlutterWindowsEngine>();
300  auto window_binding_handler =
301  std::make_unique<NiceMock<MockWindowBindingHandler>>();
302  auto egl_manager = std::make_unique<egl::MockManager>();
303  auto surface = std::make_unique<egl::MockWindowSurface>();
304  egl::MockContext render_context;
305 
306  auto engine_ptr = engine.get();
307  auto surface_ptr = surface.get();
308  auto egl_manager_ptr = egl_manager.get();
309 
310  EngineModifier modifier{engine.get()};
311  modifier.SetEGLManager(std::move(egl_manager));
312 
313  InSequence s;
314  std::unique_ptr<FlutterWindowsView> view;
315 
316  // Mock render surface initialization.
317  {
318  EXPECT_CALL(*egl_manager_ptr, CreateWindowSurface)
319  .WillOnce(Return(std::move(surface)));
320  EXPECT_CALL(*engine_ptr, running).WillOnce(Return(false));
321  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
322  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
323  EXPECT_CALL(*surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
324  EXPECT_CALL(*egl_manager_ptr, render_context)
325  .WillOnce(Return(&render_context));
326  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
327 
328  view = engine->CreateView(std::move(window_binding_handler), false,
329  BoxConstraints());
330  }
331 
332  // The view must be removed before the surface can be destroyed.
333  {
334  auto view_id = view->view_id();
335  FlutterWindowsViewController controller{std::move(engine), std::move(view)};
336 
337  EXPECT_CALL(*engine_ptr, running).WillOnce(Return(true));
338  EXPECT_CALL(*engine_ptr, RemoveView(view_id)).Times(1);
339  EXPECT_CALL(*engine_ptr, running).WillOnce(Return(true));
340  EXPECT_CALL(*engine_ptr, PostRasterThreadTask)
341  .WillOnce([](fml::closure callback) {
342  callback();
343  return true;
344  });
345  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
346  }
347 }

References callback.

◆ TEST() [81/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
SizeChangeTriggersMetricsEventWhichHasDisplayId   
)

Definition at line 1830 of file flutter_windows_view_unittests.cc.

1830  {
1831  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1832  EngineModifier modifier(engine.get());
1833 
1834  auto window_binding_handler =
1835  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1836  EXPECT_CALL(*window_binding_handler, GetDisplayId)
1837  .WillOnce(testing::Return(12));
1838  FlutterWindowsView view{kImplicitViewId, engine.get(),
1839  std::move(window_binding_handler), false,
1840  BoxConstraints()};
1841 
1842  bool received_metrics = false;
1843  modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1844  SendWindowMetricsEvent,
1845  ([&received_metrics](auto engine,
1846  const FlutterWindowMetricsEvent* event) {
1847  received_metrics = true;
1848  EXPECT_EQ(event->display_id, 12);
1849  return kSuccess;
1850  }));
1851  view.OnWindowSizeChanged(100, 100);
1852  EXPECT_TRUE(received_metrics);
1853 }
constexpr FlutterViewId kImplicitViewId

References flutter::kImplicitViewId.

◆ TEST() [82/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
SubMenuExpandedState   
)

Definition at line 188 of file flutter_windows_view_unittests.cc.

188  {
189  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
190  EngineModifier modifier(engine.get());
191  modifier.embedder_api().UpdateSemanticsEnabled =
192  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
193  return kSuccess;
194  };
195 
196  auto window_binding_handler =
197  std::make_unique<NiceMock<MockWindowBindingHandler>>();
198  std::unique_ptr<FlutterWindowsView> view =
199  engine->CreateView(std::move(window_binding_handler),
200  /*is_sized_to_content=*/false, BoxConstraints());
201 
202  // Enable semantics to instantiate accessibility bridge.
203  view->OnUpdateSemanticsEnabled(true);
204 
205  auto bridge = view->accessibility_bridge().lock();
206  ASSERT_TRUE(bridge);
207 
208  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
209  root.id = 0;
210  root.label = "root";
211  root.hint = "";
212  root.value = "";
213  root.increased_value = "";
214  root.decreased_value = "";
215  root.child_count = 0;
216  root.custom_accessibility_actions_count = 0;
217  auto flags = FlutterSemanticsFlags{
218  .is_expanded = FlutterTristate::kFlutterTristateTrue,
219  };
220  root.flags2 = &flags;
221 
222  bridge->AddFlutterSemanticsNodeUpdate(root);
223 
224  bridge->CommitUpdates();
225 
226  {
227  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
228  EXPECT_TRUE(root_node->GetData().HasState(ax::mojom::State::kExpanded));
229 
230  // Get the IAccessible for the root node.
231  IAccessible* native_view = root_node->GetNativeViewAccessible();
232  ASSERT_TRUE(native_view != nullptr);
233 
234  // Look up against the node itself (not one of its children).
235  VARIANT varchild = {};
236  varchild.vt = VT_I4;
237 
238  // Verify the submenu is expanded.
239  varchild.lVal = CHILDID_SELF;
240  VARIANT native_state = {};
241  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
242  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_EXPANDED);
243 
244  // Perform similar tests for UIA value;
245  IRawElementProviderSimple* uia_node;
246  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
247  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
248  UIA_ExpandCollapseExpandCollapseStatePropertyId, &native_state)));
249  EXPECT_EQ(native_state.lVal, ExpandCollapseState_Expanded);
250 
251  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
252  UIA_AriaPropertiesPropertyId, &native_state)));
253  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"expanded=true"), nullptr);
254  }
255 
256  // Test collapsed too.
257  auto updated_flags = FlutterSemanticsFlags{
258  .is_expanded = FlutterTristate::kFlutterTristateFalse,
259  };
260  root.flags2 = &updated_flags;
261 
262  bridge->AddFlutterSemanticsNodeUpdate(root);
263  bridge->CommitUpdates();
264 
265  {
266  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
267  EXPECT_TRUE(root_node->GetData().HasState(ax::mojom::State::kCollapsed));
268 
269  // Get the IAccessible for the root node.
270  IAccessible* native_view = root_node->GetNativeViewAccessible();
271  ASSERT_TRUE(native_view != nullptr);
272 
273  // Look up against the node itself (not one of its children).
274  VARIANT varchild = {};
275  varchild.vt = VT_I4;
276 
277  // Verify the submenu is collapsed.
278  varchild.lVal = CHILDID_SELF;
279  VARIANT native_state = {};
280  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
281  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_COLLAPSED);
282 
283  // Perform similar tests for UIA value;
284  IRawElementProviderSimple* uia_node;
285  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
286  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
287  UIA_ExpandCollapseExpandCollapseStatePropertyId, &native_state)));
288  EXPECT_EQ(native_state.lVal, ExpandCollapseState_Collapsed);
289 
290  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
291  UIA_AriaPropertiesPropertyId, &native_state)));
292  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"expanded=false"), nullptr);
293  }
294 }

References flutter::IAccessible.

◆ TEST() [83/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
SwitchNativeState   
)

Definition at line 1368 of file flutter_windows_view_unittests.cc.

1368  {
1369  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1370  EngineModifier modifier(engine.get());
1371  modifier.embedder_api().UpdateSemanticsEnabled =
1372  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
1373  return kSuccess;
1374  };
1375 
1376  std::unique_ptr<FlutterWindowsView> view =
1377  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1378  /*is_sized_to_content=*/false, BoxConstraints());
1379 
1380  // Enable semantics to instantiate accessibility bridge.
1381  view->OnUpdateSemanticsEnabled(true);
1382 
1383  auto bridge = view->accessibility_bridge().lock();
1384  ASSERT_TRUE(bridge);
1385 
1386  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
1387  root.id = 0;
1388  root.label = "root";
1389  root.hint = "";
1390  root.value = "";
1391  root.increased_value = "";
1392  root.decreased_value = "";
1393  root.child_count = 0;
1394  root.custom_accessibility_actions_count = 0;
1395 
1396  auto flags = FlutterSemanticsFlags{
1397  .is_toggled = FlutterTristate::kFlutterTristateTrue,
1398  };
1399  root.flags2 = &flags;
1400  bridge->AddFlutterSemanticsNodeUpdate(root);
1401 
1402  bridge->CommitUpdates();
1403 
1404  {
1405  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1406  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSwitch);
1407  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1408  ax::mojom::CheckedState::kTrue);
1409 
1410  // Get the IAccessible for the root node.
1411  IAccessible* native_view = root_node->GetNativeViewAccessible();
1412  ASSERT_TRUE(native_view != nullptr);
1413 
1414  // Look up against the node itself (not one of its children).
1415  VARIANT varchild = {};
1416  varchild.vt = VT_I4;
1417 
1418  varchild.lVal = CHILDID_SELF;
1419  VARIANT varrole = {};
1420 
1421  // Verify the role of the switch is CHECKBUTTON
1422  ASSERT_EQ(native_view->get_accRole(varchild, &varrole), S_OK);
1423  ASSERT_EQ(varrole.lVal, ROLE_SYSTEM_CHECKBUTTON);
1424 
1425  // Verify the switch is pressed.
1426  VARIANT native_state = {};
1427  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1428  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_PRESSED);
1429  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_CHECKED);
1430 
1431  // Test similarly on UIA node.
1432  IRawElementProviderSimple* uia_node;
1433  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1434  ASSERT_EQ(uia_node->GetPropertyValue(UIA_ControlTypePropertyId, &varrole),
1435  S_OK);
1436  EXPECT_EQ(varrole.lVal, UIA_ButtonControlTypeId);
1437  ASSERT_EQ(uia_node->GetPropertyValue(UIA_ToggleToggleStatePropertyId,
1438  &native_state),
1439  S_OK);
1440  EXPECT_EQ(native_state.lVal, ToggleState_On);
1441  ASSERT_EQ(
1442  uia_node->GetPropertyValue(UIA_AriaPropertiesPropertyId, &native_state),
1443  S_OK);
1444  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"pressed=true"), nullptr);
1445  }
1446 
1447  // Test unpressed too.
1448  auto updated_flags = FlutterSemanticsFlags{
1449  .is_toggled = FlutterTristate::kFlutterTristateFalse,
1450  };
1451  root.flags2 = &updated_flags;
1452 
1453  bridge->AddFlutterSemanticsNodeUpdate(root);
1454  bridge->CommitUpdates();
1455 
1456  {
1457  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1458  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSwitch);
1459  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1460  ax::mojom::CheckedState::kFalse);
1461 
1462  // Get the IAccessible for the root node.
1463  IAccessible* native_view = root_node->GetNativeViewAccessible();
1464  ASSERT_TRUE(native_view != nullptr);
1465 
1466  // Look up against the node itself (not one of its children).
1467  VARIANT varchild = {};
1468  varchild.vt = VT_I4;
1469 
1470  // Verify the switch is not pressed.
1471  varchild.lVal = CHILDID_SELF;
1472  VARIANT native_state = {};
1473  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1474  EXPECT_FALSE(native_state.lVal & STATE_SYSTEM_PRESSED);
1475  EXPECT_FALSE(native_state.lVal & STATE_SYSTEM_CHECKED);
1476 
1477  // Test similarly on UIA node.
1478  IRawElementProviderSimple* uia_node;
1479  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1480  ASSERT_EQ(uia_node->GetPropertyValue(UIA_ToggleToggleStatePropertyId,
1481  &native_state),
1482  S_OK);
1483  EXPECT_EQ(native_state.lVal, ToggleState_Off);
1484  ASSERT_EQ(
1485  uia_node->GetPropertyValue(UIA_AriaPropertiesPropertyId, &native_state),
1486  S_OK);
1487  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"pressed=false"), nullptr);
1488  }
1489 }

References flutter::IAccessible.

◆ TEST() [84/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
TestEmptyFrameResizes   
)

Definition at line 1024 of file flutter_windows_view_unittests.cc.

1024  {
1025  auto windows_proc_table = std::make_shared<NiceMock<MockWindowsProcTable>>();
1026  std::unique_ptr<FlutterWindowsEngine> engine =
1027  GetTestEngine(windows_proc_table);
1028 
1029  EngineModifier engine_modifier{engine.get()};
1030  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
1031  PostRenderThreadTask,
1032  ([](auto engine, VoidCallback callback, void* user_data) {
1034  return kSuccess;
1035  }));
1036 
1037  auto egl_manager = std::make_unique<egl::MockManager>();
1038  auto surface = std::make_unique<egl::MockWindowSurface>();
1039  auto resized_surface = std::make_unique<egl::MockWindowSurface>();
1040  auto resized_surface_ptr = resized_surface.get();
1041 
1042  EXPECT_CALL(*surface.get(), IsValid).WillRepeatedly(Return(true));
1043  EXPECT_CALL(*surface.get(), Destroy).WillOnce(Return(true));
1044 
1045  EXPECT_CALL(*egl_manager.get(),
1046  CreateWindowSurface(_, /*width=*/500, /*height=*/300))
1047  .WillOnce(Return(std::move((resized_surface))));
1048  EXPECT_CALL(*resized_surface_ptr, MakeCurrent).WillOnce(Return(true));
1049  EXPECT_CALL(*resized_surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
1050  EXPECT_CALL(*windows_proc_table.get(), DwmFlush).WillOnce(Return(S_OK));
1051 
1052  EXPECT_CALL(*resized_surface_ptr, Destroy).WillOnce(Return(true));
1053 
1054  fml::AutoResetWaitableEvent metrics_sent_latch;
1055  engine_modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1056  SendWindowMetricsEvent,
1057  ([&metrics_sent_latch](auto engine,
1058  const FlutterWindowMetricsEvent* event) {
1059  metrics_sent_latch.Signal();
1060  return kSuccess;
1061  }));
1062 
1063  std::unique_ptr<FlutterWindowsView> view =
1064  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1065  /*is_sized_to_content=*/false, BoxConstraints());
1066 
1067  ViewModifier view_modifier{view.get()};
1068  engine_modifier.SetEGLManager(std::move(egl_manager));
1069  view_modifier.SetSurface(std::move(surface));
1070 
1071  // Simulate raster thread.
1072  std::thread frame_thread([&metrics_sent_latch, &view]() {
1073  metrics_sent_latch.Wait();
1074 
1075  // Empty frame generated and presented from the raster thread.
1076  EXPECT_TRUE(view->OnEmptyFrameGenerated());
1077  view->OnFramePresented();
1078  });
1079 
1080  // Start the window resize. This sends the new window metrics
1081  // and then blocks until another thread completes the window resize.
1082  EXPECT_TRUE(view->OnWindowSizeChanged(500, 300));
1083  frame_thread.join();
1084 }
void(* VoidCallback)(void *)

References callback, and user_data.

◆ TEST() [85/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
TooltipNodeData   
)

Definition at line 1491 of file flutter_windows_view_unittests.cc.

1491  {
1492  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1493  EngineModifier modifier(engine.get());
1494  modifier.embedder_api().UpdateSemanticsEnabled =
1495  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
1496  return kSuccess;
1497  };
1498 
1499  std::unique_ptr<FlutterWindowsView> view =
1500  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1501  /*is_sized_to_content=*/false, BoxConstraints());
1502 
1503  // Enable semantics to instantiate accessibility bridge.
1504  view->OnUpdateSemanticsEnabled(true);
1505 
1506  auto bridge = view->accessibility_bridge().lock();
1507  ASSERT_TRUE(bridge);
1508 
1509  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
1510  root.id = 0;
1511  root.label = "root";
1512  root.hint = "";
1513  root.value = "";
1514  root.increased_value = "";
1515  root.decreased_value = "";
1516  root.tooltip = "tooltip";
1517  root.child_count = 0;
1518  root.custom_accessibility_actions_count = 0;
1519  auto flags = FlutterSemanticsFlags{
1520  .is_text_field = true,
1521  };
1522  root.flags2 = &flags;
1523  bridge->AddFlutterSemanticsNodeUpdate(root);
1524 
1525  bridge->CommitUpdates();
1526  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1527  std::string tooltip = root_node->GetData().GetStringAttribute(
1528  ax::mojom::StringAttribute::kTooltip);
1529  EXPECT_EQ(tooltip, "tooltip");
1530 
1531  // Check that MSAA name contains the tooltip.
1532  IAccessible* native_view = bridge->GetFlutterPlatformNodeDelegateFromID(0)
1533  .lock()
1534  ->GetNativeViewAccessible();
1535  VARIANT varchild = {.vt = VT_I4, .lVal = CHILDID_SELF};
1536  BSTR bname;
1537  ASSERT_EQ(native_view->get_accName(varchild, &bname), S_OK);
1538  EXPECT_NE(std::wcsstr(bname, L"tooltip"), nullptr);
1539 
1540  // Check that UIA help text is equal to the tooltip.
1541  IRawElementProviderSimple* uia_node;
1542  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1543  VARIANT varname{};
1544  ASSERT_EQ(uia_node->GetPropertyValue(UIA_HelpTextPropertyId, &varname), S_OK);
1545  std::string uia_tooltip = _com_util::ConvertBSTRToString(varname.bstrVal);
1546  EXPECT_EQ(uia_tooltip, "tooltip");
1547 }

References flutter::IAccessible.

◆ TEST() [86/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
UpdatesVSyncOnDwmUpdates   
)

Definition at line 1716 of file flutter_windows_view_unittests.cc.

1716  {
1717  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1718  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1719  auto egl_manager = std::make_unique<egl::MockManager>();
1720  egl::MockContext render_context;
1721  auto surface = std::make_unique<egl::MockWindowSurface>();
1722  auto surface_ptr = surface.get();
1723 
1724  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1725 
1726  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1727  .WillRepeatedly([](fml::closure callback) {
1728  callback();
1729  return true;
1730  });
1731 
1732  EXPECT_CALL(*egl_manager.get(), render_context)
1733  .WillRepeatedly(Return(&render_context));
1734 
1735  EXPECT_CALL(*surface_ptr, IsValid).WillRepeatedly(Return(true));
1736  EXPECT_CALL(*surface_ptr, MakeCurrent).WillRepeatedly(Return(true));
1737  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1738  EXPECT_CALL(render_context, ClearCurrent).WillRepeatedly(Return(true));
1739 
1740  InSequence s;
1741 
1742  // Mock render surface initialization.
1743  std::unique_ptr<FlutterWindowsView> view;
1744  {
1745  EXPECT_CALL(*egl_manager, CreateWindowSurface)
1746  .WillOnce(Return(std::move(surface)));
1747  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1748  .WillOnce(Return(true));
1749  EXPECT_CALL(*surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
1750 
1751  EngineModifier engine_modifier{engine.get()};
1752  engine_modifier.SetEGLManager(std::move(egl_manager));
1753 
1754  view = engine->CreateView(
1755  std::make_unique<NiceMock<MockWindowBindingHandler>>(), false,
1756  BoxConstraints());
1757  }
1758 
1759  // Disabling DWM composition should enable vsync blocking on the surface.
1760  {
1761  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1762  .WillOnce(Return(false));
1763  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1764 
1765  engine->OnDwmCompositionChanged();
1766  }
1767 
1768  // Enabling DWM composition should disable vsync blocking on the surface.
1769  {
1770  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1771  .WillOnce(Return(true));
1772  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1773 
1774  engine->OnDwmCompositionChanged();
1775  }
1776 }

References callback.

◆ TEST() [87/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
WindowMetricsEventContainsDisplayId   
)

Definition at line 1814 of file flutter_windows_view_unittests.cc.

1814  {
1815  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1816  EngineModifier modifier(engine.get());
1817 
1818  auto window_binding_handler =
1819  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1820  EXPECT_CALL(*window_binding_handler, GetDisplayId)
1821  .WillOnce(testing::Return(12));
1822  FlutterWindowsView view{kImplicitViewId, engine.get(),
1823  std::move(window_binding_handler), false,
1824  BoxConstraints()};
1825 
1826  FlutterWindowMetricsEvent event = view.CreateWindowMetricsEvent();
1827  EXPECT_EQ(event.display_id, 12);
1828 }

References flutter::kImplicitViewId.

◆ TEST() [88/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
WindowRepaintTests   
)

Definition at line 1193 of file flutter_windows_view_unittests.cc.

1193  {
1194  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1195  EngineModifier modifier(engine.get());
1196 
1197  FlutterWindowsView view{kImplicitViewId, engine.get(),
1198  std::make_unique<flutter::FlutterWindow>(
1199  100, 100, engine->display_manager()),
1200  /*is_sized_to_content=*/false, BoxConstraints()};
1201 
1202  bool schedule_frame_called = false;
1203  modifier.embedder_api().ScheduleFrame =
1204  MOCK_ENGINE_PROC(ScheduleFrame, ([&schedule_frame_called](auto engine) {
1205  schedule_frame_called = true;
1206  return kSuccess;
1207  }));
1208 
1209  view.OnWindowRepaint();
1210  EXPECT_TRUE(schedule_frame_called);
1211 }

References flutter::kImplicitViewId.

◆ TEST() [89/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
WindowResizeInvalidSurface   
)

Definition at line 1129 of file flutter_windows_view_unittests.cc.

1129  {
1130  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1131 
1132  EngineModifier engine_modifier(engine.get());
1133  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
1134  PostRenderThreadTask,
1135  ([](auto engine, VoidCallback callback, void* user_data) {
1137  return kSuccess;
1138  }));
1139 
1140  auto egl_manager = std::make_unique<egl::MockManager>();
1141  auto surface = std::make_unique<egl::MockWindowSurface>();
1142 
1143  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface).Times(0);
1144  EXPECT_CALL(*surface.get(), IsValid).WillRepeatedly(Return(false));
1145  EXPECT_CALL(*surface.get(), Destroy).WillOnce(Return(false));
1146 
1147  std::unique_ptr<FlutterWindowsView> view =
1148  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1149  /*is_sized_to_content=*/false, BoxConstraints());
1150 
1151  ViewModifier view_modifier{view.get()};
1152  engine_modifier.SetEGLManager(std::move(egl_manager));
1153  view_modifier.SetSurface(std::move(surface));
1154 
1155  auto metrics_sent = false;
1156  engine_modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1157  SendWindowMetricsEvent,
1158  ([&metrics_sent](auto engine, const FlutterWindowMetricsEvent* event) {
1159  metrics_sent = true;
1160  return kSuccess;
1161  }));
1162 
1163  view->OnWindowSizeChanged(500, 500);
1164 }

References callback, and user_data.

◆ TEST() [90/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
WindowResizeRace   
)

Definition at line 1089 of file flutter_windows_view_unittests.cc.

1089  {
1090  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1091 
1092  EngineModifier engine_modifier(engine.get());
1093  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
1094  PostRenderThreadTask,
1095  ([](auto engine, VoidCallback callback, void* user_data) {
1097  return kSuccess;
1098  }));
1099 
1100  auto egl_manager = std::make_unique<egl::MockManager>();
1101  auto surface = std::make_unique<egl::MockWindowSurface>();
1102 
1103  EXPECT_CALL(*surface.get(), IsValid).WillRepeatedly(Return(true));
1104  EXPECT_CALL(*surface.get(), Destroy).WillOnce(Return(true));
1105 
1106  std::unique_ptr<FlutterWindowsView> view =
1107  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1108  /*is_sized_to_content=*/false, BoxConstraints());
1109 
1110  ViewModifier view_modifier{view.get()};
1111  engine_modifier.SetEGLManager(std::move(egl_manager));
1112  view_modifier.SetSurface(std::move(surface));
1113 
1114  // Begin a frame.
1115  ASSERT_TRUE(view->OnFrameGenerated(100, 100));
1116 
1117  // Inject a window resize between the frame generation and
1118  // frame presentation. The new size invalidates the current frame.
1119  EXPECT_FALSE(view->OnWindowSizeChanged(500, 500));
1120 
1121  // Complete the invalidated frame while a resize is pending. Although this
1122  // might mean that we presented a frame with the wrong size, this should not
1123  // crash the app.
1124  view->OnFramePresented();
1125 }

References callback, and user_data.

◆ TEST() [91/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
WindowResizeTests   
)

Definition at line 952 of file flutter_windows_view_unittests.cc.

952  {
953  auto windows_proc_table = std::make_shared<NiceMock<MockWindowsProcTable>>();
954  std::unique_ptr<FlutterWindowsEngine> engine =
955  GetTestEngine(windows_proc_table);
956 
957  EngineModifier engine_modifier{engine.get()};
958  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
959  PostRenderThreadTask,
960  ([](auto engine, VoidCallback callback, void* user_data) {
962  return kSuccess;
963  }));
964 
965  auto egl_manager = std::make_unique<egl::MockManager>();
966  auto surface = std::make_unique<egl::MockWindowSurface>();
967  auto resized_surface = std::make_unique<egl::MockWindowSurface>();
968  egl::MockContext render_context;
969 
970  auto surface_ptr = surface.get();
971  auto resized_surface_ptr = resized_surface.get();
972 
973  // Mock render surface creation
974  EXPECT_CALL(*egl_manager, CreateWindowSurface)
975  .WillOnce(Return(std::move(surface)));
976  EXPECT_CALL(*surface_ptr, IsValid).WillRepeatedly(Return(true));
977  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
978  EXPECT_CALL(*surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
979  EXPECT_CALL(*egl_manager, render_context).WillOnce(Return(&render_context));
980  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
981 
982  // Mock render surface resize
983  EXPECT_CALL(*surface_ptr, Destroy).WillOnce(Return(true));
984  EXPECT_CALL(*egl_manager.get(),
985  CreateWindowSurface(_, /*width=*/500, /*height=*/500))
986  .WillOnce(Return(std::move((resized_surface))));
987  EXPECT_CALL(*resized_surface_ptr, MakeCurrent).WillOnce(Return(true));
988  EXPECT_CALL(*resized_surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
989  EXPECT_CALL(*windows_proc_table.get(), DwmFlush).WillOnce(Return(S_OK));
990 
991  EXPECT_CALL(*resized_surface_ptr, Destroy).WillOnce(Return(true));
992 
993  engine_modifier.SetEGLManager(std::move(egl_manager));
994 
995  std::unique_ptr<FlutterWindowsView> view =
996  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
997  /*is_sized_to_content=*/false, BoxConstraints());
998 
999  fml::AutoResetWaitableEvent metrics_sent_latch;
1000  engine_modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1001  SendWindowMetricsEvent,
1002  ([&metrics_sent_latch](auto engine,
1003  const FlutterWindowMetricsEvent* event) {
1004  metrics_sent_latch.Signal();
1005  return kSuccess;
1006  }));
1007 
1008  // Simulate raster thread.
1009  std::thread frame_thread([&metrics_sent_latch, &view]() {
1010  metrics_sent_latch.Wait();
1011  // Frame generated and presented from the raster thread.
1012  EXPECT_TRUE(view->OnFrameGenerated(500, 500));
1013  view->OnFramePresented();
1014  });
1015 
1016  // Start the window resize. This sends the new window metrics
1017  // and then blocks polling run loop until another thread completes the window
1018  // resize.
1019  EXPECT_TRUE(view->OnWindowSizeChanged(500, 500));
1020  frame_thread.join();
1021 }

References callback, and user_data.

◆ TEST() [92/174]

flutter::testing::TEST ( FlutterWindowsViewTest  ,
WindowResizeWithoutSurface   
)

Definition at line 1168 of file flutter_windows_view_unittests.cc.

1168  {
1169  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1170  EngineModifier modifier(engine.get());
1171 
1172  auto egl_manager = std::make_unique<egl::MockManager>();
1173 
1174  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface).Times(0);
1175 
1176  std::unique_ptr<FlutterWindowsView> view =
1177  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1178  /*is_sized_to_content=*/false, BoxConstraints());
1179 
1180  modifier.SetEGLManager(std::move(egl_manager));
1181 
1182  auto metrics_sent = false;
1183  modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1184  SendWindowMetricsEvent,
1185  ([&metrics_sent](auto engine, const FlutterWindowMetricsEvent* event) {
1186  metrics_sent = true;
1187  return kSuccess;
1188  }));
1189 
1190  view->OnWindowSizeChanged(500, 500);
1191 }

◆ TEST() [93/174]

flutter::testing::TEST ( KeyboardKeyChannelHandlerTest  ,
DeadKeysDoNotCrash   
)

Definition at line 128 of file keyboard_key_channel_handler_unittests.cc.

128  {
129  bool received = false;
130  TestBinaryMessenger messenger(
131  [&received](const std::string& channel, const uint8_t* message,
132  size_t message_size, BinaryReply reply) {
133  if (channel == "flutter/keyevent") {
134  auto message_doc = JsonMessageCodec::GetInstance().DecodeMessage(
135  message, message_size);
136  uint32_t character = (*message_doc)[kCharacterCodePointKey].GetUint();
137  EXPECT_EQ(character, (uint32_t)'^');
138  received = true;
139  }
140  return true;
141  });
142 
143  KeyboardKeyChannelHandler handler(&messenger);
144  // Extended key flag is passed to redispatched events if set.
145  handler.KeyboardHook(0xDD, 0x1a, WM_KEYDOWN, 0x8000005E, false, false,
146  [](bool handled) {});
147 
148  // EXPECT is done during the callback above.
149  EXPECT_TRUE(received);
150 }
Win32Message message
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply

References character, flutter::MessageCodec< T >::DecodeMessage(), flutter::JsonMessageCodec::GetInstance(), and message.

◆ TEST() [94/174]

flutter::testing::TEST ( KeyboardKeyChannelHandlerTest  ,
EmptyResponsesDoNotCrash   
)

Definition at line 152 of file keyboard_key_channel_handler_unittests.cc.

152  {
153  bool received = false;
154  TestBinaryMessenger messenger(
155  [&received](const std::string& channel, const uint8_t* message,
156  size_t message_size, BinaryReply reply) {
157  if (channel == "flutter/keyevent") {
158  std::string empty_message = "";
159  std::vector<uint8_t> empty_response(empty_message.begin(),
160  empty_message.end());
161  reply(empty_response.data(), empty_response.size());
162  received = true;
163  }
164  return true;
165  });
166 
167  KeyboardKeyChannelHandler handler(&messenger);
168  handler.KeyboardHook(64, kUnhandledScanCode, WM_KEYDOWN, L'b', false, false,
169  [](bool handled) {});
170 
171  // Passes if it does not crash.
172  EXPECT_TRUE(received);
173 }

References message.

◆ TEST() [95/174]

flutter::testing::TEST ( KeyboardKeyChannelHandlerTest  ,
ExtendedKeysAreSentToRedispatch   
)

Definition at line 88 of file keyboard_key_channel_handler_unittests.cc.

88  {
89  auto handled_message = CreateResponse(true);
90  auto unhandled_message = CreateResponse(false);
91  int received_scancode = 0;
92 
93  TestBinaryMessenger messenger(
94  [&received_scancode, &handled_message, &unhandled_message](
95  const std::string& channel, const uint8_t* message,
96  size_t message_size, BinaryReply reply) {
97  if (channel == "flutter/keyevent") {
98  auto message_doc = JsonMessageCodec::GetInstance().DecodeMessage(
99  message, message_size);
100  received_scancode = (*message_doc)[kScanCodeKey].GetInt();
101  if (received_scancode == kHandledScanCode) {
102  reply(handled_message->data(), handled_message->size());
103  } else {
104  reply(unhandled_message->data(), unhandled_message->size());
105  }
106  }
107  });
108 
109  KeyboardKeyChannelHandler handler(&messenger);
110  bool last_handled = true;
111 
112  // Extended key flag is passed to redispatched events if set.
113  handler.KeyboardHook(
114  64, kUnhandledScanCode, WM_KEYDOWN, L'b', true, false,
115  [&last_handled](bool handled) { last_handled = handled; });
116  EXPECT_EQ(last_handled, false);
117  EXPECT_EQ(received_scancode, kUnhandledScanCodeExtended);
118 
119  last_handled = true;
120  // Extended key flag is not passed to redispatched events if not set.
121  handler.KeyboardHook(
122  64, kUnhandledScanCode, WM_KEYDOWN, L'b', false, false,
123  [&last_handled](bool handled) { last_handled = handled; });
124  EXPECT_EQ(last_handled, false);
125  EXPECT_EQ(received_scancode, kUnhandledScanCode);
126 }

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

◆ TEST() [96/174]

flutter::testing::TEST ( KeyboardKeyChannelHandlerTest  ,
KeyboardHookHandling   
)

Definition at line 33 of file keyboard_key_channel_handler_unittests.cc.

33  {
34  auto handled_message = CreateResponse(true);
35  auto unhandled_message = CreateResponse(false);
36  int received_scancode = 0;
37 
38  TestBinaryMessenger messenger(
39  [&received_scancode, &handled_message, &unhandled_message](
40  const std::string& channel, const uint8_t* message,
41  size_t message_size, BinaryReply reply) {
42  if (channel == "flutter/keyevent") {
43  auto message_doc = JsonMessageCodec::GetInstance().DecodeMessage(
44  message, message_size);
45  received_scancode = (*message_doc)[kScanCodeKey].GetInt();
46  if (received_scancode == kHandledScanCode) {
47  reply(handled_message->data(), handled_message->size());
48  } else {
49  reply(unhandled_message->data(), unhandled_message->size());
50  }
51  }
52  });
53 
54  KeyboardKeyChannelHandler handler(&messenger);
55  bool last_handled = false;
56 
57  handler.KeyboardHook(
58  64, kHandledScanCode, WM_KEYDOWN, L'a', false, false,
59  [&last_handled](bool handled) { last_handled = handled; });
60  EXPECT_EQ(received_scancode, kHandledScanCode);
61  EXPECT_EQ(last_handled, true);
62 
63  received_scancode = 0;
64 
65  handler.KeyboardHook(
66  64, kUnhandledScanCode, WM_KEYDOWN, L'b', false, false,
67  [&last_handled](bool handled) { last_handled = handled; });
68  EXPECT_EQ(received_scancode, kUnhandledScanCode);
69  EXPECT_EQ(last_handled, false);
70 
71  received_scancode = 0;
72 
73  handler.KeyboardHook(
74  64, kHandledScanCode, WM_SYSKEYDOWN, L'a', false, false,
75  [&last_handled](bool handled) { last_handled = handled; });
76  EXPECT_EQ(received_scancode, kHandledScanCode);
77  EXPECT_EQ(last_handled, true);
78 
79  received_scancode = 0;
80 
81  handler.KeyboardHook(
82  64, kUnhandledScanCode, WM_SYSKEYDOWN, L'c', false, false,
83  [&last_handled](bool handled) { last_handled = handled; });
84  EXPECT_EQ(received_scancode, kUnhandledScanCode);
85  EXPECT_EQ(last_handled, false);
86 }

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

◆ TEST() [97/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
AbruptRepeatIsConvertedToDown   
)

Definition at line 777 of file keyboard_key_embedder_handler_unittests.cc.

777  {
778  TestKeystate key_state;
779  std::vector<TestFlutterKeyEvent> results;
780  TestFlutterKeyEvent* event;
781  bool last_handled = false;
782 
783  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
784  std::make_unique<KeyboardKeyEmbedderHandler>(
785  [&results](const FlutterKeyEvent& event,
786  FlutterKeyEventCallback callback, void* user_data) {
787  results.emplace_back(event, callback, user_data);
788  },
789  key_state.Getter(), DefaultMapVkToScan);
790  last_handled = false;
791 
792  key_state.Set(kVirtualKeyA, true);
793 
794  // Press A (with was_down true)
795  handler->KeyboardHook(
796  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, true,
797  [&last_handled](bool handled) { last_handled = handled; });
798  EXPECT_EQ(last_handled, false);
799  EXPECT_EQ(results.size(), 1);
800  event = &results[0];
801  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
802  EXPECT_EQ(event->physical, kPhysicalKeyA);
803  EXPECT_EQ(event->logical, kLogicalKeyA);
804  EXPECT_STREQ(event->character, "a");
805  EXPECT_EQ(event->synthesized, false);
806 
807  event->callback(true, event->user_data);
808  EXPECT_EQ(last_handled, true);
809  results.clear();
810 
811  // Release A
812  last_handled = false;
813  key_state.Set(kVirtualKeyA, false);
814  handler->KeyboardHook(
815  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 'a', false, true,
816  [&last_handled](bool handled) { last_handled = handled; });
817  EXPECT_EQ(last_handled, false);
818  EXPECT_EQ(results.size(), 1);
819  event = &results[0];
820  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
821  EXPECT_EQ(event->physical, kPhysicalKeyA);
822  EXPECT_EQ(event->logical, kLogicalKeyA);
823  EXPECT_STREQ(event->character, "");
824  EXPECT_EQ(event->synthesized, false);
825 
826  event->callback(true, event->user_data);
827  EXPECT_EQ(last_handled, true);
828  results.clear();
829 }
FlutterKeyEventCallback callback

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [98/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
AbruptUpIsIgnored   
)

Definition at line 831 of file keyboard_key_embedder_handler_unittests.cc.

831  {
832  TestKeystate key_state;
833  std::vector<TestFlutterKeyEvent> results;
834  TestFlutterKeyEvent* event;
835  bool last_handled = false;
836 
837  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
838  std::make_unique<KeyboardKeyEmbedderHandler>(
839  [&results](const FlutterKeyEvent& event,
840  FlutterKeyEventCallback callback, void* user_data) {
841  results.emplace_back(event, callback, user_data);
842  },
843  key_state.Getter(), DefaultMapVkToScan);
844  last_handled = false;
845 
846  // KeyA's key down is missed.
847 
848  key_state.Set(kVirtualKeyA, true);
849 
850  // Press A again (should yield an empty event)
851  last_handled = false;
852  handler->KeyboardHook(
853  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 'a', false, true,
854  [&last_handled](bool handled) { last_handled = handled; });
855  EXPECT_EQ(last_handled, true);
856  EXPECT_EQ(results.size(), 1);
857  event = &results[0];
858  EXPECT_EQ(event->physical, 0);
859  EXPECT_EQ(event->logical, 0);
860  EXPECT_EQ(event->callback, nullptr);
861  results.clear();
862 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [99/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
BasicKeyPressingAndHolding   
)

Definition at line 119 of file keyboard_key_embedder_handler_unittests.cc.

119  {
120  TestKeystate key_state;
121  std::vector<TestFlutterKeyEvent> results;
122  TestFlutterKeyEvent* event;
123  bool last_handled = false;
124 
125  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
126  std::make_unique<KeyboardKeyEmbedderHandler>(
127  [&results](const FlutterKeyEvent& event,
128  FlutterKeyEventCallback callback, void* user_data) {
129  results.emplace_back(event, callback, user_data);
130  },
131  key_state.Getter(), DefaultMapVkToScan);
132 
133  // Press KeyA.
134  handler->KeyboardHook(
135  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
136  [&last_handled](bool handled) { last_handled = handled; });
137  EXPECT_EQ(last_handled, false);
138  EXPECT_EQ(results.size(), 1);
139  event = &results[0];
140  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
141  EXPECT_EQ(event->physical, kPhysicalKeyA);
142  EXPECT_EQ(event->logical, kLogicalKeyA);
143  EXPECT_STREQ(event->character, "a");
144  EXPECT_EQ(event->synthesized, false);
145 
146  event->callback(true, event->user_data);
147  EXPECT_EQ(last_handled, true);
148  results.clear();
149  key_state.Set(kVirtualKeyA, true);
150 
151  // Hold KeyA.
152  handler->KeyboardHook(
153  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, true,
154  [&last_handled](bool handled) { last_handled = handled; });
155  EXPECT_EQ(last_handled, true);
156  EXPECT_EQ(results.size(), 1);
157  event = &results[0];
158  EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
159  EXPECT_EQ(event->physical, kPhysicalKeyA);
160  EXPECT_EQ(event->logical, kLogicalKeyA);
161  EXPECT_STREQ(event->character, "a");
162  EXPECT_EQ(event->synthesized, false);
163 
164  event->callback(false, event->user_data);
165  EXPECT_EQ(last_handled, false);
166  results.clear();
167 
168  // Release KeyA.
169  handler->KeyboardHook(
170  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 0, false, true,
171  [&last_handled](bool handled) { last_handled = handled; });
172  EXPECT_EQ(results.size(), 1);
173  event = &results[0];
174  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
175  EXPECT_EQ(event->physical, kPhysicalKeyA);
176  EXPECT_EQ(event->logical, kLogicalKeyA);
177  EXPECT_STREQ(event->character, "");
178  EXPECT_EQ(event->synthesized, false);
179  event->callback(false, event->user_data);
180 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [100/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
ConvertChar32ToUtf8   
)

Definition at line 90 of file keyboard_key_embedder_handler_unittests.cc.

90  {
91  std::string result;
92 
93  result = ConvertChar32ToUtf8(0x0024);
94  EXPECT_EQ(result.length(), 1);
95  EXPECT_EQ(result[0], '\x24');
96 
97  result = ConvertChar32ToUtf8(0x00A2);
98  EXPECT_EQ(result.length(), 2);
99  EXPECT_EQ(result[0], '\xC2');
100  EXPECT_EQ(result[1], '\xA2');
101 
102  result = ConvertChar32ToUtf8(0x0939);
103  EXPECT_EQ(result.length(), 3);
104  EXPECT_EQ(result[0], '\xE0');
105  EXPECT_EQ(result[1], '\xA4');
106  EXPECT_EQ(result[2], '\xB9');
107 
108  result = ConvertChar32ToUtf8(0x10348);
109  EXPECT_EQ(result.length(), 4);
110  EXPECT_EQ(result[0], '\xF0');
111  EXPECT_EQ(result[1], '\x90');
112  EXPECT_EQ(result[2], '\x8D');
113  EXPECT_EQ(result[3], '\x88');
114 }
std::string ConvertChar32ToUtf8(char32_t ch)

References flutter::ConvertChar32ToUtf8().

◆ TEST() [101/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
DoNotSynthesizeModifierDownWhenPressed   
)

Definition at line 562 of file keyboard_key_embedder_handler_unittests.cc.

562  {
563  TestKeystate key_state;
564  std::vector<TestFlutterKeyEvent> results;
565  TestFlutterKeyEvent* event;
566  bool last_handled = false;
567 
568  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
569  std::make_unique<KeyboardKeyEmbedderHandler>(
570  [&results](const FlutterKeyEvent& event,
571  FlutterKeyEventCallback callback, void* user_data) {
572  results.emplace_back(event, callback, user_data);
573  },
574  key_state.Getter(), DefaultMapVkToScan);
575 
576  // Should not synthesize shift left key down event when shift left key
577  // is already pressed.
578  handler->KeyboardHook(
579  VK_LSHIFT, kScanCodeShiftLeft, WM_KEYDOWN, 0, false, true,
580  [&last_handled](bool handled) { last_handled = handled; });
581  results.clear();
582  handler->SyncModifiersIfNeeded(kShift);
583  EXPECT_EQ(results.size(), 0);
584 
585  // Should not synthesize shift left key down event when shift right key
586  // is already pressed.
587  handler->KeyboardHook(
588  VK_RSHIFT, kScanCodeShiftRight, WM_KEYDOWN, 0, false, true,
589  [&last_handled](bool handled) { last_handled = handled; });
590  results.clear();
591  handler->SyncModifiersIfNeeded(kShift);
592  EXPECT_EQ(results.size(), 0);
593 
594  // Should not synthesize control left key down event when control left key
595  // is already pressed.
596  handler->KeyboardHook(
597  VK_LCONTROL, kScanCodeControlLeft, WM_KEYDOWN, 0, false, true,
598  [&last_handled](bool handled) { last_handled = handled; });
599  results.clear();
600  handler->SyncModifiersIfNeeded(kControl);
601  EXPECT_EQ(results.size(), 0);
602 
603  // Should not synthesize control left key down event when control right key
604  // is already pressed .
605  handler->KeyboardHook(
606  VK_RCONTROL, kScanCodeControlRight, WM_KEYDOWN, 0, true, true,
607  [&last_handled](bool handled) { last_handled = handled; });
608  results.clear();
609  handler->SyncModifiersIfNeeded(kControl);
610  EXPECT_EQ(results.size(), 0);
611 }
constexpr int kShift
constexpr int kScanCodeShiftRight
constexpr int kScanCodeShiftLeft
constexpr int kScanCodeControlRight
constexpr int kScanCodeControlLeft
constexpr int kControl

References callback, flutter::kControl, flutter::kScanCodeControlLeft, flutter::kScanCodeControlRight, flutter::kScanCodeShiftLeft, flutter::kScanCodeShiftRight, flutter::kShift, and user_data.

◆ TEST() [102/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
DoNotSynthesizeModifierUpWhenNotPressed   
)

Definition at line 696 of file keyboard_key_embedder_handler_unittests.cc.

696  {
697  TestKeystate key_state;
698  std::vector<TestFlutterKeyEvent> results;
699  TestFlutterKeyEvent* event;
700  bool last_handled = false;
701 
702  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
703  std::make_unique<KeyboardKeyEmbedderHandler>(
704  [&results](const FlutterKeyEvent& event,
705  FlutterKeyEventCallback callback, void* user_data) {
706  results.emplace_back(event, callback, user_data);
707  },
708  key_state.Getter(), DefaultMapVkToScan);
709 
710  // Should not synthesize up events when no modifier key is pressed
711  // in pressing state and modifiers state is zero.
712  handler->SyncModifiersIfNeeded(0);
713  EXPECT_EQ(results.size(), 0);
714 }

References callback, and user_data.

◆ TEST() [103/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
ImeEventsAreIgnored   
)

Definition at line 259 of file keyboard_key_embedder_handler_unittests.cc.

259  {
260  TestKeystate key_state;
261  std::vector<TestFlutterKeyEvent> results;
262  TestFlutterKeyEvent* event;
263  bool last_handled = false;
264 
265  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
266  std::make_unique<KeyboardKeyEmbedderHandler>(
267  [&results](const FlutterKeyEvent& event,
268  FlutterKeyEventCallback callback, void* user_data) {
269  results.emplace_back(event, callback, user_data);
270  },
271  key_state.Getter(), DefaultMapVkToScan);
272 
273  // Press A in an IME
274  last_handled = false;
275  handler->KeyboardHook(
276  VK_PROCESSKEY, kScanCodeKeyA, WM_KEYDOWN, 0, true, false,
277  [&last_handled](bool handled) { last_handled = handled; });
278  EXPECT_EQ(last_handled, true);
279 
280  // The A key down should yield an empty event.
281  EXPECT_EQ(results.size(), 1);
282  event = &results[0];
283  EXPECT_EQ(event->physical, 0);
284  EXPECT_EQ(event->logical, 0);
285  EXPECT_EQ(event->callback, nullptr);
286  results.clear();
287 
288  // Release A in an IME
289  last_handled = false;
290  handler->KeyboardHook(
291  // The up event for an IME press has a normal virtual key.
292  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 0, true, true,
293  [&last_handled](bool handled) { last_handled = handled; });
294  EXPECT_EQ(last_handled, true);
295 
296  // The A key up should yield an empty event.
297  EXPECT_EQ(results.size(), 1);
298  event = &results[0];
299  EXPECT_EQ(event->physical, 0);
300  EXPECT_EQ(event->logical, 0);
301  EXPECT_EQ(event->callback, nullptr);
302  results.clear();
303 
304  // Press A out of an IME
305  key_state.Set(kVirtualKeyA, true);
306  last_handled = false;
307  handler->KeyboardHook(
308  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 0, true, false,
309  [&last_handled](bool handled) { last_handled = handled; });
310  // Not decided yet
311  EXPECT_EQ(last_handled, false);
312  EXPECT_EQ(results.size(), 1);
313  event = &results[0];
314  event->callback(true, event->user_data);
315  EXPECT_EQ(last_handled, true);
316  results.clear();
317 
318  last_handled = false;
319  key_state.Set(kVirtualKeyA, false);
320  handler->KeyboardHook(
321  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 0, true, false,
322  [&last_handled](bool handled) { last_handled = handled; });
323  EXPECT_EQ(last_handled, false);
324  EXPECT_EQ(results.size(), 1);
325  event = &results[0];
326  event->callback(true, event->user_data);
327  EXPECT_EQ(last_handled, true);
328 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [104/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
ModifierKeysByExtendedBit   
)

Definition at line 333 of file keyboard_key_embedder_handler_unittests.cc.

333  {
334  TestKeystate key_state;
335  std::vector<TestFlutterKeyEvent> results;
336  TestFlutterKeyEvent* event;
337  bool last_handled = false;
338 
339  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
340  std::make_unique<KeyboardKeyEmbedderHandler>(
341  [&results](const FlutterKeyEvent& event,
342  FlutterKeyEventCallback callback, void* user_data) {
343  results.emplace_back(event, callback, user_data);
344  },
345  key_state.Getter(), DefaultMapVkToScan);
346 
347  // Press Ctrl left.
348  last_handled = false;
349  key_state.Set(VK_LCONTROL, true);
350  handler->KeyboardHook(
351  VK_LCONTROL, kScanCodeControl, WM_KEYDOWN, 0, false, false,
352  [&last_handled](bool handled) { last_handled = handled; });
353  EXPECT_EQ(last_handled, false);
354  EXPECT_EQ(results.size(), 1);
355  event = &results[0];
356  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
357  EXPECT_EQ(event->physical, kPhysicalControlLeft);
358  EXPECT_EQ(event->logical, kLogicalControlLeft);
359  EXPECT_STREQ(event->character, "");
360  EXPECT_EQ(event->synthesized, false);
361 
362  event->callback(true, event->user_data);
363  EXPECT_EQ(last_handled, true);
364  results.clear();
365 
366  // Press Ctrl right.
367  last_handled = false;
368  key_state.Set(VK_RCONTROL, true);
369  handler->KeyboardHook(
370  VK_RCONTROL, kScanCodeControl, WM_KEYDOWN, 0, true, true,
371  [&last_handled](bool handled) { last_handled = handled; });
372  EXPECT_EQ(last_handled, false);
373  EXPECT_EQ(results.size(), 1);
374  event = &results[0];
375  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
376  EXPECT_EQ(event->physical, kPhysicalControlRight);
377  EXPECT_EQ(event->logical, kLogicalControlRight);
378  EXPECT_STREQ(event->character, "");
379  EXPECT_EQ(event->synthesized, false);
380 
381  event->callback(true, event->user_data);
382  EXPECT_EQ(last_handled, true);
383  results.clear();
384 
385  // Release Ctrl left.
386  last_handled = false;
387  key_state.Set(VK_LCONTROL, false);
388  handler->KeyboardHook(
389  VK_LCONTROL, kScanCodeControl, WM_KEYUP, 0, false, true,
390  [&last_handled](bool handled) { last_handled = handled; });
391  EXPECT_EQ(last_handled, false);
392  EXPECT_EQ(results.size(), 1);
393  event = &results[0];
394  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
395  EXPECT_EQ(event->physical, kPhysicalControlLeft);
396  EXPECT_EQ(event->logical, kLogicalControlLeft);
397  EXPECT_STREQ(event->character, "");
398  EXPECT_EQ(event->synthesized, false);
399 
400  event->callback(true, event->user_data);
401  EXPECT_EQ(last_handled, true);
402  results.clear();
403 
404  // Release Ctrl right.
405  last_handled = false;
406  key_state.Set(VK_RCONTROL, false);
407  handler->KeyboardHook(
408  VK_RCONTROL, kScanCodeControl, WM_KEYUP, 0, true, true,
409  [&last_handled](bool handled) { last_handled = handled; });
410  EXPECT_EQ(last_handled, false);
411  EXPECT_EQ(results.size(), 1);
412  event = &results[0];
413  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
414  EXPECT_EQ(event->physical, kPhysicalControlRight);
415  EXPECT_EQ(event->logical, kLogicalControlRight);
416  EXPECT_STREQ(event->character, "");
417  EXPECT_EQ(event->synthesized, false);
418 
419  event->callback(true, event->user_data);
420  EXPECT_EQ(last_handled, true);
421  results.clear();
422 }

References callback, and user_data.

◆ TEST() [105/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
ModifierKeysByVirtualKey   
)

Definition at line 426 of file keyboard_key_embedder_handler_unittests.cc.

426  {
427  TestKeystate key_state;
428  std::vector<TestFlutterKeyEvent> results;
429  TestFlutterKeyEvent* event;
430  bool last_handled = false;
431 
432  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
433  std::make_unique<KeyboardKeyEmbedderHandler>(
434  [&results](const FlutterKeyEvent& event,
435  FlutterKeyEventCallback callback, void* user_data) {
436  results.emplace_back(event, callback, user_data);
437  },
438  key_state.Getter(), DefaultMapVkToScan);
439 
440  // Press Shift left.
441  last_handled = false;
442  key_state.Set(VK_LSHIFT, true);
443  handler->KeyboardHook(
444  VK_LSHIFT, kScanCodeShiftLeft, WM_KEYDOWN, 0, false, false,
445  [&last_handled](bool handled) { last_handled = handled; });
446  EXPECT_EQ(last_handled, false);
447  EXPECT_EQ(results.size(), 1);
448  event = &results[0];
449  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
450  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
451  EXPECT_EQ(event->logical, kLogicalShiftLeft);
452  EXPECT_STREQ(event->character, "");
453  EXPECT_EQ(event->synthesized, false);
454 
455  event->callback(true, event->user_data);
456  EXPECT_EQ(last_handled, true);
457  results.clear();
458 
459  // Press Shift right.
460  last_handled = false;
461  key_state.Set(VK_RSHIFT, true);
462  handler->KeyboardHook(
463  VK_RSHIFT, kScanCodeShiftRight, WM_KEYDOWN, 0, false, false,
464  [&last_handled](bool handled) { last_handled = handled; });
465  EXPECT_EQ(last_handled, false);
466  EXPECT_EQ(results.size(), 1);
467  event = &results[0];
468  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
469  EXPECT_EQ(event->physical, kPhysicalShiftRight);
470  EXPECT_EQ(event->logical, kLogicalShiftRight);
471  EXPECT_STREQ(event->character, "");
472  EXPECT_EQ(event->synthesized, false);
473 
474  event->callback(true, event->user_data);
475  EXPECT_EQ(last_handled, true);
476  results.clear();
477 
478  // Release Shift left.
479  last_handled = false;
480  key_state.Set(VK_LSHIFT, false);
481  handler->KeyboardHook(
482  VK_LSHIFT, kScanCodeShiftLeft, WM_KEYUP, 0, false, true,
483  [&last_handled](bool handled) { last_handled = handled; });
484  EXPECT_EQ(last_handled, false);
485  EXPECT_EQ(results.size(), 1);
486  event = &results[0];
487  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
488  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
489  EXPECT_EQ(event->logical, kLogicalShiftLeft);
490  EXPECT_STREQ(event->character, "");
491  EXPECT_EQ(event->synthesized, false);
492 
493  event->callback(true, event->user_data);
494  EXPECT_EQ(last_handled, true);
495  results.clear();
496 
497  // Release Shift right.
498  last_handled = false;
499  key_state.Set(VK_RSHIFT, false);
500  handler->KeyboardHook(
501  VK_RSHIFT, kScanCodeShiftRight, WM_KEYUP, 0, false, true,
502  [&last_handled](bool handled) { last_handled = handled; });
503  EXPECT_EQ(last_handled, false);
504  EXPECT_EQ(results.size(), 1);
505  event = &results[0];
506  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
507  EXPECT_EQ(event->physical, kPhysicalShiftRight);
508  EXPECT_EQ(event->logical, kLogicalShiftRight);
509  EXPECT_STREQ(event->character, "");
510  EXPECT_EQ(event->synthesized, false);
511 
512  event->callback(true, event->user_data);
513  EXPECT_EQ(last_handled, true);
514  results.clear();
515 }

References callback, flutter::kScanCodeShiftLeft, flutter::kScanCodeShiftRight, and user_data.

◆ TEST() [106/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
RepeatedDownIsIgnored   
)

Definition at line 716 of file keyboard_key_embedder_handler_unittests.cc.

716  {
717  TestKeystate key_state;
718  std::vector<TestFlutterKeyEvent> results;
719  TestFlutterKeyEvent* event;
720  bool last_handled = false;
721 
722  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
723  std::make_unique<KeyboardKeyEmbedderHandler>(
724  [&results](const FlutterKeyEvent& event,
725  FlutterKeyEventCallback callback, void* user_data) {
726  results.emplace_back(event, callback, user_data);
727  },
728  key_state.Getter(), DefaultMapVkToScan);
729  last_handled = false;
730 
731  // Press A (should yield a normal event)
732  handler->KeyboardHook(
733  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
734  [&last_handled](bool handled) { last_handled = handled; });
735  EXPECT_EQ(last_handled, false);
736  EXPECT_EQ(results.size(), 1);
737  event = &results[0];
738  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
739  EXPECT_EQ(event->physical, kPhysicalKeyA);
740  EXPECT_EQ(event->logical, kLogicalKeyA);
741  EXPECT_STREQ(event->character, "a");
742  EXPECT_EQ(event->synthesized, false);
743 
744  event->callback(true, event->user_data);
745  EXPECT_EQ(last_handled, true);
746  results.clear();
747 
748  // KeyA's key up is missed.
749 
750  // Press A again (should synthesize an up event followed by a new down).
751  last_handled = false;
752  handler->KeyboardHook(
753  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
754  [&last_handled](bool handled) { last_handled = handled; });
755  EXPECT_EQ(last_handled, false);
756  ASSERT_EQ(results.size(), 2u);
757 
758  event = &results[0];
759  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
760  EXPECT_EQ(event->physical, kPhysicalKeyA);
761  EXPECT_EQ(event->logical, kLogicalKeyA);
762  EXPECT_STREQ(event->character, "");
763  EXPECT_EQ(event->synthesized, true);
764  EXPECT_EQ(event->callback, nullptr);
765 
766  event = &results[1];
767  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
768  EXPECT_EQ(event->physical, kPhysicalKeyA);
769  EXPECT_EQ(event->logical, kLogicalKeyA);
770  EXPECT_STREQ(event->character, "a");
771  EXPECT_EQ(event->synthesized, false);
772  event->callback(true, event->user_data);
773  EXPECT_EQ(last_handled, true);
774  results.clear();
775 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [107/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SynthesizeForDesyncPressingState   
)

Definition at line 864 of file keyboard_key_embedder_handler_unittests.cc.

864  {
865  TestKeystate key_state;
866  std::vector<TestFlutterKeyEvent> results;
867  TestFlutterKeyEvent* event;
868  bool last_handled = false;
869 
870  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
871  std::make_unique<KeyboardKeyEmbedderHandler>(
872  [&results](const FlutterKeyEvent& event,
873  FlutterKeyEventCallback callback, void* user_data) {
874  results.emplace_back(event, callback, user_data);
875  },
876  key_state.Getter(), DefaultMapVkToScan);
877 
878  // A key down of control left is missed.
879  key_state.Set(VK_LCONTROL, true);
880 
881  // Send a normal event
882  key_state.Set(kVirtualKeyA, true);
883  handler->KeyboardHook(
884  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
885  [&last_handled](bool handled) { last_handled = handled; });
886  EXPECT_EQ(last_handled, false);
887  EXPECT_EQ(results.size(), 2);
888  event = &results[0];
889  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
890  EXPECT_EQ(event->physical, kPhysicalControlLeft);
891  EXPECT_EQ(event->logical, kLogicalControlLeft);
892  EXPECT_STREQ(event->character, "");
893  EXPECT_EQ(event->synthesized, true);
894  EXPECT_EQ(event->callback, nullptr);
895 
896  event = &results[1];
897  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
898  EXPECT_EQ(event->physical, kPhysicalKeyA);
899  EXPECT_EQ(event->logical, kLogicalKeyA);
900  EXPECT_STREQ(event->character, "a");
901  EXPECT_EQ(event->synthesized, false);
902 
903  last_handled = true;
904  event->callback(false, event->user_data);
905  EXPECT_EQ(last_handled, false);
906  results.clear();
907 
908  // A key down of control right is missed.
909  key_state.Set(VK_LCONTROL, false);
910 
911  // Hold KeyA.
912  handler->KeyboardHook(
913  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, true,
914  [&last_handled](bool handled) { last_handled = handled; });
915  EXPECT_EQ(last_handled, false);
916  EXPECT_EQ(results.size(), 2);
917  event = &results[0];
918  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
919  EXPECT_EQ(event->physical, kPhysicalControlLeft);
920  EXPECT_EQ(event->logical, kLogicalControlLeft);
921  EXPECT_STREQ(event->character, "");
922  EXPECT_EQ(event->synthesized, true);
923  EXPECT_EQ(event->callback, nullptr);
924 
925  event = &results[1];
926  EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
927  EXPECT_EQ(event->physical, kPhysicalKeyA);
928  EXPECT_EQ(event->logical, kLogicalKeyA);
929  EXPECT_STREQ(event->character, "a");
930  EXPECT_EQ(event->synthesized, false);
931 
932  last_handled = true;
933  event->callback(false, event->user_data);
934  EXPECT_EQ(last_handled, false);
935  results.clear();
936 
937  // Release KeyA.
938  key_state.Set(kVirtualKeyA, false);
939  handler->KeyboardHook(
940  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 0, false, true,
941  [&last_handled](bool handled) { last_handled = handled; });
942  EXPECT_EQ(results.size(), 1);
943  event = &results[0];
944  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
945  EXPECT_EQ(event->physical, kPhysicalKeyA);
946  EXPECT_EQ(event->logical, kLogicalKeyA);
947  EXPECT_STREQ(event->character, "");
948  EXPECT_EQ(event->synthesized, false);
949  event->callback(false, event->user_data);
950 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [108/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SynthesizeForDesyncToggledState   
)

Definition at line 952 of file keyboard_key_embedder_handler_unittests.cc.

952  {
953  TestKeystate key_state;
954  std::vector<TestFlutterKeyEvent> results;
955  TestFlutterKeyEvent* event;
956  bool last_handled = false;
957 
958  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
959  std::make_unique<KeyboardKeyEmbedderHandler>(
960  [&results](const FlutterKeyEvent& event,
961  FlutterKeyEventCallback callback, void* user_data) {
962  results.emplace_back(event, callback, user_data);
963  },
964  key_state.Getter(), DefaultMapVkToScan);
965 
966  // The NumLock is desynchronized by toggled on
967  key_state.Set(VK_NUMLOCK, false, true);
968 
969  // Send a normal event
970  key_state.Set(kVirtualKeyA, true);
971  handler->KeyboardHook(
972  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
973  [&last_handled](bool handled) { last_handled = handled; });
974  EXPECT_EQ(last_handled, false);
975  EXPECT_EQ(results.size(), 3);
976  event = &results[0];
977  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
978  EXPECT_EQ(event->physical, kPhysicalNumLock);
979  EXPECT_EQ(event->logical, kLogicalNumLock);
980  EXPECT_STREQ(event->character, "");
981  EXPECT_EQ(event->synthesized, true);
982 
983  event = &results[1];
984  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
985  EXPECT_EQ(event->physical, kPhysicalNumLock);
986  EXPECT_EQ(event->logical, kLogicalNumLock);
987  EXPECT_STREQ(event->character, "");
988  EXPECT_EQ(event->synthesized, true);
989 
990  event = &results[2];
991  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
992  EXPECT_EQ(event->physical, kPhysicalKeyA);
993  EXPECT_EQ(event->logical, kLogicalKeyA);
994  EXPECT_STREQ(event->character, "a");
995  EXPECT_EQ(event->synthesized, false);
996 
997  event->callback(true, event->user_data);
998  EXPECT_EQ(last_handled, true);
999  results.clear();
1000 
1001  // Test if the NumLock is mis-toggled while it should also be pressed
1002  key_state.Set(VK_NUMLOCK, true, true);
1003 
1004  // Send a normal event
1005  handler->KeyboardHook(
1006  kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, true,
1007  [&last_handled](bool handled) { last_handled = handled; });
1008  EXPECT_EQ(last_handled, true);
1009  EXPECT_EQ(results.size(), 2);
1010  event = &results[0];
1011  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1012  EXPECT_EQ(event->physical, kPhysicalNumLock);
1013  EXPECT_EQ(event->logical, kLogicalNumLock);
1014  EXPECT_STREQ(event->character, "");
1015  EXPECT_EQ(event->synthesized, true);
1016 
1017  event = &results[1];
1018  EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
1019  EXPECT_EQ(event->physical, kPhysicalKeyA);
1020  EXPECT_EQ(event->logical, kLogicalKeyA);
1021  EXPECT_STREQ(event->character, "a");
1022  EXPECT_EQ(event->synthesized, false);
1023 
1024  event->callback(false, event->user_data);
1025  EXPECT_EQ(last_handled, false);
1026  results.clear();
1027 
1028  // Numlock is pressed at this moment.
1029 
1030  // Test if the NumLock is mis-toggled while it should also be released
1031  key_state.Set(VK_NUMLOCK, false, false);
1032 
1033  // Send a normal event
1034  key_state.Set(kVirtualKeyA, false);
1035  handler->KeyboardHook(
1036  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 0, false, true,
1037  [&last_handled](bool handled) { last_handled = handled; });
1038  EXPECT_EQ(results.size(), 4);
1039  event = &results[0];
1040  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1041  EXPECT_EQ(event->physical, kPhysicalNumLock);
1042  EXPECT_EQ(event->logical, kLogicalNumLock);
1043  EXPECT_STREQ(event->character, "");
1044  EXPECT_EQ(event->synthesized, true);
1045  EXPECT_EQ(event->callback, nullptr);
1046 
1047  event = &results[1];
1048  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1049  EXPECT_EQ(event->physical, kPhysicalNumLock);
1050  EXPECT_EQ(event->logical, kLogicalNumLock);
1051  EXPECT_STREQ(event->character, "");
1052  EXPECT_EQ(event->synthesized, true);
1053  EXPECT_EQ(event->callback, nullptr);
1054 
1055  event = &results[2];
1056  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1057  EXPECT_EQ(event->physical, kPhysicalNumLock);
1058  EXPECT_EQ(event->logical, kLogicalNumLock);
1059  EXPECT_STREQ(event->character, "");
1060  EXPECT_EQ(event->synthesized, true);
1061  EXPECT_EQ(event->callback, nullptr);
1062 
1063  event = &results[3];
1064  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1065  EXPECT_EQ(event->physical, kPhysicalKeyA);
1066  EXPECT_EQ(event->logical, kLogicalKeyA);
1067  EXPECT_STREQ(event->character, "");
1068  EXPECT_EQ(event->synthesized, false);
1069  event->callback(false, event->user_data);
1070 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [109/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SynthesizeForDesyncToggledStateByItselfsDown   
)

Definition at line 1132 of file keyboard_key_embedder_handler_unittests.cc.

1133  {
1134  TestKeystate key_state;
1135  std::vector<TestFlutterKeyEvent> results;
1136  TestFlutterKeyEvent* event;
1137  bool last_handled = false;
1138 
1139  // NumLock is started up and disabled
1140  key_state.Set(VK_NUMLOCK, false, false);
1141  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
1142  std::make_unique<KeyboardKeyEmbedderHandler>(
1143  [&results](const FlutterKeyEvent& event,
1144  FlutterKeyEventCallback callback, void* user_data) {
1145  results.emplace_back(event, callback, user_data);
1146  },
1147  key_state.Getter(), DefaultMapVkToScan);
1148 
1149  // NumLock is toggled somewhere else
1150  // key_state.Set(VK_NUMLOCK, false, true);
1151 
1152  // NumLock is pressed
1153  key_state.Set(VK_NUMLOCK, true, false);
1154  handler->KeyboardHook(
1155  VK_NUMLOCK, kScanCodeNumLock, WM_KEYDOWN, 0, true, false,
1156  [&last_handled](bool handled) { last_handled = handled; });
1157  EXPECT_EQ(last_handled, false);
1158  // 4 total events should be fired:
1159  // Pre-synchronization toggle, pre-sync press,
1160  // main event, and post-sync press.
1161  EXPECT_EQ(results.size(), 4);
1162  event = &results[0];
1163  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1164  EXPECT_EQ(event->physical, kPhysicalNumLock);
1165  EXPECT_EQ(event->logical, kLogicalNumLock);
1166  EXPECT_STREQ(event->character, "");
1167  EXPECT_EQ(event->synthesized, true);
1168  EXPECT_EQ(event->callback, nullptr);
1169 
1170  event = &results[1];
1171  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1172  EXPECT_EQ(event->physical, kPhysicalNumLock);
1173  EXPECT_EQ(event->logical, kLogicalNumLock);
1174  EXPECT_STREQ(event->character, "");
1175  EXPECT_EQ(event->synthesized, true);
1176  EXPECT_EQ(event->callback, nullptr);
1177 
1178  event = &results[2];
1179  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1180  EXPECT_EQ(event->physical, kPhysicalNumLock);
1181  EXPECT_EQ(event->logical, kLogicalNumLock);
1182  EXPECT_STREQ(event->character, "");
1183  EXPECT_EQ(event->synthesized, false);
1184 
1185  last_handled = false;
1186  event->callback(true, event->user_data);
1187  EXPECT_EQ(last_handled, true);
1188 }

References callback, and user_data.

◆ TEST() [110/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SynthesizeForDesyncToggledStateByItselfsUp   
)

Definition at line 1072 of file keyboard_key_embedder_handler_unittests.cc.

1073  {
1074  TestKeystate key_state;
1075  std::vector<TestFlutterKeyEvent> results;
1076  TestFlutterKeyEvent* event;
1077  bool last_handled = false;
1078 
1079  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
1080  std::make_unique<KeyboardKeyEmbedderHandler>(
1081  [&results](const FlutterKeyEvent& event,
1082  FlutterKeyEventCallback callback, void* user_data) {
1083  results.emplace_back(event, callback, user_data);
1084  },
1085  key_state.Getter(), DefaultMapVkToScan);
1086 
1087  // When NumLock is down
1088  key_state.Set(VK_NUMLOCK, true, true);
1089  handler->KeyboardHook(
1090  VK_NUMLOCK, kScanCodeNumLock, WM_KEYDOWN, 0, true, false,
1091  [&last_handled](bool handled) { last_handled = handled; });
1092  event = &results.back();
1093  event->callback(false, event->user_data);
1094  results.clear();
1095 
1096  // Numlock is desynchronized by being off and released
1097  key_state.Set(VK_NUMLOCK, false, false);
1098  // Send a NumLock key up
1099  handler->KeyboardHook(
1100  VK_NUMLOCK, kScanCodeNumLock, WM_KEYUP, 0, true, true,
1101  [&last_handled](bool handled) { last_handled = handled; });
1102  EXPECT_EQ(last_handled, false);
1103  EXPECT_EQ(results.size(), 3);
1104  event = &results[0];
1105  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1106  EXPECT_EQ(event->physical, kPhysicalNumLock);
1107  EXPECT_EQ(event->logical, kLogicalNumLock);
1108  EXPECT_STREQ(event->character, "");
1109  EXPECT_EQ(event->synthesized, true);
1110  EXPECT_EQ(event->callback, nullptr);
1111 
1112  event = &results[1];
1113  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1114  EXPECT_EQ(event->physical, kPhysicalNumLock);
1115  EXPECT_EQ(event->logical, kLogicalNumLock);
1116  EXPECT_STREQ(event->character, "");
1117  EXPECT_EQ(event->synthesized, true);
1118  EXPECT_EQ(event->callback, nullptr);
1119 
1120  event = &results[2];
1121  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1122  EXPECT_EQ(event->physical, kPhysicalNumLock);
1123  EXPECT_EQ(event->logical, kLogicalNumLock);
1124  EXPECT_STREQ(event->character, "");
1125  EXPECT_EQ(event->synthesized, false);
1126 
1127  last_handled = false;
1128  event->callback(true, event->user_data);
1129  EXPECT_EQ(last_handled, true);
1130 }

References callback, and user_data.

◆ TEST() [111/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SynthesizeModifierLeftKeyDownWhenNotPressed   
)

Definition at line 519 of file keyboard_key_embedder_handler_unittests.cc.

520  {
521  TestKeystate key_state;
522  std::vector<TestFlutterKeyEvent> results;
523  TestFlutterKeyEvent* event;
524  bool last_handled = false;
525 
526  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
527  std::make_unique<KeyboardKeyEmbedderHandler>(
528  [&results](const FlutterKeyEvent& event,
529  FlutterKeyEventCallback callback, void* user_data) {
530  results.emplace_back(event, callback, user_data);
531  },
532  key_state.Getter(), DefaultMapVkToScan);
533 
534  // Should synthesize shift left key down event.
535  handler->SyncModifiersIfNeeded(kShift);
536  EXPECT_EQ(results.size(), 1);
537  event = &results[0];
538  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
539  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
540  EXPECT_EQ(event->logical, kLogicalShiftLeft);
541  EXPECT_STREQ(event->character, "");
542  EXPECT_EQ(event->synthesized, true);
543  results.clear();
544 
545  // Clear the pressing state.
546  handler->SyncModifiersIfNeeded(0);
547  results.clear();
548 
549  // Should synthesize control left key down event.
550  handler->SyncModifiersIfNeeded(kControl);
551  EXPECT_EQ(results.size(), 1);
552  event = &results[0];
553  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
554  EXPECT_EQ(event->physical, kPhysicalControlLeft);
555  EXPECT_EQ(event->logical, kLogicalControlLeft);
556  EXPECT_STREQ(event->character, "");
557  EXPECT_EQ(event->synthesized, true);
558 }

References callback, flutter::kControl, flutter::kShift, and user_data.

◆ TEST() [112/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SynthesizeModifierUpWhenPressed   
)

Definition at line 615 of file keyboard_key_embedder_handler_unittests.cc.

615  {
616  TestKeystate key_state;
617  std::vector<TestFlutterKeyEvent> results;
618  TestFlutterKeyEvent* event;
619  bool last_handled = false;
620 
621  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
622  std::make_unique<KeyboardKeyEmbedderHandler>(
623  [&results](const FlutterKeyEvent& event,
624  FlutterKeyEventCallback callback, void* user_data) {
625  results.emplace_back(event, callback, user_data);
626  },
627  key_state.Getter(), DefaultMapVkToScan);
628 
629  // Should synthesize shift left key up event when shift left key is
630  // already pressed and modifiers state is zero.
631  handler->KeyboardHook(
632  VK_LSHIFT, kScanCodeShiftLeft, WM_KEYDOWN, 0, false, true,
633  [&last_handled](bool handled) { last_handled = handled; });
634  results.clear();
635  handler->SyncModifiersIfNeeded(0);
636  EXPECT_EQ(results.size(), 1);
637  event = &results[0];
638  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
639  EXPECT_EQ(event->physical, kPhysicalShiftLeft);
640  EXPECT_EQ(event->logical, kLogicalShiftLeft);
641  EXPECT_STREQ(event->character, "");
642  EXPECT_EQ(event->synthesized, true);
643  results.clear();
644 
645  // Should synthesize shift right key up event when shift right key is
646  // already pressed and modifiers state is zero.
647  handler->KeyboardHook(
648  VK_RSHIFT, kScanCodeShiftRight, WM_KEYDOWN, 0, false, true,
649  [&last_handled](bool handled) { last_handled = handled; });
650  results.clear();
651  handler->SyncModifiersIfNeeded(0);
652  EXPECT_EQ(results.size(), 1);
653  event = &results[0];
654  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
655  EXPECT_EQ(event->physical, kPhysicalShiftRight);
656  EXPECT_EQ(event->logical, kLogicalShiftRight);
657  EXPECT_STREQ(event->character, "");
658  EXPECT_EQ(event->synthesized, true);
659  results.clear();
660 
661  // Should synthesize control left key up event when control left key is
662  // already pressed and modifiers state is zero.
663  handler->KeyboardHook(
664  VK_LCONTROL, kScanCodeControlLeft, WM_KEYDOWN, 0, false, true,
665  [&last_handled](bool handled) { last_handled = handled; });
666  results.clear();
667  handler->SyncModifiersIfNeeded(0);
668  EXPECT_EQ(results.size(), 1);
669  event = &results[0];
670  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
671  EXPECT_EQ(event->physical, kPhysicalControlLeft);
672  EXPECT_EQ(event->logical, kLogicalControlLeft);
673  EXPECT_STREQ(event->character, "");
674  EXPECT_EQ(event->synthesized, true);
675  results.clear();
676 
677  // Should synthesize control right key up event when control right key is
678  // already pressed and modifiers state is zero.
679  handler->KeyboardHook(
680  VK_RCONTROL, kScanCodeControlRight, WM_KEYDOWN, 0, true, true,
681  [&last_handled](bool handled) { last_handled = handled; });
682  results.clear();
683  handler->SyncModifiersIfNeeded(0);
684  EXPECT_EQ(results.size(), 1);
685  event = &results[0];
686  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
687  EXPECT_EQ(event->physical, kPhysicalControlRight);
688  EXPECT_EQ(event->logical, kLogicalControlRight);
689  EXPECT_STREQ(event->character, "");
690  EXPECT_EQ(event->synthesized, true);
691  results.clear();
692 }

References callback, flutter::kScanCodeControlLeft, flutter::kScanCodeControlRight, flutter::kScanCodeShiftLeft, flutter::kScanCodeShiftRight, and user_data.

◆ TEST() [113/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SynthesizeWithInitialTogglingState   
)

Definition at line 1190 of file keyboard_key_embedder_handler_unittests.cc.

1190  {
1191  TestKeystate key_state;
1192  std::vector<TestFlutterKeyEvent> results;
1193  TestFlutterKeyEvent* event;
1194  bool last_handled = false;
1195 
1196  // The app starts with NumLock toggled on
1197  key_state.Set(VK_NUMLOCK, false, true);
1198 
1199  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
1200  std::make_unique<KeyboardKeyEmbedderHandler>(
1201  [&results](const FlutterKeyEvent& event,
1202  FlutterKeyEventCallback callback, void* user_data) {
1203  results.emplace_back(event, callback, user_data);
1204  },
1205  key_state.Getter(), DefaultMapVkToScan);
1206 
1207  // NumLock key down
1208  key_state.Set(VK_NUMLOCK, true, false);
1209  handler->KeyboardHook(
1210  VK_NUMLOCK, kScanCodeNumLock, WM_KEYDOWN, 0, true, false,
1211  [&last_handled](bool handled) { last_handled = handled; });
1212  EXPECT_EQ(last_handled, false);
1213  EXPECT_EQ(results.size(), 1);
1214  event = &results[0];
1215  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1216  EXPECT_EQ(event->physical, kPhysicalNumLock);
1217  EXPECT_EQ(event->logical, kLogicalNumLock);
1218  EXPECT_STREQ(event->character, "");
1219  EXPECT_EQ(event->synthesized, false);
1220 
1221  event->callback(true, event->user_data);
1222  EXPECT_EQ(last_handled, true);
1223  results.clear();
1224 }

References callback, and user_data.

◆ TEST() [114/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
SysKeyPress   
)

Definition at line 1226 of file keyboard_key_embedder_handler_unittests.cc.

1226  {
1227  TestKeystate key_state;
1228  std::vector<TestFlutterKeyEvent> results;
1229  TestFlutterKeyEvent* event;
1230  bool last_handled = false;
1231 
1232  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
1233  std::make_unique<KeyboardKeyEmbedderHandler>(
1234  [&results](const FlutterKeyEvent& event,
1235  FlutterKeyEventCallback callback, void* user_data) {
1236  results.emplace_back(event, callback, user_data);
1237  },
1238  key_state.Getter(), DefaultMapVkToScan);
1239 
1240  // Press KeyAltLeft.
1241  key_state.Set(VK_LMENU, true);
1242  handler->KeyboardHook(
1243  VK_LMENU, kScanCodeAltLeft, WM_SYSKEYDOWN, 0, false, false,
1244  [&last_handled](bool handled) { last_handled = handled; });
1245  EXPECT_EQ(last_handled, false);
1246  EXPECT_EQ(results.size(), 1);
1247  event = results.data();
1248  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1249  EXPECT_EQ(event->physical, kPhysicalAltLeft);
1250  EXPECT_EQ(event->logical, kLogicalAltLeft);
1251  EXPECT_STREQ(event->character, "");
1252  EXPECT_EQ(event->synthesized, false);
1253 
1254  event->callback(true, event->user_data);
1255  EXPECT_EQ(last_handled, true);
1256  results.clear();
1257 
1258  // Release KeyAltLeft.
1259  key_state.Set(VK_LMENU, false);
1260  handler->KeyboardHook(
1261  VK_LMENU, kScanCodeAltLeft, WM_SYSKEYUP, 0, false, true,
1262  [&last_handled](bool handled) { last_handled = handled; });
1263  EXPECT_EQ(results.size(), 1);
1264  event = results.data();
1265  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1266  EXPECT_EQ(event->physical, kPhysicalAltLeft);
1267  EXPECT_EQ(event->logical, kLogicalAltLeft);
1268  EXPECT_STREQ(event->character, "");
1269  EXPECT_EQ(event->synthesized, false);
1270  event->callback(false, event->user_data);
1271 }

References callback, and user_data.

◆ TEST() [115/174]

flutter::testing::TEST ( KeyboardKeyEmbedderHandlerTest  ,
ToggleNumLockDuringNumpadPress   
)

Definition at line 187 of file keyboard_key_embedder_handler_unittests.cc.

187  {
188  TestKeystate key_state;
189  std::vector<TestFlutterKeyEvent> results;
190  TestFlutterKeyEvent* event;
191  bool last_handled = false;
192 
193  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
194  std::make_unique<KeyboardKeyEmbedderHandler>(
195  [&results](const FlutterKeyEvent& event,
196  FlutterKeyEventCallback callback, void* user_data) {
197  results.emplace_back(event, callback, user_data);
198  },
199  key_state.Getter(), DefaultMapVkToScan);
200 
201  // Press NumPad1.
202  key_state.Set(VK_NUMPAD1, true);
203  handler->KeyboardHook(
204  VK_NUMPAD1, kScanCodeNumpad1, WM_KEYDOWN, 0, false, false,
205  [&last_handled](bool handled) { last_handled = handled; });
206  EXPECT_EQ(results.size(), 1);
207  event = &results[0];
208  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
209  EXPECT_EQ(event->physical, kPhysicalNumpad1);
210  EXPECT_EQ(event->logical, kLogicalNumpad1);
211  // EXPECT_STREQ(event->character, "1"); // TODO
212  EXPECT_EQ(event->synthesized, false);
213  results.clear();
214 
215  // Press NumLock.
216  key_state.Set(VK_NUMLOCK, true, true);
217  handler->KeyboardHook(
218  VK_NUMLOCK, kScanCodeNumLock, WM_KEYDOWN, 0, true, false,
219  [&last_handled](bool handled) { last_handled = handled; });
220  EXPECT_EQ(results.size(), 1);
221  event = &results[0];
222  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
223  EXPECT_EQ(event->physical, kPhysicalNumLock);
224  EXPECT_EQ(event->logical, kLogicalNumLock);
225  EXPECT_STREQ(event->character, "");
226  EXPECT_EQ(event->synthesized, false);
227  results.clear();
228 
229  // Release NumLock.
230  key_state.Set(VK_NUMLOCK, false, true);
231  handler->KeyboardHook(
232  VK_NUMLOCK, kScanCodeNumLock, WM_KEYUP, 0, true, true,
233  [&last_handled](bool handled) { last_handled = handled; });
234  EXPECT_EQ(results.size(), 1);
235  event = &results[0];
236  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
237  EXPECT_EQ(event->physical, kPhysicalNumLock);
238  EXPECT_EQ(event->logical, kLogicalNumLock);
239  EXPECT_STREQ(event->character, "");
240  EXPECT_EQ(event->synthesized, false);
241  results.clear();
242 
243  // Release NumPad1. (The logical key is now NumpadEnd)
244  handler->KeyboardHook(
245  VK_END, kScanCodeNumpad1, WM_KEYUP, 0, false, true,
246  [&last_handled](bool handled) { last_handled = handled; });
247  EXPECT_EQ(results.size(), 1);
248  event = &results[0];
249  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
250  EXPECT_EQ(event->physical, kPhysicalNumpad1);
251  EXPECT_EQ(event->logical, kLogicalNumpad1);
252  EXPECT_STREQ(event->character, "");
253  EXPECT_EQ(event->synthesized, false);
254  results.clear();
255 }

References callback, and user_data.

◆ TEST() [116/174]

flutter::testing::TEST ( KeyboardKeyHandlerTest  ,
HandlerGetPressedState   
)

Definition at line 311 of file keyboard_key_handler_unittests.cc.

311  {
312  TestKeystate key_state;
313 
314  TestBinaryMessenger messenger([](const std::string& channel,
315  const uint8_t* message, size_t message_size,
316  BinaryReply reply) {});
317  KeyboardKeyHandler handler(&messenger);
318 
319  std::unique_ptr<KeyboardKeyEmbedderHandler> embedder_handler =
320  std::make_unique<KeyboardKeyEmbedderHandler>(
321  [](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
322  void* user_data) {},
323  key_state.Getter(), DefaultMapVkToScan);
324  handler.AddDelegate(std::move(embedder_handler));
325 
326  // Dispatch a key event.
327  handler.KeyboardHook(kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false,
328  false, OnKeyEventResult);
329 
330  std::map<uint64_t, uint64_t> pressed_state = handler.GetPressedState();
331  EXPECT_EQ(pressed_state.size(), 1);
332  EXPECT_EQ(pressed_state.at(kPhysicalKeyA), kLogicalKeyA);
333 }
FlutterKeyEventCallback callback

References callback, kScanCodeKeyA, kVirtualKeyA, message, and user_data.

◆ TEST() [117/174]

flutter::testing::TEST ( KeyboardKeyHandlerTest  ,
KeyboardChannelGetPressedState   
)

Definition at line 335 of file keyboard_key_handler_unittests.cc.

335  {
336  TestKeystate key_state;
337  TestBinaryMessenger messenger;
338  KeyboardKeyHandler handler(&messenger);
339 
340  std::unique_ptr<KeyboardKeyEmbedderHandler> embedder_handler =
341  std::make_unique<KeyboardKeyEmbedderHandler>(
342  [](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
343  void* user_data) {},
344  key_state.Getter(), DefaultMapVkToScan);
345  handler.AddDelegate(std::move(embedder_handler));
346  handler.InitKeyboardChannel();
347 
348  // Dispatch a key event.
349  handler.KeyboardHook(kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false,
350  false, OnKeyEventResult);
351 
352  bool success = false;
353 
354  MethodResultFunctions<> result_handler(
355  [&success](const EncodableValue* result) {
356  success = true;
357  auto& map = std::get<EncodableMap>(*result);
358  EXPECT_EQ(map.size(), 1);
359  EncodableValue physical_value(static_cast<long long>(kPhysicalKeyA));
360  EncodableValue logical_value(static_cast<long long>(kLogicalKeyA));
361  EXPECT_EQ(map.at(physical_value), logical_value);
362  },
363  nullptr, nullptr);
364 
365  SimulateKeyboardMessage(&messenger, kGetKeyboardStateMethod, nullptr,
366  &result_handler);
367  EXPECT_TRUE(success);
368 }

References flutter::KeyboardKeyHandler::AddDelegate(), callback, flutter::KeyboardKeyHandler::InitKeyboardChannel(), flutter::KeyboardKeyHandler::KeyboardHook(), kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [118/174]

flutter::testing::TEST ( KeyboardKeyHandlerTest  ,
SingleDelegateWithAsyncResponds   
)

Test 1: One event that is handled by the framework

Test 2: Two events that are unhandled by the framework

Definition at line 208 of file keyboard_key_handler_unittests.cc.

208  {
209  std::list<MockKeyHandlerDelegate::KeyboardHookCall> hook_history;
210 
211  TestBinaryMessenger messenger([](const std::string& channel,
212  const uint8_t* message, size_t message_size,
213  BinaryReply reply) {});
214  KeyboardKeyHandler handler(&messenger);
215 
216  // Add one delegate
217  auto delegate = std::make_unique<MockKeyHandlerDelegate>(1, &hook_history);
218  handler.AddDelegate(std::move(delegate));
219 
220  /// Test 1: One event that is handled by the framework
221 
222  // Dispatch a key event
223  handler.KeyboardHook(64, kHandledScanCode, WM_KEYDOWN, L'a', false, true,
224  OnKeyEventResult);
225  EXPECT_EQ(key_event_response, kNoResponse);
226  EXPECT_EQ(hook_history.size(), 1);
227  EXPECT_EQ(hook_history.back().delegate_id, 1);
228  EXPECT_EQ(hook_history.back().scancode, kHandledScanCode);
229  EXPECT_EQ(hook_history.back().was_down, true);
230 
231  EXPECT_EQ(key_event_response, kNoResponse);
232  hook_history.back().callback(true);
233  EXPECT_EQ(key_event_response, kHandled);
234 
235  key_event_response = kNoResponse;
236  hook_history.clear();
237 
238  /// Test 2: Two events that are unhandled by the framework
239 
240  handler.KeyboardHook(64, kHandledScanCode, WM_KEYDOWN, L'a', false, false,
241  OnKeyEventResult);
242  EXPECT_EQ(key_event_response, kNoResponse);
243  EXPECT_EQ(hook_history.size(), 1);
244  EXPECT_EQ(hook_history.back().delegate_id, 1);
245  EXPECT_EQ(hook_history.back().scancode, kHandledScanCode);
246  EXPECT_EQ(hook_history.back().was_down, false);
247 
248  // Dispatch another key event
249  handler.KeyboardHook(65, kHandledScanCode2, WM_KEYUP, L'b', false, true,
250  OnKeyEventResult);
251  EXPECT_EQ(key_event_response, kNoResponse);
252  EXPECT_EQ(hook_history.size(), 2);
253  EXPECT_EQ(hook_history.back().delegate_id, 1);
254  EXPECT_EQ(hook_history.back().scancode, kHandledScanCode2);
255  EXPECT_EQ(hook_history.back().was_down, true);
256 
257  // Resolve the second event first to test out-of-order response
258  hook_history.back().callback(false);
259  EXPECT_EQ(key_event_response, kUnhandled);
260  key_event_response = kNoResponse;
261 
262  // Resolve the first event then
263  hook_history.front().callback(false);
264  EXPECT_EQ(key_event_response, kUnhandled);
265 
266  hook_history.clear();
267  key_event_response = kNoResponse;
268 }
std::list< KeyboardHookCall > * hook_history

References hook_history, and message.

◆ TEST() [119/174]

flutter::testing::TEST ( KeyboardKeyHandlerTest  ,
SingleDelegateWithSyncResponds   
)

Test 1: One event that is handled by the framework

Test 2: An event unhandled by the framework

Definition at line 270 of file keyboard_key_handler_unittests.cc.

270  {
271  std::list<MockKeyHandlerDelegate::KeyboardHookCall> hook_history;
272 
273  TestBinaryMessenger messenger([](const std::string& channel,
274  const uint8_t* message, size_t message_size,
275  BinaryReply reply) {});
276  KeyboardKeyHandler handler(&messenger);
277  // Add one delegate
278  auto delegate = std::make_unique<MockKeyHandlerDelegate>(1, &hook_history);
279  CallbackHandler& delegate_handler = delegate->callback_handler;
280  handler.AddDelegate(std::move(delegate));
281 
282  /// Test 1: One event that is handled by the framework
283 
284  // Dispatch a key event
285  delegate_handler = respond_true;
286  handler.KeyboardHook(64, kHandledScanCode, WM_KEYDOWN, L'a', false, false,
287  OnKeyEventResult);
288  EXPECT_EQ(key_event_response, kHandled);
289  EXPECT_EQ(hook_history.size(), 1);
290  EXPECT_EQ(hook_history.back().delegate_id, 1);
291  EXPECT_EQ(hook_history.back().scancode, kHandledScanCode);
292  EXPECT_EQ(hook_history.back().was_down, false);
293 
294  hook_history.clear();
295 
296  /// Test 2: An event unhandled by the framework
297 
298  delegate_handler = respond_false;
299  handler.KeyboardHook(64, kHandledScanCode, WM_KEYDOWN, L'a', false, false,
300  OnKeyEventResult);
301  EXPECT_EQ(key_event_response, kUnhandled);
302  EXPECT_EQ(hook_history.size(), 1);
303  EXPECT_EQ(hook_history.back().delegate_id, 1);
304  EXPECT_EQ(hook_history.back().scancode, kHandledScanCode);
305  EXPECT_EQ(hook_history.back().was_down, false);
306 
307  hook_history.clear();
308  key_event_response = kNoResponse;
309 }

References hook_history, and message.

◆ TEST() [120/174]

flutter::testing::TEST ( KeyboardWin32CommonTest  ,
EncodeUtf16   
)

Definition at line 11 of file keyboard_utils_unittests.cc.

11  {
12  std::u16string result;
13 
14  result = EncodeUtf16(0x24);
15  EXPECT_EQ(result.size(), 1);
16  EXPECT_EQ(result[0], 0x24);
17 
18  result = EncodeUtf16(0x20AC);
19  EXPECT_EQ(result.size(), 1);
20  EXPECT_EQ(result[0], 0x20AC);
21 
22  result = EncodeUtf16(0x10437);
23  EXPECT_EQ(result.size(), 2);
24  EXPECT_EQ(result[0], 0xD801);
25  EXPECT_EQ(result[1], 0xDC37);
26 
27  result = EncodeUtf16(0x24B62);
28  EXPECT_EQ(result.size(), 2);
29  EXPECT_EQ(result[0], 0xD852);
30  EXPECT_EQ(result[1], 0xDF62);
31 }
std::u16string EncodeUtf16(char32_t character)

References flutter::EncodeUtf16().

◆ TEST() [121/174]

flutter::testing::TEST ( MockWindow  ,
CreateDestroy   
)

Definition at line 23 of file window_unittests.cc.

23  {
24  MockWindow window;
25  ASSERT_TRUE(TRUE);
26 }

◆ TEST() [122/174]

flutter::testing::TEST ( MockWindow  ,
DISABLED_GetObjectUia   
)

Definition at line 430 of file window_unittests.cc.

430  {
431  MockWindow window;
432  bool uia_called = false;
433  ON_CALL(window, OnGetObject)
434  .WillByDefault([&uia_called](UINT msg, WPARAM wpar, LPARAM lpar) {
435 #ifdef FLUTTER_ENGINE_USE_UIA
436  uia_called = true;
437 #endif // FLUTTER_ENGINE_USE_UIA
438  return static_cast<LRESULT>(0);
439  });
440  EXPECT_CALL(window, OnGetObject).Times(1);
441 
442  window.InjectWindowMessage(WM_GETOBJECT, 0, UiaRootObjectId);
443 
444  EXPECT_TRUE(uia_called);
445 }

◆ TEST() [123/174]

flutter::testing::TEST ( MockWindow  ,
GetDpiAfterCreate   
)

Definition at line 28 of file window_unittests.cc.

28  {
29  MockWindow window;
30  ASSERT_TRUE(window.GetDpi() > 0);
31 }

◆ TEST() [124/174]

flutter::testing::TEST ( MockWindow  ,
HorizontalScroll   
)

Definition at line 214 of file window_unittests.cc.

214  {
215  MockWindow window;
216  const int scroll_amount = 10;
217  // Vertical scroll should be passed along, adjusted for scroll tick size.
218  EXPECT_CALL(window, OnScroll(scroll_amount / 120.0, 0,
219  kFlutterPointerDeviceKindMouse, 0))
220  .Times(1);
221 
222  window.InjectWindowMessage(WM_MOUSEHWHEEL, MAKEWPARAM(0, scroll_amount), 0);
223 }

◆ TEST() [125/174]

flutter::testing::TEST ( MockWindow  ,
KeyDown   
)

Definition at line 242 of file window_unittests.cc.

242  {
243  MockWindow window;
244  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
245  LPARAM lparam = CreateKeyEventLparam(42, false, false);
246  // send a "Shift" key down event.
247  window.InjectWindowMessage(WM_KEYDOWN, 16, lparam);
248 }

◆ TEST() [126/174]

flutter::testing::TEST ( MockWindow  ,
KeyDownPrintable   
)

Definition at line 277 of file window_unittests.cc.

277  {
278  MockWindow window;
279  LPARAM lparam = CreateKeyEventLparam(30, false, false);
280 
281  auto respond_false = [](int key, int scancode, int action, char32_t character,
282  bool extended, bool was_down,
283  std::function<void(bool)> callback) {
284  callback(false);
285  };
286  EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 0, false, false, _))
287  .Times(1)
288  .WillOnce(respond_false);
289  EXPECT_CALL(window, OnText(_)).Times(1);
290  std::array<Win32Message, 2> messages = {
291  Win32Message{WM_KEYDOWN, 65, lparam, kWmResultDontCheck},
292  Win32Message{WM_CHAR, 65, lparam, kWmResultDontCheck}};
293  window.InjectMessageList(2, messages.data());
294 }

References action, callback, character, extended, key, scancode, and was_down.

◆ TEST() [127/174]

flutter::testing::TEST ( MockWindow  ,
KeyDownWithCtrl   
)

Definition at line 296 of file window_unittests.cc.

296  {
297  MockWindow window;
298 
299  // Simulate CONTROL pressed
300  std::array<BYTE, 256> keyboard_state;
301  keyboard_state[VK_CONTROL] = -1;
302  SetKeyboardState(keyboard_state.data());
303 
304  LPARAM lparam = CreateKeyEventLparam(30, false, false);
305 
306  // Expect OnKey, but not OnText, because Control + Key is not followed by
307  // WM_CHAR
308  EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 0, false, false, _)).Times(1);
309  EXPECT_CALL(window, OnText(_)).Times(0);
310 
311  window.InjectWindowMessage(WM_KEYDOWN, 65, lparam);
312 
313  keyboard_state.fill(0);
314  SetKeyboardState(keyboard_state.data());
315 }

◆ TEST() [128/174]

flutter::testing::TEST ( MockWindow  ,
KeyDownWithCtrlToggled   
)

Definition at line 317 of file window_unittests.cc.

317  {
318  MockWindow window;
319 
320  auto respond_false = [](int key, int scancode, int action, char32_t character,
321  bool extended, bool was_down,
322  std::function<void(bool)> callback) {
323  callback(false);
324  };
325 
326  // Simulate CONTROL toggled
327  std::array<BYTE, 256> keyboard_state;
328  keyboard_state[VK_CONTROL] = 1;
329  SetKeyboardState(keyboard_state.data());
330 
331  LPARAM lparam = CreateKeyEventLparam(30, false, false);
332 
333  EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 0, false, false, _))
334  .Times(1)
335  .WillOnce(respond_false);
336  EXPECT_CALL(window, OnText(_)).Times(1);
337 
338  // send a "A" key down event.
339  Win32Message messages[] = {{WM_KEYDOWN, 65, lparam, kWmResultDontCheck},
340  {WM_CHAR, 65, lparam, kWmResultDontCheck}};
341  window.InjectMessageList(2, messages);
342 
343  keyboard_state.fill(0);
344  SetKeyboardState(keyboard_state.data());
345 }

References action, callback, character, extended, key, scancode, and was_down.

◆ TEST() [129/174]

flutter::testing::TEST ( MockWindow  ,
KeyUp   
)

Definition at line 250 of file window_unittests.cc.

250  {
251  MockWindow window;
252  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
253  LPARAM lparam = CreateKeyEventLparam(42, false, true);
254  // send a "Shift" key up event.
255  window.InjectWindowMessage(WM_KEYUP, 16, lparam);
256 }

◆ TEST() [130/174]

flutter::testing::TEST ( MockWindow  ,
MouseLeave   
)

Definition at line 225 of file window_unittests.cc.

225  {
226  MockWindow window;
227  const double mouse_x = 10.0;
228  const double mouse_y = 20.0;
229 
230  EXPECT_CALL(window,
231  OnPointerMove(mouse_x, mouse_y, kFlutterPointerDeviceKindMouse, 0,
232  0, 0, 0, 0))
233  .Times(1);
234  EXPECT_CALL(window, OnPointerLeave(mouse_x, mouse_y,
235  kFlutterPointerDeviceKindMouse, 0))
236  .Times(1);
237 
238  window.InjectWindowMessage(WM_MOUSEMOVE, 0, MAKELPARAM(mouse_x, mouse_y));
239  window.InjectWindowMessage(WM_MOUSELEAVE, 0, 0);
240 }

◆ TEST() [131/174]

flutter::testing::TEST ( MockWindow  ,
OnImeCompositionClearChange   
)

Definition at line 197 of file window_unittests.cc.

197  {
198  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
199  auto* text_input_manager = new MockTextInputManager();
200  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
201  MockWindow window(std::move(windows_proc_table),
202  std::move(text_input_manager_ptr));
203  EXPECT_CALL(window, OnComposeChange(std::u16string(u""), 0)).Times(1);
204  EXPECT_CALL(window, OnComposeCommit()).Times(1);
205  ON_CALL(window, OnImeComposition)
206  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
207  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
208 
209  // send an IME_COMPOSITION event that contains both the result string and the
210  // composition string.
211  window.InjectWindowMessage(WM_IME_COMPOSITION, 0, 0);
212 }

◆ TEST() [132/174]

flutter::testing::TEST ( MockWindow  ,
OnImeCompositionCompose   
)

Definition at line 45 of file window_unittests.cc.

45  {
46  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
47  auto* text_input_manager = new MockTextInputManager();
48  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
49  MockWindow window(std::move(windows_proc_table),
50  std::move(text_input_manager_ptr));
51  EXPECT_CALL(*text_input_manager, GetComposingString())
52  .WillRepeatedly(
53  Return(std::optional<std::u16string>(std::u16string(u"nihao"))));
54  EXPECT_CALL(*text_input_manager, GetResultString())
55  .WillRepeatedly(
56  Return(std::optional<std::u16string>(std::u16string(u"`}"))));
57  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
58 
59  EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 5)).Times(1);
60  EXPECT_CALL(window, OnComposeChange(std::u16string(u"`}"), 0)).Times(0);
61  EXPECT_CALL(window, OnComposeCommit()).Times(0);
62  ON_CALL(window, OnImeComposition)
63  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
64  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
65 
66  // Send an IME_COMPOSITION event that contains just the composition string.
67  window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_COMPSTR);
68 }

◆ TEST() [133/174]

flutter::testing::TEST ( MockWindow  ,
OnImeCompositionDefaultsKoreanCursorToCompositionEnd   
)

Definition at line 71 of file window_unittests.cc.

71  {
72  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
73  auto* text_input_manager = new MockTextInputManager();
74  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
75  MockWindow window(std::move(windows_proc_table),
76  std::move(text_input_manager_ptr));
77  EXPECT_CALL(*text_input_manager, GetComposingString())
78  .WillRepeatedly(
79  Return(std::optional<std::u16string>(std::u16string(u"다"))));
80  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
81 
82  EXPECT_CALL(window, OnComposeChange(std::u16string(u"다"), 1)).Times(1);
83  EXPECT_CALL(window, OnComposeCommit()).Times(0);
84  ON_CALL(window, OnImeComposition)
85  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
86  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
87 
88  window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_COMPSTR);
89 }

◆ TEST() [134/174]

flutter::testing::TEST ( MockWindow  ,
OnImeCompositionFallsBackToTextEndForInvalidCursorPosition   
)

Definition at line 175 of file window_unittests.cc.

175  {
176  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
177  auto* text_input_manager = new MockTextInputManager();
178  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
179  MockWindow window(std::move(windows_proc_table),
180  std::move(text_input_manager_ptr));
181  EXPECT_CALL(*text_input_manager, GetComposingString())
182  .WillRepeatedly(
183  Return(std::optional<std::u16string>(std::u16string(u"nihao"))));
184  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
185  .WillOnce(Return(-1));
186 
187  EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 5)).Times(1);
188  EXPECT_CALL(window, OnComposeCommit()).Times(0);
189  ON_CALL(window, OnImeComposition)
190  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
191  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
192 
193  window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
194  GCS_COMPSTR | GCS_CURSORPOS);
195 }

◆ TEST() [135/174]

flutter::testing::TEST ( MockWindow  ,
OnImeCompositionResult   
)

Definition at line 91 of file window_unittests.cc.

91  {
92  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
93  auto* text_input_manager = new MockTextInputManager();
94  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
95  MockWindow window(std::move(windows_proc_table),
96  std::move(text_input_manager_ptr));
97  EXPECT_CALL(*text_input_manager, GetComposingString())
98  .WillRepeatedly(
99  Return(std::optional<std::u16string>(std::u16string(u"nihao"))));
100  EXPECT_CALL(*text_input_manager, GetResultString())
101  .WillRepeatedly(
102  Return(std::optional<std::u16string>(std::u16string(u"`}"))));
103  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
104 
105  EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 0)).Times(0);
106  EXPECT_CALL(window, OnComposeChange(std::u16string(u"`}"), 2)).Times(1);
107  EXPECT_CALL(window, OnComposeCommit()).Times(1);
108  ON_CALL(window, OnImeComposition)
109  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
110  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
111 
112  // Send an IME_COMPOSITION event that contains just the result string.
113  window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
114 }

◆ TEST() [136/174]

flutter::testing::TEST ( MockWindow  ,
OnImeCompositionResultAndCompose   
)

Definition at line 116 of file window_unittests.cc.

116  {
117  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
118  auto* text_input_manager = new MockTextInputManager();
119  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
120  MockWindow window(std::move(windows_proc_table),
121  std::move(text_input_manager_ptr));
122 
123  // This situation is that Google Japanese Input finished composing "今日" in
124  // "今日は" but is still composing "は".
125  {
126  InSequence dummy;
127  EXPECT_CALL(*text_input_manager, GetResultString())
128  .WillRepeatedly(
129  Return(std::optional<std::u16string>(std::u16string(u"今日"))));
130  EXPECT_CALL(*text_input_manager, GetComposingString())
131  .WillRepeatedly(
132  Return(std::optional<std::u16string>(std::u16string(u"は"))));
133  }
134  {
135  InSequence dummy;
136  EXPECT_CALL(window, OnComposeChange(std::u16string(u"今日"), 2)).Times(1);
137  EXPECT_CALL(window, OnComposeCommit()).Times(1);
138  EXPECT_CALL(window, OnComposeChange(std::u16string(u"は"), 1)).Times(1);
139  }
140 
141  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()).Times(0);
142 
143  ON_CALL(window, OnImeComposition)
144  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
145  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
146 
147  // send an IME_COMPOSITION event that contains both the result string and the
148  // composition string.
149  window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
150  GCS_COMPSTR | GCS_RESULTSTR);
151 }

◆ TEST() [137/174]

flutter::testing::TEST ( MockWindow  ,
OnImeCompositionUsesCursorPositionWhenProvided   
)

Definition at line 153 of file window_unittests.cc.

153  {
154  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
155  auto* text_input_manager = new MockTextInputManager();
156  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
157  MockWindow window(std::move(windows_proc_table),
158  std::move(text_input_manager_ptr));
159  EXPECT_CALL(*text_input_manager, GetComposingString())
160  .WillRepeatedly(
161  Return(std::optional<std::u16string>(std::u16string(u"nihao"))));
162  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
163  .WillOnce(Return(2));
164 
165  EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 2)).Times(1);
166  EXPECT_CALL(window, OnComposeCommit()).Times(0);
167  ON_CALL(window, OnImeComposition)
168  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
169  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
170 
171  window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
172  GCS_COMPSTR | GCS_CURSORPOS);
173 }

◆ TEST() [138/174]

flutter::testing::TEST ( MockWindow  ,
Paint   
)

Definition at line 347 of file window_unittests.cc.

347  {
348  MockWindow window;
349  EXPECT_CALL(window, OnPaint()).Times(1);
350  window.InjectWindowMessage(WM_PAINT, 0, 0);
351 }

◆ TEST() [139/174]

flutter::testing::TEST ( MockWindow  ,
PointerHitTest   
)

Definition at line 354 of file window_unittests.cc.

354  {
355  UINT32 pointer_id = 123;
356  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
357  auto text_input_manager = std::make_unique<MockTextInputManager>();
358 
359  EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
360  .Times(1)
361  .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE* type) {
362  *type = PT_POINTER;
363  return TRUE;
364  });
365 
366  MockWindow window(std::move(windows_proc_table),
367  std::move(text_input_manager));
368 
369  auto direct_manipulation =
370  std::make_unique<MockDirectManipulationOwner>(&window);
371 
372  EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
373 
374  window.SetDirectManipulationOwner(std::move(direct_manipulation));
375  window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
376 }
enum flutter::testing::@104::KeyboardChange::Type type

References type.

◆ TEST() [140/174]

flutter::testing::TEST ( MockWindow  ,
SysKeyDown   
)

Definition at line 258 of file window_unittests.cc.

258  {
259  MockWindow window;
260  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
261  LPARAM lparam = CreateKeyEventLparam(42, false, false);
262  // send a "Shift" key down event.
263  window.InjectWindowMessage(WM_SYSKEYDOWN, 16, lparam);
264 }

◆ TEST() [141/174]

flutter::testing::TEST ( MockWindow  ,
SysKeyUp   
)

Definition at line 266 of file window_unittests.cc.

266  {
267  MockWindow window;
268  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
269  // Prevent default proc for WM_SYSKEYUP which unfocuses the window and sends
270  // WM_MOUSELEAVE.
271  EXPECT_CALL(window, Win32DefWindowProc(_, _, _, _)).Times(0);
272  LPARAM lparam = CreateKeyEventLparam(42, false, true);
273  // send a "Shift" key up event.
274  window.InjectWindowMessage(WM_SYSKEYUP, 16, lparam);
275 }

◆ TEST() [142/174]

flutter::testing::TEST ( MockWindow  ,
TouchPadHitTest   
)

Definition at line 379 of file window_unittests.cc.

379  {
380  UINT32 pointer_id = 123;
381  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
382  auto text_input_manager = std::make_unique<MockTextInputManager>();
383 
384  EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
385  .Times(1)
386  .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE* type) {
387  *type = PT_TOUCHPAD;
388  return TRUE;
389  });
390 
391  MockWindow window(std::move(windows_proc_table),
392  std::move(text_input_manager));
393 
394  auto direct_manipulation =
395  std::make_unique<MockDirectManipulationOwner>(&window);
396 
397  EXPECT_CALL(*direct_manipulation, SetContact(Eq(pointer_id))).Times(1);
398 
399  window.SetDirectManipulationOwner(std::move(direct_manipulation));
400  window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
401 }

References type.

◆ TEST() [143/174]

flutter::testing::TEST ( MockWindow  ,
UnknownPointerTypeSkipsDirectManipulation   
)

Definition at line 407 of file window_unittests.cc.

407  {
408  UINT32 pointer_id = 123;
409  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
410  auto text_input_manager = std::make_unique<MockTextInputManager>();
411 
412  EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
413  .Times(1)
414  .WillOnce(
415  [](UINT32 pointer_id, POINTER_INPUT_TYPE* type) { return FALSE; });
416 
417  MockWindow window(std::move(windows_proc_table),
418  std::move(text_input_manager));
419 
420  auto direct_manipulation =
421  std::make_unique<MockDirectManipulationOwner>(&window);
422 
423  EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
424 
425  window.SetDirectManipulationOwner(std::move(direct_manipulation));
426  window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
427 }

References type.

◆ TEST() [144/174]

flutter::testing::TEST ( MockWindow  ,
VerticalScroll   
)

Definition at line 33 of file window_unittests.cc.

33  {
34  MockWindow window;
35  const int scroll_amount = 10;
36  // Vertical scroll should be passed along, adjusted for scroll tick size
37  // and direction.
38  EXPECT_CALL(window, OnScroll(0, -scroll_amount / 120.0,
39  kFlutterPointerDeviceKindMouse, 0))
40  .Times(1);
41 
42  window.InjectWindowMessage(WM_MOUSEWHEEL, MAKEWPARAM(0, scroll_amount), 0);
43 }

◆ TEST() [145/174]

flutter::testing::TEST ( SequentialIdGeneratorTest  ,
MaybeRemoveNumbers   
)

Definition at line 35 of file sequential_id_generator_unittests.cc.

35  {
36  const uint32_t kMinId = 0;
37  const uint32_t kMaxId = 128;
38 
39  SequentialIdGenerator generator(kMinId, kMaxId);
40 
41  EXPECT_EQ(0U, generator.GetGeneratedId(42));
42 
43  generator.ReleaseNumber(42);
44  EXPECT_FALSE(generator.HasGeneratedIdFor(42));
45  generator.ReleaseNumber(42);
46 }

References flutter::SequentialIdGenerator::GetGeneratedId(), flutter::SequentialIdGenerator::HasGeneratedIdFor(), and flutter::SequentialIdGenerator::ReleaseNumber().

◆ TEST() [146/174]

flutter::testing::TEST ( SequentialIdGeneratorTest  ,
RemoveMultipleNumbers   
)

Definition at line 12 of file sequential_id_generator_unittests.cc.

12  {
13  const uint32_t kMinId = 4;
14  const uint32_t kMaxId = 128;
15 
16  SequentialIdGenerator generator(kMinId, kMaxId);
17 
18  EXPECT_EQ(4U, generator.GetGeneratedId(45));
19  EXPECT_EQ(5U, generator.GetGeneratedId(55));
20  EXPECT_EQ(6U, generator.GetGeneratedId(15));
21 
22  generator.ReleaseNumber(45);
23  EXPECT_FALSE(generator.HasGeneratedIdFor(45));
24  generator.ReleaseNumber(15);
25  EXPECT_FALSE(generator.HasGeneratedIdFor(15));
26 
27  EXPECT_EQ(5U, generator.GetGeneratedId(55));
28  EXPECT_EQ(4U, generator.GetGeneratedId(12));
29 
30  generator.ReleaseNumber(12);
31  generator.ReleaseNumber(55);
32  EXPECT_EQ(4U, generator.GetGeneratedId(0));
33 }

References flutter::SequentialIdGenerator::GetGeneratedId(), flutter::SequentialIdGenerator::HasGeneratedIdFor(), and flutter::SequentialIdGenerator::ReleaseNumber().

◆ TEST() [147/174]

flutter::testing::TEST ( SettingsPluginTest  ,
HighContrastModeHonored   
)

Definition at line 80 of file settings_plugin_unittests.cc.

80  {
81  int times = 0;
82  TestBinaryMessenger messenger(
83  [&times](const std::string& channel, const uint8_t* message,
84  size_t message_size, BinaryReply reply) {
85  ASSERT_EQ(channel, "flutter/settings");
86  times++;
87  });
88  ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger, nullptr);
89 
90  settings_plugin.UpdateHighContrastMode(true);
91  EXPECT_TRUE(settings_plugin.is_high_contrast());
92 
93  settings_plugin.UpdateHighContrastMode(false);
94  EXPECT_FALSE(settings_plugin.is_high_contrast());
95 
96  EXPECT_EQ(times, 2);
97 }

References message.

◆ TEST() [148/174]

flutter::testing::TEST ( SettingsPluginTest  ,
SendSettingsGetsSettings   
)

Definition at line 55 of file settings_plugin_unittests.cc.

55  {
56  TestBinaryMessenger messenger([](const std::string& channel,
57  const uint8_t* message, size_t message_size,
58  BinaryReply reply) {});
59  ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger, nullptr);
60 
61  EXPECT_CALL(settings_plugin, GetAlwaysUse24HourFormat).Times(1);
62  EXPECT_CALL(settings_plugin, GetTextScaleFactor).Times(1);
63  EXPECT_CALL(settings_plugin, GetPreferredBrightness).Times(1);
64 
65  settings_plugin.SendSettings();
66 }

References message.

◆ TEST() [149/174]

flutter::testing::TEST ( SettingsPluginTest  ,
SendSettingsSendsMessage   
)

Definition at line 42 of file settings_plugin_unittests.cc.

42  {
43  bool message_is_sent = false;
44  TestBinaryMessenger messenger(
45  [&message_is_sent](const std::string& channel, const uint8_t* message,
46  size_t message_size,
47  BinaryReply reply) { message_is_sent = true; });
48  ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger, nullptr);
49 
50  settings_plugin.SendSettings();
51 
52  EXPECT_TRUE(message_is_sent);
53 }

References message.

◆ TEST() [150/174]

flutter::testing::TEST ( SettingsPluginTest  ,
StartWatchingStartsWatchingChanges   
)

Definition at line 68 of file settings_plugin_unittests.cc.

68  {
69  TestBinaryMessenger messenger([](const std::string& channel,
70  const uint8_t* message, size_t message_size,
71  BinaryReply reply) {});
72  ::testing::NiceMock<MockSettingsPlugin> settings_plugin(&messenger, nullptr);
73 
74  EXPECT_CALL(settings_plugin, WatchPreferredBrightnessChanged).Times(1);
75  EXPECT_CALL(settings_plugin, WatchTextScaleFactorChanged).Times(1);
76 
77  settings_plugin.StartWatching();
78 }

References message.

◆ TEST() [151/174]

flutter::testing::TEST ( SystemUtils  ,
GetPreferredLanguageInfo   
)

Definition at line 16 of file system_utils_unittests.cc.

16  {
17  WindowsProcTable proc_table;
18  std::vector<LanguageInfo> languages =
19  GetPreferredLanguageInfo(WindowsProcTable());
20  // There should be at least one language.
21  ASSERT_GE(languages.size(), 1);
22  // The info should have a valid languge.
23  EXPECT_GE(languages[0].language.size(), 2);
24 }
std::vector< LanguageInfo > GetPreferredLanguageInfo(const WindowsProcTable &windows_proc_table)
Definition: system_utils.cc:15

References flutter::GetPreferredLanguageInfo().

◆ TEST() [152/174]

flutter::testing::TEST ( SystemUtils  ,
GetPreferredLanguages   
)

Definition at line 26 of file system_utils_unittests.cc.

26  {
27  MockWindowsProcTable proc_table;
28  EXPECT_CALL(proc_table, GetThreadPreferredUILanguages)
29  .WillRepeatedly(
30  [](DWORD flags, PULONG count, PZZWSTR languages, PULONG size) {
31  // Languages string ends in a double-null.
32  static const wchar_t lang[] = L"en-US\0";
33  static const size_t lang_len = sizeof(lang) / sizeof(wchar_t);
34  static const int cnt = 1;
35  if (languages == nullptr) {
36  *size = lang_len;
37  *count = cnt;
38  } else if (*size >= lang_len) {
39  memcpy(languages, lang, lang_len * sizeof(wchar_t));
40  }
41  return TRUE;
42  });
43  std::vector<std::wstring> languages = GetPreferredLanguages(proc_table);
44  // There should be at least one language.
45  ASSERT_GE(languages.size(), 1);
46  // The language should be non-empty.
47  EXPECT_FALSE(languages[0].empty());
48  // There should not be a trailing null from the parsing step.
49  EXPECT_EQ(languages[0].size(), wcslen(languages[0].c_str()));
50  EXPECT_EQ(languages[0], L"en-US");
51 }
std::vector< std::wstring > GetPreferredLanguages(const WindowsProcTable &windows_proc_table)
Definition: system_utils.cc:45

References flutter::GetPreferredLanguages().

◆ TEST() [153/174]

flutter::testing::TEST ( SystemUtils  ,
GetUserTimeFormat   
)

Definition at line 96 of file system_utils_unittests.cc.

96  {
97  // The value varies based on machine; just ensure that something is returned.
98  EXPECT_FALSE(GetUserTimeFormat().empty());
99 }
std::wstring GetUserTimeFormat()

References flutter::GetUserTimeFormat().

◆ TEST() [154/174]

flutter::testing::TEST ( SystemUtils  ,
ParseLanguageNameGeneric   
)

Definition at line 53 of file system_utils_unittests.cc.

53  {
54  LanguageInfo info = ParseLanguageName(L"en");
55  EXPECT_EQ(info.language, "en");
56  EXPECT_TRUE(info.region.empty());
57  EXPECT_TRUE(info.script.empty());
58 }
LanguageInfo ParseLanguageName(std::wstring language_name)
Definition: system_utils.cc:71

References flutter::LanguageInfo::language, flutter::ParseLanguageName(), flutter::LanguageInfo::region, and flutter::LanguageInfo::script.

◆ TEST() [155/174]

flutter::testing::TEST ( SystemUtils  ,
ParseLanguageNameWithRegion   
)

Definition at line 60 of file system_utils_unittests.cc.

60  {
61  LanguageInfo info = ParseLanguageName(L"hu-HU");
62  EXPECT_EQ(info.language, "hu");
63  EXPECT_EQ(info.region, "HU");
64  EXPECT_TRUE(info.script.empty());
65 }

References flutter::LanguageInfo::language, flutter::ParseLanguageName(), flutter::LanguageInfo::region, and flutter::LanguageInfo::script.

◆ TEST() [156/174]

flutter::testing::TEST ( SystemUtils  ,
ParseLanguageNameWithRegionAndScript   
)

Definition at line 74 of file system_utils_unittests.cc.

74  {
75  LanguageInfo info = ParseLanguageName(L"uz-Latn-UZ");
76  EXPECT_EQ(info.language, "uz");
77  EXPECT_EQ(info.region, "UZ");
78  EXPECT_EQ(info.script, "Latn");
79 }

References flutter::LanguageInfo::language, flutter::ParseLanguageName(), flutter::LanguageInfo::region, and flutter::LanguageInfo::script.

◆ TEST() [157/174]

flutter::testing::TEST ( SystemUtils  ,
ParseLanguageNameWithScript   
)

Definition at line 67 of file system_utils_unittests.cc.

67  {
68  LanguageInfo info = ParseLanguageName(L"us-Latn");
69  EXPECT_EQ(info.language, "us");
70  EXPECT_TRUE(info.region.empty());
71  EXPECT_EQ(info.script, "Latn");
72 }

References flutter::LanguageInfo::language, flutter::ParseLanguageName(), flutter::LanguageInfo::region, and flutter::LanguageInfo::script.

◆ TEST() [158/174]

flutter::testing::TEST ( SystemUtils  ,
ParseLanguageNameWithSuplementalLanguage   
)

Definition at line 81 of file system_utils_unittests.cc.

81  {
82  LanguageInfo info = ParseLanguageName(L"en-US-x-fabricam");
83  EXPECT_EQ(info.language, "en");
84  EXPECT_EQ(info.region, "US");
85  EXPECT_TRUE(info.script.empty());
86 }

References flutter::LanguageInfo::language, flutter::ParseLanguageName(), flutter::LanguageInfo::region, and flutter::LanguageInfo::script.

◆ TEST() [159/174]

flutter::testing::TEST ( SystemUtils  ,
ParseLanguageNameWithThreeCharacterLanguage   
)

Definition at line 89 of file system_utils_unittests.cc.

89  {
90  LanguageInfo info = ParseLanguageName(L"ale-ZZ");
91  EXPECT_EQ(info.language, "ale");
92  EXPECT_EQ(info.region, "ZZ");
93  EXPECT_TRUE(info.script.empty());
94 }

References flutter::LanguageInfo::language, flutter::ParseLanguageName(), flutter::LanguageInfo::region, and flutter::LanguageInfo::script.

◆ TEST() [160/174]

flutter::testing::TEST ( SystemUtils  ,
Prefer24HourTimeHandles12Hour   
)

Definition at line 105 of file system_utils_unittests.cc.

105  {
106  EXPECT_FALSE(Prefer24HourTime(L"h:mm:ss tt"));
107 }
bool Prefer24HourTime(std::wstring time_format)

References flutter::Prefer24HourTime().

◆ TEST() [161/174]

flutter::testing::TEST ( SystemUtils  ,
Prefer24HourTimeHandles24Hour   
)

Definition at line 109 of file system_utils_unittests.cc.

109  {
110  EXPECT_TRUE(Prefer24HourTime(L"HH:mm:ss"));
111 }

References flutter::Prefer24HourTime().

◆ TEST() [162/174]

flutter::testing::TEST ( SystemUtils  ,
Prefer24HourTimeHandlesEmptyFormat   
)

Definition at line 101 of file system_utils_unittests.cc.

101  {
102  EXPECT_FALSE(Prefer24HourTime(L""));
103 }

References flutter::Prefer24HourTime().

◆ TEST() [163/174]

flutter::testing::TEST ( TaskRunnerTest  ,
EmptyTaskRunnerReturnsNanoSecondsMax   
)

Definition at line 124 of file task_runner_unittests.cc.

124  {
125  TaskRunner runner(MockGetCurrentTime, [](const FlutterTask*) {});
126  auto res = runner.ProcessTasks();
127  EXPECT_EQ(res, std::chrono::nanoseconds::max());
128 }

References flutter::TaskRunner::ProcessTasks().

◆ TEST() [164/174]

flutter::testing::TEST ( TaskRunnerTest  ,
MaybeExecuteTaskOnlyExpired   
)

Definition at line 72 of file task_runner_unittests.cc.

72  {
73  std::set<uint64_t> executed_task;
74  auto runner = MockTaskRunner(
75  MockGetCurrentTime, [&executed_task](const FlutterTask* expired_task) {
76  executed_task.insert(expired_task->task);
77  });
78 
79  uint64_t task_expired_before_now = 1;
80  uint64_t time_before_now = 0;
81  runner.PostFlutterTask(FlutterTask{nullptr, task_expired_before_now},
82  time_before_now);
83 
84  uint64_t task_expired_after_now = 2;
85  uint64_t time_after_now = MockGetCurrentTime() * 2;
86  runner.PostFlutterTask(FlutterTask{nullptr, task_expired_after_now},
87  time_after_now);
88 
89  runner.SimulateTimerAwake();
90 
91  std::set<uint64_t> only_task_expired_before_now{task_expired_before_now};
92  EXPECT_EQ(executed_task, only_task_expired_before_now);
93 }

◆ TEST() [165/174]

flutter::testing::TEST ( TaskRunnerTest  ,
MaybeExecuteTaskWithExactOrder   
)

Definition at line 49 of file task_runner_unittests.cc.

49  {
50  std::vector<uint64_t> executed_task_order;
51  auto runner =
52  MockTaskRunner(MockGetCurrentTime,
53  [&executed_task_order](const FlutterTask* expired_task) {
54  executed_task_order.push_back(expired_task->task);
55  });
56 
57  uint64_t time_now = MockGetCurrentTime();
58 
59  runner.PostFlutterTask(FlutterTask{nullptr, 1}, time_now);
60  runner.PostFlutterTask(FlutterTask{nullptr, 2}, time_now);
61  runner.PostTask(
62  [&executed_task_order]() { executed_task_order.push_back(3); });
63  runner.PostTask(
64  [&executed_task_order]() { executed_task_order.push_back(4); });
65 
66  runner.SimulateTimerAwake();
67 
68  std::vector<uint64_t> posted_task_order{1, 2, 3, 4};
69  EXPECT_EQ(executed_task_order, posted_task_order);
70 }

◆ TEST() [166/174]

flutter::testing::TEST ( TaskRunnerTest  ,
TaskRunnerWindowCoalescesWakeUpMessages   
)

Definition at line 130 of file task_runner_unittests.cc.

130  {
131  class Delegate : public TaskRunnerWindow::Delegate {
132  public:
133  Delegate() {}
134 
135  std::chrono::nanoseconds ProcessTasks() override {
136  process_tasks_call_count_++;
137  return std::chrono::nanoseconds::max();
138  }
139 
140  int process_tasks_call_count_ = 0;
141  };
142 
143  Delegate delegate;
144  TestTaskRunnerWindow window;
145 
146  window.AddDelegate(&delegate);
147 
148  window.WakeUp();
149  window.WakeUp();
150 
151  ::MSG msg;
152  while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
153  TranslateMessage(&msg);
154  DispatchMessage(&msg);
155  }
156 
157  EXPECT_EQ(delegate.process_tasks_call_count_, 1);
158 }

References flutter::TaskRunnerWindow::AddDelegate(), and flutter::TaskRunnerWindow::WakeUp().

◆ TEST() [167/174]

flutter::testing::TEST ( TaskRunnerTest  ,
TimerThreadDoesNotCancelEarlierScheduledTasks   
)

Definition at line 95 of file task_runner_unittests.cc.

95  {
96  std::atomic_bool signaled = false;
97  std::optional<std::chrono::high_resolution_clock::time_point> callback_time;
98  TimerThread timer_thread([&]() {
99  callback_time = std::chrono::high_resolution_clock::now();
100  signaled = true;
101  });
102  timer_thread.Start();
103  auto now = std::chrono::high_resolution_clock::now();
104  // Make sure that subsequent call to schedule does not cancel earlier task
105  // as documented in TimerThread::ScheduleAt.
106  timer_thread.ScheduleAt(now + std::chrono::milliseconds(20));
107  timer_thread.ScheduleAt(now + std::chrono::seconds(10));
108 
109  while (!signaled.load()) {
110  std::this_thread::sleep_for(std::chrono::milliseconds(5));
111  }
112 
113  EXPECT_TRUE(callback_time.has_value());
114  EXPECT_GE(*callback_time, now + std::chrono::milliseconds(20));
115 
116  timer_thread.Stop();
117 }

References flutter::TimerThread::Start().

◆ TEST() [168/174]

flutter::testing::TEST ( WindowProcDelegateManagerTest  ,
CallsCorrectly   
)

Definition at line 54 of file window_proc_delegate_manager_unittests.cc.

54  {
55  WindowProcDelegateManager manager;
56  HWND dummy_hwnd;
57 
58  bool called = false;
59  TestWindowProcDelegate delegate = [&called, &dummy_hwnd](
60  HWND hwnd, UINT message, WPARAM wparam,
61  LPARAM lparam) {
62  called = true;
63  EXPECT_EQ(hwnd, dummy_hwnd);
64  EXPECT_EQ(message, 2);
65  EXPECT_EQ(wparam, 3);
66  EXPECT_EQ(lparam, 4);
67  return std::optional<LRESULT>();
68  };
69  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback, &delegate);
70  auto result = manager.OnTopLevelWindowProc(dummy_hwnd, 2, 3, 4);
71 
72  EXPECT_TRUE(called);
73  EXPECT_FALSE(result);
74 }

References message, flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), and flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate().

◆ TEST() [169/174]

flutter::testing::TEST ( WindowProcDelegateManagerTest  ,
ConflictingDelegates   
)

Definition at line 163 of file window_proc_delegate_manager_unittests.cc.

163  {
164  WindowProcDelegateManager manager;
165 
166  bool called_a = false;
167  TestWindowProcDelegate delegate_a =
168  [&called_a](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
169  called_a = true;
170  return std::optional<LRESULT>(1);
171  };
172  bool called_b = false;
173  TestWindowProcDelegate delegate_b =
174  [&called_b](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
175  called_b = true;
176  return std::optional<LRESULT>(1);
177  };
178  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
179  &delegate_a);
180  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
181  &delegate_b);
182  auto result = manager.OnTopLevelWindowProc(nullptr, 0, 0, 0);
183 
184  EXPECT_TRUE(result);
185  // Exactly one of the handlers should be called since each will claim to have
186  // handled the message. Which one is unspecified, since the calling order is
187  // unspecified.
188  EXPECT_TRUE(called_a || called_b);
189  EXPECT_NE(called_a, called_b);
190 }

References message, flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), and flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate().

◆ TEST() [170/174]

flutter::testing::TEST ( WindowProcDelegateManagerTest  ,
Ordered   
)

Definition at line 128 of file window_proc_delegate_manager_unittests.cc.

128  {
129  TestWindowProcDelegate delegate_1 = [](HWND hwnd, UINT message, WPARAM wparam,
130  LPARAM lparam) { return 1; };
131  TestWindowProcDelegate delegate_2 = [](HWND hwnd, UINT message, WPARAM wparam,
132  LPARAM lparam) { return 2; };
133 
134  // Result should be 1 if delegate '1' is registered before delegate '2'.
135  {
136  WindowProcDelegateManager manager;
137  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
138  &delegate_1);
139  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
140  &delegate_2);
141 
142  std::optional<LRESULT> result =
143  manager.OnTopLevelWindowProc(nullptr, 0, 0, 0);
144 
145  EXPECT_EQ(result, 1);
146  }
147 
148  // Result should be 2 if delegate '2' is registered before delegate '1'.
149  {
150  WindowProcDelegateManager manager;
151  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
152  &delegate_2);
153  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
154  &delegate_1);
155 
156  std::optional<LRESULT> result =
157  manager.OnTopLevelWindowProc(nullptr, 0, 0, 0);
158 
159  EXPECT_EQ(result, 2);
160  }
161 }

References message, flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), and flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate().

◆ TEST() [171/174]

flutter::testing::TEST ( WindowProcDelegateManagerTest  ,
RegisterMultiple   
)

Definition at line 102 of file window_proc_delegate_manager_unittests.cc.

102  {
103  WindowProcDelegateManager manager;
104 
105  bool called_a = false;
106  TestWindowProcDelegate delegate_a =
107  [&called_a](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
108  called_a = true;
109  return std::optional<LRESULT>();
110  };
111  bool called_b = false;
112  TestWindowProcDelegate delegate_b =
113  [&called_b](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
114  called_b = true;
115  return std::optional<LRESULT>();
116  };
117  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
118  &delegate_a);
119  // Function pointer is different, so both should be called.
120  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback2,
121  &delegate_b);
122  manager.OnTopLevelWindowProc(nullptr, 0, 0, 0);
123 
124  EXPECT_TRUE(called_a);
125  EXPECT_TRUE(called_b);
126 }

References message, flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), and flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate().

◆ TEST() [172/174]

flutter::testing::TEST ( WindowProcDelegateManagerTest  ,
ReplacementRegister   
)

Definition at line 76 of file window_proc_delegate_manager_unittests.cc.

76  {
77  WindowProcDelegateManager manager;
78 
79  bool called_a = false;
80  TestWindowProcDelegate delegate_a =
81  [&called_a](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
82  called_a = true;
83  return std::optional<LRESULT>();
84  };
85  bool called_b = false;
86  TestWindowProcDelegate delegate_b =
87  [&called_b](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
88  called_b = true;
89  return std::optional<LRESULT>();
90  };
91  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
92  &delegate_a);
93  // The function pointer is the same, so this should replace, not add.
94  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback,
95  &delegate_b);
96  manager.OnTopLevelWindowProc(nullptr, 0, 0, 0);
97 
98  EXPECT_FALSE(called_a);
99  EXPECT_TRUE(called_b);
100 }

References message, flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), and flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate().

◆ TEST() [173/174]

flutter::testing::TEST ( WindowProcDelegateManagerTest  ,
Unregister   
)

Definition at line 192 of file window_proc_delegate_manager_unittests.cc.

192  {
193  WindowProcDelegateManager manager;
194 
195  bool called = false;
196  TestWindowProcDelegate delegate = [&called](HWND hwnd, UINT message,
197  WPARAM wparam, LPARAM lparam) {
198  called = true;
199  return std::optional<LRESULT>();
200  };
201  manager.RegisterTopLevelWindowProcDelegate(TestWindowProcCallback, &delegate);
202  manager.UnregisterTopLevelWindowProcDelegate(TestWindowProcCallback);
203  auto result = manager.OnTopLevelWindowProc(nullptr, 0, 0, 0);
204 
205  EXPECT_FALSE(result);
206  EXPECT_FALSE(called);
207 }

References message, flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate(), and flutter::WindowProcDelegateManager::UnregisterTopLevelWindowProcDelegate().

◆ TEST() [174/174]

flutter::testing::TEST ( WindowsNoFixtureTest  ,
GetTextureRegistrar   
)

Definition at line 66 of file flutter_windows_unittests.cc.

66  {
67  FlutterDesktopEngineProperties properties = {};
68  properties.assets_path = L"";
69  properties.icu_data_path = L"icudtl.dat";
70  properties.impeller_switch = DefaultImpeller;
71  auto engine = FlutterDesktopEngineCreate(&properties);
72  ASSERT_NE(engine, nullptr);
73  auto texture_registrar = FlutterDesktopEngineGetTextureRegistrar(engine);
74  EXPECT_NE(texture_registrar, nullptr);
76 }
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
bool FlutterDesktopEngineDestroy(FlutterDesktopEngineRef engine_ref)
FlutterDesktopTextureRegistrarRef FlutterDesktopEngineGetTextureRegistrar(FlutterDesktopEngineRef engine)
@ DefaultImpeller
FlutterDesktopImpellerSwitch impeller_switch

References FlutterDesktopEngineProperties::assets_path, DefaultImpeller, FlutterDesktopEngineCreate(), FlutterDesktopEngineDestroy(), FlutterDesktopEngineGetTextureRegistrar(), FlutterDesktopEngineProperties::icu_data_path, and FlutterDesktopEngineProperties::impeller_switch.

◆ TEST_F() [1/239]

flutter::testing::TEST_F ( AccessibilityPluginTest  ,
AnnounceWithInt32ViewId   
)

Definition at line 112 of file accessibility_plugin_unittests.cc.

112  {
113  EXPECT_CALL(*view(), AnnounceAlert(::testing::Eq(L"Hello"))).Times(1);
114 
115  SendAnnounceMessage("Hello", EncodableValue{static_cast<int32_t>(0)});
116 
117  // Verify expectations are met
118  ::testing::Mock::VerifyAndClearExpectations(view());
119 }

◆ TEST_F() [2/239]

flutter::testing::TEST_F ( AccessibilityPluginTest  ,
AnnounceWithInt64ViewId   
)

Definition at line 121 of file accessibility_plugin_unittests.cc.

121  {
122  EXPECT_CALL(*view(), AnnounceAlert(::testing::Eq(L"Hello World"))).Times(1);
123 
124  SendAnnounceMessage("Hello World", EncodableValue{static_cast<int64_t>(0)});
125 
126  // Verify expectations are met
127  ::testing::Mock::VerifyAndClearExpectations(view());
128 }

◆ TEST_F() [3/239]

flutter::testing::TEST_F ( AccessibilityPluginTest  ,
AnnounceWithInvalidViewIdType   
)

Definition at line 130 of file accessibility_plugin_unittests.cc.

130  {
131  // Should not be called with invalid viewId type
132  EXPECT_CALL(*view(), AnnounceAlert(_)).Times(0);
133 
134  SendAnnounceMessage("Hello", EncodableValue{"invalid"});
135 }

◆ TEST_F() [4/239]

flutter::testing::TEST_F ( AccessibilityPluginTest  ,
AnnounceWithMissingMessage   
)

Definition at line 136 of file accessibility_plugin_unittests.cc.

136  {
137  // Should not be called when message is missing
138  EXPECT_CALL(*view(), AnnounceAlert(_)).Times(0);
139 
140  EncodableMap data;
141  data[EncodableValue{"viewId"}] = EncodableValue{static_cast<int32_t>(0)};
142 
143  EncodableMap msg;
144  msg[EncodableValue{"type"}] = EncodableValue{"announce"};
145  msg[EncodableValue{"data"}] = EncodableValue{data};
146 
147  auto encoded =
148  StandardMessageCodec::GetInstance().EncodeMessage(EncodableValue{msg});
149 
150  messenger()->SimulateEngineMessage(
151  kAccessibilityChannelName, encoded->data(), encoded->size(),
152  [](const uint8_t* reply, size_t reply_size) {});
153 }
static constexpr char kAccessibilityChannelName[]
std::map< EncodableValue, EncodableValue > EncodableMap

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

◆ TEST_F() [5/239]

flutter::testing::TEST_F ( AccessibilityPluginTest  ,
DirectAnnounceCall   
)

Definition at line 102 of file accessibility_plugin_unittests.cc.

102  {
103  // Test calling Announce directly, bypassing the message channel
104  EXPECT_CALL(*view(), AnnounceAlert(::testing::Eq(L"Direct"))).Times(1);
105 
106  AccessibilityPlugin plugin(engine());
107  plugin.Announce(0, "Direct");
108 
109  ::testing::Mock::VerifyAndClearExpectations(view());
110 }

References flutter::AccessibilityPlugin::Announce().

◆ TEST_F() [6/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
CreateBackingStore   
)

Definition at line 202 of file compositor_opengl_unittests.cc.

202  {
203  UseHeadlessEngine();
204 
205  auto compositor =
206  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
207 
208  FlutterBackingStoreConfig config = {};
209  FlutterBackingStore backing_store = {};
210 
211  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
212  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
213  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
214 }

◆ TEST_F() [7/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
CreateBackingStoreImpellerMSAA   
)

Definition at line 253 of file compositor_opengl_unittests.cc.

253  {
254  UseHeadlessEngine();
255 
256  static int framebuffer_texture2d_calls = 0;
257  static int framebuffer_texture2d_multisample_calls = 0;
258  framebuffer_texture2d_calls = 0;
259  framebuffer_texture2d_multisample_calls = 0;
260 
261  const impeller::ProcTableGLES::Resolver resolver =
262  [](const char* name) -> void* {
263  std::string_view function_name{name};
264  if (function_name == "glFramebufferTexture2D") {
265  return reinterpret_cast<void*>(
266  +[](GLenum, GLenum, GLenum, GLuint, GLint) {
267  framebuffer_texture2d_calls++;
268  });
269  } else if (function_name == "glFramebufferTexture2DMultisampleEXT") {
270  return reinterpret_cast<void*>(
271  +[](GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) {
272  framebuffer_texture2d_multisample_calls++;
273  });
274  }
275  return kMockResolverWithMSAA(name);
276  };
277 
278  auto compositor =
279  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/true};
280  FlutterBackingStoreConfig config = {};
281  FlutterBackingStore backing_store = {};
282 
283  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
284  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
285  EXPECT_EQ(framebuffer_texture2d_calls, 0);
286  EXPECT_EQ(framebuffer_texture2d_multisample_calls, 1);
287  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
288 }

◆ TEST_F() [8/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
CreateBackingStoreImpellerNoMSAA   
)

Definition at line 216 of file compositor_opengl_unittests.cc.

216  {
217  UseHeadlessEngine();
218 
219  static int framebuffer_texture2d_calls = 0;
220  static int framebuffer_texture2d_multisample_calls = 0;
221  framebuffer_texture2d_calls = 0;
222  framebuffer_texture2d_multisample_calls = 0;
223 
224  const impeller::ProcTableGLES::Resolver resolver =
225  [](const char* name) -> void* {
226  std::string_view function_name{name};
227  if (function_name == "glFramebufferTexture2D") {
228  return reinterpret_cast<void*>(
229  +[](GLenum, GLenum, GLenum, GLuint, GLint) {
230  framebuffer_texture2d_calls++;
231  });
232  } else if (function_name == "glFramebufferTexture2DMultisampleEXT") {
233  return reinterpret_cast<void*>(
234  +[](GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) {
235  framebuffer_texture2d_multisample_calls++;
236  });
237  }
238  return kMockResolver(name);
239  };
240 
241  auto compositor =
242  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/true};
243  FlutterBackingStoreConfig config = {};
244  FlutterBackingStore backing_store = {};
245 
246  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
247  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
248  EXPECT_EQ(framebuffer_texture2d_calls, 1);
249  EXPECT_EQ(framebuffer_texture2d_multisample_calls, 0);
250  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
251 }

◆ TEST_F() [9/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
CreateBackingStoreImpellerOffscreenMSAA   
)

Definition at line 293 of file compositor_opengl_unittests.cc.

293  {
294  UseHeadlessEngine();
295 
296  static int framebuffer_texture2d_calls = 0;
297  static int framebuffer_texture2d_multisample_calls = 0;
298  static int renderbuffer_storage_multisample_calls = 0;
299  static int renderbuffer_storage_multisample_samples = 0;
300  static int framebuffer_renderbuffer_calls = 0;
301  static int delete_renderbuffers_calls = 0;
302  static int delete_textures_calls = 0;
303 
304  framebuffer_texture2d_calls = 0;
305  framebuffer_texture2d_multisample_calls = 0;
306  renderbuffer_storage_multisample_calls = 0;
307  renderbuffer_storage_multisample_samples = 0;
308  framebuffer_renderbuffer_calls = 0;
309  delete_renderbuffers_calls = 0;
310  delete_textures_calls = 0;
311 
312  const impeller::ProcTableGLES::Resolver resolver =
313  [](const char* name) -> void* {
314  std::string_view function_name{name};
315  if (function_name == "glFramebufferTexture2D") {
316  return reinterpret_cast<void*>(
317  +[](GLenum, GLenum, GLenum, GLuint, GLint) {
318  framebuffer_texture2d_calls++;
319  });
320  } else if (function_name == "glFramebufferTexture2DMultisampleEXT") {
321  return reinterpret_cast<void*>(
322  +[](GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) {
323  framebuffer_texture2d_multisample_calls++;
324  });
325  } else if (function_name == "glGenRenderbuffers") {
326  return reinterpret_cast<void*>(+[](GLsizei n, GLuint* renderbuffers) {
327  static GLuint next_id = 1;
328  for (GLsizei i = 0; i < n; i++) {
329  renderbuffers[i] = next_id++;
330  }
331  });
332  } else if (function_name == "glRenderbufferStorageMultisample") {
333  return reinterpret_cast<void*>(+[](GLenum target, GLsizei samples,
334  GLenum internalformat, GLsizei width,
335  GLsizei height) {
336  renderbuffer_storage_multisample_calls++;
337  renderbuffer_storage_multisample_samples = samples;
338  });
339  } else if (function_name == "glFramebufferRenderbuffer") {
340  return reinterpret_cast<void*>(+[](GLenum, GLenum, GLenum, GLuint) {
341  framebuffer_renderbuffer_calls++;
342  });
343  } else if (function_name == "glDeleteRenderbuffers") {
344  return reinterpret_cast<void*>(
345  +[](GLsizei n, const GLuint* renderbuffers) {
346  delete_renderbuffers_calls += n;
347  });
348  } else if (function_name == "glDeleteTextures") {
349  return reinterpret_cast<void*>(+[](GLsizei n, const GLuint* textures) {
350  delete_textures_calls += n;
351  });
352  }
353  return kMockResolverWithOffscreenMSAA(name);
354  };
355 
356  auto compositor =
357  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/true};
358  FlutterBackingStoreConfig config = {};
359  FlutterBackingStore backing_store = {};
360 
361  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
362  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
363  EXPECT_EQ(framebuffer_texture2d_calls, 0);
364  EXPECT_EQ(framebuffer_texture2d_multisample_calls, 0);
365  EXPECT_EQ(renderbuffer_storage_multisample_calls, 2);
366  EXPECT_EQ(renderbuffer_storage_multisample_samples, 4);
367  EXPECT_EQ(framebuffer_renderbuffer_calls, 3);
368 
369  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
370  EXPECT_EQ(delete_renderbuffers_calls, 2);
371  EXPECT_EQ(delete_textures_calls, 0);
372 }

◆ TEST_F() [10/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
InitializationFailure   
)

Definition at line 374 of file compositor_opengl_unittests.cc.

374  {
375  UseHeadlessEngine();
376 
377  auto compositor =
378  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
379 
380  FlutterBackingStoreConfig config = {};
381  FlutterBackingStore backing_store = {};
382 
383  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(false));
384  EXPECT_FALSE(compositor.CreateBackingStore(config, &backing_store));
385 }

◆ TEST_F() [11/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
InitializationRequiresBlit   
)

Definition at line 387 of file compositor_opengl_unittests.cc.

387  {
388  UseHeadlessEngine();
389 
390  const impeller::ProcTableGLES::Resolver resolver = [](const char* name) {
391  std::string function_name{name};
392 
393  if (function_name == "glBlitFramebuffer" ||
394  function_name == "glBlitFramebufferANGLE") {
395  return (void*)nullptr;
396  }
397 
398  return kMockResolver(name);
399  };
400 
401  auto compositor =
402  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/false};
403 
404  FlutterBackingStoreConfig config = {};
405  FlutterBackingStore backing_store = {};
406 
407  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
408  ASSERT_FALSE(compositor.CreateBackingStore(config, &backing_store));
409 }

◆ TEST_F() [12/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
NoSurfaceIgnored   
)

Definition at line 451 of file compositor_opengl_unittests.cc.

451  {
452  UseEngineWithView(/*add_surface = */ false);
453 
454  auto compositor =
455  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
456 
457  FlutterBackingStoreConfig config = {};
458  FlutterBackingStore backing_store = {};
459 
460  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
461  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
462 
463  FlutterLayer layer = {};
464  layer.type = kFlutterLayerContentTypeBackingStore;
465  layer.backing_store = &backing_store;
466  const FlutterLayer* layer_ptr = &layer;
467 
468  EXPECT_FALSE(compositor.Present(view(), &layer_ptr, 1));
469 
470  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
471 }

◆ TEST_F() [13/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
Present   
)

Definition at line 411 of file compositor_opengl_unittests.cc.

411  {
412  UseEngineWithView();
413 
414  auto compositor =
415  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
416 
417  FlutterBackingStoreConfig config = {};
418  FlutterBackingStore backing_store = {};
419 
420  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
421  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
422 
423  FlutterLayer layer = {};
424  layer.type = kFlutterLayerContentTypeBackingStore;
425  layer.backing_store = &backing_store;
426  const FlutterLayer* layer_ptr = &layer;
427 
428  EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
429  EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
430  EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
431  EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
432 
433  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
434 }

◆ TEST_F() [14/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
PresentEmpty   
)

Definition at line 436 of file compositor_opengl_unittests.cc.

436  {
437  UseEngineWithView();
438 
439  auto compositor =
440  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
441 
442  // The context will be bound twice: first to initialize the compositor, second
443  // to clear the surface.
444  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
445  EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
446  EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
447  EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
448  EXPECT_TRUE(compositor.Present(view(), nullptr, 0));
449 }

◆ TEST_F() [15/239]

flutter::testing::TEST_F ( CompositorOpenGLTest  ,
PresentUsingANGLEBlitExtension   
)

Definition at line 473 of file compositor_opengl_unittests.cc.

473  {
474  UseEngineWithView();
475 
476  bool resolved_ANGLE_blit = false;
477  const impeller::ProcTableGLES::Resolver resolver =
478  [&resolved_ANGLE_blit](const char* name) {
479  std::string function_name{name};
480 
481  if (function_name == "glBlitFramebuffer") {
482  return (void*)nullptr;
483  } else if (function_name == "glBlitFramebufferANGLE") {
484  resolved_ANGLE_blit = true;
485  return reinterpret_cast<void*>(&DoNothing);
486  }
487 
488  return kMockResolver(name);
489  };
490 
491  auto compositor =
492  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/false};
493 
494  FlutterBackingStoreConfig config = {};
495  FlutterBackingStore backing_store = {};
496 
497  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
498  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
499 
500  FlutterLayer layer = {};
501  layer.type = kFlutterLayerContentTypeBackingStore;
502  layer.backing_store = &backing_store;
503  const FlutterLayer* layer_ptr = &layer;
504 
505  EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
506  EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
507  EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
508  EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
509  EXPECT_TRUE(resolved_ANGLE_blit);
510 
511  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
512 }

◆ TEST_F() [16/239]

flutter::testing::TEST_F ( CompositorSoftwareTest  ,
CreateBackingStore   
)

Definition at line 74 of file compositor_software_unittests.cc.

74  {
75  CompositorSoftware compositor;
76 
77  FlutterBackingStoreConfig config = {};
78  FlutterBackingStore backing_store = {};
79 
80  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
81  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
82 }

References flutter::CompositorSoftware::CollectBackingStore(), and flutter::CompositorSoftware::CreateBackingStore().

◆ TEST_F() [17/239]

flutter::testing::TEST_F ( CompositorSoftwareTest  ,
Present   
)

Definition at line 84 of file compositor_software_unittests.cc.

84  {
85  UseEngineWithView();
86 
87  CompositorSoftware compositor;
88 
89  FlutterBackingStoreConfig config = {};
90  FlutterBackingStore backing_store = {};
91 
92  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
93 
94  FlutterLayer layer = {};
95  layer.type = kFlutterLayerContentTypeBackingStore;
96  layer.backing_store = &backing_store;
97  const FlutterLayer* layer_ptr = &layer;
98 
99  EXPECT_CALL(*view(), PresentSoftwareBitmap).WillOnce(Return(true));
100  EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
101 
102  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
103 }

References flutter::CompositorSoftware::CollectBackingStore(), flutter::CompositorSoftware::CreateBackingStore(), and flutter::CompositorSoftware::Present().

◆ TEST_F() [18/239]

flutter::testing::TEST_F ( CompositorSoftwareTest  ,
PresentEmpty   
)

Definition at line 105 of file compositor_software_unittests.cc.

105  {
106  UseEngineWithView();
107 
108  CompositorSoftware compositor;
109 
110  EXPECT_CALL(*view(), ClearSoftwareBitmap).WillOnce(Return(true));
111  EXPECT_TRUE(compositor.Present(view(), nullptr, 0));
112 }

References flutter::CompositorSoftware::Present().

◆ TEST_F() [19/239]

flutter::testing::TEST_F ( CompositorSoftwareTest  ,
PresentMultiLayers   
)

Definition at line 121 of file compositor_software_unittests.cc.

121  {
122  UseEngineWithView();
123 
124  CompositorSoftware compositor;
125 
126  FlutterBackingStoreConfig config = {sizeof(config), {2, 2}};
127  FlutterBackingStore backing_store0 = {sizeof(FlutterBackingStore), nullptr};
128  FlutterBackingStore backing_store1 = {sizeof(FlutterBackingStore), nullptr};
129 
130  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store0));
131  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store1));
132 
133  uint32_t pixels0[4] = {0xff000000, 0xff0000ff, 0xff00ff00, 0xffffffff};
134  uint32_t pixels1[4] = {0x7f0000ff, 0x00ffffff, 0x7fff0000, 0xff000000};
135 
136  std::memcpy(const_cast<void*>(backing_store0.software.allocation), pixels0,
137  sizeof(uint32_t) * 4);
138  std::memcpy(const_cast<void*>(backing_store1.software.allocation), pixels1,
139  sizeof(uint32_t) * 4);
140 
141  FlutterLayer layer0 = {};
142  layer0.type = kFlutterLayerContentTypeBackingStore;
143  layer0.backing_store = &backing_store0;
144  layer0.offset = {0, 0};
145  layer0.size = {2, 2};
146 
147  FlutterLayer layer1 = layer0;
148  layer1.backing_store = &backing_store1;
149  const FlutterLayer* layer_ptr[2] = {&layer0, &layer1};
150 
151  EXPECT_CALL(*view(), PresentSoftwareBitmap)
152  .WillOnce([&](const void* allocation, size_t row_bytes, size_t height) {
153  auto pixel_data = static_cast<const uint32_t*>(allocation);
154  EXPECT_EQ(row_bytes, 2 * sizeof(uint32_t));
155  EXPECT_EQ(height, 2);
156  EXPECT_EQ(pixel_data[0], 0xff00007f);
157  EXPECT_EQ(pixel_data[1], 0xff0000ff);
158  EXPECT_EQ(pixel_data[2], 0xff7f8000);
159  EXPECT_EQ(pixel_data[3], 0xff000000);
160  return true;
161  });
162  EXPECT_TRUE(compositor.Present(view(), layer_ptr, 2));
163 
164  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store0));
165  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store1));
166 }

References flutter::CompositorSoftware::CollectBackingStore(), flutter::CompositorSoftware::CreateBackingStore(), and flutter::CompositorSoftware::Present().

◆ TEST_F() [20/239]

flutter::testing::TEST_F ( CompositorSoftwareTest  ,
PresentOffsetLayers   
)

Definition at line 171 of file compositor_software_unittests.cc.

171  {
172  UseEngineWithView();
173 
174  CompositorSoftware compositor;
175 
176  FlutterBackingStoreConfig config0 = {sizeof(FlutterBackingStoreConfig),
177  {1, 1}};
178  FlutterBackingStore backing_store0 = {sizeof(FlutterBackingStore), nullptr};
179  FlutterBackingStoreConfig config1 = {sizeof(FlutterBackingStoreConfig),
180  {2, 1}};
181  FlutterBackingStore backing_store1 = {sizeof(FlutterBackingStore), nullptr};
182 
183  ASSERT_TRUE(compositor.CreateBackingStore(config0, &backing_store0));
184  ASSERT_TRUE(compositor.CreateBackingStore(config1, &backing_store1));
185 
186  uint32_t pixels0 = 0xff0000ff;
187  uint32_t pixels1[2] = {0xffff0000, 0xffff0000};
188 
189  std::memcpy(const_cast<void*>(backing_store0.software.allocation), &pixels0,
190  sizeof(uint32_t) * 1);
191  std::memcpy(const_cast<void*>(backing_store1.software.allocation), pixels1,
192  sizeof(uint32_t) * 2);
193 
194  FlutterLayer layer0 = {};
195  layer0.type = kFlutterLayerContentTypeBackingStore;
196  layer0.backing_store = &backing_store0;
197  layer0.offset = {0, 0};
198  layer0.size = {1, 1};
199 
200  FlutterLayer layer1 = layer0;
201  layer1.backing_store = &backing_store1;
202  layer1.offset = {0, 1};
203  layer1.size = {2, 1};
204  const FlutterLayer* layer_ptr[2] = {&layer0, &layer1};
205 
206  EXPECT_CALL(*view(), PresentSoftwareBitmap)
207  .WillOnce([&](const void* allocation, size_t row_bytes, size_t height) {
208  auto pixel_data = static_cast<const uint32_t*>(allocation);
209  EXPECT_EQ(row_bytes, 2 * sizeof(uint32_t));
210  EXPECT_EQ(height, 2);
211  EXPECT_EQ(pixel_data[0], 0xff0000ff);
212  EXPECT_EQ(pixel_data[1], 0xff000000);
213  EXPECT_EQ(pixel_data[2], 0xffff0000);
214  EXPECT_EQ(pixel_data[3], 0xffff0000);
215  return true;
216  });
217  EXPECT_TRUE(compositor.Present(view(), layer_ptr, 2));
218 
219  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store0));
220  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store1));
221 }

References flutter::CompositorSoftware::CollectBackingStore(), flutter::CompositorSoftware::CreateBackingStore(), and flutter::CompositorSoftware::Present().

◆ TEST_F() [21/239]

flutter::testing::TEST_F ( CursorHandlerTest  ,
ActivateSystemCursor   
)

Definition at line 102 of file cursor_handler_unittests.cc.

102  {
103  UseEngineWithView();
104 
105  TestBinaryMessenger messenger;
106  CursorHandler cursor_handler(&messenger, engine());
107 
108  EXPECT_CALL(*proc_table(), LoadCursor(IsNull(), IDC_HAND)).Times(1);
109  EXPECT_CALL(*proc_table(), SetCursor).Times(1);
110 
111  bool success = false;
112  MethodResultFunctions<> result_handler(
113  [&success](const EncodableValue* result) {
114  success = true;
115  EXPECT_EQ(result, nullptr);
116  },
117  nullptr, nullptr);
118 
119  SimulateCursorMessage(&messenger, kActivateSystemCursorMethod,
120  std::make_unique<EncodableValue>(EncodableMap{
121  {EncodableValue("device"), EncodableValue(0)},
122  {EncodableValue("kind"), EncodableValue("click")},
123  }),
124  &result_handler);
125 
126  EXPECT_TRUE(success);
127 }
static constexpr char kActivateSystemCursorMethod[]

References kActivateSystemCursorMethod.

◆ TEST_F() [22/239]

flutter::testing::TEST_F ( CursorHandlerTest  ,
CreateCustomCursor   
)

Definition at line 129 of file cursor_handler_unittests.cc.

129  {
130  UseEngineWithView();
131 
132  TestBinaryMessenger messenger;
133  CursorHandler cursor_handler(&messenger, engine());
134 
135  // Create a 4x4 raw BGRA test cursor buffer.
136  std::vector<uint8_t> buffer(4 * 4 * 4, 0);
137 
138  bool success = false;
139  MethodResultFunctions<> result_handler(
140  [&success](const EncodableValue* result) {
141  success = true;
142  EXPECT_EQ(std::get<std::string>(*result), "hello");
143  },
144  nullptr, nullptr);
145 
146  SimulateCursorMessage(&messenger, kCreateCustomCursorMethod,
147  std::make_unique<EncodableValue>(EncodableMap{
148  {EncodableValue("name"), EncodableValue("hello")},
149  {EncodableValue("buffer"), EncodableValue(buffer)},
150  {EncodableValue("width"), EncodableValue(4)},
151  {EncodableValue("height"), EncodableValue(4)},
152  {EncodableValue("hotX"), EncodableValue(0.0)},
153  {EncodableValue("hotY"), EncodableValue(0.0)},
154  }),
155  &result_handler);
156 
157  EXPECT_TRUE(success);
158 }
static constexpr char kCreateCustomCursorMethod[]

References kCreateCustomCursorMethod.

◆ TEST_F() [23/239]

flutter::testing::TEST_F ( CursorHandlerTest  ,
DeleteCustomCursor   
)

Definition at line 231 of file cursor_handler_unittests.cc.

231  {
232  UseEngineWithView();
233 
234  TestBinaryMessenger messenger;
235  CursorHandler cursor_handler(&messenger, engine());
236 
237  // Create a 4x4 raw BGRA test cursor buffer.
238  std::vector<uint8_t> buffer(4 * 4 * 4, 0);
239 
240  bool success = false;
241  MethodResultFunctions<> create_result_handler(nullptr, nullptr, nullptr);
242  MethodResultFunctions<> delete_result_handler(
243  [&success](const EncodableValue* result) {
244  success = true;
245  EXPECT_EQ(result, nullptr);
246  },
247  nullptr, nullptr);
248 
249  SimulateCursorMessage(&messenger, kCreateCustomCursorMethod,
250  std::make_unique<EncodableValue>(EncodableMap{
251  {EncodableValue("name"), EncodableValue("hello")},
252  {EncodableValue("buffer"), EncodableValue(buffer)},
253  {EncodableValue("width"), EncodableValue(4)},
254  {EncodableValue("height"), EncodableValue(4)},
255  {EncodableValue("hotX"), EncodableValue(0.0)},
256  {EncodableValue("hotY"), EncodableValue(0.0)},
257  }),
258  &create_result_handler);
259 
260  SimulateCursorMessage(&messenger, kDeleteCustomCursorMethod,
261  std::make_unique<EncodableValue>(EncodableMap{
262  {EncodableValue("name"), EncodableValue("hello")},
263  }),
264  &delete_result_handler);
265 
266  EXPECT_TRUE(success);
267 }
static constexpr char kDeleteCustomCursorMethod[]

References kCreateCustomCursorMethod, and kDeleteCustomCursorMethod.

◆ TEST_F() [24/239]

flutter::testing::TEST_F ( CursorHandlerTest  ,
DeleteNonexistentCustomCursor   
)

Definition at line 269 of file cursor_handler_unittests.cc.

269  {
270  UseEngineWithView();
271 
272  TestBinaryMessenger messenger;
273  CursorHandler cursor_handler(&messenger, engine());
274 
275  bool success = false;
276  MethodResultFunctions<> result_handler(
277  [&success](const EncodableValue* result) {
278  success = true;
279  EXPECT_EQ(result, nullptr);
280  },
281  nullptr, nullptr);
282 
283  SimulateCursorMessage(&messenger, kDeleteCustomCursorMethod,
284  std::make_unique<EncodableValue>(EncodableMap{
285  {EncodableValue("name"), EncodableValue("fake")},
286  }),
287  &result_handler);
288 
289  EXPECT_TRUE(success);
290 }

References kDeleteCustomCursorMethod.

◆ TEST_F() [25/239]

flutter::testing::TEST_F ( CursorHandlerTest  ,
SetCustomCursor   
)

Definition at line 160 of file cursor_handler_unittests.cc.

160  {
161  UseEngineWithView();
162 
163  TestBinaryMessenger messenger;
164  CursorHandler cursor_handler(&messenger, engine());
165 
166  // Create a 4x4 raw BGRA test cursor buffer.
167  std::vector<uint8_t> buffer(4 * 4 * 4, 0);
168 
169  bool success = false;
170  MethodResultFunctions<> create_result_handler(nullptr, nullptr, nullptr);
171  MethodResultFunctions<> set_result_handler(
172  [&success](const EncodableValue* result) {
173  success = true;
174  EXPECT_EQ(result, nullptr);
175  },
176  nullptr, nullptr);
177 
178  EXPECT_CALL(*proc_table(), LoadCursor).Times(0);
179  EXPECT_CALL(*proc_table(), SetCursor(NotNull())).Times(1);
180 
181  SimulateCursorMessage(&messenger, kCreateCustomCursorMethod,
182  std::make_unique<EncodableValue>(EncodableMap{
183  {EncodableValue("name"), EncodableValue("hello")},
184  {EncodableValue("buffer"), EncodableValue(buffer)},
185  {EncodableValue("width"), EncodableValue(4)},
186  {EncodableValue("height"), EncodableValue(4)},
187  {EncodableValue("hotX"), EncodableValue(0.0)},
188  {EncodableValue("hotY"), EncodableValue(0.0)},
189  }),
190  &create_result_handler);
191 
192  SimulateCursorMessage(&messenger, kSetCustomCursorMethod,
193  std::make_unique<EncodableValue>(EncodableMap{
194  {EncodableValue("name"), EncodableValue("hello")},
195  }),
196  &set_result_handler);
197 
198  EXPECT_TRUE(success);
199 }
static constexpr char kSetCustomCursorMethod[]

References kCreateCustomCursorMethod, and kSetCustomCursorMethod.

◆ TEST_F() [26/239]

flutter::testing::TEST_F ( CursorHandlerTest  ,
SetNonexistentCustomCursor   
)

Definition at line 201 of file cursor_handler_unittests.cc.

201  {
202  UseEngineWithView();
203 
204  TestBinaryMessenger messenger;
205  CursorHandler cursor_handler(&messenger, engine());
206 
207  bool error = false;
208  MethodResultFunctions<> result_handler(
209  nullptr,
210  [&error](const std::string& error_code, const std::string& error_message,
211  const EncodableValue* value) {
212  error = true;
213  EXPECT_EQ(
214  error_message,
215  "The custom cursor identified by the argument key cannot be found");
216  },
217  nullptr);
218 
219  EXPECT_CALL(*proc_table(), LoadCursor).Times(0);
220  EXPECT_CALL(*proc_table(), SetCursor).Times(0);
221 
222  SimulateCursorMessage(&messenger, kSetCustomCursorMethod,
223  std::make_unique<EncodableValue>(EncodableMap{
224  {EncodableValue("name"), EncodableValue("hello")},
225  }),
226  &result_handler);
227 
228  EXPECT_TRUE(error);
229 }

References kSetCustomCursorMethod.

◆ TEST_F() [27/239]

flutter::testing::TEST_F ( DisplayManagerWin32Test  ,
HandleDisplayChangeMessage   
)

Definition at line 89 of file display_manager_unittests.cc.

89  {
90  // Create a mock Windows proc table
91  auto mock_windows_proc_table =
92  std::make_shared<NiceMock<MockWindowsProcTable>>();
93 
94  // Create a mock engine
95  FlutterWindowsEngineBuilder builder(GetContext());
96  builder.SetWindowsProcTable(mock_windows_proc_table);
97  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
98 
99  EXPECT_CALL(*mock_windows_proc_table, EnumDisplayMonitors(_, _, _, _))
100  .WillRepeatedly(Return(TRUE));
101 
102  // Create the display manager with the mock engine
103  auto display_manager = std::make_unique<DisplayManagerWin32>(engine.get());
104 
105  // Test handling a display change message
106  HWND dummy_hwnd = reinterpret_cast<HWND>(1);
107  LRESULT result = 0;
108 
109  // Verify that WM_DISPLAYCHANGE is handled
110  EXPECT_FALSE(display_manager->HandleWindowMessage(
111  dummy_hwnd, WM_DISPLAYCHANGE, 0, 0, &result));
112 
113  // Verify that WM_DPICHANGED is handled
114  EXPECT_FALSE(display_manager->HandleWindowMessage(dummy_hwnd, WM_DPICHANGED,
115  0, 0, &result));
116 
117  // Verify that other messages are not handled
118  EXPECT_FALSE(display_manager->HandleWindowMessage(dummy_hwnd, WM_PAINT, 0, 0,
119  &result));
120 }
const DisplayManagerWin32 * display_manager

References display_manager.

◆ TEST_F() [28/239]

flutter::testing::TEST_F ( DisplayManagerWin32Test  ,
MultipleMonitors   
)

Definition at line 34 of file display_manager_unittests.cc.

34  {
35  auto mock_windows_proc_table =
36  std::make_shared<NiceMock<MockWindowsProcTable>>();
37 
38  FlutterWindowsEngineBuilder builder(GetContext());
39  builder.SetWindowsProcTable(mock_windows_proc_table);
40  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
41 
42  HMONITOR mock_monitor1 = reinterpret_cast<HMONITOR>(123);
43  HMONITOR mock_monitor2 = reinterpret_cast<HMONITOR>(456);
44 
45  MONITORINFOEXW monitor_info1 = {};
46  monitor_info1.cbSize = sizeof(MONITORINFOEXW);
47  monitor_info1.rcMonitor = {0, 0, 1920, 1080};
48  monitor_info1.rcWork = {0, 0, 1920, 1080};
49  monitor_info1.dwFlags = MONITORINFOF_PRIMARY;
50  wcscpy_s(monitor_info1.szDevice, L"\\\\.\\DISPLAY1");
51 
52  MONITORINFOEXW monitor_info2 = {};
53  monitor_info2.cbSize = sizeof(MONITORINFOEXW);
54  monitor_info2.rcMonitor = {1920, 0, 1920 + 2560, 1440};
55  monitor_info2.rcWork = {1920, 0, 1920 + 2560, 1440};
56  monitor_info2.dwFlags = 0;
57  wcscpy_s(monitor_info2.szDevice, L"\\\\.\\DISPLAY2");
58 
59  EXPECT_CALL(*mock_windows_proc_table, GetMonitorInfoW(mock_monitor1, _))
60  .WillOnce(DoAll(SetArgPointee<1>(monitor_info1), Return(TRUE)));
61  EXPECT_CALL(*mock_windows_proc_table, GetMonitorInfoW(mock_monitor2, _))
62  .WillOnce(DoAll(SetArgPointee<1>(monitor_info2), Return(TRUE)));
63 
64  EXPECT_CALL(*mock_windows_proc_table,
65  EnumDisplayMonitors(nullptr, nullptr, _, _))
66  .WillOnce([&](HDC hdc, LPCRECT lprcClip, MONITORENUMPROC lpfnEnum,
67  LPARAM dwData) {
68  lpfnEnum(mock_monitor1, nullptr, &monitor_info1.rcMonitor, dwData);
69  lpfnEnum(mock_monitor2, nullptr, &monitor_info2.rcMonitor, dwData);
70  return TRUE;
71  });
72 
73  // Set up GetDpiForMonitor to return different DPI values
74  EXPECT_CALL(*mock_windows_proc_table, GetDpiForMonitor(mock_monitor1, _))
75  .WillRepeatedly(Return(96)); // Default/Standard DPI
76  EXPECT_CALL(*mock_windows_proc_table, GetDpiForMonitor(mock_monitor2, _))
77  .WillRepeatedly(Return(144)); // High DPI
78 
79  EXPECT_CALL(*mock_windows_proc_table, EnumDisplaySettings(_, _, _))
80  .WillRepeatedly(Return(TRUE));
81 
82  // Create the display manager with the mock engine
83  auto display_manager = std::make_unique<DisplayManagerWin32>(engine.get());
84 
85  display_manager->UpdateDisplays();
86 }

References display_manager, and flutter::GetDpiForMonitor().

◆ TEST_F() [29/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
AccessibilityAnnouncement   
)

Definition at line 1020 of file flutter_windows_engine_unittests.cc.

1020  {
1021  auto& context = GetContext();
1022  WindowsConfigBuilder builder{context};
1023  builder.SetDartEntrypoint("sendAccessibilityAnnouncement");
1024 
1025  bool done = false;
1026  auto native_entry =
1027  CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) { done = true; });
1028  context.AddNativeFunction("Signal", native_entry);
1029 
1030  EnginePtr engine{builder.RunHeadless()};
1031  ASSERT_NE(engine, nullptr);
1032 
1033  ui::AXPlatformNodeDelegateBase parent_delegate;
1034  AlertPlatformNodeDelegate delegate{parent_delegate};
1035 
1036  auto window_binding_handler =
1037  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1038  EXPECT_CALL(*window_binding_handler, GetAlertDelegate)
1039  .WillOnce(Return(&delegate));
1040 
1041  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
1042  MockFlutterWindowsView view{windows_engine,
1043  std::move(window_binding_handler)};
1044  EngineModifier modifier{windows_engine};
1045  modifier.SetImplicitView(&view);
1046 
1047  windows_engine->UpdateSemanticsEnabled(true);
1048 
1049  EXPECT_CALL(view, NotifyWinEventWrapper).Times(1);
1050 
1051  // Rely on timeout mechanism in CI.
1052  while (!done) {
1053  windows_engine->task_runner()->ProcessTasks();
1054  }
1055 }

References flutter::FlutterWindowsEngine::UpdateSemanticsEnabled().

◆ TEST_F() [30/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
AccessibilityAnnouncementHeadless   
)

Definition at line 1058 of file flutter_windows_engine_unittests.cc.

1058  {
1059  auto& context = GetContext();
1060  WindowsConfigBuilder builder{context};
1061  builder.SetDartEntrypoint("sendAccessibilityAnnouncement");
1062 
1063  bool done = false;
1064  auto native_entry =
1065  CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) { done = true; });
1066  context.AddNativeFunction("Signal", native_entry);
1067 
1068  EnginePtr engine{builder.RunHeadless()};
1069  ASSERT_NE(engine, nullptr);
1070 
1071  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
1072  windows_engine->UpdateSemanticsEnabled(true);
1073 
1074  // Rely on timeout mechanism in CI.
1075  while (!done) {
1076  windows_engine->task_runner()->ProcessTasks();
1077  }
1078 }

References flutter::FlutterWindowsEngine::UpdateSemanticsEnabled().

◆ TEST_F() [31/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
AccessibilityTooltip   
)

Definition at line 1082 of file flutter_windows_engine_unittests.cc.

1082  {
1083  fml::testing::LogCapture log_capture;
1084 
1085  auto& context = GetContext();
1086  WindowsConfigBuilder builder{context};
1087  builder.SetDartEntrypoint("sendAccessibilityTooltipEvent");
1088 
1089  bool done = false;
1090  auto native_entry =
1091  CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) { done = true; });
1092  context.AddNativeFunction("Signal", native_entry);
1093 
1094  ViewControllerPtr controller{builder.Run()};
1095  ASSERT_NE(controller, nullptr);
1096 
1097  auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
1098  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine);
1099  windows_engine->UpdateSemanticsEnabled(true);
1100 
1101  // Rely on timeout mechanism in CI.
1102  while (!done) {
1103  windows_engine->task_runner()->ProcessTasks();
1104  }
1105 
1106  // Verify no error was logged.
1107  // Regression test for:
1108  // https://github.com/flutter/flutter/issues/144274
1109  EXPECT_EQ(log_capture.str().find("tooltip"), std::string::npos);
1110 }
FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(FlutterDesktopViewControllerRef ref)

References FlutterDesktopViewControllerGetEngine(), and flutter::FlutterWindowsEngine::UpdateSemanticsEnabled().

◆ TEST_F() [32/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
AddPluginRegistrarDestructionCallback   
)

Definition at line 868 of file flutter_windows_engine_unittests.cc.

868  {
869  FlutterWindowsEngineBuilder builder{GetContext()};
870  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
871  EngineModifier modifier(engine.get());
872 
873  MockEmbedderApiForKeyboard(modifier,
874  std::make_shared<MockKeyResponseController>());
875 
876  engine->Run();
877 
878  // Verify that destruction handlers don't overwrite each other.
879  int result1 = 0;
880  int result2 = 0;
881  engine->AddPluginRegistrarDestructionCallback(
883  auto result = reinterpret_cast<int*>(ref);
884  *result = 1;
885  },
886  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(&result1));
887  engine->AddPluginRegistrarDestructionCallback(
889  auto result = reinterpret_cast<int*>(ref);
890  *result = 2;
891  },
892  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(&result2));
893 
894  engine->Stop();
895  EXPECT_EQ(result1, 1);
896  EXPECT_EQ(result2, 2);
897 }

◆ TEST_F() [33/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
AddViewFailureDoesNotHang   
)

Definition at line 1645 of file flutter_windows_engine_unittests.cc.

1645  {
1646  FlutterWindowsEngineBuilder builder{GetContext()};
1647  auto engine = builder.Build();
1648 
1649  EngineModifier modifier{engine.get()};
1650 
1651  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1652  modifier.embedder_api().AddView = MOCK_ENGINE_PROC(
1653  AddView,
1654  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
1655  const FlutterAddViewInfo* info) { return kInternalInconsistency; });
1656 
1657  ASSERT_TRUE(engine->Run());
1658 
1659  // Create the first view. This is the implicit view and isn't added to the
1660  // engine.
1661  auto implicit_window = std::make_unique<NiceMock<MockWindowBindingHandler>>();
1662 
1663  std::unique_ptr<FlutterWindowsView> implicit_view =
1664  engine->CreateView(std::move(implicit_window),
1665  /*is_sized_to_content=*/false, BoxConstraints());
1666 
1667  EXPECT_TRUE(implicit_view);
1668 
1669  // Create a second view. The embedder attempts to add it to the engine.
1670  auto second_window = std::make_unique<NiceMock<MockWindowBindingHandler>>();
1671 
1672  EXPECT_DEBUG_DEATH(
1673  engine->CreateView(std::move(second_window),
1674  /*is_sized_to_content=*/false, BoxConstraints()),
1675  "FlutterEngineAddView returned an unexpected result");
1676 }

References flutter::FlutterEngine::Run().

◆ TEST_F() [34/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
ApplicationLifecycleExternalWindow   
)

Definition at line 1351 of file flutter_windows_engine_unittests.cc.

1351  {
1352  FlutterWindowsEngineBuilder builder{GetContext()};
1353 
1354  auto engine = builder.Build();
1355  auto window_binding_handler =
1356  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1357  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1358 
1359  EngineModifier modifier(engine.get());
1360  modifier.SetImplicitView(&view);
1361  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1362  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1363  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(false));
1364  modifier.SetLifecycleManager(std::move(handler));
1365  engine->lifecycle_manager()->BeginProcessingExit();
1366 
1367  engine->lifecycle_manager()->ExternalWindowMessage(0, WM_CLOSE, 0, 0);
1368 }

◆ TEST_F() [35/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
ChannelListenedTo   
)

Definition at line 1595 of file flutter_windows_engine_unittests.cc.

1595  {
1596  FlutterWindowsEngineBuilder builder{GetContext()};
1597  builder.SetDartEntrypoint("enableLifecycleToFrom");
1598 
1599  auto engine = builder.Build();
1600  auto window_binding_handler =
1601  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1602  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1603 
1604  EngineModifier modifier(engine.get());
1605  modifier.SetImplicitView(&view);
1606  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1607 
1608  bool lifecycle_began = false;
1609  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1610  handler->begin_processing_callback = [&]() { lifecycle_began = true; };
1611  modifier.SetLifecycleManager(std::move(handler));
1612 
1613  engine->Run();
1614 
1615  while (!lifecycle_began) {
1616  engine->task_runner()->ProcessTasks();
1617  }
1618 }

◆ TEST_F() [36/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
ConfiguresFrameVsync   
)

Definition at line 297 of file flutter_windows_engine_unittests.cc.

297  {
298  FlutterWindowsEngineBuilder builder{GetContext()};
299  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
300  EngineModifier modifier(engine.get());
301  bool on_vsync_called = false;
302 
303  modifier.embedder_api().GetCurrentTime =
304  MOCK_ENGINE_PROC(GetCurrentTime, ([]() -> uint64_t { return 1; }));
305  modifier.embedder_api().OnVsync = MOCK_ENGINE_PROC(
306  OnVsync,
307  ([&on_vsync_called, engine_instance = engine.get()](
308  FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton,
309  uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos) {
310  EXPECT_EQ(baton, 1);
311  EXPECT_EQ(frame_start_time_nanos, 16600000);
312  EXPECT_EQ(frame_target_time_nanos, 33200000);
313  on_vsync_called = true;
314  return kSuccess;
315  }));
316  modifier.SetStartTime(0);
317  modifier.SetFrameInterval(16600000);
318 
319  engine->OnVsync(1);
320 
321  EXPECT_TRUE(on_vsync_called);
322 }

◆ TEST_F() [37/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
DispatchSemanticsAction   
)

Definition at line 823 of file flutter_windows_engine_unittests.cc.

823  {
824  FlutterWindowsEngineBuilder builder{GetContext()};
825  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
826  EngineModifier modifier(engine.get());
827 
828  bool called = false;
829  std::string message = "Hello";
830  modifier.embedder_api().SendSemanticsAction = MOCK_ENGINE_PROC(
831  SendSemanticsAction, ([&called, &message](auto engine, auto info) {
832  called = true;
833  EXPECT_EQ(info->view_id, 456);
834  EXPECT_EQ(info->node_id, 42);
835  EXPECT_EQ(info->action, kFlutterSemanticsActionDismiss);
836  EXPECT_EQ(memcmp(info->data, message.c_str(), message.size()), 0);
837  EXPECT_EQ(info->data_length, message.size());
838  return kSuccess;
839  }));
840 
841  auto data = fml::MallocMapping::Copy(message.c_str(), message.size());
842  engine->DispatchSemanticsAction(456, 42, kFlutterSemanticsActionDismiss,
843  std::move(data));
844  EXPECT_TRUE(called);
845 }

References message.

◆ TEST_F() [38/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
EnableApplicationLifecycle   
)

Definition at line 1331 of file flutter_windows_engine_unittests.cc.

1331  {
1332  FlutterWindowsEngineBuilder builder{GetContext()};
1333 
1334  auto engine = builder.Build();
1335  auto window_binding_handler =
1336  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1337  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1338 
1339  EngineModifier modifier(engine.get());
1340  modifier.SetImplicitView(&view);
1341  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1342  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1343  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(false));
1344  modifier.SetLifecycleManager(std::move(handler));
1345  engine->lifecycle_manager()->BeginProcessingExit();
1346 
1347  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1348  0);
1349 }

◆ TEST_F() [39/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
EnableLifecycleState   
)

Definition at line 1494 of file flutter_windows_engine_unittests.cc.

1494  {
1495  FlutterWindowsEngineBuilder builder{GetContext()};
1496  builder.SetDartEntrypoint("enableLifecycleTest");
1497  bool finished = false;
1498 
1499  auto engine = builder.Build();
1500  auto window_binding_handler =
1501  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1502  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1503 
1504  EngineModifier modifier(engine.get());
1505  modifier.SetImplicitView(&view);
1506  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1507  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1508  EXPECT_CALL(*handler, SetLifecycleState)
1509  .WillRepeatedly([handler_ptr = handler.get()](AppLifecycleState state) {
1510  handler_ptr->WindowsLifecycleManager::SetLifecycleState(state);
1511  });
1512  modifier.SetLifecycleManager(std::move(handler));
1513 
1514  auto binary_messenger =
1515  std::make_unique<BinaryMessengerImpl>(engine->messenger());
1516  // Mark the test only as completed on receiving an inactive state message.
1517  binary_messenger->SetMessageHandler(
1518  "flutter/unittest", [&finished](const uint8_t* message,
1519  size_t message_size, BinaryReply reply) {
1520  std::string contents(message, message + message_size);
1521  EXPECT_NE(contents.find("AppLifecycleState.inactive"),
1522  std::string::npos);
1523  finished = true;
1524  char response[] = "";
1525  reply(reinterpret_cast<uint8_t*>(response), 0);
1526  });
1527 
1528  engine->Run();
1529 
1530  // Test that setting the state before enabling lifecycle does nothing.
1531  HWND hwnd = reinterpret_cast<HWND>(1);
1532  view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1533  view.OnWindowStateEvent(hwnd, WindowStateEvent::kHide);
1534  EXPECT_FALSE(finished);
1535 
1536  // Test that we can set the state afterwards.
1537 
1538  engine->lifecycle_manager()->BeginProcessingLifecycle();
1539  view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1540 
1541  while (!finished) {
1542  engine->task_runner()->ProcessTasks();
1543  }
1544 }

References flutter::kHide, flutter::kShow, and message.

◆ TEST_F() [40/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
ExternalWindowMessage   
)

Definition at line 1424 of file flutter_windows_engine_unittests.cc.

1424  {
1425  FlutterWindowsEngineBuilder builder{GetContext()};
1426 
1427  auto engine = builder.Build();
1428  auto window_binding_handler =
1429  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1430  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1431 
1432  EngineModifier modifier(engine.get());
1433  modifier.SetImplicitView(&view);
1434  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1435  // Sets lifecycle state to resumed.
1436  engine->Run();
1437 
1438  // Ensure HWND(1) is in the set of visible windows before hiding it.
1439  engine->ProcessExternalWindowMessage(reinterpret_cast<HWND>(1), WM_SHOWWINDOW,
1440  TRUE, NULL);
1441  engine->ProcessExternalWindowMessage(reinterpret_cast<HWND>(1), WM_SHOWWINDOW,
1442  FALSE, NULL);
1443 
1444  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1445  PumpMessage();
1446  }
1447 
1448  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1449  AppLifecycleState::kHidden);
1450 }

References flutter::kHidden.

◆ TEST_F() [41/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
GetExecutableName   
)

Definition at line 931 of file flutter_windows_engine_unittests.cc.

931  {
932  FlutterWindowsEngineBuilder builder{GetContext()};
933  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
934  EXPECT_EQ(engine->GetExecutableName(), "flutter_windows_unittests.exe");
935 }

◆ TEST_F() [42/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
InnerWindowHidden   
)

Definition at line 1452 of file flutter_windows_engine_unittests.cc.

1452  {
1453  FlutterWindowsEngineBuilder builder{GetContext()};
1454  HWND outer = reinterpret_cast<HWND>(1);
1455  HWND inner = reinterpret_cast<HWND>(2);
1456 
1457  auto engine = builder.Build();
1458  auto window_binding_handler =
1459  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1460  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1461  ON_CALL(view, GetWindowHandle).WillByDefault([=]() { return inner; });
1462 
1463  EngineModifier modifier(engine.get());
1464  modifier.SetImplicitView(&view);
1465  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1466  // Sets lifecycle state to resumed.
1467  engine->Run();
1468 
1469  // Show both top-level and Flutter window.
1470  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1471  outer, WM_SHOWWINDOW, TRUE, NULL);
1472  view.OnWindowStateEvent(inner, WindowStateEvent::kShow);
1473  view.OnWindowStateEvent(inner, WindowStateEvent::kFocus);
1474 
1475  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1476  PumpMessage();
1477  }
1478 
1479  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1480  AppLifecycleState::kResumed);
1481 
1482  // Hide Flutter window, but not top level window.
1483  view.OnWindowStateEvent(inner, WindowStateEvent::kHide);
1484 
1485  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1486  PumpMessage();
1487  }
1488 
1489  // The top-level window is still visible, so we ought not enter hidden state.
1490  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1491  AppLifecycleState::kInactive);
1492 }

References flutter::kFocus, flutter::kHide, flutter::kInactive, flutter::kResumed, and flutter::kShow.

◆ TEST_F() [43/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
LifecycleManagerDisabledByDefault   
)

Definition at line 1312 of file flutter_windows_engine_unittests.cc.

1312  {
1313  FlutterWindowsEngineBuilder builder{GetContext()};
1314 
1315  auto engine = builder.Build();
1316  auto window_binding_handler =
1317  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1318  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1319 
1320  EngineModifier modifier(engine.get());
1321  modifier.SetImplicitView(&view);
1322  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1323  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1324  EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(0);
1325  modifier.SetLifecycleManager(std::move(handler));
1326 
1327  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1328  0);
1329 }

◆ TEST_F() [44/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
LifecycleStateToFrom   
)

Definition at line 1546 of file flutter_windows_engine_unittests.cc.

1546  {
1547  FlutterWindowsEngineBuilder builder{GetContext()};
1548  builder.SetDartEntrypoint("enableLifecycleToFrom");
1549  bool enabled_lifecycle = false;
1550  bool dart_responded = false;
1551 
1552  auto engine = builder.Build();
1553  auto window_binding_handler =
1554  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1555  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1556 
1557  EngineModifier modifier(engine.get());
1558  modifier.SetImplicitView(&view);
1559  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1560  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1561  EXPECT_CALL(*handler, SetLifecycleState)
1562  .WillRepeatedly([handler_ptr = handler.get()](AppLifecycleState state) {
1563  handler_ptr->WindowsLifecycleManager::SetLifecycleState(state);
1564  });
1565  handler->begin_processing_callback = [&]() { enabled_lifecycle = true; };
1566  modifier.SetLifecycleManager(std::move(handler));
1567 
1568  auto binary_messenger =
1569  std::make_unique<BinaryMessengerImpl>(engine->messenger());
1570  binary_messenger->SetMessageHandler(
1571  "flutter/unittest",
1572  [&](const uint8_t* message, size_t message_size, BinaryReply reply) {
1573  std::string contents(message, message + message_size);
1574  EXPECT_NE(contents.find("AppLifecycleState."), std::string::npos);
1575  dart_responded = true;
1576  char response[] = "";
1577  reply(reinterpret_cast<uint8_t*>(response), 0);
1578  });
1579 
1580  engine->Run();
1581 
1582  while (!enabled_lifecycle) {
1583  engine->task_runner()->ProcessTasks();
1584  }
1585 
1586  HWND hwnd = reinterpret_cast<HWND>(1);
1587  view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1588  view.OnWindowStateEvent(hwnd, WindowStateEvent::kHide);
1589 
1590  while (!dart_responded) {
1591  engine->task_runner()->ProcessTasks();
1592  }
1593 }

References flutter::kHide, flutter::kShow, and message.

◆ TEST_F() [45/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
LifecycleStateTransition   
)

Definition at line 1370 of file flutter_windows_engine_unittests.cc.

1370  {
1371  FlutterWindowsEngineBuilder builder{GetContext()};
1372 
1373  auto engine = builder.Build();
1374  auto window_binding_handler =
1375  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1376  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1377 
1378  EngineModifier modifier(engine.get());
1379  modifier.SetImplicitView(&view);
1380  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1381  engine->Run();
1382 
1383  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1384  (HWND)1, WM_SIZE, SIZE_RESTORED, 0);
1385 
1386  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1387  PumpMessage();
1388  }
1389 
1390  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1391  AppLifecycleState::kInactive);
1392 
1393  engine->lifecycle_manager()->OnWindowStateEvent((HWND)1,
1394  WindowStateEvent::kFocus);
1395 
1396  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1397  PumpMessage();
1398  }
1399 
1400  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1401  AppLifecycleState::kResumed);
1402 
1403  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1404  (HWND)1, WM_SIZE, SIZE_MINIMIZED, 0);
1405 
1406  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1407  PumpMessage();
1408  }
1409 
1410  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1411  AppLifecycleState::kHidden);
1412 
1413  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1414  (HWND)1, WM_SIZE, SIZE_RESTORED, 0);
1415 
1416  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1417  PumpMessage();
1418  }
1419 
1420  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1421  AppLifecycleState::kInactive);
1422 }

References flutter::kFocus, flutter::kHidden, flutter::kInactive, and flutter::kResumed.

◆ TEST_F() [46/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
MergedUIThread   
)

Definition at line 1696 of file flutter_windows_engine_unittests.cc.

1696  {
1697  auto& context = GetContext();
1698  WindowsConfigBuilder builder{context};
1699  builder.SetDartEntrypoint("mergedUIThread");
1700  builder.SetUIThreadPolicy(FlutterDesktopUIThreadPolicy::RunOnPlatformThread);
1701 
1702  std::optional<std::thread::id> ui_thread_id;
1703 
1704  auto native_entry = CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
1705  ui_thread_id = std::this_thread::get_id();
1706  });
1707  context.AddNativeFunction("Signal", native_entry);
1708 
1709  EnginePtr engine{builder.RunHeadless()};
1710  while (!ui_thread_id) {
1711  PumpMessage();
1712  }
1713  ASSERT_EQ(*ui_thread_id, std::this_thread::get_id());
1714 }
@ RunOnPlatformThread

References RunOnPlatformThread.

◆ TEST_F() [47/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
OnViewFocusChangeRequest   
)

Definition at line 1716 of file flutter_windows_engine_unittests.cc.

1716  {
1717  FlutterWindowsEngineBuilder builder{GetContext()};
1718  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1719  auto window_binding_handler =
1720  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1721  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1722 
1723  EngineModifier modifier(engine.get());
1724  modifier.SetImplicitView(&view);
1725 
1726  FlutterViewFocusChangeRequest request;
1727  request.view_id = kImplicitViewId;
1728 
1729  EXPECT_CALL(view, Focus()).WillOnce(Return(true));
1730  modifier.OnViewFocusChangeRequest(&request);
1731 }

References flutter::kImplicitViewId.

◆ TEST_F() [48/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
PlatformMessageRespondOnDifferentThread   
)

Definition at line 713 of file flutter_windows_engine_unittests.cc.

713  {
714  FlutterWindowsEngineBuilder builder{GetContext()};
715  builder.SetDartEntrypoint("hiPlatformChannels");
716 
717  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
718 
719  EngineModifier modifier(engine.get());
720  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
721 
722  auto binary_messenger =
723  std::make_unique<BinaryMessengerImpl>(engine->messenger());
724 
725  engine->Run();
726  bool did_call_callback = false;
727  bool did_call_reply = false;
728  bool did_call_dart_reply = false;
729  std::string channel = "hi";
730  std::unique_ptr<std::thread> reply_thread;
731  binary_messenger->SetMessageHandler(
732  channel,
733  [&did_call_callback, &did_call_dart_reply, &reply_thread](
734  const uint8_t* message, size_t message_size, BinaryReply reply) {
735  if (message_size == 5) {
736  EXPECT_EQ(message[0], static_cast<uint8_t>('h'));
737  reply_thread.reset(new std::thread([reply = std::move(reply)]() {
738  char response[] = {'b', 'y', 'e'};
739  reply(reinterpret_cast<uint8_t*>(response), 3);
740  }));
741  did_call_callback = true;
742  } else {
743  EXPECT_EQ(message_size, 3);
744  EXPECT_EQ(message[0], static_cast<uint8_t>('b'));
745  did_call_dart_reply = true;
746  }
747  });
748  char payload[] = {'h', 'e', 'l', 'l', 'o'};
749  binary_messenger->Send(
750  channel, reinterpret_cast<uint8_t*>(payload), 5,
751  [&did_call_reply](const uint8_t* reply, size_t reply_size) {
752  EXPECT_EQ(reply_size, 5);
753  EXPECT_EQ(reply[0], static_cast<uint8_t>('h'));
754  did_call_reply = true;
755  });
756  // Rely on timeout mechanism in CI.
757  while (!did_call_callback || !did_call_reply || !did_call_dart_reply) {
758  engine->task_runner()->ProcessTasks();
759  }
760  ASSERT_TRUE(reply_thread);
761  reply_thread->join();
762 }

References message.

◆ TEST_F() [49/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
PlatformMessageRoundTrip   
)

Definition at line 668 of file flutter_windows_engine_unittests.cc.

668  {
669  FlutterWindowsEngineBuilder builder{GetContext()};
670  builder.SetDartEntrypoint("hiPlatformChannels");
671 
672  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
673  EngineModifier modifier(engine.get());
674  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
675 
676  auto binary_messenger =
677  std::make_unique<BinaryMessengerImpl>(engine->messenger());
678 
679  engine->Run();
680  bool did_call_callback = false;
681  bool did_call_reply = false;
682  bool did_call_dart_reply = false;
683  std::string channel = "hi";
684  binary_messenger->SetMessageHandler(
685  channel,
686  [&did_call_callback, &did_call_dart_reply](
687  const uint8_t* message, size_t message_size, BinaryReply reply) {
688  if (message_size == 5) {
689  EXPECT_EQ(message[0], static_cast<uint8_t>('h'));
690  char response[] = {'b', 'y', 'e'};
691  reply(reinterpret_cast<uint8_t*>(response), 3);
692  did_call_callback = true;
693  } else {
694  EXPECT_EQ(message_size, 3);
695  EXPECT_EQ(message[0], static_cast<uint8_t>('b'));
696  did_call_dart_reply = true;
697  }
698  });
699  char payload[] = {'h', 'e', 'l', 'l', 'o'};
700  binary_messenger->Send(
701  channel, reinterpret_cast<uint8_t*>(payload), 5,
702  [&did_call_reply](const uint8_t* reply, size_t reply_size) {
703  EXPECT_EQ(reply_size, 5);
704  EXPECT_EQ(reply[0], static_cast<uint8_t>('h'));
705  did_call_reply = true;
706  });
707  // Rely on timeout mechanism in CI.
708  while (!did_call_callback || !did_call_reply || !did_call_dart_reply) {
709  engine->task_runner()->ProcessTasks();
710  }
711 }

References message.

◆ TEST_F() [50/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
PostRasterThreadTask   
)

Definition at line 980 of file flutter_windows_engine_unittests.cc.

980  {
981  FlutterWindowsEngineBuilder builder{GetContext()};
982  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
983  EngineModifier modifier(engine.get());
984 
985  modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
986  PostRenderThreadTask, ([](auto engine, auto callback, auto context) {
987  callback(context);
988  return kSuccess;
989  }));
990 
991  bool called = false;
992  engine->PostRasterThreadTask([&called]() { called = true; });
993 
994  EXPECT_TRUE(called);
995 }

References callback.

◆ TEST_F() [51/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
ReceivePlatformViewMessage   
)

Definition at line 1620 of file flutter_windows_engine_unittests.cc.

1620  {
1621  FlutterWindowsEngineBuilder builder{GetContext()};
1622  builder.SetDartEntrypoint("sendCreatePlatformViewMethod");
1623  auto engine = builder.Build();
1624 
1625  EngineModifier modifier{engine.get()};
1626  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1627 
1628  bool received_call = false;
1629 
1630  auto manager = std::make_unique<MockPlatformViewManager>(engine.get());
1631  EXPECT_CALL(*manager, AddPlatformView)
1632  .WillOnce([&](PlatformViewId id, std::string_view type_name) {
1633  received_call = true;
1634  return true;
1635  });
1636  modifier.SetPlatformViewPlugin(std::move(manager));
1637 
1638  engine->Run();
1639 
1640  while (!received_call) {
1641  engine->task_runner()->ProcessTasks();
1642  }
1643 }
int64_t PlatformViewId

◆ TEST_F() [52/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RemoveViewFailureDoesNotHang   
)

Definition at line 1678 of file flutter_windows_engine_unittests.cc.

1678  {
1679  FlutterWindowsEngineBuilder builder{GetContext()};
1680  builder.SetDartEntrypoint("sendCreatePlatformViewMethod");
1681  auto engine = builder.Build();
1682 
1683  EngineModifier modifier{engine.get()};
1684 
1685  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1686  modifier.embedder_api().RemoveView = MOCK_ENGINE_PROC(
1687  RemoveView,
1688  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
1689  const FlutterRemoveViewInfo* info) { return kInternalInconsistency; });
1690 
1691  ASSERT_TRUE(engine->Run());
1692  EXPECT_DEBUG_DEATH(engine->RemoveView(123),
1693  "FlutterEngineRemoveView returned an unexpected result");
1694 }

References flutter::FlutterEngine::Run().

◆ TEST_F() [53/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunDoesExpectedInitialization   
)

Definition at line 137 of file flutter_windows_engine_unittests.cc.

137  {
138  FlutterWindowsEngineBuilder builder{GetContext()};
139  builder.AddDartEntrypointArgument("arg1");
140  builder.AddDartEntrypointArgument("arg2");
141 
142  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
143 
144  HMONITOR mock_monitor = reinterpret_cast<HMONITOR>(1);
145 
146  MONITORINFOEXW monitor_info = {};
147  monitor_info.cbSize = sizeof(MONITORINFOEXW);
148  monitor_info.rcMonitor = {0, 0, 1920, 1080};
149  monitor_info.rcWork = {0, 0, 1920, 1080};
150  monitor_info.dwFlags = MONITORINFOF_PRIMARY;
151  wcscpy_s(monitor_info.szDevice, L"\\\\.\\DISPLAY1");
152 
153  EXPECT_CALL(*windows_proc_table, GetMonitorInfoW(mock_monitor, _))
154  .WillRepeatedly(DoAll(SetArgPointee<1>(monitor_info), Return(TRUE)));
155 
156  EXPECT_CALL(*windows_proc_table, EnumDisplayMonitors(nullptr, nullptr, _, _))
157  .WillRepeatedly([&](HDC hdc, LPCRECT lprcClip, MONITORENUMPROC lpfnEnum,
158  LPARAM dwData) {
159  lpfnEnum(mock_monitor, nullptr, &monitor_info.rcMonitor, dwData);
160  return TRUE;
161  });
162 
163  EXPECT_CALL(*windows_proc_table, GetDpiForMonitor(mock_monitor, _))
164  .WillRepeatedly(Return(96));
165 
166  // Mock locale information
167  EXPECT_CALL(*windows_proc_table, GetThreadPreferredUILanguages(_, _, _, _))
168  .WillRepeatedly(
169  [](DWORD flags, PULONG count, PZZWSTR languages, PULONG length) {
170  // We need to mock the locale information twice because the first
171  // call is to get the size and the second call is to fill the
172  // buffer.
173  if (languages == nullptr) {
174  // First call is to get the size
175  *count = 1; // One language
176  *length = 10; // "fr-FR\0\0" (double null-terminated)
177  return TRUE;
178  } else {
179  // Second call is to fill the buffer
180  *count = 1;
181  // Fill with "fr-FR\0\0" (double null-terminated)
182  wchar_t* lang_buffer = languages;
183  wcscpy(lang_buffer, L"fr-FR");
184  // Move past the first null terminator to add the second
185  lang_buffer += wcslen(L"fr-FR") + 1;
186  *lang_buffer = L'\0';
187  return TRUE;
188  }
189  });
190 
191  builder.SetWindowsProcTable(windows_proc_table);
192 
193  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
194  EngineModifier modifier(engine.get());
195 
196  // The engine should be run with expected configuration values.
197  bool run_called = false;
198  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
199  Run, ([&run_called, engine_instance = engine.get()](
200  size_t version, const FlutterRendererConfig* config,
201  const FlutterProjectArgs* args, void* user_data,
202  FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
203  run_called = true;
204  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
205 
206  EXPECT_EQ(version, FLUTTER_ENGINE_VERSION);
207  EXPECT_NE(config, nullptr);
208  // We have an EGL manager, so this should be using OpenGL.
209  EXPECT_EQ(config->type, kOpenGL);
210  EXPECT_EQ(user_data, engine_instance);
211  // Spot-check arguments.
212  EXPECT_NE(args->assets_path, nullptr);
213  EXPECT_NE(args->icu_data_path, nullptr);
214  EXPECT_EQ(args->dart_entrypoint_argc, 2U);
215  EXPECT_EQ(strcmp(args->dart_entrypoint_argv[0], "arg1"), 0);
216  EXPECT_EQ(strcmp(args->dart_entrypoint_argv[1], "arg2"), 0);
217  EXPECT_NE(args->platform_message_callback, nullptr);
218  EXPECT_NE(args->custom_task_runners, nullptr);
219  EXPECT_NE(args->custom_task_runners->thread_priority_setter, nullptr);
220  EXPECT_EQ(args->custom_dart_entrypoint, nullptr);
221  EXPECT_NE(args->vsync_callback, nullptr);
222  EXPECT_EQ(args->update_semantics_callback, nullptr);
223  EXPECT_NE(args->update_semantics_callback2, nullptr);
224  EXPECT_EQ(args->update_semantics_node_callback, nullptr);
225  EXPECT_EQ(args->update_semantics_custom_action_callback, nullptr);
226  EXPECT_NE(args->view_focus_change_request_callback, nullptr);
227 
228  args->custom_task_runners->thread_priority_setter(
229  FlutterThreadPriority::kRaster);
230  EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
231  THREAD_PRIORITY_ABOVE_NORMAL);
232  return kSuccess;
233  }));
234  // Accessibility updates must do nothing when the embedder engine is mocked
235  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
236  UpdateAccessibilityFeatures,
237  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
238  FlutterAccessibilityFeature flags) { return kSuccess; });
239 
240  // It should send locale info.
241  bool update_locales_called = false;
242  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
243  UpdateLocales,
244  ([&update_locales_called](auto engine, const FlutterLocale** locales,
245  size_t locales_count) {
246  update_locales_called = true;
247 
248  EXPECT_GT(locales_count, 0);
249  EXPECT_NE(locales, nullptr);
250 
251  return kSuccess;
252  }));
253 
254  // And it should send initial settings info.
255  bool settings_message_sent = false;
256  modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
257  SendPlatformMessage,
258  ([&settings_message_sent](auto engine, auto message) {
259  if (std::string(message->channel) == std::string("flutter/settings")) {
260  settings_message_sent = true;
261  }
262 
263  return kSuccess;
264  }));
265 
266  // And it should send display info.
267  bool notify_display_update_called = false;
268 
269  modifier.embedder_api().NotifyDisplayUpdate = MOCK_ENGINE_PROC(
270  NotifyDisplayUpdate,
271  ([&notify_display_update_called](
272  FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
273  const FlutterEngineDisplaysUpdateType update_type,
274  const FlutterEngineDisplay* embedder_displays,
275  size_t display_count) {
276  EXPECT_EQ(update_type, kFlutterEngineDisplaysUpdateTypeStartup);
277  notify_display_update_called = true;
278  return kSuccess;
279  }));
280 
281  // Set the EGL manager to !nullptr to test ANGLE rendering.
282  modifier.SetEGLManager(std::make_unique<egl::MockManager>());
283 
284  engine->Run();
285 
286  EXPECT_TRUE(run_called);
287  EXPECT_TRUE(update_locales_called);
288  EXPECT_TRUE(settings_message_sent);
289  EXPECT_TRUE(notify_display_update_called);
290 
291  // Ensure that deallocation doesn't call the actual Shutdown with the bogus
292  // engine pointer that the overridden Run returned.
293  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
294  modifier.ReleaseEGLManager();
295 }

References flutter::GetDpiForMonitor(), message, and user_data.

◆ TEST_F() [54/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunHeadless   
)

Definition at line 55 of file flutter_windows_engine_unittests.cc.

55  {
56  FlutterWindowsEngineBuilder builder{GetContext()};
57  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
58 
59  EngineModifier modifier(engine.get());
60  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
61 
62  ASSERT_TRUE(engine->Run());
63  ASSERT_EQ(engine->view(kImplicitViewId), nullptr);
64  ASSERT_EQ(engine->view(123), nullptr);
65 }

References flutter::kImplicitViewId.

◆ TEST_F() [55/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunSkiaWithoutANGLEUsesSoftware   
)

Definition at line 324 of file flutter_windows_engine_unittests.cc.

324  {
325  FlutterWindowsEngineBuilder builder{GetContext()};
326  builder.SetImpellerSwitch(DisabledImpeller);
327  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
328  EngineModifier modifier(engine.get());
329 
330  modifier.embedder_api().NotifyDisplayUpdate =
331  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
332  ([engine_instance = engine.get()](
333  FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
334  const FlutterEngineDisplaysUpdateType update_type,
335  const FlutterEngineDisplay* embedder_displays,
336  size_t display_count) { return kSuccess; }));
337 
338  // The engine should be run with expected configuration values.
339  bool run_called = false;
340  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
341  Run, ([&run_called, engine_instance = engine.get()](
342  size_t version, const FlutterRendererConfig* config,
343  const FlutterProjectArgs* args, void* user_data,
344  FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
345  run_called = true;
346  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
347  // We don't have an EGL Manager, so we should be using software.
348  EXPECT_EQ(config->type, kSoftware);
349  return kSuccess;
350  }));
351  // Accessibility updates must do nothing when the embedder engine is mocked
352  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
353  UpdateAccessibilityFeatures,
354  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
355  FlutterAccessibilityFeature flags) { return kSuccess; });
356 
357  // Stub out UpdateLocales and SendPlatformMessage as we don't have a fully
358  // initialized engine instance.
359  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
360  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
361  size_t locales_count) { return kSuccess; }));
362  modifier.embedder_api().SendPlatformMessage =
363  MOCK_ENGINE_PROC(SendPlatformMessage,
364  ([](auto engine, auto message) { return kSuccess; }));
365 
366  // Set the EGL manager to nullptr to test software fallback path.
367  modifier.SetEGLManager(nullptr);
368 
369  engine->Run();
370 
371  EXPECT_TRUE(run_called);
372 
373  // Ensure that deallocation doesn't call the actual Shutdown with the bogus
374  // engine pointer that the overridden Run returned.
375  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
376 }
@ DisabledImpeller

References DisabledImpeller, message, and user_data.

◆ TEST_F() [56/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunWithCommandLineDisableImpeller   
)

Definition at line 589 of file flutter_windows_engine_unittests.cc.

589  {
590  FlutterWindowsEngineBuilder builder{GetContext()};
591  builder.SetSwitches({"--enable-impeller=false"});
592  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
593  EngineModifier modifier(engine.get());
594 
595  modifier.embedder_api().NotifyDisplayUpdate =
596  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
597  ([](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
598  const FlutterEngineDisplaysUpdateType update_type,
599  const FlutterEngineDisplay* embedder_displays,
600  size_t display_count) { return kSuccess; }));
601 
602  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
603  UpdateAccessibilityFeatures,
604  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
605  FlutterAccessibilityFeature flags) { return kSuccess; });
606 
607  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
608  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
609  size_t locales_count) { return kSuccess; }));
610 
611  modifier.embedder_api().SendPlatformMessage =
612  MOCK_ENGINE_PROC(SendPlatformMessage,
613  ([](auto engine, auto message) { return kSuccess; }));
614 
615  bool run_called = false;
616  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
617  Run, ([&run_called](size_t version, const FlutterRendererConfig* config,
618  const FlutterProjectArgs* args, void* user_data,
619  FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
620  run_called = true;
621  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
622 
623  bool has_disable_impeller_switch = false;
624  for (int i = 0; i < args->command_line_argc; ++i) {
625  if (strcmp(args->command_line_argv[i], "--enable-impeller=false") ==
626  0) {
627  has_disable_impeller_switch = true;
628  }
629  }
630  EXPECT_TRUE(has_disable_impeller_switch);
631  return kSuccess;
632  }));
633 
634  engine->Run();
635 
636  EXPECT_TRUE(run_called);
637 
638  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
639 }

References message, and user_data.

◆ TEST_F() [57/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunWithDefaultEnablesImpeller   
)

Definition at line 413 of file flutter_windows_engine_unittests.cc.

413  {
414  FlutterWindowsEngineBuilder builder{GetContext()};
415  builder.SetImpellerSwitch(DefaultImpeller);
416  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
417  EngineModifier modifier(engine.get());
418 
419  modifier.embedder_api().NotifyDisplayUpdate =
420  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
421  ([engine_instance = engine.get()](
422  FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
423  const FlutterEngineDisplaysUpdateType update_type,
424  const FlutterEngineDisplay* embedder_displays,
425  size_t display_count) { return kSuccess; }));
426 
427  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
428  UpdateAccessibilityFeatures,
429  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
430  FlutterAccessibilityFeature flags) { return kSuccess; });
431 
432  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
433  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
434  size_t locales_count) { return kSuccess; }));
435 
436  modifier.embedder_api().SendPlatformMessage =
437  MOCK_ENGINE_PROC(SendPlatformMessage,
438  ([](auto engine, auto message) { return kSuccess; }));
439 
440  bool run_called = false;
441  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
442  Run, ([&run_called, engine_instance = engine.get()](
443  size_t version, const FlutterRendererConfig* config,
444  const FlutterProjectArgs* args, void* user_data,
445  FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
446  run_called = true;
447  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
448 
449  bool has_impeller_switch = false;
450  bool has_sdf_switch = false;
451  for (int i = 0; i < args->command_line_argc; ++i) {
452  if (strcmp(args->command_line_argv[i], "--enable-impeller") == 0) {
453  has_impeller_switch = true;
454  }
455  if (strcmp(args->command_line_argv[i], "--impeller-use-sdfs=true") ==
456  0) {
457  has_sdf_switch = true;
458  }
459  }
460  EXPECT_TRUE(has_impeller_switch);
461  EXPECT_TRUE(has_sdf_switch);
462  return kSuccess;
463  }));
464 
465  // Set the EGL manager to !nullptr to test ANGLE rendering.
466  modifier.SetEGLManager(std::make_unique<egl::MockManager>());
467 
468  engine->Run();
469 
470  EXPECT_TRUE(run_called);
471 
472  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
473  modifier.ReleaseEGLManager();
474 }

References DefaultImpeller, message, and user_data.

◆ TEST_F() [58/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunWithoutANGLEOnImpellerFailsToStart   
)

Definition at line 378 of file flutter_windows_engine_unittests.cc.

378  {
379  FlutterWindowsEngineBuilder builder{GetContext()};
380  builder.SetSwitches({"--enable-impeller=true"});
381  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
382  EngineModifier modifier(engine.get());
383 
384  modifier.embedder_api().NotifyDisplayUpdate =
385  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
386  ([engine_instance = engine.get()](
387  FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
388  const FlutterEngineDisplaysUpdateType update_type,
389  const FlutterEngineDisplay* embedder_displays,
390  size_t display_count) { return kSuccess; }));
391 
392  // Accessibility updates must do nothing when the embedder engine is mocked
393  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
394  UpdateAccessibilityFeatures,
395  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
396  FlutterAccessibilityFeature flags) { return kSuccess; });
397 
398  // Stub out UpdateLocales and SendPlatformMessage as we don't have a fully
399  // initialized engine instance.
400  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
401  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
402  size_t locales_count) { return kSuccess; }));
403  modifier.embedder_api().SendPlatformMessage =
404  MOCK_ENGINE_PROC(SendPlatformMessage,
405  ([](auto engine, auto message) { return kSuccess; }));
406 
407  // Set the EGL manager to nullptr to test software fallback path.
408  modifier.SetEGLManager(nullptr);
409 
410  EXPECT_FALSE(engine->Run());
411 }

References message.

◆ TEST_F() [59/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunWithProjectFlagDisableImpeller   
)

Definition at line 537 of file flutter_windows_engine_unittests.cc.

537  {
538  FlutterWindowsEngineBuilder builder{GetContext()};
539  builder.SetImpellerSwitch(DisabledImpeller);
540  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
541  EngineModifier modifier(engine.get());
542 
543  modifier.embedder_api().NotifyDisplayUpdate =
544  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
545  ([](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
546  const FlutterEngineDisplaysUpdateType update_type,
547  const FlutterEngineDisplay* embedder_displays,
548  size_t display_count) { return kSuccess; }));
549 
550  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
551  UpdateAccessibilityFeatures,
552  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
553  FlutterAccessibilityFeature flags) { return kSuccess; });
554 
555  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
556  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
557  size_t locales_count) { return kSuccess; }));
558 
559  modifier.embedder_api().SendPlatformMessage =
560  MOCK_ENGINE_PROC(SendPlatformMessage,
561  ([](auto engine, auto message) { return kSuccess; }));
562 
563  bool run_called = false;
564  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
565  Run, ([&run_called](size_t version, const FlutterRendererConfig* config,
566  const FlutterProjectArgs* args, void* user_data,
567  FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
568  run_called = true;
569  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
570 
571  bool has_disable_impeller_switch = false;
572  for (int i = 0; i < args->command_line_argc; ++i) {
573  if (strcmp(args->command_line_argv[i], "--enable-impeller=false") ==
574  0) {
575  has_disable_impeller_switch = true;
576  }
577  }
578  EXPECT_TRUE(has_disable_impeller_switch);
579  return kSuccess;
580  }));
581 
582  engine->Run();
583 
584  EXPECT_TRUE(run_called);
585 
586  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
587 }

References DisabledImpeller, message, and user_data.

◆ TEST_F() [60/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
RunWithProjectFlagEnableImpeller   
)

Definition at line 476 of file flutter_windows_engine_unittests.cc.

476  {
477  FlutterWindowsEngineBuilder builder{GetContext()};
478  builder.SetImpellerSwitch(EnabledImpeller);
479  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
480  EngineModifier modifier(engine.get());
481 
482  modifier.embedder_api().NotifyDisplayUpdate =
483  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
484  ([](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
485  const FlutterEngineDisplaysUpdateType update_type,
486  const FlutterEngineDisplay* embedder_displays,
487  size_t display_count) { return kSuccess; }));
488 
489  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
490  UpdateAccessibilityFeatures,
491  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
492  FlutterAccessibilityFeature flags) { return kSuccess; });
493 
494  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
495  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
496  size_t locales_count) { return kSuccess; }));
497 
498  modifier.embedder_api().SendPlatformMessage =
499  MOCK_ENGINE_PROC(SendPlatformMessage,
500  ([](auto engine, auto message) { return kSuccess; }));
501 
502  bool run_called = false;
503  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
504  Run, ([&run_called](size_t version, const FlutterRendererConfig* config,
505  const FlutterProjectArgs* args, void* user_data,
506  FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
507  run_called = true;
508  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
509 
510  bool has_impeller_switch = false;
511  bool has_sdf_switch = false;
512  for (int i = 0; i < args->command_line_argc; ++i) {
513  if (strcmp(args->command_line_argv[i], "--enable-impeller") == 0) {
514  has_impeller_switch = true;
515  }
516  if (strcmp(args->command_line_argv[i], "--impeller-use-sdfs=true") ==
517  0) {
518  has_sdf_switch = true;
519  }
520  }
521  EXPECT_TRUE(has_impeller_switch);
522  EXPECT_TRUE(has_sdf_switch);
523  return kSuccess;
524  }));
525 
526  // Set the EGL manager to !nullptr to test ANGLE rendering.
527  modifier.SetEGLManager(std::make_unique<egl::MockManager>());
528 
529  engine->Run();
530 
531  EXPECT_TRUE(run_called);
532 
533  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
534  modifier.ReleaseEGLManager();
535 }
@ EnabledImpeller

References EnabledImpeller, message, and user_data.

◆ TEST_F() [61/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
ScheduleFrame   
)

Definition at line 899 of file flutter_windows_engine_unittests.cc.

899  {
900  FlutterWindowsEngineBuilder builder{GetContext()};
901  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
902  EngineModifier modifier(engine.get());
903 
904  bool called = false;
905  modifier.embedder_api().ScheduleFrame =
906  MOCK_ENGINE_PROC(ScheduleFrame, ([&called](auto engine) {
907  called = true;
908  return kSuccess;
909  }));
910 
911  engine->ScheduleFrame();
912  EXPECT_TRUE(called);
913 }

◆ TEST_F() [62/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
SendPlatformMessageWithoutResponse   
)

Definition at line 641 of file flutter_windows_engine_unittests.cc.

641  {
642  FlutterWindowsEngineBuilder builder{GetContext()};
643  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
644  EngineModifier modifier(engine.get());
645 
646  const char* channel = "test";
647  const std::vector<uint8_t> test_message = {1, 2, 3, 4};
648 
649  // Without a response, SendPlatformMessage should be a simple pass-through.
650  bool called = false;
651  modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
652  SendPlatformMessage, ([&called, test_message](auto engine, auto message) {
653  called = true;
654  EXPECT_STREQ(message->channel, "test");
655  EXPECT_EQ(message->message_size, test_message.size());
656  EXPECT_EQ(memcmp(message->message, test_message.data(),
657  message->message_size),
658  0);
659  EXPECT_EQ(message->response_handle, nullptr);
660  return kSuccess;
661  }));
662 
663  engine->SendPlatformMessage(channel, test_message.data(), test_message.size(),
664  nullptr, nullptr);
665  EXPECT_TRUE(called);
666 }

References message.

◆ TEST_F() [63/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
SendPlatformMessageWithResponse   
)

Definition at line 764 of file flutter_windows_engine_unittests.cc.

764  {
765  FlutterWindowsEngineBuilder builder{GetContext()};
766  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
767  EngineModifier modifier(engine.get());
768 
769  const char* channel = "test";
770  const std::vector<uint8_t> test_message = {1, 2, 3, 4};
771  auto* dummy_response_handle =
772  reinterpret_cast<FlutterPlatformMessageResponseHandle*>(5);
773  const FlutterDesktopBinaryReply reply_handler = [](auto... args) {};
774  void* reply_user_data = reinterpret_cast<void*>(6);
775 
776  // When a response is requested, a handle should be created, passed as part
777  // of the message, and then released.
778  bool create_response_handle_called = false;
779  modifier.embedder_api().PlatformMessageCreateResponseHandle =
780  MOCK_ENGINE_PROC(
781  PlatformMessageCreateResponseHandle,
782  ([&create_response_handle_called, &reply_handler, reply_user_data,
783  dummy_response_handle](auto engine, auto reply, auto user_data,
784  auto response_handle) {
785  create_response_handle_called = true;
786  EXPECT_EQ(reply, reply_handler);
787  EXPECT_EQ(user_data, reply_user_data);
788  EXPECT_NE(response_handle, nullptr);
789  *response_handle = dummy_response_handle;
790  return kSuccess;
791  }));
792  bool release_response_handle_called = false;
793  modifier.embedder_api().PlatformMessageReleaseResponseHandle =
794  MOCK_ENGINE_PROC(
795  PlatformMessageReleaseResponseHandle,
796  ([&release_response_handle_called, dummy_response_handle](
797  auto engine, auto response_handle) {
798  release_response_handle_called = true;
799  EXPECT_EQ(response_handle, dummy_response_handle);
800  return kSuccess;
801  }));
802  bool send_message_called = false;
803  modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
804  SendPlatformMessage, ([&send_message_called, test_message,
805  dummy_response_handle](auto engine, auto message) {
806  send_message_called = true;
807  EXPECT_STREQ(message->channel, "test");
808  EXPECT_EQ(message->message_size, test_message.size());
809  EXPECT_EQ(memcmp(message->message, test_message.data(),
810  message->message_size),
811  0);
812  EXPECT_EQ(message->response_handle, dummy_response_handle);
813  return kSuccess;
814  }));
815 
816  engine->SendPlatformMessage(channel, test_message.data(), test_message.size(),
817  reply_handler, reply_user_data);
818  EXPECT_TRUE(create_response_handle_called);
819  EXPECT_TRUE(release_response_handle_called);
820  EXPECT_TRUE(send_message_called);
821 }
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)

References message, and user_data.

◆ TEST_F() [64/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
SetNextFrameCallback   
)

Definition at line 915 of file flutter_windows_engine_unittests.cc.

915  {
916  FlutterWindowsEngineBuilder builder{GetContext()};
917  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
918  EngineModifier modifier(engine.get());
919 
920  bool called = false;
921  modifier.embedder_api().SetNextFrameCallback = MOCK_ENGINE_PROC(
922  SetNextFrameCallback, ([&called](auto engine, auto callback, auto data) {
923  called = true;
924  return kSuccess;
925  }));
926 
927  engine->SetNextFrameCallback([]() {});
928  EXPECT_TRUE(called);
929 }

References callback.

◆ TEST_F() [65/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
SetsThreadPriority   
)

Definition at line 847 of file flutter_windows_engine_unittests.cc.

847  {
848  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kBackground);
849  EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
850  THREAD_PRIORITY_BELOW_NORMAL);
851 
852  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kDisplay);
853  EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
854  THREAD_PRIORITY_ABOVE_NORMAL);
855 
856  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kRaster);
857  EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
858  THREAD_PRIORITY_ABOVE_NORMAL);
859 
860  // FlutterThreadPriority::kNormal does not change thread priority, reset to 0
861  // here.
862  SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
863 
864  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kNormal);
865  EXPECT_EQ(GetThreadPriority(GetCurrentThread()), THREAD_PRIORITY_NORMAL);
866 }
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)

References flutter::WindowsPlatformThreadPrioritySetter().

◆ TEST_F() [66/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
TaskRunnerDelayedTask   
)

Definition at line 67 of file flutter_windows_engine_unittests.cc.

67  {
68  bool finished = false;
69  auto runner = std::make_unique<TaskRunner>(
70  [] {
71  return static_cast<uint64_t>(
72  fml::TimePoint::Now().ToEpochDelta().ToNanoseconds());
73  },
74  [&](const FlutterTask*) { finished = true; });
75  runner->PostFlutterTask(
76  FlutterTask{},
77  static_cast<uint64_t>((fml::TimePoint::Now().ToEpochDelta() +
78  fml::TimeDelta::FromMilliseconds(50))
79  .ToNanoseconds()));
80  auto start = fml::TimePoint::Now();
81  while (!finished) {
82  PumpMessage();
83  }
84  auto duration = fml::TimePoint::Now() - start;
85  EXPECT_GE(duration, fml::TimeDelta::FromMilliseconds(50));
86 }

◆ TEST_F() [67/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
TaskRunnerDoesNotDeadlock   
)

Definition at line 89 of file flutter_windows_engine_unittests.cc.

89  {
90  auto runner = std::make_unique<TaskRunner>(
91  [] {
92  return static_cast<uint64_t>(
93  fml::TimePoint::Now().ToEpochDelta().ToNanoseconds());
94  },
95  [&](const FlutterTask*) {});
96 
97  struct RunnerHolder {
98  void PostTaskLoop() {
99  runner->PostTask([this] { PostTaskLoop(); });
100  }
101  std::unique_ptr<TaskRunner> runner;
102  };
103 
104  RunnerHolder container{.runner = std::move(runner)};
105  // Spam flutter tasks.
106  container.PostTaskLoop();
107 
108  const LPCWSTR class_name = L"FlutterTestWindowClass";
109  WNDCLASS wc = {0};
110  wc.lpfnWndProc = DefWindowProc;
111  wc.lpszClassName = class_name;
112  RegisterClass(&wc);
113 
114  HWND window;
115  container.runner->PostTask([&] {
116  window = CreateWindowEx(0, class_name, L"Empty Window", WS_OVERLAPPEDWINDOW,
117  CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, nullptr,
118  nullptr, nullptr, nullptr);
119  ShowWindow(window, SW_SHOW);
120  });
121 
122  while (true) {
123  ::MSG msg;
124  if (::GetMessage(&msg, nullptr, 0, 0)) {
125  if (msg.message == WM_PAINT) {
126  break;
127  }
128  ::TranslateMessage(&msg);
129  ::DispatchMessage(&msg);
130  }
131  }
132 
133  DestroyWindow(window);
134  UnregisterClassW(class_name, nullptr);
135 }

◆ TEST_F() [68/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
TestExit   
)

Definition at line 1137 of file flutter_windows_engine_unittests.cc.

1137  {
1138  FlutterWindowsEngineBuilder builder{GetContext()};
1139  builder.SetDartEntrypoint("exitTestExit");
1140  bool finished = false;
1141 
1142  auto engine = builder.Build();
1143  auto window_binding_handler =
1144  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1145  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1146 
1147  EngineModifier modifier(engine.get());
1148  modifier.SetImplicitView(&view);
1149  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1150  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1151  EXPECT_CALL(*handler, Quit)
1152  .WillOnce([&finished](std::optional<HWND> hwnd,
1153  std::optional<WPARAM> wparam,
1154  std::optional<LPARAM> lparam,
1155  UINT exit_code) { finished = exit_code == 0; });
1156  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillRepeatedly(Return(true));
1157  modifier.SetLifecycleManager(std::move(handler));
1158 
1159  engine->lifecycle_manager()->BeginProcessingExit();
1160 
1161  engine->Run();
1162 
1163  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1164  0);
1165 
1166  // The test will only succeed when this while loop exits. Otherwise it will
1167  // timeout.
1168  while (!finished) {
1169  engine->task_runner()->ProcessTasks();
1170  }
1171 }

◆ TEST_F() [69/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
TestExitCancel   
)

Definition at line 1173 of file flutter_windows_engine_unittests.cc.

1173  {
1174  FlutterWindowsEngineBuilder builder{GetContext()};
1175  builder.SetDartEntrypoint("exitTestCancel");
1176  bool did_call = false;
1177 
1178  auto engine = builder.Build();
1179  auto window_binding_handler =
1180  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1181  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1182 
1183  EngineModifier modifier(engine.get());
1184  modifier.SetImplicitView(&view);
1185  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1186  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1187  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillRepeatedly(Return(true));
1188  EXPECT_CALL(*handler, Quit).Times(0);
1189  modifier.SetLifecycleManager(std::move(handler));
1190  engine->lifecycle_manager()->BeginProcessingExit();
1191 
1192  auto binary_messenger =
1193  std::make_unique<BinaryMessengerImpl>(engine->messenger());
1194  binary_messenger->SetMessageHandler(
1195  "flutter/platform", [&did_call](const uint8_t* message,
1196  size_t message_size, BinaryReply reply) {
1197  std::string contents(message, message + message_size);
1198  EXPECT_NE(contents.find("\"method\":\"System.exitApplication\""),
1199  std::string::npos);
1200  EXPECT_NE(contents.find("\"type\":\"required\""), std::string::npos);
1201  EXPECT_NE(contents.find("\"exitCode\":0"), std::string::npos);
1202  did_call = true;
1203  char response[] = "";
1204  reply(reinterpret_cast<uint8_t*>(response), 0);
1205  });
1206 
1207  engine->Run();
1208 
1209  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1210  0);
1211 
1212  while (!did_call) {
1213  engine->task_runner()->ProcessTasks();
1214  }
1215 }

References message.

◆ TEST_F() [70/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
TestExitCloseMultiWindow   
)

Definition at line 1279 of file flutter_windows_engine_unittests.cc.

1279  {
1280  FlutterWindowsEngineBuilder builder{GetContext()};
1281  builder.SetDartEntrypoint("exitTestExit");
1282  bool finished = false;
1283 
1284  auto engine = builder.Build();
1285  auto window_binding_handler =
1286  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1287  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1288 
1289  EngineModifier modifier(engine.get());
1290  modifier.SetImplicitView(&view);
1291  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1292  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1293  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce([&finished]() {
1294  finished = true;
1295  return false;
1296  });
1297  // Quit should not be called when there is more than one window.
1298  EXPECT_CALL(*handler, Quit).Times(0);
1299  modifier.SetLifecycleManager(std::move(handler));
1300  engine->lifecycle_manager()->BeginProcessingExit();
1301 
1302  engine->Run();
1303 
1304  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1305  0);
1306 
1307  while (!finished) {
1308  engine->task_runner()->ProcessTasks();
1309  }
1310 }

◆ TEST_F() [71/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
TestExitSecondCloseMessage   
)

Definition at line 1220 of file flutter_windows_engine_unittests.cc.

1220  {
1221  FlutterWindowsEngineBuilder builder{GetContext()};
1222  builder.SetDartEntrypoint("exitTestExit");
1223  bool second_close = false;
1224 
1225  auto engine = builder.Build();
1226  auto window_binding_handler =
1227  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1228  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1229 
1230  EngineModifier modifier(engine.get());
1231  modifier.SetImplicitView(&view);
1232  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1233  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1234  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(true));
1235  EXPECT_CALL(*handler, Quit)
1236  .WillOnce([handler_ptr = handler.get()](
1237  std::optional<HWND> hwnd, std::optional<WPARAM> wparam,
1238  std::optional<LPARAM> lparam, UINT exit_code) {
1239  handler_ptr->WindowsLifecycleManager::Quit(hwnd, wparam, lparam,
1240  exit_code);
1241  });
1242  EXPECT_CALL(*handler, DispatchMessage)
1243  .WillRepeatedly(
1244  [&engine](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
1245  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1246  hwnd, msg, wparam, lparam);
1247  });
1248  modifier.SetLifecycleManager(std::move(handler));
1249  engine->lifecycle_manager()->BeginProcessingExit();
1250 
1251  engine->Run();
1252 
1253  // This delegate will be registered after the lifecycle manager, so it will be
1254  // called only when a message is not consumed by the lifecycle manager. This
1255  // should be called on the second, synthesized WM_CLOSE message that the
1256  // lifecycle manager posts.
1257  engine->window_proc_delegate_manager()->RegisterTopLevelWindowProcDelegate(
1258  [](HWND hwnd, UINT message, WPARAM wpar, LPARAM lpar, void* user_data,
1259  LRESULT* result) {
1260  switch (message) {
1261  case WM_CLOSE: {
1262  bool* called = reinterpret_cast<bool*>(user_data);
1263  *called = true;
1264  return true;
1265  }
1266  }
1267  return false;
1268  },
1269  reinterpret_cast<void*>(&second_close));
1270 
1271  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1272  0);
1273 
1274  while (!second_close) {
1275  engine->task_runner()->ProcessTasks();
1276  }
1277 }

References message, and user_data.

◆ TEST_F() [72/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
UpdateHighContrastFeature   
)

Definition at line 939 of file flutter_windows_engine_unittests.cc.

939  {
940  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
941  EXPECT_CALL(*windows_proc_table, GetHighContrastEnabled)
942  .WillOnce(Return(true))
943  .WillOnce(Return(false));
944 
945  FlutterWindowsEngineBuilder builder{GetContext()};
946  builder.SetWindowsProcTable(windows_proc_table);
947  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
948  EngineModifier modifier(engine.get());
949 
950  std::optional<FlutterAccessibilityFeature> engine_flags;
951  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
952  UpdateAccessibilityFeatures, ([&engine_flags](auto engine, auto flags) {
953  engine_flags = flags;
954  return kSuccess;
955  }));
956  modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
957  SendPlatformMessage,
958  [](auto engine, const auto message) { return kSuccess; });
959 
960  // 1: High contrast is enabled.
961  engine->UpdateHighContrastMode();
962 
963  EXPECT_TRUE(engine->high_contrast_enabled());
964  EXPECT_TRUE(engine_flags.has_value());
965  EXPECT_TRUE(
966  engine_flags.value() &
967  FlutterAccessibilityFeature::kFlutterAccessibilityFeatureHighContrast);
968 
969  // 2: High contrast is disabled.
970  engine_flags.reset();
971  engine->UpdateHighContrastMode();
972 
973  EXPECT_FALSE(engine->high_contrast_enabled());
974  EXPECT_TRUE(engine_flags.has_value());
975  EXPECT_FALSE(
976  engine_flags.value() &
977  FlutterAccessibilityFeature::kFlutterAccessibilityFeatureHighContrast);
978 }

References message.

◆ TEST_F() [73/239]

flutter::testing::TEST_F ( FlutterWindowsEngineTest  ,
UpdateSemanticsMultiView   
)

Definition at line 1733 of file flutter_windows_engine_unittests.cc.

1733  {
1734  auto& context = GetContext();
1735  WindowsConfigBuilder builder{context};
1736  builder.SetDartEntrypoint("sendSemanticsTreeInfo");
1737 
1738  // Setup: a signal for when we have send out all of our semantics updates
1739  bool done = false;
1740  auto native_entry =
1741  CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) { done = true; });
1742  context.AddNativeFunction("Signal", native_entry);
1743 
1744  // Setup: Create the engine and two views + enable semantics
1745  EnginePtr engine{builder.RunHeadless()};
1746  ASSERT_NE(engine, nullptr);
1747 
1748  auto window_binding_handler1 =
1749  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1750  auto window_binding_handler2 =
1751  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1752 
1753  // The following mocks are required by
1754  // FlutterWindowsView::CreateWindowMetricsEvent so that we create a valid
1755  // view.
1756  EXPECT_CALL(*window_binding_handler1, GetPhysicalWindowBounds)
1757  .WillRepeatedly(testing::Return(PhysicalWindowBounds{100, 100}));
1758  EXPECT_CALL(*window_binding_handler1, GetDpiScale)
1759  .WillRepeatedly(testing::Return(96.0));
1760  EXPECT_CALL(*window_binding_handler2, GetPhysicalWindowBounds)
1761  .WillRepeatedly(testing::Return(PhysicalWindowBounds{200, 200}));
1762  EXPECT_CALL(*window_binding_handler2, GetDpiScale)
1763  .WillRepeatedly(testing::Return(96.0));
1764 
1765  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
1766  EngineModifier modifier{windows_engine};
1767  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1768 
1769  // We want to avoid adding an implicit view as the first view
1770  modifier.SetNextViewId(kImplicitViewId + 1);
1771 
1772  auto view1 = windows_engine->CreateView(std::move(window_binding_handler1),
1773  /*is_sized_to_content=*/false,
1774  BoxConstraints());
1775  auto view2 = windows_engine->CreateView(std::move(window_binding_handler2),
1776  /*is_sized_to_content=*/false,
1777  BoxConstraints());
1778 
1779  // Act: UpdateSemanticsEnabled will trigger the semantics updates
1780  // to get sent.
1781  windows_engine->UpdateSemanticsEnabled(true);
1782 
1783  while (!done) {
1784  windows_engine->task_runner()->ProcessTasks();
1785  }
1786 
1787  auto accessibility_bridge1 = view1->accessibility_bridge().lock();
1788  auto accessibility_bridge2 = view2->accessibility_bridge().lock();
1789 
1790  // Expect: that the semantics trees are updated with their
1791  // respective nodes.
1792  while (
1793  !accessibility_bridge1->GetPlatformNodeFromTree(view1->view_id() + 1)) {
1794  windows_engine->task_runner()->ProcessTasks();
1795  }
1796 
1797  while (
1798  !accessibility_bridge2->GetPlatformNodeFromTree(view2->view_id() + 1)) {
1799  windows_engine->task_runner()->ProcessTasks();
1800  }
1801 
1802  // Rely on timeout mechanism in CI.
1803  auto tree1 = accessibility_bridge1->GetTree();
1804  auto tree2 = accessibility_bridge2->GetTree();
1805  EXPECT_NE(tree1->GetFromId(view1->view_id() + 1), nullptr);
1806  EXPECT_NE(tree2->GetFromId(view2->view_id() + 1), nullptr);
1807 }

References flutter::FlutterWindowsEngine::CreateView(), and flutter::kImplicitViewId.

◆ TEST_F() [74/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
AccessibilityNodeWithoutView   
)

Definition at line 984 of file flutter_window_unittests.cc.

984  {
985  MockFlutterWindow win32window;
986 
987  EXPECT_EQ(win32window.GetNativeViewAccessible(), nullptr);
988 }

◆ TEST_F() [75/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
AlertNode   
)

Definition at line 992 of file flutter_window_unittests.cc.

992  {
993  std::unique_ptr<FlutterWindowsEngine> engine =
994  FlutterWindowsEngineBuilder{GetContext()}.Build();
995  auto win32window = std::make_unique<MockFlutterWindow>();
996  EXPECT_CALL(*win32window.get(), GetAxFragmentRootDelegate())
997  .WillRepeatedly(Return(nullptr));
998  EXPECT_CALL(*win32window.get(), OnWindowStateEvent).Times(AnyNumber());
999  EXPECT_CALL(*win32window.get(), GetWindowHandle).Times(AnyNumber());
1000  MockFlutterWindowsView view{engine.get(), std::move(win32window)};
1001  std::wstring message = L"Test alert";
1002  EXPECT_CALL(view, NotifyWinEventWrapper(_, ax::mojom::Event::kAlert))
1003  .Times(1);
1004  view.AnnounceAlert(message);
1005 
1006  IAccessible* alert = view.AlertNode();
1007  VARIANT self{.vt = VT_I4, .lVal = CHILDID_SELF};
1008  BSTR strptr;
1009  alert->get_accName(self, &strptr);
1010  EXPECT_EQ(message, strptr);
1011 
1012  alert->get_accDescription(self, &strptr);
1013  EXPECT_EQ(message, strptr);
1014 
1015  alert->get_accValue(self, &strptr);
1016  EXPECT_EQ(message, strptr);
1017 
1018  VARIANT role;
1019  alert->get_accRole(self, &role);
1020  EXPECT_EQ(role.vt, VT_I4);
1021  EXPECT_EQ(role.lVal, ROLE_SYSTEM_ALERT);
1022 }

References flutter::IAccessible, and message.

◆ TEST_F() [76/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
CachedLifecycleMessage   
)

Definition at line 1062 of file flutter_window_unittests.cc.

1062  {
1063  MockFlutterWindow win32window;
1064  EXPECT_CALL(win32window, GetWindowHandle)
1065  .WillRepeatedly(Return(reinterpret_cast<HWND>(1)));
1066  EXPECT_CALL(win32window, OnWindowStateEvent)
1067  .WillRepeatedly([&](WindowStateEvent event) {
1068  win32window.FlutterWindow::OnWindowStateEvent(event);
1069  });
1070  EXPECT_CALL(win32window, OnResize).Times(1);
1071 
1072  // Restore
1073  win32window.InjectWindowMessage(WM_SIZE, 0, MAKEWORD(1, 1));
1074 
1075  // Focus
1076  win32window.InjectWindowMessage(WM_SETFOCUS, 0, 0);
1077 
1078  MockWindowBindingHandlerDelegate delegate;
1079  bool focused = false;
1080  bool restored = false;
1081  EXPECT_CALL(delegate, OnWindowStateEvent)
1082  .WillRepeatedly([&](HWND hwnd, WindowStateEvent event) {
1083  if (event == WindowStateEvent::kFocus) {
1084  focused = true;
1085  } else if (event == WindowStateEvent::kShow) {
1086  restored = true;
1087  }
1088  });
1089 
1090  EXPECT_CALL(delegate, OnFocus(Eq(FlutterViewFocusState::kFocused),
1091  Eq(FlutterViewFocusDirection::kUndefined)))
1092  .Times(1);
1093  win32window.SetView(&delegate);
1094  EXPECT_TRUE(focused);
1095  EXPECT_TRUE(restored);
1096 }
WindowStateEvent
An event representing a change in window state that may update the.

References flutter::kFocus, and flutter::kShow.

◆ TEST_F() [77/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
CreateDestroy   
)

Definition at line 134 of file flutter_window_unittests.cc.

134  {
135  std::unique_ptr<FlutterWindowsEngine> engine =
136  FlutterWindowsEngineBuilder{GetContext()}.Build();
137  FlutterWindow window(800, 600, engine->display_manager());
138  ASSERT_TRUE(TRUE);
139 }

◆ TEST_F() [78/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
LifecycleFocusMessages   
)

Definition at line 1024 of file flutter_window_unittests.cc.

1024  {
1025  MockFlutterWindow win32window;
1026  EXPECT_CALL(win32window, GetWindowHandle)
1027  .WillRepeatedly(Return(reinterpret_cast<HWND>(1)));
1028  MockWindowBindingHandlerDelegate delegate;
1029 
1030  WindowStateEvent last_event;
1031  EXPECT_CALL(delegate, OnWindowStateEvent)
1032  .WillRepeatedly([&last_event](HWND hwnd, WindowStateEvent event) {
1033  last_event = event;
1034  });
1035  EXPECT_CALL(win32window, OnWindowStateEvent)
1036  .WillRepeatedly([&](WindowStateEvent event) {
1037  win32window.FlutterWindow::OnWindowStateEvent(event);
1038  });
1039  EXPECT_CALL(win32window, OnResize).Times(AnyNumber());
1040 
1041  win32window.SetView(&delegate);
1042 
1043  win32window.InjectWindowMessage(WM_SIZE, 0, 0);
1044  EXPECT_EQ(last_event, WindowStateEvent::kHide);
1045 
1046  win32window.InjectWindowMessage(WM_SIZE, 0, MAKEWORD(1, 1));
1047  EXPECT_EQ(last_event, WindowStateEvent::kShow);
1048 
1049  EXPECT_CALL(delegate, OnFocus(Eq(FlutterViewFocusState::kFocused),
1050  Eq(FlutterViewFocusDirection::kUndefined)))
1051  .Times(1);
1052  win32window.InjectWindowMessage(WM_SETFOCUS, 0, 0);
1053  EXPECT_EQ(last_event, WindowStateEvent::kFocus);
1054 
1055  EXPECT_CALL(delegate, OnFocus(Eq(FlutterViewFocusState::kUnfocused),
1056  Eq(FlutterViewFocusDirection::kUndefined)))
1057  .Times(1);
1058  win32window.InjectWindowMessage(WM_KILLFOCUS, 0, 0);
1059  EXPECT_EQ(last_event, WindowStateEvent::kUnfocus);
1060 }

References flutter::kFocus, flutter::kHide, flutter::kShow, and flutter::kUnfocus.

◆ TEST_F() [79/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnBitmapSurfaceUpdated   
)

Definition at line 141 of file flutter_window_unittests.cc.

141  {
142  std::unique_ptr<FlutterWindowsEngine> engine =
143  FlutterWindowsEngineBuilder{GetContext()}.Build();
144  FlutterWindow win32window(100, 100, engine->display_manager());
145  int old_handle_count = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
146 
147  constexpr size_t row_bytes = 100 * 4;
148  constexpr size_t height = 100;
149  std::array<char, row_bytes * height> allocation;
150  win32window.OnBitmapSurfaceUpdated(allocation.data(), row_bytes, height);
151 
152  int new_handle_count = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
153  // Check GDI resources leak
154  EXPECT_EQ(old_handle_count, new_handle_count);
155 }

References flutter::FlutterWindow::OnBitmapSurfaceUpdated().

◆ TEST_F() [80/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnCursorRectUpdatedHighDPI   
)

Definition at line 173 of file flutter_window_unittests.cc.

173  {
174  MockFlutterWindow win32window;
175  EXPECT_CALL(win32window, GetDpiScale()).WillOnce(Return(1.5));
176 
177  Rect expected_cursor_rect(Point(15, 30), Size(45, 60));
178  EXPECT_CALL(win32window, UpdateCursorRect(expected_cursor_rect)).Times(1);
179 
180  Rect cursor_rect(Point(10, 20), Size(30, 40));
181  win32window.OnCursorRectUpdated(cursor_rect);
182 }

◆ TEST_F() [81/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnCursorRectUpdatedRegularDPI   
)

Definition at line 160 of file flutter_window_unittests.cc.

160  {
161  MockFlutterWindow win32window;
162  EXPECT_CALL(win32window, GetDpiScale()).WillOnce(Return(1.0));
163 
164  Rect cursor_rect(Point(10, 20), Size(30, 40));
165  EXPECT_CALL(win32window, UpdateCursorRect(cursor_rect)).Times(1);
166 
167  win32window.OnCursorRectUpdated(cursor_rect);
168 }

◆ TEST_F() [82/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnInvertedStylusPointerDownUsesDeviceKind   
)

Definition at line 675 of file flutter_window_unittests.cc.

675  {
676  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
677 
678  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
679  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
680  if (pointer_info != nullptr) {
681  pointer_info->pointerType = PT_PEN;
682  pointer_info->pointerId = pointer_id;
683  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
684  }
685  return TRUE;
686  });
687 
688  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
689  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
690  if (pen_info != nullptr) {
691  pen_info->pressure = 720;
692  pen_info->rotation = 0;
693  pen_info->penFlags = PEN_FLAG_INVERTED;
694  }
695  return TRUE;
696  });
697 
698  MockFlutterWindow win32window(100, 100, mock_proc_table);
699  MockWindowBindingHandlerDelegate delegate;
700  win32window.SetView(&delegate);
701 
702  EXPECT_CALL(delegate,
703  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindInvertedStylus,
704  kDefaultPointerDeviceId,
705  kFlutterPointerButtonStylusContact, 0, 720))
706  .Times(1);
707 
708  UINT32 pointerId = 1;
709  WPARAM wparam = static_cast<WPARAM>(pointerId);
710  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 10,
711  10);
712 }

◆ TEST_F() [83/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnMousePointerDown   
)

Definition at line 826 of file flutter_window_unittests.cc.

826  {
827  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
828 
829  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
830  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
831  if (pointer_info != nullptr) {
832  pointer_info->pointerType = PT_MOUSE;
833  pointer_info->pointerId = pointer_id;
834  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT |
835  POINTER_FLAG_FIRSTBUTTON |
836  POINTER_FLAG_DOWN;
837  }
838  return TRUE;
839  });
840 
841  MockFlutterWindow win32window(100, 100, mock_proc_table);
842  MockWindowBindingHandlerDelegate delegate;
843  win32window.SetView(&delegate);
844 
845  EXPECT_CALL(delegate, OnPointerDown(45, 50, kFlutterPointerDeviceKindMouse,
846  kDefaultPointerDeviceId,
847  kFlutterPointerButtonMousePrimary, 0, 0))
848  .Times(1);
849 
850  UINT32 pointerId = 1;
851  WPARAM wparam = static_cast<WPARAM>(pointerId);
852  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 45,
853  50);
854 }

◆ TEST_F() [84/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnPointerStarSendsDeviceType   
)

Definition at line 184 of file flutter_window_unittests.cc.

184  {
185  std::unique_ptr<FlutterWindowsEngine> engine =
186  FlutterWindowsEngineBuilder{GetContext()}.Build();
187  FlutterWindow win32window(100, 100, engine->display_manager());
188  MockWindowBindingHandlerDelegate delegate;
189  EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
190  win32window.SetView(&delegate);
191 
192  // Move
193  EXPECT_CALL(delegate,
194  OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindMouse,
195  kDefaultPointerDeviceId, 0, 0, 0, 0))
196  .Times(1);
197  EXPECT_CALL(delegate,
198  OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindTouch,
199  kDefaultPointerDeviceId, 0, 0, 0, 0))
200  .Times(1);
201  EXPECT_CALL(delegate,
202  OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindStylus,
203  kDefaultPointerDeviceId, 0, 0, 0, 0))
204  .Times(1);
205 
206  // Down
207  EXPECT_CALL(delegate,
208  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindMouse,
209  kDefaultPointerDeviceId,
210  kFlutterPointerButtonMousePrimary, 0, 0))
211  .Times(1);
212  EXPECT_CALL(delegate,
213  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindTouch,
214  kDefaultPointerDeviceId,
215  kFlutterPointerButtonMousePrimary, 0, 0))
216  .Times(1);
217  EXPECT_CALL(delegate,
218  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
219  kDefaultPointerDeviceId,
220  kFlutterPointerButtonMousePrimary, 0, 0))
221  .Times(1);
222 
223  // Up
224  EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindMouse,
225  kDefaultPointerDeviceId,
226  kFlutterPointerButtonMousePrimary))
227  .Times(1);
228  EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindTouch,
229  kDefaultPointerDeviceId,
230  kFlutterPointerButtonMousePrimary))
231  .Times(1);
232  EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindStylus,
233  kDefaultPointerDeviceId,
234  kFlutterPointerButtonMousePrimary))
235  .Times(1);
236 
237  // Leave
238  EXPECT_CALL(delegate,
239  OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindMouse,
240  kDefaultPointerDeviceId))
241  .Times(1);
242  EXPECT_CALL(delegate,
243  OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindTouch,
244  kDefaultPointerDeviceId))
245  .Times(1);
246  EXPECT_CALL(delegate,
247  OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindStylus,
248  kDefaultPointerDeviceId))
249  .Times(1);
250 
251  win32window.OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindMouse,
252  kDefaultPointerDeviceId, 0, 0, 0, 0);
253  win32window.OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindMouse,
254  kDefaultPointerDeviceId,
255  kFlutterPointerButtonMousePrimary, 0, 0);
256  win32window.OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindMouse,
257  kDefaultPointerDeviceId,
258  kFlutterPointerButtonMousePrimary);
259  win32window.OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindMouse,
260  kDefaultPointerDeviceId);
261 
262  // Touch
263  win32window.OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindTouch,
264  kDefaultPointerDeviceId, 0, 0, 0, 0);
265  win32window.OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindTouch,
266  kDefaultPointerDeviceId,
267  kFlutterPointerButtonMousePrimary, 0, 0);
268  win32window.OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindTouch,
269  kDefaultPointerDeviceId,
270  kFlutterPointerButtonMousePrimary);
271  win32window.OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindTouch,
272  kDefaultPointerDeviceId);
273 
274  // Pen
275  win32window.OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindStylus,
276  kDefaultPointerDeviceId, 0, 0, 0, 0);
277  win32window.OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
278  kDefaultPointerDeviceId,
279  kFlutterPointerButtonMousePrimary, 0, 0);
280  win32window.OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindStylus,
281  kDefaultPointerDeviceId,
282  kFlutterPointerButtonMousePrimary);
283  win32window.OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindStylus,
284  kDefaultPointerDeviceId);
285 
286  // Destruction of win32window sends a HIDE update. In situ, the window is
287  // owned by the delegate, and so is destructed first. Not so here.
288  win32window.SetView(nullptr);
289 }

References flutter::FlutterWindow::OnPointerDown(), flutter::FlutterWindow::OnPointerLeave(), flutter::FlutterWindow::OnPointerMove(), flutter::FlutterWindow::OnPointerUp(), and flutter::FlutterWindow::SetView().

◆ TEST_F() [85/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnScrollCallsGetScrollOffsetMultiplier   
)

Definition at line 939 of file flutter_window_unittests.cc.

939  {
940  MockFlutterWindow win32window;
941  MockWindowBindingHandlerDelegate delegate;
942  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
943  win32window.SetView(&delegate);
944 
945  EXPECT_CALL(win32window, GetWindowHandle).WillOnce([&win32window]() {
946  return win32window.FlutterWindow::GetWindowHandle();
947  });
948  EXPECT_CALL(win32window, GetScrollOffsetMultiplier).WillOnce(Return(120.0f));
949 
950  EXPECT_CALL(delegate,
951  OnScroll(_, _, 0, 0, 120.0f, kFlutterPointerDeviceKindMouse,
952  kDefaultPointerDeviceId))
953  .Times(1);
954 
955  win32window.OnScroll(0.0f, 0.0f, kFlutterPointerDeviceKindMouse,
956  kDefaultPointerDeviceId);
957 }

◆ TEST_F() [86/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusBarrelButtonUpdateMovesWithReleasedButton   
)

Definition at line 770 of file flutter_window_unittests.cc.

770  {
771  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
772 
773  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
774  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
775  if (pointer_info != nullptr) {
776  pointer_info->pointerType = PT_PEN;
777  pointer_info->pointerId = pointer_id;
778  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
779  }
780  return TRUE;
781  });
782 
783  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
784  .WillOnce([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
785  if (pen_info != nullptr) {
786  pen_info->pressure = 720;
787  pen_info->rotation = 0;
788  pen_info->penFlags = PEN_FLAG_BARREL;
789  }
790  return TRUE;
791  })
792  .WillOnce([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
793  if (pen_info != nullptr) {
794  pen_info->pressure = 720;
795  pen_info->rotation = 0;
796  pen_info->penFlags = 0;
797  }
798  return TRUE;
799  });
800 
801  MockFlutterWindow win32window(100, 100, mock_proc_table);
802  MockWindowBindingHandlerDelegate delegate;
803  win32window.SetView(&delegate);
804 
805  EXPECT_CALL(delegate,
806  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
807  kDefaultPointerDeviceId,
808  kFlutterPointerButtonStylusContact |
809  kFlutterPointerButtonStylusPrimary,
810  0, 720))
811  .Times(1);
812  EXPECT_CALL(delegate,
813  OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindStylus,
814  kDefaultPointerDeviceId,
815  kFlutterPointerButtonStylusContact, 0, 720, 0))
816  .Times(1);
817 
818  UINT32 pointerId = 1;
819  WPARAM wparam = static_cast<WPARAM>(pointerId);
820  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 10,
821  10);
822  InjectPointerMessageWithClientPoint(win32window, WM_POINTERUPDATE, wparam, 10,
823  10);
824 }

◆ TEST_F() [87/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusBarrelButtonUpdateMovesWithUpdatedButtons   
)

Definition at line 714 of file flutter_window_unittests.cc.

714  {
715  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
716 
717  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
718  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
719  if (pointer_info != nullptr) {
720  pointer_info->pointerType = PT_PEN;
721  pointer_info->pointerId = pointer_id;
722  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
723  }
724  return TRUE;
725  });
726 
727  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
728  .WillOnce([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
729  if (pen_info != nullptr) {
730  pen_info->pressure = 720;
731  pen_info->rotation = 0;
732  pen_info->penFlags = 0;
733  }
734  return TRUE;
735  })
736  .WillOnce([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
737  if (pen_info != nullptr) {
738  pen_info->pressure = 720;
739  pen_info->rotation = 0;
740  pen_info->penFlags = PEN_FLAG_BARREL;
741  }
742  return TRUE;
743  });
744 
745  MockFlutterWindow win32window(100, 100, mock_proc_table);
746  MockWindowBindingHandlerDelegate delegate;
747  win32window.SetView(&delegate);
748 
749  EXPECT_CALL(delegate,
750  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
751  kDefaultPointerDeviceId,
752  kFlutterPointerButtonStylusContact, 0, 720))
753  .Times(1);
754  EXPECT_CALL(delegate,
755  OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindStylus,
756  kDefaultPointerDeviceId,
757  kFlutterPointerButtonStylusContact |
758  kFlutterPointerButtonStylusPrimary,
759  0, 720, 0))
760  .Times(1);
761 
762  UINT32 pointerId = 1;
763  WPARAM wparam = static_cast<WPARAM>(pointerId);
764  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 10,
765  10);
766  InjectPointerMessageWithClientPoint(win32window, WM_POINTERUPDATE, wparam, 10,
767  10);
768 }

◆ TEST_F() [88/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusBarrelButtonUsesPenFlags   
)

Definition at line 593 of file flutter_window_unittests.cc.

593  {
594  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
595 
596  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
597  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
598  if (pointer_info != nullptr) {
599  pointer_info->pointerType = PT_PEN;
600  pointer_info->pointerId = pointer_id;
601  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
602  }
603  return TRUE;
604  });
605 
606  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
607  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
608  if (pen_info != nullptr) {
609  pen_info->pressure = 720;
610  pen_info->rotation = 0;
611  pen_info->penFlags = PEN_FLAG_BARREL;
612  }
613  return TRUE;
614  });
615 
616  MockFlutterWindow win32window(100, 100, mock_proc_table);
617  MockWindowBindingHandlerDelegate delegate;
618  win32window.SetView(&delegate);
619 
620  EXPECT_CALL(delegate,
621  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
622  kDefaultPointerDeviceId,
623  kFlutterPointerButtonStylusContact |
624  kFlutterPointerButtonStylusPrimary,
625  0, 720))
626  .Times(1);
627 
628  UINT32 pointerId = 1;
629  WPARAM wparam = static_cast<WPARAM>(pointerId);
630  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 10,
631  10);
632 }

◆ TEST_F() [89/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusEraserButtonUsesPenFlags   
)

Definition at line 634 of file flutter_window_unittests.cc.

634  {
635  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
636 
637  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
638  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
639  if (pointer_info != nullptr) {
640  pointer_info->pointerType = PT_PEN;
641  pointer_info->pointerId = pointer_id;
642  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
643  }
644  return TRUE;
645  });
646 
647  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
648  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
649  if (pen_info != nullptr) {
650  pen_info->pressure = 720;
651  pen_info->rotation = 0;
652  pen_info->penFlags = PEN_FLAG_ERASER;
653  }
654  return TRUE;
655  });
656 
657  MockFlutterWindow win32window(100, 100, mock_proc_table);
658  MockWindowBindingHandlerDelegate delegate;
659  win32window.SetView(&delegate);
660 
661  EXPECT_CALL(delegate,
662  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
663  kDefaultPointerDeviceId,
664  kFlutterPointerButtonStylusContact |
665  kFlutterPointerButtonStylusSecondary,
666  0, 720))
667  .Times(1);
668 
669  UINT32 pointerId = 1;
670  WPARAM wparam = static_cast<WPARAM>(pointerId);
671  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 10,
672  10);
673 }

◆ TEST_F() [90/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusHoverAfterPointerUp   
)

Definition at line 527 of file flutter_window_unittests.cc.

527  {
528  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
529 
530  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
531  .WillOnce([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
532  if (pointer_info != nullptr) {
533  pointer_info->pointerType = PT_PEN;
534  pointer_info->pointerId = pointer_id;
535  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
536  }
537  return TRUE;
538  })
539  .WillOnce([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
540  if (pointer_info != nullptr) {
541  pointer_info->pointerType = PT_PEN;
542  pointer_info->pointerId = pointer_id;
543  pointer_info->pointerFlags = POINTER_FLAG_UP;
544  }
545  return TRUE;
546  })
547  .WillOnce([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
548  if (pointer_info != nullptr) {
549  pointer_info->pointerType = PT_PEN;
550  pointer_info->pointerId = pointer_id;
551  pointer_info->pointerFlags = POINTER_FLAG_UPDATE;
552  }
553  return TRUE;
554  });
555 
556  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
557  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
558  if (pen_info != nullptr) {
559  pen_info->pressure = 720;
560  pen_info->rotation = 0;
561  pen_info->penFlags = 0;
562  }
563  return TRUE;
564  });
565 
566  MockFlutterWindow win32window(100, 100, mock_proc_table);
567  MockWindowBindingHandlerDelegate delegate;
568  win32window.SetView(&delegate);
569 
570  EXPECT_CALL(delegate,
571  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
572  kDefaultPointerDeviceId,
573  kFlutterPointerButtonStylusContact, 0, 720))
574  .Times(1);
575  EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindStylus,
576  kDefaultPointerDeviceId, 0))
577  .Times(1);
578  EXPECT_CALL(delegate,
579  OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindStylus,
580  kDefaultPointerDeviceId, 0, 0, 720, 0))
581  .Times(1);
582 
583  UINT32 pointerId = 1;
584  WPARAM wparam = static_cast<WPARAM>(pointerId);
585  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 10,
586  10);
587  InjectPointerMessageWithClientPoint(win32window, WM_POINTERUP, wparam, 10,
588  10);
589  InjectPointerMessageWithClientPoint(win32window, WM_POINTERUPDATE, wparam, 10,
590  10);
591 }

◆ TEST_F() [91/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusPointerDown   
)

Definition at line 291 of file flutter_window_unittests.cc.

291  {
292  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
293 
294  // Set up expectations for the mock
295  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
296  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
297  if (pointer_info != nullptr) {
298  pointer_info->pointerType = PT_PEN;
299  pointer_info->pointerId = pointer_id;
300  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
301  }
302  return TRUE;
303  });
304 
305  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
306  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
307  if (pen_info != nullptr) {
308  pen_info->pressure = 720; // Non-zero pressure for contact events
309  pen_info->rotation = 10;
310  pen_info->penFlags = 0;
311  }
312  return TRUE;
313  });
314 
315  POINTER_INFO test_pointer_info = {};
316  BOOL result = mock_proc_table->GetPointerInfo(1, &test_pointer_info);
317 
318  MockFlutterWindow win32window(100, 100, mock_proc_table);
319  MockWindowBindingHandlerDelegate delegate;
320 
321  win32window.SetView(&delegate);
322 
323  EXPECT_CALL(delegate,
324  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
325  kDefaultPointerDeviceId,
326  kFlutterPointerButtonStylusContact, 10, 720))
327  .Times(1);
328 
329  UINT32 pointerId = 1;
330  WPARAM wparam = static_cast<WPARAM>(pointerId);
331  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 10,
332  10);
333 }

◆ TEST_F() [92/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusPointerHover   
)

Definition at line 464 of file flutter_window_unittests.cc.

464  {
465  // Test that WM_POINTERUPDATE without POINTER_FLAG_INCONTACT (hover) is
466  // handled
467  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
468 
469  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
470  .WillOnce([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
471  if (pointer_info != nullptr) {
472  pointer_info->pointerId = 1;
473  pointer_info->pointerType = PT_PEN;
474  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
475  pointer_info->ptPixelLocation.x = 45;
476  pointer_info->ptPixelLocation.y = 50;
477  }
478  return TRUE;
479  })
480  .WillOnce([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
481  if (pointer_info != nullptr) {
482  pointer_info->pointerId = 1;
483  pointer_info->pointerType = PT_PEN;
484  // No POINTER_FLAG_INCONTACT - this simulates a hover event
485  pointer_info->pointerFlags = POINTER_FLAG_UPDATE;
486  pointer_info->ptPixelLocation.x = 45;
487  pointer_info->ptPixelLocation.y = 50;
488  }
489  return TRUE;
490  });
491 
492  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
493  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
494  if (pen_info != nullptr) {
495  pen_info->pressure = 0;
496  pen_info->rotation = 0;
497  pen_info->penFlags = 0;
498  }
499  return TRUE;
500  });
501 
502  MockFlutterWindow win32window(100, 100, mock_proc_table);
503  MockWindowBindingHandlerDelegate delegate;
504  win32window.SetView(&delegate);
505 
506  // First establish the pointer with WM_POINTERDOWN
507  EXPECT_CALL(delegate,
508  OnPointerDown(45, 50, kFlutterPointerDeviceKindStylus, 0,
509  kFlutterPointerButtonStylusContact, 0, 0))
510  .Times(1);
511 
512  UINT32 pointerId = 1;
513  WPARAM wparam = static_cast<WPARAM>(pointerId);
514  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 45,
515  50);
516 
517  // Now expect OnPointerMove to be called for hover events
518  EXPECT_CALL(delegate, OnPointerMove(45, 50, kFlutterPointerDeviceKindStylus,
519  0, 0, 0, 0, 0))
520  .Times(1);
521 
522  // Inject WM_POINTERUPDATE message (hover event)
523  InjectPointerMessageWithClientPoint(win32window, WM_POINTERUPDATE, wparam, 45,
524  50);
525 }

◆ TEST_F() [93/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusPointerLeave   
)

Definition at line 427 of file flutter_window_unittests.cc.

427  {
428  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
429 
430  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
431  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
432  if (pointer_info != nullptr) {
433  pointer_info->pointerType = PT_PEN;
434  pointer_info->pointerId = pointer_id;
435  pointer_info->pointerFlags = POINTER_FLAG_UP;
436  }
437  return TRUE;
438  });
439 
440  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
441  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
442  if (pen_info != nullptr) {
443  pen_info->pressure = 720;
444  pen_info->rotation = 0;
445  pen_info->penFlags = 0;
446  }
447  return TRUE;
448  });
449 
450  MockFlutterWindow win32window(100, 100, mock_proc_table);
451  MockWindowBindingHandlerDelegate delegate;
452  win32window.SetView(&delegate);
453 
454  EXPECT_CALL(delegate, OnPointerLeave(35, 40, kFlutterPointerDeviceKindStylus,
455  kDefaultPointerDeviceId))
456  .Times(1);
457 
458  UINT32 pointerId = 1;
459  WPARAM wparam = static_cast<WPARAM>(pointerId);
460  InjectPointerMessageWithClientPoint(win32window, WM_POINTERLEAVE, wparam, 35,
461  40);
462 }

◆ TEST_F() [94/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusPointerMove   
)

Definition at line 335 of file flutter_window_unittests.cc.

335  {
336  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
337 
338  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
339  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
340  if (pointer_info != nullptr) {
341  pointer_info->pointerType = PT_PEN;
342  pointer_info->pointerId = pointer_id;
343  pointer_info->pointerFlags =
344  POINTER_FLAG_INCONTACT | POINTER_FLAG_UPDATE;
345  }
346  return TRUE;
347  });
348 
349  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
350  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
351  if (pen_info != nullptr) {
352  pen_info->pressure = 720; // Non-zero pressure for contact events
353  pen_info->rotation = 10; // This is PRE-transformation to radians.
354  pen_info->penFlags = 0;
355  }
356  return TRUE;
357  });
358 
359  MockFlutterWindow win32window(100, 100, mock_proc_table);
360  MockWindowBindingHandlerDelegate delegate;
361  win32window.SetView(&delegate);
362 
363  EXPECT_CALL(delegate,
364  OnPointerMove(15, 20, kFlutterPointerDeviceKindStylus,
365  kDefaultPointerDeviceId,
366  kFlutterPointerButtonStylusContact, 10, 720, 0))
367  .Times(1);
368 
369  UINT32 pointerId = 1;
370  WPARAM wparam = static_cast<WPARAM>(pointerId);
371  InjectPointerMessageWithClientPoint(win32window, WM_POINTERUPDATE, wparam, 15,
372  20);
373 }

◆ TEST_F() [95/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnStylusPointerUp   
)

Definition at line 375 of file flutter_window_unittests.cc.

375  {
376  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
377 
378  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
379  .WillOnce([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
380  if (pointer_info != nullptr) {
381  pointer_info->pointerType = PT_PEN;
382  pointer_info->pointerId = pointer_id;
383  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT;
384  }
385  return TRUE;
386  })
387  .WillOnce([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
388  if (pointer_info != nullptr) {
389  pointer_info->pointerType = PT_PEN;
390  pointer_info->pointerId = pointer_id;
391  pointer_info->pointerFlags = POINTER_FLAG_UP;
392  }
393  return TRUE;
394  });
395 
396  EXPECT_CALL(*mock_proc_table, GetPointerPenInfo(_, _))
397  .WillRepeatedly([](UINT32 pointer_id, POINTER_PEN_INFO* pen_info) {
398  if (pen_info != nullptr) {
399  pen_info->pressure = 720;
400  pen_info->rotation = 0;
401  pen_info->penFlags = 0;
402  }
403  return TRUE;
404  });
405 
406  MockFlutterWindow win32window(100, 100, mock_proc_table);
407  MockWindowBindingHandlerDelegate delegate;
408  win32window.SetView(&delegate);
409 
410  EXPECT_CALL(delegate,
411  OnPointerDown(25, 30, kFlutterPointerDeviceKindStylus,
412  kDefaultPointerDeviceId,
413  kFlutterPointerButtonStylusContact, 0, 720))
414  .Times(1);
415  EXPECT_CALL(delegate, OnPointerUp(25, 30, kFlutterPointerDeviceKindStylus,
416  kDefaultPointerDeviceId, 0))
417  .Times(1);
418 
419  UINT32 pointerId = 1;
420  WPARAM wparam = static_cast<WPARAM>(pointerId);
421  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 25,
422  30);
423  InjectPointerMessageWithClientPoint(win32window, WM_POINTERUP, wparam, 25,
424  30);
425 }

◆ TEST_F() [96/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnThemeChange   
)

Definition at line 970 of file flutter_window_unittests.cc.

970  {
971  MockFlutterWindow win32window;
972  MockWindowBindingHandlerDelegate delegate;
973  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
974  win32window.SetView(&delegate);
975 
976  EXPECT_CALL(delegate, OnHighContrastChanged).Times(1);
977 
978  win32window.InjectWindowMessage(WM_THEMECHANGED, 0, 0);
979 }

◆ TEST_F() [97/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnTouchPointerDown   
)

Definition at line 856 of file flutter_window_unittests.cc.

856  {
857  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
858 
859  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
860  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
861  if (pointer_info != nullptr) {
862  pointer_info->pointerType = PT_TOUCH;
863  pointer_info->pointerId = pointer_id;
864  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT |
865  POINTER_FLAG_FIRSTBUTTON |
866  POINTER_FLAG_DOWN;
867  }
868  return TRUE;
869  });
870 
871  MockFlutterWindow win32window(100, 100, mock_proc_table);
872  MockWindowBindingHandlerDelegate delegate;
873  win32window.SetView(&delegate);
874 
875  EXPECT_CALL(delegate, OnPointerDown(55, 60, kFlutterPointerDeviceKindTouch,
876  kDefaultPointerDeviceId,
877  kFlutterPointerButtonMousePrimary, 0, 0))
878  .Times(1);
879 
880  UINT32 pointerId = 1;
881  WPARAM wparam = static_cast<WPARAM>(pointerId);
882  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 55,
883  60);
884 }

◆ TEST_F() [98/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
OnWindowRepaint   
)

Definition at line 959 of file flutter_window_unittests.cc.

959  {
960  MockFlutterWindow win32window;
961  MockWindowBindingHandlerDelegate delegate;
962  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
963  win32window.SetView(&delegate);
964 
965  EXPECT_CALL(delegate, OnWindowRepaint()).Times(1);
966 
967  win32window.InjectWindowMessage(WM_PAINT, 0, 0);
968 }

◆ TEST_F() [99/239]

flutter::testing::TEST_F ( FlutterWindowTest  ,
PointerMessageScreenCoordinatesAreConvertedToClient   
)

Definition at line 886 of file flutter_window_unittests.cc.

886  {
887  constexpr int kClientX = 15;
888  constexpr int kClientY = 20;
889 
890  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
891 
892  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
893  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
894  if (pointer_info != nullptr) {
895  pointer_info->pointerType = PT_TOUCH;
896  pointer_info->pointerId = pointer_id;
897  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT |
898  POINTER_FLAG_FIRSTBUTTON |
899  POINTER_FLAG_DOWN;
900  }
901  return TRUE;
902  });
903 
904  MockFlutterWindow win32window(100, 100, mock_proc_table);
905  MockWindowBindingHandlerDelegate delegate;
906  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
907  EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
908  win32window.SetView(&delegate);
909 
910  HWND parent_window =
911  CreateWindowEx(0, L"STATIC", L"", WS_POPUP, 100, 100, 300, 300, nullptr,
912  nullptr, GetModuleHandle(nullptr), nullptr);
913  ASSERT_NE(parent_window, nullptr);
914 
915  HWND flutter_window = win32window.FlutterWindow::GetWindowHandle();
916  ASSERT_NE(flutter_window, nullptr);
917  ASSERT_NE(SetParent(flutter_window, parent_window), nullptr);
918  ASSERT_TRUE(SetWindowPos(flutter_window, nullptr, 25, 35, 100, 100,
919  SWP_NOZORDER | SWP_NOACTIVATE));
920 
921  POINT pointer_point = {kClientX, kClientY};
922  ASSERT_TRUE(ClientToScreen(flutter_window, &pointer_point));
923 
924  EXPECT_CALL(delegate,
925  OnPointerDown(kClientX, kClientY, kFlutterPointerDeviceKindTouch,
926  kDefaultPointerDeviceId,
927  kFlutterPointerButtonMousePrimary, 0, 0))
928  .Times(1);
929 
930  win32window.InjectWindowMessage(WM_POINTERDOWN, /*wparam=*/1,
931  MAKELPARAM(pointer_point.x, pointer_point.y));
932 
933  EXPECT_NE(SetParent(flutter_window, HWND_MESSAGE), nullptr);
934  DestroyWindow(parent_window);
935 }

◆ TEST_F() [100/239]

flutter::testing::TEST_F ( KeyboardTest  ,
AltGrModifiedKey   
)

Definition at line 1278 of file keyboard_unittests.cc.

1278  {
1279  KeyboardTester tester{GetContext()};
1280  tester.Responding(false);
1281 
1282  // German Keyboard layout
1283 
1284  // Press AltGr, which Win32 precedes with a ContrlLeft down.
1285  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1286  KeyStateChange{VK_LCONTROL, true, true},
1287  WmKeyDownInfo{VK_LCONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1288  kWmResultZero),
1289  KeyStateChange{VK_RMENU, true, true},
1290  WmKeyDownInfo{VK_MENU, kScanCodeAlt, kExtended, kWasUp}.Build(
1291  kWmResultZero)});
1292 
1293  EXPECT_EQ(tester.key_calls.size(), 2);
1294  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1295  kPhysicalControlLeft, kLogicalControlLeft, "",
1296  kNotSynthesized);
1297  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeDown,
1298  kPhysicalAltRight, kLogicalAltRight, "",
1299  kNotSynthesized);
1300  tester.clear_key_calls();
1301  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1302 
1303  // Press Q
1304  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1305  WmKeyDownInfo{kVirtualKeyQ, kScanCodeKeyQ, kNotExtended, kWasUp}.Build(
1306  kWmResultZero),
1307  WmCharInfo{'@', kScanCodeKeyQ, kNotExtended, kWasUp}.Build(
1308  kWmResultZero)});
1309 
1310  EXPECT_EQ(tester.key_calls.size(), 2);
1311  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1312  kPhysicalKeyQ, kLogicalKeyQ, "@", kNotSynthesized);
1313  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"@");
1314  tester.clear_key_calls();
1315  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1316 
1317  // Release Q
1318  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1319  WmKeyUpInfo{kVirtualKeyQ, kScanCodeKeyQ, kNotExtended}.Build(
1320  kWmResultZero)});
1321 
1322  EXPECT_EQ(tester.key_calls.size(), 1);
1323  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1324  kPhysicalKeyQ, kLogicalKeyQ, "", kNotSynthesized);
1325  tester.clear_key_calls();
1326  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1327 
1328  // Release AltGr. Win32 doesn't dispatch ControlLeft up. Instead Flutter will
1329  // forge one. The AltGr is a system key, therefore will be handled by Win32's
1330  // default WndProc.
1331  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1332  KeyStateChange{VK_LCONTROL, false, true},
1333  ExpectForgedMessage{
1334  WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1335  kWmResultZero)},
1336  KeyStateChange{VK_RMENU, false, true},
1337  WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kExtended}.Build(
1338  kWmResultDefault)});
1339 
1340  EXPECT_EQ(tester.key_calls.size(), 2);
1341  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1342  kPhysicalControlLeft, kLogicalControlLeft, "",
1343  kNotSynthesized);
1344  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
1345  kPhysicalAltRight, kLogicalAltRight, "",
1346  kNotSynthesized);
1347  tester.clear_key_calls();
1348  // The sys key up must not be redispatched. The forged ControlLeft up will.
1349  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1350 }
#define EXPECT_CALL_IS_TEXT(_key_call, u16_string)
#define EXPECT_CALL_IS_EVENT(_key_call, _type, _physical, _logical, _character, _synthesized)

References EXPECT_CALL_IS_EVENT, and EXPECT_CALL_IS_TEXT.

◆ TEST_F() [101/239]

flutter::testing::TEST_F ( KeyboardTest  ,
AltGrTwice   
)

Definition at line 1365 of file keyboard_unittests.cc.

1365  {
1366  KeyboardTester tester{GetContext()};
1367  tester.Responding(false);
1368 
1369  // 1. AltGr down.
1370 
1371  // The key down event causes a ControlLeft down and a AltRight (extended
1372  // AltLeft) down.
1373  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1374  KeyStateChange{VK_LCONTROL, true, true},
1375  WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1376  kWmResultZero),
1377  KeyStateChange{VK_RMENU, true, true},
1378  WmKeyDownInfo{VK_MENU, kScanCodeAlt, kExtended, kWasUp}.Build(
1379  kWmResultZero)});
1380 
1381  EXPECT_EQ(tester.key_calls.size(), 2);
1382  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1383  kPhysicalControlLeft, kLogicalControlLeft, "",
1384  kNotSynthesized);
1385  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeDown,
1386  kPhysicalAltRight, kLogicalAltRight, "",
1387  kNotSynthesized);
1388  tester.clear_key_calls();
1389  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1390 
1391  // 2. AltGr up.
1392 
1393  // The key up event only causes a AltRight (extended AltLeft) up.
1394  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1395  KeyStateChange{VK_LCONTROL, false, true},
1396  ExpectForgedMessage{
1397  WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1398  kWmResultZero)},
1399  KeyStateChange{VK_RMENU, false, true},
1400  WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kExtended}.Build(
1401  kWmResultDefault)});
1402  EXPECT_EQ(tester.key_calls.size(), 2);
1403  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1404  kPhysicalControlLeft, kLogicalControlLeft, "",
1405  kNotSynthesized);
1406  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
1407  kPhysicalAltRight, kLogicalAltRight, "",
1408  kNotSynthesized);
1409  tester.clear_key_calls();
1410  // The sys key up must not be redispatched. The forged ControlLeft up will.
1411  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1412 
1413  // 3. AltGr down (or: ControlLeft down then AltRight down.)
1414 
1415  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1416  KeyStateChange{VK_LCONTROL, true, false},
1417  WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1418  kWmResultZero),
1419  KeyStateChange{VK_RMENU, true, true},
1420  WmKeyDownInfo{VK_MENU, kScanCodeAlt, kExtended, kWasUp}.Build(
1421  kWmResultZero)});
1422 
1423  EXPECT_EQ(tester.key_calls.size(), 2);
1424  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1425  kPhysicalControlLeft, kLogicalControlLeft, "",
1426  kNotSynthesized);
1427  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeDown,
1428  kPhysicalAltRight, kLogicalAltRight, "",
1429  kNotSynthesized);
1430  tester.clear_key_calls();
1431  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1432 
1433  // 4. AltGr up.
1434 
1435  // The key up event only causes a AltRight (extended AltLeft) up.
1436  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1437  KeyStateChange{VK_LCONTROL, false, false},
1438  ExpectForgedMessage{
1439  WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1440  kWmResultZero)},
1441  KeyStateChange{VK_RMENU, false, false},
1442  WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kExtended}.Build(
1443  kWmResultDefault)});
1444  EXPECT_EQ(tester.key_calls.size(), 2);
1445  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1446  kPhysicalControlLeft, kLogicalControlLeft, "",
1447  kNotSynthesized);
1448  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
1449  kPhysicalAltRight, kLogicalAltRight, "",
1450  kNotSynthesized);
1451  tester.clear_key_calls();
1452  // The sys key up must not be redispatched. The forged ControlLeft up will.
1453  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1454 
1455  // 5. For key sequence 2: a real ControlLeft up.
1456  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1457  WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1458  kWmResultZero)});
1459  EXPECT_EQ(tester.key_calls.size(), 1);
1460  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown, 0, 0, "",
1461  kNotSynthesized);
1462  tester.clear_key_calls();
1463  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
1464 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [102/239]

flutter::testing::TEST_F ( KeyboardTest  ,
AltLeftUnhandled   
)

Definition at line 841 of file keyboard_unittests.cc.

841  {
842  KeyboardTester tester{GetContext()};
843  tester.Responding(false);
844 
845  // US Keyboard layout
846 
847  // Press AltLeft. AltLeft is a SysKeyDown event.
848  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
849  KeyStateChange{VK_LMENU, true, false},
850  WmSysKeyDownInfo{VK_MENU, kScanCodeAlt, kNotExtended, kWasUp}.Build(
851  kWmResultDefault)}); // Always pass to the default WndProc.
852 
853  EXPECT_EQ(tester.key_calls.size(), 1);
854  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
855  kPhysicalAltLeft, kLogicalAltLeft, "", kNotSynthesized);
856  tester.clear_key_calls();
857  // Don't redispatch sys messages.
858  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
859 
860  // Release AltLeft. AltLeft is a SysKeyUp event.
861  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
862  KeyStateChange{VK_LMENU, false, true},
863  WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kNotExtended}.Build(
864  kWmResultDefault)}); // Always pass to the default WndProc.
865 
866  EXPECT_EQ(tester.key_calls.size(), 1);
867  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
868  kPhysicalAltLeft, kLogicalAltLeft, "", kNotSynthesized);
869  tester.clear_key_calls();
870  // Don't redispatch sys messages.
871  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
872 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [103/239]

flutter::testing::TEST_F ( KeyboardTest  ,
AltRightUnhandled   
)

Definition at line 874 of file keyboard_unittests.cc.

874  {
875  KeyboardTester tester{GetContext()};
876  tester.Responding(false);
877 
878  // US Keyboard layout
879 
880  // Press AltRight. AltRight is a SysKeyDown event.
881  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
882  KeyStateChange{VK_RMENU, true, false},
883  WmSysKeyDownInfo{VK_MENU, kScanCodeAlt, kExtended, kWasUp}.Build(
884  kWmResultDefault)}); // Always pass to the default WndProc.
885 
886  EXPECT_EQ(tester.key_calls.size(), 1);
887  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
888  kPhysicalAltRight, kLogicalAltRight, "",
889  kNotSynthesized);
890  tester.clear_key_calls();
891  // Don't redispatch sys messages.
892  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
893 
894  // Release AltRight. AltRight is a SysKeyUp event.
895  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
896  KeyStateChange{VK_RMENU, false, true},
897  WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kExtended}.Build(
898  kWmResultDefault)}); // Always pass to the default WndProc.
899 
900  EXPECT_EQ(tester.key_calls.size(), 1);
901  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
902  kPhysicalAltRight, kLogicalAltRight, "",
903  kNotSynthesized);
904  tester.clear_key_calls();
905  // Don't redispatch sys messages.
906  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
907 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [104/239]

flutter::testing::TEST_F ( KeyboardTest  ,
ArrowLeftHandled   
)

Definition at line 635 of file keyboard_unittests.cc.

635  {
636  KeyboardTester tester{GetContext()};
637  tester.Responding(true);
638 
639  // US Keyboard layout
640 
641  // Press ArrowLeft
642  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
643  WmKeyDownInfo{VK_LEFT, kScanCodeArrowLeft, kExtended, kWasUp}.Build(
644  kWmResultZero)});
645 
646  EXPECT_EQ(tester.key_calls.size(), 1);
647  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
648  kPhysicalArrowLeft, kLogicalArrowLeft, "",
649  kNotSynthesized);
650  tester.clear_key_calls();
651  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
652 
653  // Release ArrowLeft
654  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
655  WmKeyUpInfo{VK_LEFT, kScanCodeArrowLeft, kExtended}.Build(
656  kWmResultZero)});
657 
658  EXPECT_EQ(tester.key_calls.size(), 1);
659  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
660  kPhysicalArrowLeft, kLogicalArrowLeft, "",
661  kNotSynthesized);
662  tester.clear_key_calls();
663  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
664 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [105/239]

flutter::testing::TEST_F ( KeyboardTest  ,
ArrowLeftUnhandled   
)

Definition at line 666 of file keyboard_unittests.cc.

666  {
667  KeyboardTester tester{GetContext()};
668  tester.Responding(false);
669 
670  // US Keyboard layout
671 
672  // Press ArrowLeft
673  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
674  WmKeyDownInfo{VK_LEFT, kScanCodeArrowLeft, kExtended, kWasUp}.Build(
675  kWmResultZero)});
676 
677  EXPECT_EQ(tester.key_calls.size(), 1);
678  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
679  kPhysicalArrowLeft, kLogicalArrowLeft, "",
680  kNotSynthesized);
681  tester.clear_key_calls();
682  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
683 
684  // Release ArrowLeft
685  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
686  WmKeyUpInfo{VK_LEFT, kScanCodeArrowLeft, kExtended}.Build(
687  kWmResultZero)});
688 
689  EXPECT_EQ(tester.key_calls.size(), 1);
690  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
691  kPhysicalArrowLeft, kLogicalArrowLeft, "",
692  kNotSynthesized);
693  tester.clear_key_calls();
694  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
695 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [106/239]

flutter::testing::TEST_F ( KeyboardTest  ,
CtrlLeftDigit1   
)

Definition at line 1188 of file keyboard_unittests.cc.

1188  {
1189  KeyboardTester tester{GetContext()};
1190  tester.Responding(false);
1191 
1192  // US Keyboard layout
1193 
1194  // Press ControlLeft
1195  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1196  KeyStateChange{VK_LCONTROL, true, true},
1197  WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1198  kWmResultZero)});
1199 
1200  EXPECT_EQ(tester.key_calls.size(), 1);
1201  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1202  kPhysicalControlLeft, kLogicalControlLeft, "",
1203  kNotSynthesized);
1204  tester.clear_key_calls();
1205  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1206 
1207  // Press 1
1208  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1209  WmKeyDownInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended, kWasUp}
1210  .Build(kWmResultZero)});
1211 
1212  EXPECT_EQ(tester.key_calls.size(), 1);
1213  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1214  kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1215  tester.clear_key_calls();
1216  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1217 
1218  // Release 1
1219  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1220  WmKeyUpInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended}.Build(
1221  kWmResultZero)});
1222 
1223  EXPECT_EQ(tester.key_calls.size(), 1);
1224  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1225  kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1226  tester.clear_key_calls();
1227  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1228 
1229  // Release ControlLeft
1230  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1231  KeyStateChange{VK_LCONTROL, false, true},
1232  WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1233  kWmResultZero)});
1234 
1235  EXPECT_EQ(tester.key_calls.size(), 1);
1236  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1237  kPhysicalControlLeft, kLogicalControlLeft, "",
1238  kNotSynthesized);
1239  tester.clear_key_calls();
1240  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1241 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [107/239]

flutter::testing::TEST_F ( KeyboardTest  ,
CtrlLeftKeyA   
)

Definition at line 1130 of file keyboard_unittests.cc.

1130  {
1131  KeyboardTester tester{GetContext()};
1132  tester.Responding(false);
1133 
1134  // US Keyboard layout
1135 
1136  // Press ControlLeft
1137  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1138  KeyStateChange{VK_LCONTROL, true, true},
1139  WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1140  kWmResultZero)});
1141 
1142  EXPECT_EQ(tester.key_calls.size(), 1);
1143  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1144  kPhysicalControlLeft, kLogicalControlLeft, "",
1145  kNotSynthesized);
1146  tester.clear_key_calls();
1147  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1148 
1149  // Press A
1150  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1151  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1152  kWmResultZero),
1153  WmCharInfo{0x01, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1154  kWmResultZero)});
1155 
1156  EXPECT_EQ(tester.key_calls.size(), 1);
1157  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1158  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
1159  tester.clear_key_calls();
1160  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1161 
1162  // Release A
1163  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1164  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
1165  kWmResultZero)});
1166 
1167  EXPECT_EQ(tester.key_calls.size(), 1);
1168  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1169  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
1170  tester.clear_key_calls();
1171  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1172 
1173  // Release ControlLeft
1174  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1175  KeyStateChange{VK_LCONTROL, false, true},
1176  WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1177  kWmResultZero)});
1178 
1179  EXPECT_EQ(tester.key_calls.size(), 1);
1180  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1181  kPhysicalControlLeft, kLogicalControlLeft, "",
1182  kNotSynthesized);
1183  tester.clear_key_calls();
1184  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1185 }

References EXPECT_CALL_IS_EVENT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [108/239]

flutter::testing::TEST_F ( KeyboardTest  ,
CtrlLeftUnhandled   
)

Definition at line 775 of file keyboard_unittests.cc.

775  {
776  KeyboardTester tester{GetContext()};
777  tester.Responding(false);
778 
779  // US Keyboard layout
780 
781  // Press CtrlLeft
782  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
783  KeyStateChange{VK_LCONTROL, true, false},
784  WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
785  kWmResultZero)});
786 
787  EXPECT_EQ(tester.key_calls.size(), 1);
788  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
789  kPhysicalControlLeft, kLogicalControlLeft, "",
790  kNotSynthesized);
791  tester.clear_key_calls();
792  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
793 
794  // Release CtrlLeft
795  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
796  KeyStateChange{VK_LCONTROL, false, true},
797  WmKeyUpInfo{VK_SHIFT, kScanCodeControl, kNotExtended}.Build(
798  kWmResultZero)});
799 
800  EXPECT_EQ(tester.key_calls.size(), 1);
801  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
802  kPhysicalControlLeft, kLogicalControlLeft, "",
803  kNotSynthesized);
804  tester.clear_key_calls();
805  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
806 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [109/239]

flutter::testing::TEST_F ( KeyboardTest  ,
CtrlRightUnhandled   
)

Definition at line 808 of file keyboard_unittests.cc.

808  {
809  KeyboardTester tester{GetContext()};
810  tester.Responding(false);
811 
812  // US Keyboard layout
813 
814  // Press CtrlRight
815  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
816  KeyStateChange{VK_RCONTROL, true, false},
817  WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kExtended, kWasUp}.Build(
818  kWmResultZero)});
819 
820  EXPECT_EQ(tester.key_calls.size(), 1);
821  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
822  kPhysicalControlRight, kLogicalControlRight, "",
823  kNotSynthesized);
824  tester.clear_key_calls();
825  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
826 
827  // Release CtrlRight
828  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
829  KeyStateChange{VK_RCONTROL, false, true},
830  WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kExtended}.Build(
831  kWmResultZero)});
832 
833  EXPECT_EQ(tester.key_calls.size(), 1);
834  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
835  kPhysicalControlRight, kLogicalControlRight, "",
836  kNotSynthesized);
837  tester.clear_key_calls();
838  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
839 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [110/239]

flutter::testing::TEST_F ( KeyboardTest  ,
DeadKeyThatCombines   
)

Definition at line 1468 of file keyboard_unittests.cc.

1468  {
1469  KeyboardTester tester{GetContext()};
1470  tester.Responding(false);
1471 
1472  tester.SetLayout(LayoutFrench);
1473 
1474  // Press ^¨ (US: Left bracket)
1475  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1476  WmKeyDownInfo{0xDD, kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1477  kWmResultZero),
1478  WmDeadCharInfo{'^', kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1479  kWmResultZero)});
1480 
1481  EXPECT_EQ(tester.key_calls.size(), 1);
1482  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1483  kPhysicalBracketLeft, kLogicalBracketRight, "^",
1484  kNotSynthesized);
1485  tester.clear_key_calls();
1486  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1487 
1488  // Release ^¨
1489  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1490  WmKeyUpInfo{0xDD, kScanCodeBracketLeft, kNotExtended}.Build(
1491  kWmResultZero)});
1492 
1493  EXPECT_EQ(tester.key_calls.size(), 1);
1494  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1495  kPhysicalBracketLeft, kLogicalBracketRight, "",
1496  kNotSynthesized);
1497  tester.clear_key_calls();
1498  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1499 
1500  // Press E
1501  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1502  WmKeyDownInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1503  kWmResultZero),
1504  WmCharInfo{0xEA, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1505  kWmResultZero)});
1506 
1507  EXPECT_EQ(tester.key_calls.size(), 2);
1508  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1509  kPhysicalKeyE, kLogicalKeyE, "ê", kNotSynthesized);
1510  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"ê");
1511  tester.clear_key_calls();
1512  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1513 
1514  // Release E
1515  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1516  WmKeyUpInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended}.Build(
1517  kWmResultZero)});
1518 
1519  EXPECT_EQ(tester.key_calls.size(), 1);
1520  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1521  kPhysicalKeyE, kLogicalKeyE, "", kNotSynthesized);
1522  tester.clear_key_calls();
1523  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1524 }

References EXPECT_CALL_IS_EVENT, and EXPECT_CALL_IS_TEXT.

◆ TEST_F() [111/239]

flutter::testing::TEST_F ( KeyboardTest  ,
DeadKeyThatDoesNotCombine   
)

Definition at line 1612 of file keyboard_unittests.cc.

1612  {
1613  KeyboardTester tester{GetContext()};
1614  tester.Responding(false);
1615 
1616  tester.SetLayout(LayoutFrench);
1617 
1618  // Press ^¨ (US: Left bracket)
1619  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1620  WmKeyDownInfo{0xDD, kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1621  kWmResultZero),
1622  WmDeadCharInfo{'^', kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1623  kWmResultZero)});
1624 
1625  EXPECT_EQ(tester.key_calls.size(), 1);
1626  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1627  kPhysicalBracketLeft, kLogicalBracketRight, "^",
1628  kNotSynthesized);
1629  tester.clear_key_calls();
1630  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1631 
1632  // Release ^¨
1633  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1634  WmKeyUpInfo{0xDD, kScanCodeBracketLeft, kNotExtended}.Build(
1635  kWmResultZero)});
1636 
1637  EXPECT_EQ(tester.key_calls.size(), 1);
1638  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1639  kPhysicalBracketLeft, kLogicalBracketRight, "",
1640  kNotSynthesized);
1641  tester.clear_key_calls();
1642  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1643 
1644  // Press 1
1645  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1646  WmKeyDownInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended, kWasUp}
1647  .Build(kWmResultZero),
1648  WmCharInfo{'^', kScanCodeDigit1, kNotExtended, kWasUp}.Build(
1649  kWmResultZero),
1650  WmCharInfo{'&', kScanCodeDigit1, kNotExtended, kWasUp}.Build(
1651  kWmResultZero)});
1652 
1653  EXPECT_EQ(tester.key_calls.size(), 3);
1654  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1655  kPhysicalDigit1, kLogicalDigit1, "^", kNotSynthesized);
1656  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"^");
1657  EXPECT_CALL_IS_TEXT(tester.key_calls[2], u"&");
1658  tester.clear_key_calls();
1659  // TODO(dkwingsmt): This count should probably be 3. Currently the '^'
1660  // message is redispatched due to being part of the KeyDown session, which is
1661  // not handled by the framework, while the '&' message is not redispatched
1662  // for being a standalone message. We should resolve this inconsistency.
1663  // https://github.com/flutter/flutter/issues/98306
1664  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1665 
1666  // Release 1
1667  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1668  WmKeyUpInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended}.Build(
1669  kWmResultZero)});
1670 
1671  EXPECT_EQ(tester.key_calls.size(), 1);
1672  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1673  kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1674  tester.clear_key_calls();
1675  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1676 }

References EXPECT_CALL_IS_EVENT, and EXPECT_CALL_IS_TEXT.

◆ TEST_F() [112/239]

flutter::testing::TEST_F ( KeyboardTest  ,
DeadKeyTwiceThenLetter   
)

Definition at line 1681 of file keyboard_unittests.cc.

1681  {
1682  KeyboardTester tester{GetContext()};
1683  tester.Responding(false);
1684 
1685  // US INTL layout.
1686 
1687  // Press `
1688  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1689  WmKeyDownInfo{0xC0, kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1690  kWmResultZero),
1691  WmDeadCharInfo{'`', kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1692  kWmResultZero)});
1693 
1694  EXPECT_EQ(tester.key_calls.size(), 1);
1695  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1696  kPhysicalBackquote, kLogicalBackquote, "`",
1697  kNotSynthesized);
1698  tester.clear_key_calls();
1699  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1700 
1701  // Release `
1702  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1703  WmKeyUpInfo{0xC0, kScanCodeBackquote, kNotExtended}.Build(
1704  kWmResultZero)});
1705 
1706  EXPECT_EQ(tester.key_calls.size(), 1);
1707  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1708  kPhysicalBackquote, kLogicalBackquote, "",
1709  kNotSynthesized);
1710  tester.clear_key_calls();
1711  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1712 
1713  // Press ` again.
1714  // The response should be slow.
1715  std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
1716  tester.LateResponding(
1717  [&recorded_callbacks](
1718  const FlutterKeyEvent* event,
1719  MockKeyResponseController::ResponseCallback callback) {
1720  recorded_callbacks.push_back(callback);
1721  });
1722 
1723  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1724  WmKeyDownInfo{0xC0, kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1725  kWmResultZero),
1726  WmCharInfo{'`', kScanCodeBackquote, kNotExtended, kWasUp, kBeingReleased,
1727  kNoContext, 1, /*bit25*/ true}
1728  .Build(kWmResultZero),
1729  WmCharInfo{'`', kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1730  kWmResultZero)});
1731 
1732  EXPECT_EQ(recorded_callbacks.size(), 1);
1733  EXPECT_EQ(tester.key_calls.size(), 1);
1734  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1735  kPhysicalBackquote, kLogicalBackquote, "`",
1736  kNotSynthesized);
1737  tester.clear_key_calls();
1738  // Key down event responded with false.
1739  recorded_callbacks.front()(false);
1740  EXPECT_EQ(tester.key_calls.size(), 2);
1741  EXPECT_CALL_IS_TEXT(tester.key_calls[0], u"`");
1742  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"`");
1743  tester.clear_key_calls();
1744  // TODO(dkwingsmt): This count should probably be 3. See the comment above
1745  // that is marked with the same issue.
1746  // https://github.com/flutter/flutter/issues/98306
1747  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1748 
1749  tester.Responding(false);
1750 
1751  // Release `
1752  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1753  WmKeyUpInfo{0xC0, kScanCodeBackquote, kNotExtended}.Build(
1754  kWmResultZero)});
1755 
1756  EXPECT_EQ(tester.key_calls.size(), 1);
1757  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1758  kPhysicalBackquote, kLogicalBackquote, "",
1759  kNotSynthesized);
1760  tester.clear_key_calls();
1761  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1762 }

References callback, EXPECT_CALL_IS_EVENT, and EXPECT_CALL_IS_TEXT.

◆ TEST_F() [113/239]

flutter::testing::TEST_F ( KeyboardTest  ,
DeadKeyWithoutDeadMaskThatCombines   
)

Definition at line 1531 of file keyboard_unittests.cc.

1531  {
1532  KeyboardTester tester{GetContext()};
1533  tester.Responding(false);
1534 
1535  // Press ShiftLeft
1536  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1537  KeyStateChange{VK_LSHIFT, true, true},
1538  WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
1539  kWmResultZero)});
1540 
1541  EXPECT_EQ(tester.key_calls.size(), 1);
1542  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1543  kPhysicalShiftLeft, kLogicalShiftLeft, "",
1544  kNotSynthesized);
1545  tester.clear_key_calls();
1546  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1547 
1548  // Press 6^
1549  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1550  WmKeyDownInfo{'6', kScanCodeDigit6, kNotExtended, kWasUp}.Build(
1551  kWmResultZero),
1552  WmDeadCharInfo{'^', kScanCodeDigit6, kNotExtended, kWasUp}.Build(
1553  kWmResultZero)});
1554 
1555  EXPECT_EQ(tester.key_calls.size(), 1);
1556  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1557  kPhysicalDigit6, kLogicalDigit6, "6", kNotSynthesized);
1558  tester.clear_key_calls();
1559  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1560 
1561  // Release 6^
1562  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1563  WmKeyUpInfo{'6', kScanCodeDigit6, kNotExtended}.Build(kWmResultZero)});
1564 
1565  EXPECT_EQ(tester.key_calls.size(), 1);
1566  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1567  kPhysicalDigit6, kLogicalDigit6, "", kNotSynthesized);
1568  tester.clear_key_calls();
1569  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1570 
1571  // Release ShiftLeft
1572  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1573  KeyStateChange{VK_LSHIFT, false, true},
1574  WmKeyUpInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended}.Build(
1575  kWmResultZero)});
1576 
1577  EXPECT_EQ(tester.key_calls.size(), 1);
1578  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1579  kPhysicalShiftLeft, kLogicalShiftLeft, "",
1580  kNotSynthesized);
1581  tester.clear_key_calls();
1582  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1583 
1584  // Press E
1585  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1586  WmKeyDownInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1587  kWmResultZero),
1588  WmCharInfo{0xEA, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1589  kWmResultZero)});
1590 
1591  EXPECT_EQ(tester.key_calls.size(), 2);
1592  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1593  kPhysicalKeyE, kLogicalKeyE, "ê", kNotSynthesized);
1594  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"ê");
1595  tester.clear_key_calls();
1596  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1597 
1598  // Release E
1599  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1600  WmKeyUpInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended}.Build(
1601  kWmResultZero)});
1602 
1603  EXPECT_EQ(tester.key_calls.size(), 1);
1604  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1605  kPhysicalKeyE, kLogicalKeyE, "", kNotSynthesized);
1606  tester.clear_key_calls();
1607  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1608 }

References EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, and flutter::kScanCodeShiftLeft.

◆ TEST_F() [114/239]

flutter::testing::TEST_F ( KeyboardTest  ,
Digit1OnFrenchLayout   
)

Definition at line 1245 of file keyboard_unittests.cc.

1245  {
1246  KeyboardTester tester{GetContext()};
1247  tester.Responding(false);
1248 
1249  tester.SetLayout(LayoutFrench);
1250 
1251  // Press 1
1252  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1253  WmKeyDownInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended, kWasUp}
1254  .Build(kWmResultZero),
1255  WmCharInfo{'&', kScanCodeDigit1, kNotExtended, kWasUp}.Build(
1256  kWmResultZero)});
1257 
1258  EXPECT_EQ(tester.key_calls.size(), 2);
1259  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1260  kPhysicalDigit1, kLogicalDigit1, "&", kNotSynthesized);
1261  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"&");
1262  tester.clear_key_calls();
1263  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1264 
1265  // Release 1
1266  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1267  WmKeyUpInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended}.Build(
1268  kWmResultZero)});
1269 
1270  EXPECT_EQ(tester.key_calls.size(), 1);
1271  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1272  kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1273  tester.clear_key_calls();
1274  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1275 }

References EXPECT_CALL_IS_EVENT, and EXPECT_CALL_IS_TEXT.

◆ TEST_F() [115/239]

flutter::testing::TEST_F ( KeyboardTest  ,
DoubleCapsLock   
)

Definition at line 2504 of file keyboard_unittests.cc.

2504  {
2505  KeyboardTester tester{GetContext()};
2506  tester.Responding(false);
2507 
2508  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2509  WmKeyDownInfo{VK_CAPITAL, 0, kNotExtended}.Build(),
2510  WmKeyUpInfo{VK_CAPITAL, 0, kNotExtended}.Build()});
2511 
2512  tester.clear_key_calls();
2513 }

◆ TEST_F() [116/239]

flutter::testing::TEST_F ( KeyboardTest  ,
FreshKeyDownAfterMissedUpIsDelivered   
)

Definition at line 1036 of file keyboard_unittests.cc.

1036  {
1037  KeyboardTester tester{GetContext()};
1038  tester.Responding(true);
1039 
1040  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1041  WmKeyDownInfo{VK_RETURN, kScanCodeEnter, kNotExtended, kWasUp}.Build(
1042  kWmResultZero)});
1043 
1044  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1045  WmKeyDownInfo{VK_RETURN, kScanCodeEnter, kNotExtended, kWasUp}.Build(
1046  kWmResultZero)});
1047 
1048  ASSERT_EQ(tester.key_calls.size(), 3u);
1049  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1050  kPhysicalEnter, kLogicalEnter, "", kNotSynthesized);
1051  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
1052  kPhysicalEnter, kLogicalEnter, "", kSynthesized);
1053  EXPECT_CALL_IS_EVENT(tester.key_calls[2], kFlutterKeyEventTypeDown,
1054  kPhysicalEnter, kLogicalEnter, "", kNotSynthesized);
1055  tester.clear_key_calls();
1056 
1057  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1058  WmKeyUpInfo{VK_RETURN, kScanCodeEnter, kNotExtended}.Build(
1059  kWmResultZero)});
1060 
1061  ASSERT_EQ(tester.key_calls.size(), 1u);
1062  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1063  kPhysicalEnter, kLogicalEnter, "", kNotSynthesized);
1064  tester.clear_key_calls();
1065  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0u);
1066 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [117/239]

flutter::testing::TEST_F ( KeyboardTest  ,
ImeExtendedEventsAreIgnored   
)

Definition at line 2030 of file keyboard_unittests.cc.

2030  {
2031  KeyboardTester tester{GetContext()};
2032  tester.Responding(false);
2033 
2034  // US Keyboard layout.
2035 
2036  // There should be preceding key events to make the keyboard into IME mode.
2037  // Omit them in this test since they are not relavent.
2038 
2039  // Press CtrlRight in IME mode.
2040  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2041  KeyStateChange{VK_RCONTROL, true, false},
2042  WmKeyDownInfo{VK_PROCESSKEY, kScanCodeControl, kExtended, kWasUp}.Build(
2043  kWmResultZero)});
2044 
2045  EXPECT_EQ(tester.key_calls.size(), 1);
2046  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown, 0, 0, "",
2047  kNotSynthesized);
2048  tester.clear_key_calls();
2049  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2050 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [118/239]

flutter::testing::TEST_F ( KeyboardTest  ,
LowerCaseAHandled   
)

Definition at line 572 of file keyboard_unittests.cc.

572  {
573  KeyboardTester tester{GetContext()};
574  tester.Responding(true);
575 
576  // US Keyboard layout
577 
578  // Press A
579  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
580  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
581  kWmResultZero),
582  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
583  kWmResultZero)});
584 
585  EXPECT_EQ(tester.key_calls.size(), 1);
586  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
587  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
588  tester.clear_key_calls();
589  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
590 
591  // Release A
592  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
593  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
594  kWmResultZero)});
595 
596  EXPECT_EQ(tester.key_calls.size(), 1);
597  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
598  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
599  tester.clear_key_calls();
600  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
601 }

References EXPECT_CALL_IS_EVENT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [119/239]

flutter::testing::TEST_F ( KeyboardTest  ,
LowerCaseAUnhandled   
)

Definition at line 603 of file keyboard_unittests.cc.

603  {
604  KeyboardTester tester{GetContext()};
605  tester.Responding(false);
606 
607  // US Keyboard layout
608 
609  // Press A
610  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
611  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
612  kWmResultZero),
613  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
614  kWmResultZero)});
615 
616  EXPECT_EQ(tester.key_calls.size(), 2);
617  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
618  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
619  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
620  tester.clear_key_calls();
621  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
622 
623  // Release A
624  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
625  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
626  kWmResultZero)});
627 
628  EXPECT_EQ(tester.key_calls.size(), 1);
629  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
630  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
631  tester.clear_key_calls();
632  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
633 }

References EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [120/239]

flutter::testing::TEST_F ( KeyboardTest  ,
MetaLeftUnhandled   
)

Definition at line 909 of file keyboard_unittests.cc.

909  {
910  KeyboardTester tester{GetContext()};
911  tester.Responding(false);
912 
913  // US Keyboard layout
914 
915  // Press MetaLeft
916  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
917  KeyStateChange{VK_LWIN, true, false},
918  WmKeyDownInfo{VK_LWIN, kScanCodeMetaLeft, kExtended, kWasUp}.Build(
919  kWmResultZero)});
920 
921  EXPECT_EQ(tester.key_calls.size(), 1);
922  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
923  kPhysicalMetaLeft, kLogicalMetaLeft, "",
924  kNotSynthesized);
925  tester.clear_key_calls();
926  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
927 
928  // Release MetaLeft
929  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
930  KeyStateChange{VK_LWIN, false, true},
931  WmKeyUpInfo{VK_LWIN, kScanCodeMetaLeft, kExtended}.Build(kWmResultZero)});
932 
933  EXPECT_EQ(tester.key_calls.size(), 1);
934  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
935  kPhysicalMetaLeft, kLogicalMetaLeft, "",
936  kNotSynthesized);
937  tester.clear_key_calls();
938  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
939 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [121/239]

flutter::testing::TEST_F ( KeyboardTest  ,
MetaRightUnhandled   
)

Definition at line 941 of file keyboard_unittests.cc.

941  {
942  KeyboardTester tester{GetContext()};
943  tester.Responding(false);
944 
945  // US Keyboard layout
946 
947  // Press MetaRight
948  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
949  KeyStateChange{VK_RWIN, true, false},
950  WmKeyDownInfo{VK_RWIN, kScanCodeMetaRight, kExtended, kWasUp}.Build(
951  kWmResultZero)});
952 
953  EXPECT_EQ(tester.key_calls.size(), 1);
954  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
955  kPhysicalMetaRight, kLogicalMetaRight, "",
956  kNotSynthesized);
957  tester.clear_key_calls();
958  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
959 
960  // Release MetaRight
961  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
962  KeyStateChange{VK_RWIN, false, true},
963  WmKeyUpInfo{VK_RWIN, kScanCodeMetaRight, kExtended}.Build(
964  kWmResultZero)});
965 
966  EXPECT_EQ(tester.key_calls.size(), 1);
967  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
968  kPhysicalMetaRight, kLogicalMetaRight, "",
969  kNotSynthesized);
970  tester.clear_key_calls();
971  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
972 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [122/239]

flutter::testing::TEST_F ( KeyboardTest  ,
MultibyteCharacter   
)

Definition at line 1765 of file keyboard_unittests.cc.

1765  {
1766  KeyboardTester tester{GetContext()};
1767  tester.Responding(false);
1768 
1769  // Gothic Keyboard layout. (We need a layout that yields non-BMP characters
1770  // without IME, which is actually very rare.)
1771 
1772  // Press key W of a US keyboard, which should yield character '𐍅'.
1773  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1774  WmKeyDownInfo{kVirtualKeyW, kScanCodeKeyW, kNotExtended, kWasUp}.Build(
1775  kWmResultZero),
1776  WmCharInfo{0xd800, kScanCodeKeyW, kNotExtended, kWasUp}.Build(
1777  kWmResultZero),
1778  WmCharInfo{0xdf45, kScanCodeKeyW, kNotExtended, kWasUp}.Build(
1779  kWmResultZero)});
1780 
1781  const char* st = tester.key_calls[0].key_event.character;
1782 
1783  EXPECT_EQ(tester.key_calls.size(), 2);
1784  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1785  kPhysicalKeyW, kLogicalKeyW, "𐍅", kNotSynthesized);
1786  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"𐍅");
1787  tester.clear_key_calls();
1788  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 3);
1789 
1790  // Release W
1791  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1792  WmKeyUpInfo{kVirtualKeyW, kScanCodeKeyW, kNotExtended}.Build(
1793  kWmResultZero)});
1794 
1795  EXPECT_EQ(tester.key_calls.size(), 1);
1796  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1797  kPhysicalKeyW, kLogicalKeyW, "", kNotSynthesized);
1798  tester.clear_key_calls();
1799  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1800 }

References EXPECT_CALL_IS_EVENT, and EXPECT_CALL_IS_TEXT.

◆ TEST_F() [123/239]

flutter::testing::TEST_F ( KeyboardTest  ,
RepeatA   
)

Definition at line 975 of file keyboard_unittests.cc.

975  {
976  KeyboardTester tester{GetContext()};
977  tester.Responding(true);
978 
979  // Press A
980  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
981  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
982  kWmResultZero),
983  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
984  kWmResultZero)});
985 
986  // Hold A
987  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
988  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasDown}.Build(
989  kWmResultZero),
990  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasDown}.Build(
991  kWmResultZero)});
992 
993  EXPECT_EQ(tester.key_calls.size(), 2);
994  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
995  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
996  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeRepeat,
997  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
998  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
999 }

References EXPECT_CALL_IS_EVENT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [124/239]

flutter::testing::TEST_F ( KeyboardTest  ,
RestartClearsKeyboardState   
)

Definition at line 1004 of file keyboard_unittests.cc.

1004  {
1005  KeyboardTester tester{GetContext()};
1006  tester.Responding(true);
1007 
1008  // Press A
1009  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1010  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1011  kWmResultZero),
1012  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1013  kWmResultZero)});
1014 
1015  // Reset the keyboard's state.
1016  tester.ResetKeyboard();
1017 
1018  // Hold A. Notice the message declares the key is already down, however, the
1019  // the keyboard does not send a repeat event as its state was reset.
1020  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1021  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasDown}.Build(
1022  kWmResultZero),
1023  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasDown}.Build(
1024  kWmResultZero)});
1025 
1026  EXPECT_EQ(tester.key_calls.size(), 2);
1027  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1028  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
1029  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeDown,
1030  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
1031  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
1032 }

References EXPECT_CALL_IS_EVENT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [125/239]

flutter::testing::TEST_F ( KeyboardTest  ,
ShiftLeftKeyA   
)

Definition at line 1070 of file keyboard_unittests.cc.

1070  {
1071  KeyboardTester tester{GetContext()};
1072  tester.Responding(false);
1073 
1074  // US Keyboard layout
1075 
1076  // Press ShiftLeft
1077  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1078  KeyStateChange{VK_LSHIFT, true, true},
1079  WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
1080  kWmResultZero)});
1081 
1082  EXPECT_EQ(tester.key_calls.size(), 1);
1083  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1084  kPhysicalShiftLeft, kLogicalShiftLeft, "",
1085  kNotSynthesized);
1086  tester.clear_key_calls();
1087  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1088 
1089  // Press A
1090  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1091  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1092  kWmResultZero),
1093  WmCharInfo{'A', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1094  kWmResultZero)});
1095 
1096  EXPECT_EQ(tester.key_calls.size(), 2);