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 (AccessibilityBridgeWindows, OnAccessibilityEnabledChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityReadOnlyChanged)
 
 TEST_F (AccessibilityPluginTest, DirectAnnounceCall)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithInt32ViewId)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithInt64ViewId)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithInvalidViewIdType)
 
 TEST_F (AccessibilityPluginTest, AnnounceWithMissingMessage)
 
 INSTANTIATE_TEST_SUITE_P (RendererAndFeatureLevel, CompositorOpenGLANGLETest, ::testing::Values(TestParams{.name="SkiaFeatureLevelDefault",.enable_impeller=false,.max_feature_level=std::nullopt}, TestParams{.name="ImpellerFeatureLevelDefault",.enable_impeller=true,.max_feature_level=std::nullopt}, TestParams{.name="SkiaFeatureLevel10_0",.enable_impeller=false,.max_feature_level=egl::D3DFeatureLevel{10, 0}}, TestParams{.name="ImpellerFeatureLevel10_0",.enable_impeller=true,.max_feature_level=egl::D3DFeatureLevel{10, 0}}), [](const ::testing::TestParamInfo< TestParams > &info) { return std::string(info.param.name);})
 
 TEST_P (CompositorOpenGLANGLETest, CreateBackingStore)
 
 TEST_P (CompositorOpenGLANGLETest, Present)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStore)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreImpellerNoMSAA)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreImpellerMSAA)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreImpellerOffscreenMSAA)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreGLES2Unsized)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreImpellerGLES2Unsized)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStoreGLES3Sized)
 
 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 (EGLManagerTest, FeatureLevel10CapLimitsToOpenGLES2)
 
 TEST (FlutterProjectBundle, BasicPropertiesAbsolutePaths)
 
 TEST (FlutterProjectBundle, BasicPropertiesRelativePaths)
 
 TEST (FlutterProjectBundle, EnableFlutterGpu)
 
 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, NonPrimaryMouseButtonCapturesPointer)
 
 TEST_F (FlutterWindowTest, MouseButtonCaptureReleasedAfterAllButtonsReleased)
 
 TEST_F (FlutterWindowTest, MouseMoveWithButtonIgnoredWithoutCapture)
 
 TEST_F (FlutterWindowTest, MouseMoveWithButtonDispatchedWithCapture)
 
 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, RunWithTopLeftSurfaceOriginPassesTopLeftFramebufferSwitch)
 
 TEST_F (FlutterWindowsEngineTest, RunWithBottomLeftSurfaceOriginOmitsTopLeftFramebufferSwitch)
 
 TEST_F (FlutterWindowsEngineTest, RunWithProjectFlagEnableFlutterGpu)
 
 TEST_F (FlutterWindowsEngineTest, RunWithoutProjectFlagEnableFlutterGpu)
 
 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, PostPlatformThreadTaskNotCancelledWhenRun)
 
 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, ClipboardSetDataReplacesNullTerminators)
 
 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, SetEditingStatePreservesComposingRange)
 
 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, DISABLED_TooltipWindowUpdatesPositionOnViewSizeChange)
 
 TEST_F (WindowManagerTest, CreatePopupWindow)
 
 TEST_F (WindowManagerTest, PopupWindowHasNoActivateStyle)
 
 TEST_F (WindowManagerTest, PopupWindowDoesNotStealFocus)
 
 TEST_F (WindowManagerTest, DISABLED_PopupWindowUpdatesPositionOnViewSizeChange)
 
 TEST_F (WindowManagerTest, CreateRegularWindowSizedToContent)
 
 TEST_F (WindowManagerTest, DISABLED_RegularWindowSizedToContentResizesToContent)
 
 TEST_F (WindowManagerTest, RegularWindowSizedToContentNonResizableHasNoThickFrame)
 
 TEST_F (WindowManagerTest, RegularWindowSizedToContentResizableHasThickFrame)
 
 TEST_F (WindowManagerTest, DISABLED_RegularWindowSizedToContentResizableStopsTrackingAfterFirstFrame)
 
 TEST_F (WindowManagerTest, CreateModelessDialogSizedToContent)
 
 TEST_F (WindowManagerTest, CreateModalDialogSizedToContent)
 
 TEST_F (WindowManagerTest, DISABLED_DialogWindowSizedToContentResizesToContent)
 
 TEST_F (WindowManagerTest, DialogWindowSizedToContentNonResizableHasNoThickFrame)
 
 TEST_F (WindowManagerTest, OnPreEngineRestartDestroysWindowsWithoutDispatchingMessages)
 
 TEST_F (WindowManagerTest, OnEngineShutdownDispatchesWmDestroyForPopupWindow)
 
 TEST_F (WindowManagerTest, OnEngineShutdownDispatchesWmDestroyForTooltipWindow)
 
 TEST_F (WindowManagerTest, CreateSatelliteWindow)
 
 TEST_F (WindowManagerTest, SatelliteWindowUsesPositionCallbackAfterFirstFrame)
 
 TEST_F (WindowManagerTest, SatelliteWindowIsHiddenUntilFirstFrame)
 
 TEST_F (WindowManagerTest, SatelliteWindowHandlesNullPositionCallback)
 
 TEST_F (WindowManagerTest, SatelliteWindowFollowsParentMovement)
 
 TEST_F (WindowManagerTest, SatelliteWindowDoesNotMoveWhenParentOnlyResizes)
 
 TEST_F (WindowManagerTest, SatelliteWindowKeepsOffsetAfterBeingMoved)
 
 TEST_F (WindowManagerTest, SatelliteWindowFollowsParentClientArea)
 
 TEST_F (WindowManagerTest, SatelliteWindowCannotBeMinimized)
 
 TEST_F (WindowManagerTest, SatelliteWindowCanReparent)
 
 TEST_F (WindowManagerTest, CreateSatelliteWindowSizedToContent)
 
 TEST_F (WindowManagerTest, SatelliteWindowSizedToContentUsesPositionCallbackAfterFirstFrame)
 
 TEST_F (WindowManagerTest, SatelliteWindowCannotBeReparentedToItself)
 
 TEST_F (WindowManagerTest, SatelliteWindowCannotBeReparentedToItsOwnSatellite)
 
 TEST_F (WindowManagerTest, OnEngineShutdownDispatchesWmDestroyForSatellite)
 
 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, DisabledButtonHasDisabledRestriction)
 
 TEST (AccessibilityBridgeTest, EnabledButtonHasNoRestriction)
 
 TEST (AccessibilityBridgeTest, ReadOnlyTextFieldHasReadOnlyRestriction)
 
 TEST (AccessibilityBridgeTest, ReadOnlyTextFieldHasTextFieldRole)
 
 TEST (AccessibilityBridgeTest, EditableTextFieldHasTextFieldRole)
 
 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().

◆ INSTANTIATE_TEST_SUITE_P()

flutter::testing::INSTANTIATE_TEST_SUITE_P ( RendererAndFeatureLevel  ,
CompositorOpenGLANGLETest  ,
::testing::Values(TestParams{.name="SkiaFeatureLevelDefault",.enable_impeller=false,.max_feature_level=std::nullopt}, TestParams{.name="ImpellerFeatureLevelDefault",.enable_impeller=true,.max_feature_level=std::nullopt}, TestParams{.name="SkiaFeatureLevel10_0",.enable_impeller=false,.max_feature_level=egl::D3DFeatureLevel{10, 0}}, TestParams{.name="ImpellerFeatureLevel10_0",.enable_impeller=true,.max_feature_level=egl::D3DFeatureLevel{10, 0}})  ,
[] (const ::testing::TestParamInfo< TestParams > &info) { return std::string(info.param.name);}   
)

◆ TEST() [1/183]

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/183]

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/183]

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

Definition at line 655 of file accessibility_bridge_unittests.cc.

655  {
656  std::shared_ptr<TestAccessibilityBridge> bridge =
657  std::make_shared<TestAccessibilityBridge>();
658 
659  ui::AXTreeID tree_id = bridge->GetTreeID();
660  ui::AXTreeManager* manager =
661  ui::AXTreeManagerMap::GetInstance().GetManager(tree_id);
662  ASSERT_EQ(manager, static_cast<ui::AXTreeManager*>(bridge.get()));
663 }

◆ TEST() [4/183]

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/183]

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/183]

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/183]

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

Definition at line 481 of file accessibility_bridge_unittests.cc.

481  {
482  std::shared_ptr<TestAccessibilityBridge> bridge =
483  std::make_shared<TestAccessibilityBridge>();
484 
485  int32_t root_id = 0;
486  int32_t intermediary1_id = 1;
487  int32_t intermediary2_id = 2;
488  int32_t leaf1_id = 3;
489  int32_t leaf2_id = 4;
490  int32_t leaf3_id = 5;
491 
492  std::vector<int32_t> root_children{intermediary1_id, intermediary2_id};
493  std::vector<int32_t> intermediary1_children{leaf1_id};
494  std::vector<int32_t> intermediary2_children{leaf2_id, leaf3_id};
495  FlutterSemanticsNode2 root =
496  CreateSemanticsNode(root_id, "root", &root_children);
497  FlutterSemanticsNode2 intermediary1 = CreateSemanticsNode(
498  intermediary1_id, "intermediary 1", &intermediary1_children);
499  FlutterSemanticsNode2 intermediary2 = CreateSemanticsNode(
500  intermediary2_id, "intermediary 2", &intermediary2_children);
501  FlutterSemanticsNode2 leaf1 = CreateSemanticsNode(leaf1_id, "leaf 1");
502  FlutterSemanticsNode2 leaf2 = CreateSemanticsNode(leaf2_id, "leaf 2");
503  FlutterSemanticsNode2 leaf3 = CreateSemanticsNode(leaf3_id, "leaf 3");
504 
505  bridge->AddFlutterSemanticsNodeUpdate(root);
506  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
507  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
508  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
509  bridge->AddFlutterSemanticsNodeUpdate(leaf2);
510  bridge->AddFlutterSemanticsNodeUpdate(leaf3);
511  bridge->CommitUpdates();
512  bridge->accessibility_events.clear();
513 
514  // Swap intermediary 1's and intermediary2's children.
515  int32_t new_intermediary1_children[] = {leaf2_id, leaf3_id};
516  intermediary1.child_count = 2;
517  intermediary1.children_in_traversal_order = new_intermediary1_children;
518 
519  int32_t new_intermediary2_children[] = {leaf1_id};
520  intermediary2.child_count = 1;
521  intermediary2.children_in_traversal_order = new_intermediary2_children;
522 
523  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
524  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
525  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
526  bridge->AddFlutterSemanticsNodeUpdate(leaf2);
527  bridge->AddFlutterSemanticsNodeUpdate(leaf3);
528  bridge->CommitUpdates();
529 
530  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
531  auto intermediary1_node =
532  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary1_id).lock();
533  auto intermediary2_node =
534  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary2_id).lock();
535  auto leaf1_node =
536  bridge->GetFlutterPlatformNodeDelegateFromID(leaf1_id).lock();
537  auto leaf2_node =
538  bridge->GetFlutterPlatformNodeDelegateFromID(leaf2_id).lock();
539  auto leaf3_node =
540  bridge->GetFlutterPlatformNodeDelegateFromID(leaf3_id).lock();
541 
542  EXPECT_EQ(root_node->GetChildCount(), 2);
543  EXPECT_EQ(root_node->GetData().child_ids[0], intermediary1_id);
544  EXPECT_EQ(root_node->GetData().child_ids[1], intermediary2_id);
545  EXPECT_EQ(root_node->GetName(), "root");
546 
547  EXPECT_EQ(intermediary1_node->GetChildCount(), 2);
548  EXPECT_EQ(intermediary1_node->GetData().child_ids[0], leaf2_id);
549  EXPECT_EQ(intermediary1_node->GetData().child_ids[1], leaf3_id);
550  EXPECT_EQ(intermediary1_node->GetName(), "intermediary 1");
551 
552  EXPECT_EQ(intermediary2_node->GetChildCount(), 1);
553  EXPECT_EQ(intermediary2_node->GetData().child_ids[0], leaf1_id);
554  EXPECT_EQ(intermediary2_node->GetName(), "intermediary 2");
555 
556  EXPECT_EQ(leaf1_node->GetChildCount(), 0);
557  EXPECT_EQ(leaf1_node->GetName(), "leaf 1");
558 
559  EXPECT_EQ(leaf2_node->GetChildCount(), 0);
560  EXPECT_EQ(leaf2_node->GetName(), "leaf 2");
561 
562  EXPECT_EQ(leaf3_node->GetChildCount(), 0);
563  EXPECT_EQ(leaf3_node->GetName(), "leaf 3");
564 
565  // Intermediary 1 and intermediary 2 have new children.
566  // Leaf 1, 2, and 3 are all moved.
567  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
568  EXPECT_THAT(bridge->accessibility_events,
569  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
570  EXPECT_THAT(bridge->accessibility_events,
571  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(3));
572 }

References CreateSemanticsNode().

◆ TEST() [8/183]

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

Definition at line 418 of file accessibility_bridge_unittests.cc.

418  {
419  std::shared_ptr<TestAccessibilityBridge> bridge =
420  std::make_shared<TestAccessibilityBridge>();
421 
422  std::vector<int32_t> root_children{1};
423  std::vector<int32_t> child1_children{2};
424  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &root_children);
425  FlutterSemanticsNode2 child1 =
426  CreateSemanticsNode(1, "child 1", &child1_children);
427  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
428 
429  bridge->AddFlutterSemanticsNodeUpdate(root);
430  bridge->AddFlutterSemanticsNodeUpdate(child1);
431  bridge->AddFlutterSemanticsNodeUpdate(child2);
432  bridge->CommitUpdates();
433  bridge->accessibility_events.clear();
434 
435  // Reparent child2 from child1 to the root.
436  child1.child_count = 0;
437  child1.children_in_traversal_order = nullptr;
438 
439  int32_t new_root_children[] = {1, 2};
440  root.child_count = 2;
441  root.children_in_traversal_order = new_root_children;
442 
443  bridge->AddFlutterSemanticsNodeUpdate(root);
444  bridge->AddFlutterSemanticsNodeUpdate(child1);
445  bridge->AddFlutterSemanticsNodeUpdate(child2);
446  bridge->CommitUpdates();
447 
448  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
449  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
450  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
451 
452  EXPECT_EQ(root_node->GetChildCount(), 2);
453  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
454  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
455  EXPECT_EQ(root_node->GetName(), "root");
456 
457  EXPECT_EQ(child1_node->GetChildCount(), 0);
458  EXPECT_EQ(child1_node->GetName(), "child 1");
459 
460  EXPECT_EQ(child2_node->GetChildCount(), 0);
461  EXPECT_EQ(child2_node->GetName(), "child 2");
462 
463  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
464 
465  // Child2 is moved from child1 to root.
466  EXPECT_THAT(bridge->accessibility_events,
467  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
468  EXPECT_THAT(bridge->accessibility_events,
469  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
470 
471  // Child1 is no longer a parent. It loses its group role and disables its
472  // 'clip children' attribute.
473  EXPECT_THAT(
474  bridge->accessibility_events,
475  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
476  EXPECT_THAT(bridge->accessibility_events,
477  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
478 }

References CreateSemanticsNode().

◆ TEST() [9/183]

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

Definition at line 575 of file accessibility_bridge_unittests.cc.

575  {
576  std::shared_ptr<TestAccessibilityBridge> bridge =
577  std::make_shared<TestAccessibilityBridge>();
578 
579  int32_t root_id = 0;
580  int32_t intermediary1_id = 1;
581  int32_t intermediary2_id = 2;
582  int32_t leaf1_id = 3;
583 
584  std::vector<int32_t> root_children{intermediary1_id, intermediary2_id};
585  std::vector<int32_t> intermediary1_children{leaf1_id};
586  FlutterSemanticsNode2 root =
587  CreateSemanticsNode(root_id, "root", &root_children);
588  FlutterSemanticsNode2 intermediary1 = CreateSemanticsNode(
589  intermediary1_id, "intermediary 1", &intermediary1_children);
590  FlutterSemanticsNode2 intermediary2 =
591  CreateSemanticsNode(intermediary2_id, "intermediary 2");
592  FlutterSemanticsNode2 leaf1 = CreateSemanticsNode(leaf1_id, "leaf 1");
593 
594  bridge->AddFlutterSemanticsNodeUpdate(root);
595  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
596  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
597  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
598  bridge->CommitUpdates();
599  bridge->accessibility_events.clear();
600 
601  // Move intermediary1 from root to intermediary 2.
602  int32_t new_root_children[] = {intermediary2_id};
603  root.child_count = 1;
604  root.children_in_traversal_order = new_root_children;
605 
606  int32_t new_intermediary2_children[] = {intermediary1_id};
607  intermediary2.child_count = 1;
608  intermediary2.children_in_traversal_order = new_intermediary2_children;
609 
610  bridge->AddFlutterSemanticsNodeUpdate(root);
611  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
612  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
613  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
614  bridge->CommitUpdates();
615 
616  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
617  auto intermediary1_node =
618  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary1_id).lock();
619  auto intermediary2_node =
620  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary2_id).lock();
621  auto leaf1_node =
622  bridge->GetFlutterPlatformNodeDelegateFromID(leaf1_id).lock();
623 
624  EXPECT_EQ(root_node->GetChildCount(), 1);
625  EXPECT_EQ(root_node->GetData().child_ids[0], intermediary2_id);
626  EXPECT_EQ(root_node->GetName(), "root");
627 
628  EXPECT_EQ(intermediary2_node->GetChildCount(), 1);
629  EXPECT_EQ(intermediary2_node->GetData().child_ids[0], intermediary1_id);
630  EXPECT_EQ(intermediary2_node->GetName(), "intermediary 2");
631 
632  EXPECT_EQ(intermediary1_node->GetChildCount(), 1);
633  EXPECT_EQ(intermediary1_node->GetData().child_ids[0], leaf1_id);
634  EXPECT_EQ(intermediary1_node->GetName(), "intermediary 1");
635 
636  EXPECT_EQ(leaf1_node->GetChildCount(), 0);
637  EXPECT_EQ(leaf1_node->GetName(), "leaf 1");
638 
639  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
640 
641  EXPECT_THAT(bridge->accessibility_events,
642  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
643  EXPECT_THAT(bridge->accessibility_events,
644  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
645 
646  // Intermediary 2 becomes a parent node. It updates to group role and enables
647  // its 'clip children' attribute.
648  EXPECT_THAT(
649  bridge->accessibility_events,
650  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
651  EXPECT_THAT(bridge->accessibility_events,
652  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
653 }

References CreateSemanticsNode().

◆ TEST() [10/183]

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

Definition at line 399 of file accessibility_bridge_unittests.cc.

399  {
400  std::shared_ptr<TestAccessibilityBridge> bridge =
401  std::make_shared<TestAccessibilityBridge>();
402  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
403  auto flags = FlutterSemanticsFlags{
404  .is_checked = FlutterCheckState::kFlutterCheckStateTrue,
405  };
406 
407  root.flags2 = &flags;
408  bridge->AddFlutterSemanticsNodeUpdate(root);
409  bridge->CommitUpdates();
410 
411  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
412  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
413  EXPECT_EQ(root_node->GetData().GetCheckedState(),
414  ax::mojom::CheckedState::kTrue);
415 }

References CreateSemanticsNode().

◆ TEST() [11/183]

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

Definition at line 305 of file accessibility_bridge_unittests.cc.

305  {
306  std::shared_ptr<TestAccessibilityBridge> bridge =
307  std::make_shared<TestAccessibilityBridge>();
308  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
309  auto flags = FlutterSemanticsFlags{
310  .is_enabled = FlutterTristate::kFlutterTristateFalse,
311  .is_button = true,
312  };
313  root.flags2 = &flags;
314  bridge->AddFlutterSemanticsNodeUpdate(root);
315  bridge->CommitUpdates();
316 
317  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
318  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kButton);
319  EXPECT_EQ(root_node->GetData().GetRestriction(),
320  ax::mojom::Restriction::kDisabled);
321 }

References CreateSemanticsNode().

◆ TEST() [12/183]

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() [13/183]

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

Definition at line 376 of file accessibility_bridge_unittests.cc.

376  {
377  std::shared_ptr<TestAccessibilityBridge> bridge =
378  std::make_shared<TestAccessibilityBridge>();
379  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
380  auto flags = FlutterSemanticsFlags{
381  .is_enabled = FlutterTristate::kFlutterTristateTrue,
382  .is_text_field = true,
383  .is_read_only = false,
384  };
385  root.flags2 = &flags;
386  bridge->AddFlutterSemanticsNodeUpdate(root);
387  bridge->CommitUpdates();
388 
389  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
390  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kTextField);
391  EXPECT_TRUE(root_node->GetData().HasState(ax::mojom::State::kEditable));
392 }

References CreateSemanticsNode().

◆ TEST() [14/183]

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

Definition at line 323 of file accessibility_bridge_unittests.cc.

323  {
324  std::shared_ptr<TestAccessibilityBridge> bridge =
325  std::make_shared<TestAccessibilityBridge>();
326  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
327  auto flags = FlutterSemanticsFlags{
328  .is_enabled = FlutterTristate::kFlutterTristateTrue,
329  .is_button = true,
330  };
331  root.flags2 = &flags;
332  bridge->AddFlutterSemanticsNodeUpdate(root);
333  bridge->CommitUpdates();
334 
335  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
336  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kButton);
337  EXPECT_EQ(root_node->GetData().GetRestriction(),
338  ax::mojom::Restriction::kNone);
339 }

References CreateSemanticsNode().

◆ TEST() [15/183]

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

Definition at line 684 of file accessibility_bridge_unittests.cc.

684  {
685  std::shared_ptr<TestAccessibilityBridge> bridge =
686  std::make_shared<TestAccessibilityBridge>();
687 
688  std::vector<int32_t> children{1, 2};
689  FlutterSemanticsNode2 node0 = CreateSemanticsNode(0, "node 0", &children);
690  auto flags0 = FlutterSemanticsFlags{
691  .is_selected = FlutterTristate::kFlutterTristateNone,
692  };
693  node0.flags2 = &flags0;
694 
695  FlutterSemanticsNode2 node1 = CreateSemanticsNode(1, "node 1");
696  auto flags1 = FlutterSemanticsFlags{
697  .is_selected = FlutterTristate::kFlutterTristateTrue,
698  };
699  node1.flags2 = &flags1;
700 
701  FlutterSemanticsNode2 node2 = CreateSemanticsNode(2, "node 2");
702  auto flags2 = FlutterSemanticsFlags{
703  .is_selected = FlutterTristate::kFlutterTristateFalse,
704  };
705  node2.flags2 = &flags2;
706 
707  bridge->AddFlutterSemanticsNodeUpdate(node0);
708  bridge->AddFlutterSemanticsNodeUpdate(node1);
709  bridge->AddFlutterSemanticsNodeUpdate(node2);
710  bridge->CommitUpdates();
711 
712  auto delegate0 = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
713  auto delegate1 = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
714  auto delegate2 = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
715 
716  // For kFlutterTristateNone, selected should be false.
717  EXPECT_FALSE(delegate0->GetData().GetBoolAttribute(
718  ax::mojom::BoolAttribute::kSelected));
719  // For kFlutterTristateTrue, selected should be true.
720  EXPECT_TRUE(delegate1->GetData().GetBoolAttribute(
721  ax::mojom::BoolAttribute::kSelected));
722  // For kFlutterTristateFalse, selected should be false.
723  EXPECT_FALSE(delegate2->GetData().GetBoolAttribute(
724  ax::mojom::BoolAttribute::kSelected));
725 }

References CreateSemanticsNode().

◆ TEST() [16/183]

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

Definition at line 665 of file accessibility_bridge_unittests.cc.

665  {
666  std::shared_ptr<TestAccessibilityBridge> bridge =
667  std::make_shared<TestAccessibilityBridge>();
668 
669  const int32_t root_id = 0;
670 
671  FlutterSemanticsNode2 root = CreateSemanticsNode(root_id, "root", {});
672 
673  bridge->AddFlutterSemanticsNodeUpdate(root);
674  bridge->CommitUpdates();
675 
676  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
677  auto root_data = root_node->GetData();
678  EXPECT_TRUE(root_data.HasBoolAttribute(
679  ax::mojom::BoolAttribute::kIsLineBreakingObject));
680  EXPECT_TRUE(root_data.GetBoolAttribute(
681  ax::mojom::BoolAttribute::kIsLineBreakingObject));
682 }

References CreateSemanticsNode().

◆ TEST() [17/183]

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

Definition at line 341 of file accessibility_bridge_unittests.cc.

341  {
342  std::shared_ptr<TestAccessibilityBridge> bridge =
343  std::make_shared<TestAccessibilityBridge>();
344  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
345  auto flags = FlutterSemanticsFlags{
346  .is_enabled = FlutterTristate::kFlutterTristateTrue,
347  .is_text_field = true,
348  .is_read_only = true,
349  };
350  root.flags2 = &flags;
351  bridge->AddFlutterSemanticsNodeUpdate(root);
352  bridge->CommitUpdates();
353 
354  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
355  EXPECT_EQ(root_node->GetData().GetRestriction(),
356  ax::mojom::Restriction::kReadOnly);
357 }

References CreateSemanticsNode().

◆ TEST() [18/183]

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

Definition at line 359 of file accessibility_bridge_unittests.cc.

359  {
360  std::shared_ptr<TestAccessibilityBridge> bridge =
361  std::make_shared<TestAccessibilityBridge>();
362  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
363  auto flags = FlutterSemanticsFlags{
364  .is_enabled = FlutterTristate::kFlutterTristateTrue,
365  .is_text_field = true,
366  .is_read_only = true,
367  };
368  root.flags2 = &flags;
369  bridge->AddFlutterSemanticsNodeUpdate(root);
370  bridge->CommitUpdates();
371 
372  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
373  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kTextField);
374 }

References CreateSemanticsNode().

◆ TEST() [19/183]

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() [20/183]

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() [21/183]

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() [22/183]

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() [23/183]

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() [24/183]

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

Definition at line 406 of file accessibility_bridge_windows_unittests.cc.

406  {
407  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::ENABLED_CHANGED,
408  ax::mojom::Event::kStateChanged);
409 }

◆ TEST() [25/183]

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() [26/183]

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() [27/183]

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() [28/183]

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() [29/183]

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() [30/183]

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() [31/183]

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() [32/183]

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() [33/183]

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

Definition at line 411 of file accessibility_bridge_windows_unittests.cc.

411  {
412  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::READONLY_CHANGED,
413  ax::mojom::Event::kStateChanged);
414 }

◆ TEST() [34/183]

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() [35/183]

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() [36/183]

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() [37/183]

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() [38/183]

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() [39/183]

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() [40/183]

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() [41/183]

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::@108::KeyboardChange::@0 content

References content.

◆ TEST() [42/183]

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() [43/183]

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() [44/183]

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() [45/183]

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() [46/183]

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() [47/183]

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() [48/183]

flutter::testing::TEST ( EGLManagerTest  ,
FeatureLevel10CapLimitsToOpenGLES2   
)

Definition at line 31 of file manager_unittests.cc.

31  {
32  // Create an uncapped manager first to verify this machine supports OpenGL ES
33  // 3.0; otherwise the cap has nothing to limit and the test proves nothing.
34  auto uncapped = egl::Manager::Create(egl::GpuPreference::NoPreference,
35  /*allow_inverted_surface=*/false);
36  ASSERT_NE(uncapped, nullptr);
37  if (!CanCreateGLESContext(*uncapped, 3)) {
38  GTEST_SKIP() << "This machine only supports OpenGL ES 2.0.";
39  }
40 
41  auto capped = egl::Manager::Create(egl::GpuPreference::NoPreference,
42  /*allow_inverted_surface=*/false,
43  egl::D3DFeatureLevel{10, 0});
44  ASSERT_NE(capped, nullptr);
45  EXPECT_TRUE(CanCreateGLESContext(*capped, 2));
46  EXPECT_FALSE(CanCreateGLESContext(*capped, 3));
47 }
@ NoPreference

References flutter::egl::Manager::Create(), and flutter::egl::NoPreference.

◆ TEST() [49/183]

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() [50/183]

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() [51/183]

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() [52/183]

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() [53/183]

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() [54/183]

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() [55/183]

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() [56/183]

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() [57/183]

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() [58/183]

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() [59/183]

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

Definition at line 63 of file flutter_project_bundle_unittests.cc.

63  {
64  FlutterDesktopEngineProperties properties = {};
65  properties.assets_path = L"foo\\flutter_assets";
66  properties.icu_data_path = L"foo\\icudtl.dat";
67 
68  std::vector<const char*> test_arguments = {"arg1", "arg2"};
69  properties.dart_entrypoint_argc = test_arguments.size();
70  properties.dart_entrypoint_argv = test_arguments.data();
71 
72  FlutterProjectBundle project(properties);
73 
74  std::vector<std::string> retrieved_arguments =
75  project.dart_entrypoint_arguments();
76  EXPECT_EQ(retrieved_arguments.size(), 2U);
77  EXPECT_EQ(retrieved_arguments[0], "arg1");
78  EXPECT_EQ(retrieved_arguments[1], "arg2");
79 }

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

◆ TEST() [60/183]

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

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  FlutterProjectBundle default_project(properties);
43  EXPECT_FALSE(default_project.enable_flutter_gpu());
44 
45  properties.enable_flutter_gpu = true;
46  FlutterProjectBundle project(properties);
47  EXPECT_TRUE(project.enable_flutter_gpu());
48 }

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

◆ TEST() [61/183]

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

Definition at line 82 of file flutter_project_bundle_unittests.cc.

82  {
83  FlutterDesktopEngineProperties properties = {};
84  properties.assets_path = L"foo\\flutter_assets";
85  properties.icu_data_path = L"foo\\icudtl.dat";
86 
87  _putenv_s("FLUTTER_ENGINE_SWITCHES", "2");
88  _putenv_s("FLUTTER_ENGINE_SWITCH_1", "abc");
89  _putenv_s("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"");
90 
91  FlutterProjectBundle project(properties);
92 
93  std::vector<std::string> switches = project.GetSwitches();
94  EXPECT_EQ(switches.size(), 2);
95  EXPECT_EQ(switches[0], "--abc");
96  EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
97 }

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

◆ TEST() [62/183]

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

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  // Clear the main environment variable, since test order is not guaranteed.
56  _putenv_s("FLUTTER_ENGINE_SWITCHES", "");
57 
58  FlutterProjectBundle project(properties);
59 
60  EXPECT_EQ(project.GetSwitches().size(), 0);
61 }

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

◆ TEST() [63/183]

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() [64/183]

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() [65/183]

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() [66/183]

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() [67/183]

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() [68/183]

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() [69/183]

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() [70/183]

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() [71/183]

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

Definition at line 861 of file flutter_windows_view_unittests.cc.

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

References flutter::IAccessible.

◆ TEST() [72/183]

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

Definition at line 425 of file flutter_windows_view_unittests.cc.

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

References flutter::IAccessible, name, and node_delegate.

◆ TEST() [73/183]

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

Definition at line 528 of file flutter_windows_view_unittests.cc.

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

References flutter::IAccessible, name, and node_delegate.

◆ TEST() [74/183]

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

Definition at line 1232 of file flutter_windows_view_unittests.cc.

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

References flutter::IAccessible.

◆ TEST() [75/183]

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

Definition at line 1642 of file flutter_windows_view_unittests.cc.

1642  {
1643  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1644  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1645  auto egl_manager = std::make_unique<egl::MockManager>();
1646  egl::MockContext render_context;
1647  auto surface = std::make_unique<egl::MockWindowSurface>();
1648  auto surface_ptr = surface.get();
1649 
1650  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1651  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1652  .WillOnce(Return(true));
1653 
1654  EXPECT_CALL(*egl_manager.get(), render_context)
1655  .WillOnce(Return(&render_context));
1656  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1657 
1658  InSequence s;
1659  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1660  .WillOnce(Return(std::move(surface)));
1661  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1662  .WillOnce([](fml::closure callback) {
1663  callback();
1664  return true;
1665  });
1666  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1667  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1668  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1669  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1670  .WillOnce([](fml::closure callback) {
1671  callback();
1672  return true;
1673  });
1674  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1675 
1676  EngineModifier modifier{engine.get()};
1677  modifier.SetEGLManager(std::move(egl_manager));
1678 
1679  std::unique_ptr<FlutterWindowsView> view =
1680  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1681  /*is_sized_to_content=*/false, BoxConstraints(),
1682  /*allow_implicit_view=*/true);
1683 }

References callback.

◆ TEST() [76/183]

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

Definition at line 1567 of file flutter_windows_view_unittests.cc.

1567  {
1568  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1569  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1570  auto egl_manager = std::make_unique<egl::MockManager>();
1571  egl::MockContext render_context;
1572  auto surface = std::make_unique<egl::MockWindowSurface>();
1573  auto surface_ptr = surface.get();
1574 
1575  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(false));
1576  EXPECT_CALL(*engine.get(), PostRasterThreadTask).Times(0);
1577 
1578  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1579  .WillOnce(Return(true));
1580 
1581  EXPECT_CALL(*egl_manager.get(), render_context)
1582  .WillOnce(Return(&render_context));
1583  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1584 
1585  InSequence s;
1586  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1587  .WillOnce(Return(std::move(surface)));
1588  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1589  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1590  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1591 
1592  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1593 
1594  EngineModifier modifier{engine.get()};
1595  modifier.SetEGLManager(std::move(egl_manager));
1596 
1597  std::unique_ptr<FlutterWindowsView> view =
1598  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1599  /*is_sized_to_content=*/false, BoxConstraints(),
1600  /*allow_implicit_view=*/true);
1601 }

◆ TEST() [77/183]

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

Definition at line 401 of file flutter_windows_view_unittests.cc.

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

◆ TEST() [78/183]

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

Definition at line 1687 of file flutter_windows_view_unittests.cc.

1687  {
1688  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1689  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1690  auto egl_manager = std::make_unique<egl::MockManager>();
1691  egl::MockContext render_context;
1692  auto surface = std::make_unique<egl::MockWindowSurface>();
1693  auto surface_ptr = surface.get();
1694 
1695  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1696 
1697  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1698  .WillOnce(Return(false));
1699 
1700  EXPECT_CALL(*egl_manager.get(), render_context)
1701  .WillOnce(Return(&render_context));
1702  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1703 
1704  InSequence s;
1705  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1706  .WillOnce(Return(std::move(surface)));
1707  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1708  .WillOnce([](fml::closure callback) {
1709  callback();
1710  return true;
1711  });
1712 
1713  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1714  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1715  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1716 
1717  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1718  .WillOnce([](fml::closure callback) {
1719  callback();
1720  return true;
1721  });
1722  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1723 
1724  EngineModifier modifier{engine.get()};
1725  modifier.SetEGLManager(std::move(egl_manager));
1726 
1727  std::unique_ptr<FlutterWindowsView> view =
1728  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1729  /*is_sized_to_content=*/false, BoxConstraints(),
1730  /*allow_implicit_view=*/true);
1731 }

References callback.

◆ TEST() [79/183]

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

Definition at line 1605 of file flutter_windows_view_unittests.cc.

1605  {
1606  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1607  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1608  auto egl_manager = std::make_unique<egl::MockManager>();
1609  egl::MockContext render_context;
1610  auto surface = std::make_unique<egl::MockWindowSurface>();
1611  auto surface_ptr = surface.get();
1612 
1613  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(false));
1614  EXPECT_CALL(*engine.get(), PostRasterThreadTask).Times(0);
1615  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1616  .WillOnce(Return(false));
1617 
1618  EXPECT_CALL(*egl_manager.get(), render_context)
1619  .WillOnce(Return(&render_context));
1620  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1621 
1622  InSequence s;
1623  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1624  .WillOnce(Return(std::move(surface)));
1625  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1626  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1627  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1628 
1629  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1630 
1631  EngineModifier modifier{engine.get()};
1632  modifier.SetEGLManager(std::move(egl_manager));
1633 
1634  std::unique_ptr<FlutterWindowsView> view =
1635  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1636  /*is_sized_to_content=*/false, BoxConstraints(),
1637  /*allow_implicit_view=*/true);
1638 }

◆ TEST() [80/183]

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

Definition at line 1880 of file flutter_windows_view_unittests.cc.

1880  {
1881  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1882 
1883  std::unique_ptr<FlutterWindowsView> view =
1884  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1885  /*is_sized_to_content=*/false, BoxConstraints(),
1886  /*allow_implicit_view=*/true);
1887 
1888  bool callback_fired = false;
1889  view->SetFirstFrameCallback([&callback_fired]() { callback_fired = true; });
1890 
1891  // Simulate the raster thread presenting a frame.
1892  view->OnFramePresented();
1893 
1894  // The callback is posted to the platform thread's task runner.
1895  // Process pending tasks to execute it.
1896  engine->task_runner()->ProcessTasks();
1897 
1898  EXPECT_TRUE(callback_fired);
1899 }

◆ TEST() [81/183]

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

Definition at line 1931 of file flutter_windows_view_unittests.cc.

1931  {
1932  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1933 
1934  std::unique_ptr<FlutterWindowsView> view =
1935  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1936  /*is_sized_to_content=*/false, BoxConstraints(),
1937  /*allow_implicit_view=*/true);
1938 
1939  int callback_count = 0;
1940  view->SetFirstFrameCallback([&callback_count]() { callback_count++; });
1941 
1942  // Present two frames.
1943  view->OnFramePresented();
1944  view->OnFramePresented();
1945 
1946  // Process all pending tasks.
1947  engine->task_runner()->ProcessTasks();
1948 
1949  EXPECT_EQ(callback_count, 1);
1950 }

◆ TEST() [82/183]

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

Definition at line 1903 of file flutter_windows_view_unittests.cc.

1903  {
1904  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1905 
1906  auto window_binding_handler =
1907  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1908  EXPECT_CALL(*window_binding_handler, OnBitmapSurfaceUpdated)
1909  .WillOnce(Return(true));
1910 
1911  std::unique_ptr<FlutterWindowsView> view =
1912  engine->CreateView(std::move(window_binding_handler),
1913  /*is_sized_to_content=*/false, BoxConstraints(),
1914  /*allow_implicit_view=*/true);
1915 
1916  bool callback_fired = false;
1917  view->SetFirstFrameCallback([&callback_fired]() { callback_fired = true; });
1918 
1919  // Simulate software rendering presenting a bitmap.
1920  const uint32_t pixel = 0;
1921  view->PresentSoftwareBitmap(&pixel, sizeof(pixel), 1);
1922 
1923  // Process pending tasks.
1924  engine->task_runner()->ProcessTasks();
1925 
1926  EXPECT_TRUE(callback_fired);
1927 }

◆ TEST() [83/183]

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

Definition at line 1954 of file flutter_windows_view_unittests.cc.

1954  {
1955  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1956 
1957  auto window_binding_handler =
1958  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1959  EXPECT_CALL(*window_binding_handler, OnBitmapSurfaceUpdated)
1960  .WillOnce(Return(false));
1961 
1962  std::unique_ptr<FlutterWindowsView> view =
1963  engine->CreateView(std::move(window_binding_handler),
1964  /*is_sized_to_content=*/false, BoxConstraints(),
1965  /*allow_implicit_view=*/true);
1966 
1967  bool callback_fired = false;
1968  view->SetFirstFrameCallback([&callback_fired]() { callback_fired = true; });
1969 
1970  const uint32_t pixel = 0;
1971  view->PresentSoftwareBitmap(&pixel, sizeof(pixel), 1);
1972 
1973  engine->task_runner()->ProcessTasks();
1974 
1975  EXPECT_FALSE(callback_fired);
1976 }

◆ TEST() [84/183]

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

Definition at line 1799 of file flutter_windows_view_unittests.cc.

1799  {
1800  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1801  auto window_binding_handler =
1802  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1803  EXPECT_CALL(*window_binding_handler, Focus()).WillOnce(Return(true));
1804  std::unique_ptr<FlutterWindowsView> view =
1805  engine->CreateView(std::move(window_binding_handler),
1806  /*is_sized_to_content=*/false, BoxConstraints(),
1807  /*allow_implicit_view=*/true);
1808  EXPECT_TRUE(view->Focus());
1809 }

◆ TEST() [85/183]

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

Definition at line 370 of file flutter_windows_view_unittests.cc.

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

References callback, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST() [86/183]

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

Definition at line 350 of file flutter_windows_view_unittests.cc.

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

References kScanCodeKeyA, and kVirtualKeyA.

◆ TEST() [87/183]

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

Definition at line 731 of file flutter_windows_view_unittests.cc.

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

References flutter::IAccessible, and name.

◆ TEST() [88/183]

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

Definition at line 1811 of file flutter_windows_view_unittests.cc.

1811  {
1812  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1813  auto window_binding_handler =
1814  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1815  std::unique_ptr<FlutterWindowsView> view =
1816  engine->CreateView(std::move(window_binding_handler),
1817  /*is_sized_to_content=*/false, BoxConstraints(),
1818  /*allow_implicit_view=*/true);
1819 
1820  EngineModifier modifier(engine.get());
1821  bool received_focus_event = false;
1822  modifier.embedder_api().SendViewFocusEvent = MOCK_ENGINE_PROC(
1823  SendViewFocusEvent, [&](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
1824  FlutterViewFocusEvent const* event) {
1825  EXPECT_EQ(event->state, FlutterViewFocusState::kFocused);
1826  EXPECT_EQ(event->direction, FlutterViewFocusDirection::kUndefined);
1827  EXPECT_EQ(event->view_id, view->view_id());
1828  EXPECT_EQ(event->struct_size, sizeof(FlutterViewFocusEvent));
1829  received_focus_event = true;
1830  return kSuccess;
1831  });
1832  view->OnFocus(FlutterViewFocusState::kFocused,
1833  FlutterViewFocusDirection::kUndefined);
1834  EXPECT_TRUE(received_focus_event);
1835 }

◆ TEST() [89/183]

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

Definition at line 299 of file flutter_windows_view_unittests.cc.

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

References callback.

◆ TEST() [90/183]

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

Definition at line 1853 of file flutter_windows_view_unittests.cc.

1853  {
1854  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1855  EngineModifier modifier(engine.get());
1856 
1857  auto window_binding_handler =
1858  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1859  EXPECT_CALL(*window_binding_handler, GetDisplayId)
1860  .WillOnce(testing::Return(12));
1861  FlutterWindowsView view{kImplicitViewId, engine.get(),
1862  std::move(window_binding_handler), false,
1863  BoxConstraints()};
1864 
1865  bool received_metrics = false;
1866  modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1867  SendWindowMetricsEvent,
1868  ([&received_metrics](auto engine,
1869  const FlutterWindowMetricsEvent* event) {
1870  received_metrics = true;
1871  EXPECT_EQ(event->display_id, 12);
1872  return kSuccess;
1873  }));
1874  view.OnWindowSizeChanged(100, 100);
1875  EXPECT_TRUE(received_metrics);
1876 }
constexpr FlutterViewId kImplicitViewId

References flutter::kImplicitViewId.

◆ TEST() [91/183]

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

References flutter::IAccessible.

◆ TEST() [92/183]

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

Definition at line 1382 of file flutter_windows_view_unittests.cc.

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

References flutter::IAccessible.

◆ TEST() [93/183]

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

Definition at line 1033 of file flutter_windows_view_unittests.cc.

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

References callback, and user_data.

◆ TEST() [94/183]

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

Definition at line 1506 of file flutter_windows_view_unittests.cc.

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

References flutter::IAccessible.

◆ TEST() [95/183]

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

Definition at line 1736 of file flutter_windows_view_unittests.cc.

1736  {
1737  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1738  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1739  auto egl_manager = std::make_unique<egl::MockManager>();
1740  egl::MockContext render_context;
1741  auto surface = std::make_unique<egl::MockWindowSurface>();
1742  auto surface_ptr = surface.get();
1743 
1744  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1745 
1746  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1747  .WillRepeatedly([](fml::closure callback) {
1748  callback();
1749  return true;
1750  });
1751 
1752  EXPECT_CALL(*egl_manager.get(), render_context)
1753  .WillRepeatedly(Return(&render_context));
1754 
1755  EXPECT_CALL(*surface_ptr, IsValid).WillRepeatedly(Return(true));
1756  EXPECT_CALL(*surface_ptr, MakeCurrent).WillRepeatedly(Return(true));
1757  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1758  EXPECT_CALL(render_context, ClearCurrent).WillRepeatedly(Return(true));
1759 
1760  InSequence s;
1761 
1762  // Mock render surface initialization.
1763  std::unique_ptr<FlutterWindowsView> view;
1764  {
1765  EXPECT_CALL(*egl_manager, CreateWindowSurface)
1766  .WillOnce(Return(std::move(surface)));
1767  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1768  .WillOnce(Return(true));
1769  EXPECT_CALL(*surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
1770 
1771  EngineModifier engine_modifier{engine.get()};
1772  engine_modifier.SetEGLManager(std::move(egl_manager));
1773 
1774  view = engine->CreateView(
1775  std::make_unique<NiceMock<MockWindowBindingHandler>>(), false,
1776  BoxConstraints(),
1777  /*allow_implicit_view=*/true);
1778  }
1779 
1780  // Disabling DWM composition should enable vsync blocking on the surface.
1781  {
1782  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1783  .WillOnce(Return(false));
1784  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1785 
1786  engine->OnDwmCompositionChanged();
1787  }
1788 
1789  // Enabling DWM composition should disable vsync blocking on the surface.
1790  {
1791  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1792  .WillOnce(Return(true));
1793  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1794 
1795  engine->OnDwmCompositionChanged();
1796  }
1797 }

References callback.

◆ TEST() [96/183]

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

Definition at line 1837 of file flutter_windows_view_unittests.cc.

1837  {
1838  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1839  EngineModifier modifier(engine.get());
1840 
1841  auto window_binding_handler =
1842  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1843  EXPECT_CALL(*window_binding_handler, GetDisplayId)
1844  .WillOnce(testing::Return(12));
1845  FlutterWindowsView view{kImplicitViewId, engine.get(),
1846  std::move(window_binding_handler), false,
1847  BoxConstraints()};
1848 
1849  FlutterWindowMetricsEvent event = view.CreateWindowMetricsEvent();
1850  EXPECT_EQ(event.display_id, 12);
1851 }

References flutter::kImplicitViewId.

◆ TEST() [97/183]

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

Definition at line 1206 of file flutter_windows_view_unittests.cc.

1206  {
1207  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1208  EngineModifier modifier(engine.get());
1209 
1210  FlutterWindowsView view{kImplicitViewId, engine.get(),
1211  std::make_unique<flutter::FlutterWindow>(
1212  100, 100, engine->display_manager()),
1213  /*is_sized_to_content=*/false, BoxConstraints()};
1214 
1215  bool schedule_frame_called = false;
1216  modifier.embedder_api().ScheduleFrame =
1217  MOCK_ENGINE_PROC(ScheduleFrame, ([&schedule_frame_called](auto engine) {
1218  schedule_frame_called = true;
1219  return kSuccess;
1220  }));
1221 
1222  view.OnWindowRepaint();
1223  EXPECT_TRUE(schedule_frame_called);
1224 }

References flutter::kImplicitViewId.

◆ TEST() [98/183]

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

Definition at line 1140 of file flutter_windows_view_unittests.cc.

1140  {
1141  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1142 
1143  EngineModifier engine_modifier(engine.get());
1144  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
1145  PostRenderThreadTask,
1146  ([](auto engine, VoidCallback callback, void* user_data) {
1148  return kSuccess;
1149  }));
1150 
1151  auto egl_manager = std::make_unique<egl::MockManager>();
1152  auto surface = std::make_unique<egl::MockWindowSurface>();
1153 
1154  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface).Times(0);
1155  EXPECT_CALL(*surface.get(), IsValid).WillRepeatedly(Return(false));
1156  EXPECT_CALL(*surface.get(), Destroy).WillOnce(Return(false));
1157 
1158  std::unique_ptr<FlutterWindowsView> view =
1159  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1160  /*is_sized_to_content=*/false, BoxConstraints(),
1161  /*allow_implicit_view=*/true);
1162 
1163  ViewModifier view_modifier{view.get()};
1164  engine_modifier.SetEGLManager(std::move(egl_manager));
1165  view_modifier.SetSurface(std::move(surface));
1166 
1167  auto metrics_sent = false;
1168  engine_modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1169  SendWindowMetricsEvent,
1170  ([&metrics_sent](auto engine, const FlutterWindowMetricsEvent* event) {
1171  metrics_sent = true;
1172  return kSuccess;
1173  }));
1174 
1175  view->OnWindowSizeChanged(500, 500);
1176 }

References callback, and user_data.

◆ TEST() [99/183]

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

Definition at line 1099 of file flutter_windows_view_unittests.cc.

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

References callback, and user_data.

◆ TEST() [100/183]

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

Definition at line 960 of file flutter_windows_view_unittests.cc.

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

References callback, and user_data.

◆ TEST() [101/183]

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

Definition at line 1180 of file flutter_windows_view_unittests.cc.

1180  {
1181  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1182  EngineModifier modifier(engine.get());
1183 
1184  auto egl_manager = std::make_unique<egl::MockManager>();
1185 
1186  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface).Times(0);
1187 
1188  std::unique_ptr<FlutterWindowsView> view =
1189  engine->CreateView(std::make_unique<NiceMock<MockWindowBindingHandler>>(),
1190  /*is_sized_to_content=*/false, BoxConstraints(),
1191  /*allow_implicit_view=*/true);
1192 
1193  modifier.SetEGLManager(std::move(egl_manager));
1194 
1195  auto metrics_sent = false;
1196  modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1197  SendWindowMetricsEvent,
1198  ([&metrics_sent](auto engine, const FlutterWindowMetricsEvent* event) {
1199  metrics_sent = true;
1200  return kSuccess;
1201  }));
1202 
1203  view->OnWindowSizeChanged(500, 500);
1204 }

◆ TEST() [102/183]

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() [103/183]

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() [104/183]

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() [105/183]

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() [106/183]

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() [107/183]

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() [108/183]

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() [109/183]

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() [110/183]

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() [111/183]

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() [112/183]

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() [113/183]

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() [114/183]

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() [115/183]

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() [116/183]

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() [117/183]

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() [118/183]

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() [119/183]

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() [120/183]

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() [121/183]

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() [122/183]

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() [123/183]

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() [124/183]

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() [125/183]

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() [126/183]

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() [127/183]

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() [128/183]

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() [129/183]

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() [130/183]

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

Definition at line 23 of file window_unittests.cc.

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

◆ TEST() [131/183]

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() [132/183]

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() [133/183]

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() [134/183]

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() [135/183]

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() [136/183]

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() [137/183]

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() [138/183]

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() [139/183]

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() [140/183]

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() [141/183]

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() [142/183]

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() [143/183]

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() [144/183]

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() [145/183]

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() [146/183]

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() [147/183]

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() [148/183]

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::@108::KeyboardChange::Type type

References type.

◆ TEST() [149/183]

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() [150/183]

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() [151/183]

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() [152/183]

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() [153/183]

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() [154/183]

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() [155/183]

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() [156/183]

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() [157/183]

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() [158/183]

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() [159/183]

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() [160/183]

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() [161/183]

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() [162/183]

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() [163/183]

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() [164/183]

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() [165/183]

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() [166/183]

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() [167/183]

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() [168/183]

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() [169/183]

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() [170/183]

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() [171/183]

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() [172/183]

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() [173/183]

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() [174/183]

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() [175/183]

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() [176/183]

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() [177/183]

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() [178/183]

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() [179/183]

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() [180/183]

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() [181/183]

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() [182/183]

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() [183/183]

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

Definition at line 68 of file flutter_windows_unittests.cc.

68  {
69  FlutterDesktopEngineProperties properties = {};
70  properties.assets_path = L"";
71  properties.icu_data_path = L"icudtl.dat";
72  properties.impeller_switch = DefaultImpeller;
73  auto engine = FlutterDesktopEngineCreate(&properties);
74  ASSERT_NE(engine, nullptr);
75  auto texture_registrar = FlutterDesktopEngineGetTextureRegistrar(engine);
76  EXPECT_NE(texture_registrar, nullptr);
78 }
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/271]

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/271]

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/271]

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/271]

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/271]

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/271]

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

Definition at line 291 of file compositor_opengl_unittests.cc.

291  {
292  UseHeadlessEngine();
293 
294  auto compositor =
295  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
296 
297  FlutterBackingStoreConfig config = {};
298  FlutterBackingStore backing_store = {};
299 
300  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
301  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
302  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
303 }

◆ TEST_F() [7/271]

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

Definition at line 465 of file compositor_opengl_unittests.cc.

465  {
466  UseHeadlessEngine();
467 
468  auto compositor = CompositorOpenGL{engine(), kRecordingResolverGLES2,
469  /*enable_impeller=*/false};
470  FlutterBackingStoreConfig config = {};
471  FlutterBackingStore backing_store = {};
472 
473  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
474  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
475  EXPECT_EQ(TexImage2DInternalFormats(), std::vector<GLint>{GL_BGRA_EXT});
476  EXPECT_EQ(backing_store.open_gl.framebuffer.target,
477  static_cast<uint32_t>(GL_BGRA8_EXT));
478  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
479 }

◆ TEST_F() [8/271]

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

Definition at line 495 of file compositor_opengl_unittests.cc.

495  {
496  UseHeadlessEngine();
497 
498  auto compositor = CompositorOpenGL{engine(), kRecordingResolverGLES3,
499  /*enable_impeller=*/false};
500  FlutterBackingStoreConfig config = {};
501  FlutterBackingStore backing_store = {};
502 
503  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
504  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
505  EXPECT_EQ(TexImage2DInternalFormats(), std::vector<GLint>{GL_RGBA8});
506  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
507 }

◆ TEST_F() [9/271]

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

Definition at line 481 of file compositor_opengl_unittests.cc.

481  {
482  UseHeadlessEngine();
483 
484  auto compositor = CompositorOpenGL{engine(), kRecordingResolverGLES2,
485  /*enable_impeller=*/true};
486  FlutterBackingStoreConfig config = {};
487  FlutterBackingStore backing_store = {};
488 
489  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
490  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
491  EXPECT_EQ(TexImage2DInternalFormats(), std::vector<GLint>{GL_BGRA_EXT});
492  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
493 }

◆ TEST_F() [10/271]

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

Definition at line 342 of file compositor_opengl_unittests.cc.

342  {
343  UseHeadlessEngine();
344 
345  static int framebuffer_texture2d_calls = 0;
346  static int framebuffer_texture2d_multisample_calls = 0;
347  framebuffer_texture2d_calls = 0;
348  framebuffer_texture2d_multisample_calls = 0;
349 
350  const impeller::ProcTableGLES::Resolver resolver =
351  [](const char* name) -> void* {
352  std::string_view function_name{name};
353  if (function_name == "glFramebufferTexture2D") {
354  return reinterpret_cast<void*>(
355  +[](GLenum, GLenum, GLenum, GLuint, GLint) {
356  framebuffer_texture2d_calls++;
357  });
358  } else if (function_name == "glFramebufferTexture2DMultisampleEXT") {
359  return reinterpret_cast<void*>(
360  +[](GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) {
361  framebuffer_texture2d_multisample_calls++;
362  });
363  }
364  return kMockResolverWithMSAA(name);
365  };
366 
367  auto compositor =
368  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/true};
369  FlutterBackingStoreConfig config = {};
370  FlutterBackingStore backing_store = {};
371 
372  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
373  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
374  EXPECT_EQ(framebuffer_texture2d_calls, 0);
375  EXPECT_EQ(framebuffer_texture2d_multisample_calls, 1);
376  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
377 }

References name.

◆ TEST_F() [11/271]

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

Definition at line 305 of file compositor_opengl_unittests.cc.

305  {
306  UseHeadlessEngine();
307 
308  static int framebuffer_texture2d_calls = 0;
309  static int framebuffer_texture2d_multisample_calls = 0;
310  framebuffer_texture2d_calls = 0;
311  framebuffer_texture2d_multisample_calls = 0;
312 
313  const impeller::ProcTableGLES::Resolver resolver =
314  [](const char* name) -> void* {
315  std::string_view function_name{name};
316  if (function_name == "glFramebufferTexture2D") {
317  return reinterpret_cast<void*>(
318  +[](GLenum, GLenum, GLenum, GLuint, GLint) {
319  framebuffer_texture2d_calls++;
320  });
321  } else if (function_name == "glFramebufferTexture2DMultisampleEXT") {
322  return reinterpret_cast<void*>(
323  +[](GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) {
324  framebuffer_texture2d_multisample_calls++;
325  });
326  }
327  return kMockResolver(name);
328  };
329 
330  auto compositor =
331  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/true};
332  FlutterBackingStoreConfig config = {};
333  FlutterBackingStore backing_store = {};
334 
335  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
336  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
337  EXPECT_EQ(framebuffer_texture2d_calls, 1);
338  EXPECT_EQ(framebuffer_texture2d_multisample_calls, 0);
339  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
340 }

References name.

◆ TEST_F() [12/271]

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

Definition at line 382 of file compositor_opengl_unittests.cc.

382  {
383  UseHeadlessEngine();
384 
385  static int framebuffer_texture2d_calls = 0;
386  static int framebuffer_texture2d_multisample_calls = 0;
387  static int renderbuffer_storage_multisample_calls = 0;
388  static int renderbuffer_storage_multisample_samples = 0;
389  static int framebuffer_renderbuffer_calls = 0;
390  static int delete_renderbuffers_calls = 0;
391  static int delete_textures_calls = 0;
392 
393  framebuffer_texture2d_calls = 0;
394  framebuffer_texture2d_multisample_calls = 0;
395  renderbuffer_storage_multisample_calls = 0;
396  renderbuffer_storage_multisample_samples = 0;
397  framebuffer_renderbuffer_calls = 0;
398  delete_renderbuffers_calls = 0;
399  delete_textures_calls = 0;
400 
401  const impeller::ProcTableGLES::Resolver resolver =
402  [](const char* name) -> void* {
403  std::string_view function_name{name};
404  if (function_name == "glFramebufferTexture2D") {
405  return reinterpret_cast<void*>(
406  +[](GLenum, GLenum, GLenum, GLuint, GLint) {
407  framebuffer_texture2d_calls++;
408  });
409  } else if (function_name == "glFramebufferTexture2DMultisampleEXT") {
410  return reinterpret_cast<void*>(
411  +[](GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) {
412  framebuffer_texture2d_multisample_calls++;
413  });
414  } else if (function_name == "glGenRenderbuffers") {
415  return reinterpret_cast<void*>(+[](GLsizei n, GLuint* renderbuffers) {
416  static GLuint next_id = 1;
417  for (GLsizei i = 0; i < n; i++) {
418  renderbuffers[i] = next_id++;
419  }
420  });
421  } else if (function_name == "glRenderbufferStorageMultisample") {
422  return reinterpret_cast<void*>(+[](GLenum target, GLsizei samples,
423  GLenum internalformat, GLsizei width,
424  GLsizei height) {
425  renderbuffer_storage_multisample_calls++;
426  renderbuffer_storage_multisample_samples = samples;
427  });
428  } else if (function_name == "glFramebufferRenderbuffer") {
429  return reinterpret_cast<void*>(+[](GLenum, GLenum, GLenum, GLuint) {
430  framebuffer_renderbuffer_calls++;
431  });
432  } else if (function_name == "glDeleteRenderbuffers") {
433  return reinterpret_cast<void*>(
434  +[](GLsizei n, const GLuint* renderbuffers) {
435  delete_renderbuffers_calls += n;
436  });
437  } else if (function_name == "glDeleteTextures") {
438  return reinterpret_cast<void*>(+[](GLsizei n, const GLuint* textures) {
439  delete_textures_calls += n;
440  });
441  }
442  return kMockResolverWithOffscreenMSAA(name);
443  };
444 
445  auto compositor =
446  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/true};
447  FlutterBackingStoreConfig config = {};
448  FlutterBackingStore backing_store = {};
449 
450  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
451  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
452  EXPECT_EQ(framebuffer_texture2d_calls, 0);
453  EXPECT_EQ(framebuffer_texture2d_multisample_calls, 0);
454  EXPECT_EQ(renderbuffer_storage_multisample_calls, 2);
455  EXPECT_EQ(renderbuffer_storage_multisample_samples, 4);
456  EXPECT_EQ(framebuffer_renderbuffer_calls, 3);
457 
458  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
459  EXPECT_EQ(delete_renderbuffers_calls, 2);
460  EXPECT_EQ(delete_textures_calls, 0);
461 }

References name.

◆ TEST_F() [13/271]

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

Definition at line 509 of file compositor_opengl_unittests.cc.

509  {
510  UseHeadlessEngine();
511 
512  auto compositor =
513  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
514 
515  FlutterBackingStoreConfig config = {};
516  FlutterBackingStore backing_store = {};
517 
518  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(false));
519  EXPECT_FALSE(compositor.CreateBackingStore(config, &backing_store));
520 }

◆ TEST_F() [14/271]

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

Definition at line 522 of file compositor_opengl_unittests.cc.

522  {
523  UseHeadlessEngine();
524 
525  const impeller::ProcTableGLES::Resolver resolver = [](const char* name) {
526  std::string function_name{name};
527 
528  if (function_name == "glBlitFramebuffer" ||
529  function_name == "glBlitFramebufferANGLE") {
530  return (void*)nullptr;
531  }
532 
533  return kMockResolver(name);
534  };
535 
536  auto compositor =
537  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/false};
538 
539  FlutterBackingStoreConfig config = {};
540  FlutterBackingStore backing_store = {};
541 
542  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
543  ASSERT_FALSE(compositor.CreateBackingStore(config, &backing_store));
544 }

References name.

◆ TEST_F() [15/271]

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

Definition at line 586 of file compositor_opengl_unittests.cc.

586  {
587  UseEngineWithView(/*add_surface = */ false);
588 
589  auto compositor =
590  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
591 
592  FlutterBackingStoreConfig config = {};
593  FlutterBackingStore backing_store = {};
594 
595  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
596  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
597 
598  FlutterLayer layer = {};
599  layer.type = kFlutterLayerContentTypeBackingStore;
600  layer.backing_store = &backing_store;
601  const FlutterLayer* layer_ptr = &layer;
602 
603  EXPECT_FALSE(compositor.Present(view(), &layer_ptr, 1));
604 
605  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
606 }

◆ TEST_F() [16/271]

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

Definition at line 546 of file compositor_opengl_unittests.cc.

546  {
547  UseEngineWithView();
548 
549  auto compositor =
550  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
551 
552  FlutterBackingStoreConfig config = {};
553  FlutterBackingStore backing_store = {};
554 
555  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
556  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
557 
558  FlutterLayer layer = {};
559  layer.type = kFlutterLayerContentTypeBackingStore;
560  layer.backing_store = &backing_store;
561  const FlutterLayer* layer_ptr = &layer;
562 
563  EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
564  EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
565  EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
566  EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
567 
568  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
569 }

◆ TEST_F() [17/271]

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

Definition at line 571 of file compositor_opengl_unittests.cc.

571  {
572  UseEngineWithView();
573 
574  auto compositor =
575  CompositorOpenGL{engine(), kMockResolver, /*enable_impeller=*/false};
576 
577  // The context will be bound twice: first to initialize the compositor, second
578  // to clear the surface.
579  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
580  EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
581  EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
582  EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
583  EXPECT_TRUE(compositor.Present(view(), nullptr, 0));
584 }

◆ TEST_F() [18/271]

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

Definition at line 608 of file compositor_opengl_unittests.cc.

608  {
609  UseEngineWithView();
610 
611  bool resolved_ANGLE_blit = false;
612  const impeller::ProcTableGLES::Resolver resolver =
613  [&resolved_ANGLE_blit](const char* name) {
614  std::string function_name{name};
615 
616  if (function_name == "glBlitFramebuffer") {
617  return (void*)nullptr;
618  } else if (function_name == "glBlitFramebufferANGLE") {
619  resolved_ANGLE_blit = true;
620  return reinterpret_cast<void*>(&DoNothing);
621  }
622 
623  return kMockResolver(name);
624  };
625 
626  auto compositor =
627  CompositorOpenGL{engine(), resolver, /*enable_impeller=*/false};
628 
629  FlutterBackingStoreConfig config = {};
630  FlutterBackingStore backing_store = {};
631 
632  EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
633  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
634 
635  FlutterLayer layer = {};
636  layer.type = kFlutterLayerContentTypeBackingStore;
637  layer.backing_store = &backing_store;
638  const FlutterLayer* layer_ptr = &layer;
639 
640  EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
641  EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
642  EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
643  EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
644  EXPECT_TRUE(resolved_ANGLE_blit);
645 
646  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
647 }

References name.

◆ TEST_F() [19/271]

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() [20/271]

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() [21/271]

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() [22/271]

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() [23/271]

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() [24/271]

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() [25/271]

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() [26/271]

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() [27/271]

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() [28/271]

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() [29/271]

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() [30/271]

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() [31/271]

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() [32/271]

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

Definition at line 1206 of file flutter_windows_engine_unittests.cc.

1206  {
1207  auto& context = GetContext();
1208  WindowsConfigBuilder builder{context};
1209  builder.SetDartEntrypoint("sendAccessibilityAnnouncement");
1210 
1211  bool done = false;
1212  auto native_entry = CREATE_FFI_LAMBDA([&]() { done = true; });
1213  context.AddFfiNativeFunction("Signal", native_entry);
1214 
1215  EnginePtr engine{builder.RunHeadless()};
1216  ASSERT_NE(engine, nullptr);
1217 
1218  ui::AXPlatformNodeDelegateBase parent_delegate;
1219  AlertPlatformNodeDelegate delegate{parent_delegate};
1220 
1221  auto window_binding_handler =
1222  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1223  EXPECT_CALL(*window_binding_handler, GetAlertDelegate)
1224  .WillOnce(Return(&delegate));
1225 
1226  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
1227  MockFlutterWindowsView view{windows_engine,
1228  std::move(window_binding_handler)};
1229  EngineModifier modifier{windows_engine};
1230  modifier.SetImplicitView(&view);
1231 
1232  windows_engine->UpdateSemanticsEnabled(true);
1233 
1234  EXPECT_CALL(view, NotifyWinEventWrapper).Times(1);
1235 
1236  // Rely on timeout mechanism in CI.
1237  while (!done) {
1238  windows_engine->task_runner()->ProcessTasks();
1239  }
1240 }

References flutter::FlutterWindowsEngine::UpdateSemanticsEnabled().

◆ TEST_F() [33/271]

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

Definition at line 1243 of file flutter_windows_engine_unittests.cc.

1243  {
1244  auto& context = GetContext();
1245  WindowsConfigBuilder builder{context};
1246  builder.SetDartEntrypoint("sendAccessibilityAnnouncement");
1247 
1248  bool done = false;
1249  auto native_entry = CREATE_FFI_LAMBDA([&]() { done = true; });
1250  context.AddFfiNativeFunction("Signal", native_entry);
1251 
1252  EnginePtr engine{builder.RunHeadless()};
1253  ASSERT_NE(engine, nullptr);
1254 
1255  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
1256  windows_engine->UpdateSemanticsEnabled(true);
1257 
1258  // Rely on timeout mechanism in CI.
1259  while (!done) {
1260  windows_engine->task_runner()->ProcessTasks();
1261  }
1262 }

References flutter::FlutterWindowsEngine::UpdateSemanticsEnabled().

◆ TEST_F() [34/271]

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

Definition at line 1266 of file flutter_windows_engine_unittests.cc.

1266  {
1267  fml::testing::LogCapture log_capture;
1268 
1269  auto& context = GetContext();
1270  WindowsConfigBuilder builder{context};
1271  builder.SetDartEntrypoint("sendAccessibilityTooltipEvent");
1272 
1273  bool done = false;
1274  auto native_entry = CREATE_FFI_LAMBDA([&]() { done = true; });
1275  context.AddFfiNativeFunction("Signal", native_entry);
1276 
1277  ViewControllerPtr controller{builder.Run()};
1278  ASSERT_NE(controller, nullptr);
1279 
1280  auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
1281  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine);
1282  windows_engine->UpdateSemanticsEnabled(true);
1283 
1284  // Rely on timeout mechanism in CI.
1285  while (!done) {
1286  windows_engine->task_runner()->ProcessTasks();
1287  }
1288 
1289  // Verify no error was logged.
1290  // Regression test for:
1291  // https://github.com/flutter/flutter/issues/144274
1292  EXPECT_EQ(log_capture.str().find("tooltip"), std::string::npos);
1293 }
FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(FlutterDesktopViewControllerRef ref)

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

◆ TEST_F() [35/271]

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

Definition at line 1054 of file flutter_windows_engine_unittests.cc.

1054  {
1055  FlutterWindowsEngineBuilder builder{GetContext()};
1056  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1057  EngineModifier modifier(engine.get());
1058 
1059  MockEmbedderApiForKeyboard(modifier,
1060  std::make_shared<MockKeyResponseController>());
1061 
1062  engine->Run();
1063 
1064  // Verify that destruction handlers don't overwrite each other.
1065  int result1 = 0;
1066  int result2 = 0;
1067  engine->AddPluginRegistrarDestructionCallback(
1069  auto result = reinterpret_cast<int*>(ref);
1070  *result = 1;
1071  },
1072  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(&result1));
1073  engine->AddPluginRegistrarDestructionCallback(
1075  auto result = reinterpret_cast<int*>(ref);
1076  *result = 2;
1077  },
1078  reinterpret_cast<FlutterDesktopPluginRegistrarRef>(&result2));
1079 
1080  engine->Stop();
1081  EXPECT_EQ(result1, 1);
1082  EXPECT_EQ(result2, 2);
1083 }

◆ TEST_F() [36/271]

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

Definition at line 1828 of file flutter_windows_engine_unittests.cc.

1828  {
1829  FlutterWindowsEngineBuilder builder{GetContext()};
1830  auto engine = builder.Build();
1831 
1832  EngineModifier modifier{engine.get()};
1833 
1834  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1835  modifier.embedder_api().AddView = MOCK_ENGINE_PROC(
1836  AddView,
1837  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
1838  const FlutterAddViewInfo* info) { return kInternalInconsistency; });
1839 
1840  ASSERT_TRUE(engine->Run());
1841 
1842  // Create the first view. This is the implicit view and isn't added to the
1843  // engine.
1844  auto implicit_window = std::make_unique<NiceMock<MockWindowBindingHandler>>();
1845 
1846  std::unique_ptr<FlutterWindowsView> implicit_view =
1847  engine->CreateView(std::move(implicit_window),
1848  /*is_sized_to_content=*/false, BoxConstraints(),
1849  /*allow_implicit_view=*/true);
1850 
1851  EXPECT_TRUE(implicit_view);
1852 
1853  // Create a second view. The embedder attempts to add it to the engine.
1854  auto second_window = std::make_unique<NiceMock<MockWindowBindingHandler>>();
1855 
1856  EXPECT_DEBUG_DEATH(
1857  engine->CreateView(std::move(second_window),
1858  /*is_sized_to_content=*/false, BoxConstraints(),
1859  /*allow_implicit_view=*/false),
1860  "FlutterEngineAddView returned an unexpected result");
1861 }

References flutter::FlutterEngine::Run().

◆ TEST_F() [37/271]

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

Definition at line 1534 of file flutter_windows_engine_unittests.cc.

1534  {
1535  FlutterWindowsEngineBuilder builder{GetContext()};
1536 
1537  auto engine = builder.Build();
1538  auto window_binding_handler =
1539  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1540  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1541 
1542  EngineModifier modifier(engine.get());
1543  modifier.SetImplicitView(&view);
1544  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1545  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1546  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(false));
1547  modifier.SetLifecycleManager(std::move(handler));
1548  engine->lifecycle_manager()->BeginProcessingExit();
1549 
1550  engine->lifecycle_manager()->ExternalWindowMessage(0, WM_CLOSE, 0, 0);
1551 }

References flutter::WindowsLifecycleManager::BeginProcessingExit(), flutter::WindowsLifecycleManager::ExternalWindowMessage(), and flutter::FlutterWindowsEngine::lifecycle_manager().

◆ TEST_F() [38/271]

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

Definition at line 1778 of file flutter_windows_engine_unittests.cc.

1778  {
1779  FlutterWindowsEngineBuilder builder{GetContext()};
1780  builder.SetDartEntrypoint("enableLifecycleToFrom");
1781 
1782  auto engine = builder.Build();
1783  auto window_binding_handler =
1784  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1785  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1786 
1787  EngineModifier modifier(engine.get());
1788  modifier.SetImplicitView(&view);
1789  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1790 
1791  bool lifecycle_began = false;
1792  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1793  handler->begin_processing_callback = [&]() { lifecycle_began = true; };
1794  modifier.SetLifecycleManager(std::move(handler));
1795 
1796  engine->Run();
1797 
1798  while (!lifecycle_began) {
1799  engine->task_runner()->ProcessTasks();
1800  }
1801 }

References flutter::TaskRunner::ProcessTasks(), flutter::FlutterWindowsEngine::Run(), and flutter::FlutterWindowsEngine::task_runner().

◆ TEST_F() [39/271]

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

Definition at line 299 of file flutter_windows_engine_unittests.cc.

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

◆ TEST_F() [40/271]

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

Definition at line 1009 of file flutter_windows_engine_unittests.cc.

1009  {
1010  FlutterWindowsEngineBuilder builder{GetContext()};
1011  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1012  EngineModifier modifier(engine.get());
1013 
1014  bool called = false;
1015  std::string message = "Hello";
1016  modifier.embedder_api().SendSemanticsAction = MOCK_ENGINE_PROC(
1017  SendSemanticsAction, ([&called, &message](auto engine, auto info) {
1018  called = true;
1019  EXPECT_EQ(info->view_id, 456);
1020  EXPECT_EQ(info->node_id, 42);
1021  EXPECT_EQ(info->action, kFlutterSemanticsActionDismiss);
1022  EXPECT_EQ(memcmp(info->data, message.c_str(), message.size()), 0);
1023  EXPECT_EQ(info->data_length, message.size());
1024  return kSuccess;
1025  }));
1026 
1027  auto data = fml::MallocMapping::Copy(message.c_str(), message.size());
1028  engine->DispatchSemanticsAction(456, 42, kFlutterSemanticsActionDismiss,
1029  std::move(data));
1030  EXPECT_TRUE(called);
1031 }

References message.

◆ TEST_F() [41/271]

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

Definition at line 1514 of file flutter_windows_engine_unittests.cc.

1514  {
1515  FlutterWindowsEngineBuilder builder{GetContext()};
1516 
1517  auto engine = builder.Build();
1518  auto window_binding_handler =
1519  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1520  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1521 
1522  EngineModifier modifier(engine.get());
1523  modifier.SetImplicitView(&view);
1524  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1525  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1526  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(false));
1527  modifier.SetLifecycleManager(std::move(handler));
1528  engine->lifecycle_manager()->BeginProcessingExit();
1529 
1530  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1531  0);
1532 }

References flutter::WindowsLifecycleManager::BeginProcessingExit(), flutter::FlutterWindowsEngine::lifecycle_manager(), flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [42/271]

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

Definition at line 1677 of file flutter_windows_engine_unittests.cc.

1677  {
1678  FlutterWindowsEngineBuilder builder{GetContext()};
1679  builder.SetDartEntrypoint("enableLifecycleTest");
1680  bool finished = false;
1681 
1682  auto engine = builder.Build();
1683  auto window_binding_handler =
1684  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1685  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1686 
1687  EngineModifier modifier(engine.get());
1688  modifier.SetImplicitView(&view);
1689  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1690  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1691  EXPECT_CALL(*handler, SetLifecycleState)
1692  .WillRepeatedly([handler_ptr = handler.get()](AppLifecycleState state) {
1693  handler_ptr->WindowsLifecycleManager::SetLifecycleState(state);
1694  });
1695  modifier.SetLifecycleManager(std::move(handler));
1696 
1697  auto binary_messenger =
1698  std::make_unique<BinaryMessengerImpl>(engine->messenger());
1699  // Mark the test only as completed on receiving an inactive state message.
1700  binary_messenger->SetMessageHandler(
1701  "flutter/unittest", [&finished](const uint8_t* message,
1702  size_t message_size, BinaryReply reply) {
1703  std::string contents(message, message + message_size);
1704  EXPECT_NE(contents.find("AppLifecycleState.inactive"),
1705  std::string::npos);
1706  finished = true;
1707  char response[] = "";
1708  reply(reinterpret_cast<uint8_t*>(response), 0);
1709  });
1710 
1711  engine->Run();
1712 
1713  // Test that setting the state before enabling lifecycle does nothing.
1714  HWND hwnd = reinterpret_cast<HWND>(1);
1715  view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1716  view.OnWindowStateEvent(hwnd, WindowStateEvent::kHide);
1717  EXPECT_FALSE(finished);
1718 
1719  // Test that we can set the state afterwards.
1720 
1721  engine->lifecycle_manager()->BeginProcessingLifecycle();
1722  view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1723 
1724  while (!finished) {
1725  engine->task_runner()->ProcessTasks();
1726  }
1727 }

References flutter::WindowsLifecycleManager::BeginProcessingLifecycle(), flutter::kHide, flutter::kShow, flutter::FlutterWindowsEngine::lifecycle_manager(), message, flutter::FlutterWindowsEngine::messenger(), flutter::TaskRunner::ProcessTasks(), flutter::FlutterWindowsEngine::Run(), and flutter::FlutterWindowsEngine::task_runner().

◆ TEST_F() [43/271]

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

Definition at line 1607 of file flutter_windows_engine_unittests.cc.

1607  {
1608  FlutterWindowsEngineBuilder builder{GetContext()};
1609 
1610  auto engine = builder.Build();
1611  auto window_binding_handler =
1612  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1613  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1614 
1615  EngineModifier modifier(engine.get());
1616  modifier.SetImplicitView(&view);
1617  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1618  // Sets lifecycle state to resumed.
1619  engine->Run();
1620 
1621  // Ensure HWND(1) is in the set of visible windows before hiding it.
1622  engine->ProcessExternalWindowMessage(reinterpret_cast<HWND>(1), WM_SHOWWINDOW,
1623  TRUE, NULL);
1624  engine->ProcessExternalWindowMessage(reinterpret_cast<HWND>(1), WM_SHOWWINDOW,
1625  FALSE, NULL);
1626 
1627  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1628  PumpMessage();
1629  }
1630 
1631  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1632  AppLifecycleState::kHidden);
1633 }

References flutter::WindowsLifecycleManager::GetLifecycleState(), flutter::WindowsLifecycleManager::IsUpdateStateScheduled(), flutter::kHidden, flutter::FlutterWindowsEngine::lifecycle_manager(), flutter::FlutterWindowsEngine::ProcessExternalWindowMessage(), and flutter::FlutterWindowsEngine::Run().

◆ TEST_F() [44/271]

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

Definition at line 1117 of file flutter_windows_engine_unittests.cc.

1117  {
1118  FlutterWindowsEngineBuilder builder{GetContext()};
1119  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1120  EXPECT_EQ(engine->GetExecutableName(), "flutter_windows_unittests.exe");
1121 }

◆ TEST_F() [45/271]

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

Definition at line 1635 of file flutter_windows_engine_unittests.cc.

1635  {
1636  FlutterWindowsEngineBuilder builder{GetContext()};
1637  HWND outer = reinterpret_cast<HWND>(1);
1638  HWND inner = reinterpret_cast<HWND>(2);
1639 
1640  auto engine = builder.Build();
1641  auto window_binding_handler =
1642  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1643  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1644  ON_CALL(view, GetWindowHandle).WillByDefault([=]() { return inner; });
1645 
1646  EngineModifier modifier(engine.get());
1647  modifier.SetImplicitView(&view);
1648  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1649  // Sets lifecycle state to resumed.
1650  engine->Run();
1651 
1652  // Show both top-level and Flutter window.
1653  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1654  outer, WM_SHOWWINDOW, TRUE, NULL);
1655  view.OnWindowStateEvent(inner, WindowStateEvent::kShow);
1656  view.OnWindowStateEvent(inner, WindowStateEvent::kFocus);
1657 
1658  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1659  PumpMessage();
1660  }
1661 
1662  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1663  AppLifecycleState::kResumed);
1664 
1665  // Hide Flutter window, but not top level window.
1666  view.OnWindowStateEvent(inner, WindowStateEvent::kHide);
1667 
1668  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1669  PumpMessage();
1670  }
1671 
1672  // The top-level window is still visible, so we ought not enter hidden state.
1673  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1674  AppLifecycleState::kInactive);
1675 }

References flutter::WindowsLifecycleManager::GetLifecycleState(), flutter::WindowsLifecycleManager::IsUpdateStateScheduled(), flutter::kFocus, flutter::kHide, flutter::kInactive, flutter::kResumed, flutter::kShow, flutter::FlutterWindowsEngine::lifecycle_manager(), flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), flutter::FlutterWindowsEngine::Run(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [46/271]

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

Definition at line 1495 of file flutter_windows_engine_unittests.cc.

1495  {
1496  FlutterWindowsEngineBuilder builder{GetContext()};
1497 
1498  auto engine = builder.Build();
1499  auto window_binding_handler =
1500  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1501  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1502 
1503  EngineModifier modifier(engine.get());
1504  modifier.SetImplicitView(&view);
1505  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1506  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1507  EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(0);
1508  modifier.SetLifecycleManager(std::move(handler));
1509 
1510  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1511  0);
1512 }

References flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [47/271]

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

Definition at line 1729 of file flutter_windows_engine_unittests.cc.

1729  {
1730  FlutterWindowsEngineBuilder builder{GetContext()};
1731  builder.SetDartEntrypoint("enableLifecycleToFrom");
1732  bool enabled_lifecycle = false;
1733  bool dart_responded = false;
1734 
1735  auto engine = builder.Build();
1736  auto window_binding_handler =
1737  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1738  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1739 
1740  EngineModifier modifier(engine.get());
1741  modifier.SetImplicitView(&view);
1742  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1743  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1744  EXPECT_CALL(*handler, SetLifecycleState)
1745  .WillRepeatedly([handler_ptr = handler.get()](AppLifecycleState state) {
1746  handler_ptr->WindowsLifecycleManager::SetLifecycleState(state);
1747  });
1748  handler->begin_processing_callback = [&]() { enabled_lifecycle = true; };
1749  modifier.SetLifecycleManager(std::move(handler));
1750 
1751  auto binary_messenger =
1752  std::make_unique<BinaryMessengerImpl>(engine->messenger());
1753  binary_messenger->SetMessageHandler(
1754  "flutter/unittest",
1755  [&](const uint8_t* message, size_t message_size, BinaryReply reply) {
1756  std::string contents(message, message + message_size);
1757  EXPECT_NE(contents.find("AppLifecycleState."), std::string::npos);
1758  dart_responded = true;
1759  char response[] = "";
1760  reply(reinterpret_cast<uint8_t*>(response), 0);
1761  });
1762 
1763  engine->Run();
1764 
1765  while (!enabled_lifecycle) {
1766  engine->task_runner()->ProcessTasks();
1767  }
1768 
1769  HWND hwnd = reinterpret_cast<HWND>(1);
1770  view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1771  view.OnWindowStateEvent(hwnd, WindowStateEvent::kHide);
1772 
1773  while (!dart_responded) {
1774  engine->task_runner()->ProcessTasks();
1775  }
1776 }

References flutter::kHide, flutter::kShow, message, flutter::FlutterWindowsEngine::messenger(), flutter::TaskRunner::ProcessTasks(), flutter::FlutterWindowsEngine::Run(), and flutter::FlutterWindowsEngine::task_runner().

◆ TEST_F() [48/271]

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

Definition at line 1553 of file flutter_windows_engine_unittests.cc.

1553  {
1554  FlutterWindowsEngineBuilder builder{GetContext()};
1555 
1556  auto engine = builder.Build();
1557  auto window_binding_handler =
1558  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1559  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1560 
1561  EngineModifier modifier(engine.get());
1562  modifier.SetImplicitView(&view);
1563  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1564  engine->Run();
1565 
1566  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1567  (HWND)1, WM_SIZE, SIZE_RESTORED, 0);
1568 
1569  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1570  PumpMessage();
1571  }
1572 
1573  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1574  AppLifecycleState::kInactive);
1575 
1576  engine->lifecycle_manager()->OnWindowStateEvent((HWND)1,
1577  WindowStateEvent::kFocus);
1578 
1579  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1580  PumpMessage();
1581  }
1582 
1583  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1584  AppLifecycleState::kResumed);
1585 
1586  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1587  (HWND)1, WM_SIZE, SIZE_MINIMIZED, 0);
1588 
1589  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1590  PumpMessage();
1591  }
1592 
1593  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1594  AppLifecycleState::kHidden);
1595 
1596  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1597  (HWND)1, WM_SIZE, SIZE_RESTORED, 0);
1598 
1599  while (engine->lifecycle_manager()->IsUpdateStateScheduled()) {
1600  PumpMessage();
1601  }
1602 
1603  EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1604  AppLifecycleState::kInactive);
1605 }

References flutter::WindowsLifecycleManager::GetLifecycleState(), flutter::WindowsLifecycleManager::IsUpdateStateScheduled(), flutter::kFocus, flutter::kHidden, flutter::kInactive, flutter::kResumed, flutter::FlutterWindowsEngine::lifecycle_manager(), flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), flutter::WindowsLifecycleManager::OnWindowStateEvent(), flutter::FlutterWindowsEngine::Run(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [49/271]

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

Definition at line 1881 of file flutter_windows_engine_unittests.cc.

1881  {
1882  auto& context = GetContext();
1883  WindowsConfigBuilder builder{context};
1884  builder.SetDartEntrypoint("mergedUIThread");
1885  builder.SetUIThreadPolicy(FlutterDesktopUIThreadPolicy::RunOnPlatformThread);
1886 
1887  std::optional<std::thread::id> ui_thread_id;
1888 
1889  auto native_entry =
1890  CREATE_FFI_LAMBDA([&]() { ui_thread_id = std::this_thread::get_id(); });
1891  context.AddFfiNativeFunction("Signal", native_entry);
1892 
1893  EnginePtr engine{builder.RunHeadless()};
1894  while (!ui_thread_id) {
1895  PumpMessage();
1896  }
1897  ASSERT_EQ(*ui_thread_id, std::this_thread::get_id());
1898 }
@ RunOnPlatformThread

References RunOnPlatformThread.

◆ TEST_F() [50/271]

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

Definition at line 1900 of file flutter_windows_engine_unittests.cc.

1900  {
1901  FlutterWindowsEngineBuilder builder{GetContext()};
1902  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1903  auto window_binding_handler =
1904  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1905  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1906 
1907  EngineModifier modifier(engine.get());
1908  modifier.SetImplicitView(&view);
1909 
1910  FlutterViewFocusChangeRequest request;
1911  request.view_id = kImplicitViewId;
1912 
1913  EXPECT_CALL(view, Focus()).WillOnce(Return(true));
1914  modifier.OnViewFocusChangeRequest(&request);
1915 }

References flutter::kImplicitViewId.

◆ TEST_F() [51/271]

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

Definition at line 899 of file flutter_windows_engine_unittests.cc.

899  {
900  FlutterWindowsEngineBuilder builder{GetContext()};
901  builder.SetDartEntrypoint("hiPlatformChannels");
902 
903  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
904 
905  EngineModifier modifier(engine.get());
906  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
907 
908  auto binary_messenger =
909  std::make_unique<BinaryMessengerImpl>(engine->messenger());
910 
911  engine->Run();
912  bool did_call_callback = false;
913  bool did_call_reply = false;
914  bool did_call_dart_reply = false;
915  std::string channel = "hi";
916  std::unique_ptr<std::thread> reply_thread;
917  binary_messenger->SetMessageHandler(
918  channel,
919  [&did_call_callback, &did_call_dart_reply, &reply_thread](
920  const uint8_t* message, size_t message_size, BinaryReply reply) {
921  if (message_size == 5) {
922  EXPECT_EQ(message[0], static_cast<uint8_t>('h'));
923  reply_thread.reset(new std::thread([reply = std::move(reply)]() {
924  char response[] = {'b', 'y', 'e'};
925  reply(reinterpret_cast<uint8_t*>(response), 3);
926  }));
927  did_call_callback = true;
928  } else {
929  EXPECT_EQ(message_size, 3);
930  EXPECT_EQ(message[0], static_cast<uint8_t>('b'));
931  did_call_dart_reply = true;
932  }
933  });
934  char payload[] = {'h', 'e', 'l', 'l', 'o'};
935  binary_messenger->Send(
936  channel, reinterpret_cast<uint8_t*>(payload), 5,
937  [&did_call_reply](const uint8_t* reply, size_t reply_size) {
938  EXPECT_EQ(reply_size, 5);
939  EXPECT_EQ(reply[0], static_cast<uint8_t>('h'));
940  did_call_reply = true;
941  });
942  // Rely on timeout mechanism in CI.
943  while (!did_call_callback || !did_call_reply || !did_call_dart_reply) {
944  engine->task_runner()->ProcessTasks();
945  }
946  ASSERT_TRUE(reply_thread);
947  reply_thread->join();
948 }

References message.

◆ TEST_F() [52/271]

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

Definition at line 854 of file flutter_windows_engine_unittests.cc.

854  {
855  FlutterWindowsEngineBuilder builder{GetContext()};
856  builder.SetDartEntrypoint("hiPlatformChannels");
857 
858  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
859  EngineModifier modifier(engine.get());
860  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
861 
862  auto binary_messenger =
863  std::make_unique<BinaryMessengerImpl>(engine->messenger());
864 
865  engine->Run();
866  bool did_call_callback = false;
867  bool did_call_reply = false;
868  bool did_call_dart_reply = false;
869  std::string channel = "hi";
870  binary_messenger->SetMessageHandler(
871  channel,
872  [&did_call_callback, &did_call_dart_reply](
873  const uint8_t* message, size_t message_size, BinaryReply reply) {
874  if (message_size == 5) {
875  EXPECT_EQ(message[0], static_cast<uint8_t>('h'));
876  char response[] = {'b', 'y', 'e'};
877  reply(reinterpret_cast<uint8_t*>(response), 3);
878  did_call_callback = true;
879  } else {
880  EXPECT_EQ(message_size, 3);
881  EXPECT_EQ(message[0], static_cast<uint8_t>('b'));
882  did_call_dart_reply = true;
883  }
884  });
885  char payload[] = {'h', 'e', 'l', 'l', 'o'};
886  binary_messenger->Send(
887  channel, reinterpret_cast<uint8_t*>(payload), 5,
888  [&did_call_reply](const uint8_t* reply, size_t reply_size) {
889  EXPECT_EQ(reply_size, 5);
890  EXPECT_EQ(reply[0], static_cast<uint8_t>('h'));
891  did_call_reply = true;
892  });
893  // Rely on timeout mechanism in CI.
894  while (!did_call_callback || !did_call_reply || !did_call_dart_reply) {
895  engine->task_runner()->ProcessTasks();
896  }
897 }

References message.

◆ TEST_F() [53/271]

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

Definition at line 1166 of file flutter_windows_engine_unittests.cc.

1166  {
1167  FlutterWindowsEngineBuilder builder{GetContext()};
1168  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1169  EngineModifier modifier(engine.get());
1170 
1171  modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
1172  PostRenderThreadTask, ([](auto engine, auto callback, auto context) {
1173  callback(context);
1174  return kSuccess;
1175  }));
1176 
1177  bool called = false;
1178  engine->PostRasterThreadTask([&called]() { called = true; });
1179 
1180  EXPECT_TRUE(called);
1181 }

References callback.

◆ TEST_F() [54/271]

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

Definition at line 1803 of file flutter_windows_engine_unittests.cc.

1803  {
1804  FlutterWindowsEngineBuilder builder{GetContext()};
1805  builder.SetDartEntrypoint("sendCreatePlatformViewMethod");
1806  auto engine = builder.Build();
1807 
1808  EngineModifier modifier{engine.get()};
1809  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1810 
1811  bool received_call = false;
1812 
1813  auto manager = std::make_unique<MockPlatformViewManager>(engine.get());
1814  EXPECT_CALL(*manager, AddPlatformView)
1815  .WillOnce([&](PlatformViewId id, std::string_view type_name) {
1816  received_call = true;
1817  return true;
1818  });
1819  modifier.SetPlatformViewPlugin(std::move(manager));
1820 
1821  engine->Run();
1822 
1823  while (!received_call) {
1824  engine->task_runner()->ProcessTasks();
1825  }
1826 }
int64_t PlatformViewId

References flutter::TaskRunner::ProcessTasks(), flutter::FlutterWindowsEngine::Run(), and flutter::FlutterWindowsEngine::task_runner().

◆ TEST_F() [55/271]

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

Definition at line 1863 of file flutter_windows_engine_unittests.cc.

1863  {
1864  FlutterWindowsEngineBuilder builder{GetContext()};
1865  builder.SetDartEntrypoint("sendCreatePlatformViewMethod");
1866  auto engine = builder.Build();
1867 
1868  EngineModifier modifier{engine.get()};
1869 
1870  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1871  modifier.embedder_api().RemoveView = MOCK_ENGINE_PROC(
1872  RemoveView,
1873  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
1874  const FlutterRemoveViewInfo* info) { return kInternalInconsistency; });
1875 
1876  ASSERT_TRUE(engine->Run());
1877  EXPECT_DEBUG_DEATH(engine->RemoveView(123),
1878  "FlutterEngineRemoveView returned an unexpected result");
1879 }

References flutter::FlutterWindowsEngine::RemoveView(), and flutter::FlutterEngine::Run().

◆ TEST_F() [56/271]

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

Definition at line 139 of file flutter_windows_engine_unittests.cc.

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

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

◆ TEST_F() [57/271]

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

Definition at line 57 of file flutter_windows_engine_unittests.cc.

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

References flutter::kImplicitViewId.

◆ TEST_F() [58/271]

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

Definition at line 326 of file flutter_windows_engine_unittests.cc.

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

References DisabledImpeller, message, and user_data.

◆ TEST_F() [59/271]

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

Definition at line 601 of file flutter_windows_engine_unittests.cc.

602  {
603  FlutterWindowsEngineBuilder builder{GetContext()};
604  builder.SetImpellerSwitch(EnabledImpeller);
605  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
606 
607  std::vector<std::string> switches =
608  RunImpellerWithSurfaceOrigin(engine.get(), /*top_left=*/false);
609 
610  EXPECT_THAT(switches,
611  ::testing::Not(::testing::Contains(kTopLeftOriginSwitch)));
612 }
@ EnabledImpeller

References EnabledImpeller.

◆ TEST_F() [60/271]

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

Definition at line 775 of file flutter_windows_engine_unittests.cc.

775  {
776  FlutterWindowsEngineBuilder builder{GetContext()};
777  builder.SetSwitches({"--enable-impeller=false"});
778  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
779  EngineModifier modifier(engine.get());
780 
781  modifier.embedder_api().NotifyDisplayUpdate =
782  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
783  ([](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
784  const FlutterEngineDisplaysUpdateType update_type,
785  const FlutterEngineDisplay* embedder_displays,
786  size_t display_count) { return kSuccess; }));
787 
788  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
789  UpdateAccessibilityFeatures,
790  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
791  FlutterAccessibilityFeature flags) { return kSuccess; });
792 
793  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
794  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
795  size_t locales_count) { return kSuccess; }));
796 
797  modifier.embedder_api().SendPlatformMessage =
798  MOCK_ENGINE_PROC(SendPlatformMessage,
799  ([](auto engine, auto message) { return kSuccess; }));
800 
801  bool run_called = false;
802  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
803  Run, ([&run_called](size_t version, const FlutterRendererConfig* config,
804  const FlutterProjectArgs* args, void* user_data,
805  FLUTTER_API_SYMBOL(FlutterEngine)* engine_out) {
806  run_called = true;
807  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
808 
809  bool has_disable_impeller_switch = false;
810  for (int i = 0; i < args->command_line_argc; ++i) {
811  if (strcmp(args->command_line_argv[i], "--enable-impeller=false") ==
812  0) {
813  has_disable_impeller_switch = true;
814  }
815  }
816  EXPECT_TRUE(has_disable_impeller_switch);
817  return kSuccess;
818  }));
819 
820  engine->Run();
821 
822  EXPECT_TRUE(run_called);
823 
824  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
825 }

References message, and user_data.

◆ TEST_F() [61/271]

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

Definition at line 415 of file flutter_windows_engine_unittests.cc.

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

References DefaultImpeller, message, and user_data.

◆ TEST_F() [62/271]

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

Definition at line 380 of file flutter_windows_engine_unittests.cc.

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

References message.

◆ TEST_F() [63/271]

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

Definition at line 669 of file flutter_windows_engine_unittests.cc.

669  {
670  FlutterWindowsEngineBuilder builder{GetContext()};
671  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
672  EngineModifier modifier(engine.get());
673 
674  modifier.embedder_api().NotifyDisplayUpdate =
675  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
676  ([](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
677  const FlutterEngineDisplaysUpdateType update_type,
678  const FlutterEngineDisplay* embedder_displays,
679  size_t display_count) { return kSuccess; }));
680 
681  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
682  UpdateAccessibilityFeatures,
683  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
684  FlutterAccessibilityFeature flags) { return kSuccess; });
685 
686  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
687  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
688  size_t locales_count) { return kSuccess; }));
689 
690  modifier.embedder_api().SendPlatformMessage =
691  MOCK_ENGINE_PROC(SendPlatformMessage,
692  ([](auto engine, auto message) { return kSuccess; }));
693 
694  bool run_called = false;
695  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
696  Run, ([&run_called](size_t version, const FlutterRendererConfig* config,
697  const FlutterProjectArgs* args, void* user_data,
698  FLUTTER_API_SYMBOL(FlutterEngine)* engine_out) {
699  run_called = true;
700  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
701 
702  bool has_flutter_gpu_switch = false;
703  for (int i = 0; i < args->command_line_argc; ++i) {
704  if (strcmp(args->command_line_argv[i], "--enable-flutter-gpu") == 0) {
705  has_flutter_gpu_switch = true;
706  }
707  }
708  EXPECT_FALSE(has_flutter_gpu_switch);
709  return kSuccess;
710  }));
711 
712  // Set the EGL manager to !nullptr to test ANGLE rendering.
713  modifier.SetEGLManager(std::make_unique<egl::MockManager>());
714 
715  engine->Run();
716 
717  EXPECT_TRUE(run_called);
718 
719  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
720  modifier.ReleaseEGLManager();
721 }

References message, and user_data.

◆ TEST_F() [64/271]

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

Definition at line 723 of file flutter_windows_engine_unittests.cc.

723  {
724  FlutterWindowsEngineBuilder builder{GetContext()};
725  builder.SetImpellerSwitch(DisabledImpeller);
726  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
727  EngineModifier modifier(engine.get());
728 
729  modifier.embedder_api().NotifyDisplayUpdate =
730  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
731  ([](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
732  const FlutterEngineDisplaysUpdateType update_type,
733  const FlutterEngineDisplay* embedder_displays,
734  size_t display_count) { return kSuccess; }));
735 
736  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
737  UpdateAccessibilityFeatures,
738  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
739  FlutterAccessibilityFeature flags) { return kSuccess; });
740 
741  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
742  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
743  size_t locales_count) { return kSuccess; }));
744 
745  modifier.embedder_api().SendPlatformMessage =
746  MOCK_ENGINE_PROC(SendPlatformMessage,
747  ([](auto engine, auto message) { return kSuccess; }));
748 
749  bool run_called = false;
750  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
751  Run, ([&run_called](size_t version, const FlutterRendererConfig* config,
752  const FlutterProjectArgs* args, void* user_data,
753  FLUTTER_API_SYMBOL(FlutterEngine)* engine_out) {
754  run_called = true;
755  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
756 
757  bool has_disable_impeller_switch = false;
758  for (int i = 0; i < args->command_line_argc; ++i) {
759  if (strcmp(args->command_line_argv[i], "--enable-impeller=false") ==
760  0) {
761  has_disable_impeller_switch = true;
762  }
763  }
764  EXPECT_TRUE(has_disable_impeller_switch);
765  return kSuccess;
766  }));
767 
768  engine->Run();
769 
770  EXPECT_TRUE(run_called);
771 
772  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
773 }

References DisabledImpeller, message, and user_data.

◆ TEST_F() [65/271]

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

Definition at line 614 of file flutter_windows_engine_unittests.cc.

614  {
615  FlutterWindowsEngineBuilder builder{GetContext()};
616  builder.SetEnableFlutterGpu(true);
617  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
618  EngineModifier modifier(engine.get());
619 
620  modifier.embedder_api().NotifyDisplayUpdate =
621  MOCK_ENGINE_PROC(NotifyDisplayUpdate,
622  ([](FLUTTER_API_SYMBOL(FlutterEngine) raw_engine,
623  const FlutterEngineDisplaysUpdateType update_type,
624  const FlutterEngineDisplay* embedder_displays,
625  size_t display_count) { return kSuccess; }));
626 
627  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
628  UpdateAccessibilityFeatures,
629  [](FLUTTER_API_SYMBOL(FlutterEngine) engine,
630  FlutterAccessibilityFeature flags) { return kSuccess; });
631 
632  modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
633  UpdateLocales, ([](auto engine, const FlutterLocale** locales,
634  size_t locales_count) { return kSuccess; }));
635 
636  modifier.embedder_api().SendPlatformMessage =
637  MOCK_ENGINE_PROC(SendPlatformMessage,
638  ([](auto engine, auto message) { return kSuccess; }));
639 
640  bool run_called = false;
641  modifier.embedder_api().Run = MOCK_ENGINE_PROC(
642  Run, ([&run_called](size_t version, const FlutterRendererConfig* config,
643  const FlutterProjectArgs* args, void* user_data,
644  FLUTTER_API_SYMBOL(FlutterEngine)* engine_out) {
645  run_called = true;
646  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
647 
648  bool has_flutter_gpu_switch = false;
649  for (int i = 0; i < args->command_line_argc; ++i) {
650  if (strcmp(args->command_line_argv[i], "--enable-flutter-gpu") == 0) {
651  has_flutter_gpu_switch = true;
652  }
653  }
654  EXPECT_TRUE(has_flutter_gpu_switch);
655  return kSuccess;
656  }));
657 
658  // Set the EGL manager to !nullptr to test ANGLE rendering.
659  modifier.SetEGLManager(std::make_unique<egl::MockManager>());
660 
661  engine->Run();
662 
663  EXPECT_TRUE(run_called);
664 
665  modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
666  modifier.ReleaseEGLManager();
667 }

References message, and user_data.

◆ TEST_F() [66/271]

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

Definition at line 478 of file flutter_windows_engine_unittests.cc.

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

References EnabledImpeller, message, and user_data.

◆ TEST_F() [67/271]

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

Definition at line 589 of file flutter_windows_engine_unittests.cc.

590  {
591  FlutterWindowsEngineBuilder builder{GetContext()};
592  builder.SetImpellerSwitch(EnabledImpeller);
593  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
594 
595  std::vector<std::string> switches =
596  RunImpellerWithSurfaceOrigin(engine.get(), /*top_left=*/true);
597 
598  EXPECT_THAT(switches, ::testing::Contains(kTopLeftOriginSwitch));
599 }

References EnabledImpeller.

◆ TEST_F() [68/271]

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

Definition at line 1085 of file flutter_windows_engine_unittests.cc.

1085  {
1086  FlutterWindowsEngineBuilder builder{GetContext()};
1087  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1088  EngineModifier modifier(engine.get());
1089 
1090  bool called = false;
1091  modifier.embedder_api().ScheduleFrame =
1092  MOCK_ENGINE_PROC(ScheduleFrame, ([&called](auto engine) {
1093  called = true;
1094  return kSuccess;
1095  }));
1096 
1097  engine->ScheduleFrame();
1098  EXPECT_TRUE(called);
1099 }

◆ TEST_F() [69/271]

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

Definition at line 827 of file flutter_windows_engine_unittests.cc.

827  {
828  FlutterWindowsEngineBuilder builder{GetContext()};
829  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
830  EngineModifier modifier(engine.get());
831 
832  const char* channel = "test";
833  const std::vector<uint8_t> test_message = {1, 2, 3, 4};
834 
835  // Without a response, SendPlatformMessage should be a simple pass-through.
836  bool called = false;
837  modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
838  SendPlatformMessage, ([&called, test_message](auto engine, auto message) {
839  called = true;
840  EXPECT_STREQ(message->channel, "test");
841  EXPECT_EQ(message->message_size, test_message.size());
842  EXPECT_EQ(memcmp(message->message, test_message.data(),
843  message->message_size),
844  0);
845  EXPECT_EQ(message->response_handle, nullptr);
846  return kSuccess;
847  }));
848 
849  engine->SendPlatformMessage(channel, test_message.data(), test_message.size(),
850  nullptr, nullptr);
851  EXPECT_TRUE(called);
852 }

References message.

◆ TEST_F() [70/271]

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

Definition at line 950 of file flutter_windows_engine_unittests.cc.

950  {
951  FlutterWindowsEngineBuilder builder{GetContext()};
952  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
953  EngineModifier modifier(engine.get());
954 
955  const char* channel = "test";
956  const std::vector<uint8_t> test_message = {1, 2, 3, 4};
957  auto* dummy_response_handle =
958  reinterpret_cast<FlutterPlatformMessageResponseHandle*>(5);
959  const FlutterDesktopBinaryReply reply_handler = [](auto... args) {};
960  void* reply_user_data = reinterpret_cast<void*>(6);
961 
962  // When a response is requested, a handle should be created, passed as part
963  // of the message, and then released.
964  bool create_response_handle_called = false;
965  modifier.embedder_api().PlatformMessageCreateResponseHandle =
966  MOCK_ENGINE_PROC(
967  PlatformMessageCreateResponseHandle,
968  ([&create_response_handle_called, &reply_handler, reply_user_data,
969  dummy_response_handle](auto engine, auto reply, auto user_data,
970  auto response_handle) {
971  create_response_handle_called = true;
972  EXPECT_EQ(reply, reply_handler);
973  EXPECT_EQ(user_data, reply_user_data);
974  EXPECT_NE(response_handle, nullptr);
975  *response_handle = dummy_response_handle;
976  return kSuccess;
977  }));
978  bool release_response_handle_called = false;
979  modifier.embedder_api().PlatformMessageReleaseResponseHandle =
980  MOCK_ENGINE_PROC(
981  PlatformMessageReleaseResponseHandle,
982  ([&release_response_handle_called, dummy_response_handle](
983  auto engine, auto response_handle) {
984  release_response_handle_called = true;
985  EXPECT_EQ(response_handle, dummy_response_handle);
986  return kSuccess;
987  }));
988  bool send_message_called = false;
989  modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
990  SendPlatformMessage, ([&send_message_called, test_message,
991  dummy_response_handle](auto engine, auto message) {
992  send_message_called = true;
993  EXPECT_STREQ(message->channel, "test");
994  EXPECT_EQ(message->message_size, test_message.size());
995  EXPECT_EQ(memcmp(message->message, test_message.data(),
996  message->message_size),
997  0);
998  EXPECT_EQ(message->response_handle, dummy_response_handle);
999  return kSuccess;
1000  }));
1001 
1002  engine->SendPlatformMessage(channel, test_message.data(), test_message.size(),
1003  reply_handler, reply_user_data);
1004  EXPECT_TRUE(create_response_handle_called);
1005  EXPECT_TRUE(release_response_handle_called);
1006  EXPECT_TRUE(send_message_called);
1007 }
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)

References message, and user_data.

◆ TEST_F() [71/271]

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

Definition at line 1101 of file flutter_windows_engine_unittests.cc.

1101  {
1102  FlutterWindowsEngineBuilder builder{GetContext()};
1103  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1104  EngineModifier modifier(engine.get());
1105 
1106  bool called = false;
1107  modifier.embedder_api().SetNextFrameCallback = MOCK_ENGINE_PROC(
1108  SetNextFrameCallback, ([&called](auto engine, auto callback, auto data) {
1109  called = true;
1110  return kSuccess;
1111  }));
1112 
1113  engine->SetNextFrameCallback([]() {});
1114  EXPECT_TRUE(called);
1115 }

References callback.

◆ TEST_F() [72/271]

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

Definition at line 1033 of file flutter_windows_engine_unittests.cc.

1033  {
1034  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kBackground);
1035  EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
1036  THREAD_PRIORITY_BELOW_NORMAL);
1037 
1038  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kDisplay);
1039  EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
1040  THREAD_PRIORITY_ABOVE_NORMAL);
1041 
1042  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kRaster);
1043  EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
1044  THREAD_PRIORITY_ABOVE_NORMAL);
1045 
1046  // FlutterThreadPriority::kNormal does not change thread priority, reset to 0
1047  // here.
1048  SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
1049 
1050  WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kNormal);
1051  EXPECT_EQ(GetThreadPriority(GetCurrentThread()), THREAD_PRIORITY_NORMAL);
1052 }
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)

References flutter::WindowsPlatformThreadPrioritySetter().

◆ TEST_F() [73/271]

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

Definition at line 69 of file flutter_windows_engine_unittests.cc.

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

◆ TEST_F() [74/271]

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

Definition at line 91 of file flutter_windows_engine_unittests.cc.

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

◆ TEST_F() [75/271]

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

Definition at line 1320 of file flutter_windows_engine_unittests.cc.

1320  {
1321  FlutterWindowsEngineBuilder builder{GetContext()};
1322  builder.SetDartEntrypoint("exitTestExit");
1323  bool finished = false;
1324 
1325  auto engine = builder.Build();
1326  auto window_binding_handler =
1327  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1328  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1329 
1330  EngineModifier modifier(engine.get());
1331  modifier.SetImplicitView(&view);
1332  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1333  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1334  EXPECT_CALL(*handler, Quit)
1335  .WillOnce([&finished](std::optional<HWND> hwnd,
1336  std::optional<WPARAM> wparam,
1337  std::optional<LPARAM> lparam,
1338  UINT exit_code) { finished = exit_code == 0; });
1339  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillRepeatedly(Return(true));
1340  modifier.SetLifecycleManager(std::move(handler));
1341 
1342  engine->lifecycle_manager()->BeginProcessingExit();
1343 
1344  engine->Run();
1345 
1346  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1347  0);
1348 
1349  // The test will only succeed when this while loop exits. Otherwise it will
1350  // timeout.
1351  while (!finished) {
1352  engine->task_runner()->ProcessTasks();
1353  }
1354 }

References flutter::WindowsLifecycleManager::BeginProcessingExit(), flutter::FlutterWindowsEngine::lifecycle_manager(), flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), flutter::TaskRunner::ProcessTasks(), flutter::FlutterWindowsEngine::Run(), flutter::FlutterWindowsEngine::task_runner(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [76/271]

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

Definition at line 1356 of file flutter_windows_engine_unittests.cc.

1356  {
1357  FlutterWindowsEngineBuilder builder{GetContext()};
1358  builder.SetDartEntrypoint("exitTestCancel");
1359  bool did_call = false;
1360 
1361  auto engine = builder.Build();
1362  auto window_binding_handler =
1363  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1364  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1365 
1366  EngineModifier modifier(engine.get());
1367  modifier.SetImplicitView(&view);
1368  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1369  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1370  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillRepeatedly(Return(true));
1371  EXPECT_CALL(*handler, Quit).Times(0);
1372  modifier.SetLifecycleManager(std::move(handler));
1373  engine->lifecycle_manager()->BeginProcessingExit();
1374 
1375  auto binary_messenger =
1376  std::make_unique<BinaryMessengerImpl>(engine->messenger());
1377  binary_messenger->SetMessageHandler(
1378  "flutter/platform", [&did_call](const uint8_t* message,
1379  size_t message_size, BinaryReply reply) {
1380  std::string contents(message, message + message_size);
1381  EXPECT_NE(contents.find("\"method\":\"System.exitApplication\""),
1382  std::string::npos);
1383  EXPECT_NE(contents.find("\"type\":\"required\""), std::string::npos);
1384  EXPECT_NE(contents.find("\"exitCode\":0"), std::string::npos);
1385  did_call = true;
1386  char response[] = "";
1387  reply(reinterpret_cast<uint8_t*>(response), 0);
1388  });
1389 
1390  engine->Run();
1391 
1392  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1393  0);
1394 
1395  while (!did_call) {
1396  engine->task_runner()->ProcessTasks();
1397  }
1398 }

References flutter::WindowsLifecycleManager::BeginProcessingExit(), flutter::FlutterWindowsEngine::lifecycle_manager(), message, flutter::FlutterWindowsEngine::messenger(), flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), flutter::TaskRunner::ProcessTasks(), flutter::FlutterWindowsEngine::Run(), flutter::FlutterWindowsEngine::task_runner(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [77/271]

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

Definition at line 1462 of file flutter_windows_engine_unittests.cc.

1462  {
1463  FlutterWindowsEngineBuilder builder{GetContext()};
1464  builder.SetDartEntrypoint("exitTestExit");
1465  bool finished = false;
1466 
1467  auto engine = builder.Build();
1468  auto window_binding_handler =
1469  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1470  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1471 
1472  EngineModifier modifier(engine.get());
1473  modifier.SetImplicitView(&view);
1474  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1475  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1476  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce([&finished]() {
1477  finished = true;
1478  return false;
1479  });
1480  // Quit should not be called when there is more than one window.
1481  EXPECT_CALL(*handler, Quit).Times(0);
1482  modifier.SetLifecycleManager(std::move(handler));
1483  engine->lifecycle_manager()->BeginProcessingExit();
1484 
1485  engine->Run();
1486 
1487  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1488  0);
1489 
1490  while (!finished) {
1491  engine->task_runner()->ProcessTasks();
1492  }
1493 }

References flutter::WindowsLifecycleManager::BeginProcessingExit(), flutter::FlutterWindowsEngine::lifecycle_manager(), flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), flutter::TaskRunner::ProcessTasks(), flutter::FlutterWindowsEngine::Run(), flutter::FlutterWindowsEngine::task_runner(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [78/271]

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

Definition at line 1403 of file flutter_windows_engine_unittests.cc.

1403  {
1404  FlutterWindowsEngineBuilder builder{GetContext()};
1405  builder.SetDartEntrypoint("exitTestExit");
1406  bool second_close = false;
1407 
1408  auto engine = builder.Build();
1409  auto window_binding_handler =
1410  std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1411  MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1412 
1413  EngineModifier modifier(engine.get());
1414  modifier.SetImplicitView(&view);
1415  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1416  auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1417  EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(true));
1418  EXPECT_CALL(*handler, Quit)
1419  .WillOnce([handler_ptr = handler.get()](
1420  std::optional<HWND> hwnd, std::optional<WPARAM> wparam,
1421  std::optional<LPARAM> lparam, UINT exit_code) {
1422  handler_ptr->WindowsLifecycleManager::Quit(hwnd, wparam, lparam,
1423  exit_code);
1424  });
1425  EXPECT_CALL(*handler, DispatchMessage)
1426  .WillRepeatedly(
1427  [&engine](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
1428  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1429  hwnd, msg, wparam, lparam);
1430  });
1431  modifier.SetLifecycleManager(std::move(handler));
1432  engine->lifecycle_manager()->BeginProcessingExit();
1433 
1434  engine->Run();
1435 
1436  // This delegate will be registered after the lifecycle manager, so it will be
1437  // called only when a message is not consumed by the lifecycle manager. This
1438  // should be called on the second, synthesized WM_CLOSE message that the
1439  // lifecycle manager posts.
1440  engine->window_proc_delegate_manager()->RegisterTopLevelWindowProcDelegate(
1441  [](HWND hwnd, UINT message, WPARAM wpar, LPARAM lpar, void* user_data,
1442  LRESULT* result) {
1443  switch (message) {
1444  case WM_CLOSE: {
1445  bool* called = reinterpret_cast<bool*>(user_data);
1446  *called = true;
1447  return true;
1448  }
1449  }
1450  return false;
1451  },
1452  reinterpret_cast<void*>(&second_close));
1453 
1454  engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
1455  0);
1456 
1457  while (!second_close) {
1458  engine->task_runner()->ProcessTasks();
1459  }
1460 }

References flutter::WindowsLifecycleManager::BeginProcessingExit(), flutter::FlutterWindowsEngine::lifecycle_manager(), message, flutter::WindowProcDelegateManager::OnTopLevelWindowProc(), flutter::TaskRunner::ProcessTasks(), flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate(), flutter::FlutterWindowsEngine::Run(), flutter::FlutterWindowsEngine::task_runner(), user_data, and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

◆ TEST_F() [79/271]

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

Definition at line 1125 of file flutter_windows_engine_unittests.cc.

1125  {
1126  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1127  EXPECT_CALL(*windows_proc_table, GetHighContrastEnabled)
1128  .WillOnce(Return(true))
1129  .WillOnce(Return(false));
1130 
1131  FlutterWindowsEngineBuilder builder{GetContext()};
1132  builder.SetWindowsProcTable(windows_proc_table);
1133  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
1134  EngineModifier modifier(engine.get());
1135 
1136  std::optional<FlutterAccessibilityFeature> engine_flags;
1137  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
1138  UpdateAccessibilityFeatures, ([&engine_flags](auto engine, auto flags) {
1139  engine_flags = flags;
1140  return kSuccess;
1141  }));
1142  modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
1143  SendPlatformMessage,
1144  [](auto engine, const auto message) { return kSuccess; });
1145 
1146  // 1: High contrast is enabled.
1147  engine->UpdateHighContrastMode();
1148 
1149  EXPECT_TRUE(engine->high_contrast_enabled());
1150  EXPECT_TRUE(engine_flags.has_value());
1151  EXPECT_TRUE(
1152  engine_flags.value() &
1153  FlutterAccessibilityFeature::kFlutterAccessibilityFeatureHighContrast);
1154 
1155  // 2: High contrast is disabled.
1156  engine_flags.reset();
1157  engine->UpdateHighContrastMode();
1158 
1159  EXPECT_FALSE(engine->high_contrast_enabled());
1160  EXPECT_TRUE(engine_flags.has_value());
1161  EXPECT_FALSE(
1162  engine_flags.value() &
1163  FlutterAccessibilityFeature::kFlutterAccessibilityFeatureHighContrast);
1164 }

References message.

◆ TEST_F() [80/271]

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

Definition at line 1917 of file flutter_windows_engine_unittests.cc.

1917  {
1918  auto& context = GetContext();
1919  WindowsConfigBuilder builder{context};
1920  builder.SetDartEntrypoint("sendSemanticsTreeInfo");
1921 
1922  // Setup: a signal for when we have send out all of our semantics updates
1923  bool done = false;
1924  auto native_entry = CREATE_FFI_LAMBDA([&]() { done = true; });
1925  context.AddFfiNativeFunction("Signal", native_entry);
1926 
1927  // Setup: Create the engine and two views + enable semantics
1928  EnginePtr engine{builder.RunHeadless()};
1929  ASSERT_NE(engine, nullptr);
1930 
1931  auto window_binding_handler1 =
1932  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1933  auto window_binding_handler2 =
1934  std::make_unique<NiceMock<MockWindowBindingHandler>>();
1935 
1936  // The following mocks are required by
1937  // FlutterWindowsView::CreateWindowMetricsEvent so that we create a valid
1938  // view.
1939  EXPECT_CALL(*window_binding_handler1, GetPhysicalWindowBounds)
1940  .WillRepeatedly(testing::Return(PhysicalWindowBounds{100, 100}));
1941  EXPECT_CALL(*window_binding_handler1, GetDpiScale)
1942  .WillRepeatedly(testing::Return(96.0));
1943  EXPECT_CALL(*window_binding_handler2, GetPhysicalWindowBounds)
1944  .WillRepeatedly(testing::Return(PhysicalWindowBounds{200, 200}));
1945  EXPECT_CALL(*window_binding_handler2, GetDpiScale)
1946  .WillRepeatedly(testing::Return(96.0));
1947 
1948  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
1949  EngineModifier modifier{windows_engine};
1950  modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1951 
1952  // We want to avoid adding an implicit view as the first view
1953  modifier.SetNextViewId(kImplicitViewId + 1);
1954 
1955  auto view1 = windows_engine->CreateView(std::move(window_binding_handler1),
1956  /*is_sized_to_content=*/false,
1957  BoxConstraints(),
1958  /*allow_implicit_view=*/false);
1959  auto view2 = windows_engine->CreateView(std::move(window_binding_handler2),
1960  /*is_sized_to_content=*/false,
1961  BoxConstraints(),
1962  /*allow_implicit_view=*/false);
1963 
1964  // Act: UpdateSemanticsEnabled will trigger the semantics updates
1965  // to get sent.
1966  windows_engine->UpdateSemanticsEnabled(true);
1967 
1968  while (!done) {
1969  windows_engine->task_runner()->ProcessTasks();
1970  }
1971 
1972  auto accessibility_bridge1 = view1->accessibility_bridge().lock();
1973  auto accessibility_bridge2 = view2->accessibility_bridge().lock();
1974 
1975  // Expect: that the semantics trees are updated with their
1976  // respective nodes.
1977  while (
1978  !accessibility_bridge1->GetPlatformNodeFromTree(view1->view_id() + 1)) {
1979  windows_engine->task_runner()->ProcessTasks();
1980  }
1981 
1982  while (
1983  !accessibility_bridge2->GetPlatformNodeFromTree(view2->view_id() + 1)) {
1984  windows_engine->task_runner()->ProcessTasks();
1985  }
1986 
1987  // Rely on timeout mechanism in CI.
1988  auto tree1 = accessibility_bridge1->GetTree();
1989  auto tree2 = accessibility_bridge2->GetTree();
1990  EXPECT_NE(tree1->GetFromId(view1->view_id() + 1), nullptr);
1991  EXPECT_NE(tree2->GetFromId(view2->view_id() + 1), nullptr);
1992 }

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

◆ TEST_F() [81/271]

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

Definition at line 1094 of file flutter_window_unittests.cc.

1094  {
1095  MockFlutterWindow win32window;
1096 
1097  EXPECT_EQ(win32window.GetNativeViewAccessible(), nullptr);
1098 }

◆ TEST_F() [82/271]

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

Definition at line 1102 of file flutter_window_unittests.cc.

1102  {
1103  std::unique_ptr<FlutterWindowsEngine> engine =
1104  FlutterWindowsEngineBuilder{GetContext()}.Build();
1105  auto win32window = std::make_unique<MockFlutterWindow>();
1106  EXPECT_CALL(*win32window.get(), GetAxFragmentRootDelegate())
1107  .WillRepeatedly(Return(nullptr));
1108  EXPECT_CALL(*win32window.get(), OnWindowStateEvent).Times(AnyNumber());
1109  EXPECT_CALL(*win32window.get(), GetWindowHandle).Times(AnyNumber());
1110  MockFlutterWindowsView view{engine.get(), std::move(win32window)};
1111  std::wstring message = L"Test alert";
1112  EXPECT_CALL(view, NotifyWinEventWrapper(_, ax::mojom::Event::kAlert))
1113  .Times(1);
1114  view.AnnounceAlert(message);
1115 
1116  IAccessible* alert = view.AlertNode();
1117  VARIANT self{.vt = VT_I4, .lVal = CHILDID_SELF};
1118  BSTR strptr;
1119  alert->get_accName(self, &strptr);
1120  EXPECT_EQ(message, strptr);
1121 
1122  alert->get_accDescription(self, &strptr);
1123  EXPECT_EQ(message, strptr);
1124 
1125  alert->get_accValue(self, &strptr);
1126  EXPECT_EQ(message, strptr);
1127 
1128  VARIANT role;
1129  alert->get_accRole(self, &role);
1130  EXPECT_EQ(role.vt, VT_I4);
1131  EXPECT_EQ(role.lVal, ROLE_SYSTEM_ALERT);
1132 }

References flutter::IAccessible, and message.

◆ TEST_F() [83/271]

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

Definition at line 1172 of file flutter_window_unittests.cc.

1172  {
1173  MockFlutterWindow win32window;
1174  EXPECT_CALL(win32window, GetWindowHandle)
1175  .WillRepeatedly(Return(reinterpret_cast<HWND>(1)));
1176  EXPECT_CALL(win32window, OnWindowStateEvent)
1177  .WillRepeatedly([&](WindowStateEvent event) {
1178  win32window.FlutterWindow::OnWindowStateEvent(event);
1179  });
1180  EXPECT_CALL(win32window, OnResize).Times(1);
1181 
1182  // Restore
1183  win32window.InjectWindowMessage(WM_SIZE, 0, MAKEWORD(1, 1));
1184 
1185  // Focus
1186  win32window.InjectWindowMessage(WM_SETFOCUS, 0, 0);
1187 
1188  MockWindowBindingHandlerDelegate delegate;
1189  bool focused = false;
1190  bool restored = false;
1191  EXPECT_CALL(delegate, OnWindowStateEvent)
1192  .WillRepeatedly([&](HWND hwnd, WindowStateEvent event) {
1193  if (event == WindowStateEvent::kFocus) {
1194  focused = true;
1195  } else if (event == WindowStateEvent::kShow) {
1196  restored = true;
1197  }
1198  });
1199 
1200  EXPECT_CALL(delegate, OnFocus(Eq(FlutterViewFocusState::kFocused),
1201  Eq(FlutterViewFocusDirection::kUndefined)))
1202  .Times(1);
1203  win32window.SetView(&delegate);
1204  EXPECT_TRUE(focused);
1205  EXPECT_TRUE(restored);
1206 }
WindowStateEvent
An event representing a change in window state that may update the.

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

◆ TEST_F() [84/271]

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() [85/271]

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

Definition at line 1134 of file flutter_window_unittests.cc.

1134  {
1135  MockFlutterWindow win32window;
1136  EXPECT_CALL(win32window, GetWindowHandle)
1137  .WillRepeatedly(Return(reinterpret_cast<HWND>(1)));
1138  MockWindowBindingHandlerDelegate delegate;
1139 
1140  WindowStateEvent last_event;
1141  EXPECT_CALL(delegate, OnWindowStateEvent)
1142  .WillRepeatedly([&last_event](HWND hwnd, WindowStateEvent event) {
1143  last_event = event;
1144  });
1145  EXPECT_CALL(win32window, OnWindowStateEvent)
1146  .WillRepeatedly([&](WindowStateEvent event) {
1147  win32window.FlutterWindow::OnWindowStateEvent(event);
1148  });
1149  EXPECT_CALL(win32window, OnResize).Times(AnyNumber());
1150 
1151  win32window.SetView(&delegate);
1152 
1153  win32window.InjectWindowMessage(WM_SIZE, 0, 0);
1154  EXPECT_EQ(last_event, WindowStateEvent::kHide);
1155 
1156  win32window.InjectWindowMessage(WM_SIZE, 0, MAKEWORD(1, 1));
1157  EXPECT_EQ(last_event, WindowStateEvent::kShow);
1158 
1159  EXPECT_CALL(delegate, OnFocus(Eq(FlutterViewFocusState::kFocused),
1160  Eq(FlutterViewFocusDirection::kUndefined)))
1161  .Times(1);
1162  win32window.InjectWindowMessage(WM_SETFOCUS, 0, 0);
1163  EXPECT_EQ(last_event, WindowStateEvent::kFocus);
1164 
1165  EXPECT_CALL(delegate, OnFocus(Eq(FlutterViewFocusState::kUnfocused),
1166  Eq(FlutterViewFocusDirection::kUndefined)))
1167  .Times(1);
1168  win32window.InjectWindowMessage(WM_KILLFOCUS, 0, 0);
1169  EXPECT_EQ(last_event, WindowStateEvent::kUnfocus);
1170 }

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

◆ TEST_F() [86/271]

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

Definition at line 885 of file flutter_window_unittests.cc.

885  {
886  MockFlutterWindow win32window(100, 100);
887  MockWindowBindingHandlerDelegate delegate;
888  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
889  EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
890  win32window.SetView(&delegate);
891 
892  HWND window_handle = win32window.FlutterWindow::GetWindowHandle();
893  ASSERT_NE(window_handle, nullptr);
894  ReleaseCapture();
895  ASSERT_EQ(GetCapture(), nullptr);
896 
897  EXPECT_CALL(delegate,
898  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindMouse,
899  kDefaultPointerDeviceId,
900  kFlutterPointerButtonMouseSecondary, 0, 0))
901  .Times(1);
902  win32window.InjectWindowMessage(WM_RBUTTONDOWN, MK_RBUTTON,
903  MAKELPARAM(10, 10));
904  EXPECT_EQ(GetCapture(), window_handle);
905 
906  EXPECT_CALL(delegate,
907  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindMouse,
908  kDefaultPointerDeviceId,
909  kFlutterPointerButtonMousePrimary, 0, 0))
910  .Times(1);
911  win32window.InjectWindowMessage(WM_LBUTTONDOWN, MK_LBUTTON | MK_RBUTTON,
912  MAKELPARAM(10, 10));
913  EXPECT_EQ(GetCapture(), window_handle);
914 
915  EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindMouse,
916  kDefaultPointerDeviceId,
917  kFlutterPointerButtonMouseSecondary))
918  .Times(1);
919  win32window.InjectWindowMessage(WM_RBUTTONUP, MK_LBUTTON, MAKELPARAM(10, 10));
920  EXPECT_EQ(GetCapture(), window_handle);
921 
922  EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindMouse,
923  kDefaultPointerDeviceId,
924  kFlutterPointerButtonMousePrimary))
925  .Times(1);
926  win32window.InjectWindowMessage(WM_LBUTTONUP, 0, MAKELPARAM(10, 10));
927  EXPECT_EQ(GetCapture(), nullptr);
928 }

◆ TEST_F() [87/271]

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

Definition at line 944 of file flutter_window_unittests.cc.

944  {
945  MockFlutterWindow win32window(100, 100);
946  MockWindowBindingHandlerDelegate delegate;
947  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
948  EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
949  win32window.SetView(&delegate);
950 
951  HWND window_handle = win32window.FlutterWindow::GetWindowHandle();
952  ASSERT_NE(window_handle, nullptr);
953  SetCapture(window_handle);
954  ASSERT_EQ(GetCapture(), window_handle);
955 
956  EXPECT_CALL(delegate,
957  OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindMouse,
958  kDefaultPointerDeviceId,
959  kFlutterPointerButtonMousePrimary, 0, 0, 0))
960  .Times(1);
961  win32window.InjectWindowMessage(WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(10, 10));
962 
963  ReleaseCapture();
964 }

◆ TEST_F() [88/271]

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

Definition at line 930 of file flutter_window_unittests.cc.

930  {
931  MockFlutterWindow win32window(100, 100);
932  MockWindowBindingHandlerDelegate delegate;
933  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
934  EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
935  win32window.SetView(&delegate);
936 
937  ReleaseCapture();
938  ASSERT_EQ(GetCapture(), nullptr);
939 
940  EXPECT_CALL(delegate, OnPointerMove).Times(0);
941  win32window.InjectWindowMessage(WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(10, 10));
942 }

◆ TEST_F() [89/271]

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

Definition at line 856 of file flutter_window_unittests.cc.

856  {
857  MockFlutterWindow win32window(100, 100);
858  MockWindowBindingHandlerDelegate delegate;
859  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
860  EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
861  win32window.SetView(&delegate);
862 
863  HWND window_handle = win32window.FlutterWindow::GetWindowHandle();
864  ASSERT_NE(window_handle, nullptr);
865  ReleaseCapture();
866  ASSERT_EQ(GetCapture(), nullptr);
867 
868  EXPECT_CALL(delegate,
869  OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindMouse,
870  kDefaultPointerDeviceId,
871  kFlutterPointerButtonMouseSecondary, 0, 0))
872  .Times(1);
873  win32window.InjectWindowMessage(WM_RBUTTONDOWN, MK_RBUTTON,
874  MAKELPARAM(10, 10));
875  EXPECT_EQ(GetCapture(), window_handle);
876 
877  EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindMouse,
878  kDefaultPointerDeviceId,
879  kFlutterPointerButtonMouseSecondary))
880  .Times(1);
881  win32window.InjectWindowMessage(WM_RBUTTONUP, 0, MAKELPARAM(10, 10));
882  EXPECT_EQ(GetCapture(), nullptr);
883 }

◆ TEST_F() [90/271]

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() [91/271]

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() [92/271]

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() [93/271]

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() [94/271]

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() [95/271]

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() [96/271]

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

Definition at line 1049 of file flutter_window_unittests.cc.

1049  {
1050  MockFlutterWindow win32window;
1051  MockWindowBindingHandlerDelegate delegate;
1052  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
1053  win32window.SetView(&delegate);
1054 
1055  EXPECT_CALL(win32window, GetWindowHandle).WillOnce([&win32window]() {
1056  return win32window.FlutterWindow::GetWindowHandle();
1057  });
1058  EXPECT_CALL(win32window, GetScrollOffsetMultiplier).WillOnce(Return(120.0f));
1059 
1060  EXPECT_CALL(delegate,
1061  OnScroll(_, _, 0, 0, 120.0f, kFlutterPointerDeviceKindMouse,
1062  kDefaultPointerDeviceId))
1063  .Times(1);
1064 
1065  win32window.OnScroll(0.0f, 0.0f, kFlutterPointerDeviceKindMouse,
1066  kDefaultPointerDeviceId);
1067 }

◆ TEST_F() [97/271]

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() [98/271]

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() [99/271]

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() [100/271]

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() [101/271]

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() [102/271]

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() [103/271]

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() [104/271]

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() [105/271]

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() [106/271]

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() [107/271]

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

Definition at line 1080 of file flutter_window_unittests.cc.

1080  {
1081  MockFlutterWindow win32window;
1082  MockWindowBindingHandlerDelegate delegate;
1083  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
1084  win32window.SetView(&delegate);
1085 
1086  EXPECT_CALL(delegate, OnHighContrastChanged).Times(1);
1087 
1088  win32window.InjectWindowMessage(WM_THEMECHANGED, 0, 0);
1089 }

◆ TEST_F() [108/271]

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

Definition at line 966 of file flutter_window_unittests.cc.

966  {
967  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
968 
969  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
970  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
971  if (pointer_info != nullptr) {
972  pointer_info->pointerType = PT_TOUCH;
973  pointer_info->pointerId = pointer_id;
974  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT |
975  POINTER_FLAG_FIRSTBUTTON |
976  POINTER_FLAG_DOWN;
977  }
978  return TRUE;
979  });
980 
981  MockFlutterWindow win32window(100, 100, mock_proc_table);
982  MockWindowBindingHandlerDelegate delegate;
983  win32window.SetView(&delegate);
984 
985  EXPECT_CALL(delegate, OnPointerDown(55, 60, kFlutterPointerDeviceKindTouch,
986  kDefaultPointerDeviceId,
987  kFlutterPointerButtonMousePrimary, 0, 0))
988  .Times(1);
989 
990  UINT32 pointerId = 1;
991  WPARAM wparam = static_cast<WPARAM>(pointerId);
992  InjectPointerMessageWithClientPoint(win32window, WM_POINTERDOWN, wparam, 55,
993  60);
994 }

◆ TEST_F() [109/271]

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

Definition at line 1069 of file flutter_window_unittests.cc.

1069  {
1070  MockFlutterWindow win32window;
1071  MockWindowBindingHandlerDelegate delegate;
1072  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
1073  win32window.SetView(&delegate);
1074 
1075  EXPECT_CALL(delegate, OnWindowRepaint()).Times(1);
1076 
1077  win32window.InjectWindowMessage(WM_PAINT, 0, 0);
1078 }

◆ TEST_F() [110/271]

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

Definition at line 996 of file flutter_window_unittests.cc.

996  {
997  constexpr int kClientX = 15;
998  constexpr int kClientY = 20;
999 
1000  auto mock_proc_table = std::make_shared<MockWindowsProcTable>();
1001 
1002  EXPECT_CALL(*mock_proc_table, GetPointerInfo(_, _))
1003  .WillRepeatedly([](UINT32 pointer_id, POINTER_INFO* pointer_info) {
1004  if (pointer_info != nullptr) {
1005  pointer_info->pointerType = PT_TOUCH;
1006  pointer_info->pointerId = pointer_id;
1007  pointer_info->pointerFlags = POINTER_FLAG_INCONTACT |
1008  POINTER_FLAG_FIRSTBUTTON |
1009  POINTER_FLAG_DOWN;
1010  }
1011  return TRUE;
1012  });
1013 
1014  MockFlutterWindow win32window(100, 100, mock_proc_table);
1015  MockWindowBindingHandlerDelegate delegate;
1016  EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
1017  EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
1018  win32window.SetView(&delegate);
1019 
1020  HWND parent_window =
1021  CreateWindowEx(0, L"STATIC", L"", WS_POPUP, 100, 100, 300, 300, nullptr,
1022  nullptr, GetModuleHandle(nullptr), nullptr);
1023  ASSERT_NE(parent_window, nullptr);
1024 
1025  HWND flutter_window = win32window.FlutterWindow::GetWindowHandle();
1026  ASSERT_NE(flutter_window, nullptr);
1027  ASSERT_NE(SetParent(flutter_window, parent_window), nullptr);
1028  ASSERT_TRUE(SetWindowPos(flutter_window, nullptr, 25, 35, 100, 100,
1029  SWP_NOZORDER | SWP_NOACTIVATE));
1030 
1031  POINT pointer_point = {kClientX, kClientY};
1032  ASSERT_TRUE(ClientToScreen(flutter_window, &pointer_point));
1033 
1034  EXPECT_CALL(delegate,
1035  OnPointerDown(kClientX, kClientY, kFlutterPointerDeviceKindTouch,
1036  kDefaultPointerDeviceId,
1037  kFlutterPointerButtonMousePrimary, 0, 0))
1038  .Times(1);
1039 
1040  win32window.InjectWindowMessage(WM_POINTERDOWN, /*wparam=*/1,
1041  MAKELPARAM(pointer_point.x, pointer_point.y));
1042 
1043  EXPECT_NE(SetParent(flutter_window, HWND_MESSAGE), nullptr);
1044  DestroyWindow(parent_window);
1045 }

◆ TEST_F() [111/271]

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() [112/271]

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() [113/271]

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() [114/271]

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() [115/271]

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() [116/271]

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() [117/271]

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() [118/271]

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() [119/271]

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() [120/271]

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() [121/271]

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() [122/271]

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() [123/271]

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() [124/271]

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() [125/271]

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() [126/271]

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() [127/271]

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() [128/271]

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() [129/271]

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() [130/271]

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() [131/271]

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() [132/271]

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() [133/271]

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() [134/271]

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() [135/271]

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() [136/271]

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);
1097  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1098  kPhysicalKeyA, kLogicalKeyA, "A", kNotSynthesized);
1099  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"A");
1100  tester.clear_key_calls();
1101  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1102 
1103  // Release ShiftLeft
1104  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1105  KeyStateChange{VK_LSHIFT, false, true},
1106  WmKeyUpInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended}.Build(
1107  kWmResultZero)});
1108 
1109  EXPECT_EQ(tester.key_calls.size(), 1);
1110  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1111  kPhysicalShiftLeft, kLogicalShiftLeft, "",
1112  kNotSynthesized);
1113  tester.clear_key_calls();
1114  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1115 
1116  // Release A
1117  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1118  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
1119  kWmResultZero)});
1120 
1121  EXPECT_EQ(tester.key_calls.size(), 1);
1122  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1123  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
1124  tester.clear_key_calls();
1125  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1126 }

References EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, kScanCodeKeyA, flutter::kScanCodeShiftLeft, and kVirtualKeyA.

◆ TEST_F() [137/271]

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

Definition at line 697 of file keyboard_unittests.cc.

697  {
698  KeyboardTester tester{GetContext()};
699  tester.Responding(false);
700 
701  // US Keyboard layout
702 
703  // Press ShiftLeft
704  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
705  KeyStateChange{VK_LSHIFT, true, false},
706  WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
707  kWmResultZero)});
708 
709  EXPECT_EQ(tester.key_calls.size(), 1);
710  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
711  kPhysicalShiftLeft, kLogicalShiftLeft, "",
712  kNotSynthesized);
713  tester.clear_key_calls();
714  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
715 
716  // Hold ShiftLeft
717  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
718  WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasDown}.Build(
719  kWmResultZero)});
720 
721  EXPECT_EQ(tester.key_calls.size(), 1);
722  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeRepeat,
723  kPhysicalShiftLeft, kLogicalShiftLeft, "",
724  kNotSynthesized);
725  tester.clear_key_calls();
726  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
727 
728  // Release ShiftLeft
729  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
730  KeyStateChange{VK_LSHIFT, false, true},
731  WmKeyUpInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended}.Build(
732  kWmResultZero)});
733 
734  EXPECT_EQ(tester.key_calls.size(), 1);
735  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
736  kPhysicalShiftLeft, kLogicalShiftLeft, "",
737  kNotSynthesized);
738  tester.clear_key_calls();
739  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
740 }

References EXPECT_CALL_IS_EVENT, and flutter::kScanCodeShiftLeft.

◆ TEST_F() [138/271]

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

Definition at line 742 of file keyboard_unittests.cc.

742  {
743  KeyboardTester tester{GetContext()};
744  tester.Responding(false);
745 
746  // US Keyboard layout
747 
748  // Press ShiftRight
749  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
750  KeyStateChange{VK_RSHIFT, true, false},
751  WmKeyDownInfo{VK_SHIFT, kScanCodeShiftRight, kNotExtended, kWasUp}.Build(
752  kWmResultZero)});
753 
754  EXPECT_EQ(tester.key_calls.size(), 1);
755  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
756  kPhysicalShiftRight, kLogicalShiftRight, "",
757  kNotSynthesized);
758  tester.clear_key_calls();
759  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
760 
761  // Release ShiftRight
762  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
763  KeyStateChange{VK_RSHIFT, false, true},
764  WmKeyUpInfo{VK_SHIFT, kScanCodeShiftRight, kNotExtended}.Build(
765  kWmResultZero)});
766 
767  EXPECT_EQ(tester.key_calls.size(), 1);
768  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
769  kPhysicalShiftRight, kLogicalShiftRight, "",
770  kNotSynthesized);
771  tester.clear_key_calls();
772  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
773 }

References EXPECT_CALL_IS_EVENT, and flutter::kScanCodeShiftRight.

◆ TEST_F() [139/271]

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

Definition at line 2097 of file keyboard_unittests.cc.

2097  {
2098  KeyboardTester tester{GetContext()};
2099 
2100  std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2101 
2102  // Store callbacks to manually call them.
2103  tester.LateResponding(
2104  [&recorded_callbacks](
2105  const FlutterKeyEvent* event,
2106  MockKeyResponseController::ResponseCallback callback) {
2107  recorded_callbacks.push_back(callback);
2108  });
2109 
2110  // Press A
2111  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2112  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2113  kWmResultZero),
2114  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2115  kWmResultZero)});
2116 
2117  // Hold A
2118  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2119  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasDown}.Build(
2120  kWmResultZero),
2121  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasDown}.Build(
2122  kWmResultZero)});
2123 
2124  EXPECT_EQ(tester.key_calls.size(), 1);
2125  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2126  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2127  EXPECT_EQ(recorded_callbacks.size(), 1);
2128  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2129 
2130  // The first response.
2131  recorded_callbacks.front()(false);
2132 
2133  EXPECT_EQ(tester.key_calls.size(), 3);
2134  EXPECT_EQ(recorded_callbacks.size(), 2);
2135  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2136  EXPECT_CALL_IS_EVENT(tester.key_calls[2], kFlutterKeyEventTypeRepeat,
2137  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2138  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2139 
2140  // The second response.
2141  recorded_callbacks.back()(false);
2142 
2143  EXPECT_EQ(tester.key_calls.size(), 4);
2144  EXPECT_CALL_IS_TEXT(tester.key_calls[3], u"a");
2145  tester.clear_key_calls();
2146  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2147 }

References callback, EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [140/271]

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

Definition at line 2160 of file keyboard_unittests.cc.

2160  {
2161  KeyboardTester tester{GetContext()};
2162  std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2163 
2164  // Store callbacks to manually call them.
2165  tester.LateResponding(
2166  [&recorded_callbacks](
2167  const FlutterKeyEvent* event,
2168  MockKeyResponseController::ResponseCallback callback) {
2169  recorded_callbacks.push_back(callback);
2170  });
2171 
2172  // Press A
2173  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2174  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2175  kWmResultZero),
2176  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2177  kWmResultZero)});
2178 
2179  EXPECT_EQ(tester.key_calls.size(), 1);
2180  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2181  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2182  tester.clear_key_calls();
2183  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2184 
2185  // Release A
2186  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2187  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
2188  kWmResultZero)});
2189 
2190  EXPECT_EQ(tester.key_calls.size(), 0);
2191  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2192 
2193  // The first down event responded with false.
2194  EXPECT_EQ(recorded_callbacks.size(), 1);
2195  recorded_callbacks.front()(false);
2196 
2197  EXPECT_EQ(tester.key_calls.size(), 2);
2198  EXPECT_CALL_IS_TEXT(tester.key_calls[0], u"a");
2199  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
2200  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2201  tester.clear_key_calls();
2202  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2203 
2204  // Press A again
2205  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2206  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2207  kWmResultZero),
2208  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2209  kWmResultZero)});
2210 
2211  // Nothing more was dispatched because the first up event hasn't been
2212  // responded yet.
2213  EXPECT_EQ(recorded_callbacks.size(), 2);
2214  EXPECT_EQ(tester.key_calls.size(), 0);
2215  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2216 
2217  // The first up event responded with false, which was redispatched, and caused
2218  // the down event to be dispatched.
2219  recorded_callbacks.back()(false);
2220  EXPECT_EQ(tester.key_calls.size(), 1);
2221  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2222  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2223  tester.clear_key_calls();
2224  EXPECT_EQ(recorded_callbacks.size(), 3);
2225  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2226 
2227  // Release A again
2228  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2229  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
2230  kWmResultZero)});
2231 
2232  EXPECT_EQ(tester.key_calls.size(), 0);
2233  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2234 }

References callback, EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [141/271]

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

Definition at line 1802 of file keyboard_unittests.cc.

1802  {
1803  KeyboardTester tester{GetContext()};
1804  tester.Responding(false);
1805 
1806  // Two dummy events used to trigger synthesization.
1807  Win32Message event1 =
1808  WmKeyDownInfo{VK_BACK, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
1809  kWmResultZero);
1810  Win32Message event2 =
1811  WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
1812  kWmResultZero);
1813 
1814  // ShiftLeft
1815  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1816  KeyStateChange{VK_LSHIFT, true, true}, event1});
1817  EXPECT_EQ(tester.key_calls.size(), 2);
1818  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1819  kPhysicalShiftLeft, kLogicalShiftLeft, "", kSynthesized);
1820  tester.clear_key_calls();
1821  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1822 
1823  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1824  KeyStateChange{VK_LSHIFT, false, true}, event2});
1825  EXPECT_EQ(tester.key_calls.size(), 2);
1826  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1827  kPhysicalShiftLeft, kLogicalShiftLeft, "", kSynthesized);
1828  tester.clear_key_calls();
1829  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1830 
1831  // ShiftRight
1832  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1833  KeyStateChange{VK_RSHIFT, true, true}, event1});
1834  EXPECT_EQ(tester.key_calls.size(), 2);
1835  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1836  kPhysicalShiftRight, kLogicalShiftRight, "",
1837  kSynthesized);
1838  tester.clear_key_calls();
1839  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1840 
1841  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1842  KeyStateChange{VK_RSHIFT, false, true}, event2});
1843  EXPECT_EQ(tester.key_calls.size(), 2);
1844  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1845  kPhysicalShiftRight, kLogicalShiftRight, "",
1846  kSynthesized);
1847  tester.clear_key_calls();
1848  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1849 
1850  // ControlLeft
1851  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1852  KeyStateChange{VK_LCONTROL, true, true}, event1});
1853  EXPECT_EQ(tester.key_calls.size(), 2);
1854  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1855  kPhysicalControlLeft, kLogicalControlLeft, "",
1856  kSynthesized);
1857  tester.clear_key_calls();
1858  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1859 
1860  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1861  KeyStateChange{VK_LCONTROL, false, true}, event2});
1862  EXPECT_EQ(tester.key_calls.size(), 2);
1863  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1864  kPhysicalControlLeft, kLogicalControlLeft, "",
1865  kSynthesized);
1866  tester.clear_key_calls();
1867  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1868 
1869  // ControlRight
1870  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1871  KeyStateChange{VK_RCONTROL, true, true}, event1});
1872  EXPECT_EQ(tester.key_calls.size(), 2);
1873  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1874  kPhysicalControlRight, kLogicalControlRight, "",
1875  kSynthesized);
1876  tester.clear_key_calls();
1877  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1878 
1879  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1880  KeyStateChange{VK_RCONTROL, false, true}, event2});
1881  EXPECT_EQ(tester.key_calls.size(), 2);
1882  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1883  kPhysicalControlRight, kLogicalControlRight, "",
1884  kSynthesized);
1885  tester.clear_key_calls();
1886  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1887 
1888  // AltLeft
1889  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1890  KeyStateChange{VK_LMENU, true, true}, event1});
1891  EXPECT_EQ(tester.key_calls.size(), 2);
1892  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1893  kPhysicalAltLeft, kLogicalAltLeft, "", kSynthesized);
1894  tester.clear_key_calls();
1895  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1896 
1897  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1898  KeyStateChange{VK_LMENU, false, true}, event2});
1899  EXPECT_EQ(tester.key_calls.size(), 2);
1900  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1901  kPhysicalAltLeft, kLogicalAltLeft, "", kSynthesized);
1902  tester.clear_key_calls();
1903  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1904 
1905  // AltRight
1906  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1907  KeyStateChange{VK_RMENU, true, true}, event1});
1908  EXPECT_EQ(tester.key_calls.size(), 2);
1909  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1910  kPhysicalAltRight, kLogicalAltRight, "", kSynthesized);
1911  tester.clear_key_calls();
1912  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1913 
1914  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1915  KeyStateChange{VK_RMENU, false, true}, event2});
1916  EXPECT_EQ(tester.key_calls.size(), 2);
1917  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1918  kPhysicalAltRight, kLogicalAltRight, "", kSynthesized);
1919  tester.clear_key_calls();
1920  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1921 
1922  // MetaLeft
1923  tester.InjectKeyboardChanges(
1924  std::vector<KeyboardChange>{KeyStateChange{VK_LWIN, true, true}, event1});
1925  EXPECT_EQ(tester.key_calls.size(), 2);
1926  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1927  kPhysicalMetaLeft, kLogicalMetaLeft, "", kSynthesized);
1928  tester.clear_key_calls();
1929  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1930 
1931  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1932  KeyStateChange{VK_LWIN, false, true}, event2});
1933  EXPECT_EQ(tester.key_calls.size(), 2);
1934  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1935  kPhysicalMetaLeft, kLogicalMetaLeft, "", kSynthesized);
1936  tester.clear_key_calls();
1937  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1938 
1939  // MetaRight
1940  tester.InjectKeyboardChanges(
1941  std::vector<KeyboardChange>{KeyStateChange{VK_RWIN, true, true}, event1});
1942  EXPECT_EQ(tester.key_calls.size(), 2);
1943  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1944  kPhysicalMetaRight, kLogicalMetaRight, "", kSynthesized);
1945  tester.clear_key_calls();
1946  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1947 
1948  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1949  KeyStateChange{VK_RWIN, false, true}, event2});
1950  EXPECT_EQ(tester.key_calls.size(), 2);
1951  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1952  kPhysicalMetaRight, kLogicalMetaRight, "", kSynthesized);
1953  tester.clear_key_calls();
1954  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1955 
1956  // CapsLock, phase 0 -> 2 -> 0.
1957  // (For phases, see |SynchronizeCriticalToggledStates|.)
1958  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1959  KeyStateChange{VK_CAPITAL, false, true}, event1});
1960  EXPECT_EQ(tester.key_calls.size(), 3);
1961  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1962  kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1963  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
1964  kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1965  tester.clear_key_calls();
1966  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1967 
1968  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1969  KeyStateChange{VK_CAPITAL, false, false}, event2});
1970  EXPECT_EQ(tester.key_calls.size(), 3);
1971  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1972  kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1973  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
1974  kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1975  tester.clear_key_calls();
1976  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1977 
1978  // ScrollLock, phase 0 -> 1 -> 3
1979  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1980  KeyStateChange{VK_SCROLL, true, true}, event1});
1981  EXPECT_EQ(tester.key_calls.size(), 2);
1982  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
1983  kPhysicalScrollLock, kLogicalScrollLock, "",
1984  kSynthesized);
1985  tester.clear_key_calls();
1986  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1987 
1988  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1989  KeyStateChange{VK_SCROLL, true, false}, event2});
1990  EXPECT_EQ(tester.key_calls.size(), 3);
1991  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
1992  kPhysicalScrollLock, kLogicalScrollLock, "",
1993  kSynthesized);
1994  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeDown,
1995  kPhysicalScrollLock, kLogicalScrollLock, "",
1996  kSynthesized);
1997  tester.clear_key_calls();
1998  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1999 
2000  // NumLock, phase 0 -> 3 -> 2
2001  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2002  KeyStateChange{VK_NUMLOCK, true, false}, event1});
2003  // TODO(dkwingsmt): Synthesizing from phase 0 to 3 should yield a full key
2004  // tap and a key down. Fix the algorithm so that the following result becomes
2005  // 4 keycalls with an extra pair of key down and up.
2006  // https://github.com/flutter/flutter/issues/98533
2007  EXPECT_EQ(tester.key_calls.size(), 2);
2008  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2009  kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
2010  tester.clear_key_calls();
2011  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2012 
2013  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2014  KeyStateChange{VK_NUMLOCK, false, true}, event2});
2015  EXPECT_EQ(tester.key_calls.size(), 4);
2016  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
2017  kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
2018  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeDown,
2019  kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
2020  EXPECT_CALL_IS_EVENT(tester.key_calls[2], kFlutterKeyEventTypeUp,
2021  kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
2022  tester.clear_key_calls();
2023  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2024 }

References EXPECT_CALL_IS_EVENT.

◆ TEST_F() [142/271]

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

Definition at line 2236 of file keyboard_unittests.cc.

2236  {
2237  KeyboardTester tester{GetContext()};
2238  tester.Responding(false);
2239 
2240  // US Keyboard layout
2241 
2242  tester.InjectPlatformMessage(
2243  "flutter/textinput", "TextInput.setClient",
2244  R"|([108, {"inputAction": "TextInputAction.none", "viewId": 0}])|");
2245 
2246  // Press Enter
2247  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2248  WmKeyDownInfo{VK_RETURN, kScanCodeEnter, kNotExtended, kWasUp}.Build(
2249  kWmResultZero),
2250  WmCharInfo{'\n', kScanCodeEnter, kNotExtended, kWasUp}.Build(
2251  kWmResultZero)});
2252 
2253  EXPECT_EQ(tester.key_calls.size(), 2);
2254  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2255  kPhysicalEnter, kLogicalEnter, "", kNotSynthesized);
2257  tester.key_calls[1],
2258  "{"
2259  R"|("method":"TextInputClient.performAction",)|"
2260  R"|("args":[108,"TextInputAction.none"])|"
2261  "}");
2262  tester.clear_key_calls();
2263  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2264 
2265  // Release Enter
2266  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2267  WmKeyUpInfo{VK_RETURN, kScanCodeEnter, kNotExtended}.Build(
2268  kWmResultZero)});
2269 
2270  EXPECT_EQ(tester.key_calls.size(), 1);
2271  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
2272  kPhysicalEnter, kLogicalEnter, "", kNotSynthesized);
2273  tester.clear_key_calls();
2274  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2275 
2276  // Make sure OnText is not obstructed after pressing Enter.
2277  //
2278  // Regression test for https://github.com/flutter/flutter/issues/97706.
2279 
2280  // Press A
2281  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2282  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2283  kWmResultZero),
2284  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2285  kWmResultZero)});
2286 
2287  EXPECT_EQ(tester.key_calls.size(), 2);
2288  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2289  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2290  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2291  tester.clear_key_calls();
2292 
2293  // Release A
2294  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2295  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
2296  kWmResultZero)});
2297 
2298  EXPECT_EQ(tester.key_calls.size(), 1);
2299  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
2300  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2301  tester.clear_key_calls();
2302 }
#define EXPECT_CALL_IS_TEXT_METHOD_CALL(_key_call, json_string)

References EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, EXPECT_CALL_IS_TEXT_METHOD_CALL, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [143/271]

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

Definition at line 2058 of file keyboard_unittests.cc.

2058  {
2059  KeyboardTester tester{GetContext()};
2060  tester.Responding(true);
2061 
2062  // US Keyboard layout.
2063 
2064  // Press CtrlRight in IME mode.
2065  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2066  KeyStateChange{VK_LSHIFT, true, false},
2067  WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
2068  kWmResultZero),
2069  WmKeyDownInfo{VK_PROCESSKEY, kScanCodeDigit2, kNotExtended, kWasUp}.Build(
2070  kWmResultZero),
2071  KeyStateChange{VK_LSHIFT, false, true},
2072  WmKeyUpInfo{VK_PROCESSKEY, kScanCodeShiftLeft, kNotExtended}.Build(
2073  kWmResultZero),
2074  WmKeyUpInfo{'2', kScanCodeDigit2, kNotExtended, kWasUp}.Build(
2075  kWmResultZero)});
2076 
2077  EXPECT_EQ(tester.key_calls.size(), 4);
2078  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2079  kPhysicalShiftLeft, kLogicalShiftLeft, "",
2080  kNotSynthesized);
2081  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeDown, 0, 0, "",
2082  kNotSynthesized);
2083  EXPECT_CALL_IS_EVENT(tester.key_calls[2], kFlutterKeyEventTypeUp,
2084  kPhysicalShiftLeft, kLogicalShiftLeft, "",
2085  kNotSynthesized);
2086  EXPECT_CALL_IS_EVENT(tester.key_calls[3], kFlutterKeyEventTypeDown, 0, 0, "",
2087  kNotSynthesized);
2088  tester.clear_key_calls();
2089 }

References EXPECT_CALL_IS_EVENT, and flutter::kScanCodeShiftLeft.

◆ TEST_F() [144/271]

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

Definition at line 2304 of file keyboard_unittests.cc.

2304  {
2305  // In this test, the user presses the folloing keys:
2306  //
2307  // Key Current text
2308  // ===========================
2309  // A a
2310  // F à
2311  //
2312  // And the Backspace event is responded immediately.
2313 
2314  KeyboardTester tester{GetContext()};
2315  tester.Responding(false);
2316 
2317  // US Keyboard layout
2318 
2319  // Press A
2320  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2321  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2322  kWmResultZero),
2323  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2324  kWmResultZero)});
2325 
2326  EXPECT_EQ(tester.key_calls.size(), 2);
2327  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2328  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2329  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2330  tester.clear_key_calls();
2331  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2332 
2333  // Release A
2334  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2335  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
2336  kWmResultZero)});
2337 
2338  EXPECT_EQ(tester.key_calls.size(), 1);
2339  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
2340  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2341  tester.clear_key_calls();
2342  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2343 
2344  // Press F, which is translated to:
2345  //
2346  // Backspace down, char & up, then VK_PACKET('à').
2347  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2348  WmKeyDownInfo{VK_BACK, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2349  kWmResultZero),
2350  WmCharInfo{0x8, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2351  kWmResultZero),
2352  WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
2353  kWmResultZero),
2354  WmKeyDownInfo{VK_PACKET, 0, kNotExtended, kWasUp}.Build(kWmResultDefault),
2355  WmCharInfo{0xe0 /*'à'*/, 0, kNotExtended, kWasUp}.Build(kWmResultZero),
2356  WmKeyUpInfo{VK_PACKET, 0, kNotExtended}.Build(kWmResultDefault)});
2357 
2358  EXPECT_EQ(tester.key_calls.size(), 3);
2359  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2360  kPhysicalBackspace, kLogicalBackspace, "",
2361  kNotSynthesized);
2362  EXPECT_CALL_IS_EVENT(tester.key_calls[1], kFlutterKeyEventTypeUp,
2363  kPhysicalBackspace, kLogicalBackspace, "",
2364  kNotSynthesized);
2365  EXPECT_CALL_IS_TEXT(tester.key_calls[2], u"à");
2366  tester.clear_key_calls();
2367  // TODO(dkwingsmt): This count should probably be 4. Currently the CHAR 0x8
2368  // message is redispatched due to being part of the KeyDown session, which is
2369  // not handled by the framework, while the 'à' message is not redispatched
2370  // for being a standalone message. We should resolve this inconsistency.
2371  // https://github.com/flutter/flutter/issues/98306
2372  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 3);
2373 
2374  // Release F
2375  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2376  WmKeyUpInfo{kVirtualKeyF, kScanCodeKeyF, kNotExtended,
2377  /* overwrite_prev_state_0 */ true}
2378  .Build(kWmResultZero)});
2379 
2380  EXPECT_EQ(tester.key_calls.size(), 1);
2381  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown, 0, 0, "",
2382  kNotSynthesized);
2383  tester.clear_key_calls();
2384  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2385 }

References EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, kScanCodeKeyA, and kVirtualKeyA.

◆ TEST_F() [145/271]

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

Definition at line 2494 of file keyboard_unittests.cc.

2494  {
2495  VietnameseTelexAddDiacriticWithSlowResponse(GetContext(), false);
2496 }
void VietnameseTelexAddDiacriticWithSlowResponse(WindowsTestContext &context, bool backspace_response)

References VietnameseTelexAddDiacriticWithSlowResponse().

◆ TEST_F() [146/271]

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

Definition at line 2498 of file keyboard_unittests.cc.

2498  {
2499  VietnameseTelexAddDiacriticWithSlowResponse(GetContext(), true);
2500 }

References VietnameseTelexAddDiacriticWithSlowResponse().

◆ TEST_F() [147/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardHasStrings   
)

Definition at line 243 of file platform_handler_unittests.cc.

243  {
244  UseHeadlessEngine();
245 
246  TestBinaryMessenger messenger;
247  PlatformHandler platform_handler(&messenger, engine(), []() {
248  auto clipboard = std::make_unique<MockScopedClipboard>();
249 
250  EXPECT_CALL(*clipboard.get(), Open)
251  .Times(1)
252  .WillOnce(Return(kErrorSuccess));
253  EXPECT_CALL(*clipboard.get(), HasString).Times(1).WillOnce(Return(true));
254 
255  return clipboard;
256  });
257 
258  std::string result =
259  SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
260 
261  EXPECT_EQ(result, "[{\"value\":true}]");
262 }
static constexpr int kErrorSuccess

References kErrorSuccess.

◆ TEST_F() [148/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardHasStringsIgnoresPermissionErrors   
)

Definition at line 298 of file platform_handler_unittests.cc.

298  {
299  UseHeadlessEngine();
300 
301  TestBinaryMessenger messenger;
302  PlatformHandler platform_handler(&messenger, engine(), []() {
303  auto clipboard = std::make_unique<MockScopedClipboard>();
304 
305  EXPECT_CALL(*clipboard.get(), Open)
306  .Times(1)
307  .WillOnce(Return(kAccessDeniedErrorCode));
308 
309  return clipboard;
310  });
311 
312  std::string result =
313  SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
314 
315  EXPECT_EQ(result, "[{\"value\":false}]");
316 }
static constexpr int kAccessDeniedErrorCode

References kAccessDeniedErrorCode.

◆ TEST_F() [149/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardHasStringsRejectsUnknownContentType   
)

Definition at line 285 of file platform_handler_unittests.cc.

285  {
286  UseHeadlessEngine();
287 
288  TestBinaryMessenger messenger;
289  PlatformHandler platform_handler(&messenger, engine());
290 
291  std::string result = SimulatePlatformMessage(
292  &messenger, kClipboardHasStringsFakeContentTypeMessage);
293 
294  EXPECT_EQ(result, "[\"Clipboard error\",\"Unknown clipboard format\",null]");
295 }

◆ TEST_F() [150/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardHasStringsReportsErrors   
)

Definition at line 318 of file platform_handler_unittests.cc.

318  {
319  UseHeadlessEngine();
320 
321  TestBinaryMessenger messenger;
322  PlatformHandler platform_handler(&messenger, engine(), []() {
323  auto clipboard = std::make_unique<MockScopedClipboard>();
324 
325  EXPECT_CALL(*clipboard.get(), Open)
326  .Times(1)
327  .WillOnce(Return(kArbitraryErrorCode));
328 
329  return clipboard;
330  });
331 
332  std::string result =
333  SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
334 
335  EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to open clipboard\",1]");
336 }

◆ TEST_F() [151/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardHasStringsReturnsFalse   
)

Definition at line 264 of file platform_handler_unittests.cc.

264  {
265  UseHeadlessEngine();
266 
267  TestBinaryMessenger messenger;
268  PlatformHandler platform_handler(&messenger, engine(), []() {
269  auto clipboard = std::make_unique<MockScopedClipboard>();
270 
271  EXPECT_CALL(*clipboard.get(), Open)
272  .Times(1)
273  .WillOnce(Return(kErrorSuccess));
274  EXPECT_CALL(*clipboard.get(), HasString).Times(1).WillOnce(Return(false));
275 
276  return clipboard;
277  });
278 
279  std::string result =
280  SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
281 
282  EXPECT_EQ(result, "[{\"value\":false}]");
283 }

References kErrorSuccess.

◆ TEST_F() [152/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardSetData   
)

Definition at line 338 of file platform_handler_unittests.cc.

338  {
339  UseHeadlessEngine();
340 
341  TestBinaryMessenger messenger;
342  PlatformHandler platform_handler(&messenger, engine(), []() {
343  auto clipboard = std::make_unique<MockScopedClipboard>();
344 
345  EXPECT_CALL(*clipboard.get(), Open)
346  .Times(1)
347  .WillOnce(Return(kErrorSuccess));
348  EXPECT_CALL(*clipboard.get(), SetString)
349  .Times(1)
350  .WillOnce([](std::wstring string) {
351  EXPECT_EQ(string, L"hello");
352  return kErrorSuccess;
353  });
354 
355  return clipboard;
356  });
357 
358  std::string result =
359  SimulatePlatformMessage(&messenger, kClipboardSetDataMessage);
360 
361  EXPECT_EQ(result, "[null]");
362 }

References kErrorSuccess.

◆ TEST_F() [153/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardSetDataReplacesNullTerminators   
)

Definition at line 365 of file platform_handler_unittests.cc.

365  {
366  UseHeadlessEngine();
367 
368  TestBinaryMessenger messenger;
369  PlatformHandler platform_handler(&messenger, engine(), []() {
370  auto clipboard = std::make_unique<MockScopedClipboard>();
371 
372  EXPECT_CALL(*clipboard.get(), Open)
373  .Times(1)
374  .WillOnce(Return(kErrorSuccess));
375  EXPECT_CALL(*clipboard.get(), SetString)
376  .Times(1)
377  .WillOnce([](std::wstring string) {
378  EXPECT_EQ(string, L"hello\uFFFDworld");
379  return kErrorSuccess;
380  });
381 
382  return clipboard;
383  });
384 
385  std::string result = SimulatePlatformMessage(
386  &messenger, kClipboardSetDataNullTerminatorMessage);
387 
388  EXPECT_EQ(result, "[null]");
389 }

References kErrorSuccess.

◆ TEST_F() [154/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardSetDataReportsOpenFailure   
)

Definition at line 416 of file platform_handler_unittests.cc.

416  {
417  UseHeadlessEngine();
418 
419  TestBinaryMessenger messenger;
420  PlatformHandler platform_handler(&messenger, engine(), []() {
421  auto clipboard = std::make_unique<MockScopedClipboard>();
422 
423  EXPECT_CALL(*clipboard.get(), Open)
424  .Times(1)
425  .WillOnce(Return(kArbitraryErrorCode));
426 
427  return clipboard;
428  });
429 
430  std::string result =
431  SimulatePlatformMessage(&messenger, kClipboardSetDataMessage);
432 
433  EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to open clipboard\",1]");
434 }

◆ TEST_F() [155/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardSetDataReportsSetDataFailure   
)

Definition at line 436 of file platform_handler_unittests.cc.

436  {
437  UseHeadlessEngine();
438 
439  TestBinaryMessenger messenger;
440  PlatformHandler platform_handler(&messenger, engine(), []() {
441  auto clipboard = std::make_unique<MockScopedClipboard>();
442 
443  EXPECT_CALL(*clipboard.get(), Open)
444  .Times(1)
445  .WillOnce(Return(kErrorSuccess));
446  EXPECT_CALL(*clipboard.get(), SetString)
447  .Times(1)
448  .WillOnce(Return(kArbitraryErrorCode));
449 
450  return clipboard;
451  });
452 
453  std::string result =
454  SimulatePlatformMessage(&messenger, kClipboardSetDataMessage);
455 
456  EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to set clipboard data\",1]");
457 }

References kErrorSuccess.

◆ TEST_F() [156/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardSetDataTextMustBeString   
)

Definition at line 392 of file platform_handler_unittests.cc.

392  {
393  UseHeadlessEngine();
394 
395  TestBinaryMessenger messenger;
396  PlatformHandler platform_handler(&messenger, engine());
397 
398  std::string result =
399  SimulatePlatformMessage(&messenger, kClipboardSetDataNullTextMessage);
400 
401  EXPECT_EQ(result, "[\"Clipboard error\",\"Unknown clipboard format\",null]");
402 }

◆ TEST_F() [157/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
ClipboardSetDataUnknownType   
)

Definition at line 404 of file platform_handler_unittests.cc.

404  {
405  UseHeadlessEngine();
406 
407  TestBinaryMessenger messenger;
408  PlatformHandler platform_handler(&messenger, engine());
409 
410  std::string result =
411  SimulatePlatformMessage(&messenger, kClipboardSetDataUnknownTypeMessage);
412 
413  EXPECT_EQ(result, "[\"Clipboard error\",\"Unknown clipboard format\",null]");
414 }

◆ TEST_F() [158/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
GetClipboardData   
)

Definition at line 162 of file platform_handler_unittests.cc.

162  {
163  UseHeadlessEngine();
164 
165  TestBinaryMessenger messenger;
166  PlatformHandler platform_handler(&messenger, engine(), []() {
167  auto clipboard = std::make_unique<MockScopedClipboard>();
168 
169  EXPECT_CALL(*clipboard.get(), Open)
170  .Times(1)
171  .WillOnce(Return(kErrorSuccess));
172  EXPECT_CALL(*clipboard.get(), HasString).Times(1).WillOnce(Return(true));
173  EXPECT_CALL(*clipboard.get(), GetString)
174  .Times(1)
175  .WillOnce(Return(std::wstring(L"Hello world")));
176 
177  return clipboard;
178  });
179 
180  std::string result =
181  SimulatePlatformMessage(&messenger, kClipboardGetDataMessage);
182 
183  EXPECT_EQ(result, "[{\"text\":\"Hello world\"}]");
184 }

References kErrorSuccess.

◆ TEST_F() [159/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
GetClipboardDataRejectsUnknownContentType   
)

Definition at line 186 of file platform_handler_unittests.cc.

186  {
187  UseHeadlessEngine();
188 
189  TestBinaryMessenger messenger;
190  PlatformHandler platform_handler(&messenger, engine());
191 
192  // Requesting an unknown content type is an error.
193  std::string result = SimulatePlatformMessage(
194  &messenger, kClipboardGetDataFakeContentTypeMessage);
195 
196  EXPECT_EQ(result, "[\"Clipboard error\",\"Unknown clipboard format\",null]");
197 }

◆ TEST_F() [160/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
GetClipboardDataReportsGetDataFailure   
)

Definition at line 219 of file platform_handler_unittests.cc.

219  {
220  UseHeadlessEngine();
221 
222  TestBinaryMessenger messenger;
223  PlatformHandler platform_handler(&messenger, engine(), []() {
224  auto clipboard = std::make_unique<MockScopedClipboard>();
225 
226  EXPECT_CALL(*clipboard.get(), Open)
227  .Times(1)
228  .WillOnce(Return(kErrorSuccess));
229  EXPECT_CALL(*clipboard.get(), HasString).Times(1).WillOnce(Return(true));
230  EXPECT_CALL(*clipboard.get(), GetString)
231  .Times(1)
232  .WillOnce(Return(kArbitraryErrorCode));
233 
234  return clipboard;
235  });
236 
237  std::string result =
238  SimulatePlatformMessage(&messenger, kClipboardGetDataMessage);
239 
240  EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to get clipboard data\",1]");
241 }

References kErrorSuccess.

◆ TEST_F() [161/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
GetClipboardDataReportsOpenFailure   
)

Definition at line 199 of file platform_handler_unittests.cc.

199  {
200  UseHeadlessEngine();
201 
202  TestBinaryMessenger messenger;
203  PlatformHandler platform_handler(&messenger, engine(), []() {
204  auto clipboard = std::make_unique<MockScopedClipboard>();
205 
206  EXPECT_CALL(*clipboard.get(), Open)
207  .Times(1)
208  .WillOnce(Return(kArbitraryErrorCode));
209 
210  return clipboard;
211  });
212 
213  std::string result =
214  SimulatePlatformMessage(&messenger, kClipboardGetDataMessage);
215 
216  EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to open clipboard\",1]");
217 }

◆ TEST_F() [162/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
PlaySystemSound   
)

Definition at line 459 of file platform_handler_unittests.cc.

459  {
460  UseHeadlessEngine();
461 
462  TestBinaryMessenger messenger;
463  MockPlatformHandler platform_handler(&messenger, engine());
464 
465  EXPECT_CALL(platform_handler, SystemSoundPlay("SystemSoundType.alert", _))
466  .WillOnce([](const std::string& sound,
467  std::unique_ptr<MethodResult<rapidjson::Document>> result) {
468  result->Success();
469  });
470 
471  std::string result =
472  SimulatePlatformMessage(&messenger, kSystemSoundTypeAlertMessage);
473 
474  EXPECT_EQ(result, "[null]");
475 }

◆ TEST_F() [163/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
SystemExitApplicationCancelableCancel   
)

Definition at line 499 of file platform_handler_unittests.cc.

499  {
500  UseHeadlessEngine();
501  bool called_cancel = false;
502 
503  TestBinaryMessenger messenger(
504  [&called_cancel](const std::string& channel, const uint8_t* message,
505  size_t size, BinaryReply reply) {
506  reply(reinterpret_cast<const uint8_t*>(kExitResponseCancelMessage),
507  sizeof(kExitResponseCancelMessage));
508  called_cancel = true;
509  });
510  MockPlatformHandler platform_handler(&messenger, engine());
511 
512  EXPECT_CALL(platform_handler, QuitApplication).Times(0);
513 
514  std::string result = SimulatePlatformMessage(
515  &messenger, kSystemExitApplicationCancelableMessage);
516  EXPECT_EQ(result, "[{\"response\":\"cancel\"}]");
517  EXPECT_TRUE(called_cancel);
518 }

References message.

◆ TEST_F() [164/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
SystemExitApplicationCancelableExit   
)

Definition at line 520 of file platform_handler_unittests.cc.

520  {
521  UseHeadlessEngine();
522  bool called_cancel = false;
523  UINT exit_code = 0;
524 
525  TestBinaryMessenger messenger(
526  [&called_cancel](const std::string& channel, const uint8_t* message,
527  size_t size, BinaryReply reply) {
528  reply(reinterpret_cast<const uint8_t*>(kExitResponseExitMessage),
529  sizeof(kExitResponseExitMessage));
530  called_cancel = true;
531  });
532  MockPlatformHandler platform_handler(&messenger, engine());
533 
534  ON_CALL(platform_handler, QuitApplication)
535  .WillByDefault([&exit_code](std::optional<HWND> hwnd,
536  std::optional<WPARAM> wparam,
537  std::optional<LPARAM> lparam,
538  UINT ec) { exit_code = ec; });
539  EXPECT_CALL(platform_handler, QuitApplication).Times(1);
540 
541  std::string result = SimulatePlatformMessage(
542  &messenger, kSystemExitApplicationCancelableMessage);
543  EXPECT_EQ(result, "[{\"response\":\"cancel\"}]");
544  EXPECT_TRUE(called_cancel);
545  EXPECT_EQ(exit_code, 2);
546 }

References message.

◆ TEST_F() [165/271]

flutter::testing::TEST_F ( PlatformHandlerTest  ,
SystemExitApplicationRequired   
)

Definition at line 477 of file platform_handler_unittests.cc.

477  {
478  UseHeadlessEngine();
479  UINT exit_code = 0;
480 
481  TestBinaryMessenger messenger([](const std::string& channel,
482  const uint8_t* message, size_t size,
483  BinaryReply reply) {});
484  MockPlatformHandler platform_handler(&messenger, engine());
485 
486  ON_CALL(platform_handler, QuitApplication)
487  .WillByDefault([&exit_code](std::optional<HWND> hwnd,
488  std::optional<WPARAM> wparam,
489  std::optional<LPARAM> lparam,
490  UINT ec) { exit_code = ec; });
491  EXPECT_CALL(platform_handler, QuitApplication).Times(1);
492 
493  std::string result = SimulatePlatformMessage(
494  &messenger, kSystemExitApplicationRequiredMessage);
495  EXPECT_EQ(result, "[{\"response\":\"exit\"}]");
496  EXPECT_EQ(exit_code, 1);
497 }

References message.

◆ TEST_F() [166/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
ClearClientRequiresView   
)

Definition at line 253 of file text_input_plugin_unittest.cc.

253  {
254  UseHeadlessEngine();
255 
256  TestBinaryMessenger messenger([](const std::string& channel,
257  const uint8_t* message, size_t message_size,
258  BinaryReply reply) {});
259 
260  std::string reply;
261  BinaryReply reply_handler = [&reply](const uint8_t* reply_bytes,
262  size_t reply_size) {
263  reply = std::string(reinterpret_cast<const char*>(reply_bytes), reply_size);
264  };
265 
266  TextInputPlugin handler(&messenger, engine());
267 
268  auto& codec = JsonMethodCodec::GetInstance();
269  auto message = codec.EncodeMethodCall({"TextInput.clearClient", nullptr});
270  messenger.SimulateEngineMessage(kChannelName, message->data(),
271  message->size(), reply_handler);
272 
273  EXPECT_EQ(
274  reply,
275  "[\"Internal Consistency Error\",\"Text input is not available because "
276  "view with view_id=0 cannot be found\",null]");
277 }
static constexpr char kChannelName[]

References flutter::JsonMethodCodec::GetInstance(), kChannelName, and message.

◆ TEST_F() [167/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
ClearClientResetsComposing   
)

Definition at line 232 of file text_input_plugin_unittest.cc.

232  {
233  UseEngineWithView();
234 
235  TestBinaryMessenger messenger([](const std::string& channel,
236  const uint8_t* message, size_t message_size,
237  BinaryReply reply) {});
238  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
239 
240  TextInputPlugin handler(&messenger, engine());
241  TextInputPluginModifier modifier(&handler);
242  modifier.SetViewId(456);
243 
244  EXPECT_CALL(*view(), OnResetImeComposing());
245 
246  auto& codec = JsonMethodCodec::GetInstance();
247  auto message = codec.EncodeMethodCall({"TextInput.clearClient", nullptr});
248  messenger.SimulateEngineMessage(kChannelName, message->data(),
249  message->size(), reply_handler);
250 }

References flutter::JsonMethodCodec::GetInstance(), kChannelName, message, and flutter::TextInputPluginModifier::SetViewId().

◆ TEST_F() [168/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
CompositionCursorPos   
)

Definition at line 605 of file text_input_plugin_unittest.cc.

605  {
606  UseEngineWithView();
607 
608  int selection_base = -1;
609  TestBinaryMessenger messenger([&](const std::string& channel,
610  const uint8_t* message, size_t size,
611  BinaryReply reply) {
612  auto method = JsonMethodCodec::GetInstance().DecodeMethodCall(
613  std::vector<uint8_t>(message, message + size));
614  if (method->method_name() == kUpdateEditingStateMethod) {
615  const auto& args = *method->arguments();
616  const auto& editing_state = args[1];
617  auto base = editing_state.FindMember(kSelectionBaseKey);
618  auto extent = editing_state.FindMember(kSelectionExtentKey);
619  ASSERT_NE(base, editing_state.MemberEnd());
620  ASSERT_TRUE(base->value.IsInt());
621  ASSERT_NE(extent, editing_state.MemberEnd());
622  ASSERT_TRUE(extent->value.IsInt());
623  selection_base = base->value.GetInt();
624  EXPECT_EQ(extent->value.GetInt(), selection_base);
625  }
626  });
627 
628  TextInputPlugin plugin(&messenger, engine());
629 
630  auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
631  auto& allocator = args->GetAllocator();
632  args->PushBack(123, allocator); // client_id
633  rapidjson::Value client_config(rapidjson::kObjectType);
634  client_config.AddMember(kViewId, 456, allocator);
635  args->PushBack(client_config, allocator);
636  auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall(
637  MethodCall<rapidjson::Document>(kSetClientMethod, std::move(args)));
638  EXPECT_TRUE(messenger.SimulateEngineMessage(
639  kChannelName, encoded->data(), encoded->size(),
640  [](const uint8_t* reply, size_t reply_size) {}));
641 
642  plugin.ComposeBeginHook();
643  EXPECT_EQ(selection_base, 0);
644  plugin.ComposeChangeHook(u"abc", 3);
645  EXPECT_EQ(selection_base, 3);
646 
647  plugin.ComposeCommitHook();
648  plugin.ComposeEndHook();
649  EXPECT_EQ(selection_base, 3);
650 
651  plugin.ComposeBeginHook();
652  plugin.ComposeChangeHook(u"1", 1);
653  EXPECT_EQ(selection_base, 4);
654 
655  plugin.ComposeChangeHook(u"12", 2);
656  EXPECT_EQ(selection_base, 5);
657 
658  plugin.ComposeChangeHook(u"12", 1);
659  EXPECT_EQ(selection_base, 4);
660 
661  plugin.ComposeChangeHook(u"12", 2);
662  EXPECT_EQ(selection_base, 5);
663 }
static constexpr char kSelectionExtentKey[]
static constexpr char kSetClientMethod[]
static constexpr char kUpdateEditingStateMethod[]
static constexpr char kViewId[]
static constexpr char kSelectionBaseKey[]

References flutter::MethodCodec< T >::DecodeMethodCall(), flutter::MethodCodec< T >::EncodeMethodCall(), flutter::JsonMethodCodec::GetInstance(), kChannelName, kSelectionBaseKey, kSelectionExtentKey, kSetClientMethod, kUpdateEditingStateMethod, kViewId, and message.

◆ TEST_F() [169/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
OnViewRemovedIgnoresImplicitView   
)

Definition at line 893 of file text_input_plugin_unittest.cc.

893  {
894  UseEngineWithView();
895 
896  TestBinaryMessenger messenger([](const std::string& channel,
897  const uint8_t* message, size_t message_size,
898  BinaryReply reply) {});
899  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
900 
901  TextInputPlugin handler(&messenger, engine());
902  TextInputPluginModifier modifier(&handler);
903 
904  // Set a client to create an active model. EncodedClientConfig sets view_id
905  // to 456, so we override it to the implicit view id afterwards.
906  auto& codec = JsonMethodCodec::GetInstance();
907  auto set_client_message = codec.EncodeMethodCall(
908  {"TextInput.setClient",
909  EncodedClientConfig("TextInputType.text", "TextInputAction.done")});
910  messenger.SimulateEngineMessage(kChannelName, set_client_message->data(),
911  set_client_message->size(), reply_handler);
912 
913  EXPECT_TRUE(modifier.HasActiveModel());
914  modifier.SetViewId(kImplicitViewId);
915 
916  // Attempt to remove the implicit view.
917  handler.OnViewRemoved(kImplicitViewId);
918 
919  // State should be unchanged for the implicit view.
920  EXPECT_TRUE(modifier.HasActiveModel());
921  EXPECT_EQ(modifier.GetViewId(), kImplicitViewId);
922 }

References flutter::JsonMethodCodec::GetInstance(), flutter::TextInputPluginModifier::GetViewId(), flutter::TextInputPluginModifier::HasActiveModel(), kChannelName, flutter::kImplicitViewId, message, flutter::TextInputPlugin::OnViewRemoved(), and flutter::TextInputPluginModifier::SetViewId().

◆ TEST_F() [170/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
OnViewRemovedIgnoresNonActiveView   
)

Definition at line 861 of file text_input_plugin_unittest.cc.

861  {
862  UseEngineWithView();
863 
864  TestBinaryMessenger messenger([](const std::string& channel,
865  const uint8_t* message, size_t message_size,
866  BinaryReply reply) {});
867  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
868 
869  TextInputPlugin handler(&messenger, engine());
870  TextInputPluginModifier modifier(&handler);
871  modifier.SetViewId(456);
872 
873  // Set a client to create an active model.
874  auto& codec = JsonMethodCodec::GetInstance();
875  auto set_client_message = codec.EncodeMethodCall(
876  {"TextInput.setClient",
877  EncodedClientConfig("TextInputType.text", "TextInputAction.done")});
878  messenger.SimulateEngineMessage(kChannelName, set_client_message->data(),
879  set_client_message->size(), reply_handler);
880 
881  EXPECT_TRUE(modifier.HasActiveModel());
882  EXPECT_EQ(modifier.GetViewId(), 456);
883 
884  // Remove a different view.
885  handler.OnViewRemoved(789);
886 
887  // State should be unchanged.
888  EXPECT_TRUE(modifier.HasActiveModel());
889  EXPECT_EQ(modifier.GetViewId(), 456);
890 }

References flutter::JsonMethodCodec::GetInstance(), flutter::TextInputPluginModifier::GetViewId(), flutter::TextInputPluginModifier::HasActiveModel(), kChannelName, message, flutter::TextInputPlugin::OnViewRemoved(), and flutter::TextInputPluginModifier::SetViewId().

◆ TEST_F() [171/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
OnViewRemovedResetsActiveView   
)

Definition at line 829 of file text_input_plugin_unittest.cc.

829  {
830  UseEngineWithView();
831 
832  TestBinaryMessenger messenger([](const std::string& channel,
833  const uint8_t* message, size_t message_size,
834  BinaryReply reply) {});
835  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
836 
837  TextInputPlugin handler(&messenger, engine());
838  TextInputPluginModifier modifier(&handler);
839  modifier.SetViewId(456);
840 
841  // Set a client to create an active model.
842  auto& codec = JsonMethodCodec::GetInstance();
843  auto set_client_message = codec.EncodeMethodCall(
844  {"TextInput.setClient",
845  EncodedClientConfig("TextInputType.text", "TextInputAction.done")});
846  messenger.SimulateEngineMessage(kChannelName, set_client_message->data(),
847  set_client_message->size(), reply_handler);
848 
849  EXPECT_TRUE(modifier.HasActiveModel());
850  EXPECT_EQ(modifier.GetViewId(), 456);
851 
852  // Remove the active view.
853  handler.OnViewRemoved(456);
854 
855  EXPECT_FALSE(modifier.HasActiveModel());
856  EXPECT_EQ(modifier.GetViewId(), 0);
857 }

References flutter::JsonMethodCodec::GetInstance(), flutter::TextInputPluginModifier::GetViewId(), flutter::TextInputPluginModifier::HasActiveModel(), kChannelName, message, flutter::TextInputPlugin::OnViewRemoved(), and flutter::TextInputPluginModifier::SetViewId().

◆ TEST_F() [172/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
SetAndUseMultipleClients   
)

Definition at line 775 of file text_input_plugin_unittest.cc.

775  {
776  UseEngineWithView(); // Creates the default view
777  AddViewWithId(789); // Creates the next view
778 
779  bool sent_message = false;
780  TestBinaryMessenger messenger(
781  [&sent_message](const std::string& channel, const uint8_t* message,
782  size_t message_size,
783  BinaryReply reply) { sent_message = true; });
784 
785  TextInputPlugin handler(&messenger, engine());
786 
787  auto const set_client_and_send_message = [&](int client_id, int view_id) {
788  auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
789  auto& allocator = args->GetAllocator();
790  args->PushBack(client_id, allocator); // client_id
791 
792  rapidjson::Value client_config(rapidjson::kObjectType);
793  client_config.AddMember(kViewId, view_id, allocator); // view_id
794 
795  args->PushBack(client_config, allocator);
796  auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall(
797  MethodCall<rapidjson::Document>(kSetClientMethod, std::move(args)));
798 
799  std::string reply;
800  BinaryReply reply_handler = [&reply](const uint8_t* reply_bytes,
801  size_t reply_size) {
802  reply =
803  std::string(reinterpret_cast<const char*>(reply_bytes), reply_size);
804  };
805 
806  EXPECT_TRUE(messenger.SimulateEngineMessage(
807  kChannelName, encoded->data(), encoded->size(), reply_handler));
808 
809  sent_message = false;
810  handler.ComposeBeginHook();
811  EXPECT_TRUE(sent_message);
812  sent_message = false;
813  handler.ComposeChangeHook(u"4", 1);
814  EXPECT_TRUE(sent_message);
815  sent_message = false;
816  handler.ComposeCommitHook();
817  EXPECT_FALSE(sent_message);
818  sent_message = false;
819  handler.ComposeEndHook();
820  EXPECT_TRUE(sent_message);
821  };
822 
823  set_client_and_send_message(123, 456); // Set and send for the first view
824  set_client_and_send_message(123, 789); // Set and send for the next view
825 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::JsonMethodCodec::GetInstance(), kChannelName, kSetClientMethod, kViewId, and message.

◆ TEST_F() [173/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
SetClientRequiresViewId   
)

Definition at line 443 of file text_input_plugin_unittest.cc.

443  {
444  UseEngineWithView();
445 
446  TestBinaryMessenger messenger([](const std::string& channel,
447  const uint8_t* message, size_t message_size,
448  BinaryReply reply) {});
449 
450  TextInputPlugin handler(&messenger, engine());
451 
452  auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
453  auto& allocator = args->GetAllocator();
454  args->PushBack(123, allocator); // client_id
455 
456  rapidjson::Value client_config(rapidjson::kObjectType);
457 
458  args->PushBack(client_config, allocator);
459  auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall(
460  MethodCall<rapidjson::Document>(kSetClientMethod, std::move(args)));
461 
462  std::string reply;
463  BinaryReply reply_handler = [&reply](const uint8_t* reply_bytes,
464  size_t reply_size) {
465  reply = std::string(reinterpret_cast<const char*>(reply_bytes), reply_size);
466  };
467 
468  EXPECT_TRUE(messenger.SimulateEngineMessage(kChannelName, encoded->data(),
469  encoded->size(), reply_handler));
470  EXPECT_EQ(
471  reply,
472  "[\"Bad Arguments\",\"Could not set client, view ID is null.\",null]");
473 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::JsonMethodCodec::GetInstance(), kChannelName, kSetClientMethod, and message.

◆ TEST_F() [174/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
SetClientRequiresViewIdToBeInteger   
)

Definition at line 475 of file text_input_plugin_unittest.cc.

475  {
476  UseEngineWithView();
477 
478  TestBinaryMessenger messenger([](const std::string& channel,
479  const uint8_t* message, size_t message_size,
480  BinaryReply reply) {});
481 
482  TextInputPlugin handler(&messenger, engine());
483 
484  auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
485  auto& allocator = args->GetAllocator();
486  args->PushBack(123, allocator); // client_id
487 
488  rapidjson::Value client_config(rapidjson::kObjectType);
489  client_config.AddMember(kViewId, "Not an integer", allocator); // view_id
490 
491  args->PushBack(client_config, allocator);
492  auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall(
493  MethodCall<rapidjson::Document>(kSetClientMethod, std::move(args)));
494 
495  std::string reply;
496  BinaryReply reply_handler = [&reply](const uint8_t* reply_bytes,
497  size_t reply_size) {
498  reply = std::string(reinterpret_cast<const char*>(reply_bytes), reply_size);
499  };
500 
501  EXPECT_TRUE(messenger.SimulateEngineMessage(kChannelName, encoded->data(),
502  encoded->size(), reply_handler));
503  EXPECT_EQ(
504  reply,
505  "[\"Bad Arguments\",\"Could not set client, view ID is null.\",null]");
506 }

References flutter::MethodCodec< T >::EncodeMethodCall(), flutter::JsonMethodCodec::GetInstance(), kChannelName, kSetClientMethod, kViewId, and message.

◆ TEST_F() [175/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
SetEditingStatePreservesComposingRange   
)

Definition at line 508 of file text_input_plugin_unittest.cc.

508  {
509  UseEngineWithView();
510 
511  TestBinaryMessenger messenger(
512  [](const std::string&, const uint8_t*, size_t, BinaryReply) {});
513  BinaryReply reply_handler = [](const uint8_t*, size_t) {};
514 
515  TextInputPlugin handler(&messenger, engine());
516  TextInputPluginModifier modifier(&handler);
517  auto& codec = JsonMethodCodec::GetInstance();
518 
519  auto set_client_message = codec.EncodeMethodCall(
521  EncodedClientConfig("TextInputType.text", "TextInputAction.done")});
522  EXPECT_TRUE(messenger.SimulateEngineMessage(
523  kChannelName, set_client_message->data(), set_client_message->size(),
524  reply_handler));
525  ASSERT_TRUE(modifier.HasActiveModel());
526  handler.ComposeBeginHook();
527 
528  auto editing_state =
529  std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
530  auto& allocator = editing_state->GetAllocator();
531  editing_state->AddMember(kTextKey, "abcd", allocator);
532  editing_state->AddMember(kSelectionBaseKey, 2, allocator);
533  editing_state->AddMember(kSelectionExtentKey, 2, allocator);
534  editing_state->AddMember(kComposingBaseKey, 1, allocator);
535  editing_state->AddMember(kComposingExtentKey, 3, allocator);
536  auto set_editing_state_message = codec.EncodeMethodCall(
537  {kSetEditingStateMethod, std::move(editing_state)});
538  EXPECT_TRUE(messenger.SimulateEngineMessage(
539  kChannelName, set_editing_state_message->data(),
540  set_editing_state_message->size(), reply_handler));
541 
542  EXPECT_TRUE(modifier.GetActiveModel()->composing());
543  EXPECT_EQ(modifier.GetActiveModel()->composing_range(), TextRange(1, 3));
544 }
static constexpr char kTextKey[]
static constexpr char kSetEditingStateMethod[]
static constexpr char kComposingExtentKey[]
static constexpr char kComposingBaseKey[]

References flutter::TextInputPlugin::ComposeBeginHook(), flutter::TextInputModel::composing(), flutter::TextInputModel::composing_range(), flutter::TextInputPluginModifier::GetActiveModel(), flutter::JsonMethodCodec::GetInstance(), flutter::TextInputPluginModifier::HasActiveModel(), kChannelName, kComposingBaseKey, kComposingExtentKey, kSelectionBaseKey, kSelectionExtentKey, kSetClientMethod, kSetEditingStateMethod, and kTextKey.

◆ TEST_F() [176/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
SetMarkedTextRectRequiresView   
)

Definition at line 738 of file text_input_plugin_unittest.cc.

738  {
739  UseHeadlessEngine();
740 
741  TestBinaryMessenger messenger([](const std::string& channel,
742  const uint8_t* message, size_t message_size,
743  BinaryReply reply) {});
744 
745  std::string reply;
746  BinaryReply reply_handler = [&reply](const uint8_t* reply_bytes,
747  size_t reply_size) {
748  reply = std::string(reinterpret_cast<const char*>(reply_bytes), reply_size);
749  };
750 
751  TextInputPlugin handler(&messenger, engine());
752 
753  auto& codec = JsonMethodCodec::GetInstance();
754 
755  auto arguments =
756  std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
757  auto& allocator = arguments->GetAllocator();
758 
759  arguments->AddMember("x", 0, allocator);
760  arguments->AddMember("y", 0, allocator);
761  arguments->AddMember("width", 0, allocator);
762  arguments->AddMember("height", 0, allocator);
763 
764  auto message = codec.EncodeMethodCall(
765  {"TextInput.setMarkedTextRect", std::move(arguments)});
766  messenger.SimulateEngineMessage(kChannelName, message->data(),
767  message->size(), reply_handler);
768 
769  EXPECT_EQ(
770  reply,
771  "[\"Internal Consistency Error\",\"Text input is not available because "
772  "view with view_id=0 cannot be found\",null]");
773 }

References flutter::JsonMethodCodec::GetInstance(), kChannelName, and message.

◆ TEST_F() [177/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
TextEditingWorksWithDeltaModel   
)

Definition at line 546 of file text_input_plugin_unittest.cc.

546  {
547  UseEngineWithView();
548 
549  auto handled_message = CreateResponse(true);
550  auto unhandled_message = CreateResponse(false);
551  int received_scancode = 0;
552 
553  TestBinaryMessenger messenger(
554  [&received_scancode, &handled_message, &unhandled_message](
555  const std::string& channel, const uint8_t* message,
556  size_t message_size, BinaryReply reply) {});
557 
558  int redispatch_scancode = 0;
559  TextInputPlugin handler(&messenger, engine());
560 
561  auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
562  auto& allocator = args->GetAllocator();
563  args->PushBack(123, allocator); // client_id
564 
565  rapidjson::Value client_config(rapidjson::kObjectType);
566  client_config.AddMember(kEnableDeltaModel, true, allocator);
567  client_config.AddMember(kViewId, 456, allocator);
568 
569  args->PushBack(client_config, allocator);
570  auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall(
571  MethodCall<rapidjson::Document>(kSetClientMethod, std::move(args)));
572 
573  EXPECT_TRUE(messenger.SimulateEngineMessage(
574  kChannelName, encoded->data(), encoded->size(),
575  [](const uint8_t* reply, size_t reply_size) {}));
576 
577  handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
578  handler.ComposeBeginHook();
579  std::u16string text;
580  text.push_back('\n');
581  handler.ComposeChangeHook(text, 1);
582  handler.ComposeEndHook();
583 
584  handler.KeyboardHook(0x4E, 100, WM_KEYDOWN, 'n', false, false);
585  handler.ComposeBeginHook();
586  std::u16string textN;
587  text.push_back('n');
588  handler.ComposeChangeHook(textN, 1);
589  handler.KeyboardHook(0x49, 100, WM_KEYDOWN, 'i', false, false);
590  std::u16string textNi;
591  text.push_back('n');
592  text.push_back('i');
593  handler.ComposeChangeHook(textNi, 2);
594  handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
595  std::u16string textChineseCharacter;
596  text.push_back(u'\u4F60');
597  handler.ComposeChangeHook(textChineseCharacter, 1);
598  handler.ComposeCommitHook();
599  handler.ComposeEndHook();
600 
601  // Passes if it did not crash
602 }
std::u16string text
static constexpr char kEnableDeltaModel[]

References flutter::TextInputPlugin::ComposeBeginHook(), flutter::TextInputPlugin::ComposeChangeHook(), flutter::TextInputPlugin::ComposeCommitHook(), flutter::TextInputPlugin::ComposeEndHook(), flutter::MethodCodec< T >::EncodeMethodCall(), flutter::JsonMethodCodec::GetInstance(), kChannelName, kEnableDeltaModel, flutter::TextInputPlugin::KeyboardHook(), kSetClientMethod, kViewId, message, and text.

◆ TEST_F() [178/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
TextMethodsWorksWithEmptyModel   
)

Definition at line 207 of file text_input_plugin_unittest.cc.

207  {
208  UseEngineWithView();
209 
210  auto handled_message = CreateResponse(true);
211  auto unhandled_message = CreateResponse(false);
212  int received_scancode = 0;
213 
214  TestBinaryMessenger messenger(
215  [&received_scancode, &handled_message, &unhandled_message](
216  const std::string& channel, const uint8_t* message,
217  size_t message_size, BinaryReply reply) {});
218 
219  int redispatch_scancode = 0;
220  TextInputPlugin handler(&messenger, engine());
221 
222  handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
223  handler.ComposeBeginHook();
224  std::u16string text;
225  text.push_back('\n');
226  handler.ComposeChangeHook(text, 1);
227  handler.ComposeEndHook();
228 
229  // Passes if it did not crash
230 }

References flutter::TextInputPlugin::ComposeBeginHook(), flutter::TextInputPlugin::ComposeChangeHook(), flutter::TextInputPlugin::ComposeEndHook(), flutter::TextInputPlugin::KeyboardHook(), message, and text.

◆ TEST_F() [179/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
TransformCursorRect   
)

Definition at line 665 of file text_input_plugin_unittest.cc.

665  {
666  UseEngineWithView();
667 
668  // A position of `EditableText`.
669  double view_x = 100;
670  double view_y = 200;
671 
672  // A position and size of marked text, in `EditableText` local coordinates.
673  double ime_x = 3;
674  double ime_y = 4;
675  double ime_width = 50;
676  double ime_height = 60;
677 
678  // Transformation matrix.
679  std::array<std::array<double, 4>, 4> editabletext_transform = {
680  1.0, 0.0, 0.0, view_x, //
681  0.0, 1.0, 0.0, view_y, //
682  0.0, 0.0, 0.0, 0.0, //
683  0.0, 0.0, 0.0, 1.0};
684 
685  TestBinaryMessenger messenger([](const std::string& channel,
686  const uint8_t* message, size_t message_size,
687  BinaryReply reply) {});
688  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
689 
690  TextInputPlugin handler(&messenger, engine());
691  TextInputPluginModifier modifier(&handler);
692  modifier.SetViewId(456);
693 
694  auto& codec = JsonMethodCodec::GetInstance();
695 
696  EXPECT_CALL(*view(), OnCursorRectUpdated(Rect{{view_x, view_y}, {0, 0}}));
697 
698  {
699  auto arguments =
700  std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
701  auto& allocator = arguments->GetAllocator();
702 
703  rapidjson::Value transoform(rapidjson::kArrayType);
704  for (int i = 0; i < 4 * 4; i++) {
705  // Pack 2-dimensional array by column-major order.
706  transoform.PushBack(editabletext_transform[i % 4][i / 4], allocator);
707  }
708 
709  arguments->AddMember("transform", transoform, allocator);
710 
711  auto message = codec.EncodeMethodCall(
712  {"TextInput.setEditableSizeAndTransform", std::move(arguments)});
713  messenger.SimulateEngineMessage(kChannelName, message->data(),
714  message->size(), reply_handler);
715  }
716 
717  EXPECT_CALL(*view(),
718  OnCursorRectUpdated(Rect{{view_x + ime_x, view_y + ime_y},
719  {ime_width, ime_height}}));
720 
721  {
722  auto arguments =
723  std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
724  auto& allocator = arguments->GetAllocator();
725 
726  arguments->AddMember("x", ime_x, allocator);
727  arguments->AddMember("y", ime_y, allocator);
728  arguments->AddMember("width", ime_width, allocator);
729  arguments->AddMember("height", ime_height, allocator);
730 
731  auto message = codec.EncodeMethodCall(
732  {"TextInput.setMarkedTextRect", std::move(arguments)});
733  messenger.SimulateEngineMessage(kChannelName, message->data(),
734  message->size(), reply_handler);
735  }
736 }

References flutter::JsonMethodCodec::GetInstance(), kChannelName, message, and flutter::TextInputPluginModifier::SetViewId().

◆ TEST_F() [180/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
VerifyComposingSendStateUpdate   
)

Definition at line 281 of file text_input_plugin_unittest.cc.

281  {
282  UseEngineWithView();
283 
284  bool sent_message = false;
285  TestBinaryMessenger messenger(
286  [&sent_message](const std::string& channel, const uint8_t* message,
287  size_t message_size,
288  BinaryReply reply) { sent_message = true; });
289  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
290 
291  TextInputPlugin handler(&messenger, engine());
292 
293  auto& codec = JsonMethodCodec::GetInstance();
294 
295  // Call TextInput.setClient to initialize the TextInputModel.
296  auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
297  auto& allocator = arguments->GetAllocator();
298  arguments->PushBack(kDefaultClientId, allocator);
299  rapidjson::Value config(rapidjson::kObjectType);
300  config.AddMember("inputAction", "done", allocator);
301  config.AddMember("inputType", "text", allocator);
302  config.AddMember(kEnableDeltaModel, false, allocator);
303  config.AddMember(kViewId, 456, allocator);
304  arguments->PushBack(config, allocator);
305  auto message =
306  codec.EncodeMethodCall({"TextInput.setClient", std::move(arguments)});
307  messenger.SimulateEngineMessage("flutter/textinput", message->data(),
308  message->size(), reply_handler);
309 
310  // ComposeBeginHook should send state update.
311  sent_message = false;
312  handler.ComposeBeginHook();
313  EXPECT_TRUE(sent_message);
314 
315  // ComposeChangeHook should send state update.
316  sent_message = false;
317  handler.ComposeChangeHook(u"4", 1);
318  EXPECT_TRUE(sent_message);
319 
320  // ComposeCommitHook should NOT send state update.
321  //
322  // Commit messages are always immediately followed by a change message or an
323  // end message, both of which will send an update. Sending intermediate state
324  // with a collapsed composing region will trigger the framework to assume
325  // composing has ended, which is not the case until a WM_IME_ENDCOMPOSING
326  // event is received in the main event loop, which will trigger a call to
327  // ComposeEndHook.
328  sent_message = false;
329  handler.ComposeCommitHook();
330  EXPECT_FALSE(sent_message);
331 
332  // ComposeEndHook should send state update.
333  sent_message = false;
334  handler.ComposeEndHook();
335  EXPECT_TRUE(sent_message);
336 }

References flutter::TextInputPlugin::ComposeBeginHook(), flutter::TextInputPlugin::ComposeChangeHook(), flutter::TextInputPlugin::ComposeCommitHook(), flutter::TextInputPlugin::ComposeEndHook(), flutter::JsonMethodCodec::GetInstance(), kEnableDeltaModel, kViewId, and message.

◆ TEST_F() [181/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
VerifyInputActionNewlineInsertNewLine   
)

Definition at line 338 of file text_input_plugin_unittest.cc.

338  {
339  UseEngineWithView();
340 
341  // Store messages as std::string for convenience.
342  std::vector<std::string> messages;
343 
344  TestBinaryMessenger messenger(
345  [&messages](const std::string& channel, const uint8_t* message,
346  size_t message_size, BinaryReply reply) {
347  std::string last_message(reinterpret_cast<const char*>(message),
348  message_size);
349  messages.push_back(last_message);
350  });
351  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
352 
353  TextInputPlugin handler(&messenger, engine());
354 
355  auto& codec = JsonMethodCodec::GetInstance();
356 
357  // Call TextInput.setClient to initialize the TextInputModel.
358  auto set_client_arguments =
359  EncodedClientConfig("TextInputType.multiline", "TextInputAction.newline");
360  auto message = codec.EncodeMethodCall(
361  {"TextInput.setClient", std::move(set_client_arguments)});
362  messenger.SimulateEngineMessage("flutter/textinput", message->data(),
363  message->size(), reply_handler);
364 
365  // Simulate a key down event for '\n'.
366  handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
367 
368  // Two messages are expected, the first is TextInput.updateEditingState and
369  // the second is TextInputClient.performAction.
370  EXPECT_EQ(messages.size(), 2);
371 
372  // Editing state should have been updated.
373  auto encoded_arguments = EncodedEditingState("\n", TextRange(1));
374  auto update_state_message = codec.EncodeMethodCall(
375  {kUpdateEditingStateMethod, std::move(encoded_arguments)});
376 
377  EXPECT_TRUE(std::equal(update_state_message->begin(),
378  update_state_message->end(),
379  messages.front().begin()));
380 
381  // TextInputClient.performAction should have been called.
382  auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
383  auto& allocator = arguments->GetAllocator();
384  arguments->PushBack(kDefaultClientId, allocator);
385  arguments->PushBack(
386  rapidjson::Value("TextInputAction.newline", allocator).Move(), allocator);
387  auto invoke_action_message = codec.EncodeMethodCall(
388  {"TextInputClient.performAction", std::move(arguments)});
389 
390  EXPECT_TRUE(std::equal(invoke_action_message->begin(),
391  invoke_action_message->end(),
392  messages.back().begin()));
393 }

References flutter::JsonMethodCodec::GetInstance(), flutter::TextInputPlugin::KeyboardHook(), kUpdateEditingStateMethod, and message.

◆ TEST_F() [182/271]

flutter::testing::TEST_F ( TextInputPluginTest  ,
VerifyInputActionSendDoesNotInsertNewLine   
)

Definition at line 396 of file text_input_plugin_unittest.cc.

396  {
397  UseEngineWithView();
398 
399  std::vector<std::vector<uint8_t>> messages;
400 
401  TestBinaryMessenger messenger(
402  [&messages](const std::string& channel, const uint8_t* message,
403  size_t message_size, BinaryReply reply) {
404  int length = static_cast<int>(message_size);
405  std::vector<uint8_t> last_message(length);
406  memcpy(&last_message[0], &message[0], length * sizeof(uint8_t));
407  messages.push_back(last_message);
408  });
409  BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
410 
411  TextInputPlugin handler(&messenger, engine());
412 
413  auto& codec = JsonMethodCodec::GetInstance();
414 
415  // Call TextInput.setClient to initialize the TextInputModel.
416  auto set_client_arguments =
417  EncodedClientConfig("TextInputType.multiline", "TextInputAction.send");
418  auto message = codec.EncodeMethodCall(
419  {"TextInput.setClient", std::move(set_client_arguments)});
420  messenger.SimulateEngineMessage("flutter/textinput", message->data(),
421  message->size(), reply_handler);
422 
423  // Simulate a key down event for '\n'.
424  handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
425 
426  // Only a call to TextInputClient.performAction is expected.
427  EXPECT_EQ(messages.size(), 1);
428 
429  // TextInputClient.performAction should have been called.
430  auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
431  auto& allocator = arguments->GetAllocator();
432  arguments->PushBack(kDefaultClientId, allocator);
433  arguments->PushBack(
434  rapidjson::Value("TextInputAction.send", allocator).Move(), allocator);
435  auto invoke_action_message = codec.EncodeMethodCall(
436  {"TextInputClient.performAction", std::move(arguments)});
437 
438  EXPECT_TRUE(std::equal(invoke_action_message->begin(),
439  invoke_action_message->end(),
440  messages.front().begin()));
441 }

References flutter::JsonMethodCodec::GetInstance(), flutter::TextInputPlugin::KeyboardHook(), and message.

◆ TEST_F() [183/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CanConstrainByMaximumSize   
)

Definition at line 257 of file window_manager_unittests.cc.

257  {
258  IsolateScope isolate_scope(isolate());
259 
260  const int64_t view_id =
262  engine_id(), regular_creation_request());
263  const HWND window_handle =
265  view_id);
266  WindowConstraints constraints{.has_view_constraints = true,
267  .view_min_width = 0,
268  .view_min_height = 0,
269  .view_max_width = 500,
270  .view_max_height = 500};
272  &constraints);
273 
274  ActualWindowSize actual_size =
276  EXPECT_EQ(actual_size.width, 500);
277  EXPECT_EQ(actual_size.height, 500);
278 }
void InternalFlutterWindows_WindowManager_SetWindowConstraints(HWND hwnd, const flutter::WindowConstraints *constraints)
FlutterViewId InternalFlutterWindows_WindowManager_CreateRegularWindow(int64_t engine_id, const flutter::RegularWindowCreationRequest *request)
flutter::ActualWindowSize InternalFlutterWindows_WindowManager_GetWindowContentSize(HWND hwnd)
HWND InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(int64_t engine_id, FlutterViewId view_id)

References flutter::WindowConstraints::has_view_constraints, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), InternalFlutterWindows_WindowManager_SetWindowConstraints(), and flutter::ActualWindowSize::width.

◆ TEST_F() [184/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CanConstrainByMinimiumSize   
)

Definition at line 234 of file window_manager_unittests.cc.

234  {
235  IsolateScope isolate_scope(isolate());
236 
237  const int64_t view_id =
239  engine_id(), regular_creation_request());
240  const HWND window_handle =
242  view_id);
243  WindowConstraints constraints{.has_view_constraints = true,
244  .view_min_width = 900,
245  .view_min_height = 700,
246  .view_max_width = 10000,
247  .view_max_height = 10000};
249  &constraints);
250 
251  ActualWindowSize actual_size =
253  EXPECT_EQ(actual_size.width, 900);
254  EXPECT_EQ(actual_size.height, 700);
255 }

References flutter::WindowConstraints::has_view_constraints, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), InternalFlutterWindows_WindowManager_SetWindowConstraints(), and flutter::ActualWindowSize::width.

◆ TEST_F() [185/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CanFullscreenWindow   
)

Definition at line 280 of file window_manager_unittests.cc.

280  {
281  IsolateScope isolate_scope(isolate());
282 
283  const int64_t view_id =
285  engine_id(), regular_creation_request());
286  const HWND window_handle =
288  view_id);
289 
290  FullscreenRequest request{.fullscreen = true, .has_display_id = false};
292 
293  int screen_width = GetSystemMetrics(SM_CXSCREEN);
294  int screen_height = GetSystemMetrics(SM_CYSCREEN);
295  ActualWindowSize actual_size =
297  EXPECT_EQ(actual_size.width, screen_width);
298  EXPECT_EQ(actual_size.height, screen_height);
299  EXPECT_TRUE(
301 }
bool InternalFlutterWindows_WindowManager_GetFullscreen(HWND hwnd)
void InternalFlutterWindows_WindowManager_SetFullscreen(HWND hwnd, const flutter::FullscreenRequest *request)

References flutter::FullscreenRequest::fullscreen, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetFullscreen(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), InternalFlutterWindows_WindowManager_SetFullscreen(), and flutter::ActualWindowSize::width.

◆ TEST_F() [186/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CanSetWindowConstraintsWhileFullscreen   
)

Definition at line 358 of file window_manager_unittests.cc.

358  {
359  IsolateScope isolate_scope(isolate());
360 
361  const int64_t view_id =
363  engine_id(), regular_creation_request());
364  const HWND window_handle =
366  view_id);
367 
368  FullscreenRequest request{.fullscreen = true, .has_display_id = false};
370 
371  WindowConstraints constraints{.has_view_constraints = true,
372  .view_min_width = 0,
373  .view_min_height = 0,
374  .view_max_width = 500,
375  .view_max_height = 500};
377  &constraints);
378 
379  request.fullscreen = false;
381 
382  ActualWindowSize actual_size =
384  EXPECT_EQ(actual_size.width, 500);
385  EXPECT_EQ(actual_size.height, 500);
386 }

References flutter::FullscreenRequest::fullscreen, flutter::WindowConstraints::has_view_constraints, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), InternalFlutterWindows_WindowManager_SetFullscreen(), InternalFlutterWindows_WindowManager_SetWindowConstraints(), and flutter::ActualWindowSize::width.

◆ TEST_F() [187/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CanSetWindowSizeWhileFullscreen   
)

Definition at line 327 of file window_manager_unittests.cc.

327  {
328  IsolateScope isolate_scope(isolate());
329 
330  const int64_t view_id =
332  engine_id(), regular_creation_request());
333  const HWND window_handle =
335  view_id);
336 
337  FullscreenRequest request{.fullscreen = true, .has_display_id = false};
339 
340  WindowSizeRequest requestedSize{
341 
342  .has_preferred_view_size = true,
343  .preferred_view_width = 500,
344  .preferred_view_height = 500,
345  };
347  &requestedSize);
348 
349  request.fullscreen = false;
351 
352  ActualWindowSize actual_size =
354  EXPECT_EQ(actual_size.width, 500);
355  EXPECT_EQ(actual_size.height, 500);
356 }
void InternalFlutterWindows_WindowManager_SetWindowSize(HWND hwnd, const flutter::WindowSizeRequest *size)

References flutter::FullscreenRequest::fullscreen, flutter::WindowSizeRequest::has_preferred_view_size, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), InternalFlutterWindows_WindowManager_SetFullscreen(), InternalFlutterWindows_WindowManager_SetWindowSize(), and flutter::ActualWindowSize::width.

◆ TEST_F() [188/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CanUnfullscreenWindow   
)

Definition at line 303 of file window_manager_unittests.cc.

303  {
304  IsolateScope isolate_scope(isolate());
305 
306  const int64_t view_id =
308  engine_id(), regular_creation_request());
309  const HWND window_handle =
311  view_id);
312 
313  FullscreenRequest request{.fullscreen = true, .has_display_id = false};
315 
316  request.fullscreen = false;
318 
319  ActualWindowSize actual_size =
321  EXPECT_EQ(actual_size.width, 800);
322  EXPECT_EQ(actual_size.height, 600);
323  EXPECT_FALSE(
325 }

References flutter::FullscreenRequest::fullscreen, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetFullscreen(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), InternalFlutterWindows_WindowManager_SetFullscreen(), and flutter::ActualWindowSize::width.

◆ TEST_F() [189/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateModalDialogSizedToContent   
)

Definition at line 1097 of file window_manager_unittests.cc.

1097  {
1098  IsolateScope isolate_scope(isolate());
1099 
1100  const int64_t parent_view_id =
1102  engine_id(), regular_creation_request());
1103  const HWND parent_window_handle =
1105  engine_id(), parent_view_id);
1106 
1107  DialogWindowCreationRequest creation_request{
1108  .preferred_size = {.has_preferred_view_size = false},
1109  .preferred_constraints = {.has_view_constraints = false},
1110  .title = L"Modal Dialog Sized To Content",
1111  .parent_or_null = parent_window_handle,
1112  .sized_to_content = true,
1113  .resizable = false};
1114 
1115  const int64_t view_id =
1117  engine_id(), &creation_request);
1118  EXPECT_GE(view_id, 0);
1119 }
FLUTTER_EXPORT FlutterViewId InternalFlutterWindows_WindowManager_CreateDialogWindow(int64_t engine_id, const flutter::DialogWindowCreationRequest *request)

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateDialogWindow(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and flutter::DialogWindowCreationRequest::preferred_size.

◆ TEST_F() [190/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateModalDialogWindow   
)

Definition at line 403 of file window_manager_unittests.cc.

403  {
404  IsolateScope isolate_scope(isolate());
405 
406  const int64_t parent_view_id =
408  engine_id(), regular_creation_request());
409  const HWND parent_window_handle =
411  engine_id(), parent_view_id);
412 
413  DialogWindowCreationRequest creation_request{
414  .preferred_size =
415  {
416  .has_preferred_view_size = true,
417  .preferred_view_width = 800,
418  .preferred_view_height = 600,
419  },
420  .preferred_constraints = {.has_view_constraints = false},
421  .title = L"Hello World",
422  .parent_or_null = parent_window_handle};
423 
424  const int64_t view_id =
426  engine_id(), &creation_request);
427  EXPECT_EQ(view_id, 2);
428 
429  const HWND window_handle =
431  view_id);
432  HostWindow* host_window = HostWindow::GetThisFromHandle(window_handle);
433  EXPECT_EQ(host_window->GetOwnerWindow()->GetWindowHandle(),
434  parent_window_handle);
435 }

References flutter::HostWindow::GetOwnerWindow(), flutter::HostWindow::GetThisFromHandle(), flutter::HostWindow::GetWindowHandle(), flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateDialogWindow(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and flutter::DialogWindowCreationRequest::preferred_size.

◆ TEST_F() [191/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateModelessDialogSizedToContent   
)

Definition at line 1080 of file window_manager_unittests.cc.

1080  {
1081  IsolateScope isolate_scope(isolate());
1082 
1083  DialogWindowCreationRequest creation_request{
1084  .preferred_size = {.has_preferred_view_size = false},
1085  .preferred_constraints = {.has_view_constraints = false},
1086  .title = L"Modeless Dialog Sized To Content",
1087  .parent_or_null = nullptr,
1088  .sized_to_content = true,
1089  .resizable = false};
1090 
1091  const int64_t view_id =
1093  engine_id(), &creation_request);
1094  EXPECT_GE(view_id, 0);
1095 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateDialogWindow(), and flutter::DialogWindowCreationRequest::preferred_size.

◆ TEST_F() [192/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateModelessDialogWindow   
)

Definition at line 388 of file window_manager_unittests.cc.

388  {
389  IsolateScope isolate_scope(isolate());
390  DialogWindowCreationRequest creation_request{
391  .preferred_size = {.has_preferred_view_size = true,
392  .preferred_view_width = 800,
393  .preferred_view_height = 600},
394  .preferred_constraints = {.has_view_constraints = false},
395  .title = L"Hello World",
396  .parent_or_null = nullptr};
397  const int64_t view_id =
399  engine_id(), &creation_request);
400  EXPECT_EQ(view_id, 1);
401 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateDialogWindow(), and flutter::DialogWindowCreationRequest::preferred_size.

◆ TEST_F() [193/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreatePopupWindow   
)

Definition at line 748 of file window_manager_unittests.cc.

748  {
749  IsolateScope isolate_scope(isolate());
750 
751  const int64_t parent_view_id =
753  engine_id(), regular_creation_request());
754  const HWND parent_window_handle =
756  engine_id(), parent_view_id);
757 
758  auto position_callback =
759  [](const WindowSize& child_size, const WindowRect& parent_rect,
760  const WindowRect& display_rect, WindowRect& rect) {
761  rect.left = parent_rect.left + 10;
762  rect.top = parent_rect.top + 10;
763  rect.width = child_size.width;
764  rect.height = child_size.height;
765  };
766 
767  PopupWindowCreationRequest creation_request{
768  .preferred_constraints = {.has_view_constraints = true,
769  .view_min_width = 100,
770  .view_min_height = 50,
771  .view_max_width = 300,
772  .view_max_height = 200},
773  .parent = parent_window_handle,
774  .get_position_callback = position_callback};
775 
776  const int64_t popup_view_id =
778  &creation_request);
779 
780  EXPECT_NE(popup_view_id, -1);
781  HWND popup_window_handle =
783  engine_id(), popup_view_id);
784  EXPECT_NE(popup_window_handle, nullptr);
785 }
FLUTTER_EXPORT FlutterViewId InternalFlutterWindows_WindowManager_CreatePopupWindow(int64_t engine_id, const flutter::PopupWindowCreationRequest *request)

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreatePopupWindow(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::PopupWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [194/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateRegularWindow   
)

Definition at line 169 of file window_manager_unittests.cc.

169  {
170  IsolateScope isolate_scope(isolate());
171 
172  const int64_t view_id =
174  engine_id(), regular_creation_request());
175  EXPECT_EQ(view_id, 1);
176 }

References InternalFlutterWindows_WindowManager_CreateRegularWindow().

◆ TEST_F() [195/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateRegularWindowSizedToContent   
)

Definition at line 957 of file window_manager_unittests.cc.

957  {
958  IsolateScope isolate_scope(isolate());
959 
960  RegularWindowCreationRequest creation_request{
961  .preferred_size = {.has_preferred_view_size = false},
962  .preferred_constraints = {.has_view_constraints = false},
963  .title = L"Sized To Content",
964  .sized_to_content = true,
965  .resizable = false};
966 
967  const int64_t view_id =
969  engine_id(), &creation_request);
970  EXPECT_GE(view_id, 1);
971 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateRegularWindow(), and flutter::RegularWindowCreationRequest::preferred_size.

◆ TEST_F() [196/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateSatelliteWindow   
)

Definition at line 1304 of file window_manager_unittests.cc.

1304  {
1305  IsolateScope isolate_scope(isolate());
1306 
1307  const HWND parent_window_handle = CreateParentWindow();
1308  SatelliteWindowCreationRequest creation_request =
1309  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1310 
1311  const int64_t satellite_view_id =
1313  engine_id(), &creation_request);
1314 
1315  EXPECT_GE(satellite_view_id, 0);
1316  const HWND satellite_window_handle =
1318  engine_id(), satellite_view_id);
1319  EXPECT_NE(satellite_window_handle, nullptr);
1320 }
FLUTTER_EXPORT FlutterViewId InternalFlutterWindows_WindowManager_CreateSatelliteWindow(int64_t engine_id, const flutter::SatelliteWindowCreationRequest *request)

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), and InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle().

◆ TEST_F() [197/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateSatelliteWindowSizedToContent   
)

Definition at line 1636 of file window_manager_unittests.cc.

1636  {
1637  IsolateScope isolate_scope(isolate());
1638 
1639  const HWND parent_window_handle = CreateParentWindow();
1640  SetWindowPos(parent_window_handle, nullptr, 200, 100, 0, 0,
1641  SWP_NOSIZE | SWP_NOZORDER);
1642 
1643  SatelliteWindowCreationRequest creation_request =
1644  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1645  creation_request.preferred_size = {.has_preferred_view_size = false};
1646  creation_request.sized_to_content = true;
1647 
1648  const int64_t satellite_view_id =
1650  engine_id(), &creation_request);
1651  ASSERT_GE(satellite_view_id, 0);
1652  const HWND satellite_window_handle =
1654  engine_id(), satellite_view_id);
1655  ASSERT_NE(satellite_window_handle, nullptr);
1656 
1657  FlutterWindowsView* view =
1658  engine()->GetViewFromTopLevelWindow(satellite_window_handle);
1659  ASSERT_NE(view, nullptr);
1660  EXPECT_TRUE(view->IsSizedToContent());
1661 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::FlutterWindowsView::IsSizedToContent(), flutter::SatelliteWindowCreationRequest::preferred_size, and flutter::SatelliteWindowCreationRequest::sized_to_content.

◆ TEST_F() [198/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
CreateTooltipWindow   
)

Definition at line 493 of file window_manager_unittests.cc.

493  {
494  IsolateScope isolate_scope(isolate());
495 
496  const int64_t parent_view_id =
498  engine_id(), regular_creation_request());
499  const HWND parent_window_handle =
501  engine_id(), parent_view_id);
502 
503  auto position_callback =
504  [](const WindowSize& child_size, const WindowRect& parent_rect,
505  const WindowRect& display_rect, WindowRect& rect) {
506  rect.left = parent_rect.left + 10;
507  rect.top = parent_rect.top + 10;
508  rect.width = child_size.width;
509  rect.height = child_size.height;
510  };
511 
512  TooltipWindowCreationRequest creation_request{
513  .preferred_constraints = {.has_view_constraints = true,
514  .view_min_width = 100,
515  .view_min_height = 50,
516  .view_max_width = 300,
517  .view_max_height = 200},
518  .parent = parent_window_handle,
519  .get_position_callback = position_callback};
520 
521  const int64_t tooltip_view_id =
523  engine_id(), &creation_request);
524 
525  EXPECT_NE(tooltip_view_id, -1);
526  HWND tooltip_window_handle =
528  engine_id(), tooltip_view_id);
529  EXPECT_NE(tooltip_window_handle, nullptr);
530 }
FLUTTER_EXPORT FlutterViewId InternalFlutterWindows_WindowManager_CreateTooltipWindow(int64_t engine_id, const flutter::TooltipWindowCreationRequest *request)

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_CreateTooltipWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::TooltipWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [199/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DeactivatedRegularWindowDoesNotReactivateItself   
)

Definition at line 437 of file window_manager_unittests.cc.

437  {
438  IsolateScope isolate_scope(isolate());
439 
440  // Two independent top-level regular windows (regular windows have no Win32
441  // owner). |window_handle| is deactivated while |active_window_handle| holds
442  // activation.
443  const int64_t window_view_id =
445  engine_id(), regular_creation_request());
446  const HWND window_handle =
448  engine_id(), window_view_id);
449 
450  const int64_t active_view_id =
452  engine_id(), regular_creation_request());
453  const HWND active_window_handle =
455  engine_id(), active_view_id);
456 
457  SetActiveWindow(active_window_handle);
458  ASSERT_EQ(GetActiveWindow(), active_window_handle);
459 
460  // A window receiving WM_ACTIVATE with WA_INACTIVE must not focus its own
461  // content: SetFocus activates the parent of the focused window (the window
462  // itself), which would reactivate the deactivated window, pull it back to the
463  // top of the z-order, and take activation away from the active window.
464  SendMessage(window_handle, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), 0);
465 
466  EXPECT_EQ(GetActiveWindow(), active_window_handle);
467 }

References InternalFlutterWindows_WindowManager_CreateRegularWindow(), and InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle().

◆ TEST_F() [200/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DialogCanNeverBeFullscreen   
)

Definition at line 469 of file window_manager_unittests.cc.

469  {
470  IsolateScope isolate_scope(isolate());
471 
472  DialogWindowCreationRequest creation_request{
473  .preferred_size = {.has_preferred_view_size = true,
474  .preferred_view_width = 800,
475  .preferred_view_height = 600},
476  .preferred_constraints = {.has_view_constraints = false},
477  .title = L"Hello World",
478  .parent_or_null = nullptr};
479 
480  const int64_t view_id =
482  engine_id(), &creation_request);
483  const HWND window_handle =
485  view_id);
486 
487  FullscreenRequest request{.fullscreen = true, .has_display_id = false};
489  EXPECT_FALSE(
491 }

References flutter::FullscreenRequest::fullscreen, flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateDialogWindow(), InternalFlutterWindows_WindowManager_GetFullscreen(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_SetFullscreen(), and flutter::DialogWindowCreationRequest::preferred_size.

◆ TEST_F() [201/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DialogWindowSizedToContentNonResizableHasNoThickFrame   
)

Definition at line 1153 of file window_manager_unittests.cc.

1154  {
1155  IsolateScope isolate_scope(isolate());
1156 
1157  DialogWindowCreationRequest creation_request{
1158  .preferred_size = {.has_preferred_view_size = false},
1159  .preferred_constraints = {.has_view_constraints = false},
1160  .title = L"Dialog Sized To Content Non-Resizable",
1161  .parent_or_null = nullptr,
1162  .sized_to_content = true,
1163  .resizable = false};
1164 
1165  const int64_t view_id =
1167  engine_id(), &creation_request);
1168  const HWND window_handle =
1170  view_id);
1171 
1172  const LONG style = GetWindowLong(window_handle, GWL_STYLE);
1173  EXPECT_EQ(style & WS_THICKFRAME, 0L);
1174 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateDialogWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and flutter::DialogWindowCreationRequest::preferred_size.

◆ TEST_F() [202/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DISABLED_DialogWindowSizedToContentResizesToContent   
)

Definition at line 1123 of file window_manager_unittests.cc.

1123  {
1124  IsolateScope isolate_scope(isolate());
1125 
1126  DialogWindowCreationRequest creation_request{
1127  .preferred_size = {.has_preferred_view_size = false},
1128  .preferred_constraints = {.has_view_constraints = false},
1129  .title = L"Dialog Sized To Content",
1130  .parent_or_null = nullptr,
1131  .sized_to_content = true,
1132  .resizable = false};
1133 
1134  const int64_t view_id =
1136  engine_id(), &creation_request);
1137  const HWND window_handle =
1139  view_id);
1140 
1141  FlutterWindowsView* view = engine()->GetViewFromTopLevelWindow(window_handle);
1142  ASSERT_NE(view, nullptr);
1143 
1144  view->OnFrameGenerated(300, 200);
1145  engine()->task_runner()->ProcessTasks();
1146 
1147  ActualWindowSize size =
1149  EXPECT_EQ(size.width, 300);
1150  EXPECT_EQ(size.height, 200);
1151 }

References flutter::WindowSizeRequest::has_preferred_view_size, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateDialogWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), flutter::FlutterWindowsView::OnFrameGenerated(), flutter::DialogWindowCreationRequest::preferred_size, and flutter::ActualWindowSize::width.

◆ TEST_F() [203/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DISABLED_PopupWindowUpdatesPositionOnViewSizeChange   
)

Definition at line 875 of file window_manager_unittests.cc.

875  {
876  IsolateScope isolate_scope(isolate());
877 
878  const int64_t parent_view_id =
880  engine_id(), regular_creation_request());
881  const HWND parent_window_handle =
883  engine_id(), parent_view_id);
884 
885  // Track the child size passed to the callback
886  static int callback_count = 0;
887  static int last_width = 0;
888  static int last_height = 0;
889 
890  auto position_callback =
891  [](const WindowSize& child_size, const WindowRect& parent_rect,
892  const WindowRect& display_rect, WindowRect& rect) {
893  callback_count++;
894  last_width = child_size.width;
895  last_height = child_size.height;
896 
897  rect.left = parent_rect.left + callback_count * 5;
898  rect.top = parent_rect.top + callback_count * 5;
899  rect.width = child_size.width;
900  rect.height = child_size.height;
901  };
902 
903  PopupWindowCreationRequest creation_request{
904  .preferred_constraints = {.has_view_constraints = true,
905  .view_min_width = 100,
906  .view_min_height = 50,
907  .view_max_width = 300,
908  .view_max_height = 200},
909  .parent = parent_window_handle,
910  .get_position_callback = position_callback};
911 
912  // Reset callback tracking
913  callback_count = 0;
914  last_width = 0;
915  last_height = 0;
916 
917  const int64_t popup_view_id =
919  &creation_request);
920 
921  HWND popup_window_handle =
923  engine_id(), popup_view_id);
924 
925  // Get the view associated with the popup window
926  FlutterWindowsView* view =
927  engine()->GetViewFromTopLevelWindow(popup_window_handle);
928  ASSERT_NE(view, nullptr);
929 
930  // Get initial position
931  RECT initial_rect;
932  GetWindowRect(popup_window_handle, &initial_rect);
933  int initial_callback_count = callback_count;
934 
935  // Simulate a frame being generated with new dimensions
936  // This should trigger DidUpdateViewSize which calls UpdatePosition
937  view->OnFrameGenerated(150, 100);
938 
939  // Process any pending tasks to ensure the callback is executed
940  engine()->task_runner()->ProcessTasks();
941 
942  // Verify the callback was called again with the new dimensions
943  EXPECT_GT(callback_count, initial_callback_count);
944  EXPECT_EQ(last_width, 150);
945  EXPECT_EQ(last_height, 100);
946 
947  // Get new position and verify it changed
948  RECT new_rect;
949  GetWindowRect(popup_window_handle, &new_rect);
950 
951  // The position should have changed due to our callback logic
952  // (we offset by callback_count * 5)
953  EXPECT_NE(initial_rect.left, new_rect.left);
954  EXPECT_NE(initial_rect.top, new_rect.top);
955 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreatePopupWindow(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::FlutterWindowsView::OnFrameGenerated(), flutter::PopupWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [204/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DISABLED_RegularWindowSizedToContentResizableStopsTrackingAfterFirstFrame   
)

Definition at line 1052 of file window_manager_unittests.cc.

1054  {
1055  IsolateScope isolate_scope(isolate());
1056 
1057  RegularWindowCreationRequest creation_request{
1058  .preferred_size = {.has_preferred_view_size = false},
1059  .preferred_constraints = {.has_view_constraints = false},
1060  .title = L"Sized To Content Resizable",
1061  .sized_to_content = true,
1062  .resizable = true};
1063 
1064  const int64_t view_id =
1066  engine_id(), &creation_request);
1067  const HWND window_handle =
1069  view_id);
1070 
1071  FlutterWindowsView* view = engine()->GetViewFromTopLevelWindow(window_handle);
1072  ASSERT_NE(view, nullptr);
1073 
1074  view->OnFrameGenerated(300, 200);
1075  engine()->task_runner()->ProcessTasks();
1076 
1077  EXPECT_FALSE(view->IsSizedToContent());
1078 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::FlutterWindowsView::IsSizedToContent(), flutter::FlutterWindowsView::OnFrameGenerated(), and flutter::RegularWindowCreationRequest::preferred_size.

◆ TEST_F() [205/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DISABLED_RegularWindowSizedToContentResizesToContent   
)

Definition at line 975 of file window_manager_unittests.cc.

976  {
977  IsolateScope isolate_scope(isolate());
978 
979  RegularWindowCreationRequest creation_request{
980  .preferred_size = {.has_preferred_view_size = false},
981  .preferred_constraints = {.has_view_constraints = false},
982  .title = L"Sized To Content",
983  .sized_to_content = true,
984  .resizable = false};
985 
986  const int64_t view_id =
988  engine_id(), &creation_request);
989  const HWND window_handle =
991  view_id);
992 
993  FlutterWindowsView* view = engine()->GetViewFromTopLevelWindow(window_handle);
994  ASSERT_NE(view, nullptr);
995 
996  view->OnFrameGenerated(300, 200);
997  engine()->task_runner()->ProcessTasks();
998 
999  ActualWindowSize size =
1001  EXPECT_EQ(size.width, 300);
1002  EXPECT_EQ(size.height, 200);
1003 }

References flutter::WindowSizeRequest::has_preferred_view_size, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), flutter::FlutterWindowsView::OnFrameGenerated(), flutter::RegularWindowCreationRequest::preferred_size, and flutter::ActualWindowSize::width.

◆ TEST_F() [206/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
DISABLED_TooltipWindowUpdatesPositionOnViewSizeChange   
)

Definition at line 665 of file window_manager_unittests.cc.

666  {
667  IsolateScope isolate_scope(isolate());
668 
669  const int64_t parent_view_id =
671  engine_id(), regular_creation_request());
672  const HWND parent_window_handle =
674  engine_id(), parent_view_id);
675 
676  // Track the child size passed to the callback
677  static int callback_count = 0;
678  static int last_width = 0;
679  static int last_height = 0;
680 
681  auto position_callback =
682  [](const WindowSize& child_size, const WindowRect& parent_rect,
683  const WindowRect& display_rect, WindowRect& rect) {
684  callback_count++;
685  last_width = child_size.width;
686  last_height = child_size.height;
687 
688  rect.left = parent_rect.left + callback_count * 5;
689  rect.top = parent_rect.top + callback_count * 5;
690  rect.width = child_size.width;
691  rect.height = child_size.height;
692  };
693 
694  TooltipWindowCreationRequest creation_request{
695  .preferred_constraints = {.has_view_constraints = true,
696  .view_min_width = 100,
697  .view_min_height = 50,
698  .view_max_width = 300,
699  .view_max_height = 200},
700  .parent = parent_window_handle,
701  .get_position_callback = position_callback};
702 
703  // Reset callback tracking
704  callback_count = 0;
705  last_width = 0;
706  last_height = 0;
707 
708  const int64_t tooltip_view_id =
710  engine_id(), &creation_request);
711 
712  HWND tooltip_window_handle =
714  engine_id(), tooltip_view_id);
715 
716  // Get the view associated with the tooltip window
717  FlutterWindowsView* view =
718  engine()->GetViewFromTopLevelWindow(tooltip_window_handle);
719  ASSERT_NE(view, nullptr);
720 
721  // Get initial position
722  RECT initial_rect;
723  GetWindowRect(tooltip_window_handle, &initial_rect);
724  int initial_callback_count = callback_count;
725 
726  // Simulate a frame being generated with new dimensions
727  // This should trigger DidUpdateViewSize which calls UpdatePosition
728  view->OnFrameGenerated(150, 100);
729 
730  // Process any pending tasks to ensure the callback is executed
731  engine()->task_runner()->ProcessTasks();
732 
733  // Verify the callback was called again with the new dimensions
734  EXPECT_GT(callback_count, initial_callback_count);
735  EXPECT_EQ(last_width, 150);
736  EXPECT_EQ(last_height, 100);
737 
738  // Get new position and verify it changed
739  RECT new_rect;
740  GetWindowRect(tooltip_window_handle, &new_rect);
741 
742  // The position should have changed due to our callback logic
743  // (we offset by callback_count * 5)
744  EXPECT_NE(initial_rect.left, new_rect.left);
745  EXPECT_NE(initial_rect.top, new_rect.top);
746 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_CreateTooltipWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::FlutterWindowsView::OnFrameGenerated(), flutter::TooltipWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [207/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
GetWindowHandle   
)

Definition at line 178 of file window_manager_unittests.cc.

178  {
179  IsolateScope isolate_scope(isolate());
180 
181  const int64_t view_id =
183  engine_id(), regular_creation_request());
184  const HWND window_handle =
186  view_id);
187  EXPECT_NE(window_handle, nullptr);
188 }

References InternalFlutterWindows_WindowManager_CreateRegularWindow(), and InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle().

◆ TEST_F() [208/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
GetWindowSize   
)

Definition at line 190 of file window_manager_unittests.cc.

190  {
191  IsolateScope isolate_scope(isolate());
192 
193  const int64_t view_id =
195  engine_id(), regular_creation_request());
196  const HWND window_handle =
198  view_id);
199 
200  ActualWindowSize size =
202 
203  EXPECT_EQ(size.width,
204  regular_creation_request()->preferred_size.preferred_view_width);
205  EXPECT_EQ(size.height,
206  regular_creation_request()->preferred_size.preferred_view_height);
207 }

References flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), and flutter::ActualWindowSize::width.

◆ TEST_F() [209/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
OnEngineShutdownDispatchesWmDestroyForPopupWindow   
)

Definition at line 1211 of file window_manager_unittests.cc.

1211  {
1212  IsolateScope isolate_scope(isolate());
1213 
1214  static std::vector<UINT> received_messages;
1215  received_messages.clear();
1216  WindowingInitRequest init_request{.on_message = [](WindowsMessage* message) {
1217  received_messages.push_back(message->message);
1218  }};
1219  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1220 
1221  const int64_t parent_view_id =
1223  engine_id(), regular_creation_request());
1224  const HWND parent_window_handle =
1226  engine_id(), parent_view_id);
1227 
1228  auto position_callback =
1229  [](const WindowSize& child_size, const WindowRect& parent_rect,
1230  const WindowRect& display_rect, WindowRect& rect) {
1231  rect.left = parent_rect.left + 10;
1232  rect.top = parent_rect.top + 10;
1233  rect.width = child_size.width;
1234  rect.height = child_size.height;
1235  };
1236 
1237  PopupWindowCreationRequest creation_request{
1238  .preferred_constraints = {.has_view_constraints = true,
1239  .view_min_width = 100,
1240  .view_min_height = 50,
1241  .view_max_width = 300,
1242  .view_max_height = 200},
1243  .parent = parent_window_handle,
1244  .get_position_callback = position_callback};
1245 
1247  &creation_request);
1248 
1249  received_messages.clear();
1250  engine()->window_manager()->OnEngineShutdown();
1251 
1252  EXPECT_NE(std::find(received_messages.begin(), received_messages.end(),
1253  static_cast<UINT>(WM_DESTROY)),
1254  received_messages.end());
1255 }
void InternalFlutterWindows_WindowManager_Initialize(int64_t engine_id, const flutter::WindowingInitRequest *request)

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreatePopupWindow(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, flutter::WindowingInitRequest::on_message, flutter::PopupWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [210/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
OnEngineShutdownDispatchesWmDestroyForSatellite   
)

Definition at line 1791 of file window_manager_unittests.cc.

1791  {
1792  IsolateScope isolate_scope(isolate());
1793 
1794  static std::vector<UINT> received_messages;
1795  received_messages.clear();
1796  WindowingInitRequest init_request{.on_message = [](WindowsMessage* message) {
1797  received_messages.push_back(message->message);
1798  }};
1799  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1800 
1801  const HWND parent_window_handle = CreateParentWindow();
1802  SatelliteWindowCreationRequest creation_request =
1803  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1805  &creation_request);
1806 
1807  received_messages.clear();
1808  engine()->window_manager()->OnEngineShutdown();
1809 
1810  EXPECT_NE(std::find(received_messages.begin(), received_messages.end(),
1811  static_cast<UINT>(WM_DESTROY)),
1812  received_messages.end());
1813 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_Initialize(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [211/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
OnEngineShutdownDispatchesWmDestroyForTooltipWindow   
)

Definition at line 1258 of file window_manager_unittests.cc.

1258  {
1259  IsolateScope isolate_scope(isolate());
1260 
1261  static std::vector<UINT> received_messages;
1262  received_messages.clear();
1263  WindowingInitRequest init_request{.on_message = [](WindowsMessage* message) {
1264  received_messages.push_back(message->message);
1265  }};
1266  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1267 
1268  const int64_t parent_view_id =
1270  engine_id(), regular_creation_request());
1271  const HWND parent_window_handle =
1273  engine_id(), parent_view_id);
1274 
1275  auto position_callback =
1276  [](const WindowSize& child_size, const WindowRect& parent_rect,
1277  const WindowRect& display_rect, WindowRect& rect) {
1278  rect.left = parent_rect.left + 10;
1279  rect.top = parent_rect.top + 10;
1280  rect.width = child_size.width;
1281  rect.height = child_size.height;
1282  };
1283 
1284  TooltipWindowCreationRequest creation_request{
1285  .preferred_constraints = {.has_view_constraints = true,
1286  .view_min_width = 100,
1287  .view_min_height = 50,
1288  .view_max_width = 300,
1289  .view_max_height = 200},
1290  .parent = parent_window_handle,
1291  .get_position_callback = position_callback};
1292 
1294  &creation_request);
1295 
1296  received_messages.clear();
1297  engine()->window_manager()->OnEngineShutdown();
1298 
1299  EXPECT_NE(std::find(received_messages.begin(), received_messages.end(),
1300  static_cast<UINT>(WM_DESTROY)),
1301  received_messages.end());
1302 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_CreateTooltipWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, flutter::WindowingInitRequest::on_message, flutter::TooltipWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [212/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
OnPreEngineRestartDestroysWindowsWithoutDispatchingMessages   
)

Definition at line 1176 of file window_manager_unittests.cc.

1177  {
1178  IsolateScope isolate_scope(isolate());
1179 
1180  static bool received_message = false;
1181  WindowingInitRequest init_request{
1182  .on_message = [](WindowsMessage* message) { received_message = true; }};
1183  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1184 
1185  const int64_t first_view_id =
1187  engine_id(), regular_creation_request());
1188  const HWND first_window_handle =
1190  engine_id(), first_view_id);
1191  const int64_t second_view_id =
1193  engine_id(), regular_creation_request());
1194  const HWND second_window_handle =
1196  engine_id(), second_view_id);
1197 
1198  received_message = false;
1199  EngineModifier{engine()}.Restart();
1200 
1201  EXPECT_FALSE(received_message);
1202  EXPECT_FALSE(IsWindow(first_window_handle));
1203  EXPECT_FALSE(IsWindow(second_window_handle));
1204 }

References InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [213/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
PopupWindowDoesNotStealFocus   
)

Definition at line 827 of file window_manager_unittests.cc.

827  {
828  IsolateScope isolate_scope(isolate());
829 
830  const int64_t parent_view_id =
832  engine_id(), regular_creation_request());
833  const HWND parent_window_handle =
835  engine_id(), parent_view_id);
836 
837  // Give focus to the parent window
838  SetFocus(parent_window_handle);
839  HWND focused_before = GetFocus();
840 
841  auto position_callback =
842  [](const WindowSize& child_size, const WindowRect& parent_rect,
843  const WindowRect& display_rect, WindowRect& rect) {
844  rect.left = parent_rect.left + 10;
845  rect.top = parent_rect.top + 10;
846  rect.width = child_size.width;
847  rect.height = child_size.height;
848  };
849 
850  PopupWindowCreationRequest creation_request{
851  .preferred_constraints = {.has_view_constraints = true,
852  .view_min_width = 100,
853  .view_min_height = 50,
854  .view_max_width = 300,
855  .view_max_height = 200},
856  .parent = parent_window_handle,
857  .get_position_callback = position_callback};
858 
859  const int64_t popup_view_id =
861  &creation_request);
862 
863  HWND popup_window_handle =
865  engine_id(), popup_view_id);
866 
867  // Verify focus remains with the parent window
868  HWND focused_after = GetFocus();
869  EXPECT_EQ(focused_before, focused_after);
870  EXPECT_NE(focused_after, popup_window_handle);
871 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreatePopupWindow(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::PopupWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [214/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
PopupWindowHasNoActivateStyle   
)

Definition at line 787 of file window_manager_unittests.cc.

787  {
788  IsolateScope isolate_scope(isolate());
789 
790  const int64_t parent_view_id =
792  engine_id(), regular_creation_request());
793  const HWND parent_window_handle =
795  engine_id(), parent_view_id);
796 
797  auto position_callback =
798  [](const WindowSize& child_size, const WindowRect& parent_rect,
799  const WindowRect& display_rect, WindowRect& rect) {
800  rect.left = parent_rect.left + 10;
801  rect.top = parent_rect.top + 10;
802  rect.width = child_size.width;
803  rect.height = child_size.height;
804  };
805 
806  PopupWindowCreationRequest creation_request{
807  .preferred_constraints = {.has_view_constraints = true,
808  .view_min_width = 100,
809  .view_min_height = 50,
810  .view_max_width = 300,
811  .view_max_height = 200},
812  .parent = parent_window_handle,
813  .get_position_callback = position_callback};
814 
815  const int64_t popup_view_id =
817  &creation_request);
818 
819  HWND popup_window_handle =
821  engine_id(), popup_view_id);
822 
823  DWORD ex_style = GetWindowLong(popup_window_handle, GWL_EXSTYLE);
824  EXPECT_TRUE(ex_style & WS_EX_NOACTIVATE);
825 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreatePopupWindow(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::PopupWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [215/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
RegularWindowSizedToContentNonResizableHasNoThickFrame   
)

Definition at line 1005 of file window_manager_unittests.cc.

1006  {
1007  IsolateScope isolate_scope(isolate());
1008 
1009  RegularWindowCreationRequest creation_request{
1010  .preferred_size = {.has_preferred_view_size = false},
1011  .preferred_constraints = {.has_view_constraints = false},
1012  .title = L"Sized To Content Non-Resizable",
1013  .sized_to_content = true,
1014  .resizable = false};
1015 
1016  const int64_t view_id =
1018  engine_id(), &creation_request);
1019  const HWND window_handle =
1021  view_id);
1022 
1023  const LONG style = GetWindowLong(window_handle, GWL_STYLE);
1024  EXPECT_EQ(style & WS_THICKFRAME, 0L);
1025  EXPECT_EQ(style & WS_MAXIMIZEBOX, 0L);
1026 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and flutter::RegularWindowCreationRequest::preferred_size.

◆ TEST_F() [216/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
RegularWindowSizedToContentResizableHasThickFrame   
)

Definition at line 1028 of file window_manager_unittests.cc.

1028  {
1029  IsolateScope isolate_scope(isolate());
1030 
1031  RegularWindowCreationRequest creation_request{
1032  .preferred_size = {.has_preferred_view_size = false},
1033  .preferred_constraints = {.has_view_constraints = false},
1034  .title = L"Sized To Content Resizable",
1035  .sized_to_content = true,
1036  .resizable = true};
1037 
1038  const int64_t view_id =
1040  engine_id(), &creation_request);
1041  const HWND window_handle =
1043  view_id);
1044 
1045  const LONG style = GetWindowLong(window_handle, GWL_STYLE);
1046  EXPECT_NE(style & WS_THICKFRAME, 0L);
1047  EXPECT_NE(style & WS_MAXIMIZEBOX, 0L);
1048 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and flutter::RegularWindowCreationRequest::preferred_size.

◆ TEST_F() [217/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowCannotBeMinimized   
)

Definition at line 1561 of file window_manager_unittests.cc.

1561  {
1562  IsolateScope isolate_scope(isolate());
1563 
1564  const HWND parent_window_handle = CreateParentWindow();
1565  SatelliteWindowCreationRequest creation_request =
1566  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1567 
1568  const HWND satellite_window_handle =
1570  engine_id(),
1572  engine_id(), &creation_request));
1573 
1574  SendMessage(satellite_window_handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
1575 
1576  EXPECT_FALSE(IsIconic(satellite_window_handle));
1577 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), and InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle().

◆ TEST_F() [218/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowCannotBeReparentedToItself   
)

Definition at line 1705 of file window_manager_unittests.cc.

1705  {
1706  IsolateScope isolate_scope(isolate());
1707 
1708  WindowingInitRequest init_request{
1709  .on_message = [](WindowsMessage* message) {}};
1710  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1711 
1712  const HWND parent_window_handle = CreateParentWindow();
1713  SatelliteWindowCreationRequest creation_request =
1714  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1715  const HWND satellite_handle =
1717  engine_id(),
1719  engine_id(), &creation_request));
1720 
1721  // Anchoring a satellite to itself would make parent-movement propagation
1722  // recurse forever, so the request must be rejected.
1724  satellite_handle);
1725 
1726  RECT parent_rect;
1727  GetWindowRect(parent_window_handle, &parent_rect);
1728  RECT satellite_rect_before;
1729  GetWindowRect(satellite_handle, &satellite_rect_before);
1730 
1731  // The satellite still tracks its original parent.
1732  SetWindowPos(parent_window_handle, nullptr, parent_rect.left + 15,
1733  parent_rect.top + 25, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
1734 
1735  RECT satellite_rect_after;
1736  GetWindowRect(satellite_handle, &satellite_rect_after);
1737  EXPECT_EQ(satellite_rect_after.left, satellite_rect_before.left + 15);
1738  EXPECT_EQ(satellite_rect_after.top, satellite_rect_before.top + 25);
1739 }
FLUTTER_EXPORT void InternalFlutterWindows_WindowManager_SetSatelliteParent(HWND satellite_hwnd, HWND new_parent)

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), InternalFlutterWindows_WindowManager_SetSatelliteParent(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [219/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowCannotBeReparentedToItsOwnSatellite   
)

Definition at line 1741 of file window_manager_unittests.cc.

1741  {
1742  IsolateScope isolate_scope(isolate());
1743 
1744  WindowingInitRequest init_request{
1745  .on_message = [](WindowsMessage* message) {}};
1746  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1747 
1748  const HWND parent_window_handle = CreateParentWindow();
1749  SatelliteWindowCreationRequest outer_request =
1750  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1751  const HWND outer_handle =
1753  engine_id(),
1755  engine_id(), &outer_request));
1756 
1757  SatelliteWindowCreationRequest inner_request =
1758  SatelliteCreationRequest(outer_handle, OffsetPositionCallback);
1759  const HWND inner_handle =
1761  engine_id(),
1763  engine_id(), &inner_request));
1764 
1765  // |outer| already anchors |inner|, so anchoring |outer| to |inner| would
1766  // close a cycle and must be rejected.
1768  inner_handle);
1769 
1770  RECT parent_rect;
1771  GetWindowRect(parent_window_handle, &parent_rect);
1772  RECT outer_rect_before;
1773  GetWindowRect(outer_handle, &outer_rect_before);
1774  RECT inner_rect_before;
1775  GetWindowRect(inner_handle, &inner_rect_before);
1776 
1777  // Moving the root window still propagates down the chain exactly once.
1778  SetWindowPos(parent_window_handle, nullptr, parent_rect.left + 10,
1779  parent_rect.top + 20, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
1780 
1781  RECT outer_rect_after;
1782  GetWindowRect(outer_handle, &outer_rect_after);
1783  RECT inner_rect_after;
1784  GetWindowRect(inner_handle, &inner_rect_after);
1785  EXPECT_EQ(outer_rect_after.left, outer_rect_before.left + 10);
1786  EXPECT_EQ(outer_rect_after.top, outer_rect_before.top + 20);
1787  EXPECT_EQ(inner_rect_after.left, inner_rect_before.left + 10);
1788  EXPECT_EQ(inner_rect_after.top, inner_rect_before.top + 20);
1789 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), InternalFlutterWindows_WindowManager_SetSatelliteParent(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [220/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowCanReparent   
)

Definition at line 1579 of file window_manager_unittests.cc.

1579  {
1580  IsolateScope isolate_scope(isolate());
1581 
1582  WindowingInitRequest init_request{
1583  .on_message = [](WindowsMessage* message) {}};
1584  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1585 
1586  const HWND parent1_handle = CreateParentWindow();
1587  SetWindowPos(parent1_handle, nullptr, 100, 100, 0, 0,
1588  SWP_NOSIZE | SWP_NOZORDER);
1589  const HWND parent2_handle = CreateParentWindow();
1590  SetWindowPos(parent2_handle, nullptr, 500, 500, 0, 0,
1591  SWP_NOSIZE | SWP_NOZORDER);
1592 
1593  SatelliteWindowCreationRequest creation_request =
1594  SatelliteCreationRequest(parent1_handle, OffsetPositionCallback);
1595  const HWND satellite_handle =
1597  engine_id(),
1599  engine_id(), &creation_request));
1600 
1601  RECT satellite_rect_before;
1602  GetWindowRect(satellite_handle, &satellite_rect_before);
1603 
1604  // Reparenting must not move the satellite.
1606  parent2_handle);
1607 
1608  RECT satellite_rect_after;
1609  GetWindowRect(satellite_handle, &satellite_rect_after);
1610  EXPECT_EQ(satellite_rect_after.left, satellite_rect_before.left);
1611  EXPECT_EQ(satellite_rect_after.top, satellite_rect_before.top);
1612 
1613  // The satellite now follows the new parent...
1614  RECT parent2_rect;
1615  GetWindowRect(parent2_handle, &parent2_rect);
1616  SetWindowPos(parent2_handle, nullptr, parent2_rect.left + 30,
1617  parent2_rect.top + 40, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
1618 
1619  RECT satellite_rect_moved;
1620  GetWindowRect(satellite_handle, &satellite_rect_moved);
1621  EXPECT_EQ(satellite_rect_moved.left, satellite_rect_after.left + 30);
1622  EXPECT_EQ(satellite_rect_moved.top, satellite_rect_after.top + 40);
1623 
1624  // ...and no longer follows the old one.
1625  RECT parent1_rect;
1626  GetWindowRect(parent1_handle, &parent1_rect);
1627  SetWindowPos(parent1_handle, nullptr, parent1_rect.left + 70,
1628  parent1_rect.top + 80, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
1629 
1630  RECT satellite_rect_final;
1631  GetWindowRect(satellite_handle, &satellite_rect_final);
1632  EXPECT_EQ(satellite_rect_final.left, satellite_rect_moved.left);
1633  EXPECT_EQ(satellite_rect_final.top, satellite_rect_moved.top);
1634 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), InternalFlutterWindows_WindowManager_SetSatelliteParent(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [221/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowDoesNotMoveWhenParentOnlyResizes   
)

Definition at line 1442 of file window_manager_unittests.cc.

1442  {
1443  IsolateScope isolate_scope(isolate());
1444 
1445  WindowingInitRequest init_request{
1446  .on_message = [](WindowsMessage* message) {}};
1447  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1448 
1449  const HWND parent_window_handle = CreateParentWindow();
1450  SetWindowPos(parent_window_handle, nullptr, 200, 100, 0, 0,
1451  SWP_NOSIZE | SWP_NOZORDER);
1452 
1453  SatelliteWindowCreationRequest creation_request =
1454  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1455  const HWND satellite_window_handle =
1457  engine_id(),
1459  engine_id(), &creation_request));
1460 
1461  RECT satellite_rect_before;
1462  GetWindowRect(satellite_window_handle, &satellite_rect_before);
1463 
1464  SetWindowPos(parent_window_handle, nullptr, 0, 0, 640, 480,
1465  SWP_NOMOVE | SWP_NOZORDER);
1466 
1467  RECT satellite_rect_after;
1468  GetWindowRect(satellite_window_handle, &satellite_rect_after);
1469 
1470  EXPECT_EQ(satellite_rect_after.left, satellite_rect_before.left);
1471  EXPECT_EQ(satellite_rect_after.top, satellite_rect_before.top);
1472 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [222/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowFollowsParentClientArea   
)

Definition at line 1514 of file window_manager_unittests.cc.

1514  {
1515  IsolateScope isolate_scope(isolate());
1516 
1517  WindowingInitRequest init_request{
1518  .on_message = [](WindowsMessage* message) {}};
1519  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1520 
1521  const HWND parent_window_handle = CreateParentWindow();
1522  SetWindowPos(parent_window_handle, nullptr, 200, 100, 0, 0,
1523  SWP_NOSIZE | SWP_NOZORDER);
1524 
1525  SatelliteWindowCreationRequest creation_request =
1526  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1527  const HWND satellite_window_handle =
1529  engine_id(),
1531  engine_id(), &creation_request));
1532 
1533  POINT parent_client_origin_before = {0, 0};
1534  ClientToScreen(parent_window_handle, &parent_client_origin_before);
1535  RECT satellite_rect_before;
1536  GetWindowRect(satellite_window_handle, &satellite_rect_before);
1537 
1538  // Removing the parent's caption moves its client area without moving the
1539  // window, much like a DPI change that rescales the title bar.
1540  SetWindowLongPtr(
1541  parent_window_handle, GWL_STYLE,
1542  GetWindowLongPtr(parent_window_handle, GWL_STYLE) & ~WS_CAPTION);
1543  SetWindowPos(parent_window_handle, nullptr, 0, 0, 0, 0,
1544  SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE |
1545  SWP_FRAMECHANGED);
1546 
1547  POINT parent_client_origin_after = {0, 0};
1548  ClientToScreen(parent_window_handle, &parent_client_origin_after);
1549  ASSERT_NE(parent_client_origin_after.y, parent_client_origin_before.y);
1550 
1551  RECT satellite_rect_after;
1552  GetWindowRect(satellite_window_handle, &satellite_rect_after);
1553  EXPECT_EQ(satellite_rect_after.left,
1554  satellite_rect_before.left +
1555  (parent_client_origin_after.x - parent_client_origin_before.x));
1556  EXPECT_EQ(satellite_rect_after.top,
1557  satellite_rect_before.top +
1558  (parent_client_origin_after.y - parent_client_origin_before.y));
1559 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [223/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowFollowsParentMovement   
)

Definition at line 1407 of file window_manager_unittests.cc.

1407  {
1408  IsolateScope isolate_scope(isolate());
1409 
1410  WindowingInitRequest init_request{
1411  .on_message = [](WindowsMessage* message) {}};
1412  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1413 
1414  const HWND parent_window_handle = CreateParentWindow();
1415  SetWindowPos(parent_window_handle, nullptr, 200, 100, 0, 0,
1416  SWP_NOSIZE | SWP_NOZORDER);
1417 
1418  SatelliteWindowCreationRequest creation_request =
1419  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1420  const HWND satellite_window_handle =
1422  engine_id(),
1424  engine_id(), &creation_request));
1425 
1426  RECT satellite_rect_before;
1427  GetWindowRect(satellite_window_handle, &satellite_rect_before);
1428 
1429  // Move the parent by (+50, +100). SetWindowPos dispatches
1430  // WM_WINDOWPOSCHANGED synchronously, so the satellite moves before it
1431  // returns.
1432  SetWindowPos(parent_window_handle, nullptr, 250, 200, 0, 0,
1433  SWP_NOSIZE | SWP_NOZORDER);
1434 
1435  RECT satellite_rect_after;
1436  GetWindowRect(satellite_window_handle, &satellite_rect_after);
1437 
1438  EXPECT_EQ(satellite_rect_after.left, satellite_rect_before.left + 50);
1439  EXPECT_EQ(satellite_rect_after.top, satellite_rect_before.top + 100);
1440 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [224/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowHandlesNullPositionCallback   
)

Definition at line 1390 of file window_manager_unittests.cc.

1390  {
1391  IsolateScope isolate_scope(isolate());
1392 
1393  const HWND parent_window_handle = CreateParentWindow();
1394  SatelliteWindowCreationRequest creation_request =
1395  SatelliteCreationRequest(parent_window_handle, nullptr);
1396 
1397  const int64_t satellite_view_id =
1399  engine_id(), &creation_request);
1400 
1401  EXPECT_GE(satellite_view_id, 0);
1403  engine_id(), satellite_view_id),
1404  nullptr);
1405 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), and InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle().

◆ TEST_F() [225/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowIsHiddenUntilFirstFrame   
)

Definition at line 1363 of file window_manager_unittests.cc.

1363  {
1364  IsolateScope isolate_scope(isolate());
1365 
1366  const HWND parent_window_handle = CreateParentWindow();
1367  SatelliteWindowCreationRequest creation_request =
1368  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1369 
1370  const HWND satellite_window_handle =
1372  engine_id(),
1374  engine_id(), &creation_request));
1375  ASSERT_NE(satellite_window_handle, nullptr);
1376 
1377  // The satellite is placed by the positioner before it is shown, so that the
1378  // move is never visible to the user.
1379  EXPECT_FALSE(IsWindowVisible(satellite_window_handle));
1380 
1381  FlutterWindowsView* view =
1382  engine()->GetViewFromTopLevelWindow(satellite_window_handle);
1383  ASSERT_NE(view, nullptr);
1384  view->OnFramePresented();
1385  engine()->task_runner()->ProcessTasks();
1386 
1387  EXPECT_TRUE(IsWindowVisible(satellite_window_handle));
1388 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and flutter::FlutterWindowsView::OnFramePresented().

◆ TEST_F() [226/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowKeepsOffsetAfterBeingMoved   
)

Definition at line 1474 of file window_manager_unittests.cc.

1474  {
1475  IsolateScope isolate_scope(isolate());
1476 
1477  WindowingInitRequest init_request{
1478  .on_message = [](WindowsMessage* message) {}};
1479  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
1480 
1481  const HWND parent_window_handle = CreateParentWindow();
1482  SetWindowPos(parent_window_handle, nullptr, 200, 100, 0, 0,
1483  SWP_NOSIZE | SWP_NOZORDER);
1484 
1485  SatelliteWindowCreationRequest creation_request =
1486  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1487  const HWND satellite_window_handle =
1489  engine_id(),
1491  engine_id(), &creation_request));
1492 
1493  // Move the satellite itself, as the user would by dragging it.
1494  RECT satellite_rect;
1495  GetWindowRect(satellite_window_handle, &satellite_rect);
1496  SetWindowPos(satellite_window_handle, nullptr, satellite_rect.left + 40,
1497  satellite_rect.top + 60, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
1498 
1499  RECT satellite_rect_before;
1500  GetWindowRect(satellite_window_handle, &satellite_rect_before);
1501  ASSERT_EQ(satellite_rect_before.left, satellite_rect.left + 40);
1502  ASSERT_EQ(satellite_rect_before.top, satellite_rect.top + 60);
1503 
1504  // The satellite keeps its new offset from the parent.
1505  SetWindowPos(parent_window_handle, nullptr, 250, 200, 0, 0,
1506  SWP_NOSIZE | SWP_NOZORDER);
1507 
1508  RECT satellite_rect_after;
1509  GetWindowRect(satellite_window_handle, &satellite_rect_after);
1510  EXPECT_EQ(satellite_rect_after.left, satellite_rect_before.left + 50);
1511  EXPECT_EQ(satellite_rect_after.top, satellite_rect_before.top + 100);
1512 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [227/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowSizedToContentUsesPositionCallbackAfterFirstFrame   
)

Definition at line 1663 of file window_manager_unittests.cc.

1664  {
1665  IsolateScope isolate_scope(isolate());
1666 
1667  const HWND parent_window_handle = CreateParentWindow();
1668  SetWindowPos(parent_window_handle, nullptr, 200, 100, 0, 0,
1669  SWP_NOSIZE | SWP_NOZORDER);
1670 
1671  SatelliteWindowCreationRequest creation_request =
1672  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1673  creation_request.preferred_size = {.has_preferred_view_size = false};
1674  creation_request.sized_to_content = true;
1675 
1676  const HWND satellite_window_handle =
1678  engine_id(),
1680  engine_id(), &creation_request));
1681  ASSERT_NE(satellite_window_handle, nullptr);
1682 
1683  FlutterWindowsView* view =
1684  engine()->GetViewFromTopLevelWindow(satellite_window_handle);
1685  ASSERT_NE(view, nullptr);
1686 
1687  // A sized-to-content satellite does not know its size until the first frame,
1688  // so the positioner only runs once that frame has been generated.
1689  view->OnFrameGenerated(150, 100);
1690  engine()->task_runner()->ProcessTasks();
1691 
1692  RECT parent_client_rect;
1693  GetClientRect(parent_window_handle, &parent_client_rect);
1694  POINT parent_top_left = {parent_client_rect.left, parent_client_rect.top};
1695  ClientToScreen(parent_window_handle, &parent_top_left);
1696 
1697  // As on the creation path, the positioner's origin applies to the window
1698  // rectangle.
1699  RECT satellite_rect;
1700  GetWindowRect(satellite_window_handle, &satellite_rect);
1701  EXPECT_EQ(satellite_rect.left, parent_top_left.x + 20);
1702  EXPECT_EQ(satellite_rect.top, parent_top_left.y + 30);
1703 }

References flutter::WindowSizeRequest::has_preferred_view_size, InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::FlutterWindowsView::OnFrameGenerated(), flutter::SatelliteWindowCreationRequest::preferred_size, and flutter::SatelliteWindowCreationRequest::sized_to_content.

◆ TEST_F() [228/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SatelliteWindowUsesPositionCallbackAfterFirstFrame   
)

Definition at line 1322 of file window_manager_unittests.cc.

1322  {
1323  IsolateScope isolate_scope(isolate());
1324 
1325  const HWND parent_window_handle = CreateParentWindow();
1326  SetWindowPos(parent_window_handle, nullptr, 200, 100, 0, 0,
1327  SWP_NOSIZE | SWP_NOZORDER);
1328 
1329  SatelliteWindowCreationRequest creation_request =
1330  SatelliteCreationRequest(parent_window_handle, OffsetPositionCallback);
1331 
1332  const int64_t satellite_view_id =
1334  engine_id(), &creation_request);
1335  const HWND satellite_window_handle =
1337  engine_id(), satellite_view_id);
1338 
1339  FlutterWindowsView* view =
1340  engine()->GetViewFromTopLevelWindow(satellite_window_handle);
1341  ASSERT_NE(view, nullptr);
1342 
1343  // The positioner runs once the satellite has rendered its first frame, while
1344  // the window is still hidden.
1345  view->OnFramePresented();
1346  engine()->task_runner()->ProcessTasks();
1347 
1348  // |OffsetPositionCallback| places the satellite at the parent's client-area
1349  // origin, offset by (20, 30).
1350  RECT parent_client_rect;
1351  GetClientRect(parent_window_handle, &parent_client_rect);
1352  POINT parent_top_left = {parent_client_rect.left, parent_client_rect.top};
1353  ClientToScreen(parent_window_handle, &parent_top_left);
1354 
1355  // The positioner's origin applies to the window rectangle.
1356  RECT satellite_rect;
1357  GetWindowRect(satellite_window_handle, &satellite_rect);
1358 
1359  EXPECT_EQ(satellite_rect.left, parent_top_left.x + 20);
1360  EXPECT_EQ(satellite_rect.top, parent_top_left.y + 30);
1361 }

References InternalFlutterWindows_WindowManager_CreateSatelliteWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and flutter::FlutterWindowsView::OnFramePresented().

◆ TEST_F() [229/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
SetWindowSize   
)

Definition at line 209 of file window_manager_unittests.cc.

209  {
210  IsolateScope isolate_scope(isolate());
211 
212  const int64_t view_id =
214  engine_id(), regular_creation_request());
215  const HWND window_handle =
217  view_id);
218 
219  WindowSizeRequest requestedSize{
220 
221  .has_preferred_view_size = true,
222  .preferred_view_width = 640,
223  .preferred_view_height = 480,
224  };
226  &requestedSize);
227 
228  ActualWindowSize actual_size =
230  EXPECT_EQ(actual_size.width, 640);
231  EXPECT_EQ(actual_size.height, 480);
232 }

References flutter::WindowSizeRequest::has_preferred_view_size, flutter::ActualWindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_GetWindowContentSize(), InternalFlutterWindows_WindowManager_SetWindowSize(), and flutter::ActualWindowSize::width.

◆ TEST_F() [230/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
TooltipWindowDoesNotStealFocus   
)

Definition at line 572 of file window_manager_unittests.cc.

572  {
573  IsolateScope isolate_scope(isolate());
574 
575  const int64_t parent_view_id =
577  engine_id(), regular_creation_request());
578  const HWND parent_window_handle =
580  engine_id(), parent_view_id);
581 
582  // Give focus to the parent window
583  SetFocus(parent_window_handle);
584  HWND focused_before = GetFocus();
585 
586  auto position_callback =
587  [](const WindowSize& child_size, const WindowRect& parent_rect,
588  const WindowRect& display_rect, WindowRect& rect) {
589  rect.left = parent_rect.left + 10;
590  rect.top = parent_rect.top + 10;
591  rect.width = child_size.width;
592  rect.height = child_size.height;
593  };
594 
595  TooltipWindowCreationRequest creation_request{
596  .preferred_constraints = {.has_view_constraints = true,
597  .view_min_width = 100,
598  .view_min_height = 50,
599  .view_max_width = 300,
600  .view_max_height = 200},
601  .parent = parent_window_handle,
602  .get_position_callback = position_callback};
603 
604  const int64_t tooltip_view_id =
606  engine_id(), &creation_request);
607 
608  HWND tooltip_window_handle =
610  engine_id(), tooltip_view_id);
611 
612  // Verify focus remains with the parent window
613  HWND focused_after = GetFocus();
614  EXPECT_EQ(focused_before, focused_after);
615  EXPECT_NE(focused_after, tooltip_window_handle);
616 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_CreateTooltipWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::TooltipWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [231/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
TooltipWindowHasNoActivateStyle   
)

Definition at line 532 of file window_manager_unittests.cc.

532  {
533  IsolateScope isolate_scope(isolate());
534 
535  const int64_t parent_view_id =
537  engine_id(), regular_creation_request());
538  const HWND parent_window_handle =
540  engine_id(), parent_view_id);
541 
542  auto position_callback =
543  [](const WindowSize& child_size, const WindowRect& parent_rect,
544  const WindowRect& display_rect, WindowRect& rect) {
545  rect.left = parent_rect.left + 10;
546  rect.top = parent_rect.top + 10;
547  rect.width = child_size.width;
548  rect.height = child_size.height;
549  };
550 
551  TooltipWindowCreationRequest creation_request{
552  .preferred_constraints = {.has_view_constraints = true,
553  .view_min_width = 100,
554  .view_min_height = 50,
555  .view_max_width = 300,
556  .view_max_height = 200},
557  .parent = parent_window_handle,
558  .get_position_callback = position_callback};
559 
560  const int64_t tooltip_view_id =
562  engine_id(), &creation_request);
563 
564  HWND tooltip_window_handle =
566  engine_id(), tooltip_view_id);
567 
568  DWORD ex_style = GetWindowLong(tooltip_window_handle, GWL_EXSTYLE);
569  EXPECT_TRUE(ex_style & WS_EX_NOACTIVATE);
570 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_CreateTooltipWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::TooltipWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [232/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
TooltipWindowReturnsNoActivateOnMouseClick   
)

Definition at line 618 of file window_manager_unittests.cc.

618  {
619  IsolateScope isolate_scope(isolate());
620 
621  const int64_t parent_view_id =
623  engine_id(), regular_creation_request());
624  const HWND parent_window_handle =
626  engine_id(), parent_view_id);
627 
628  auto position_callback =
629  [](const WindowSize& child_size, const WindowRect& parent_rect,
630  const WindowRect& display_rect, WindowRect& rect) {
631  rect.left = parent_rect.left + 10;
632  rect.top = parent_rect.top + 10;
633  rect.width = child_size.width;
634  rect.height = child_size.height;
635  };
636 
637  TooltipWindowCreationRequest creation_request{
638  .preferred_constraints = {.has_view_constraints = true,
639  .view_min_width = 100,
640  .view_min_height = 50,
641  .view_max_width = 300,
642  .view_max_height = 200},
643  .parent = parent_window_handle,
644  .get_position_callback = position_callback};
645 
646  const int64_t tooltip_view_id =
648  engine_id(), &creation_request);
649 
650  HWND tooltip_window_handle =
652  engine_id(), tooltip_view_id);
653 
654  // Send WM_MOUSEACTIVATE message to the tooltip window
655  LRESULT result = SendMessage(tooltip_window_handle, WM_MOUSEACTIVATE,
656  reinterpret_cast<WPARAM>(parent_window_handle),
657  MAKELPARAM(HTCLIENT, WM_LBUTTONDOWN));
658 
659  // Verify the tooltip returns MA_NOACTIVATE
660  EXPECT_EQ(result, MA_NOACTIVATE);
661 }

References flutter::WindowConstraints::has_view_constraints, flutter::WindowSize::height, InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_CreateTooltipWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), flutter::TooltipWindowCreationRequest::preferred_constraints, and flutter::WindowSize::width.

◆ TEST_F() [233/271]

flutter::testing::TEST_F ( WindowManagerTest  ,
WindowingInitialize   
)

Definition at line 152 of file window_manager_unittests.cc.

152  {
153  IsolateScope isolate_scope(isolate());
154 
155  static bool received_message = false;
156  WindowingInitRequest init_request{
157  .on_message = [](WindowsMessage* message) { received_message = true; }};
158 
159  InternalFlutterWindows_WindowManager_Initialize(engine_id(), &init_request);
160  const int64_t view_id =
162  engine_id(), regular_creation_request());
164  engine_id(), view_id));
165 
166  EXPECT_TRUE(received_message);
167 }

References InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_Initialize(), message, and flutter::WindowingInitRequest::on_message.

◆ TEST_F() [234/271]

flutter::testing::TEST_F ( WindowsLifecycleManagerTest  ,
StateTransitions   
)

Definition at line 26 of file windows_lifecycle_manager_unittests.cc.

26  {
27  FlutterWindowsEngineBuilder builder{GetContext()};
28  std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
29 
30  WindowsLifecycleManager manager{engine.get()};
31  HWND win1 = reinterpret_cast<HWND>(1);
32  HWND win2 = reinterpret_cast<HWND>(2);
33 
34  // Hidden to inactive upon window shown.
35  manager.SetLifecycleState(AppLifecycleState::kHidden);
36  manager.OnWindowStateEvent(win1, WindowStateEvent::kShow);
37  WaitUntilUpdated(manager);
38  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
39 
40  // Showing a second window does not change state.
41  manager.OnWindowStateEvent(win2, WindowStateEvent::kShow);
42  WaitUntilUpdated(manager);
43  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
44 
45  // Inactive to resumed upon window focus.
46  manager.OnWindowStateEvent(win2, WindowStateEvent::kFocus);
47  WaitUntilUpdated(manager);
48  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
49 
50  // Showing a second window does not change state.
51  manager.OnWindowStateEvent(win1, WindowStateEvent::kFocus);
52  WaitUntilUpdated(manager);
53  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
54 
55  // Unfocusing one window does not change state while another is focused.
56  manager.OnWindowStateEvent(win1, WindowStateEvent::kUnfocus);
57  WaitUntilUpdated(manager);
58  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
59 
60  // Unfocusing final remaining focused window transitions to inactive.
61  manager.OnWindowStateEvent(win2, WindowStateEvent::kUnfocus);
62  WaitUntilUpdated(manager);
63  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
64 
65  // Hiding one of two visible windows does not change state.
66  manager.OnWindowStateEvent(win2, WindowStateEvent::kHide);
67  WaitUntilUpdated(manager);
68  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
69 
70  // Hiding only visible window transitions to hidden.
71  manager.OnWindowStateEvent(win1, WindowStateEvent::kHide);
72  WaitUntilUpdated(manager);
73  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
74 
75  // Transition directly from resumed to hidden when the window is hidden.
76  manager.OnWindowStateEvent(win1, WindowStateEvent::kShow);
77  manager.OnWindowStateEvent(win1, WindowStateEvent::kFocus);
78  manager.OnWindowStateEvent(win1, WindowStateEvent::kHide);
79  WaitUntilUpdated(manager);
80  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
81 }
static void WaitUntilUpdated(const WindowsLifecycleManager &manager)

References flutter::kFocus, flutter::kHidden, flutter::kHide, flutter::kInactive, flutter::kResumed, flutter::kShow, flutter::kUnfocus, flutter::WindowsLifecycleManager::SetLifecycleState(), and WaitUntilUpdated().

◆ TEST_F() [235/271]

flutter::testing::TEST_F ( WindowsTest  ,
AddRemoveView   
)

Definition at line 869 of file flutter_windows_unittests.cc.

869  {
870  std::mutex mutex;
871  std::string view_ids;
872 
873  auto& context = GetContext();
874  WindowsConfigBuilder builder(context);
875  builder.SetDartEntrypoint("onMetricsChangedSignalViewIds");
876 
877  bool ready = false;
878  context.AddFfiNativeFunction("Signal",
879  CREATE_FFI_LAMBDA([&]() { ready = true; }));
880 
881  context.AddFfiNativeFunction(
882  "SignalStringValue", CREATE_FFI_LAMBDA([&](Dart_Handle handle) {
883  ASSERT_FALSE(Dart_IsError(handle));
884 
885  std::scoped_lock lock{mutex};
886  view_ids = tonic::DartConverter<std::string>::FromDart(handle);
887  }));
888 
889  // Create the implicit view.
890  ViewControllerPtr first_controller{builder.Run()};
891  ASSERT_NE(first_controller, nullptr);
892 
893  while (!ready) {
894  PumpMessage();
895  }
896 
897  // Create a second view.
898  FlutterDesktopEngineRef engine =
899  FlutterDesktopViewControllerGetEngine(first_controller.get());
901  properties.width = 100;
902  properties.height = 100;
903  ViewControllerPtr second_controller{
904  FlutterDesktopEngineCreateViewController(engine, &properties)};
905  ASSERT_NE(second_controller, nullptr);
906 
907  // Pump messages for the Windows platform task runner until the view is added.
908  while (true) {
909  PumpMessage();
910  std::scoped_lock lock{mutex};
911  if (view_ids == "View IDs: [0, 1]") {
912  break;
913  }
914  }
915 
916  // Delete the second view and pump messages for the Windows platform task
917  // runner until the view is removed.
918  second_controller.reset();
919  while (true) {
920  PumpMessage();
921  std::scoped_lock lock{mutex};
922  if (view_ids == "View IDs: [0]") {
923  break;
924  }
925  }
926 }
FlutterDesktopViewControllerRef FlutterDesktopEngineCreateViewController(FlutterDesktopEngineRef engine, const FlutterDesktopViewControllerProperties *properties)
struct FlutterDesktopEngine * FlutterDesktopEngineRef

References FlutterDesktopEngineCreateViewController(), FlutterDesktopViewControllerGetEngine(), FlutterDesktopViewControllerProperties::height, and FlutterDesktopViewControllerProperties::width.

◆ TEST_F() [236/271]

flutter::testing::TEST_F ( WindowsTest  ,
EnableIAccessible   
)

Definition at line 953 of file flutter_windows_unittests.cc.

953  {
954  auto& context = GetContext();
955  WindowsConfigBuilder builder(context);
956  builder.SetAccessibilityMode(
958  builder.SetDartEntrypoint("sendSemanticsTree");
959 
960  // Setup: a signal for when we have send out all of our semantics updates
961  bool done = false;
962  auto native_entry = CREATE_FFI_LAMBDA([&]() { done = true; });
963  context.AddFfiNativeFunction("Signal", native_entry);
964 
965  // Setup: Create a view
966  ViewControllerPtr controller{builder.Run()};
967  ASSERT_NE(controller, nullptr);
968 
969  auto view = FlutterDesktopViewControllerGetView(controller.get());
970  ASSERT_NE(view, nullptr);
971 
972  // Setup: UpdateSemanticsEnabled will trigger the semantics updates
973  // to get sent.
974  auto windows_view = reinterpret_cast<FlutterWindowsView*>(view);
975  windows_view->OnUpdateSemanticsEnabled(true);
976 
977  while (!done) {
978  PumpMessage();
979  }
980 
981  HWND hwnd = FlutterDesktopViewGetHWND(view);
982  ASSERT_NE(hwnd, nullptr);
983 
984  LRESULT lres = SendMessage(hwnd, WM_GETOBJECT, 0, OBJID_CLIENT);
985  ASSERT_NE(lres, 0);
986 
987  // In IAccessible mode, the object returned from WM_GETOBJECT should support
988  // IAccessible but not IAccessibleEx.
989  IAccessible* accessible = nullptr;
990  HRESULT hr = ObjectFromLresult(lres, IID_IAccessible, 0, (void**)&accessible);
991  ASSERT_TRUE(SUCCEEDED(hr));
992  ASSERT_NE(accessible, nullptr);
993 
994  IAccessibleEx* accessible_ex = nullptr;
995  hr = ObjectFromLresult(lres, IID_IAccessibleEx, 0, (void**)&accessible_ex);
996  ASSERT_TRUE(FAILED(hr));
997  ASSERT_EQ(accessible_ex, nullptr);
998 }
HWND FlutterDesktopViewGetHWND(FlutterDesktopViewRef view)
FlutterDesktopViewRef FlutterDesktopViewControllerGetView(FlutterDesktopViewControllerRef ref)
@ IAccessibleMode

References FlutterDesktopViewControllerGetView(), FlutterDesktopViewGetHWND(), flutter::IAccessible, flutter::IAccessibleEx, IAccessibleMode, and flutter::FlutterWindowsView::OnUpdateSemanticsEnabled().

◆ TEST_F() [237/271]

flutter::testing::TEST_F ( WindowsTest  ,
EnableIAccessibleEx   
)

Definition at line 1000 of file flutter_windows_unittests.cc.

1000  {
1001  auto& context = GetContext();
1002  WindowsConfigBuilder builder(context);
1003  builder.SetAccessibilityMode(
1005  builder.SetDartEntrypoint("sendSemanticsTree");
1006 
1007  // Setup: a signal for when we have send out all of our semantics updates
1008  bool done = false;
1009  auto native_entry = CREATE_FFI_LAMBDA([&]() { done = true; });
1010  context.AddFfiNativeFunction("Signal", native_entry);
1011 
1012  // Setup: Create a view
1013  ViewControllerPtr controller{builder.Run()};
1014  ASSERT_NE(controller, nullptr);
1015 
1016  auto view = FlutterDesktopViewControllerGetView(controller.get());
1017  ASSERT_NE(view, nullptr);
1018 
1019  // Setup: UpdateSemanticsEnabled will trigger the semantics updates
1020  // to get sent.
1021  auto windows_view = reinterpret_cast<FlutterWindowsView*>(view);
1022  windows_view->OnUpdateSemanticsEnabled(true);
1023 
1024  while (!done) {
1025  PumpMessage();
1026  }
1027 
1028  HWND hwnd = FlutterDesktopViewGetHWND(view);
1029  ASSERT_NE(hwnd, nullptr);
1030 
1031  LRESULT lres = SendMessage(hwnd, WM_GETOBJECT, 0, OBJID_CLIENT);
1032  ASSERT_NE(lres, 0);
1033 
1034  // In IAccessibleEx mode, the object returned from WM_GETOBJECT should
1035  // support IAccessibleEx.
1036  IAccessibleEx* accessible_ex = nullptr;
1037  HRESULT hr =
1038  ObjectFromLresult(lres, IID_IAccessibleEx, 0, (void**)&accessible_ex);
1039  ASSERT_TRUE(SUCCEEDED(hr));
1040  ASSERT_NE(accessible_ex, nullptr);
1041  accessible_ex->Release();
1042 }
@ IAccessibleExMode

References FlutterDesktopViewControllerGetView(), FlutterDesktopViewGetHWND(), flutter::IAccessibleEx, IAccessibleExMode, and flutter::FlutterWindowsView::OnUpdateSemanticsEnabled().

◆ TEST_F() [238/271]

flutter::testing::TEST_F ( WindowsTest  ,
EngineCanTransitionToHeadless   
)

Definition at line 157 of file flutter_windows_unittests.cc.

157  {
158  auto& context = GetContext();
159  WindowsConfigBuilder builder(context);
160  EnginePtr engine{builder.RunHeadless()};
161  ASSERT_NE(engine, nullptr);
162 
163  // Create and then destroy a view controller that does not own its engine.
164  // This causes the engine to transition back to headless mode.
165  {
167  ViewControllerPtr controller{
168  FlutterDesktopEngineCreateViewController(engine.get(), &properties)};
169 
170  ASSERT_NE(controller, nullptr);
171  }
172 
173  // The engine is back in headless mode now.
174  ASSERT_NE(engine, nullptr);
175 
176  auto engine_ptr = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
177  ASSERT_TRUE(engine_ptr->running());
178 }

References FlutterDesktopEngineCreateViewController().

◆ TEST_F() [239/271]

flutter::testing::TEST_F ( WindowsTest  ,
EngineId   
)

Definition at line 928 of file flutter_windows_unittests.cc.

928  {
929  auto& context = GetContext();
930  WindowsConfigBuilder builder(context);
931  builder.SetDartEntrypoint("testEngineId");
932 
933  std::optional<int64_t> engineId;
934  context.AddFfiNativeFunction(
935  "NotifyEngineId", CREATE_FFI_LAMBDA([&](Dart_Handle argument) {
936  if (!Dart_IsNull(argument)) {
937  const auto handle = tonic::DartConverter<int64_t>::FromDart(argument);
938  engineId = handle;
939  }
940  }));
941  // Create the implicit view.
942  ViewControllerPtr first_controller{builder.Run()};
943  ASSERT_NE(first_controller, nullptr);
944 
945  while (!engineId.has_value()) {
946  PumpMessage();
947  }
948 
949  auto engine = FlutterDesktopViewControllerGetEngine(first_controller.get());
950  EXPECT_EQ(engine, FlutterDesktopEngineForId(*engineId));
951 }
FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineForId(int64_t engine_id)

References FlutterDesktopEngineForId(), and FlutterDesktopViewControllerGetEngine().

◆ TEST_F() [240/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetEngineGraphicsAdapter   
)

Definition at line 601 of file flutter_windows_unittests.cc.

601  {
602  auto& context = GetContext();
603  WindowsConfigBuilder builder(context);
604  ViewControllerPtr controller{builder.Run()};
605  ASSERT_NE(controller, nullptr);
606  auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
607 
608  // Can't use smart pointer because the result is not a real COM object.
609  IDXGIAdapter* dxgi_adapter;
610  ASSERT_TRUE(FlutterDesktopEngineGetGraphicsAdapter(engine, &dxgi_adapter));
611  ASSERT_NE(dxgi_adapter, nullptr);
612  DXGI_ADAPTER_DESC desc{};
613  ASSERT_TRUE(SUCCEEDED(dxgi_adapter->GetDesc(&desc)));
614 }
bool FlutterDesktopEngineGetGraphicsAdapter(FlutterDesktopEngineRef engine, IDXGIAdapter **adapter_out)

References FlutterDesktopEngineGetGraphicsAdapter(), and FlutterDesktopViewControllerGetEngine().

◆ TEST_F() [241/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetEngineGraphicsAdapterWithHighPerformancePreference   
)

Definition at line 684 of file flutter_windows_unittests.cc.

684  {
685  std::optional<LUID> luid = egl::Manager::GetHighPerformanceGpuLuid();
686  if (!luid) {
687  GTEST_SKIP() << "Not able to find high performance GPU, nothing to check.";
688  }
689 
690  auto& context = GetContext();
691  WindowsConfigBuilder builder(context);
692  builder.SetGpuPreference(
694  ViewControllerPtr controller{builder.Run()};
695  ASSERT_NE(controller, nullptr);
696  auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
697 
698  // Can't use smart pointer because the result is not a real COM object.
699  IDXGIAdapter* dxgi_adapter;
700  ASSERT_TRUE(FlutterDesktopEngineGetGraphicsAdapter(engine, &dxgi_adapter));
701  ASSERT_NE(dxgi_adapter, nullptr);
702  DXGI_ADAPTER_DESC desc{};
703  ASSERT_TRUE(SUCCEEDED(dxgi_adapter->GetDesc(&desc)));
704  ASSERT_EQ(desc.AdapterLuid.HighPart, luid->HighPart);
705  ASSERT_EQ(desc.AdapterLuid.LowPart, luid->LowPart);
706 }
@ HighPerformancePreference

References FlutterDesktopEngineGetGraphicsAdapter(), FlutterDesktopViewControllerGetEngine(), flutter::egl::Manager::GetHighPerformanceGpuLuid(), and HighPerformancePreference.

◆ TEST_F() [242/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetEngineGraphicsAdapterWithLowPowerPreference   
)

Definition at line 661 of file flutter_windows_unittests.cc.

661  {
662  std::optional<LUID> luid = egl::Manager::GetLowPowerGpuLuid();
663  if (!luid) {
664  GTEST_SKIP() << "Not able to find low power GPU, nothing to check.";
665  }
666 
667  auto& context = GetContext();
668  WindowsConfigBuilder builder(context);
669  builder.SetGpuPreference(FlutterDesktopGpuPreference::LowPowerPreference);
670  ViewControllerPtr controller{builder.Run()};
671  ASSERT_NE(controller, nullptr);
672  auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
673 
674  // Can't use smart pointer because the result is not a real COM object.
675  IDXGIAdapter* dxgi_adapter;
676  ASSERT_TRUE(FlutterDesktopEngineGetGraphicsAdapter(engine, &dxgi_adapter));
677  ASSERT_NE(dxgi_adapter, nullptr);
678  DXGI_ADAPTER_DESC desc{};
679  ASSERT_TRUE(SUCCEEDED(dxgi_adapter->GetDesc(&desc)));
680  ASSERT_EQ(desc.AdapterLuid.HighPart, luid->HighPart);
681  ASSERT_EQ(desc.AdapterLuid.LowPart, luid->LowPart);
682 }
@ LowPowerPreference

References FlutterDesktopEngineGetGraphicsAdapter(), FlutterDesktopViewControllerGetEngine(), flutter::egl::Manager::GetLowPowerGpuLuid(), and LowPowerPreference.

◆ TEST_F() [243/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetGraphicsAdapter   
)

Definition at line 587 of file flutter_windows_unittests.cc.

587  {
588  auto& context = GetContext();
589  WindowsConfigBuilder builder(context);
590  ViewControllerPtr controller{builder.Run()};
591  ASSERT_NE(controller, nullptr);
592  auto view = FlutterDesktopViewControllerGetView(controller.get());
593 
594  Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter;
595  dxgi_adapter = FlutterDesktopViewGetGraphicsAdapter(view);
596  ASSERT_NE(dxgi_adapter, nullptr);
597  DXGI_ADAPTER_DESC desc{};
598  ASSERT_TRUE(SUCCEEDED(dxgi_adapter->GetDesc(&desc)));
599 }
IDXGIAdapter * FlutterDesktopViewGetGraphicsAdapter(FlutterDesktopViewRef view)

References FlutterDesktopViewControllerGetView(), and FlutterDesktopViewGetGraphicsAdapter().

◆ TEST_F() [244/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetGraphicsAdapterWithHighPerformancePreference   
)

Definition at line 638 of file flutter_windows_unittests.cc.

638  {
639  std::optional<LUID> luid = egl::Manager::GetHighPerformanceGpuLuid();
640  if (!luid) {
641  GTEST_SKIP() << "Not able to find high performance GPU, nothing to check.";
642  }
643 
644  auto& context = GetContext();
645  WindowsConfigBuilder builder(context);
646  builder.SetGpuPreference(
648  ViewControllerPtr controller{builder.Run()};
649  ASSERT_NE(controller, nullptr);
650  auto view = FlutterDesktopViewControllerGetView(controller.get());
651 
652  Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter;
653  dxgi_adapter = FlutterDesktopViewGetGraphicsAdapter(view);
654  ASSERT_NE(dxgi_adapter, nullptr);
655  DXGI_ADAPTER_DESC desc{};
656  ASSERT_TRUE(SUCCEEDED(dxgi_adapter->GetDesc(&desc)));
657  ASSERT_EQ(desc.AdapterLuid.HighPart, luid->HighPart);
658  ASSERT_EQ(desc.AdapterLuid.LowPart, luid->LowPart);
659 }

References FlutterDesktopViewControllerGetView(), FlutterDesktopViewGetGraphicsAdapter(), flutter::egl::Manager::GetHighPerformanceGpuLuid(), and HighPerformancePreference.

◆ TEST_F() [245/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetGraphicsAdapterWithLowPowerPreference   
)

Definition at line 616 of file flutter_windows_unittests.cc.

616  {
617  std::optional<LUID> luid = egl::Manager::GetLowPowerGpuLuid();
618  if (!luid) {
619  GTEST_SKIP() << "Not able to find low power GPU, nothing to check.";
620  }
621 
622  auto& context = GetContext();
623  WindowsConfigBuilder builder(context);
624  builder.SetGpuPreference(FlutterDesktopGpuPreference::LowPowerPreference);
625  ViewControllerPtr controller{builder.Run()};
626  ASSERT_NE(controller, nullptr);
627  auto view = FlutterDesktopViewControllerGetView(controller.get());
628 
629  Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter;
630  dxgi_adapter = FlutterDesktopViewGetGraphicsAdapter(view);
631  ASSERT_NE(dxgi_adapter, nullptr);
632  DXGI_ADAPTER_DESC desc{};
633  ASSERT_TRUE(SUCCEEDED(dxgi_adapter->GetDesc(&desc)));
634  ASSERT_EQ(desc.AdapterLuid.HighPart, luid->HighPart);
635  ASSERT_EQ(desc.AdapterLuid.LowPart, luid->LowPart);
636 }

References FlutterDesktopViewControllerGetView(), FlutterDesktopViewGetGraphicsAdapter(), flutter::egl::Manager::GetLowPowerGpuLuid(), and LowPowerPreference.

◆ TEST_F() [246/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetKeyboardStateHeadless   
)

Definition at line 844 of file flutter_windows_unittests.cc.

844  {
845  auto& context = GetContext();
846  WindowsConfigBuilder builder(context);
847  builder.SetDartEntrypoint("sendGetKeyboardState");
848 
849  std::atomic<bool> done = false;
850  context.AddFfiNativeFunction(
851  "SignalStringValue", CREATE_FFI_LAMBDA([&](Dart_Handle handle) {
852  ASSERT_FALSE(Dart_IsError(handle));
853  auto value = tonic::DartConverter<std::string>::FromDart(handle);
854  EXPECT_EQ(value, "Success");
855  done = true;
856  }));
857 
858  ViewControllerPtr controller{builder.Run()};
859  ASSERT_NE(controller, nullptr);
860 
861  // Pump messages for the Windows platform task runner.
862  ::MSG msg;
863  while (!done) {
864  PumpMessage();
865  }
866 }

◆ TEST_F() [247/271]

flutter::testing::TEST_F ( WindowsTest  ,
GetViewId   
)

Definition at line 576 of file flutter_windows_unittests.cc.

576  {
577  auto& context = GetContext();
578  WindowsConfigBuilder builder(context);
579  ViewControllerPtr controller{builder.Run()};
580  ASSERT_NE(controller, nullptr);
581  FlutterDesktopViewId view_id =
582  FlutterDesktopViewControllerGetViewId(controller.get());
583 
584  ASSERT_EQ(view_id, static_cast<FlutterDesktopViewId>(kImplicitViewId));
585 }
FlutterDesktopViewId FlutterDesktopViewControllerGetViewId(FlutterDesktopViewControllerRef ref)
int64_t FlutterDesktopViewId

References FlutterDesktopViewControllerGetViewId(), and flutter::kImplicitViewId.

◆ TEST_F() [248/271]

flutter::testing::TEST_F ( WindowsTest  ,
IsNotPlatformThread   
)

Definition at line 418 of file flutter_windows_unittests.cc.

418  {
419  auto& context = GetContext();
420  WindowsConfigBuilder builder(context);
421 
422  EnginePtr engine{builder.RunHeadless()};
423  ASSERT_NE(engine, nullptr);
424 
425  bool result = true;
426  std::thread background(
427  [&]() { result = FlutterDesktopEngineIsPlatformThread(engine.get()); });
428  background.join();
429 
430  EXPECT_FALSE(result);
431 }
bool FlutterDesktopEngineIsPlatformThread(FlutterDesktopEngineRef engine)

References FlutterDesktopEngineIsPlatformThread().

◆ TEST_F() [249/271]

flutter::testing::TEST_F ( WindowsTest  ,
IsPlatformThread   
)

Definition at line 407 of file flutter_windows_unittests.cc.

407  {
408  auto& context = GetContext();
409  WindowsConfigBuilder builder(context);
410 
411  EnginePtr engine{builder.RunHeadless()};
412  ASSERT_NE(engine, nullptr);
413 
414  EXPECT_TRUE(FlutterDesktopEngineIsPlatformThread(engine.get()));
415 }

References FlutterDesktopEngineIsPlatformThread().

◆ TEST_F() [250/271]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchConflictingCustomEntrypoints   
)

Definition at line 206 of file flutter_windows_unittests.cc.

206  {
207  auto& context = GetContext();
208  WindowsConfigBuilder builder(context);
209  builder.SetDartEntrypoint("customEntrypoint");
210  EnginePtr engine{builder.InitializeEngine()};
211  ASSERT_NE(engine, nullptr);
212 
213  ASSERT_FALSE(FlutterDesktopEngineRun(engine.get(), "conflictingEntrypoint"));
214 }
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)

References FlutterDesktopEngineRun().

◆ TEST_F() [251/271]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchCustomEntrypoint   
)

Definition at line 106 of file flutter_windows_unittests.cc.

106  {
107  auto& context = GetContext();
108  WindowsConfigBuilder builder(context);
109  builder.SetDartEntrypoint("customEntrypoint");
110  ViewControllerPtr controller{builder.Run()};
111  ASSERT_NE(controller, nullptr);
112 }

◆ TEST_F() [252/271]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchCustomEntrypointInEngineRunInvocation   
)

Definition at line 119 of file flutter_windows_unittests.cc.

119  {
120  auto& context = GetContext();
121  WindowsConfigBuilder builder(context);
122  EnginePtr engine{builder.InitializeEngine()};
123  ASSERT_NE(engine, nullptr);
124 
125  ASSERT_TRUE(FlutterDesktopEngineRun(engine.get(), "customEntrypoint"));
126 }

References FlutterDesktopEngineRun().

◆ TEST_F() [253/271]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchHeadlessEngine   
)

Definition at line 129 of file flutter_windows_unittests.cc.

129  {
130  auto& context = GetContext();
131  WindowsConfigBuilder builder(context);
132  builder.SetDartEntrypoint("signalViewIds");
133  EnginePtr engine{builder.RunHeadless()};
134  ASSERT_NE(engine, nullptr);
135 
136  std::string view_ids;
137  bool signaled = false;
138  context.AddFfiNativeFunction(
139  "SignalStringValue", CREATE_FFI_LAMBDA([&](Dart_Handle handle) {
140  ASSERT_FALSE(Dart_IsError(handle));
141  view_ids = tonic::DartConverter<std::string>::FromDart(handle);
142  signaled = true;
143  }));
144 
145  ViewControllerPtr controller{builder.Run()};
146  ASSERT_NE(controller, nullptr);
147 
148  while (!signaled) {
149  PumpMessage();
150  }
151 
152  // Verify a headless app has the implicit view.
153  EXPECT_EQ(view_ids, "View IDs: [0]");
154 }

◆ TEST_F() [254/271]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchMain   
)

Definition at line 81 of file flutter_windows_unittests.cc.

81  {
82  auto& context = GetContext();
83  WindowsConfigBuilder builder(context);
84  ViewControllerPtr controller{builder.Run()};
85  ASSERT_NE(controller, nullptr);
86 }

◆ TEST_F() [255/271]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchMainHasNoOutput   
)

Definition at line 89 of file flutter_windows_unittests.cc.

89  {
90  // Replace stderr stream buffer with our own. (stdout may contain expected
91  // output printed by Dart, such as the Dart VM service startup message)
92  StreamCapture stderr_capture(&std::cerr);
93 
94  auto& context = GetContext();
95  WindowsConfigBuilder builder(context);
96  ViewControllerPtr controller{builder.Run()};
97  ASSERT_NE(controller, nullptr);
98 
99  stderr_capture.Stop();
100 
101  // Verify stderr has no output.
102  EXPECT_TRUE(stderr_capture.GetOutput().empty());
103 }

◆ TEST_F() [256/271]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchRefreshesAccessibility   
)

Definition at line 181 of file flutter_windows_unittests.cc.

181  {
182  auto& context = GetContext();
183  WindowsConfigBuilder builder(context);
184  EnginePtr engine{builder.InitializeEngine()};
185  EngineModifier modifier{
186  reinterpret_cast<FlutterWindowsEngine*>(engine.get())};
187 
188  auto called = false;
189  modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
190  UpdateAccessibilityFeatures, ([&called](auto engine, auto flags) {
191  called = true;
192  return kSuccess;
193  }));
194 
195  ViewControllerPtr controller{
196  FlutterDesktopViewControllerCreate(0, 0, engine.release())};
197 
198  ASSERT_TRUE(called);
199 }
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)

References FlutterDesktopViewControllerCreate(), and flutter::FlutterWindowsEngine::UpdateAccessibilityFeatures().

◆ TEST_F() [257/271]

flutter::testing::TEST_F ( WindowsTest  ,
Lifecycle   
)

Definition at line 786 of file flutter_windows_unittests.cc.

786  {
787  auto& context = GetContext();
788  WindowsConfigBuilder builder(context);
789  EnginePtr engine{builder.InitializeEngine()};
790  auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
791  EngineModifier modifier{windows_engine};
792 
793  auto lifecycle_manager =
794  std::make_unique<MockWindowsLifecycleManager>(windows_engine);
795  auto lifecycle_manager_ptr = lifecycle_manager.get();
796  modifier.SetLifecycleManager(std::move(lifecycle_manager));
797 
798  EXPECT_CALL(*lifecycle_manager_ptr,
799  SetLifecycleState(AppLifecycleState::kInactive))
800  .WillOnce([lifecycle_manager_ptr](AppLifecycleState state) {
801  lifecycle_manager_ptr->WindowsLifecycleManager::SetLifecycleState(
802  state);
803  });
804 
805  EXPECT_CALL(*lifecycle_manager_ptr,
806  SetLifecycleState(AppLifecycleState::kHidden))
807  .WillOnce([lifecycle_manager_ptr](AppLifecycleState state) {
808  lifecycle_manager_ptr->WindowsLifecycleManager::SetLifecycleState(
809  state);
810  });
811 
812  FlutterDesktopViewControllerProperties properties = {0, 0};
813 
814  // Create a controller. This launches the engine and sets the app lifecycle
815  // to the "resumed" state.
816  ViewControllerPtr controller{
817  FlutterDesktopEngineCreateViewController(engine.get(), &properties)};
818 
819  FlutterDesktopViewRef view =
820  FlutterDesktopViewControllerGetView(controller.get());
821  ASSERT_NE(view, nullptr);
822 
823  HWND hwnd = FlutterDesktopViewGetHWND(view);
824  ASSERT_NE(hwnd, nullptr);
825 
826  // Give the window a non-zero size to show it. This does not change the app
827  // lifecycle directly. However, destroying the view will now result in a
828  // "hidden" app lifecycle event.
829  ::MoveWindow(hwnd, /* X */ 0, /* Y */ 0, /* nWidth*/ 100, /* nHeight*/ 100,
830  /* bRepaint*/ false);
831 
832  while (lifecycle_manager_ptr->IsUpdateStateScheduled()) {
833  PumpMessage();
834  }
835 
836  // Resets the view, simulating the window being hidden.
837  controller.reset();
838 
839  while (lifecycle_manager_ptr->IsUpdateStateScheduled()) {
840  PumpMessage();
841  }
842 }
struct FlutterDesktopView * FlutterDesktopViewRef

References FlutterDesktopEngineCreateViewController(), FlutterDesktopViewControllerGetView(), FlutterDesktopViewGetHWND(), flutter::kHidden, and flutter::kInactive.

◆ TEST_F() [258/271]

flutter::testing::TEST_F ( WindowsTest  ,
NextFrameCallback   
)

Definition at line 318 of file flutter_windows_unittests.cc.

318  {
319  struct Captures {
320  fml::AutoResetWaitableEvent frame_scheduled_latch;
321  std::thread::id thread_id;
322  bool done = false;
323  };
324  Captures captures;
325 
326  auto platform_thread = std::make_unique<fml::Thread>("test_platform_thread");
327  platform_thread->GetTaskRunner()->PostTask([&]() {
328  captures.thread_id = std::this_thread::get_id();
329 
330  auto& context = GetContext();
331  WindowsConfigBuilder builder(context);
332  builder.SetDartEntrypoint("drawHelloWorld");
333 
334  auto native_entry =
335  CREATE_FFI_LAMBDA([&]() { captures.frame_scheduled_latch.Signal(); });
336  context.AddFfiNativeFunction("NotifyFirstFrameScheduled", native_entry);
337 
338  ViewControllerPtr controller{builder.Run()};
339  EXPECT_NE(controller, nullptr);
340 
341  auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
342 
344  engine,
345  [](void* user_data) {
346  auto captures = static_cast<Captures*>(user_data);
347 
348  EXPECT_TRUE(captures->frame_scheduled_latch.IsSignaledForTest());
349 
350  // Callback should execute on platform thread.
351  EXPECT_EQ(std::this_thread::get_id(), captures->thread_id);
352 
353  // Signal the test passed and end the Windows message loop.
354  captures->done = true;
355  },
356  &captures);
357 
358  // Pump messages for the Windows platform task runner.
359  while (!captures.done) {
360  PumpMessage();
361  }
362  });
363 
364  // Wait for the platform thread to exit.
365  platform_thread->Join();
366 }
void FlutterDesktopEngineSetNextFrameCallback(FlutterDesktopEngineRef engine, VoidCallback callback, void *user_data)

References FlutterDesktopEngineSetNextFrameCallback(), FlutterDesktopViewControllerGetEngine(), and user_data.

◆ TEST_F() [259/271]

flutter::testing::TEST_F ( WindowsTest  ,
PlatformExecutable   
)

Definition at line 261 of file flutter_windows_unittests.cc.

261  {
262  auto& context = GetContext();
263  WindowsConfigBuilder builder(context);
264  builder.SetDartEntrypoint("readPlatformExecutable");
265 
266  std::string executable_name;
267  bool signaled = false;
268  auto native_entry = CREATE_FFI_LAMBDA([&](Dart_Handle handle) {
269  ASSERT_FALSE(Dart_IsError(handle));
270  executable_name = tonic::DartConverter<std::string>::FromDart(handle);
271  signaled = true;
272  });
273  context.AddFfiNativeFunction("SignalStringValue", native_entry);
274 
275  ViewControllerPtr controller{builder.Run()};
276  ASSERT_NE(controller, nullptr);
277 
278  // Wait until signalStringValue has been called.
279  while (!signaled) {
280  PumpMessage();
281  }
282  EXPECT_EQ(executable_name, "flutter_windows_unittests.exe");
283 }

◆ TEST_F() [260/271]

flutter::testing::TEST_F ( WindowsTest  ,
PluginRegistrarGetImplicitView   
)

Definition at line 709 of file flutter_windows_unittests.cc.

709  {
710  auto& context = GetContext();
711  WindowsConfigBuilder builder(context);
712  ViewControllerPtr controller{builder.Run()};
713  ASSERT_NE(controller, nullptr);
714 
715  FlutterDesktopEngineRef engine =
716  FlutterDesktopViewControllerGetEngine(controller.get());
718  FlutterDesktopEngineGetPluginRegistrar(engine, "foo_bar");
719  FlutterDesktopViewRef implicit_view =
721 
722  ASSERT_NE(implicit_view, nullptr);
723 }
FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(FlutterDesktopEngineRef engine, const char *plugin_name)
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(FlutterDesktopPluginRegistrarRef registrar)

References FlutterDesktopEngineGetPluginRegistrar(), FlutterDesktopPluginRegistrarGetView(), and FlutterDesktopViewControllerGetEngine().

◆ TEST_F() [261/271]

flutter::testing::TEST_F ( WindowsTest  ,
PluginRegistrarGetView   
)

Definition at line 725 of file flutter_windows_unittests.cc.

725  {
726  auto& context = GetContext();
727  WindowsConfigBuilder builder(context);
728  ViewControllerPtr controller{builder.Run()};
729  ASSERT_NE(controller, nullptr);
730 
731  FlutterDesktopEngineRef engine =
732  FlutterDesktopViewControllerGetEngine(controller.get());
734  FlutterDesktopEngineGetPluginRegistrar(engine, "foo_bar");
735 
736  FlutterDesktopViewId view_id =
737  FlutterDesktopViewControllerGetViewId(controller.get());
738  FlutterDesktopViewRef view =
739  FlutterDesktopPluginRegistrarGetViewById(registrar, view_id);
740 
742  registrar, static_cast<FlutterDesktopViewId>(123));
743 
744  ASSERT_NE(view, nullptr);
745  ASSERT_EQ(view_123, nullptr);
746 }
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetViewById(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopViewId view_id)

References FlutterDesktopEngineGetPluginRegistrar(), FlutterDesktopPluginRegistrarGetViewById(), FlutterDesktopViewControllerGetEngine(), and FlutterDesktopViewControllerGetViewId().

◆ TEST_F() [262/271]

flutter::testing::TEST_F ( WindowsTest  ,
PluginRegistrarGetViewHeadless   
)

Definition at line 748 of file flutter_windows_unittests.cc.

748  {
749  auto& context = GetContext();
750  WindowsConfigBuilder builder(context);
751  EnginePtr engine{builder.RunHeadless()};
752  ASSERT_NE(engine, nullptr);
753 
755  FlutterDesktopEngineGetPluginRegistrar(engine.get(), "foo_bar");
756 
757  FlutterDesktopViewRef implicit_view =
760  registrar, static_cast<FlutterDesktopViewId>(123));
761 
762  ASSERT_EQ(implicit_view, nullptr);
763  ASSERT_EQ(view_123, nullptr);
764 }

References FlutterDesktopEngineGetPluginRegistrar(), FlutterDesktopPluginRegistrarGetView(), and FlutterDesktopPluginRegistrarGetViewById().

◆ TEST_F() [263/271]

flutter::testing::TEST_F ( WindowsTest  ,
PostPlatformThreadTaskCancelledOnEngineDestroy   
)

Definition at line 508 of file flutter_windows_unittests.cc.

508  {
509  auto& context = GetContext();
510  WindowsConfigBuilder builder(context);
511 
512  EnginePtr engine{builder.RunHeadless()};
513  ASSERT_NE(engine, nullptr);
514 
515  struct Captures {
516  bool callback_called = false;
517  bool cancel_called = false;
518  } captures;
519 
521  engine.get(),
522  [](void* user_data) {
523  static_cast<Captures*>(user_data)->callback_called = true;
524  },
525  [](void* user_data) {
526  static_cast<Captures*>(user_data)->cancel_called = true;
527  },
528  &captures);
529 
530  // Destroy the engine before the task has a chance to run. The cancel
531  // callback should be called and the task callback should not.
532  engine.reset();
533 
534  EXPECT_FALSE(captures.callback_called);
535  EXPECT_TRUE(captures.cancel_called);
536 }
void FlutterDesktopEnginePostPlatformThreadTask(FlutterDesktopEngineRef engine, VoidCallback callback, VoidCallback on_cancel, void *user_data)

References FlutterDesktopEnginePostPlatformThreadTask(), and user_data.

◆ TEST_F() [264/271]

flutter::testing::TEST_F ( WindowsTest  ,
PostPlatformThreadTaskFromBackgroundThread   
)

Definition at line 465 of file flutter_windows_unittests.cc.

465  {
466  auto& context = GetContext();
467  WindowsConfigBuilder builder(context);
468 
469  EnginePtr engine{builder.RunHeadless()};
470  ASSERT_NE(engine, nullptr);
471 
472  std::mutex background_thread_id_mutex;
473  struct Captures {
474  std::thread::id background_thread_id;
475  std::thread::id platform_thread_id;
476  bool done = false;
477  } captures;
478 
479  std::thread background([&]() {
480  {
481  std::scoped_lock lock{background_thread_id_mutex};
482  captures.background_thread_id = std::this_thread::get_id();
483  }
484 
486  engine.get(),
487  [](void* user_data) {
488  auto captures = static_cast<Captures*>(user_data);
489  captures->platform_thread_id = std::this_thread::get_id();
490  captures->done = true;
491  },
492  /*on_cancel=*/nullptr, &captures);
493  });
494  background.join();
495 
496  while (!captures.done) {
497  PumpMessage();
498  }
499 
500  std::scoped_lock lock{background_thread_id_mutex};
501  EXPECT_NE(captures.background_thread_id, std::thread::id{});
502  EXPECT_NE(captures.background_thread_id, captures.platform_thread_id);
503  EXPECT_EQ(captures.platform_thread_id, std::this_thread::get_id());
504 }

References FlutterDesktopEnginePostPlatformThreadTask(), and user_data.

◆ TEST_F() [265/271]

flutter::testing::TEST_F ( WindowsTest  ,
PostPlatformThreadTaskFromPlatformThread   
)

Definition at line 435 of file flutter_windows_unittests.cc.

435  {
436  auto& context = GetContext();
437  WindowsConfigBuilder builder(context);
438 
439  EnginePtr engine{builder.RunHeadless()};
440  ASSERT_NE(engine, nullptr);
441 
442  struct Captures {
443  std::thread::id thread_id;
444  bool done = false;
445  } captures;
446 
448  engine.get(),
449  [](void* user_data) {
450  auto captures = static_cast<Captures*>(user_data);
451  captures->thread_id = std::this_thread::get_id();
452  captures->done = true;
453  },
454  /*on_cancel=*/nullptr, &captures);
455 
456  while (!captures.done) {
457  PumpMessage();
458  }
459 
460  EXPECT_EQ(captures.thread_id, std::this_thread::get_id());
461 }

References FlutterDesktopEnginePostPlatformThreadTask(), and user_data.

◆ TEST_F() [266/271]

flutter::testing::TEST_F ( WindowsTest  ,
PostPlatformThreadTaskNotCancelledWhenRun   
)

Definition at line 539 of file flutter_windows_unittests.cc.

539  {
540  auto& context = GetContext();
541  WindowsConfigBuilder builder(context);
542 
543  EnginePtr engine{builder.RunHeadless()};
544  ASSERT_NE(engine, nullptr);
545 
546  struct Captures {
547  bool callback_called = false;
548  bool cancel_called = false;
549  } captures;
550 
552  engine.get(),
553  [](void* user_data) {
554  static_cast<Captures*>(user_data)->callback_called = true;
555  },
556  [](void* user_data) {
557  static_cast<Captures*>(user_data)->cancel_called = true;
558  },
559  &captures);
560 
561  EXPECT_FALSE(captures.cancel_called);
562 
563  while (!captures.callback_called) {
564  PumpMessage();
565  }
566 
567  // Ensures that the cancel callback is not called,
568  // in case the engine was shut down after running the task.
569  engine.reset();
570 
571  EXPECT_TRUE(captures.callback_called);
572  EXPECT_FALSE(captures.cancel_called);
573 }

References FlutterDesktopEnginePostPlatformThreadTask(), and user_data.

◆ TEST_F() [267/271]

flutter::testing::TEST_F ( WindowsTest  ,
PresentHeadless   
)

Definition at line 370 of file flutter_windows_unittests.cc.

370  {
371  auto& context = GetContext();
372  WindowsConfigBuilder builder(context);
373  builder.SetDartEntrypoint("renderImplicitView");
374 
375  EnginePtr engine{builder.RunHeadless()};
376  ASSERT_NE(engine, nullptr);
377 
378  bool done = false;
380  engine.get(),
381  [](void* user_data) {
382  // This executes on the platform thread.
383  auto done = reinterpret_cast<std::atomic<bool>*>(user_data);
384  *done = true;
385  },
386  &done);
387 
388  // This app is in headless mode, however, the engine assumes the implicit
389  // view always exists. Send window metrics for the implicit view, causing
390  // the engine to present to the implicit view. The embedder must not crash.
391  auto engine_ptr = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
392  FlutterWindowMetricsEvent metrics = {};
393  metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
394  metrics.width = 100;
395  metrics.height = 100;
396  metrics.pixel_ratio = 1.0;
397  metrics.view_id = kImplicitViewId;
398  engine_ptr->SendWindowMetricsEvent(metrics);
399 
400  // Pump messages for the Windows platform task runner.
401  while (!done) {
402  PumpMessage();
403  }
404 }

References FlutterDesktopEngineSetNextFrameCallback(), flutter::kImplicitViewId, and user_data.

◆ TEST_F() [268/271]

flutter::testing::TEST_F ( WindowsTest  ,
SurfaceOptional   
)

Definition at line 768 of file flutter_windows_unittests.cc.

768  {
769  auto& context = GetContext();
770  WindowsConfigBuilder builder(context);
771  EnginePtr engine{builder.InitializeEngine()};
772  EngineModifier modifier{
773  reinterpret_cast<FlutterWindowsEngine*>(engine.get())};
774 
775  auto egl_manager = std::make_unique<HalfBrokenEGLManager>();
776  ASSERT_TRUE(egl_manager->IsValid());
777  modifier.SetEGLManager(std::move(egl_manager));
778 
779  ViewControllerPtr controller{
780  FlutterDesktopViewControllerCreate(0, 0, engine.release())};
781 
782  ASSERT_NE(controller, nullptr);
783 }

References FlutterDesktopViewControllerCreate().

◆ TEST_F() [269/271]

flutter::testing::TEST_F ( WindowsTest  ,
VerifyNativeFunction   
)

Definition at line 217 of file flutter_windows_unittests.cc.

217  {
218  auto& context = GetContext();
219  WindowsConfigBuilder builder(context);
220  builder.SetDartEntrypoint("verifyNativeFunction");
221 
222  bool signaled = false;
223  auto native_entry = CREATE_FFI_LAMBDA([&]() { signaled = true; });
224  context.AddFfiNativeFunction("Signal", native_entry);
225 
226  ViewControllerPtr controller{builder.Run()};
227  ASSERT_NE(controller, nullptr);
228 
229  // Wait until signal has been called.
230  while (!signaled) {
231  PumpMessage();
232  }
233 }

◆ TEST_F() [270/271]

flutter::testing::TEST_F ( WindowsTest  ,
VerifyNativeFunctionWithParameters   
)

Definition at line 237 of file flutter_windows_unittests.cc.

237  {
238  auto& context = GetContext();
239  WindowsConfigBuilder builder(context);
240  builder.SetDartEntrypoint("verifyNativeFunctionWithParameters");
241 
242  bool bool_value = false;
243  bool signaled = false;
244  auto native_entry = CREATE_FFI_LAMBDA([&](bool value) {
245  bool_value = value;
246  signaled = true;
247  });
248  context.AddFfiNativeFunction("SignalBoolValue", native_entry);
249 
250  ViewControllerPtr controller{builder.Run()};
251  ASSERT_NE(controller, nullptr);
252 
253  // Wait until signalBoolValue has been called.
254  while (!signaled) {
255  PumpMessage();
256  }
257  EXPECT_TRUE(bool_value);
258 }

◆ TEST_F() [271/271]

flutter::testing::TEST_F ( WindowsTest  ,
VerifyNativeFunctionWithReturn   
)

Definition at line 287 of file flutter_windows_unittests.cc.

287  {
288  auto& context = GetContext();
289  WindowsConfigBuilder builder(context);
290  builder.SetDartEntrypoint("verifyNativeFunctionWithReturn");
291 
292  bool bool_value_to_return = true;
293  int count = 2;
294  auto bool_return_entry = CREATE_FFI_LAMBDA([&]() {
295  --count;
296  return bool_value_to_return;
297  });
298  context.AddFfiNativeFunction("SignalBoolReturn", bool_return_entry);
299 
300  bool bool_value_passed = false;
301  auto bool_pass_entry = CREATE_FFI_LAMBDA([&](bool value) {
302  bool_value_passed = value;
303  --count;
304  });
305  context.AddFfiNativeFunction("SignalBoolValue", bool_pass_entry);
306 
307  ViewControllerPtr controller{builder.Run()};
308  ASSERT_NE(controller, nullptr);
309 
310  // Wait until signalBoolReturn and signalBoolValue have been called.
311  while (count > 0) {
312  PumpMessage();
313  }
314  EXPECT_TRUE(bool_value_passed);
315 }

◆ TEST_P() [1/2]

flutter::testing::TEST_P ( CompositorOpenGLANGLETest  ,
CreateBackingStore   
)

Definition at line 137 of file compositor_opengl_angle_unittests.cc.

137  {
138  UseHeadlessEngine();
139 
140  auto compositor =
141  CompositorOpenGL{engine(), kEGLResolver, GetParam().enable_impeller};
142  FlutterBackingStoreConfig config = {};
143  config.size = {320, 240};
144  FlutterBackingStore backing_store = {};
145 
146  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
147  ExpectNoGLError();
148  ExpectFramebufferComplete(backing_store.open_gl.framebuffer.name);
149  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
150 }

◆ TEST_P() [2/2]

flutter::testing::TEST_P ( CompositorOpenGLANGLETest  ,
Present   
)

Definition at line 152 of file compositor_opengl_angle_unittests.cc.

152  {
153  UseEngineWithView();
154 
155  auto compositor =
156  CompositorOpenGL{engine(), kEGLResolver, GetParam().enable_impeller};
157  FlutterBackingStoreConfig config = {};
158  config.size = {320, 240};
159  FlutterBackingStore backing_store = {};
160 
161  ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
162  ExpectNoGLError();
163 
164  FlutterLayer layer = {};
165  layer.type = kFlutterLayerContentTypeBackingStore;
166  layer.backing_store = &backing_store;
167  layer.size = {320, 240};
168  const FlutterLayer* layer_ptr = &layer;
169 
170  EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
171  ExpectNoGLError();
172 
173  ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
174 }

◆ VietnameseTelexAddDiacriticWithSlowResponse()

void flutter::testing::VietnameseTelexAddDiacriticWithSlowResponse ( WindowsTestContext &  context,
bool  backspace_response 
)

Definition at line 2387 of file keyboard_unittests.cc.

2388  {
2389  // In this test, the user presses the following keys:
2390  //
2391  // Key Current text
2392  // ===========================
2393  // A a
2394  // F à
2395  //
2396  // And the Backspace down event is responded slowly with `backspace_response`.
2397 
2398  KeyboardTester tester{context};
2399  tester.Responding(false);
2400 
2401  // US Keyboard layout
2402 
2403  // Press A
2404  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2405  WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2406  kWmResultZero),
2407  WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2408  kWmResultZero)});
2409 
2410  EXPECT_EQ(tester.key_calls.size(), 2);
2411  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2412  kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2413  EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2414  tester.clear_key_calls();
2415  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2416 
2417  // Release A
2418  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2419  WmKeyUpInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended}.Build(
2420  kWmResultZero)});
2421 
2422  EXPECT_EQ(tester.key_calls.size(), 1);
2423  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
2424  kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2425  tester.clear_key_calls();
2426  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2427 
2428  std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2429  tester.LateResponding(
2430  [&recorded_callbacks](
2431  const FlutterKeyEvent* event,
2432  MockKeyResponseController::ResponseCallback callback) {
2433  recorded_callbacks.push_back(callback);
2434  });
2435 
2436  // Press F, which is translated to:
2437  //
2438  // Backspace down, char & up, VK_PACKET('à').
2439  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2440  WmKeyDownInfo{VK_BACK, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2441  kWmResultZero),
2442  WmCharInfo{0x8, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2443  kWmResultZero),
2444  WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
2445  kWmResultZero),
2446  WmKeyDownInfo{VK_PACKET, 0, kNotExtended, kWasUp}.Build(kWmResultDefault),
2447  WmCharInfo{0xe0 /*'à'*/, 0, kNotExtended, kWasUp}.Build(kWmResultZero),
2448  WmKeyUpInfo{VK_PACKET, 0, kNotExtended}.Build(kWmResultDefault)});
2449 
2450  // The Backspace event has not responded yet, therefore the char message must
2451  // hold. This is because when the framework is handling the Backspace event,
2452  // it will send a setEditingState message that updates the text state that has
2453  // the last character deleted (denoted by `string1`). Processing the char
2454  // message before then will cause the final text to set to `string1`.
2455  EXPECT_EQ(tester.key_calls.size(), 1);
2456  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown,
2457  kPhysicalBackspace, kLogicalBackspace, "",
2458  kNotSynthesized);
2459  tester.clear_key_calls();
2460  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2461 
2462  EXPECT_EQ(recorded_callbacks.size(), 1);
2463  recorded_callbacks[0](backspace_response);
2464 
2465  EXPECT_EQ(tester.key_calls.size(), 1);
2466  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeUp,
2467  kPhysicalBackspace, kLogicalBackspace, "",
2468  kNotSynthesized);
2469  tester.clear_key_calls();
2470  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(),
2471  backspace_response ? 0 : 2);
2472 
2473  recorded_callbacks[1](false);
2474  EXPECT_EQ(tester.key_calls.size(), 1);
2475  EXPECT_CALL_IS_TEXT(tester.key_calls[0], u"à");
2476  tester.clear_key_calls();
2477  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2478 
2479  tester.Responding(false);
2480 
2481  // Release F
2482  tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2483  WmKeyUpInfo{kVirtualKeyF, kScanCodeKeyF, kNotExtended,
2484  /* overwrite_prev_state_0 */ true}
2485  .Build(kWmResultZero)});
2486 
2487  EXPECT_EQ(tester.key_calls.size(), 1);
2488  EXPECT_CALL_IS_EVENT(tester.key_calls[0], kFlutterKeyEventTypeDown, 0, 0, "",
2489  kNotSynthesized);
2490  tester.clear_key_calls();
2491  EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2492 }

References callback, EXPECT_CALL_IS_EVENT, EXPECT_CALL_IS_TEXT, kScanCodeKeyA, and kVirtualKeyA.

Referenced by TEST_F().

◆ WaitUntilUpdated()

static void flutter::testing::WaitUntilUpdated ( const WindowsLifecycleManager &  manager)
static

Definition at line 16 of file windows_lifecycle_manager_unittests.cc.

16  {
17  while (manager.IsUpdateStateScheduled()) {
18  ::MSG msg;
19  if (::GetMessage(&msg, nullptr, 0, 0)) {
20  ::TranslateMessage(&msg);
21  ::DispatchMessage(&msg);
22  }
23  }
24 }

References flutter::WindowsLifecycleManager::IsUpdateStateScheduled().

Referenced by TEST_F().

Variable Documentation

◆ kEmptyFlags

FlutterSemanticsFlags flutter::testing::kEmptyFlags = FlutterSemanticsFlags{}

Definition at line 18 of file accessibility_bridge_unittests.cc.

Referenced by CreateSemanticsNode().

◆ kScanCodeKeyA

constexpr uint64_t flutter::testing::kScanCodeKeyA = 0x1e
constexpr

◆ kVirtualKeyA

constexpr uint64_t flutter::testing::kVirtualKeyA = 0x41
constexpr