Flutter Windows Embedder
flutter::testing Namespace Reference

Classes

class  CursorHandlerTest
 
class  FlutterWindowsEngineTest
 
class  MockFlutterWindowsView
 
class  MockIDirectManipulationContent
 
class  MockIDirectManipulationViewport
 
class  MockWindowsLifecycleManager
 
class  PlatformHandlerTest
 
class  TextInputPluginTest
 
class  WindowsLifecycleManagerTest
 

Functions

 TEST (AccessibilityBridgeWindows, GetParent)
 
 TEST (AccessibilityBridgeWindows, GetParentOnRootRetunsNullptr)
 
 TEST (AccessibilityBridgeWindows, DispatchAccessibilityAction)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventAlert)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventChildrenChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventFocusChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityEventIgnoredChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityImageAnnotationChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityLiveRegionChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityNameChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityHScrollPosChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityVScrollPosChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilitySelectedChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilitySelectedChildrenChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilitySubtreeCreated)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityValueChanged)
 
 TEST (AccessibilityBridgeWindows, OnAccessibilityStateChanged)
 
 TEST (AccessibilityBridgeWindows, OnDocumentSelectionChanged)
 
 TEST_F (CompositorOpenGLTest, CreateBackingStore)
 
 TEST_F (CompositorOpenGLTest, InitializationFailure)
 
 TEST_F (CompositorOpenGLTest, Present)
 
 TEST_F (CompositorOpenGLTest, PresentEmpty)
 
 TEST_F (CompositorOpenGLTest, NoSurfaceIgnored)
 
 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, ActivateSystemCursorRequiresView)
 
 TEST_F (CursorHandlerTest, CreateCustomCursor)
 
 TEST_F (CursorHandlerTest, SetCustomCursor)
 
 TEST_F (CursorHandlerTest, SetCustomCursorRequiresView)
 
 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 (DpiUtilsTest, NonZero)
 
 TEST (DpiUtilsTest, NullHwndUsesPrimaryMonitor)
 
 TEST (FlutterProjectBundle, BasicPropertiesAbsolutePaths)
 
 TEST (FlutterProjectBundle, BasicPropertiesRelativePaths)
 
 TEST (FlutterProjectBundle, SwitchesEmpty)
 
 TEST (FlutterProjectBundle, DartEntrypointArguments)
 
 TEST (FlutterProjectBundle, Switches)
 
 TEST_F (FlutterWindowTest, CreateDestroy)
 
 TEST_F (FlutterWindowTest, OnBitmapSurfaceUpdated)
 
 TEST_F (FlutterWindowTest, OnCursorRectUpdatedRegularDPI)
 
 TEST_F (FlutterWindowTest, OnCursorRectUpdatedHighDPI)
 
 TEST_F (FlutterWindowTest, OnPointerStarSendsDeviceType)
 
 TEST_F (FlutterWindowTest, 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 (FlutterWindowTest, UpdateCursor)
 
 TEST_F (FlutterWindowsEngineTest, RunHeadless)
 
 TEST_F (FlutterWindowsEngineTest, RunDoesExpectedInitialization)
 
 TEST_F (FlutterWindowsEngineTest, ConfiguresFrameVsync)
 
 TEST_F (FlutterWindowsEngineTest, RunWithoutANGLEUsesSoftware)
 
 TEST_F (FlutterWindowsEngineTest, RunWithoutANGLEOnImpellerFailsToStart)
 
 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, AppStartsInResumedState)
 
 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 (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, GetViewId)
 
 TEST_F (WindowsTest, GetGraphicsAdapter)
 
 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 (FlutterWindowsViewTest, SubMenuExpandedState)
 
 TEST (FlutterWindowsViewTest, Shutdown)
 
 TEST (FlutterWindowsViewTest, KeySequence)
 
 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 (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, 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, GetClipboardDataRequiresView)
 
 TEST_F (PlatformHandlerTest, GetClipboardDataReportsOpenFailure)
 
 TEST_F (PlatformHandlerTest, GetClipboardDataReportsGetDataFailure)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStrings)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsReturnsFalse)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsRejectsUnknownContentType)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsRequiresView)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsIgnoresPermissionErrors)
 
 TEST_F (PlatformHandlerTest, ClipboardHasStringsReportsErrors)
 
 TEST_F (PlatformHandlerTest, ClipboardSetData)
 
 TEST_F (PlatformHandlerTest, ClipboardSetDataTextMustBeString)
 
 TEST_F (PlatformHandlerTest, ClipboardSetDataUnknownType)
 
 TEST_F (PlatformHandlerTest, ClipboardSetDataRequiresView)
 
 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_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, TextEditingWorksWithDeltaModel)
 
 TEST_F (TextInputPluginTest, CompositionCursorPos)
 
 TEST_F (TextInputPluginTest, TransformCursorRect)
 
 TEST_F (TextInputPluginTest, SetMarkedTextRectRequiresView)
 
 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, OnImeCompositionResult)
 
 TEST (MockWindow, OnImeCompositionResultAndCompose)
 
 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)
 
 TEST_F (WindowsLifecycleManagerTest, StateTransitions)
 
FlutterSemanticsNode2 CreateSemanticsNode (int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)
 
 TEST (AccessibilityBridgeTest, BasicTest)
 
 TEST (AccessibilityBridgeTest, AccessibilityRootId)
 
 TEST (AccessibilityBridgeTest, AddOrder)
 
 TEST (AccessibilityBridgeTest, CanFireChildrenChangedCorrectly)
 
 TEST (AccessibilityBridgeTest, CanHandleSelectionChangeCorrectly)
 
 TEST (AccessibilityBridgeTest, DoesNotAssignEditableRootToSelectableText)
 
 TEST (AccessibilityBridgeTest, SwitchHasSwitchRole)
 
 TEST (AccessibilityBridgeTest, SliderHasSliderRole)
 
 TEST (AccessibilityBridgeTest, CanSetCheckboxChecked)
 
 TEST (AccessibilityBridgeTest, CanReparentNode)
 
 TEST (AccessibilityBridgeTest, CanReparentMultipleNodes)
 
 TEST (AccessibilityBridgeTest, CanReparentNodeWithChild)
 
 TEST (AccessibilityBridgeTest, AXTreeManagerTest)
 
 TEST (AccessibilityBridgeTest, LineBreakingObjectTest)
 
 TEST (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
 

Function Documentation

◆ CreateSemanticsNode()

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

Definition at line 18 of file accessibility_bridge_unittests.cc.

21  {
22  return {
23  .id = id,
24  .flags = static_cast<FlutterSemanticsFlag>(0),
25  .actions = static_cast<FlutterSemanticsAction>(0),
26  .text_selection_base = -1,
27  .text_selection_extent = -1,
28  .label = label,
29  .hint = "",
30  .value = "",
31  .increased_value = "",
32  .decreased_value = "",
33  .child_count = children ? children->size() : 0,
34  .children_in_traversal_order = children ? children->data() : nullptr,
35  .custom_accessibility_actions_count = 0,
36  .tooltip = "",
37  };
38 }

Referenced by TEST().

◆ TEST() [1/158]

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

Definition at line 72 of file accessibility_bridge_unittests.cc.

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

References CreateSemanticsNode().

◆ TEST() [2/158]

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

Definition at line 109 of file accessibility_bridge_unittests.cc.

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

References CreateSemanticsNode().

◆ TEST() [3/158]

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

Definition at line 546 of file accessibility_bridge_unittests.cc.

546  {
547  std::shared_ptr<TestAccessibilityBridge> bridge =
548  std::make_shared<TestAccessibilityBridge>();
549 
550  ui::AXTreeID tree_id = bridge->GetTreeID();
551  ui::AXTreeManager* manager =
552  ui::AXTreeManagerMap::GetInstance().GetManager(tree_id);
553  ASSERT_EQ(manager, static_cast<ui::AXTreeManager*>(bridge.get()));
554 }

◆ TEST() [4/158]

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

Definition at line 40 of file accessibility_bridge_unittests.cc.

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

References CreateSemanticsNode().

◆ TEST() [5/158]

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

Definition at line 160 of file accessibility_bridge_unittests.cc.

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

References CreateSemanticsNode().

◆ TEST() [6/158]

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

Definition at line 208 of file accessibility_bridge_unittests.cc.

208  {
209  std::shared_ptr<TestAccessibilityBridge> bridge =
210  std::make_shared<TestAccessibilityBridge>();
211  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
212  root.flags = static_cast<FlutterSemanticsFlag>(
213  FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField |
214  FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocused);
215  bridge->AddFlutterSemanticsNodeUpdate(root);
216  bridge->CommitUpdates();
217 
218  const ui::AXTreeData& tree = bridge->GetAXTreeData();
219  EXPECT_EQ(tree.sel_anchor_object_id, ui::AXNode::kInvalidAXID);
220  bridge->accessibility_events.clear();
221 
222  // Update the selection.
223  root.text_selection_base = 0;
224  root.text_selection_extent = 5;
225  bridge->AddFlutterSemanticsNodeUpdate(root);
226 
227  bridge->CommitUpdates();
228 
229  EXPECT_EQ(tree.sel_anchor_object_id, 0);
230  EXPECT_EQ(tree.sel_anchor_offset, 0);
231  EXPECT_EQ(tree.sel_focus_object_id, 0);
232  EXPECT_EQ(tree.sel_focus_offset, 5);
233  ASSERT_EQ(bridge->accessibility_events.size(), size_t{2});
234  EXPECT_EQ(bridge->accessibility_events[0],
235  ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED);
236  EXPECT_EQ(bridge->accessibility_events[1],
237  ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED);
238 }

References CreateSemanticsNode().

◆ TEST() [7/158]

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

Definition at line 372 of file accessibility_bridge_unittests.cc.

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

References CreateSemanticsNode().

◆ TEST() [8/158]

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

Definition at line 309 of file accessibility_bridge_unittests.cc.

309  {
310  std::shared_ptr<TestAccessibilityBridge> bridge =
311  std::make_shared<TestAccessibilityBridge>();
312 
313  std::vector<int32_t> root_children{1};
314  std::vector<int32_t> child1_children{2};
315  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &root_children);
316  FlutterSemanticsNode2 child1 =
317  CreateSemanticsNode(1, "child 1", &child1_children);
318  FlutterSemanticsNode2 child2 = CreateSemanticsNode(2, "child 2");
319 
320  bridge->AddFlutterSemanticsNodeUpdate(root);
321  bridge->AddFlutterSemanticsNodeUpdate(child1);
322  bridge->AddFlutterSemanticsNodeUpdate(child2);
323  bridge->CommitUpdates();
324  bridge->accessibility_events.clear();
325 
326  // Reparent child2 from child1 to the root.
327  child1.child_count = 0;
328  child1.children_in_traversal_order = nullptr;
329 
330  int32_t new_root_children[] = {1, 2};
331  root.child_count = 2;
332  root.children_in_traversal_order = new_root_children;
333 
334  bridge->AddFlutterSemanticsNodeUpdate(root);
335  bridge->AddFlutterSemanticsNodeUpdate(child1);
336  bridge->AddFlutterSemanticsNodeUpdate(child2);
337  bridge->CommitUpdates();
338 
339  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
340  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
341  auto child2_node = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
342 
343  EXPECT_EQ(root_node->GetChildCount(), 2);
344  EXPECT_EQ(root_node->GetData().child_ids[0], 1);
345  EXPECT_EQ(root_node->GetData().child_ids[1], 2);
346  EXPECT_EQ(root_node->GetName(), "root");
347 
348  EXPECT_EQ(child1_node->GetChildCount(), 0);
349  EXPECT_EQ(child1_node->GetName(), "child 1");
350 
351  EXPECT_EQ(child2_node->GetChildCount(), 0);
352  EXPECT_EQ(child2_node->GetName(), "child 2");
353 
354  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
355 
356  // Child2 is moved from child1 to root.
357  EXPECT_THAT(bridge->accessibility_events,
358  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
359  EXPECT_THAT(bridge->accessibility_events,
360  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
361 
362  // Child1 is no longer a parent. It loses its group role and disables its
363  // 'clip children' attribute.
364  EXPECT_THAT(
365  bridge->accessibility_events,
366  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
367  EXPECT_THAT(bridge->accessibility_events,
368  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
369 }

References CreateSemanticsNode().

◆ TEST() [9/158]

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

Definition at line 466 of file accessibility_bridge_unittests.cc.

466  {
467  std::shared_ptr<TestAccessibilityBridge> bridge =
468  std::make_shared<TestAccessibilityBridge>();
469 
470  int32_t root_id = 0;
471  int32_t intermediary1_id = 1;
472  int32_t intermediary2_id = 2;
473  int32_t leaf1_id = 3;
474 
475  std::vector<int32_t> root_children{intermediary1_id, intermediary2_id};
476  std::vector<int32_t> intermediary1_children{leaf1_id};
477  FlutterSemanticsNode2 root =
478  CreateSemanticsNode(root_id, "root", &root_children);
479  FlutterSemanticsNode2 intermediary1 = CreateSemanticsNode(
480  intermediary1_id, "intermediary 1", &intermediary1_children);
481  FlutterSemanticsNode2 intermediary2 =
482  CreateSemanticsNode(intermediary2_id, "intermediary 2");
483  FlutterSemanticsNode2 leaf1 = CreateSemanticsNode(leaf1_id, "leaf 1");
484 
485  bridge->AddFlutterSemanticsNodeUpdate(root);
486  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
487  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
488  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
489  bridge->CommitUpdates();
490  bridge->accessibility_events.clear();
491 
492  // Move intermediary1 from root to intermediary 2.
493  int32_t new_root_children[] = {intermediary2_id};
494  root.child_count = 1;
495  root.children_in_traversal_order = new_root_children;
496 
497  int32_t new_intermediary2_children[] = {intermediary1_id};
498  intermediary2.child_count = 1;
499  intermediary2.children_in_traversal_order = new_intermediary2_children;
500 
501  bridge->AddFlutterSemanticsNodeUpdate(root);
502  bridge->AddFlutterSemanticsNodeUpdate(intermediary1);
503  bridge->AddFlutterSemanticsNodeUpdate(intermediary2);
504  bridge->AddFlutterSemanticsNodeUpdate(leaf1);
505  bridge->CommitUpdates();
506 
507  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
508  auto intermediary1_node =
509  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary1_id).lock();
510  auto intermediary2_node =
511  bridge->GetFlutterPlatformNodeDelegateFromID(intermediary2_id).lock();
512  auto leaf1_node =
513  bridge->GetFlutterPlatformNodeDelegateFromID(leaf1_id).lock();
514 
515  EXPECT_EQ(root_node->GetChildCount(), 1);
516  EXPECT_EQ(root_node->GetData().child_ids[0], intermediary2_id);
517  EXPECT_EQ(root_node->GetName(), "root");
518 
519  EXPECT_EQ(intermediary2_node->GetChildCount(), 1);
520  EXPECT_EQ(intermediary2_node->GetData().child_ids[0], intermediary1_id);
521  EXPECT_EQ(intermediary2_node->GetName(), "intermediary 2");
522 
523  EXPECT_EQ(intermediary1_node->GetChildCount(), 1);
524  EXPECT_EQ(intermediary1_node->GetData().child_ids[0], leaf1_id);
525  EXPECT_EQ(intermediary1_node->GetName(), "intermediary 1");
526 
527  EXPECT_EQ(leaf1_node->GetChildCount(), 0);
528  EXPECT_EQ(leaf1_node->GetName(), "leaf 1");
529 
530  ASSERT_EQ(bridge->accessibility_events.size(), size_t{5});
531 
532  EXPECT_THAT(bridge->accessibility_events,
533  Contains(ui::AXEventGenerator::Event::CHILDREN_CHANGED).Times(2));
534  EXPECT_THAT(bridge->accessibility_events,
535  Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED).Times(1));
536 
537  // Intermediary 2 becomes a parent node. It updates to group role and enables
538  // its 'clip children' attribute.
539  EXPECT_THAT(
540  bridge->accessibility_events,
541  Contains(ui::AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED).Times(1));
542  EXPECT_THAT(bridge->accessibility_events,
543  Contains(ui::AXEventGenerator::Event::ROLE_CHANGED).Times(1));
544 }

References CreateSemanticsNode().

◆ TEST() [10/158]

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

Definition at line 292 of file accessibility_bridge_unittests.cc.

292  {
293  std::shared_ptr<TestAccessibilityBridge> bridge =
294  std::make_shared<TestAccessibilityBridge>();
295  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
296  root.flags = static_cast<FlutterSemanticsFlag>(
297  FlutterSemanticsFlag::kFlutterSemanticsFlagHasCheckedState |
298  FlutterSemanticsFlag::kFlutterSemanticsFlagIsChecked);
299  bridge->AddFlutterSemanticsNodeUpdate(root);
300  bridge->CommitUpdates();
301 
302  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
303  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
304  EXPECT_EQ(root_node->GetData().GetCheckedState(),
305  ax::mojom::CheckedState::kTrue);
306 }

References CreateSemanticsNode().

◆ TEST() [11/158]

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

Definition at line 240 of file accessibility_bridge_unittests.cc.

240  {
241  std::shared_ptr<TestAccessibilityBridge> bridge =
242  std::make_shared<TestAccessibilityBridge>();
243  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
244  root.flags = static_cast<FlutterSemanticsFlag>(
245  FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField |
246  FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly);
247  bridge->AddFlutterSemanticsNodeUpdate(root);
248  bridge->CommitUpdates();
249 
250  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
251 
252  EXPECT_FALSE(root_node->GetData().GetBoolAttribute(
253  ax::mojom::BoolAttribute::kEditableRoot));
254 }

References CreateSemanticsNode().

◆ TEST() [12/158]

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

Definition at line 556 of file accessibility_bridge_unittests.cc.

556  {
557  std::shared_ptr<TestAccessibilityBridge> bridge =
558  std::make_shared<TestAccessibilityBridge>();
559 
560  const int32_t root_id = 0;
561 
562  FlutterSemanticsNode2 root = CreateSemanticsNode(root_id, "root", {});
563 
564  bridge->AddFlutterSemanticsNodeUpdate(root);
565  bridge->CommitUpdates();
566 
567  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(root_id).lock();
568  auto root_data = root_node->GetData();
569  EXPECT_TRUE(root_data.HasBoolAttribute(
570  ax::mojom::BoolAttribute::kIsLineBreakingObject));
571  EXPECT_TRUE(root_data.GetBoolAttribute(
572  ax::mojom::BoolAttribute::kIsLineBreakingObject));
573 }

References CreateSemanticsNode().

◆ TEST() [13/158]

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

Definition at line 271 of file accessibility_bridge_unittests.cc.

271  {
272  std::shared_ptr<TestAccessibilityBridge> bridge =
273  std::make_shared<TestAccessibilityBridge>();
274  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
275  root.flags = static_cast<FlutterSemanticsFlag>(
276  FlutterSemanticsFlag::kFlutterSemanticsFlagIsSlider |
277  FlutterSemanticsFlag::kFlutterSemanticsFlagHasEnabledState |
278  FlutterSemanticsFlag::kFlutterSemanticsFlagIsEnabled |
279  FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocusable);
280  bridge->AddFlutterSemanticsNodeUpdate(root);
281  bridge->CommitUpdates();
282 
283  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
284  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSlider);
285 }

References CreateSemanticsNode().

◆ TEST() [14/158]

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

Definition at line 256 of file accessibility_bridge_unittests.cc.

256  {
257  std::shared_ptr<TestAccessibilityBridge> bridge =
258  std::make_shared<TestAccessibilityBridge>();
259  FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root");
260  root.flags = static_cast<FlutterSemanticsFlag>(
261  FlutterSemanticsFlag::kFlutterSemanticsFlagHasToggledState |
262  FlutterSemanticsFlag::kFlutterSemanticsFlagHasEnabledState |
263  FlutterSemanticsFlag::kFlutterSemanticsFlagIsEnabled);
264  bridge->AddFlutterSemanticsNodeUpdate(root);
265  bridge->CommitUpdates();
266 
267  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
268  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSwitch);
269 }

References CreateSemanticsNode().

◆ TEST() [15/158]

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

Definition at line 269 of file accessibility_bridge_windows_unittests.cc.

269  {
270  auto engine = GetTestEngine();
271  FlutterWindowsViewSpy view{
272  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
273  EngineModifier modifier{engine.get()};
274  modifier.SetImplicitView(&view);
275  view.OnUpdateSemanticsEnabled(true);
276 
277  auto bridge = view.accessibility_bridge().lock();
278  PopulateAXTree(bridge);
279 
280  FlutterSemanticsAction actual_action = kFlutterSemanticsActionTap;
281  modifier.embedder_api().DispatchSemanticsAction = MOCK_ENGINE_PROC(
282  DispatchSemanticsAction,
283  ([&actual_action](FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t id,
284  FlutterSemanticsAction action, const uint8_t* data,
285  size_t data_length) {
286  actual_action = action;
287  return kSuccess;
288  }));
289 
290  AccessibilityBridgeWindows delegate(&view);
291  delegate.DispatchAccessibilityAction(1, kFlutterSemanticsActionCopy, {});
292  EXPECT_EQ(actual_action, kFlutterSemanticsActionCopy);
293 }

References action, and flutter::AccessibilityBridgeWindows::DispatchAccessibilityAction().

◆ TEST() [16/158]

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

Definition at line 237 of file accessibility_bridge_windows_unittests.cc.

237  {
238  auto engine = GetTestEngine();
239  FlutterWindowsViewSpy view{
240  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
241  EngineModifier modifier{engine.get()};
242  modifier.SetImplicitView(&view);
243  view.OnUpdateSemanticsEnabled(true);
244 
245  auto bridge = view.accessibility_bridge().lock();
246  PopulateAXTree(bridge);
247 
248  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
249  auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
250  EXPECT_EQ(node0_delegate->GetNativeViewAccessible(),
251  node1_delegate->GetParent());
252 }

◆ TEST() [17/158]

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

Definition at line 254 of file accessibility_bridge_windows_unittests.cc.

254  {
255  auto engine = GetTestEngine();
256  FlutterWindowsViewSpy view{
257  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
258  EngineModifier modifier{engine.get()};
259  modifier.SetImplicitView(&view);
260  view.OnUpdateSemanticsEnabled(true);
261 
262  auto bridge = view.accessibility_bridge().lock();
263  PopulateAXTree(bridge);
264 
265  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
266  ASSERT_TRUE(node0_delegate->GetParent() == nullptr);
267 }

◆ TEST() [18/158]

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

Definition at line 295 of file accessibility_bridge_windows_unittests.cc.

295  {
296  ExpectWinEventFromAXEvent(0, ui::AXEventGenerator::Event::ALERT,
297  ax::mojom::Event::kAlert);
298 }

◆ TEST() [19/158]

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

Definition at line 300 of file accessibility_bridge_windows_unittests.cc.

300  {
301  ExpectWinEventFromAXEvent(0, ui::AXEventGenerator::Event::CHILDREN_CHANGED,
302  ax::mojom::Event::kChildrenChanged);
303 }

◆ TEST() [20/158]

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

Definition at line 305 of file accessibility_bridge_windows_unittests.cc.

305  {
306  auto engine = GetTestEngine();
307  FlutterWindowsViewSpy view{
308  engine.get(), std::make_unique<NiceMock<MockWindowBindingHandler>>()};
309  EngineModifier modifier{engine.get()};
310  modifier.SetImplicitView(&view);
311  view.OnUpdateSemanticsEnabled(true);
312 
313  auto bridge = GetAccessibilityBridgeSpy(view);
314  PopulateAXTree(bridge);
315 
316  bridge->ResetRecords();
317  bridge->OnAccessibilityEvent({AXNodeFromID(bridge, 1),
318  {ui::AXEventGenerator::Event::FOCUS_CHANGED,
319  ax::mojom::EventFrom::kNone,
320  {}}});
321  ASSERT_EQ(bridge->dispatched_events().size(), 1);
322  EXPECT_EQ(bridge->dispatched_events()[0].event_type,
323  ax::mojom::Event::kFocus);
324 
325  ASSERT_EQ(bridge->focused_nodes().size(), 1);
326  EXPECT_EQ(bridge->focused_nodes()[0], 1);
327 }

◆ TEST() [21/158]

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

Definition at line 329 of file accessibility_bridge_windows_unittests.cc.

329  {
330  // Static test nodes with no text, hint, or scrollability are ignored.
331  ExpectWinEventFromAXEvent(4, ui::AXEventGenerator::Event::IGNORED_CHANGED,
332  ax::mojom::Event::kHide);
333 }

◆ TEST() [22/158]

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

Definition at line 351 of file accessibility_bridge_windows_unittests.cc.

351  {
352  ExpectWinEventFromAXEvent(
353  1, ui::AXEventGenerator::Event::SCROLL_HORIZONTAL_POSITION_CHANGED,
354  ax::mojom::Event::kScrollPositionChanged);
355 }

◆ TEST() [23/158]

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

Definition at line 335 of file accessibility_bridge_windows_unittests.cc.

335  {
336  ExpectWinEventFromAXEvent(
337  1, ui::AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED,
338  ax::mojom::Event::kTextChanged);
339 }

◆ TEST() [24/158]

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

Definition at line 341 of file accessibility_bridge_windows_unittests.cc.

341  {
342  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::LIVE_REGION_CHANGED,
343  ax::mojom::Event::kLiveRegionChanged);
344 }

◆ TEST() [25/158]

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

Definition at line 346 of file accessibility_bridge_windows_unittests.cc.

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

◆ TEST() [26/158]

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

Definition at line 363 of file accessibility_bridge_windows_unittests.cc.

363  {
364  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::SELECTED_CHANGED,
365  ax::mojom::Event::kValueChanged);
366 }

◆ TEST() [27/158]

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

Definition at line 368 of file accessibility_bridge_windows_unittests.cc.

368  {
369  ExpectWinEventFromAXEvent(
370  2, ui::AXEventGenerator::Event::SELECTED_CHILDREN_CHANGED,
371  ax::mojom::Event::kSelectedChildrenChanged);
372 }

◆ TEST() [28/158]

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

Definition at line 384 of file accessibility_bridge_windows_unittests.cc.

384  {
385  ExpectWinEventFromAXEvent(
386  1, ui::AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
387  ax::mojom::Event::kStateChanged);
388 }

◆ TEST() [29/158]

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

Definition at line 374 of file accessibility_bridge_windows_unittests.cc.

374  {
375  ExpectWinEventFromAXEvent(0, ui::AXEventGenerator::Event::SUBTREE_CREATED,
376  ax::mojom::Event::kShow);
377 }

◆ TEST() [30/158]

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

Definition at line 379 of file accessibility_bridge_windows_unittests.cc.

379  {
380  ExpectWinEventFromAXEvent(1, ui::AXEventGenerator::Event::VALUE_CHANGED,
381  ax::mojom::Event::kValueChanged);
382 }

◆ TEST() [31/158]

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

Definition at line 357 of file accessibility_bridge_windows_unittests.cc.

357  {
358  ExpectWinEventFromAXEvent(
359  1, ui::AXEventGenerator::Event::SCROLL_VERTICAL_POSITION_CHANGED,
360  ax::mojom::Event::kScrollPositionChanged);
361 }

◆ TEST() [32/158]

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

Definition at line 390 of file accessibility_bridge_windows_unittests.cc.

390  {
391  ExpectWinEventFromAXEventOnFocusNode(
392  1, ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED,
393  ax::mojom::Event::kDocumentSelectionChanged, 2);
394 }

◆ TEST() [33/158]

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(::testing::Invoke([&content](REFIID in, void** out) {
157  *out = &content;
158  return S_OK;
159  }))
160  .RetiresOnSaturation();
161  EXPECT_CALL(content, GetContentTransform(_, 6))
162  .WillOnce(::testing::Invoke([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(::testing::Invoke(
175  [scale, pan_x, pan_y](float* transform, DWORD size) {
176  transform[0] = scale;
177  transform[4] = pan_x;
178  transform[5] = pan_y;
179  return S_OK;
180  }));
181  EXPECT_CALL(delegate,
182  OnPointerPanZoomUpdate(device_id, pan_x, pan_y, scale, 0));
183  handler->OnContentUpdated((IDirectManipulationViewport*)&viewport,
184  (IDirectManipulationContent*)&content);
185  EXPECT_CALL(delegate, OnPointerPanZoomEnd(device_id));
186  EXPECT_CALL(viewport, GetViewportRect(_))
187  .WillOnce(::testing::Invoke([DISPLAY_WIDTH, DISPLAY_HEIGHT](RECT* rect) {
188  rect->left = 0;
189  rect->top = 0;
190  rect->right = DISPLAY_WIDTH;
191  rect->bottom = DISPLAY_HEIGHT;
192  return S_OK;
193  }));
194  EXPECT_CALL(viewport, ZoomToRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, false))
195  .WillOnce(::testing::Return(S_OK));
196  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
197  DIRECTMANIPULATION_INERTIA,
198  DIRECTMANIPULATION_RUNNING);
199  handler->OnViewportStatusChanged((IDirectManipulationViewport*)&viewport,
200  DIRECTMANIPULATION_READY,
201  DIRECTMANIPULATION_INERTIA);
202 }

References content.

◆ TEST() [34/158]

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

Definition at line 394 of file direct_manipulation_unittests.cc.

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

References content.

◆ TEST() [35/158]

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

Definition at line 340 of file direct_manipulation_unittests.cc.

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

References content.

◆ TEST() [36/158]

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

Definition at line 287 of file direct_manipulation_unittests.cc.

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

References content.

◆ TEST() [37/158]

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

Definition at line 205 of file direct_manipulation_unittests.cc.

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

References content.

◆ TEST() [38/158]

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 };

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

◆ TEST() [39/158]

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

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

Definition at line 110 of file flutter_platform_node_delegate_unittests.cc.

110  {
111  std::shared_ptr<TestAccessibilityBridge> bridge =
112  std::make_shared<TestAccessibilityBridge>();
113  FlutterSemanticsNode2 root;
114  root.id = 0;
115  root.label = "root";
116  root.hint = "";
117  root.value = "";
118  root.increased_value = "";
119  root.decreased_value = "";
120  root.tooltip = "";
121  root.child_count = 1;
122  int32_t children[] = {1};
123  root.children_in_traversal_order = children;
124  root.custom_accessibility_actions_count = 0;
125  root.rect = {0, 0, 100, 100}; // LTRB
126  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
127  bridge->AddFlutterSemanticsNodeUpdate(root);
128 
129  FlutterSemanticsNode2 child1;
130  child1.id = 1;
131  child1.label = "child 1";
132  child1.hint = "";
133  child1.value = "";
134  child1.increased_value = "";
135  child1.decreased_value = "";
136  child1.tooltip = "";
137  child1.child_count = 0;
138  child1.custom_accessibility_actions_count = 0;
139  child1.rect = {0, 0, 50, 50}; // LTRB
140  child1.transform = {0.5, 0, 0, 0, 0.5, 0, 0, 0, 1};
141  bridge->AddFlutterSemanticsNodeUpdate(child1);
142 
143  bridge->CommitUpdates();
144  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
145  ui::AXOffscreenResult result;
146  gfx::Rect bounds =
147  child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
148  ui::AXClippingBehavior::kClipped, &result);
149  EXPECT_EQ(bounds.x(), 0);
150  EXPECT_EQ(bounds.y(), 0);
151  EXPECT_EQ(bounds.width(), 25);
152  EXPECT_EQ(bounds.height(), 25);
153  EXPECT_EQ(result, ui::AXOffscreenResult::kOnscreen);
154 }

◆ TEST() [41/158]

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

Definition at line 156 of file flutter_platform_node_delegate_unittests.cc.

156  {
157  std::shared_ptr<TestAccessibilityBridge> bridge =
158  std::make_shared<TestAccessibilityBridge>();
159  FlutterSemanticsNode2 root;
160  root.id = 0;
161  root.label = "root";
162  root.hint = "";
163  root.value = "";
164  root.increased_value = "";
165  root.decreased_value = "";
166  root.tooltip = "";
167  root.child_count = 1;
168  int32_t children[] = {1};
169  root.children_in_traversal_order = children;
170  root.custom_accessibility_actions_count = 0;
171  root.rect = {0, 0, 100, 100}; // LTRB
172  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
173  bridge->AddFlutterSemanticsNodeUpdate(root);
174 
175  FlutterSemanticsNode2 child1;
176  child1.id = 1;
177  child1.label = "child 1";
178  child1.hint = "";
179  child1.value = "";
180  child1.increased_value = "";
181  child1.decreased_value = "";
182  child1.tooltip = "";
183  child1.child_count = 0;
184  child1.custom_accessibility_actions_count = 0;
185  child1.rect = {90, 90, 100, 100}; // LTRB
186  child1.transform = {2, 0, 0, 0, 2, 0, 0, 0, 1};
187  bridge->AddFlutterSemanticsNodeUpdate(child1);
188 
189  bridge->CommitUpdates();
190  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
191  ui::AXOffscreenResult result;
192  gfx::Rect bounds =
193  child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
194  ui::AXClippingBehavior::kUnclipped, &result);
195  EXPECT_EQ(bounds.x(), 180);
196  EXPECT_EQ(bounds.y(), 180);
197  EXPECT_EQ(bounds.width(), 20);
198  EXPECT_EQ(bounds.height(), 20);
199  EXPECT_EQ(result, ui::AXOffscreenResult::kOffscreen);
200 }

◆ TEST() [42/158]

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

Definition at line 84 of file flutter_platform_node_delegate_unittests.cc.

84  {
85  // Set up a flutter accessibility node.
86  std::shared_ptr<TestAccessibilityBridge> bridge =
87  std::make_shared<TestAccessibilityBridge>();
88  FlutterSemanticsNode2 root;
89  root.id = 0;
90  root.flags = FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField;
91  root.actions = static_cast<FlutterSemanticsAction>(0);
92  root.text_selection_base = -1;
93  root.text_selection_extent = -1;
94  root.label = "root";
95  root.hint = "";
96  root.value = "";
97  root.increased_value = "";
98  root.decreased_value = "";
99  root.tooltip = "";
100  root.child_count = 0;
101  root.custom_accessibility_actions_count = 0;
102  bridge->AddFlutterSemanticsNodeUpdate(root);
103 
104  bridge->CommitUpdates();
105 
106  auto accessibility = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
107  EXPECT_EQ(accessibility->GetData().id, 0);
108 }

◆ TEST() [43/158]

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

Definition at line 271 of file flutter_platform_node_delegate_unittests.cc.

271  {
272  std::shared_ptr<TestAccessibilityBridge> bridge =
273  std::make_shared<TestAccessibilityBridge>();
274  FlutterSemanticsNode2 root;
275  root.id = 0;
276  root.label = "root";
277  root.hint = "";
278  root.value = "";
279  root.increased_value = "";
280  root.decreased_value = "";
281  root.tooltip = "";
282  root.child_count = 1;
283  int32_t children[] = {1};
284  root.children_in_traversal_order = children;
285  root.custom_accessibility_actions_count = 0;
286  bridge->AddFlutterSemanticsNodeUpdate(root);
287 
288  FlutterSemanticsNode2 child1;
289  child1.id = 1;
290  child1.label = "child 1";
291  child1.hint = "";
292  child1.value = "";
293  child1.increased_value = "";
294  child1.decreased_value = "";
295  child1.tooltip = "";
296  child1.child_count = 0;
297  child1.custom_accessibility_actions_count = 0;
298  bridge->AddFlutterSemanticsNodeUpdate(child1);
299 
300  bridge->CommitUpdates();
301  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
302  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
303  auto node_by_id = root_node->GetFromNodeID(1);
304  EXPECT_EQ(child1_node->GetPlatformNode(), node_by_id);
305 }

◆ TEST() [44/158]

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

Definition at line 40 of file flutter_platform_node_delegate_unittests.cc.

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

◆ TEST() [45/158]

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

Definition at line 202 of file flutter_platform_node_delegate_unittests.cc.

202  {
203  std::shared_ptr<TestAccessibilityBridge> bridge =
204  std::make_shared<TestAccessibilityBridge>();
205  FlutterSemanticsNode2 root;
206  root.id = 0;
207  root.label = "root";
208  root.hint = "";
209  root.value = "";
210  root.increased_value = "";
211  root.decreased_value = "";
212  root.tooltip = "";
213  root.child_count = 1;
214  int32_t children[] = {1};
215  root.children_in_traversal_order = children;
216  root.custom_accessibility_actions_count = 0;
217  root.rect = {0, 0, 100, 100}; // LTRB
218  root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
219  bridge->AddFlutterSemanticsNodeUpdate(root);
220 
221  FlutterSemanticsNode2 child1;
222  child1.id = 1;
223  child1.label = "child 1";
224  child1.hint = "";
225  child1.value = "";
226  child1.increased_value = "";
227  child1.decreased_value = "";
228  child1.tooltip = "";
229  child1.child_count = 0;
230  child1.custom_accessibility_actions_count = 0;
231  child1.rect = {0, 0, 50, 50}; // LTRB
232  child1.transform = {0.5, 0, 0, 0, 0.5, 0, 0, 0, 1};
233  bridge->AddFlutterSemanticsNodeUpdate(child1);
234 
235  bridge->CommitUpdates();
236  auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
237  auto owner_bridge = child1_node->GetOwnerBridge().lock();
238 
239  bool result;
240  gfx::RectF bounds = owner_bridge->RelativeToGlobalBounds(
241  child1_node->GetAXNode(), result, true);
242  EXPECT_EQ(bounds.x(), 0);
243  EXPECT_EQ(bounds.y(), 0);
244  EXPECT_EQ(bounds.width(), 25);
245  EXPECT_EQ(bounds.height(), 25);
246  EXPECT_EQ(result, false);
247 }

◆ TEST() [46/158]

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  node0.child_count = node0_children.size();
23  node0.children_in_traversal_order = node0_children.data();
24  node0.children_in_hit_test_order = node0_children.data();
25 
26  // Add node 1: text child of node 0.
27  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
28  node1.label = "prefecture";
29  node1.value = "Kyoto";
30 
31  bridge->AddFlutterSemanticsNodeUpdate(node0);
32  bridge->AddFlutterSemanticsNodeUpdate(node1);
33  bridge->CommitUpdates();
34 
35  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
36  auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
37  EXPECT_TRUE(node0_delegate->GetUniqueId() != node1_delegate->GetUniqueId());
38 }

◆ TEST() [47/158]

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

Definition at line 249 of file flutter_platform_node_delegate_unittests.cc.

249  {
250  std::shared_ptr<TestAccessibilityBridge> bridge =
251  std::make_shared<TestAccessibilityBridge>();
252  FlutterSemanticsNode2 root;
253  root.id = 0;
254  root.label = "root";
255  root.hint = "";
256  root.value = "";
257  root.increased_value = "";
258  root.decreased_value = "";
259  root.tooltip = "";
260  root.child_count = 0;
261  root.children_in_traversal_order = nullptr;
262  root.custom_accessibility_actions_count = 0;
263  bridge->AddFlutterSemanticsNodeUpdate(root);
264 
265  bridge->CommitUpdates();
266  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
267  auto lowest_platform_ancestor = root_node->GetLowestPlatformAncestor();
268  EXPECT_EQ(root_node->GetNativeViewAccessible(), lowest_platform_ancestor);
269 }

◆ TEST() [48/158]

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

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

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

Definition at line 50 of file flutter_project_bundle_unittests.cc.

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

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

◆ TEST() [51/158]

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

Definition at line 69 of file flutter_project_bundle_unittests.cc.

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

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

◆ TEST() [52/158]

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

Definition at line 37 of file flutter_project_bundle_unittests.cc.

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

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

◆ TEST() [53/158]

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

Definition at line 67 of file flutter_windows_texture_registrar_unittests.cc.

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

◆ TEST() [54/158]

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

Definition at line 267 of file flutter_windows_texture_registrar_unittests.cc.

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

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, user_data, FlutterDesktopGpuSurfaceTextureConfig::user_data, FlutterDesktopGpuSurfaceDescriptor::visible_height, FlutterDesktopGpuSurfaceDescriptor::visible_width, and FlutterDesktopGpuSurfaceDescriptor::width.

◆ TEST() [55/158]

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

Definition at line 205 of file flutter_windows_texture_registrar_unittests.cc.

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

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, user_data, FlutterDesktopGpuSurfaceTextureConfig::user_data, FlutterDesktopGpuSurfaceDescriptor::visible_height, FlutterDesktopGpuSurfaceDescriptor::visible_width, and FlutterDesktopGpuSurfaceDescriptor::width.

◆ TEST() [56/158]

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

Definition at line 323 of file flutter_windows_texture_registrar_unittests.cc.

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

References flutter::FlutterWindowsTextureRegistrar::PopulateTexture().

◆ TEST() [57/158]

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

Definition at line 154 of file flutter_windows_texture_registrar_unittests.cc.

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

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, user_data, FlutterDesktopPixelBufferTextureConfig::user_data, and FlutterDesktopPixelBuffer::width.

◆ TEST() [58/158]

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

Definition at line 140 of file flutter_windows_texture_registrar_unittests.cc.

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

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

◆ TEST() [59/158]

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

Definition at line 75 of file flutter_windows_texture_registrar_unittests.cc.

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

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

◆ TEST() [60/158]

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

Definition at line 333 of file flutter_windows_texture_registrar_unittests.cc.

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

References flutter::FlutterWindowsTextureRegistrar::UnregisterTexture().

◆ TEST() [61/158]

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

Definition at line 752 of file flutter_windows_view_unittests.cc.

752  {
753  constexpr FlutterTransformation kIdentityTransform = {1, 0, 0, //
754  0, 1, 0, //
755  0, 0, 1};
756 
757  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
758  EngineModifier modifier(engine.get());
759  modifier.embedder_api().UpdateSemanticsEnabled =
760  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
761  return kSuccess;
762  };
763 
764  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
765  std::make_unique<NiceMock<MockWindowBindingHandler>>());
766 
767  // Enable semantics to instantiate accessibility bridge.
768  view->OnUpdateSemanticsEnabled(true);
769 
770  auto bridge = view->accessibility_bridge().lock();
771  ASSERT_TRUE(bridge);
772 
773  // Add root node at origin. Size 500x500.
774  FlutterSemanticsNode2 node0{sizeof(FlutterSemanticsNode2), 0};
775  std::vector<int32_t> node0_children{1, 2};
776  node0.rect = {0, 0, 500, 500};
777  node0.transform = kIdentityTransform;
778  node0.child_count = node0_children.size();
779  node0.children_in_traversal_order = node0_children.data();
780  node0.children_in_hit_test_order = node0_children.data();
781 
782  // Add node 1 located at 0,0 relative to node 0. Size 250x500.
783  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
784  node1.rect = {0, 0, 250, 500};
785  node1.transform = kIdentityTransform;
786  node1.label = "prefecture";
787  node1.value = "Kyoto";
788 
789  // Add node 2 located at 250,0 relative to node 0. Size 250x500.
790  FlutterSemanticsNode2 node2{sizeof(FlutterSemanticsNode2), 2};
791  std::vector<int32_t> node2_children{3};
792  node2.rect = {0, 0, 250, 500};
793  node2.transform = {1, 0, 250, 0, 1, 0, 0, 0, 1};
794  node2.child_count = node2_children.size();
795  node2.children_in_traversal_order = node2_children.data();
796  node2.children_in_hit_test_order = node2_children.data();
797 
798  // Add node 3 located at 0,250 relative to node 2. Size 250, 250.
799  FlutterSemanticsNode2 node3{sizeof(FlutterSemanticsNode2), 3};
800  node3.rect = {0, 0, 250, 250};
801  node3.transform = {1, 0, 0, 0, 1, 250, 0, 0, 1};
802  node3.label = "city";
803  node3.value = "Uji";
804 
805  bridge->AddFlutterSemanticsNodeUpdate(node0);
806  bridge->AddFlutterSemanticsNodeUpdate(node1);
807  bridge->AddFlutterSemanticsNodeUpdate(node2);
808  bridge->AddFlutterSemanticsNodeUpdate(node3);
809  bridge->CommitUpdates();
810 
811  // Look up the root windows node delegate.
812  auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
813  ASSERT_TRUE(node0_delegate);
814  auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
815  ASSERT_TRUE(node1_delegate);
816  auto node2_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
817  ASSERT_TRUE(node2_delegate);
818  auto node3_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(3).lock();
819  ASSERT_TRUE(node3_delegate);
820 
821  // Get the native IAccessible root object.
822  IAccessible* node0_accessible = node0_delegate->GetNativeViewAccessible();
823  ASSERT_TRUE(node0_accessible != nullptr);
824 
825  // Perform a hit test that should hit node 1.
826  VARIANT varchild{};
827  ASSERT_TRUE(SUCCEEDED(node0_accessible->accHitTest(150, 150, &varchild)));
828  EXPECT_EQ(varchild.vt, VT_DISPATCH);
829  EXPECT_EQ(varchild.pdispVal, node1_delegate->GetNativeViewAccessible());
830 
831  // Perform a hit test that should hit node 2.
832  varchild = {};
833  ASSERT_TRUE(SUCCEEDED(node0_accessible->accHitTest(450, 150, &varchild)));
834  EXPECT_EQ(varchild.vt, VT_DISPATCH);
835  EXPECT_EQ(varchild.pdispVal, node2_delegate->GetNativeViewAccessible());
836 
837  // Perform a hit test that should hit node 3.
838  varchild = {};
839  ASSERT_TRUE(SUCCEEDED(node0_accessible->accHitTest(450, 450, &varchild)));
840  EXPECT_EQ(varchild.vt, VT_DISPATCH);
841  EXPECT_EQ(varchild.pdispVal, node3_delegate->GetNativeViewAccessible());
842 }

◆ TEST() [62/158]

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

Definition at line 331 of file flutter_windows_view_unittests.cc.

331  {
332  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
333  EngineModifier modifier(engine.get());
334  modifier.embedder_api().UpdateSemanticsEnabled =
335  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
336  return kSuccess;
337  };
338 
339  auto window_binding_handler =
340  std::make_unique<NiceMock<MockWindowBindingHandler>>();
341  std::unique_ptr<FlutterWindowsView> view =
342  engine->CreateView(std::move(window_binding_handler));
343 
344  // Enable semantics to instantiate accessibility bridge.
345  view->OnUpdateSemanticsEnabled(true);
346 
347  auto bridge = view->accessibility_bridge().lock();
348  ASSERT_TRUE(bridge);
349 
350  // Add root node.
351  FlutterSemanticsNode2 node{sizeof(FlutterSemanticsNode2), 0};
352  node.label = "name";
353  node.value = "value";
354  node.platform_view_id = -1;
355  bridge->AddFlutterSemanticsNodeUpdate(node);
356  bridge->CommitUpdates();
357 
358  // Look up the root windows node delegate.
359  auto node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
360  ASSERT_TRUE(node_delegate);
361  EXPECT_EQ(node_delegate->GetChildCount(), 0);
362 
363  // Get the native IAccessible object.
364  IAccessible* native_view = node_delegate->GetNativeViewAccessible();
365  ASSERT_TRUE(native_view != nullptr);
366 
367  // Property lookups will be made against this node itself.
368  VARIANT varchild{};
369  varchild.vt = VT_I4;
370  varchild.lVal = CHILDID_SELF;
371 
372  // Verify node name matches our label.
373  BSTR bname = nullptr;
374  ASSERT_EQ(native_view->get_accName(varchild, &bname), S_OK);
375  std::string name(_com_util::ConvertBSTRToString(bname));
376  EXPECT_EQ(name, "name");
377 
378  // Verify node value matches.
379  BSTR bvalue = nullptr;
380  ASSERT_EQ(native_view->get_accValue(varchild, &bvalue), S_OK);
381  std::string value(_com_util::ConvertBSTRToString(bvalue));
382  EXPECT_EQ(value, "value");
383 
384  // Verify node type is static text.
385  VARIANT varrole{};
386  varrole.vt = VT_I4;
387  ASSERT_EQ(native_view->get_accRole(varchild, &varrole), S_OK);
388  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
389 
390  // Get the IRawElementProviderFragment object.
391  IRawElementProviderSimple* uia_view;
392  native_view->QueryInterface(IID_PPV_ARGS(&uia_view));
393  ASSERT_TRUE(uia_view != nullptr);
394 
395  // Verify name property matches our label.
396  VARIANT varname{};
397  ASSERT_EQ(uia_view->GetPropertyValue(UIA_NamePropertyId, &varname), S_OK);
398  EXPECT_EQ(varname.vt, VT_BSTR);
399  name = _com_util::ConvertBSTRToString(varname.bstrVal);
400  EXPECT_EQ(name, "name");
401 
402  // Verify value property matches our label.
403  VARIANT varvalue{};
404  ASSERT_EQ(uia_view->GetPropertyValue(UIA_ValueValuePropertyId, &varvalue),
405  S_OK);
406  EXPECT_EQ(varvalue.vt, VT_BSTR);
407  value = _com_util::ConvertBSTRToString(varvalue.bstrVal);
408  EXPECT_EQ(value, "value");
409 
410  // Verify node control type is text.
411  varrole = {};
412  ASSERT_EQ(uia_view->GetPropertyValue(UIA_ControlTypePropertyId, &varrole),
413  S_OK);
414  EXPECT_EQ(varrole.vt, VT_I4);
415  EXPECT_EQ(varrole.lVal, UIA_TextControlTypeId);
416 }

References node_delegate.

◆ TEST() [63/158]

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

Definition at line 430 of file flutter_windows_view_unittests.cc.

430  {
431  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
432  EngineModifier modifier(engine.get());
433  modifier.embedder_api().UpdateSemanticsEnabled =
434  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
435  return kSuccess;
436  };
437 
438  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
439  std::make_unique<NiceMock<MockWindowBindingHandler>>());
440 
441  // Enable semantics to instantiate accessibility bridge.
442  view->OnUpdateSemanticsEnabled(true);
443 
444  auto bridge = view->accessibility_bridge().lock();
445  ASSERT_TRUE(bridge);
446 
447  // Add root node.
448  FlutterSemanticsNode2 node0{sizeof(FlutterSemanticsNode2), 0};
449  std::vector<int32_t> node0_children{1, 2};
450  node0.child_count = node0_children.size();
451  node0.children_in_traversal_order = node0_children.data();
452  node0.children_in_hit_test_order = node0_children.data();
453 
454  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
455  node1.label = "prefecture";
456  node1.value = "Kyoto";
457  FlutterSemanticsNode2 node2{sizeof(FlutterSemanticsNode2), 2};
458  std::vector<int32_t> node2_children{3};
459  node2.child_count = node2_children.size();
460  node2.children_in_traversal_order = node2_children.data();
461  node2.children_in_hit_test_order = node2_children.data();
462  FlutterSemanticsNode2 node3{sizeof(FlutterSemanticsNode2), 3};
463  node3.label = "city";
464  node3.value = "Uji";
465 
466  bridge->AddFlutterSemanticsNodeUpdate(node0);
467  bridge->AddFlutterSemanticsNodeUpdate(node1);
468  bridge->AddFlutterSemanticsNodeUpdate(node2);
469  bridge->AddFlutterSemanticsNodeUpdate(node3);
470  bridge->CommitUpdates();
471 
472  // Look up the root windows node delegate.
473  auto node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
474  ASSERT_TRUE(node_delegate);
475  EXPECT_EQ(node_delegate->GetChildCount(), 2);
476 
477  // Get the native IAccessible object.
478  IAccessible* node0_accessible = node_delegate->GetNativeViewAccessible();
479  ASSERT_TRUE(node0_accessible != nullptr);
480 
481  // Property lookups will be made against this node itself.
482  VARIANT varchild{};
483  varchild.vt = VT_I4;
484  varchild.lVal = CHILDID_SELF;
485 
486  // Verify node type is a group.
487  VARIANT varrole{};
488  varrole.vt = VT_I4;
489  ASSERT_EQ(node0_accessible->get_accRole(varchild, &varrole), S_OK);
490  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_GROUPING);
491 
492  // Verify child count.
493  long node0_child_count = 0;
494  ASSERT_EQ(node0_accessible->get_accChildCount(&node0_child_count), S_OK);
495  EXPECT_EQ(node0_child_count, 2);
496 
497  {
498  // Look up first child of node0 (node1), a static text node.
499  varchild.lVal = 1;
500  IDispatch* node1_dispatch = nullptr;
501  ASSERT_EQ(node0_accessible->get_accChild(varchild, &node1_dispatch), S_OK);
502  ASSERT_TRUE(node1_dispatch != nullptr);
503  IAccessible* node1_accessible = nullptr;
504  ASSERT_EQ(node1_dispatch->QueryInterface(
505  IID_IAccessible, reinterpret_cast<void**>(&node1_accessible)),
506  S_OK);
507  ASSERT_TRUE(node1_accessible != nullptr);
508 
509  // Verify node name matches our label.
510  varchild.lVal = CHILDID_SELF;
511  BSTR bname = nullptr;
512  ASSERT_EQ(node1_accessible->get_accName(varchild, &bname), S_OK);
513  std::string name(_com_util::ConvertBSTRToString(bname));
514  EXPECT_EQ(name, "prefecture");
515 
516  // Verify node value matches.
517  BSTR bvalue = nullptr;
518  ASSERT_EQ(node1_accessible->get_accValue(varchild, &bvalue), S_OK);
519  std::string value(_com_util::ConvertBSTRToString(bvalue));
520  EXPECT_EQ(value, "Kyoto");
521 
522  // Verify node type is static text.
523  VARIANT varrole{};
524  varrole.vt = VT_I4;
525  ASSERT_EQ(node1_accessible->get_accRole(varchild, &varrole), S_OK);
526  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
527 
528  // Verify the parent node is the root.
529  IDispatch* parent_dispatch;
530  node1_accessible->get_accParent(&parent_dispatch);
531  IAccessible* parent_accessible;
532  ASSERT_EQ(
533  parent_dispatch->QueryInterface(
534  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
535  S_OK);
536  EXPECT_EQ(parent_accessible, node0_accessible);
537  }
538 
539  // Look up second child of node0 (node2), a parent group for node3.
540  varchild.lVal = 2;
541  IDispatch* node2_dispatch = nullptr;
542  ASSERT_EQ(node0_accessible->get_accChild(varchild, &node2_dispatch), S_OK);
543  ASSERT_TRUE(node2_dispatch != nullptr);
544  IAccessible* node2_accessible = nullptr;
545  ASSERT_EQ(node2_dispatch->QueryInterface(
546  IID_IAccessible, reinterpret_cast<void**>(&node2_accessible)),
547  S_OK);
548  ASSERT_TRUE(node2_accessible != nullptr);
549 
550  {
551  // Verify child count.
552  long node2_child_count = 0;
553  ASSERT_EQ(node2_accessible->get_accChildCount(&node2_child_count), S_OK);
554  EXPECT_EQ(node2_child_count, 1);
555 
556  // Verify node type is static text.
557  varchild.lVal = CHILDID_SELF;
558  VARIANT varrole{};
559  varrole.vt = VT_I4;
560  ASSERT_EQ(node2_accessible->get_accRole(varchild, &varrole), S_OK);
561  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_GROUPING);
562 
563  // Verify the parent node is the root.
564  IDispatch* parent_dispatch;
565  node2_accessible->get_accParent(&parent_dispatch);
566  IAccessible* parent_accessible;
567  ASSERT_EQ(
568  parent_dispatch->QueryInterface(
569  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
570  S_OK);
571  EXPECT_EQ(parent_accessible, node0_accessible);
572  }
573 
574  {
575  // Look up only child of node2 (node3), a static text node.
576  varchild.lVal = 1;
577  IDispatch* node3_dispatch = nullptr;
578  ASSERT_EQ(node2_accessible->get_accChild(varchild, &node3_dispatch), S_OK);
579  ASSERT_TRUE(node3_dispatch != nullptr);
580  IAccessible* node3_accessible = nullptr;
581  ASSERT_EQ(node3_dispatch->QueryInterface(
582  IID_IAccessible, reinterpret_cast<void**>(&node3_accessible)),
583  S_OK);
584  ASSERT_TRUE(node3_accessible != nullptr);
585 
586  // Verify node name matches our label.
587  varchild.lVal = CHILDID_SELF;
588  BSTR bname = nullptr;
589  ASSERT_EQ(node3_accessible->get_accName(varchild, &bname), S_OK);
590  std::string name(_com_util::ConvertBSTRToString(bname));
591  EXPECT_EQ(name, "city");
592 
593  // Verify node value matches.
594  BSTR bvalue = nullptr;
595  ASSERT_EQ(node3_accessible->get_accValue(varchild, &bvalue), S_OK);
596  std::string value(_com_util::ConvertBSTRToString(bvalue));
597  EXPECT_EQ(value, "Uji");
598 
599  // Verify node type is static text.
600  VARIANT varrole{};
601  varrole.vt = VT_I4;
602  ASSERT_EQ(node3_accessible->get_accRole(varchild, &varrole), S_OK);
603  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
604 
605  // Verify the parent node is node2.
606  IDispatch* parent_dispatch;
607  node3_accessible->get_accParent(&parent_dispatch);
608  IAccessible* parent_accessible;
609  ASSERT_EQ(
610  parent_dispatch->QueryInterface(
611  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
612  S_OK);
613  EXPECT_EQ(parent_accessible, node2_accessible);
614  }
615 }

References node_delegate.

◆ TEST() [64/158]

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

Definition at line 1116 of file flutter_windows_view_unittests.cc.

1116  {
1117  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1118  EngineModifier modifier(engine.get());
1119  modifier.embedder_api().UpdateSemanticsEnabled =
1120  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
1121  return kSuccess;
1122  };
1123 
1124  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1125  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1126 
1127  // Enable semantics to instantiate accessibility bridge.
1128  view->OnUpdateSemanticsEnabled(true);
1129 
1130  auto bridge = view->accessibility_bridge().lock();
1131  ASSERT_TRUE(bridge);
1132 
1133  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
1134  root.id = 0;
1135  root.label = "root";
1136  root.hint = "";
1137  root.value = "";
1138  root.increased_value = "";
1139  root.decreased_value = "";
1140  root.child_count = 0;
1141  root.custom_accessibility_actions_count = 0;
1142  root.flags = static_cast<FlutterSemanticsFlag>(
1143  FlutterSemanticsFlag::kFlutterSemanticsFlagHasCheckedState |
1144  FlutterSemanticsFlag::kFlutterSemanticsFlagIsChecked);
1145  bridge->AddFlutterSemanticsNodeUpdate(root);
1146 
1147  bridge->CommitUpdates();
1148 
1149  {
1150  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1151  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
1152  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1153  ax::mojom::CheckedState::kTrue);
1154 
1155  // Get the IAccessible for the root node.
1156  IAccessible* native_view = root_node->GetNativeViewAccessible();
1157  ASSERT_TRUE(native_view != nullptr);
1158 
1159  // Look up against the node itself (not one of its children).
1160  VARIANT varchild = {};
1161  varchild.vt = VT_I4;
1162 
1163  // Verify the checkbox is checked.
1164  varchild.lVal = CHILDID_SELF;
1165  VARIANT native_state = {};
1166  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1167  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_CHECKED);
1168 
1169  // Perform similar tests for UIA value;
1170  IRawElementProviderSimple* uia_node;
1171  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1172  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1173  UIA_ToggleToggleStatePropertyId, &native_state)));
1174  EXPECT_EQ(native_state.lVal, ToggleState_On);
1175 
1176  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1177  UIA_AriaPropertiesPropertyId, &native_state)));
1178  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"checked=true"), nullptr);
1179  }
1180 
1181  // Test unchecked too.
1182  root.flags = static_cast<FlutterSemanticsFlag>(
1183  FlutterSemanticsFlag::kFlutterSemanticsFlagHasCheckedState);
1184  bridge->AddFlutterSemanticsNodeUpdate(root);
1185  bridge->CommitUpdates();
1186 
1187  {
1188  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1189  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
1190  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1191  ax::mojom::CheckedState::kFalse);
1192 
1193  // Get the IAccessible for the root node.
1194  IAccessible* native_view = root_node->GetNativeViewAccessible();
1195  ASSERT_TRUE(native_view != nullptr);
1196 
1197  // Look up against the node itself (not one of its children).
1198  VARIANT varchild = {};
1199  varchild.vt = VT_I4;
1200 
1201  // Verify the checkbox is unchecked.
1202  varchild.lVal = CHILDID_SELF;
1203  VARIANT native_state = {};
1204  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1205  EXPECT_FALSE(native_state.lVal & STATE_SYSTEM_CHECKED);
1206 
1207  // Perform similar tests for UIA value;
1208  IRawElementProviderSimple* uia_node;
1209  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1210  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1211  UIA_ToggleToggleStatePropertyId, &native_state)));
1212  EXPECT_EQ(native_state.lVal, ToggleState_Off);
1213 
1214  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1215  UIA_AriaPropertiesPropertyId, &native_state)));
1216  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"checked=false"), nullptr);
1217  }
1218 
1219  // Now check mixed state.
1220  root.flags = static_cast<FlutterSemanticsFlag>(
1221  FlutterSemanticsFlag::kFlutterSemanticsFlagHasCheckedState |
1222  FlutterSemanticsFlag::kFlutterSemanticsFlagIsCheckStateMixed);
1223  bridge->AddFlutterSemanticsNodeUpdate(root);
1224  bridge->CommitUpdates();
1225 
1226  {
1227  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1228  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kCheckBox);
1229  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1230  ax::mojom::CheckedState::kMixed);
1231 
1232  // Get the IAccessible for the root node.
1233  IAccessible* native_view = root_node->GetNativeViewAccessible();
1234  ASSERT_TRUE(native_view != nullptr);
1235 
1236  // Look up against the node itself (not one of its children).
1237  VARIANT varchild = {};
1238  varchild.vt = VT_I4;
1239 
1240  // Verify the checkbox is mixed.
1241  varchild.lVal = CHILDID_SELF;
1242  VARIANT native_state = {};
1243  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1244  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_MIXED);
1245 
1246  // Perform similar tests for UIA value;
1247  IRawElementProviderSimple* uia_node;
1248  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1249  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1250  UIA_ToggleToggleStatePropertyId, &native_state)));
1251  EXPECT_EQ(native_state.lVal, ToggleState_Indeterminate);
1252 
1253  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
1254  UIA_AriaPropertiesPropertyId, &native_state)));
1255  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"checked=mixed"), nullptr);
1256  }
1257 }

◆ TEST() [65/158]

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

Definition at line 1505 of file flutter_windows_view_unittests.cc.

1505  {
1506  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1507  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1508  auto egl_manager = std::make_unique<egl::MockManager>();
1509  egl::MockContext render_context;
1510  auto surface = std::make_unique<egl::MockWindowSurface>();
1511  auto surface_ptr = surface.get();
1512 
1513  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1514  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1515  .WillOnce(Return(true));
1516 
1517  EXPECT_CALL(*egl_manager.get(), render_context)
1518  .WillOnce(Return(&render_context));
1519  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1520 
1521  InSequence s;
1522  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1523  .WillOnce(Return(std::move(surface)));
1524  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1525  .WillOnce([](fml::closure callback) {
1526  callback();
1527  return true;
1528  });
1529  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1530  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1531  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1532  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1533  .WillOnce([](fml::closure callback) {
1534  callback();
1535  return true;
1536  });
1537  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1538 
1539  EngineModifier modifier{engine.get()};
1540  modifier.SetEGLManager(std::move(egl_manager));
1541 
1542  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1543  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1544 }

References callback.

◆ TEST() [66/158]

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

Definition at line 1434 of file flutter_windows_view_unittests.cc.

1434  {
1435  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1436  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1437  auto egl_manager = std::make_unique<egl::MockManager>();
1438  egl::MockContext render_context;
1439  auto surface = std::make_unique<egl::MockWindowSurface>();
1440  auto surface_ptr = surface.get();
1441 
1442  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(false));
1443  EXPECT_CALL(*engine.get(), PostRasterThreadTask).Times(0);
1444 
1445  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1446  .WillOnce(Return(true));
1447 
1448  EXPECT_CALL(*egl_manager.get(), render_context)
1449  .WillOnce(Return(&render_context));
1450  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1451 
1452  InSequence s;
1453  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1454  .WillOnce(Return(std::move(surface)));
1455  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1456  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1457  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1458 
1459  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1460 
1461  EngineModifier modifier{engine.get()};
1462  modifier.SetEGLManager(std::move(egl_manager));
1463 
1464  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1465  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1466 }

◆ TEST() [67/158]

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

Definition at line 309 of file flutter_windows_view_unittests.cc.

309  {
310  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
311  EngineModifier modifier(engine.get());
312 
313  bool semantics_enabled = false;
314  modifier.embedder_api().UpdateSemanticsEnabled = MOCK_ENGINE_PROC(
315  UpdateSemanticsEnabled,
316  [&semantics_enabled](FLUTTER_API_SYMBOL(FlutterEngine) engine,
317  bool enabled) {
318  semantics_enabled = enabled;
319  return kSuccess;
320  });
321 
322  auto window_binding_handler =
323  std::make_unique<NiceMock<MockWindowBindingHandler>>();
324  std::unique_ptr<FlutterWindowsView> view =
325  engine->CreateView(std::move(window_binding_handler));
326 
327  view->OnUpdateSemanticsEnabled(true);
328  EXPECT_TRUE(semantics_enabled);
329 }

◆ TEST() [68/158]

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

Definition at line 1548 of file flutter_windows_view_unittests.cc.

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

References callback.

◆ TEST() [69/158]

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

Definition at line 1470 of file flutter_windows_view_unittests.cc.

1470  {
1471  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1472  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1473  auto egl_manager = std::make_unique<egl::MockManager>();
1474  egl::MockContext render_context;
1475  auto surface = std::make_unique<egl::MockWindowSurface>();
1476  auto surface_ptr = surface.get();
1477 
1478  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(false));
1479  EXPECT_CALL(*engine.get(), PostRasterThreadTask).Times(0);
1480  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1481  .WillOnce(Return(false));
1482 
1483  EXPECT_CALL(*egl_manager.get(), render_context)
1484  .WillOnce(Return(&render_context));
1485  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
1486 
1487  InSequence s;
1488  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface)
1489  .WillOnce(Return(std::move(surface)));
1490  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
1491  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1492  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
1493 
1494  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1495 
1496  EngineModifier modifier{engine.get()};
1497  modifier.SetEGLManager(std::move(egl_manager));
1498 
1499  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1500  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1501 }

◆ TEST() [70/158]

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

Definition at line 291 of file flutter_windows_view_unittests.cc.

291  {
292  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
293 
294  test_response = false;
295 
296  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
297  std::make_unique<NiceMock<MockWindowBindingHandler>>());
298 
299  view->OnKey(kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false, false,
300  [](bool handled) {});
301 
302  EXPECT_EQ(key_event_logs.size(), 2);
303  EXPECT_EQ(key_event_logs[0], kKeyEventFromEmbedder);
304  EXPECT_EQ(key_event_logs[1], kKeyEventFromChannel);
305 
306  key_event_logs.clear();
307 }

References kScanCodeKeyA, and kVirtualKeyA.

◆ TEST() [71/158]

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

Definition at line 626 of file flutter_windows_view_unittests.cc.

626  {
627  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
628  EngineModifier modifier(engine.get());
629  modifier.embedder_api().UpdateSemanticsEnabled =
630  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
631  return kSuccess;
632  };
633 
634  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
635  std::make_unique<NiceMock<MockWindowBindingHandler>>());
636 
637  // Enable semantics to instantiate accessibility bridge.
638  view->OnUpdateSemanticsEnabled(true);
639 
640  auto bridge = view->accessibility_bridge().lock();
641  ASSERT_TRUE(bridge);
642 
643  // Add root node.
644  FlutterSemanticsNode2 node1{sizeof(FlutterSemanticsNode2), 1};
645  std::vector<int32_t> node1_children{2};
646  node1.child_count = node1_children.size();
647  node1.children_in_traversal_order = node1_children.data();
648  node1.children_in_hit_test_order = node1_children.data();
649 
650  FlutterSemanticsNode2 node2{sizeof(FlutterSemanticsNode2), 2};
651  node2.label = "prefecture";
652  node2.value = "Kyoto";
653 
654  bridge->AddFlutterSemanticsNodeUpdate(node1);
655  bridge->AddFlutterSemanticsNodeUpdate(node2);
656  bridge->CommitUpdates();
657 
658  // Look up the root windows node delegate.
659  auto root_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
660  ASSERT_TRUE(root_delegate);
661  EXPECT_EQ(root_delegate->GetChildCount(), 1);
662 
663  // Look up the child node delegate
664  auto child_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
665  ASSERT_TRUE(child_delegate);
666  EXPECT_EQ(child_delegate->GetChildCount(), 0);
667 
668  // Ensure a node with ID 0 does not exist.
669  auto fake_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
670  ASSERT_FALSE(fake_delegate);
671 
672  // Get the root's native IAccessible object.
673  IAccessible* node1_accessible = root_delegate->GetNativeViewAccessible();
674  ASSERT_TRUE(node1_accessible != nullptr);
675 
676  // Property lookups will be made against this node itself.
677  VARIANT varchild{};
678  varchild.vt = VT_I4;
679  varchild.lVal = CHILDID_SELF;
680 
681  // Verify node type is a group.
682  VARIANT varrole{};
683  varrole.vt = VT_I4;
684  ASSERT_EQ(node1_accessible->get_accRole(varchild, &varrole), S_OK);
685  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_GROUPING);
686 
687  // Verify child count.
688  long node1_child_count = 0;
689  ASSERT_EQ(node1_accessible->get_accChildCount(&node1_child_count), S_OK);
690  EXPECT_EQ(node1_child_count, 1);
691 
692  {
693  // Look up first child of node1 (node0), a static text node.
694  varchild.lVal = 1;
695  IDispatch* node2_dispatch = nullptr;
696  ASSERT_EQ(node1_accessible->get_accChild(varchild, &node2_dispatch), S_OK);
697  ASSERT_TRUE(node2_dispatch != nullptr);
698  IAccessible* node2_accessible = nullptr;
699  ASSERT_EQ(node2_dispatch->QueryInterface(
700  IID_IAccessible, reinterpret_cast<void**>(&node2_accessible)),
701  S_OK);
702  ASSERT_TRUE(node2_accessible != nullptr);
703 
704  // Verify node name matches our label.
705  varchild.lVal = CHILDID_SELF;
706  BSTR bname = nullptr;
707  ASSERT_EQ(node2_accessible->get_accName(varchild, &bname), S_OK);
708  std::string name(_com_util::ConvertBSTRToString(bname));
709  EXPECT_EQ(name, "prefecture");
710 
711  // Verify node value matches.
712  BSTR bvalue = nullptr;
713  ASSERT_EQ(node2_accessible->get_accValue(varchild, &bvalue), S_OK);
714  std::string value(_com_util::ConvertBSTRToString(bvalue));
715  EXPECT_EQ(value, "Kyoto");
716 
717  // Verify node type is static text.
718  VARIANT varrole{};
719  varrole.vt = VT_I4;
720  ASSERT_EQ(node2_accessible->get_accRole(varchild, &varrole), S_OK);
721  EXPECT_EQ(varrole.lVal, ROLE_SYSTEM_STATICTEXT);
722 
723  // Verify the parent node is the root.
724  IDispatch* parent_dispatch;
725  node2_accessible->get_accParent(&parent_dispatch);
726  IAccessible* parent_accessible;
727  ASSERT_EQ(
728  parent_dispatch->QueryInterface(
729  IID_IAccessible, reinterpret_cast<void**>(&parent_accessible)),
730  S_OK);
731  EXPECT_EQ(parent_accessible, node1_accessible);
732  }
733 }

◆ TEST() [72/158]

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

Definition at line 241 of file flutter_windows_view_unittests.cc.

241  {
242  auto engine = std::make_unique<MockFlutterWindowsEngine>();
243  auto window_binding_handler =
244  std::make_unique<NiceMock<MockWindowBindingHandler>>();
245  auto egl_manager = std::make_unique<egl::MockManager>();
246  auto surface = std::make_unique<egl::MockWindowSurface>();
247  egl::MockContext render_context;
248 
249  auto engine_ptr = engine.get();
250  auto surface_ptr = surface.get();
251  auto egl_manager_ptr = egl_manager.get();
252 
253  EngineModifier modifier{engine.get()};
254  modifier.SetEGLManager(std::move(egl_manager));
255 
256  InSequence s;
257  std::unique_ptr<FlutterWindowsView> view;
258 
259  // Mock render surface initialization.
260  {
261  EXPECT_CALL(*egl_manager_ptr, CreateWindowSurface)
262  .WillOnce(Return(std::move(surface)));
263  EXPECT_CALL(*engine_ptr, running).WillOnce(Return(false));
264  EXPECT_CALL(*surface_ptr, IsValid).WillOnce(Return(true));
265  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
266  EXPECT_CALL(*surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
267  EXPECT_CALL(*egl_manager_ptr, render_context)
268  .WillOnce(Return(&render_context));
269  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
270 
271  view = engine->CreateView(std::move(window_binding_handler));
272  }
273 
274  // The view must be removed before the surface can be destroyed.
275  {
276  auto view_id = view->view_id();
277  FlutterWindowsViewController controller{std::move(engine), std::move(view)};
278 
279  EXPECT_CALL(*engine_ptr, running).WillOnce(Return(true));
280  EXPECT_CALL(*engine_ptr, RemoveView(view_id)).Times(1);
281  EXPECT_CALL(*engine_ptr, running).WillOnce(Return(true));
282  EXPECT_CALL(*engine_ptr, PostRasterThreadTask)
283  .WillOnce([](fml::closure callback) {
284  callback();
285  return true;
286  });
287  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
288  }
289 }

References callback.

◆ TEST() [73/158]

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

Definition at line 137 of file flutter_windows_view_unittests.cc.

137  {
138  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
139  EngineModifier modifier(engine.get());
140  modifier.embedder_api().UpdateSemanticsEnabled =
141  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
142  return kSuccess;
143  };
144 
145  auto window_binding_handler =
146  std::make_unique<NiceMock<MockWindowBindingHandler>>();
147  std::unique_ptr<FlutterWindowsView> view =
148  engine->CreateView(std::move(window_binding_handler));
149 
150  // Enable semantics to instantiate accessibility bridge.
151  view->OnUpdateSemanticsEnabled(true);
152 
153  auto bridge = view->accessibility_bridge().lock();
154  ASSERT_TRUE(bridge);
155 
156  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
157  root.id = 0;
158  root.label = "root";
159  root.hint = "";
160  root.value = "";
161  root.increased_value = "";
162  root.decreased_value = "";
163  root.child_count = 0;
164  root.custom_accessibility_actions_count = 0;
165  root.flags = static_cast<FlutterSemanticsFlag>(
166  FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState |
167  FlutterSemanticsFlag::kFlutterSemanticsFlagIsExpanded);
168  bridge->AddFlutterSemanticsNodeUpdate(root);
169 
170  bridge->CommitUpdates();
171 
172  {
173  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
174  EXPECT_TRUE(root_node->GetData().HasState(ax::mojom::State::kExpanded));
175 
176  // Get the IAccessible for the root node.
177  IAccessible* native_view = root_node->GetNativeViewAccessible();
178  ASSERT_TRUE(native_view != nullptr);
179 
180  // Look up against the node itself (not one of its children).
181  VARIANT varchild = {};
182  varchild.vt = VT_I4;
183 
184  // Verify the submenu is expanded.
185  varchild.lVal = CHILDID_SELF;
186  VARIANT native_state = {};
187  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
188  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_EXPANDED);
189 
190  // Perform similar tests for UIA value;
191  IRawElementProviderSimple* uia_node;
192  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
193  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
194  UIA_ExpandCollapseExpandCollapseStatePropertyId, &native_state)));
195  EXPECT_EQ(native_state.lVal, ExpandCollapseState_Expanded);
196 
197  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
198  UIA_AriaPropertiesPropertyId, &native_state)));
199  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"expanded=true"), nullptr);
200  }
201 
202  // Test collapsed too.
203  root.flags = static_cast<FlutterSemanticsFlag>(
204  FlutterSemanticsFlag::kFlutterSemanticsFlagHasExpandedState);
205  bridge->AddFlutterSemanticsNodeUpdate(root);
206  bridge->CommitUpdates();
207 
208  {
209  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
210  EXPECT_TRUE(root_node->GetData().HasState(ax::mojom::State::kCollapsed));
211 
212  // Get the IAccessible for the root node.
213  IAccessible* native_view = root_node->GetNativeViewAccessible();
214  ASSERT_TRUE(native_view != nullptr);
215 
216  // Look up against the node itself (not one of its children).
217  VARIANT varchild = {};
218  varchild.vt = VT_I4;
219 
220  // Verify the submenu is collapsed.
221  varchild.lVal = CHILDID_SELF;
222  VARIANT native_state = {};
223  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
224  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_COLLAPSED);
225 
226  // Perform similar tests for UIA value;
227  IRawElementProviderSimple* uia_node;
228  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
229  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
230  UIA_ExpandCollapseExpandCollapseStatePropertyId, &native_state)));
231  EXPECT_EQ(native_state.lVal, ExpandCollapseState_Collapsed);
232 
233  ASSERT_TRUE(SUCCEEDED(uia_node->GetPropertyValue(
234  UIA_AriaPropertiesPropertyId, &native_state)));
235  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"expanded=false"), nullptr);
236  }
237 }

◆ TEST() [74/158]

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

Definition at line 1260 of file flutter_windows_view_unittests.cc.

1260  {
1261  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1262  EngineModifier modifier(engine.get());
1263  modifier.embedder_api().UpdateSemanticsEnabled =
1264  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
1265  return kSuccess;
1266  };
1267 
1268  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1269  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1270 
1271  // Enable semantics to instantiate accessibility bridge.
1272  view->OnUpdateSemanticsEnabled(true);
1273 
1274  auto bridge = view->accessibility_bridge().lock();
1275  ASSERT_TRUE(bridge);
1276 
1277  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
1278  root.id = 0;
1279  root.label = "root";
1280  root.hint = "";
1281  root.value = "";
1282  root.increased_value = "";
1283  root.decreased_value = "";
1284  root.child_count = 0;
1285  root.custom_accessibility_actions_count = 0;
1286  root.flags = static_cast<FlutterSemanticsFlag>(
1287  FlutterSemanticsFlag::kFlutterSemanticsFlagHasToggledState |
1288  FlutterSemanticsFlag::kFlutterSemanticsFlagIsToggled);
1289  bridge->AddFlutterSemanticsNodeUpdate(root);
1290 
1291  bridge->CommitUpdates();
1292 
1293  {
1294  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1295  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSwitch);
1296  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1297  ax::mojom::CheckedState::kTrue);
1298 
1299  // Get the IAccessible for the root node.
1300  IAccessible* native_view = root_node->GetNativeViewAccessible();
1301  ASSERT_TRUE(native_view != nullptr);
1302 
1303  // Look up against the node itself (not one of its children).
1304  VARIANT varchild = {};
1305  varchild.vt = VT_I4;
1306 
1307  varchild.lVal = CHILDID_SELF;
1308  VARIANT varrole = {};
1309 
1310  // Verify the role of the switch is CHECKBUTTON
1311  ASSERT_EQ(native_view->get_accRole(varchild, &varrole), S_OK);
1312  ASSERT_EQ(varrole.lVal, ROLE_SYSTEM_CHECKBUTTON);
1313 
1314  // Verify the switch is pressed.
1315  VARIANT native_state = {};
1316  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1317  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_PRESSED);
1318  EXPECT_TRUE(native_state.lVal & STATE_SYSTEM_CHECKED);
1319 
1320  // Test similarly on UIA node.
1321  IRawElementProviderSimple* uia_node;
1322  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1323  ASSERT_EQ(uia_node->GetPropertyValue(UIA_ControlTypePropertyId, &varrole),
1324  S_OK);
1325  EXPECT_EQ(varrole.lVal, UIA_ButtonControlTypeId);
1326  ASSERT_EQ(uia_node->GetPropertyValue(UIA_ToggleToggleStatePropertyId,
1327  &native_state),
1328  S_OK);
1329  EXPECT_EQ(native_state.lVal, ToggleState_On);
1330  ASSERT_EQ(
1331  uia_node->GetPropertyValue(UIA_AriaPropertiesPropertyId, &native_state),
1332  S_OK);
1333  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"pressed=true"), nullptr);
1334  }
1335 
1336  // Test unpressed too.
1337  root.flags = static_cast<FlutterSemanticsFlag>(
1338  FlutterSemanticsFlag::kFlutterSemanticsFlagHasToggledState);
1339  bridge->AddFlutterSemanticsNodeUpdate(root);
1340  bridge->CommitUpdates();
1341 
1342  {
1343  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1344  EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSwitch);
1345  EXPECT_EQ(root_node->GetData().GetCheckedState(),
1346  ax::mojom::CheckedState::kFalse);
1347 
1348  // Get the IAccessible for the root node.
1349  IAccessible* native_view = root_node->GetNativeViewAccessible();
1350  ASSERT_TRUE(native_view != nullptr);
1351 
1352  // Look up against the node itself (not one of its children).
1353  VARIANT varchild = {};
1354  varchild.vt = VT_I4;
1355 
1356  // Verify the switch is not pressed.
1357  varchild.lVal = CHILDID_SELF;
1358  VARIANT native_state = {};
1359  ASSERT_TRUE(SUCCEEDED(native_view->get_accState(varchild, &native_state)));
1360  EXPECT_FALSE(native_state.lVal & STATE_SYSTEM_PRESSED);
1361  EXPECT_FALSE(native_state.lVal & STATE_SYSTEM_CHECKED);
1362 
1363  // Test similarly on UIA node.
1364  IRawElementProviderSimple* uia_node;
1365  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1366  ASSERT_EQ(uia_node->GetPropertyValue(UIA_ToggleToggleStatePropertyId,
1367  &native_state),
1368  S_OK);
1369  EXPECT_EQ(native_state.lVal, ToggleState_Off);
1370  ASSERT_EQ(
1371  uia_node->GetPropertyValue(UIA_AriaPropertiesPropertyId, &native_state),
1372  S_OK);
1373  EXPECT_NE(std::wcsstr(native_state.bstrVal, L"pressed=false"), nullptr);
1374  }
1375 }

◆ TEST() [75/158]

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

Definition at line 917 of file flutter_windows_view_unittests.cc.

917  {
918  auto windows_proc_table = std::make_shared<NiceMock<MockWindowsProcTable>>();
919  std::unique_ptr<FlutterWindowsEngine> engine =
920  GetTestEngine(windows_proc_table);
921 
922  EngineModifier engine_modifier{engine.get()};
923  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
924  PostRenderThreadTask,
925  ([](auto engine, VoidCallback callback, void* user_data) {
927  return kSuccess;
928  }));
929 
930  auto egl_manager = std::make_unique<egl::MockManager>();
931  auto surface = std::make_unique<egl::MockWindowSurface>();
932  auto resized_surface = std::make_unique<egl::MockWindowSurface>();
933  auto resized_surface_ptr = resized_surface.get();
934 
935  EXPECT_CALL(*surface.get(), IsValid).WillRepeatedly(Return(true));
936  EXPECT_CALL(*surface.get(), Destroy).WillOnce(Return(true));
937 
938  EXPECT_CALL(*egl_manager.get(),
939  CreateWindowSurface(_, /*width=*/500, /*height=*/500))
940  .WillOnce(Return(std::move((resized_surface))));
941  EXPECT_CALL(*resized_surface_ptr, MakeCurrent).WillOnce(Return(true));
942  EXPECT_CALL(*resized_surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
943  EXPECT_CALL(*windows_proc_table.get(), DwmFlush).WillOnce(Return(S_OK));
944 
945  EXPECT_CALL(*resized_surface_ptr, Destroy).WillOnce(Return(true));
946 
947  fml::AutoResetWaitableEvent metrics_sent_latch;
948  engine_modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
949  SendWindowMetricsEvent,
950  ([&metrics_sent_latch](auto engine,
951  const FlutterWindowMetricsEvent* event) {
952  metrics_sent_latch.Signal();
953  return kSuccess;
954  }));
955 
956  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
957  std::make_unique<NiceMock<MockWindowBindingHandler>>());
958 
959  ViewModifier view_modifier{view.get()};
960  engine_modifier.SetEGLManager(std::move(egl_manager));
961  view_modifier.SetSurface(std::move(surface));
962 
963  fml::AutoResetWaitableEvent resized_latch;
964  std::thread([&resized_latch, &view]() {
965  // Start the window resize. This sends the new window metrics
966  // and then blocks until another thread completes the window resize.
967  EXPECT_TRUE(view->OnWindowSizeChanged(500, 500));
968  resized_latch.Signal();
969  }).detach();
970 
971  // Wait until the platform thread has started the window resize.
972  metrics_sent_latch.Wait();
973 
974  // Complete the window resize by reporting an empty frame.
975  view->OnEmptyFrameGenerated();
976  view->OnFramePresented();
977  resized_latch.Wait();
978 }

References callback, and user_data.

◆ TEST() [76/158]

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

Definition at line 1377 of file flutter_windows_view_unittests.cc.

1377  {
1378  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1379  EngineModifier modifier(engine.get());
1380  modifier.embedder_api().UpdateSemanticsEnabled =
1381  [](FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) {
1382  return kSuccess;
1383  };
1384 
1385  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1386  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1387 
1388  // Enable semantics to instantiate accessibility bridge.
1389  view->OnUpdateSemanticsEnabled(true);
1390 
1391  auto bridge = view->accessibility_bridge().lock();
1392  ASSERT_TRUE(bridge);
1393 
1394  FlutterSemanticsNode2 root{sizeof(FlutterSemanticsNode2), 0};
1395  root.id = 0;
1396  root.label = "root";
1397  root.hint = "";
1398  root.value = "";
1399  root.increased_value = "";
1400  root.decreased_value = "";
1401  root.tooltip = "tooltip";
1402  root.child_count = 0;
1403  root.custom_accessibility_actions_count = 0;
1404  root.flags = static_cast<FlutterSemanticsFlag>(
1405  FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField);
1406  bridge->AddFlutterSemanticsNodeUpdate(root);
1407 
1408  bridge->CommitUpdates();
1409  auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1410  std::string tooltip = root_node->GetData().GetStringAttribute(
1411  ax::mojom::StringAttribute::kTooltip);
1412  EXPECT_EQ(tooltip, "tooltip");
1413 
1414  // Check that MSAA name contains the tooltip.
1415  IAccessible* native_view = bridge->GetFlutterPlatformNodeDelegateFromID(0)
1416  .lock()
1417  ->GetNativeViewAccessible();
1418  VARIANT varchild = {.vt = VT_I4, .lVal = CHILDID_SELF};
1419  BSTR bname;
1420  ASSERT_EQ(native_view->get_accName(varchild, &bname), S_OK);
1421  EXPECT_NE(std::wcsstr(bname, L"tooltip"), nullptr);
1422 
1423  // Check that UIA help text is equal to the tooltip.
1424  IRawElementProviderSimple* uia_node;
1425  native_view->QueryInterface(IID_PPV_ARGS(&uia_node));
1426  VARIANT varname{};
1427  ASSERT_EQ(uia_node->GetPropertyValue(UIA_HelpTextPropertyId, &varname), S_OK);
1428  std::string uia_tooltip = _com_util::ConvertBSTRToString(varname.bstrVal);
1429  EXPECT_EQ(uia_tooltip, "tooltip");
1430 }

◆ TEST() [77/158]

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

Definition at line 1595 of file flutter_windows_view_unittests.cc.

1595  {
1596  auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
1597  auto engine = std::make_unique<MockFlutterWindowsEngine>(windows_proc_table);
1598  auto egl_manager = std::make_unique<egl::MockManager>();
1599  egl::MockContext render_context;
1600  auto surface = std::make_unique<egl::MockWindowSurface>();
1601  auto surface_ptr = surface.get();
1602 
1603  EXPECT_CALL(*engine.get(), running).WillRepeatedly(Return(true));
1604 
1605  EXPECT_CALL(*engine.get(), PostRasterThreadTask)
1606  .WillRepeatedly([](fml::closure callback) {
1607  callback();
1608  return true;
1609  });
1610 
1611  EXPECT_CALL(*egl_manager.get(), render_context)
1612  .WillRepeatedly(Return(&render_context));
1613 
1614  EXPECT_CALL(*surface_ptr, IsValid).WillRepeatedly(Return(true));
1615  EXPECT_CALL(*surface_ptr, MakeCurrent).WillRepeatedly(Return(true));
1616  EXPECT_CALL(*surface_ptr, Destroy).Times(1);
1617  EXPECT_CALL(render_context, ClearCurrent).WillRepeatedly(Return(true));
1618 
1619  InSequence s;
1620 
1621  // Mock render surface initialization.
1622  std::unique_ptr<FlutterWindowsView> view;
1623  {
1624  EXPECT_CALL(*egl_manager, CreateWindowSurface)
1625  .WillOnce(Return(std::move(surface)));
1626  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1627  .WillOnce(Return(true));
1628  EXPECT_CALL(*surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
1629 
1630  EngineModifier engine_modifier{engine.get()};
1631  engine_modifier.SetEGLManager(std::move(egl_manager));
1632 
1633  view = engine->CreateView(
1634  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1635  }
1636 
1637  // Disabling DWM composition should enable vsync blocking on the surface.
1638  {
1639  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1640  .WillOnce(Return(false));
1641  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(true)).WillOnce(Return(true));
1642 
1643  engine->OnDwmCompositionChanged();
1644  }
1645 
1646  // Enabling DWM composition should disable vsync blocking on the surface.
1647  {
1648  EXPECT_CALL(*windows_proc_table.get(), DwmIsCompositionEnabled)
1649  .WillOnce(Return(true));
1650  EXPECT_CALL(*surface_ptr, SetVSyncEnabled(false)).WillOnce(Return(true));
1651 
1652  engine->OnDwmCompositionChanged();
1653  }
1654 }

References callback.

◆ TEST() [78/158]

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

Definition at line 1092 of file flutter_windows_view_unittests.cc.

1092  {
1093  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1094  EngineModifier modifier(engine.get());
1095 
1096  FlutterWindowsView view{kImplicitViewId, engine.get(),
1097  std::make_unique<flutter::FlutterWindow>(100, 100)};
1098 
1099  bool schedule_frame_called = false;
1100  modifier.embedder_api().ScheduleFrame =
1101  MOCK_ENGINE_PROC(ScheduleFrame, ([&schedule_frame_called](auto engine) {
1102  schedule_frame_called = true;
1103  return kSuccess;
1104  }));
1105 
1106  view.OnWindowRepaint();
1107  EXPECT_TRUE(schedule_frame_called);
1108 }

References flutter::kImplicitViewId.

◆ TEST() [79/158]

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

Definition at line 1030 of file flutter_windows_view_unittests.cc.

1030  {
1031  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1032 
1033  EngineModifier engine_modifier(engine.get());
1034  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
1035  PostRenderThreadTask,
1036  ([](auto engine, VoidCallback callback, void* user_data) {
1038  return kSuccess;
1039  }));
1040 
1041  auto egl_manager = std::make_unique<egl::MockManager>();
1042  auto surface = std::make_unique<egl::MockWindowSurface>();
1043 
1044  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface).Times(0);
1045  EXPECT_CALL(*surface.get(), IsValid).WillRepeatedly(Return(false));
1046  EXPECT_CALL(*surface.get(), Destroy).WillOnce(Return(false));
1047 
1048  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1049  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1050 
1051  ViewModifier view_modifier{view.get()};
1052  engine_modifier.SetEGLManager(std::move(egl_manager));
1053  view_modifier.SetSurface(std::move(surface));
1054 
1055  auto metrics_sent = false;
1056  engine_modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1057  SendWindowMetricsEvent,
1058  ([&metrics_sent](auto engine, const FlutterWindowMetricsEvent* event) {
1059  metrics_sent = true;
1060  return kSuccess;
1061  }));
1062 
1063  view->OnWindowSizeChanged(500, 500);
1064 }

References callback, and user_data.

◆ TEST() [80/158]

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

Definition at line 983 of file flutter_windows_view_unittests.cc.

983  {
984  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
985 
986  EngineModifier engine_modifier(engine.get());
987  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
988  PostRenderThreadTask,
989  ([](auto engine, VoidCallback callback, void* user_data) {
991  return kSuccess;
992  }));
993 
994  auto egl_manager = std::make_unique<egl::MockManager>();
995  auto surface = std::make_unique<egl::MockWindowSurface>();
996 
997  EXPECT_CALL(*surface.get(), IsValid).WillRepeatedly(Return(true));
998  EXPECT_CALL(*surface.get(), Destroy).WillOnce(Return(true));
999 
1000  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1001  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1002 
1003  ViewModifier view_modifier{view.get()};
1004  engine_modifier.SetEGLManager(std::move(egl_manager));
1005  view_modifier.SetSurface(std::move(surface));
1006 
1007  // Begin a frame.
1008  ASSERT_TRUE(view->OnFrameGenerated(100, 100));
1009 
1010  // Inject a window resize between the frame generation and
1011  // frame presentation. The new size invalidates the current frame.
1012  fml::AutoResetWaitableEvent resized_latch;
1013  std::thread([&resized_latch, &view]() {
1014  // The resize is never completed. The view times out and returns false.
1015  EXPECT_FALSE(view->OnWindowSizeChanged(500, 500));
1016  resized_latch.Signal();
1017  }).detach();
1018 
1019  // Wait until the platform thread has started the window resize.
1020  resized_latch.Wait();
1021 
1022  // Complete the invalidated frame while a resize is pending. Although this
1023  // might mean that we presented a frame with the wrong size, this should not
1024  // crash the app.
1025  view->OnFramePresented();
1026 }

References callback, and user_data.

◆ TEST() [81/158]

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

Definition at line 844 of file flutter_windows_view_unittests.cc.

844  {
845  auto windows_proc_table = std::make_shared<NiceMock<MockWindowsProcTable>>();
846  std::unique_ptr<FlutterWindowsEngine> engine =
847  GetTestEngine(windows_proc_table);
848 
849  EngineModifier engine_modifier{engine.get()};
850  engine_modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
851  PostRenderThreadTask,
852  ([](auto engine, VoidCallback callback, void* user_data) {
854  return kSuccess;
855  }));
856 
857  auto egl_manager = std::make_unique<egl::MockManager>();
858  auto surface = std::make_unique<egl::MockWindowSurface>();
859  auto resized_surface = std::make_unique<egl::MockWindowSurface>();
860  egl::MockContext render_context;
861 
862  auto surface_ptr = surface.get();
863  auto resized_surface_ptr = resized_surface.get();
864 
865  // Mock render surface creation
866  EXPECT_CALL(*egl_manager, CreateWindowSurface)
867  .WillOnce(Return(std::move(surface)));
868  EXPECT_CALL(*surface_ptr, IsValid).WillRepeatedly(Return(true));
869  EXPECT_CALL(*surface_ptr, MakeCurrent).WillOnce(Return(true));
870  EXPECT_CALL(*surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
871  EXPECT_CALL(*egl_manager, render_context).WillOnce(Return(&render_context));
872  EXPECT_CALL(render_context, ClearCurrent).WillOnce(Return(true));
873 
874  // Mock render surface resize
875  EXPECT_CALL(*surface_ptr, Destroy).WillOnce(Return(true));
876  EXPECT_CALL(*egl_manager.get(),
877  CreateWindowSurface(_, /*width=*/500, /*height=*/500))
878  .WillOnce(Return(std::move((resized_surface))));
879  EXPECT_CALL(*resized_surface_ptr, MakeCurrent).WillOnce(Return(true));
880  EXPECT_CALL(*resized_surface_ptr, SetVSyncEnabled).WillOnce(Return(true));
881  EXPECT_CALL(*windows_proc_table.get(), DwmFlush).WillOnce(Return(S_OK));
882 
883  EXPECT_CALL(*resized_surface_ptr, Destroy).WillOnce(Return(true));
884 
885  engine_modifier.SetEGLManager(std::move(egl_manager));
886 
887  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
888  std::make_unique<NiceMock<MockWindowBindingHandler>>());
889 
890  fml::AutoResetWaitableEvent metrics_sent_latch;
891  engine_modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
892  SendWindowMetricsEvent,
893  ([&metrics_sent_latch](auto engine,
894  const FlutterWindowMetricsEvent* event) {
895  metrics_sent_latch.Signal();
896  return kSuccess;
897  }));
898 
899  fml::AutoResetWaitableEvent resized_latch;
900  std::thread([&resized_latch, &view]() {
901  // Start the window resize. This sends the new window metrics
902  // and then blocks until another thread completes the window resize.
903  EXPECT_TRUE(view->OnWindowSizeChanged(500, 500));
904  resized_latch.Signal();
905  }).detach();
906 
907  // Wait until the platform thread has started the window resize.
908  metrics_sent_latch.Wait();
909 
910  // Complete the window resize by reporting a frame with the new window size.
911  ASSERT_TRUE(view->OnFrameGenerated(500, 500));
912  view->OnFramePresented();
913  resized_latch.Wait();
914 }

References callback, and user_data.

◆ TEST() [82/158]

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

Definition at line 1068 of file flutter_windows_view_unittests.cc.

1068  {
1069  std::unique_ptr<FlutterWindowsEngine> engine = GetTestEngine();
1070  EngineModifier modifier(engine.get());
1071 
1072  auto egl_manager = std::make_unique<egl::MockManager>();
1073 
1074  EXPECT_CALL(*egl_manager.get(), CreateWindowSurface).Times(0);
1075 
1076  std::unique_ptr<FlutterWindowsView> view = engine->CreateView(
1077  std::make_unique<NiceMock<MockWindowBindingHandler>>());
1078 
1079  modifier.SetEGLManager(std::move(egl_manager));
1080 
1081  auto metrics_sent = false;
1082  modifier.embedder_api().SendWindowMetricsEvent = MOCK_ENGINE_PROC(
1083  SendWindowMetricsEvent,
1084  ([&metrics_sent](auto engine, const FlutterWindowMetricsEvent* event) {
1085  metrics_sent = true;
1086  return kSuccess;
1087  }));
1088 
1089  view->OnWindowSizeChanged(500, 500);
1090 }

◆ TEST() [83/158]

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 }

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

◆ TEST() [84/158]

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

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

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

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

Definition at line 764 of file keyboard_key_embedder_handler_unittests.cc.

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

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [88/158]

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

Definition at line 818 of file keyboard_key_embedder_handler_unittests.cc.

818  {
819  TestKeystate key_state;
820  std::vector<TestFlutterKeyEvent> results;
821  TestFlutterKeyEvent* event;
822  bool last_handled = false;
823 
824  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
825  std::make_unique<KeyboardKeyEmbedderHandler>(
826  [&results](const FlutterKeyEvent& event,
827  FlutterKeyEventCallback callback, void* user_data) {
828  results.emplace_back(event, callback, user_data);
829  },
830  key_state.Getter(), DefaultMapVkToScan);
831  last_handled = false;
832 
833  // KeyA's key down is missed.
834 
835  key_state.Set(kVirtualKeyA, true);
836 
837  // Press A again (should yield an empty event)
838  last_handled = false;
839  handler->KeyboardHook(
840  kVirtualKeyA, kScanCodeKeyA, WM_KEYUP, 'a', false, true,
841  [&last_handled](bool handled) { last_handled = handled; });
842  EXPECT_EQ(last_handled, true);
843  EXPECT_EQ(results.size(), 1);
844  event = &results[0];
845  EXPECT_EQ(event->physical, 0);
846  EXPECT_EQ(event->logical, 0);
847  EXPECT_EQ(event->callback, nullptr);
848  results.clear();
849 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [89/158]

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

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 }

References flutter::ConvertChar32ToUtf8().

◆ TEST() [91/158]

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 }

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

◆ TEST() [92/158]

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

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

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

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

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 yield an empty event)
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, true);
756  EXPECT_EQ(results.size(), 1);
757  event = &results[0];
758  EXPECT_EQ(event->physical, 0);
759  EXPECT_EQ(event->logical, 0);
760  EXPECT_EQ(event->callback, nullptr);
761  results.clear();
762 }

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [97/158]

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

Definition at line 851 of file keyboard_key_embedder_handler_unittests.cc.

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

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [98/158]

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

Definition at line 939 of file keyboard_key_embedder_handler_unittests.cc.

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

References callback, kScanCodeKeyA, kVirtualKeyA, and user_data.

◆ TEST() [99/158]

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

Definition at line 1119 of file keyboard_key_embedder_handler_unittests.cc.

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

References callback, and user_data.

◆ TEST() [100/158]

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

Definition at line 1059 of file keyboard_key_embedder_handler_unittests.cc.

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

References callback, and user_data.

◆ TEST() [101/158]

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

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

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

Definition at line 1177 of file keyboard_key_embedder_handler_unittests.cc.

1177  {
1178  TestKeystate key_state;
1179  std::vector<TestFlutterKeyEvent> results;
1180  TestFlutterKeyEvent* event;
1181  bool last_handled = false;
1182 
1183  // The app starts with NumLock toggled on
1184  key_state.Set(VK_NUMLOCK, false, true);
1185 
1186  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
1187  std::make_unique<KeyboardKeyEmbedderHandler>(
1188  [&results](const FlutterKeyEvent& event,
1189  FlutterKeyEventCallback callback, void* user_data) {
1190  results.emplace_back(event, callback, user_data);
1191  },
1192  key_state.Getter(), DefaultMapVkToScan);
1193 
1194  // NumLock key down
1195  key_state.Set(VK_NUMLOCK, true, false);
1196  handler->KeyboardHook(
1197  VK_NUMLOCK, kScanCodeNumLock, WM_KEYDOWN, 0, true, false,
1198  [&last_handled](bool handled) { last_handled = handled; });
1199  EXPECT_EQ(last_handled, false);
1200  EXPECT_EQ(results.size(), 1);
1201  event = &results[0];
1202  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1203  EXPECT_EQ(event->physical, kPhysicalNumLock);
1204  EXPECT_EQ(event->logical, kLogicalNumLock);
1205  EXPECT_STREQ(event->character, "");
1206  EXPECT_EQ(event->synthesized, false);
1207 
1208  event->callback(true, event->user_data);
1209  EXPECT_EQ(last_handled, true);
1210  results.clear();
1211 }

References callback, and user_data.

◆ TEST() [104/158]

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

Definition at line 1213 of file keyboard_key_embedder_handler_unittests.cc.

1213  {
1214  TestKeystate key_state;
1215  std::vector<TestFlutterKeyEvent> results;
1216  TestFlutterKeyEvent* event;
1217  bool last_handled = false;
1218 
1219  std::unique_ptr<KeyboardKeyEmbedderHandler> handler =
1220  std::make_unique<KeyboardKeyEmbedderHandler>(
1221  [&results](const FlutterKeyEvent& event,
1222  FlutterKeyEventCallback callback, void* user_data) {
1223  results.emplace_back(event, callback, user_data);
1224  },
1225  key_state.Getter(), DefaultMapVkToScan);
1226 
1227  // Press KeyAltLeft.
1228  key_state.Set(VK_LMENU, true);
1229  handler->KeyboardHook(
1230  VK_LMENU, kScanCodeAltLeft, WM_SYSKEYDOWN, 0, false, false,
1231  [&last_handled](bool handled) { last_handled = handled; });
1232  EXPECT_EQ(last_handled, false);
1233  EXPECT_EQ(results.size(), 1);
1234  event = results.data();
1235  EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1236  EXPECT_EQ(event->physical, kPhysicalAltLeft);
1237  EXPECT_EQ(event->logical, kLogicalAltLeft);
1238  EXPECT_STREQ(event->character, "");
1239  EXPECT_EQ(event->synthesized, false);
1240 
1241  event->callback(true, event->user_data);
1242  EXPECT_EQ(last_handled, true);
1243  results.clear();
1244 
1245  // Release KeyAltLeft.
1246  key_state.Set(VK_LMENU, false);
1247  handler->KeyboardHook(
1248  VK_LMENU, kScanCodeAltLeft, WM_SYSKEYUP, 0, false, true,
1249  [&last_handled](bool handled) { last_handled = handled; });
1250  EXPECT_EQ(results.size(), 1);
1251  event = results.data();
1252  EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1253  EXPECT_EQ(event->physical, kPhysicalAltLeft);
1254  EXPECT_EQ(event->logical, kLogicalAltLeft);
1255  EXPECT_STREQ(event->character, "");
1256  EXPECT_EQ(event->synthesized, false);
1257  event->callback(false, event->user_data);
1258 }

References callback, and user_data.

◆ TEST() [105/158]

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

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 }

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

◆ TEST() [107/158]

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

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 }

References hook_history, and message.

◆ TEST() [109/158]

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

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 }

References flutter::EncodeUtf16().

◆ TEST() [111/158]

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

Definition at line 23 of file window_unittests.cc.

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

◆ TEST() [112/158]

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

Definition at line 364 of file window_unittests.cc.

364  {
365  MockWindow window;
366  bool uia_called = false;
367  ON_CALL(window, OnGetObject)
368  .WillByDefault(Invoke([&uia_called](UINT msg, WPARAM wpar, LPARAM lpar) {
369 #ifdef FLUTTER_ENGINE_USE_UIA
370  uia_called = true;
371 #endif // FLUTTER_ENGINE_USE_UIA
372  return static_cast<LRESULT>(0);
373  }));
374  EXPECT_CALL(window, OnGetObject).Times(1);
375 
376  window.InjectWindowMessage(WM_GETOBJECT, 0, UiaRootObjectId);
377 
378  EXPECT_TRUE(uia_called);
379 }

◆ TEST() [113/158]

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

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

Definition at line 152 of file window_unittests.cc.

152  {
153  MockWindow window;
154  const int scroll_amount = 10;
155  // Vertical scroll should be passed along, adjusted for scroll tick size.
156  EXPECT_CALL(window, OnScroll(scroll_amount / 120.0, 0,
157  kFlutterPointerDeviceKindMouse, 0))
158  .Times(1);
159 
160  window.InjectWindowMessage(WM_MOUSEHWHEEL, MAKEWPARAM(0, scroll_amount), 0);
161 }

◆ TEST() [115/158]

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

Definition at line 179 of file window_unittests.cc.

179  {
180  MockWindow window;
181  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
182  LPARAM lparam = CreateKeyEventLparam(42, false, false);
183  // send a "Shift" key down event.
184  window.InjectWindowMessage(WM_KEYDOWN, 16, lparam);
185 }

◆ TEST() [116/158]

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

Definition at line 211 of file window_unittests.cc.

211  {
212  MockWindow window;
213  LPARAM lparam = CreateKeyEventLparam(30, false, false);
214 
215  auto respond_false = [](int key, int scancode, int action, char32_t character,
216  bool extended, bool was_down,
217  std::function<void(bool)> callback) {
218  callback(false);
219  };
220  EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 0, false, false, _))
221  .Times(1)
222  .WillOnce(respond_false);
223  EXPECT_CALL(window, OnText(_)).Times(1);
224  std::array<Win32Message, 2> messages = {
225  Win32Message{WM_KEYDOWN, 65, lparam, kWmResultDontCheck},
226  Win32Message{WM_CHAR, 65, lparam, kWmResultDontCheck}};
227  window.InjectMessageList(2, messages.data());
228 }

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

◆ TEST() [117/158]

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

Definition at line 230 of file window_unittests.cc.

230  {
231  MockWindow window;
232 
233  // Simulate CONTROL pressed
234  std::array<BYTE, 256> keyboard_state;
235  keyboard_state[VK_CONTROL] = -1;
236  SetKeyboardState(keyboard_state.data());
237 
238  LPARAM lparam = CreateKeyEventLparam(30, false, false);
239 
240  // Expect OnKey, but not OnText, because Control + Key is not followed by
241  // WM_CHAR
242  EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 0, false, false, _)).Times(1);
243  EXPECT_CALL(window, OnText(_)).Times(0);
244 
245  window.InjectWindowMessage(WM_KEYDOWN, 65, lparam);
246 
247  keyboard_state.fill(0);
248  SetKeyboardState(keyboard_state.data());
249 }

◆ TEST() [118/158]

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

Definition at line 251 of file window_unittests.cc.

251  {
252  MockWindow window;
253 
254  auto respond_false = [](int key, int scancode, int action, char32_t character,
255  bool extended, bool was_down,
256  std::function<void(bool)> callback) {
257  callback(false);
258  };
259 
260  // Simulate CONTROL toggled
261  std::array<BYTE, 256> keyboard_state;
262  keyboard_state[VK_CONTROL] = 1;
263  SetKeyboardState(keyboard_state.data());
264 
265  LPARAM lparam = CreateKeyEventLparam(30, false, false);
266 
267  EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 0, false, false, _))
268  .Times(1)
269  .WillOnce(respond_false);
270  EXPECT_CALL(window, OnText(_)).Times(1);
271 
272  // send a "A" key down event.
273  Win32Message messages[] = {{WM_KEYDOWN, 65, lparam, kWmResultDontCheck},
274  {WM_CHAR, 65, lparam, kWmResultDontCheck}};
275  window.InjectMessageList(2, messages);
276 
277  keyboard_state.fill(0);
278  SetKeyboardState(keyboard_state.data());
279 }

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

◆ TEST() [119/158]

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

Definition at line 187 of file window_unittests.cc.

187  {
188  MockWindow window;
189  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
190  LPARAM lparam = CreateKeyEventLparam(42, false, true);
191  // send a "Shift" key up event.
192  window.InjectWindowMessage(WM_KEYUP, 16, lparam);
193 }

◆ TEST() [120/158]

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

Definition at line 163 of file window_unittests.cc.

163  {
164  MockWindow window;
165  const double mouse_x = 10.0;
166  const double mouse_y = 20.0;
167 
168  EXPECT_CALL(window, OnPointerMove(mouse_x, mouse_y,
169  kFlutterPointerDeviceKindMouse, 0, 0))
170  .Times(1);
171  EXPECT_CALL(window, OnPointerLeave(mouse_x, mouse_y,
172  kFlutterPointerDeviceKindMouse, 0))
173  .Times(1);
174 
175  window.InjectWindowMessage(WM_MOUSEMOVE, 0, MAKELPARAM(mouse_x, mouse_y));
176  window.InjectWindowMessage(WM_MOUSELEAVE, 0, 0);
177 }

◆ TEST() [121/158]

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

Definition at line 135 of file window_unittests.cc.

135  {
136  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
137  auto* text_input_manager = new MockTextInputManager();
138  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
139  MockWindow window(std::move(windows_proc_table),
140  std::move(text_input_manager_ptr));
141  EXPECT_CALL(window, OnComposeChange(std::u16string(u""), 0)).Times(1);
142  EXPECT_CALL(window, OnComposeCommit()).Times(1);
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, 0);
150 }

◆ TEST() [122/158]

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())
58  .WillRepeatedly(Return((int)0));
59 
60  EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 0)).Times(1);
61  EXPECT_CALL(window, OnComposeChange(std::u16string(u"`}"), 0)).Times(0);
62  EXPECT_CALL(window, OnComposeCommit()).Times(0);
63  ON_CALL(window, OnImeComposition)
64  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
65  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
66 
67  // Send an IME_COMPOSITION event that contains just the composition string.
68  window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_COMPSTR);
69 }

◆ TEST() [123/158]

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

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"nihao"))));
80  EXPECT_CALL(*text_input_manager, GetResultString())
81  .WillRepeatedly(
82  Return(std::optional<std::u16string>(std::u16string(u"`}"))));
83  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
84  .WillRepeatedly(Return((int)0));
85 
86  EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 0)).Times(0);
87  EXPECT_CALL(window, OnComposeChange(std::u16string(u"`}"), 0)).Times(1);
88  EXPECT_CALL(window, OnComposeCommit()).Times(1);
89  ON_CALL(window, OnImeComposition)
90  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
91  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
92 
93  // Send an IME_COMPOSITION event that contains just the result string.
94  window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
95 }

◆ TEST() [124/158]

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

Definition at line 97 of file window_unittests.cc.

97  {
98  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
99  auto* text_input_manager = new MockTextInputManager();
100  std::unique_ptr<TextInputManager> text_input_manager_ptr(text_input_manager);
101  MockWindow window(std::move(windows_proc_table),
102  std::move(text_input_manager_ptr));
103 
104  // This situation is that Google Japanese Input finished composing "今日" in
105  // "今日は" but is still composing "は".
106  {
107  InSequence dummy;
108  EXPECT_CALL(*text_input_manager, GetResultString())
109  .WillRepeatedly(
110  Return(std::optional<std::u16string>(std::u16string(u"今日"))));
111  EXPECT_CALL(*text_input_manager, GetComposingString())
112  .WillRepeatedly(
113  Return(std::optional<std::u16string>(std::u16string(u"は"))));
114  }
115  {
116  InSequence dummy;
117  EXPECT_CALL(window, OnComposeChange(std::u16string(u"今日"), 0)).Times(1);
118  EXPECT_CALL(window, OnComposeCommit()).Times(1);
119  EXPECT_CALL(window, OnComposeChange(std::u16string(u"は"), 0)).Times(1);
120  }
121 
122  EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
123  .WillRepeatedly(Return((int)0));
124 
125  ON_CALL(window, OnImeComposition)
126  .WillByDefault(Invoke(&window, &MockWindow::CallOnImeComposition));
127  EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
128 
129  // send an IME_COMPOSITION event that contains both the result string and the
130  // composition string.
131  window.InjectWindowMessage(WM_IME_COMPOSITION, 0,
132  GCS_COMPSTR | GCS_RESULTSTR);
133 }

◆ TEST() [125/158]

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

Definition at line 281 of file window_unittests.cc.

281  {
282  MockWindow window;
283  EXPECT_CALL(window, OnPaint()).Times(1);
284  window.InjectWindowMessage(WM_PAINT, 0, 0);
285 }

◆ TEST() [126/158]

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

Definition at line 288 of file window_unittests.cc.

288  {
289  UINT32 pointer_id = 123;
290  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
291  auto text_input_manager = std::make_unique<MockTextInputManager>();
292 
293  EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
294  .Times(1)
295  .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE* type) {
296  *type = PT_POINTER;
297  return TRUE;
298  });
299 
300  MockWindow window(std::move(windows_proc_table),
301  std::move(text_input_manager));
302 
303  auto direct_manipulation =
304  std::make_unique<MockDirectManipulationOwner>(&window);
305 
306  EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
307 
308  window.SetDirectManipulationOwner(std::move(direct_manipulation));
309  window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
310 }

References type.

◆ TEST() [127/158]

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

Definition at line 195 of file window_unittests.cc.

195  {
196  MockWindow window;
197  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
198  LPARAM lparam = CreateKeyEventLparam(42, false, false);
199  // send a "Shift" key down event.
200  window.InjectWindowMessage(WM_SYSKEYDOWN, 16, lparam);
201 }

◆ TEST() [128/158]

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

Definition at line 203 of file window_unittests.cc.

203  {
204  MockWindow window;
205  EXPECT_CALL(window, OnKey(_, _, _, _, _, _, _)).Times(1);
206  LPARAM lparam = CreateKeyEventLparam(42, false, true);
207  // send a "Shift" key up event.
208  window.InjectWindowMessage(WM_SYSKEYUP, 16, lparam);
209 }

◆ TEST() [129/158]

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

Definition at line 313 of file window_unittests.cc.

313  {
314  UINT32 pointer_id = 123;
315  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
316  auto text_input_manager = std::make_unique<MockTextInputManager>();
317 
318  EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
319  .Times(1)
320  .WillOnce([](UINT32 pointer_id, POINTER_INPUT_TYPE* type) {
321  *type = PT_TOUCHPAD;
322  return TRUE;
323  });
324 
325  MockWindow window(std::move(windows_proc_table),
326  std::move(text_input_manager));
327 
328  auto direct_manipulation =
329  std::make_unique<MockDirectManipulationOwner>(&window);
330 
331  EXPECT_CALL(*direct_manipulation, SetContact(Eq(pointer_id))).Times(1);
332 
333  window.SetDirectManipulationOwner(std::move(direct_manipulation));
334  window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
335 }

References type.

◆ TEST() [130/158]

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

Definition at line 341 of file window_unittests.cc.

341  {
342  UINT32 pointer_id = 123;
343  auto windows_proc_table = std::make_unique<MockWindowsProcTable>();
344  auto text_input_manager = std::make_unique<MockTextInputManager>();
345 
346  EXPECT_CALL(*windows_proc_table, GetPointerType(Eq(pointer_id), _))
347  .Times(1)
348  .WillOnce(
349  [](UINT32 pointer_id, POINTER_INPUT_TYPE* type) { return FALSE; });
350 
351  MockWindow window(std::move(windows_proc_table),
352  std::move(text_input_manager));
353 
354  auto direct_manipulation =
355  std::make_unique<MockDirectManipulationOwner>(&window);
356 
357  EXPECT_CALL(*direct_manipulation, SetContact).Times(0);
358 
359  window.SetDirectManipulationOwner(std::move(direct_manipulation));
360  window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
361 }

References type.

◆ TEST() [131/158]

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

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

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

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, <