Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
flutter::testing Namespace Reference

Namespaces

namespace  android
 
namespace  egl
 
namespace  keycodes
 

Classes

struct  AOTDataDeleter
 
class  AutoIsolateShutdown
 
class  AutoreleasePoolTest
 
class  AutoreleasePoolTestMixin
 
class  BoundsTolerance
 
class  CanvasCompareTester
 
class  CanvasTestBase
 
class  CaseParameters
 
class  ConstantFiringVsyncWaiter
 
class  CursorHandlerTest
 
class  DartFixture
 
class  DartIsolateTest
 
class  DartNativeBenchmarks
 
class  DartPersistentHandleTest
 
class  DartSecondaryIsolateTest
 
class  DartWeakPersistentHandle
 
class  DarwinContextMetal
 
class  DepthExpector
 
class  DiffContextTest
 
struct  DisplayListInvocation
 
struct  DisplayListInvocationGroup
 
struct  DisplayListJobRenderer
 
class  DisplayListNopTest
 
class  DisplayListRenderingTestBase
 
class  DisplayListStreamDispatcher
 
class  DisplayListTestBase
 
struct  DlJobRenderer
 
class  DlMetalPixelData
 
class  DlMetalSurfaceInstance
 
class  DlMetalSurfaceProvider
 
class  DlOpenGLSurfaceProvider
 
class  DlOpRecorder
 A custom |DlOpReceiver| that records some |DlOps| it receives. More...
 
class  DlPixelData
 
class  DlSoftwareSurfaceProvider
 
class  DlSurfaceInstance
 
class  DlSurfaceInstanceBase
 
class  DlSurfaceProvider
 
struct  ELFAOTSymbols
 
class  EmbedderConfigBuilder
 
class  EmbedderTest
 
class  EmbedderTestBackingStoreProducer
 
class  EmbedderTestCompositor
 
class  EmbedderTestCompositorGL
 
class  EmbedderTestCompositorMetal
 
class  EmbedderTestCompositorSoftware
 
class  EmbedderTestCompositorVulkan
 
class  EmbedderTestContext
 
class  EmbedderTestContextGL
 
class  EmbedderTestContextMetal
 
class  EmbedderTestContextSoftware
 
class  EmbedderTestContextVulkan
 
class  EmbedderTestMultiBackend
 
class  EmbedderTestTaskRunner
 A task runner that we expect the embedder to provide but whose implementation is a real FML task runner. More...
 
struct  EngineDeleter
 
class  FakeAnimatorDelegate
 
class  FakeImageGenerator
 
class  FakePlatformConfigurationClient
 
class  FakeRefreshRateUpdater
 
class  FfiNativeTest
 
class  FixtureTest
 
class  FlutterEngineTest
 
class  FlutterMenuPluginTest
 
class  FlutterWindowsEngineBuilder
 
class  FlutterWindowsEngineTest
 
struct  FrozenFlutterDamage
 
struct  FrozenFlutterPoint
 
struct  FrozenFlutterRect
 
struct  FrozenFlutterSemanticsCustomAction
 
struct  FrozenFlutterSemanticsNode
 
struct  FrozenFlutterTransformation
 
class  FuchsiaShellTest
 
class  ImageDisposeTest
 
class  ImpellerRenderResult
 
struct  IsolateData
 
class  IsolateStartupFailureTest
 Tests error handling path of Isolate.spawn() in the engine. More...
 
struct  JobRenderer
 
struct  KeyEventUserData
 
class  LayerTestBase
 
class  LayerTreeTest
 
struct  LoadedELFDeleter
 
class  LoggerListener
 
struct  MatrixClipJobRenderer
 
class  MockAccessibilityBridge
 
class  MockAccessibilityBridgeNoWindow
 
class  MockAPKAssetProviderImpl
 
class  MockBinaryMessenger
 
class  MockCacheableContainerLayer
 
class  MockCacheableLayer
 
class  MockCanvas
 
class  MockDirectManipulationOwner
 Mock for the |DirectManipulationOwner| base class. More...
 
class  MockDispatchHelper
 
class  MockFlutterEngineTest
 
class  MockFlutterWindowsView
 
class  MockIDirectManipulationContent
 
class  MockIDirectManipulationViewport
 
class  MockIMContext
 
class  MockKeyResponseController
 
class  MockLayer
 
class  MockLayerCacheableItem
 
class  MockLayerTree
 
class  MockMessageQueue
 
class  MockRasterCache
 A RasterCache implementation that simulates the act of rendering a Layer or DisplayList without the overhead of rasterization or pixel storage. This implementation is used only for testing proper usage of the RasterCache in layer unit tests. More...
 
class  MockRasterCacheResult
 A RasterCacheResult implementation that represents a cached Layer or DisplayList without the overhead of storage. More...
 
class  MockSettings
 
class  MockSignalHandler
 
class  MockSignalHandler1
 
class  MockSignalHandler2
 
class  MockSyncSwitch
 
class  MockTextInputManager
 Mock for the |Window| base class. More...
 
class  MockTextInputViewDelegate
 
class  MockTexture
 
class  MockViewEmbedder
 
class  MockWindow
 Mock for the |FlutterWindow| base class. More...
 
class  MockWindowBindingHandler
 Mock for the |Window| base class. More...
 
class  MockWindowBindingHandlerDelegate
 
class  MockWindowsLifecycleManager
 
class  MockWindowsProcTable
 Mock for the |WindowsProcTable| base class. More...
 
class  MyNativeClass
 
class  OncePerBackendWarning
 
struct  PaintContextHolder
 
class  PainterTestBase
 
class  PendingTests
 
class  PlatformConfigurationTest
 
class  PlatformHandlerTest
 
class  PlatformIsolateManagerTest
 
struct  PrerollContextHolder
 
struct  RenderContext
 
class  RenderEnvironment
 
struct  RenderJobInfo
 
class  RenderResult
 
class  SaveLayerBoundsExpector
 
class  SaveLayerOptionsExpector
 
class  ScopedStubFlutterApi
 
class  ScopedStubFlutterGlfwApi
 
class  ScopedStubFlutterWindowsApi
 
class  SemanticsActionObservation
 
class  ShellIOManagerTest
 
class  ShellTest
 
class  ShellTestPlatformView
 
class  ShellTestPlatformViewBuilder
 
class  ShellTestPlatformViewGL
 
class  ShellTestPlatformViewMetal
 
class  ShellTestPlatformViewVulkan
 
class  ShellTestVsyncClock
 
class  ShellTestVsyncWaiter
 
class  SignalHandler
 
class  SinglePixelImageGenerator
 An image generator that always creates a 1x1 single-frame green image. More...
 
class  SkiaGpuObjectTest
 
class  SkImageSampling
 
struct  SkJobRenderer
 
struct  SkPictureJobRenderer
 
class  SkRenderResult
 
class  StreamCapture
 
class  StubFlutterApi
 
class  StubFlutterGlfwApi
 
class  StubFlutterWindowsApi
 
class  SurfaceMock
 
class  TestAndroidSurfaceFactory
 
class  TestAssetResolver
 
class  TestDartNativeResolver
 
class  TestFlutterWindowsEngine
 
class  TestGLSurface
 
class  TestGPUSurfaceMetalDelegate
 
class  TestParameters
 
class  TestRefreshRateReporter
 
class  TestResourceCacheLimitItem
 
class  TestResourceContext
 
class  TestSkObject
 
class  TestSwitchableGLContext
 The renderer context used for testing. More...
 
class  TestTimeoutListener
 
class  TestVsyncWaiter
 
class  TestVulkanContext
 
class  TestVulkanImage
 Captures the lifetime of a test VkImage along with its bound memory. More...
 
class  TestVulkanSurface
 
class  TextInputPluginTest
 
class  ThreadCheckingAssetResolver
 
class  ThreadTest
 A fixture that creates threads with running message loops that are terminated when the test is done (the threads are joined then as well). While this fixture may be used on it's own, it is often sub-classed by other fixtures whose functioning requires threads to be created as necessary. More...
 
class  TypeConversionsTest
 
struct  UniqueEngineTraits
 
struct  ViewContent
 
struct  ViewControllerDeleter
 
struct  Win32Message
 
class  WindowsConfigBuilder
 
class  WindowsLifecycleManagerTest
 
class  WindowsTest
 
class  WindowsTestContext
 
struct  WmCharInfo
 
struct  WmDeadCharInfo
 
struct  WmKeyDownInfo
 
struct  WmKeyUpInfo
 
struct  WmSysKeyDownInfo
 
struct  WmSysKeyUpInfo
 

Typedefs

using BackendType = DlSurfaceProvider::BackendType
 
using ClipOp = DlCanvas::ClipOp
 
using PointMode = DlCanvas::PointMode
 
using DisplayListTest = DisplayListTestBase<::testing::Test >
 
using Builder = DlVertices::Builder
 
using SkSetupContext = RenderContext< SkCanvas *, SkPaint &, sk_sp< SkImage > >
 
using DlSetupContext = RenderContext< DlCanvas *, DlPaint &, sk_sp< DlImage > >
 
using SkRenderContext = RenderContext< SkCanvas *, const SkPaint &, sk_sp< SkImage > >
 
using DlRenderContext = RenderContext< DlCanvas *, const DlPaint &, sk_sp< DlImage > >
 
using SkSetup = const std::function< void(const SkSetupContext &)>
 
using SkRenderer = const std::function< void(const SkRenderContext &)>
 
using DlSetup = const std::function< void(const DlSetupContext &)>
 
using DlRenderer = const std::function< void(const DlRenderContext &)>
 
using PixelFormat = DlSurfaceProvider::PixelFormat
 
using DisplayListRendering = DisplayListRenderingTestBase<::testing::Test >
 
typedef const std::function< void(DlOpReceiver &)> DlInvoker
 
using MetalScreenshotter = impeller::testing::MetalScreenshotter
 
using DlRect = impeller::Rect
 
using DlMatrix = impeller::Matrix
 
using Degrees = impeller::Degrees
 
using BackdropFilterLayerTest = LayerTest
 
using BackdropLayerDiffTest = DiffContextTest
 
using CheckerBoardLayerTest = LayerTest
 
using ClipPathLayerTest = LayerTest
 
using ClipRectLayerTest = LayerTest
 
using ClipRRectLayerTest = LayerTest
 
using ColorFilterLayerTest = LayerTest
 
using ContainerLayerTest = LayerTest
 
using ContainerLayerDiffTest = DiffContextTest
 
using DisplayListLayerTest = LayerTest
 
using DisplayListLayerDiffTest = DiffContextTest
 
using ImageFilterLayerTest = LayerTest
 
using ImageFilterLayerDiffTest = DiffContextTest
 
using OpacityLayerTest = LayerTest
 
using OpacityLayerDiffTest = DiffContextTest
 
using PerformanceOverlayLayerTest = LayerTest
 
using PlatformViewLayerTest = LayerTest
 
using ShaderMaskLayerTest = LayerTest
 
using TextureLayerTest = LayerTest
 
using TextureLayerDiffTest = DiffContextTest
 
using TransformLayerTest = LayerTest
 
using TransformLayerLayerDiffTest = DiffContextTest
 
using RasterCacheTest = LayerTest
 
using LayerTest = LayerTestBase<::testing::Test >
 
using MockLayerTest = LayerTest
 
using HooksTest = ShellTest
 
using SemanticsUpdateBuilderTest = ShellTest
 
using DartLifecycleTest = FixtureTest
 
using DartVMTest = FixtureTest
 
using IsolateDataMap = std::unordered_map< Dart_Isolate, std::vector< std::unique_ptr< IsolateData > > >
 
using UnitlessTime = int
 
using Generator = std::function< UnitlessTime(int)>
 
using PersistentCacheTest = ShellTest
 
using IntPipeline = Pipeline< int >
 
using Continuation = IntPipeline::ProducerContinuation
 
using LayerTreeBuilder = std::function< void(std::shared_ptr< ContainerLayer > root)>
 
using FrameContent = std::map< int64_t, ViewContent >
 
using CreateVsyncWaiter = std::function< std::unique_ptr< VsyncWaiter >()>
 
using FlutterChannelKeyResponderTest = AutoreleasePoolTest
 
using FlutterEmbedderExternalTextureTest = AutoreleasePoolTest
 
using FlutterViewControllerTest = AutoreleasePoolTest
 
using FlutterViewControllerMockEngineTest = MockFlutterEngineTest
 
using EmbedderA11yTest = testing::EmbedderTest
 
using UniqueEngine = fml::UniqueObject< FlutterEngine, UniqueEngineTraits >
 
using EmbedderTest = testing::EmbedderTest
 
using SemanticsUpdateCallback2 = std::function< void(const FlutterSemanticsUpdate2 *)>
 
using SemanticsUpdateCallback = std::function< void(const FlutterSemanticsUpdate *)>
 
using SemanticsNodeCallback = std::function< void(const FlutterSemanticsNode *)>
 
using SemanticsActionCallback = std::function< void(const FlutterSemanticsCustomAction *)>
 
using LogMessageCallback = std::function< void(const char *tag, const char *message)>
 
using ChannelUpdateCallback = std::function< void(const FlutterChannelUpdate *)>
 
using UniqueAOTData = std::unique_ptr< _FlutterEngineAOTData, AOTDataDeleter >
 
using EnginePtr = std::unique_ptr< FlutterDesktopEngine, EngineDeleter >
 
using ViewControllerPtr = std::unique_ptr< FlutterDesktopViewController, ViewControllerDeleter >
 
typedef enum flutter::testing::WmFieldExtended WmFieldExtended
 
typedef enum flutter::testing::WmFieldContext WmFieldContext
 
typedef enum flutter::testing::WmFieldPrevState WmFieldPrevState
 
typedef enum flutter::testing::WmFieldTransitionState WmFieldTransitionState
 
typedef struct flutter::testing::WmKeyDownInfo WmKeyDownInfo
 
typedef struct flutter::testing::WmKeyUpInfo WmKeyUpInfo
 
typedef struct flutter::testing::WmCharInfo WmCharInfo
 
typedef struct flutter::testing::WmSysKeyDownInfo WmSysKeyDownInfo
 
typedef struct flutter::testing::WmSysKeyUpInfo WmSysKeyUpInfo
 
typedef struct flutter::testing::WmDeadCharInfo WmDeadCharInfo
 
using CanvasTest = CanvasTestBase<::testing::Test >
 
using UniqueLoadedELF = std::unique_ptr< Dart_LoadedElf, LoadedELFDeleter >
 
using MockCanvasTest = CanvasTest
 
using NativeEntry = std::function< void(Dart_NativeArguments)>
 
using FileLoaderTest = FixtureTest
 
using DartState = FixtureTest
 
using PainterTest = PainterTestBase<::testing::Test >
 

Enumerations

enum  BenchmarkAttributes {
  kEmpty = 0 , kStrokedStyle = 1 << 0 , kFilledStyle = 1 << 1 , kHairlineStroke = 1 << 2 ,
  kAntiAliasing = 1 << 3
}
 
enum class  EmbedderTestContextType { kSoftwareContext , kOpenGLContext , kMetalContext , kVulkanContext }
 
enum  WmFieldExtended { kNotExtended = 0 , kExtended = 1 }
 
enum  WmFieldContext { kNoContext = 0 , kAltHeld = 1 }
 
enum  WmFieldPrevState { kWasUp = 0 , kWasDown = 1 }
 
enum  WmFieldTransitionState { kBeingReleased = 0 , kBeingPressed = 1 }
 
enum class  DebuggerStatus { kDontKnow , kAttached }
 
enum class  MemsetPatternOp { kMemsetPatternOpSetBuffer , kMemsetPatternOpCheckBuffer }
 

Functions

DlPaint GetPaintForRun (unsigned attributes)
 
static void FlushSubmitCpuSync (const sk_sp< SkSurface > &surface)
 
void AnnotateAttributes (unsigned attributes, benchmark::State &state, const DisplayListAttributeFlags flags)
 
void BM_DrawLine (benchmark::State &state, BackendType backend_type, unsigned attributes)
 
void BM_DrawRect (benchmark::State &state, BackendType backend_type, unsigned attributes)
 
void BM_DrawOval (benchmark::State &state, BackendType backend_type, unsigned attributes)
 
void BM_DrawCircle (benchmark::State &state, BackendType backend_type, unsigned attributes)
 
void BM_DrawRRect (benchmark::State &state, BackendType backend_type, unsigned attributes, SkRRect::Type type)
 
void BM_DrawDRRect (benchmark::State &state, BackendType backend_type, unsigned attributes, SkRRect::Type type)
 
void BM_DrawArc (benchmark::State &state, BackendType backend_type, unsigned attributes)
 
std::vector< SkPointGetPolygonPoints (size_t n, SkPoint center, SkScalar r)
 
void GetLinesPath (SkPath &path, size_t sides, SkPoint center, float radius)
 
void GetQuadsPath (SkPath &path, size_t sides, SkPoint center, float radius)
 
void GetConicsPath (SkPath &path, size_t sides, SkPoint center, float radius)
 
void GetCubicsPath (SkPath &path, size_t sides, SkPoint center, float radius)
 
void MultiplyPath (SkPath &path, SkPath::Verb type, SkPoint center, size_t sides, size_t number, float radius)
 
std::string VerbToString (SkPath::Verb type)
 
void BM_DrawPath (benchmark::State &state, BackendType backend_type, unsigned attributes, SkPath::Verb type)
 
std::shared_ptr< DlVerticesGetTestVertices (SkPoint center, float radius, size_t vertex_count, DlVertexMode mode, size_t &final_vertex_count)
 
std::string VertexModeToString (DlVertexMode mode)
 
void BM_DrawVertices (benchmark::State &state, BackendType backend_type, unsigned attributes, DlVertexMode mode)
 
std::vector< SkPointGetTestPoints (size_t count, SkISize canvas_size)
 
std::string PointModeToString (DlCanvas::PointMode mode)
 
void BM_DrawPoints (benchmark::State &state, BackendType backend_type, unsigned attributes, DlCanvas::PointMode mode)
 
sk_sp< SkImageImageFromBitmapWithNewID (const SkBitmap &bitmap)
 
void BM_DrawImage (benchmark::State &state, BackendType backend_type, unsigned attributes, DlImageSampling options, bool upload_bitmap)
 
std::string ConstraintToString (DlCanvas::SrcRectConstraint constraint)
 
void BM_DrawImageRect (benchmark::State &state, BackendType backend_type, unsigned attributes, DlImageSampling options, DlCanvas::SrcRectConstraint constraint, bool upload_bitmap)
 
std::string FilterModeToString (const DlFilterMode mode)
 
void BM_DrawImageNine (benchmark::State &state, BackendType backend_type, unsigned attributes, const DlFilterMode filter, bool upload_bitmap)
 
void BM_DrawTextBlob (benchmark::State &state, BackendType backend_type, unsigned attributes)
 
void BM_DrawShadow (benchmark::State &state, BackendType backend_type, unsigned attributes, bool transparent_occluder, SkPath::Verb type)
 
void BM_SaveLayer (benchmark::State &state, BackendType backend_type, unsigned attributes, size_t save_depth)
 
 TEST (DisplayListComplexity, EmptyDisplayList)
 
 TEST (DisplayListComplexity, DisplayListCeiling)
 
 TEST (DisplayListComplexity, NestedDisplayList)
 
 TEST (DisplayListComplexity, AntiAliasing)
 
 TEST (DisplayListComplexity, StrokeWidth)
 
 TEST (DisplayListComplexity, Style)
 
 TEST (DisplayListComplexity, SaveLayers)
 
 TEST (DisplayListComplexity, DrawPath)
 
 TEST (DisplayListComplexity, DrawShadow)
 
 TEST (DisplayListComplexity, DrawOval)
 
 TEST (DisplayListComplexity, DrawCircle)
 
 TEST (DisplayListComplexity, DrawRRect)
 
 TEST (DisplayListComplexity, DrawDRRect)
 
 TEST (DisplayListComplexity, DrawArc)
 
 TEST (DisplayListComplexity, DrawVertices)
 
 TEST (DisplayListComplexity, DrawTextBlob)
 
 TEST (DisplayListComplexity, DrawPoints)
 
 TEST (DisplayListComplexity, DrawImage)
 
 TEST (DisplayListComplexity, DrawImageNine)
 
 TEST (DisplayListComplexity, DrawImageRect)
 
 TEST (DisplayListComplexity, DrawAtlas)
 
 TEST_F (DisplayListTest, Defaults)
 
 TEST_F (DisplayListTest, EmptyBuild)
 
 TEST_F (DisplayListTest, EmptyRebuild)
 
 TEST_F (DisplayListTest, BuilderCanBeReused)
 
 TEST_F (DisplayListTest, SaveRestoreRestoresTransform)
 
 TEST_F (DisplayListTest, BuildRestoresTransform)
 
 TEST_F (DisplayListTest, SaveRestoreRestoresClip)
 
 TEST_F (DisplayListTest, BuildRestoresClip)
 
 TEST_F (DisplayListTest, BuildRestoresAttributes)
 
 TEST_F (DisplayListTest, BuilderBoundsTransformComparedToSkia)
 
 TEST_F (DisplayListTest, BuilderInitialClipBounds)
 
 TEST_F (DisplayListTest, BuilderInitialClipBoundsNaN)
 
 TEST_F (DisplayListTest, BuilderClipBoundsAfterClipRect)
 
 TEST_F (DisplayListTest, BuilderClipBoundsAfterClipRRect)
 
 TEST_F (DisplayListTest, BuilderClipBoundsAfterClipPath)
 
 TEST_F (DisplayListTest, BuilderInitialClipBoundsNonZero)
 
 TEST_F (DisplayListTest, UnclippedSaveLayerContentAccountsForFilter)
 
 TEST_F (DisplayListTest, ClippedSaveLayerContentAccountsForFilter)
 
 TEST_F (DisplayListTest, SingleOpSizes)
 
 TEST_F (DisplayListTest, SingleOpDisplayListsNotEqualEmpty)
 
 TEST_F (DisplayListTest, SingleOpDisplayListsRecapturedAreEqual)
 
 TEST_F (DisplayListTest, SingleOpDisplayListsCompareToEachOther)
 
 TEST_F (DisplayListTest, SingleOpDisplayListsAreEqualWithOrWithoutRtree)
 
 TEST_F (DisplayListTest, FullRotationsAreNop)
 
 TEST_F (DisplayListTest, AllBlendModeNops)
 
 TEST_F (DisplayListTest, DisplayListsWithVaryingOpComparisons)
 
 TEST_F (DisplayListTest, DisplayListSaveLayerBoundsWithAlphaFilter)
 
 TEST_F (DisplayListTest, NestedOpCountMetricsSameAsSkPicture)
 
 TEST_F (DisplayListTest, DisplayListFullPerspectiveTransformHandling)
 
 TEST_F (DisplayListTest, DisplayListTransformResetHandling)
 
 TEST_F (DisplayListTest, SingleOpsMightSupportGroupOpacityBlendMode)
 
 TEST_F (DisplayListTest, OverlappingOpsDoNotSupportGroupOpacity)
 
 TEST_F (DisplayListTest, SaveLayerFalseSupportsGroupOpacityOverlappingChidren)
 
 TEST_F (DisplayListTest, SaveLayerTrueSupportsGroupOpacityOverlappingChidren)
 
 TEST_F (DisplayListTest, SaveLayerFalseWithSrcBlendSupportsGroupOpacity)
 
 TEST_F (DisplayListTest, SaveLayerTrueWithSrcBlendDoesNotSupportGroupOpacity)
 
 TEST_F (DisplayListTest, SaveLayerFalseSupportsGroupOpacityWithChildSrcBlend)
 
 TEST_F (DisplayListTest, SaveLayerTrueSupportsGroupOpacityWithChildSrcBlend)
 
 TEST_F (DisplayListTest, SaveLayerBoundsSnapshotsImageFilter)
 
 TEST_F (DisplayListTest, SaveLayerOneSimpleOpInheritsOpacity)
 
 TEST_F (DisplayListTest, SaveLayerNoAttributesInheritsOpacity)
 
 TEST_F (DisplayListTest, SaveLayerTwoOverlappingOpsDoesNotInheritOpacity)
 
 TEST_F (DisplayListTest, NestedSaveLayersMightInheritOpacity)
 
 TEST_F (DisplayListTest, NestedSaveLayersCanBothSupportOpacityOptimization)
 
 TEST_F (DisplayListTest, SaveLayerImageFilterDoesNotInheritOpacity)
 
 TEST_F (DisplayListTest, SaveLayerColorFilterDoesNotInheritOpacity)
 
 TEST_F (DisplayListTest, SaveLayerSrcBlendDoesNotInheritOpacity)
 
 TEST_F (DisplayListTest, SaveLayerImageFilterOnChildInheritsOpacity)
 
 TEST_F (DisplayListTest, SaveLayerColorFilterOnChildDoesNotInheritOpacity)
 
 TEST_F (DisplayListTest, SaveLayerSrcBlendOnChildDoesNotInheritOpacity)
 
 TEST_F (DisplayListTest, FlutterSvgIssue661BoundsWereEmpty)
 
 TEST_F (DisplayListTest, TranslateAffectsCurrentTransform)
 
 TEST_F (DisplayListTest, ScaleAffectsCurrentTransform)
 
 TEST_F (DisplayListTest, RotateAffectsCurrentTransform)
 
 TEST_F (DisplayListTest, SkewAffectsCurrentTransform)
 
 TEST_F (DisplayListTest, TransformAffectsCurrentTransform)
 
 TEST_F (DisplayListTest, FullTransformAffectsCurrentTransform)
 
 TEST_F (DisplayListTest, ClipRectAffectsClipBounds)
 
 TEST_F (DisplayListTest, ClipRectDoAAAffectsClipBounds)
 
 TEST_F (DisplayListTest, ClipRectAffectsClipBoundsWithMatrix)
 
 TEST_F (DisplayListTest, ClipRRectAffectsClipBounds)
 
 TEST_F (DisplayListTest, ClipRRectDoAAAffectsClipBounds)
 
 TEST_F (DisplayListTest, ClipRRectAffectsClipBoundsWithMatrix)
 
 TEST_F (DisplayListTest, ClipPathAffectsClipBounds)
 
 TEST_F (DisplayListTest, ClipPathDoAAAffectsClipBounds)
 
 TEST_F (DisplayListTest, ClipPathAffectsClipBoundsWithMatrix)
 
 TEST_F (DisplayListTest, DiffClipRectDoesNotAffectClipBounds)
 
 TEST_F (DisplayListTest, DiffClipRRectDoesNotAffectClipBounds)
 
 TEST_F (DisplayListTest, DiffClipPathDoesNotAffectClipBounds)
 
 TEST_F (DisplayListTest, ClipPathWithInvertFillTypeDoesNotAffectClipBounds)
 
 TEST_F (DisplayListTest, DiffClipPathWithInvertFillTypeAffectsClipBounds)
 
 TEST_F (DisplayListTest, FlatDrawPointsProducesBounds)
 
static void test_rtree (const sk_sp< const DlRTree > &rtree, const SkRect &query, std::vector< SkRect > expected_rects, const std::vector< int > &expected_indices)
 
 TEST_F (DisplayListTest, RTreeOfSimpleScene)
 
 TEST_F (DisplayListTest, RTreeOfSaveRestoreScene)
 
 TEST_F (DisplayListTest, RTreeOfSaveLayerFilterScene)
 
 TEST_F (DisplayListTest, NestedDisplayListRTreesAreSparse)
 
 TEST_F (DisplayListTest, RemoveUnnecessarySaveRestorePairs)
 
 TEST_F (DisplayListTest, CollapseMultipleNestedSaveRestore)
 
 TEST_F (DisplayListTest, CollapseNestedSaveAndSaveLayerRestore)
 
 TEST_F (DisplayListTest, RemoveUnnecessarySaveRestorePairsInSetPaint)
 
 TEST_F (DisplayListTest, TransformTriggersDeferredSave)
 
 TEST_F (DisplayListTest, Transform2DTriggersDeferredSave)
 
 TEST_F (DisplayListTest, TransformPerspectiveTriggersDeferredSave)
 
 TEST_F (DisplayListTest, ResetTransformTriggersDeferredSave)
 
 TEST_F (DisplayListTest, SkewTriggersDeferredSave)
 
 TEST_F (DisplayListTest, TranslateTriggersDeferredSave)
 
 TEST_F (DisplayListTest, ScaleTriggersDeferredSave)
 
 TEST_F (DisplayListTest, ClipRectTriggersDeferredSave)
 
 TEST_F (DisplayListTest, ClipRRectTriggersDeferredSave)
 
 TEST_F (DisplayListTest, ClipPathTriggersDeferredSave)
 
 TEST_F (DisplayListTest, NOPTranslateDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, NOPScaleDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, NOPRotationDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, NOPSkewDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, NOPTransformDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, NOPTransform2DDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, NOPTransformFullPerspectiveDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, NOPClipDoesNotTriggerDeferredSave)
 
 TEST_F (DisplayListTest, RTreeOfClippedSaveLayerFilterScene)
 
 TEST_F (DisplayListTest, RTreeRenderCulling)
 
 TEST_F (DisplayListTest, DrawSaveDrawCannotInheritOpacity)
 
 TEST_F (DisplayListTest, DrawUnorderedRect)
 
 TEST_F (DisplayListTest, DrawUnorderedRoundRect)
 
 TEST_F (DisplayListTest, DrawUnorderedOval)
 
 TEST_F (DisplayListTest, DrawUnorderedRectangularPath)
 
 TEST_F (DisplayListTest, DrawUnorderedOvalPath)
 
 TEST_F (DisplayListTest, DrawUnorderedRoundRectPathCW)
 
 TEST_F (DisplayListTest, DrawUnorderedRoundRectPathCCW)
 
 TEST_F (DisplayListTest, NopOperationsOmittedFromRecords)
 
 TEST_F (DisplayListTest, ImpellerPathPreferenceIsHonored)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfSimpleRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfMaskBlurredRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfImageBlurredRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfStrokedRect)
 
 TEST_F (DisplayListTest, TranslatedSaveLayerBoundsComputationOfSimpleRect)
 
 TEST_F (DisplayListTest, ScaledSaveLayerBoundsComputationOfSimpleRect)
 
 TEST_F (DisplayListTest, RotatedSaveLayerBoundsComputationOfSimpleRect)
 
 TEST_F (DisplayListTest, TransformResetSaveLayerBoundsComputationOfSimpleRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfTranslatedSimpleRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfScaledSimpleRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfRotatedSimpleRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfNestedSimpleRect)
 
 TEST_F (DisplayListTest, FloodingSaveLayerBoundsComputationOfSimpleRect)
 
 TEST_F (DisplayListTest, NestedFloodingSaveLayerBoundsComputationOfSimpleRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfFloodingImageFilter)
 
 TEST_F (DisplayListTest, SaveLayerBoundsComputationOfFloodingColorFilter)
 
 TEST_F (DisplayListTest, SaveLayerBoundsClipDetectionSimpleUnclippedRect)
 
 TEST_F (DisplayListTest, SaveLayerBoundsClipDetectionSimpleClippedRect)
 
 TEST_F (DisplayListTest, SaveContentDepthTest)
 
static void arraysEqual (const uint32_t *ints, const DlColor *colors, int count)
 
 TEST (DisplayListColor, ArrayInterchangeableWithUint32)
 
 TEST (DisplayListColor, DlColorDirectlyComparesToSkColor)
 
 TEST (DisplayListPaint, ConstructorDefaults)
 
 TEST (DisplayListPaint, NullPointerSetGet)
 
 TEST (DisplayListPaint, NullSharedPointerSetGet)
 
 TEST (DisplayListPaint, ChainingConstructor)
 
 TEST (DisplayListVertices, MakeWithZeroAndNegativeVerticesAndIndices)
 
 TEST (DisplayListVertices, MakeWithTexAndColorAndIndices)
 
 TEST (DisplayListVertices, MakeWithTexAndColor)
 
 TEST (DisplayListVertices, MakeWithTexAndIndices)
 
 TEST (DisplayListVertices, MakeWithColorAndIndices)
 
 TEST (DisplayListVertices, MakeWithTex)
 
 TEST (DisplayListVertices, MakeWithColor)
 
 TEST (DisplayListVertices, MakeWithIndices)
 
 TEST (DisplayListVertices, MakeWithNoOptionalData)
 
 TEST (DisplayListVertices, MakeWithIndicesButZeroIndexCount)
 
 TEST (DisplayListVertices, MakeWithIndicesButNegativeIndexCount)
 
 TEST (DisplayListVertices, BuilderFlags)
 
 TEST (DisplayListVertices, BuildWithZeroAndNegativeVerticesAndIndices)
 
 TEST (DisplayListVertices, BuildWithTexAndColorAndIndices)
 
 TEST (DisplayListVertices, BuildWithTexAndColor)
 
 TEST (DisplayListVertices, BuildWithTexAndIndices)
 
 TEST (DisplayListVertices, BuildWithColorAndIndices)
 
 TEST (DisplayListVertices, BuildWithTexUsingPoints)
 
 TEST (DisplayListVertices, BuildWithTexUsingFloats)
 
 TEST (DisplayListVertices, BuildUsingFloatsSameAsPoints)
 
 TEST (DisplayListVertices, BuildWithColor)
 
 TEST (DisplayListVertices, BuildWithIndices)
 
 TEST (DisplayListVertices, BuildWithNoOptionalData)
 
 TEST (DisplayListVertices, BuildWithNegativeIndexCount)
 
 TEST (DisplayListVertices, TestEquals)
 
 TEST (DisplayListVertices, TestNotEquals)
 
 TEST (DisplayListColorFilter, BlendConstructor)
 
 TEST (DisplayListColorFilter, BlendShared)
 
 TEST (DisplayListColorFilter, BlendAsBlend)
 
 TEST (DisplayListColorFilter, BlendContents)
 
 TEST (DisplayListColorFilter, BlendEquals)
 
 TEST (DisplayListColorFilter, BlendNotEquals)
 
 TEST (DisplayListColorFilter, NopBlendShouldNotCrash)
 
 TEST (DisplayListColorFilter, MatrixConstructor)
 
 TEST (DisplayListColorFilter, MatrixShared)
 
 TEST (DisplayListColorFilter, MatrixAsMatrix)
 
 TEST (DisplayListColorFilter, MatrixContents)
 
 TEST (DisplayListColorFilter, MatrixEquals)
 
 TEST (DisplayListColorFilter, MatrixNotEquals)
 
 TEST (DisplayListColorFilter, NopMatrixShouldNotCrash)
 
 TEST (DisplayListColorFilter, SrgbToLinearConstructor)
 
 TEST (DisplayListColorFilter, SrgbToLinearShared)
 
 TEST (DisplayListColorFilter, SrgbToLinearEquals)
 
 TEST (DisplayListColorFilter, LinearToSrgbConstructor)
 
 TEST (DisplayListColorFilter, LinearToSrgbShared)
 
 TEST (DisplayListColorFilter, LinearToSrgbEquals)
 
static sk_sp< DlImageMakeTestImage (int w, int h, SkColor color)
 
 TEST (DisplayListColorSource, ColorConstructor)
 
 TEST (DisplayListColorSource, ColorShared)
 
 TEST (DisplayListColorSource, ColorAsColor)
 
 TEST (DisplayListColorSource, ColorContents)
 
 TEST (DisplayListColorSource, ColorEquals)
 
 TEST (DisplayListColorSource, ColorNotEquals)
 
 TEST (DisplayListColorSource, ImageConstructor)
 
 TEST (DisplayListColorSource, ImageShared)
 
 TEST (DisplayListColorSource, ImageAsImage)
 
 TEST (DisplayListColorSource, ImageContents)
 
 TEST (DisplayListColorSource, AlphaImageContents)
 
 TEST (DisplayListColorSource, ImageEquals)
 
 TEST (DisplayListColorSource, ImageNotEquals)
 
 TEST (DisplayListColorSource, LinearGradientConstructor)
 
 TEST (DisplayListColorSource, LinearGradientShared)
 
 TEST (DisplayListColorSource, LinearGradientAsLinear)
 
 TEST (DisplayListColorSource, LinearGradientContents)
 
 TEST (DisplayListColorSource, AlphaLinearGradientContents)
 
 TEST (DisplayListColorSource, LinearGradientEquals)
 
 TEST (DisplayListColorSource, LinearGradientNotEquals)
 
 TEST (DisplayListColorSource, RadialGradientConstructor)
 
 TEST (DisplayListColorSource, RadialGradientShared)
 
 TEST (DisplayListColorSource, RadialGradientAsRadial)
 
 TEST (DisplayListColorSource, RadialGradientContents)
 
 TEST (DisplayListColorSource, AlphaRadialGradientContents)
 
 TEST (DisplayListColorSource, RadialGradientEquals)
 
 TEST (DisplayListColorSource, RadialGradientNotEquals)
 
 TEST (DisplayListColorSource, ConicalGradientConstructor)
 
 TEST (DisplayListColorSource, ConicalGradientShared)
 
 TEST (DisplayListColorSource, ConicalGradientAsConical)
 
 TEST (DisplayListColorSource, ConicalGradientContents)
 
 TEST (DisplayListColorSource, AlphaConicalGradientContents)
 
 TEST (DisplayListColorSource, ConicalGradientEquals)
 
 TEST (DisplayListColorSource, ConicalGradientNotEquals)
 
 TEST (DisplayListColorSource, SweepGradientConstructor)
 
 TEST (DisplayListColorSource, SweepGradientShared)
 
 TEST (DisplayListColorSource, SweepGradientAsSweep)
 
 TEST (DisplayListColorSource, SweepGradientContents)
 
 TEST (DisplayListColorSource, AlphaSweepGradientContents)
 
 TEST (DisplayListColorSource, SweepGradientEquals)
 
 TEST (DisplayListColorSource, SweepGradientNotEquals)
 
 TEST (DisplayListColorSource, RuntimeEffect)
 
static bool containsInclusive (const SkRect rect, const SkPoint p)
 
static bool containsInclusive (const SkRect rect, const SkPoint quad[4])
 
static bool containsInclusive (const SkIRect rect, const SkPoint quad[4])
 
static bool containsInclusive (const SkIRect rect, const SkRect bounds)
 
static void TestBoundsWithMatrix (const DlImageFilter &filter, const SkMatrix &matrix, const SkRect &sourceBounds, const SkPoint expectedLocalOutputQuad[4])
 
static void TestInvalidBounds (const DlImageFilter &filter, const SkMatrix &matrix, const SkRect &localInputBounds)
 
static void TestBounds (const DlImageFilter &filter, const SkRect &sourceBounds, const SkPoint expectedLocalOutputQuad[4])
 
static void TestBounds (const DlImageFilter &filter, const SkRect &sourceBounds, const SkRect &expectedLocalOutputBounds)
 
 TEST (DisplayListImageFilter, BlurConstructor)
 
 TEST (DisplayListImageFilter, BlurShared)
 
 TEST (DisplayListImageFilter, BlurAsBlur)
 
 TEST (DisplayListImageFilter, BlurContents)
 
 TEST (DisplayListImageFilter, BlurEquals)
 
 TEST (DisplayListImageFilter, BlurWithLocalMatrixEquals)
 
 TEST (DisplayListImageFilter, BlurNotEquals)
 
 TEST (DisplayListImageFilter, BlurBounds)
 
 TEST (DisplayListImageFilter, BlurZeroSigma)
 
 TEST (DisplayListImageFilter, DilateConstructor)
 
 TEST (DisplayListImageFilter, DilateShared)
 
 TEST (DisplayListImageFilter, DilateAsDilate)
 
 TEST (DisplayListImageFilter, DilateContents)
 
 TEST (DisplayListImageFilter, DilateEquals)
 
 TEST (DisplayListImageFilter, DilateWithLocalMatrixEquals)
 
 TEST (DisplayListImageFilter, DilateNotEquals)
 
 TEST (DisplayListImageFilter, DilateBounds)
 
 TEST (DisplayListImageFilter, ErodeConstructor)
 
 TEST (DisplayListImageFilter, ErodeShared)
 
 TEST (DisplayListImageFilter, ErodeAsErode)
 
 TEST (DisplayListImageFilter, ErodeContents)
 
 TEST (DisplayListImageFilter, ErodeEquals)
 
 TEST (DisplayListImageFilter, ErodeWithLocalMatrixEquals)
 
 TEST (DisplayListImageFilter, ErodeNotEquals)
 
 TEST (DisplayListImageFilter, ErodeBounds)
 
 TEST (DisplayListImageFilter, MatrixConstructor)
 
 TEST (DisplayListImageFilter, MatrixShared)
 
 TEST (DisplayListImageFilter, MatrixAsMatrix)
 
 TEST (DisplayListImageFilter, MatrixContents)
 
 TEST (DisplayListImageFilter, MatrixEquals)
 
 TEST (DisplayListImageFilter, MatrixWithLocalMatrixEquals)
 
 TEST (DisplayListImageFilter, MatrixNotEquals)
 
 TEST (DisplayListImageFilter, MatrixBounds)
 
 TEST (DisplayListImageFilter, ComposeConstructor)
 
 TEST (DisplayListImageFilter, ComposeShared)
 
 TEST (DisplayListImageFilter, ComposeAsCompose)
 
 TEST (DisplayListImageFilter, ComposeContents)
 
 TEST (DisplayListImageFilter, ComposeEquals)
 
 TEST (DisplayListImageFilter, ComposeWithLocalMatrixEquals)
 
 TEST (DisplayListImageFilter, ComposeNotEquals)
 
 TEST (DisplayListImageFilter, ComposeBounds)
 
static void TestUnboundedBounds (DlImageFilter &filter, const SkRect &sourceBounds, const SkRect &expectedOutputBounds, const SkRect &expectedInputBounds)
 
 TEST (DisplayListImageFilter, ComposeBoundsWithUnboundedInner)
 
 TEST (DisplayListImageFilter, ComposeBoundsWithUnboundedOuter)
 
 TEST (DisplayListImageFilter, ComposeBoundsWithUnboundedInnerAndOuter)
 
 TEST (DisplayListImageFilter, Issue108433)
 
 TEST (DisplayListImageFilter, ColorFilterConstructor)
 
 TEST (DisplayListImageFilter, ColorFilterShared)
 
 TEST (DisplayListImageFilter, ColorFilterAsColorFilter)
 
 TEST (DisplayListImageFilter, ColorFilterContents)
 
 TEST (DisplayListImageFilter, ColorFilterEquals)
 
 TEST (DisplayListImageFilter, ColorFilterWithLocalMatrixEquals)
 
 TEST (DisplayListImageFilter, ColorFilterNotEquals)
 
 TEST (DisplayListImageFilter, ColorFilterBounds)
 
 TEST (DisplayListImageFilter, ColorFilterModifiesTransparencyBounds)
 
 TEST (DisplayListImageFilter, LocalImageFilterBounds)
 
 TEST (DisplayListMaskFilter, BlurConstructor)
 
 TEST (DisplayListMaskFilter, BlurShared)
 
 TEST (DisplayListMaskFilter, BlurAsBlur)
 
 TEST (DisplayListMaskFilter, BlurContents)
 
 TEST (DisplayListMaskFilter, BlurEquals)
 
 TEST (DisplayListMaskFilter, BlurNotEquals)
 
void testEquals (DlMaskFilter *a, DlMaskFilter *b)
 
void testNotEquals (DlMaskFilter *a, DlMaskFilter *b)
 
void testEquals (const std::shared_ptr< const DlMaskFilter > &a, DlMaskFilter *b)
 
void testNotEquals (const std::shared_ptr< const DlMaskFilter > &a, DlMaskFilter *b)
 
void testEquals (const std::shared_ptr< const DlMaskFilter > &a, const std::shared_ptr< const DlMaskFilter > &b)
 
void testNotEquals (const std::shared_ptr< const DlMaskFilter > &a, const std::shared_ptr< const DlMaskFilter > &b)
 
 TEST (DisplayListMaskFilter, ComparableTemplates)
 
 TEST (DisplayListPathEffect, EffectShared)
 
 TEST (DisplayListPathEffect, DashEffectAsDash)
 
 TEST (DisplayListPathEffect, DashEffectEquals)
 
 TEST (DisplayListPathEffect, CheckEffectProperties)
 
 TEST (DisplayListRegion, EmptyRegion)
 
 TEST (DisplayListRegion, SingleRectangle)
 
 TEST (DisplayListRegion, NonOverlappingRectangles1)
 
 TEST (DisplayListRegion, NonOverlappingRectangles2)
 
 TEST (DisplayListRegion, NonOverlappingRectangles3)
 
 TEST (DisplayListRegion, MergeTouchingRectangles)
 
 TEST (DisplayListRegion, OverlappingRectangles)
 
 TEST (DisplayListRegion, Deband)
 
 TEST (DisplayListRegion, Intersects1)
 
 TEST (DisplayListRegion, Intersects2)
 
 TEST (DisplayListRegion, Intersection1)
 
 TEST (DisplayListRegion, Intersection2)
 
 TEST (DisplayListRegion, Intersection3)
 
 TEST (DisplayListRegion, Union1)
 
 TEST (DisplayListRegion, Union2)
 
 TEST (DisplayListRegion, Union3)
 
 TEST (DisplayListRegion, UnionEmpty)
 
void CheckEquality (const DlRegion &dl_region, const SkRegion &sk_region)
 
 TEST (DisplayListRegion, TestAgainstSkRegion)
 
 TEST (DisplayListRTree, NullRectListNonZeroCount)
 
 TEST (DisplayListRTree, NegativeCount)
 
 TEST (DisplayListRTree, NullSearchResultVector)
 
 TEST (DisplayListRTree, NullRectListZeroCount)
 
 TEST (DisplayListRTree, ManySizes)
 
 TEST (DisplayListRTree, HugeSize)
 
 TEST (DisplayListRTree, Grid)
 
 TEST (DisplayListRTree, OverlappingRects)
 
 TEST (DisplayListRTree, Region)
 
 TEST (DisplayListImageFilter, LocalImageSkiaNull)
 
 TEST (DisplayListSkConversions, ToSkColor)
 
 TEST (DisplayListSkConversions, ToSkTileMode)
 
 TEST (DisplayListSkConversions, ToSkBlurStyle)
 
 TEST (DisplayListSkConversions, ToSkDrawStyle)
 
 TEST (DisplayListSkConversions, ToSkStrokeCap)
 
 TEST (DisplayListSkConversions, ToSkStrokeJoin)
 
 TEST (DisplayListSkConversions, ToSkVertexMode)
 
 TEST (DisplayListSkConversions, ToSkFilterMode)
 
 TEST (DisplayListSkConversions, ToSkSrcRectConstraint)
 
 TEST (DisplayListSkConversions, ToSkSamplingOptions)
 
 TEST (DisplayListSkConversions, ToSkBlendMode)
 
 TEST (DisplayListSkConversions, BlendColorFilterModifiesTransparency)
 
 TEST (DisplayListSkConversions, ConvertWithZeroAndNegativeVerticesAndIndices)
 
 TEST (DisplayListVertices, ConvertWithZeroAndNegativeVerticesAndIndices)
 
 TEST (DisplayListColorSource, ConvertRuntimeEffect)
 
 TEST (DisplayListColorSource, ConvertRuntimeEffectWithNullSampler)
 
 TEST (DisplayListSkConversions, MatrixColorFilterModifiesTransparency)
 
 TEST (DisplayListSkConversions, ToSkDitheringEnabledForGradients)
 
 TEST (DisplayListUtils, OverRestore)
 
 TEST (DisplayListUtils, SetColorSourceDithersIfGradient)
 
 TEST (DisplayListUtils, SetColorSourceDoesNotDitherIfNotGradient)
 
 TEST (DisplayListUtils, SkDispatcherSetColorSourceDithersIfGradient)
 
 TEST (DisplayListUtils, SkDispatcherSetColorSourceDoesNotDitherIfNotGradient)
 
static void DrawCheckerboard (DlCanvas *canvas)
 
static void DrawCheckerboard (SkCanvas *canvas)
 
static std::shared_ptr< DlImageColorSourceMakeColorSource (const sk_sp< DlImage > &image)
 
static sk_sp< SkShaderMakeColorSource (const sk_sp< SkImage > &image)
 
 TEST_F (DisplayListRendering, DrawPaint)
 
 TEST_F (DisplayListRendering, DrawOpaqueColor)
 
 TEST_F (DisplayListRendering, DrawAlphaColor)
 
 TEST_F (DisplayListRendering, DrawDiagonalLines)
 
 TEST_F (DisplayListRendering, DrawHorizontalLine)
 
 TEST_F (DisplayListRendering, DrawVerticalLine)
 
 TEST_F (DisplayListRendering, DrawRect)
 
 TEST_F (DisplayListRendering, DrawOval)
 
 TEST_F (DisplayListRendering, DrawCircle)
 
 TEST_F (DisplayListRendering, DrawRRect)
 
 TEST_F (DisplayListRendering, DrawDRRect)
 
 TEST_F (DisplayListRendering, DrawPath)
 
 TEST_F (DisplayListRendering, DrawArc)
 
 TEST_F (DisplayListRendering, DrawArcCenter)
 
 TEST_F (DisplayListRendering, DrawPointsAsPoints)
 
 TEST_F (DisplayListRendering, DrawPointsAsLines)
 
 TEST_F (DisplayListRendering, DrawPointsAsPolygon)
 
 TEST_F (DisplayListRendering, DrawVerticesWithColors)
 
 TEST_F (DisplayListRendering, DrawVerticesWithImage)
 
 TEST_F (DisplayListRendering, DrawImageNearest)
 
 TEST_F (DisplayListRendering, DrawImageNearestNoPaint)
 
 TEST_F (DisplayListRendering, DrawImageLinear)
 
 TEST_F (DisplayListRendering, DrawImageRectNearest)
 
 TEST_F (DisplayListRendering, DrawImageRectNearestNoPaint)
 
 TEST_F (DisplayListRendering, DrawImageRectLinear)
 
 TEST_F (DisplayListRendering, DrawImageNineNearest)
 
 TEST_F (DisplayListRendering, DrawImageNineNearestNoPaint)
 
 TEST_F (DisplayListRendering, DrawImageNineLinear)
 
 TEST_F (DisplayListRendering, DrawAtlasNearest)
 
 TEST_F (DisplayListRendering, DrawAtlasNearestNoPaint)
 
 TEST_F (DisplayListRendering, DrawAtlasLinear)
 
sk_sp< DisplayListmakeTestDisplayList ()
 
 TEST_F (DisplayListRendering, DrawDisplayList)
 
 TEST_F (DisplayListRendering, DrawTextBlob)
 
 TEST_F (DisplayListRendering, DrawShadow)
 
 TEST_F (DisplayListRendering, DrawShadowTransparentOccluder)
 
 TEST_F (DisplayListRendering, DrawShadowDpr)
 
 TEST_F (DisplayListRendering, SaveLayerClippedContentStillFilters)
 
 TEST_F (DisplayListRendering, SaveLayerConsolidation)
 
 TEST_F (DisplayListRendering, MatrixColorFilterModifyTransparencyCheck)
 
 TEST_F (DisplayListRendering, MatrixColorFilterOpacityCommuteCheck)
 
static std::string BlendModeToString (DlBlendMode mode)
 
 TEST_F (DisplayListRendering, BlendColorFilterModifyTransparencyCheck)
 
 TEST_F (DisplayListRendering, BlendColorFilterOpacityCommuteCheck)
 
 TEST_F (DisplayListNopTest, BlendModeAndColorViaColorFilter)
 
 TEST_F (DisplayListNopTest, BlendModeAndColorByRendering)
 
 TEST_F (DisplayListNopTest, BlendModeAndColorAndFiltersByRendering)
 
template<class T >
static void TestEquals (T &source1, T &source2)
 
template<class T >
static void TestNotEquals (T &source1, T &source2, const std::string &label)
 
sk_sp< DisplayListGetSampleDisplayList ()
 
sk_sp< DisplayListGetSampleNestedDisplayList ()
 
sk_sp< DisplayListGetSampleDisplayList (int ops)
 
std::vector< DisplayListInvocationGroupCreateAllAttributesOps ()
 
std::vector< DisplayListInvocationGroupCreateAllSaveRestoreOps ()
 
std::vector< DisplayListInvocationGroupCreateAllTransformOps ()
 
std::vector< DisplayListInvocationGroupCreateAllClipOps ()
 
std::vector< DisplayListInvocationGroupCreateAllRenderingOps ()
 
std::vector< DisplayListInvocationGroupCreateAllGroups ()
 
SkFont CreateTestFontOfSize (SkScalar scalar)
 
sk_sp< SkTextBlobGetTestTextBlob (int index)
 
static sk_sp< DlImageMakeTestImage (int w, int h, int checker_size)
 
static const DlImageColorSource kTestSource1 (TestImage1, DlTileMode::kClamp, DlTileMode::kMirror, kLinearSampling)
 
static const DlBlendColorFilter kTestBlendColorFilter1 (DlColor::kRed(), DlBlendMode::kDstATop)
 
static const DlBlendColorFilter kTestBlendColorFilter2 (DlColor::kBlue(), DlBlendMode::kDstATop)
 
static const DlBlendColorFilter kTestBlendColorFilter3 (DlColor::kRed(), DlBlendMode::kDstIn)
 
static const DlMatrixColorFilter kTestMatrixColorFilter1 (kRotateColorMatrix)
 
static const DlMatrixColorFilter kTestMatrixColorFilter2 (kInvertColorMatrix)
 
static const DlBlurImageFilter kTestBlurImageFilter1 (5.0, 5.0, DlTileMode::kClamp)
 
static const DlBlurImageFilter kTestBlurImageFilter2 (6.0, 5.0, DlTileMode::kClamp)
 
static const DlBlurImageFilter kTestBlurImageFilter3 (5.0, 6.0, DlTileMode::kClamp)
 
static const DlBlurImageFilter kTestBlurImageFilter4 (5.0, 5.0, DlTileMode::kDecal)
 
static const DlDilateImageFilter kTestDilateImageFilter1 (5.0, 5.0)
 
static const DlDilateImageFilter kTestDilateImageFilter2 (6.0, 5.0)
 
static const DlDilateImageFilter kTestDilateImageFilter3 (5.0, 6.0)
 
static const DlErodeImageFilter kTestErodeImageFilter1 (4.0, 4.0)
 
static const DlErodeImageFilter kTestErodeImageFilter2 (4.0, 3.0)
 
static const DlErodeImageFilter kTestErodeImageFilter3 (3.0, 4.0)
 
static const DlMatrixImageFilter kTestMatrixImageFilter1 (SkMatrix::RotateDeg(45), kNearestSampling)
 
static const DlMatrixImageFilter kTestMatrixImageFilter2 (SkMatrix::RotateDeg(85), kNearestSampling)
 
static const DlMatrixImageFilter kTestMatrixImageFilter3 (SkMatrix::RotateDeg(45), kLinearSampling)
 
static const DlComposeImageFilter kTestComposeImageFilter1 (kTestBlurImageFilter1, kTestMatrixImageFilter1)
 
static const DlComposeImageFilter kTestComposeImageFilter2 (kTestBlurImageFilter2, kTestMatrixImageFilter1)
 
static const DlComposeImageFilter kTestComposeImageFilter3 (kTestBlurImageFilter1, kTestMatrixImageFilter2)
 
static const DlColorFilterImageFilter kTestCFImageFilter1 (kTestBlendColorFilter1)
 
static const DlColorFilterImageFilter kTestCFImageFilter2 (kTestBlendColorFilter2)
 
static const DlBlurMaskFilter kTestMaskFilter1 (DlBlurStyle::kNormal, 3.0)
 
static const DlBlurMaskFilter kTestMaskFilter2 (DlBlurStyle::kNormal, 5.0)
 
static const DlBlurMaskFilter kTestMaskFilter3 (DlBlurStyle::kSolid, 3.0)
 
static const DlBlurMaskFilter kTestMaskFilter4 (DlBlurStyle::kInner, 3.0)
 
static const DlBlurMaskFilter kTestMaskFilter5 (DlBlurStyle::kOuter, 3.0)
 
static sk_sp< DisplayListMakeTestDisplayList (int w, int h, SkColor color)
 
 TEST (DisplayListMatrixClipTracker, Constructor)
 
 TEST (DisplayListMatrixClipState, Constructor)
 
 TEST (DisplayListMatrixClipTracker, Constructor4x4)
 
 TEST (DisplayListMatrixClipState, Constructor4x4)
 
 TEST (DisplayListMatrixClipTracker, TransformTo4x4)
 
 TEST (DisplayListMatrixClipState, TransformTo4x4)
 
 TEST (DisplayListMatrixClipTracker, SetTo4x4)
 
 TEST (DisplayListMatrixClipState, SetTo4x4)
 
 TEST (DisplayListMatrixClipTracker, UpgradeTo4x4SaveAndRestore)
 
 TEST (DisplayListMatrixClipTracker, Translate)
 
 TEST (DisplayListMatrixClipState, Translate)
 
 TEST (DisplayListMatrixClipTracker, Scale)
 
 TEST (DisplayListMatrixClipState, Scale)
 
 TEST (DisplayListMatrixClipTracker, Skew)
 
 TEST (DisplayListMatrixClipState, Skew)
 
 TEST (DisplayListMatrixClipTracker, Rotate)
 
 TEST (DisplayListMatrixClipState, Rotate)
 
 TEST (DisplayListMatrixClipTracker, Transform2DAffine)
 
 TEST (DisplayListMatrixClipState, Transform2DAffine)
 
 TEST (DisplayListMatrixClipTracker, TransformFullPerspectiveUsing3x3Matrix)
 
 TEST (DisplayListMatrixClipState, TransformFullPerspectiveUsing3x3Matrix)
 
 TEST (DisplayListMatrixClipTracker, TransformFullPerspectiveUsing4x4Matrix)
 
 TEST (DisplayListMatrixClipState, TransformFullPerspectiveUsing4x4Matrix)
 
 TEST (DisplayListMatrixClipTracker, ClipDifference)
 
 TEST (DisplayListMatrixClipTracker, ClipPathWithInvertFillType)
 
 TEST (DisplayListMatrixClipState, ClipPathWithInvertFillType)
 
 TEST (DisplayListMatrixClipTracker, DiffClipPathWithInvertFillType)
 
 TEST (DisplayListMatrixClipState, DiffClipPathWithInvertFillType)
 
 TEST_F (DiffContextTest, ClipAlignment)
 
 TEST (EmbeddedViewParams, GetBoundingRectAfterMutationsWithNoMutations)
 
 TEST (EmbeddedViewParams, GetBoundingRectAfterMutationsWithScale)
 
 TEST (EmbeddedViewParams, GetBoundingRectAfterMutationsWithTranslate)
 
 TEST (EmbeddedViewParams, GetBoundingRectAfterMutationsWithRotation90)
 
 TEST (EmbeddedViewParams, GetBoundingRectAfterMutationsWithRotation45)
 
 TEST (EmbeddedViewParams, GetBoundingRectAfterMutationsWithTranslateScaleAndRotation)
 
 TEST (GLContextSwitchTest, SwitchKeepsContextCurrentWhileInScope)
 
 TEST_F (BackdropFilterLayerTest, PaintingEmptyLayerDies)
 
 TEST_F (BackdropFilterLayerTest, PaintBeforePrerollDies)
 
 TEST_F (BackdropFilterLayerTest, EmptyFilter)
 
 TEST_F (BackdropFilterLayerTest, SimpleFilter)
 
 TEST_F (BackdropFilterLayerTest, NonSrcOverBlend)
 
 TEST_F (BackdropFilterLayerTest, MultipleChildren)
 
 TEST_F (BackdropFilterLayerTest, Nested)
 
 TEST_F (BackdropFilterLayerTest, Readback)
 
 TEST_F (BackdropFilterLayerTest, OpacityInheritance)
 
 TEST_F (BackdropLayerDiffTest, BackdropLayer)
 
 TEST_F (BackdropLayerDiffTest, ReadbackOutsideOfPaintArea)
 
 TEST_F (BackdropLayerDiffTest, BackdropLayerInvalidTransform)
 
 TEST_F (CheckerBoardLayerTest, ClipRectSaveLayerCheckBoard)
 
 TEST_F (CheckerBoardLayerTest, ClipPathSaveLayerCheckBoard)
 
 TEST_F (CheckerBoardLayerTest, ClipRRectSaveLayerCheckBoard)
 
 TEST_F (ClipPathLayerTest, ClipNoneBehaviorDies)
 
 TEST_F (ClipPathLayerTest, PaintingCulledLayerDies)
 
 TEST_F (ClipPathLayerTest, ChildOutsideBounds)
 
 TEST_F (ClipPathLayerTest, FullyContainedChild)
 
 TEST_F (ClipPathLayerTest, PartiallyContainedChild)
 
static bool ReadbackResult (PrerollContext *context, Clip clip_behavior, const std::shared_ptr< Layer > &child, bool before)
 
 TEST_F (ClipPathLayerTest, OpacityInheritancePainting)
 
 TEST_F (ClipPathLayerTest, OpacityInheritanceSaveLayerPainting)
 
 TEST_F (ClipPathLayerTest, LayerCached)
 
 TEST_F (ClipPathLayerTest, EmptyClipDoesNotCullPlatformView)
 
static bool ReadbackResult (PrerollContext *context, Clip clip_behavior, const std::shared_ptr< Layer > &child, bool before)
 
static bool ReadbackResult (PrerollContext *context, Clip clip_behavior, const std::shared_ptr< Layer > &child, bool before)
 
 TEST_F (ClipRRectLayerTest, NoSaveLayerShouldNotCache)
 
 TEST_F (ColorFilterLayerTest, CacheChild)
 
 TEST_F (ColorFilterLayerTest, CacheChildren)
 
 TEST_F (ColorFilterLayerTest, CacheColorFilterLayerSelf)
 
 TEST_F (ContainerLayerTest, LayerWithParentHasPlatformView)
 
 TEST_F (ContainerLayerTest, LayerWithParentHasTextureLayer)
 
 TEST_F (ContainerLayerTest, LayerWithParentHasTextureLayerNeedsResetFlag)
 
 TEST_F (ContainerLayerTest, Simple)
 
 TEST_F (ContainerLayerTest, Multiple)
 
 TEST_F (ContainerLayerTest, MultipleWithEmpty)
 
 TEST_F (ContainerLayerTest, NeedsSystemComposite)
 
 TEST_F (ContainerLayerTest, RasterCacheTest)
 
 TEST_F (ContainerLayerTest, CollectionCacheableLayer)
 
 TEST_F (ContainerLayerDiffTest, PictureLayerInsertion)
 
 TEST_F (ContainerLayerDiffTest, PictureInsertion)
 
 TEST_F (ContainerLayerDiffTest, LayerDeletion)
 
 TEST_F (ContainerLayerDiffTest, ReplaceLayer)
 
 TEST_F (DisplayListLayerTest, PaintBeforePrerollInvalidDisplayListDies)
 
 TEST_F (DisplayListLayerTest, InvalidDisplayListDies)
 
 TEST_F (DisplayListLayerTest, SimpleDisplayList)
 
 TEST_F (DisplayListLayerTest, CachingDoesNotChangeCullRect)
 
 TEST_F (DisplayListLayerTest, SimpleDisplayListOpacityInheritance)
 
 TEST_F (DisplayListLayerTest, IncompatibleDisplayListOpacityInheritance)
 
 TEST_F (DisplayListLayerTest, CachedIncompatibleDisplayListOpacityInheritance)
 
 TEST_F (DisplayListLayerTest, RasterCachePreservesRTree)
 
 TEST_F (DisplayListLayerDiffTest, SimpleDisplayList)
 
 TEST_F (DisplayListLayerDiffTest, FractionalTranslation)
 
 TEST_F (DisplayListLayerDiffTest, FractionalTranslationWithRasterCache)
 
 TEST_F (DisplayListLayerDiffTest, DisplayListCompare)
 
 TEST_F (DisplayListLayerTest, LayerTreeSnapshotsWhenEnabled)
 
 TEST_F (DisplayListLayerTest, NoLayerTreeSnapshotsWhenDisabledByDefault)
 
 TEST_F (DisplayListLayerTest, DisplayListAccessCountDependsOnVisibility)
 
 TEST_F (DisplayListLayerTest, OverflowCachedDisplayListOpacityInheritance)
 
 TEST_F (ImageFilterLayerTest, SimpleFilterWithOffset)
 
 TEST_F (ImageFilterLayerTest, SimpleFilterBounds)
 
 TEST_F (ImageFilterLayerTest, CacheImageFilterLayerSelf)
 
 TEST_F (ImageFilterLayerDiffTest, ImageFilterLayer)
 
 TEST_F (ImageFilterLayerDiffTest, ImageFilterLayerInflatestChildSize)
 
 TEST_F (ImageFilterLayerTest, EmptyFilterWithOffset)
 
 TEST (LayerStateStack, AccessorsDieWithoutDelegate)
 
 TEST (LayerStateStack, Defaults)
 
 TEST (LayerStateStack, SingularDelegate)
 
 TEST (LayerStateStack, OldDelegateIsRolledBack)
 
 TEST (LayerStateStack, Opacity)
 
 TEST (LayerStateStack, ColorFilter)
 
 TEST (LayerStateStack, ImageFilter)
 
 TEST (LayerStateStack, OpacityAndColorFilterInteraction)
 
 TEST (LayerStateStack, OpacityAndImageFilterInteraction)
 
 TEST (LayerStateStack, ColorFilterAndImageFilterInteraction)
 
 TEST_F (LayerTreeTest, PaintingEmptyLayerDies)
 
 TEST_F (LayerTreeTest, PaintBeforePrerollDies)
 
 TEST_F (LayerTreeTest, Simple)
 
 TEST_F (LayerTreeTest, Multiple)
 
 TEST_F (LayerTreeTest, MultipleWithEmpty)
 
 TEST_F (LayerTreeTest, NeedsSystemComposite)
 
 TEST_F (LayerTreeTest, PrerollContextInitialization)
 
 TEST_F (LayerTreeTest, PaintContextInitialization)
 
 TEST (OffscreenSurfaceTest, EmptySurfaceIsInvalid)
 
 TEST (OffscreenSurfaceTest, OnexOneSurfaceIsValid)
 
 TEST (OffscreenSurfaceTest, PaintSurfaceBlack)
 
 TEST_F (OpacityLayerTest, TranslateChildren)
 
 TEST_F (OpacityLayerTest, ShouldNotCacheChildren)
 
 TEST_F (OpacityLayerTest, FullyOpaque)
 
 TEST_F (OpacityLayerTest, FullyTransparent)
 
 TEST_F (OpacityLayerTest, HalfTransparent)
 
 TEST_F (OpacityLayerTest, CullRectIsTransformed)
 
 TEST_F (OpacityLayerTest, OpacityInheritanceCompatibleChild)
 
 TEST_F (OpacityLayerTest, OpacityInheritanceIncompatibleChild)
 
 TEST_F (OpacityLayerTest, OpacityInheritanceThroughContainer)
 
 TEST_F (OpacityLayerTest, OpacityInheritanceThroughTransform)
 
 TEST_F (OpacityLayerTest, OpacityInheritanceThroughImageFilter)
 
 TEST_F (OpacityLayerTest, OpacityInheritanceNestedWithCompatibleChild)
 
 TEST_F (OpacityLayerTest, OpacityInheritanceNestedWithIncompatibleChild)
 
 TEST_F (OpacityLayerTest, FullyOpaqueWithFractionalValues)
 
 TEST_F (OpacityLayerTest, FullyTransparentDoesNotCullPlatformView)
 
 TEST_F (PerformanceOverlayLayerTest, InvalidOptions)
 
 TEST_F (PerformanceOverlayLayerTest, SimpleRasterizerStatistics)
 
 TEST_F (PerformanceOverlayLayerTest, MarkAsDirtyWhenResized)
 
 TEST (PerformanceOverlayLayerDefault, Gold)
 
 TEST (PerformanceOverlayLayer90fps, Gold)
 
 TEST (PerformanceOverlayLayer120fps, Gold)
 
 TEST_F (PlatformViewLayerTest, NullViewEmbedderDoesntPrerollCompositeOrPaint)
 
 TEST_F (PlatformViewLayerTest, ClippedPlatformViewPrerollsAndPaintsNothing)
 
 TEST_F (PlatformViewLayerTest, StateTransfer)
 
static std::shared_ptr< DlColorSourceMakeFilter (DlColor color)
 
 TEST_F (ShaderMaskLayerTest, SimpleFilterWithRasterCacheLayerNotCached)
 
 TEST_F (TextureLayerTest, InvalidTexture)
 
 TEST_F (TextureLayerTest, PaintingWithLinearSampling)
 
 TEST_F (TextureLayerDiffTest, TextureInRetainedLayer)
 
 TEST_F (TransformLayerTest, Identity)
 
 TEST_F (TransformLayerTest, SimpleM44)
 
 TEST_F (TransformLayerTest, ComplexM44)
 
 TEST_F (TransformLayerTest, NestedSeparated)
 
 TEST_F (TransformLayerLayerDiffTest, Transform)
 
 TEST_F (TransformLayerLayerDiffTest, TransformNested)
 
 TEST (MutatorsStack, Initialization)
 
 TEST (MutatorsStack, CopyConstructor)
 
 TEST (MutatorsStack, CopyAndUpdateTheCopy)
 
 TEST (MutatorsStack, PushClipRect)
 
 TEST (MutatorsStack, PushClipRRect)
 
 TEST (MutatorsStack, PushClipPath)
 
 TEST (MutatorsStack, PushTransform)
 
 TEST (MutatorsStack, PushOpacity)
 
 TEST (MutatorsStack, PushBackdropFilter)
 
 TEST (MutatorsStack, Pop)
 
 TEST (MutatorsStack, Traversal)
 
 TEST (MutatorsStack, Equality)
 
 TEST (Mutator, Initialization)
 
 TEST (Mutator, CopyConstructor)
 
 TEST (Mutator, Equality)
 
 TEST (Mutator, UnEquality)
 
 TEST (RasterCache, SimpleInitialization)
 
 TEST (RasterCache, MetricsOmitUnpopulatedEntries)
 
 TEST (RasterCache, ThresholdIsRespectedForDisplayList)
 
 TEST (RasterCache, SetCheckboardCacheImages)
 
 TEST (RasterCache, AccessThresholdOfZeroDisablesCachingForDisplayList)
 
 TEST (RasterCache, PictureCacheLimitPerFrameIsRespectedWhenZeroForDisplayList)
 
 TEST (RasterCache, EvictUnusedCacheEntries)
 
 TEST (RasterCache, ComputeDeviceRectBasedOnFractionalTranslation)
 
 TEST (RasterCache, DeviceRectRoundOutForDisplayList)
 
 TEST (RasterCache, NestedOpCountMetricUsedForDisplayList)
 
 TEST (RasterCache, NaiveComplexityScoringDisplayList)
 
 TEST (RasterCache, DisplayListWithSingularMatrixIsNotCached)
 
 TEST (RasterCache, PrepareLayerTransform)
 
 TEST (RasterCache, RasterCacheKeyHashFunction)
 
 TEST (RasterCache, RasterCacheKeySameID)
 
 TEST (RasterCache, RasterCacheKeySameType)
 
 TEST (RasterCache, RasterCacheKeyIDEqual)
 
 TEST (RasterCache, RasterCacheKeyIDHashCode)
 
 TEST_F (RasterCacheTest, RasterCacheKeyIDLayerChildrenIds)
 
 TEST (RasterCacheUtilsTest, SkMatrixIntegralTransCTM)
 
 TEST (RasterCacheUtilsTest, SkM44IntegralTransCTM)
 
 TEST_F (SkiaGpuObjectTest, QueueSimple)
 
 TEST_F (SkiaGpuObjectTest, ObjectDestructor)
 
 TEST_F (SkiaGpuObjectTest, ObjectReset)
 
 TEST_F (SkiaGpuObjectTest, ObjectResetTwice)
 
 TEST_F (SkiaGpuObjectTest, UnrefResourceContextInTaskRunnerThread)
 
static SkRect MakeRectFromVertices (SkPoint vertices[6])
 
 TEST (DlVertexPainter, DrawRectIntoVertices)
 
 TEST (Instrumentation, GetDefaultFrameBudgetTest)
 
 TEST (Instrumentation, GetOneShotFrameBudgetTest)
 
 TEST (Instrumentation, GetFrameBudgetFromUpdaterTest)
 
 TEST (Instrumentation, GetLapByIndexTest)
 
 TEST (Instrumentation, GetCurrentSampleTest)
 
 TEST (Instrumentation, GetLapsCount)
 
 TEST_F (MockLayerTest, SimpleParams)
 
 TEST_F (MockLayerTest, FakePlatformView)
 
 TEST_F (MockLayerTest, SaveLayerOnLeafNodesCanvas)
 
 TEST_F (MockLayerTest, FlagGetSet)
 
PrerollContextHolder GetSamplePrerollContextHolder (LayerStateStack &state_stack, RasterCache *raster_cache, FixedRefreshRateStopwatch *raster_time, FixedRefreshRateStopwatch *ui_time)
 
PaintContextHolder GetSamplePaintContextHolder (LayerStateStack &state_stack, RasterCache *raster_cache, FixedRefreshRateStopwatch *raster_time, FixedRefreshRateStopwatch *ui_time)
 
bool RasterCacheItemPrerollAndTryToRasterCache (DisplayListRasterCacheItem &display_list_item, PrerollContext &context, PaintContext &paint_context, const SkMatrix &matrix)
 
void RasterCacheItemPreroll (DisplayListRasterCacheItem &display_list_item, PrerollContext &context, const SkMatrix &matrix)
 
bool RasterCacheItemTryToRasterCache (DisplayListRasterCacheItem &display_list_item, PaintContext &paint_context)
 
 TEST (MockTextureTest, Callbacks)
 
 TEST (MockTextureTest, PaintCalls)
 
 TEST (MockTextureTest, PaintCallsWithLinearSampling)
 
 TEST (TextureRegistryTest, UnregisterTextureCallbackTriggered)
 
 TEST (TextureRegistryTest, GrContextCallbackTriggered)
 
 TEST (TextureRegistryTest, RegisterTextureTwice)
 
 TEST (TextureRegistryTest, ReuseSameTextureSlot)
 
 TEST (TextureRegistryTest, CallsOnGrContextCreatedInInsertionOrder)
 
 TEST (MathTest, Constants)
 
 TEST_F (ShellTest, SceneBuilderBuildAndSceneDisposeReleasesLayerStack)
 
 TEST_F (ShellTest, EngineLayerDisposeReleasesReference)
 
 TEST_F (HooksTest, HooksUnitTests)
 
float HalfToFloat (uint16_t half)
 
float DecodeBGR10 (uint32_t x)
 
 TEST (ImageDecoderNoGLTest, ImpellerWideGamutDisplayP3)
 
 TEST (ImageDecoderNoGLTest, ImpellerWideGamutIndexedPng)
 
 TEST_F (ImageDisposeTest, ImageReleasedAfterFrameAndDisposePictureAndLayer)
 
 TEST_F (ShellTest, EncodeImageGivesExternalTypedData)
 
 TEST_F (ShellTest, EncodeImageAccessesSyncSwitch)
 
static sk_sp< SkDataLoadValidImageFixture ()
 
 TEST_F (ShellTest, CreateCompatibleReturnsBuiltinImageGeneratorForValidImage)
 
 TEST_F (ShellTest, CreateCompatibleReturnsNullptrForInvalidImage)
 
 TEST_F (ShellTest, PositivePriorityTakesPrecedentOverDefaultGenerators)
 
 TEST_F (ShellTest, DefaultGeneratorsTakePrecedentOverNegativePriority)
 
 TEST_F (ShellTest, DefaultGeneratorsTakePrecedentOverZeroPriority)
 
 TEST_F (ShellTest, ImageGeneratorsWithSamePriorityCascadeChronologically)
 
 TEST_F (ShellTest, ConvertPaintToDlPaint)
 
 TEST_F (ShellTest, PathVolatilityOldPathsBecomeNonVolatile)
 
 TEST_F (ShellTest, PathVolatilityGCRemovesPathFromTracker)
 
 TEST_F (ShellTest, DeterministicRenderingDisablesPathVolatility)
 
 TEST_F (ShellTest, SingleFrameCodecAccuratelyReportsSize)
 
 TEST_F (SemanticsUpdateBuilderTest, CanHandleAttributedStrings)
 
 TEST_F (PlatformConfigurationTest, Initialization)
 
 TEST_F (PlatformConfigurationTest, WindowMetricsUpdate)
 
 TEST_F (PlatformConfigurationTest, GetWindowReturnsNullForNonexistentId)
 
 TEST_F (PlatformConfigurationTest, OnErrorHandlesError)
 
 TEST_F (PlatformConfigurationTest, OnErrorDoesNotHandleError)
 
 TEST_F (PlatformConfigurationTest, OnErrorThrows)
 
 TEST_F (PlatformConfigurationTest, SetDartPerformanceMode)
 
 TEST_F (ShellTest, PlatformMessageResponseDartPort)
 
 TEST_F (ShellTest, PlatformMessageResponseDart)
 
void CreateSimulatedPointerData (PointerData &data, PointerData::Change change, int64_t device, double dx, double dy, int64_t buttons)
 
void CreateSimulatedMousePointerData (PointerData &data, PointerData::Change change, PointerData::SignalKind signal_kind, int64_t device, double dx, double dy, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
 
void CreateSimulatedTrackpadGestureData (PointerData &data, PointerData::Change change, int64_t device, double dx, double dy, double pan_x, double pan_y, double scale, double rotation)
 
void UnpackPointerPacket (std::vector< PointerData > &output, std::unique_ptr< PointerDataPacket > packet)
 
 TEST (PointerDataPacketConverterTest, CanConvertPointerDataPacket)
 
 TEST (PointerDataPacketConverterTest, CanSynthesizeDownAndUp)
 
 TEST (PointerDataPacketConverterTest, CanUpdatePointerIdentifier)
 
 TEST (PointerDataPacketConverterTest, AlwaysForwardMoveEvent)
 
 TEST (PointerDataPacketConverterTest, CanWorkWithDifferentDevices)
 
 TEST (PointerDataPacketConverterTest, CanSynthesizeAdd)
 
 TEST (PointerDataPacketConverterTest, CanHandleThreeFingerGesture)
 
 TEST (PointerDataPacketConverterTest, CanConvertPointerSignals)
 
 TEST (PointerDataPacketConverterTest, CanConvertTrackpadGesture)
 
 TEST (PointerDataPacketConverterTest, CanConvertViewId)
 
void CreateSimpleSimulatedPointerData (PointerData &data, PointerData::Change change, int64_t device, double dx, double dy, int64_t buttons)
 
 TEST (PointerDataPacketTest, CanGetPointerData)
 
 TEST (PointerDataPacketTest, CanGetLength)
 
 TEST_F (DartIsolateTest, RootIsolateCreationAndShutdown)
 
 TEST_F (DartIsolateTest, IsolateShutdownCallbackIsInIsolateScope)
 
 TEST_F (DartIsolateTest, IsolateCanLoadAndRunDartCode)
 
 TEST_F (DartIsolateTest, IsolateCannotLoadAndRunUnknownDartEntrypoint)
 
 TEST_F (DartIsolateTest, CanRunDartCodeCodeSynchronously)
 
 TEST_F (DartIsolateTest, ImpellerFlagIsCorrectWhenTrue)
 
 TEST_F (DartIsolateTest, ImpellerFlagIsCorrectWhenFalse)
 
 TEST_F (DartIsolateTest, CanRegisterNativeCallback)
 
 TEST_F (DartSecondaryIsolateTest, CanLaunchSecondaryIsolates)
 
 TEST_F (IsolateStartupFailureTest, HandlesIsolateInitializationFailureCorrectly)
 
 TEST_F (DartIsolateTest, CanReceiveArguments)
 
 TEST_F (DartIsolateTest, CanCreateServiceIsolate)
 
 TEST_F (DartIsolateTest, RootIsolateCreateCallbackIsMadeOnceAndBeforeIsolateRunning)
 
 TEST_F (DartIsolateTest, IsolateCreateCallbacksTakeInstanceSettingsInsteadOfVMSettings)
 
 TEST_F (DartIsolateTest, InvalidLoadingUnitFails)
 
 TEST_F (DartIsolateTest, DartPluginRegistrantIsCalled)
 
 TEST_F (DartIsolateTest, SpawningAnIsolateDoesNotReloadKernel)
 
 TEST_F (DartIsolateTest, PlatformIsolateCreationAndShutdown)
 
 TEST_F (DartIsolateTest, PlatformIsolateEarlyShutdown)
 
 TEST_F (DartIsolateTest, PlatformIsolateSendAndReceive)
 
 TEST_F (DartIsolateTest, PlatformIsolateCreationAfterManagerShutdown)
 
 TEST_F (DartIsolateTest, PlatformIsolateManagerShutdownBeforeMainRuns)
 
 TEST_F (DartIsolateTest, PlatformIsolateMainThrowsError)
 
 TEST_F (DartLifecycleTest, CanStartAndShutdownVM)
 
 TEST_F (DartLifecycleTest, CanStartAndShutdownVMOverAndOver)
 
static std::shared_ptr< DartIsolateCreateAndRunRootIsolate (const Settings &settings, const DartVMData &vm, const fml::RefPtr< fml::TaskRunner > &task_runner, std::string entrypoint)
 
 TEST_F (DartLifecycleTest, DISABLED_ShuttingDownTheVMShutsDownAllIsolates)
 
 TEST_F (DartIsolateTest, DartPluginRegistrantIsPresent)
 
 TEST_F (DartIsolateTest, DartPluginRegistrantFromBackgroundIsolate)
 
 TEST_F (DartIsolateTest, DartPluginRegistrantNotFromBackgroundIsolate)
 
 TEST_F (DartIsolateTest, DartPluginRegistrantWhenRegisteringBackgroundIsolate)
 
 TEST_F (DartVMTest, SimpleInitialization)
 
 TEST_F (DartVMTest, SimpleIsolateNameServer)
 
 TEST_F (DartVMTest, OldGenHeapSize)
 
 TEST_F (DartVMTest, DisableTimelineEventHandler)
 
 TEST_F (DartVMTest, TraceGetTimelineMicrosDoesNotGetClockWhenSystraceIsEnabled)
 
 TEST_F (DartIsolateTest, DartPluginRegistrantIsNotPresent)
 
 TEST_F (PlatformIsolateManagerTest, OrdinaryFlow)
 
 TEST_F (PlatformIsolateManagerTest, EarlyShutdown)
 
 TEST_F (PlatformIsolateManagerTest, RegistrationAfterShutdown)
 
 TEST_F (PlatformIsolateManagerTest, MultithreadedCreation)
 
 TEST_F (TypeConversionsTest, TestFixture)
 
 TEST_F (TypeConversionsTest, CanConvertEmptyList)
 
 TEST_F (TypeConversionsTest, CanConvertListOfStrings)
 
 TEST_F (TypeConversionsTest, CanConvertListOfDoubles)
 
 TEST_F (TypeConversionsTest, CanConvertListOfInts)
 
 TEST_F (ShellTest, VSyncTargetTime)
 
 TEST_F (ShellTest, AnimatorDoesNotNotifyIdleBeforeRender)
 
 TEST_F (ShellTest, AnimatorDoesNotNotifyDelegateIfPipelineIsNotEmpty)
 
 TEST (Base64, EncodeStrings)
 
 TEST (Base64, EncodeBytes)
 
 TEST (Base64, DecodeStringsSuccess)
 
 TEST (Base64, DecodeStringsHasErrors)
 
 TEST (Base64, DecodeBytes)
 
 TEST (ContextOptionsTest, OpenGLDisablesStencilBuffers)
 
 TEST (DlOpSpy, DidDrawIsFalseByDefault)
 
 TEST (DlOpSpy, EmptyDisplayList)
 
 TEST (DlOpSpy, SetColor)
 
 TEST (DlOpSpy, SetColorSource)
 
 TEST (DlOpSpy, DrawColor)
 
 TEST (DlOpSpy, DrawPaint)
 
 TEST (DlOpSpy, DrawLine)
 
 TEST (DlOpSpy, DrawRect)
 
 TEST (DlOpSpy, DrawOval)
 
 TEST (DlOpSpy, DrawCircle)
 
 TEST (DlOpSpy, DrawRRect)
 
 TEST (DlOpSpy, DrawPath)
 
 TEST (DlOpSpy, DrawArc)
 
 TEST (DlOpSpy, DrawPoints)
 
 TEST (DlOpSpy, DrawVertices)
 
 TEST (DlOpSpy, Images)
 
 TEST (DlOpSpy, DrawDisplayList)
 
 TEST (DlOpSpy, DrawTextBlob)
 
 TEST (DlOpSpy, DrawShadow)
 
static void TestSimulatedInputEvents (ShellTest *fixture, int num_events, UnitlessTime base_latency, Generator delivery_time, UnitlessTime frame_time, std::vector< UnitlessTime > &events_consumed_at_frame, bool restart_engine=false)
 
void CreateSimulatedPointerData (PointerData &data, PointerData::Change change, double dx, double dy)
 
 TEST_F (ShellTest, MissAtMostOneFrameForIrregularInputEvents)
 
 TEST_F (ShellTest, DelayAtMostOneEventForFasterThanVSyncInputEvents)
 
 TEST_F (ShellTest, HandlesActualIphoneXsInputEvents)
 
 TEST_F (ShellTest, CanCorrectlyPipePointerPacket)
 
 TEST_F (ShellTest, CanCorrectlySynthesizePointerPacket)
 
static void CheckTextSkData (const sk_sp< SkData > &data, const std::string &expected)
 
static void ResetAssetManager ()
 
static void CheckTwoSkSLsAreLoaded ()
 
 TEST_F (PersistentCacheTest, CanLoadSkSLsFromAsset)
 
 TEST_F (PersistentCacheTest, CanRemoveOldPersistentCache)
 
 TEST_F (PersistentCacheTest, CanPurgePersistentCache)
 
 TEST_F (PersistentCacheTest, PurgeAllowsFutureSkSLCache)
 
 TEST (PipelineTest, ConsumeOneVal)
 
 TEST (PipelineTest, ContinuationCanOnlyBeUsedOnce)
 
 TEST (PipelineTest, PushingMoreThanDepthCompletesFirstSubmission)
 
 TEST (PipelineTest, PushingMultiProcessesInOrder)
 
 TEST (PipelineTest, ProduceIfEmptyDoesNotConsumeWhenQueueIsNotEmpty)
 
 TEST (PipelineTest, ProduceIfEmptySuccessfulIfQueueIsEmpty)
 
 TEST (ResourceCacheLimitCalculatorTest, GetResourceCacheMaxBytes)
 
 TEST_F (FuchsiaShellTest, LocaltimesVaryOnTimezoneChanges)
 
 TEST_F (ShellIOManagerTest, ItDoesNotCrashThatSkiaUnrefQueueDrainAfterIOManagerReset)
 
static std::vector< std::shared_ptr< fml::Mapping > > ShaderLibraryMappings ()
 
static fml::scoped_nsprotocol< id< MTLTexture > > CreateOffscreenTexture (id< MTLDevice > device)
 
static bool ValidateShell (Shell *shell)
 
static bool RasterizerIsTornDown (Shell *shell)
 
static void ValidateDestroyPlatformView (Shell *shell)
 
static std::string CreateFlagsString (std::vector< const char * > &flags)
 
static void TestDartVmFlags (std::vector< const char * > &flags)
 
static void PostSync (const fml::RefPtr< fml::TaskRunner > &task_runner, const fml::closure &task)
 
static sk_sp< DisplayListMakeSizedDisplayList (int width, int height)
 
 TEST_F (ShellTest, InitializeWithInvalidThreads)
 
 TEST_F (ShellTest, InitializeWithDifferentThreads)
 
 TEST_F (ShellTest, InitializeWithSingleThread)
 
 TEST_F (ShellTest, InitializeWithSingleThreadWhichIsTheCallingThread)
 
 TEST_F (ShellTest, InitializeWithMultipleThreadButCallingThreadAsPlatformThread)
 
 TEST_F (ShellTest, InitializeWithDisabledGpu)
 
 TEST_F (ShellTest, InitializeWithGPUAndPlatformThreadsTheSame)
 
 TEST_F (ShellTest, FixturesAreFunctional)
 
 TEST_F (ShellTest, SecondaryIsolateBindingsAreSetupViaShellSettings)
 
 TEST_F (ShellTest, LastEntrypoint)
 
 TEST_F (ShellTest, LastEntrypointArgs)
 
 TEST_F (ShellTest, DisallowedDartVMFlag)
 
 TEST_F (ShellTest, AllowedDartVMFlag)
 
 TEST_F (ShellTest, NoNeedToReportTimingsByDefault)
 
 TEST_F (ShellTest, NeedsReportTimingsIsSetWithCallback)
 
static void CheckFrameTimings (const std::vector< FrameTiming > &timings, fml::TimePoint start, fml::TimePoint finish)
 
 TEST_F (ShellTest, ReportTimingsIsCalled)
 
 TEST_F (ShellTest, FrameRasterizedCallbackIsCalled)
 
 TEST_F (ShellTest, ExternalEmbedderNoThreadMerger)
 
 TEST_F (ShellTest, PushBackdropFilterToVisitedPlatformViews)
 
 TEST_F (ShellTest, ExternalEmbedderEndFrameIsCalledWhenPostPrerollResultIsResubmit)
 
 TEST_F (ShellTest, OnPlatformViewDestroyDisablesThreadMerger)
 
 TEST_F (ShellTest, OnPlatformViewDestroyAfterMergingThreads)
 
 TEST_F (ShellTest, OnPlatformViewDestroyWhenThreadsAreMerging)
 
 TEST_F (ShellTest, OnPlatformViewDestroyWithThreadMergerWhileThreadsAreUnmerged)
 
 TEST_F (ShellTest, OnPlatformViewDestroyWithoutRasterThreadMerger)
 
 TEST_F (ShellTest, OnPlatformViewDestroyWithStaticThreadMerging)
 
 TEST_F (ShellTest, GetUsedThisFrameShouldBeSetBeforeEndFrame)
 
 TEST_F (ShellTest, DISABLED_SkipAndSubmitFrame)
 
 TEST (SettingsTest, FrameTimingSetsAndGetsProperly)
 
 TEST_F (ShellTest, ReportTimingsIsCalledImmediatelyAfterTheFirstFrame)
 
 TEST_F (ShellTest, WaitForFirstFrame)
 
 TEST_F (ShellTest, WaitForFirstFrameZeroSizeFrame)
 
 TEST_F (ShellTest, WaitForFirstFrameTimeout)
 
 TEST_F (ShellTest, WaitForFirstFrameMultiple)
 
 TEST_F (ShellTest, WaitForFirstFrameInlined)
 
static size_t GetRasterizerResourceCacheBytesSync (const Shell &shell)
 
 TEST_F (ShellTest, MultipleFluttersSetResourceCacheBytes)
 
 TEST_F (ShellTest, SetResourceCacheSize)
 
 TEST_F (ShellTest, SetResourceCacheSizeEarly)
 
 TEST_F (ShellTest, SetResourceCacheSizeNotifiesDart)
 
 TEST_F (ShellTest, CanCreateImagefromDecompressedBytes)
 
 TEST_F (ShellTest, TextureFrameMarkedAvailableAndUnregister)
 
 TEST_F (ShellTest, IsolateCanAccessPersistentIsolateData)
 
 TEST_F (ShellTest, CanScheduleFrameFromPlatform)
 
 TEST_F (ShellTest, SecondaryVsyncCallbackShouldBeCalledAfterVsyncCallback)
 
static void LogSkData (const sk_sp< SkData > &data, const char *title)
 
 TEST_F (ShellTest, Screenshot)
 
 TEST_F (ShellTest, LocaltimesMatch)
 
 TEST_F (ShellTest, CanRegisterImageDecoders)
 
 TEST_F (ShellTest, OnServiceProtocolGetSkSLsWorks)
 
 TEST_F (ShellTest, RasterizerScreenshot)
 
 TEST_F (ShellTest, RasterizerMakeRasterSnapshot)
 
 TEST_F (ShellTest, OnServiceProtocolEstimateRasterCacheMemoryWorks)
 
 TEST_F (ShellTest, OnServiceProtocolRenderFrameWithRasterStatsWorks)
 
 TEST_F (ShellTest, DISABLED_DiscardLayerTreeOnResize)
 
 TEST_F (ShellTest, DISABLED_DiscardResubmittedLayerTreeOnResize)
 
 TEST_F (ShellTest, IgnoresInvalidMetrics)
 
 TEST_F (ShellTest, IgnoresMetricsUpdateToInvalidView)
 
 TEST_F (ShellTest, OnServiceProtocolSetAssetBundlePathWorks)
 
 TEST_F (ShellTest, EngineRootIsolateLaunchesDontTakeVMDataSettings)
 
 TEST_F (ShellTest, AssetManagerSingle)
 
 TEST_F (ShellTest, AssetManagerMulti)
 
 TEST_F (ShellTest, Spawn)
 
 TEST_F (ShellTest, SpawnWithDartEntrypointArgs)
 
 TEST_F (ShellTest, IOManagerIsSharedBetweenParentAndSpawnedShell)
 
 TEST_F (ShellTest, IOManagerInSpawnedShellIsNotNullAfterParentShellDestroyed)
 
 TEST_F (ShellTest, ImageGeneratorRegistryNotNullAfterParentShellDestroyed)
 
 TEST_F (ShellTest, UpdateAssetResolverByTypeReplaces)
 
 TEST_F (ShellTest, UpdateAssetResolverByTypeAppends)
 
 TEST_F (ShellTest, UpdateAssetResolverByTypeNull)
 
 TEST_F (ShellTest, UpdateAssetResolverByTypeDoesNotReplaceMismatchType)
 
 TEST_F (ShellTest, CanCreateShellsWithGLBackend)
 
 TEST_F (ShellTest, CanCreateShellsWithVulkanBackend)
 
 TEST_F (ShellTest, CanCreateShellsWithMetalBackend)
 
 TEST_F (ShellTest, UserTagSetOnStartup)
 
 TEST_F (ShellTest, PrefetchDefaultFontManager)
 
 TEST_F (ShellTest, OnPlatformViewCreatedWhenUIThreadIsBusy)
 
 TEST_F (ShellTest, UIWorkAfterOnPlatformViewDestroyed)
 
 TEST_F (ShellTest, UsesPlatformMessageHandler)
 
 TEST_F (ShellTest, SpawnWorksWithOnError)
 
 TEST_F (ShellTest, ImmutableBufferLoadsAssetOnBackgroundThread)
 
 TEST_F (ShellTest, PictureToImageSync)
 
 TEST_F (ShellTest, PictureToImageSyncImpellerNoSurface)
 
 TEST_F (ShellTest, PluginUtilitiesCallbackHandleErrorHandling)
 
 TEST_F (ShellTest, NotifyIdleRejectsPastAndNearFuture)
 
 TEST_F (ShellTest, NotifyIdleNotCalledInLatencyMode)
 
 TEST_F (ShellTest, NotifyDestroyed)
 
 TEST_F (ShellTest, PrintsErrorWhenPlatformMessageSentFromWrongThread)
 
 TEST_F (ShellTest, DiesIfSoftwareRenderingAndImpellerAreEnabledDeathTest)
 
static void ParseViewIdsCallback (const Dart_NativeArguments &args, bool *hasImplicitView, std::vector< int64_t > *viewIds)
 
 TEST_F (ShellTest, ShellStartsWithImplicitView)
 
 TEST_F (ShellTest, ShellCanAddViewOrRemoveView)
 
 TEST_F (ShellTest, ShellCannotAddDuplicateViewId)
 
 TEST_F (ShellTest, ShellCannotRemoveNonexistentId)
 
static void ParseViewWidthsCallback (const Dart_NativeArguments &args, std::map< int64_t, int64_t > *viewWidths)
 
 TEST_F (ShellTest, ShellFlushesPlatformStatesByMain)
 
 TEST_F (ShellTest, CanRemoveViewBeforeLaunchingIsolate)
 
 TEST_F (ShellTest, IgnoresBadAddViewsBeforeLaunchingIsolate)
 
 TEST_F (ShellTest, RuntimeStageBackendDefaultsToSkSLWithoutImpeller)
 
 TEST_F (ShellTest, WillLogWarningWhenImpellerIsOptedOut)
 
 TEST (SwitchesTest, SkiaTraceAllowlistFlag)
 
 TEST (SwitchesTest, TraceToFile)
 
 TEST (SwitchesTest, RouteParsedFlag)
 
 TEST (SwitchesTest, MsaaSamples)
 
 TEST (SwitchesTest, EnableEmbedderAPI)
 
 TEST (SwitchesTest, NoEnableImpeller)
 
 TEST (SwitchesTest, EnableAsserts)
 
 TEST (VariableRefreshRateDisplayTest, ReportCorrectInitialRefreshRate)
 
 TEST (VariableRefreshRateDisplayTest, ReportCorrectRefreshRateWhenUpdated)
 
 TEST (VariableRefreshRateDisplayTest, Report0IfReporterSharedPointerIsDestroyedAfterDisplayCreation)
 
 TEST (VariableRefreshRateDisplayTest, Report0IfReporterSharedPointerIsDestroyedBeforeDisplayCreation)
 
 TEST (VsyncWaiterTest, NoUnneededAwaitVsync)
 
static std::shared_ptr< impeller::ContextMTLCreateImpellerContext ()
 
 TEST (GPUSurfaceMetalImpeller, InvalidImpellerContextCreatesCausesSurfaceToBeInvalid)
 
 TEST (GPUSurfaceMetalImpeller, CanCreateValidSurface)
 
 TEST (GPUSurfaceMetalImpeller, AcquireFrameFromCAMetalLayerNullChecksDrawable)
 
 TEST (GPUSurfaceMetalImpeller, AcquireFrameFromCAMetalLayerDoesNotRetainThis)
 
 TEST (AndroidContextGLImpeller, MSAAFirstAttempt)
 
 TEST (AndroidContextGLImpeller, FallbackForEmulator)
 
 TEST (AndroidShellHolder, Create)
 
 TEST (AndroidShellHolder, HandlePlatformMessage)
 
 TEST (APKAssetProvider, CloneAndEquals)
 
fml::RefPtr< fml::RasterThreadMergerGetThreadMergerFromPlatformThread (fml::Thread *rasterizer_thread=nullptr)
 
fml::RefPtr< fml::RasterThreadMergerGetThreadMergerFromRasterThread (fml::Thread *platform_thread)
 
TaskRunners GetTaskRunnersForFixture ()
 
 TEST (AndroidExternalViewEmbedder, CompositeEmbeddedView)
 
 TEST (AndroidExternalViewEmbedder, CancelFrame)
 
 TEST (AndroidExternalViewEmbedder, RasterizerRunsOnPlatformThread)
 
 TEST (AndroidExternalViewEmbedder, RasterizerRunsOnRasterizerThread)
 
 TEST (AndroidExternalViewEmbedder, PlatformViewRect)
 
 TEST (AndroidExternalViewEmbedder, PlatformViewRectChangedParams)
 
 TEST (AndroidExternalViewEmbedder, SubmitFlutterView)
 
 TEST (AndroidExternalViewEmbedder, OverlayCoverTwoPlatformViews)
 
 TEST (AndroidExternalViewEmbedder, SubmitFrameOverlayComposition)
 
 TEST (AndroidExternalViewEmbedder, SubmitFramePlatformViewWithoutAnyOverlay)
 
 TEST (AndroidExternalViewEmbedder, DoesNotCallJNIPlatformThreadOnlyMethods)
 
 TEST (AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange)
 
 TEST (AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange)
 
 TEST (AndroidExternalViewEmbedder, SupportsDynamicThreadMerging)
 
 TEST (AndroidExternalViewEmbedder, DisableThreadMerger)
 
 TEST (AndroidExternalViewEmbedder, Teardown)
 
 TEST (AndroidExternalViewEmbedder, TeardownDoesNotCallJNIMethod)
 
 TEST (SurfacePool, GetLayerAllocateOneLayer)
 
 TEST (SurfacePool, GetUnusedLayers)
 
 TEST (SurfacePool, GetLayerRecycle)
 
 TEST (SurfacePool, GetLayerAllocateTwoLayers)
 
 TEST (SurfacePool, DestroyLayers)
 
 TEST (SurfacePool, DestroyLayersFrameSizeChanged)
 
 TEST (ImageLRU, CanStoreSingleImage)
 
 TEST (ImageLRU, EvictsLRU)
 
 TEST (ImageLRU, CanClear)
 
 TEST (JNIMock, FlutterViewHandlePlatformMessage)
 
 TEST (PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics)
 
 TEST (PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemanticsWithStringAttribtes)
 
 TEST (PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateCustomAccessibilityActions)
 
 TEST (AndroidPlatformView, SelectsVulkanBasedOnApiLevel)
 
 TEST (AndroidPlatformView, SoftwareRenderingNotSupportedWithImpeller)
 
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)
 
FlutterUIPressProxykeyDownEvent (UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))
 
FlutterUIPressProxykeyUpEvent (UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))
 
FlutterUIPressProxykeyEventWithPhase (UIPressPhase phase, UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))
 
 TEST_F (AccessibilityBridgeMacWindowTest, SendsAccessibilityCreateNotificationFlutterViewWindow)
 
 TEST_F (AccessibilityBridgeMacWindowTest, NonZeroRootNodeId)
 
 TEST_F (AccessibilityBridgeMacTest, DoesNotSendAccessibilityCreateNotificationWhenHeadless)
 
 TEST_F (AccessibilityBridgeMacTest, DoesNotSendAccessibilityCreateNotificationWhenNoWindow)
 
 TEST (FlutterAppDelegateTest, DoesNotCallDelegatesWithoutHandler)
 
 TEST (FlutterAppDelegateTest, ReceivesOpenURLs)
 
 TEST (FlutterAppDelegateTest, OperURLsStopsAfterHandled)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillFinishLaunching)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidFinishLaunching)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillBecomeActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidBecomeActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillResignActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidResignActive)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillTerminate)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillHide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToWillUnhide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidHide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidUnhide)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidChangeScreenParameters)
 
 TEST (FlutterAppLifecycleDelegateTest, RespondsToDidChangeOcclusionState)
 
 TEST_F (FlutterChannelKeyResponderTest, BasicKeyEvent)
 
 TEST_F (FlutterChannelKeyResponderTest, EmptyResponseIsTakenAsHandled)
 
 TEST_F (FlutterChannelKeyResponderTest, FollowsLayoutMap)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestTextureResolution)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTexture)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTextureYUVA)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateExternalTextureYUVA2)
 
 TEST_F (FlutterEmbedderExternalTextureTest, TestPopulateUnsupportedExternalTexture)
 
 TEST (FlutterEmbedderKeyResponderUnittests, BasicKeyEvent)
 
 TEST (FlutterEmbedderKeyResponderUnittests, NonAsciiCharacters)
 
 TEST (FlutterEmbedderKeyResponderUnittests, MultipleCharacters)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynthesizeForDuplicateDownEvent)
 
 TEST (FlutterEmbedderKeyResponderUnittests, IgnoreDuplicateUpEvent)
 
 TEST (FlutterEmbedderKeyResponderUnittests, ConvertAbruptRepeatEventsToDown)
 
 TEST (FlutterEmbedderKeyResponderUnittests, ToggleModifiersDuringKeyTap)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SpecialModiferFlags)
 
 TEST (FlutterEmbedderKeyResponderUnittests, IdentifyLeftAndRightModifiers)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynthesizeMissedModifierEvents)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynthesizeMissedModifierEventsInNormalEvents)
 
 TEST (FlutterEmbedderKeyResponderUnittests, ConvertCapsLockEvents)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynchronizeCapsLockStateOnCapsLock)
 
 TEST (FlutterEmbedderKeyResponderUnittests, SynchronizeCapsLockStateOnNormalKey)
 
 TEST_F (FlutterEngineTest, CanLaunch)
 
 TEST_F (FlutterEngineTest, HasNonNullExecutableName)
 
 TEST_F (FlutterEngineTest, Switches)
 
 TEST_F (FlutterEngineTest, MessengerSend)
 
 TEST_F (FlutterEngineTest, CanLogToStdout)
 
 TEST_F (FlutterEngineTest, DISABLED_BackgroundIsBlack)
 
 TEST_F (FlutterEngineTest, DISABLED_CanOverrideBackgroundColor)
 
 TEST_F (FlutterEngineTest, CanToggleAccessibility)
 
 TEST_F (FlutterEngineTest, CanToggleAccessibilityWhenHeadless)
 
 TEST_F (FlutterEngineTest, ProducesAccessibilityTreeWhenAddingViews)
 
 TEST_F (FlutterEngineTest, NativeCallbacks)
 
 TEST_F (FlutterEngineTest, Compositor)
 
 TEST_F (FlutterEngineTest, CompositorIgnoresUnknownView)
 
 TEST_F (FlutterEngineTest, DartEntrypointArguments)
 
 TEST_F (FlutterEngineTest, FlutterBinaryMessengerDoesNotRetainEngine)
 
 TEST_F (FlutterEngineTest, FlutterTextureRegistryDoesNotReturnEngine)
 
 TEST_F (FlutterEngineTest, PublishedValueNilForUnknownPlugin)
 
 TEST_F (FlutterEngineTest, PublishedValueNSNullIfNoPublishedValue)
 
 TEST_F (FlutterEngineTest, PublishedValueReturnsLastPublished)
 
 TEST_F (FlutterEngineTest, MessengerCleanupConnectionWorks)
 
 TEST_F (FlutterEngineTest, HasStringsWhenPasteboardEmpty)
 
 TEST_F (FlutterEngineTest, HasStringsWhenPasteboardFull)
 
 TEST_F (FlutterEngineTest, ResponseAfterEngineDied)
 
 TEST_F (FlutterEngineTest, ResponseFromBackgroundThread)
 
 TEST_F (FlutterEngineTest, ThreadSynchronizerNotBlockingRasterThreadAfterShutdown)
 
 TEST_F (FlutterEngineTest, ManageControllersIfInitiatedByController)
 
 TEST_F (FlutterEngineTest, ManageControllersIfInitiatedByEngine)
 
 TEST_F (FlutterEngineTest, HandlesTerminationRequest)
 
 TEST_F (FlutterEngineTest, IgnoresTerminationRequestIfNotFlutterAppDelegate)
 
 TEST_F (FlutterEngineTest, HandleAccessibilityEvent)
 
 TEST_F (FlutterEngineTest, HandleLifecycleStates) API_AVAILABLE(macos(10.9))
 
 TEST_F (FlutterEngineTest, ForwardsPluginDelegateRegistration)
 
 TEST_F (FlutterEngineTest, UnregistersPluginsOnEngineDestruction)
 
 TEST_F (FlutterEngineTest, RunWithEntrypointUpdatesDisplayConfig)
 
 TEST_F (FlutterEngineTest, NotificationsUpdateDisplays)
 
 TEST_F (FlutterEngineTest, DisplaySizeIsInPhysicalPixel)
 
id CreateMockFlutterEngine (NSString *pasteboardString)
 
 TEST (FlutterKeyboardManagerUnittests, SinglePrimaryResponder)
 
 TEST (FlutterKeyboardManagerUnittests, DoublePrimaryResponder)
 
 TEST (FlutterKeyboardManagerUnittests, SingleFinalResponder)
 
 TEST (FlutterKeyboardManagerUnittests, EmptyNextResponder)
 
 TEST (FlutterKeyboardManagerUnittests, GetPressedState)
 
 TEST (FlutterKeyboardManagerUnittests, KeyboardChannelGetPressedState)
 
 TEST (FlutterKeyboardManagerUnittests, RacingConditionBetweenKeyAndText)
 
 TEST (FlutterKeyboardManagerUnittests, CorrectLogicalKeyForLayouts)
 
 TEST (FlutterKeyboardManagerUnittests, ShouldNotHoldStrongReferenceToViewDelegate)
 
 TEST_F (FlutterMenuPluginTest, TestSetMenu)
 
 TEST (FlutterPlatformNodeDelegateMac, Basics)
 
 TEST (FlutterPlatformNodeDelegateMac, SelectableTextHasCorrectSemantics)
 
 TEST (FlutterPlatformNodeDelegateMac, SelectableTextWithoutSelectionReturnZeroRange)
 
 TEST (FlutterPlatformNodeDelegateMac, CanPerformAction)
 
 TEST (FlutterPlatformNodeDelegateMac, TextFieldUsesFlutterTextField)
 
 TEST (FlutterPlatformViewController, TestCreatePlatformViewNoMatchingViewType)
 
 TEST (FlutterPlatformViewController, TestRegisterPlatformViewFactoryAndCreate)
 
 TEST (FlutterPlatformViewController, TestCreateAndDispose)
 
 TEST (FlutterPlatformViewController, TestDisposeOnMissingViewId)
 
 TEST (FlutterPlatformViewController, TestAcceptGesture)
 
 TEST (FlutterPlatformViewController, TestAcceptGestureOnMissingViewId)
 
 TEST (FlutterPlatformViewController, TestRejectGesture)
 
 TEST (FlutterPlatformViewController, TestRejectGestureOnMissingViewId)
 
static FlutterSurfaceManagerCreateSurfaceManager (TestView *testView)
 
static FlutterSurfacePresentInfoCreatePresentInfo (FlutterSurface *surface, CGPoint offset=CGPointZero, size_t index=0, const std::vector< FlutterRect > &paintRegion={})
 
 TEST (FlutterSurfaceManager, MetalTextureSizeMatchesSurfaceSize)
 
 TEST (FlutterSurfaceManager, TestSurfaceLookupFromTexture)
 
 TEST (FlutterSurfaceManager, BackBufferCacheDoesNotLeak)
 
 TEST (FlutterSurfaceManager, SurfacesAreRecycled)
 
 TEST (FlutterSurfaceManager, BackingStoreCacheSurfaceStuckInUse)
 
bool operator== (const CGRect &lhs, const CGRect &rhs)
 
 TEST (FlutterSurfaceManager, LayerManagement)
 
 TEST (FlutterTextInputPluginTest, TestEmptyCompositionRange)
 
 TEST (FlutterTextInputPluginTest, TestSetMarkedTextWithSelectionChange)
 
 TEST (FlutterTextInputPluginTest, TestSetMarkedTextWithReplacementRange)
 
 TEST (FlutterTextInputPluginTest, TestComposingRegionRemovedByFramework)
 
 TEST (FlutterTextInputPluginTest, TestClearClientDuringComposing)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenAutofillNotSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteEnabledWhenAutofillSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteEnabledWhenAutofillSetNoHint)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenObscureTextSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenPasswordAutofillSet)
 
 TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenAutofillGroupIncludesPassword)
 
 TEST (FlutterTextInputPluginTest, TestFirstRectForCharacterRange)
 
 TEST (FlutterTextInputPluginTest, TestFirstRectForCharacterRangeAtInfinity)
 
 TEST (FlutterTextInputPluginTest, TestFirstRectForCharacterRangeWithEsotericAffineTransform)
 
 TEST (FlutterTextInputPluginTest, TestSetEditingStateWithTextEditingDelta)
 
 TEST (FlutterTextInputPluginTest, TestOperationsThatTriggerDelta)
 
 TEST (FlutterTextInputPluginTest, TestComposingWithDelta)
 
 TEST (FlutterTextInputPluginTest, testComposingWithDeltasWhenSelectionIsActive)
 
 TEST (FlutterTextInputPluginTest, TestLocalTextAndSelectionUpdateAfterDelta)
 
 TEST (FlutterTextInputPluginTest, TestPerformKeyEquivalent)
 
 TEST (FlutterTextInputPluginTest, HandleArrowKeyWhenImePopoverIsActive)
 
 TEST (FlutterTextInputPluginTest, UnhandledKeyEquivalent)
 
 TEST (FlutterTextInputPluginTest, TestSelectorsAreForwardedToFramework)
 
 TEST (FlutterTextInputPluginTest, TestInsertNewLine)
 
 TEST (FlutterTextInputPluginTest, TestSendActionDoNotInsertNewLine)
 
 TEST (FlutterTextInputPluginTest, CanWorkWithFlutterTextField)
 
 TEST (FlutterTextInputPluginTest, CanNotBecomeResponderIfNoViewController)
 
 TEST (FlutterTextInputPluginTest, IsAddedAndRemovedFromViewHierarchy)
 
 TEST (FlutterTextInputPluginTest, FirstResponderIsCorrect)
 
 TEST (FlutterTextInputPluginTest, HasZeroSizeAndClipsToBounds)
 
 TEST (FlutterTextInputSemanticsObjectTest, DoesInitialize)
 
 TEST_F (FlutterViewControllerTest, HasViewThatHidesOtherViewsInAccessibility)
 
 TEST_F (FlutterViewControllerTest, FlutterViewAcceptsFirstMouse)
 
 TEST_F (FlutterViewControllerTest, ReparentsPluginWhenAccessibilityDisabled)
 
 TEST_F (FlutterViewControllerTest, CanSetMouseTrackingModeBeforeViewLoaded)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEventsAreSentToFramework)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEventsArePropagatedIfNotHandled)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEventsAreNotPropagatedIfHandled)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestCtrlTabKeyEventIsPropagated)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyEquivalentIsPassedToTextInputPlugin)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestFlagsChangedEventsArePropagatedIfNotHandled)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestKeyboardIsRestartedOnEngineRestart)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestTrackpadGesturesAreSentToFramework)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestmouseAndGestureEventsAreHandledSeparately)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestMouseDownUpEventsSentToNextResponder)
 
 TEST_F (FlutterViewControllerMockEngineTest, TestModifierKeysAreSynthesizedOnMouseMove)
 
 TEST_F (FlutterViewControllerMockEngineTest, testViewWillAppearCalledMultipleTimes)
 
 TEST_F (FlutterViewControllerMockEngineTest, testFlutterViewIsConfigured)
 
 TEST_F (FlutterViewControllerTest, testLookupKeyAssets)
 
 TEST_F (FlutterViewControllerTest, testLookupKeyAssetsWithPackage)
 
 TEST_F (FlutterViewControllerTest, testViewControllerIsReleased)
 
id CreateMockViewController ()
 
 TEST (FlutterViewEngineProviderUnittests, GetViewReturnsTheCorrectView)
 
 TEST (KeyMappingTest, HasExpectedValues)
 
 TEST (PlatformViewEmbedderTest, HasPlatformMessageHandler)
 
 TEST (PlatformViewEmbedderTest, Dispatches)
 
 TEST (PlatformViewEmbedderTest, DeletionDisabledDispatch)
 
 TEST_F (EmbedderTest, CannotProvideMultipleSemanticsCallbacks)
 
 TEST_F (EmbedderA11yTest, A11yTreeIsConsistentUsingV3Callbacks)
 
 TEST_F (EmbedderA11yTest, A11yStringAttributes)
 
 TEST_F (EmbedderA11yTest, A11yTreeIsConsistentUsingV2Callbacks)
 
 TEST_F (EmbedderA11yTest, A11yTreeIsConsistentUsingV1Callbacks)
 
 TEST (EmbedderFrozen, FlutterTransformationIsFrozen)
 
 TEST (EmbedderFrozen, FlutterRectIsFrozen)
 
 TEST (EmbedderFrozen, FlutterPointIsFrozen)
 
 TEST (EmbedderFrozen, FlutterDamageIsFrozen)
 
 TEST (EmbedderFrozen, FlutterSemanticsNodeIsFrozen)
 
 TEST (EmbedderFrozen, FlutterSemanticsCustomActionIsFrozen)
 
 TEST_F (EmbedderTest, CanGetVulkanEmbedderContext)
 
 TEST_F (EmbedderTest, CanCreateOpenGLRenderingEngine)
 
 TEST_F (EmbedderTest, MustPreventEngineLaunchWhenRequiredCompositorArgsAreAbsent)
 
 TEST_F (EmbedderTest, LaunchFailsWhenMultiplePresentCallbacks)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderToOpenGLFramebuffer)
 
 TEST_F (EmbedderTest, RasterCacheDisabledWithPlatformViews)
 
 TEST_F (EmbedderTest, RasterCacheEnabled)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderToOpenGLTexture)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderToSoftwareBuffer)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderKnownScene)
 
 TEST_F (EmbedderTest, CustomCompositorMustWorkWithCustomTaskRunner)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderWithRootLayerOnly)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderWithPlatformLayerOnBottom)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderKnownSceneWithRootSurfaceTransformation)
 
 TEST_F (EmbedderTest, CanRenderSceneWithoutCustomCompositor)
 
 TEST_F (EmbedderTest, CanRenderSceneWithoutCustomCompositorWithTransformation)
 
 TEST_P (EmbedderTestMultiBackend, CanRenderGradientWithoutCompositor)
 
 TEST_F (EmbedderTest, CanRenderGradientWithoutCompositorWithXform)
 
 TEST_P (EmbedderTestMultiBackend, CanRenderGradientWithCompositor)
 
 TEST_F (EmbedderTest, CanRenderGradientWithCompositorWithXform)
 
 TEST_P (EmbedderTestMultiBackend, CanRenderGradientWithCompositorOnNonRootLayer)
 
 TEST_F (EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayerWithXform)
 
 TEST_F (EmbedderTest, VerifyB141980393)
 
 TEST_F (EmbedderTest, CanCreateEmbedderWithCustomRenderTaskRunner)
 
 TEST_P (EmbedderTestMultiBackend, CanCreateEmbedderWithCustomRenderTaskRunnerTheSameAsPlatformTaskRunner)
 
 TEST_P (EmbedderTestMultiBackend, CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurface)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurfaceWithRootSurfaceXformation)
 
 TEST_F (EmbedderTest, PushingMutlipleFramesSetsUpNewRecordingCanvasWithCustomCompositor)
 
 TEST_F (EmbedderTest, PushingMutlipleFramesSetsUpNewRecordingCanvasWithoutCustomCompositor)
 
 TEST_P (EmbedderTestMultiBackend, PlatformViewMutatorsAreValid)
 
 TEST_F (EmbedderTest, PlatformViewMutatorsAreValidWithPixelRatio)
 
 TEST_F (EmbedderTest, PlatformViewMutatorsAreValidWithPixelRatioAndRootSurfaceTransformation)
 
 TEST_F (EmbedderTest, EmptySceneIsAcceptable)
 
 TEST_F (EmbedderTest, SceneWithNoRootContainerIsAcceptable)
 
 TEST_F (EmbedderTest, ArcEndCapsAreDrawnCorrectly)
 
 TEST_F (EmbedderTest, ClipsAreCorrectlyCalculated)
 
 TEST_F (EmbedderTest, ComplexClipsAreCorrectlyCalculated)
 
 TEST_F (EmbedderTest, ObjectsCanBePostedViaPorts)
 
 TEST_F (EmbedderTest, CompositorCanPostZeroLayersForPresentation)
 
 TEST_F (EmbedderTest, CompositorCanPostOnlyPlatformViews)
 
 TEST_F (EmbedderTest, CompositorRenderTargetsAreRecycled)
 
 TEST_F (EmbedderTest, CompositorRenderTargetsAreInStableOrder)
 
 TEST_F (EmbedderTest, FrameInfoContainsValidWidthAndHeight)
 
 TEST_F (EmbedderTest, MustNotRunWithBothFBOCallbacksSet)
 
 TEST_F (EmbedderTest, MustNotRunWithBothPresentCallbacksSet)
 
 TEST_F (EmbedderTest, MustStillRunWhenPopulateExistingDamageIsNotProvided)
 
 TEST_F (EmbedderTest, MustRunWhenPopulateExistingDamageIsProvided)
 
 TEST_F (EmbedderTest, MustRunWithPopulateExistingDamageAndFBOCallback)
 
 TEST_F (EmbedderTest, MustNotRunWhenPopulateExistingDamageButNoOtherFBOCallback)
 
 TEST_F (EmbedderTest, PresentInfoContainsValidFBOId)
 
 TEST_F (EmbedderTest, PresentInfoReceivesFullDamageWhenExistingDamageIsWholeScreen)
 
 TEST_F (EmbedderTest, PresentInfoReceivesEmptyDamage)
 
 TEST_F (EmbedderTest, PresentInfoReceivesPartialDamage)
 
 TEST_F (EmbedderTest, PopulateExistingDamageReceivesValidID)
 
 TEST_F (EmbedderTest, PopulateExistingDamageReceivesInvalidID)
 
 TEST_F (EmbedderTest, SetSingleDisplayConfigurationWithDisplayId)
 
 TEST_F (EmbedderTest, SetSingleDisplayConfigurationWithoutDisplayId)
 
 TEST_F (EmbedderTest, SetValidMultiDisplayConfiguration)
 
 TEST_F (EmbedderTest, MultipleDisplaysWithSingleDisplayTrueIsInvalid)
 
 TEST_F (EmbedderTest, MultipleDisplaysWithSameDisplayIdIsInvalid)
 
 TEST_F (EmbedderTest, CompositorRenderTargetsNotRecycledWhenAvoidsCacheSet)
 
 TEST_F (EmbedderTest, SnapshotRenderTargetScalesDownToDriverMax)
 
 TEST_F (EmbedderTest, ObjectsPostedViaPortsServicedOnSecondaryTaskHeap)
 
 TEST_F (EmbedderTest, CreateInvalidBackingstoreOpenGLTexture)
 
 TEST_F (EmbedderTest, CreateInvalidBackingstoreOpenGLFramebuffer)
 
 TEST_F (EmbedderTest, ExternalTextureGLRefreshedTooOften)
 
 TEST_F (EmbedderTest, PresentInfoReceivesFullScreenDamageWhenPopulateExistingDamageIsNotProvided)
 
 TEST_F (EmbedderTest, PresentInfoReceivesJoinedDamageWhenExistingDamageContainsMultipleRects)
 
 TEST_F (EmbedderTest, CanRenderWithImpellerOpenGL)
 
 INSTANTIATE_TEST_SUITE_P (EmbedderTestGlVk, EmbedderTestMultiBackend, ::testing::Values(EmbedderTestContextType::kOpenGLContext, EmbedderTestContextType::kVulkanContext))
 
 TEST_F (EmbedderTest, CanRenderGradientWithMetal)
 
static sk_sp< SkSurfaceGetSurfaceFromTexture (const sk_sp< GrDirectContext > &skia_context, SkISize texture_size, void *texture)
 
 TEST_F (EmbedderTest, ExternalTextureMetal)
 
 TEST_F (EmbedderTest, MetalCompositorMustBeAbleToRenderPlatformViews)
 
 TEST_F (EmbedderTest, CanRenderSceneWithoutCustomCompositorMetal)
 
 TEST_F (EmbedderTest, TextureDestructionCallbackCalledWithoutCustomCompositorMetal)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderKnownSceneMetal)
 
 TEST_F (EmbedderTest, CreateInvalidBackingstoreMetalTexture)
 
 TEST_F (EmbedderTest, ExternalTextureMetalRefreshedTooOften)
 
static void InvokeAllCallbacks (const std::vector< fml::closure > &callbacks)
 
 TEST (EmbedderTestNoFixture, MustNotRunWithInvalidArgs)
 
 TEST_F (EmbedderTest, CanLaunchAndShutdownWithValidProjectArgs)
 
 TEST_F (EmbedderTest, DISABLED_CanLaunchAndShutdownMultipleTimes)
 
 TEST_F (EmbedderTest, CanInvokeCustomEntrypoint)
 
 TEST_F (EmbedderTest, CanInvokeCustomEntrypointMacro)
 
 TEST_F (EmbedderTest, CanTerminateCleanly)
 
 TEST_F (EmbedderTest, ExecutableNameNotNull)
 
 TEST_F (EmbedderTest, ImplicitViewNotNull)
 
 TEST_F (EmbedderTest, CanSpecifyCustomPlatformTaskRunner)
 
 TEST (EmbedderTestNoFixture, CanGetCurrentTimeInNanoseconds)
 
 TEST_F (EmbedderTest, CanReloadSystemFonts)
 
 TEST_F (EmbedderTest, IsolateServiceIdSent)
 
 TEST_F (EmbedderTest, CanCreateAndCollectCallbacks)
 
 TEST_F (EmbedderTest, PlatformMessagesCanReceiveResponse)
 
 TEST_F (EmbedderTest, PlatformMessagesCanBeSentWithoutResponseHandles)
 
 TEST_F (EmbedderTest, NullPlatformMessagesCanBeSent)
 
 TEST_F (EmbedderTest, InvalidPlatformMessages)
 
 TEST_F (EmbedderTest, CanSetCustomLogMessageCallback)
 
 TEST_F (EmbedderTest, CanSetCustomLogTag)
 Tests that setting a custom log tag works.
 
 TEST_F (EmbedderTest, VMShutsDownWhenNoEnginesInProcess)
 
 TEST_F (EmbedderTest, DartEntrypointArgs)
 
 TEST_F (EmbedderTest, VMAndIsolateSnapshotSizesAreRedundantInAOTMode)
 
 TEST_F (EmbedderTest, CanRenderImplicitView)
 
 TEST_F (EmbedderTest, CanRenderImplicitViewUsingPresentLayersCallback)
 
 TEST_F (EmbedderTest, CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor)
 
 TEST_F (EmbedderTest, NoLayerCreatedForTransparentOverlayOnTopOfPlatformLayer)
 
 TEST_F (EmbedderTest, NoLayerCreatedForNoOverlayOnTopOfPlatformLayer)
 
 TEST_F (EmbedderTest, CanCreateInitializedEngine)
 
 TEST_F (EmbedderTest, CanRunInitializedEngine)
 
 TEST_F (EmbedderTest, CanDeinitializeAnEngine)
 
 TEST_F (EmbedderTest, CanAddView)
 
 TEST_F (EmbedderTest, AddViewSchedulesFrame)
 
 TEST_F (EmbedderTest, CanRemoveView)
 
 TEST_F (EmbedderTest, CannotRemoveImplicitView)
 
 TEST_F (EmbedderTest, CannotAddDuplicateViews)
 
 TEST_F (EmbedderTest, CanReuseViewIds)
 
 TEST_F (EmbedderTest, CannotRemoveUnknownView)
 
 TEST_F (EmbedderTest, ViewOperationsOrdered)
 
 TEST_F (EmbedderTest, CanRenderMultipleViews)
 
 TEST_F (EmbedderTest, BackingStoresCorrespondToTheirViews)
 
 TEST_F (EmbedderTest, CanUpdateLocales)
 
 TEST_F (EmbedderTest, LocalizationCallbacksCalled)
 
 TEST_F (EmbedderTest, CanQueryDartAOTMode)
 
 TEST_F (EmbedderTest, VerifyB143464703WithSoftwareBackend)
 
 TEST_F (EmbedderTest, CanSendLowMemoryNotification)
 
 TEST_F (EmbedderTest, CanPostTaskToAllNativeThreads)
 
 TEST_F (EmbedderTest, InvalidAOTDataSourcesMustReturnError)
 
 TEST_F (EmbedderTest, MustNotRunWithMultipleAOTSources)
 
 TEST_F (EmbedderTest, CanCreateAndCollectAValidElfSource)
 
 TEST_F (EmbedderTest, CanLaunchAndShutdownWithAValidElfSource)
 
 TEST_F (EmbedderTest, CanSuccessfullyPopulateSpecificJITSnapshotCallbacks)
 
 TEST_F (EmbedderTest, JITSnapshotCallbacksFailWithInvalidLocation)
 
 TEST_F (EmbedderTest, CanLaunchEngineWithSpecifiedJITSnapshots)
 
 TEST_F (EmbedderTest, CanLaunchEngineWithSomeSpecifiedJITSnapshots)
 
 TEST_F (EmbedderTest, CanLaunchEngineWithInvalidJITSnapshots)
 
 TEST_F (EmbedderTest, CanLaunchEngineWithUnspecifiedJITSnapshots)
 
 TEST_F (EmbedderTest, InvalidFlutterWindowMetricsEvent)
 
static void expectSoftwareRenderingOutputMatches (EmbedderTest &test, std::string entrypoint, FlutterSoftwarePixelFormat pixfmt, const std::vector< uint8_t > &bytes)
 
template<typename T >
static void expectSoftwareRenderingOutputMatches (EmbedderTest &test, std::string entrypoint, FlutterSoftwarePixelFormat pixfmt, T pixelvalue)
 
 SW_PIXFMT_TEST_F (RedRGBA565xF800, draw_solid_red, kFlutterSoftwarePixelFormatRGB565,(uint16_t) 0xF800)
 
 SW_PIXFMT_TEST_F (RedRGBA4444xF00F, draw_solid_red, kFlutterSoftwarePixelFormatRGBA4444,(uint16_t) 0xF00F)
 
 SW_PIXFMT_TEST_F (RedRGBA8888xFFx00x00xFF, draw_solid_red, kFlutterSoftwarePixelFormatRGBA8888,(std::vector< uint8_t >{0xFF, 0x00, 0x00, 0xFF}))
 
 SW_PIXFMT_TEST_F (RedBGRA8888x00x00xFFxFF, draw_solid_red, kFlutterSoftwarePixelFormatBGRA8888,(std::vector< uint8_t >{0x00, 0x00, 0xFF, 0xFF}))
 
 SW_PIXFMT_TEST_F (RedGray8x36, draw_solid_red, kFlutterSoftwarePixelFormatGray8,(uint8_t) 0x36)
 
 SW_PIXFMT_TEST_F (GreenRGB565x07E0, draw_solid_green, kFlutterSoftwarePixelFormatRGB565,(uint16_t) 0x07E0)
 
 SW_PIXFMT_TEST_F (GreenRGBA4444x0F0F, draw_solid_green, kFlutterSoftwarePixelFormatRGBA4444,(uint16_t) 0x0F0F)
 
 SW_PIXFMT_TEST_F (GreenRGBA8888x00xFFx00xFF, draw_solid_green, kFlutterSoftwarePixelFormatRGBA8888,(std::vector< uint8_t >{0x00, 0xFF, 0x00, 0xFF}))
 
 SW_PIXFMT_TEST_F (GreenBGRA8888x00xFFx00xFF, draw_solid_green, kFlutterSoftwarePixelFormatBGRA8888,(std::vector< uint8_t >{0x00, 0xFF, 0x00, 0xFF}))
 
 SW_PIXFMT_TEST_F (GreenGray8xB6, draw_solid_green, kFlutterSoftwarePixelFormatGray8,(uint8_t) 0xB6)
 
 SW_PIXFMT_TEST_F (BlueRGB565x001F, draw_solid_blue, kFlutterSoftwarePixelFormatRGB565,(uint16_t) 0x001F)
 
 SW_PIXFMT_TEST_F (BlueRGBA4444x00FF, draw_solid_blue, kFlutterSoftwarePixelFormatRGBA4444,(uint16_t) 0x00FF)
 
 SW_PIXFMT_TEST_F (BlueRGBA8888x00x00xFFxFF, draw_solid_blue, kFlutterSoftwarePixelFormatRGBA8888,(std::vector< uint8_t >{0x00, 0x00, 0xFF, 0xFF}))
 
 SW_PIXFMT_TEST_F (BlueBGRA8888xFFx00x00xFF, draw_solid_blue, kFlutterSoftwarePixelFormatBGRA8888,(std::vector< uint8_t >{0xFF, 0x00, 0x00, 0xFF}))
 
 SW_PIXFMT_TEST_F (BlueGray8x12, draw_solid_blue, kFlutterSoftwarePixelFormatGray8,(uint8_t) 0x12)
 
FlutterKeyEventType UnserializeKeyEventType (uint64_t kind)
 
FlutterKeyEventDeviceType UnserializeKeyEventDeviceType (uint64_t source)
 
void ExpectKeyEventEq (const FlutterKeyEvent &subject, const FlutterKeyEvent &baseline)
 
 TEST_F (EmbedderTest, KeyDataIsCorrectlySerialized)
 
 TEST_F (EmbedderTest, KeyDataAreBuffered)
 
 TEST_F (EmbedderTest, KeyDataResponseIsCorrectlyInvoked)
 
 TEST_F (EmbedderTest, BackToBackKeyEventResponsesCorrectlyInvoked)
 
 TEST_F (EmbedderTest, VsyncCallbackPostedIntoFuture)
 
 TEST_F (EmbedderTest, CanScheduleFrame)
 
 TEST_F (EmbedderTest, CanSetNextFrameCallback)
 
 TEST_F (EmbedderTest, CanSendPointer)
 
 TEST_F (EmbedderTest, CanSendPointerEventWithViewId)
 
 TEST_F (EmbedderTest, WindowMetricsEventDefaultsToImplicitView)
 
 TEST_F (EmbedderTest, IgnoresWindowMetricsEventForUnknownView)
 
 TEST_F (EmbedderTest, RegisterChannelListener)
 
 TEST_F (EmbedderTest, PlatformThreadIsolatesWithCustomPlatformTaskRunner)
 
 TEST (EmbedderProcTable, AllPointersProvided)
 
 TEST (EmbedderProcTable, NoDuplicatePointers)
 
 TEST (EmbedderProcTable, CallProc)
 
sk_sp< SkSurfaceCreateRenderSurface (const FlutterLayer &layer, GrDirectContext *context)
 
static sk_sp< SkDataNormalizeImage (const sk_sp< SkImage > &image)
 
bool RasterImagesAreSame (const sk_sp< SkImage > &a, const sk_sp< SkImage > &b)
 
std::string FixtureNameForBackend (EmbedderTestContextType backend, const std::string &name)
 Prepends a prefix to the name which is unique to the test context type. This is useful for tests that use EmbedderTestMultiBackend and require different fixtures per backend. For OpenGL, the name remains unchanged.
 
EmbedderTestBackingStoreProducer::RenderTargetType GetRenderTargetFromBackend (EmbedderTestContextType backend, bool opengl_framebuffer)
 Resolves a render target type for a given backend description. This is useful for tests that use EmbedderTestMultiBackend.
 
void ConfigureBackingStore (FlutterBackingStore &backing_store, EmbedderTestContextType backend, bool opengl_framebuffer)
 Configures per-backend properties for a given backing store.
 
bool WriteImageToDisk (const fml::UniqueFD &directory, const std::string &name, const sk_sp< SkImage > &image)
 
bool ImageMatchesFixture (const std::string &fixture_file_name, const sk_sp< SkImage > &scene_image)
 
bool ImageMatchesFixture (const std::string &fixture_file_name, std::future< sk_sp< SkImage > > &scene_image)
 
bool SurfacePixelDataMatchesBytes (SkSurface *surface, const std::vector< uint8_t > &bytes)
 
bool SurfacePixelDataMatchesBytes (std::future< SkSurface * > &surface_future, const std::vector< uint8_t > &bytes)
 
void FilterMutationsByType (const FlutterPlatformViewMutation **mutations, size_t count, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
 
void FilterMutationsByType (const FlutterPlatformView *view, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
 
SkMatrix GetTotalMutationTransformationMatrix (const FlutterPlatformViewMutation **mutations, size_t count)
 
SkMatrix GetTotalMutationTransformationMatrix (const FlutterPlatformView *view)
 
 TEST_F (EmbedderTest, CanSwapOutVulkanCalls)
 
 TEST (CanvasSpyTest, DrawingIsTracked)
 
 TEST (CanvasSpyTest, SpiedCanvasIsDrawing)
 
 TEST (RTree, searchNonOverlappingDrawnRectsNoIntersection)
 
 TEST (RTree, searchNonOverlappingDrawnRectsSingleRectIntersection)
 
 TEST (RTree, searchNonOverlappingDrawnRectsIgnoresNonDrawingRecords)
 
 TEST (RTree, searchNonOverlappingDrawnRectsMultipleRectIntersection)
 
 TEST (RTree, searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase1)
 
 TEST (RTree, searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase2)
 
 TEST (RTree, searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase3)
 
void fl_ensure_gtk_init (GLogWriterFunc writer=nullptr)
 Ensures that GTK has been initialized and starts monitoring logs.
 
void fl_reset_received_gtk_log_levels ()
 Resets the recorded log levels.
 
GLogLevelFlags fl_get_received_gtk_log_levels ()
 Returns the recorded log levels.
 
 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)
 
char * clone_string (const char *string)
 
::testing::AssertionResult _EventEquals (const char *expr_event, const char *expr_expected, const FlutterKeyEvent &event, const FlutterKeyEvent &expected)
 
LPARAM CreateKeyEventLparam (USHORT scancode, bool extended, bool was_down, USHORT repeat_count, bool context_code, bool transition_state)
 
void MockEmbedderApiForKeyboard (EngineModifier &modifier, std::shared_ptr< MockKeyResponseController > response_controller)
 
 TEST (TestKeyboard, CloneString)
 
 TEST (TestKeyboard, CreateKeyEventLparam)
 
 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)
 
bool NumberNear (double a, double b)
 
std::unique_ptr< AutoIsolateShutdownRunDartCodeInIsolateOnUITaskRunner (DartVMRef &vm_ref, const Settings &p_settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, const std::shared_ptr< VolatilePathTracker > &volatile_path_tracker, std::unique_ptr< PlatformConfiguration > platform_configuration)
 
std::unique_ptr< AutoIsolateShutdownRunDartCodeInIsolate (DartVMRef &vm_ref, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::shared_ptr< VolatilePathTracker > volatile_path_tracker, std::unique_ptr< PlatformConfiguration > platform_configuration)
 
void RunDartCodeInIsolate (DartVMRef &vm_ref, std::unique_ptr< AutoIsolateShutdown > &result, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &fixtures_path, fml::WeakPtr< IOManager > io_manager={}, std::shared_ptr< VolatilePathTracker > volatile_path_tracker=nullptr, std::unique_ptr< PlatformConfiguration > platform_configuration=nullptr)
 
DebuggerStatus GetDebuggerStatus ()
 
bool DisplayListsEQ_Verbose (const DisplayList *a, const DisplayList *b)
 
bool DisplayListsNE_Verbose (const DisplayList *a, const DisplayList *b)
 
std::ostream & operator<< (std::ostream &os, const DisplayList &display_list)
 
std::ostream & operator<< (std::ostream &os, const DlPaint &paint)
 
std::ostream & operator<< (std::ostream &os, const DlBlendMode &mode)
 
std::ostream & operator<< (std::ostream &os, const SaveLayerOptions &options)
 
static std::ostream & operator<< (std::ostream &os, const SkPoint &point)
 
static std::ostream & operator<< (std::ostream &os, const SkIRect &rect)
 
static std::ostream & operator<< (std::ostream &os, const SkRect &rect)
 
static std::ostream & operator<< (std::ostream &os, const SkRect *rect)
 
static std::ostream & operator<< (std::ostream &os, const SkRRect &rrect)
 
static std::ostream & operator<< (std::ostream &os, const SkPath &path)
 
static std::ostream & operator<< (std::ostream &os, const SkMatrix &matrix)
 
static std::ostream & operator<< (std::ostream &os, const SkMatrix *matrix)
 
static std::ostream & operator<< (std::ostream &os, const SkRSXform &xform)
 
std::ostream & operator<< (std::ostream &os, const DlCanvas::ClipOp &op)
 
std::ostream & operator<< (std::ostream &os, const DlCanvas::SrcRectConstraint &constraint)
 
std::ostream & operator<< (std::ostream &os, const DlStrokeCap &cap)
 
std::ostream & operator<< (std::ostream &os, const DlStrokeJoin &join)
 
std::ostream & operator<< (std::ostream &os, const DlDrawStyle &style)
 
std::ostream & operator<< (std::ostream &os, const DlBlurStyle &style)
 
std::ostream & operator<< (std::ostream &os, const DlCanvas::PointMode &mode)
 
std::ostream & operator<< (std::ostream &os, const DlFilterMode &mode)
 
std::ostream & operator<< (std::ostream &os, const DlColor &color)
 
std::ostream & operator<< (std::ostream &os, DlImageSampling sampling)
 
static std::ostream & operator<< (std::ostream &os, const SkTextBlob *blob)
 
static std::ostream & operator<< (std::ostream &os, const impeller::TextFrame *frame)
 
std::ostream & operator<< (std::ostream &os, const DlVertexMode &mode)
 
std::ostream & operator<< (std::ostream &os, const DlTileMode &mode)
 
std::ostream & operator<< (std::ostream &os, const DlImage *image)
 
bool DisplayListsEQ_Verbose (const DisplayList &a, const DisplayList &b)
 
bool DisplayListsEQ_Verbose (const sk_sp< const DisplayList > &a, const sk_sp< const DisplayList > &b)
 
bool DisplayListsNE_Verbose (const DisplayList &a, const DisplayList &b)
 
bool DisplayListsNE_Verbose (const sk_sp< const DisplayList > &a, const sk_sp< const DisplayList > &b)
 
ELFAOTSymbols LoadELFSymbolFromFixturesIfNeccessary (std::string elf_filename)
 Attempts to resolve AOT symbols from the portable ELF loader. This location is automatically resolved from the fixtures generator. This only returns valid symbols when the VM is configured for AOT.
 
ELFAOTSymbols LoadELFSplitSymbolFromFixturesIfNeccessary (std::string elf_split_filename)
 Attempts to resolve split loading unit AOT symbols from the portable ELF loader. If the dart code does not make use of deferred libraries, then there will be no split .so to load. This only returns valid symbols when the VM is configured for AOT.
 
bool PrepareSettingsForAOTWithSymbols (Settings &settings, const ELFAOTSymbols &symbols)
 Prepare the settings objects various AOT mappings resolvers with the symbols already loaded. This method does nothing in non-AOT runtime modes.
 
std::string TestStatusAsString (const ::testing::TestResult *result)
 
std::string TestLabel (const ::testing::TestInfo &info)
 
std::string TestTimeAsString (const ::testing::TestResult *result)
 
static std::ostream & operator<< (std::ostream &os, const SkPoint &r)
 
static std::ostream & operator<< (std::ostream &os, const SkRect &r)
 
static std::ostream & operator<< (std::ostream &os, const SkRRect &r)
 
static std::ostream & operator<< (std::ostream &os, const SkPath &r)
 
static std::ostream & operator<< (std::ostream &os, const SkM44 &m)
 
bool operator== (const MockCanvas::SaveData &a, const MockCanvas::SaveData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::SaveData &data)
 
bool operator== (const MockCanvas::SaveLayerData &a, const MockCanvas::SaveLayerData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::SaveLayerData &data)
 
bool operator== (const MockCanvas::RestoreData &a, const MockCanvas::RestoreData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::RestoreData &data)
 
bool operator== (const MockCanvas::ConcatMatrixData &a, const MockCanvas::ConcatMatrixData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::ConcatMatrixData &data)
 
bool operator== (const MockCanvas::SetMatrixData &a, const MockCanvas::SetMatrixData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::SetMatrixData &data)
 
bool operator== (const MockCanvas::DrawRectData &a, const MockCanvas::DrawRectData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawRectData &data)
 
bool operator== (const MockCanvas::DrawPathData &a, const MockCanvas::DrawPathData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawPathData &data)
 
bool operator== (const MockCanvas::DrawTextData &a, const MockCanvas::DrawTextData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawTextData &data)
 
bool operator== (const MockCanvas::DrawImageData &a, const MockCanvas::DrawImageData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawImageData &data)
 
bool operator== (const MockCanvas::DrawImageDataNoPaint &a, const MockCanvas::DrawImageDataNoPaint &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawImageDataNoPaint &data)
 
bool operator== (const MockCanvas::DrawDisplayListData &a, const MockCanvas::DrawDisplayListData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawDisplayListData &data)
 
bool operator== (const MockCanvas::DrawShadowData &a, const MockCanvas::DrawShadowData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawShadowData &data)
 
bool operator== (const MockCanvas::ClipRectData &a, const MockCanvas::ClipRectData &b)
 
static std::ostream & operator<< (std::ostream &os, const MockCanvas::ClipEdgeStyle &style)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::ClipRectData &data)
 
bool operator== (const MockCanvas::ClipRRectData &a, const MockCanvas::ClipRRectData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::ClipRRectData &data)
 
bool operator== (const MockCanvas::ClipPathData &a, const MockCanvas::ClipPathData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::ClipPathData &data)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawCallData &data)
 
bool operator== (const MockCanvas::DrawCall &a, const MockCanvas::DrawCall &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawCall &draw)
 
bool operator== (const MockCanvas::DrawPaintData &a, const MockCanvas::DrawPaintData &b)
 
std::ostream & operator<< (std::ostream &os, const MockCanvas::DrawPaintData &data)
 
 TEST_F (MockCanvasTest, DrawRRectDies)
 
 TEST_F (MockCanvasTest, DrawCalls)
 
void PostTaskSync (const fml::RefPtr< fml::TaskRunner > &task_runner, const std::function< void()> &function)
 
const fml::CommandLineGetArgsForProcess ()
 
void SetArgsForProcess (int argc, char **argv)
 
static const uint8_t * DartNativeEntrySymbolCallback (Dart_NativeFunction function)
 
static std::string GetEGLError ()
 
static bool HasExtension (const char *extensions, const char *name)
 
static void CheckSwanglekExtensions ()
 
static EGLDisplay CreateSwangleDisplay ()
 
template<class T >
auto WeakPtr (std::shared_ptr< T > pointer)
 
static std::string GetTestNameFromTestInfo (const ::testing::TestInfo &test_info)
 
std::string GetCurrentTestName ()
 Gets the name of the currently running test. This is useful in generating logs or assets based on test name.
 
std::string GetDefaultKernelFilePath ()
 Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixturesPath().
 
fml::UniqueFD OpenFixturesDirectory ()
 Opens the fixtures directory for the unit-test harness.
 
fml::UniqueFD OpenFixture (const std::string &fixture_name)
 Opens a fixture of the given file name.
 
std::unique_ptr< fml::MappingOpenFixtureAsMapping (const std::string &fixture_name)
 Opens a fixture of the given file name and returns a mapping to its contents.
 
sk_sp< SkDataOpenFixtureAsSkData (const std::string &fixture_name)
 Opens a fixture of the given file name and returns a Skia SkData holding its contents.
 
bool MemsetPatternSetOrCheck (uint8_t *buffer, size_t size, MemsetPatternOp op)
 Depending on the operation, either scribbles a known pattern into the buffer or checks if that pattern is present in an existing buffer. This is a portable variant of the memset_pattern class of methods that also happen to do assert that the same pattern exists.
 
bool MemsetPatternSetOrCheck (std::vector< uint8_t > &buffer, MemsetPatternOp op)
 
const char * GetSourcePath ()
 
const char * GetFixturesPath ()
 Returns the directory containing the test fixture for the target if this target has fixtures configured. If there are no fixtures, this is a link error. If you see a linker error on this symbol, the unit-test target needs to depend on a test_fixtures target.
 
const char * GetTestingAssetsPath ()
 Returns the directory containing assets shared across all tests.
 
 TEST_F (FileLoaderTest, CanonicalizesFileUrlCorrectly)
 
 TEST_F (DartPersistentHandleTest, ClearAfterShutdown)
 
 TEST_F (DartState, CurrentWithNullDataDoesNotSegfault)
 
 TEST_F (DartState, IsShuttingDown)
 
 TEST_F (DartWeakPersistentHandle, ClearImmediately)
 
 TEST_F (DartWeakPersistentHandle, ClearLaterCc)
 
 TEST_F (DartWeakPersistentHandle, ClearLaterDart)
 
 TEST_F (DartWeakPersistentHandle, ClearOnShutdown)
 
void Nop ()
 
 TEST_F (FfiNativeTest, FfiBindingCallNop)
 
 TEST_F (FfiNativeTest, SerialiseNop)
 
bool EchoBool (bool arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoBool)
 
 TEST_F (FfiNativeTest, SerialiseEchoBool)
 
intptr_t EchoIntPtr (intptr_t arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoIntPtr)
 
 TEST_F (FfiNativeTest, SerialiseEchoIntPtr)
 
double EchoDouble (double arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoDouble)
 
 TEST_F (FfiNativeTest, SerialiseEchoDouble)
 
Dart_Handle EchoHandle (Dart_Handle str)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoHandle)
 
 TEST_F (FfiNativeTest, SerialiseEchoHandle)
 
std::string EchoString (std::string arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoString)
 
 TEST_F (FfiNativeTest, SerialiseEchoString)
 
std::u16string EchoU16String (std::u16string arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoU16String)
 
 TEST_F (FfiNativeTest, SerialiseEchoU16String)
 
std::vector< std::string > EchoVector (const std::vector< std::string > &arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoVector)
 
 TEST_F (FfiNativeTest, SerialiseEchoVector)
 
intptr_t EchoWrappable (MyNativeClass *arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoWrappable)
 
 TEST_F (FfiNativeTest, SerialiseEchoWrappable)
 
tonic::Float32List EchoTypedList (tonic::Float32List arg)
 
 TEST_F (FfiNativeTest, FfiBindingCallEchoTypedList)
 
 TEST_F (FfiNativeTest, SerialiseEchoTypedList)
 
 TEST_F (FfiNativeTest, FfiBindingCallClassMemberFunction)
 
 TEST_F (FfiNativeTest, SerialiseClassMemberFunction)
 
 TEST_F (FfiNativeTest, FfiBindingCallClassMemberMethod)
 
 TEST_F (FfiNativeTest, SerialiseClassMemberMethod)
 
 TEST_F (PainterTest, DrawsSolidLineSkia)
 
 TEST_F (PainterTest, DrawDashedLineSkia)
 

Variables

constexpr size_t kLinesToDraw = 10000
 
constexpr size_t kRectsToDraw = 5000
 
constexpr size_t kOvalsToDraw = 1000
 
constexpr size_t kCirclesToDraw = 5000
 
constexpr size_t kRRectsToDraw = 5000
 
constexpr size_t kDRRectsToDraw = 2000
 
constexpr size_t kArcSweepSetsToDraw = 1000
 
constexpr size_t kImagesToDraw = 500
 
constexpr size_t kFixedCanvasSize = 1024
 
static std::vector< testing::DisplayListInvocationGroupallGroups
 
static const float kMatrix [20]
 
static const sk_sp< DlRuntimeEffectkTestRuntimeEffect1
 
static const sk_sp< DlRuntimeEffectkTestRuntimeEffect2
 
static const sk_sp< DlImagekTestImage1 = MakeTestImage(10, 10, SK_ColorGREEN)
 
static const sk_sp< DlImagekTestAlphaImage1
 
static const SkMatrix kTestMatrix1
 
static const SkMatrix kTestMatrix2
 
static constexpr int kTestStopCount = 3
 
static constexpr DlColor kTestColors [kTestStopCount]
 
static const DlColor kTestAlphaColors [kTestStopCount]
 
static constexpr float kTestStops [kTestStopCount]
 
static constexpr float kTestStops2 [kTestStopCount]
 
static constexpr SkPoint kTestPoints [2]
 
static constexpr SkPoint kTestPoints2 [2]
 
static const DlColor kTestColors [2]
 
static const float kTestStops [2] = {0.0f, 1.0f}
 
static const auto kTestLinearGradient
 
constexpr int kTestWidth = 200
 
constexpr int kTestHeight = 200
 
constexpr int kRenderWidth = 100
 
constexpr int kRenderHeight = 100
 
constexpr int kRenderHalfWidth = 50
 
constexpr int kRenderHalfHeight = 50
 
constexpr int kRenderLeft = (kTestWidth - kRenderWidth) / 2
 
constexpr int kRenderTop = (kTestHeight - kRenderHeight) / 2
 
constexpr int kRenderRight = kRenderLeft + kRenderWidth
 
constexpr int kRenderBottom = kRenderTop + kRenderHeight
 
constexpr int kRenderCenterX = (kRenderLeft + kRenderRight) / 2
 
constexpr int kRenderCenterY = (kRenderTop + kRenderBottom) / 2
 
constexpr SkScalar kRenderRadius = std::min(kRenderWidth, kRenderHeight) / 2.0
 
constexpr SkScalar kRenderCornerRadius = kRenderRadius / 5.0
 
constexpr SkPoint kTestCenter = SkPoint::Make(kTestWidth / 2, kTestHeight / 2)
 
constexpr SkRect kTestBounds2 = SkRect::MakeWH(kTestWidth, kTestHeight)
 
constexpr SkRect kRenderBounds
 
constexpr SkScalar kMiterExtremeDiamondOffsetX = kRenderHeight * 0.04
 
constexpr SkScalar kMiter10DiamondOffsetX = kRenderHeight * 0.051
 
constexpr SkScalar kMiter4DiamondOffsetX = kRenderHeight * 0.14
 
constexpr SkScalar kMiterExtremeDiamondOffsetY = kRenderWidth * 0.04
 
constexpr SkScalar kMiter10DiamondOffsetY = kRenderWidth * 0.051
 
constexpr SkScalar kMiter4DiamondOffsetY = kRenderWidth * 0.14
 
constexpr SkScalar kXOffset0 = kRenderCenterX + 0.5
 
constexpr SkScalar kXOffsetL1 = kXOffset0 - kMiter4DiamondOffsetX
 
constexpr SkScalar kXOffsetL2 = kXOffsetL1 - kMiter10DiamondOffsetX
 
constexpr SkScalar kXOffsetL3 = kXOffsetL2 - kMiter10DiamondOffsetX
 
constexpr SkScalar kXOffsetR1 = kXOffset0 + kMiter4DiamondOffsetX
 
constexpr SkScalar kXOffsetR2 = kXOffsetR1 + kMiterExtremeDiamondOffsetX
 
constexpr SkScalar kXOffsetR3 = kXOffsetR2 + kMiterExtremeDiamondOffsetX
 
constexpr SkPoint kVerticalMiterDiamondPoints []
 
const int kVerticalMiterDiamondPointCount
 
constexpr SkScalar kYOffset0 = kRenderCenterY + 0.5
 
constexpr SkScalar kYOffsetU1 = kXOffset0 - kMiter4DiamondOffsetY
 
constexpr SkScalar kYOffsetU2 = kYOffsetU1 - kMiter10DiamondOffsetY
 
constexpr SkScalar kYOffsetU3 = kYOffsetU2 - kMiter10DiamondOffsetY
 
constexpr SkScalar kYOffsetD1 = kXOffset0 + kMiter4DiamondOffsetY
 
constexpr SkScalar kYOffsetD2 = kYOffsetD1 + kMiterExtremeDiamondOffsetY
 
constexpr SkScalar kYOffsetD3 = kYOffsetD2 + kMiterExtremeDiamondOffsetY
 
const SkPoint kHorizontalMiterDiamondPoints []
 
const int kHorizontalMiterDiamondPointCount
 
static const SkSetup kEmptySkSetup = [](const SkSetupContext&) {}
 
static const SkRenderer kEmptySkRenderer = [](const SkRenderContext&) {}
 
static const DlSetup kEmptyDlSetup = [](const DlSetupContext&) {}
 
static const DlRenderer kEmptyDlRenderer = [](const DlRenderContext&) {}
 
constexpr SkPoint kEndPoints []
 
const DlColor kColors []
 
constexpr float kStops []
 
constexpr float kRotateColorMatrix [20]
 
constexpr float kInvertColorMatrix [20]
 
const SkScalar kTestDashes1 [] = {4.0, 2.0}
 
const SkScalar kTestDashes2 [] = {1.0, 1.5}
 
static DlImageSampling kNearestSampling = DlImageSampling::kNearestNeighbor
 
static DlImageSampling kLinearSampling = DlImageSampling::kLinear
 
static auto TestImage1 = MakeTestImage(40, 40, 5)
 
static auto TestImage2 = MakeTestImage(50, 50, 5)
 
static auto TestSkImage = MakeTestImage(30, 30, 5)->skia_image()
 
static const std::shared_ptr< DlColorSourcekTestSource2
 
static const std::shared_ptr< DlColorSourcekTestSource3
 
static const std::shared_ptr< DlColorSourcekTestSource4
 
static const std::shared_ptr< DlColorSourcekTestSource5
 
static const std::shared_ptr< DlPathEffectkTestPathEffect1
 
static const std::shared_ptr< DlPathEffectkTestPathEffect2
 
constexpr SkRect kTestBounds = SkRect::MakeLTRB(10, 10, 50, 60)
 
static const SkRRect kTestRRect = SkRRect::MakeRectXY(kTestBounds, 5, 5)
 
static const SkRRect kTestRRectRect = SkRRect::MakeRect(kTestBounds)
 
static const SkRRect kTestInnerRRect
 
static const SkPath kTestPathRect = SkPath::Rect(kTestBounds)
 
static const SkPath kTestPathOval = SkPath::Oval(kTestBounds)
 
static const SkPath kTestPath1
 
static const SkPath kTestPath2
 
static const SkPath kTestPath3
 
static const SkMatrix kTestMatrix1 = SkMatrix::Scale(2, 2)
 
static const SkMatrix kTestMatrix2 = SkMatrix::RotateDeg(45)
 
static std::shared_ptr< const DlVerticesTestVertices1
 
static std::shared_ptr< const DlVerticesTestVertices2
 
static sk_sp< DisplayListTestDisplayList1
 
static sk_sp< DisplayListTestDisplayList2
 
static thread_local std::unique_ptr< intcurrent_context
 
static std::vector< RasterCacheItem * > raster_cache_items_
 
const std::string kKernelFileName = "plugin_registrant_kernel_blob.bin"
 
const std::string kElfFileName = "plugin_registrant_app_elf_snapshot.so"
 
static thread_local std::unique_ptr< IsolateDataMapisolate_data_map_
 
constexpr int64_t kImplicitViewId = 0
 
static constexpr char kTooltip [] = "tooltip"
 
constexpr uint64_t kScanCodeKeyA = 0x1e
 
constexpr uint64_t kVirtualKeyA = 0x41
 
static std::shared_ptr< MockKeyResponseControllerstored_response_controller
 
constexpr LRESULT kWmResultZero = 0
 
constexpr LRESULT kWmResultDefault = 0xDEADC0DE
 
constexpr LRESULT kWmResultDontCheck = 0xFFFF1234
 
constexpr const char * kDefaultAOTAppELFFileName = "app_elf_snapshot.so"
 
constexpr const char * kDefaultAOTAppELFSplitFileName
 
constexpr SkISize kSize = SkISize::Make(64, 64)
 
static constexpr SkRect kEmptyRect = SkRect::MakeEmpty()
 
static fml::CommandLine gProcessArgs
 
static std::mutex gIsolateResolversMutex
 
static std::map< Dart_Isolate, std::weak_ptr< TestDartNativeResolver > > gIsolateResolvers
 
tonic::DartWeakPersistentValue global_weak_persistent_value
 

Typedef Documentation

◆ BackdropFilterLayerTest

Definition at line 18 of file backdrop_filter_layer_unittests.cc.

◆ BackdropLayerDiffTest

Definition at line 424 of file backdrop_filter_layer_unittests.cc.

◆ BackendType

Definition at line 33 of file dl_benchmarks.h.

◆ Builder

Definition at line 372 of file dl_vertices_unittests.cc.

◆ CanvasTest

using flutter::testing::CanvasTest = typedef CanvasTestBase<::testing::Test>

Definition at line 31 of file canvas_test.h.

◆ ChannelUpdateCallback

using flutter::testing::ChannelUpdateCallback = typedef std::function<void(const FlutterChannelUpdate*)>

Definition at line 36 of file embedder_test_context.h.

◆ CheckerBoardLayerTest

Definition at line 16 of file checkerboard_layertree_unittests.cc.

◆ ClipOp

Definition at line 46 of file display_list_unittests.cc.

◆ ClipPathLayerTest

Definition at line 22 of file clip_path_layer_unittests.cc.

◆ ClipRectLayerTest

Definition at line 21 of file clip_rect_layer_unittests.cc.

◆ ClipRRectLayerTest

Definition at line 21 of file clip_rrect_layer_unittests.cc.

◆ ColorFilterLayerTest

Definition at line 26 of file color_filter_layer_unittests.cc.

◆ ContainerLayerDiffTest

Definition at line 563 of file container_layer_unittests.cc.

◆ ContainerLayerTest

Definition at line 22 of file container_layer_unittests.cc.

◆ Continuation

Definition at line 19 of file pipeline_unittests.cc.

◆ CreateVsyncWaiter

using flutter::testing::CreateVsyncWaiter = typedef std::function<std::unique_ptr<VsyncWaiter>()>

Definition at line 17 of file vsync_waiters_test.h.

◆ DartLifecycleTest

Definition at line 17 of file dart_lifecycle_unittests.cc.

◆ DartState

Definition at line 14 of file dart_state_unittest.cc.

◆ DartVMTest

Definition at line 14 of file dart_vm_unittests.cc.

◆ Degrees

Definition at line 14 of file dl_matrix_clip_tracker_unittests.cc.

◆ DisplayListLayerDiffTest

Definition at line 355 of file display_list_layer_unittests.cc.

◆ DisplayListLayerTest

Definition at line 20 of file display_list_layer_unittests.cc.

◆ DisplayListRendering

Definition at line 2849 of file dl_rendering_unittests.cc.

◆ DisplayListTest

using flutter::testing::DisplayListTest = typedef DisplayListTestBase<::testing::Test>

Definition at line 228 of file display_list_unittests.cc.

◆ DlInvoker

typedef const std::function<void(DlOpReceiver&)> flutter::testing::DlInvoker

Definition at line 25 of file dl_test_snippets.h.

◆ DlMatrix

Definition at line 13 of file dl_matrix_clip_tracker_unittests.cc.

◆ DlRect

Definition at line 12 of file dl_matrix_clip_tracker_unittests.cc.

◆ DlRenderContext

Definition at line 352 of file dl_rendering_unittests.cc.

◆ DlRenderer

using flutter::testing::DlRenderer = typedef const std::function<void(const DlRenderContext&)>

Definition at line 358 of file dl_rendering_unittests.cc.

◆ DlSetup

using flutter::testing::DlSetup = typedef const std::function<void(const DlSetupContext&)>

Definition at line 357 of file dl_rendering_unittests.cc.

◆ DlSetupContext

Definition at line 349 of file dl_rendering_unittests.cc.

◆ EmbedderA11yTest

Definition at line 29 of file embedder_a11y_unittests.cc.

◆ EmbedderTest

Definition at line 47 of file embedder_gl_unittests.cc.

◆ EnginePtr

using flutter::testing::EnginePtr = typedef std::unique_ptr<FlutterDesktopEngine, EngineDeleter>

Definition at line 29 of file windows_test_config_builder.h.

◆ FileLoaderTest

Definition at line 14 of file file_loader_unittests.cc.

◆ FlutterChannelKeyResponderTest

Definition at line 73 of file FlutterChannelKeyResponderTest.mm.

◆ FlutterEmbedderExternalTextureTest

Definition at line 71 of file FlutterEmbedderExternalTextureTest.mm.

◆ FlutterViewControllerMockEngineTest

Definition at line 180 of file FlutterViewControllerTest.mm.

◆ FlutterViewControllerTest

Definition at line 179 of file FlutterViewControllerTest.mm.

◆ FrameContent

using flutter::testing::FrameContent = typedef std::map<int64_t, ViewContent>

Definition at line 37 of file shell_test.h.

◆ Generator

using flutter::testing::Generator = typedef std::function<UnitlessTime(int)>

Definition at line 20 of file input_events_unittests.cc.

◆ HooksTest

Definition at line 21 of file hooks_unittests.cc.

◆ ImageFilterLayerDiffTest

Definition at line 623 of file image_filter_layer_unittests.cc.

◆ ImageFilterLayerTest

Definition at line 24 of file image_filter_layer_unittests.cc.

◆ IntPipeline

Definition at line 18 of file pipeline_unittests.cc.

◆ IsolateDataMap

using flutter::testing::IsolateDataMap = typedef std::unordered_map<Dart_Isolate, std::vector<std::unique_ptr<IsolateData> >>

Definition at line 27 of file platform_isolate_manager_unittests.cc.

◆ LayerTest

using flutter::testing::LayerTest = typedef LayerTestBase<::testing::Test>

Definition at line 240 of file layer_test.h.

◆ LayerTreeBuilder

using flutter::testing::LayerTreeBuilder = typedef std::function<void(std::shared_ptr<ContainerLayer> root)>

Definition at line 33 of file shell_test.h.

◆ LogMessageCallback

using flutter::testing::LogMessageCallback = typedef std::function<void(const char* tag, const char* message)>

Definition at line 34 of file embedder_test_context.h.

◆ MetalScreenshotter

Definition at line 16 of file dl_test_surface_metal.h.

◆ MockCanvasTest

Definition at line 13 of file mock_canvas_unittests.cc.

◆ MockLayerTest

Definition at line 14 of file mock_layer_unittests.cc.

◆ NativeEntry

using flutter::testing::NativeEntry = typedef std::function<void(Dart_NativeArguments)>

Definition at line 29 of file test_dart_native_resolver.h.

◆ OpacityLayerDiffTest

Definition at line 650 of file opacity_layer_unittests.cc.

◆ OpacityLayerTest

Definition at line 27 of file opacity_layer_unittests.cc.

◆ PainterTest

using flutter::testing::PainterTest = typedef PainterTestBase<::testing::Test>

Definition at line 132 of file paragraph_unittests.cc.

◆ PerformanceOverlayLayerTest

Definition at line 132 of file performance_overlay_layer_unittests.cc.

◆ PersistentCacheTest

Definition at line 24 of file persistent_cache_unittests.cc.

◆ PixelFormat

Definition at line 364 of file dl_rendering_unittests.cc.

◆ PlatformViewLayerTest

Definition at line 18 of file platform_view_layer_unittests.cc.

◆ PointMode

Definition at line 47 of file display_list_unittests.cc.

◆ RasterCacheTest

Definition at line 787 of file raster_cache_unittests.cc.

◆ SemanticsActionCallback

using flutter::testing::SemanticsActionCallback = typedef std::function<void(const FlutterSemanticsCustomAction*)>

Definition at line 32 of file embedder_test_context.h.

◆ SemanticsNodeCallback

using flutter::testing::SemanticsNodeCallback = typedef std::function<void(const FlutterSemanticsNode*)>

Definition at line 31 of file embedder_test_context.h.

◆ SemanticsUpdateBuilderTest

Definition at line 13 of file semantics_update_builder_unittests.cc.

◆ SemanticsUpdateCallback

using flutter::testing::SemanticsUpdateCallback = typedef std::function<void(const FlutterSemanticsUpdate*)>

Definition at line 29 of file embedder_test_context.h.

◆ SemanticsUpdateCallback2

using flutter::testing::SemanticsUpdateCallback2 = typedef std::function<void(const FlutterSemanticsUpdate2*)>

Definition at line 27 of file embedder_test_context.h.

◆ ShaderMaskLayerTest

Definition at line 22 of file shader_mask_layer_unittests.cc.

◆ SkRenderContext

Definition at line 350 of file dl_rendering_unittests.cc.

◆ SkRenderer

using flutter::testing::SkRenderer = typedef const std::function<void(const SkRenderContext&)>

Definition at line 356 of file dl_rendering_unittests.cc.

◆ SkSetup

using flutter::testing::SkSetup = typedef const std::function<void(const SkSetupContext&)>

Definition at line 355 of file dl_rendering_unittests.cc.

◆ SkSetupContext

Definition at line 348 of file dl_rendering_unittests.cc.

◆ TextureLayerDiffTest

Definition at line 99 of file texture_layer_unittests.cc.

◆ TextureLayerTest

Definition at line 17 of file texture_layer_unittests.cc.

◆ TransformLayerLayerDiffTest

Definition at line 475 of file transform_layer_unittests.cc.

◆ TransformLayerTest

Definition at line 15 of file transform_layer_unittests.cc.

◆ UniqueAOTData

Definition at line 46 of file embedder_test_context.h.

◆ UniqueEngine

Definition at line 28 of file embedder_config_builder.h.

◆ UniqueLoadedELF

Definition at line 31 of file elf_loader.h.

◆ UnitlessTime

Definition at line 16 of file input_events_unittests.cc.

◆ ViewControllerPtr

using flutter::testing::ViewControllerPtr = typedef std::unique_ptr<FlutterDesktopViewController, ViewControllerDeleter>

Definition at line 40 of file windows_test_config_builder.h.

◆ WmCharInfo

◆ WmDeadCharInfo

◆ WmFieldContext

◆ WmFieldExtended

◆ WmFieldPrevState

◆ WmFieldTransitionState

◆ WmKeyDownInfo

◆ WmKeyUpInfo

◆ WmSysKeyDownInfo

◆ WmSysKeyUpInfo

Enumeration Type Documentation

◆ BenchmarkAttributes

Enumerator
kEmpty 
kStrokedStyle 
kFilledStyle 
kHairlineStroke 
kAntiAliasing 

Definition at line 23 of file dl_benchmarks.h.

23 {
24 kEmpty = 0,
25 kStrokedStyle = 1 << 0,
26 kFilledStyle = 1 << 1,
27 kHairlineStroke = 1 << 2,
28 kAntiAliasing = 1 << 3
29};

◆ DebuggerStatus

Enumerator
kDontKnow 
kAttached 

Definition at line 13 of file debugger_detection.h.

◆ EmbedderTestContextType

Enumerator
kSoftwareContext 
kOpenGLContext 
kMetalContext 
kVulkanContext 

Definition at line 48 of file embedder_test_context.h.

◆ MemsetPatternOp

Enumerator
kMemsetPatternOpSetBuffer 
kMemsetPatternOpCheckBuffer 

Definition at line 96 of file testing.h.

◆ WmFieldContext

Enumerator
kNoContext 
kAltHeld 

Definition at line 32 of file wm_builders.h.

32 {
33 kNoContext = 0,
34 kAltHeld = 1,
35} WmFieldContext;

◆ WmFieldExtended

Enumerator
kNotExtended 
kExtended 

Definition at line 27 of file wm_builders.h.

27 {
28 kNotExtended = 0,
29 kExtended = 1,
30} WmFieldExtended;

◆ WmFieldPrevState

Enumerator
kWasUp 
kWasDown 

Definition at line 37 of file wm_builders.h.

37 {
38 kWasUp = 0,
39 kWasDown = 1,
40} WmFieldPrevState;

◆ WmFieldTransitionState

Enumerator
kBeingReleased 
kBeingPressed 

Definition at line 42 of file wm_builders.h.

42 {
44 kBeingPressed = 1,
45} WmFieldTransitionState;

Function Documentation

◆ _EventEquals()

testing::AssertionResult flutter::testing::_EventEquals ( const char *  expr_event,
const char *  expr_expected,
const FlutterKeyEvent event,
const FlutterKeyEvent expected 
)

Definition at line 63 of file test_keyboard.cc.

66 {
67 _RETURN_IF_NOT_EQUALS(event.struct_size, sizeof(FlutterKeyEvent));
68 _RETURN_IF_NOT_EQUALS(event.type, expected.type);
69 _RETURN_IF_NOT_EQUALS(event.physical, expected.physical);
70 _RETURN_IF_NOT_EQUALS(event.logical, expected.logical);
71 if ((event.character == nullptr) != (expected.character == nullptr) ||
72 strcmp(event.character, expected.character) != 0) {
73 return ::testing::AssertionFailure()
74 << "Expected equality of these values:\n expected.character\n "
75 << _print_character(expected.character) << "\n Actual: \n "
76 << _print_character(event.character);
77 }
78 _RETURN_IF_NOT_EQUALS(event.synthesized, expected.synthesized);
79 return ::testing::AssertionSuccess();
80}
FlKeyEvent * event
uint64_t logical
Definition embedder.h:1132
uint64_t physical
Definition embedder.h:1124
FlutterKeyEventType type
The event kind.
Definition embedder.h:1116
const char * character
Definition embedder.h:1135
#define _RETURN_IF_NOT_EQUALS(val1, val2)

◆ AnnotateAttributes()

void flutter::testing::AnnotateAttributes ( unsigned  attributes,
benchmark::State &  state,
const DisplayListAttributeFlags  flags 
)

Definition at line 56 of file dl_benchmarks.cc.

58 {
59 if (flags.always_stroked()) {
60 state.counters["HairlineStroke"] = attributes & kHairlineStroke ? 1 : 0;
61 }
62 if (flags.applies_style()) {
63 state.counters["HairlineStroke"] = attributes & kHairlineStroke ? 1 : 0;
64 state.counters["StrokedStyle"] = attributes & kStrokedStyle ? 1 : 0;
65 state.counters["FilledStyle"] = attributes & kFilledStyle ? 1 : 0;
66 }
67 if (flags.applies_anti_alias()) {
68 state.counters["AntiAliasing"] = attributes & kAntiAliasing ? 1 : 0;
69 }
70}
AtkStateType state
FlutterSemanticsFlag flags

◆ arraysEqual()

static void flutter::testing::arraysEqual ( const uint32_t *  ints,
const DlColor colors,
int  count 
)
static

Definition at line 13 of file dl_color_unittests.cc.

15 {
16 for (int i = 0; i < count; i++) {
17 EXPECT_TRUE(ints[i] == colors[i].argb());
18 }
19}
int count
#define EXPECT_TRUE(handle)
Definition unit_test.h:685

◆ BlendModeToString()

static std::string flutter::testing::BlendModeToString ( DlBlendMode  mode)
static

Definition at line 4203 of file dl_rendering_unittests.cc.

4203 {
4204 switch (mode) {
4205#define MODE_CASE(m) \
4206 case DlBlendMode::m: \
4207 return #m;
4209#undef MODE_CASE
4210 }
4211}
#define FOR_EACH_BLEND_MODE_ENUM(FUNC)
#define MODE_CASE(m)

◆ BM_DrawArc()

void flutter::testing::BM_DrawArc ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes 
)

Definition at line 426 of file dl_benchmarks.cc.

428 {
429 auto surface_provider = DlSurfaceProvider::Create(backend_type);
430 DisplayListBuilder builder;
431 DlPaint paint = GetPaintForRun(attributes);
432
433 AnnotateAttributes(attributes, state,
434 DisplayListOpFlags::kDrawArcNoCenterFlags);
435
436 size_t length = state.range(0);
437 size_t canvas_size = length * 2;
438 surface_provider->InitializeSurface(canvas_size, canvas_size);
439 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
440 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
441
442 SkScalar starting_angle = 0.0f;
443 SkScalar offset = 0.5f;
444
445 // Just some random sweeps that will mostly circumnavigate the circle
446 std::vector<SkScalar> segment_sweeps = {5.5f, -10.0f, 42.0f, 71.7f, 90.0f,
447 37.5f, 17.9f, 32.0f, 379.4f};
448
449 SkRect bounds = SkRect::MakeLTRB(0, 0, length, length);
450
451 state.counters["DrawCallCount"] = kArcSweepSetsToDraw * segment_sweeps.size();
452 for (size_t i = 0; i < kArcSweepSetsToDraw; i++) {
453 for (SkScalar sweep : segment_sweeps) {
454 builder.DrawArc(bounds, starting_angle, sweep, false, paint);
455 starting_angle += sweep + 5.0f;
456 }
457 bounds.offset(offset, offset);
458 if (bounds.right() > canvas_size) {
459 bounds.offset(-canvas_size, 0);
460 }
461 if (bounds.bottom() > canvas_size) {
462 bounds.offset(0, -canvas_size);
463 }
464 }
465
466 auto display_list = builder.Build();
467
468 // We only want to time the actual rasterization.
469 for ([[maybe_unused]] auto _ : state) {
470 canvas.DrawDisplayList(display_list);
472 }
473
474 auto filename = surface_provider->backend_name() + "-DrawArc-" +
475 std::to_string(state.range(0)) + ".png";
476 surface_provider->Snapshot(filename);
477}
Backend implementation of |DlCanvas| for |SkCanvas|.
const Paint & paint
VkSurfaceKHR surface
Definition main.cc:49
float SkScalar
Definition extension.cpp:12
size_t length
Optional< SkRect > bounds
Definition SkRecords.h:189
static void FlushSubmitCpuSync(const sk_sp< SkSurface > &surface)
void AnnotateAttributes(unsigned attributes, benchmark::State &state, const DisplayListAttributeFlags flags)
DlPaint GetPaintForRun(unsigned attributes)
Point offset
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646

◆ BM_DrawCircle()

void flutter::testing::BM_DrawCircle ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes 
)

Definition at line 222 of file dl_benchmarks.cc.

224 {
225 auto surface_provider = DlSurfaceProvider::Create(backend_type);
226 DisplayListBuilder builder;
227 DlPaint paint = GetPaintForRun(attributes);
228
229 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawCircleFlags);
230
231 size_t length = state.range(0);
232 size_t canvas_size = length * 2;
233 surface_provider->InitializeSurface(canvas_size, canvas_size);
234 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
235 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
236
237 SkScalar radius = length / 2.0f;
238 const SkScalar offset = 0.5f;
239
240 SkPoint center = SkPoint::Make(radius, radius);
241
242 state.counters["DrawCallCount"] = kCirclesToDraw;
243 for (size_t i = 0; i < kCirclesToDraw; i++) {
244 builder.DrawCircle(center, radius, paint);
245 center.offset(offset, offset);
246 if (center.x() + radius > canvas_size) {
247 center.set(radius, center.y());
248 }
249 if (center.y() + radius > canvas_size) {
250 center.set(center.x(), radius);
251 }
252 }
253 auto display_list = builder.Build();
254
255 // We only want to time the actual rasterization.
256 for ([[maybe_unused]] auto _ : state) {
257 canvas.DrawDisplayList(display_list);
259 }
260
261 auto filename = surface_provider->backend_name() + "-DrawCircle-" +
262 std::to_string(state.range(0)) + ".png";
263 surface_provider->Snapshot(filename);
264}
static SkScalar center(float pos0, float pos1)
constexpr size_t kCirclesToDraw
static constexpr SkPoint Make(float x, float y)

◆ BM_DrawDRRect()

void flutter::testing::BM_DrawDRRect ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
SkRRect::Type  type 
)

Definition at line 351 of file dl_benchmarks.cc.

354 {
355 auto surface_provider = DlSurfaceProvider::Create(backend_type);
356 DisplayListBuilder builder;
357 DlPaint paint = GetPaintForRun(attributes);
358
359 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawDRRectFlags);
360
361 size_t length = state.range(0);
362 size_t canvas_size = length * 2;
363 surface_provider->InitializeSurface(canvas_size, canvas_size);
364 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
365 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
366
367 SkVector radii[4] = {};
368 switch (type) {
370 radii[0] = SkVector::Make(5.0f, 5.0f);
371 radii[1] = SkVector::Make(5.0f, 5.0f);
372 radii[2] = SkVector::Make(5.0f, 5.0f);
373 radii[3] = SkVector::Make(5.0f, 5.0f);
374 break;
376 radii[0] = SkVector::Make(5.0f, 7.0f);
377 radii[1] = SkVector::Make(3.0f, 7.0f);
378 radii[2] = SkVector::Make(3.0f, 4.0f);
379 radii[3] = SkVector::Make(5.0f, 4.0f);
380 break;
382 radii[0] = SkVector::Make(5.0f, 4.0f);
383 radii[1] = SkVector::Make(4.0f, 5.0f);
384 radii[2] = SkVector::Make(3.0f, 6.0f);
385 radii[3] = SkVector::Make(8.0f, 7.0f);
386 break;
387 default:
388 break;
389 }
390
391 const SkScalar offset = 0.5f;
392 const SkScalar multiplier = length / 16.0f;
393 SkRRect rrect, rrect_2;
394
396 for (size_t i = 0; i < 4; i++) {
397 set_radii[i] = radii[i] * multiplier;
398 }
400
401 state.counters["DrawCallCount"] = kDRRectsToDraw;
402 for (size_t i = 0; i < kDRRectsToDraw; i++) {
403 rrect.inset(0.1f * length, 0.1f * length, &rrect_2);
404 builder.DrawDRRect(rrect, rrect_2, paint);
406 if (rrect.rect().right() > canvas_size) {
407 rrect.offset(-canvas_size, 0);
408 }
409 if (rrect.rect().bottom() > canvas_size) {
410 rrect.offset(0, -canvas_size);
411 }
412 }
413 auto display_list = builder.Build();
414
415 // We only want to time the actual rasterization.
416 for ([[maybe_unused]] auto _ : state) {
417 canvas.DrawDisplayList(display_list);
419 }
420
421 auto filename = surface_provider->backend_name() + "-DrawDRRect-" +
422 std::to_string(state.range(0)) + ".png";
423 surface_provider->Snapshot(filename);
424}
static void set_radii(SkVector radii[4], int index, float rad)
Definition PathTest.cpp:62
const SkRect & rect() const
Definition SkRRect.h:264
@ kSimple_Type
non-zero width and height with equal radii
Definition SkRRect.h:70
@ kNinePatch_Type
non-zero width and height with axis-aligned radii
Definition SkRRect.h:71
@ kComplex_Type
non-zero width and height with arbitrary radii
Definition SkRRect.h:72
void inset(SkScalar dx, SkScalar dy, SkRRect *dst) const
Definition SkRRect.cpp:562
void offset(SkScalar dx, SkScalar dy)
Definition SkRRect.h:387
void setRectRadii(const SkRect &rect, const SkVector radii[4])
Definition SkRRect.cpp:189
SkRRect rrect
Definition SkRecords.h:232
constexpr size_t kDRRectsToDraw
constexpr float right() const
Definition SkRect.h:748
constexpr float bottom() const
Definition SkRect.h:755

◆ BM_DrawImage()

void flutter::testing::BM_DrawImage ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
DlImageSampling  options,
bool  upload_bitmap 
)

Definition at line 936 of file dl_benchmarks.cc.

940 {
941 auto surface_provider = DlSurfaceProvider::Create(backend_type);
942 DisplayListBuilder builder;
943 DlPaint paint = GetPaintForRun(attributes);
944
945 AnnotateAttributes(attributes, state,
946 DisplayListOpFlags::kDrawImageWithPaintFlags);
947
948 size_t bitmap_size = state.range(0);
949 size_t canvas_size = 2 * bitmap_size;
950 surface_provider->InitializeSurface(canvas_size, canvas_size);
951 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
952 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
953
955 std::shared_ptr<DlSurfaceInstance> offscreen_instance;
956 sk_sp<SkSurface> offscreen;
958
959 if (upload_bitmap) {
960 SkImageInfo info = SkImageInfo::Make(bitmap_size, bitmap_size,
963 bitmap.allocPixels(info, 0);
964 bitmap.eraseColor(SK_ColorBLUE);
965 } else {
966 offscreen_instance =
967 surface_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
968 offscreen = offscreen_instance->sk_surface();
969 offscreen->getCanvas()->clear(SK_ColorRED);
970 }
971
972 SkScalar offset = 0.5f;
973 SkPoint dst = SkPoint::Make(0, 0);
974
975 state.counters["DrawCallCount"] = kImagesToDraw;
976 for (size_t i = 0; i < kImagesToDraw; i++) {
977 image = upload_bitmap ? ImageFromBitmapWithNewID(bitmap)
978 : offscreen->makeImageSnapshot();
979 builder.DrawImage(DlImage::Make(image), dst, options, &paint);
980
981 dst.offset(offset, offset);
982 if (dst.x() + bitmap_size > canvas_size) {
983 dst.set(0, dst.y());
984 }
985 if (dst.y() + bitmap_size > canvas_size) {
986 dst.set(dst.x(), 0);
987 }
988 }
989
990 auto display_list = builder.Build();
991
992 for ([[maybe_unused]] auto _ : state) {
993 canvas.DrawDisplayList(display_list);
995 }
996
997 auto filename = surface_provider->backend_name() + "-DrawImage-" +
998 (upload_bitmap ? "Upload-" : "Texture-") +
999 std::to_string(bitmap_size) + ".png";
1000 surface_provider->Snapshot(filename);
1001}
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
sk_sp< SkImage > image
Definition examples.cpp:29
dst
Definition cp.py:12
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ BM_DrawImageNine()

void flutter::testing::BM_DrawImageNine ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
const DlFilterMode  filter,
bool  upload_bitmap 
)

Definition at line 1106 of file dl_benchmarks.cc.

1110 {
1111 auto surface_provider = DlSurfaceProvider::Create(backend_type);
1112 DisplayListBuilder builder;
1113 DlPaint paint = GetPaintForRun(attributes);
1114
1115 AnnotateAttributes(attributes, state,
1116 DisplayListOpFlags::kDrawImageNineWithPaintFlags);
1117
1118 size_t bitmap_size = state.range(0);
1119 size_t canvas_size = 2 * bitmap_size;
1120 surface_provider->InitializeSurface(canvas_size, canvas_size);
1121 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
1122 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
1123
1124 SkIRect center = SkIRect::MakeXYWH(bitmap_size / 4, bitmap_size / 4,
1125 bitmap_size / 2, bitmap_size / 2);
1126
1128 std::shared_ptr<DlSurfaceInstance> offscreen_instance;
1129 sk_sp<SkSurface> offscreen;
1131
1132 if (upload_bitmap) {
1133 SkImageInfo info = SkImageInfo::Make(bitmap_size, bitmap_size,
1136 bitmap.allocPixels(info, 0);
1137 bitmap.eraseColor(SK_ColorBLUE);
1138 } else {
1139 offscreen_instance =
1140 surface_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
1141 offscreen = offscreen_instance->sk_surface();
1142 offscreen->getCanvas()->clear(SK_ColorRED);
1143 }
1144
1145 SkScalar offset = 0.5f;
1146 SkRect dst =
1147 SkRect::MakeXYWH(0.0f, 0.0f, bitmap_size * 0.75f, bitmap_size * 0.75f);
1148
1149 state.counters["DrawCallCount"] = kImagesToDraw;
1150 for (size_t i = 0; i < kImagesToDraw; i++) {
1151 image = upload_bitmap ? ImageFromBitmapWithNewID(bitmap)
1152 : offscreen->makeImageSnapshot();
1153 builder.DrawImageNine(DlImage::Make(image), center, dst, filter, &paint);
1154 dst.offset(offset, offset);
1155 if (dst.right() > canvas_size) {
1156 dst.offsetTo(0, dst.y());
1157 }
1158 if (dst.bottom() > canvas_size) {
1159 dst.offsetTo(dst.x(), 0);
1160 }
1161 }
1162
1163 auto display_list = builder.Build();
1164
1165 for ([[maybe_unused]] auto _ : state) {
1166 canvas.DrawDisplayList(display_list);
1168 }
1169
1170 auto filename = surface_provider->backend_name() + "-DrawImageNine-" +
1171 (upload_bitmap ? "Upload-" : "Texture-") +
1172 FilterModeToString(filter) + "-" +
1173 std::to_string(bitmap_size) + ".png";
1174 surface_provider->Snapshot(filename);
1175}
std::string FilterModeToString(const DlFilterMode mode)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

◆ BM_DrawImageRect()

void flutter::testing::BM_DrawImageRect ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
DlImageSampling  options,
DlCanvas::SrcRectConstraint  constraint,
bool  upload_bitmap 
)

Definition at line 1018 of file dl_benchmarks.cc.

1023 {
1024 auto surface_provider = DlSurfaceProvider::Create(backend_type);
1025 DisplayListBuilder builder;
1026 DlPaint paint = GetPaintForRun(attributes);
1027
1028 AnnotateAttributes(attributes, state,
1029 DisplayListOpFlags::kDrawImageRectWithPaintFlags);
1030
1031 size_t bitmap_size = state.range(0);
1032 size_t canvas_size = 2 * bitmap_size;
1033 surface_provider->InitializeSurface(canvas_size, canvas_size);
1034 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
1035 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
1036
1038 std::shared_ptr<DlSurfaceInstance> offscreen_instance;
1039 sk_sp<SkSurface> offscreen;
1041
1042 if (upload_bitmap) {
1043 SkImageInfo info = SkImageInfo::Make(bitmap_size, bitmap_size,
1046 bitmap.allocPixels(info, 0);
1047 bitmap.eraseColor(SK_ColorBLUE);
1048 } else {
1049 offscreen_instance =
1050 surface_provider->MakeOffscreenSurface(bitmap_size, bitmap_size);
1051 offscreen = offscreen_instance->sk_surface();
1052 offscreen->getCanvas()->clear(SK_ColorRED);
1053 }
1054
1055 SkScalar offset = 0.5f;
1056 SkRect src = SkRect::MakeXYWH(bitmap_size / 4.0f, bitmap_size / 4.0f,
1057 bitmap_size / 2.0f, bitmap_size / 2.0f);
1058 SkRect dst =
1059 SkRect::MakeXYWH(0.0f, 0.0f, bitmap_size * 0.75f, bitmap_size * 0.75f);
1060
1061 state.counters["DrawCallCount"] = kImagesToDraw;
1062 for (size_t i = 0; i < kImagesToDraw; i++) {
1063 image = upload_bitmap ? ImageFromBitmapWithNewID(bitmap)
1064 : offscreen->makeImageSnapshot();
1065 builder.DrawImageRect(DlImage::Make(image), src, dst, options, &paint,
1066 constraint);
1067 dst.offset(offset, offset);
1068 if (dst.right() > canvas_size) {
1069 dst.offsetTo(0, dst.y());
1070 }
1071 if (dst.bottom() > canvas_size) {
1072 dst.offsetTo(dst.x(), 0);
1073 }
1074 }
1075
1076 auto display_list = builder.Build();
1077
1078 for ([[maybe_unused]] auto _ : state) {
1079 canvas.DrawDisplayList(display_list);
1081 }
1082
1083 auto filename = surface_provider->backend_name() + "-DrawImageRect-" +
1084 (upload_bitmap ? "Upload-" : "Texture-") +
1085 ConstraintToString(constraint) + "-" +
1086 std::to_string(bitmap_size) + ".png";
1087 surface_provider->Snapshot(filename);
1088}
std::string ConstraintToString(DlCanvas::SrcRectConstraint constraint)

◆ BM_DrawLine()

void flutter::testing::BM_DrawLine ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes 
)

Definition at line 89 of file dl_benchmarks.cc.

91 {
92 auto surface_provider = DlSurfaceProvider::Create(backend_type);
93 DisplayListBuilder builder;
94 DlPaint paint = GetPaintForRun(attributes);
95
96 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawLineFlags);
97
98 size_t length = state.range(0);
99
100 surface_provider->InitializeSurface(length, length);
101 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
102 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
103
104 state.counters["DrawCallCount"] = kLinesToDraw;
105 for (size_t i = 0; i < kLinesToDraw; i++) {
106 builder.DrawLine(SkPoint::Make(i % length, 0),
108 }
109
110 auto display_list = builder.Build();
111
112 // We only want to time the actual rasterization.
113 for ([[maybe_unused]] auto _ : state) {
114 canvas.DrawDisplayList(display_list);
115 FlushSubmitCpuSync(surface);
116 }
117
118 auto filename = surface_provider->backend_name() + "-DrawLine-" +
119 std::to_string(state.range(0)) + ".png";
120 surface_provider->Snapshot(filename);
121}
constexpr size_t kLinesToDraw

◆ BM_DrawOval()

void flutter::testing::BM_DrawOval ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes 
)

Definition at line 176 of file dl_benchmarks.cc.

178 {
179 auto surface_provider = DlSurfaceProvider::Create(backend_type);
180 DisplayListBuilder builder;
181 DlPaint paint = GetPaintForRun(attributes);
182
183 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawOvalFlags);
184
185 size_t length = state.range(0);
186 size_t canvas_size = length * 2;
187 surface_provider->InitializeSurface(canvas_size, canvas_size);
188 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
189 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
190
191 SkRect rect = SkRect::MakeXYWH(0, 0, length * 1.5f, length);
192 const SkScalar offset = 0.5f;
193
194 state.counters["DrawCallCount"] = kOvalsToDraw;
195 for (size_t i = 0; i < kOvalsToDraw; i++) {
196 builder.DrawOval(rect, paint);
197 rect.offset(offset, offset);
198 if (rect.right() > canvas_size) {
199 rect.offset(-canvas_size, 0);
200 }
201 if (rect.bottom() > canvas_size) {
202 rect.offset(0, -canvas_size);
203 }
204 }
205 auto display_list = builder.Build();
206
207 // We only want to time the actual rasterization.
208 for ([[maybe_unused]] auto _ : state) {
209 canvas.DrawDisplayList(display_list);
211 }
212
213 auto filename = surface_provider->backend_name() + "-DrawOval-" +
214 std::to_string(state.range(0)) + ".png";
215 surface_provider->Snapshot(filename);
216}
constexpr size_t kOvalsToDraw

◆ BM_DrawPath()

void flutter::testing::BM_DrawPath ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
SkPath::Verb  type 
)

Definition at line 641 of file dl_benchmarks.cc.

644 {
645 auto surface_provider = DlSurfaceProvider::Create(backend_type);
646 DisplayListBuilder builder;
647 DlPaint paint = GetPaintForRun(attributes);
648
649 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawPathFlags);
650
651 size_t length = kFixedCanvasSize;
652 surface_provider->InitializeSurface(length, length);
653 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
654 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
655
656 SkPath path;
657
658 std::string label = VerbToString(type);
659 SkPoint center = SkPoint::Make(length / 2.0f, length / 2.0f);
660 float radius = length * 0.25f;
661 state.SetComplexityN(state.range(0));
662
663 MultiplyPath(path, type, center, 20, state.range(0), radius);
664
665 state.counters["VerbCount"] = path.countVerbs();
666 state.counters["DrawCallCount"] = 1;
667
668 builder.DrawPath(path, paint);
669 auto display_list = builder.Build();
670
671 // We only want to time the actual rasterization.
672 for ([[maybe_unused]] auto _ : state) {
673 canvas.DrawDisplayList(display_list);
675 }
676
677 auto filename = surface_provider->backend_name() + "-DrawPath-" + label +
678 "-" + std::to_string(state.range(0)) + ".png";
679 surface_provider->Snapshot(filename);
680}
constexpr size_t kFixedCanvasSize
std::string VerbToString(SkPath::Verb type)
void MultiplyPath(SkPath &path, SkPath::Verb type, SkPoint center, size_t sides, size_t number, float radius)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ BM_DrawPoints()

void flutter::testing::BM_DrawPoints ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
DlCanvas::PointMode  mode 
)

Definition at line 875 of file dl_benchmarks.cc.

878 {
879 auto surface_provider = DlSurfaceProvider::Create(backend_type);
880 DisplayListBuilder builder;
881 DlPaint paint = GetPaintForRun(attributes);
882
883 switch (mode) {
884 case DlCanvas::PointMode::kPoints:
885 AnnotateAttributes(attributes, state,
886 DisplayListOpFlags::kDrawPointsAsPointsFlags);
887 break;
888 case DlCanvas::PointMode::kLines:
889 AnnotateAttributes(attributes, state,
890 DisplayListOpFlags::kDrawPointsAsLinesFlags);
891 break;
892 case DlCanvas::PointMode::kPolygon:
893 AnnotateAttributes(attributes, state,
894 DisplayListOpFlags::kDrawPointsAsPolygonFlags);
895 break;
896 }
897
898 size_t length = kFixedCanvasSize;
899 surface_provider->InitializeSurface(length, length);
900 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
901 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
902
903 size_t point_count = state.range(0);
904 state.SetComplexityN(point_count);
905 state.counters["PointCount"] = point_count;
906 state.counters["DrawCallCount"] = 1;
907
908 std::vector<SkPoint> points =
909 GetTestPoints(point_count, SkISize::Make(length, length));
910 builder.DrawPoints(mode, points.size(), points.data(), paint);
911
912 auto display_list = builder.Build();
913
914 for ([[maybe_unused]] auto _ : state) {
915 canvas.DrawDisplayList(display_list);
916 FlushSubmitCpuSync(surface);
917 }
918
919 auto filename = surface_provider->backend_name() + "-DrawPoints-" +
920 PointModeToString(mode) + "-" + std::to_string(point_count) +
921 ".png";
922 surface_provider->Snapshot(filename);
923}
static const int points[]
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ BM_DrawRect()

void flutter::testing::BM_DrawRect ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes 
)

Definition at line 127 of file dl_benchmarks.cc.

129 {
130 auto surface_provider = DlSurfaceProvider::Create(backend_type);
131 DisplayListBuilder builder;
132 DlPaint paint = GetPaintForRun(attributes);
133
134 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawRectFlags);
135
136 size_t length = state.range(0);
137 size_t canvas_size = length * 2;
138 surface_provider->InitializeSurface(canvas_size, canvas_size);
139 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
140 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
141
142 // As rects have SkScalar dimensions, we want to ensure that we also
143 // draw rects with non-integer position and size
144 const SkScalar offset = 0.5f;
145 SkRect rect = SkRect::MakeLTRB(0, 0, length, length);
146
147 state.counters["DrawCallCount"] = kRectsToDraw;
148 for (size_t i = 0; i < kRectsToDraw; i++) {
149 builder.DrawRect(rect, paint);
150 rect.offset(offset, offset);
151 if (rect.right() > canvas_size) {
152 rect.offset(-canvas_size, 0);
153 }
154 if (rect.bottom() > canvas_size) {
155 rect.offset(0, -canvas_size);
156 }
157 }
158
159 auto display_list = builder.Build();
160
161 // We only want to time the actual rasterization.
162 for ([[maybe_unused]] auto _ : state) {
163 canvas.DrawDisplayList(display_list);
165 }
166
167 auto filename = surface_provider->backend_name() + "-DrawRect-" +
168 std::to_string(state.range(0)) + ".png";
169 surface_provider->Snapshot(filename);
170}
constexpr size_t kRectsToDraw

◆ BM_DrawRRect()

void flutter::testing::BM_DrawRRect ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
SkRRect::Type  type 
)

Definition at line 270 of file dl_benchmarks.cc.

273 {
274 auto surface_provider = DlSurfaceProvider::Create(backend_type);
275 DisplayListBuilder builder;
276 DlPaint paint = GetPaintForRun(attributes);
277
278 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawRRectFlags);
279
280 size_t length = state.range(0);
281 size_t canvas_size = length * 2;
282 surface_provider->InitializeSurface(canvas_size, canvas_size);
283 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
284 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
285
286 SkVector radii[4] = {};
287 switch (type) {
289 radii[0] = SkVector::Make(5.0f, 5.0f);
290 radii[1] = SkVector::Make(5.0f, 5.0f);
291 radii[2] = SkVector::Make(5.0f, 5.0f);
292 radii[3] = SkVector::Make(5.0f, 5.0f);
293 break;
295 radii[0] = SkVector::Make(5.0f, 2.0f);
296 radii[1] = SkVector::Make(3.0f, 2.0f);
297 radii[2] = SkVector::Make(3.0f, 4.0f);
298 radii[3] = SkVector::Make(5.0f, 4.0f);
299 break;
301 radii[0] = SkVector::Make(5.0f, 4.0f);
302 radii[1] = SkVector::Make(4.0f, 5.0f);
303 radii[2] = SkVector::Make(3.0f, 6.0f);
304 radii[3] = SkVector::Make(2.0f, 7.0f);
305 break;
306 default:
307 break;
308 }
309
310 const SkScalar offset = 0.5f;
311 const SkScalar multiplier = length / 16.0f;
312 SkRRect rrect;
313
315 for (size_t i = 0; i < 4; i++) {
316 set_radii[i] = radii[i] * multiplier;
317 }
319
320 state.counters["DrawCallCount"] = kRRectsToDraw;
321 for (size_t i = 0; i < kRRectsToDraw; i++) {
322 builder.DrawRRect(rrect, paint);
324 if (rrect.rect().right() > canvas_size) {
325 rrect.offset(-canvas_size, 0);
326 }
327 if (rrect.rect().bottom() > canvas_size) {
328 rrect.offset(0, -canvas_size);
329 }
330 }
331 auto display_list = builder.Build();
332
333 // We only want to time the actual rasterization.
334 for ([[maybe_unused]] auto _ : state) {
335 canvas.DrawDisplayList(display_list);
337 }
338
339 auto filename = surface_provider->backend_name() + "-DrawRRect-" +
340 std::to_string(state.range(0)) + ".png";
341 surface_provider->Snapshot(filename);
342}
constexpr size_t kRRectsToDraw

◆ BM_DrawShadow()

void flutter::testing::BM_DrawShadow ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
bool  transparent_occluder,
SkPath::Verb  type 
)

Definition at line 1229 of file dl_benchmarks.cc.

1233 {
1234 auto surface_provider = DlSurfaceProvider::Create(backend_type);
1235 DisplayListBuilder builder;
1236 DlPaint paint = GetPaintForRun(attributes);
1237
1238 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawShadowFlags);
1239
1240 size_t length = kFixedCanvasSize;
1241 surface_provider->InitializeSurface(length, length);
1242 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
1243 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
1244
1245 SkPath path;
1246
1247 SkPoint center = SkPoint::Make(length / 2.0f, length / 2.0f);
1248 float radius = length * 0.25f;
1249
1250 switch (type) {
1252 GetLinesPath(path, 10, center, radius);
1253 break;
1255 GetQuadsPath(path, 10, center, radius);
1256 break;
1258 GetConicsPath(path, 10, center, radius);
1259 break;
1261 GetCubicsPath(path, 10, center, radius);
1262 break;
1263 default:
1264 break;
1265 }
1266
1267 float elevation = state.range(0);
1268 state.counters["DrawCallCount"] = 1;
1269
1270 // We can hardcode dpr to 1.0f as we're varying elevation, and dpr is only
1271 // ever used in conjunction with elevation.
1272 builder.DrawShadow(path, DlColor(SK_ColorBLUE), elevation,
1273 transparent_occluder, 1.0f);
1274 auto display_list = builder.Build();
1275
1276 // We only want to time the actual rasterization.
1277 for ([[maybe_unused]] auto _ : state) {
1278 canvas.DrawDisplayList(display_list);
1279 FlushSubmitCpuSync(surface);
1280 }
1281
1282 auto filename = surface_provider->backend_name() + "-DrawShadow-" +
1283 VerbToString(type) + "-" +
1284 (transparent_occluder ? "Transparent-" : "Opaque-") +
1285 std::to_string(elevation) + "-" + ".png";
1286 surface_provider->Snapshot(filename);
1287}
@ kConic_Verb
Definition SkPath.h:1461
@ kCubic_Verb
Definition SkPath.h:1462
@ kQuad_Verb
Definition SkPath.h:1460
@ kLine_Verb
Definition SkPath.h:1459
void GetLinesPath(SkPath &path, size_t sides, SkPoint center, float radius)
void GetQuadsPath(SkPath &path, size_t sides, SkPoint center, float radius)
void GetConicsPath(SkPath &path, size_t sides, SkPoint center, float radius)
void GetCubicsPath(SkPath &path, size_t sides, SkPoint center, float radius)

◆ BM_DrawTextBlob()

void flutter::testing::BM_DrawTextBlob ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes 
)

Definition at line 1184 of file dl_benchmarks.cc.

1186 {
1187 auto surface_provider = DlSurfaceProvider::Create(backend_type);
1188 DisplayListBuilder builder;
1189 DlPaint paint = GetPaintForRun(attributes);
1190
1191 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawTextBlobFlags);
1192
1193 size_t draw_calls = state.range(0);
1194 size_t canvas_size = kFixedCanvasSize;
1195 surface_provider->InitializeSurface(canvas_size, canvas_size);
1196 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
1197 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
1198
1199 state.counters["DrawCallCount_Varies"] = draw_calls;
1200 state.counters["GlyphCount"] = draw_calls;
1201 char character[2] = {'A', '\0'};
1202
1203 for (size_t i = 0; i < draw_calls; i++) {
1204 character[0] = 'A' + (i % 26);
1205 auto blob = SkTextBlob::MakeFromString(character, CreateTestFontOfSize(20));
1206 builder.DrawTextBlob(blob, 50.0f, 50.0f, paint);
1207 }
1208
1209 auto display_list = builder.Build();
1210
1211 for ([[maybe_unused]] auto _ : state) {
1212 canvas.DrawDisplayList(display_list);
1213 FlushSubmitCpuSync(surface);
1214 }
1215
1216 auto filename = surface_provider->backend_name() + "-DrawTextBlob-" +
1217 std::to_string(draw_calls) + ".png";
1218 surface_provider->Snapshot(filename);
1219}
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition SkTextBlob.h:115

◆ BM_DrawVertices()

void flutter::testing::BM_DrawVertices ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
DlVertexMode  mode 
)

Definition at line 779 of file dl_benchmarks.cc.

782 {
783 auto surface_provider = DlSurfaceProvider::Create(backend_type);
784 DisplayListBuilder builder;
785 DlPaint paint = GetPaintForRun(attributes);
786
787 AnnotateAttributes(attributes, state, DisplayListOpFlags::kDrawVerticesFlags);
788
789 size_t length = kFixedCanvasSize;
790 surface_provider->InitializeSurface(length, length);
791 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
792 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
793
794 SkPoint center = SkPoint::Make(length / 2.0f, length / 2.0f);
795
796 float radius = length / 4.0f;
797
798 size_t vertex_count, total_vertex_count = 0;
799 size_t disc_count = state.range(0);
800
801 std::vector<SkPoint> center_points =
802 GetPolygonPoints(disc_count, center, radius / 4.0f);
803
804 state.counters["DrawCallCount"] = center_points.size();
805 for (SkPoint p : center_points) {
806 std::shared_ptr<DlVertices> vertices =
807 GetTestVertices(p, radius, 50, mode, vertex_count);
808 total_vertex_count += vertex_count;
809 builder.DrawVertices(vertices.get(), DlBlendMode::kSrc, paint);
810 }
811
812 state.counters["VertexCount"] = total_vertex_count;
813 state.SetComplexityN(total_vertex_count);
814
815 auto display_list = builder.Build();
816
817 // We only want to time the actual rasterization.
818 for ([[maybe_unused]] auto _ : state) {
819 canvas.DrawDisplayList(display_list);
820 FlushSubmitCpuSync(surface);
821 }
822
823 auto filename = surface_provider->backend_name() + "-DrawVertices-" +
824 std::to_string(disc_count) + "-" + VertexModeToString(mode) +
825 ".png";
826 surface_provider->Snapshot(filename);
827}
std::vector< SkPoint > GetPolygonPoints(size_t n, SkPoint center, SkScalar r)
std::shared_ptr< DlVertices > GetTestVertices(SkPoint center, float radius, size_t vertex_count, DlVertexMode mode, size_t &final_vertex_count)

◆ BM_SaveLayer()

void flutter::testing::BM_SaveLayer ( benchmark::State &  state,
BackendType  backend_type,
unsigned  attributes,
size_t  save_depth 
)

Definition at line 1295 of file dl_benchmarks.cc.

1298 {
1299 auto surface_provider = DlSurfaceProvider::Create(backend_type);
1300 DisplayListBuilder builder;
1301 DlPaint paint = GetPaintForRun(attributes);
1302
1303 AnnotateAttributes(attributes, state, DisplayListOpFlags::kSaveLayerFlags);
1304
1305 size_t length = kFixedCanvasSize;
1306 surface_provider->InitializeSurface(length, length);
1307 auto surface = surface_provider->GetPrimarySurface()->sk_surface();
1308 auto canvas = DlSkCanvasAdapter(surface->getCanvas());
1309
1310 size_t save_layer_calls = state.range(0);
1311
1312 // Ensure we draw two overlapping rects to avoid any peephole optimisations
1313 SkRect rect1 = SkRect::MakeLTRB(0, 0, 0.75f * length, 0.75f * length);
1314 SkRect rect2 =
1315 SkRect::MakeLTRB(0.25f * length, 0.25f * length, length, length);
1316
1317 state.counters["DrawCallCount_Varies"] = save_layer_calls * save_depth;
1318 for (size_t i = 0; i < save_layer_calls; i++) {
1319 for (size_t j = 0; j < save_depth; j++) {
1320 builder.SaveLayer(nullptr, nullptr);
1321 builder.DrawRect(rect1, paint);
1322 builder.DrawRect(rect2, paint);
1323 }
1324 for (size_t j = 0; j < save_depth; j++) {
1325 builder.Restore();
1326 }
1327 }
1328 auto display_list = builder.Build();
1329
1330 // We only want to time the actual rasterization.
1331 for ([[maybe_unused]] auto _ : state) {
1332 canvas.DrawDisplayList(display_list);
1334 }
1335
1336 auto filename = surface_provider->backend_name() + "-SaveLayer-" +
1337 std::to_string(save_depth) + "-" +
1338 std::to_string(save_layer_calls) + ".png";
1339 surface_provider->Snapshot(filename);
1340}

◆ CheckEquality()

void flutter::testing::CheckEquality ( const DlRegion dl_region,
const SkRegion sk_region 
)

Definition at line 344 of file dl_region_unittests.cc.

344 {
345 EXPECT_EQ(dl_region.bounds(), sk_region.getBounds());
346
347 // Do not deband the rectangles - identical to SkRegion::Iterator
348 auto rects = dl_region.getRects(false);
349
350 std::vector<SkIRect> skia_rects;
351
352 auto iterator = SkRegion::Iterator(sk_region);
353 while (!iterator.done()) {
354 skia_rects.push_back(iterator.rect());
355 iterator.next();
356 }
357
358 EXPECT_EQ(rects, skia_rects);
359}
const SkIRect & getBounds() const
Definition SkRegion.h:165
const SkIRect & bounds() const
Definition dl_region.h:53
std::vector< SkIRect > getRects(bool deband=true) const
Definition dl_region.cc:563

◆ CheckFrameTimings()

static void flutter::testing::CheckFrameTimings ( const std::vector< FrameTiming > &  timings,
fml::TimePoint  start,
fml::TimePoint  finish 
)
static

Definition at line 722 of file shell_unittests.cc.

724 {
725 fml::TimePoint last_frame_start;
726 for (size_t i = 0; i < timings.size(); i += 1) {
727 // Ensure that timings are sorted.
728 ASSERT_TRUE(timings[i].Get(FrameTiming::kPhases[0]) >= last_frame_start);
729 last_frame_start = timings[i].Get(FrameTiming::kPhases[0]);
730
731 fml::TimePoint last_phase_time;
732 for (auto phase : FrameTiming::kPhases) {
733 // raster finish wall time doesn't use the same clock base
734 // as rest of the frame timings.
735 if (phase == FrameTiming::kRasterFinishWallTime) {
736 continue;
737 }
738
739 ASSERT_TRUE(timings[i].Get(phase) >= start);
740 ASSERT_TRUE(timings[i].Get(phase) <= finish);
741
742 // phases should have weakly increasing time points
743 ASSERT_TRUE(last_phase_time <= timings[i].Get(phase));
744 last_phase_time = timings[i].Get(phase);
745 }
746 }
747}

◆ CheckSwanglekExtensions()

static void flutter::testing::CheckSwanglekExtensions ( )
static

Definition at line 98 of file test_gl_surface.cc.

98 {
99 const char* extensions = ::eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
100 FML_CHECK(HasExtension(extensions, "EGL_EXT_platform_base")) << extensions;
101 FML_CHECK(HasExtension(extensions, "EGL_ANGLE_platform_angle_vulkan"))
102 << extensions;
103 FML_CHECK(HasExtension(extensions,
104 "EGL_ANGLE_platform_angle_device_type_swiftshader"))
105 << extensions;
106}
#define FML_CHECK(condition)
Definition logging.h:85
static bool HasExtension(const char *extensions, const char *name)

◆ CheckTextSkData()

static void flutter::testing::CheckTextSkData ( const sk_sp< SkData > &  data,
const std::string &  expected 
)
static

Definition at line 26 of file persistent_cache_unittests.cc.

27 {
28 std::string data_string(reinterpret_cast<const char*>(data->bytes()),
29 data->size());
30 ASSERT_EQ(data_string, expected);
31}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ CheckTwoSkSLsAreLoaded()

static void flutter::testing::CheckTwoSkSLsAreLoaded ( )
static

Definition at line 38 of file persistent_cache_unittests.cc.

38 {
39 auto shaders = PersistentCache::GetCacheForProcess()->LoadSkSLs();
40 ASSERT_EQ(shaders.size(), 2u);
41}

◆ clone_string()

char * flutter::testing::clone_string ( const char *  string)

Definition at line 16 of file test_keyboard.cc.

16 {
17 if (string == nullptr) {
18 return nullptr;
19 }
20 size_t len = strlen(string);
21 char* result = new char[len + 1];
22 strcpy(result, string);
23 return result;
24}
GAsyncResult * result

◆ ConfigureBackingStore()

void flutter::testing::ConfigureBackingStore ( FlutterBackingStore backing_store,
EmbedderTestContextType  backend,
bool  opengl_framebuffer 
)

Configures per-backend properties for a given backing store.

Parameters
[in]backing_storeThe backing store to configure.
[in]backendThe test context type used to decide which backend the backing store will be used with.
[in]opengl_framebufferIgnored for all non-OpenGL backends. Flutter supports rendering to both OpenGL textures and framebuffers. When false, the backing store is configured to be an OpenGL texture.

Definition at line 109 of file embedder_unittests_util.cc.

111 {
112 switch (backend) {
113 case EmbedderTestContextType::kVulkanContext:
114 backing_store.type = kFlutterBackingStoreTypeVulkan;
115 break;
116 case EmbedderTestContextType::kOpenGLContext:
117 if (opengl_framebuffer) {
118 backing_store.type = kFlutterBackingStoreTypeOpenGL;
120 } else {
121 backing_store.type = kFlutterBackingStoreTypeOpenGL;
123 }
124 break;
125 case EmbedderTestContextType::kMetalContext:
126 backing_store.type = kFlutterBackingStoreTypeMetal;
127 break;
128 case EmbedderTestContextType::kSoftwareContext:
130 break;
131 }
132}
@ kFlutterOpenGLTargetTypeFramebuffer
Definition embedder.h:304
@ kFlutterOpenGLTargetTypeTexture
Definition embedder.h:301
@ kFlutterBackingStoreTypeMetal
Specifies a Metal backing store. This is backed by a Metal texture.
Definition embedder.h:1744
@ kFlutterBackingStoreTypeVulkan
Specifies a Vulkan backing store. This is backed by a Vulkan VkImage.
Definition embedder.h:1746
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
Definition embedder.h:1742
@ kFlutterBackingStoreTypeOpenGL
Definition embedder.h:1740
FlutterBackingStoreType type
Specifies the type of backing store.
Definition embedder.h:1760
FlutterOpenGLBackingStore open_gl
The description of the OpenGL backing store.
Definition embedder.h:1766
FlutterOpenGLTargetType type
Definition embedder.h:1608

◆ ConstraintToString()

std::string flutter::testing::ConstraintToString ( DlCanvas::SrcRectConstraint  constraint)

Definition at line 1003 of file dl_benchmarks.cc.

1003 {
1004 switch (constraint) {
1005 case DlCanvas::SrcRectConstraint::kStrict:
1006 return "Strict";
1007 case DlCanvas::SrcRectConstraint::kFast:
1008 return "Fast";
1009 default:
1010 return "Unknown";
1011 }
1012}

◆ containsInclusive() [1/4]

static bool flutter::testing::containsInclusive ( const SkIRect  rect,
const SkPoint  quad[4] 
)
static

Definition at line 49 of file dl_image_filter_unittests.cc.

49 {
50 return containsInclusive(SkRect::Make(rect), quad);
51}
static bool containsInclusive(const SkRect rect, const SkPoint p)
static SkRect Make(const SkISize &size)
Definition SkRect.h:669

◆ containsInclusive() [2/4]

static bool flutter::testing::containsInclusive ( const SkIRect  rect,
const SkRect  bounds 
)
static

Definition at line 53 of file dl_image_filter_unittests.cc.

53 {
54 return (bounds.fLeft >= rect.fLeft - 1E-9 &&
55 bounds.fTop >= rect.fTop - 1E-9 &&
56 bounds.fRight <= rect.fRight + 1E-9 &&
57 bounds.fBottom <= rect.fBottom + 1E-9);
58}

◆ containsInclusive() [3/4]

static bool flutter::testing::containsInclusive ( const SkRect  rect,
const SkPoint  p 
)
static

Definition at line 30 of file dl_image_filter_unittests.cc.

30 {
31 // Test with a slight offset of 1E-9 to "forgive" IEEE bit-rounding
32 // Ending up with bounds that are off by 1E-9 (these numbers are all
33 // being tested in device space with this method) will be off by a
34 // negligible amount of a pixel that wouldn't contribute to changing
35 // the color of a pixel.
36 return (p.fX >= rect.fLeft - 1E-9 && //
37 p.fX <= rect.fRight + 1E-9 && //
38 p.fY >= rect.fTop - 1E-9 && //
39 p.fY <= rect.fBottom + 1E-9);
40}

◆ containsInclusive() [4/4]

static bool flutter::testing::containsInclusive ( const SkRect  rect,
const SkPoint  quad[4] 
)
static

Definition at line 42 of file dl_image_filter_unittests.cc.

42 {
43 return (containsInclusive(rect, quad[0]) && //
44 containsInclusive(rect, quad[1]) && //
45 containsInclusive(rect, quad[2]) && //
46 containsInclusive(rect, quad[3]));
47}

◆ CreateAllAttributesOps()

std::vector< DisplayListInvocationGroup > flutter::testing::CreateAllAttributesOps ( )

Definition at line 48 of file dl_test_snippets.cc.

48 {
49 return {
50 {"SetAntiAlias",
51 {
52 {0, 8, 0, [](DlOpReceiver& r) { r.setAntiAlias(true); }},
53 {0, 0, 0, [](DlOpReceiver& r) { r.setAntiAlias(false); }},
54 }},
55 {"SetInvertColors",
56 {
57 {0, 8, 0, [](DlOpReceiver& r) { r.setInvertColors(true); }},
58 {0, 0, 0, [](DlOpReceiver& r) { r.setInvertColors(false); }},
59 }},
60 {"SetStrokeCap",
61 {
62 {0, 8, 0,
63 [](DlOpReceiver& r) { r.setStrokeCap(DlStrokeCap::kRound); }},
64 {0, 8, 0,
65 [](DlOpReceiver& r) { r.setStrokeCap(DlStrokeCap::kSquare); }},
66 {0, 0, 0,
67 [](DlOpReceiver& r) { r.setStrokeCap(DlStrokeCap::kButt); }},
68 }},
69 {"SetStrokeJoin",
70 {
71 {0, 8, 0,
72 [](DlOpReceiver& r) { r.setStrokeJoin(DlStrokeJoin::kBevel); }},
73 {0, 8, 0,
74 [](DlOpReceiver& r) { r.setStrokeJoin(DlStrokeJoin::kRound); }},
75 {0, 0, 0,
76 [](DlOpReceiver& r) { r.setStrokeJoin(DlStrokeJoin::kMiter); }},
77 }},
78 {"SetStyle",
79 {
80 {0, 8, 0,
81 [](DlOpReceiver& r) { r.setDrawStyle(DlDrawStyle::kStroke); }},
82 {0, 8, 0,
83 [](DlOpReceiver& r) {
84 r.setDrawStyle(DlDrawStyle::kStrokeAndFill);
85 }},
86 {0, 0, 0,
87 [](DlOpReceiver& r) { r.setDrawStyle(DlDrawStyle::kFill); }},
88 }},
89 {"SetStrokeWidth",
90 {
91 {0, 8, 0, [](DlOpReceiver& r) { r.setStrokeWidth(1.0); }},
92 {0, 8, 0, [](DlOpReceiver& r) { r.setStrokeWidth(5.0); }},
93 {0, 0, 0, [](DlOpReceiver& r) { r.setStrokeWidth(0.0); }},
94 }},
95 {"SetStrokeMiter",
96 {
97 {0, 8, 0, [](DlOpReceiver& r) { r.setStrokeMiter(0.0); }},
98 {0, 8, 0, [](DlOpReceiver& r) { r.setStrokeMiter(5.0); }},
99 {0, 0, 0, [](DlOpReceiver& r) { r.setStrokeMiter(4.0); }},
100 }},
101 {"SetColor",
102 {
103 {0, 8, 0,
104 [](DlOpReceiver& r) { r.setColor(DlColor(SK_ColorGREEN)); }},
105 {0, 8, 0,
106 [](DlOpReceiver& r) { r.setColor(DlColor(SK_ColorBLUE)); }},
107 {0, 0, 0,
108 [](DlOpReceiver& r) { r.setColor(DlColor(SK_ColorBLACK)); }},
109 }},
110 {"SetBlendMode",
111 {
112 {0, 8, 0,
113 [](DlOpReceiver& r) { r.setBlendMode(DlBlendMode::kSrcIn); }},
114 {0, 8, 0,
115 [](DlOpReceiver& r) { r.setBlendMode(DlBlendMode::kDstIn); }},
116 {0, 0, 0,
117 [](DlOpReceiver& r) { r.setBlendMode(DlBlendMode::kSrcOver); }},
118 }},
119 {"SetColorSource",
120 {
121 {0, 96, 0, [](DlOpReceiver& r) { r.setColorSource(&kTestSource1); }},
122 // stop_count * (sizeof(float) + sizeof(uint32_t)) = 80
123 {0, 80 + 6 * 4, 0,
124 [](DlOpReceiver& r) { r.setColorSource(kTestSource2.get()); }},
125 {0, 80 + 6 * 4, 0,
126 [](DlOpReceiver& r) { r.setColorSource(kTestSource3.get()); }},
127 {0, 88 + 6 * 4, 0,
128 [](DlOpReceiver& r) { r.setColorSource(kTestSource4.get()); }},
129 {0, 80 + 6 * 4, 0,
130 [](DlOpReceiver& r) { r.setColorSource(kTestSource5.get()); }},
131 {0, 0, 0, [](DlOpReceiver& r) { r.setColorSource(nullptr); }},
132 }},
133 {"SetImageFilter",
134 {
135 {0, 32, 0,
136 [](DlOpReceiver& r) { r.setImageFilter(&kTestBlurImageFilter1); }},
137 {0, 32, 0,
138 [](DlOpReceiver& r) { r.setImageFilter(&kTestBlurImageFilter2); }},
139 {0, 32, 0,
140 [](DlOpReceiver& r) { r.setImageFilter(&kTestBlurImageFilter3); }},
141 {0, 32, 0,
142 [](DlOpReceiver& r) { r.setImageFilter(&kTestBlurImageFilter4); }},
143 {0, 24, 0,
144 [](DlOpReceiver& r) {
145 r.setImageFilter(&kTestDilateImageFilter1);
146 }},
147 {0, 24, 0,
148 [](DlOpReceiver& r) {
149 r.setImageFilter(&kTestDilateImageFilter2);
150 }},
151 {0, 24, 0,
152 [](DlOpReceiver& r) {
153 r.setImageFilter(&kTestDilateImageFilter3);
154 }},
155 {0, 24, 0,
156 [](DlOpReceiver& r) { r.setImageFilter(&kTestErodeImageFilter1); }},
157 {0, 24, 0,
158 [](DlOpReceiver& r) { r.setImageFilter(&kTestErodeImageFilter2); }},
159 {0, 24, 0,
160 [](DlOpReceiver& r) { r.setImageFilter(&kTestErodeImageFilter3); }},
161 {0, 64, 0,
162 [](DlOpReceiver& r) {
163 r.setImageFilter(&kTestMatrixImageFilter1);
164 }},
165 {0, 64, 0,
166 [](DlOpReceiver& r) {
167 r.setImageFilter(&kTestMatrixImageFilter2);
168 }},
169 {0, 64, 0,
170 [](DlOpReceiver& r) {
171 r.setImageFilter(&kTestMatrixImageFilter3);
172 }},
173 {0, 24, 0,
174 [](DlOpReceiver& r) {
175 r.setImageFilter(&kTestComposeImageFilter1);
176 }},
177 {0, 24, 0,
178 [](DlOpReceiver& r) {
179 r.setImageFilter(&kTestComposeImageFilter2);
180 }},
181 {0, 24, 0,
182 [](DlOpReceiver& r) {
183 r.setImageFilter(&kTestComposeImageFilter3);
184 }},
185 {0, 24, 0,
186 [](DlOpReceiver& r) { r.setImageFilter(&kTestCFImageFilter1); }},
187 {0, 24, 0,
188 [](DlOpReceiver& r) { r.setImageFilter(&kTestCFImageFilter2); }},
189 {0, 0, 0, [](DlOpReceiver& r) { r.setImageFilter(nullptr); }},
190 {0, 24, 0,
191 [](DlOpReceiver& r) {
192 r.setImageFilter(
193 kTestBlurImageFilter1
194 .makeWithLocalMatrix(SkMatrix::Translate(2, 2))
195 .get());
196 }},
197 }},
198 {"SetColorFilter",
199 {
200 {0, 24, 0,
201 [](DlOpReceiver& r) { r.setColorFilter(&kTestBlendColorFilter1); }},
202 {0, 24, 0,
203 [](DlOpReceiver& r) { r.setColorFilter(&kTestBlendColorFilter2); }},
204 {0, 24, 0,
205 [](DlOpReceiver& r) { r.setColorFilter(&kTestBlendColorFilter3); }},
206 {0, 96, 0,
207 [](DlOpReceiver& r) {
208 r.setColorFilter(&kTestMatrixColorFilter1);
209 }},
210 {0, 96, 0,
211 [](DlOpReceiver& r) {
212 r.setColorFilter(&kTestMatrixColorFilter2);
213 }},
214 {0, 16, 0,
215 [](DlOpReceiver& r) {
216 r.setColorFilter(DlSrgbToLinearGammaColorFilter::kInstance.get());
217 }},
218 {0, 16, 0,
219 [](DlOpReceiver& r) {
220 r.setColorFilter(DlLinearToSrgbGammaColorFilter::kInstance.get());
221 }},
222 {0, 0, 0, [](DlOpReceiver& r) { r.setColorFilter(nullptr); }},
223 }},
224 {"SetPathEffect",
225 {
226 // sizeof(DlDashPathEffect) + 2 * sizeof(SkScalar)
227 {0, 32, 0,
228 [](DlOpReceiver& r) { r.setPathEffect(kTestPathEffect1.get()); }},
229 {0, 32, 0,
230 [](DlOpReceiver& r) { r.setPathEffect(kTestPathEffect2.get()); }},
231 {0, 0, 0, [](DlOpReceiver& r) { r.setPathEffect(nullptr); }},
232 }},
233 {"SetMaskFilter",
234 {
235 {0, 32, 0,
236 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter1); }, 0u,
237 2u},
238 {0, 32, 0,
239 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter2); }, 0u,
240 2u},
241 {0, 32, 0,
242 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter3); }, 0u,
243 2u},
244 {0, 32, 0,
245 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter4); }, 0u,
246 2u},
247 {0, 32, 0,
248 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter5); }, 0u,
249 2u},
250 {0, 0, 0, [](DlOpReceiver& r) { r.setMaskFilter(nullptr); }, 0u, 1u},
251 }},
252 };
253}
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition SkMatrix.h:91
Internal API for rendering recorded display lists to backends.
const myers::Point & get(const myers::Segment &)

◆ CreateAllClipOps()

std::vector< DisplayListInvocationGroup > flutter::testing::CreateAllClipOps ( )

Definition at line 407 of file dl_test_snippets.cc.

407 {
408 return {
409 {"ClipRect",
410 {
411 {1, 24, 0,
412 [](DlOpReceiver& r) {
413 r.clipRect(kTestBounds, DlCanvas::ClipOp::kIntersect, true);
414 }},
415 {1, 24, 0,
416 [](DlOpReceiver& r) {
417 r.clipRect(kTestBounds.makeOffset(1, 1),
418 DlCanvas::ClipOp::kIntersect, true);
419 }},
420 {1, 24, 0,
421 [](DlOpReceiver& r) {
422 r.clipRect(kTestBounds, DlCanvas::ClipOp::kIntersect, false);
423 }},
424 {1, 24, 0,
425 [](DlOpReceiver& r) {
426 r.clipRect(kTestBounds, DlCanvas::ClipOp::kDifference, true);
427 }},
428 {1, 24, 0,
429 [](DlOpReceiver& r) {
430 r.clipRect(kTestBounds, DlCanvas::ClipOp::kDifference, false);
431 }},
432 }},
433 {"ClipRRect",
434 {
435 {1, 64, 0,
436 [](DlOpReceiver& r) {
437 r.clipRRect(kTestRRect, DlCanvas::ClipOp::kIntersect, true);
438 }},
439 {1, 64, 0,
440 [](DlOpReceiver& r) {
441 r.clipRRect(kTestRRect.makeOffset(1, 1),
442 DlCanvas::ClipOp::kIntersect, true);
443 }},
444 {1, 64, 0,
445 [](DlOpReceiver& r) {
446 r.clipRRect(kTestRRect, DlCanvas::ClipOp::kIntersect, false);
447 }},
448 {1, 64, 0,
449 [](DlOpReceiver& r) {
450 r.clipRRect(kTestRRect, DlCanvas::ClipOp::kDifference, true);
451 }},
452 {1, 64, 0,
453 [](DlOpReceiver& r) {
454 r.clipRRect(kTestRRect, DlCanvas::ClipOp::kDifference, false);
455 }},
456 }},
457 {"ClipPath",
458 {
459 {1, 40, 0,
460 [](DlOpReceiver& r) {
461 r.clipPath(kTestPath1, DlCanvas::ClipOp::kIntersect, true);
462 }},
463 {1, 40, 0,
464 [](DlOpReceiver& r) {
465 r.clipPath(kTestPath2, DlCanvas::ClipOp::kIntersect, true);
466 }},
467 {1, 40, 0,
468 [](DlOpReceiver& r) {
469 r.clipPath(kTestPath3, DlCanvas::ClipOp::kIntersect, true);
470 }},
471 {1, 40, 0,
472 [](DlOpReceiver& r) {
473 r.clipPath(kTestPath1, DlCanvas::ClipOp::kIntersect, false);
474 }},
475 {1, 40, 0,
476 [](DlOpReceiver& r) {
477 r.clipPath(kTestPath1, DlCanvas::ClipOp::kDifference, true);
478 }},
479 {1, 40, 0,
480 [](DlOpReceiver& r) {
481 r.clipPath(kTestPath1, DlCanvas::ClipOp::kDifference, false);
482 }},
483 // clipPath(rect) becomes clipRect
484 {1, 24, 0,
485 [](DlOpReceiver& r) {
486 r.clipPath(kTestPathRect, DlCanvas::ClipOp::kIntersect, true);
487 }},
488 // clipPath(oval) becomes clipRRect
489 {1, 64, 0,
490 [](DlOpReceiver& r) {
491 r.clipPath(kTestPathOval, DlCanvas::ClipOp::kIntersect, true);
492 }},
493 }},
494 };
495}
constexpr SkRect makeOffset(float dx, float dy) const
Definition SkRect.h:965

◆ CreateAllGroups()

std::vector< DisplayListInvocationGroup > flutter::testing::CreateAllGroups ( )

Definition at line 942 of file dl_test_snippets.cc.

942 {
943 std::vector<DisplayListInvocationGroup> result;
944 auto all_attribute_ops = CreateAllAttributesOps();
945 std::move(all_attribute_ops.begin(), all_attribute_ops.end(),
946 std::back_inserter(result));
947 auto all_save_restore_ops = CreateAllSaveRestoreOps();
948 std::move(all_save_restore_ops.begin(), all_save_restore_ops.end(),
949 std::back_inserter(result));
950 auto all_transform_ops = CreateAllTransformOps();
951 std::move(all_transform_ops.begin(), all_transform_ops.end(),
952 std::back_inserter(result));
953 auto all_clip_ops = CreateAllClipOps();
954 std::move(all_clip_ops.begin(), all_clip_ops.end(),
955 std::back_inserter(result));
956 auto all_rendering_ops = CreateAllRenderingOps();
957 std::move(all_rendering_ops.begin(), all_rendering_ops.end(),
958 std::back_inserter(result));
959 return result;
960}
std::vector< DisplayListInvocationGroup > CreateAllClipOps()
std::vector< DisplayListInvocationGroup > CreateAllTransformOps()
std::vector< DisplayListInvocationGroup > CreateAllSaveRestoreOps()
std::vector< DisplayListInvocationGroup > CreateAllAttributesOps()
std::vector< DisplayListInvocationGroup > CreateAllRenderingOps()

◆ CreateAllRenderingOps()

std::vector< DisplayListInvocationGroup > flutter::testing::CreateAllRenderingOps ( )

Definition at line 497 of file dl_test_snippets.cc.

497 {
498 return {
499 {"DrawPaint",
500 {
501 {1, 8, 1, [](DlOpReceiver& r) { r.drawPaint(); }},
502 }},
503 {"DrawColor",
504 {
505 {1, 16, 1,
506 [](DlOpReceiver& r) {
507 r.drawColor(DlColor(SK_ColorBLUE), DlBlendMode::kSrcIn);
508 }},
509 {1, 16, 1,
510 [](DlOpReceiver& r) {
511 r.drawColor(DlColor(SK_ColorBLUE), DlBlendMode::kDstOut);
512 }},
513 {1, 16, 1,
514 [](DlOpReceiver& r) {
515 r.drawColor(DlColor(SK_ColorCYAN), DlBlendMode::kSrcIn);
516 }},
517 }},
518 {"DrawLine",
519 {
520 {1, 24, 1,
521 [](DlOpReceiver& r) {
522 r.drawLine({0, 0}, {10, 10});
523 }},
524 {1, 24, 1,
525 [](DlOpReceiver& r) {
526 r.drawLine({0, 1}, {10, 10});
527 }},
528 {1, 24, 1,
529 [](DlOpReceiver& r) {
530 r.drawLine({0, 0}, {20, 10});
531 }},
532 {1, 24, 1,
533 [](DlOpReceiver& r) {
534 r.drawLine({0, 0}, {10, 20});
535 }},
536 }},
537 {"DrawRect",
538 {
539 {1, 24, 1,
540 [](DlOpReceiver& r) {
541 r.drawRect({0, 0, 10, 10});
542 }},
543 {1, 24, 1,
544 [](DlOpReceiver& r) {
545 r.drawRect({0, 1, 10, 10});
546 }},
547 {1, 24, 1,
548 [](DlOpReceiver& r) {
549 r.drawRect({0, 0, 20, 10});
550 }},
551 {1, 24, 1,
552 [](DlOpReceiver& r) {
553 r.drawRect({0, 0, 10, 20});
554 }},
555 }},
556 {"DrawOval",
557 {
558 {1, 24, 1,
559 [](DlOpReceiver& r) {
560 r.drawOval({0, 0, 10, 10});
561 }},
562 {1, 24, 1,
563 [](DlOpReceiver& r) {
564 r.drawOval({0, 1, 10, 10});
565 }},
566 {1, 24, 1,
567 [](DlOpReceiver& r) {
568 r.drawOval({0, 0, 20, 10});
569 }},
570 {1, 24, 1,
571 [](DlOpReceiver& r) {
572 r.drawOval({0, 0, 10, 20});
573 }},
574 }},
575 {"DrawCircle",
576 {
577 {1, 16, 1,
578 [](DlOpReceiver& r) {
579 r.drawCircle({0, 0}, 10);
580 }},
581 {1, 16, 1,
582 [](DlOpReceiver& r) {
583 r.drawCircle({0, 5}, 10);
584 }},
585 {1, 16, 1,
586 [](DlOpReceiver& r) {
587 r.drawCircle({0, 0}, 20);
588 }},
589 }},
590 {"DrawRRect",
591 {
592 {1, 56, 1, [](DlOpReceiver& r) { r.drawRRect(kTestRRect); }},
593 {1, 56, 1,
594 [](DlOpReceiver& r) { r.drawRRect(kTestRRect.makeOffset(5, 5)); }},
595 }},
596 {"DrawDRRect",
597 {
598 {1, 112, 1,
599 [](DlOpReceiver& r) { r.drawDRRect(kTestRRect, kTestInnerRRect); }},
600 {1, 112, 1,
601 [](DlOpReceiver& r) {
602 r.drawDRRect(kTestRRect.makeOffset(5, 5),
603 kTestInnerRRect.makeOffset(4, 4));
604 }},
605 }},
606 {"DrawPath",
607 {
608 {1, 40, 1, [](DlOpReceiver& r) { r.drawPath(kTestPath1); }},
609 {1, 40, 1, [](DlOpReceiver& r) { r.drawPath(kTestPath2); }},
610 {1, 40, 1, [](DlOpReceiver& r) { r.drawPath(kTestPath3); }},
611 {1, 40, 1, [](DlOpReceiver& r) { r.drawPath(kTestPathRect); }},
612 {1, 40, 1, [](DlOpReceiver& r) { r.drawPath(kTestPathOval); }},
613 }},
614 {"DrawArc",
615 {
616 {1, 32, 1,
617 [](DlOpReceiver& r) { r.drawArc(kTestBounds, 45, 270, false); }},
618 {1, 32, 1,
619 [](DlOpReceiver& r) {
620 r.drawArc(kTestBounds.makeOffset(1, 1), 45, 270, false);
621 }},
622 {1, 32, 1,
623 [](DlOpReceiver& r) { r.drawArc(kTestBounds, 30, 270, false); }},
624 {1, 32, 1,
625 [](DlOpReceiver& r) { r.drawArc(kTestBounds, 45, 260, false); }},
626 {1, 32, 1,
627 [](DlOpReceiver& r) { r.drawArc(kTestBounds, 45, 270, true); }},
628 }},
629 {"DrawPoints",
630 {
631 {1, 8 + TestPointCount * 8, 1,
632 [](DlOpReceiver& r) {
633 r.drawPoints(DlCanvas::PointMode::kPoints, TestPointCount,
634 kTestPoints);
635 }},
636 {1, 8 + (TestPointCount - 1) * 8, 1,
637 [](DlOpReceiver& r) {
638 r.drawPoints(DlCanvas::PointMode::kPoints, TestPointCount - 1,
639 kTestPoints);
640 }},
641 {1, 8 + TestPointCount * 8, 1,
642 [](DlOpReceiver& r) {
643 r.drawPoints(DlCanvas::PointMode::kLines, TestPointCount,
644 kTestPoints);
645 }},
646 {1, 8 + TestPointCount * 8, 1,
647 [](DlOpReceiver& r) {
648 r.drawPoints(DlCanvas::PointMode::kPolygon, TestPointCount,
649 kTestPoints);
650 }},
651 }},
652 {"DrawVertices",
653 {
654 {1, 112, 1,
655 [](DlOpReceiver& r) {
656 r.drawVertices(TestVertices1.get(), DlBlendMode::kSrcIn);
657 }},
658 {1, 112, 1,
659 [](DlOpReceiver& r) {
660 r.drawVertices(TestVertices1.get(), DlBlendMode::kDstIn);
661 }},
662 {1, 112, 1,
663 [](DlOpReceiver& r) {
664 r.drawVertices(TestVertices2.get(), DlBlendMode::kSrcIn);
665 }},
666 }},
667 {"DrawImage",
668 {
669 {1, 24, 1,
670 [](DlOpReceiver& r) {
671 r.drawImage(TestImage1, {10, 10}, kNearestSampling, false);
672 }},
673 {1, 24, 1,
674 [](DlOpReceiver& r) {
675 r.drawImage(TestImage1, {10, 10}, kNearestSampling, true);
676 }},
677 {1, 24, 1,
678 [](DlOpReceiver& r) {
679 r.drawImage(TestImage1, {20, 10}, kNearestSampling, false);
680 }},
681 {1, 24, 1,
682 [](DlOpReceiver& r) {
683 r.drawImage(TestImage1, {10, 20}, kNearestSampling, false);
684 }},
685 {1, 24, 1,
686 [](DlOpReceiver& r) {
687 r.drawImage(TestImage1, {10, 10}, kLinearSampling, false);
688 }},
689 {1, 24, 1,
690 [](DlOpReceiver& r) {
691 r.drawImage(TestImage2, {10, 10}, kNearestSampling, false);
692 }},
693 {1, 24, 1,
694 [](DlOpReceiver& r) {
695 auto dl_image = DlImage::Make(TestSkImage);
696 r.drawImage(dl_image, {10, 10}, kNearestSampling, false);
697 }},
698 }},
699 {"DrawImageRect",
700 {
701 {1, 56, 1,
702 [](DlOpReceiver& r) {
703 r.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
704 kNearestSampling, false,
705 DlCanvas::SrcRectConstraint::kFast);
706 }},
707 {1, 56, 1,
708 [](DlOpReceiver& r) {
709 r.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
710 kNearestSampling, true,
711 DlCanvas::SrcRectConstraint::kFast);
712 }},
713 {1, 56, 1,
714 [](DlOpReceiver& r) {
715 r.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
716 kNearestSampling, false,
717 DlCanvas::SrcRectConstraint::kStrict);
718 }},
719 {1, 56, 1,
720 [](DlOpReceiver& r) {
721 r.drawImageRect(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
722 kNearestSampling, false,
723 DlCanvas::SrcRectConstraint::kFast);
724 }},
725 {1, 56, 1,
726 [](DlOpReceiver& r) {
727 r.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
728 kNearestSampling, false,
729 DlCanvas::SrcRectConstraint::kFast);
730 }},
731 {1, 56, 1,
732 [](DlOpReceiver& r) {
733 r.drawImageRect(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
734 kLinearSampling, false,
735 DlCanvas::SrcRectConstraint::kFast);
736 }},
737 {1, 56, 1,
738 [](DlOpReceiver& r) {
739 r.drawImageRect(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
740 kNearestSampling, false,
741 DlCanvas::SrcRectConstraint::kFast);
742 }},
743 {1, 56, 1,
744 [](DlOpReceiver& r) {
745 auto dl_image = DlImage::Make(TestSkImage);
746 r.drawImageRect(dl_image, {10, 10, 15, 15}, {10, 10, 80, 80},
747 kNearestSampling, false,
748 DlCanvas::SrcRectConstraint::kFast);
749 }},
750 }},
751 {"DrawImageNine",
752 {
753 {1, 48, 1,
754 [](DlOpReceiver& r) {
755 r.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
756 DlFilterMode::kNearest, false);
757 }},
758 {1, 48, 1,
759 [](DlOpReceiver& r) {
760 r.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
761 DlFilterMode::kNearest, true);
762 }},
763 {1, 48, 1,
764 [](DlOpReceiver& r) {
765 r.drawImageNine(TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
766 DlFilterMode::kNearest, false);
767 }},
768 {1, 48, 1,
769 [](DlOpReceiver& r) {
770 r.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
771 DlFilterMode::kNearest, false);
772 }},
773 {1, 48, 1,
774 [](DlOpReceiver& r) {
775 r.drawImageNine(TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
776 DlFilterMode::kLinear, false);
777 }},
778 {1, 48, 1,
779 [](DlOpReceiver& r) {
780 r.drawImageNine(TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
781 DlFilterMode::kNearest, false);
782 }},
783 {1, 48, 1,
784 [](DlOpReceiver& r) {
785 auto dl_image = DlImage::Make(TestSkImage);
786 r.drawImageNine(dl_image, {10, 10, 15, 15}, {10, 10, 80, 80},
787 DlFilterMode::kNearest, false);
788 }},
789 }},
790 {"DrawAtlas",
791 {
792 {1, 48 + 32 + 8, 1,
793 [](DlOpReceiver& r) {
794 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
795 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
796 r.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
797 DlBlendMode::kSrcIn, kNearestSampling, nullptr,
798 false);
799 }},
800 {1, 48 + 32 + 8, 1,
801 [](DlOpReceiver& r) {
802 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
803 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
804 r.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
805 DlBlendMode::kSrcIn, kNearestSampling, nullptr, true);
806 }},
807 {1, 48 + 32 + 8, 1,
808 [](DlOpReceiver& r) {
809 static SkRSXform xforms[] = {{0, 1, 0, 0}, {0, 1, 0, 0}};
810 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
811 r.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
812 DlBlendMode::kSrcIn, kNearestSampling, nullptr,
813 false);
814 }},
815 {1, 48 + 32 + 8, 1,
816 [](DlOpReceiver& r) {
817 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
818 static SkRect texs[] = {{10, 10, 20, 20}, {20, 25, 30, 30}};
819 r.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
820 DlBlendMode::kSrcIn, kNearestSampling, nullptr,
821 false);
822 }},
823 {1, 48 + 32 + 8, 1,
824 [](DlOpReceiver& r) {
825 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
826 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
827 r.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
828 DlBlendMode::kSrcIn, kLinearSampling, nullptr, false);
829 }},
830 {1, 48 + 32 + 8, 1,
831 [](DlOpReceiver& r) {
832 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
833 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
834 r.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
835 DlBlendMode::kDstIn, kNearestSampling, nullptr,
836 false);
837 }},
838 {1, 64 + 32 + 8, 1,
839 [](DlOpReceiver& r) {
840 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
841 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
842 static SkRect cull_rect = {0, 0, 200, 200};
843 r.drawAtlas(TestImage2, xforms, texs, nullptr, 2,
844 DlBlendMode::kSrcIn, kNearestSampling, &cull_rect,
845 false);
846 }},
847 {1, 48 + 32 + 8 + 8, 1,
848 [](DlOpReceiver& r) {
849 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
850 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
851 static DlColor colors[] = {DlColor::kBlue(), DlColor::kGreen()};
852 r.drawAtlas(TestImage1, xforms, texs, colors, 2,
853 DlBlendMode::kSrcIn, kNearestSampling, nullptr,
854 false);
855 }},
856 {1, 64 + 32 + 8 + 8, 1,
857 [](DlOpReceiver& r) {
858 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
859 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
860 static DlColor colors[] = {DlColor::kBlue(), DlColor::kGreen()};
861 static SkRect cull_rect = {0, 0, 200, 200};
862 r.drawAtlas(TestImage1, xforms, texs, colors, 2,
863 DlBlendMode::kSrcIn, kNearestSampling, &cull_rect,
864 false);
865 }},
866 {1, 48 + 32 + 8, 1,
867 [](DlOpReceiver& r) {
868 auto dl_image = DlImage::Make(TestSkImage);
869 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
870 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
871 r.drawAtlas(dl_image, xforms, texs, nullptr, 2,
872 DlBlendMode::kSrcIn, kNearestSampling, nullptr,
873 false);
874 }},
875 }},
876 {"DrawDisplayList",
877 {
878 {1, 16, 1,
879 [](DlOpReceiver& r) { r.drawDisplayList(TestDisplayList1, 1.0); },
880 1u},
881 {1, 16, 1,
882 [](DlOpReceiver& r) { r.drawDisplayList(TestDisplayList1, 0.5); },
883 1u},
884 {1, 16, 1,
885 [](DlOpReceiver& r) { r.drawDisplayList(TestDisplayList2, 1.0); },
886 1u},
887 {1, 16, 1,
888 [](DlOpReceiver& r) {
889 r.drawDisplayList(MakeTestDisplayList(10, 10, SK_ColorRED), 1.0);
890 },
891 1u},
892 }},
893 {"DrawTextBlob",
894 {
895 {1, 24, 1,
896 [](DlOpReceiver& r) {
897 r.drawTextBlob(GetTestTextBlob(1), 10, 10);
898 }},
899 {1, 24, 1,
900 [](DlOpReceiver& r) {
901 r.drawTextBlob(GetTestTextBlob(1), 20, 10);
902 }},
903 {1, 24, 1,
904 [](DlOpReceiver& r) {
905 r.drawTextBlob(GetTestTextBlob(1), 10, 20);
906 }},
907 {1, 24, 1,
908 [](DlOpReceiver& r) {
909 r.drawTextBlob(GetTestTextBlob(2), 10, 10);
910 }},
911 }},
912 {"DrawShadow",
913 {
914 {1, 48, 1,
915 [](DlOpReceiver& r) {
916 r.drawShadow(kTestPath1, DlColor(SK_ColorGREEN), 1.0, false, 1.0);
917 }},
918 {1, 48, 1,
919 [](DlOpReceiver& r) {
920 r.drawShadow(kTestPath2, DlColor(SK_ColorGREEN), 1.0, false, 1.0);
921 }},
922 {1, 48, 1,
923 [](DlOpReceiver& r) {
924 r.drawShadow(kTestPath1, DlColor(SK_ColorBLUE), 1.0, false, 1.0);
925 }},
926 {1, 48, 1,
927 [](DlOpReceiver& r) {
928 r.drawShadow(kTestPath1, DlColor(SK_ColorGREEN), 2.0, false, 1.0);
929 }},
930 {1, 48, 1,
931 [](DlOpReceiver& r) {
932 r.drawShadow(kTestPath1, DlColor(SK_ColorGREEN), 1.0, true, 1.0);
933 }},
934 {1, 48, 1,
935 [](DlOpReceiver& r) {
936 r.drawShadow(kTestPath1, DlColor(SK_ColorGREEN), 1.0, false, 2.5);
937 }},
938 }},
939 };
940}
constexpr SkColor SK_ColorCYAN
Definition SkColor.h:143
#define TestPointCount
PODArray< SkRect > texs
Definition SkRecords.h:333
PODArray< SkRSXform > xforms
Definition SkRecords.h:332
PODArray< SkColor > colors
Definition SkRecords.h:276
constexpr SkRect kTestBounds
sk_sp< SkTextBlob > GetTestTextBlob(int index)

◆ CreateAllSaveRestoreOps()

std::vector< DisplayListInvocationGroup > flutter::testing::CreateAllSaveRestoreOps ( )

Definition at line 255 of file dl_test_snippets.cc.

255 {
256 return {
257 {"Save(Layer)+Restore",
258 {
259 // There are many reasons that save and restore can elide content,
260 // including whether or not there are any draw operations between
261 // them, whether or not there are any state changes to restore, and
262 // whether group rendering (opacity) optimizations can allow
263 // attributes to be distributed to the children. To prevent those
264 // cases we include at least one clip operation and 2 overlapping
265 // rendering primitives between each save/restore pair.
266 {5, 96, 2,
267 [](DlOpReceiver& r) {
268 r.save();
269 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
270 r.drawRect({5, 5, 15, 15});
271 r.drawRect({10, 10, 20, 20});
272 r.restore();
273 }},
274 {5, 112, 3,
275 [](DlOpReceiver& r) {
276 r.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
277 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
278 r.drawRect({5, 5, 15, 15});
279 r.drawRect({10, 10, 20, 20});
280 r.restore();
281 }},
282 {5, 112, 3,
283 [](DlOpReceiver& r) {
284 r.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
285 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
286 r.drawRect({5, 5, 15, 15});
287 r.drawRect({10, 10, 20, 20});
288 r.restore();
289 }},
290 {5, 112, 3,
291 [](DlOpReceiver& r) {
292 r.saveLayer(&kTestBounds, SaveLayerOptions::kNoAttributes);
293 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
294 r.drawRect({5, 5, 15, 15});
295 r.drawRect({10, 10, 20, 20});
296 r.restore();
297 }},
298 {5, 112, 3,
299 [](DlOpReceiver& r) {
300 r.saveLayer(&kTestBounds, SaveLayerOptions::kWithAttributes);
301 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
302 r.drawRect({5, 5, 15, 15});
303 r.drawRect({10, 10, 20, 20});
304 r.restore();
305 }},
306 {5, 128, 3,
307 [](DlOpReceiver& r) {
308 r.saveLayer(nullptr, SaveLayerOptions::kNoAttributes,
309 &kTestCFImageFilter1);
310 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
311 r.drawRect({5, 5, 15, 15});
312 r.drawRect({10, 10, 20, 20});
313 r.restore();
314 }},
315 {5, 128, 3,
316 [](DlOpReceiver& r) {
317 r.saveLayer(nullptr, SaveLayerOptions::kWithAttributes,
318 &kTestCFImageFilter1);
319 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
320 r.drawRect({5, 5, 15, 15});
321 r.drawRect({10, 10, 20, 20});
322 r.restore();
323 }},
324 {5, 128, 3,
325 [](DlOpReceiver& r) {
326 r.saveLayer(&kTestBounds, SaveLayerOptions::kNoAttributes,
327 &kTestCFImageFilter1);
328 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
329 r.drawRect({5, 5, 15, 15});
330 r.drawRect({10, 10, 20, 20});
331 r.restore();
332 }},
333 {5, 128, 3,
334 [](DlOpReceiver& r) {
335 r.saveLayer(&kTestBounds, SaveLayerOptions::kWithAttributes,
336 &kTestCFImageFilter1);
337 r.clipRect({0, 0, 25, 25}, DlCanvas::ClipOp::kIntersect, true);
338 r.drawRect({5, 5, 15, 15});
339 r.drawRect({10, 10, 20, 20});
340 r.restore();
341 }},
342 }},
343 };
344}

◆ CreateAllTransformOps()

std::vector< DisplayListInvocationGroup > flutter::testing::CreateAllTransformOps ( )

Definition at line 346 of file dl_test_snippets.cc.

346 {
347 return {
348 {"Translate",
349 {
350 {1, 16, 0, [](DlOpReceiver& r) { r.translate(10, 10); }},
351 {1, 16, 0, [](DlOpReceiver& r) { r.translate(10, 15); }},
352 {1, 16, 0, [](DlOpReceiver& r) { r.translate(15, 10); }},
353 {0, 0, 0, [](DlOpReceiver& r) { r.translate(0, 0); }},
354 }},
355 {"Scale",
356 {
357 {1, 16, 0, [](DlOpReceiver& r) { r.scale(2, 2); }},
358 {1, 16, 0, [](DlOpReceiver& r) { r.scale(2, 3); }},
359 {1, 16, 0, [](DlOpReceiver& r) { r.scale(3, 2); }},
360 {0, 0, 0, [](DlOpReceiver& r) { r.scale(1, 1); }},
361 }},
362 {"Rotate",
363 {
364 {1, 8, 0, [](DlOpReceiver& r) { r.rotate(30); }},
365 {1, 8, 0, [](DlOpReceiver& r) { r.rotate(45); }},
366 {0, 0, 0, [](DlOpReceiver& r) { r.rotate(0); }},
367 {0, 0, 0, [](DlOpReceiver& r) { r.rotate(360); }},
368 }},
369 {"Skew",
370 {
371 {1, 16, 0, [](DlOpReceiver& r) { r.skew(0.1, 0.1); }},
372 {1, 16, 0, [](DlOpReceiver& r) { r.skew(0.1, 0.2); }},
373 {1, 16, 0, [](DlOpReceiver& r) { r.skew(0.2, 0.1); }},
374 {0, 0, 0, [](DlOpReceiver& r) { r.skew(0, 0); }},
375 }},
376 {"Transform2DAffine",
377 {
378 {1, 32, 0,
379 [](DlOpReceiver& r) { r.transform2DAffine(0, 1, 12, 1, 0, 33); }},
380 // r.transform(identity) is ignored
381 {0, 0, 0,
382 [](DlOpReceiver& r) { r.transform2DAffine(1, 0, 0, 0, 1, 0); }},
383 }},
384 {"TransformFullPerspective",
385 {
386 {1, 72, 0,
387 [](DlOpReceiver& r) {
388 r.transformFullPerspective(0, 1, 0, 12, 1, 0, 0, 33, 3, 2, 5, 29,
389 0, 0, 0, 12);
390 }},
391 // r.transform(2D affine) is reduced to 2x3
392 {1, 32, 0,
393 [](DlOpReceiver& r) {
394 r.transformFullPerspective(2, 1, 0, 4, 1, 3, 0, 5, 0, 0, 1, 0, 0,
395 0, 0, 1);
396 }},
397 // r.transform(identity) is ignored
398 {0, 0, 0,
399 [](DlOpReceiver& r) {
400 r.transformFullPerspective(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
401 0, 0, 1);
402 }},
403 }},
404 };
405}

◆ CreateAndRunRootIsolate()

static std::shared_ptr< DartIsolate > flutter::testing::CreateAndRunRootIsolate ( const Settings settings,
const DartVMData vm,
const fml::RefPtr< fml::TaskRunner > &  task_runner,
std::string  entrypoint 
)
static

Definition at line 46 of file dart_lifecycle_unittests.cc.

50 {
51 FML_CHECK(!entrypoint.empty());
52 TaskRunners runners("io.flutter.test", task_runner, task_runner, task_runner,
53 task_runner);
54
55 auto isolate_configuration =
56 IsolateConfiguration::InferFromSettings(settings);
57
58 UIDartState::Context context(runners);
59 context.advisory_script_uri = "main.dart";
60 context.advisory_script_entrypoint = entrypoint.c_str();
61 auto isolate =
62 DartIsolate::CreateRunningRootIsolate(
63 vm.GetSettings(), // settings
64 vm.GetIsolateSnapshot(), // isolate_snapshot
65 {}, // platform configuration
66 DartIsolate::Flags{}, // flags
67 nullptr, // root isolate create callback
68 settings.isolate_create_callback, // isolate create callback
69 settings.isolate_shutdown_callback, // isolate shutdown callback,
70 entrypoint, // dart entrypoint
71 std::nullopt, // dart entrypoint library
72 {}, // dart entrypoint arguments
73 std::move(isolate_configuration), // isolate configuration
74 context // engine context
75 )
76 .lock();
77
78 if (!isolate) {
79 FML_LOG(ERROR) << "Could not launch the root isolate.";
80 return nullptr;
81 }
82
83 return isolate;
84}
fml::RefPtr< const DartSnapshot > GetIsolateSnapshot() const
Get the isolate snapshot necessary to launch isolates in the Dart VM. The Dart VM instance in which t...
const Settings & GetSettings() const
The settings object from which the Dart snapshots were inferred.
#define FML_LOG(severity)
Definition logging.h:82
The subset of state which is owned by the shell or engine and passed through the RuntimeController in...
#define ERROR(message)

◆ CreateFlagsString()

static std::string flutter::testing::CreateFlagsString ( std::vector< const char * > &  flags)
static

Definition at line 357 of file shell_unittests.cc.

357 {
358 if (flags.empty()) {
359 return "";
360 }
361 std::string flags_string = flags[0];
362 for (size_t i = 1; i < flags.size(); ++i) {
363 flags_string += ",";
364 flags_string += flags[i];
365 }
366 return flags_string;
367}

◆ CreateImpellerContext()

static std::shared_ptr< impeller::ContextMTL > flutter::testing::CreateImpellerContext ( )
static

Definition at line 45 of file gpu_surface_metal_impeller_unittests.mm.

45 {
46 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
47 std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
48 impeller_entity_shaders_length),
49 std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
50 impeller_modern_shaders_length),
51 std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
52 impeller_framebuffer_blend_shaders_length),
53 };
54 auto sync_switch = std::make_shared<fml::SyncSwitch>(false);
55 return impeller::ContextMTL::Create(shader_mappings, sync_switch, "Impeller Library");
56}
static std::shared_ptr< ContextMTL > Create(const std::vector< std::string > &shader_library_paths, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)

◆ CreateKeyEventLparam()

LPARAM flutter::testing::CreateKeyEventLparam ( USHORT  scancode,
bool  extended,
bool  was_down,
USHORT  repeat_count,
bool  context_code,
bool  transition_state 
)

Definition at line 82 of file test_keyboard.cc.

87 {
88 return ((LPARAM(transition_state) << 31) | (LPARAM(was_down) << 30) |
89 (LPARAM(context_code) << 29) | (LPARAM(extended ? 0x1 : 0x0) << 24) |
90 (LPARAM(scancode) << 16) | LPARAM(repeat_count));
91}
LONG_PTR LPARAM

◆ CreateMockFlutterEngine()

id flutter::testing::CreateMockFlutterEngine ( NSString *  pasteboardString)

Definition at line 76 of file FlutterEngineTestUtils.mm.

76 {
77 NSString* fixtures = @(testing::GetFixturesPath());
78 FlutterDartProject* project = [[FlutterDartProject alloc]
79 initWithAssetsPath:fixtures
80 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
81 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
82 project:project
83 allowHeadlessExecution:true];
84
85 FakePasteboard* pasteboardMock = [[FakePasteboard alloc] init];
86 [pasteboardMock setString:pasteboardString forType:NSPasteboardTypeString];
87 engine.pasteboard = pasteboardMock;
88 id engineMock = OCMPartialMock(engine);
89 return engineMock;
90}
FlutterEngine engine
Definition main.cc:68
FlutterPasteboard * pasteboard

◆ CreateMockViewController()

id flutter::testing::CreateMockViewController ( )

Definition at line 9 of file FlutterViewControllerTestUtils.mm.

9 {
10 {
11 NSString* fixtures = @(testing::GetFixturesPath());
12 FlutterDartProject* project = [[FlutterDartProject alloc]
13 initWithAssetsPath:fixtures
14 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
15 FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project];
16 id viewControllerMock = OCMPartialMock(viewController);
17 return viewControllerMock;
18 }
19}
FlutterViewController * viewController

◆ CreateOffscreenTexture()

static fml::scoped_nsprotocol< id< MTLTexture > > flutter::testing::CreateOffscreenTexture ( id< MTLDevice >  device)
static

Definition at line 20 of file shell_test_platform_view_metal.mm.

20 {
21 auto descriptor =
22 [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
23 width:800
24 height:600
25 mipmapped:NO];
26 descriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
27 return fml::scoped_nsprotocol<id<MTLTexture>>{[device newTextureWithDescriptor:descriptor]};
28}
VkDevice device
Definition main.cc:53
int32_t height
int32_t width

◆ CreatePresentInfo()

static FlutterSurfacePresentInfo * flutter::testing::CreatePresentInfo ( FlutterSurface surface,
CGPoint  offset = CGPointZero,
size_t  index = 0,
const std::vector< FlutterRect > &  paintRegion = {} 
)
static

Definition at line 51 of file FlutterSurfaceManagerTest.mm.

55 {}) {
57 res.surface = surface;
58 res.offset = offset;
59 res.zIndex = index;
60 res.paintRegion = paintRegion;
61 return res;
62}
std::vector< FlutterRect > paintRegion

◆ CreateRenderSurface()

sk_sp< SkSurface > flutter::testing::CreateRenderSurface ( const FlutterLayer layer,
GrDirectContext context 
)

Definition at line 21 of file embedder_unittests_util.cc.

22 {
23 const auto image_info =
25 auto surface = context ? SkSurfaces::RenderTarget(
26 context, // context
27 skgpu::Budgeted::kNo, // budgeted
28 image_info, // image info
29 1, // sample count
30 kTopLeft_GrSurfaceOrigin, // surface origin
31 nullptr, // surface properties
32 false // mipmaps
33
34 )
35 : SkSurfaces::Raster(image_info);
36 FML_CHECK(surface != nullptr);
37 return surface;
38}
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
FlutterSize size
The size of the layer (in physical pixels).
Definition embedder.h:1835
double height
Definition embedder.h:423
double width
Definition embedder.h:422
static SkImageInfo MakeN32Premul(int width, int height)

◆ 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}
FlutterSemanticsAction
Definition embedder.h:113
FlutterSemanticsFlag
Definition embedder.h:170
const uintptr_t id

◆ CreateSimpleSimulatedPointerData()

void flutter::testing::CreateSimpleSimulatedPointerData ( PointerData data,
PointerData::Change  change,
int64_t  device,
double  dx,
double  dy,
int64_t  buttons 
)

Definition at line 15 of file pointer_data_packet_unittests.cc.

20 {
21 data.time_stamp = 0;
22 data.change = change;
23 data.kind = PointerData::DeviceKind::kTouch;
24 data.signal_kind = PointerData::SignalKind::kNone;
25 data.device = device;
26 data.pointer_identifier = 0;
27 data.physical_x = dx;
28 data.physical_y = dy;
29 data.physical_delta_x = 0.0;
30 data.physical_delta_y = 0.0;
31 data.buttons = buttons;
32 data.obscured = 0;
33 data.synthesized = 0;
34 data.pressure = 0.0;
35 data.pressure_min = 0.0;
36 data.pressure_max = 0.0;
37 data.distance = 0.0;
38 data.distance_max = 0.0;
39 data.size = 0.0;
40 data.radius_major = 0.0;
41 data.radius_minor = 0.0;
42 data.radius_min = 0.0;
43 data.radius_max = 0.0;
44 data.orientation = 0.0;
45 data.tilt = 0.0;
46 data.platformData = 0;
47 data.scroll_delta_x = 0.0;
48 data.scroll_delta_y = 0.0;
49}

◆ CreateSimulatedMousePointerData()

void flutter::testing::CreateSimulatedMousePointerData ( PointerData data,
PointerData::Change  change,
PointerData::SignalKind  signal_kind,
int64_t  device,
double  dx,
double  dy,
double  scroll_delta_x,
double  scroll_delta_y,
int64_t  buttons 
)

Definition at line 51 of file pointer_data_packet_converter_unittests.cc.

59 {
60 data.time_stamp = 0;
61 data.change = change;
62 data.kind = PointerData::DeviceKind::kMouse;
63 data.signal_kind = signal_kind;
64 data.device = device;
65 data.pointer_identifier = 0;
66 data.physical_x = dx;
67 data.physical_y = dy;
68 data.physical_delta_x = 0.0;
69 data.physical_delta_y = 0.0;
70 data.buttons = buttons;
71 data.obscured = 0;
72 data.synthesized = 0;
73 data.pressure = 0.0;
74 data.pressure_min = 0.0;
75 data.pressure_max = 0.0;
76 data.distance = 0.0;
77 data.distance_max = 0.0;
78 data.size = 0.0;
79 data.radius_major = 0.0;
80 data.radius_minor = 0.0;
81 data.radius_min = 0.0;
82 data.radius_max = 0.0;
83 data.orientation = 0.0;
84 data.tilt = 0.0;
85 data.platformData = 0;
86 data.scroll_delta_x = scroll_delta_x;
87 data.scroll_delta_y = scroll_delta_y;
88 data.view_id = 0;
89}

◆ CreateSimulatedPointerData() [1/2]

void flutter::testing::CreateSimulatedPointerData ( PointerData data,
PointerData::Change  change,
double  dx,
double  dy 
)

Definition at line 152 of file input_events_unittests.cc.

155 {
156 data.time_stamp = 0;
157 data.change = change;
158 data.kind = PointerData::DeviceKind::kTouch;
159 data.signal_kind = PointerData::SignalKind::kNone;
160 data.device = 0;
161 data.pointer_identifier = 0;
162 data.physical_x = dx;
163 data.physical_y = dy;
164 data.physical_delta_x = 0.0;
165 data.physical_delta_y = 0.0;
166 data.buttons = 0;
167 data.obscured = 0;
168 data.synthesized = 0;
169 data.pressure = 0.0;
170 data.pressure_min = 0.0;
171 data.pressure_max = 0.0;
172 data.distance = 0.0;
173 data.distance_max = 0.0;
174 data.size = 0.0;
175 data.radius_major = 0.0;
176 data.radius_minor = 0.0;
177 data.radius_min = 0.0;
178 data.radius_max = 0.0;
179 data.orientation = 0.0;
180 data.tilt = 0.0;
181 data.platformData = 0;
182 data.scroll_delta_x = 0.0;
183 data.scroll_delta_y = 0.0;
184}

◆ CreateSimulatedPointerData() [2/2]

void flutter::testing::CreateSimulatedPointerData ( PointerData data,
PointerData::Change  change,
int64_t  device,
double  dx,
double  dy,
int64_t  buttons 
)

Definition at line 14 of file pointer_data_packet_converter_unittests.cc.

19 {
20 data.time_stamp = 0;
21 data.change = change;
22 data.kind = PointerData::DeviceKind::kTouch;
23 data.signal_kind = PointerData::SignalKind::kNone;
24 data.device = device;
25 data.pointer_identifier = 0;
26 data.physical_x = dx;
27 data.physical_y = dy;
28 data.physical_delta_x = 0.0;
29 data.physical_delta_y = 0.0;
30 data.buttons = buttons;
31 data.obscured = 0;
32 data.synthesized = 0;
33 data.pressure = 0.0;
34 data.pressure_min = 0.0;
35 data.pressure_max = 0.0;
36 data.distance = 0.0;
37 data.distance_max = 0.0;
38 data.size = 0.0;
39 data.radius_major = 0.0;
40 data.radius_minor = 0.0;
41 data.radius_min = 0.0;
42 data.radius_max = 0.0;
43 data.orientation = 0.0;
44 data.tilt = 0.0;
45 data.platformData = 0;
46 data.scroll_delta_x = 0.0;
47 data.scroll_delta_y = 0.0;
48 data.view_id = 0;
49}

◆ CreateSimulatedTrackpadGestureData()

void flutter::testing::CreateSimulatedTrackpadGestureData ( PointerData data,
PointerData::Change  change,
int64_t  device,
double  dx,
double  dy,
double  pan_x,
double  pan_y,
double  scale,
double  rotation 
)

Definition at line 91 of file pointer_data_packet_converter_unittests.cc.

99 {
100 data.time_stamp = 0;
101 data.change = change;
102 data.kind = PointerData::DeviceKind::kMouse;
103 data.signal_kind = PointerData::SignalKind::kNone;
104 data.device = device;
105 data.pointer_identifier = 0;
106 data.physical_x = dx;
107 data.physical_y = dy;
108 data.physical_delta_x = 0.0;
109 data.physical_delta_y = 0.0;
110 data.buttons = 0;
111 data.obscured = 0;
112 data.synthesized = 0;
113 data.pressure = 0.0;
114 data.pressure_min = 0.0;
115 data.pressure_max = 0.0;
116 data.distance = 0.0;
117 data.distance_max = 0.0;
118 data.size = 0.0;
119 data.radius_major = 0.0;
120 data.radius_minor = 0.0;
121 data.radius_min = 0.0;
122 data.radius_max = 0.0;
123 data.orientation = 0.0;
124 data.tilt = 0.0;
125 data.platformData = 0;
126 data.scroll_delta_x = 0.0;
127 data.scroll_delta_y = 0.0;
128 data.pan_x = pan_x;
129 data.pan_y = pan_y;
130 data.pan_delta_x = 0.0;
131 data.pan_delta_y = 0.0;
132 data.scale = scale;
133 data.rotation = rotation;
134 data.view_id = 0;
135}
const Scalar scale

◆ CreateSurfaceManager()

static FlutterSurfaceManager * flutter::testing::CreateSurfaceManager ( TestView testView)
static

Definition at line 41 of file FlutterSurfaceManagerTest.mm.

41 {
42 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
43 id<MTLCommandQueue> commandQueue = [device newCommandQueue];
44 CALayer* layer = reinterpret_cast<CALayer*>(testView.layer);
45 return [[FlutterSurfaceManager alloc] initWithDevice:device
46 commandQueue:commandQueue
47 layer:layer
48 delegate:testView];
49}

◆ CreateSwangleDisplay()

static EGLDisplay flutter::testing::CreateSwangleDisplay ( )
static

Definition at line 108 of file test_gl_surface.cc.

108 {
110
111 PFNEGLGETPLATFORMDISPLAYEXTPROC egl_get_platform_display_EXT =
112 reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
113 eglGetProcAddress("eglGetPlatformDisplayEXT"));
114 FML_CHECK(egl_get_platform_display_EXT)
115 << "eglGetPlatformDisplayEXT not available.";
116
117 const EGLint display_config[] = {
119 EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE,
120 EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE,
121 EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE,
122 EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE,
123 EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE,
124 EGL_NONE,
125 };
126
127 return egl_get_platform_display_EXT(
129 reinterpret_cast<EGLNativeDisplayType*>(EGL_DEFAULT_DISPLAY),
130 display_config);
131}
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE
#define EGL_PLATFORM_ANGLE_ANGLE
static void CheckSwanglekExtensions()

◆ CreateTestFontOfSize()

SkFont flutter::testing::CreateTestFontOfSize ( SkScalar  scalar)

Definition at line 962 of file dl_test_snippets.cc.

962 {
963 static constexpr const char* kTestFontFixture = "Roboto-Regular.ttf";
964 auto mapping = flutter::testing::OpenFixtureAsSkData(kTestFontFixture);
965 FML_CHECK(mapping);
966 return SkFont{txt::GetDefaultFontManager()->makeFromData(mapping), scalar};
967}
sk_sp< SkTypeface > makeFromData(sk_sp< SkData >, int ttcIndex=0) const
sk_sp< SkData > OpenFixtureAsSkData(const std::string &fixture_name)
Opens a fixture of the given file name and returns a Skia SkData holding its contents.
Definition testing.cc:64
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
Definition platform.cc:17

◆ DartNativeEntrySymbolCallback()

static const uint8_t * flutter::testing::DartNativeEntrySymbolCallback ( Dart_NativeFunction  function)
static

Definition at line 76 of file test_dart_native_resolver.cc.

77 {
78 return reinterpret_cast<const uint8_t*>("¯\\_(ツ)_/¯");
79}

◆ DecodeBGR10()

float flutter::testing::DecodeBGR10 ( uint32_t  x)

Definition at line 68 of file image_decoder_no_gl_unittests.cc.

68 {
69 const float max = 1.25098f;
70 const float min = -0.752941f;
71 const float intercept = min;
72 const float slope = (max - min) / 1024.0f;
73 return (x * slope) + intercept;
74}
static float max(float r, float g, float b)
Definition hsl.cpp:49
static float min(float r, float g, float b)
Definition hsl.cpp:48
double x

◆ DisplayListsEQ_Verbose() [1/3]

bool flutter::testing::DisplayListsEQ_Verbose ( const DisplayList a,
const DisplayList b 
)
inline

Definition at line 17 of file display_list_testing.h.

17 {
18 return DisplayListsEQ_Verbose(&a, &b);
19}
static bool b
struct MyStruct a[10]
bool DisplayListsEQ_Verbose(const DisplayList *a, const DisplayList *b)

◆ DisplayListsEQ_Verbose() [2/3]

bool flutter::testing::DisplayListsEQ_Verbose ( const DisplayList a,
const DisplayList b 
)

Definition at line 15 of file display_list_testing.cc.

15 {
16 if (a->Equals(b)) {
17 return true;
18 }
19 FML_LOG(ERROR) << std::endl
20 << std::endl
21 << *a << std::endl
22 << "not identical to ..." << std::endl
23 << std::endl
24 << *b;
25 return false;
26}

◆ DisplayListsEQ_Verbose() [3/3]

bool flutter::testing::DisplayListsEQ_Verbose ( const sk_sp< const DisplayList > &  a,
const sk_sp< const DisplayList > &  b 
)
inline

Definition at line 20 of file display_list_testing.h.

21 {
22 return DisplayListsEQ_Verbose(a.get(), b.get());
23}

◆ DisplayListsNE_Verbose() [1/3]

bool flutter::testing::DisplayListsNE_Verbose ( const DisplayList a,
const DisplayList b 
)
inline

Definition at line 25 of file display_list_testing.h.

25 {
26 return DisplayListsNE_Verbose(&a, &b);
27}
bool DisplayListsNE_Verbose(const DisplayList *a, const DisplayList *b)

◆ DisplayListsNE_Verbose() [2/3]

bool flutter::testing::DisplayListsNE_Verbose ( const DisplayList a,
const DisplayList b 
)

Definition at line 28 of file display_list_testing.cc.

28 {
29 if (a->Equals(b)) {
30 FML_LOG(ERROR) << std::endl
31 << "DisplayLists are both the same:" << std::endl
32 << *a;
33 return false;
34 }
35 return true;
36}

◆ DisplayListsNE_Verbose() [3/3]

bool flutter::testing::DisplayListsNE_Verbose ( const sk_sp< const DisplayList > &  a,
const sk_sp< const DisplayList > &  b 
)
inline

Definition at line 28 of file display_list_testing.h.

29 {
30 return DisplayListsNE_Verbose(a.get(), b.get());
31}

◆ DrawCheckerboard() [1/2]

static void flutter::testing::DrawCheckerboard ( DlCanvas canvas)
static

Definition at line 170 of file dl_rendering_unittests.cc.

170 {
171 DlPaint p0, p1;
172 p0.setDrawStyle(DlDrawStyle::kFill);
173 p0.setColor(DlColor(0xff00fe00)); // off-green
174 p1.setDrawStyle(DlDrawStyle::kFill);
175 p1.setColor(DlColor::kBlue());
176 // Some pixels need some transparency for DstIn testing
177 p1.setAlpha(128);
178 int cbdim = 5;
179 int width = canvas->GetBaseLayerSize().width();
180 int height = canvas->GetBaseLayerSize().height();
181 for (int y = 0; y < width; y += cbdim) {
182 for (int x = 0; x < height; x += cbdim) {
183 DlPaint& cellp = ((x + y) & 1) == 0 ? p0 : p1;
184 canvas->DrawRect(SkRect::MakeXYWH(x, y, cbdim, cbdim), cellp);
185 }
186 }
187}
virtual void DrawRect(const SkRect &rect, const DlPaint &paint)=0
virtual SkISize GetBaseLayerSize() const =0
DlPaint & setColor(DlColor color)
Definition dl_paint.h:71
DlPaint & setAlpha(uint8_t alpha)
Definition dl_paint.h:77
DlPaint & setDrawStyle(DlDrawStyle style)
Definition dl_paint.h:95
double y
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ DrawCheckerboard() [2/2]

static void flutter::testing::DrawCheckerboard ( SkCanvas canvas)
static

Definition at line 189 of file dl_rendering_unittests.cc.

189 {
190 DlSkCanvasAdapter dl_canvas(canvas);
191 DrawCheckerboard(&dl_canvas);
192}
static void DrawCheckerboard(DlCanvas *canvas)

◆ EchoBool()

bool flutter::testing::EchoBool ( bool  arg)

Definition at line 153 of file ffi_native_unittest.cc.

153 {
154 EXPECT_TRUE(arg);
155 return arg;
156}

◆ EchoDouble()

double flutter::testing::EchoDouble ( double  arg)

Definition at line 193 of file ffi_native_unittest.cc.

193 {
194 EXPECT_EQ(arg, 23.0);
195 return arg;
196}

◆ EchoHandle()

Dart_Handle flutter::testing::EchoHandle ( Dart_Handle  str)

Definition at line 210 of file ffi_native_unittest.cc.

210 {
211 const char* c_str = nullptr;
212 Dart_StringToCString(str, &c_str);
213 EXPECT_STREQ(c_str, "Hello EchoHandle");
214 return str;
215}
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str, const char **cstr)

◆ EchoIntPtr()

intptr_t flutter::testing::EchoIntPtr ( intptr_t  arg)

Definition at line 170 of file ffi_native_unittest.cc.

170 {
171 EXPECT_EQ(arg, 23);
172 return arg;
173}

◆ EchoString()

std::string flutter::testing::EchoString ( std::string  arg)

Definition at line 229 of file ffi_native_unittest.cc.

229 {
230 EXPECT_STREQ(arg.c_str(), "Hello EchoString");
231 return arg;
232}

◆ EchoTypedList()

tonic::Float32List flutter::testing::EchoTypedList ( tonic::Float32List  arg)

Definition at line 303 of file ffi_native_unittest.cc.

303 {
304 EXPECT_NEAR(arg[1], 3.14, 0.01);
305 return arg;
306}

◆ EchoU16String()

std::u16string flutter::testing::EchoU16String ( std::u16string  arg)

Definition at line 246 of file ffi_native_unittest.cc.

246 {
247 EXPECT_EQ(arg, u"Hello EchoU16String");
248 return arg;
249}

◆ EchoVector()

std::vector< std::string > flutter::testing::EchoVector ( const std::vector< std::string > &  arg)

Definition at line 263 of file ffi_native_unittest.cc.

263 {
264 EXPECT_STREQ(arg[0].c_str(), "Hello EchoVector");
265 return arg;
266}

◆ EchoWrappable()

intptr_t flutter::testing::EchoWrappable ( MyNativeClass arg)

Definition at line 280 of file ffi_native_unittest.cc.

280 {
281 EXPECT_EQ(arg->_value, 0x1234);
282 return arg->_value;
283}

◆ ExpectKeyEventEq()

void flutter::testing::ExpectKeyEventEq ( const FlutterKeyEvent subject,
const FlutterKeyEvent baseline 
)

Definition at line 2892 of file embedder_unittests.cc.

2893 {
2894 EXPECT_EQ(subject.timestamp, baseline.timestamp);
2895 EXPECT_EQ(subject.type, baseline.type);
2896 EXPECT_EQ(subject.physical, baseline.physical);
2897 EXPECT_EQ(subject.logical, baseline.logical);
2898 EXPECT_EQ(subject.synthesized, baseline.synthesized);
2899 EXPECT_EQ(subject.device_type, baseline.device_type);
2900}
FlutterKeyEventDeviceType device_type
The source device for the key event.
Definition embedder.h:1150

◆ expectSoftwareRenderingOutputMatches() [1/2]

static void flutter::testing::expectSoftwareRenderingOutputMatches ( EmbedderTest test,
std::string  entrypoint,
FlutterSoftwarePixelFormat  pixfmt,
const std::vector< uint8_t > &  bytes 
)
static

Definition at line 2706 of file embedder_unittests.cc.

2710 {
2711 auto& context =
2712 test.GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2713
2714 EmbedderConfigBuilder builder(context);
2716 bool matches = false;
2717
2718 builder.SetSoftwareRendererConfig();
2719 builder.SetCompositor();
2720 builder.SetDartEntrypoint(std::move(entrypoint));
2721 builder.SetRenderTargetType(
2722 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer2,
2723 pixfmt);
2724
2725 auto engine = builder.LaunchEngine();
2726 ASSERT_TRUE(engine.is_valid());
2727
2728 context.GetCompositor().SetNextPresentCallback(
2729 [&matches, &bytes, &latch](FlutterViewId view_id,
2730 const FlutterLayer** layers,
2731 size_t layers_count) {
2732 ASSERT_EQ(layers[0]->type, kFlutterLayerContentTypeBackingStore);
2733 ASSERT_EQ(layers[0]->backing_store->type,
2736 static_cast<SkSurface*>(
2737 layers[0]->backing_store->software2.user_data),
2738 bytes);
2739 latch.Signal();
2740 });
2741
2742 // Send a window metrics events so frames may be scheduled.
2743 FlutterWindowMetricsEvent event = {};
2744 event.struct_size = sizeof(event);
2745 event.width = 1;
2746 event.height = 1;
2747 event.pixel_ratio = 1.0;
2749 kSuccess);
2750
2751 latch.Wait();
2752 ASSERT_TRUE(matches);
2753
2754 engine.reset();
2755}
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics)
Definition embedder.cc:2314
@ kFlutterLayerContentTypeBackingStore
Definition embedder.h:1791
@ kSuccess
Definition embedder.h:73
@ kFlutterBackingStoreTypeSoftware2
Definition embedder.h:1749
bool SurfacePixelDataMatchesBytes(SkSurface *surface, const std::vector< uint8_t > &bytes)
int64_t FlutterViewId
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
Definition embedder.h:841

◆ expectSoftwareRenderingOutputMatches() [2/2]

template<typename T >
static void flutter::testing::expectSoftwareRenderingOutputMatches ( EmbedderTest test,
std::string  entrypoint,
FlutterSoftwarePixelFormat  pixfmt,
T  pixelvalue 
)
static

Definition at line 2758 of file embedder_unittests.cc.

2762 {
2763 uint8_t* bytes = reinterpret_cast<uint8_t*>(&pixelvalue);
2765 test, std::move(entrypoint), pixfmt,
2766 std::vector<uint8_t>(bytes, bytes + sizeof(T)));
2767}
static void expectSoftwareRenderingOutputMatches(EmbedderTest &test, std::string entrypoint, FlutterSoftwarePixelFormat pixfmt, const std::vector< uint8_t > &bytes)
#define T

◆ FilterModeToString()

std::string flutter::testing::FilterModeToString ( const DlFilterMode  mode)

Definition at line 1090 of file dl_benchmarks.cc.

1090 {
1091 switch (mode) {
1092 case DlFilterMode::kNearest:
1093 return "Nearest";
1094 case DlFilterMode::kLinear:
1095 return "Linear";
1096 default:
1097 return "Unknown";
1098 }
1099}

◆ FilterMutationsByType() [1/2]

void flutter::testing::FilterMutationsByType ( const FlutterPlatformView view,
FlutterPlatformViewMutationType  type,
const std::function< void(const FlutterPlatformViewMutation &mutation)> &  handler 
)

Definition at line 282 of file embedder_unittests_util.cc.

286 {
288 handler);
289}
void FilterMutationsByType(const FlutterPlatformViewMutation **mutations, size_t count, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
const FlutterPlatformViewMutation ** mutations
Definition embedder.h:1734

◆ FilterMutationsByType() [2/2]

void flutter::testing::FilterMutationsByType ( const FlutterPlatformViewMutation **  mutations,
size_t  count,
FlutterPlatformViewMutationType  type,
const std::function< void(const FlutterPlatformViewMutation &mutation)> &  handler 
)

Definition at line 262 of file embedder_unittests_util.cc.

267 {
268 if (mutations == nullptr) {
269 return;
270 }
271
272 for (size_t i = 0; i < count; ++i) {
273 const FlutterPlatformViewMutation* mutation = mutations[i];
274 if (mutation->type != type) {
275 continue;
276 }
277
278 handler(*mutation);
279 }
280}
FlutterPlatformViewMutationType type
The type of the mutation described by the subsequent union.
Definition embedder.h:1703

◆ FixtureNameForBackend()

std::string flutter::testing::FixtureNameForBackend ( EmbedderTestContextType  backend,
const std::string &  name 
)

Prepends a prefix to the name which is unique to the test context type. This is useful for tests that use EmbedderTestMultiBackend and require different fixtures per backend. For OpenGL, the name remains unchanged.

Parameters
[in]backendThe test context type used to determine the prepended prefix (e.g. vk_[name] for Vulkan).
[in]nameThe name of the fixture without any special prefixes.

Definition at line 79 of file embedder_unittests_util.cc.

80 {
81 switch (backend) {
82 case EmbedderTestContextType::kVulkanContext:
83 return "vk_" + name;
84 default:
85 return name;
86 }
87}
const char * name
Definition fuchsia.cc:50

◆ fl_ensure_gtk_init()

void flutter::testing::fl_ensure_gtk_init ( GLogWriterFunc  writer = nullptr)

Ensures that GTK has been initialized and starts monitoring logs.

Ensures that GTK has been initialized. If GTK has not been initialized, it will be initialized using gtk_init(). It will also set the GTK log writer function to monitor the log output, recording the log levels that have been received in a bitfield accessible via fl_get_received_gtk_log_levels

To retrieve the bitfield of recorded log levels, use fl_get_received_gtk_log_levels().

Parameters
[in]writerThe custom log writer function to use. If nullptr, or it returns G_LOG_WRITER_UNHANDLED, the default log writer function will be called.

Definition at line 35 of file fl_test_gtk_logs.cc.

35 {
36 if (!gtk_initialized) {
37 gtk_init(0, nullptr);
38 g_log_set_writer_func(log_writer, nullptr, nullptr);
39 gtk_initialized = true;
40 }
41 fl_reset_received_gtk_log_levels();
42 log_writer_cb = writer;
43}

◆ fl_get_received_gtk_log_levels()

GLogLevelFlags flutter::testing::fl_get_received_gtk_log_levels ( )

Returns the recorded log levels.

Returns a bitfield containing the GTK log levels that have been seen since the last time they were reset.

Returns
A GLogLevelFlags bitfield representing the recorded log levels.

Definition at line 49 of file fl_test_gtk_logs.cc.

49 {
50 return fl_received_log_levels;
51}

◆ fl_reset_received_gtk_log_levels()

void flutter::testing::fl_reset_received_gtk_log_levels ( )

Resets the recorded log levels.

Resets the recorded GTK log levels to zero.

Definition at line 45 of file fl_test_gtk_logs.cc.

45 {
46 fl_received_log_levels = (GLogLevelFlags)0x0;
47}

◆ FlushSubmitCpuSync()

static void flutter::testing::FlushSubmitCpuSync ( const sk_sp< SkSurface > &  surface)
static

Definition at line 46 of file dl_benchmarks.cc.

46 {
47 if (!surface) {
48 return;
49 }
50 if (GrDirectContext* dContext =
51 GrAsDirectContext(surface->recordingContext())) {
52 dContext->flushAndSubmit(surface.get(), GrSyncCpu::kYes);
53 }
54}
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)

◆ GetArgsForProcess()

const fml::CommandLine & flutter::testing::GetArgsForProcess ( )

Definition at line 12 of file test_args.cc.

12 {
13 return gProcessArgs;
14}
static fml::CommandLine gProcessArgs
Definition test_args.cc:10

◆ GetConicsPath()

void flutter::testing::GetConicsPath ( SkPath path,
size_t  sides,
SkPoint  center,
float  radius 
)

Definition at line 542 of file dl_benchmarks.cc.

542 {
543 std::vector<SkPoint> points = GetPolygonPoints(sides, center, radius);
544 std::vector<SkPoint> control_points =
545 GetPolygonPoints(sides * 2, center, radius * 0.8f);
546
547 path.moveTo(points[0]);
548 for (size_t i = 1; i < sides; i++) {
549 path.conicTo(control_points[2 * i - 1], points[i], 3.7f);
550 }
551 path.conicTo(control_points[2 * sides - 1], points[0], 3.7f);
552 path.close();
553}

◆ GetCubicsPath()

void flutter::testing::GetCubicsPath ( SkPath path,
size_t  sides,
SkPoint  center,
float  radius 
)

Definition at line 565 of file dl_benchmarks.cc.

565 {
566 std::vector<SkPoint> points = GetPolygonPoints(sides, center, radius);
567 std::vector<SkPoint> inner_control_points =
568 GetPolygonPoints(sides * 3, center, radius * 0.8f);
569 std::vector<SkPoint> outer_control_points =
570 GetPolygonPoints(sides * 3, center, radius * 1.2f);
571
572 path.moveTo(points[0]);
573 for (size_t i = 1; i < sides; i++) {
574 path.cubicTo(inner_control_points[3 * i - 2],
575 outer_control_points[3 * i - 1], points[i]);
576 }
577 path.cubicTo(inner_control_points[3 * sides - 2],
578 outer_control_points[3 * sides - 1], points[0]);
579 path.close();
580}

◆ GetCurrentTestName()

std::string flutter::testing::GetCurrentTestName ( )

Gets the name of the currently running test. This is useful in generating logs or assets based on test name.

Returns
The current test name.

Definition at line 15 of file testing.cc.

15 {
16 return ::testing::UnitTest::GetInstance()->current_test_info()->name();
17}

◆ GetDebuggerStatus()

DebuggerStatus flutter::testing::GetDebuggerStatus ( )

Definition at line 25 of file debugger_detection.cc.

25 {
26#if FML_OS_MACOSX
27 // From Technical Q&A QA1361 Detecting the Debugger
28 // https://developer.apple.com/library/archive/qa/qa1361/_index.html
29 int management_info_base[4];
30 struct kinfo_proc info;
31 size_t size;
32
33 // Initialize the flags so that, if sysctl fails for some bizarre
34 // reason, we get a predictable result.
35 info.kp_proc.p_flag = 0;
36
37 // Initialize management_info_base, which tells sysctl the info we want, in
38 // this case we're looking for information about a specific process ID.
39 management_info_base[0] = CTL_KERN;
40 management_info_base[1] = KERN_PROC;
41 management_info_base[2] = KERN_PROC_PID;
42 management_info_base[3] = getpid();
43
44 // Call sysctl.
45
46 size = sizeof(info);
47 auto status =
48 ::sysctl(management_info_base,
49 sizeof(management_info_base) / sizeof(*management_info_base),
50 &info, &size, NULL, 0);
51 FML_CHECK(status == 0);
52
53 // We're being debugged if the P_TRACED flag is set.
54 return ((info.kp_proc.p_flag & P_TRACED) != 0) ? DebuggerStatus::kAttached
55 : DebuggerStatus::kDontKnow;
56
57#elif FML_OS_WIN
58 return ::IsDebuggerPresent() ? DebuggerStatus::kAttached
59 : DebuggerStatus::kDontKnow;
60
61#else
62 return DebuggerStatus::kDontKnow;
63#endif
64} // namespace testing
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ GetDefaultKernelFilePath()

std::string flutter::testing::GetDefaultKernelFilePath ( )

Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixturesPath().

Returns
The kernel file path.

Definition at line 19 of file testing.cc.

19 {
20 return fml::paths::JoinPaths({GetFixturesPath(), "kernel_blob.bin"});
21}
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
std::string JoinPaths(std::initializer_list< std::string > components)
Definition paths.cc:14

◆ GetEGLError()

static std::string flutter::testing::GetEGLError ( )
static

Definition at line 30 of file test_gl_surface.cc.

30 {
31 std::stringstream stream;
32
33 auto error = ::eglGetError();
34
35 stream << "EGL Result: '";
36
37 switch (error) {
38 case EGL_SUCCESS:
39 stream << "EGL_SUCCESS";
40 break;
41 case EGL_NOT_INITIALIZED:
42 stream << "EGL_NOT_INITIALIZED";
43 break;
44 case EGL_BAD_ACCESS:
45 stream << "EGL_BAD_ACCESS";
46 break;
47 case EGL_BAD_ALLOC:
48 stream << "EGL_BAD_ALLOC";
49 break;
50 case EGL_BAD_ATTRIBUTE:
51 stream << "EGL_BAD_ATTRIBUTE";
52 break;
53 case EGL_BAD_CONTEXT:
54 stream << "EGL_BAD_CONTEXT";
55 break;
56 case EGL_BAD_CONFIG:
57 stream << "EGL_BAD_CONFIG";
58 break;
59 case EGL_BAD_CURRENT_SURFACE:
60 stream << "EGL_BAD_CURRENT_SURFACE";
61 break;
62 case EGL_BAD_DISPLAY:
63 stream << "EGL_BAD_DISPLAY";
64 break;
65 case EGL_BAD_SURFACE:
66 stream << "EGL_BAD_SURFACE";
67 break;
68 case EGL_BAD_MATCH:
69 stream << "EGL_BAD_MATCH";
70 break;
71 case EGL_BAD_PARAMETER:
72 stream << "EGL_BAD_PARAMETER";
73 break;
74 case EGL_BAD_NATIVE_PIXMAP:
75 stream << "EGL_BAD_NATIVE_PIXMAP";
76 break;
77 case EGL_BAD_NATIVE_WINDOW:
78 stream << "EGL_BAD_NATIVE_WINDOW";
79 break;
80 case EGL_CONTEXT_LOST:
81 stream << "EGL_CONTEXT_LOST";
82 break;
83 default:
84 stream << "Unknown";
85 }
86
87 stream << "' (0x" << std::hex << error << std::dec << ").";
88 return stream.str();
89}
const uint8_t uint32_t uint32_t GError ** error

◆ GetFixturesPath()

const char * flutter::testing::GetFixturesPath ( )

Returns the directory containing the test fixture for the target if this target has fixtures configured. If there are no fixtures, this is a link error. If you see a linker error on this symbol, the unit-test target needs to depend on a test_fixtures target.

Returns
The fixtures path.

◆ GetLinesPath()

void flutter::testing::GetLinesPath ( SkPath path,
size_t  sides,
SkPoint  center,
float  radius 
)

Definition at line 501 of file dl_benchmarks.cc.

501 {
502 std::vector<SkPoint> points = GetPolygonPoints(sides, center, radius);
503 path.moveTo(points[0]);
504 for (size_t i = 1; i < sides; i++) {
505 path.lineTo(points[i]);
506 }
507 path.lineTo(points[0]);
508 path.close();
509}

◆ GetPaintForRun()

DlPaint flutter::testing::GetPaintForRun ( unsigned  attributes)

Definition at line 23 of file dl_benchmarks.cc.

23 {
25
26 if (attributes & kStrokedStyle && attributes & kFilledStyle) {
27 // Not currently exposed by Flutter, but we can probably benchmark this in
28 // the future
29 paint.setDrawStyle(DlDrawStyle::kStrokeAndFill);
30 } else if (attributes & kStrokedStyle) {
31 paint.setDrawStyle(DlDrawStyle::kStroke);
32 } else if (attributes & kFilledStyle) {
33 paint.setDrawStyle(DlDrawStyle::kFill);
34 }
35
36 if (attributes & kHairlineStroke) {
37 paint.setStrokeWidth(0.0f);
38 } else {
39 paint.setStrokeWidth(1.0f);
40 }
41
42 paint.setAntiAlias(attributes & kAntiAliasing);
43 return paint;
44}

◆ GetPolygonPoints()

std::vector< SkPoint > flutter::testing::GetPolygonPoints ( size_t  n,
SkPoint  center,
SkScalar  r 
)

Definition at line 481 of file dl_benchmarks.cc.

481 {
482 std::vector<SkPoint> points;
483 SkScalar x, y;
484 float angle;
485 float full_circle = 2.0f * M_PI;
486 for (size_t i = 0; i < n; i++) {
487 angle = (full_circle / static_cast<float>(n)) * static_cast<float>(i);
488 x = center.x() + r * std::cosf(angle);
489 y = center.y() + r * std::sinf(angle);
490 points.push_back(SkPoint::Make(x, y));
491 }
492 return points;
493}
#define M_PI

◆ GetQuadsPath()

void flutter::testing::GetQuadsPath ( SkPath path,
size_t  sides,
SkPoint  center,
float  radius 
)

Definition at line 520 of file dl_benchmarks.cc.

520 {
521 std::vector<SkPoint> points = GetPolygonPoints(sides, center, radius);
522 std::vector<SkPoint> control_points =
523 GetPolygonPoints(sides * 2, center, radius * 0.8f);
524
525 path.moveTo(points[0]);
526 for (size_t i = 1; i < sides; i++) {
527 path.quadTo(control_points[2 * i - 1], points[i]);
528 }
529 path.quadTo(control_points[2 * sides - 1], points[0]);
530 path.close();
531}

◆ GetRasterizerResourceCacheBytesSync()

static size_t flutter::testing::GetRasterizerResourceCacheBytesSync ( const Shell shell)
static

Definition at line 1666 of file shell_unittests.cc.

1666 {
1667 size_t bytes = 0;
1670 shell.GetTaskRunners().GetRasterTaskRunner(), [&]() {
1671 if (auto rasterizer = shell.GetRasterizer()) {
1672 bytes = rasterizer->GetResourceCacheMaxBytes().value_or(0U);
1673 }
1674 latch.Signal();
1675 });
1676 latch.Wait();
1677 return bytes;
1678}
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)

◆ GetRenderTargetFromBackend()

EmbedderTestBackingStoreProducer::RenderTargetType flutter::testing::GetRenderTargetFromBackend ( EmbedderTestContextType  backend,
bool  opengl_framebuffer 
)

Resolves a render target type for a given backend description. This is useful for tests that use EmbedderTestMultiBackend.

Parameters
[in]backendThe test context type to resolve the render target for.
[in]opengl_framebufferIgnored for all non-OpenGL backends. Flutter supports rendering to both OpenGL textures and framebuffers. When false, the OpenGL texture render target type is returned.

Definition at line 89 of file embedder_unittests_util.cc.

91 {
92 switch (backend) {
93 case EmbedderTestContextType::kVulkanContext:
94 return EmbedderTestBackingStoreProducer::RenderTargetType::kVulkanImage;
95 case EmbedderTestContextType::kOpenGLContext:
96 if (opengl_framebuffer) {
97 return EmbedderTestBackingStoreProducer::RenderTargetType::
98 kOpenGLFramebuffer;
99 }
100 return EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture;
101 case EmbedderTestContextType::kMetalContext:
102 return EmbedderTestBackingStoreProducer::RenderTargetType::kMetalTexture;
103 case EmbedderTestContextType::kSoftwareContext:
104 return EmbedderTestBackingStoreProducer::RenderTargetType::
105 kSoftwareBuffer;
106 }
107}

◆ GetSampleDisplayList() [1/2]

sk_sp< DisplayList > flutter::testing::GetSampleDisplayList ( )

Definition at line 15 of file dl_test_snippets.cc.

15 {
16 DisplayListBuilder builder(SkRect::MakeWH(150, 100));
17 builder.DrawRect(SkRect::MakeXYWH(10, 10, 80, 80), DlPaint(DlColor::kRed()));
18 return builder.Build();
19}
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

◆ GetSampleDisplayList() [2/2]

sk_sp< DisplayList > flutter::testing::GetSampleDisplayList ( int  ops)

Definition at line 36 of file dl_test_snippets.cc.

36 {
37 DisplayListBuilder builder(SkRect::MakeWH(150, 100));
38 for (int i = 0; i < ops; i++) {
39 builder.DrawColor(DlColor::kRed(), DlBlendMode::kSrc);
40 }
41 return builder.Build();
42}
SkPathOp ops[]

◆ GetSampleNestedDisplayList()

sk_sp< DisplayList > flutter::testing::GetSampleNestedDisplayList ( )

Definition at line 21 of file dl_test_snippets.cc.

21 {
22 DisplayListBuilder builder(SkRect::MakeWH(150, 100));
24 for (int y = 10; y <= 60; y += 10) {
25 for (int x = 10; x <= 60; x += 10) {
26 paint.setColor(((x + y) % 20) == 10 ? DlColor(SK_ColorRED)
28 builder.DrawRect(SkRect::MakeXYWH(x, y, 80, 80), paint);
29 }
30 }
31 DisplayListBuilder outer_builder(SkRect::MakeWH(150, 100));
32 outer_builder.DrawDisplayList(builder.Build());
33 return outer_builder.Build();
34}

◆ GetSamplePaintContextHolder()

PaintContextHolder flutter::testing::GetSamplePaintContextHolder ( LayerStateStack state_stack,
RasterCache raster_cache,
FixedRefreshRateStopwatch raster_time,
FixedRefreshRateStopwatch ui_time 
)

Definition at line 113 of file mock_raster_cache.cc.

117 {
119 PaintContextHolder holder = {// clang-format off
120 {
121 .state_stack = state_stack,
122 .canvas = nullptr,
123 .gr_context = nullptr,
124 .dst_color_space = srgb,
125 .view_embedder = nullptr,
126 .raster_time = *raster_time,
127 .ui_time = *ui_time,
128 .texture_registry = nullptr,
129 .raster_cache = raster_cache,
130 },
131 // clang-format on
132 srgb};
133
134 return holder;
135}
static sk_sp< SkColorSpace > MakeSRGB()

◆ GetSamplePrerollContextHolder()

PrerollContextHolder flutter::testing::GetSamplePrerollContextHolder ( LayerStateStack state_stack,
RasterCache raster_cache,
FixedRefreshRateStopwatch raster_time,
FixedRefreshRateStopwatch ui_time 
)

Definition at line 84 of file mock_raster_cache.cc.

88 {
90
91 PrerollContextHolder holder = {
92 {
93 // clang-format off
94 .raster_cache = raster_cache,
95 .gr_context = nullptr,
96 .view_embedder = nullptr,
97 .state_stack = state_stack,
98 .dst_color_space = srgb,
99 .surface_needs_readback = false,
100 .raster_time = *raster_time,
101 .ui_time = *ui_time,
102 .texture_registry = nullptr,
103 .has_platform_view = false,
104 .has_texture_layer = false,
105 .raster_cached_entries = &raster_cache_items_,
106 // clang-format on
107 },
108 srgb};
109
110 return holder;
111}

◆ GetSourcePath()

const char * flutter::testing::GetSourcePath ( )

◆ GetSurfaceFromTexture()

static sk_sp< SkSurface > flutter::testing::GetSurfaceFromTexture ( const sk_sp< GrDirectContext > &  skia_context,
SkISize  texture_size,
void *  texture 
)
static

Definition at line 64 of file embedder_metal_unittests.mm.

66 {
67 GrMtlTextureInfo info;
68 info.fTexture.reset([(id<MTLTexture>)texture retain]);
70 texture_size.width(), texture_size.height(), skgpu::Mipmapped::kNo, info);
71
72 return SkSurfaces::WrapBackendTexture(skia_context.get(), backend_texture,
74 nullptr, nullptr);
75}
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
T * get() const
Definition SkRefCnt.h:303
FlTexture * texture
SK_API GrBackendTexture MakeMtl(int width, int height, skgpu::Mipmapped, const GrMtlTextureInfo &mtlInfo, std::string_view label={})
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)

◆ GetTaskRunnersForFixture()

TaskRunners flutter::testing::GetTaskRunnersForFixture ( )

Definition at line 97 of file external_view_embedder_unittests.cc.

97 {
99 auto& loop = fml::MessageLoop::GetCurrent();
100 return {
101 "test",
102 loop.GetTaskRunner(), // platform
103 loop.GetTaskRunner(), // raster
104 loop.GetTaskRunner(), // ui
105 loop.GetTaskRunner() // io
106 };
107}
static void EnsureInitializedForCurrentThread()
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()

◆ GetTestingAssetsPath()

const char * flutter::testing::GetTestingAssetsPath ( )

Returns the directory containing assets shared across all tests.

Returns
The testing assets path.

◆ GetTestNameFromTestInfo()

static std::string flutter::testing::GetTestNameFromTestInfo ( const ::testing::TestInfo &  test_info)
static

Definition at line 86 of file test_timeout_listener.cc.

87 {
88 std::stringstream stream;
89 stream << test_info.test_suite_name();
90 stream << ".";
91 stream << test_info.name();
92 if (auto type_param = test_info.type_param()) {
93 stream << "/" << type_param;
94 }
95 if (auto value_param = test_info.value_param()) {
96 stream << "/" << value_param;
97 }
98 return stream.str();
99}
static void test_info(skiatest::Reporter *r, Codec *codec, const SkImageInfo &info, SkCodec::Result expectedResult, const SkMD5::Digest *goodDigest)

◆ GetTestPoints()

std::vector< SkPoint > flutter::testing::GetTestPoints ( size_t  count,
SkISize  canvas_size 
)

Definition at line 835 of file dl_benchmarks.cc.

835 {
836 std::vector<SkPoint> points;
837
838 // Some arbitrary offsets to use when building the list of points
839 std::vector<SkScalar> delta_x = {10.0f, 6.3f, 15.0f, 3.5f, 22.6f, 4.7f};
840 std::vector<SkScalar> delta_y = {9.3f, -5.4f, 8.5f, -12.0f, 19.2f, -19.6f};
841
842 SkPoint current = SkPoint::Make(0.0f, 0.0f);
843 for (size_t i = 0; i < count; i++) {
844 points.push_back(current);
845 current.offset(delta_x[i % delta_x.size()], delta_y[i % delta_y.size()]);
846 if (current.x() > canvas_size.width()) {
847 current.offset(-canvas_size.width(), 25.0f);
848 }
849 if (current.y() > canvas_size.height()) {
850 current.offset(0.0f, -canvas_size.height());
851 }
852 }
853
854 return points;
855}
void offset(float dx, float dy)
constexpr float y() const
constexpr float x() const

◆ GetTestTextBlob()

sk_sp< SkTextBlob > flutter::testing::GetTestTextBlob ( int  index)

Definition at line 969 of file dl_test_snippets.cc.

969 {
970 static std::map<int, sk_sp<SkTextBlob>> text_blobs;
971 auto it = text_blobs.find(index);
972 if (it != text_blobs.end()) {
973 return it->second;
974 }
975 std::string text = "TestBlob" + std::to_string(index);
976 sk_sp<SkTextBlob> blob =
977 SkTextBlob::MakeFromText(text.c_str(), text.size(),
978 CreateTestFontOfSize(20), SkTextEncoding::kUTF8);
979 text_blobs.insert(std::make_pair(index, blob));
980 return blob;
981}
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
std::u16string text

◆ GetTestVertices()

std::shared_ptr< DlVertices > flutter::testing::GetTestVertices ( SkPoint  center,
float  radius,
size_t  vertex_count,
DlVertexMode  mode,
size_t &  final_vertex_count 
)

Definition at line 694 of file dl_benchmarks.cc.

698 {
699 size_t outer_vertex_count = vertex_count / 2;
700 std::vector<SkPoint> outer_points =
701 GetPolygonPoints(outer_vertex_count, center, radius);
702
703 std::vector<SkPoint> vertices;
704 std::vector<DlColor> colors;
705
706 switch (mode) {
707 case DlVertexMode::kTriangleFan:
708 // Calling the points on the outer circle O_0, O_1, O_2, ..., and
709 // the center point C, this should create a triangle fan with vertices
710 // C, O_0, O_1, O_2, O_3, ...
711 vertices.push_back(center);
712 colors.push_back(DlColor(SK_ColorCYAN));
713 for (size_t i = 0; i <= outer_points.size(); i++) {
714 vertices.push_back(outer_points[i % outer_points.size()]);
715 if (i % 3 == 0) {
716 colors.push_back(DlColor(SK_ColorRED));
717 } else if (i % 3 == 1) {
718 colors.push_back(DlColor(SK_ColorGREEN));
719 } else {
720 colors.push_back(DlColor(SK_ColorBLUE));
721 }
722 }
723 break;
724 case DlVertexMode::kTriangles:
725 // Calling the points on the outer circle O_0, O_1, O_2, ..., and
726 // the center point C, this should create a series of triangles with
727 // vertices O_0, O_1, C, O_1, O_2, C, O_2, O_3, C, ...
728 for (size_t i = 0; i < outer_vertex_count; i++) {
729 vertices.push_back(outer_points[i % outer_points.size()]);
730 colors.push_back(DlColor(SK_ColorRED));
731 vertices.push_back(outer_points[(i + 1) % outer_points.size()]);
732 colors.push_back(DlColor(SK_ColorGREEN));
733 vertices.push_back(center);
734 colors.push_back(DlColor(SK_ColorBLUE));
735 }
736 break;
737 case DlVertexMode::kTriangleStrip:
738 // Calling the points on the outer circle O_0, O_1, O_2, ..., and
739 // the center point C, this should create a strip with vertices
740 // O_0, O_1, C, O_2, O_3, C, O_4, O_5, C, ...
741 for (size_t i = 0; i <= outer_vertex_count; i++) {
742 vertices.push_back(outer_points[i % outer_points.size()]);
743 colors.push_back(i % 2 ? DlColor(SK_ColorRED) : DlColor(SK_ColorGREEN));
744 if (i % 2 == 1) {
745 vertices.push_back(center);
746 colors.push_back(DlColor(SK_ColorBLUE));
747 }
748 }
749 break;
750 default:
751 break;
752 }
753
754 final_vertex_count = vertices.size();
755 return DlVertices::Make(mode, vertices.size(), vertices.data(), nullptr,
756 colors.data());
757}

◆ GetThreadMergerFromPlatformThread()

fml::RefPtr< fml::RasterThreadMerger > flutter::testing::GetThreadMergerFromPlatformThread ( fml::Thread rasterizer_thread = nullptr)

Definition at line 69 of file external_view_embedder_unittests.cc.

70 {
71 // Assume the current thread is the platform thread.
73 auto platform_queue_id = fml::MessageLoop::GetCurrentTaskQueueId();
74
75 if (!rasterizer_thread) {
76 return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
77 platform_queue_id);
78 }
79 auto rasterizer_queue_id =
80 rasterizer_thread->GetTaskRunner()->GetTaskQueueId();
81 return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
82 rasterizer_queue_id);
83}
static TaskQueueId GetCurrentTaskQueueId()
virtual TaskQueueId GetTaskQueueId()
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition thread.cc:164

◆ GetThreadMergerFromRasterThread()

fml::RefPtr< fml::RasterThreadMerger > flutter::testing::GetThreadMergerFromRasterThread ( fml::Thread platform_thread)

Definition at line 85 of file external_view_embedder_unittests.cc.

86 {
87 auto platform_queue_id = platform_thread->GetTaskRunner()->GetTaskQueueId();
88
89 // Assume the current thread is the raster thread.
91 auto rasterizer_queue_id = fml::MessageLoop::GetCurrentTaskQueueId();
92
93 return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
94 rasterizer_queue_id);
95}

◆ GetTotalMutationTransformationMatrix() [1/2]

SkMatrix flutter::testing::GetTotalMutationTransformationMatrix ( const FlutterPlatformView view)

Definition at line 305 of file embedder_unittests_util.cc.

305 {
307 view->mutations_count);
308}
SkMatrix GetTotalMutationTransformationMatrix(const FlutterPlatformViewMutation **mutations, size_t count)

◆ GetTotalMutationTransformationMatrix() [2/2]

SkMatrix flutter::testing::GetTotalMutationTransformationMatrix ( const FlutterPlatformViewMutation **  mutations,
size_t  count 
)

Definition at line 291 of file embedder_unittests_util.cc.

293 {
294 SkMatrix collected;
295
298 [&](const auto& mutation) {
299 collected.preConcat(SkMatrixMake(mutation.transformation));
300 });
301
302 return collected;
303}
SkMatrix & preConcat(const SkMatrix &other)
Definition SkMatrix.cpp:674
@ kFlutterPlatformViewMutationTypeTransformation
Definition embedder.h:1698
SkMatrix SkMatrixMake(const FlutterTransformation &xformation)

◆ HalfToFloat()

float flutter::testing::HalfToFloat ( uint16_t  half)

Definition at line 52 of file image_decoder_no_gl_unittests.cc.

52 {
53 switch (half) {
54 case 0x7c00:
55 return std::numeric_limits<float>::infinity();
56 case 0xfc00:
57 return -std::numeric_limits<float>::infinity();
58 }
59 bool negative = half >> 15;
60 uint16_t exponent = (half >> 10) & 0x1f;
61 uint16_t fraction = half & 0x3ff;
62 float fExponent = exponent - 15.0f;
63 float fFraction = static_cast<float>(fraction) / 1024.f;
64 float pow_value = powf(2.0f, fExponent);
65 return (negative ? -1.f : 1.f) * pow_value * (1.0f + fFraction);
66}

◆ HasExtension()

static bool flutter::testing::HasExtension ( const char *  extensions,
const char *  name 
)
static

Definition at line 91 of file test_gl_surface.cc.

91 {
92 const char* r = strstr(extensions, name);
93 auto len = strlen(name);
94 // check that the extension name is terminated by space or null terminator
95 return r != nullptr && (r[len] == ' ' || r[len] == 0);
96}

◆ ImageFromBitmapWithNewID()

sk_sp< SkImage > flutter::testing::ImageFromBitmapWithNewID ( const SkBitmap bitmap)

Definition at line 925 of file dl_benchmarks.cc.

925 {
926 // If we create an SkPixmap with a ref to the SkBitmap's pixel data,
927 // then create an SkImage from that, we always get a new generation ID,
928 // so we will avoid hitting the cache.
929 SkPixmap pixmap;
930 bitmap.peekPixels(&pixmap);
931 return SkImages::RasterFromPixmap(pixmap, nullptr, nullptr);
932}
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)

◆ ImageMatchesFixture() [1/2]

bool flutter::testing::ImageMatchesFixture ( const std::string &  fixture_file_name,
const sk_sp< SkImage > &  scene_image 
)

Definition at line 152 of file embedder_unittests_util.cc.

153 {
154 fml::FileMapping fixture_image_mapping(OpenFixture(fixture_file_name));
155
156 FML_CHECK(fixture_image_mapping.GetSize() != 0u)
157 << "Could not find fixture: " << fixture_file_name;
158
159 auto encoded_image = SkData::MakeWithoutCopy(
160 fixture_image_mapping.GetMapping(), fixture_image_mapping.GetSize());
161 auto fixture_image =
162 SkImages::DeferredFromEncodedData(std::move(encoded_image))
163 ->makeRasterImage();
164
165 FML_CHECK(fixture_image) << "Could not create image from fixture: "
166 << fixture_file_name;
167
168 FML_CHECK(scene_image) << "Invalid scene image.";
169
170 auto scene_image_subset = scene_image->makeSubset(
171 nullptr,
172 SkIRect::MakeWH(fixture_image->width(), fixture_image->height()));
173
174 FML_CHECK(scene_image_subset)
175 << "Could not create image subset for fixture comparison: "
176 << scene_image_subset;
177
178 const auto images_are_same =
179 RasterImagesAreSame(scene_image_subset, fixture_image);
180
181 // If the images are not the same, this predicate is going to indicate test
182 // failure. Dump both the actual image and the expectation to disk to the
183 // test author can figure out what went wrong.
184 if (!images_are_same) {
185 const auto fixtures_path = GetFixturesPath();
186
187 const auto actual_file_name = "actual_" + fixture_file_name;
188 const auto expect_file_name = "expectation_" + fixture_file_name;
189
190 auto fixtures_fd = OpenFixturesDirectory();
191
192 FML_CHECK(
193 WriteImageToDisk(fixtures_fd, actual_file_name, scene_image_subset))
194 << "Could not write file to disk: " << actual_file_name;
195
196 FML_CHECK(WriteImageToDisk(fixtures_fd, expect_file_name, fixture_image))
197 << "Could not write file to disk: " << expect_file_name;
198
199 FML_LOG(ERROR) << "Image did not match expectation." << std::endl
200 << "Expected:"
201 << fml::paths::JoinPaths({fixtures_path, expect_file_name})
202 << std::endl
203 << "Got:"
204 << fml::paths::JoinPaths({fixtures_path, actual_file_name})
205 << std::endl;
206 }
207 return images_are_same;
208}
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
Definition SkData.h:116
sk_sp< SkImage > makeRasterImage(GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
Definition SkImage.cpp:267
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
bool WriteImageToDisk(const fml::UniqueFD &directory, const std::string &name, const sk_sp< SkImage > &image)
fml::UniqueFD OpenFixture(const std::string &fixture_name)
Opens a fixture of the given file name.
Definition testing.cc:37
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
Definition testing.cc:23
bool RasterImagesAreSame(const sk_sp< SkImage > &a, const sk_sp< SkImage > &b)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56

◆ ImageMatchesFixture() [2/2]

bool flutter::testing::ImageMatchesFixture ( const std::string &  fixture_file_name,
std::future< sk_sp< SkImage > > &  scene_image 
)

Definition at line 210 of file embedder_unittests_util.cc.

211 {
212 return ImageMatchesFixture(fixture_file_name, scene_image.get());
213}
bool ImageMatchesFixture(const std::string &fixture_file_name, const sk_sp< SkImage > &scene_image)

◆ INSTANTIATE_TEST_SUITE_P()

flutter::testing::INSTANTIATE_TEST_SUITE_P ( EmbedderTestGlVk  ,
EmbedderTestMultiBackend  ,
::testing::Values(EmbedderTestContextType::kOpenGLContext, EmbedderTestContextType::kVulkanContext  
)

◆ InvokeAllCallbacks()

static void flutter::testing::InvokeAllCallbacks ( const std::vector< fml::closure > &  callbacks)
static

Definition at line 24 of file embedder_test_compositor.cc.

24 {
25 for (const auto& callback : callbacks) {
26 if (callback) {
27 callback();
28 }
29 }
30}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ keyDownEvent()

FlutterUIPressProxy * flutter::testing::keyDownEvent ( UIKeyboardHIDUsage  keyCode,
UIKeyModifierFlags  modifierFlags = 0x0,
NSTimeInterval  timestamp = 0.0f,
const char *  characters = "",
const char *  charactersIgnoringModifiers = "" 
)
extern

Definition at line 90 of file FlutterFakeKeyEvents.mm.

95 {
96 return keyEventWithPhase(UIPressPhaseBegan, keyCode, modifierFlags, timestamp, characters,
97 charactersIgnoringModifiers);
98}
FlutterUIPressProxy * keyEventWithPhase(UIPressPhase phase, UIKeyboardHIDUsage keyCode, UIKeyModifierFlags modifierFlags=0x0, NSTimeInterval timestamp=0.0f, const char *characters="", const char *charactersIgnoringModifiers="") API_AVAILABLE(ios(13.4))

◆ keyEventWithPhase()

FlutterUIPressProxy * flutter::testing::keyEventWithPhase ( UIPressPhase  phase,
UIKeyboardHIDUsage  keyCode,
UIKeyModifierFlags  modifierFlags = 0x0,
NSTimeInterval  timestamp = 0.0f,
const char *  characters = "",
const char *  charactersIgnoringModifiers = "" 
)
extern

Definition at line 109 of file FlutterFakeKeyEvents.mm.

115 {
116 FML_DCHECK(!(modifierFlags & kModifierFlagSidedMask))
117 << "iOS doesn't supply modifier side flags, so don't create events with them.";
118 UIKey* key =
119 [[FakeUIKey alloc] initWithData:keyCode
120 modifierFlags:modifierFlags
121 characters:[NSString stringWithUTF8String:characters]
122 charactersIgnoringModifiers:[NSString stringWithUTF8String:charactersIgnoringModifiers]];
123
124 return [[FakeUIPressProxy alloc] initWithData:phase
125 key:key
126 type:UIEventTypePresses
127 timestamp:timestamp];
128}
#define FML_DCHECK(condition)
Definition logging.h:103
constexpr uint32_t kModifierFlagSidedMask

◆ keyUpEvent()

FlutterUIPressProxy * flutter::testing::keyUpEvent ( UIKeyboardHIDUsage  keyCode,
UIKeyModifierFlags  modifierFlags = 0x0,
NSTimeInterval  timestamp = 0.0f,
const char *  characters = "",
const char *  charactersIgnoringModifiers = "" 
)
extern

Definition at line 100 of file FlutterFakeKeyEvents.mm.

104 {
105 return keyEventWithPhase(UIPressPhaseEnded, keyCode, modifierFlags, timestamp, characters,
106 charactersIgnoringModifiers);
107}

◆ kTestBlendColorFilter1()

static const DlBlendColorFilter flutter::testing::kTestBlendColorFilter1 ( DlColor::kRed()  ,
DlBlendMode::kDstATop   
)
static

◆ kTestBlendColorFilter2()

static const DlBlendColorFilter flutter::testing::kTestBlendColorFilter2 ( DlColor::kBlue()  ,
DlBlendMode::kDstATop   
)
static

◆ kTestBlendColorFilter3()

static const DlBlendColorFilter flutter::testing::kTestBlendColorFilter3 ( DlColor::kRed()  ,
DlBlendMode::kDstIn   
)
static

◆ kTestBlurImageFilter1()

static const DlBlurImageFilter flutter::testing::kTestBlurImageFilter1 ( 5.  0,
5.  0,
DlTileMode::kClamp   
)
static

◆ kTestBlurImageFilter2()

static const DlBlurImageFilter flutter::testing::kTestBlurImageFilter2 ( 6.  0,
5.  0,
DlTileMode::kClamp   
)
static

◆ kTestBlurImageFilter3()

static const DlBlurImageFilter flutter::testing::kTestBlurImageFilter3 ( 5.  0,
6.  0,
DlTileMode::kClamp   
)
static

◆ kTestBlurImageFilter4()

static const DlBlurImageFilter flutter::testing::kTestBlurImageFilter4 ( 5.  0,
5.  0,
DlTileMode::kDecal   
)
static

◆ kTestCFImageFilter1()

static const DlColorFilterImageFilter flutter::testing::kTestCFImageFilter1 ( kTestBlendColorFilter1  )
static

◆ kTestCFImageFilter2()

static const DlColorFilterImageFilter flutter::testing::kTestCFImageFilter2 ( kTestBlendColorFilter2  )
static

◆ kTestComposeImageFilter1()

static const DlComposeImageFilter flutter::testing::kTestComposeImageFilter1 ( kTestBlurImageFilter1  ,
kTestMatrixImageFilter1   
)
static

◆ kTestComposeImageFilter2()

static const DlComposeImageFilter flutter::testing::kTestComposeImageFilter2 ( kTestBlurImageFilter2  ,
kTestMatrixImageFilter1   
)
static

◆ kTestComposeImageFilter3()

static const DlComposeImageFilter flutter::testing::kTestComposeImageFilter3 ( kTestBlurImageFilter1  ,
kTestMatrixImageFilter2   
)
static

◆ kTestDilateImageFilter1()

static const DlDilateImageFilter flutter::testing::kTestDilateImageFilter1 ( 5.  0,
5.  0 
)
static

◆ kTestDilateImageFilter2()

static const DlDilateImageFilter flutter::testing::kTestDilateImageFilter2 ( 6.  0,
5.  0 
)
static

◆ kTestDilateImageFilter3()

static const DlDilateImageFilter flutter::testing::kTestDilateImageFilter3 ( 5.  0,
6.  0 
)
static

◆ kTestErodeImageFilter1()

static const DlErodeImageFilter flutter::testing::kTestErodeImageFilter1 ( 4.  0,
4.  0 
)
static

◆ kTestErodeImageFilter2()

static const DlErodeImageFilter flutter::testing::kTestErodeImageFilter2 ( 4.  0,
3.  0 
)
static

◆ kTestErodeImageFilter3()

static const DlErodeImageFilter flutter::testing::kTestErodeImageFilter3 ( 3.  0,
4.  0 
)
static

◆ kTestMaskFilter1()

static const DlBlurMaskFilter flutter::testing::kTestMaskFilter1 ( DlBlurStyle::kNormal  ,
3.  0 
)
static

◆ kTestMaskFilter2()

static const DlBlurMaskFilter flutter::testing::kTestMaskFilter2 ( DlBlurStyle::kNormal  ,
5.  0 
)
static

◆ kTestMaskFilter3()

static const DlBlurMaskFilter flutter::testing::kTestMaskFilter3 ( DlBlurStyle::kSolid  ,
3.  0 
)
static

◆ kTestMaskFilter4()

static const DlBlurMaskFilter flutter::testing::kTestMaskFilter4 ( DlBlurStyle::kInner  ,
3.  0 
)
static

◆ kTestMaskFilter5()

static const DlBlurMaskFilter flutter::testing::kTestMaskFilter5 ( DlBlurStyle::kOuter  ,
3.  0 
)
static

◆ kTestMatrixColorFilter1()

static const DlMatrixColorFilter flutter::testing::kTestMatrixColorFilter1 ( kRotateColorMatrix  )
static

◆ kTestMatrixColorFilter2()

static const DlMatrixColorFilter flutter::testing::kTestMatrixColorFilter2 ( kInvertColorMatrix  )
static

◆ kTestMatrixImageFilter1()

static const DlMatrixImageFilter flutter::testing::kTestMatrixImageFilter1 ( SkMatrix::RotateDeg(45)  ,
kNearestSampling   
)
static

◆ kTestMatrixImageFilter2()

static const DlMatrixImageFilter flutter::testing::kTestMatrixImageFilter2 ( SkMatrix::RotateDeg(85)  ,
kNearestSampling   
)
static

◆ kTestMatrixImageFilter3()

static const DlMatrixImageFilter flutter::testing::kTestMatrixImageFilter3 ( SkMatrix::RotateDeg(45)  ,
kLinearSampling   
)
static

◆ kTestSource1()

static const DlImageColorSource flutter::testing::kTestSource1 ( TestImage1  ,
DlTileMode::kClamp  ,
DlTileMode::kMirror  ,
kLinearSampling   
)
static

◆ LoadELFSplitSymbolFromFixturesIfNeccessary()

ELFAOTSymbols flutter::testing::LoadELFSplitSymbolFromFixturesIfNeccessary ( std::string  elf_split_filename)

Attempts to resolve split loading unit AOT symbols from the portable ELF loader. If the dart code does not make use of deferred libraries, then there will be no split .so to load. This only returns valid symbols when the VM is configured for AOT.

Parameters
[in]elf_split_filenameThe split AOT ELF filename from the fixtures generator.
Returns
The loaded ELF symbols.

Definition at line 66 of file elf_loader.cc.

67 {
68 if (!DartVM::IsRunningPrecompiledCode()) {
69 return {};
70 }
71
72 const auto elf_path =
73 fml::paths::JoinPaths({GetFixturesPath(), std::move(elf_split_filename)});
74
75 if (!fml::IsFile(elf_path)) {
76 // We do not log here, as there is no expectation for a split library to
77 // exist.
78 return {};
79 }
80
81 ELFAOTSymbols symbols;
82
83#if OS_FUCHSIA
84 // TODO(gw280): https://github.com/flutter/flutter/issues/50285
85 // Dart doesn't implement Dart_LoadELF on Fuchsia
86 FML_LOG(ERROR) << "Dart doesn't implement Dart_LoadELF on Fuchsia";
87 return {};
88#else
89 // Must not be freed.
90 const char* error = nullptr;
91
92 auto loaded_elf =
93 Dart_LoadELF(elf_path.c_str(), // file path
94 0, // file offset
95 &error, // error (out)
96 &symbols.vm_snapshot_data, // vm snapshot data (out)
97 &symbols.vm_snapshot_instrs, // vm snapshot instrs (out)
98 &symbols.vm_isolate_data, // vm isolate data (out)
99 &symbols.vm_isolate_instrs // vm isolate instr (out)
100 );
101
102 if (loaded_elf == nullptr) {
104 << "Could not fetch AOT symbols from loaded ELF. Attempts "
105 "to launch the Dart VM with these AOT symbols will fail. Error: "
106 << error;
107 return {};
108 }
109
110 symbols.loaded_elf.reset(loaded_elf);
111
112 return symbols;
113#endif
114}
bool IsFile(const std::string &path)
DART_EXPORT Dart_LoadedElf * Dart_LoadELF(const char *filename, uint64_t file_offset, const char **error, const uint8_t **vm_snapshot_data, const uint8_t **vm_snapshot_instrs, const uint8_t **vm_isolate_data, const uint8_t **vm_isolate_instrs)
Please see documentation for Dart_LoadElf_Fd.

◆ LoadELFSymbolFromFixturesIfNeccessary()

ELFAOTSymbols flutter::testing::LoadELFSymbolFromFixturesIfNeccessary ( std::string  elf_filename)

Attempts to resolve AOT symbols from the portable ELF loader. This location is automatically resolved from the fixtures generator. This only returns valid symbols when the VM is configured for AOT.

Parameters
[in]elf_filenameThe AOT ELF filename from the fixtures generator.
Returns
The loaded ELF symbols.

Definition at line 17 of file elf_loader.cc.

17 {
18 if (!DartVM::IsRunningPrecompiledCode()) {
19 return {};
20 }
21
22 const auto elf_path =
23 fml::paths::JoinPaths({GetFixturesPath(), std::move(elf_filename)});
24
25 if (!fml::IsFile(elf_path)) {
26 FML_LOG(ERROR) << "App AOT file does not exist for this fixture. Attempts "
27 "to launch the Dart VM with these AOT symbols will fail.";
28 return {};
29 }
30
31 ELFAOTSymbols symbols;
32
33#if OS_FUCHSIA
34 // TODO(gw280): https://github.com/flutter/flutter/issues/50285
35 // Dart doesn't implement Dart_LoadELF on Fuchsia
36 FML_LOG(ERROR) << "Dart doesn't implement Dart_LoadELF on Fuchsia";
37 return {};
38#else
39 // Must not be freed.
40 const char* error = nullptr;
41
42 auto loaded_elf =
43 Dart_LoadELF(elf_path.c_str(), // file path
44 0, // file offset
45 &error, // error (out)
46 &symbols.vm_snapshot_data, // vm snapshot data (out)
47 &symbols.vm_snapshot_instrs, // vm snapshot instrs (out)
48 &symbols.vm_isolate_data, // vm isolate data (out)
49 &symbols.vm_isolate_instrs // vm isolate instr (out)
50 );
51
52 if (loaded_elf == nullptr) {
54 << "Could not fetch AOT symbols from loaded ELF. Attempts "
55 "to launch the Dart VM with these AOT symbols will fail. Error: "
56 << error;
57 return {};
58 }
59
60 symbols.loaded_elf.reset(loaded_elf);
61
62 return symbols;
63#endif // OS_FUCHSIA
64}

◆ LoadValidImageFixture()

static sk_sp< SkData > flutter::testing::LoadValidImageFixture ( )
static

Definition at line 16 of file image_generator_registry_unittests.cc.

16 {
17 auto fixture_mapping = OpenFixtureAsMapping("DashInNooglerHat.jpg");
18
19 // Remap to sk_sp<SkData>.
20 SkData::ReleaseProc on_release = [](const void* ptr, void* context) -> void {
21 delete reinterpret_cast<fml::FileMapping*>(context);
22 };
23 auto data = SkData::MakeWithProc(fixture_mapping->GetMapping(),
24 fixture_mapping->GetSize(), on_release,
25 fixture_mapping.get());
26
27 if (data) {
28 fixture_mapping.release();
29 }
30
31 return data;
32}
void(* ReleaseProc)(const void *ptr, void *context)
Definition SkData.h:78
static sk_sp< SkData > MakeWithProc(const void *ptr, size_t length, ReleaseProc proc, void *ctx)
Definition SkData.cpp:128
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
Definition testing.cc:59

◆ LogSkData()

static void flutter::testing::LogSkData ( const sk_sp< SkData > &  data,
const char *  title 
)
static

Definition at line 2159 of file shell_unittests.cc.

2159 {
2160 FML_LOG(ERROR) << "---------- " << title;
2161 std::ostringstream ostr;
2162 for (size_t i = 0; i < data->size();) {
2163 ostr << std::hex << std::setfill('0') << std::setw(2)
2164 << static_cast<int>(data->bytes()[i]) << " ";
2165 i++;
2166 if (i % 16 == 0 || i == data->size()) {
2167 FML_LOG(ERROR) << ostr.str();
2168 ostr.str("");
2169 ostr.clear();
2170 }
2171 }
2172}

◆ MakeColorSource() [1/2]

static std::shared_ptr< DlImageColorSource > flutter::testing::MakeColorSource ( const sk_sp< DlImage > &  image)
static

Definition at line 194 of file dl_rendering_unittests.cc.

195 {
196 return std::make_shared<DlImageColorSource>(image, //
197 DlTileMode::kRepeat, //
198 DlTileMode::kRepeat, //
199 DlImageSampling::kLinear);
200}

◆ MakeColorSource() [2/2]

static sk_sp< SkShader > flutter::testing::MakeColorSource ( const sk_sp< SkImage > &  image)
static

Definition at line 202 of file dl_rendering_unittests.cc.

202 {
205 SkImageSampling::kLinear);
206}
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkImage.cpp:179

◆ MakeFilter()

static std::shared_ptr< DlColorSource > flutter::testing::MakeFilter ( DlColor  color)
static

Definition at line 24 of file shader_mask_layer_unittests.cc.

24 {
25 DlColor colors[] = {
26 color.withAlpha(0x7f),
27 color,
28 };
29 float stops[] = {
30 0,
31 1,
32 };
33 return DlColorSource::MakeLinear(SkPoint::Make(0, 0), SkPoint::Make(10, 10),
34 2, colors, stops, DlTileMode::kRepeat);
35}
SkColor4f color

◆ MakeRectFromVertices()

static SkRect flutter::testing::MakeRectFromVertices ( SkPoint  vertices[6])
static

Definition at line 11 of file stopwatch_dl_unittests.cc.

11 {
12 // "Combine" the vertices to form a rectangle.
13 auto const left = std::min(vertices[0].x(), vertices[5].x());
14 auto const top = std::min(vertices[0].y(), vertices[1].y());
15 auto const right = std::max(vertices[1].x(), vertices[2].x());
16 auto const bottom = std::max(vertices[2].y(), vertices[3].y());
17
18 return SkRect::MakeLTRB(left, top, right, bottom);
19}
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)

◆ MakeSizedDisplayList()

static sk_sp< DisplayList > flutter::testing::MakeSizedDisplayList ( int  width,
int  height 
)
static

Definition at line 391 of file shell_unittests.cc.

391 {
393 builder.DrawRect(SkRect::MakeXYWH(0, 0, width, height),
394 DlPaint(DlColor::kRed()));
395 return builder.Build();
396}

◆ makeTestDisplayList()

sk_sp< DisplayList > flutter::testing::makeTestDisplayList ( )

Definition at line 3644 of file dl_rendering_unittests.cc.

3644 {
3645 DisplayListBuilder builder;
3646 DlPaint paint;
3647 paint.setDrawStyle(DlDrawStyle::kFill);
3648 paint.setColor(DlColor(SK_ColorRED));
3650 paint);
3651 paint.setColor(DlColor(SK_ColorBLUE));
3652 builder.DrawRect({kRenderCenterX, kRenderTop, kRenderRight, kRenderCenterY},
3653 paint);
3654 paint.setColor(DlColor(SK_ColorGREEN));
3655 builder.DrawRect({kRenderLeft, kRenderCenterY, kRenderCenterX, kRenderBottom},
3656 paint);
3657 paint.setColor(DlColor(SK_ColorYELLOW));
3658 builder.DrawRect(
3660 return builder.Build();
3661}
constexpr SkColor SK_ColorYELLOW
Definition SkColor.h:139

◆ MakeTestDisplayList()

static sk_sp< DisplayList > flutter::testing::MakeTestDisplayList ( int  w,
int  h,
SkColor  color 
)
static

Definition at line 216 of file dl_test_snippets.h.

216 {
217 DisplayListBuilder builder;
218 builder.DrawRect(SkRect::MakeWH(w, h), DlPaint(DlColor(color)));
219 return builder.Build();
220}
SkScalar w
SkScalar h

◆ MakeTestImage() [1/2]

static sk_sp< DlImage > flutter::testing::MakeTestImage ( int  w,
int  h,
int  checker_size 
)
static

Definition at line 71 of file dl_test_snippets.h.

71 {
74 SkCanvas* canvas = surface->getCanvas();
75 SkPaint p0, p1;
80 p1.setAlpha(128);
81 for (int y = 0; y < w; y += checker_size) {
82 for (int x = 0; x < h; x += checker_size) {
83 SkPaint& cellp = ((x + y) & 1) == 0 ? p0 : p1;
84 canvas->drawRect(SkRect::MakeXYWH(x, y, checker_size, checker_size),
85 cellp);
86 }
87 }
88 return DlImage::Make(surface->makeImageSnapshot());
89}
void drawRect(const SkRect &rect, const SkPaint &paint)
void setStyle(Style style)
Definition SkPaint.cpp:105
void setColor(SkColor color)
Definition SkPaint.cpp:119
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
void setAlpha(U8CPU a)
Definition SkPaint.h:279
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)

◆ MakeTestImage() [2/2]

static sk_sp< DlImage > flutter::testing::MakeTestImage ( int  w,
int  h,
SkColor  color 
)
static

Definition at line 21 of file dl_color_source_unittests.cc.

21 {
23 if (SkColorGetA(color) < 255) {
25 } else {
29 }
30 SkCanvas* canvas = surface->getCanvas();
31 canvas->drawColor(color);
32 return DlImage::Make(surface->makeImageSnapshot());
33}
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
#define SkColorGetA(color)
Definition SkColor.h:61
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition SkCanvas.h:1182
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)

◆ MemsetPatternSetOrCheck() [1/2]

bool flutter::testing::MemsetPatternSetOrCheck ( std::vector< uint8_t > &  buffer,
MemsetPatternOp  op 
)

Definition at line 120 of file testing.cc.

120 {
121 return MemsetPatternSetOrCheck(buffer.data(), buffer.size(), op);
122}
static const uint8_t buffer[]
bool MemsetPatternSetOrCheck(uint8_t *buffer, size_t size, MemsetPatternOp op)
Depending on the operation, either scribbles a known pattern into the buffer or checks if that patter...
Definition testing.cc:79

◆ MemsetPatternSetOrCheck() [2/2]

bool flutter::testing::MemsetPatternSetOrCheck ( uint8_t *  buffer,
size_t  size,
MemsetPatternOp  op 
)

Depending on the operation, either scribbles a known pattern into the buffer or checks if that pattern is present in an existing buffer. This is a portable variant of the memset_pattern class of methods that also happen to do assert that the same pattern exists.

Parameters
bufferThe buffer
[in]sizeThe size
[in]opThe operation
Returns
If the result of the operation was a success.

Definition at line 79 of file testing.cc.

79 {
80 if (buffer == nullptr) {
81 return false;
82 }
83
84 auto pattern = reinterpret_cast<const uint8_t*>("dErP");
85 constexpr auto pattern_length = 4;
86
87 uint8_t* start = buffer;
88 uint8_t* p = buffer;
89
90 while ((start + size) - p >= pattern_length) {
91 switch (op) {
92 case MemsetPatternOp::kMemsetPatternOpSetBuffer:
93 memmove(p, pattern, pattern_length);
94 break;
95 case MemsetPatternOp::kMemsetPatternOpCheckBuffer:
96 if (memcmp(pattern, p, pattern_length) != 0) {
97 return false;
98 }
99 break;
100 };
101 p += pattern_length;
102 }
103
104 if ((start + size) - p != 0) {
105 switch (op) {
106 case MemsetPatternOp::kMemsetPatternOpSetBuffer:
107 memmove(p, pattern, (start + size) - p);
108 break;
109 case MemsetPatternOp::kMemsetPatternOpCheckBuffer:
110 if (memcmp(pattern, p, (start + size) - p) != 0) {
111 return false;
112 }
113 break;
114 }
115 }
116
117 return true;
118}

◆ MockEmbedderApiForKeyboard()

void flutter::testing::MockEmbedderApiForKeyboard ( EngineModifier modifier,
std::shared_ptr< MockKeyResponseController response_controller 
)

Definition at line 101 of file test_keyboard.cc.

103 {
104 stored_response_controller = response_controller;
105 // This mock handles channel messages.
106 modifier.embedder_api()
109 if (std::string(message->channel) == std::string("flutter/settings")) {
110 return kSuccess;
111 }
112 if (std::string(message->channel) == std::string("flutter/keyevent")) {
113 stored_response_controller->HandleChannelMessage([message](bool handled) {
114 auto response = _keyHandlingResponse(handled);
115 auto response_handle = message->response_handle;
116 if (response_handle->callback != nullptr) {
117 response_handle->callback(response->data(), response->size(),
118 response_handle->user_data);
119 }
120 });
121 return kSuccess;
122 }
123 if (std::string(message->channel) == std::string("flutter/textinput")) {
124 std::unique_ptr<rapidjson::Document> document =
126 message->message, message->message_size);
127 if (document == nullptr) {
128 return kInvalidArguments;
129 }
130 stored_response_controller->HandleTextInputMessage(std::move(document));
131 return kSuccess;
132 }
133 return kSuccess;
134 };
135
136 // This mock handles key events sent through the embedder API.
137 modifier.embedder_api().SendKeyEvent =
140 stored_response_controller->HandleEmbedderMessage(
141 event, [callback, user_data](bool handled) {
142 if (callback != nullptr) {
143 callback(handled, user_data);
144 }
145 });
146 return kSuccess;
147 };
148
149 // The following mocks enable channel mocking.
151 [](auto engine, auto data_callback, auto user_data, auto response_out) {
152 auto response_handle = new FlutterPlatformMessageResponseHandle();
153 response_handle->user_data = user_data;
154 response_handle->callback = data_callback;
155 *response_out = response_handle;
156 return kSuccess;
157 };
158
162 delete response;
163 return kSuccess;
164 };
165
166 // The following mock disables responses for method channels sent from the
167 // embedding to the framework. (No code uses the response yet.)
171 const uint8_t* data, size_t data_length) { return kSuccess; };
172
173 // The following mocks allows RunWithEntrypoint to be run, which creates a
174 // non-empty FlutterEngine and enables SendKeyEvent.
175
176 modifier.embedder_api().Run =
177 [](size_t version, const FlutterRendererConfig* config,
178 const FlutterProjectArgs* args, void* user_data,
179 FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
180 *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
181
182 return kSuccess;
183 };
184 // Any time the associated EmbedderEngine will be mocked, such as here,
185 // the Update accessibility features must not attempt to actually push the
186 // update
190 modifier.embedder_api().UpdateLocales =
191 [](auto engine, const FlutterLocale** locales, size_t locales_count) {
192 return kSuccess;
193 };
195 [](auto engine, const FlutterWindowMetricsEvent* event) {
196 return kSuccess;
197 };
198 modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
200 [](auto engine, const FlutterEngineDisplaysUpdateType update_type,
201 const FlutterEngineDisplay* embedder_displays,
202 size_t display_count) { return kSuccess; };
203}
FlutterEngineProcTable & embedder_api()
static const JsonMessageCodec & GetInstance()
std::unique_ptr< T > DecodeMessage(const uint8_t *binary_message, const size_t message_size) const
#define FLUTTER_API_SYMBOL(symbol)
Definition embedder.h:67
struct _FlutterPlatformMessageResponseHandle FlutterPlatformMessageResponseHandle
Definition embedder.h:1157
FlutterAccessibilityFeature
Definition embedder.h:91
@ kInvalidArguments
Definition embedder.h:75
FlutterEngineDisplaysUpdateType
Definition embedder.h:1998
void(* FlutterKeyEventCallback)(bool, void *)
Definition embedder.h:1153
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Win32Message message
static std::shared_ptr< MockKeyResponseController > stored_response_controller
FlutterEnginePlatformMessageReleaseResponseHandleFnPtr PlatformMessageReleaseResponseHandle
Definition embedder.h:3335
FlutterEngineUpdateLocalesFnPtr UpdateLocales
Definition embedder.h:3352
FlutterEngineSendKeyEventFnPtr SendKeyEvent
Definition embedder.h:3330
FlutterEngineSendWindowMetricsEventFnPtr SendWindowMetricsEvent
Definition embedder.h:3328
FlutterEngineShutdownFnPtr Shutdown
Definition embedder.h:3324
FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate
Definition embedder.h:3358
FlutterEngineSendPlatformMessageFnPtr SendPlatformMessage
Definition embedder.h:3331
FlutterEnginePlatformMessageCreateResponseHandleFnPtr PlatformMessageCreateResponseHandle
Definition embedder.h:3333
FlutterEngineSendPlatformMessageResponseFnPtr SendPlatformMessageResponse
Definition embedder.h:3336
FlutterEngineRunFnPtr Run
Definition embedder.h:3323
FlutterEngineUpdateAccessibilityFeaturesFnPtr UpdateAccessibilityFeatures
Definition embedder.h:3342

◆ MultiplyPath()

void flutter::testing::MultiplyPath ( SkPath path,
SkPath::Verb  type,
SkPoint  center,
size_t  sides,
size_t  number,
float  radius 
)

Definition at line 590 of file dl_benchmarks.cc.

595 {
596 std::vector<SkPoint> center_points =
597 GetPolygonPoints(number, center, radius / 2.0f);
598
599 for (SkPoint p : center_points) {
600 switch (type) {
602 GetLinesPath(path, sides, p, radius);
603 break;
605 GetQuadsPath(path, sides, p, radius);
606 break;
608 GetConicsPath(path, sides, p, radius);
609 break;
611 GetCubicsPath(path, sides, p, radius);
612 break;
613 default:
614 break;
615 }
616 }
617}

◆ Nop()

void flutter::testing::Nop ( )

Definition at line 140 of file ffi_native_unittest.cc.

140{}

◆ NormalizeImage()

static sk_sp< SkData > flutter::testing::NormalizeImage ( const sk_sp< SkImage > &  image)
static

Definition at line 41 of file embedder_unittests_util.cc.

41 {
42 // To avoid clipping, convert to a very wide gamut, and a high bit depth.
45 SkImageInfo norm_image_info =
48 SkAlphaType::kUnpremul_SkAlphaType, norm_colorspace);
49 size_t row_bytes = norm_image_info.minRowBytes();
50 size_t size = norm_image_info.computeByteSize(row_bytes);
52 if (!data) {
53 FML_CHECK(false) << "Unable to allocate data.";
54 }
55
56 bool success = image->readPixels(norm_image_info, data->writable_data(),
57 row_bytes, 0, 0);
58 if (!success) {
59 FML_CHECK(false) << "Unable to read pixels.";
60 }
61
62 return data;
63}
@ kUnpremul_SkAlphaType
pixel components are independent of alpha
Definition SkAlphaType.h:30
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
Definition SkColorType.h:50
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition SkData.cpp:116
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Definition SkImage.cpp:42
int width() const
Definition SkImage.h:285
int height() const
Definition SkImage.h:291
static constexpr skcms_Matrix3x3 kRec2020
static constexpr skcms_TransferFunction kRec2020
size_t minRowBytes() const
size_t computeByteSize(size_t rowBytes) const

◆ NumberNear()

bool flutter::testing::NumberNear ( double  a,
double  b 
)
inline

Definition at line 13 of file assertions.h.

13 {
14 static const double epsilon = 1e-3;
15 return (a > (b - epsilon)) && (a < (b + epsilon));
16}

◆ OpenFixture()

fml::UniqueFD flutter::testing::OpenFixture ( const std::string &  fixture_name)

Opens a fixture of the given file name.

Parameters
[in]fixture_nameThe fixture name
Returns
The file descriptor of the given fixture. An invalid file descriptor is returned in case the fixture is not found.

Definition at line 37 of file testing.cc.

37 {
38 if (fixture_name.size() == 0) {
39 FML_LOG(ERROR) << "Invalid fixture name.";
40 return {};
41 }
42
43 auto fixtures_directory = OpenFixturesDirectory();
44
45 auto fixture_fd = fml::OpenFile(fixtures_directory, // base directory
46 fixture_name.c_str(), // path
47 false, // create
48 fml::FilePermission::kRead // permission
49 );
50 if (!fixture_fd.is_valid()) {
51 FML_LOG(ERROR) << "Could not open fixture for path: " << GetFixturesPath()
52 << "/" << fixture_name << ".";
53 return {};
54 }
55
56 return fixture_fd;
57}
fml::UniqueFD OpenFile(const char *path, bool create_if_necessary, FilePermission permission)
This can open a directory on POSIX, but not on Windows.
Definition file_posix.cc:66

◆ OpenFixtureAsMapping()

std::unique_ptr< fml::Mapping > flutter::testing::OpenFixtureAsMapping ( const std::string &  fixture_name)

Opens a fixture of the given file name and returns a mapping to its contents.

Parameters
[in]fixture_nameThe fixture name
Returns
A mapping to the contents of fixture or null if the fixture does not exist or its contents cannot be mapped in.

Definition at line 59 of file testing.cc.

60 {
62}
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
Definition mapping.cc:20

◆ OpenFixtureAsSkData()

sk_sp< SkData > flutter::testing::OpenFixtureAsSkData ( const std::string &  fixture_name)

Opens a fixture of the given file name and returns a Skia SkData holding its contents.

Parameters
[in]fixture_nameThe fixture name
Returns
An SkData, or null if the fixture does not exist or its contents cannot be mapped in.

Definition at line 64 of file testing.cc.

64 {
65 auto mapping = flutter::testing::OpenFixtureAsMapping(fixture_name);
66 if (!mapping) {
67 return nullptr;
68 }
70 mapping->GetMapping(), mapping->GetSize(),
71 [](const void* ptr, void* context) {
72 delete reinterpret_cast<fml::Mapping*>(context);
73 },
74 mapping.get());
75 mapping.release();
76 return data;
77}

◆ OpenFixturesDirectory()

fml::UniqueFD flutter::testing::OpenFixturesDirectory ( )

Opens the fixtures directory for the unit-test harness.

Returns
The file descriptor of the fixtures directory.

Definition at line 23 of file testing.cc.

23 {
24 auto fixtures_directory =
25 OpenDirectory(GetFixturesPath(), // path
26 false, // create
27 fml::FilePermission::kRead // permission
28 );
29
30 if (!fixtures_directory.is_valid()) {
31 FML_LOG(ERROR) << "Could not open fixtures directory.";
32 return {};
33 }
34 return fixtures_directory;
35}

◆ operator<<() [1/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DisplayList display_list 
)

Definition at line 38 of file display_list_testing.cc.

39 {
40 DisplayListStreamDispatcher dispatcher(os);
41 os << std::boolalpha;
42 os << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
43 os << "DisplayList {" << std::endl;
44 display_list.Dispatch(dispatcher);
45 os << "}" << std::endl;
46 return os;
47}
void Dispatch(DlOpReceiver &ctx) const

◆ operator<<() [2/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlBlendMode mode 
)

Definition at line 79 of file display_list_testing.cc.

79 {
80 switch (mode) {
81 case DlBlendMode::kClear: return os << "BlendMode::kClear";
82 case DlBlendMode::kSrc: return os << "BlendMode::kSrc";
83 case DlBlendMode::kDst: return os << "BlendMode::kDst";
84 case DlBlendMode::kSrcOver: return os << "BlendMode::kSrcOver";
85 case DlBlendMode::kDstOver: return os << "BlendMode::kDstOver";
86 case DlBlendMode::kSrcIn: return os << "BlendMode::kSrcIn";
87 case DlBlendMode::kDstIn: return os << "BlendMode::kDstIn";
88 case DlBlendMode::kSrcOut: return os << "BlendMode::kSrcOut";
89 case DlBlendMode::kDstOut: return os << "BlendMode::kDstOut";
90 case DlBlendMode::kSrcATop: return os << "BlendMode::kSrcATop";
91 case DlBlendMode::kDstATop: return os << "BlendMode::kDstATop";
92 case DlBlendMode::kXor: return os << "BlendMode::kXor";
93 case DlBlendMode::kPlus: return os << "BlendMode::kPlus";
94 case DlBlendMode::kModulate: return os << "BlendMode::kModulate";
95 case DlBlendMode::kScreen: return os << "BlendMode::kScreen";
96
97 case DlBlendMode::kOverlay: return os << "BlendMode::kOverlay";
98 case DlBlendMode::kDarken: return os << "BlendMode::kDarken";
99 case DlBlendMode::kLighten: return os << "BlendMode::kLighten";
100 case DlBlendMode::kColorDodge: return os << "BlendMode::kColorDodge";
101 case DlBlendMode::kColorBurn: return os << "BlendMode::kColorBurn";
102 case DlBlendMode::kHardLight: return os << "BlendMode::kHardLight";
103 case DlBlendMode::kSoftLight: return os << "BlendMode::kSoftLight";
104 case DlBlendMode::kDifference: return os << "BlendMode::kDifference";
105 case DlBlendMode::kExclusion: return os << "BlendMode::kExclusion";
106 case DlBlendMode::kMultiply: return os << "BlendMode::kMultiply";
107
108 case DlBlendMode::kHue: return os << "BlendMode::kHue";
109 case DlBlendMode::kSaturation: return os << "BlendMode::kSaturation";
110 case DlBlendMode::kColor: return os << "BlendMode::kColor";
111 case DlBlendMode::kLuminosity: return os << "BlendMode::kLuminosity";
112
113 default: return os << "BlendMode::????";
114 }
115}

◆ operator<<() [3/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlBlurStyle style 
)

Definition at line 233 of file display_list_testing.cc.

233 {
234 switch (style) {
235 case DlBlurStyle::kNormal: return os << "BlurStyle::kNormal";
236 case DlBlurStyle::kSolid: return os << "BlurStyle::kSolid";
237 case DlBlurStyle::kOuter: return os << "BlurStyle::kOuter";
238 case DlBlurStyle::kInner: return os << "BlurStyle::kInner";
239 }
240}

◆ operator<<() [4/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlCanvas::ClipOp op 
)

Definition at line 193 of file display_list_testing.cc.

193 {
194 switch (op) {
195 case DlCanvas::ClipOp::kDifference: return os << "ClipOp::kDifference";
196 case DlCanvas::ClipOp::kIntersect: return os << "ClipOp::kIntersect";
197 }
198}

◆ operator<<() [5/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlCanvas::PointMode mode 
)

Definition at line 242 of file display_list_testing.cc.

242 {
243 switch (mode) {
244 case DlCanvas::PointMode::kPoints: return os << "PointMode::kPoints";
245 case DlCanvas::PointMode::kLines: return os << "PointMode::kLines";
246 case DlCanvas::PointMode::kPolygon: return os << "PointMode::kPolygon";
247 }
248}

◆ operator<<() [6/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlCanvas::SrcRectConstraint constraint 
)

Definition at line 200 of file display_list_testing.cc.

200 {
201 switch (constraint) {
202 case DlCanvas::SrcRectConstraint::kFast:
203 return os << "SrcRectConstraint::kFast";
204 case DlCanvas::SrcRectConstraint::kStrict:
205 return os << "SrcRectConstraint::kStrict";
206 }
207}

◆ operator<<() [7/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlColor color 
)

Definition at line 259 of file display_list_testing.cc.

259 {
260 return os << "DlColor(" << std::hex << color.argb() << std::dec << ")";
261}

◆ operator<<() [8/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlDrawStyle style 
)

Definition at line 225 of file display_list_testing.cc.

225 {
226 switch (style) {
227 case DlDrawStyle::kFill: return os << "Style::kFill";
228 case DlDrawStyle::kStroke: return os << "Style::kStroke";
229 case DlDrawStyle::kStrokeAndFill: return os << "Style::kStrokeAnFill";
230 }
231}

◆ operator<<() [9/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlFilterMode mode 
)

Definition at line 250 of file display_list_testing.cc.

250 {
251 switch (mode) {
252 case DlFilterMode::kNearest: return os << "FilterMode::kNearest";
253 case DlFilterMode::kLinear: return os << "FilterMode::kLinear";
254
255 default: return os << "FilterMode::????";
256 }
257}

◆ operator<<() [10/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlImage image 
)

Definition at line 319 of file display_list_testing.cc.

319 {
320 if (image == nullptr) {
321 return os << "null image";
322 }
323 os << "&DlImage(" << image->width() << " x " << image->height() << ", ";
324 if (image->skia_image()) {
325 os << "skia(" << image->skia_image().get() << "), ";
326 }
327 if (image->impeller_texture()) {
328 os << "impeller(" << image->impeller_texture().get() << "), ";
329 }
330 return os << "isTextureBacked: " << image->isTextureBacked() << ")";
331}
virtual bool isTextureBacked() const =0

◆ operator<<() [11/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlPaint paint 
)

Definition at line 49 of file display_list_testing.cc.

49 {
50 os << "DlPaint("
51 << "isaa: " << paint.isAntiAlias() << ", "
52 << paint.getColor() << ", "
53 << paint.getBlendMode() << ", "
54 << paint.getDrawStyle();
55 if (paint.getDrawStyle() != DlDrawStyle::kFill) {
56 os << ", width: " << paint.getStrokeWidth()
57 << ", miter: " << paint.getStrokeMiter()
58 << ", " << paint.getStrokeCap()
59 << ", " << paint.getStrokeJoin();
60 }
61 if (paint.getColorSource()) {
62 os << ", " << paint.getColorSource();
63 }
64 if (paint.getColorFilter()) {
65 os << ", " << paint.getColorFilter();
66 }
67 if (paint.getImageFilter()) {
68 os << ", " << paint.getImageFilter();
69 }
70 if (paint.getMaskFilter()) {
71 os << ", " << paint.getMaskFilter();
72 }
73 if (paint.isInvertColors()) {
74 os << ", invertColors: " << paint.isInvertColors();
75 }
76 return os << ")";
77}

◆ operator<<() [12/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlStrokeCap cap 
)

Definition at line 209 of file display_list_testing.cc.

209 {
210 switch (cap) {
211 case DlStrokeCap::kButt: return os << "Cap::kButt";
212 case DlStrokeCap::kRound: return os << "Cap::kRound";
213 case DlStrokeCap::kSquare: return os << "Cap::kSquare";
214 }
215}

◆ operator<<() [13/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlStrokeJoin join 
)

Definition at line 217 of file display_list_testing.cc.

217 {
218 switch (join) {
219 case DlStrokeJoin::kMiter: return os << "Join::kMiter";
220 case DlStrokeJoin::kRound: return os << "Join::kRound";
221 case DlStrokeJoin::kBevel: return os << "Join::kBevel";
222 }
223}

◆ operator<<() [14/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlTileMode mode 
)

Definition at line 308 of file display_list_testing.cc.

308 {
309 switch (mode) {
310 case DlTileMode::kClamp: return os << "TileMode::kClamp";
311 case DlTileMode::kRepeat: return os << "TileMode::kRepeat";
312 case DlTileMode::kMirror: return os << "TileMode::kMirror";
313 case DlTileMode::kDecal: return os << "TileMode::kDecal";
314
315 default: return os << "TileMode::????";
316 }
317}

◆ operator<<() [15/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const DlVertexMode mode 
)

Definition at line 298 of file display_list_testing.cc.

298 {
299 switch (mode) {
300 case DlVertexMode::kTriangles: return os << "VertexMode::kTriangles";
301 case DlVertexMode::kTriangleStrip: return os << "VertexMode::kTriangleStrip";
302 case DlVertexMode::kTriangleFan: return os << "VertexMode::kTriangleFan";
303
304 default: return os << "VertexMode::????";
305 }
306}

◆ operator<<() [16/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const impeller::TextFrame frame 
)
static

Definition at line 287 of file display_list_testing.cc.

288 {
289 if (frame == nullptr) {
290 return os << "no text";
291 }
292 auto bounds = frame->GetBounds();
293 return os << "&TextFrame("
294 << bounds.GetLeft() << ", " << bounds.GetTop() << " => "
295 << bounds.GetRight() << ", " << bounds.GetBottom() << ")";
296}
double frame
Definition examples.cpp:31

◆ operator<<() [17/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::ClipEdgeStyle style 
)
static

Definition at line 502 of file mock_canvas.cc.

503 {
504 return os << (style == MockCanvas::kSoftClipEdgeStyle ? "kSoftEdges"
505 : "kHardEdges");
506}

◆ operator<<() [18/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::ClipPathData data 
)

Definition at line 528 of file mock_canvas.cc.

529 {
530 return os << data.path << " " << data.clip_op << " " << data.style;
531}

◆ operator<<() [19/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::ClipRectData data 
)

Definition at line 508 of file mock_canvas.cc.

509 {
510 return os << data.rect << " " << data.clip_op << " " << data.style;
511}

◆ operator<<() [20/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::ClipRRectData data 
)

Definition at line 518 of file mock_canvas.cc.

519 {
520 return os << data.rrect << " " << data.clip_op << " " << data.style;
521}

◆ operator<<() [21/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::ConcatMatrixData data 
)

Definition at line 403 of file mock_canvas.cc.

404 {
405 return os << data.matrix;
406}

◆ operator<<() [22/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawCall draw 
)

Definition at line 543 of file mock_canvas.cc.

543 {
544 return os << "[Layer: " << draw.layer << ", Data: " << draw.data << "]";
545}
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27

◆ operator<<() [23/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawCallData data 
)

Definition at line 533 of file mock_canvas.cc.

534 {
535 std::visit([&os](auto& d) { os << d; }, data);
536 return os;
537}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19

◆ operator<<() [24/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawDisplayListData data 
)

Definition at line 478 of file mock_canvas.cc.

479 {
480 auto dl = data.display_list;
481 return os << "[" << dl->unique_id() << " " << dl->op_count() << " "
482 << dl->bytes() << "] " << data.opacity;
483}

◆ operator<<() [25/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawImageData data 
)

Definition at line 455 of file mock_canvas.cc.

456 {
457 return os << data.image << " " << data.x << " " << data.y << " "
458 << data.options << " " << data.paint;
459}

◆ operator<<() [26/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawImageDataNoPaint data 
)

Definition at line 467 of file mock_canvas.cc.

468 {
469 return os << data.image << " " << data.x << " " << data.y << " "
470 << data.options;
471}

◆ operator<<() [27/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawPaintData data 
)

Definition at line 552 of file mock_canvas.cc.

553 {
554 return os << data.paint;
555}

◆ operator<<() [28/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawPathData data 
)

Definition at line 433 of file mock_canvas.cc.

434 {
435 return os << data.path << " " << data.paint;
436}

◆ operator<<() [29/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawRectData data 
)

Definition at line 423 of file mock_canvas.cc.

424 {
425 return os << data.rect << " " << data.paint;
426}

◆ operator<<() [30/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawShadowData data 
)

Definition at line 491 of file mock_canvas.cc.

492 {
493 return os << data.path << " " << data.color << " " << data.elevation << " "
494 << data.transparent_occluder << " " << data.dpr;
495}

◆ operator<<() [31/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::DrawTextData data 
)

Definition at line 444 of file mock_canvas.cc.

445 {
446 return os << data.serialized_text << " " << data.paint << " " << data.offset;
447}

◆ operator<<() [32/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::RestoreData data 
)

Definition at line 393 of file mock_canvas.cc.

394 {
395 return os << data.restore_to_layer;
396}

◆ operator<<() [33/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::SaveData data 
)

Definition at line 371 of file mock_canvas.cc.

371 {
372 return os << data.save_to_layer;
373}

◆ operator<<() [34/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::SaveLayerData data 
)

Definition at line 382 of file mock_canvas.cc.

383 {
384 return os << data.save_bounds << " " << data.restore_paint << " "
385 << data.backdrop_filter << " " << data.save_to_layer;
386}

◆ operator<<() [35/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const MockCanvas::SetMatrixData data 
)

Definition at line 413 of file mock_canvas.cc.

414 {
415 return os << data.matrix;
416}

◆ operator<<() [36/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SaveLayerOptions options 
)

Definition at line 117 of file display_list_testing.cc.

117 {
118 return os << "SaveLayerOptions("
119 << "can_distribute_opacity: " << options.can_distribute_opacity()
120 << ", "
121 << "renders_with_attributes: " << options.renders_with_attributes()
122 << ")";
123}

◆ operator<<() [37/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkIRect rect 
)
static

Definition at line 129 of file display_list_testing.cc.

129 {
130 return os << "SkIRect("
131 << "left: " << rect.fLeft << ", "
132 << "top: " << rect.fTop << ", "
133 << "right: " << rect.fRight << ", "
134 << "bottom: " << rect.fBottom
135 << ")";
136}

◆ operator<<() [38/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkM44 m 
)
static

Definition at line 355 of file mock_canvas.cc.

355 {
356 os << m.rc(0, 0) << ", " << m.rc(0, 1) << ", " << m.rc(0, 2) << ", "
357 << m.rc(0, 3) << std::endl;
358 os << m.rc(1, 0) << ", " << m.rc(1, 1) << ", " << m.rc(1, 2) << ", "
359 << m.rc(1, 3) << std::endl;
360 os << m.rc(2, 0) << ", " << m.rc(2, 1) << ", " << m.rc(2, 2) << ", "
361 << m.rc(2, 3) << std::endl;
362 os << m.rc(3, 0) << ", " << m.rc(3, 1) << ", " << m.rc(3, 2) << ", "
363 << m.rc(3, 3);
364 return os;
365}

◆ operator<<() [39/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkMatrix matrix 
)
static

Definition at line 172 of file display_list_testing.cc.

172 {
173 return os << "SkMatrix("
174 << "[" << matrix[0] << ", " << matrix[1] << ", " << matrix[2] << "], "
175 << "[" << matrix[3] << ", " << matrix[4] << ", " << matrix[5] << "], "
176 << "[" << matrix[6] << ", " << matrix[7] << ", " << matrix[8] << "]"
177 << ")";
178}

◆ operator<<() [40/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkMatrix matrix 
)
static

Definition at line 180 of file display_list_testing.cc.

180 {
181 if (matrix) return os << "&" << *matrix;
182 return os << "no matrix";
183}

◆ operator<<() [41/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkPath path 
)
static

Definition at line 165 of file display_list_testing.cc.

165 {
166 return os << "SkPath("
167 << "bounds: " << path.getBounds()
168 // should iterate over verbs and coordinates...
169 << ")";
170}

◆ operator<<() [42/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkPath r 
)
static

Definition at line 348 of file mock_canvas.cc.

348 {
349 return os << "Valid: " << r.isValid()
350 << ", FillType: " << static_cast<int>(r.getFillType())
351 << ", Bounds: " << r.getBounds();
352}
SkPathFillType getFillType() const
Definition SkPath.h:230
const SkRect & getBounds() const
Definition SkPath.cpp:420
bool isValid() const
Definition SkPath.cpp:428

◆ operator<<() [43/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkPoint point 
)
static

Definition at line 125 of file display_list_testing.cc.

125 {
126 return os << "SkPoint(" << point.fX << ", " << point.fY << ")";
127}
float fX
x-axis value
float fY
y-axis value

◆ operator<<() [44/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkPoint r 
)
static

Definition at line 334 of file mock_canvas.cc.

334 {
335 return os << "XY: " << r.fX << ", " << r.fY;
336}

◆ operator<<() [45/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkRect r 
)
static

Definition at line 338 of file mock_canvas.cc.

338 {
339 return os << "LTRB: " << r.fLeft << ", " << r.fTop << ", " << r.fRight << ", "
340 << r.fBottom;
341}
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ operator<<() [46/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkRect rect 
)
static

Definition at line 138 of file display_list_testing.cc.

138 {
139 return os << "SkRect("
140 << "left: " << rect.fLeft << ", "
141 << "top: " << rect.fTop << ", "
142 << "right: " << rect.fRight << ", "
143 << "bottom: " << rect.fBottom
144 << ")";
145}

◆ operator<<() [47/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkRect rect 
)
static

Definition at line 147 of file display_list_testing.cc.

147 {
148 return rect ? (os << "&" << *rect) : os << "no rect";
149}

◆ operator<<() [48/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkRRect r 
)
static

Definition at line 343 of file mock_canvas.cc.

343 {
344 return os << "LTRB: " << r.rect().fLeft << ", " << r.rect().fTop << ", "
345 << r.rect().fRight << ", " << r.rect().fBottom;
346}

◆ operator<<() [49/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkRRect rrect 
)
static

Definition at line 151 of file display_list_testing.cc.

151 {
152 return os << "SkRRect("
153 << rrect.rect() << ", "
154 << "ul: (" << rrect.radii(SkRRect::kUpperLeft_Corner).fX << ", "
155 << rrect.radii(SkRRect::kUpperLeft_Corner).fY << "), "
156 << "ur: (" << rrect.radii(SkRRect::kUpperRight_Corner).fX << ", "
157 << rrect.radii(SkRRect::kUpperRight_Corner).fY << "), "
158 << "lr: (" << rrect.radii(SkRRect::kLowerRight_Corner).fX << ", "
159 << rrect.radii(SkRRect::kLowerRight_Corner).fY << "), "
160 << "ll: (" << rrect.radii(SkRRect::kLowerLeft_Corner).fX << ", "
161 << rrect.radii(SkRRect::kLowerLeft_Corner).fY << ")"
162 << ")";
163}
SkVector radii(Corner corner) const
Definition SkRRect.h:271
@ kUpperLeft_Corner
index of top-left corner radii
Definition SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition SkRRect.h:255

◆ operator<<() [50/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkRSXform xform 
)
static

Definition at line 185 of file display_list_testing.cc.

185 {
186 return os << "SkRSXform("
187 << "scos: " << xform.fSCos << ", "
188 << "ssin: " << xform.fSSin << ", "
189 << "tx: " << xform.fTx << ", "
190 << "ty: " << xform.fTy << ")";
191}
SkScalar fTy
Definition SkRSXform.h:45
SkScalar fSCos
Definition SkRSXform.h:42
SkScalar fTx
Definition SkRSXform.h:44
SkScalar fSSin
Definition SkRSXform.h:43

◆ operator<<() [51/52]

static std::ostream & flutter::testing::operator<< ( std::ostream &  os,
const SkTextBlob blob 
)
static

Definition at line 280 of file display_list_testing.cc.

280 {
281 if (blob == nullptr) {
282 return os << "no text";
283 }
284 return os << "&SkTextBlob(ID: " << blob->uniqueID() << ", " << blob->bounds() << ")";
285}
uint32_t uniqueID() const
Definition SkTextBlob.h:59
const SkRect & bounds() const
Definition SkTextBlob.h:53

◆ operator<<() [52/52]

std::ostream & flutter::testing::operator<< ( std::ostream &  os,
DlImageSampling  sampling 
)

Definition at line 263 of file display_list_testing.cc.

263 {
264 switch (sampling) {
265 case DlImageSampling::kNearestNeighbor: {
266 return os << "NearestSampling";
267 }
268 case DlImageSampling::kLinear: {
269 return os << "LinearSampling";
270 }
271 case DlImageSampling::kMipmapLinear: {
272 return os << "MipmapSampling";
273 }
274 case DlImageSampling::kCubic: {
275 return os << "CubicSampling";
276 }
277 }
278}

◆ operator==() [1/18]

bool flutter::testing::operator== ( const CGRect &  lhs,
const CGRect &  rhs 
)
inline

Definition at line 198 of file FlutterSurfaceManagerTest.mm.

198 {
199 return CGRectEqualToRect(lhs, rhs);
200}

◆ operator==() [2/18]

bool flutter::testing::operator== ( const MockCanvas::ClipPathData a,
const MockCanvas::ClipPathData b 
)

Definition at line 523 of file mock_canvas.cc.

524 {
525 return a.path == b.path && a.clip_op == b.clip_op && a.style == b.style;
526}

◆ operator==() [3/18]

bool flutter::testing::operator== ( const MockCanvas::ClipRectData a,
const MockCanvas::ClipRectData b 
)

Definition at line 497 of file mock_canvas.cc.

498 {
499 return a.rect == b.rect && a.clip_op == b.clip_op && a.style == b.style;
500}

◆ operator==() [4/18]

bool flutter::testing::operator== ( const MockCanvas::ClipRRectData a,
const MockCanvas::ClipRRectData b 
)

Definition at line 513 of file mock_canvas.cc.

514 {
515 return a.rrect == b.rrect && a.clip_op == b.clip_op && a.style == b.style;
516}

◆ operator==() [5/18]

bool flutter::testing::operator== ( const MockCanvas::ConcatMatrixData a,
const MockCanvas::ConcatMatrixData b 
)

Definition at line 398 of file mock_canvas.cc.

399 {
400 return a.matrix == b.matrix;
401}

◆ operator==() [6/18]

bool flutter::testing::operator== ( const MockCanvas::DrawCall a,
const MockCanvas::DrawCall b 
)

Definition at line 539 of file mock_canvas.cc.

539 {
540 return a.layer == b.layer && a.data == b.data;
541}

◆ operator==() [7/18]

bool flutter::testing::operator== ( const MockCanvas::DrawDisplayListData a,
const MockCanvas::DrawDisplayListData b 
)

Definition at line 473 of file mock_canvas.cc.

474 {
475 return a.display_list->Equals(b.display_list) && a.opacity == b.opacity;
476}

◆ operator==() [8/18]

bool flutter::testing::operator== ( const MockCanvas::DrawImageData a,
const MockCanvas::DrawImageData b 
)

Definition at line 449 of file mock_canvas.cc.

450 {
451 return a.image == b.image && a.x == b.x && a.y == b.y &&
452 a.options == b.options && a.paint == b.paint;
453}

◆ operator==() [9/18]

bool flutter::testing::operator== ( const MockCanvas::DrawImageDataNoPaint a,
const MockCanvas::DrawImageDataNoPaint b 
)

Definition at line 461 of file mock_canvas.cc.

462 {
463 return a.image == b.image && a.x == b.x && a.y == b.y &&
464 a.options == b.options;
465}

◆ operator==() [10/18]

bool flutter::testing::operator== ( const MockCanvas::DrawPaintData a,
const MockCanvas::DrawPaintData b 
)

Definition at line 547 of file mock_canvas.cc.

548 {
549 return a.paint == b.paint;
550}

◆ operator==() [11/18]

bool flutter::testing::operator== ( const MockCanvas::DrawPathData a,
const MockCanvas::DrawPathData b 
)

Definition at line 428 of file mock_canvas.cc.

429 {
430 return a.path == b.path && a.paint == b.paint;
431}

◆ operator==() [12/18]

bool flutter::testing::operator== ( const MockCanvas::DrawRectData a,
const MockCanvas::DrawRectData b 
)

Definition at line 418 of file mock_canvas.cc.

419 {
420 return a.rect == b.rect && a.paint == b.paint;
421}

◆ operator==() [13/18]

bool flutter::testing::operator== ( const MockCanvas::DrawShadowData a,
const MockCanvas::DrawShadowData b 
)

Definition at line 485 of file mock_canvas.cc.

486 {
487 return a.path == b.path && a.color == b.color && a.elevation == b.elevation &&
488 a.transparent_occluder == b.transparent_occluder && a.dpr == b.dpr;
489}

◆ operator==() [14/18]

bool flutter::testing::operator== ( const MockCanvas::DrawTextData a,
const MockCanvas::DrawTextData b 
)

Definition at line 438 of file mock_canvas.cc.

439 {
440 return a.serialized_text->equals(b.serialized_text.get()) &&
441 a.paint == b.paint && a.offset == b.offset;
442}

◆ operator==() [15/18]

bool flutter::testing::operator== ( const MockCanvas::RestoreData a,
const MockCanvas::RestoreData b 
)

Definition at line 388 of file mock_canvas.cc.

389 {
390 return a.restore_to_layer == b.restore_to_layer;
391}

◆ operator==() [16/18]

bool flutter::testing::operator== ( const MockCanvas::SaveData a,
const MockCanvas::SaveData b 
)

Definition at line 367 of file mock_canvas.cc.

367 {
368 return a.save_to_layer == b.save_to_layer;
369}

◆ operator==() [17/18]

bool flutter::testing::operator== ( const MockCanvas::SaveLayerData a,
const MockCanvas::SaveLayerData b 
)

Definition at line 375 of file mock_canvas.cc.

376 {
377 return a.save_bounds == b.save_bounds && a.restore_paint == b.restore_paint &&
378 Equals(a.backdrop_filter, b.backdrop_filter) &&
379 a.save_to_layer == b.save_to_layer;
380}
bool Equals(const SkPath &a, const SkPath &b)

◆ operator==() [18/18]

bool flutter::testing::operator== ( const MockCanvas::SetMatrixData a,
const MockCanvas::SetMatrixData b 
)

Definition at line 408 of file mock_canvas.cc.

409 {
410 return a.matrix == b.matrix;
411}

◆ ParseViewIdsCallback()

static void flutter::testing::ParseViewIdsCallback ( const Dart_NativeArguments args,
bool *  hasImplicitView,
std::vector< int64_t > *  viewIds 
)
static

Definition at line 4436 of file shell_unittests.cc.

4438 {
4439 Dart_Handle exception = nullptr;
4440 viewIds->clear();
4441 *hasImplicitView =
4443 ASSERT_EQ(exception, nullptr);
4444 *viewIds = tonic::DartConverter<std::vector<int64_t>>::FromArguments(
4445 args, 1, exception);
4446 ASSERT_EQ(exception, nullptr);
4447}
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258

◆ ParseViewWidthsCallback()

static void flutter::testing::ParseViewWidthsCallback ( const Dart_NativeArguments args,
std::map< int64_t, int64_t > *  viewWidths 
)
static

Definition at line 4668 of file shell_unittests.cc.

4669 {
4670 Dart_Handle exception = nullptr;
4671 viewWidths->clear();
4672 std::vector<int64_t> viewWidthPacket =
4674 exception);
4675 ASSERT_EQ(exception, nullptr);
4676 ASSERT_EQ(viewWidthPacket.size() % 2, 0ul);
4677 for (size_t packetIndex = 0; packetIndex < viewWidthPacket.size();
4678 packetIndex += 2) {
4679 (*viewWidths)[viewWidthPacket[packetIndex]] =
4680 viewWidthPacket[packetIndex + 1];
4681 }
4682}

◆ PointModeToString()

std::string flutter::testing::PointModeToString ( DlCanvas::PointMode  mode)

Definition at line 857 of file dl_benchmarks.cc.

857 {
858 switch (mode) {
859 case DlCanvas::PointMode::kLines:
860 return "Lines";
861 case DlCanvas::PointMode::kPolygon:
862 return "Polygon";
863 case DlCanvas::PointMode::kPoints:
864 default:
865 return "Points";
866 }
867}

◆ PostSync()

static void flutter::testing::PostSync ( const fml::RefPtr< fml::TaskRunner > &  task_runner,
const fml::closure task 
)
static

Definition at line 381 of file shell_unittests.cc.

382 {
384 fml::TaskRunner::RunNowOrPostTask(task_runner, [&latch, &task] {
385 task();
386 latch.Signal();
387 });
388 latch.Wait();
389}

◆ PostTaskSync()

void flutter::testing::PostTaskSync ( const fml::RefPtr< fml::TaskRunner > &  task_runner,
const std::function< void()> &  function 
)

Definition at line 12 of file post_task_sync.cc.

13 {
15 task_runner->PostTask([&] {
16 function();
17 latch.Signal();
18 });
19 latch.Wait();
20}
virtual void PostTask(const fml::closure &task) override
Dart_NativeFunction function
Definition fuchsia.cc:51

◆ PrepareSettingsForAOTWithSymbols()

bool flutter::testing::PrepareSettingsForAOTWithSymbols ( Settings settings,
const ELFAOTSymbols symbols 
)

Prepare the settings objects various AOT mappings resolvers with the symbols already loaded. This method does nothing in non-AOT runtime modes.

Warning
The symbols must not be collected till all shell instantiations made using the settings object are collected.
Parameters
[in/out]settings The settings whose AOT resolvers to populate.
[in]symbolsThe symbols used to populate the settings object.
Returns
If the settings object was correctly updated.

Definition at line 116 of file elf_loader.cc.

117 {
118 if (!DartVM::IsRunningPrecompiledCode()) {
119 return false;
120 }
121 settings.vm_snapshot_data = [&]() {
122 return std::make_unique<fml::NonOwnedMapping>(symbols.vm_snapshot_data, 0u);
123 };
124 settings.isolate_snapshot_data = [&]() {
125 return std::make_unique<fml::NonOwnedMapping>(symbols.vm_isolate_data, 0u);
126 };
127 settings.vm_snapshot_instr = [&]() {
128 return std::make_unique<fml::NonOwnedMapping>(symbols.vm_snapshot_instrs,
129 0u);
130 };
131 settings.isolate_snapshot_instr = [&]() {
132 return std::make_unique<fml::NonOwnedMapping>(symbols.vm_isolate_instrs,
133 0u);
134 };
135 return true;
136}

◆ RasterCacheItemPreroll()

void flutter::testing::RasterCacheItemPreroll ( DisplayListRasterCacheItem display_list_item,
PrerollContext context,
const SkMatrix matrix 
)

Definition at line 147 of file mock_raster_cache.cc.

149 {
150 display_list_item.PrerollSetup(&context, matrix);
151 display_list_item.PrerollFinalize(&context, matrix);
152}
void PrerollSetup(PrerollContext *context, const SkMatrix &matrix) override
void PrerollFinalize(PrerollContext *context, const SkMatrix &matrix) override

◆ RasterCacheItemPrerollAndTryToRasterCache()

bool flutter::testing::RasterCacheItemPrerollAndTryToRasterCache ( DisplayListRasterCacheItem display_list_item,
PrerollContext context,
PaintContext paint_context,
const SkMatrix matrix 
)

Definition at line 137 of file mock_raster_cache.cc.

141 {
142 RasterCacheItemPreroll(display_list_item, context, matrix);
144 return RasterCacheItemTryToRasterCache(display_list_item, paint_context);
145}
bool RasterCacheItemTryToRasterCache(DisplayListRasterCacheItem &display_list_item, PaintContext &paint_context)
void RasterCacheItemPreroll(DisplayListRasterCacheItem &display_list_item, PrerollContext &context, const SkMatrix &matrix)
RasterCache * raster_cache
Definition layer.h:55

◆ RasterCacheItemTryToRasterCache()

bool flutter::testing::RasterCacheItemTryToRasterCache ( DisplayListRasterCacheItem display_list_item,
PaintContext paint_context 
)

Definition at line 154 of file mock_raster_cache.cc.

156 {
157 if (display_list_item.cache_state() ==
158 RasterCacheItem::CacheState::kCurrent) {
159 return display_list_item.TryToPrepareRasterCache(paint_context);
160 }
161 return false;
162}
bool TryToPrepareRasterCache(const PaintContext &context, bool parent_cached=false) const override
CacheState cache_state() const

◆ RasterImagesAreSame()

bool flutter::testing::RasterImagesAreSame ( const sk_sp< SkImage > &  a,
const sk_sp< SkImage > &  b 
)

Definition at line 65 of file embedder_unittests_util.cc.

65 {
66 if (!a || !b) {
67 return false;
68 }
69
70 FML_CHECK(!a->isTextureBacked());
71 FML_CHECK(!b->isTextureBacked());
72
73 sk_sp<SkData> normalized_a = NormalizeImage(a);
74 sk_sp<SkData> normalized_b = NormalizeImage(b);
75
76 return normalized_a->equals(normalized_b.get());
77}

◆ RasterizerIsTornDown()

static bool flutter::testing::RasterizerIsTornDown ( Shell shell)
static

Definition at line 335 of file shell_unittests.cc.

335 {
337 bool is_torn_down = false;
339 shell->GetTaskRunners().GetRasterTaskRunner(),
340 [shell, &latch, &is_torn_down]() {
341 is_torn_down = shell->GetRasterizer()->IsTornDown();
342 latch.Signal();
343 });
344 latch.Wait();
345 return is_torn_down;
346}

◆ ReadbackResult() [1/3]

static bool flutter::testing::ReadbackResult ( PrerollContext context,
Clip  clip_behavior,
const std::shared_ptr< Layer > &  child,
bool  before 
)
static

Definition at line 245 of file clip_path_layer_unittests.cc.

248 {
249 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
250 const SkPath layer_path = SkPath().addRect(layer_bounds);
251 auto layer = std::make_shared<ClipPathLayer>(layer_path, clip_behavior);
252 if (child != nullptr) {
253 layer->Add(child);
254 }
255 context->surface_needs_readback = before;
256 layer->Preroll(context);
257 return context->surface_needs_readback;
258}
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition SkPath.cpp:854
bool surface_needs_readback
Definition layer.h:60

◆ ReadbackResult() [2/3]

static bool flutter::testing::ReadbackResult ( PrerollContext context,
Clip  clip_behavior,
const std::shared_ptr< Layer > &  child,
bool  before 
)
static

Definition at line 235 of file clip_rect_layer_unittests.cc.

238 {
239 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
240 auto layer = std::make_shared<ClipRectLayer>(layer_bounds, clip_behavior);
241 if (child != nullptr) {
242 layer->Add(child);
243 }
244 context->surface_needs_readback = before;
245 layer->Preroll(context);
246 return context->surface_needs_readback;
247}

◆ ReadbackResult() [3/3]

static bool flutter::testing::ReadbackResult ( PrerollContext context,
Clip  clip_behavior,
const std::shared_ptr< Layer > &  child,
bool  before 
)
static

Definition at line 242 of file clip_rrect_layer_unittests.cc.

245 {
246 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
247 const SkRRect layer_rrect = SkRRect::MakeRect(layer_bounds);
248 auto layer = std::make_shared<ClipRRectLayer>(layer_rrect, clip_behavior);
249 if (child != nullptr) {
250 layer->Add(child);
251 }
252 context->surface_needs_readback = before;
253 layer->Preroll(context);
254 return context->surface_needs_readback;
255}
static SkRRect MakeRect(const SkRect &r)
Definition SkRRect.h:149

◆ ResetAssetManager()

static void flutter::testing::ResetAssetManager ( )
static

Definition at line 33 of file persistent_cache_unittests.cc.

33 {
34 PersistentCache::SetAssetManager(nullptr);
35 ASSERT_EQ(PersistentCache::GetCacheForProcess()->LoadSkSLs().size(), 0u);
36}

◆ RunDartCodeInIsolate() [1/2]

std::unique_ptr< AutoIsolateShutdown > flutter::testing::RunDartCodeInIsolate ( DartVMRef vm_ref,
const Settings settings,
const TaskRunners task_runners,
std::string  entrypoint,
const std::vector< std::string > &  args,
const std::string &  kernel_file_path,
fml::WeakPtr< IOManager io_manager,
std::shared_ptr< VolatilePathTracker volatile_path_tracker,
std::unique_ptr< PlatformConfiguration platform_configuration 
)

Definition at line 155 of file dart_isolate_runner.cc.

164 {
165 std::unique_ptr<AutoIsolateShutdown> result;
168 task_runners.GetUITaskRunner(), fml::MakeCopyable([&]() mutable {
169 result = RunDartCodeInIsolateOnUITaskRunner(
170 vm_ref, settings, task_runners, entrypoint, args, kernel_file_path,
171 io_manager, volatile_path_tracker,
172 std::move(platform_configuration));
173 latch.Signal();
174 }));
175 latch.Wait();
176 return result;
177}
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
internal::CopyableLambda< T > MakeCopyable(T lambda)

◆ RunDartCodeInIsolate() [2/2]

void flutter::testing::RunDartCodeInIsolate ( DartVMRef vm_ref,
std::unique_ptr< AutoIsolateShutdown > &  result,
const Settings settings,
const TaskRunners task_runners,
std::string  entrypoint,
const std::vector< std::string > &  args,
const std::string &  fixtures_path,
fml::WeakPtr< IOManager io_manager = {},
std::shared_ptr< VolatilePathTracker volatile_path_tracker = nullptr,
std::unique_ptr< PlatformConfiguration platform_configuration = nullptr 
)

◆ RunDartCodeInIsolateOnUITaskRunner()

std::unique_ptr< AutoIsolateShutdown > flutter::testing::RunDartCodeInIsolateOnUITaskRunner ( DartVMRef vm_ref,
const Settings p_settings,
const TaskRunners task_runners,
std::string  entrypoint,
const std::vector< std::string > &  args,
const std::string &  kernel_file_path,
fml::WeakPtr< IOManager io_manager,
const std::shared_ptr< VolatilePathTracker > &  volatile_path_tracker,
std::unique_ptr< PlatformConfiguration platform_configuration 
)

Definition at line 67 of file dart_isolate_runner.cc.

76 {
78
79 if (!vm_ref) {
80 return nullptr;
81 }
82
83 auto vm_data = vm_ref.GetVMData();
84
85 if (!vm_data) {
86 return nullptr;
87 }
88
89 auto settings = p_settings;
90
91 if (!DartVM::IsRunningPrecompiledCode()) {
92 if (!fml::IsFile(kernel_file_path)) {
93 FML_LOG(ERROR) << "Could not locate kernel file.";
94 return nullptr;
95 }
96
97 auto kernel_file = fml::OpenFile(kernel_file_path.c_str(), false,
99
100 if (!kernel_file.is_valid()) {
101 FML_LOG(ERROR) << "Kernel file descriptor was invalid.";
102 return nullptr;
103 }
104
105 auto kernel_mapping = std::make_unique<fml::FileMapping>(kernel_file);
106
107 if (kernel_mapping->GetMapping() == nullptr) {
108 FML_LOG(ERROR) << "Could not set up kernel mapping.";
109 return nullptr;
110 }
111
112 settings.application_kernels = fml::MakeCopyable(
113 [kernel_mapping = std::move(kernel_mapping)]() mutable -> Mappings {
114 Mappings mappings;
115 mappings.emplace_back(std::move(kernel_mapping));
116 return mappings;
117 });
118 }
119
120 auto isolate_configuration =
121 IsolateConfiguration::InferFromSettings(settings);
122
123 UIDartState::Context context(task_runners);
124 context.io_manager = std::move(io_manager);
125 context.advisory_script_uri = "main.dart";
126 context.advisory_script_entrypoint = entrypoint.c_str();
127 context.enable_impeller = p_settings.enable_impeller;
128
129 auto isolate =
130 DartIsolate::CreateRunningRootIsolate(
131 settings, // settings
132 vm_data->GetIsolateSnapshot(), // isolate snapshot
133 std::move(platform_configuration), // platform configuration
134 DartIsolate::Flags{}, // flags
135 nullptr, // root isolate create callback
136 settings.isolate_create_callback, // isolate create callback
137 settings.isolate_shutdown_callback, // isolate shutdown callback
138 entrypoint, // entrypoint
139 std::nullopt, // library
140 args, // args
141 std::move(isolate_configuration), // isolate configuration
142 context // engine context
143 )
144 .lock();
145
146 if (!isolate) {
147 FML_LOG(ERROR) << "Could not create running isolate.";
148 return nullptr;
149 }
150
151 return std::make_unique<AutoIsolateShutdown>(
152 isolate, context.task_runners.GetUITaskRunner());
153}
static std::shared_ptr< const DartVMData > GetVMData()
virtual bool RunsTasksOnCurrentThread()
std::vector< std::unique_ptr< const fml::Mapping > > Mappings
Definition settings.h:94

◆ SetArgsForProcess()

void flutter::testing::SetArgsForProcess ( int  argc,
char **  argv 
)

Definition at line 16 of file test_args.cc.

16 {
18}
CommandLine CommandLineFromArgcArgv(int argc, const char *const *argv)

◆ ShaderLibraryMappings()

static std::vector< std::shared_ptr< fml::Mapping > > flutter::testing::ShaderLibraryMappings ( )
static

Definition at line 21 of file shell_test_platform_view_gl.cc.

21 {
22 return {
23 std::make_shared<fml::NonOwnedMapping>(
24 impeller_entity_shaders_gles_data,
25 impeller_entity_shaders_gles_length),
26#if IMPELLER_ENABLE_3D
27 std::make_shared<fml::NonOwnedMapping>(
28 impeller_scene_shaders_gles_data, impeller_scene_shaders_gles_length),
29#endif
30 };
31}

◆ SurfacePixelDataMatchesBytes() [1/2]

bool flutter::testing::SurfacePixelDataMatchesBytes ( SkSurface surface,
const std::vector< uint8_t > &  bytes 
)

Definition at line 215 of file embedder_unittests_util.cc.

216 {
217 SkPixmap pixmap;
218 auto ok = surface->peekPixels(&pixmap);
219 if (!ok) {
220 return false;
221 }
222
223 auto matches = (pixmap.rowBytes() == bytes.size()) &&
224 (memcmp(bytes.data(), pixmap.addr(), bytes.size()) == 0);
225
226 if (!matches) {
227 FML_LOG(ERROR) << "SkImage pixel data didn't match bytes.";
228
229 {
230 const uint8_t* addr = static_cast<const uint8_t*>(pixmap.addr());
231 std::stringstream stream;
232 for (size_t i = 0; i < pixmap.computeByteSize(); ++i) {
233 stream << "0x" << std::setfill('0') << std::setw(2) << std::uppercase
234 << std::hex << static_cast<int>(addr[i]);
235 if (i != pixmap.computeByteSize() - 1) {
236 stream << ", ";
237 }
238 }
239 FML_LOG(ERROR) << " Actual: " << stream.str();
240 }
241 {
242 std::stringstream stream;
243 for (auto b = bytes.begin(); b != bytes.end(); ++b) {
244 stream << "0x" << std::setfill('0') << std::setw(2) << std::uppercase
245 << std::hex << static_cast<int>(*b);
246 if (b != bytes.end() - 1) {
247 stream << ", ";
248 }
249 }
250 FML_LOG(ERROR) << " Expected: " << stream.str();
251 }
252 }
253
254 return matches;
255}
static bool ok(int result)
size_t rowBytes() const
Definition SkPixmap.h:145
size_t computeByteSize() const
Definition SkPixmap.h:231
const void * addr() const
Definition SkPixmap.h:153

◆ SurfacePixelDataMatchesBytes() [2/2]

bool flutter::testing::SurfacePixelDataMatchesBytes ( std::future< SkSurface * > &  surface_future,
const std::vector< uint8_t > &  bytes 
)

Definition at line 257 of file embedder_unittests_util.cc.

258 {
259 return SurfacePixelDataMatchesBytes(surface_future.get(), bytes);
260}

◆ SW_PIXFMT_TEST_F() [1/15]

flutter::testing::SW_PIXFMT_TEST_F ( BlueBGRA8888xFFx00x00xFF  ,
draw_solid_blue  ,
kFlutterSoftwarePixelFormatBGRA8888  ,
(std::vector< uint8_t >{0xFF, 0x00, 0x00, 0xFF})   
)

◆ SW_PIXFMT_TEST_F() [2/15]

flutter::testing::SW_PIXFMT_TEST_F ( BlueGray8x12  ,
draw_solid_blue  ,
kFlutterSoftwarePixelFormatGray8  ,
(uint8_t)  0x12 
)

◆ SW_PIXFMT_TEST_F() [3/15]

flutter::testing::SW_PIXFMT_TEST_F ( BlueRGB565x001F  ,
draw_solid_blue  ,
kFlutterSoftwarePixelFormatRGB565  ,
(uint16_t)  0x001F 
)

◆ SW_PIXFMT_TEST_F() [4/15]

flutter::testing::SW_PIXFMT_TEST_F ( BlueRGBA4444x00FF  ,
draw_solid_blue  ,
kFlutterSoftwarePixelFormatRGBA4444  ,
(uint16_t)  0x00FF 
)

◆ SW_PIXFMT_TEST_F() [5/15]

flutter::testing::SW_PIXFMT_TEST_F ( BlueRGBA8888x00x00xFFxFF  ,
draw_solid_blue  ,
kFlutterSoftwarePixelFormatRGBA8888  ,
(std::vector< uint8_t >{0x00, 0x00, 0xFF, 0xFF})   
)

◆ SW_PIXFMT_TEST_F() [6/15]

flutter::testing::SW_PIXFMT_TEST_F ( GreenBGRA8888x00xFFx00xFF  ,
draw_solid_green  ,
kFlutterSoftwarePixelFormatBGRA8888  ,
(std::vector< uint8_t >{0x00, 0xFF, 0x00, 0xFF})   
)

◆ SW_PIXFMT_TEST_F() [7/15]

flutter::testing::SW_PIXFMT_TEST_F ( GreenGray8xB6  ,
draw_solid_green  ,
kFlutterSoftwarePixelFormatGray8  ,
(uint8_t)  0xB6 
)

◆ SW_PIXFMT_TEST_F() [8/15]

flutter::testing::SW_PIXFMT_TEST_F ( GreenRGB565x07E0  ,
draw_solid_green  ,
kFlutterSoftwarePixelFormatRGB565  ,
(uint16_t)  0x07E0 
)

◆ SW_PIXFMT_TEST_F() [9/15]

flutter::testing::SW_PIXFMT_TEST_F ( GreenRGBA4444x0F0F  ,
draw_solid_green  ,
kFlutterSoftwarePixelFormatRGBA4444  ,
(uint16_t)  0x0F0F 
)

◆ SW_PIXFMT_TEST_F() [10/15]

flutter::testing::SW_PIXFMT_TEST_F ( GreenRGBA8888x00xFFx00xFF  ,
draw_solid_green  ,
kFlutterSoftwarePixelFormatRGBA8888  ,
(std::vector< uint8_t >{0x00, 0xFF, 0x00, 0xFF})   
)

◆ SW_PIXFMT_TEST_F() [11/15]

flutter::testing::SW_PIXFMT_TEST_F ( RedBGRA8888x00x00xFFxFF  ,
draw_solid_red  ,
kFlutterSoftwarePixelFormatBGRA8888  ,
(std::vector< uint8_t >{0x00, 0x00, 0xFF, 0xFF})   
)

◆ SW_PIXFMT_TEST_F() [12/15]

flutter::testing::SW_PIXFMT_TEST_F ( RedGray8x36  ,
draw_solid_red  ,
kFlutterSoftwarePixelFormatGray8  ,
(uint8_t)  0x36 
)

◆ SW_PIXFMT_TEST_F() [13/15]

flutter::testing::SW_PIXFMT_TEST_F ( RedRGBA4444xF00F  ,
draw_solid_red  ,
kFlutterSoftwarePixelFormatRGBA4444  ,
(uint16_t)  0xF00F 
)

◆ SW_PIXFMT_TEST_F() [14/15]

flutter::testing::SW_PIXFMT_TEST_F ( RedRGBA565xF800  ,
draw_solid_red  ,
kFlutterSoftwarePixelFormatRGB565  ,
(uint16_t)  0xF800 
)

◆ SW_PIXFMT_TEST_F() [15/15]

flutter::testing::SW_PIXFMT_TEST_F ( RedRGBA8888xFFx00x00xFF  ,
draw_solid_red  ,
kFlutterSoftwarePixelFormatRGBA8888  ,
(std::vector< uint8_t >{0xFF, 0x00, 0x00, 0xFF})   
)

◆ TEST() [1/709]

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}
flutter::FakeDelegate fake_delegate

◆ TEST() [2/709]

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}
FlutterSemanticsNode2 CreateSemanticsNode(int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)

◆ TEST() [3/709]

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();
553 ASSERT_EQ(manager, static_cast<ui::AXTreeManager*>(bridge.get()));
554}
AXTreeManager * GetManager(AXTreeID tree_id)
static AXTreeManagerMap & GetInstance()
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
Definition switches.h:218

◆ TEST() [4/709]

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}

◆ TEST() [5/709]

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}
bool Contains(const Container &container, const Value &value)

◆ TEST() [6/709]

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>();
212 root.flags = static_cast<FlutterSemanticsFlag>(
215 bridge->AddFlutterSemanticsNodeUpdate(root);
216 bridge->CommitUpdates();
217
218 const ui::AXTreeData& tree = bridge->GetAXTreeData();
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}
static constexpr AXID kInvalidAXID
Definition ax_node.h:41
@ kFlutterSemanticsFlagIsFocused
Whether the semantic node currently holds the user's focus.
Definition embedder.h:183
@ kFlutterSemanticsFlagIsTextField
Whether the semantic node represents a text field.
Definition embedder.h:181
AXNode::AXID sel_anchor_object_id
AXNode::AXID sel_focus_object_id
int32_t sel_focus_offset
int32_t sel_anchor_offset

◆ TEST() [7/709]

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};
387 CreateSemanticsNode(root_id, "root", &root_children);
389 intermediary1_id, "intermediary 1", &intermediary1_children);
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}
const int32_t * children_in_traversal_order
Array of child node IDs in traversal order. Has length child_count.
Definition embedder.h:1383
size_t child_count
The number of children this node has.
Definition embedder.h:1381

◆ TEST() [8/709]

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}

◆ TEST() [9/709]

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

◆ TEST() [10/709]

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>();
296 root.flags = static_cast<FlutterSemanticsFlag>(
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(),
306}
@ kFlutterSemanticsFlagIsChecked
Whether a semantics node is checked.
Definition embedder.h:175
@ kFlutterSemanticsFlagHasCheckedState
Definition embedder.h:173

◆ TEST() [11/709]

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>();
244 root.flags = static_cast<FlutterSemanticsFlag>(
247 bridge->AddFlutterSemanticsNodeUpdate(root);
248 bridge->CommitUpdates();
249
250 auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
251
252 EXPECT_FALSE(root_node->GetData().GetBoolAttribute(
254}
@ kFlutterSemanticsFlagIsReadOnly
Definition embedder.h:228

◆ TEST() [12/709]

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(
571 EXPECT_TRUE(root_data.GetBoolAttribute(
573}

◆ TEST() [13/709]

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>();
275 root.flags = static_cast<FlutterSemanticsFlag>(
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}
@ kFlutterSemanticsFlagIsSlider
Whether the semantics node represents a slider.
Definition embedder.h:234
@ kFlutterSemanticsFlagIsEnabled
Whether a semantic node that hasEnabledState is currently enabled.
Definition embedder.h:188
@ kFlutterSemanticsFlagIsFocusable
Whether the semantic node can hold the user's focus.
Definition embedder.h:230
@ kFlutterSemanticsFlagHasEnabledState
Definition embedder.h:186

◆ TEST() [14/709]

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>();
260 root.flags = static_cast<FlutterSemanticsFlag>(
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}
@ kFlutterSemanticsFlagHasToggledState
The semantics node has the quality of either being "on" or "off".
Definition embedder.h:207

◆ TEST() [15/709]

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
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}
@ kFlutterSemanticsActionCopy
Copy the current selection to the clipboard.
Definition embedder.h:146
@ kFlutterSemanticsActionTap
Definition embedder.h:116
#define MOCK_ENGINE_PROC(proc, mock_impl)

◆ TEST() [16/709]

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

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

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

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

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,
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/709]

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

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

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

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

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

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

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

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

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

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

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

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

flutter::testing::TEST ( AndroidContextGLImpeller  ,
FallbackForEmulator   
)

Definition at line 57 of file android_context_gl_impeller_unittests.cc.

57 {
58 auto display = std::make_unique<MockDisplay>();
59 EXPECT_CALL(*display, IsValid).WillRepeatedly(Return(true));
60 std::unique_ptr<Config> first_result;
61 auto second_result =
62 std::make_unique<Config>(ConfigDescriptor(), EGLConfig());
63 auto third_result = std::make_unique<Config>(ConfigDescriptor(), EGLConfig());
64 EXPECT_CALL(
65 *display,
66 ChooseConfig(Matcher<ConfigDescriptor>(AllOf(
67 Field(&ConfigDescriptor::samples, impeller::egl::Samples::kFour),
68 Field(&ConfigDescriptor::surface_type,
70 .WillOnce(Return(ByMove(std::move(first_result))));
71 EXPECT_CALL(
72 *display,
73 ChooseConfig(Matcher<ConfigDescriptor>(
74 AllOf(Field(&ConfigDescriptor::samples, impeller::egl::Samples::kOne),
75 Field(&ConfigDescriptor::surface_type,
77 .WillOnce(Return(ByMove(std::move(second_result))));
78 EXPECT_CALL(*display, ChooseConfig(Matcher<ConfigDescriptor>(
79 Field(&ConfigDescriptor::surface_type,
81 .WillOnce(Return(ByMove(std::move(third_result))));
82 ON_CALL(*display, ChooseConfig(_))
83 .WillByDefault(Return(ByMove(std::unique_ptr<Config>())));
84 auto context =
85 std::make_unique<AndroidContextGLImpeller>(std::move(display), true);
86 ASSERT_TRUE(context);
87}

◆ TEST() [34/709]

flutter::testing::TEST ( AndroidContextGLImpeller  ,
MSAAFirstAttempt   
)

Definition at line 33 of file android_context_gl_impeller_unittests.cc.

33 {
34 auto display = std::make_unique<MockDisplay>();
35 EXPECT_CALL(*display, IsValid).WillRepeatedly(Return(true));
36 auto first_result = std::make_unique<Config>(ConfigDescriptor(), EGLConfig());
37 auto second_result =
38 std::make_unique<Config>(ConfigDescriptor(), EGLConfig());
39 EXPECT_CALL(
40 *display,
41 ChooseConfig(Matcher<ConfigDescriptor>(AllOf(
42 Field(&ConfigDescriptor::samples, impeller::egl::Samples::kFour),
43 Field(&ConfigDescriptor::surface_type,
45 .WillOnce(Return(ByMove(std::move(first_result))));
46 EXPECT_CALL(*display, ChooseConfig(Matcher<ConfigDescriptor>(
47 Field(&ConfigDescriptor::surface_type,
49 .WillOnce(Return(ByMove(std::move(second_result))));
50 ON_CALL(*display, ChooseConfig(_))
51 .WillByDefault(Return(ByMove(std::unique_ptr<Config>())));
52 auto context =
53 std::make_unique<AndroidContextGLImpeller>(std::move(display), true);
54 ASSERT_TRUE(context);
55}

◆ TEST() [35/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
CancelFrame   
)

Definition at line 125 of file external_view_embedder_unittests.cc.

125 {
126 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
127 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
128 android_context, nullptr, nullptr, GetTaskRunnersForFixture());
129
130 embedder->PrerollCompositeEmbeddedView(
131 0, std::make_unique<EmbeddedViewParams>());
132 embedder->CancelFrame();
133
134 ASSERT_EQ(embedder->CompositeEmbeddedView(0), nullptr);
135}
Holds state that is shared across Android surfaces.

◆ TEST() [36/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
CompositeEmbeddedView   
)

Definition at line 109 of file external_view_embedder_unittests.cc.

109 {
110 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
111 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
112 android_context, nullptr, nullptr, GetTaskRunnersForFixture());
113
114 ASSERT_EQ(nullptr, embedder->CompositeEmbeddedView(0));
115 embedder->PrerollCompositeEmbeddedView(
116 0, std::make_unique<EmbeddedViewParams>());
117 ASSERT_NE(nullptr, embedder->CompositeEmbeddedView(0));
118
119 ASSERT_EQ(nullptr, embedder->CompositeEmbeddedView(1));
120 embedder->PrerollCompositeEmbeddedView(
121 1, std::make_unique<EmbeddedViewParams>());
122 ASSERT_NE(nullptr, embedder->CompositeEmbeddedView(1));
123}

◆ TEST() [37/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
DestroyOverlayLayersOnSizeChange   
)

Definition at line 767 of file external_view_embedder_unittests.cc.

767 {
768 auto jni_mock = std::make_shared<JNIMock>();
769
770 auto android_context =
771 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
772 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
773 auto gr_context = GrDirectContext::MakeMock(nullptr);
774 auto frame_size = SkISize::Make(1000, 1000);
775 SurfaceFrame::FramebufferInfo framebuffer_info;
776 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
777 [gr_context, window, frame_size, framebuffer_info]() {
778 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
779 SkSurfaces::Null(1000, 1000), framebuffer_info,
780 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
781 return true;
782 },
783 /*frame_size=*/SkISize::Make(800, 600));
784
785 auto surface_mock = std::make_unique<SurfaceMock>();
786 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
787 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
788
789 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
790 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
791
792 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
793 .WillOnce(Return(ByMove(std::move(surface_mock))));
794
795 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
796
797 return android_surface_mock;
798 });
799
800 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
801 *android_context, jni_mock, surface_factory, GetTaskRunnersForFixture());
802 fml::Thread rasterizer_thread("rasterizer");
803 auto raster_thread_merger =
804 GetThreadMergerFromPlatformThread(&rasterizer_thread);
805
806 // ------------------ First frame ------------------ //
807 {
808 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
809 embedder->BeginFrame(nullptr, raster_thread_merger);
810 embedder->PrepareFlutterView(frame_size, 1.5);
811
812 // Add an Android view.
813 MutatorsStack stack1;
814 // TODO(egarciad): Investigate why Flow applies the device pixel ratio to
815 // the offsetPixels, but not the sizePoints.
816 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
817 SkMatrix(), SkSize::Make(200, 200), stack1);
818
819 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
820
821 // This simulates Flutter UI that intersects with the Android view.
822 embedder->CompositeEmbeddedView(0)->DrawRect(
823 SkRect::MakeXYWH(50, 50, 200, 200), DlPaint());
824
825 // Create a new overlay surface.
826 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
827 .WillOnce(Return(
828 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
829 0, window))));
830 // The JNI call to display the Android view.
831 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
832 300, 300, stack1));
833 EXPECT_CALL(*jni_mock,
834 FlutterViewDisplayOverlaySurface(0, 50, 50, 150, 150));
835
836 SurfaceFrame::FramebufferInfo framebuffer_info;
837 auto surface_frame = std::make_unique<SurfaceFrame>(
838 SkSurfaces::Null(1000, 1000), framebuffer_info,
839 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
840 return true;
841 },
842 /*frame_size=*/SkISize::Make(800, 600));
843 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
844 std::move(surface_frame));
845
846 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
847 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
848 }
849
850 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces());
851 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
852 // Change the frame size.
853 embedder->BeginFrame(nullptr, raster_thread_merger);
854 embedder->PrepareFlutterView(SkISize::Make(30, 40), 1.0);
855}
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:37
GLFWwindow * window
Definition main.cc:45
static constexpr FlutterViewId kImplicitViewId
SK_API sk_sp< SkSurface > Null(int width, int height)
static constexpr SkSize Make(SkScalar w, SkScalar h)
Definition SkSize.h:56

◆ TEST() [38/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
DisableThreadMerger   
)

Definition at line 956 of file external_view_embedder_unittests.cc.

956 {
957 auto jni_mock = std::make_shared<JNIMock>();
958 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
959 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
960 android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
961
962 fml::Thread platform_thread("platform");
963 auto raster_thread_merger = GetThreadMergerFromRasterThread(&platform_thread);
964 ASSERT_FALSE(raster_thread_merger->IsMerged());
965
966 // The shell may disable the thread merger during `OnPlatformViewDestroyed`.
967 raster_thread_merger->Disable();
968
969 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0);
970
971 embedder->BeginFrame(nullptr, raster_thread_merger);
972 embedder->PrepareFlutterView(SkISize::Make(10, 20), 1.0);
973 // Push a platform view.
974 embedder->PrerollCompositeEmbeddedView(
975 0, std::make_unique<EmbeddedViewParams>());
976
977 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
978 ASSERT_EQ(PostPrerollResult::kSkipAndRetryFrame, postpreroll_result);
979
980 EXPECT_CALL(*jni_mock, FlutterViewEndFrame()).Times(0);
981 embedder->EndFrame(/*should_resubmit_frame=*/true, raster_thread_merger);
982
983 ASSERT_FALSE(raster_thread_merger->IsMerged());
984}
fml::RefPtr< fml::RasterThreadMerger > GetThreadMergerFromRasterThread(fml::Thread *platform_thread)

◆ TEST() [39/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
DoesNotCallJNIPlatformThreadOnlyMethods   
)

Definition at line 747 of file external_view_embedder_unittests.cc.

747 {
748 auto jni_mock = std::make_shared<JNIMock>();
749
750 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
751 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
752 android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
753
754 // While on the raster thread, don't make JNI calls as these methods can only
755 // run on the platform thread.
756 fml::Thread platform_thread("platform");
757 auto raster_thread_merger = GetThreadMergerFromRasterThread(&platform_thread);
758
759 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0);
760 embedder->BeginFrame(nullptr, raster_thread_merger);
761 embedder->PrepareFlutterView(SkISize::Make(10, 20), 1.0);
762
763 EXPECT_CALL(*jni_mock, FlutterViewEndFrame()).Times(0);
764 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
765}

◆ TEST() [40/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
DoesNotDestroyOverlayLayersOnSizeChange   
)

Definition at line 857 of file external_view_embedder_unittests.cc.

857 {
858 auto jni_mock = std::make_shared<JNIMock>();
859 auto android_context =
860 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
861
862 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
863 auto gr_context = GrDirectContext::MakeMock(nullptr);
864 auto frame_size = SkISize::Make(1000, 1000);
865 SurfaceFrame::FramebufferInfo framebuffer_info;
866 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
867 [gr_context, window, frame_size, framebuffer_info]() {
868 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
869 SkSurfaces::Null(1000, 1000), framebuffer_info,
870 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
871 return true;
872 },
873 /*frame_size=*/SkISize::Make(800, 600));
874
875 auto surface_mock = std::make_unique<SurfaceMock>();
876 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
877 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
878
879 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
880 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
881
882 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
883 .WillOnce(Return(ByMove(std::move(surface_mock))));
884
885 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
886
887 return android_surface_mock;
888 });
889
890 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
891 *android_context, jni_mock, surface_factory, GetTaskRunnersForFixture());
892
893 // ------------------ First frame ------------------ //
894 {
895 fml::Thread rasterizer_thread("rasterizer");
896 auto raster_thread_merger =
897 GetThreadMergerFromPlatformThread(&rasterizer_thread);
898 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
899 embedder->BeginFrame(nullptr, raster_thread_merger);
900 embedder->PrepareFlutterView(frame_size, 1.5);
901
902 // Add an Android view.
903 MutatorsStack stack1;
904 // TODO(egarciad): Investigate why Flow applies the device pixel ratio to
905 // the offsetPixels, but not the sizePoints.
906 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
907 SkMatrix(), SkSize::Make(200, 200), stack1);
908
909 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
910
911 // This simulates Flutter UI that intersects with the Android view.
912 embedder->CompositeEmbeddedView(0)->DrawRect(
913 SkRect::MakeXYWH(50, 50, 200, 200), DlPaint());
914
915 // Create a new overlay surface.
916 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
917 .WillOnce(Return(
918 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
919 0, window))));
920 // The JNI call to display the Android view.
921 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
922 300, 300, stack1));
923 EXPECT_CALL(*jni_mock,
924 FlutterViewDisplayOverlaySurface(0, 50, 50, 150, 150));
925
926 auto surface_frame = std::make_unique<SurfaceFrame>(
927 SkSurfaces::Null(1000, 1000), framebuffer_info,
928 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
929 return true;
930 },
931 /*frame_size=*/SkISize::Make(800, 600));
932 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
933 std::move(surface_frame));
934
935 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
936 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
937 }
938
939 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(1);
940 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0);
941
942 fml::Thread platform_thread("platform");
943 embedder->BeginFrame(nullptr,
944 GetThreadMergerFromRasterThread(&platform_thread));
945 embedder->PrepareFlutterView(SkISize::Make(30, 40), 1.0);
946}

◆ TEST() [41/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
OverlayCoverTwoPlatformViews   
)

Definition at line 469 of file external_view_embedder_unittests.cc.

469 {
470 // In this test we will simulate two Android views appearing on the screen
471 // with a rect intersecting both of them
472
473 auto jni_mock = std::make_shared<JNIMock>();
474 auto android_context =
475 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
476
477 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
478 auto gr_context = GrDirectContext::MakeMock(nullptr);
479 auto frame_size = SkISize::Make(1000, 1000);
480 SurfaceFrame::FramebufferInfo framebuffer_info;
481 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
482 [gr_context, window, frame_size, framebuffer_info]() {
483 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
484 SkSurfaces::Null(1000, 1000), framebuffer_info,
485 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
486 return true;
487 },
488 /*frame_size=*/SkISize::Make(800, 600));
489
490 auto surface_mock = std::make_unique<SurfaceMock>();
491 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
492 .Times(1 /* frames */)
493 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
494
495 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
496 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
497
498 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
499 .WillOnce(Return(ByMove(std::move(surface_mock))));
500
501 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
502 return android_surface_mock;
503 });
504 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
505 *android_context, jni_mock, surface_factory, GetTaskRunnersForFixture());
506
507 auto raster_thread_merger = GetThreadMergerFromPlatformThread();
508
509 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
510 embedder->BeginFrame(nullptr, raster_thread_merger);
511 embedder->PrepareFlutterView(frame_size, 1.5);
512
513 {
514 // Add first Android view.
515 SkMatrix matrix = SkMatrix::Translate(100, 100);
516 MutatorsStack stack;
517 embedder->PrerollCompositeEmbeddedView(
518 0, std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(100, 100),
519 stack));
520 // The JNI call to display the Android view.
521 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
522 0, 100, 100, 100, 100, 150, 150, stack));
523 }
524
525 {
526 // Add second Android view.
528 MutatorsStack stack;
529 embedder->PrerollCompositeEmbeddedView(
530 1, std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(100, 100),
531 stack));
532 // The JNI call to display the Android view.
533 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
534 1, 300, 100, 100, 100, 150, 150, stack));
535 }
536 auto rect_paint = DlPaint();
537 rect_paint.setColor(DlColor::kCyan());
538 rect_paint.setDrawStyle(DlDrawStyle::kFill);
539
540 // This simulates Flutter UI that intersects with the two Android views.
541 // Since we will compute the intersection for each android view in turn, and
542 // finally merge The final size of the overlay will be smaller than the
543 // width and height of the rect.
544 embedder->CompositeEmbeddedView(1)->DrawRect(
545 SkRect::MakeXYWH(150, 50, 200, 200), rect_paint);
546
547 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
548 .WillRepeatedly([&]() {
549 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
550 1, window);
551 });
552
553 // The JNI call to display the overlay surface.
554 EXPECT_CALL(*jni_mock,
555 FlutterViewDisplayOverlaySurface(1, 150, 100, 200, 100))
556 .Times(1);
557
558 auto surface_frame = std::make_unique<SurfaceFrame>(
559 SkSurfaces::Null(1000, 1000), framebuffer_info,
560 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) mutable {
561 return true;
562 },
563 /*frame_size=*/SkISize::Make(800, 600));
564
565 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
566 std::move(surface_frame));
567
568 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
569 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
570}
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258

◆ TEST() [42/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
PlatformViewRect   
)

Definition at line 192 of file external_view_embedder_unittests.cc.

192 {
193 auto jni_mock = std::make_shared<JNIMock>();
194
195 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
196 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
197 android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
198 fml::Thread rasterizer_thread("rasterizer");
199 auto raster_thread_merger =
200 GetThreadMergerFromPlatformThread(&rasterizer_thread);
201
202 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
203 embedder->BeginFrame(nullptr, raster_thread_merger);
204 embedder->PrepareFlutterView(SkISize::Make(100, 100), 1.5);
205
206 MutatorsStack stack;
207 SkMatrix matrix;
208 matrix.setIdentity();
209 // The framework always push a scale matrix based on the screen ratio.
210 matrix.setConcat(matrix, SkMatrix::Scale(1.5, 1.5));
211 matrix.setConcat(matrix, SkMatrix::Translate(10, 20));
212 auto view_params =
213 std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(30, 40), stack);
214
215 auto view_id = 0;
216 embedder->PrerollCompositeEmbeddedView(view_id, std::move(view_params));
217 ASSERT_EQ(SkRect::MakeXYWH(15, 30, 45, 60), embedder->GetViewRect(view_id));
218}
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition SkMatrix.h:75
fml::RefPtr< fml::RasterThreadMerger > GetThreadMergerFromPlatformThread(fml::Thread *rasterizer_thread=nullptr)

◆ TEST() [43/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
PlatformViewRectChangedParams   
)

Definition at line 220 of file external_view_embedder_unittests.cc.

220 {
221 auto jni_mock = std::make_shared<JNIMock>();
222
223 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
224 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
225 android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
226 fml::Thread rasterizer_thread("rasterizer");
227 auto raster_thread_merger =
228 GetThreadMergerFromPlatformThread(&rasterizer_thread);
229
230 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
231 embedder->BeginFrame(nullptr, raster_thread_merger);
232 embedder->PrepareFlutterView(SkISize::Make(100, 100), 1.5);
233
234 auto view_id = 0;
235
236 MutatorsStack stack1;
237 SkMatrix matrix1;
238 matrix1.setIdentity();
239 // The framework always push a scale matrix based on the screen ratio.
240 matrix1.setConcat(SkMatrix::Scale(1.5, 1.5), SkMatrix::Translate(10, 20));
241 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
242 matrix1, SkSize::Make(30, 40), stack1);
243
244 embedder->PrerollCompositeEmbeddedView(view_id, std::move(view_params_1));
245
246 MutatorsStack stack2;
247 SkMatrix matrix2;
248 matrix2.setIdentity();
249 // The framework always push a scale matrix based on the screen ratio.
250 matrix2.setConcat(matrix2, SkMatrix::Scale(1.5, 1.5));
251 matrix2.setConcat(matrix2, SkMatrix::Translate(50, 60));
252 auto view_params_2 = std::make_unique<EmbeddedViewParams>(
253 matrix2, SkSize::Make(70, 80), stack2);
254
255 embedder->PrerollCompositeEmbeddedView(view_id, std::move(view_params_2));
256
257 ASSERT_EQ(SkRect::MakeXYWH(75, 90, 105, 120), embedder->GetViewRect(view_id));
258}
SkMatrix & setIdentity()
Definition SkMatrix.h:626
SkMatrix & setConcat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.cpp:603

◆ TEST() [44/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
RasterizerRunsOnPlatformThread   
)

Definition at line 137 of file external_view_embedder_unittests.cc.

137 {
138 auto jni_mock = std::make_shared<JNIMock>();
139 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
140 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
141 android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
142
143 fml::Thread rasterizer_thread("rasterizer");
144 auto raster_thread_merger =
145 GetThreadMergerFromPlatformThread(&rasterizer_thread);
146 ASSERT_FALSE(raster_thread_merger->IsMerged());
147
148 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
149 embedder->BeginFrame(nullptr, raster_thread_merger);
150 embedder->PrepareFlutterView(SkISize::Make(10, 20), 1.0);
151
152 // Push a platform view.
153 embedder->PrerollCompositeEmbeddedView(
154 0, std::make_unique<EmbeddedViewParams>());
155
156 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
157 ASSERT_EQ(PostPrerollResult::kSkipAndRetryFrame, postpreroll_result);
158
159 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
160 embedder->EndFrame(/*should_resubmit_frame=*/true, raster_thread_merger);
161
162 ASSERT_TRUE(raster_thread_merger->IsMerged());
163
164 int pending_frames = 0;
165 while (raster_thread_merger->IsMerged()) {
166 raster_thread_merger->DecrementLease();
167 pending_frames++;
168 }
169 ASSERT_EQ(10, pending_frames); // kDefaultMergedLeaseDuration
170}

◆ TEST() [45/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
RasterizerRunsOnRasterizerThread   
)

Definition at line 172 of file external_view_embedder_unittests.cc.

172 {
173 auto jni_mock = std::make_shared<JNIMock>();
174 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
175 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
176 android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
177
178 fml::Thread rasterizer_thread("rasterizer");
179 auto raster_thread_merger =
180 GetThreadMergerFromPlatformThread(&rasterizer_thread);
181 ASSERT_FALSE(raster_thread_merger->IsMerged());
182
183 PostPrerollResult result = embedder->PostPrerollAction(raster_thread_merger);
184 ASSERT_EQ(PostPrerollResult::kSuccess, result);
185
186 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
187 embedder->EndFrame(/*should_resubmit_frame=*/true, raster_thread_merger);
188
189 ASSERT_FALSE(raster_thread_merger->IsMerged());
190}

◆ TEST() [46/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
SubmitFlutterView   
)

Definition at line 260 of file external_view_embedder_unittests.cc.

260 {
261 auto jni_mock = std::make_shared<JNIMock>();
262 auto android_context =
263 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
264
265 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
266 auto gr_context = GrDirectContext::MakeMock(nullptr);
267 auto frame_size = SkISize::Make(1000, 1000);
268 SurfaceFrame::FramebufferInfo framebuffer_info;
269 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
270 [gr_context, window, frame_size, framebuffer_info]() {
271 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
272 SkSurfaces::Null(1000, 1000), framebuffer_info,
273 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
274 return true;
275 },
276 /*frame_size=*/SkISize::Make(800, 600));
277 auto surface_frame_2 = std::make_unique<SurfaceFrame>(
278 SkSurfaces::Null(1000, 1000), framebuffer_info,
279 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
280 return true;
281 },
282 /*frame_size=*/SkISize::Make(800, 600));
283
284 auto surface_mock = std::make_unique<SurfaceMock>();
285 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
286 .Times(2 /* frames */)
287 .WillOnce(Return(ByMove(std::move(surface_frame_1))))
288 .WillOnce(Return(ByMove(std::move(surface_frame_2))));
289
290 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
291 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
292
293 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
294 .WillOnce(Return(ByMove(std::move(surface_mock))));
295
296 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
297
298 return android_surface_mock;
299 });
300 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
301 *android_context, jni_mock, surface_factory, GetTaskRunnersForFixture());
302
303 auto raster_thread_merger = GetThreadMergerFromPlatformThread();
304
305 // ------------------ First frame ------------------ //
306 {
307 auto did_submit_frame = false;
308 auto surface_frame = std::make_unique<SurfaceFrame>(
309 SkSurfaces::Null(1000, 1000), framebuffer_info,
310 [&did_submit_frame](const SurfaceFrame& surface_frame,
311 DlCanvas* canvas) mutable {
312 if (canvas != nullptr) {
313 did_submit_frame = true;
314 }
315 return true;
316 },
317 /*frame_size=*/SkISize::Make(800, 600));
318
319 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
320 std::move(surface_frame));
321 // Submits frame if no Android view in the current frame.
322 EXPECT_TRUE(did_submit_frame);
323 // Doesn't resubmit frame.
324 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
325 ASSERT_EQ(PostPrerollResult::kSuccess, postpreroll_result);
326
327 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
328 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
329 }
330
331 // ------------------ Second frame ------------------ //
332 {
333 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
334 embedder->BeginFrame(nullptr, raster_thread_merger);
335 embedder->PrepareFlutterView(frame_size, 1.5);
336
337 // Add an Android view.
338 MutatorsStack stack1;
339 SkMatrix matrix1;
340 matrix1.setIdentity();
341 SkMatrix scale = SkMatrix::Scale(1.5, 1.5);
342 SkMatrix trans = SkMatrix::Translate(100, 100);
343 matrix1.setConcat(scale, trans);
344 stack1.PushTransform(scale);
345 stack1.PushTransform(trans);
346 // TODO(egarciad): Investigate why Flow applies the device pixel ratio to
347 // the offsetPixels, but not the sizePoints.
348 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
349 matrix1, SkSize::Make(200, 200), stack1);
350
351 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
352 // This is the recording canvas flow writes to.
353 auto canvas_1 = embedder->CompositeEmbeddedView(0);
354
355 auto rect_paint = DlPaint();
356 rect_paint.setColor(DlColor::kCyan());
357 rect_paint.setDrawStyle(DlDrawStyle::kFill);
358
359 // This simulates Flutter UI that doesn't intersect with the Android view.
360 canvas_1->DrawRect(SkRect::MakeXYWH(0, 0, 50, 50), rect_paint);
361 // This simulates Flutter UI that intersects with the Android view.
362 canvas_1->DrawRect(SkRect::MakeXYWH(50, 50, 200, 200), rect_paint);
363 canvas_1->DrawRect(SkRect::MakeXYWH(150, 150, 100, 100), rect_paint);
364
365 // Create a new overlay surface.
366 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
367 .WillOnce(Return(
368 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
369 0, window))));
370 // The JNI call to display the Android view.
371 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
372 0, 150, 150, 300, 300, 300, 300, stack1));
373 // The JNI call to display the overlay surface.
374 EXPECT_CALL(*jni_mock,
375 FlutterViewDisplayOverlaySurface(0, 150, 150, 100, 100));
376
377 auto did_submit_frame = false;
378 auto surface_frame = std::make_unique<SurfaceFrame>(
379 SkSurfaces::Null(1000, 1000), framebuffer_info,
380 [&did_submit_frame](const SurfaceFrame& surface_frame,
381 DlCanvas* canvas) mutable {
382 if (canvas != nullptr) {
383 did_submit_frame = true;
384 }
385 return true;
386 },
387 /*frame_size=*/SkISize::Make(800, 600));
388
389 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
390 std::move(surface_frame));
391 // Doesn't submit frame if there aren't Android views in the previous frame.
392 EXPECT_FALSE(did_submit_frame);
393 // Resubmits frame.
394 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
395 ASSERT_EQ(PostPrerollResult::kResubmitFrame, postpreroll_result);
396
397 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
398 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
399 }
400
401 // ------------------ Third frame ------------------ //
402 {
403 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
404 embedder->BeginFrame(nullptr, raster_thread_merger);
405 embedder->PrepareFlutterView(frame_size, 1.5);
406
407 // Add an Android view.
408 MutatorsStack stack1;
409 SkMatrix matrix1;
410 matrix1.setIdentity();
411 SkMatrix scale = SkMatrix::Scale(1.5, 1.5);
412 SkMatrix trans = SkMatrix::Translate(100, 100);
413 matrix1.setConcat(scale, trans);
414 stack1.PushTransform(scale);
415 stack1.PushTransform(trans);
416 // TODO(egarciad): Investigate why Flow applies the device pixel ratio to
417 // the offsetPixels, but not the sizePoints.
418 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
419 matrix1, SkSize::Make(200, 200), stack1);
420
421 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
422 // This is the recording canvas flow writes to.
423 auto canvas_1 = embedder->CompositeEmbeddedView(0);
424
425 auto rect_paint = DlPaint();
426 rect_paint.setColor(DlColor::kCyan());
427 rect_paint.setDrawStyle(DlDrawStyle::kFill);
428
429 // This simulates Flutter UI that doesn't intersect with the Android view.
430 canvas_1->DrawRect(SkRect::MakeXYWH(0, 0, 50, 50), rect_paint);
431 // This simulates Flutter UI that intersects with the Android view.
432 canvas_1->DrawRect(SkRect::MakeXYWH(50, 50, 200, 200), rect_paint);
433 canvas_1->DrawRect(SkRect::MakeXYWH(150, 150, 100, 100), rect_paint);
434
435 // Don't create a new overlay surface since it's recycled from the first
436 // frame.
437 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface()).Times(0);
438 // The JNI call to display the Android view.
439 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
440 0, 150, 150, 300, 300, 300, 300, stack1));
441 // The JNI call to display the overlay surface.
442 EXPECT_CALL(*jni_mock,
443 FlutterViewDisplayOverlaySurface(0, 150, 150, 100, 100));
444
445 auto did_submit_frame = false;
446 auto surface_frame = std::make_unique<SurfaceFrame>(
447 SkSurfaces::Null(1000, 1000), framebuffer_info,
448 [&did_submit_frame](const SurfaceFrame& surface_frame,
449 DlCanvas* canvas) mutable {
450 if (canvas != nullptr) {
451 did_submit_frame = true;
452 }
453 return true;
454 },
455 /*frame_size=*/SkISize::Make(800, 600));
456 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
457 std::move(surface_frame));
458 // Submits frame if there are Android views in the previous frame.
459 EXPECT_TRUE(did_submit_frame);
460 // Doesn't resubmit frame.
461 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
462 ASSERT_EQ(PostPrerollResult::kSuccess, postpreroll_result);
463
464 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
465 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
466 }
467}

◆ TEST() [47/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
SubmitFrameOverlayComposition   
)

Definition at line 572 of file external_view_embedder_unittests.cc.

572 {
573 auto jni_mock = std::make_shared<JNIMock>();
574 auto android_context =
575 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
576
577 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
578 auto gr_context = GrDirectContext::MakeMock(nullptr);
579 auto frame_size = SkISize::Make(1000, 1000);
580 SurfaceFrame::FramebufferInfo framebuffer_info;
581 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
582 [gr_context, window, frame_size, framebuffer_info]() {
583 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
584 SkSurfaces::Null(1000, 1000), framebuffer_info,
585 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
586 return true;
587 },
588 /*frame_size=*/SkISize::Make(800, 600));
589
590 auto surface_mock = std::make_unique<SurfaceMock>();
591 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
592 .Times(1 /* frames */)
593 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
594
595 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
596 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
597
598 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
599 .WillOnce(Return(ByMove(std::move(surface_mock))));
600
601 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
602 return android_surface_mock;
603 });
604 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
605 *android_context, jni_mock, surface_factory, GetTaskRunnersForFixture());
606
607 auto raster_thread_merger = GetThreadMergerFromPlatformThread();
608
609 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
610 embedder->BeginFrame(nullptr, raster_thread_merger);
611 embedder->PrepareFlutterView(frame_size, 1.5);
612
613 {
614 // Add first Android view.
615 SkMatrix matrix;
616 MutatorsStack stack;
617 stack.PushTransform(SkMatrix::Translate(0, 0));
618
619 embedder->PrerollCompositeEmbeddedView(
620 0, std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(200, 200),
621 stack));
622 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
623 300, 300, stack));
624 }
625
626 auto rect_paint = DlPaint();
627 rect_paint.setColor(DlColor::kCyan());
628 rect_paint.setDrawStyle(DlDrawStyle::kFill);
629
630 // This simulates Flutter UI that intersects with the first Android view.
631 embedder->CompositeEmbeddedView(0)->DrawRect(
632 SkRect::MakeXYWH(25, 25, 80, 150), rect_paint);
633
634 {
635 // Add second Android view.
637 MutatorsStack stack;
638 stack.PushTransform(SkMatrix::Translate(0, 100));
639
640 embedder->PrerollCompositeEmbeddedView(
641 1, std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(100, 100),
642 stack));
643 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(1, 0, 0, 100, 100,
644 150, 150, stack));
645 }
646 // This simulates Flutter UI that intersects with the first and second Android
647 // views.
648 embedder->CompositeEmbeddedView(1)->DrawRect(SkRect::MakeXYWH(25, 25, 80, 50),
649 rect_paint);
650
651 embedder->CompositeEmbeddedView(1)->DrawRect(
652 SkRect::MakeXYWH(75, 75, 30, 100), rect_paint);
653
654 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
655 .WillRepeatedly([&]() {
656 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
657 1, window);
658 });
659
660 EXPECT_CALL(*jni_mock, FlutterViewDisplayOverlaySurface(1, 25, 25, 80, 150))
661 .Times(2);
662
663 auto surface_frame = std::make_unique<SurfaceFrame>(
664 SkSurfaces::Null(1000, 1000), framebuffer_info,
665 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) mutable {
666 return true;
667 },
668 /*frame_size=*/SkISize::Make(800, 600));
669
670 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
671 std::move(surface_frame));
672
673 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
674 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
675}

◆ TEST() [48/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
SubmitFramePlatformViewWithoutAnyOverlay   
)

Definition at line 677 of file external_view_embedder_unittests.cc.

677 {
678 auto jni_mock = std::make_shared<JNIMock>();
679 auto android_context =
680 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
681
682 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
683 auto gr_context = GrDirectContext::MakeMock(nullptr);
684 auto frame_size = SkISize::Make(1000, 1000);
685 SurfaceFrame::FramebufferInfo framebuffer_info;
686 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
687 [gr_context, window, frame_size, framebuffer_info]() {
688 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
689 SkSurfaces::Null(1000, 1000), framebuffer_info,
690 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
691 return true;
692 },
693 /*frame_size=*/SkISize::Make(800, 600));
694
695 auto surface_mock = std::make_unique<SurfaceMock>();
696 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
697 .Times(1 /* frames */)
698 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
699
700 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
701 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
702
703 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
704 .WillOnce(Return(ByMove(std::move(surface_mock))));
705
706 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
707 return android_surface_mock;
708 });
709 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
710 *android_context, jni_mock, surface_factory, GetTaskRunnersForFixture());
711
712 auto raster_thread_merger = GetThreadMergerFromPlatformThread();
713
714 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
715 embedder->BeginFrame(nullptr, raster_thread_merger);
716 embedder->PrepareFlutterView(frame_size, 1.5);
717
718 {
719 // Add Android view.
720 SkMatrix matrix;
721 MutatorsStack stack;
722 stack.PushTransform(SkMatrix::Translate(0, 0));
723
724 embedder->PrerollCompositeEmbeddedView(
725 0, std::make_unique<EmbeddedViewParams>(matrix, SkSize::Make(200, 200),
726 stack));
727 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
728 300, 300, stack));
729 }
730
731 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface()).Times(0);
732
733 auto surface_frame = std::make_unique<SurfaceFrame>(
734 SkSurfaces::Null(1000, 1000), framebuffer_info,
735 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) mutable {
736 return true;
737 },
738 /*frame_size=*/SkISize::Make(800, 600));
739
740 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
741 std::move(surface_frame));
742
743 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
744 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
745}

◆ TEST() [49/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
SupportsDynamicThreadMerging   
)

Definition at line 948 of file external_view_embedder_unittests.cc.

948 {
949 auto jni_mock = std::make_shared<JNIMock>();
950 auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
951 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
952 android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
953 ASSERT_TRUE(embedder->SupportsDynamicThreadMerging());
954}

◆ TEST() [50/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
Teardown   
)

Definition at line 986 of file external_view_embedder_unittests.cc.

986 {
987 auto jni_mock = std::make_shared<JNIMock>();
988 auto android_context =
989 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
990 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
991 auto gr_context = GrDirectContext::MakeMock(nullptr);
992 auto frame_size = SkISize::Make(1000, 1000);
993 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
994 [gr_context, window, frame_size]() {
995 SurfaceFrame::FramebufferInfo framebuffer_info;
996 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
997 SkSurfaces::Null(1000, 1000), framebuffer_info,
998 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) {
999 return true;
1000 },
1001 /*frame_size=*/SkISize::Make(800, 600));
1002
1003 auto surface_mock = std::make_unique<SurfaceMock>();
1004 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
1005 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
1006
1007 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
1008 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
1009 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
1010 .WillOnce(Return(ByMove(std::move(surface_mock))));
1011
1012 return android_surface_mock;
1013 });
1014
1015 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
1016 *android_context, jni_mock, surface_factory, GetTaskRunnersForFixture());
1017 fml::Thread rasterizer_thread("rasterizer");
1018 auto raster_thread_merger =
1019 GetThreadMergerFromPlatformThread(&rasterizer_thread);
1020
1021 embedder->BeginFrame(nullptr, raster_thread_merger);
1022 embedder->PrepareFlutterView(frame_size, 1.5);
1023
1024 // Add an Android view.
1025 MutatorsStack stack;
1026 auto view_params = std::make_unique<EmbeddedViewParams>(
1027 SkMatrix(), SkSize::Make(200, 200), stack);
1028
1029 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params));
1030
1031 // This simulates Flutter UI that intersects with the Android view.
1032 embedder->CompositeEmbeddedView(0)->DrawRect(
1033 SkRect::MakeXYWH(50, 50, 200, 200), DlPaint());
1034
1035 // Create a new overlay surface.
1036 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
1037 .WillOnce(Return(
1038 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1039 0, window))));
1040
1041 SurfaceFrame::FramebufferInfo framebuffer_info;
1042 auto surface_frame = std::make_unique<SurfaceFrame>(
1043 SkSurfaces::Null(1000, 1000), framebuffer_info,
1044 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) { return true; },
1045 /*frame_size=*/SkISize::Make(800, 600));
1046 embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr,
1047 std::move(surface_frame));
1048
1049 embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
1050
1051 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces());
1052 // Teardown.
1053 embedder->Teardown();
1054}

◆ TEST() [51/709]

flutter::testing::TEST ( AndroidExternalViewEmbedder  ,
TeardownDoesNotCallJNIMethod   
)

Definition at line 1056 of file external_view_embedder_unittests.cc.

1056 {
1057 auto jni_mock = std::make_shared<JNIMock>();
1058 auto android_context =
1059 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
1060 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
1061 *android_context, jni_mock, nullptr, GetTaskRunnersForFixture());
1062
1063 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(0);
1064 embedder->Teardown();
1065}

◆ TEST() [52/709]

flutter::testing::TEST ( AndroidPlatformView  ,
SelectsVulkanBasedOnApiLevel   
)

Definition at line 13 of file platform_view_android_unittests.cc.

13 {
14 Settings settings;
15 settings.enable_software_rendering = false;
16 settings.enable_impeller = true;
17
18 int api_level = android_get_device_api_level();
19 EXPECT_GT(api_level, 0);
20 if (api_level >= 29) {
21 EXPECT_EQ(FlutterMain::SelectedRenderingAPI(settings),
22 AndroidRenderingAPI::kImpellerVulkan);
23 } else {
24 EXPECT_EQ(FlutterMain::SelectedRenderingAPI(settings),
25 AndroidRenderingAPI::kSkiaOpenGLES);
26 }
27}

◆ TEST() [53/709]

flutter::testing::TEST ( AndroidPlatformView  ,
SoftwareRenderingNotSupportedWithImpeller   
)

Definition at line 29 of file platform_view_android_unittests.cc.

29 {
30 Settings settings;
31 settings.enable_software_rendering = true;
32 settings.enable_impeller = true;
33
34 ASSERT_DEATH(FlutterMain::SelectedRenderingAPI(settings), "");
35}

◆ TEST() [54/709]

flutter::testing::TEST ( AndroidShellHolder  ,
Create   
)

Definition at line 122 of file android_shell_holder_unittests.cc.

122 {
123 Settings settings;
124 settings.enable_software_rendering = false;
125 auto jni = std::make_shared<MockPlatformViewAndroidJNI>();
126 auto holder = std::make_unique<AndroidShellHolder>(settings, jni);
127 EXPECT_NE(holder.get(), nullptr);
128 EXPECT_TRUE(holder->IsValid());
129 EXPECT_NE(holder->GetPlatformView().get(), nullptr);
130 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
131 nullptr, /*is_fake_window=*/true);
132 holder->GetPlatformView()->NotifyCreated(window);
133}

◆ TEST() [55/709]

flutter::testing::TEST ( AndroidShellHolder  ,
HandlePlatformMessage   
)

Definition at line 135 of file android_shell_holder_unittests.cc.

135 {
136 Settings settings;
137 settings.enable_software_rendering = false;
138 auto jni = std::make_shared<MockPlatformViewAndroidJNI>();
139 auto holder = std::make_unique<AndroidShellHolder>(settings, jni);
140 EXPECT_NE(holder.get(), nullptr);
141 EXPECT_TRUE(holder->IsValid());
142 EXPECT_NE(holder->GetPlatformView().get(), nullptr);
143 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
144 nullptr, /*is_fake_window=*/true);
145 holder->GetPlatformView()->NotifyCreated(window);
146 EXPECT_TRUE(holder->GetPlatformMessageHandler());
147 size_t data_size = 4;
148 fml::MallocMapping bytes =
149 fml::MallocMapping(static_cast<uint8_t*>(malloc(data_size)), data_size);
151 MockPlatformMessageResponse::Create();
152 auto message = std::make_unique<PlatformMessage>(
153 /*channel=*/"foo", /*data=*/std::move(bytes), /*response=*/response);
154 int response_id = 1;
155 EXPECT_CALL(*jni,
156 FlutterViewHandlePlatformMessage(::testing::_, response_id));
157 EXPECT_CALL(*response, CompleteEmpty());
158 holder->GetPlatformMessageHandler()->HandlePlatformMessage(
159 std::move(message));
160 holder->GetPlatformMessageHandler()
161 ->InvokePlatformMessageEmptyResponseCallback(response_id);
162}
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144

◆ TEST() [56/709]

flutter::testing::TEST ( APKAssetProvider  ,
CloneAndEquals   
)

Definition at line 19 of file apk_asset_provider_unittests.cc.

19 {
20 auto first_provider = std::make_unique<APKAssetProvider>(
21 std::make_shared<MockAPKAssetProviderImpl>());
22 auto second_provider = std::make_unique<APKAssetProvider>(
23 std::make_shared<MockAPKAssetProviderImpl>());
24 auto third_provider = first_provider->Clone();
25
26 ASSERT_NE(first_provider->GetImpl(), second_provider->GetImpl());
27 ASSERT_EQ(first_provider->GetImpl(), third_provider->GetImpl());
28 ASSERT_FALSE(*first_provider == *second_provider);
29 ASSERT_TRUE(*first_provider == *third_provider);
30}

◆ TEST() [57/709]

flutter::testing::TEST ( Base64  ,
DecodeBytes   
)

Definition at line 101 of file base64_unittests.cc.

101 {
102 auto test = [](const std::string& input, const uint8_t output[], size_t num) {
103 char buffer[256];
104 size_t len = 0;
105 auto err = Base64::Decode(input.c_str(), input.length(), &buffer, &len);
106 ASSERT_EQ(err, Base64::Error::kNone);
107 FML_CHECK(len <= 256);
108 ASSERT_EQ(num, len) << input;
109 for (int i = 0; i < int(len); i++) {
110 ASSERT_EQ(uint8_t(buffer[i]), output[i]) << input << i;
111 }
112 };
113 // Some arbitrary raw bytes, same as the byte output above
114 uint8_t e[] = {0x02, 0x71, 0x82, 0x81, 0x82, 0x84, 0x59};
115 test("AnGCgYKEWQ==", e, sizeof(e));
116
117 uint8_t pi[] = {0x03, 0x24, 0x3F, 0x6A, 0x88, 0x85};
118 test("AyQ/aoiF", pi, sizeof(pi));
119}
#define test(name)
Type::kYUV Type::kRGBA() int(0.7 *637)

◆ TEST() [58/709]

flutter::testing::TEST ( Base64  ,
DecodeStringsHasErrors   
)

Definition at line 83 of file base64_unittests.cc.

83 {
84 auto test = [](const std::string& input, Base64::Error expectedError) {
85 char buffer[256];
86 size_t len = 0;
87 auto err = Base64::Decode(input.c_str(), input.length(), &buffer, &len);
88 ASSERT_EQ(err, expectedError) << input;
89 };
90
91 test("Nuts&Bolts", Base64::Error::kBadChar);
92 test("Error!", Base64::Error::kBadChar);
93 test(":", Base64::Error::kBadChar);
94
95 test("RmlzaCAmIENoaXBz=", Base64::Error::kBadPadding);
96 // Some cases of bad padding may be ignored due to an internal optimization
97 // test("ZGF0ZQ=", Base64::Error::kBadPadding);
98 // test("RWdncGxhbnQ", Base64::Error::kBadPadding);
99}

◆ TEST() [59/709]

flutter::testing::TEST ( Base64  ,
DecodeStringsSuccess   
)

Definition at line 62 of file base64_unittests.cc.

62 {
63 auto test = [](const std::string& input, const std::string& output) {
64 char buffer[256];
65 size_t len = 0;
66 auto err = Base64::Decode(input.c_str(), input.length(), &buffer, &len);
67 ASSERT_EQ(err, Base64::Error::kNone);
68 FML_CHECK(len <= 256);
69 std::string actual(buffer, len);
70 ASSERT_STREQ(actual.c_str(), output.c_str());
71 };
72 // Some arbitrary strings
73 test("ZGF0ZQ==", "date");
74 test("RWdncGxhbnQ=", "Eggplant");
75 test("RmlzaCAmIENoaXBz", "Fish & Chips");
76 test("U3VQZVJjQWxJZlJhR2lMaVN0SWNFeFBpQWxJZE9jSW9Vcw==",
77 "SuPeRcAlIfRaGiLiStIcExPiAlIdOcIoUs");
78
79 // Spaces are ignored
80 test("Y X Bwb GU=", "apple");
81}

◆ TEST() [60/709]

flutter::testing::TEST ( Base64  ,
EncodeBytes   
)

Definition at line 33 of file base64_unittests.cc.

33 {
34 auto test = [](const uint8_t input[], size_t num, const std::string& output) {
35 char buffer[512];
36 size_t len = Base64::Encode(input, num, &buffer);
37 FML_CHECK(len <= 512);
38 ASSERT_EQ(len, Base64::EncodedSize(num));
39 std::string actual(buffer, len);
40 ASSERT_STREQ(actual.c_str(), output.c_str());
41 };
42 // Some arbitrary raw bytes
43 uint8_t e[] = {0x02, 0x71, 0x82, 0x81, 0x82, 0x84, 0x59};
44 test(e, sizeof(e), "AnGCgYKEWQ==");
45
46 uint8_t pi[] = {0x03, 0x24, 0x3F, 0x6A, 0x88, 0x85};
47 test(pi, sizeof(pi), "AyQ/aoiF");
48
49 uint8_t bytes[256];
50 for (int i = 0; i < 256; i++) {
51 bytes[i] = i;
52 }
53 test(bytes, sizeof(bytes),
54 "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gIS"
55 "IjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFV"
56 "WV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJ"
57 "iouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8v"
58 "b6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8P"
59 "Hy8/T19vf4+fr7/P3+/w==");
60}

◆ TEST() [61/709]

flutter::testing::TEST ( Base64  ,
EncodeStrings   
)

Definition at line 15 of file base64_unittests.cc.

15 {
16 auto test = [](const std::string& input, const std::string& output) {
17 char buffer[256];
18 size_t len = Base64::Encode(input.c_str(), input.length(), &buffer);
19 FML_CHECK(len <= 256);
20 ASSERT_EQ(len, Base64::EncodedSize(input.length()));
21 std::string actual(buffer, len);
22 ASSERT_STREQ(actual.c_str(), output.c_str());
23 };
24 // Some arbitrary strings
25 test("apple", "YXBwbGU=");
26 test("BANANA", "QkFOQU5B");
27 test("Cherry Pie", "Q2hlcnJ5IFBpZQ==");
28 test("fLoCcInAuCiNiHiLiPiLiFiCaTiOn",
29 "ZkxvQ2NJbkF1Q2lOaUhpTGlQaUxpRmlDYVRpT24=");
30 test("", "");
31}

◆ TEST() [62/709]

flutter::testing::TEST ( CanvasSpyTest  ,
DrawingIsTracked   
)

Definition at line 14 of file canvas_spy_unittests.cc.

14 {
15 SkPictureRecorder picture_recorder;
16 SkCanvas* canvas = picture_recorder.beginRecording(100, 100);
17 CanvasSpy canvas_spy = CanvasSpy(canvas);
18 DlCanvas* spy = canvas_spy.GetSpyingCanvas();
19
20 ASSERT_FALSE(canvas_spy.DidDrawIntoCanvas());
21
22 spy->Translate(128, 128);
23 spy->Clear(DlColor::kTransparent());
24 ASSERT_FALSE(canvas_spy.DidDrawIntoCanvas());
25
27 spy->DrawCircle({0, 0}, 60, paint);
28 ASSERT_TRUE(canvas_spy.DidDrawIntoCanvas());
29}
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
bool DidDrawIntoCanvas()
Returns true if any non transparent content has been drawn into the spying canvas....
Definition canvas_spy.cc:38
DlCanvas * GetSpyingCanvas()
The returned canvas delegate all operations to the target canvas while spying on them.
Definition canvas_spy.cc:20
virtual void DrawCircle(const SkPoint &center, SkScalar radius, const DlPaint &paint)=0
virtual void Translate(SkScalar tx, SkScalar ty)=0
void Clear(DlColor color)
Definition dl_canvas.h:131

◆ TEST() [63/709]

flutter::testing::TEST ( CanvasSpyTest  ,
SpiedCanvasIsDrawing   
)

Definition at line 31 of file canvas_spy_unittests.cc.

31 {
32 auto actual_surface =
34 SkCanvas* actual_canvas = actual_surface->getCanvas();
35
36 auto expected_surface =
38 SkCanvas* expected_canvas = expected_surface->getCanvas();
39
40 CanvasSpy canvas_spy = CanvasSpy(actual_canvas);
41 SkCanvas* spy = canvas_spy.GetRawSpyingCanvas();
42
43 SkNWayCanvas multi_canvas = SkNWayCanvas(100, 100);
44 multi_canvas.addCanvas(spy);
45 multi_canvas.addCanvas(expected_canvas);
46
47 multi_canvas.clipRect(SkRect::MakeWH(100, 100));
48 multi_canvas.clear(SK_ColorRED);
49 multi_canvas.scale(.5, .5);
50 multi_canvas.clipRect(SkRect::MakeWH(100, 100));
51 multi_canvas.clear(SK_ColorBLUE);
52
53 ASSERT_TRUE(canvas_spy.DidDrawIntoCanvas());
54
55 SkPixmap actual;
56 SkPixmap expected;
57
58 ASSERT_TRUE(actual_surface->peekPixels(&actual));
59 ASSERT_TRUE(expected_surface->peekPixels(&expected));
60
61 const auto size = actual.rowBytes() * actual.height();
62 ASSERT_NE(size, 0u);
63
64 ASSERT_EQ(::memcmp(actual.addr(), expected.addr(), size), 0);
65}
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void clear(SkColor color)
Definition SkCanvas.h:1199
void scale(SkScalar sx, SkScalar sy)
virtual void addCanvas(SkCanvas *)
int height() const
Definition SkPixmap.h:166
SkCanvas * GetRawSpyingCanvas()
The underlying Skia canvas that implements the spying (mainly for testing)
Definition canvas_spy.cc:24

◆ TEST() [64/709]

flutter::testing::TEST ( ContextOptionsTest  ,
OpenGLDisablesStencilBuffers   
)

Definition at line 12 of file context_options_unittests.cc.

12 {
13 auto options = MakeDefaultContextOptions(flutter::ContextType::kRender,
15 EXPECT_TRUE(options.fAvoidStencilBuffers);
16}
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...

◆ TEST() [65/709]

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

Definition at line 141 of file direct_manipulation_unittests.cc.

141 {
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}
union flutter::testing::@2838::KeyboardChange::@76 content
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47
unsigned long DWORD

◆ TEST() [66/709]

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

Definition at line 394 of file direct_manipulation_unittests.cc.

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

◆ TEST() [67/709]

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

Definition at line 340 of file direct_manipulation_unittests.cc.

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

◆ TEST() [68/709]

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

Definition at line 287 of file direct_manipulation_unittests.cc.

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

◆ TEST() [69/709]

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

Definition at line 205 of file direct_manipulation_unittests.cc.

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

◆ TEST() [70/709]

flutter::testing::TEST ( DisplayListColor  ,
ArrayInterchangeableWithUint32   
)

Definition at line 21 of file dl_color_unittests.cc.

21 {
22 uint32_t ints[5] = {
23 0xFF000000, //
24 0xFFFF0000, //
25 0xFF00FF00, //
26 0xFF0000FF, //
27 0xF1F2F3F4,
28 };
29 DlColor colors[5] = {
30 DlColor::kBlack(), //
31 DlColor::kRed(), //
32 DlColor::kGreen(), //
33 DlColor::kBlue(), //
34 DlColor(0xF1F2F3F4),
35 };
36 arraysEqual(ints, colors, 5);
37 arraysEqual(reinterpret_cast<const uint32_t*>(colors),
38 reinterpret_cast<const DlColor*>(ints), 5);
39}

◆ TEST() [71/709]

flutter::testing::TEST ( DisplayListColor  ,
DlColorDirectlyComparesToSkColor   
)

Definition at line 41 of file dl_color_unittests.cc.

41 {
42 EXPECT_EQ(DlColor::kBlack(), SK_ColorBLACK);
43 EXPECT_EQ(DlColor::kRed(), SK_ColorRED);
44 EXPECT_EQ(DlColor::kGreen(), SK_ColorGREEN);
45 EXPECT_EQ(DlColor::kBlue(), SK_ColorBLUE);
46}

◆ TEST() [72/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
BlendAsBlend   
)

Definition at line 28 of file dl_color_filter_unittests.cc.

28 {
29 DlBlendColorFilter filter(DlColor::kRed(), DlBlendMode::kDstATop);
30 ASSERT_NE(filter.asBlend(), nullptr);
31 ASSERT_EQ(filter.asBlend(), &filter);
32}

◆ TEST() [73/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
BlendConstructor   
)

Definition at line 18 of file dl_color_filter_unittests.cc.

18 {
19 DlBlendColorFilter filter(DlColor::kRed(), DlBlendMode::kDstATop);
20}

◆ TEST() [74/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
BlendContents   
)

Definition at line 34 of file dl_color_filter_unittests.cc.

34 {
35 DlBlendColorFilter filter(DlColor::kRed(), DlBlendMode::kDstATop);
36 ASSERT_EQ(filter.color(), DlColor::kRed());
37 ASSERT_EQ(filter.mode(), DlBlendMode::kDstATop);
38}

◆ TEST() [75/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
BlendEquals   
)

Definition at line 40 of file dl_color_filter_unittests.cc.

40 {
41 DlBlendColorFilter filter1(DlColor::kRed(), DlBlendMode::kDstATop);
42 DlBlendColorFilter filter2(DlColor::kRed(), DlBlendMode::kDstATop);
43 TestEquals(filter1, filter2);
44}

◆ TEST() [76/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
BlendNotEquals   
)

Definition at line 46 of file dl_color_filter_unittests.cc.

46 {
47 DlBlendColorFilter filter1(DlColor::kRed(), DlBlendMode::kDstATop);
48 DlBlendColorFilter filter2(DlColor::kBlue(), DlBlendMode::kDstATop);
49 DlBlendColorFilter filter3(DlColor::kRed(), DlBlendMode::kDstIn);
50 TestNotEquals(filter1, filter2, "Color differs");
51 TestNotEquals(filter1, filter3, "Blend mode differs");
52}

◆ TEST() [77/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
BlendShared   
)

Definition at line 22 of file dl_color_filter_unittests.cc.

22 {
23 DlBlendColorFilter filter(DlColor::kRed(), DlBlendMode::kDstATop);
24 ASSERT_NE(filter.shared().get(), &filter);
25 ASSERT_EQ(*filter.shared(), filter);
26}

◆ TEST() [78/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
LinearToSrgbConstructor   
)

◆ TEST() [79/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
LinearToSrgbEquals   
)

Definition at line 151 of file dl_color_filter_unittests.cc.

151 {
154 TestEquals(filter1, filter2);
155 TestEquals(filter1, *DlLinearToSrgbGammaColorFilter::kInstance);
156}

◆ TEST() [80/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
LinearToSrgbShared   
)

Definition at line 145 of file dl_color_filter_unittests.cc.

145 {
147 ASSERT_NE(filter.shared().get(), &filter);
148 ASSERT_EQ(*filter.shared(), filter);
149}
std::shared_ptr< DlColorFilter > shared() const override

◆ TEST() [81/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
MatrixAsMatrix   
)

Definition at line 69 of file dl_color_filter_unittests.cc.

69 {
71 ASSERT_NE(filter.asMatrix(), nullptr);
72 ASSERT_EQ(filter.asMatrix(), &filter);
73}

◆ TEST() [82/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
MatrixConstructor   
)

Definition at line 59 of file dl_color_filter_unittests.cc.

59 {
61}

◆ TEST() [83/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
MatrixContents   
)

Definition at line 75 of file dl_color_filter_unittests.cc.

75 {
76 float matrix[20];
77 memcpy(matrix, kMatrix, sizeof(matrix));
78 DlMatrixColorFilter filter(matrix);
79
80 // Test deref operator []
81 for (int i = 0; i < 20; i++) {
82 ASSERT_EQ(filter[i], matrix[i]);
83 }
84
85 // Test get_matrix
86 float matrix2[20];
87 filter.get_matrix(matrix2);
88 for (int i = 0; i < 20; i++) {
89 ASSERT_EQ(matrix2[i], matrix[i]);
90 }
91
92 // Test perturbing original array does not affect filter
93 float original_value = matrix[4];
94 matrix[4] += 101;
95 ASSERT_EQ(filter[4], original_value);
96}

◆ TEST() [84/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
MatrixEquals   
)

Definition at line 98 of file dl_color_filter_unittests.cc.

98 {
101 TestEquals(filter1, filter2);
102}

◆ TEST() [85/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
MatrixNotEquals   
)

Definition at line 104 of file dl_color_filter_unittests.cc.

104 {
105 float matrix[20];
106 memcpy(matrix, kMatrix, sizeof(matrix));
107 DlMatrixColorFilter filter1(matrix);
108 matrix[4] += 101;
109 DlMatrixColorFilter filter2(matrix);
110 TestNotEquals(filter1, filter2, "Matrix differs");
111}

◆ TEST() [86/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
MatrixShared   
)

Definition at line 63 of file dl_color_filter_unittests.cc.

63 {
65 ASSERT_NE(filter.shared().get(), &filter);
66 ASSERT_EQ(*filter.shared(), filter);
67}

◆ TEST() [87/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
NopBlendShouldNotCrash   
)

Definition at line 54 of file dl_color_filter_unittests.cc.

54 {
55 DlBlendColorFilter filter(DlColor::kTransparent(), DlBlendMode::kSrcOver);
56 ASSERT_FALSE(filter.modifies_transparent_black());
57}

◆ TEST() [88/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
NopMatrixShouldNotCrash   
)

Definition at line 113 of file dl_color_filter_unittests.cc.

113 {
114 float matrix[20] = {
115 1, 0, 0, 0, 0, //
116 0, 1, 0, 0, 0, //
117 0, 0, 1, 0, 0, //
118 0, 0, 0, 1, 0, //
119 };
120 DlMatrixColorFilter filter(matrix);
121 ASSERT_FALSE(filter.modifies_transparent_black());
122}

◆ TEST() [89/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
SrgbToLinearConstructor   
)

◆ TEST() [90/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
SrgbToLinearEquals   
)

Definition at line 134 of file dl_color_filter_unittests.cc.

134 {
137 TestEquals(filter1, filter2);
138 TestEquals(filter1, *DlSrgbToLinearGammaColorFilter::kInstance);
139}

◆ TEST() [91/709]

flutter::testing::TEST ( DisplayListColorFilter  ,
SrgbToLinearShared   
)

Definition at line 128 of file dl_color_filter_unittests.cc.

128 {
130 ASSERT_NE(filter.shared().get(), &filter);
131 ASSERT_EQ(*filter.shared(), filter);
132}
std::shared_ptr< DlColorFilter > shared() const override

◆ TEST() [92/709]

flutter::testing::TEST ( DisplayListColorSource  ,
AlphaConicalGradientContents   
)

Definition at line 516 of file dl_color_source_unittests.cc.

516 {
517 std::shared_ptr<DlColorSource> source = DlColorSource::MakeConical(
518 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount,
519 kTestAlphaColors, kTestStops, DlTileMode::kClamp, &kTestMatrix1);
520 ASSERT_EQ(source->asConicalGradient()->start_center(), kTestPoints[0]);
521 ASSERT_EQ(source->asConicalGradient()->start_radius(), 10.0);
522 ASSERT_EQ(source->asConicalGradient()->end_center(), kTestPoints[1]);
523 ASSERT_EQ(source->asConicalGradient()->end_radius(), 20.0);
524 ASSERT_EQ(source->asConicalGradient()->stop_count(), kTestStopCount);
525 for (int i = 0; i < kTestStopCount; i++) {
526 ASSERT_EQ(source->asConicalGradient()->colors()[i], kTestAlphaColors[i]);
527 ASSERT_EQ(source->asConicalGradient()->stops()[i], kTestStops[i]);
528 }
529 ASSERT_EQ(source->asConicalGradient()->tile_mode(), DlTileMode::kClamp);
530 ASSERT_EQ(source->asConicalGradient()->matrix(), kTestMatrix1);
531 ASSERT_EQ(source->is_opaque(), false);
532}
SkBitmap source
Definition examples.cpp:28
static constexpr int kTestStopCount

◆ TEST() [93/709]

flutter::testing::TEST ( DisplayListColorSource  ,
AlphaImageContents   
)

Definition at line 173 of file dl_color_source_unittests.cc.

173 {
174 DlImageColorSource source(kTestAlphaImage1, DlTileMode::kRepeat,
175 DlTileMode::kMirror, DlImageSampling::kLinear,
176 &kTestMatrix1);
177 ASSERT_EQ(source.image(), kTestAlphaImage1);
178 ASSERT_EQ(source.horizontal_tile_mode(), DlTileMode::kRepeat);
179 ASSERT_EQ(source.vertical_tile_mode(), DlTileMode::kMirror);
180 ASSERT_EQ(source.sampling(), DlImageSampling::kLinear);
181 ASSERT_EQ(source.matrix(), kTestMatrix1);
182 ASSERT_EQ(source.is_opaque(), false);
183}

◆ TEST() [94/709]

flutter::testing::TEST ( DisplayListColorSource  ,
AlphaLinearGradientContents   
)

Definition at line 276 of file dl_color_source_unittests.cc.

276 {
277 std::shared_ptr<DlColorSource> source = DlColorSource::MakeLinear(
278 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestAlphaColors,
279 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
280 ASSERT_EQ(source->asLinearGradient()->start_point(), kTestPoints[0]);
281 ASSERT_EQ(source->asLinearGradient()->end_point(), kTestPoints[1]);
282 ASSERT_EQ(source->asLinearGradient()->stop_count(), kTestStopCount);
283 for (int i = 0; i < kTestStopCount; i++) {
284 ASSERT_EQ(source->asLinearGradient()->colors()[i], kTestAlphaColors[i]);
285 ASSERT_EQ(source->asLinearGradient()->stops()[i], kTestStops[i]);
286 }
287 ASSERT_EQ(source->asLinearGradient()->tile_mode(), DlTileMode::kClamp);
288 ASSERT_EQ(source->asLinearGradient()->matrix(), kTestMatrix1);
289 ASSERT_EQ(source->is_opaque(), false);
290}

◆ TEST() [95/709]

flutter::testing::TEST ( DisplayListColorSource  ,
AlphaRadialGradientContents   
)

Definition at line 395 of file dl_color_source_unittests.cc.

395 {
396 std::shared_ptr<DlColorSource> source = DlColorSource::MakeRadial(
397 kTestPoints[0], 10.0, kTestStopCount, kTestAlphaColors, kTestStops,
398 DlTileMode::kClamp, &kTestMatrix1);
399 ASSERT_EQ(source->asRadialGradient()->center(), kTestPoints[0]);
400 ASSERT_EQ(source->asRadialGradient()->radius(), 10.0);
401 ASSERT_EQ(source->asRadialGradient()->stop_count(), kTestStopCount);
402 for (int i = 0; i < kTestStopCount; i++) {
403 ASSERT_EQ(source->asRadialGradient()->colors()[i], kTestAlphaColors[i]);
404 ASSERT_EQ(source->asRadialGradient()->stops()[i], kTestStops[i]);
405 }
406 ASSERT_EQ(source->asRadialGradient()->tile_mode(), DlTileMode::kClamp);
407 ASSERT_EQ(source->asRadialGradient()->matrix(), kTestMatrix1);
408 ASSERT_EQ(source->is_opaque(), false);
409}

◆ TEST() [96/709]

flutter::testing::TEST ( DisplayListColorSource  ,
AlphaSweepGradientContents   
)

Definition at line 650 of file dl_color_source_unittests.cc.

650 {
651 std::shared_ptr<DlColorSource> source = DlColorSource::MakeSweep(
652 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestAlphaColors, kTestStops,
653 DlTileMode::kClamp, &kTestMatrix1);
654 ASSERT_EQ(source->asSweepGradient()->center(), kTestPoints[0]);
655 ASSERT_EQ(source->asSweepGradient()->start(), 10.0);
656 ASSERT_EQ(source->asSweepGradient()->end(), 20.0);
657 ASSERT_EQ(source->asSweepGradient()->stop_count(), kTestStopCount);
658 for (int i = 0; i < kTestStopCount; i++) {
659 ASSERT_EQ(source->asSweepGradient()->colors()[i], kTestAlphaColors[i]);
660 ASSERT_EQ(source->asSweepGradient()->stops()[i], kTestStops[i]);
661 }
662 ASSERT_EQ(source->asSweepGradient()->tile_mode(), DlTileMode::kClamp);
663 ASSERT_EQ(source->asSweepGradient()->matrix(), kTestMatrix1);
664 ASSERT_EQ(source->is_opaque(), false);
665}

◆ TEST() [97/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ColorAsColor   
)

Definition at line 99 of file dl_color_source_unittests.cc.

99 {
100 DlColorColorSource source(DlColor::kRed());
101 ASSERT_NE(source.asColor(), nullptr);
102 ASSERT_EQ(source.asColor(), &source);
103
104 ASSERT_EQ(source.asImage(), nullptr);
105 ASSERT_EQ(source.asLinearGradient(), nullptr);
106 ASSERT_EQ(source.asRadialGradient(), nullptr);
107 ASSERT_EQ(source.asConicalGradient(), nullptr);
108 ASSERT_EQ(source.asSweepGradient(), nullptr);
109 ASSERT_EQ(source.asRuntimeEffect(), nullptr);
110}
sk_sp< SkImage > asImage() const
Definition SkBitmap.cpp:645

◆ TEST() [98/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ColorConstructor   
)

Definition at line 89 of file dl_color_source_unittests.cc.

89 {
90 DlColorColorSource source(DlColor::kRed());
91}

◆ TEST() [99/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ColorContents   
)

Definition at line 112 of file dl_color_source_unittests.cc.

112 {
113 DlColorColorSource source(DlColor::kRed());
114 ASSERT_EQ(source.color(), DlColor::kRed());
115 ASSERT_EQ(source.is_opaque(), true);
116 for (int i = 0; i < 255; i++) {
117 SkColor alpha_color = SkColorSetA(SK_ColorRED, i);
118 auto const alpha_source = DlColorColorSource(DlColor(alpha_color));
119 ASSERT_EQ(alpha_source.color(), alpha_color);
120 ASSERT_EQ(alpha_source.is_opaque(), false);
121 }
122}
uint32_t SkColor
Definition SkColor.h:37
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
Definition SkColor.h:82

◆ TEST() [100/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ColorEquals   
)

Definition at line 124 of file dl_color_source_unittests.cc.

124 {
125 DlColorColorSource source1(DlColor::kRed());
126 DlColorColorSource source2(DlColor::kRed());
127 TestEquals(source1, source2);
128}

◆ TEST() [101/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ColorNotEquals   
)

Definition at line 130 of file dl_color_source_unittests.cc.

130 {
131 DlColorColorSource source1(DlColor::kRed());
132 DlColorColorSource source2(DlColor::kBlue());
133 TestNotEquals(source1, source2, "Color differs");
134}

◆ TEST() [102/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ColorShared   
)

Definition at line 93 of file dl_color_source_unittests.cc.

93 {
94 DlColorColorSource source(DlColor::kRed());
95 ASSERT_NE(source.shared().get(), &source);
96 ASSERT_EQ(*source.shared(), source);
97}

◆ TEST() [103/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConicalGradientAsConical   
)

Definition at line 483 of file dl_color_source_unittests.cc.

483 {
484 std::shared_ptr<DlColorSource> source = DlColorSource::MakeConical(
485 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
486 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
487 ASSERT_NE(source->asConicalGradient(), nullptr);
488 ASSERT_EQ(source->asConicalGradient(), source.get());
489
490 ASSERT_EQ(source->asColor(), nullptr);
491 ASSERT_EQ(source->asImage(), nullptr);
492 ASSERT_EQ(source->asLinearGradient(), nullptr);
493 ASSERT_EQ(source->asRadialGradient(), nullptr);
494 ASSERT_EQ(source->asSweepGradient(), nullptr);
495 ASSERT_EQ(source->asRuntimeEffect(), nullptr);
496}

◆ TEST() [104/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConicalGradientConstructor   
)

Definition at line 469 of file dl_color_source_unittests.cc.

469 {
470 std::shared_ptr<DlColorSource> source = DlColorSource::MakeConical(
471 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
472 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
473}

◆ TEST() [105/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConicalGradientContents   
)

Definition at line 498 of file dl_color_source_unittests.cc.

498 {
499 std::shared_ptr<DlColorSource> source = DlColorSource::MakeConical(
500 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
501 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
502 ASSERT_EQ(source->asConicalGradient()->start_center(), kTestPoints[0]);
503 ASSERT_EQ(source->asConicalGradient()->start_radius(), 10.0);
504 ASSERT_EQ(source->asConicalGradient()->end_center(), kTestPoints[1]);
505 ASSERT_EQ(source->asConicalGradient()->end_radius(), 20.0);
506 ASSERT_EQ(source->asConicalGradient()->stop_count(), kTestStopCount);
507 for (int i = 0; i < kTestStopCount; i++) {
508 ASSERT_EQ(source->asConicalGradient()->colors()[i], kTestColors[i]);
509 ASSERT_EQ(source->asConicalGradient()->stops()[i], kTestStops[i]);
510 }
511 ASSERT_EQ(source->asConicalGradient()->tile_mode(), DlTileMode::kClamp);
512 ASSERT_EQ(source->asConicalGradient()->matrix(), kTestMatrix1);
513 ASSERT_EQ(source->is_opaque(), true);
514}

◆ TEST() [106/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConicalGradientEquals   
)

Definition at line 534 of file dl_color_source_unittests.cc.

534 {
535 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeConical(
536 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
537 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
538 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
539 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
540 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
541 TestEquals(*source1, *source2);
542}

◆ TEST() [107/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConicalGradientNotEquals   
)

Definition at line 544 of file dl_color_source_unittests.cc.

544 {
545 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeConical(
546 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
547 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
548 {
549 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
550 kTestPoints2[0], 10.0, kTestPoints[1], 20.0, kTestStopCount,
551 kTestColors, kTestStops, DlTileMode::kClamp, &kTestMatrix1);
552 TestNotEquals(*source1, *source2, "Start Center differs");
553 }
554 {
555 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
556 kTestPoints[0], 15.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
557 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
558 TestNotEquals(*source1, *source2, "Start Radius differs");
559 }
560 {
561 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
562 kTestPoints[0], 10.0, kTestPoints2[1], 20.0, kTestStopCount,
563 kTestColors, kTestStops, DlTileMode::kClamp, &kTestMatrix1);
564 TestNotEquals(*source1, *source2, "End Center differs");
565 }
566 {
567 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
568 kTestPoints[0], 10.0, kTestPoints[1], 25.0, kTestStopCount, kTestColors,
569 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
570 TestNotEquals(*source1, *source2, "End Radius differs");
571 }
572 {
573 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
574 kTestPoints[0], 10.0, kTestPoints[1], 20.0, 2, kTestColors, kTestStops,
575 DlTileMode::kClamp, &kTestMatrix1);
576 TestNotEquals(*source1, *source2, "Stop count differs");
577 }
578 {
579 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
580 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount,
581 kTestAlphaColors, kTestStops, DlTileMode::kClamp, &kTestMatrix1);
582 TestNotEquals(*source1, *source2, "Colors differ");
583 }
584 {
585 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
586 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
587 kTestStops2, DlTileMode::kClamp, &kTestMatrix1);
588 TestNotEquals(*source1, *source2, "Stops differ");
589 }
590 {
591 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
592 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
593 kTestStops, DlTileMode::kMirror, &kTestMatrix1);
594 TestNotEquals(*source1, *source2, "Tile Mode differs");
595 }
596 {
597 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
598 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
599 kTestStops, DlTileMode::kClamp, &kTestMatrix2);
600 TestNotEquals(*source1, *source2, "Matrix differs");
601 }
602}

◆ TEST() [108/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConicalGradientShared   
)

Definition at line 475 of file dl_color_source_unittests.cc.

475 {
476 std::shared_ptr<DlColorSource> source = DlColorSource::MakeConical(
477 kTestPoints[0], 10.0, kTestPoints[1], 20.0, kTestStopCount, kTestColors,
478 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
479 ASSERT_NE(source->shared().get(), source.get());
480 ASSERT_EQ(*source->shared().get(), *source.get());
481}

◆ TEST() [109/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConvertRuntimeEffect   
)

Definition at line 224 of file dl_sk_conversions_unittests.cc.

224 {
225 const sk_sp<DlRuntimeEffect> kTestRuntimeEffect1 = DlRuntimeEffect::MakeSkia(
227 SkString("vec4 main(vec2 p) { return vec4(0); }"))
228 .effect);
229 const sk_sp<DlRuntimeEffect> kTestRuntimeEffect2 = DlRuntimeEffect::MakeSkia(
231 SkString("vec4 main(vec2 p) { return vec4(1); }"))
232 .effect);
233 std::shared_ptr<DlRuntimeEffectColorSource> source1 =
234 DlColorSource::MakeRuntimeEffect(
235 kTestRuntimeEffect1, {}, std::make_shared<std::vector<uint8_t>>());
236 std::shared_ptr<DlRuntimeEffectColorSource> source2 =
237 DlColorSource::MakeRuntimeEffect(
238 kTestRuntimeEffect2, {}, std::make_shared<std::vector<uint8_t>>());
239 std::shared_ptr<DlRuntimeEffectColorSource> source3 =
240 DlColorSource::MakeRuntimeEffect(
241 nullptr, {}, std::make_shared<std::vector<uint8_t>>());
242
243 ASSERT_NE(ToSk(source1), nullptr);
244 ASSERT_NE(ToSk(source2), nullptr);
245 ASSERT_EQ(ToSk(source3), nullptr);
246}
static Result MakeForShader(SkString sksl, const Options &)
SkPaint ToSk(const DlPaint &paint)

◆ TEST() [110/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ConvertRuntimeEffectWithNullSampler   
)

Definition at line 248 of file dl_sk_conversions_unittests.cc.

248 {
249 const sk_sp<DlRuntimeEffect> kTestRuntimeEffect1 = DlRuntimeEffect::MakeSkia(
251 SkString("vec4 main(vec2 p) { return vec4(0); }"))
252 .effect);
253 std::shared_ptr<DlRuntimeEffectColorSource> source1 =
254 DlColorSource::MakeRuntimeEffect(
255 kTestRuntimeEffect1, {nullptr},
256 std::make_shared<std::vector<uint8_t>>());
257
258 ASSERT_EQ(ToSk(source1), nullptr);
259}

◆ TEST() [111/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ImageAsImage   
)

Definition at line 148 of file dl_color_source_unittests.cc.

148 {
149 DlImageColorSource source(kTestImage1, DlTileMode::kClamp, DlTileMode::kClamp,
150 DlImageSampling::kLinear, &kTestMatrix1);
151 ASSERT_NE(source.asImage(), nullptr);
152 ASSERT_EQ(source.asImage(), &source);
153
154 ASSERT_EQ(source.asColor(), nullptr);
155 ASSERT_EQ(source.asLinearGradient(), nullptr);
156 ASSERT_EQ(source.asRadialGradient(), nullptr);
157 ASSERT_EQ(source.asConicalGradient(), nullptr);
158 ASSERT_EQ(source.asSweepGradient(), nullptr);
159}

◆ TEST() [112/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ImageConstructor   
)

Definition at line 136 of file dl_color_source_unittests.cc.

136 {
137 DlImageColorSource source(kTestImage1, DlTileMode::kClamp, DlTileMode::kClamp,
138 DlImageSampling::kLinear, &kTestMatrix1);
139}

◆ TEST() [113/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ImageContents   
)

Definition at line 161 of file dl_color_source_unittests.cc.

161 {
162 DlImageColorSource source(kTestImage1, DlTileMode::kRepeat,
163 DlTileMode::kMirror, DlImageSampling::kLinear,
164 &kTestMatrix1);
165 ASSERT_EQ(source.image(), kTestImage1);
166 ASSERT_EQ(source.horizontal_tile_mode(), DlTileMode::kRepeat);
167 ASSERT_EQ(source.vertical_tile_mode(), DlTileMode::kMirror);
168 ASSERT_EQ(source.sampling(), DlImageSampling::kLinear);
169 ASSERT_EQ(source.matrix(), kTestMatrix1);
170 ASSERT_EQ(source.is_opaque(), true);
171}

◆ TEST() [114/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ImageEquals   
)

Definition at line 185 of file dl_color_source_unittests.cc.

185 {
186 DlImageColorSource source1(kTestImage1, DlTileMode::kClamp,
187 DlTileMode::kMirror, DlImageSampling::kLinear,
188 &kTestMatrix1);
189 DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
190 DlTileMode::kMirror, DlImageSampling::kLinear,
191 &kTestMatrix1);
192 TestEquals(source1, source2);
193}

◆ TEST() [115/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ImageNotEquals   
)

Definition at line 195 of file dl_color_source_unittests.cc.

195 {
196 DlImageColorSource source1(kTestImage1, DlTileMode::kClamp,
197 DlTileMode::kMirror, DlImageSampling::kLinear,
198 &kTestMatrix1);
199 {
200 DlImageColorSource source2(kTestAlphaImage1, DlTileMode::kClamp,
201 DlTileMode::kMirror, DlImageSampling::kLinear,
202 &kTestMatrix1);
203 TestNotEquals(source1, source2, "Image differs");
204 }
205 {
206 DlImageColorSource source2(kTestImage1, DlTileMode::kRepeat,
207 DlTileMode::kMirror, DlImageSampling::kLinear,
208 &kTestMatrix1);
209 TestNotEquals(source1, source2, "hTileMode differs");
210 }
211 {
212 DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
213 DlTileMode::kRepeat, DlImageSampling::kLinear,
214 &kTestMatrix1);
215 TestNotEquals(source1, source2, "vTileMode differs");
216 }
217 {
218 DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
219 DlTileMode::kMirror, DlImageSampling::kCubic,
220 &kTestMatrix1);
221 TestNotEquals(source1, source2, "Sampling differs");
222 }
223 {
224 DlImageColorSource source2(kTestImage1, DlTileMode::kClamp,
225 DlTileMode::kMirror, DlImageSampling::kLinear,
226 &kTestMatrix2);
227 TestNotEquals(source1, source2, "Matrix differs");
228 }
229}

◆ TEST() [116/709]

flutter::testing::TEST ( DisplayListColorSource  ,
ImageShared   
)

Definition at line 141 of file dl_color_source_unittests.cc.

141 {
142 DlImageColorSource source(kTestImage1, DlTileMode::kClamp, DlTileMode::kClamp,
143 DlImageSampling::kLinear, &kTestMatrix1);
144 ASSERT_NE(source.shared().get(), &source);
145 ASSERT_EQ(*source.shared(), source);
146}

◆ TEST() [117/709]

flutter::testing::TEST ( DisplayListColorSource  ,
LinearGradientAsLinear   
)

Definition at line 245 of file dl_color_source_unittests.cc.

245 {
246 std::shared_ptr<DlColorSource> source = DlColorSource::MakeLinear(
247 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
248 DlTileMode::kClamp, &kTestMatrix1);
249 ASSERT_NE(source->asLinearGradient(), nullptr);
250 ASSERT_EQ(source->asLinearGradient(), source.get());
251
252 ASSERT_EQ(source->asColor(), nullptr);
253 ASSERT_EQ(source->asImage(), nullptr);
254 ASSERT_EQ(source->asRadialGradient(), nullptr);
255 ASSERT_EQ(source->asConicalGradient(), nullptr);
256 ASSERT_EQ(source->asSweepGradient(), nullptr);
257 ASSERT_EQ(source->asRuntimeEffect(), nullptr);
258}

◆ TEST() [118/709]

flutter::testing::TEST ( DisplayListColorSource  ,
LinearGradientConstructor   
)

Definition at line 231 of file dl_color_source_unittests.cc.

231 {
232 std::shared_ptr<DlColorSource> source = DlColorSource::MakeLinear(
233 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
234 DlTileMode::kClamp, &kTestMatrix1);
235}

◆ TEST() [119/709]

flutter::testing::TEST ( DisplayListColorSource  ,
LinearGradientContents   
)

Definition at line 260 of file dl_color_source_unittests.cc.

260 {
261 std::shared_ptr<DlColorSource> source = DlColorSource::MakeLinear(
262 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
263 DlTileMode::kClamp, &kTestMatrix1);
264 ASSERT_EQ(source->asLinearGradient()->start_point(), kTestPoints[0]);
265 ASSERT_EQ(source->asLinearGradient()->end_point(), kTestPoints[1]);
266 ASSERT_EQ(source->asLinearGradient()->stop_count(), kTestStopCount);
267 for (int i = 0; i < kTestStopCount; i++) {
268 ASSERT_EQ(source->asLinearGradient()->colors()[i], kTestColors[i]);
269 ASSERT_EQ(source->asLinearGradient()->stops()[i], kTestStops[i]);
270 }
271 ASSERT_EQ(source->asLinearGradient()->tile_mode(), DlTileMode::kClamp);
272 ASSERT_EQ(source->asLinearGradient()->matrix(), kTestMatrix1);
273 ASSERT_EQ(source->is_opaque(), true);
274}

◆ TEST() [120/709]

flutter::testing::TEST ( DisplayListColorSource  ,
LinearGradientEquals   
)

Definition at line 292 of file dl_color_source_unittests.cc.

292 {
293 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeLinear(
294 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
295 DlTileMode::kClamp, &kTestMatrix1);
296 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
297 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
298 DlTileMode::kClamp, &kTestMatrix1);
299 TestEquals(*source1, *source2);
300}

◆ TEST() [121/709]

flutter::testing::TEST ( DisplayListColorSource  ,
LinearGradientNotEquals   
)

Definition at line 302 of file dl_color_source_unittests.cc.

302 {
303 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeLinear(
304 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
305 DlTileMode::kClamp, &kTestMatrix1);
306 {
307 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
308 kTestPoints2[0], kTestPoints[1], kTestStopCount, kTestColors,
309 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
310 TestNotEquals(*source1, *source2, "Point 0 differs");
311 }
312 {
313 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
314 kTestPoints[0], kTestPoints2[1], kTestStopCount, kTestColors,
315 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
316 TestNotEquals(*source1, *source2, "Point 1 differs");
317 }
318 {
319 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
320 kTestPoints[0], kTestPoints[1], 2, kTestColors, kTestStops, //
321 DlTileMode::kClamp, &kTestMatrix1);
322 TestNotEquals(*source1, *source2, "Stop count differs");
323 }
324 {
325 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
326 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestAlphaColors,
327 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
328 TestNotEquals(*source1, *source2, "Colors differ");
329 }
330 {
331 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
332 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors,
333 kTestStops2, DlTileMode::kClamp, &kTestMatrix1);
334 TestNotEquals(*source1, *source2, "Stops differ");
335 }
336 {
337 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
338 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
339 DlTileMode::kMirror, &kTestMatrix1);
340 TestNotEquals(*source1, *source2, "Tile Mode differs");
341 }
342 {
343 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
344 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
345 DlTileMode::kClamp, &kTestMatrix2);
346 TestNotEquals(*source1, *source2, "Matrix differs");
347 }
348}

◆ TEST() [122/709]

flutter::testing::TEST ( DisplayListColorSource  ,
LinearGradientShared   
)

Definition at line 237 of file dl_color_source_unittests.cc.

237 {
238 std::shared_ptr<DlColorSource> source = DlColorSource::MakeLinear(
239 kTestPoints[0], kTestPoints[1], kTestStopCount, kTestColors, kTestStops,
240 DlTileMode::kClamp, &kTestMatrix1);
241 ASSERT_NE(source->shared().get(), source.get());
242 ASSERT_EQ(*source->shared().get(), *source.get());
243}

◆ TEST() [123/709]

flutter::testing::TEST ( DisplayListColorSource  ,
RadialGradientAsRadial   
)

Definition at line 364 of file dl_color_source_unittests.cc.

364 {
365 std::shared_ptr<DlColorSource> source = DlColorSource::MakeRadial(
366 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
367 DlTileMode::kClamp, &kTestMatrix1);
368 ASSERT_NE(source->asRadialGradient(), nullptr);
369 ASSERT_EQ(source->asRadialGradient(), source.get());
370
371 ASSERT_EQ(source->asColor(), nullptr);
372 ASSERT_EQ(source->asImage(), nullptr);
373 ASSERT_EQ(source->asLinearGradient(), nullptr);
374 ASSERT_EQ(source->asConicalGradient(), nullptr);
375 ASSERT_EQ(source->asSweepGradient(), nullptr);
376 ASSERT_EQ(source->asRuntimeEffect(), nullptr);
377}

◆ TEST() [124/709]

flutter::testing::TEST ( DisplayListColorSource  ,
RadialGradientConstructor   
)

Definition at line 350 of file dl_color_source_unittests.cc.

350 {
351 std::shared_ptr<DlColorSource> source = DlColorSource::MakeRadial(
352 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
353 DlTileMode::kClamp, &kTestMatrix1);
354}

◆ TEST() [125/709]

flutter::testing::TEST ( DisplayListColorSource  ,
RadialGradientContents   
)

Definition at line 379 of file dl_color_source_unittests.cc.

379 {
380 std::shared_ptr<DlColorSource> source = DlColorSource::MakeRadial(
381 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
382 DlTileMode::kClamp, &kTestMatrix1);
383 ASSERT_EQ(source->asRadialGradient()->center(), kTestPoints[0]);
384 ASSERT_EQ(source->asRadialGradient()->radius(), 10.0);
385 ASSERT_EQ(source->asRadialGradient()->stop_count(), kTestStopCount);
386 for (int i = 0; i < kTestStopCount; i++) {
387 ASSERT_EQ(source->asRadialGradient()->colors()[i], kTestColors[i]);
388 ASSERT_EQ(source->asRadialGradient()->stops()[i], kTestStops[i]);
389 }
390 ASSERT_EQ(source->asRadialGradient()->tile_mode(), DlTileMode::kClamp);
391 ASSERT_EQ(source->asRadialGradient()->matrix(), kTestMatrix1);
392 ASSERT_EQ(source->is_opaque(), true);
393}

◆ TEST() [126/709]

flutter::testing::TEST ( DisplayListColorSource  ,
RadialGradientEquals   
)

Definition at line 411 of file dl_color_source_unittests.cc.

411 {
412 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeRadial(
413 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
414 DlTileMode::kClamp, &kTestMatrix1);
415 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
416 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
417 DlTileMode::kClamp, &kTestMatrix1);
418 TestEquals(*source1, *source2);
419}

◆ TEST() [127/709]

flutter::testing::TEST ( DisplayListColorSource  ,
RadialGradientNotEquals   
)

Definition at line 421 of file dl_color_source_unittests.cc.

421 {
422 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeRadial(
423 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
424 DlTileMode::kClamp, &kTestMatrix1);
425 {
426 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
427 kTestPoints2[0], 10.0, kTestStopCount, kTestColors, kTestStops,
428 DlTileMode::kClamp, &kTestMatrix1);
429 TestNotEquals(*source1, *source2, "Center differs");
430 }
431 {
432 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
433 kTestPoints[0], 20.0, kTestStopCount, kTestColors, kTestStops,
434 DlTileMode::kClamp, &kTestMatrix1);
435 TestNotEquals(*source1, *source2, "Radius differs");
436 }
437 {
438 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
439 kTestPoints[0], 10.0, 2, kTestColors, kTestStops, //
440 DlTileMode::kClamp, &kTestMatrix1);
441 TestNotEquals(*source1, *source2, "Stop count differs");
442 }
443 {
444 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
445 kTestPoints[0], 10.0, kTestStopCount, kTestAlphaColors, kTestStops,
446 DlTileMode::kClamp, &kTestMatrix1);
447 TestNotEquals(*source1, *source2, "Colors differ");
448 }
449 {
450 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
451 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops2,
452 DlTileMode::kClamp, &kTestMatrix1);
453 TestNotEquals(*source1, *source2, "Stops differ");
454 }
455 {
456 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
457 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
458 DlTileMode::kMirror, &kTestMatrix1);
459 TestNotEquals(*source1, *source2, "Tile Mode differs");
460 }
461 {
462 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
463 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
464 DlTileMode::kClamp, &kTestMatrix2);
465 TestNotEquals(*source1, *source2, "Matrix differs");
466 }
467}

◆ TEST() [128/709]

flutter::testing::TEST ( DisplayListColorSource  ,
RadialGradientShared   
)

Definition at line 356 of file dl_color_source_unittests.cc.

356 {
357 std::shared_ptr<DlColorSource> source = DlColorSource::MakeRadial(
358 kTestPoints[0], 10.0, kTestStopCount, kTestColors, kTestStops,
359 DlTileMode::kClamp, &kTestMatrix1);
360 ASSERT_NE(source->shared().get(), source.get());
361 ASSERT_EQ(*source->shared().get(), *source.get());
362}

◆ TEST() [129/709]

flutter::testing::TEST ( DisplayListColorSource  ,
RuntimeEffect   
)

Definition at line 731 of file dl_color_source_unittests.cc.

731 {
732 std::shared_ptr<DlRuntimeEffectColorSource> source1 =
733 DlColorSource::MakeRuntimeEffect(
734 kTestRuntimeEffect1, {}, std::make_shared<std::vector<uint8_t>>());
735 std::shared_ptr<DlRuntimeEffectColorSource> source2 =
736 DlColorSource::MakeRuntimeEffect(
737 kTestRuntimeEffect2, {}, std::make_shared<std::vector<uint8_t>>());
738 std::shared_ptr<DlRuntimeEffectColorSource> source3 =
739 DlColorSource::MakeRuntimeEffect(
740 nullptr, {}, std::make_shared<std::vector<uint8_t>>());
741
742 ASSERT_EQ(source1->type(), DlColorSourceType::kRuntimeEffect);
743 ASSERT_EQ(source1->asRuntimeEffect(), source1.get());
744 ASSERT_NE(source2->asRuntimeEffect(), source1.get());
745
746 ASSERT_EQ(source1->asImage(), nullptr);
747 ASSERT_EQ(source1->asColor(), nullptr);
748 ASSERT_EQ(source1->asLinearGradient(), nullptr);
749 ASSERT_EQ(source1->asRadialGradient(), nullptr);
750 ASSERT_EQ(source1->asConicalGradient(), nullptr);
751 ASSERT_EQ(source1->asSweepGradient(), nullptr);
752
753 TestEquals(source1, source1);
754 TestEquals(source3, source3);
755 TestNotEquals(source1, source2, "SkRuntimeEffect differs");
756 TestNotEquals(source2, source3, "SkRuntimeEffect differs");
757}

◆ TEST() [130/709]

flutter::testing::TEST ( DisplayListColorSource  ,
SweepGradientAsSweep   
)

Definition at line 618 of file dl_color_source_unittests.cc.

618 {
619 std::shared_ptr<DlColorSource> source = DlColorSource::MakeSweep(
620 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
621 DlTileMode::kClamp, &kTestMatrix1);
622 ASSERT_NE(source->asSweepGradient(), nullptr);
623 ASSERT_EQ(source->asSweepGradient(), source.get());
624
625 ASSERT_EQ(source->asColor(), nullptr);
626 ASSERT_EQ(source->asImage(), nullptr);
627 ASSERT_EQ(source->asLinearGradient(), nullptr);
628 ASSERT_EQ(source->asRadialGradient(), nullptr);
629 ASSERT_EQ(source->asConicalGradient(), nullptr);
630 ASSERT_EQ(source->asRuntimeEffect(), nullptr);
631}

◆ TEST() [131/709]

flutter::testing::TEST ( DisplayListColorSource  ,
SweepGradientConstructor   
)

Definition at line 604 of file dl_color_source_unittests.cc.

604 {
605 std::shared_ptr<DlColorSource> source = DlColorSource::MakeSweep(
606 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
607 DlTileMode::kClamp, &kTestMatrix1);
608}

◆ TEST() [132/709]

flutter::testing::TEST ( DisplayListColorSource  ,
SweepGradientContents   
)

Definition at line 633 of file dl_color_source_unittests.cc.

633 {
634 std::shared_ptr<DlColorSource> source = DlColorSource::MakeSweep(
635 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
636 DlTileMode::kClamp, &kTestMatrix1);
637 ASSERT_EQ(source->asSweepGradient()->center(), kTestPoints[0]);
638 ASSERT_EQ(source->asSweepGradient()->start(), 10.0);
639 ASSERT_EQ(source->asSweepGradient()->end(), 20.0);
640 ASSERT_EQ(source->asSweepGradient()->stop_count(), kTestStopCount);
641 for (int i = 0; i < kTestStopCount; i++) {
642 ASSERT_EQ(source->asSweepGradient()->colors()[i], kTestColors[i]);
643 ASSERT_EQ(source->asSweepGradient()->stops()[i], kTestStops[i]);
644 }
645 ASSERT_EQ(source->asSweepGradient()->tile_mode(), DlTileMode::kClamp);
646 ASSERT_EQ(source->asSweepGradient()->matrix(), kTestMatrix1);
647 ASSERT_EQ(source->is_opaque(), true);
648}

◆ TEST() [133/709]

flutter::testing::TEST ( DisplayListColorSource  ,
SweepGradientEquals   
)

Definition at line 667 of file dl_color_source_unittests.cc.

667 {
668 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeSweep(
669 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
670 DlTileMode::kClamp, &kTestMatrix1);
671 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
672 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
673 DlTileMode::kClamp, &kTestMatrix1);
674 TestEquals(*source1, *source2);
675}

◆ TEST() [134/709]

flutter::testing::TEST ( DisplayListColorSource  ,
SweepGradientNotEquals   
)

Definition at line 677 of file dl_color_source_unittests.cc.

677 {
678 std::shared_ptr<DlColorSource> source1 = DlColorSource::MakeSweep(
679 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
680 DlTileMode::kClamp, &kTestMatrix1);
681 {
682 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
683 kTestPoints2[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
684 DlTileMode::kClamp, &kTestMatrix1);
685 TestNotEquals(*source1, *source2, "Center differs");
686 }
687 {
688 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
689 kTestPoints[0], 15.0, 20.0, kTestStopCount, kTestColors, kTestStops,
690 DlTileMode::kClamp, &kTestMatrix1);
691 TestNotEquals(*source1, *source2, "Start Angle differs");
692 }
693 {
694 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
695 kTestPoints[0], 10.0, 25.0, kTestStopCount, kTestColors, kTestStops,
696 DlTileMode::kClamp, &kTestMatrix1);
697 TestNotEquals(*source1, *source2, "End Angle differs");
698 }
699 {
700 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
701 kTestPoints[0], 10.0, 20.0, 2, kTestColors, kTestStops, //
702 DlTileMode::kClamp, &kTestMatrix1);
703 TestNotEquals(*source1, *source2, "Stop count differs");
704 }
705 {
706 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
707 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestAlphaColors,
708 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
709 TestNotEquals(*source1, *source2, "Colors differ");
710 }
711 {
712 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
713 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops2,
714 DlTileMode::kClamp, &kTestMatrix1);
715 TestNotEquals(*source1, *source2, "Stops differ");
716 }
717 {
718 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
719 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
720 DlTileMode::kMirror, &kTestMatrix1);
721 TestNotEquals(*source1, *source2, "Tile Mode differs");
722 }
723 {
724 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
725 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
726 DlTileMode::kClamp, &kTestMatrix2);
727 TestNotEquals(*source1, *source2, "Matrix differs");
728 }
729}

◆ TEST() [135/709]

flutter::testing::TEST ( DisplayListColorSource  ,
SweepGradientShared   
)

Definition at line 610 of file dl_color_source_unittests.cc.

610 {
611 std::shared_ptr<DlColorSource> source = DlColorSource::MakeSweep(
612 kTestPoints[0], 10.0, 20.0, kTestStopCount, kTestColors, kTestStops,
613 DlTileMode::kClamp, &kTestMatrix1);
614 ASSERT_NE(source->shared().get(), source.get());
615 ASSERT_EQ(*source->shared().get(), *source.get());
616}

◆ TEST() [136/709]

flutter::testing::TEST ( DisplayListComplexity  ,
AntiAliasing   
)

Definition at line 80 of file dl_complexity_unittests.cc.

80 {
81 DisplayListBuilder builder_no_aa;
82 builder_no_aa.DrawLine(SkPoint::Make(0, 0), SkPoint::Make(100, 100),
83 DlPaint());
84 auto display_list_no_aa = builder_no_aa.Build();
85
86 DisplayListBuilder builder_aa;
87 builder_aa.DrawLine(SkPoint::Make(0, 0), SkPoint::Make(100, 100),
88 DlPaint().setAntiAlias(true));
89 auto display_list_aa = builder_aa.Build();
90
91 auto calculators = AccumulatorCalculators();
92 for (auto calculator : calculators) {
93 ASSERT_NE(calculator->Compute(display_list_no_aa.get()),
94 calculator->Compute(display_list_aa.get()));
95 }
96}
void DrawLine(const SkPoint &p0, const SkPoint &p1, const DlPaint &paint) override
sk_sp< DisplayList > Build()
Definition dl_builder.cc:67

◆ TEST() [137/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DisplayListCeiling   
)

Definition at line 56 of file dl_complexity_unittests.cc.

56 {
57 auto display_list = GetSampleDisplayList();
58
59 auto calculators = AccumulatorCalculators();
60 for (auto calculator : calculators) {
61 calculator->SetComplexityCeiling(10u);
62 ASSERT_EQ(calculator->Compute(display_list.get()), 10u);
63 calculator->SetComplexityCeiling(std::numeric_limits<unsigned int>::max());
64 }
65}
sk_sp< DisplayList > GetSampleDisplayList()

◆ TEST() [138/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawArc   
)

Definition at line 281 of file dl_complexity_unittests.cc.

281 {
282 DisplayListBuilder builder;
283 builder.DrawArc(SkRect::MakeXYWH(10, 10, 100, 80), 0.0f, 10.0f, true,
284 DlPaint());
285 auto display_list = builder.Build();
286
287 auto calculators = AccumulatorCalculators();
288 for (auto calculator : calculators) {
289 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
290 }
291}

◆ TEST() [139/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawAtlas   
)

Definition at line 416 of file dl_complexity_unittests.cc.

416 {
421 bitmap.allocPixels(info, 0);
423
424 std::vector<SkRect> rects;
425 std::vector<SkRSXform> xforms;
426 for (int i = 0; i < 10; i++) {
427 rects.push_back(SkRect::MakeXYWH(0, 0, 10, 10));
428 xforms.push_back(SkRSXform::Make(1, 0, 0, 0));
429 }
430
431 DisplayListBuilder builder;
432 builder.DrawAtlas(DlImage::Make(image), xforms.data(), rects.data(), nullptr,
433 10, DlBlendMode::kSrc, DlImageSampling::kNearestNeighbor,
434 nullptr, nullptr);
435 auto display_list = builder.Build();
436
437 auto calculators = AccumulatorCalculators();
438 for (auto calculator : calculators) {
439 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
440 }
441}
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty)
Definition SkRSXform.h:24

◆ TEST() [140/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawCircle   
)

Definition at line 242 of file dl_complexity_unittests.cc.

242 {
243 DisplayListBuilder builder;
244 builder.DrawCircle(SkPoint::Make(50, 50), 10.0f, DlPaint());
245 auto display_list = builder.Build();
246
247 auto calculators = AccumulatorCalculators();
248 for (auto calculator : calculators) {
249 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
250 }
251}

◆ TEST() [141/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawDRRect   
)

Definition at line 266 of file dl_complexity_unittests.cc.

266 {
267 DisplayListBuilder builder;
268 SkRRect outer =
269 SkRRect::MakeRectXY(SkRect::MakeXYWH(10, 10, 80, 80), 2.0f, 3.0f);
270 SkRRect inner =
271 SkRRect::MakeRectXY(SkRect::MakeXYWH(15, 15, 70, 70), 1.5f, 1.5f);
272 builder.DrawDRRect(outer, inner, DlPaint());
273 auto display_list = builder.Build();
274
275 auto calculators = AccumulatorCalculators();
276 for (auto calculator : calculators) {
277 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
278 }
279}
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition SkRRect.h:180

◆ TEST() [142/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawImage   
)

Definition at line 353 of file dl_complexity_unittests.cc.

353 {
358 bitmap.allocPixels(info, 0);
360
361 DisplayListBuilder builder;
362 builder.DrawImage(DlImage::Make(image), SkPoint::Make(0, 0),
363 DlImageSampling::kNearestNeighbor, nullptr);
364 auto display_list = builder.Build();
365
366 auto calculators = AccumulatorCalculators();
367 for (auto calculator : calculators) {
368 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
369 }
370}

◆ TEST() [143/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawImageNine   
)

Definition at line 372 of file dl_complexity_unittests.cc.

372 {
377 bitmap.allocPixels(info, 0);
379
380 SkIRect center = SkIRect::MakeXYWH(5, 5, 20, 20);
381 SkRect dest = SkRect::MakeXYWH(0, 0, 50, 50);
382
383 DisplayListBuilder builder;
384 builder.DrawImageNine(DlImage::Make(image), center, dest,
385 DlFilterMode::kNearest, nullptr);
386 auto display_list = builder.Build();
387
388 auto calculators = AccumulatorCalculators();
389 for (auto calculator : calculators) {
390 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
391 }
392}

◆ TEST() [144/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawImageRect   
)

Definition at line 394 of file dl_complexity_unittests.cc.

394 {
399 bitmap.allocPixels(info, 0);
401
402 SkRect src = SkRect::MakeXYWH(0, 0, 50, 50);
403 SkRect dest = SkRect::MakeXYWH(0, 0, 50, 50);
404
405 DisplayListBuilder builder;
406 builder.DrawImageRect(DlImage::Make(image), src, dest,
407 DlImageSampling::kNearestNeighbor, nullptr);
408 auto display_list = builder.Build();
409
410 auto calculators = AccumulatorCalculators();
411 for (auto calculator : calculators) {
412 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
413 }
414}

◆ TEST() [145/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawOval   
)

Definition at line 231 of file dl_complexity_unittests.cc.

231 {
232 DisplayListBuilder builder;
233 builder.DrawOval(SkRect::MakeXYWH(10, 10, 100, 80), DlPaint());
234 auto display_list = builder.Build();
235
236 auto calculators = AccumulatorCalculators();
237 for (auto calculator : calculators) {
238 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
239 }
240}

◆ TEST() [146/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawPath   
)

Definition at line 145 of file dl_complexity_unittests.cc.

145 {
146 DisplayListBuilder builder_line;
147 SkPath line_path;
148 line_path.moveTo(SkPoint::Make(0, 0));
149 line_path.lineTo(SkPoint::Make(10, 10));
150 line_path.close();
151 builder_line.DrawPath(line_path, DlPaint());
152 auto display_list_line = builder_line.Build();
153
154 DisplayListBuilder builder_quad;
159 builder_quad.DrawPath(quad_path, DlPaint());
160 auto display_list_quad = builder_quad.Build();
161
162 DisplayListBuilder builder_conic;
163 SkPath conic_path;
164 conic_path.moveTo(SkPoint::Make(0, 0));
165 conic_path.conicTo(SkPoint::Make(10, 10), SkPoint::Make(10, 20), 1.5f);
166 conic_path.close();
167 builder_conic.DrawPath(conic_path, DlPaint());
168 auto display_list_conic = builder_conic.Build();
169
170 DisplayListBuilder builder_cubic;
174 SkPoint::Make(20, 20));
175 builder_cubic.DrawPath(cubic_path, DlPaint());
176 auto display_list_cubic = builder_cubic.Build();
177
178 auto calculators = AccumulatorCalculators();
179 for (auto calculator : calculators) {
180 ASSERT_NE(calculator->Compute(display_list_line.get()), 0u);
181 ASSERT_NE(calculator->Compute(display_list_quad.get()), 0u);
182 ASSERT_NE(calculator->Compute(display_list_conic.get()), 0u);
183 ASSERT_NE(calculator->Compute(display_list_cubic.get()), 0u);
184 }
185}
SkPath & moveTo(SkScalar x, SkScalar y)
Definition SkPath.cpp:678
SkPath & lineTo(SkScalar x, SkScalar y)
Definition SkPath.cpp:718
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition SkPath.cpp:736
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition SkPath.cpp:789
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
Definition SkPath.cpp:756
SkPath & close()
Definition SkPath.cpp:813
void DrawPath(const SkPath &path, const DlPaint &paint) override
SkPath quad_path()
SkPath cubic_path()

◆ TEST() [147/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawPoints   
)

Definition at line 328 of file dl_complexity_unittests.cc.

328 {
329 auto points = GetTestPoints();
330 DisplayListBuilder builder_lines;
331 builder_lines.DrawPoints(DlCanvas::PointMode::kLines, points.size(),
332 points.data(), DlPaint());
333 auto display_list_lines = builder_lines.Build();
334
335 DisplayListBuilder builder_points;
336 builder_points.DrawPoints(DlCanvas::PointMode::kPoints, points.size(),
337 points.data(), DlPaint());
338 auto display_list_points = builder_points.Build();
339
340 DisplayListBuilder builder_polygon;
341 builder_polygon.DrawPoints(DlCanvas::PointMode::kPolygon, points.size(),
342 points.data(), DlPaint());
343 auto display_list_polygon = builder_polygon.Build();
344
345 auto calculators = AccumulatorCalculators();
346 for (auto calculator : calculators) {
347 ASSERT_NE(calculator->Compute(display_list_lines.get()), 0u);
348 ASSERT_NE(calculator->Compute(display_list_points.get()), 0u);
349 ASSERT_NE(calculator->Compute(display_list_polygon.get()), 0u);
350 }
351}
void DrawPoints(PointMode mode, uint32_t count, const SkPoint pts[], const DlPaint &paint) override
std::vector< SkPoint > GetTestPoints(size_t count, SkISize canvas_size)

◆ TEST() [148/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawRRect   
)

Definition at line 253 of file dl_complexity_unittests.cc.

253 {
254 DisplayListBuilder builder;
255 builder.DrawRRect(
256 SkRRect::MakeRectXY(SkRect::MakeXYWH(10, 10, 80, 80), 2.0f, 3.0f),
257 DlPaint());
258 auto display_list = builder.Build();
259
260 auto calculators = AccumulatorCalculators();
261 for (auto calculator : calculators) {
262 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
263 }
264}

◆ TEST() [149/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawShadow   
)

Definition at line 187 of file dl_complexity_unittests.cc.

187 {
188 DisplayListBuilder builder_line;
189 SkPath line_path;
190 line_path.moveTo(SkPoint::Make(0, 0));
191 line_path.lineTo(SkPoint::Make(10, 10));
192 line_path.close();
193 builder_line.DrawShadow(line_path, DlColor(SK_ColorRED), 10.0f, false, 1.0f);
194 auto display_list_line = builder_line.Build();
195
196 DisplayListBuilder builder_quad;
201 builder_quad.DrawShadow(quad_path, DlColor(SK_ColorRED), 10.0f, false, 1.0f);
202 auto display_list_quad = builder_quad.Build();
203
204 DisplayListBuilder builder_conic;
205 SkPath conic_path;
206 conic_path.moveTo(SkPoint::Make(0, 0));
207 conic_path.conicTo(SkPoint::Make(10, 10), SkPoint::Make(10, 20), 1.5f);
208 conic_path.close();
209 builder_conic.DrawShadow(conic_path, DlColor(SK_ColorRED), 10.0f, false,
210 1.0f);
211 auto display_list_conic = builder_conic.Build();
212
213 DisplayListBuilder builder_cubic;
217 SkPoint::Make(20, 20));
218 builder_cubic.DrawShadow(cubic_path, DlColor(SK_ColorRED), 10.0f, false,
219 1.0f);
220 auto display_list_cubic = builder_cubic.Build();
221
222 auto calculators = AccumulatorCalculators();
223 for (auto calculator : calculators) {
224 ASSERT_NE(calculator->Compute(display_list_line.get()), 0u);
225 ASSERT_NE(calculator->Compute(display_list_quad.get()), 0u);
226 ASSERT_NE(calculator->Compute(display_list_conic.get()), 0u);
227 ASSERT_NE(calculator->Compute(display_list_cubic.get()), 0u);
228 }
229}
void DrawShadow(const SkPath &path, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override

◆ TEST() [150/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawTextBlob   
)

Definition at line 307 of file dl_complexity_unittests.cc.

307 {
308 auto text_blob = SkTextBlob::MakeFromString(
309 "The quick brown fox jumps over the lazy dog.", CreateTestFontOfSize(20));
310
311 DisplayListBuilder builder;
312 builder.DrawTextBlob(text_blob, 0.0f, 0.0f, DlPaint());
313 auto display_list = builder.Build();
314
315 DisplayListBuilder builder_multiple;
316 builder_multiple.DrawTextBlob(text_blob, 0.0f, 0.0f, DlPaint());
317 builder_multiple.DrawTextBlob(text_blob, 0.0f, 0.0f, DlPaint());
318 auto display_list_multiple = builder_multiple.Build();
319
320 auto calculators = AccumulatorCalculators();
321 for (auto calculator : calculators) {
322 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
323 ASSERT_GT(calculator->Compute(display_list_multiple.get()),
324 calculator->Compute(display_list.get()));
325 }
326}
void DrawTextBlob(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const DlPaint &paint) override
SkFont CreateTestFontOfSize(SkScalar scalar)

◆ TEST() [151/709]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawVertices   
)

Definition at line 293 of file dl_complexity_unittests.cc.

293 {
294 auto points = GetTestPoints();
295 auto vertices = DlVertices::Make(DlVertexMode::kTriangles, points.size(),
296 points.data(), nullptr, nullptr);
297 DisplayListBuilder builder;
298 builder.DrawVertices(vertices.get(), DlBlendMode::kSrc, DlPaint());
299 auto display_list = builder.Build();
300
301 auto calculators = AccumulatorCalculators();
302 for (auto calculator : calculators) {
303 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
304 }
305}

◆ TEST() [152/709]

flutter::testing::TEST ( DisplayListComplexity  ,
EmptyDisplayList   
)

Definition at line 47 of file dl_complexity_unittests.cc.

47 {
48 auto display_list = GetSampleDisplayList(0);
49
50 auto calculators = Calculators();
51 for (auto calculator : calculators) {
52 ASSERT_EQ(calculator->Compute(display_list.get()), 0u);
53 }
54}

◆ TEST() [153/709]

flutter::testing::TEST ( DisplayListComplexity  ,
NestedDisplayList   
)

Definition at line 67 of file dl_complexity_unittests.cc.

67 {
68 auto display_list = GetSampleNestedDisplayList();
69
70 auto calculators = Calculators();
71 for (auto calculator : calculators) {
72 // There's only one draw call in the "outer" DisplayList, which calls
73 // drawDisplayList with the "inner" DisplayList. To ensure we are
74 // recursing correctly into the inner DisplayList, check that we aren't
75 // returning 0 (if the function is a no-op) or 1 (as the op_count is 1)
76 ASSERT_GT(calculator->Compute(display_list.get()), 1u);
77 }
78}
sk_sp< DisplayList > GetSampleNestedDisplayList()

◆ TEST() [154/709]

flutter::testing::TEST ( DisplayListComplexity  ,
SaveLayers   
)

Definition at line 134 of file dl_complexity_unittests.cc.

134 {
135 DisplayListBuilder builder;
136 builder.SaveLayer(nullptr, nullptr);
137 auto display_list = builder.Build();
138
139 auto calculators = AccumulatorCalculators();
140 for (auto calculator : calculators) {
141 ASSERT_NE(calculator->Compute(display_list.get()), 0u);
142 }
143}

◆ TEST() [155/709]

flutter::testing::TEST ( DisplayListComplexity  ,
StrokeWidth   
)

Definition at line 98 of file dl_complexity_unittests.cc.

98 {
99 DisplayListBuilder builder_stroke_0;
100 builder_stroke_0.DrawLine(SkPoint::Make(0, 0), SkPoint::Make(100, 100),
101 DlPaint().setStrokeWidth(0.0f));
102 auto display_list_stroke_0 = builder_stroke_0.Build();
103
104 DisplayListBuilder builder_stroke_1;
105 builder_stroke_0.DrawLine(SkPoint::Make(0, 0), SkPoint::Make(100, 100),
106 DlPaint().setStrokeWidth(1.0f));
107 auto display_list_stroke_1 = builder_stroke_1.Build();
108
109 auto calculators = AccumulatorCalculators();
110 for (auto calculator : calculators) {
111 ASSERT_NE(calculator->Compute(display_list_stroke_0.get()),
112 calculator->Compute(display_list_stroke_1.get()));
113 }
114}

◆ TEST() [156/709]

flutter::testing::TEST ( DisplayListComplexity  ,
Style   
)

Definition at line 116 of file dl_complexity_unittests.cc.

116 {
117 DisplayListBuilder builder_filled;
118 builder_filled.DrawRect(SkRect::MakeXYWH(10, 10, 80, 80),
119 DlPaint().setDrawStyle(DlDrawStyle::kFill));
120 auto display_list_filled = builder_filled.Build();
121
122 DisplayListBuilder builder_stroked;
123 builder_stroked.DrawRect(SkRect::MakeXYWH(10, 10, 80, 80),
124 DlPaint().setDrawStyle(DlDrawStyle::kStroke));
125 auto display_list_stroked = builder_stroked.Build();
126
127 auto calculators = AccumulatorCalculators();
128 for (auto calculator : calculators) {
129 ASSERT_NE(calculator->Compute(display_list_filled.get()),
130 calculator->Compute(display_list_stroked.get()));
131 }
132}
void DrawRect(const SkRect &rect, const DlPaint &paint) override

◆ TEST() [157/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurAsBlur   
)

Definition at line 163 of file dl_image_filter_unittests.cc.

163 {
164 DlBlurImageFilter filter(5.0, 6.0, DlTileMode::kMirror);
165
166 ASSERT_NE(filter.asBlur(), nullptr);
167 ASSERT_EQ(filter.asBlur(), &filter);
168}

◆ TEST() [158/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurBounds   
)

Definition at line 205 of file dl_image_filter_unittests.cc.

205 {
206 DlBlurImageFilter filter = DlBlurImageFilter(5, 10, DlTileMode::kDecal);
207 SkRect input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
208 SkRect expected_output_bounds = input_bounds.makeOutset(15, 30);
209 TestBounds(filter, input_bounds, expected_output_bounds);
210}
static void TestBounds(const DlImageFilter &filter, const SkRect &sourceBounds, const SkPoint expectedLocalOutputQuad[4])
SkRect makeOutset(float dx, float dy) const
Definition SkRect.h:1002

◆ TEST() [159/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurConstructor   
)

Definition at line 152 of file dl_image_filter_unittests.cc.

152 {
153 DlBlurImageFilter filter(5.0, 6.0, DlTileMode::kMirror);
154}

◆ TEST() [160/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurContents   
)

Definition at line 170 of file dl_image_filter_unittests.cc.

170 {
171 DlBlurImageFilter filter(5.0, 6.0, DlTileMode::kMirror);
172
173 ASSERT_EQ(filter.sigma_x(), 5.0);
174 ASSERT_EQ(filter.sigma_y(), 6.0);
175 ASSERT_EQ(filter.tile_mode(), DlTileMode::kMirror);
176}

◆ TEST() [161/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurEquals   
)

Definition at line 178 of file dl_image_filter_unittests.cc.

178 {
179 DlBlurImageFilter filter1(5.0, 6.0, DlTileMode::kMirror);
180 DlBlurImageFilter filter2(5.0, 6.0, DlTileMode::kMirror);
181
182 TestEquals(filter1, filter2);
183}

◆ TEST() [162/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurNotEquals   
)

Definition at line 194 of file dl_image_filter_unittests.cc.

194 {
195 DlBlurImageFilter filter1(5.0, 6.0, DlTileMode::kMirror);
196 DlBlurImageFilter filter2(7.0, 6.0, DlTileMode::kMirror);
197 DlBlurImageFilter filter3(5.0, 8.0, DlTileMode::kMirror);
198 DlBlurImageFilter filter4(5.0, 6.0, DlTileMode::kRepeat);
199
200 TestNotEquals(filter1, filter2, "Sigma X differs");
201 TestNotEquals(filter1, filter3, "Sigma Y differs");
202 TestNotEquals(filter1, filter4, "Tile Mode differs");
203}

◆ TEST() [163/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurShared   
)

Definition at line 156 of file dl_image_filter_unittests.cc.

156 {
157 DlBlurImageFilter filter(5.0, 6.0, DlTileMode::kMirror);
158
159 ASSERT_NE(filter.shared().get(), &filter);
160 ASSERT_EQ(*filter.shared(), filter);
161}

◆ TEST() [164/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurWithLocalMatrixEquals   
)

Definition at line 185 of file dl_image_filter_unittests.cc.

185 {
186 DlBlurImageFilter filter1(5.0, 6.0, DlTileMode::kMirror);
187 DlBlurImageFilter filter2(5.0, 6.0, DlTileMode::kMirror);
188
189 SkMatrix local_matrix = SkMatrix::Translate(10, 10);
190 TestEquals(*filter1.makeWithLocalMatrix(local_matrix),
191 *filter2.makeWithLocalMatrix(local_matrix));
192}

◆ TEST() [165/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
BlurZeroSigma   
)

Definition at line 212 of file dl_image_filter_unittests.cc.

212 {
213 std::shared_ptr<DlImageFilter> filter =
214 DlBlurImageFilter::Make(0, 0, DlTileMode::kMirror);
215 ASSERT_EQ(filter, nullptr);
216 filter = DlBlurImageFilter::Make(3, SK_ScalarNaN, DlTileMode::kMirror);
217 ASSERT_EQ(filter, nullptr);
218 filter = DlBlurImageFilter::Make(SK_ScalarNaN, 3, DlTileMode::kMirror);
219 ASSERT_EQ(filter, nullptr);
220 filter =
221 DlBlurImageFilter::Make(SK_ScalarNaN, SK_ScalarNaN, DlTileMode::kMirror);
222 ASSERT_EQ(filter, nullptr);
223 filter = DlBlurImageFilter::Make(3, 0, DlTileMode::kMirror);
224 ASSERT_NE(filter, nullptr);
225 filter = DlBlurImageFilter::Make(0, 3, DlTileMode::kMirror);
226 ASSERT_NE(filter, nullptr);
227}
#define SK_ScalarNaN
Definition SkScalar.h:28

◆ TEST() [166/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterAsColorFilter   
)

Definition at line 634 of file dl_image_filter_unittests.cc.

634 {
635 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kLighten);
636 DlColorFilterImageFilter filter(dl_color_filter);
637
638 ASSERT_NE(filter.asColorFilter(), nullptr);
639 ASSERT_EQ(filter.asColorFilter(), &filter);
640}

◆ TEST() [167/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterBounds   
)

Definition at line 685 of file dl_image_filter_unittests.cc.

685 {
686 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kSrcIn);
687 DlColorFilterImageFilter filter(dl_color_filter);
688 SkRect input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
689 TestBounds(filter, input_bounds, input_bounds);
690}

◆ TEST() [168/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterConstructor   
)

Definition at line 622 of file dl_image_filter_unittests.cc.

622 {
623 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kLighten);
624 DlColorFilterImageFilter filter(dl_color_filter);
625}

◆ TEST() [169/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterContents   
)

Definition at line 642 of file dl_image_filter_unittests.cc.

642 {
643 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kLighten);
644 DlColorFilterImageFilter filter(dl_color_filter);
645
646 ASSERT_EQ(*filter.color_filter().get(), dl_color_filter);
647}

◆ TEST() [170/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterEquals   
)

Definition at line 649 of file dl_image_filter_unittests.cc.

649 {
650 DlBlendColorFilter dl_color_filter1(DlColor::kRed(), DlBlendMode::kLighten);
651 DlColorFilterImageFilter filter1(dl_color_filter1);
652
653 DlBlendColorFilter dl_color_filter2(DlColor::kRed(), DlBlendMode::kLighten);
654 DlColorFilterImageFilter filter2(dl_color_filter2);
655
656 TestEquals(filter1, filter2);
657}

◆ TEST() [171/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterModifiesTransparencyBounds   
)

Definition at line 692 of file dl_image_filter_unittests.cc.

692 {
693 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kSrcOver);
694 DlColorFilterImageFilter filter(dl_color_filter);
695 SkRect input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
696 TestInvalidBounds(filter, SkMatrix::I(), input_bounds);
697}
static const SkMatrix & I()
static void TestInvalidBounds(const DlImageFilter &filter, const SkMatrix &matrix, const SkRect &localInputBounds)

◆ TEST() [172/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterNotEquals   
)

Definition at line 671 of file dl_image_filter_unittests.cc.

671 {
672 DlBlendColorFilter dl_color_filter1(DlColor::kRed(), DlBlendMode::kLighten);
673 DlColorFilterImageFilter filter1(dl_color_filter1);
674
675 DlBlendColorFilter dl_color_filter2(DlColor::kBlue(), DlBlendMode::kLighten);
676 DlColorFilterImageFilter filter2(dl_color_filter2);
677
678 DlBlendColorFilter dl_color_filter3(DlColor::kRed(), DlBlendMode::kDarken);
679 DlColorFilterImageFilter filter3(dl_color_filter3);
680
681 TestNotEquals(filter1, filter2, "Color differs");
682 TestNotEquals(filter1, filter3, "Blend Mode differs");
683}

◆ TEST() [173/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterShared   
)

Definition at line 627 of file dl_image_filter_unittests.cc.

627 {
628 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kLighten);
629 DlColorFilterImageFilter filter(dl_color_filter);
630
631 ASSERT_EQ(*filter.shared(), filter);
632}

◆ TEST() [174/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ColorFilterWithLocalMatrixEquals   
)

Definition at line 659 of file dl_image_filter_unittests.cc.

659 {
660 DlBlendColorFilter dl_color_filter1(DlColor::kRed(), DlBlendMode::kLighten);
661 DlColorFilterImageFilter filter1(dl_color_filter1);
662
663 DlBlendColorFilter dl_color_filter2(DlColor::kRed(), DlBlendMode::kLighten);
664 DlColorFilterImageFilter filter2(dl_color_filter2);
665
666 SkMatrix local_matrix = SkMatrix::Translate(10, 10);
667 TestEquals(*filter1.makeWithLocalMatrix(local_matrix),
668 *filter2.makeWithLocalMatrix(local_matrix));
669}

◆ TEST() [175/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeAsCompose   
)

Definition at line 455 of file dl_image_filter_unittests.cc.

455 {
456 DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
457 0.5, 3.0, 15, //
458 0.0, 0.0, 1),
459 DlImageSampling::kLinear);
460 DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
461 DlComposeImageFilter filter(outer, inner);
462
463 ASSERT_NE(filter.asCompose(), nullptr);
464 ASSERT_EQ(filter.asCompose(), &filter);
465}
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition SkMatrix.h:179

◆ TEST() [176/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeBounds   
)

Definition at line 538 of file dl_image_filter_unittests.cc.

538 {
540 DlBlurImageFilter inner = DlBlurImageFilter(12, 5, DlTileMode::kDecal);
541 DlComposeImageFilter filter = DlComposeImageFilter(outer, inner);
542 SkRect input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
543 SkRect expected_output_bounds =
544 input_bounds.makeOutset(36, 15).makeOutset(5, 10);
545 TestBounds(filter, input_bounds, expected_output_bounds);
546}

◆ TEST() [177/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeBoundsWithUnboundedInner   
)

Definition at line 568 of file dl_image_filter_unittests.cc.

568 {
569 auto input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
570 auto expected_bounds = SkRect::MakeLTRB(5, 2, 95, 98);
571
572 DlBlendColorFilter color_filter(DlColor::kRed(), DlBlendMode::kSrcOver);
573 auto outer = DlBlurImageFilter(5.0, 6.0, DlTileMode::kRepeat);
574 auto inner = DlColorFilterImageFilter(color_filter.shared());
575 auto composed = DlComposeImageFilter(outer.shared(), inner.shared());
576
577 TestUnboundedBounds(composed, input_bounds, expected_bounds, expected_bounds);
578}
static sk_sp< SkImage > color_filter(const SkImage *image, SkColorFilter *colorFilter)
static void TestUnboundedBounds(DlImageFilter &filter, const SkRect &sourceBounds, const SkRect &expectedOutputBounds, const SkRect &expectedInputBounds)

◆ TEST() [178/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeBoundsWithUnboundedInnerAndOuter   
)

Definition at line 592 of file dl_image_filter_unittests.cc.

592 {
593 auto input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
594 auto expected_bounds = input_bounds;
595
596 DlBlendColorFilter color_filter1(DlColor::kRed(), DlBlendMode::kSrcOver);
597 DlBlendColorFilter color_filter2(DlColor::kBlue(), DlBlendMode::kSrcOver);
598 auto outer = DlColorFilterImageFilter(color_filter1.shared());
599 auto inner = DlColorFilterImageFilter(color_filter2.shared());
600 auto composed = DlComposeImageFilter(outer.shared(), inner.shared());
601
602 TestUnboundedBounds(composed, input_bounds, expected_bounds, expected_bounds);
603}

◆ TEST() [179/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeBoundsWithUnboundedOuter   
)

Definition at line 580 of file dl_image_filter_unittests.cc.

580 {
581 auto input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
582 auto expected_bounds = SkRect::MakeLTRB(5, 2, 95, 98);
583
584 DlBlendColorFilter color_filter(DlColor::kRed(), DlBlendMode::kSrcOver);
585 auto outer = DlColorFilterImageFilter(color_filter.shared());
586 auto inner = DlBlurImageFilter(5.0, 6.0, DlTileMode::kRepeat);
587 auto composed = DlComposeImageFilter(outer.shared(), inner.shared());
588
589 TestUnboundedBounds(composed, input_bounds, expected_bounds, expected_bounds);
590}

◆ TEST() [180/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeConstructor   
)

Definition at line 434 of file dl_image_filter_unittests.cc.

434 {
435 DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
436 0.5, 3.0, 15, //
437 0.0, 0.0, 1),
438 DlImageSampling::kLinear);
439 DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
440 DlComposeImageFilter filter(outer, inner);
441}

◆ TEST() [181/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeContents   
)

Definition at line 467 of file dl_image_filter_unittests.cc.

467 {
468 DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
469 0.5, 3.0, 15, //
470 0.0, 0.0, 1),
471 DlImageSampling::kLinear);
472 DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
473 DlComposeImageFilter filter(outer, inner);
474
475 ASSERT_EQ(*filter.outer().get(), outer);
476 ASSERT_EQ(*filter.inner().get(), inner);
477}

◆ TEST() [182/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeEquals   
)

Definition at line 479 of file dl_image_filter_unittests.cc.

479 {
480 DlMatrixImageFilter outer1(SkMatrix::MakeAll(2.0, 0.0, 10, //
481 0.5, 3.0, 15, //
482 0.0, 0.0, 1),
483 DlImageSampling::kLinear);
484 DlBlurImageFilter inner1(5.0, 6.0, DlTileMode::kMirror);
485 DlComposeImageFilter filter1(outer1, inner1);
486
487 DlMatrixImageFilter outer2(SkMatrix::MakeAll(2.0, 0.0, 10, //
488 0.5, 3.0, 15, //
489 0.0, 0.0, 1),
490 DlImageSampling::kLinear);
491 DlBlurImageFilter inner2(5.0, 6.0, DlTileMode::kMirror);
492 DlComposeImageFilter filter2(outer1, inner1);
493
494 TestEquals(filter1, filter2);
495}

◆ TEST() [183/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeNotEquals   
)

Definition at line 517 of file dl_image_filter_unittests.cc.

517 {
518 DlMatrixImageFilter outer1(SkMatrix::MakeAll(2.0, 0.0, 10, //
519 0.5, 3.0, 15, //
520 0.0, 0.0, 1),
521 DlImageSampling::kLinear);
522 DlBlurImageFilter inner1(5.0, 6.0, DlTileMode::kMirror);
523
524 DlMatrixImageFilter outer2(SkMatrix::MakeAll(5.0, 0.0, 10, //
525 0.5, 3.0, 15, //
526 0.0, 0.0, 1),
527 DlImageSampling::kLinear);
528 DlBlurImageFilter inner2(7.0, 6.0, DlTileMode::kMirror);
529
530 DlComposeImageFilter filter1(outer1, inner1);
531 DlComposeImageFilter filter2(outer2, inner1);
532 DlComposeImageFilter filter3(outer1, inner2);
533
534 TestNotEquals(filter1, filter2, "Outer differs");
535 TestNotEquals(filter1, filter3, "Inner differs");
536}

◆ TEST() [184/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeShared   
)

Definition at line 443 of file dl_image_filter_unittests.cc.

443 {
444 DlMatrixImageFilter outer(SkMatrix::MakeAll(2.0, 0.0, 10, //
445 0.5, 3.0, 15, //
446 0.0, 0.0, 1),
447 DlImageSampling::kLinear);
448 DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
449 DlComposeImageFilter filter(outer, inner);
450
451 ASSERT_NE(filter.shared().get(), &filter);
452 ASSERT_EQ(*filter.shared(), filter);
453}

◆ TEST() [185/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ComposeWithLocalMatrixEquals   
)

Definition at line 497 of file dl_image_filter_unittests.cc.

497 {
498 DlMatrixImageFilter outer1(SkMatrix::MakeAll(2.0, 0.0, 10, //
499 0.5, 3.0, 15, //
500 0.0, 0.0, 1),
501 DlImageSampling::kLinear);
502 DlBlurImageFilter inner1(5.0, 6.0, DlTileMode::kMirror);
503 DlComposeImageFilter filter1(outer1, inner1);
504
505 DlMatrixImageFilter outer2(SkMatrix::MakeAll(2.0, 0.0, 10, //
506 0.5, 3.0, 15, //
507 0.0, 0.0, 1),
508 DlImageSampling::kLinear);
509 DlBlurImageFilter inner2(5.0, 6.0, DlTileMode::kMirror);
510 DlComposeImageFilter filter2(outer1, inner1);
511
512 SkMatrix local_matrix = SkMatrix::Translate(10, 10);
513 TestEquals(*filter1.makeWithLocalMatrix(local_matrix),
514 *filter2.makeWithLocalMatrix(local_matrix));
515}

◆ TEST() [186/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateAsDilate   
)

Definition at line 240 of file dl_image_filter_unittests.cc.

240 {
241 DlDilateImageFilter filter(5.0, 6.0);
242
243 ASSERT_NE(filter.asDilate(), nullptr);
244 ASSERT_EQ(filter.asDilate(), &filter);
245}

◆ TEST() [187/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateBounds   
)

Definition at line 279 of file dl_image_filter_unittests.cc.

279 {
281 SkRect input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
282 SkRect expected_output_bounds = input_bounds.makeOutset(5, 10);
283 TestBounds(filter, input_bounds, expected_output_bounds);
284}

◆ TEST() [188/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateConstructor   
)

Definition at line 229 of file dl_image_filter_unittests.cc.

229 {
230 DlDilateImageFilter filter(5.0, 6.0);
231}

◆ TEST() [189/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateContents   
)

Definition at line 247 of file dl_image_filter_unittests.cc.

247 {
248 DlDilateImageFilter filter(5.0, 6.0);
249
250 ASSERT_EQ(filter.radius_x(), 5.0);
251 ASSERT_EQ(filter.radius_y(), 6.0);
252}

◆ TEST() [190/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateEquals   
)

Definition at line 254 of file dl_image_filter_unittests.cc.

254 {
255 DlDilateImageFilter filter1(5.0, 6.0);
256 DlDilateImageFilter filter2(5.0, 6.0);
257
258 TestEquals(filter1, filter2);
259}

◆ TEST() [191/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateNotEquals   
)

Definition at line 270 of file dl_image_filter_unittests.cc.

270 {
271 DlDilateImageFilter filter1(5.0, 6.0);
272 DlDilateImageFilter filter2(7.0, 6.0);
273 DlDilateImageFilter filter3(5.0, 8.0);
274
275 TestNotEquals(filter1, filter2, "Radius X differs");
276 TestNotEquals(filter1, filter3, "Radius Y differs");
277}

◆ TEST() [192/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateShared   
)

Definition at line 233 of file dl_image_filter_unittests.cc.

233 {
234 DlDilateImageFilter filter(5.0, 6.0);
235
236 ASSERT_NE(filter.shared().get(), &filter);
237 ASSERT_EQ(*filter.shared(), filter);
238}

◆ TEST() [193/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
DilateWithLocalMatrixEquals   
)

Definition at line 261 of file dl_image_filter_unittests.cc.

261 {
262 DlDilateImageFilter filter1(5.0, 6.0);
263 DlDilateImageFilter filter2(5.0, 6.0);
264
265 SkMatrix local_matrix = SkMatrix::Translate(10, 10);
266 TestEquals(*filter1.makeWithLocalMatrix(local_matrix),
267 *filter2.makeWithLocalMatrix(local_matrix));
268}

◆ TEST() [194/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeAsErode   
)

Definition at line 297 of file dl_image_filter_unittests.cc.

297 {
298 DlErodeImageFilter filter(5.0, 6.0);
299
300 ASSERT_NE(filter.asErode(), nullptr);
301 ASSERT_EQ(filter.asErode(), &filter);
302}

◆ TEST() [195/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeBounds   
)

Definition at line 336 of file dl_image_filter_unittests.cc.

336 {
338 SkRect input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
339 SkRect expected_output_bounds = input_bounds.makeInset(5, 10);
340 TestBounds(filter, input_bounds, expected_output_bounds);
341}
SkRect makeInset(float dx, float dy) const
Definition SkRect.h:987

◆ TEST() [196/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeConstructor   
)

Definition at line 286 of file dl_image_filter_unittests.cc.

286 {
287 DlErodeImageFilter filter(5.0, 6.0);
288}

◆ TEST() [197/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeContents   
)

Definition at line 304 of file dl_image_filter_unittests.cc.

304 {
305 DlErodeImageFilter filter(5.0, 6.0);
306
307 ASSERT_EQ(filter.radius_x(), 5.0);
308 ASSERT_EQ(filter.radius_y(), 6.0);
309}

◆ TEST() [198/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeEquals   
)

Definition at line 311 of file dl_image_filter_unittests.cc.

311 {
312 DlErodeImageFilter filter1(5.0, 6.0);
313 DlErodeImageFilter filter2(5.0, 6.0);
314
315 TestEquals(filter1, filter2);
316}

◆ TEST() [199/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeNotEquals   
)

Definition at line 327 of file dl_image_filter_unittests.cc.

327 {
328 DlErodeImageFilter filter1(5.0, 6.0);
329 DlErodeImageFilter filter2(7.0, 6.0);
330 DlErodeImageFilter filter3(5.0, 8.0);
331
332 TestNotEquals(filter1, filter2, "Radius X differs");
333 TestNotEquals(filter1, filter3, "Radius Y differs");
334}

◆ TEST() [200/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeShared   
)

Definition at line 290 of file dl_image_filter_unittests.cc.

290 {
291 DlErodeImageFilter filter(5.0, 6.0);
292
293 ASSERT_NE(filter.shared().get(), &filter);
294 ASSERT_EQ(*filter.shared(), filter);
295}

◆ TEST() [201/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
ErodeWithLocalMatrixEquals   
)

Definition at line 318 of file dl_image_filter_unittests.cc.

318 {
319 DlErodeImageFilter filter1(5.0, 6.0);
320 DlErodeImageFilter filter2(5.0, 6.0);
321
322 SkMatrix local_matrix = SkMatrix::Translate(10, 10);
323 TestEquals(*filter1.makeWithLocalMatrix(local_matrix),
324 *filter2.makeWithLocalMatrix(local_matrix));
325}

◆ TEST() [202/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
Issue108433   
)

Definition at line 606 of file dl_image_filter_unittests.cc.

606 {
607 auto input_bounds = SkIRect::MakeLTRB(20, 20, 80, 80);
608 auto expected_bounds = SkIRect::MakeLTRB(5, 2, 95, 98);
609
610 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kSrcOver);
611 auto dl_outer = DlBlurImageFilter(5.0, 6.0, DlTileMode::kRepeat);
612 auto dl_inner = DlColorFilterImageFilter(dl_color_filter.shared());
613 auto dl_compose = DlComposeImageFilter(dl_outer, dl_inner);
614
615 SkIRect dl_bounds;
616 ASSERT_EQ(
617 dl_compose.map_device_bounds(input_bounds, SkMatrix::I(), dl_bounds),
618 nullptr);
619 ASSERT_EQ(dl_bounds, expected_bounds);
620}
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
Definition SkRect.h:91

◆ TEST() [203/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
LocalImageFilterBounds   
)

Definition at line 699 of file dl_image_filter_unittests.cc.

699 {
700 auto filter_matrix = SkMatrix::MakeAll(2.0, 0.0, 10, //
701 0.5, 3.0, 15, //
702 0.0, 0.0, 1);
703 std::vector<sk_sp<SkImageFilter>> sk_filters{
704 SkImageFilters::Blur(5.0, 6.0, SkTileMode::kRepeat, nullptr),
707 SkImageFilters::Dilate(5.0, 10.0, nullptr),
709 filter_matrix, SkSamplingOptions(SkFilterMode::kLinear), nullptr),
711 SkImageFilters::Blur(5.0, 6.0, SkTileMode::kRepeat, nullptr),
714 nullptr))};
715
716 DlBlendColorFilter dl_color_filter(DlColor::kRed(), DlBlendMode::kSrcOver);
717 std::vector<std::shared_ptr<DlImageFilter>> dl_filters{
718 std::make_shared<DlBlurImageFilter>(5.0, 6.0, DlTileMode::kRepeat),
719 std::make_shared<DlColorFilterImageFilter>(dl_color_filter.shared()),
720 std::make_shared<DlDilateImageFilter>(5, 10),
721 std::make_shared<DlMatrixImageFilter>(filter_matrix,
722 DlImageSampling::kLinear),
723 std::make_shared<DlComposeImageFilter>(
724 std::make_shared<DlBlurImageFilter>(5.0, 6.0, DlTileMode::kRepeat),
725 std::make_shared<DlColorFilterImageFilter>(
726 dl_color_filter.shared()))};
727
728 auto persp = SkMatrix::I();
729 persp.setPerspY(0.001);
730 std::vector<SkMatrix> matrices = {
731 SkMatrix::Translate(10.0, 10.0),
732 SkMatrix::Scale(2.0, 2.0).preTranslate(10.0, 10.0),
733 SkMatrix::RotateDeg(45).preTranslate(5.0, 5.0), persp};
734 std::vector<SkMatrix> bounds_matrices{SkMatrix::Translate(5.0, 10.0),
735 SkMatrix::Scale(2.0, 2.0)};
736
737 for (unsigned j = 0; j < matrices.size(); j++) {
738 DlLocalMatrixImageFilter filter(matrices[j], nullptr);
739 {
740 const auto input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
741 SkRect output_bounds;
742 EXPECT_EQ(filter.map_local_bounds(input_bounds, output_bounds),
743 &output_bounds);
744 EXPECT_EQ(input_bounds, output_bounds);
745 }
746 for (unsigned k = 0; k < bounds_matrices.size(); k++) {
747 auto& bounds_matrix = bounds_matrices[k];
748 {
749 const auto input_bounds = SkIRect::MakeLTRB(20, 20, 80, 80);
750 SkIRect output_bounds;
751 EXPECT_EQ(filter.map_device_bounds(input_bounds, bounds_matrix,
752 output_bounds),
753 &output_bounds);
754 EXPECT_EQ(input_bounds, output_bounds);
755 }
756 {
757 const auto output_bounds = SkIRect::MakeLTRB(20, 20, 80, 80);
758 SkIRect input_bounds;
759 EXPECT_EQ(filter.get_input_device_bounds(output_bounds, bounds_matrix,
760 input_bounds),
761 &input_bounds);
762 EXPECT_EQ(input_bounds, output_bounds);
763 }
764 }
765 }
766
767 for (unsigned i = 0; i < sk_filters.size(); i++) {
768 for (unsigned j = 0; j < matrices.size(); j++) {
769 for (unsigned k = 0; k < bounds_matrices.size(); k++) {
770 auto desc = "filter " + std::to_string(i + 1) //
771 + ", filter matrix " + std::to_string(j + 1) //
772 + ", bounds matrix " + std::to_string(k + 1);
773 auto& m = matrices[j];
774 auto& bounds_matrix = bounds_matrices[k];
775 auto sk_local_filter = sk_filters[i]->makeWithLocalMatrix(m);
776 auto dl_local_filter = dl_filters[i]->makeWithLocalMatrix(m);
777 if (!sk_local_filter || !dl_local_filter) {
778 // Temporarily relax the equivalence testing to allow Skia to expand
779 // their behavior. Once the Skia fixes are rolled in, the
780 // DlImageFilter should adapt to the new rules.
781 // See https://github.com/flutter/flutter/issues/114723
782 ASSERT_TRUE(sk_local_filter || !dl_local_filter) << desc;
783 continue;
784 }
785 {
786 auto input_bounds = SkIRect::MakeLTRB(20, 20, 80, 80);
787 SkIRect sk_rect, dl_rect;
788 sk_rect = sk_local_filter->filterBounds(
789 input_bounds, bounds_matrix,
791 if (dl_local_filter->map_device_bounds(input_bounds, bounds_matrix,
792 dl_rect)) {
793 ASSERT_EQ(sk_rect, dl_rect) << desc;
794 } else {
795 ASSERT_TRUE(dl_local_filter->modifies_transparent_black()) << desc;
796 ASSERT_FALSE(sk_local_filter->canComputeFastBounds()) << desc;
797 }
798 }
799 {
800 // Test for: Know the outset bounds to get the inset bounds
801 // Skia have some bounds calculate error of DilateFilter and
802 // MatrixFilter
803 // Skia issue: https://bugs.chromium.org/p/skia/issues/detail?id=13444
804 // flutter issue: https://github.com/flutter/flutter/issues/108693
805 if (i == 2 || i == 3) {
806 continue;
807 }
808 auto outset_bounds = SkIRect::MakeLTRB(20, 20, 80, 80);
809 SkIRect sk_rect, dl_rect;
810 sk_rect = sk_local_filter->filterBounds(
811 outset_bounds, bounds_matrix,
813 if (dl_local_filter->get_input_device_bounds(
814 outset_bounds, bounds_matrix, dl_rect)) {
815 ASSERT_EQ(sk_rect, dl_rect) << desc;
816 } else {
817 ASSERT_TRUE(dl_local_filter->modifies_transparent_black());
818 ASSERT_FALSE(sk_local_filter->canComputeFastBounds());
819 }
820 }
821 }
822 }
823 }
824}
@ kSrcOver
r = s + (1-sa)*d
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Compose(sk_sp< SkImageFilter > outer, sk_sp< SkImageFilter > inner)
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static SkMatrix RotateDeg(SkScalar deg)
Definition SkMatrix.h:104
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:263
SkRect sk_rect

◆ TEST() [204/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
LocalImageSkiaNull   
)

Definition at line 20 of file dl_sk_conversions_unittests.cc.

20 {
21 auto blur_filter =
22 std::make_shared<DlBlurImageFilter>(0, 0, DlTileMode::kClamp);
23 DlLocalMatrixImageFilter dl_local_matrix_filter(SkMatrix::RotateDeg(45),
24 blur_filter);
25 // With sigmas set to zero on the blur filter, Skia will return a null filter.
26 // The local matrix filter should return nullptr instead of crashing.
27 ASSERT_EQ(ToSk(dl_local_matrix_filter), nullptr);
28}

◆ TEST() [205/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixAsMatrix   
)

Definition at line 360 of file dl_image_filter_unittests.cc.

360 {
361 DlMatrixImageFilter filter(SkMatrix::MakeAll(2.0, 0.0, 10, //
362 0.5, 3.0, 15, //
363 0.0, 0.0, 1),
364 DlImageSampling::kLinear);
365
366 ASSERT_NE(filter.asMatrix(), nullptr);
367 ASSERT_EQ(filter.asMatrix(), &filter);
368}

◆ TEST() [206/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixBounds   
)

Definition at line 417 of file dl_image_filter_unittests.cc.

417 {
418 SkMatrix matrix = SkMatrix::MakeAll(2.0, 0.0, 10, //
419 0.5, 3.0, 7, //
420 0.0, 0.0, 1);
421 SkMatrix inverse;
422 ASSERT_TRUE(matrix.invert(&inverse));
423 DlMatrixImageFilter filter(matrix, DlImageSampling::kLinear);
424 SkRect input_bounds = SkRect::MakeLTRB(20, 20, 80, 80);
425 SkPoint expectedOutputQuad[4] = {
426 {50, 77}, // (20,20) => (20*2 + 10, 20/2 + 20*3 + 7) == (50, 77)
427 {50, 257}, // (20,80) => (20*2 + 10, 20/2 + 80*3 + 7) == (50, 257)
428 {170, 287}, // (80,80) => (80*2 + 10, 80/2 + 80*3 + 7) == (170, 287)
429 {170, 107}, // (80,20) => (80*2 + 10, 80/2 + 20*3 + 7) == (170, 107)
430 };
431 TestBounds(filter, input_bounds, expectedOutputQuad);
432}

◆ TEST() [207/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixConstructor   
)

Definition at line 343 of file dl_image_filter_unittests.cc.

343 {
344 DlMatrixImageFilter filter(SkMatrix::MakeAll(2.0, 0.0, 10, //
345 0.5, 3.0, 15, //
346 0.0, 0.0, 1),
347 DlImageSampling::kLinear);
348}

◆ TEST() [208/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixContents   
)

Definition at line 370 of file dl_image_filter_unittests.cc.

370 {
371 SkMatrix matrix = SkMatrix::MakeAll(2.0, 0.0, 10, //
372 0.5, 3.0, 15, //
373 0.0, 0.0, 1);
374 DlMatrixImageFilter filter(matrix, DlImageSampling::kLinear);
375
376 ASSERT_EQ(filter.matrix(), matrix);
377 ASSERT_EQ(filter.sampling(), DlImageSampling::kLinear);
378}

◆ TEST() [209/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixEquals   
)

Definition at line 380 of file dl_image_filter_unittests.cc.

380 {
381 SkMatrix matrix = SkMatrix::MakeAll(2.0, 0.0, 10, //
382 0.5, 3.0, 15, //
383 0.0, 0.0, 1);
384 DlMatrixImageFilter filter1(matrix, DlImageSampling::kLinear);
385 DlMatrixImageFilter filter2(matrix, DlImageSampling::kLinear);
386
387 TestEquals(filter1, filter2);
388}

◆ TEST() [210/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixNotEquals   
)

Definition at line 402 of file dl_image_filter_unittests.cc.

402 {
403 SkMatrix matrix1 = SkMatrix::MakeAll(2.0, 0.0, 10, //
404 0.5, 3.0, 15, //
405 0.0, 0.0, 1);
406 SkMatrix matrix2 = SkMatrix::MakeAll(5.0, 0.0, 10, //
407 0.5, 3.0, 15, //
408 0.0, 0.0, 1);
409 DlMatrixImageFilter filter1(matrix1, DlImageSampling::kLinear);
410 DlMatrixImageFilter filter2(matrix2, DlImageSampling::kLinear);
411 DlMatrixImageFilter filter3(matrix1, DlImageSampling::kNearestNeighbor);
412
413 TestNotEquals(filter1, filter2, "Matrix differs");
414 TestNotEquals(filter1, filter3, "Sampling differs");
415}

◆ TEST() [211/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixShared   
)

Definition at line 350 of file dl_image_filter_unittests.cc.

350 {
351 DlMatrixImageFilter filter(SkMatrix::MakeAll(2.0, 0.0, 10, //
352 0.5, 3.0, 15, //
353 0.0, 0.0, 1),
354 DlImageSampling::kLinear);
355
356 ASSERT_NE(filter.shared().get(), &filter);
357 ASSERT_EQ(*filter.shared(), filter);
358}

◆ TEST() [212/709]

flutter::testing::TEST ( DisplayListImageFilter  ,
MatrixWithLocalMatrixEquals   
)

Definition at line 390 of file dl_image_filter_unittests.cc.

390 {
391 SkMatrix matrix = SkMatrix::MakeAll(2.0, 0.0, 10, //
392 0.5, 3.0, 15, //
393 0.0, 0.0, 1);
394 DlMatrixImageFilter filter1(matrix, DlImageSampling::kLinear);
395 DlMatrixImageFilter filter2(matrix, DlImageSampling::kLinear);
396
397 SkMatrix local_matrix = SkMatrix::Translate(10, 10);
398 TestEquals(*filter1.makeWithLocalMatrix(local_matrix),
399 *filter2.makeWithLocalMatrix(local_matrix));
400}

◆ TEST() [213/709]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurAsBlur   
)

Definition at line 23 of file dl_mask_filter_unittests.cc.

23 {
24 DlBlurMaskFilter filter(DlBlurStyle::kNormal, 5.0);
25 ASSERT_NE(filter.asBlur(), nullptr);
26 ASSERT_EQ(filter.asBlur(), &filter);
27}

◆ TEST() [214/709]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurConstructor   
)

Definition at line 13 of file dl_mask_filter_unittests.cc.

13 {
14 DlBlurMaskFilter filter(DlBlurStyle::kNormal, 5.0);
15}

◆ TEST() [215/709]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurContents   
)

Definition at line 29 of file dl_mask_filter_unittests.cc.

29 {
30 DlBlurMaskFilter filter(DlBlurStyle::kNormal, 5.0);
31 ASSERT_EQ(filter.style(), DlBlurStyle::kNormal);
32 ASSERT_EQ(filter.sigma(), 5.0);
33}

◆ TEST() [216/709]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurEquals   
)

Definition at line 35 of file dl_mask_filter_unittests.cc.

35 {
36 DlBlurMaskFilter filter1(DlBlurStyle::kNormal, 5.0);
37 DlBlurMaskFilter filter2(DlBlurStyle::kNormal, 5.0);
38 TestEquals(filter1, filter2);
39}

◆ TEST() [217/709]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurNotEquals   
)

Definition at line 41 of file dl_mask_filter_unittests.cc.

41 {
42 DlBlurMaskFilter filter1(DlBlurStyle::kNormal, 5.0);
43 DlBlurMaskFilter filter2(DlBlurStyle::kInner, 5.0);
44 DlBlurMaskFilter filter3(DlBlurStyle::kNormal, 6.0);
45 TestNotEquals(filter1, filter2, "Blur style differs");
46 TestNotEquals(filter1, filter3, "blur radius differs");
47}

◆ TEST() [218/709]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurShared   
)

Definition at line 17 of file dl_mask_filter_unittests.cc.

17 {
18 DlBlurMaskFilter filter(DlBlurStyle::kNormal, 5.0);
19 ASSERT_NE(filter.shared().get(), &filter);
20 ASSERT_EQ(*filter.shared(), filter);
21}

◆ TEST() [219/709]

flutter::testing::TEST ( DisplayListMaskFilter  ,
ComparableTemplates   
)

Definition at line 100 of file dl_mask_filter_unittests.cc.

100 {
101 DlBlurMaskFilter filter1a(DlBlurStyle::kNormal, 3.0);
102 DlBlurMaskFilter filter1b(DlBlurStyle::kNormal, 3.0);
103 DlBlurMaskFilter filter2(DlBlurStyle::kNormal, 5.0);
104 std::shared_ptr<DlMaskFilter> shared_null;
105
106 // null to null
107 testEquals(nullptr, nullptr);
108 testEquals(shared_null, nullptr);
109 testEquals(shared_null, shared_null);
110
111 // ptr to null
112 testNotEquals(&filter1a, nullptr);
113 testNotEquals(&filter1b, nullptr);
114 testNotEquals(&filter2, nullptr);
115
116 // shared_ptr to null and shared_null to ptr
117 testNotEquals(filter1a.shared(), nullptr);
118 testNotEquals(filter1b.shared(), nullptr);
119 testNotEquals(filter2.shared(), nullptr);
120 testNotEquals(shared_null, &filter1a);
121 testNotEquals(shared_null, &filter1b);
122 testNotEquals(shared_null, &filter2);
123
124 // ptr to ptr
125 testEquals(&filter1a, &filter1a);
126 testEquals(&filter1a, &filter1b);
127 testEquals(&filter1b, &filter1b);
128 testEquals(&filter2, &filter2);
129 testNotEquals(&filter1a, &filter2);
130
131 // shared_ptr to ptr
132 testEquals(filter1a.shared(), &filter1a);
133 testEquals(filter1a.shared(), &filter1b);
134 testEquals(filter1b.shared(), &filter1b);
135 testEquals(filter2.shared(), &filter2);
136 testNotEquals(filter1a.shared(), &filter2);
137 testNotEquals(filter1b.shared(), &filter2);
138 testNotEquals(filter2.shared(), &filter1a);
139 testNotEquals(filter2.shared(), &filter1b);
140
141 // shared_ptr to shared_ptr
142 testEquals(filter1a.shared(), filter1a.shared());
143 testEquals(filter1a.shared(), filter1b.shared());
144 testEquals(filter1b.shared(), filter1b.shared());
145 testEquals(filter2.shared(), filter2.shared());
146 testNotEquals(filter1a.shared(), filter2.shared());
147 testNotEquals(filter1b.shared(), filter2.shared());
148 testNotEquals(filter2.shared(), filter1a.shared());
149 testNotEquals(filter2.shared(), filter1b.shared());
150}
void testNotEquals(DlMaskFilter *a, DlMaskFilter *b)
void testEquals(DlMaskFilter *a, DlMaskFilter *b)

◆ TEST() [220/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
ClipPathWithInvertFillType   
)

Definition at line 1147 of file dl_matrix_clip_tracker_unittests.cc.

1147 {
1148 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
1150 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
1152 state.clipPath(clip, DlCanvas::ClipOp::kIntersect, false);
1153
1154 EXPECT_EQ(state.local_cull_rect(), cull_rect);
1155 EXPECT_EQ(state.device_cull_rect(), cull_rect);
1156}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition SkPath.cpp:1149
void setFillType(SkPathFillType ft)
Definition SkPath.h:235

◆ TEST() [221/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Constructor   
)

Definition at line 50 of file dl_matrix_clip_tracker_unittests.cc.

50 {
51 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
52 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
53 const SkMatrix matrix = SkMatrix::Scale(4, 4);
54 const SkM44 m44 = SkM44::Scale(4, 4);
55 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
56 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
57
58 DisplayListMatrixClipState state1(cull_rect, matrix);
59 DisplayListMatrixClipState state2(cull_rect, m44);
60 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
61
62 EXPECT_FALSE(state1.using_4x4_matrix());
63 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
64 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
65 EXPECT_EQ(state1.matrix_3x3(), matrix);
66 EXPECT_EQ(state1.matrix_4x4(), m44);
67 EXPECT_EQ(state1.matrix(), dl_matrix);
68
69 EXPECT_FALSE(state2.using_4x4_matrix());
70 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
71 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
72 EXPECT_EQ(state2.matrix_3x3(), matrix);
73 EXPECT_EQ(state2.matrix_4x4(), m44);
74 EXPECT_EQ(state2.matrix(), dl_matrix);
75
76 EXPECT_FALSE(state3.using_4x4_matrix());
77 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
78 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
79 EXPECT_EQ(state3.matrix_3x3(), matrix);
80 EXPECT_EQ(state3.matrix_4x4(), m44);
81 EXPECT_EQ(state3.matrix(), dl_matrix);
82}
Definition SkM44.h:150
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z=1)
Definition SkM44.h:232
A 4x4 matrix using column-major storage.
Definition matrix.h:37

◆ TEST() [222/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Constructor4x4   
)

Definition at line 115 of file dl_matrix_clip_tracker_unittests.cc.

115 {
116 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
117 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
118 // clang-format off
119 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
120 0, 4, 0.5, 0,
121 0, 0, 4.0, 0,
122 0, 0, 0.0, 1);
123 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
124 0, 4, 0.5, 0,
125 0, 0, 4.0, 0,
126 0, 0, 0.0, 1);
127 // clang-format on
128 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
129
130 DisplayListMatrixClipState state1(cull_rect, m44);
131 DisplayListMatrixClipState state2(dl_cull_rect, dl_matrix);
132
133 EXPECT_TRUE(state1.using_4x4_matrix());
134 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
135 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
136 EXPECT_EQ(state1.matrix_4x4(), m44);
137 EXPECT_EQ(state1.matrix(), dl_matrix);
138
139 EXPECT_TRUE(state2.using_4x4_matrix());
140 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
141 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
142 EXPECT_EQ(state2.matrix_4x4(), m44);
143 EXPECT_EQ(state2.matrix(), dl_matrix);
144}

◆ TEST() [223/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
DiffClipPathWithInvertFillType   
)

Definition at line 1171 of file dl_matrix_clip_tracker_unittests.cc.

1171 {
1172 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
1174
1175 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
1177 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
1178 state.clipPath(clip, DlCanvas::ClipOp::kDifference, false);
1179
1180 EXPECT_EQ(state.local_cull_rect(), clip_bounds);
1181 EXPECT_EQ(state.device_cull_rect(), clip_bounds);
1182}

◆ TEST() [224/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Rotate   
)

Definition at line 637 of file dl_matrix_clip_tracker_unittests.cc.

637 {
638 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
639 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
640 const SkMatrix matrix = SkMatrix::Scale(4, 4);
641 const SkM44 m44 = SkM44::Scale(4, 4);
642 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
643 const SkMatrix rotated_matrix =
645 const SkM44 rotated_m44 = SkM44(rotated_matrix);
646 const DlMatrix rotated_dl_matrix =
647 dl_matrix * DlMatrix::MakeRotationZ(Degrees(90));
648 const SkRect local_cull_rect = SkRect::MakeLTRB(10, -15, 20, -5);
649
650 DisplayListMatrixClipState state1(cull_rect, matrix);
651 DisplayListMatrixClipState state2(cull_rect, m44);
652 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
653 state1.rotate(90);
654 state2.rotate(90);
655 state3.rotate(90);
656
657 EXPECT_FALSE(state1.using_4x4_matrix());
658 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
659 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
660 EXPECT_EQ(state1.matrix_3x3(), rotated_matrix);
661 EXPECT_EQ(state1.matrix_4x4(), rotated_m44);
662 EXPECT_EQ(state1.matrix(), rotated_dl_matrix);
663
664 EXPECT_FALSE(state2.using_4x4_matrix());
665 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
666 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
667 EXPECT_EQ(state2.matrix_3x3(), rotated_matrix);
668 EXPECT_EQ(state2.matrix_4x4(), rotated_m44);
669 EXPECT_EQ(state2.matrix(), rotated_dl_matrix);
670
671 EXPECT_FALSE(state3.using_4x4_matrix());
672 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
673 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
674 EXPECT_EQ(state3.matrix_3x3(), rotated_matrix);
675 EXPECT_EQ(state3.matrix_4x4(), rotated_m44);
676 EXPECT_EQ(state3.matrix(), rotated_dl_matrix);
677}
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.h:1775

◆ TEST() [225/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Scale   
)

Definition at line 470 of file dl_matrix_clip_tracker_unittests.cc.

470 {
471 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
472 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
473 const SkMatrix matrix = SkMatrix::Scale(4, 4);
474 const SkM44 m44 = SkM44::Scale(4, 4);
475 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
476 // Scale factor carefully chosen to multiply cleanly and invert
477 // without any non-binary-power-of-2 approximation errors.
478 const SkMatrix scaled_matrix =
479 SkMatrix::Concat(matrix, SkMatrix::Scale(0.5, 2));
480 const SkM44 scaled_m44 = SkM44(scaled_matrix);
481 const DlMatrix scaled_dl_matrix = dl_matrix.Scale({0.5, 2, 1});
482 const SkRect local_cull_rect = SkRect::MakeLTRB(10, 5, 30, 10);
483
484 DisplayListMatrixClipState state1(cull_rect, matrix);
485 DisplayListMatrixClipState state2(cull_rect, m44);
486 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
487 state1.scale(0.5, 2);
488 state2.scale(0.5, 2);
489 state3.scale(0.5, 2);
490
491 EXPECT_FALSE(state1.using_4x4_matrix());
492 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
493 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
494 EXPECT_EQ(state1.matrix_3x3(), scaled_matrix);
495 EXPECT_EQ(state1.matrix_4x4(), scaled_m44);
496 EXPECT_EQ(state1.matrix(), scaled_dl_matrix);
497
498 EXPECT_FALSE(state2.using_4x4_matrix());
499 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
500 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
501 EXPECT_EQ(state2.matrix_3x3(), scaled_matrix);
502 EXPECT_EQ(state2.matrix_4x4(), scaled_m44);
503 EXPECT_EQ(state2.matrix(), scaled_dl_matrix);
504
505 EXPECT_FALSE(state3.using_4x4_matrix());
506 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
507 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
508 EXPECT_EQ(state3.matrix_3x3(), scaled_matrix);
509 EXPECT_EQ(state3.matrix_4x4(), scaled_m44);
510 EXPECT_EQ(state3.matrix(), scaled_dl_matrix);
511}
constexpr Matrix Scale(const Vector3 &s) const
Definition matrix.h:252

◆ TEST() [226/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
SetTo4x4   
)

Definition at line 251 of file dl_matrix_clip_tracker_unittests.cc.

251 {
252 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
253 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
254 // clang-format off
255 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
256 0, 4, 0.5, 0,
257 0, 0, 4.0, 0,
258 0, 0, 0.0, 1);
259 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
260 0, 4, 0.5, 0,
261 0, 0, 4.0, 0,
262 0, 0, 0.0, 1);
263 // clang-format on
264 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
265
266 DisplayListMatrixClipState state1(cull_rect, SkMatrix::I());
267 DisplayListMatrixClipState state2(dl_cull_rect, DlMatrix());
268 EXPECT_FALSE(state1.using_4x4_matrix());
269 EXPECT_FALSE(state2.using_4x4_matrix());
270
271 state1.setTransform(m44);
272 EXPECT_TRUE(state1.using_4x4_matrix());
273 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
274 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
275 EXPECT_EQ(state1.matrix_4x4(), m44);
276 EXPECT_EQ(state1.matrix(), dl_matrix);
277
278 state2.setTransform(dl_matrix);
279 EXPECT_TRUE(state2.using_4x4_matrix());
280 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
281 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
282 EXPECT_EQ(state2.matrix_4x4(), m44);
283 EXPECT_EQ(state2.matrix(), dl_matrix);
284}

◆ TEST() [227/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Skew   
)

Definition at line 554 of file dl_matrix_clip_tracker_unittests.cc.

554 {
555 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
556 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
557 const SkMatrix matrix = SkMatrix::Scale(4, 4);
558 const SkM44 m44 = SkM44::Scale(4, 4);
559 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
560 const SkMatrix skewed_matrix =
561 SkMatrix::Concat(matrix, SkMatrix::Skew(.25, 0));
562 const SkM44 skewed_m44 = SkM44(skewed_matrix);
563 const DlMatrix skewed_dl_matrix = dl_matrix * DlMatrix::MakeSkew(0.25, 0);
564 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 10, 12.5, 20);
565
566 DisplayListMatrixClipState state1(cull_rect, matrix);
567 DisplayListMatrixClipState state2(cull_rect, m44);
568 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
569 state1.skew(.25, 0);
570 state2.skew(.25, 0);
571 state3.skew(.25, 0);
572
573 EXPECT_FALSE(state1.using_4x4_matrix());
574 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
575 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
576 EXPECT_EQ(state1.matrix_3x3(), skewed_matrix);
577 EXPECT_EQ(state1.matrix_4x4(), skewed_m44);
578 EXPECT_EQ(state1.matrix(), skewed_dl_matrix);
579
580 EXPECT_FALSE(state2.using_4x4_matrix());
581 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
582 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
583 EXPECT_EQ(state2.matrix_3x3(), skewed_matrix);
584 EXPECT_EQ(state2.matrix_4x4(), skewed_m44);
585 EXPECT_EQ(state2.matrix(), skewed_dl_matrix);
586
587 EXPECT_FALSE(state3.using_4x4_matrix());
588 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
589 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
590 EXPECT_EQ(state3.matrix_3x3(), skewed_matrix);
591 EXPECT_EQ(state3.matrix_4x4(), skewed_m44);
592 EXPECT_EQ(state3.matrix(), skewed_dl_matrix);
593}
static SkMatrix Skew(SkScalar kx, SkScalar ky)
Definition SkMatrix.h:124

◆ TEST() [228/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Transform2DAffine   
)

Definition at line 730 of file dl_matrix_clip_tracker_unittests.cc.

730 {
731 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
732 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
733 const SkMatrix matrix = SkMatrix::Scale(4, 4);
734 const SkM44 m44 = SkM44::Scale(4, 4);
735 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
736
737 const SkMatrix transformed_matrix =
738 SkMatrix::Concat(matrix, SkMatrix::MakeAll(2, 0, 5, //
739 0, 2, 6, //
740 0, 0, 1));
741 const SkM44 transformed_m44 = SkM44(transformed_matrix);
742 const DlMatrix transformed_dl_matrix =
743 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
744 0, 2, 0, 6, //
745 0, 0, 1, 0, //
746 0, 0, 0, 1);
747 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
748
749 DisplayListMatrixClipState state1(cull_rect, matrix);
750 DisplayListMatrixClipState state2(cull_rect, m44);
751 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
752 state1.transform2DAffine(2, 0, 5, //
753 0, 2, 6);
754 state2.transform2DAffine(2, 0, 5, //
755 0, 2, 6);
756 state3.transform2DAffine(2, 0, 5, //
757 0, 2, 6);
758
759 EXPECT_FALSE(state1.using_4x4_matrix());
760 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
761 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
762 EXPECT_EQ(state1.matrix_3x3(), transformed_matrix);
763 EXPECT_EQ(state1.matrix_4x4(), transformed_m44);
764 EXPECT_EQ(state1.matrix(), transformed_dl_matrix);
765
766 EXPECT_FALSE(state2.using_4x4_matrix());
767 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
768 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
769 EXPECT_EQ(state2.matrix_3x3(), transformed_matrix);
770 EXPECT_EQ(state2.matrix_4x4(), transformed_m44);
771 EXPECT_EQ(state2.matrix(), transformed_dl_matrix);
772
773 EXPECT_FALSE(state3.using_4x4_matrix());
774 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
775 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
776 EXPECT_EQ(state3.matrix_3x3(), transformed_matrix);
777 EXPECT_EQ(state3.matrix_4x4(), transformed_m44);
778 EXPECT_EQ(state3.matrix(), transformed_dl_matrix);
779}

◆ TEST() [229/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
TransformFullPerspectiveUsing3x3Matrix   
)

Definition at line 838 of file dl_matrix_clip_tracker_unittests.cc.

838 {
839 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
840 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
841 const SkMatrix matrix = SkMatrix::Scale(4, 4);
842 const SkM44 m44 = SkM44::Scale(4, 4);
843 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
844
845 const SkMatrix transformed_matrix =
846 SkMatrix::Concat(matrix, SkMatrix::MakeAll(2, 0, 5, //
847 0, 2, 6, //
848 0, 0, 1));
849 const SkM44 transformed_m44 = SkM44(transformed_matrix);
850 const DlMatrix transformed_dl_matrix =
851 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
852 0, 2, 0, 6, //
853 0, 0, 1, 0, //
854 0, 0, 0, 1);
855 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
856
857 DisplayListMatrixClipState state1(cull_rect, matrix);
858 DisplayListMatrixClipState state2(cull_rect, m44);
859 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
860 state1.transformFullPerspective(2, 0, 0, 5, //
861 0, 2, 0, 6, //
862 0, 0, 1, 0, //
863 0, 0, 0, 1);
864 state2.transformFullPerspective(2, 0, 0, 5, //
865 0, 2, 0, 6, //
866 0, 0, 1, 0, //
867 0, 0, 0, 1);
868 state3.transformFullPerspective(2, 0, 0, 5, //
869 0, 2, 0, 6, //
870 0, 0, 1, 0, //
871 0, 0, 0, 1);
872
873 EXPECT_FALSE(state1.using_4x4_matrix());
874 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
875 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
876 EXPECT_EQ(state1.matrix_3x3(), transformed_matrix);
877 EXPECT_EQ(state1.matrix_4x4(), transformed_m44);
878 EXPECT_EQ(state1.matrix(), transformed_dl_matrix);
879
880 EXPECT_FALSE(state2.using_4x4_matrix());
881 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
882 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
883 EXPECT_EQ(state2.matrix_3x3(), transformed_matrix);
884 EXPECT_EQ(state2.matrix_4x4(), transformed_m44);
885 EXPECT_EQ(state2.matrix(), transformed_dl_matrix);
886
887 EXPECT_FALSE(state3.using_4x4_matrix());
888 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
889 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
890 EXPECT_EQ(state3.matrix_3x3(), transformed_matrix);
891 EXPECT_EQ(state3.matrix_4x4(), transformed_m44);
892 EXPECT_EQ(state3.matrix(), transformed_dl_matrix);
893}

◆ TEST() [230/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
TransformFullPerspectiveUsing4x4Matrix   
)

Definition at line 948 of file dl_matrix_clip_tracker_unittests.cc.

948 {
949 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
950 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
951 const SkMatrix matrix = SkMatrix::Scale(4, 4);
952 const SkM44 m44 = SkM44::Scale(4, 4);
953 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
954
955 const SkM44 transformed_m44 = SkM44(m44, SkM44(2, 0, 0, 5, //
956 0, 2, 0, 6, //
957 0, 0, 1, 7, //
958 0, 0, 0, 1));
959 const DlMatrix transformed_dl_matrix =
960 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
961 0, 2, 0, 6, //
962 0, 0, 1, 7, //
963 0, 0, 0, 1);
964 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
965
966 DisplayListMatrixClipState state1(cull_rect, matrix);
967 DisplayListMatrixClipState state2(cull_rect, m44);
968 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
969 state1.transformFullPerspective(2, 0, 0, 5, //
970 0, 2, 0, 6, //
971 0, 0, 1, 7, //
972 0, 0, 0, 1);
973 state2.transformFullPerspective(2, 0, 0, 5, //
974 0, 2, 0, 6, //
975 0, 0, 1, 7, //
976 0, 0, 0, 1);
977 state3.transformFullPerspective(2, 0, 0, 5, //
978 0, 2, 0, 6, //
979 0, 0, 1, 7, //
980 0, 0, 0, 1);
981
982 EXPECT_TRUE(state1.using_4x4_matrix());
983 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
984 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
985 EXPECT_EQ(state1.matrix_4x4(), transformed_m44);
986 EXPECT_EQ(state1.matrix(), transformed_dl_matrix);
987
988 EXPECT_TRUE(state2.using_4x4_matrix());
989 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
990 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
991 EXPECT_EQ(state2.matrix_4x4(), transformed_m44);
992 EXPECT_EQ(state2.matrix(), transformed_dl_matrix);
993
994 EXPECT_TRUE(state3.using_4x4_matrix());
995 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
996 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
997 EXPECT_EQ(state3.matrix_4x4(), transformed_m44);
998 EXPECT_EQ(state3.matrix(), transformed_dl_matrix);
999}

◆ TEST() [231/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
TransformTo4x4   
)

Definition at line 181 of file dl_matrix_clip_tracker_unittests.cc.

181 {
182 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
183 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
184 // clang-format off
185 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
186 0, 4, 0.5, 0,
187 0, 0, 4.0, 0,
188 0, 0, 0.0, 1);
189 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
190 0, 4, 0.5, 0,
191 0, 0, 4.0, 0,
192 0, 0, 0.0, 1);
193 // clang-format on
194 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
195
196 DisplayListMatrixClipTracker state1(cull_rect, SkMatrix::I());
197 DisplayListMatrixClipTracker state2(dl_cull_rect, DlMatrix());
198 EXPECT_FALSE(state1.using_4x4_matrix());
199 EXPECT_FALSE(state2.using_4x4_matrix());
200
201 state1.transform(m44);
202 EXPECT_TRUE(state1.using_4x4_matrix());
203 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
204 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
205 EXPECT_EQ(state1.matrix_4x4(), m44);
206 EXPECT_EQ(state1.matrix(), dl_matrix);
207
208 state2.transform(dl_matrix);
209 EXPECT_TRUE(state2.using_4x4_matrix());
210 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
211 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
212 EXPECT_EQ(state2.matrix_4x4(), m44);
213 EXPECT_EQ(state2.matrix(), dl_matrix);
214}

◆ TEST() [232/709]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Translate   
)

Definition at line 385 of file dl_matrix_clip_tracker_unittests.cc.

385 {
386 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
387 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
388 const SkMatrix matrix = SkMatrix::Scale(4, 4);
389 const SkM44 m44 = SkM44::Scale(4, 4);
390 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
391 const SkMatrix translated_matrix =
393 const SkM44 translated_m44 = SkM44(translated_matrix);
394 const DlMatrix dl_translated_matrix =
395 dl_matrix * DlMatrix::MakeTranslation({5.0, 1.0});
396 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 9, 10, 19);
397
398 DisplayListMatrixClipState state1(cull_rect, matrix);
399 DisplayListMatrixClipState state2(cull_rect, m44);
400 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
401 state1.translate(5, 1);
402 state2.translate(5, 1);
403 state3.translate(5, 1);
404
405 EXPECT_FALSE(state1.using_4x4_matrix());
406 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
407 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
408 EXPECT_EQ(state1.matrix_3x3(), translated_matrix);
409 EXPECT_EQ(state1.matrix_4x4(), translated_m44);
410 EXPECT_EQ(state1.matrix(), dl_translated_matrix);
411
412 EXPECT_FALSE(state2.using_4x4_matrix());
413 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
414 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
415 EXPECT_EQ(state2.matrix_3x3(), translated_matrix);
416 EXPECT_EQ(state2.matrix_4x4(), translated_m44);
417 EXPECT_EQ(state2.matrix(), dl_translated_matrix);
418
419 EXPECT_FALSE(state3.using_4x4_matrix());
420 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
421 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
422 EXPECT_EQ(state3.matrix_3x3(), translated_matrix);
423 EXPECT_EQ(state3.matrix_4x4(), translated_m44);
424 EXPECT_EQ(state3.matrix(), dl_translated_matrix);
425}

◆ TEST() [233/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
ClipDifference   
)

Definition at line 1001 of file dl_matrix_clip_tracker_unittests.cc.

1001 {
1002 SkRect cull_rect = SkRect::MakeLTRB(20, 20, 40, 40);
1003
1004 auto non_reducing = [&cull_rect](const SkRect& diff_rect,
1005 const std::string& label) {
1006 {
1007 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1008 tracker.clipRect(diff_rect, DlCanvas::ClipOp::kDifference, false);
1009 EXPECT_EQ(tracker.device_cull_rect(), cull_rect) << label;
1010 }
1011 {
1012 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1013 const SkRRect diff_rrect = SkRRect::MakeRect(diff_rect);
1014 tracker.clipRRect(diff_rrect, DlCanvas::ClipOp::kDifference, false);
1015 EXPECT_EQ(tracker.device_cull_rect(), cull_rect) << label << " (RRect)";
1016 }
1017 {
1018 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1019 const SkPath diff_path = SkPath().addRect(diff_rect);
1020 tracker.clipPath(diff_path, DlCanvas::ClipOp::kDifference, false);
1021 EXPECT_EQ(tracker.device_cull_rect(), cull_rect) << label << " (RRect)";
1022 }
1023 {
1024 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
1025 state.clipRect(diff_rect, DlCanvas::ClipOp::kDifference, false);
1026 EXPECT_EQ(state.device_cull_rect(), cull_rect) << label;
1027 }
1028 {
1029 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
1030 const SkRRect diff_rrect = SkRRect::MakeRect(diff_rect);
1031 state.clipRRect(diff_rrect, DlCanvas::ClipOp::kDifference, false);
1032 EXPECT_EQ(state.device_cull_rect(), cull_rect) << label << " (RRect)";
1033 }
1034 {
1035 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
1036 const SkPath diff_path = SkPath().addRect(diff_rect);
1037 state.clipPath(diff_path, DlCanvas::ClipOp::kDifference, false);
1038 EXPECT_EQ(state.device_cull_rect(), cull_rect) << label << " (RRect)";
1039 }
1040 };
1041
1042 auto reducing = [&cull_rect](const SkRect& diff_rect,
1043 const SkRect& result_rect,
1044 const std::string& label) {
1045 EXPECT_TRUE(result_rect.isEmpty() || cull_rect.contains(result_rect));
1046 {
1047 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1048 tracker.clipRect(diff_rect, DlCanvas::ClipOp::kDifference, false);
1049 EXPECT_EQ(tracker.device_cull_rect(), result_rect) << label;
1050 }
1051 {
1052 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1053 const SkRRect diff_rrect = SkRRect::MakeRect(diff_rect);
1054 tracker.clipRRect(diff_rrect, DlCanvas::ClipOp::kDifference, false);
1055 EXPECT_EQ(tracker.device_cull_rect(), result_rect) << label << " (RRect)";
1056 }
1057 {
1058 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1059 const SkPath diff_path = SkPath().addRect(diff_rect);
1060 tracker.clipPath(diff_path, DlCanvas::ClipOp::kDifference, false);
1061 EXPECT_EQ(tracker.device_cull_rect(), result_rect) << label << " (RRect)";
1062 }
1063 {
1064 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
1065 state.clipRect(diff_rect, DlCanvas::ClipOp::kDifference, false);
1066 EXPECT_EQ(state.device_cull_rect(), result_rect) << label;
1067 }
1068 {
1069 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
1070 const SkRRect diff_rrect = SkRRect::MakeRect(diff_rect);
1071 state.clipRRect(diff_rrect, DlCanvas::ClipOp::kDifference, false);
1072 EXPECT_EQ(state.device_cull_rect(), result_rect) << label << " (RRect)";
1073 }
1074 {
1075 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
1076 const SkPath diff_path = SkPath().addRect(diff_rect);
1077 state.clipPath(diff_path, DlCanvas::ClipOp::kDifference, false);
1078 EXPECT_EQ(state.device_cull_rect(), result_rect) << label << " (RRect)";
1079 }
1080 };
1081
1082 // Skim the corners and edge
1083 non_reducing(SkRect::MakeLTRB(10, 10, 20, 20), "outside UL corner");
1084 non_reducing(SkRect::MakeLTRB(20, 10, 40, 20), "Above");
1085 non_reducing(SkRect::MakeLTRB(40, 10, 50, 20), "outside UR corner");
1086 non_reducing(SkRect::MakeLTRB(40, 20, 50, 40), "Right");
1087 non_reducing(SkRect::MakeLTRB(40, 40, 50, 50), "outside LR corner");
1088 non_reducing(SkRect::MakeLTRB(20, 40, 40, 50), "Below");
1089 non_reducing(SkRect::MakeLTRB(10, 40, 20, 50), "outside LR corner");
1090 non_reducing(SkRect::MakeLTRB(10, 20, 20, 40), "Left");
1091
1092 // Overlap corners
1093 non_reducing(SkRect::MakeLTRB(15, 15, 25, 25), "covering UL corner");
1094 non_reducing(SkRect::MakeLTRB(35, 15, 45, 25), "covering UR corner");
1095 non_reducing(SkRect::MakeLTRB(35, 35, 45, 45), "covering LR corner");
1096 non_reducing(SkRect::MakeLTRB(15, 35, 25, 45), "covering LL corner");
1097
1098 // Overlap edges, but not across an entire side
1099 non_reducing(SkRect::MakeLTRB(20, 15, 39, 25), "Top edge left-biased");
1100 non_reducing(SkRect::MakeLTRB(21, 15, 40, 25), "Top edge, right biased");
1101 non_reducing(SkRect::MakeLTRB(35, 20, 45, 39), "Right edge, top-biased");
1102 non_reducing(SkRect::MakeLTRB(35, 21, 45, 40), "Right edge, bottom-biased");
1103 non_reducing(SkRect::MakeLTRB(20, 35, 39, 45), "Bottom edge, left-biased");
1104 non_reducing(SkRect::MakeLTRB(21, 35, 40, 45), "Bottom edge, right-biased");
1105 non_reducing(SkRect::MakeLTRB(15, 20, 25, 39), "Left edge, top-biased");
1106 non_reducing(SkRect::MakeLTRB(15, 21, 25, 40), "Left edge, bottom-biased");
1107
1108 // Slice all the way through the middle
1109 non_reducing(SkRect::MakeLTRB(25, 15, 35, 45), "Vertical interior slice");
1110 non_reducing(SkRect::MakeLTRB(15, 25, 45, 35), "Horizontal interior slice");
1111
1112 // Slice off each edge
1113 reducing(SkRect::MakeLTRB(20, 15, 40, 25), //
1114 SkRect::MakeLTRB(20, 25, 40, 40), //
1115 "Slice off top");
1116 reducing(SkRect::MakeLTRB(35, 20, 45, 40), //
1117 SkRect::MakeLTRB(20, 20, 35, 40), //
1118 "Slice off right");
1119 reducing(SkRect::MakeLTRB(20, 35, 40, 45), //
1120 SkRect::MakeLTRB(20, 20, 40, 35), //
1121 "Slice off bottom");
1122 reducing(SkRect::MakeLTRB(15, 20, 25, 40), //
1123 SkRect::MakeLTRB(25, 20, 40, 40), //
1124 "Slice off left");
1125
1126 // cull rect contains diff rect
1127 non_reducing(SkRect::MakeLTRB(21, 21, 39, 39), "Contained, non-covering");
1128
1129 // cull rect equals diff rect
1130 reducing(cull_rect, SkRect::MakeEmpty(), "Perfectly covering");
1131
1132 // diff rect contains cull rect
1133 reducing(SkRect::MakeLTRB(15, 15, 45, 45), SkRect::MakeEmpty(), "Smothering");
1134}
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595
bool contains(SkScalar x, SkScalar y) const
Definition extension.cpp:19

◆ TEST() [234/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
ClipPathWithInvertFillType   
)

Definition at line 1136 of file dl_matrix_clip_tracker_unittests.cc.

1136 {
1137 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
1138 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1139 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
1141 tracker.clipPath(clip, DlCanvas::ClipOp::kIntersect, false);
1142
1143 EXPECT_EQ(tracker.local_cull_rect(), cull_rect);
1144 EXPECT_EQ(tracker.device_cull_rect(), cull_rect);
1145}

◆ TEST() [235/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
Constructor   
)

Definition at line 16 of file dl_matrix_clip_tracker_unittests.cc.

16 {
17 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
18 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
19 const SkMatrix matrix = SkMatrix::Scale(4, 4);
20 const SkM44 m44 = SkM44::Scale(4, 4);
21 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
22 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
23
24 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
25 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
26 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
27
28 EXPECT_FALSE(tracker1.using_4x4_matrix());
29 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
30 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
31 EXPECT_EQ(tracker1.matrix_3x3(), matrix);
32 EXPECT_EQ(tracker1.matrix_4x4(), m44);
33 EXPECT_EQ(tracker1.matrix(), dl_matrix);
34
35 EXPECT_FALSE(tracker2.using_4x4_matrix());
36 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
37 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
38 EXPECT_EQ(tracker2.matrix_3x3(), matrix);
39 EXPECT_EQ(tracker2.matrix_4x4(), m44);
40 EXPECT_EQ(tracker2.matrix(), dl_matrix);
41
42 EXPECT_FALSE(tracker3.using_4x4_matrix());
43 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
44 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
45 EXPECT_EQ(tracker3.matrix_3x3(), matrix);
46 EXPECT_EQ(tracker3.matrix_4x4(), m44);
47 EXPECT_EQ(tracker3.matrix(), dl_matrix);
48}

◆ TEST() [236/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
Constructor4x4   
)

Definition at line 84 of file dl_matrix_clip_tracker_unittests.cc.

84 {
85 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
86 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
87 // clang-format off
88 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
89 0, 4, 0.5, 0,
90 0, 0, 4.0, 0,
91 0, 0, 0.0, 1);
92 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
93 0, 4, 0.5, 0,
94 0, 0, 4.0, 0,
95 0, 0, 0.0, 1);
96 // clang-format on
97 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
98
99 DisplayListMatrixClipTracker tracker1(cull_rect, m44);
100 DisplayListMatrixClipTracker tracker2(dl_cull_rect, dl_matrix);
101
102 EXPECT_TRUE(tracker1.using_4x4_matrix());
103 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
104 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
105 EXPECT_EQ(tracker1.matrix_4x4(), m44);
106 EXPECT_EQ(tracker1.matrix(), dl_matrix);
107
108 EXPECT_TRUE(tracker2.using_4x4_matrix());
109 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
110 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
111 EXPECT_EQ(tracker2.matrix_4x4(), m44);
112 EXPECT_EQ(tracker2.matrix(), dl_matrix);
113}

◆ TEST() [237/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
DiffClipPathWithInvertFillType   
)

Definition at line 1158 of file dl_matrix_clip_tracker_unittests.cc.

1158 {
1159 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
1160 DisplayListMatrixClipTracker tracker(cull_rect, SkMatrix::I());
1161
1162 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
1164 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
1165 tracker.clipPath(clip, DlCanvas::ClipOp::kDifference, false);
1166
1167 EXPECT_EQ(tracker.local_cull_rect(), clip_bounds);
1168 EXPECT_EQ(tracker.device_cull_rect(), clip_bounds);
1169}

◆ TEST() [238/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
Rotate   
)

Definition at line 595 of file dl_matrix_clip_tracker_unittests.cc.

595 {
596 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
597 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
598 const SkMatrix matrix = SkMatrix::Scale(4, 4);
599 const SkM44 m44 = SkM44::Scale(4, 4);
600 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
601 const SkMatrix rotated_matrix =
603 const SkM44 rotated_m44 = SkM44(rotated_matrix);
604 const DlMatrix rotated_dl_matrix =
605 dl_matrix * DlMatrix::MakeRotationZ(Degrees(90));
606 const SkRect local_cull_rect = SkRect::MakeLTRB(10, -15, 20, -5);
607
608 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
609 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
610 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
611 tracker1.rotate(90);
612 tracker2.rotate(90);
613 tracker3.rotate(90);
614
615 EXPECT_FALSE(tracker1.using_4x4_matrix());
616 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
617 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
618 EXPECT_EQ(tracker1.matrix_3x3(), rotated_matrix);
619 EXPECT_EQ(tracker1.matrix_4x4(), rotated_m44);
620 EXPECT_EQ(tracker1.matrix(), rotated_dl_matrix);
621
622 EXPECT_FALSE(tracker2.using_4x4_matrix());
623 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
624 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
625 EXPECT_EQ(tracker2.matrix_3x3(), rotated_matrix);
626 EXPECT_EQ(tracker2.matrix_4x4(), rotated_m44);
627 EXPECT_EQ(tracker2.matrix(), rotated_dl_matrix);
628
629 EXPECT_FALSE(tracker3.using_4x4_matrix());
630 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
631 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
632 EXPECT_EQ(tracker3.matrix_3x3(), rotated_matrix);
633 EXPECT_EQ(tracker3.matrix_4x4(), rotated_m44);
634 EXPECT_EQ(tracker3.matrix(), rotated_dl_matrix);
635}

◆ TEST() [239/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
Scale   
)

Definition at line 427 of file dl_matrix_clip_tracker_unittests.cc.

427 {
428 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
429 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
430 const SkMatrix matrix = SkMatrix::Scale(4, 4);
431 const SkM44 m44 = SkM44::Scale(4, 4);
432 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
433 // Scale factor carefully chosen to multiply cleanly and invert
434 // without any non-binary-power-of-2 approximation errors.
435 const SkMatrix scaled_matrix =
436 SkMatrix::Concat(matrix, SkMatrix::Scale(0.5, 2));
437 const SkM44 scaled_m44 = SkM44(scaled_matrix);
438 const DlMatrix scaled_dl_matrix = dl_matrix.Scale({0.5, 2, 1});
439 const SkRect local_cull_rect = SkRect::MakeLTRB(10, 5, 30, 10);
440
441 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
442 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
443 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
444 tracker1.scale(0.5, 2);
445 tracker2.scale(0.5, 2);
446 tracker3.scale(0.5, 2);
447
448 EXPECT_FALSE(tracker1.using_4x4_matrix());
449 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
450 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
451 EXPECT_EQ(tracker1.matrix_3x3(), scaled_matrix);
452 EXPECT_EQ(tracker1.matrix_4x4(), scaled_m44);
453 EXPECT_EQ(tracker1.matrix(), scaled_dl_matrix);
454
455 EXPECT_FALSE(tracker2.using_4x4_matrix());
456 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
457 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
458 EXPECT_EQ(tracker2.matrix_3x3(), scaled_matrix);
459 EXPECT_EQ(tracker2.matrix_4x4(), scaled_m44);
460 EXPECT_EQ(tracker2.matrix(), scaled_dl_matrix);
461
462 EXPECT_FALSE(tracker3.using_4x4_matrix());
463 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
464 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
465 EXPECT_EQ(tracker3.matrix_3x3(), scaled_matrix);
466 EXPECT_EQ(tracker3.matrix_4x4(), scaled_m44);
467 EXPECT_EQ(tracker3.matrix(), scaled_dl_matrix);
468}

◆ TEST() [240/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
SetTo4x4   
)

Definition at line 216 of file dl_matrix_clip_tracker_unittests.cc.

216 {
217 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
218 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
219 // clang-format off
220 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
221 0, 4, 0.5, 0,
222 0, 0, 4.0, 0,
223 0, 0, 0.0, 1);
224 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
225 0, 4, 0.5, 0,
226 0, 0, 4.0, 0,
227 0, 0, 0.0, 1);
228 // clang-format on
229 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
230
231 DisplayListMatrixClipTracker tracker1(cull_rect, SkMatrix::I());
232 DisplayListMatrixClipTracker tracker2(dl_cull_rect, DlMatrix());
233 EXPECT_FALSE(tracker1.using_4x4_matrix());
234 EXPECT_FALSE(tracker2.using_4x4_matrix());
235
236 tracker1.setTransform(m44);
237 EXPECT_TRUE(tracker1.using_4x4_matrix());
238 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
239 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
240 EXPECT_EQ(tracker1.matrix_4x4(), m44);
241 EXPECT_EQ(tracker1.matrix(), dl_matrix);
242
243 tracker2.setTransform(dl_matrix);
244 EXPECT_TRUE(tracker2.using_4x4_matrix());
245 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
246 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
247 EXPECT_EQ(tracker2.matrix_4x4(), m44);
248 EXPECT_EQ(tracker2.matrix(), dl_matrix);
249}

◆ TEST() [241/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
Skew   
)

Definition at line 513 of file dl_matrix_clip_tracker_unittests.cc.

513 {
514 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
515 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
516 const SkMatrix matrix = SkMatrix::Scale(4, 4);
517 const SkM44 m44 = SkM44::Scale(4, 4);
518 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
519 const SkMatrix skewed_matrix =
520 SkMatrix::Concat(matrix, SkMatrix::Skew(.25, 0));
521 const SkM44 skewed_m44 = SkM44(skewed_matrix);
522 const DlMatrix skewed_dl_matrix = dl_matrix * DlMatrix::MakeSkew(0.25, 0);
523 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 10, 12.5, 20);
524
525 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
526 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
527 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
528 tracker1.skew(.25, 0);
529 tracker2.skew(.25, 0);
530 tracker3.skew(.25, 0);
531
532 EXPECT_FALSE(tracker1.using_4x4_matrix());
533 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
534 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
535 EXPECT_EQ(tracker1.matrix_3x3(), skewed_matrix);
536 EXPECT_EQ(tracker1.matrix_4x4(), skewed_m44);
537 EXPECT_EQ(tracker1.matrix(), skewed_dl_matrix);
538
539 EXPECT_FALSE(tracker2.using_4x4_matrix());
540 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
541 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
542 EXPECT_EQ(tracker2.matrix_3x3(), skewed_matrix);
543 EXPECT_EQ(tracker2.matrix_4x4(), skewed_m44);
544 EXPECT_EQ(tracker2.matrix(), skewed_dl_matrix);
545
546 EXPECT_FALSE(tracker3.using_4x4_matrix());
547 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
548 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
549 EXPECT_EQ(tracker3.matrix_3x3(), skewed_matrix);
550 EXPECT_EQ(tracker3.matrix_4x4(), skewed_m44);
551 EXPECT_EQ(tracker3.matrix(), skewed_dl_matrix);
552}

◆ TEST() [242/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
Transform2DAffine   
)

Definition at line 679 of file dl_matrix_clip_tracker_unittests.cc.

679 {
680 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
681 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
682 const SkMatrix matrix = SkMatrix::Scale(4, 4);
683 const SkM44 m44 = SkM44::Scale(4, 4);
684 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
685
686 const SkMatrix transformed_matrix =
687 SkMatrix::Concat(matrix, SkMatrix::MakeAll(2, 0, 5, //
688 0, 2, 6, //
689 0, 0, 1));
690 const SkM44 transformed_m44 = SkM44(transformed_matrix);
691 const DlMatrix transformed_dl_matrix =
692 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
693 0, 2, 0, 6, //
694 0, 0, 1, 0, //
695 0, 0, 0, 1);
696 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
697
698 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
699 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
700 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
701 tracker1.transform2DAffine(2, 0, 5, //
702 0, 2, 6);
703 tracker2.transform2DAffine(2, 0, 5, //
704 0, 2, 6);
705 tracker3.transform2DAffine(2, 0, 5, //
706 0, 2, 6);
707
708 EXPECT_FALSE(tracker1.using_4x4_matrix());
709 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
710 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
711 EXPECT_EQ(tracker1.matrix_3x3(), transformed_matrix);
712 EXPECT_EQ(tracker1.matrix_4x4(), transformed_m44);
713 EXPECT_EQ(tracker1.matrix(), transformed_dl_matrix);
714
715 EXPECT_FALSE(tracker2.using_4x4_matrix());
716 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
717 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
718 EXPECT_EQ(tracker2.matrix_3x3(), transformed_matrix);
719 EXPECT_EQ(tracker2.matrix_4x4(), transformed_m44);
720 EXPECT_EQ(tracker2.matrix(), transformed_dl_matrix);
721
722 EXPECT_FALSE(tracker3.using_4x4_matrix());
723 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
724 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
725 EXPECT_EQ(tracker3.matrix_3x3(), transformed_matrix);
726 EXPECT_EQ(tracker3.matrix_4x4(), transformed_m44);
727 EXPECT_EQ(tracker3.matrix(), transformed_dl_matrix);
728}

◆ TEST() [243/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
TransformFullPerspectiveUsing3x3Matrix   
)

Definition at line 781 of file dl_matrix_clip_tracker_unittests.cc.

781 {
782 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
783 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
784 const SkMatrix matrix = SkMatrix::Scale(4, 4);
785 const SkM44 m44 = SkM44::Scale(4, 4);
786 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
787
788 const SkMatrix transformed_matrix =
789 SkMatrix::Concat(matrix, SkMatrix::MakeAll(2, 0, 5, //
790 0, 2, 6, //
791 0, 0, 1));
792 const SkM44 transformed_m44 = SkM44(transformed_matrix);
793 const DlMatrix transformed_dl_matrix =
794 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
795 0, 2, 0, 6, //
796 0, 0, 1, 0, //
797 0, 0, 0, 1);
798 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
799
800 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
801 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
802 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
803 tracker1.transformFullPerspective(2, 0, 0, 5, //
804 0, 2, 0, 6, //
805 0, 0, 1, 0, //
806 0, 0, 0, 1);
807 tracker2.transformFullPerspective(2, 0, 0, 5, //
808 0, 2, 0, 6, //
809 0, 0, 1, 0, //
810 0, 0, 0, 1);
811 tracker3.transformFullPerspective(2, 0, 0, 5, //
812 0, 2, 0, 6, //
813 0, 0, 1, 0, //
814 0, 0, 0, 1);
815
816 EXPECT_FALSE(tracker1.using_4x4_matrix());
817 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
818 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
819 EXPECT_EQ(tracker1.matrix_3x3(), transformed_matrix);
820 EXPECT_EQ(tracker1.matrix_4x4(), transformed_m44);
821 EXPECT_EQ(tracker1.matrix(), transformed_dl_matrix);
822
823 EXPECT_FALSE(tracker2.using_4x4_matrix());
824 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
825 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
826 EXPECT_EQ(tracker2.matrix_3x3(), transformed_matrix);
827 EXPECT_EQ(tracker2.matrix_4x4(), transformed_m44);
828 EXPECT_EQ(tracker2.matrix(), transformed_dl_matrix);
829
830 EXPECT_FALSE(tracker3.using_4x4_matrix());
831 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
832 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
833 EXPECT_EQ(tracker3.matrix_3x3(), transformed_matrix);
834 EXPECT_EQ(tracker3.matrix_4x4(), transformed_m44);
835 EXPECT_EQ(tracker3.matrix(), transformed_dl_matrix);
836}

◆ TEST() [244/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
TransformFullPerspectiveUsing4x4Matrix   
)

Definition at line 895 of file dl_matrix_clip_tracker_unittests.cc.

895 {
896 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
897 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
898 const SkMatrix matrix = SkMatrix::Scale(4, 4);
899 const SkM44 m44 = SkM44::Scale(4, 4);
900 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
901
902 const SkM44 transformed_m44 = SkM44(m44, SkM44(2, 0, 0, 5, //
903 0, 2, 0, 6, //
904 0, 0, 1, 7, //
905 0, 0, 0, 1));
906 const DlMatrix transformed_dl_matrix =
907 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
908 0, 2, 0, 6, //
909 0, 0, 1, 7, //
910 0, 0, 0, 1);
911 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
912
913 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
914 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
915 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
916 tracker1.transformFullPerspective(2, 0, 0, 5, //
917 0, 2, 0, 6, //
918 0, 0, 1, 7, //
919 0, 0, 0, 1);
920 tracker2.transformFullPerspective(2, 0, 0, 5, //
921 0, 2, 0, 6, //
922 0, 0, 1, 7, //
923 0, 0, 0, 1);
924 tracker3.transformFullPerspective(2, 0, 0, 5, //
925 0, 2, 0, 6, //
926 0, 0, 1, 7, //
927 0, 0, 0, 1);
928
929 EXPECT_TRUE(tracker1.using_4x4_matrix());
930 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
931 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
932 EXPECT_EQ(tracker1.matrix_4x4(), transformed_m44);
933 EXPECT_EQ(tracker1.matrix(), transformed_dl_matrix);
934
935 EXPECT_TRUE(tracker2.using_4x4_matrix());
936 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
937 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
938 EXPECT_EQ(tracker2.matrix_4x4(), transformed_m44);
939 EXPECT_EQ(tracker2.matrix(), transformed_dl_matrix);
940
941 EXPECT_TRUE(tracker3.using_4x4_matrix());
942 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
943 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
944 EXPECT_EQ(tracker3.matrix_4x4(), transformed_m44);
945 EXPECT_EQ(tracker3.matrix(), transformed_dl_matrix);
946}

◆ TEST() [245/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
TransformTo4x4   
)

Definition at line 146 of file dl_matrix_clip_tracker_unittests.cc.

146 {
147 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
148 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
149 // clang-format off
150 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
151 0, 4, 0.5, 0,
152 0, 0, 4.0, 0,
153 0, 0, 0.0, 1);
154 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
155 0, 4, 0.5, 0,
156 0, 0, 4.0, 0,
157 0, 0, 0.0, 1);
158 // clang-format on
159 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
160
161 DisplayListMatrixClipTracker tracker1(cull_rect, SkMatrix::I());
162 DisplayListMatrixClipTracker tracker2(dl_cull_rect, DlMatrix());
163 EXPECT_FALSE(tracker1.using_4x4_matrix());
164 EXPECT_FALSE(tracker2.using_4x4_matrix());
165
166 tracker1.transform(m44);
167 EXPECT_TRUE(tracker1.using_4x4_matrix());
168 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
169 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
170 EXPECT_EQ(tracker1.matrix_4x4(), m44);
171 EXPECT_EQ(tracker1.matrix(), dl_matrix);
172
173 tracker2.transform(dl_matrix);
174 EXPECT_TRUE(tracker2.using_4x4_matrix());
175 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
176 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
177 EXPECT_EQ(tracker2.matrix_4x4(), m44);
178 EXPECT_EQ(tracker2.matrix(), dl_matrix);
179}

◆ TEST() [246/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
Translate   
)

Definition at line 343 of file dl_matrix_clip_tracker_unittests.cc.

343 {
344 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
345 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
346 const SkMatrix matrix = SkMatrix::Scale(4, 4);
347 const SkM44 m44 = SkM44::Scale(4, 4);
348 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
349 const SkMatrix translated_matrix =
351 const SkM44 translated_m44 = SkM44(translated_matrix);
352 const DlMatrix dl_translated_matrix =
353 dl_matrix * DlMatrix::MakeTranslation({5.0, 1.0});
354 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 9, 10, 19);
355
356 DisplayListMatrixClipTracker tracker1(cull_rect, matrix);
357 DisplayListMatrixClipTracker tracker2(cull_rect, m44);
358 DisplayListMatrixClipTracker tracker3(dl_cull_rect, dl_matrix);
359 tracker1.translate(5, 1);
360 tracker2.translate(5, 1);
361 tracker3.translate(5, 1);
362
363 EXPECT_FALSE(tracker1.using_4x4_matrix());
364 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
365 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
366 EXPECT_EQ(tracker1.matrix_3x3(), translated_matrix);
367 EXPECT_EQ(tracker1.matrix_4x4(), translated_m44);
368 EXPECT_EQ(tracker1.matrix(), dl_translated_matrix);
369
370 EXPECT_FALSE(tracker2.using_4x4_matrix());
371 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
372 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
373 EXPECT_EQ(tracker2.matrix_3x3(), translated_matrix);
374 EXPECT_EQ(tracker2.matrix_4x4(), translated_m44);
375 EXPECT_EQ(tracker2.matrix(), dl_translated_matrix);
376
377 EXPECT_FALSE(tracker3.using_4x4_matrix());
378 EXPECT_EQ(tracker3.device_cull_rect(), cull_rect);
379 EXPECT_EQ(tracker3.local_cull_rect(), local_cull_rect);
380 EXPECT_EQ(tracker3.matrix_3x3(), translated_matrix);
381 EXPECT_EQ(tracker3.matrix_4x4(), translated_m44);
382 EXPECT_EQ(tracker3.matrix(), dl_translated_matrix);
383}

◆ TEST() [247/709]

flutter::testing::TEST ( DisplayListMatrixClipTracker  ,
UpgradeTo4x4SaveAndRestore   
)

Definition at line 286 of file dl_matrix_clip_tracker_unittests.cc.

286 {
287 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
288 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
289 // clang-format off
290 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
291 0, 4, 0.5, 0,
292 0, 0, 4.0, 0,
293 0, 0, 0.0, 1);
294 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
295 0, 4, 0.5, 0,
296 0, 0, 4.0, 0,
297 0, 0, 0.0, 1);
298 // clang-format on
299 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
300
301 DisplayListMatrixClipTracker tracker1(cull_rect, SkMatrix::I());
302 DisplayListMatrixClipTracker tracker2(dl_cull_rect, DlMatrix());
303 EXPECT_FALSE(tracker1.using_4x4_matrix());
304 EXPECT_FALSE(tracker2.using_4x4_matrix());
305
306 tracker1.save();
307 tracker2.save();
308 EXPECT_FALSE(tracker1.using_4x4_matrix());
309 EXPECT_FALSE(tracker2.using_4x4_matrix());
310
311 tracker1.transform(m44);
312 EXPECT_TRUE(tracker1.using_4x4_matrix());
313 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
314 EXPECT_EQ(tracker1.local_cull_rect(), local_cull_rect);
315 EXPECT_EQ(tracker1.matrix_4x4(), m44);
316 EXPECT_EQ(tracker1.matrix(), dl_matrix);
317
318 tracker1.restore();
319 EXPECT_FALSE(tracker1.using_4x4_matrix());
320 EXPECT_EQ(tracker1.device_cull_rect(), cull_rect);
321 EXPECT_EQ(tracker1.local_cull_rect(), cull_rect);
322 EXPECT_EQ(tracker1.matrix_4x4(), SkM44());
323 EXPECT_EQ(tracker1.matrix(), DlMatrix());
324
325 tracker2.transform(dl_matrix);
326 EXPECT_TRUE(tracker2.using_4x4_matrix());
327 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
328 EXPECT_EQ(tracker2.local_cull_rect(), local_cull_rect);
329 EXPECT_EQ(tracker2.matrix_4x4(), m44);
330 EXPECT_EQ(tracker2.matrix(), dl_matrix);
331
332 tracker2.restore();
333 EXPECT_FALSE(tracker2.using_4x4_matrix());
334 EXPECT_EQ(tracker2.device_cull_rect(), cull_rect);
335 EXPECT_EQ(tracker2.local_cull_rect(), cull_rect);
336 EXPECT_EQ(tracker2.matrix_4x4(), SkM44());
337 EXPECT_EQ(tracker2.matrix(), DlMatrix());
338}

◆ TEST() [248/709]

flutter::testing::TEST ( DisplayListPaint  ,
ChainingConstructor   
)

Definition at line 104 of file dl_paint_unittests.cc.

104 {
105 SkScalar intervals[] = {1.0f, 2.0f};
106 auto path_effect = DlDashPathEffect::Make(intervals, 2, 0.0f);
107
108 DlPaint paint =
109 DlPaint() //
110 .setAntiAlias(true) //
111 .setInvertColors(true) //
112 .setColor(DlColor::kGreen()) //
113 .setAlpha(0x7F) //
114 .setBlendMode(DlBlendMode::kLuminosity) //
115 .setDrawStyle(DlDrawStyle::kStrokeAndFill) //
116 .setStrokeCap(DlStrokeCap::kSquare) //
117 .setStrokeJoin(DlStrokeJoin::kBevel) //
118 .setStrokeWidth(42) //
119 .setStrokeMiter(1.5) //
120 .setColorSource(DlColorColorSource(DlColor::kMagenta()).shared()) //
122 DlBlendColorFilter(DlColor::kYellow(), DlBlendMode::kDstIn)
123 .shared())
125 DlBlurImageFilter(1.3, 4.7, DlTileMode::kClamp).shared())
126 .setMaskFilter(DlBlurMaskFilter(DlBlurStyle::kInner, 3.14).shared())
127 .setPathEffect(path_effect);
128 EXPECT_TRUE(paint.isAntiAlias());
129 EXPECT_TRUE(paint.isInvertColors());
130 EXPECT_EQ(paint.getColor(), DlColor::kGreen().withAlpha(0x7F));
131 EXPECT_EQ(paint.getAlpha(), 0x7F);
132 EXPECT_EQ(paint.getBlendMode(), DlBlendMode::kLuminosity);
133 EXPECT_EQ(paint.getDrawStyle(), DlDrawStyle::kStrokeAndFill);
134 EXPECT_EQ(paint.getStrokeCap(), DlStrokeCap::kSquare);
135 EXPECT_EQ(paint.getStrokeJoin(), DlStrokeJoin::kBevel);
136 EXPECT_EQ(paint.getStrokeWidth(), 42);
137 EXPECT_EQ(paint.getStrokeMiter(), 1.5);
138 EXPECT_EQ(*paint.getColorSource(), DlColorColorSource(DlColor::kMagenta()));
139 EXPECT_EQ(*paint.getColorFilter(),
140 DlBlendColorFilter(DlColor::kYellow(), DlBlendMode::kDstIn));
141 EXPECT_EQ(*paint.getImageFilter(),
142 DlBlurImageFilter(1.3, 4.7, DlTileMode::kClamp));
143 EXPECT_EQ(*paint.getMaskFilter(),
144 DlBlurMaskFilter(DlBlurStyle::kInner, 3.14));
145 EXPECT_EQ(*paint.getPathEffect(), *path_effect);
146
147 EXPECT_NE(paint, DlPaint());
148}
DlPaint & setPathEffect(const std::shared_ptr< DlPathEffect > &pathEffect)
Definition dl_paint.h:184
DlPaint & setAntiAlias(bool isAntiAlias)
Definition dl_paint.h:59
DlPaint & setInvertColors(bool isInvertColors)
Definition dl_paint.h:65
DlPaint & setColorFilter(const std::shared_ptr< const DlColorFilter > &filter)
Definition dl_paint.h:145
DlPaint & setMaskFilter(const std::shared_ptr< DlMaskFilter > &filter)
Definition dl_paint.h:171
DlPaint & setStrokeCap(DlStrokeCap cap)
Definition dl_paint.h:103
DlPaint & setStrokeWidth(float width)
Definition dl_paint.h:117
DlPaint & setStrokeMiter(float miter)
Definition dl_paint.h:123
DlPaint & setBlendMode(DlBlendMode mode)
Definition dl_paint.h:87
DlPaint & setImageFilter(const std::shared_ptr< const DlImageFilter > &filter)
Definition dl_paint.h:158
DlPaint & setStrokeJoin(DlStrokeJoin join)
Definition dl_paint.h:111
DlPaint & setColorSource(std::shared_ptr< const DlColorSource > source)
Definition dl_paint.h:132

◆ TEST() [249/709]

flutter::testing::TEST ( DisplayListPaint  ,
ConstructorDefaults   
)

Definition at line 13 of file dl_paint_unittests.cc.

13 {
15 EXPECT_FALSE(paint.isAntiAlias());
16 EXPECT_FALSE(paint.isInvertColors());
17 EXPECT_EQ(paint.getColor(), DlPaint::kDefaultColor);
18 EXPECT_EQ(paint.getAlpha(), 0xFF);
19 EXPECT_EQ(paint.getBlendMode(), DlBlendMode::kDefaultMode);
20 EXPECT_EQ(paint.getDrawStyle(), DlDrawStyle::kDefaultStyle);
21 EXPECT_EQ(paint.getStrokeCap(), DlStrokeCap::kDefaultCap);
22 EXPECT_EQ(paint.getStrokeJoin(), DlStrokeJoin::kDefaultJoin);
23 EXPECT_EQ(paint.getStrokeWidth(), DlPaint::kDefaultWidth);
24 EXPECT_EQ(paint.getStrokeMiter(), DlPaint::kDefaultMiter);
25 EXPECT_EQ(paint.getColorSource(), nullptr);
26 EXPECT_EQ(paint.getColorFilter(), nullptr);
27 EXPECT_EQ(paint.getImageFilter(), nullptr);
28 EXPECT_EQ(paint.getMaskFilter(), nullptr);
29 EXPECT_EQ(paint.getPathEffect(), nullptr);
30 EXPECT_TRUE(paint.isDefault());
31 EXPECT_EQ(paint, DlPaint::kDefault);
32
33 EXPECT_EQ(DlBlendMode::kDefaultMode, DlBlendMode::kSrcOver);
34 EXPECT_EQ(DlDrawStyle::kDefaultStyle, DlDrawStyle::kFill);
35 EXPECT_EQ(DlStrokeCap::kDefaultCap, DlStrokeCap::kButt);
36 EXPECT_EQ(DlStrokeJoin::kDefaultJoin, DlStrokeJoin::kMiter);
37
38 EXPECT_EQ(DlPaint::kDefaultColor, DlColor::kBlack());
39 EXPECT_EQ(DlPaint::kDefaultWidth, 0.0);
40 EXPECT_EQ(DlPaint::kDefaultMiter, 4.0);
41
42 EXPECT_EQ(paint, DlPaint());
43 EXPECT_EQ(paint, DlPaint(DlColor::kBlack()));
44 EXPECT_EQ(paint, DlPaint(DlColor(0xFF000000)));
45
46 EXPECT_NE(paint, DlPaint().setAntiAlias(true));
47 EXPECT_NE(paint, DlPaint().setInvertColors(true));
48 EXPECT_NE(paint, DlPaint().setColor(DlColor::kGreen()));
49 EXPECT_NE(paint, DlPaint(DlColor::kGreen()));
50 EXPECT_NE(paint, DlPaint(DlColor(0xFF00FF00)));
51 EXPECT_NE(paint, DlPaint().setAlpha(0x7f));
52 EXPECT_NE(paint, DlPaint().setBlendMode(DlBlendMode::kDstIn));
53 EXPECT_NE(paint, DlPaint().setDrawStyle(DlDrawStyle::kStrokeAndFill));
54 EXPECT_NE(paint, DlPaint().setStrokeCap(DlStrokeCap::kRound));
55 EXPECT_NE(paint, DlPaint().setStrokeJoin(DlStrokeJoin::kRound));
56 EXPECT_NE(paint, DlPaint().setStrokeWidth(6));
57 EXPECT_NE(paint, DlPaint().setStrokeMiter(7));
58
59 DlColorColorSource color_source(DlColor::kMagenta());
60 EXPECT_NE(paint, DlPaint().setColorSource(color_source.shared()));
61
62 DlBlendColorFilter color_filter(DlColor::kYellow(), DlBlendMode::kDstIn);
63 EXPECT_NE(paint, DlPaint().setColorFilter(color_filter.shared()));
64
65 DlBlurImageFilter image_filter(1.3, 4.7, DlTileMode::kClamp);
66 EXPECT_NE(paint, DlPaint().setImageFilter(image_filter.shared()));
67
68 DlBlurMaskFilter mask_filter(DlBlurStyle::kInner, 3.14);
69 EXPECT_NE(paint, DlPaint().setMaskFilter(mask_filter.shared()));
70
71 SkScalar intervals[] = {1.0f, 2.0f};
72 auto path_effect = DlDashPathEffect::Make(intervals, 2, 0.0f);
73 EXPECT_NE(paint, DlPaint().setPathEffect(path_effect.get()));
74}

◆ TEST() [250/709]

flutter::testing::TEST ( DisplayListPaint  ,
NullPointerSetGet   
)

Definition at line 76 of file dl_paint_unittests.cc.

76 {
77 DlColorSource* null_color_source = nullptr;
78 DlColorFilter* null_color_filter = nullptr;
79 DlImageFilter* null_image_filter = nullptr;
80 DlMaskFilter* null_mask_filter = nullptr;
81 DlPathEffect* null_path_effect = nullptr;
83 EXPECT_EQ(paint.setColorSource(null_color_source).getColorSource(), nullptr);
84 EXPECT_EQ(paint.setColorFilter(null_color_filter).getColorFilter(), nullptr);
85 EXPECT_EQ(paint.setImageFilter(null_image_filter).getImageFilter(), nullptr);
86 EXPECT_EQ(paint.setMaskFilter(null_mask_filter).getMaskFilter(), nullptr);
87 EXPECT_EQ(paint.setPathEffect(null_path_effect).getPathEffect(), nullptr);
88}

◆ TEST() [251/709]

flutter::testing::TEST ( DisplayListPaint  ,
NullSharedPointerSetGet   
)

Definition at line 90 of file dl_paint_unittests.cc.

90 {
91 std::shared_ptr<DlColorSource> null_color_source;
92 std::shared_ptr<DlColorFilter> null_color_filter;
93 std::shared_ptr<DlImageFilter> null_image_filter;
94 std::shared_ptr<DlMaskFilter> null_mask_filter;
95 std::shared_ptr<DlPathEffect> null_path_effect;
97 EXPECT_EQ(paint.setColorSource(null_color_source).getColorSource(), nullptr);
98 EXPECT_EQ(paint.setColorFilter(null_color_filter).getColorFilter(), nullptr);
99 EXPECT_EQ(paint.setImageFilter(null_image_filter).getImageFilter(), nullptr);
100 EXPECT_EQ(paint.setMaskFilter(null_mask_filter).getMaskFilter(), nullptr);
101 EXPECT_EQ(paint.setPathEffect(null_path_effect).getPathEffect(), nullptr);
102}

◆ TEST() [252/709]

flutter::testing::TEST ( DisplayListPathEffect  ,
CheckEffectProperties   
)

Definition at line 34 of file dl_path_effect_unittests.cc.

34 {
35 const SkScalar test_dashes[] = {4.0, 2.0};
36 const SkScalar TestDashes2[] = {5.0, 2.0};
37 const SkScalar TestDashes3[] = {4.0, 3.0};
38 const SkScalar TestDashes4[] = {4.0, 2.0, 6.0};
39 auto effect1 = DlDashPathEffect::Make(test_dashes, 2, 0.0);
40 auto effect2 = DlDashPathEffect::Make(TestDashes2, 2, 0.0);
41 auto effect3 = DlDashPathEffect::Make(TestDashes3, 2, 0.0);
42 auto effect4 = DlDashPathEffect::Make(TestDashes4, 3, 0.0);
43 auto effect5 = DlDashPathEffect::Make(test_dashes, 2, 1.0);
44
45 TestNotEquals(*effect1, *effect2, "Interval 1 differs");
46 TestNotEquals(*effect1, *effect3, "Interval 2 differs");
47 TestNotEquals(*effect1, *effect4, "Dash count differs");
48 TestNotEquals(*effect1, *effect5, "Dash phase differs");
49}

◆ TEST() [253/709]

flutter::testing::TEST ( DisplayListPathEffect  ,
DashEffectAsDash   
)

Definition at line 20 of file dl_path_effect_unittests.cc.

20 {
21 const SkScalar TestDashes2[] = {1.0, 1.5};
22 auto effect = DlDashPathEffect::Make(TestDashes2, 2, 0.0);
23 ASSERT_NE(effect->asDash(), nullptr);
24 ASSERT_EQ(effect->asDash(), effect.get());
25}

◆ TEST() [254/709]

flutter::testing::TEST ( DisplayListPathEffect  ,
DashEffectEquals   
)

Definition at line 27 of file dl_path_effect_unittests.cc.

27 {
28 const SkScalar TestDashes2[] = {1.0, 1.5};
29 auto effect1 = DlDashPathEffect::Make(TestDashes2, 2, 0.0);
30 auto effect2 = DlDashPathEffect::Make(TestDashes2, 2, 0.0);
31 TestEquals(*effect1, *effect1);
32}

◆ TEST() [255/709]

flutter::testing::TEST ( DisplayListPathEffect  ,
EffectShared   
)

Definition at line 14 of file dl_path_effect_unittests.cc.

14 {
15 const SkScalar TestDashes2[] = {1.0, 1.5};
16 auto effect = DlDashPathEffect::Make(TestDashes2, 2, 0.0);
17 ASSERT_TRUE(Equals(effect->shared(), effect));
18}

◆ TEST() [256/709]

flutter::testing::TEST ( DisplayListRegion  ,
Deband   
)

Definition at line 128 of file dl_region_unittests.cc.

128 {
129 DlRegion region({
130 SkIRect::MakeXYWH(0, 0, 50, 50),
131 SkIRect::MakeXYWH(60, 0, 20, 20),
132 SkIRect::MakeXYWH(90, 0, 50, 50),
133 });
134
135 auto rects_with_deband = region.getRects(true);
136 std::vector<SkIRect> expected{
137 SkIRect::MakeXYWH(60, 0, 20, 20),
138 SkIRect::MakeXYWH(0, 0, 50, 50),
139 SkIRect::MakeXYWH(90, 0, 50, 50),
140 };
141 EXPECT_EQ(rects_with_deband, expected);
142
143 auto rects_without_deband = region.getRects(false);
144 std::vector<SkIRect> expected_without_deband{
145 SkIRect::MakeXYWH(0, 0, 50, 20), //
146 SkIRect::MakeXYWH(60, 0, 20, 20), //
147 SkIRect::MakeXYWH(90, 0, 50, 20), //
148 SkIRect::MakeXYWH(0, 20, 50, 30), //
149 SkIRect::MakeXYWH(90, 20, 50, 30),
150 };
151 EXPECT_EQ(rects_without_deband, expected_without_deband);
152}

◆ TEST() [257/709]

flutter::testing::TEST ( DisplayListRegion  ,
EmptyRegion   
)

Definition at line 15 of file dl_region_unittests.cc.

15 {
16 DlRegion region;
17 EXPECT_TRUE(region.isEmpty());
18 EXPECT_TRUE(region.getRects().empty());
19}
bool isEmpty() const
Definition SkRegion.h:146

◆ TEST() [258/709]

flutter::testing::TEST ( DisplayListRegion  ,
Intersection1   
)

Definition at line 197 of file dl_region_unittests.cc.

197 {
198 DlRegion region1({
199 SkIRect::MakeXYWH(0, 0, 20, 20),
200 SkIRect::MakeXYWH(20, 20, 20, 20),
201 });
202 DlRegion region2({
203 SkIRect::MakeXYWH(20, 0, 20, 20),
204 SkIRect::MakeXYWH(0, 20, 20, 20),
205 });
206 DlRegion i = DlRegion::MakeIntersection(region1, region2);
207 EXPECT_EQ(i.bounds(), SkIRect::MakeEmpty());
208 EXPECT_TRUE(i.isEmpty());
209 auto rects = i.getRects();
210 EXPECT_TRUE(rects.empty());
211}
static constexpr SkIRect MakeEmpty()
Definition SkRect.h:45

◆ TEST() [259/709]

flutter::testing::TEST ( DisplayListRegion  ,
Intersection2   
)

Definition at line 213 of file dl_region_unittests.cc.

213 {
214 DlRegion region1({
215 SkIRect::MakeXYWH(0, 0, 20, 20),
216 SkIRect::MakeXYWH(20, 20, 20, 20),
217 });
218 DlRegion region2({
219 SkIRect::MakeXYWH(0, 0, 20, 20),
220 SkIRect::MakeXYWH(20, 20, 20, 20),
221 });
222 DlRegion i = DlRegion::MakeIntersection(region1, region2);
223 EXPECT_EQ(i.bounds(), SkIRect::MakeXYWH(0, 0, 40, 40));
224 auto rects = i.getRects();
225 std::vector<SkIRect> expected{
226 SkIRect::MakeXYWH(0, 0, 20, 20),
227 SkIRect::MakeXYWH(20, 20, 20, 20),
228 };
229 EXPECT_EQ(rects, expected);
230}

◆ TEST() [260/709]

flutter::testing::TEST ( DisplayListRegion  ,
Intersection3   
)

Definition at line 232 of file dl_region_unittests.cc.

232 {
233 DlRegion region1({
234 SkIRect::MakeXYWH(0, 0, 20, 20),
235 });
236 DlRegion region2({
237 SkIRect::MakeXYWH(-10, -10, 20, 20),
238 SkIRect::MakeXYWH(10, 10, 20, 20),
239 });
240 DlRegion i = DlRegion::MakeIntersection(region1, region2);
241 EXPECT_EQ(i.bounds(), SkIRect::MakeXYWH(0, 0, 20, 20));
242 auto rects = i.getRects();
243 std::vector<SkIRect> expected{
244 SkIRect::MakeXYWH(0, 0, 10, 10),
245 SkIRect::MakeXYWH(10, 10, 10, 10),
246 };
247 EXPECT_EQ(rects, expected);
248}

◆ TEST() [261/709]

flutter::testing::TEST ( DisplayListRegion  ,
Intersects1   
)

Definition at line 154 of file dl_region_unittests.cc.

154 {
155 DlRegion region1({
156 SkIRect::MakeXYWH(0, 0, 20, 20),
157 SkIRect::MakeXYWH(20, 20, 20, 20),
158 });
159 DlRegion region2({
160 SkIRect::MakeXYWH(20, 0, 20, 20),
161 SkIRect::MakeXYWH(0, 20, 20, 20),
162 });
163 EXPECT_FALSE(region1.intersects(region2));
164 EXPECT_FALSE(region2.intersects(region1));
165
166 EXPECT_TRUE(region1.intersects(region2.bounds()));
167 EXPECT_TRUE(region2.intersects(region1.bounds()));
168
169 EXPECT_TRUE(region1.intersects(SkIRect::MakeXYWH(0, 0, 20, 20)));
170 EXPECT_FALSE(region1.intersects(SkIRect::MakeXYWH(20, 0, 20, 20)));
171
172 EXPECT_TRUE(region1.intersects(
173 DlRegion(std::vector<SkIRect>{SkIRect::MakeXYWH(0, 0, 20, 20)})));
174 EXPECT_FALSE(region1.intersects(
175 DlRegion(std::vector<SkIRect>{SkIRect::MakeXYWH(20, 0, 20, 20)})));
176
177 EXPECT_FALSE(region1.intersects(SkIRect::MakeXYWH(-1, -1, 1, 1)));
178 EXPECT_TRUE(region1.intersects(SkIRect::MakeXYWH(0, 0, 1, 1)));
179
180 EXPECT_FALSE(region1.intersects(SkIRect::MakeXYWH(40, 40, 1, 1)));
181 EXPECT_TRUE(region1.intersects(SkIRect::MakeXYWH(39, 39, 1, 1)));
182}

◆ TEST() [262/709]

flutter::testing::TEST ( DisplayListRegion  ,
Intersects2   
)

Definition at line 184 of file dl_region_unittests.cc.

184 {
185 DlRegion region1({
186 SkIRect::MakeXYWH(-10, -10, 20, 20),
187 SkIRect::MakeXYWH(-30, -30, 20, 20),
188 });
189 DlRegion region2({
190 SkIRect::MakeXYWH(20, 20, 5, 5),
191 SkIRect::MakeXYWH(0, 0, 20, 20),
192 });
193 EXPECT_TRUE(region1.intersects(region2));
194 EXPECT_TRUE(region2.intersects(region1));
195}

◆ TEST() [263/709]

flutter::testing::TEST ( DisplayListRegion  ,
MergeTouchingRectangles   
)

Definition at line 89 of file dl_region_unittests.cc.

89 {
90 DlRegion region({
91 SkIRect::MakeXYWH(0, 0, 10, 10),
92 SkIRect::MakeXYWH(-10, -10, 10, 10),
93 SkIRect::MakeXYWH(10, 10, 10, 10),
94 SkIRect::MakeXYWH(-10, 0, 10, 10),
95 SkIRect::MakeXYWH(0, 10, 10, 10),
96 SkIRect::MakeXYWH(0, -10, 10, 10),
97 SkIRect::MakeXYWH(10, 0, 10, 10),
98 SkIRect::MakeXYWH(10, -10, 10, 10),
99 SkIRect::MakeXYWH(-10, 10, 10, 10),
100 });
101
102 auto rects = region.getRects();
103 std::vector<SkIRect> expected{
104 SkIRect::MakeXYWH(-10, -10, 30, 30),
105 };
106 EXPECT_EQ(rects, expected);
107}

◆ TEST() [264/709]

flutter::testing::TEST ( DisplayListRegion  ,
NonOverlappingRectangles1   
)

Definition at line 28 of file dl_region_unittests.cc.

28 {
29 std::vector<SkIRect> rects_in;
30 for (int i = 0; i < 10; ++i) {
31 SkIRect rect = SkIRect::MakeXYWH(50 * i, 50 * i, 50, 50);
32 rects_in.push_back(rect);
33 }
34 DlRegion region(rects_in);
35 auto rects = region.getRects();
36 std::vector<SkIRect> expected{
37 {0, 0, 50, 50}, {50, 50, 100, 100}, {100, 100, 150, 150},
38 {150, 150, 200, 200}, {200, 200, 250, 250}, {250, 250, 300, 300},
39 {300, 300, 350, 350}, {350, 350, 400, 400}, {400, 400, 450, 450},
40 {450, 450, 500, 500},
41 };
42 EXPECT_EQ(rects, expected);
43}

◆ TEST() [265/709]

flutter::testing::TEST ( DisplayListRegion  ,
NonOverlappingRectangles2   
)

Definition at line 45 of file dl_region_unittests.cc.

45 {
46 DlRegion region({
47 SkIRect::MakeXYWH(5, 5, 10, 10),
48 SkIRect::MakeXYWH(25, 5, 10, 10),
49 SkIRect::MakeXYWH(5, 25, 10, 10),
50 SkIRect::MakeXYWH(25, 25, 10, 10),
51 });
52 auto rects = region.getRects();
53 std::vector<SkIRect> expected{
54 SkIRect::MakeXYWH(5, 5, 10, 10),
55 SkIRect::MakeXYWH(25, 5, 10, 10),
56 SkIRect::MakeXYWH(5, 25, 10, 10),
57 SkIRect::MakeXYWH(25, 25, 10, 10),
58 };
59 EXPECT_EQ(rects, expected);
60}

◆ TEST() [266/709]

flutter::testing::TEST ( DisplayListRegion  ,
NonOverlappingRectangles3   
)

Definition at line 62 of file dl_region_unittests.cc.

62 {
63 DlRegion region({
64 SkIRect::MakeXYWH(0, 0, 10, 10),
65 SkIRect::MakeXYWH(-11, -11, 10, 10),
66 SkIRect::MakeXYWH(11, 11, 10, 10),
67 SkIRect::MakeXYWH(-11, 0, 10, 10),
68 SkIRect::MakeXYWH(0, 11, 10, 10),
69 SkIRect::MakeXYWH(0, -11, 10, 10),
70 SkIRect::MakeXYWH(11, 0, 10, 10),
71 SkIRect::MakeXYWH(11, -11, 10, 10),
72 SkIRect::MakeXYWH(-11, 11, 10, 10),
73 });
74 auto rects = region.getRects();
75 std::vector<SkIRect> expected{
76 SkIRect::MakeXYWH(-11, -11, 10, 10), //
77 SkIRect::MakeXYWH(0, -11, 10, 10), //
78 SkIRect::MakeXYWH(11, -11, 10, 10), //
79 SkIRect::MakeXYWH(-11, 0, 10, 10), //
80 SkIRect::MakeXYWH(0, 0, 10, 10), //
81 SkIRect::MakeXYWH(11, 0, 10, 10), //
82 SkIRect::MakeXYWH(-11, 11, 10, 10), //
83 SkIRect::MakeXYWH(0, 11, 10, 10), //
84 SkIRect::MakeXYWH(11, 11, 10, 10),
85 };
86 EXPECT_EQ(rects, expected);
87}

◆ TEST() [267/709]

flutter::testing::TEST ( DisplayListRegion  ,
OverlappingRectangles   
)

Definition at line 109 of file dl_region_unittests.cc.

109 {
110 std::vector<SkIRect> rects_in;
111 for (int i = 0; i < 10; ++i) {
112 SkIRect rect = SkIRect::MakeXYWH(10 * i, 10 * i, 50, 50);
113 rects_in.push_back(rect);
114 }
115 DlRegion region(rects_in);
116 auto rects = region.getRects();
117 std::vector<SkIRect> expected{
118 {0, 0, 50, 10}, {0, 10, 60, 20}, {0, 20, 70, 30},
119 {0, 30, 80, 40}, {0, 40, 90, 50}, {10, 50, 100, 60},
120 {20, 60, 110, 70}, {30, 70, 120, 80}, {40, 80, 130, 90},
121 {50, 90, 140, 100}, {60, 100, 140, 110}, {70, 110, 140, 120},
122 {80, 120, 140, 130}, {90, 130, 140, 140},
123 };
124
125 EXPECT_EQ(rects, expected);
126}

◆ TEST() [268/709]

flutter::testing::TEST ( DisplayListRegion  ,
SingleRectangle   
)

Definition at line 21 of file dl_region_unittests.cc.

21 {
22 DlRegion region({SkIRect::MakeLTRB(10, 10, 50, 50)});
23 auto rects = region.getRects();
24 ASSERT_EQ(rects.size(), 1u);
25 EXPECT_EQ(rects.front(), SkIRect::MakeLTRB(10, 10, 50, 50));
26}

◆ TEST() [269/709]

flutter::testing::TEST ( DisplayListRegion  ,
TestAgainstSkRegion   
)

Definition at line 361 of file dl_region_unittests.cc.

361 {
362 struct Settings {
363 int max_size;
364 };
365 std::vector<Settings> all_settings{{100}, {400}, {800}};
366
367 std::vector<size_t> iterations{1, 10, 100, 1000};
368
369 for (const auto& settings : all_settings) {
370 for (const auto iterations_1 : iterations) {
371 for (const auto iterations_2 : iterations) {
372 std::random_device d;
373 std::seed_seq seed{::testing::UnitTest::GetInstance()->random_seed()};
374 std::mt19937 rng(seed);
375
376 SkRegion sk_region1;
377 SkRegion sk_region2;
378
379 std::uniform_int_distribution pos(0, 4000);
380 std::uniform_int_distribution size(1, settings.max_size);
381
382 std::vector<SkIRect> rects_in1;
383 std::vector<SkIRect> rects_in2;
384
385 for (size_t i = 0; i < iterations_1; ++i) {
386 SkIRect rect =
387 SkIRect::MakeXYWH(pos(rng), pos(rng), size(rng), size(rng));
388 rects_in1.push_back(rect);
389 }
390
391 for (size_t i = 0; i < iterations_2; ++i) {
392 SkIRect rect =
393 SkIRect::MakeXYWH(pos(rng), pos(rng), size(rng), size(rng));
394 rects_in2.push_back(rect);
395 }
396
397 DlRegion region1(rects_in1);
398 sk_region1.setRects(rects_in1.data(), rects_in1.size());
399 CheckEquality(region1, sk_region1);
400
401 DlRegion region2(rects_in2);
402 sk_region2.setRects(rects_in2.data(), rects_in2.size());
403 CheckEquality(region2, sk_region2);
404
405 auto intersects_1 = region1.intersects(region2);
406 auto intersects_2 = region2.intersects(region1);
407 auto sk_intesects = sk_region1.intersects(sk_region2);
408 EXPECT_EQ(intersects_1, intersects_2);
409 EXPECT_EQ(intersects_1, sk_intesects);
410
411 {
412 auto rects = region2.getRects(true);
413 for (const auto& r : rects) {
414 EXPECT_EQ(region1.intersects(r), sk_region1.intersects(r));
415 }
416 }
417
418 DlRegion dl_union = DlRegion::MakeUnion(region1, region2);
419 SkRegion sk_union(sk_region1);
420 sk_union.op(sk_region2, SkRegion::kUnion_Op);
421 CheckEquality(dl_union, sk_union);
422
423 DlRegion dl_intersection = DlRegion::MakeIntersection(region1, region2);
424 SkRegion sk_intersection(sk_region1);
425 sk_intersection.op(sk_region2, SkRegion::kIntersect_Op);
426 CheckEquality(dl_intersection, sk_intersection);
427 }
428 }
429 }
430}
SkPoint pos
@ kUnion_Op
target unioned with operand
Definition SkRegion.h:369
@ kIntersect_Op
target intersected with operand
Definition SkRegion.h:368
bool setRects(const SkIRect rects[], int count)
Definition SkRegion.cpp:657
bool intersects(const SkIRect &rect) const
Definition SkRegion.cpp:502
void CheckEquality(const DlRegion &dl_region, const SkRegion &sk_region)

◆ TEST() [270/709]

flutter::testing::TEST ( DisplayListRegion  ,
Union1   
)

Definition at line 250 of file dl_region_unittests.cc.

250 {
251 DlRegion region1({
252 SkIRect::MakeXYWH(0, 0, 20, 20),
253 SkIRect::MakeXYWH(20, 20, 20, 20),
254 });
255 DlRegion region2({
256 SkIRect::MakeXYWH(20, 0, 20, 20),
257 SkIRect::MakeXYWH(0, 20, 20, 20),
258 });
259 DlRegion u = DlRegion::MakeUnion(region1, region2);
260 EXPECT_EQ(u.bounds(), SkIRect::MakeXYWH(0, 0, 40, 40));
261 EXPECT_TRUE(u.isSimple());
262 auto rects = u.getRects();
263 std::vector<SkIRect> expected{
264 SkIRect::MakeXYWH(0, 0, 40, 40), //
265 };
266 EXPECT_EQ(rects, expected);
267}

◆ TEST() [271/709]

flutter::testing::TEST ( DisplayListRegion  ,
Union2   
)

Definition at line 269 of file dl_region_unittests.cc.

269 {
270 DlRegion region1({
271 SkIRect::MakeXYWH(0, 0, 20, 20),
272 SkIRect::MakeXYWH(21, 21, 20, 20),
273 });
274 DlRegion region2({
275 SkIRect::MakeXYWH(21, 0, 20, 20),
276 SkIRect::MakeXYWH(0, 21, 20, 20),
277 });
278 DlRegion u = DlRegion::MakeUnion(region1, region2);
279 EXPECT_EQ(u.bounds(), SkIRect::MakeXYWH(0, 0, 41, 41));
280 auto rects = u.getRects();
281 std::vector<SkIRect> expected{
282 SkIRect::MakeXYWH(0, 0, 20, 20),
283 SkIRect::MakeXYWH(21, 0, 20, 20),
284 SkIRect::MakeXYWH(0, 21, 20, 20),
285 SkIRect::MakeXYWH(21, 21, 20, 20),
286 };
287 EXPECT_EQ(rects, expected);
288}

◆ TEST() [272/709]

flutter::testing::TEST ( DisplayListRegion  ,
Union3   
)

Definition at line 290 of file dl_region_unittests.cc.

290 {
291 DlRegion region1({
292 SkIRect::MakeXYWH(-10, -10, 20, 20),
293 });
294 DlRegion region2({
295 SkIRect::MakeXYWH(0, 0, 20, 20),
296 });
297 DlRegion u = DlRegion::MakeUnion(region1, region2);
298 EXPECT_EQ(u.bounds(), SkIRect::MakeXYWH(-10, -10, 30, 30));
299 auto rects = u.getRects();
300 std::vector<SkIRect> expected{
301 SkIRect::MakeXYWH(-10, -10, 20, 10),
302 SkIRect::MakeXYWH(-10, 0, 30, 10),
303 SkIRect::MakeXYWH(0, 10, 20, 10),
304 };
305 EXPECT_EQ(rects, expected);
306}

◆ TEST() [273/709]

flutter::testing::TEST ( DisplayListRegion  ,
UnionEmpty   
)

Definition at line 308 of file dl_region_unittests.cc.

308 {
309 {
310 DlRegion region1(std::vector<SkIRect>{});
311 DlRegion region2(std::vector<SkIRect>{});
312 DlRegion u = DlRegion::MakeUnion(region1, region2);
313 EXPECT_EQ(u.bounds(), SkIRect::MakeEmpty());
314 EXPECT_TRUE(u.isEmpty());
315 auto rects = u.getRects();
316 EXPECT_TRUE(rects.empty());
317 }
318 {
319 DlRegion region1(std::vector<SkIRect>{});
320 DlRegion region2({
321 SkIRect::MakeXYWH(0, 0, 20, 20),
322 });
323 DlRegion u = DlRegion::MakeUnion(region1, region2);
324 EXPECT_EQ(u.bounds(), SkIRect::MakeXYWH(0, 0, 20, 20));
325 auto rects = u.getRects();
326 std::vector<SkIRect> expected{
327 SkIRect::MakeXYWH(0, 0, 20, 20),
328 };
329 }
330 {
331 DlRegion region1({
332 SkIRect::MakeXYWH(0, 0, 20, 20),
333 });
334 DlRegion region2(std::vector<SkIRect>{});
335 DlRegion u = DlRegion::MakeUnion(region1, region2);
336 EXPECT_EQ(u.bounds(), SkIRect::MakeXYWH(0, 0, 20, 20));
337 auto rects = u.getRects();
338 std::vector<SkIRect> expected{
339 SkIRect::MakeXYWH(0, 0, 20, 20),
340 };
341 }
342}

◆ TEST() [274/709]

flutter::testing::TEST ( DisplayListRTree  ,
Grid   
)

Definition at line 125 of file dl_rtree_unittests.cc.

125 {
126 // Non-overlapping 10 x 10 rectangles starting at 5, 5 with
127 // 10 pixels between them.
128 // Rect 1 goes from 5 to 15
129 // Rect 2 goes from 25 to 35
130 // etc. in both dimensions
131 const int ROWS = 10;
132 const int COLS = 10;
133 const int N = ROWS * COLS;
134 SkRect rects[N];
135 int ids[N];
136 for (int r = 0; r < ROWS; r++) {
137 int y = r * 20 + 5;
138 for (int c = 0; c < COLS; c++) {
139 int x = c * 20 + 5;
140 int i = r * COLS + c;
141 rects[i] = SkRect::MakeXYWH(x, y, 10, 10);
142 ids[i] = i + 42;
143 }
144 }
145 DlRTree tree(rects, N, ids);
146 EXPECT_EQ(tree.leaf_count(), N);
147 EXPECT_GE(tree.node_count(), N);
148 EXPECT_EQ(tree.id(-1), -1);
149 EXPECT_EQ(tree.bounds(-1), SkRect::MakeEmpty());
150 EXPECT_EQ(tree.id(N), -1);
151 EXPECT_EQ(tree.bounds(N), SkRect::MakeEmpty());
152 std::vector<int> results;
153 tree.search(SkRect::MakeEmpty(), &results);
154 EXPECT_EQ(results.size(), 0u);
155 // Testing eqch rect for a single hit
156 for (int r = 0; r < ROWS; r++) {
157 int y = r * 20 + 5;
158 for (int c = 0; c < COLS; c++) {
159 int x = c * 20 + 5;
160 int i = r * COLS + c;
161 auto desc =
162 "row " + std::to_string(r + 1) + ", col " + std::to_string(c + 1);
163 results.clear();
164 auto query = SkRect::MakeXYWH(x + 2, y + 2, 6, 6);
165 tree.search(query, &results);
166 EXPECT_EQ(results.size(), 1u) << desc;
167 EXPECT_EQ(results[0], i) << desc;
168 EXPECT_EQ(tree.id(results[0]), ids[i]) << desc;
169 EXPECT_EQ(tree.bounds(results[0]), rects[i]) << desc;
170 auto list = tree.searchAndConsolidateRects(query);
171 EXPECT_EQ(list.size(), 1u);
172 EXPECT_EQ(list.front(), rects[i]);
173 }
174 }
175 // Testing inside each gap for no hits
176 for (int r = 1; r < ROWS; r++) {
177 int y = r * 20 + 5;
178 for (int c = 1; c < COLS; c++) {
179 int x = c * 20 + 5;
180 auto desc =
181 "row " + std::to_string(r + 1) + ", col " + std::to_string(c + 1);
182 results.clear();
183 auto query = SkRect::MakeXYWH(x - 8, y - 8, 6, 6);
184 tree.search(query, &results);
185 EXPECT_EQ(results.size(), 0u) << desc;
186 auto list = tree.searchAndConsolidateRects(query);
187 EXPECT_EQ(list.size(), 0u) << desc;
188 }
189 }
190 // Spanning each gap for a quad of hits
191 for (int r = 1; r < ROWS; r++) {
192 int y = r * 20 + 5;
193 for (int c = 1; c < COLS; c++) {
194 int x = c * 20 + 5;
195 // We will hit this rect and the ones above/left of us
196 int i = r * COLS + c;
197 auto desc =
198 "row " + std::to_string(r + 1) + ", col " + std::to_string(c + 1);
199 results.clear();
200 auto query = SkRect::MakeXYWH(x - 11, y - 11, 12, 12);
201 tree.search(query, &results);
202 EXPECT_EQ(results.size(), 4u) << desc;
203
204 // First rect is above and to the left
205 EXPECT_EQ(results[0], i - COLS - 1) << desc;
206 EXPECT_EQ(tree.id(results[0]), ids[i - COLS - 1]) << desc;
207 EXPECT_EQ(tree.bounds(results[0]), rects[i - COLS - 1]) << desc;
208
209 // Second rect is above
210 EXPECT_EQ(results[1], i - COLS) << desc;
211 EXPECT_EQ(tree.id(results[1]), ids[i - COLS]) << desc;
212 EXPECT_EQ(tree.bounds(results[1]), rects[i - COLS]) << desc;
213
214 // Third rect is left
215 EXPECT_EQ(results[2], i - 1) << desc;
216 EXPECT_EQ(tree.id(results[2]), ids[i - 1]) << desc;
217 EXPECT_EQ(tree.bounds(results[2]), rects[i - 1]) << desc;
218
219 // Fourth rect is us
220 EXPECT_EQ(results[3], i) << desc;
221 EXPECT_EQ(tree.id(results[3]), ids[i]) << desc;
222 EXPECT_EQ(tree.bounds(results[3]), rects[i]) << desc;
223
224 auto list = tree.searchAndConsolidateRects(query);
225 EXPECT_EQ(list.size(), 4u);
226 list.remove(rects[i - COLS - 1]);
227 list.remove(rects[i - COLS]);
228 list.remove(rects[i - 1]);
229 list.remove(rects[i]);
230 EXPECT_EQ(list.size(), 0u);
231 }
232 }
233}
#define N
Definition beziers.cpp:19

◆ TEST() [275/709]

flutter::testing::TEST ( DisplayListRTree  ,
HugeSize   
)

Definition at line 92 of file dl_rtree_unittests.cc.

92 {
93 // A diagonal of non-overlapping 10x10 rectangles spaced 20
94 // pixels apart.
95 // Rect 1 goes from 0 to 10
96 // Rect 2 goes from 20 to 30
97 // etc. in both dimensions
98 const int N = 10000;
99 SkRect rects[N];
100 int ids[N];
101 for (int i = 0; i < N; i++) {
102 rects[i].setXYWH(i * 20, i * 20, 10, 10);
103 ids[i] = i + 42;
104 }
105 DlRTree tree(rects, N, ids);
106 EXPECT_EQ(tree.leaf_count(), N);
107 EXPECT_GE(tree.node_count(), N);
108 EXPECT_EQ(tree.id(-1), -1);
109 EXPECT_EQ(tree.bounds(-1), SkRect::MakeEmpty());
110 EXPECT_EQ(tree.id(N), -1);
111 EXPECT_EQ(tree.bounds(N), SkRect::MakeEmpty());
112 std::vector<int> results;
113 tree.search(SkRect::MakeEmpty(), &results);
114 EXPECT_EQ(results.size(), 0u);
115 for (int i = 0; i < N; i++) {
116 results.clear();
117 tree.search(SkRect::MakeXYWH(i * 20 + 2, i * 20 + 2, 6, 6), &results);
118 EXPECT_EQ(results.size(), 1u);
119 EXPECT_EQ(results[0], i);
120 EXPECT_EQ(tree.id(results[0]), ids[i]);
121 EXPECT_EQ(tree.bounds(results[0]), rects[i]);
122 }
123}
void setXYWH(float x, float y, float width, float height)
Definition SkRect.h:931

◆ TEST() [276/709]

flutter::testing::TEST ( DisplayListRTree  ,
ManySizes   
)

Definition at line 41 of file dl_rtree_unittests.cc.

41 {
42 // A diagonal of non-overlapping 10x10 rectangles spaced 20
43 // pixels apart.
44 // Rect 1 goes from 0 to 10
45 // Rect 2 goes from 20 to 30
46 // etc. in both dimensions
47 const int kMaxN = 250;
48 SkRect rects[kMaxN + 1];
49 int ids[kMaxN + 1];
50 for (int i = 0; i <= kMaxN; i++) {
51 rects[i].setXYWH(i * 20, i * 20, 10, 10);
52 ids[i] = i + 42;
53 }
54 std::vector<int> results;
55 for (int N = 0; N <= kMaxN; N++) {
56 DlRTree tree(rects, N, ids);
57 auto desc = "node count = " + std::to_string(N);
58 EXPECT_EQ(tree.leaf_count(), N) << desc;
59 EXPECT_GE(tree.node_count(), N) << desc;
60 EXPECT_EQ(tree.id(-1), -1) << desc;
61 EXPECT_EQ(tree.bounds(-1), SkRect::MakeEmpty()) << desc;
62 EXPECT_EQ(tree.id(N), -1) << desc;
63 EXPECT_EQ(tree.bounds(N), SkRect::MakeEmpty()) << desc;
64 results.clear();
65 tree.search(SkRect::MakeEmpty(), &results);
66 EXPECT_EQ(results.size(), 0u) << desc;
67 results.clear();
68 tree.search(SkRect::MakeLTRB(2, 2, 8, 8), &results);
69 if (N == 0) {
70 EXPECT_EQ(results.size(), 0u) << desc;
71 } else {
72 EXPECT_EQ(results.size(), 1u) << desc;
73 EXPECT_EQ(results[0], 0) << desc;
74 EXPECT_EQ(tree.id(results[0]), ids[0]) << desc;
75 EXPECT_EQ(tree.bounds(results[0]), rects[0]) << desc;
76 for (int i = 1; i < N; i++) {
77 results.clear();
78 auto query = SkRect::MakeXYWH(i * 20 + 2, i * 20 + 2, 6, 6);
79 tree.search(query, &results);
80 EXPECT_EQ(results.size(), 1u) << desc;
81 EXPECT_EQ(results[0], i) << desc;
82 EXPECT_EQ(tree.id(results[0]), ids[i]) << desc;
83 EXPECT_EQ(tree.bounds(results[0]), rects[i]) << desc;
84 auto list = tree.searchAndConsolidateRects(query);
85 EXPECT_EQ(list.size(), 1u);
86 EXPECT_EQ(list.front(), rects[i]);
87 }
88 }
89 }
90}

◆ TEST() [277/709]

flutter::testing::TEST ( DisplayListRTree  ,
NegativeCount   
)

Definition at line 18 of file dl_rtree_unittests.cc.

18 {
19 EXPECT_DEATH_IF_SUPPORTED(new DlRTree(nullptr, -1), "N >= 0");
20}

◆ TEST() [278/709]

flutter::testing::TEST ( DisplayListRTree  ,
NullRectListNonZeroCount   
)

Definition at line 14 of file dl_rtree_unittests.cc.

14 {
15 EXPECT_DEATH_IF_SUPPORTED(new DlRTree(nullptr, 1), "rects != nullptr");
16}

◆ TEST() [279/709]

flutter::testing::TEST ( DisplayListRTree  ,
NullRectListZeroCount   
)

Definition at line 29 of file dl_rtree_unittests.cc.

29 {
30 DlRTree tree(nullptr, 0);
31 EXPECT_EQ(tree.leaf_count(), 0);
32 EXPECT_EQ(tree.node_count(), 0);
33 std::vector<int> results;
34 auto huge = SkRect::MakeLTRB(-1e6, -1e6, 1e6, 1e6);
35 tree.search(huge, &results);
36 EXPECT_EQ(results.size(), 0u);
37 auto list = tree.searchAndConsolidateRects(huge);
38 EXPECT_EQ(list.size(), 0u);
39}

◆ TEST() [280/709]

flutter::testing::TEST ( DisplayListRTree  ,
NullSearchResultVector   
)

Definition at line 22 of file dl_rtree_unittests.cc.

22 {
23 DlRTree tree(nullptr, 0);
24 EXPECT_DEATH_IF_SUPPORTED(tree.search(SkRect::MakeLTRB(0, 0, 1, 1), nullptr),
25 "results != nullptr");
26}

◆ TEST() [281/709]

flutter::testing::TEST ( DisplayListRTree  ,
OverlappingRects   
)

Definition at line 235 of file dl_rtree_unittests.cc.

235 {
236 // Rectangles are centered at coordinates 15, 35, and 55 and are 15 wide
237 // This gives them 10 pixels of overlap with the rectangles on either
238 // side of them and the 10 pixels around their center coordinate are
239 // exclusive to themselves.
240 // So, horizontally and vertically, they cover the following ranges:
241 // First row/col: 0 to 30
242 // Second row/col: 20 to 50
243 // Third row/col: 40 to 70
244 // Coords 0 to 20 are only the first row/col
245 // Coords 20 to 30 are both first and second row/col
246 // Coords 30 to 40 are only the second row/col
247 // Coords 40 to 50 are both second and third row/col
248 // Coords 50 to 70 are only the third row/col
249 //
250 // In either dimension:
251 // 0------------------20--------30--------40--------50------------------70
252 // | rect1 |
253 // | 1 & 2 |
254 // | rect2 |
255 // | 2 & 3 |
256 // | rect3 |
257 SkRect rects[9];
258 for (int r = 0; r < 3; r++) {
259 int y = 15 + 20 * r;
260 for (int c = 0; c < 3; c++) {
261 int x = 15 + 20 * c;
262 rects[r * 3 + c].setLTRB(x - 15, y - 15, x + 15, y + 15);
263 }
264 }
265 DlRTree tree(rects, 9);
266 // Tiny rects only intersecting a single source rect
267 for (int r = 0; r < 3; r++) {
268 int y = 15 + 20 * r;
269 for (int c = 0; c < 3; c++) {
270 int x = 15 + 20 * c;
271 auto query = SkRect::MakeLTRB(x - 1, y - 1, x + 1, y + 1);
272 auto list = tree.searchAndConsolidateRects(query);
273 EXPECT_EQ(list.size(), 1u);
274 EXPECT_EQ(list.front(), rects[r * 3 + c]);
275 }
276 }
277 // Wide rects intersecting 3 source rects horizontally
278 for (int r = 0; r < 3; r++) {
279 int c = 1;
280 int y = 15 + 20 * r;
281 int x = 15 + 20 * c;
282 auto query = SkRect::MakeLTRB(x - 6, y - 1, x + 6, y + 1);
283 auto list = tree.searchAndConsolidateRects(query);
284 EXPECT_EQ(list.size(), 1u);
285 EXPECT_EQ(list.front(), SkRect::MakeLTRB(x - 35, y - 15, x + 35, y + 15));
286 }
287 // Tall rects intersecting 3 source rects vertically
288 for (int c = 0; c < 3; c++) {
289 int r = 1;
290 int x = 15 + 20 * c;
291 int y = 15 + 20 * r;
292 auto query = SkRect::MakeLTRB(x - 1, y - 6, x + 1, y + 6);
293 auto list = tree.searchAndConsolidateRects(query);
294 EXPECT_EQ(list.size(), 1u);
295 EXPECT_EQ(list.front(), SkRect::MakeLTRB(x - 15, y - 35, x + 15, y + 35));
296 }
297 // Finally intersecting all 9 rects
298 auto query = SkRect::MakeLTRB(35 - 6, 35 - 6, 35 + 6, 35 + 6);
299 auto list = tree.searchAndConsolidateRects(query);
300 EXPECT_EQ(list.size(), 1u);
301 EXPECT_EQ(list.front(), SkRect::MakeLTRB(0, 0, 70, 70));
302}
void setLTRB(float left, float top, float right, float bottom)
Definition SkRect.h:865

◆ TEST() [282/709]

flutter::testing::TEST ( DisplayListRTree  ,
Region   
)

Definition at line 304 of file dl_rtree_unittests.cc.

304 {
305 SkRect rect[9];
306 for (int i = 0; i < 9; i++) {
307 rect[i] = SkRect::MakeXYWH(i * 10, i * 10, 20, 20);
308 }
309 DlRTree rtree(rect, 9);
310 const auto& region = rtree.region();
311 auto rects = region.getRects(true);
312 std::vector<SkIRect> expected_rects{
313 SkIRect::MakeLTRB(0, 0, 20, 10), SkIRect::MakeLTRB(0, 10, 30, 20),
314 SkIRect::MakeLTRB(10, 20, 40, 30), SkIRect::MakeLTRB(20, 30, 50, 40),
315 SkIRect::MakeLTRB(30, 40, 60, 50), SkIRect::MakeLTRB(40, 50, 70, 60),
316 SkIRect::MakeLTRB(50, 60, 80, 70), SkIRect::MakeLTRB(60, 70, 90, 80),
317 SkIRect::MakeLTRB(70, 80, 100, 90), SkIRect::MakeLTRB(80, 90, 100, 100),
318 };
319 EXPECT_EQ(rects.size(), expected_rects.size());
320}

◆ TEST() [283/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
BlendColorFilterModifiesTransparency   
)

Definition at line 152 of file dl_sk_conversions_unittests.cc.

152 {
153 auto test_mode_color = [](DlBlendMode mode, DlColor color) {
154 std::stringstream desc_str;
155 desc_str << "blend[" << static_cast<int>(mode) << ", " << color.argb()
156 << "]";
157 std::string desc = desc_str.str();
158 DlBlendColorFilter filter(color, mode);
159 auto srgb = SkColorSpace::MakeSRGB();
160 if (filter.modifies_transparent_black()) {
161 auto dl_filter = DlBlendColorFilter::Make(color, mode);
162 auto sk_filter = ToSk(filter);
163 ASSERT_NE(dl_filter, nullptr) << desc;
164 ASSERT_NE(sk_filter, nullptr) << desc;
165 ASSERT_TRUE(sk_filter->filterColor4f(SkColors::kTransparent, srgb.get(),
166 srgb.get()) !=
168 << desc;
169 } else {
170 auto dl_filter = DlBlendColorFilter::Make(color, mode);
171 auto sk_filter = ToSk(filter);
172 EXPECT_EQ(dl_filter == nullptr, sk_filter == nullptr) << desc;
173 ASSERT_TRUE(sk_filter == nullptr ||
174 sk_filter->filterColor4f(SkColors::kTransparent, srgb.get(),
175 srgb.get()) ==
177 << desc;
178 }
179 };
180
181 auto test_mode = [&test_mode_color](DlBlendMode mode) {
182 test_mode_color(mode, DlColor::kTransparent());
183 test_mode_color(mode, DlColor::kWhite());
184 test_mode_color(mode, DlColor::kWhite().modulateOpacity(0.5));
185 test_mode_color(mode, DlColor::kBlack());
186 test_mode_color(mode, DlColor::kBlack().modulateOpacity(0.5));
187 };
188
189#define TEST_MODE(V) test_mode(DlBlendMode::V);
191#undef TEST_MODE
192}
#define FOR_EACH_BLEND_MODE_ENUM(FUNC)
#define TEST_MODE(V)
constexpr SkColor4f kTransparent
Definition SkColor.h:434
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition switches.h:228

◆ TEST() [284/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ConvertWithZeroAndNegativeVerticesAndIndices   
)

Definition at line 196 of file dl_sk_conversions_unittests.cc.

196 {
197 std::shared_ptr<const DlVertices> vertices1 = DlVertices::Make(
198 DlVertexMode::kTriangles, 0, nullptr, nullptr, nullptr, 0, nullptr);
199 EXPECT_NE(vertices1, nullptr);
200 EXPECT_NE(ToSk(vertices1), nullptr);
201
202 std::shared_ptr<const DlVertices> vertices2 = DlVertices::Make(
203 DlVertexMode::kTriangles, -1, nullptr, nullptr, nullptr, -1, nullptr);
204 EXPECT_NE(vertices2, nullptr);
205 EXPECT_NE(ToSk(vertices2), nullptr);
206}

◆ TEST() [285/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
MatrixColorFilterModifiesTransparency   
)

Definition at line 261 of file dl_sk_conversions_unittests.cc.

261 {
262 auto test_matrix = [](int element, SkScalar value) {
263 // clang-format off
264 float matrix[] = {
265 1, 0, 0, 0, 0,
266 0, 1, 0, 0, 0,
267 0, 0, 1, 0, 0,
268 0, 0, 0, 1, 0,
269 };
270 // clang-format on
271 std::string desc =
272 "matrix[" + std::to_string(element) + "] = " + std::to_string(value);
273 matrix[element] = value;
274 DlMatrixColorFilter filter(matrix);
275 auto dl_filter = DlMatrixColorFilter::Make(matrix);
276 auto sk_filter = ToSk(filter);
277 auto srgb = SkColorSpace::MakeSRGB();
278 EXPECT_EQ(dl_filter == nullptr, sk_filter == nullptr);
279 EXPECT_EQ(filter.modifies_transparent_black(),
280 sk_filter && sk_filter->filterColor4f(SkColors::kTransparent,
281 srgb.get(), srgb.get()) !=
283 };
284
285 // Tests identity (matrix[0] already == 1 in an identity filter)
286 test_matrix(0, 1);
287 // test_matrix(19, 1);
288 for (int i = 0; i < 20; i++) {
289 test_matrix(i, -0.25);
290 test_matrix(i, 0);
291 test_matrix(i, 0.25);
292 test_matrix(i, 1);
293 test_matrix(i, 1.25);
297 }
298}
static void test_matrix(skiatest::Reporter *reporter)
#define SK_ScalarInfinity
Definition SkScalar.h:26
uint8_t value

◆ TEST() [286/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkBlendMode   
)

Definition at line 146 of file dl_sk_conversions_unittests.cc.

146 {
147#define CHECK_TO_SKENUM(V) ASSERT_EQ(ToSk(DlBlendMode::V), SkBlendMode::V);
149#undef CHECK_TO_SKENUM
150}
#define CHECK_TO_SKENUM(V)

◆ TEST() [287/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkBlurStyle   
)

Definition at line 52 of file dl_sk_conversions_unittests.cc.

52 {
53 ASSERT_EQ(ToSk(DlBlurStyle::kInner), SkBlurStyle::kInner_SkBlurStyle);
54 ASSERT_EQ(ToSk(DlBlurStyle::kOuter), SkBlurStyle::kOuter_SkBlurStyle);
55 ASSERT_EQ(ToSk(DlBlurStyle::kSolid), SkBlurStyle::kSolid_SkBlurStyle);
56 ASSERT_EQ(ToSk(DlBlurStyle::kNormal), SkBlurStyle::kNormal_SkBlurStyle);
57}
@ kOuter_SkBlurStyle
nothing inside, fuzzy outside
Definition SkBlurTypes.h:14
@ kSolid_SkBlurStyle
solid inside, fuzzy outside
Definition SkBlurTypes.h:13
@ kInner_SkBlurStyle
fuzzy inside, nothing outside
Definition SkBlurTypes.h:15
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition SkBlurTypes.h:12

◆ TEST() [288/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkColor   
)

Definition at line 30 of file dl_sk_conversions_unittests.cc.

30 {
31 // Red
32 ASSERT_EQ(ToSk(DlColor::kRed()), SK_ColorRED);
33
34 // Green
35 ASSERT_EQ(ToSk(DlColor::kGreen()), SK_ColorGREEN);
36
37 // Blue
38 ASSERT_EQ(ToSk(DlColor::kBlue()), SK_ColorBLUE);
39
40 // Half transparent grey
41 auto const grey_hex_half_opaque = 0x7F999999;
42 ASSERT_EQ(ToSk(DlColor(grey_hex_half_opaque)), SkColor(grey_hex_half_opaque));
43}

◆ TEST() [289/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkDitheringEnabledForGradients   
)

Definition at line 300 of file dl_sk_conversions_unittests.cc.

300 {
301 // Test that when using the utility method "ToSk", the resulting SkPaint
302 // has "isDither" set to true, if the paint is a gradient, because it's
303 // a supported feature in the Impeller backend.
304
305 DlPaint dl_paint;
306
307 // Set the paint to be a gradient.
308 dl_paint.setColorSource(DlColorSource::MakeLinear(SkPoint::Make(0, 0),
309 SkPoint::Make(100, 100), 0,
310 0, 0, DlTileMode::kClamp));
311
312 {
313 SkPaint sk_paint = ToSk(dl_paint);
314 EXPECT_TRUE(sk_paint.isDither());
315 }
316
317 {
318 SkPaint sk_paint = ToStrokedSk(dl_paint);
319 EXPECT_TRUE(sk_paint.isDither());
320 }
321
322 {
323 SkPaint sk_paint = ToNonShaderSk(dl_paint);
324 EXPECT_FALSE(sk_paint.isDither());
325 }
326}
bool isDither() const
Definition SkPaint.h:175
SkPaint ToStrokedSk(const DlPaint &paint)

◆ TEST() [290/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkDrawStyle   
)

Definition at line 59 of file dl_sk_conversions_unittests.cc.

59 {
60 ASSERT_EQ(ToSk(DlDrawStyle::kFill), SkPaint::Style::kFill_Style);
61 ASSERT_EQ(ToSk(DlDrawStyle::kStroke), SkPaint::Style::kStroke_Style);
62 ASSERT_EQ(ToSk(DlDrawStyle::kStrokeAndFill),
64}
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition SkPaint.h:195

◆ TEST() [291/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkFilterMode   
)

Definition at line 87 of file dl_sk_conversions_unittests.cc.

87 {
88 ASSERT_EQ(ToSk(DlFilterMode::kLinear), SkFilterMode::kLinear);
89 ASSERT_EQ(ToSk(DlFilterMode::kNearest), SkFilterMode::kNearest);
90 ASSERT_EQ(ToSk(DlFilterMode::kLast), SkFilterMode::kLast);
91}

◆ TEST() [292/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkSamplingOptions   
)

Definition at line 100 of file dl_sk_conversions_unittests.cc.

100 {
101 ASSERT_EQ(ToSk(DlImageSampling::kLinear),
103 ASSERT_EQ(ToSk(DlImageSampling::kMipmapLinear),
105 ASSERT_EQ(ToSk(DlImageSampling::kNearestNeighbor),
107 ASSERT_EQ(ToSk(DlImageSampling::kCubic),
108 SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f}));
109}

◆ TEST() [293/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkSrcRectConstraint   
)

Definition at line 93 of file dl_sk_conversions_unittests.cc.

93 {
94 ASSERT_EQ(ToSk(DlCanvas::SrcRectConstraint::kFast),
96 ASSERT_EQ(ToSk(DlCanvas::SrcRectConstraint::kStrict),
98}
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition SkCanvas.h:1542
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition SkCanvas.h:1543

◆ TEST() [294/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkStrokeCap   
)

Definition at line 66 of file dl_sk_conversions_unittests.cc.

66 {
67 ASSERT_EQ(ToSk(DlStrokeCap::kButt), SkPaint::Cap::kButt_Cap);
68 ASSERT_EQ(ToSk(DlStrokeCap::kRound), SkPaint::Cap::kRound_Cap);
69 ASSERT_EQ(ToSk(DlStrokeCap::kSquare), SkPaint::Cap::kSquare_Cap);
70}
@ kRound_Cap
adds circle
Definition SkPaint.h:335
@ kButt_Cap
no stroke extension
Definition SkPaint.h:334
@ kSquare_Cap
adds square
Definition SkPaint.h:336

◆ TEST() [295/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkStrokeJoin   
)

Definition at line 72 of file dl_sk_conversions_unittests.cc.

72 {
73 ASSERT_EQ(ToSk(DlStrokeJoin::kMiter), SkPaint::Join::kMiter_Join);
74 ASSERT_EQ(ToSk(DlStrokeJoin::kRound), SkPaint::Join::kRound_Join);
75 ASSERT_EQ(ToSk(DlStrokeJoin::kBevel), SkPaint::Join::kBevel_Join);
76}
@ kRound_Join
adds circle
Definition SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition SkPaint.h:361

◆ TEST() [296/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkTileMode   
)

Definition at line 45 of file dl_sk_conversions_unittests.cc.

45 {
46 ASSERT_EQ(ToSk(DlTileMode::kClamp), SkTileMode::kClamp);
47 ASSERT_EQ(ToSk(DlTileMode::kRepeat), SkTileMode::kRepeat);
48 ASSERT_EQ(ToSk(DlTileMode::kMirror), SkTileMode::kMirror);
49 ASSERT_EQ(ToSk(DlTileMode::kDecal), SkTileMode::kDecal);
50}

◆ TEST() [297/709]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkVertexMode   
)

Definition at line 78 of file dl_sk_conversions_unittests.cc.

78 {
79 ASSERT_EQ(ToSk(DlVertexMode::kTriangles),
81 ASSERT_EQ(ToSk(DlVertexMode::kTriangleStrip),
83 ASSERT_EQ(ToSk(DlVertexMode::kTriangleFan),
85}
@ kTriangleStrip_VertexMode
Definition SkVertices.h:32
@ kTriangleFan_VertexMode
Definition SkVertices.h:33
@ kTriangles_VertexMode
Definition SkVertices.h:31

◆ TEST() [298/709]

flutter::testing::TEST ( DisplayListUtils  ,
OverRestore   
)

Definition at line 40 of file dl_sk_paint_dispatcher_unittests.cc.

40 {
41 MockDispatchHelper helper;
42 helper.save();
43 helper.restore();
44 // There should be a protection here for over-restore to keep the program from
45 // crashing.
46 helper.restore();
47}

◆ TEST() [299/709]

flutter::testing::TEST ( DisplayListUtils  ,
SetColorSourceDithersIfGradient   
)

Definition at line 50 of file dl_sk_paint_dispatcher_unittests.cc.

50 {
51 MockDispatchHelper helper;
52
54 EXPECT_TRUE(helper.paint(true).isDither());
55 EXPECT_FALSE(helper.paint(false).isDither());
56}
virtual void setColorSource(const DlColorSource *source)=0
const SkPaint & paint(bool uses_shader=true)

◆ TEST() [300/709]

flutter::testing::TEST ( DisplayListUtils  ,
SetColorSourceDoesNotDitherIfNotGradient   
)

Definition at line 59 of file dl_sk_paint_dispatcher_unittests.cc.

59 {
60 MockDispatchHelper helper;
61
63 helper.setColorSource(nullptr);
64 EXPECT_FALSE(helper.paint(true).isDither());
65 EXPECT_FALSE(helper.paint(false).isDither());
66
67 DlColorColorSource color_color_source(DlColor::kBlue());
68 helper.setColorSource(&color_color_source);
69 EXPECT_FALSE(helper.paint(true).isDither());
70 EXPECT_FALSE(helper.paint(false).isDither());
71
72 helper.setColorSource(&kTestSource1);
73 EXPECT_FALSE(helper.paint(true).isDither());
74 EXPECT_FALSE(helper.paint(false).isDither());
75}

◆ TEST() [301/709]

flutter::testing::TEST ( DisplayListUtils  ,
SkDispatcherSetColorSourceDithersIfGradient   
)

Definition at line 78 of file dl_sk_paint_dispatcher_unittests.cc.

78 {
79 SkCanvas canvas;
80 DlSkCanvasDispatcher dispatcher(&canvas);
81
82 dispatcher.setColorSource(kTestLinearGradient.get());
83 EXPECT_TRUE(dispatcher.paint(true).isDither());
84 EXPECT_FALSE(dispatcher.paint(false).isDither());
85 EXPECT_FALSE(dispatcher.safe_paint(true)->isDither());
86 // Calling safe_paint(false) returns a nullptr
87}
Backend implementation of |DlOpReceiver| for |SkCanvas|.

◆ TEST() [302/709]

flutter::testing::TEST ( DisplayListUtils  ,
SkDispatcherSetColorSourceDoesNotDitherIfNotGradient   
)

Definition at line 90 of file dl_sk_paint_dispatcher_unittests.cc.

90 {
91 SkCanvas canvas;
92 DlSkCanvasDispatcher dispatcher(&canvas);
93
94 dispatcher.setColorSource(kTestLinearGradient.get());
95 dispatcher.setColorSource(nullptr);
96 EXPECT_FALSE(dispatcher.paint(true).isDither());
97 EXPECT_FALSE(dispatcher.paint(false).isDither());
98 EXPECT_FALSE(dispatcher.safe_paint(true)->isDither());
99 // Calling safe_paint(false) returns a nullptr
100
101 DlColorColorSource color_color_source(DlColor::kBlue());
102 dispatcher.setColorSource(&color_color_source);
103 EXPECT_FALSE(dispatcher.paint(true).isDither());
104 EXPECT_FALSE(dispatcher.paint(false).isDither());
105 EXPECT_FALSE(dispatcher.safe_paint(true)->isDither());
106 // Calling safe_paint(false) returns a nullptr
107
108 dispatcher.setColorSource(&kTestSource1);
109 EXPECT_FALSE(dispatcher.paint(true).isDither());
110 EXPECT_FALSE(dispatcher.paint(false).isDither());
111 EXPECT_FALSE(dispatcher.safe_paint(true)->isDither());
112 // Calling safe_paint(false) returns a nullptr
113}

◆ TEST() [303/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuilderFlags   
)

Definition at line 374 of file dl_vertices_unittests.cc.

374 {
376 EXPECT_FALSE(flags.has_texture_coordinates);
377 EXPECT_FALSE(flags.has_colors);
378
379 flags |= Builder::kHasTextureCoordinates;
380 EXPECT_TRUE(flags.has_texture_coordinates);
381 EXPECT_FALSE(flags.has_colors);
382
383 flags |= Builder::kHasColors;
384 EXPECT_TRUE(flags.has_texture_coordinates);
385 EXPECT_TRUE(flags.has_colors);
386
388 EXPECT_FALSE(flags.has_texture_coordinates);
389 EXPECT_FALSE(flags.has_colors);
390
391 flags |= Builder::kHasColors;
392 EXPECT_FALSE(flags.has_texture_coordinates);
393 EXPECT_TRUE(flags.has_colors);
394
395 flags |= Builder::kHasTextureCoordinates;
396 EXPECT_TRUE(flags.has_texture_coordinates);
397 EXPECT_TRUE(flags.has_colors);
398
399 EXPECT_FALSE(Builder::kNone.has_texture_coordinates);
400 EXPECT_FALSE(Builder::kNone.has_colors);
401
402 EXPECT_TRUE(Builder::kHasTextureCoordinates.has_texture_coordinates);
403 EXPECT_FALSE(Builder::kHasTextureCoordinates.has_colors);
404
405 EXPECT_FALSE(Builder::kHasColors.has_texture_coordinates);
406 EXPECT_TRUE(Builder::kHasColors.has_colors);
407
408 EXPECT_TRUE((Builder::kHasTextureCoordinates | Builder::kHasColors) //
409 .has_texture_coordinates);
410 EXPECT_TRUE((Builder::kHasTextureCoordinates | Builder::kHasColors) //
411 .has_colors);
412}
flags to indicate/promise which of the optional texture coordinates or colors will be supplied during...
Definition dl_vertices.h:80

◆ TEST() [304/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildUsingFloatsSameAsPoints   
)

Definition at line 699 of file dl_vertices_unittests.cc.

699 {
700 SkPoint coord_points[3] = {
701 SkPoint::Make(2, 3),
702 SkPoint::Make(5, 6),
703 SkPoint::Make(15, 20),
704 };
705 SkPoint texture_coord_points[3] = {
706 SkPoint::Make(102, 103),
707 SkPoint::Make(105, 106),
708 SkPoint::Make(115, 120),
709 };
710
711 float coord_floats[6] = {
712 2, 3, //
713 5, 6, //
714 15, 20,
715 };
716 float texture_coord_floats[6] = {
717 102, 103, //
718 105, 106, //
719 115, 120,
720 };
721
722 Builder builder_points(DlVertexMode::kTriangles, 3, //
723 Builder::kHasTextureCoordinates, 0);
724 builder_points.store_vertices(coord_points);
725 builder_points.store_texture_coordinates(texture_coord_points);
726 std::shared_ptr<const DlVertices> vertices_points = builder_points.build();
727
728 Builder builder_floats(DlVertexMode::kTriangles, 3, //
729 Builder::kHasTextureCoordinates, 0);
730 builder_floats.store_vertices(coord_floats);
731 builder_floats.store_texture_coordinates(texture_coord_floats);
732 std::shared_ptr<const DlVertices> vertices_floats = builder_floats.build();
733
734 TestEquals(*vertices_points, *vertices_floats);
735}
DlVertices::Builder Builder

◆ TEST() [305/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithColor   
)

Definition at line 737 of file dl_vertices_unittests.cc.

737 {
738 SkPoint coords[3] = {
739 SkPoint::Make(2, 3),
740 SkPoint::Make(5, 6),
741 SkPoint::Make(15, 20),
742 };
743 SkColor colors[3] = {
747 };
748
749 Builder builder(DlVertexMode::kTriangles, 3, //
750 Builder::kHasColors, 0);
751 builder.store_vertices(coords);
752 builder.store_colors(colors);
753 std::shared_ptr<const DlVertices> vertices = builder.build();
754
755 ASSERT_NE(vertices, nullptr);
756 ASSERT_NE(vertices->vertices(), nullptr);
757 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
758 ASSERT_NE(vertices->colors(), nullptr);
759 ASSERT_EQ(vertices->indices(), nullptr);
760
761 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
762 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
763 ASSERT_EQ(vertices->vertex_count(), 3);
764 for (int i = 0; i < 3; i++) {
765 ASSERT_EQ(vertices->vertices()[i], coords[i]);
766 ASSERT_EQ(vertices->colors()[i], colors[i]);
767 }
768 ASSERT_EQ(vertices->index_count(), 0);
769}

◆ TEST() [306/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithColorAndIndices   
)

Definition at line 587 of file dl_vertices_unittests.cc.

587 {
588 SkPoint coords[3] = {
589 SkPoint::Make(2, 3),
590 SkPoint::Make(5, 6),
591 SkPoint::Make(15, 20),
592 };
593 SkColor colors[3] = {
597 };
598 uint16_t indices[6] = {
599 2, 1, 0, //
600 1, 2, 0,
601 };
602
603 Builder builder(DlVertexMode::kTriangles, 3, //
604 Builder::kHasColors, 6);
605 builder.store_vertices(coords);
606 builder.store_colors(colors);
607 builder.store_indices(indices);
608 std::shared_ptr<const DlVertices> vertices = builder.build();
609
610 ASSERT_NE(vertices, nullptr);
611 ASSERT_NE(vertices->vertices(), nullptr);
612 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
613 ASSERT_NE(vertices->colors(), nullptr);
614 ASSERT_NE(vertices->indices(), nullptr);
615
616 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
617 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
618 ASSERT_EQ(vertices->vertex_count(), 3);
619 for (int i = 0; i < 3; i++) {
620 ASSERT_EQ(vertices->vertices()[i], coords[i]);
621 ASSERT_EQ(vertices->colors()[i], colors[i]);
622 }
623 ASSERT_EQ(vertices->index_count(), 6);
624 for (int i = 0; i < 6; i++) {
625 ASSERT_EQ(vertices->indices()[i], indices[i]);
626 }
627}

◆ TEST() [307/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithIndices   
)

Definition at line 771 of file dl_vertices_unittests.cc.

771 {
772 SkPoint coords[3] = {
773 SkPoint::Make(2, 3),
774 SkPoint::Make(5, 6),
775 SkPoint::Make(15, 20),
776 };
777 uint16_t indices[6] = {
778 2, 1, 0, //
779 1, 2, 0,
780 };
781
782 Builder builder(DlVertexMode::kTriangles, 3, Builder::kNone, 6);
783 builder.store_vertices(coords);
784 builder.store_indices(indices);
785 std::shared_ptr<const DlVertices> vertices = builder.build();
786
787 ASSERT_NE(vertices, nullptr);
788 ASSERT_NE(vertices->vertices(), nullptr);
789 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
790 ASSERT_EQ(vertices->colors(), nullptr);
791 ASSERT_NE(vertices->indices(), nullptr);
792
793 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
794 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
795 ASSERT_EQ(vertices->vertex_count(), 3);
796 for (int i = 0; i < 3; i++) {
797 ASSERT_EQ(vertices->vertices()[i], coords[i]);
798 }
799 ASSERT_EQ(vertices->index_count(), 6);
800 for (int i = 0; i < 6; i++) {
801 ASSERT_EQ(vertices->indices()[i], indices[i]);
802 }
803}

◆ TEST() [308/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithNegativeIndexCount   
)

Definition at line 831 of file dl_vertices_unittests.cc.

831 {
832 SkPoint coords[3] = {
833 SkPoint::Make(2, 3),
834 SkPoint::Make(5, 6),
835 SkPoint::Make(15, 20),
836 };
837
838 Builder builder(DlVertexMode::kTriangles, 3, Builder::kNone, -5);
839 builder.store_vertices(coords);
840 std::shared_ptr<const DlVertices> vertices = builder.build();
841
842 ASSERT_NE(vertices, nullptr);
843 ASSERT_NE(vertices->vertices(), nullptr);
844 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
845 ASSERT_EQ(vertices->colors(), nullptr);
846 ASSERT_EQ(vertices->indices(), nullptr);
847
848 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
849 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
850 ASSERT_EQ(vertices->vertex_count(), 3);
851 for (int i = 0; i < 3; i++) {
852 ASSERT_EQ(vertices->vertices()[i], coords[i]);
853 }
854 ASSERT_EQ(vertices->index_count(), 0);
855}

◆ TEST() [309/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithNoOptionalData   
)

Definition at line 805 of file dl_vertices_unittests.cc.

805 {
806 SkPoint coords[3] = {
807 SkPoint::Make(2, 3),
808 SkPoint::Make(5, 6),
809 SkPoint::Make(15, 20),
810 };
811
812 Builder builder(DlVertexMode::kTriangles, 3, Builder::kNone, 0);
813 builder.store_vertices(coords);
814 std::shared_ptr<const DlVertices> vertices = builder.build();
815
816 ASSERT_NE(vertices, nullptr);
817 ASSERT_NE(vertices->vertices(), nullptr);
818 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
819 ASSERT_EQ(vertices->colors(), nullptr);
820 ASSERT_EQ(vertices->indices(), nullptr);
821
822 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
823 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
824 ASSERT_EQ(vertices->vertex_count(), 3);
825 for (int i = 0; i < 3; i++) {
826 ASSERT_EQ(vertices->vertices()[i], coords[i]);
827 }
828 ASSERT_EQ(vertices->index_count(), 0);
829}

◆ TEST() [310/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithTexAndColor   
)

Definition at line 504 of file dl_vertices_unittests.cc.

504 {
505 SkPoint coords[3] = {
506 SkPoint::Make(2, 3),
507 SkPoint::Make(5, 6),
508 SkPoint::Make(15, 20),
509 };
510 SkPoint texture_coords[3] = {
511 SkPoint::Make(102, 103),
512 SkPoint::Make(105, 106),
513 SkPoint::Make(115, 120),
514 };
515 DlColor colors[3] = {
516 DlColor::kRed(),
517 DlColor::kCyan(),
518 DlColor::kGreen(),
519 };
520
521 Builder builder(DlVertexMode::kTriangles, 3, //
522 Builder::kHasTextureCoordinates | Builder::kHasColors, 0);
523 builder.store_vertices(coords);
524 builder.store_texture_coordinates(texture_coords);
525 builder.store_colors(colors);
526 std::shared_ptr<const DlVertices> vertices = builder.build();
527
528 ASSERT_NE(vertices, nullptr);
529 ASSERT_NE(vertices->vertices(), nullptr);
530 ASSERT_NE(vertices->texture_coordinates(), nullptr);
531 ASSERT_NE(vertices->colors(), nullptr);
532 ASSERT_EQ(vertices->indices(), nullptr);
533
534 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
535 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
536 ASSERT_EQ(vertices->vertex_count(), 3);
537 for (int i = 0; i < 3; i++) {
538 ASSERT_EQ(vertices->vertices()[i], coords[i]);
539 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
540 ASSERT_EQ(vertices->colors()[i], colors[i]);
541 }
542 ASSERT_EQ(vertices->index_count(), 0);
543}

◆ TEST() [311/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithTexAndColorAndIndices   
)

Definition at line 440 of file dl_vertices_unittests.cc.

440 {
441 SkPoint coords[3] = {
442 SkPoint::Make(2, 3),
443 SkPoint::Make(5, 6),
444 SkPoint::Make(15, 20),
445 };
446 SkPoint texture_coords[3] = {
447 SkPoint::Make(102, 103),
448 SkPoint::Make(105, 106),
449 SkPoint::Make(115, 120),
450 };
451 DlColor colors[3] = {
452 DlColor::kRed(),
453 DlColor::kCyan(),
454 DlColor::kGreen(),
455 };
456 uint16_t indices[6] = {
457 2, 1, 0, //
458 1, 2, 0,
459 };
460
461 Builder builder(DlVertexMode::kTriangles, 3, //
462 Builder::kHasTextureCoordinates | Builder::kHasColors, 6);
463 builder.store_vertices(coords);
464 builder.store_texture_coordinates(texture_coords);
465 builder.store_colors(colors);
466 builder.store_indices(indices);
467 std::shared_ptr<const DlVertices> vertices = builder.build();
468
469 ASSERT_NE(vertices, nullptr);
470 ASSERT_NE(vertices->vertices(), nullptr);
471 ASSERT_NE(vertices->texture_coordinates(), nullptr);
472 ASSERT_NE(vertices->colors(), nullptr);
473 ASSERT_NE(vertices->indices(), nullptr);
474
475 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
476 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
477 ASSERT_EQ(vertices->vertex_count(), 3);
478 for (int i = 0; i < 3; i++) {
479 ASSERT_EQ(vertices->vertices()[i], coords[i]);
480 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
481 ASSERT_EQ(vertices->colors()[i], colors[i]);
482 }
483 ASSERT_EQ(vertices->index_count(), 6);
484 for (int i = 0; i < 6; i++) {
485 ASSERT_EQ(vertices->indices()[i], indices[i]);
486 }
487
488 Builder builder2(DlVertexMode::kTriangles, 3, //
489 Builder::kHasTextureCoordinates | Builder::kHasColors, 6);
490 builder2.store_vertices(coords);
491 builder2.store_texture_coordinates(texture_coords);
492 builder2.store_colors(colors);
493 builder2.store_indices(indices);
494 std::shared_ptr<const DlVertices> vertices2 = builder2.build();
495
496 TestEquals(*vertices, *vertices2);
497
498 std::shared_ptr<const DlVertices> vertices3 = DlVertices::Make(
499 DlVertexMode::kTriangles, 3, coords, texture_coords, colors, 6, indices);
500
501 TestEquals(*vertices, *vertices3);
502}

◆ TEST() [312/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithTexAndIndices   
)

Definition at line 545 of file dl_vertices_unittests.cc.

545 {
546 SkPoint coords[3] = {
547 SkPoint::Make(2, 3),
548 SkPoint::Make(5, 6),
549 SkPoint::Make(15, 20),
550 };
551 SkPoint texture_coords[3] = {
552 SkPoint::Make(102, 103),
553 SkPoint::Make(105, 106),
554 SkPoint::Make(115, 120),
555 };
556 uint16_t indices[6] = {
557 2, 1, 0, //
558 1, 2, 0,
559 };
560
561 Builder builder(DlVertexMode::kTriangles, 3, //
562 Builder::kHasTextureCoordinates, 6);
563 builder.store_vertices(coords);
564 builder.store_texture_coordinates(texture_coords);
565 builder.store_indices(indices);
566 std::shared_ptr<const DlVertices> vertices = builder.build();
567
568 ASSERT_NE(vertices, nullptr);
569 ASSERT_NE(vertices->vertices(), nullptr);
570 ASSERT_NE(vertices->texture_coordinates(), nullptr);
571 ASSERT_EQ(vertices->colors(), nullptr);
572 ASSERT_NE(vertices->indices(), nullptr);
573
574 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
575 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
576 ASSERT_EQ(vertices->vertex_count(), 3);
577 for (int i = 0; i < 3; i++) {
578 ASSERT_EQ(vertices->vertices()[i], coords[i]);
579 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
580 }
581 ASSERT_EQ(vertices->index_count(), 6);
582 for (int i = 0; i < 6; i++) {
583 ASSERT_EQ(vertices->indices()[i], indices[i]);
584 }
585}

◆ TEST() [313/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithTexUsingFloats   
)

Definition at line 663 of file dl_vertices_unittests.cc.

663 {
664 float coords[6] = {
665 2, 3, //
666 5, 6, //
667 15, 20,
668 };
669 float texture_coords[6] = {
670 102, 103, //
671 105, 106, //
672 115, 120,
673 };
674
675 Builder builder(DlVertexMode::kTriangles, 3, //
676 Builder::kHasTextureCoordinates, 0);
677 builder.store_vertices(coords);
678 builder.store_texture_coordinates(texture_coords);
679 std::shared_ptr<const DlVertices> vertices = builder.build();
680
681 ASSERT_NE(vertices, nullptr);
682 ASSERT_NE(vertices->vertices(), nullptr);
683 ASSERT_NE(vertices->texture_coordinates(), nullptr);
684 ASSERT_EQ(vertices->colors(), nullptr);
685 ASSERT_EQ(vertices->indices(), nullptr);
686
687 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
688 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
689 ASSERT_EQ(vertices->vertex_count(), 3);
690 for (int i = 0; i < 3; i++) {
691 ASSERT_EQ(vertices->vertices()[i].fX, coords[i * 2 + 0]);
692 ASSERT_EQ(vertices->vertices()[i].fY, coords[i * 2 + 1]);
693 ASSERT_EQ(vertices->texture_coordinates()[i].fX, texture_coords[i * 2 + 0]);
694 ASSERT_EQ(vertices->texture_coordinates()[i].fY, texture_coords[i * 2 + 1]);
695 }
696 ASSERT_EQ(vertices->index_count(), 0);
697}

◆ TEST() [314/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithTexUsingPoints   
)

Definition at line 629 of file dl_vertices_unittests.cc.

629 {
630 SkPoint coords[3] = {
631 SkPoint::Make(2, 3),
632 SkPoint::Make(5, 6),
633 SkPoint::Make(15, 20),
634 };
635 SkPoint texture_coords[3] = {
636 SkPoint::Make(102, 103),
637 SkPoint::Make(105, 106),
638 SkPoint::Make(115, 120),
639 };
640
641 Builder builder(DlVertexMode::kTriangles, 3, //
642 Builder::kHasTextureCoordinates, 0);
643 builder.store_vertices(coords);
644 builder.store_texture_coordinates(texture_coords);
645 std::shared_ptr<const DlVertices> vertices = builder.build();
646
647 ASSERT_NE(vertices, nullptr);
648 ASSERT_NE(vertices->vertices(), nullptr);
649 ASSERT_NE(vertices->texture_coordinates(), nullptr);
650 ASSERT_EQ(vertices->colors(), nullptr);
651 ASSERT_EQ(vertices->indices(), nullptr);
652
653 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
654 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
655 ASSERT_EQ(vertices->vertex_count(), 3);
656 for (int i = 0; i < 3; i++) {
657 ASSERT_EQ(vertices->vertices()[i], coords[i]);
658 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
659 }
660 ASSERT_EQ(vertices->index_count(), 0);
661}

◆ TEST() [315/709]

flutter::testing::TEST ( DisplayListVertices  ,
BuildWithZeroAndNegativeVerticesAndIndices   
)

Definition at line 414 of file dl_vertices_unittests.cc.

414 {
415 Builder builder1(DlVertexMode::kTriangles, 0, Builder::kNone, 0);
416 EXPECT_TRUE(builder1.is_valid());
417 std::shared_ptr<DlVertices> vertices1 = builder1.build();
418 EXPECT_NE(vertices1, nullptr);
419 EXPECT_EQ(vertices1->vertex_count(), 0);
420 EXPECT_EQ(vertices1->vertices(), nullptr);
421 EXPECT_EQ(vertices1->texture_coordinates(), nullptr);
422 EXPECT_EQ(vertices1->colors(), nullptr);
423 EXPECT_EQ(vertices1->index_count(), 0);
424 EXPECT_EQ(vertices1->indices(), nullptr);
425
426 Builder builder2(DlVertexMode::kTriangles, -1, Builder::kNone, -1);
427 EXPECT_TRUE(builder2.is_valid());
428 std::shared_ptr<DlVertices> vertices2 = builder2.build();
429 EXPECT_NE(vertices2, nullptr);
430 EXPECT_EQ(vertices2->vertex_count(), 0);
431 EXPECT_EQ(vertices2->vertices(), nullptr);
432 EXPECT_EQ(vertices2->texture_coordinates(), nullptr);
433 EXPECT_EQ(vertices2->colors(), nullptr);
434 EXPECT_EQ(vertices2->index_count(), 0);
435 EXPECT_EQ(vertices2->indices(), nullptr);
436
437 TestEquals(*vertices1, *vertices2);
438}
A utility class to build up a |DlVertices| object one set of data at a time.
Definition dl_vertices.h:75

◆ TEST() [316/709]

flutter::testing::TEST ( DisplayListVertices  ,
ConvertWithZeroAndNegativeVerticesAndIndices   
)

Definition at line 208 of file dl_sk_conversions_unittests.cc.

208 {
209 DlVertices::Builder builder1(DlVertexMode::kTriangles, 0,
210 DlVertices::Builder::kNone, 0);
211 EXPECT_TRUE(builder1.is_valid());
212 std::shared_ptr<DlVertices> vertices1 = builder1.build();
213 EXPECT_NE(vertices1, nullptr);
214 EXPECT_NE(ToSk(vertices1), nullptr);
215
216 DlVertices::Builder builder2(DlVertexMode::kTriangles, -1,
217 DlVertices::Builder::kNone, -1);
218 EXPECT_TRUE(builder2.is_valid());
219 std::shared_ptr<DlVertices> vertices2 = builder2.build();
220 EXPECT_NE(vertices2, nullptr);
221 EXPECT_NE(ToSk(vertices2), nullptr);
222}

◆ TEST() [317/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithColor   
)

Definition at line 226 of file dl_vertices_unittests.cc.

226 {
227 SkPoint coords[3] = {
228 SkPoint::Make(2, 3),
229 SkPoint::Make(5, 6),
230 SkPoint::Make(15, 20),
231 };
232 DlColor colors[3] = {
233 DlColor::kRed(),
234 DlColor::kCyan(),
235 DlColor::kGreen(),
236 };
237
238 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
239 DlVertexMode::kTriangles, 3, coords, nullptr, colors, 6, nullptr);
240
241 ASSERT_NE(vertices, nullptr);
242 ASSERT_NE(vertices->vertices(), nullptr);
243 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
244 ASSERT_NE(vertices->colors(), nullptr);
245 ASSERT_EQ(vertices->indices(), nullptr);
246
247 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
248 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
249 ASSERT_EQ(vertices->vertex_count(), 3);
250 for (int i = 0; i < 3; i++) {
251 ASSERT_EQ(vertices->vertices()[i], coords[i]);
252 ASSERT_EQ(vertices->colors()[i], colors[i]);
253 }
254 ASSERT_EQ(vertices->index_count(), 0);
255}

◆ TEST() [318/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithColorAndIndices   
)

Definition at line 157 of file dl_vertices_unittests.cc.

157 {
158 SkPoint coords[3] = {
159 SkPoint::Make(2, 3),
160 SkPoint::Make(5, 6),
161 SkPoint::Make(15, 20),
162 };
163 DlColor colors[3] = {
164 DlColor::kRed(),
165 DlColor::kCyan(),
166 DlColor::kGreen(),
167 };
168 uint16_t indices[6] = {
169 2, 1, 0, //
170 1, 2, 0,
171 };
172
173 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
174 DlVertexMode::kTriangles, 3, coords, nullptr, colors, 6, indices);
175
176 ASSERT_NE(vertices, nullptr);
177 ASSERT_NE(vertices->vertices(), nullptr);
178 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
179 ASSERT_NE(vertices->colors(), nullptr);
180 ASSERT_NE(vertices->indices(), nullptr);
181
182 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
183 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
184 ASSERT_EQ(vertices->vertex_count(), 3);
185 for (int i = 0; i < 3; i++) {
186 ASSERT_EQ(vertices->vertices()[i], coords[i]);
187 ASSERT_EQ(vertices->colors()[i], colors[i]);
188 }
189 ASSERT_EQ(vertices->index_count(), 6);
190 for (int i = 0; i < 6; i++) {
191 ASSERT_EQ(vertices->indices()[i], indices[i]);
192 }
193}

◆ TEST() [319/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithIndices   
)

Definition at line 257 of file dl_vertices_unittests.cc.

257 {
258 SkPoint coords[3] = {
259 SkPoint::Make(2, 3),
260 SkPoint::Make(5, 6),
261 SkPoint::Make(15, 20),
262 };
263 uint16_t indices[6] = {
264 2, 1, 0, //
265 1, 2, 0,
266 };
267
268 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
269 DlVertexMode::kTriangles, 3, coords, nullptr, nullptr, 6, indices);
270
271 ASSERT_NE(vertices, nullptr);
272 ASSERT_NE(vertices->vertices(), nullptr);
273 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
274 ASSERT_EQ(vertices->colors(), nullptr);
275 ASSERT_NE(vertices->indices(), nullptr);
276
277 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
278 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
279 ASSERT_EQ(vertices->vertex_count(), 3);
280 for (int i = 0; i < 3; i++) {
281 ASSERT_EQ(vertices->vertices()[i], coords[i]);
282 }
283 ASSERT_EQ(vertices->index_count(), 6);
284 for (int i = 0; i < 6; i++) {
285 ASSERT_EQ(vertices->indices()[i], indices[i]);
286 }
287}

◆ TEST() [320/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithIndicesButNegativeIndexCount   
)

Definition at line 343 of file dl_vertices_unittests.cc.

343 {
344 SkPoint coords[3] = {
345 SkPoint::Make(2, 3),
346 SkPoint::Make(5, 6),
347 SkPoint::Make(15, 20),
348 };
349 uint16_t indices[6] = {
350 2, 1, 0, //
351 1, 2, 0,
352 };
353
354 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
355 DlVertexMode::kTriangles, 3, coords, nullptr, nullptr, -5, indices);
356
357 ASSERT_NE(vertices, nullptr);
358 ASSERT_NE(vertices->vertices(), nullptr);
359 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
360 ASSERT_EQ(vertices->colors(), nullptr);
361 ASSERT_EQ(vertices->indices(), nullptr);
362
363 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
364 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
365 ASSERT_EQ(vertices->vertex_count(), 3);
366 for (int i = 0; i < 3; i++) {
367 ASSERT_EQ(vertices->vertices()[i], coords[i]);
368 }
369 ASSERT_EQ(vertices->index_count(), 0);
370}

◆ TEST() [321/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithIndicesButZeroIndexCount   
)

Definition at line 314 of file dl_vertices_unittests.cc.

314 {
315 SkPoint coords[3] = {
316 SkPoint::Make(2, 3),
317 SkPoint::Make(5, 6),
318 SkPoint::Make(15, 20),
319 };
320 uint16_t indices[6] = {
321 2, 1, 0, //
322 1, 2, 0,
323 };
324
325 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
326 DlVertexMode::kTriangles, 3, coords, nullptr, nullptr, 0, indices);
327
328 ASSERT_NE(vertices, nullptr);
329 ASSERT_NE(vertices->vertices(), nullptr);
330 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
331 ASSERT_EQ(vertices->colors(), nullptr);
332 ASSERT_EQ(vertices->indices(), nullptr);
333
334 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
335 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
336 ASSERT_EQ(vertices->vertex_count(), 3);
337 for (int i = 0; i < 3; i++) {
338 ASSERT_EQ(vertices->vertices()[i], coords[i]);
339 }
340 ASSERT_EQ(vertices->index_count(), 0);
341}

◆ TEST() [322/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithNoOptionalData   
)

Definition at line 289 of file dl_vertices_unittests.cc.

289 {
290 SkPoint coords[3] = {
291 SkPoint::Make(2, 3),
292 SkPoint::Make(5, 6),
293 SkPoint::Make(15, 20),
294 };
295
296 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
297 DlVertexMode::kTriangles, 3, coords, nullptr, nullptr, 6, nullptr);
298
299 ASSERT_NE(vertices, nullptr);
300 ASSERT_NE(vertices->vertices(), nullptr);
301 ASSERT_EQ(vertices->texture_coordinates(), nullptr);
302 ASSERT_EQ(vertices->colors(), nullptr);
303 ASSERT_EQ(vertices->indices(), nullptr);
304
305 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
306 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
307 ASSERT_EQ(vertices->vertex_count(), 3);
308 for (int i = 0; i < 3; i++) {
309 ASSERT_EQ(vertices->vertices()[i], coords[i]);
310 }
311 ASSERT_EQ(vertices->index_count(), 0);
312}

◆ TEST() [323/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithTex   
)

Definition at line 195 of file dl_vertices_unittests.cc.

195 {
196 SkPoint coords[3] = {
197 SkPoint::Make(2, 3),
198 SkPoint::Make(5, 6),
199 SkPoint::Make(15, 20),
200 };
201 SkPoint texture_coords[3] = {
202 SkPoint::Make(102, 103),
203 SkPoint::Make(105, 106),
204 SkPoint::Make(115, 120),
205 };
206
207 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
208 DlVertexMode::kTriangles, 3, coords, texture_coords, nullptr, 6, nullptr);
209
210 ASSERT_NE(vertices, nullptr);
211 ASSERT_NE(vertices->vertices(), nullptr);
212 ASSERT_NE(vertices->texture_coordinates(), nullptr);
213 ASSERT_EQ(vertices->colors(), nullptr);
214 ASSERT_EQ(vertices->indices(), nullptr);
215
216 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
217 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
218 ASSERT_EQ(vertices->vertex_count(), 3);
219 for (int i = 0; i < 3; i++) {
220 ASSERT_EQ(vertices->vertices()[i], coords[i]);
221 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
222 }
223 ASSERT_EQ(vertices->index_count(), 0);
224}

◆ TEST() [324/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithTexAndColor   
)

Definition at line 82 of file dl_vertices_unittests.cc.

82 {
83 SkPoint coords[3] = {
84 SkPoint::Make(2, 3),
85 SkPoint::Make(5, 6),
86 SkPoint::Make(15, 20),
87 };
88 SkPoint texture_coords[3] = {
89 SkPoint::Make(102, 103),
90 SkPoint::Make(105, 106),
91 SkPoint::Make(115, 120),
92 };
93 DlColor colors[3] = {
94 DlColor::kRed(),
95 DlColor::kCyan(),
96 DlColor::kGreen(),
97 };
98
99 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
100 DlVertexMode::kTriangles, 3, coords, texture_coords, colors, 6, nullptr);
101
102 ASSERT_NE(vertices, nullptr);
103 ASSERT_NE(vertices->vertices(), nullptr);
104 ASSERT_NE(vertices->texture_coordinates(), nullptr);
105 ASSERT_NE(vertices->colors(), nullptr);
106 ASSERT_EQ(vertices->indices(), nullptr);
107
108 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
109 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
110 ASSERT_EQ(vertices->vertex_count(), 3);
111 for (int i = 0; i < 3; i++) {
112 ASSERT_EQ(vertices->vertices()[i], coords[i]);
113 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
114 ASSERT_EQ(vertices->colors()[i], colors[i]);
115 }
116 ASSERT_EQ(vertices->index_count(), 0);
117}

◆ TEST() [325/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithTexAndColorAndIndices   
)

Definition at line 38 of file dl_vertices_unittests.cc.

38 {
39 SkPoint coords[3] = {
40 SkPoint::Make(2, 3),
41 SkPoint::Make(5, 6),
42 SkPoint::Make(15, 20),
43 };
44 SkPoint texture_coords[3] = {
45 SkPoint::Make(102, 103),
46 SkPoint::Make(105, 106),
47 SkPoint::Make(115, 120),
48 };
49 DlColor colors[3] = {
50 DlColor::kRed(),
51 DlColor::kCyan(),
52 DlColor::kGreen(),
53 };
54 uint16_t indices[6] = {
55 2, 1, 0, //
56 1, 2, 0,
57 };
58
59 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
60 DlVertexMode::kTriangles, 3, coords, texture_coords, colors, 6, indices);
61
62 ASSERT_NE(vertices, nullptr);
63 ASSERT_NE(vertices->vertices(), nullptr);
64 ASSERT_NE(vertices->texture_coordinates(), nullptr);
65 ASSERT_NE(vertices->colors(), nullptr);
66 ASSERT_NE(vertices->indices(), nullptr);
67
68 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
69 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
70 ASSERT_EQ(vertices->vertex_count(), 3);
71 for (int i = 0; i < 3; i++) {
72 ASSERT_EQ(vertices->vertices()[i], coords[i]);
73 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
74 ASSERT_EQ(vertices->colors()[i], colors[i]);
75 }
76 ASSERT_EQ(vertices->index_count(), 6);
77 for (int i = 0; i < 6; i++) {
78 ASSERT_EQ(vertices->indices()[i], indices[i]);
79 }
80}

◆ TEST() [326/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithTexAndIndices   
)

Definition at line 119 of file dl_vertices_unittests.cc.

119 {
120 SkPoint coords[3] = {
121 SkPoint::Make(2, 3),
122 SkPoint::Make(5, 6),
123 SkPoint::Make(15, 20),
124 };
125 SkPoint texture_coords[3] = {
126 SkPoint::Make(102, 103),
127 SkPoint::Make(105, 106),
128 SkPoint::Make(115, 120),
129 };
130 uint16_t indices[6] = {
131 2, 1, 0, //
132 1, 2, 0,
133 };
134
135 std::shared_ptr<const DlVertices> vertices = DlVertices::Make(
136 DlVertexMode::kTriangles, 3, coords, texture_coords, nullptr, 6, indices);
137
138 ASSERT_NE(vertices, nullptr);
139 ASSERT_NE(vertices->vertices(), nullptr);
140 ASSERT_NE(vertices->texture_coordinates(), nullptr);
141 ASSERT_EQ(vertices->colors(), nullptr);
142 ASSERT_NE(vertices->indices(), nullptr);
143
144 ASSERT_EQ(vertices->bounds(), SkRect::MakeLTRB(2, 3, 15, 20));
145 ASSERT_EQ(vertices->mode(), DlVertexMode::kTriangles);
146 ASSERT_EQ(vertices->vertex_count(), 3);
147 for (int i = 0; i < 3; i++) {
148 ASSERT_EQ(vertices->vertices()[i], coords[i]);
149 ASSERT_EQ(vertices->texture_coordinates()[i], texture_coords[i]);
150 }
151 ASSERT_EQ(vertices->index_count(), 6);
152 for (int i = 0; i < 6; i++) {
153 ASSERT_EQ(vertices->indices()[i], indices[i]);
154 }
155}

◆ TEST() [327/709]

flutter::testing::TEST ( DisplayListVertices  ,
MakeWithZeroAndNegativeVerticesAndIndices   
)

Definition at line 14 of file dl_vertices_unittests.cc.

14 {
15 std::shared_ptr<const DlVertices> vertices1 = DlVertices::Make(
16 DlVertexMode::kTriangles, 0, nullptr, nullptr, nullptr, 0, nullptr);
17 EXPECT_NE(vertices1, nullptr);
18 EXPECT_EQ(vertices1->vertex_count(), 0);
19 EXPECT_EQ(vertices1->vertices(), nullptr);
20 EXPECT_EQ(vertices1->texture_coordinates(), nullptr);
21 EXPECT_EQ(vertices1->colors(), nullptr);
22 EXPECT_EQ(vertices1->index_count(), 0);
23 EXPECT_EQ(vertices1->indices(), nullptr);
24
25 std::shared_ptr<const DlVertices> vertices2 = DlVertices::Make(
26 DlVertexMode::kTriangles, -1, nullptr, nullptr, nullptr, -1, nullptr);
27 EXPECT_NE(vertices2, nullptr);
28 EXPECT_EQ(vertices2->vertex_count(), 0);
29 EXPECT_EQ(vertices2->vertices(), nullptr);
30 EXPECT_EQ(vertices2->texture_coordinates(), nullptr);
31 EXPECT_EQ(vertices2->colors(), nullptr);
32 EXPECT_EQ(vertices2->index_count(), 0);
33 EXPECT_EQ(vertices2->indices(), nullptr);
34
35 TestEquals(*vertices1, *vertices2);
36}

◆ TEST() [328/709]

flutter::testing::TEST ( DisplayListVertices  ,
TestEquals   
)

Definition at line 857 of file dl_vertices_unittests.cc.

857 {
858 SkPoint coords[3] = {
859 SkPoint::Make(2, 3),
860 SkPoint::Make(5, 6),
861 SkPoint::Make(15, 20),
862 };
863 SkPoint texture_coords[3] = {
864 SkPoint::Make(102, 103),
865 SkPoint::Make(105, 106),
866 SkPoint::Make(115, 120),
867 };
868 DlColor colors[3] = {
869 DlColor::kRed(),
870 DlColor::kCyan(),
871 DlColor::kGreen(),
872 };
873 uint16_t indices[6] = {
874 2, 1, 0, //
875 1, 2, 0,
876 };
877
878 std::shared_ptr<const DlVertices> vertices1 = DlVertices::Make(
879 DlVertexMode::kTriangles, 3, coords, texture_coords, colors, 6, indices);
880 std::shared_ptr<const DlVertices> vertices2 = DlVertices::Make(
881 DlVertexMode::kTriangles, 3, coords, texture_coords, colors, 6, indices);
882 TestEquals(*vertices1, *vertices2);
883}

◆ TEST() [329/709]

flutter::testing::TEST ( DisplayListVertices  ,
TestNotEquals   
)

Definition at line 885 of file dl_vertices_unittests.cc.

885 {
886 SkPoint coords[4] = {
887 SkPoint::Make(2, 3),
888 SkPoint::Make(5, 6),
889 SkPoint::Make(15, 20),
890 SkPoint::Make(53, 62),
891 };
892 SkPoint wrong_coords[4] = {
893 SkPoint::Make(2, 3),
894 SkPoint::Make(5, 6),
895 SkPoint::Make(15, 20),
896 SkPoint::Make(57, 62),
897 };
898 SkPoint texture_coords[4] = {
899 SkPoint::Make(102, 103),
900 SkPoint::Make(105, 106),
901 SkPoint::Make(115, 120),
902 SkPoint::Make(153, 162),
903 };
904 SkPoint wrong_texture_coords[4] = {
905 SkPoint::Make(102, 103),
906 SkPoint::Make(105, 106),
907 SkPoint::Make(115, 121),
908 SkPoint::Make(153, 162),
909 };
910 DlColor colors[4] = {
911 DlColor::kRed(),
912 DlColor::kCyan(),
913 DlColor::kGreen(),
914 DlColor::kMagenta(),
915 };
916 DlColor wrong_colors[4] = {
917 DlColor::kRed(),
918 DlColor::kBlue(),
919 DlColor::kGreen(),
920 DlColor::kMagenta(),
921 };
922 uint16_t indices[9] = {
923 2, 1, 0, //
924 1, 2, 0, //
925 1, 2, 3,
926 };
927 uint16_t wrong_indices[9] = {
928 2, 1, 0, //
929 1, 2, 0, //
930 2, 3, 1,
931 };
932
933 std::shared_ptr<const DlVertices> vertices1 = DlVertices::Make(
934 DlVertexMode::kTriangles, 4, coords, texture_coords, colors, 9, indices);
935
936 {
937 std::shared_ptr<const DlVertices> vertices2 =
938 DlVertices::Make(DlVertexMode::kTriangleFan, 4, coords, //
939 texture_coords, colors, 9, indices);
940 TestNotEquals(*vertices1, *vertices2, "vertex mode differs");
941 }
942 {
943 std::shared_ptr<const DlVertices> vertices2 =
944 DlVertices::Make(DlVertexMode::kTriangles, 3, coords, //
945 texture_coords, colors, 9, indices);
946 TestNotEquals(*vertices1, *vertices2, "vertex count differs");
947 }
948 {
949 std::shared_ptr<const DlVertices> vertices2 =
950 DlVertices::Make(DlVertexMode::kTriangles, 4, wrong_coords, //
951 texture_coords, colors, 9, indices);
952 TestNotEquals(*vertices1, *vertices2, "vertex coordinates differ");
953 }
954 {
955 std::shared_ptr<const DlVertices> vertices2 =
956 DlVertices::Make(DlVertexMode::kTriangles, 4, coords, //
957 wrong_texture_coords, colors, 9, indices);
958 TestNotEquals(*vertices1, *vertices2, "texture coordinates differ");
959 }
960 {
961 std::shared_ptr<const DlVertices> vertices2 =
962 DlVertices::Make(DlVertexMode::kTriangles, 4, coords, //
963 texture_coords, wrong_colors, 9, indices);
964 TestNotEquals(*vertices1, *vertices2, "colors differ");
965 }
966 {
967 std::shared_ptr<const DlVertices> vertices2 =
968 DlVertices::Make(DlVertexMode::kTriangles, 4, coords, //
969 texture_coords, colors, 6, indices);
970 TestNotEquals(*vertices1, *vertices2, "index count differs");
971 }
972 {
973 std::shared_ptr<const DlVertices> vertices2 =
974 DlVertices::Make(DlVertexMode::kTriangles, 4, coords, //
975 texture_coords, colors, 9, wrong_indices);
976 TestNotEquals(*vertices1, *vertices2, "indices differ");
977 }
978}

◆ TEST() [330/709]

flutter::testing::TEST ( DlOpSpy  ,
DidDrawIsFalseByDefault   
)

Definition at line 33 of file dl_op_spy_unittests.cc.

33 {
34 DlOpSpy dl_op_spy;
35 ASSERT_FALSE(dl_op_spy.did_draw());
36}
bool did_draw()
Returns true if any non transparent content has been drawn.
Definition dl_op_spy.cc:9

◆ TEST() [331/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawArc   
)

Definition at line 307 of file dl_op_spy_unittests.cc.

307 {
308 { // black
309 DisplayListBuilder builder;
310 DlPaint paint(DlColor::kBlack());
311 builder.DrawArc(SkRect::MakeWH(5, 5), 0, 1, true, paint);
312 sk_sp<DisplayList> dl = builder.Build();
313 DlOpSpy dl_op_spy;
314 dl->Dispatch(dl_op_spy);
315 ASSERT_DID_DRAW(dl_op_spy, dl);
316 }
317 { // transparent
318 DisplayListBuilder builder;
319 DlPaint paint(DlColor::kTransparent());
320 builder.DrawArc(SkRect::MakeWH(5, 5), 0, 1, true, paint);
321 sk_sp<DisplayList> dl = builder.Build();
322 DlOpSpy dl_op_spy;
323 dl->Dispatch(dl_op_spy);
324 ASSERT_NO_DRAW(dl_op_spy, dl);
325 }
326}
#define ASSERT_DID_DRAW(spy, dl)
#define ASSERT_NO_DRAW(spy, dl)

◆ TEST() [332/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawCircle   
)

Definition at line 227 of file dl_op_spy_unittests.cc.

227 {
228 { // black
229 DisplayListBuilder builder;
230 DlPaint paint(DlColor::kBlack());
231 builder.DrawCircle(SkPoint::Make(5, 5), 1.0, paint);
232 sk_sp<DisplayList> dl = builder.Build();
233 DlOpSpy dl_op_spy;
234 dl->Dispatch(dl_op_spy);
235 ASSERT_DID_DRAW(dl_op_spy, dl);
236 }
237 { // transparent
238 DisplayListBuilder builder;
239 DlPaint paint(DlColor::kTransparent());
240 builder.DrawCircle(SkPoint::Make(5, 5), 1.0, paint);
241 sk_sp<DisplayList> dl = builder.Build();
242 DlOpSpy dl_op_spy;
243 dl->Dispatch(dl_op_spy);
244 ASSERT_NO_DRAW(dl_op_spy, dl);
245 }
246}

◆ TEST() [333/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawColor   
)

Definition at line 113 of file dl_op_spy_unittests.cc.

113 {
114 { // Black color source.
115 DisplayListBuilder builder;
116 auto color = DlColor::kBlack();
117 builder.DrawColor(color, DlBlendMode::kSrc);
118 sk_sp<DisplayList> dl = builder.Build();
119 DlOpSpy dl_op_spy;
120 dl->Dispatch(dl_op_spy);
121 ASSERT_DID_DRAW(dl_op_spy, dl);
122 }
123 { // Transparent color with kSrc.
124 DisplayListBuilder builder;
125 auto color = DlColor::kTransparent();
126 builder.DrawColor(color, DlBlendMode::kSrc);
127 sk_sp<DisplayList> dl = builder.Build();
128 DlOpSpy dl_op_spy;
129 dl->Dispatch(dl_op_spy);
130 ASSERT_NO_DRAW(dl_op_spy, dl);
131 }
132 { // Transparent color with kSrcOver.
133 DisplayListBuilder builder;
134 auto color = DlColor::kTransparent();
135 builder.DrawColor(color, DlBlendMode::kSrcOver);
136 sk_sp<DisplayList> dl = builder.Build();
137 DlOpSpy dl_op_spy;
138 dl->Dispatch(dl_op_spy);
139 ASSERT_NO_DRAW(dl_op_spy, dl);
140 }
141}

◆ TEST() [334/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawDisplayList   
)

Definition at line 476 of file dl_op_spy_unittests.cc.

476 {
477 { // Recursive Transparent DisplayList
478 DisplayListBuilder builder;
479 DlPaint paint(DlColor::kTransparent());
480 builder.DrawPaint(paint);
481 sk_sp<DisplayList> dl = builder.Build();
482
483 DisplayListBuilder builder_parent;
484 DlPaint paint_parent(DlColor::kTransparent());
485 builder_parent.DrawPaint(paint_parent);
486 builder_parent.DrawDisplayList(dl, 1);
487 sk_sp<DisplayList> dl2 = builder_parent.Build();
488
489 DlOpSpy dl_op_spy;
490 dl2->Dispatch(dl_op_spy);
491 ASSERT_NO_DRAW(dl_op_spy, dl2);
492 }
493 { // Sub non-transparent DisplayList,
494 DisplayListBuilder builder;
495 DlPaint paint(DlColor::kBlack());
496 builder.DrawPaint(paint);
497 sk_sp<DisplayList> dl = builder.Build();
498
499 DisplayListBuilder builder_parent;
500 DlPaint paint_parent(DlColor::kTransparent());
501 builder_parent.DrawPaint(paint_parent);
502 builder_parent.DrawDisplayList(dl, 1);
503 sk_sp<DisplayList> dl2 = builder_parent.Build();
504
505 DlOpSpy dl_op_spy;
506 dl2->Dispatch(dl_op_spy);
507 ASSERT_DID_DRAW(dl_op_spy, dl2);
508 }
509
510 { // Sub non-transparent DisplayList, 0 opacity
511 DisplayListBuilder builder;
512 DlPaint paint(DlColor::kBlack());
513 builder.DrawPaint(paint);
514 sk_sp<DisplayList> dl = builder.Build();
515
516 DisplayListBuilder builder_parent;
517 DlPaint paint_parent(DlColor::kTransparent());
518 builder_parent.DrawPaint(paint_parent);
519 builder_parent.DrawDisplayList(dl, 0);
520 sk_sp<DisplayList> dl2 = builder_parent.Build();
521
522 DlOpSpy dl_op_spy;
523 dl2->Dispatch(dl_op_spy);
524 ASSERT_NO_DRAW(dl_op_spy, dl2);
525 }
526
527 { // Parent non-transparent DisplayList
528 DisplayListBuilder builder;
529 DlPaint paint(DlColor::kTransparent());
530 builder.DrawPaint(paint);
531 sk_sp<DisplayList> dl = builder.Build();
532
533 DisplayListBuilder builder_parent;
534 DlPaint paint_parent(DlColor::kBlack());
535 builder_parent.DrawPaint(paint_parent);
536 builder_parent.DrawDisplayList(dl, 0);
537 sk_sp<DisplayList> dl2 = builder_parent.Build();
538
539 DlOpSpy dl_op_spy;
540 dl2->Dispatch(dl_op_spy);
541 ASSERT_DID_DRAW(dl_op_spy, dl2);
542 }
543}
void DrawPaint(const DlPaint &paint) override
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override

◆ TEST() [335/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawLine   
)

Definition at line 164 of file dl_op_spy_unittests.cc.

164 {
165 { // black
166 DisplayListBuilder builder;
167 DlPaint paint(DlColor::kBlack());
168 builder.DrawLine(SkPoint::Make(0, 1), SkPoint::Make(1, 2), paint);
169 sk_sp<DisplayList> dl = builder.Build();
170 DlOpSpy dl_op_spy;
171 dl->Dispatch(dl_op_spy);
172 ASSERT_DID_DRAW(dl_op_spy, dl);
173 }
174 { // transparent
175 DisplayListBuilder builder;
176 DlPaint paint(DlColor::kTransparent());
177 builder.DrawLine(SkPoint::Make(0, 1), SkPoint::Make(1, 2), paint);
178 sk_sp<DisplayList> dl = builder.Build();
179 DlOpSpy dl_op_spy;
180 dl->Dispatch(dl_op_spy);
181 ASSERT_NO_DRAW(dl_op_spy, dl);
182 }
183}

◆ TEST() [336/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawOval   
)

Definition at line 206 of file dl_op_spy_unittests.cc.

206 {
207 { // black
208 DisplayListBuilder builder;
209 DlPaint paint(DlColor::kBlack());
210 builder.DrawOval(SkRect::MakeWH(5, 5), paint);
211 sk_sp<DisplayList> dl = builder.Build();
212 DlOpSpy dl_op_spy;
213 dl->Dispatch(dl_op_spy);
214 ASSERT_DID_DRAW(dl_op_spy, dl);
215 }
216 { // transparent
217 DisplayListBuilder builder;
218 DlPaint paint(DlColor::kTransparent());
219 builder.DrawOval(SkRect::MakeWH(5, 5), paint);
220 sk_sp<DisplayList> dl = builder.Build();
221 DlOpSpy dl_op_spy;
222 dl->Dispatch(dl_op_spy);
223 ASSERT_NO_DRAW(dl_op_spy, dl);
224 }
225}

◆ TEST() [337/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawPaint   
)

Definition at line 143 of file dl_op_spy_unittests.cc.

143 {
144 { // Transparent color in paint.
145 DisplayListBuilder builder;
146 DlPaint paint(DlColor::kTransparent());
147 builder.DrawPaint(paint);
148 sk_sp<DisplayList> dl = builder.Build();
149 DlOpSpy dl_op_spy;
150 dl->Dispatch(dl_op_spy);
151 ASSERT_NO_DRAW(dl_op_spy, dl);
152 }
153 { // black color in paint.
154 DisplayListBuilder builder;
155 DlPaint paint(DlColor::kBlack());
156 builder.DrawPaint(paint);
157 sk_sp<DisplayList> dl = builder.Build();
158 DlOpSpy dl_op_spy;
159 dl->Dispatch(dl_op_spy);
160 ASSERT_DID_DRAW(dl_op_spy, dl);
161 }
162}

◆ TEST() [338/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawPath   
)

Definition at line 269 of file dl_op_spy_unittests.cc.

269 {
270 { // black line
271 DisplayListBuilder builder;
272 DlPaint paint(DlColor::kBlack());
273 paint.setDrawStyle(DlDrawStyle::kStroke);
274 builder.DrawPath(SkPath::Line(SkPoint::Make(0, 1), SkPoint::Make(1, 1)),
275 paint);
276 sk_sp<DisplayList> dl = builder.Build();
277 DlOpSpy dl_op_spy;
278 dl->Dispatch(dl_op_spy);
279 ASSERT_DID_DRAW(dl_op_spy, dl);
280 }
281 { // triangle
282 DisplayListBuilder builder;
283 DlPaint paint(DlColor::kBlack());
284 SkPath path;
285 path.moveTo({0, 0});
286 path.lineTo({1, 0});
287 path.lineTo({0, 1});
288 builder.DrawPath(path, paint);
289 sk_sp<DisplayList> dl = builder.Build();
290 DlOpSpy dl_op_spy;
291 dl->Dispatch(dl_op_spy);
292 ASSERT_DID_DRAW(dl_op_spy, dl);
293 }
294 { // transparent line
295 DisplayListBuilder builder;
296 DlPaint paint(DlColor::kTransparent());
297 paint.setDrawStyle(DlDrawStyle::kStroke);
298 builder.DrawPath(SkPath::Line(SkPoint::Make(0, 1), SkPoint::Make(1, 1)),
299 paint);
300 sk_sp<DisplayList> dl = builder.Build();
301 DlOpSpy dl_op_spy;
302 dl->Dispatch(dl_op_spy);
303 ASSERT_NO_DRAW(dl_op_spy, dl);
304 }
305}
static SkPath Line(const SkPoint a, const SkPoint b)
Definition SkPath.h:106

◆ TEST() [339/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawPoints   
)

Definition at line 328 of file dl_op_spy_unittests.cc.

328 {
329 { // black
330 DisplayListBuilder builder;
331 DlPaint paint(DlColor::kBlack());
332 const SkPoint points[] = {SkPoint::Make(5, 4)};
333 builder.DrawPoints(DlCanvas::PointMode::kPoints, 1, points, paint);
334 sk_sp<DisplayList> dl = builder.Build();
335 DlOpSpy dl_op_spy;
336 dl->Dispatch(dl_op_spy);
337 ASSERT_DID_DRAW(dl_op_spy, dl);
338 }
339 { // transparent
340 DisplayListBuilder builder;
341 DlPaint paint(DlColor::kTransparent());
342 const SkPoint points[] = {SkPoint::Make(5, 4)};
343 builder.DrawPoints(DlCanvas::PointMode::kPoints, 1, points, paint);
344 sk_sp<DisplayList> dl = builder.Build();
345 DlOpSpy dl_op_spy;
346 dl->Dispatch(dl_op_spy);
347 ASSERT_NO_DRAW(dl_op_spy, dl);
348 }
349}

◆ TEST() [340/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawRect   
)

Definition at line 185 of file dl_op_spy_unittests.cc.

185 {
186 { // black
187 DisplayListBuilder builder;
188 DlPaint paint(DlColor::kBlack());
189 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
190 sk_sp<DisplayList> dl = builder.Build();
191 DlOpSpy dl_op_spy;
192 dl->Dispatch(dl_op_spy);
193 ASSERT_DID_DRAW(dl_op_spy, dl);
194 }
195 { // transparent
196 DisplayListBuilder builder;
197 DlPaint paint(DlColor::kTransparent());
198 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
199 sk_sp<DisplayList> dl = builder.Build();
200 DlOpSpy dl_op_spy;
201 dl->Dispatch(dl_op_spy);
202 ASSERT_NO_DRAW(dl_op_spy, dl);
203 }
204}

◆ TEST() [341/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawRRect   
)

Definition at line 248 of file dl_op_spy_unittests.cc.

248 {
249 { // black
250 DisplayListBuilder builder;
251 DlPaint paint(DlColor::kBlack());
252 builder.DrawRRect(SkRRect::MakeRect(SkRect::MakeWH(5, 5)), paint);
253 sk_sp<DisplayList> dl = builder.Build();
254 DlOpSpy dl_op_spy;
255 dl->Dispatch(dl_op_spy);
256 ASSERT_DID_DRAW(dl_op_spy, dl);
257 }
258 { // transparent
259 DisplayListBuilder builder;
260 DlPaint paint(DlColor::kTransparent());
261 builder.DrawRRect(SkRRect::MakeRect(SkRect::MakeWH(5, 5)), paint);
262 sk_sp<DisplayList> dl = builder.Build();
263 DlOpSpy dl_op_spy;
264 dl->Dispatch(dl_op_spy);
265 ASSERT_NO_DRAW(dl_op_spy, dl);
266 }
267}

◆ TEST() [342/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawShadow   
)

Definition at line 572 of file dl_op_spy_unittests.cc.

572 {
573 { // valid shadow
574 DisplayListBuilder builder;
576 DlColor color = DlColor::kBlack();
578 builder.DrawShadow(path, color, 1, false, 1);
579 sk_sp<DisplayList> dl = builder.Build();
580 DlOpSpy dl_op_spy;
581 dl->Dispatch(dl_op_spy);
582 ASSERT_DID_DRAW(dl_op_spy, dl);
583 }
584 { // transparent color
585 DisplayListBuilder builder;
587 DlColor color = DlColor::kTransparent();
589 builder.DrawShadow(path, color, 1, false, 1);
590 sk_sp<DisplayList> dl = builder.Build();
591 DlOpSpy dl_op_spy;
592 dl->Dispatch(dl_op_spy);
593 ASSERT_NO_DRAW(dl_op_spy, dl);
594 }
595}

◆ TEST() [343/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawTextBlob   
)

Definition at line 545 of file dl_op_spy_unittests.cc.

545 {
546 { // Non-transparent color.
547 DisplayListBuilder builder;
548 DlPaint paint(DlColor::kBlack());
549 std::string string = "xx";
550 SkFont font = CreateTestFontOfSize(12);
551 auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
552 builder.DrawTextBlob(text_blob, 1, 1, paint);
553 sk_sp<DisplayList> dl = builder.Build();
554 DlOpSpy dl_op_spy;
555 dl->Dispatch(dl_op_spy);
556 ASSERT_DID_DRAW(dl_op_spy, dl);
557 }
558 { // transparent color.
559 DisplayListBuilder builder;
560 DlPaint paint(DlColor::kTransparent());
561 std::string string = "xx";
562 SkFont font = CreateTestFontOfSize(12);
563 auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
564 builder.DrawTextBlob(text_blob, 1, 1, paint);
565 sk_sp<DisplayList> dl = builder.Build();
566 DlOpSpy dl_op_spy;
567 dl->Dispatch(dl_op_spy);
568 ASSERT_NO_DRAW(dl_op_spy, dl);
569 }
570}

◆ TEST() [344/709]

flutter::testing::TEST ( DlOpSpy  ,
DrawVertices   
)

Definition at line 351 of file dl_op_spy_unittests.cc.

351 {
352 { // black
353 DisplayListBuilder builder;
354 DlPaint paint(DlColor::kBlack());
355 const SkPoint vertices[] = {
356 SkPoint::Make(5, 5),
357 SkPoint::Make(5, 15),
358 SkPoint::Make(15, 5),
359 };
360 const SkPoint texture_coordinates[] = {
361 SkPoint::Make(5, 5),
362 SkPoint::Make(15, 5),
363 SkPoint::Make(5, 15),
364 };
365 const DlColor colors[] = {
366 DlColor::kBlack(),
367 DlColor::kRed(),
368 DlColor::kGreen(),
369 };
370 auto dl_vertices = DlVertices::Make(DlVertexMode::kTriangles, 3, vertices,
371 texture_coordinates, colors, 0);
372 builder.DrawVertices(dl_vertices.get(), DlBlendMode::kSrc, paint);
373 sk_sp<DisplayList> dl = builder.Build();
374 DlOpSpy dl_op_spy;
375 dl->Dispatch(dl_op_spy);
376 ASSERT_DID_DRAW(dl_op_spy, dl);
377 }
378 { // transparent
379 DisplayListBuilder builder;
380 DlPaint paint(DlColor::kTransparent());
381 const SkPoint vertices[] = {
382 SkPoint::Make(5, 5),
383 SkPoint::Make(5, 15),
384 SkPoint::Make(15, 5),
385 };
386 const SkPoint texture_coordinates[] = {
387 SkPoint::Make(5, 5),
388 SkPoint::Make(15, 5),
389 SkPoint::Make(5, 15),
390 };
391 const DlColor colors[] = {
392 DlColor::kBlack(),
393 DlColor::kRed(),
394 DlColor::kGreen(),
395 };
396 auto dl_vertices = DlVertices::Make(DlVertexMode::kTriangles, 3, vertices,
397 texture_coordinates, colors, 0);
398 builder.DrawVertices(dl_vertices.get(), DlBlendMode::kSrc, paint);
399 sk_sp<DisplayList> dl = builder.Build();
400 DlOpSpy dl_op_spy;
401 dl->Dispatch(dl_op_spy);
402 ASSERT_NO_DRAW(dl_op_spy, dl);
403 }
404}

◆ TEST() [345/709]

flutter::testing::TEST ( DlOpSpy  ,
EmptyDisplayList   
)

Definition at line 38 of file dl_op_spy_unittests.cc.

38 {
39 DisplayListBuilder builder;
40 sk_sp<DisplayList> dl = builder.Build();
41 DlOpSpy dl_op_spy;
42 dl->Dispatch(dl_op_spy);
43 ASSERT_NO_DRAW(dl_op_spy, dl);
44}

◆ TEST() [346/709]

flutter::testing::TEST ( DlOpSpy  ,
Images   
)

Definition at line 406 of file dl_op_spy_unittests.cc.

406 {
407 { // DrawImage
408 DisplayListBuilder builder;
409 DlPaint paint(DlColor::kBlack());
414 bitmap.allocPixels(info, 0);
415 auto sk_image = SkImages::RasterFromBitmap(bitmap);
416 builder.DrawImage(DlImage::Make(sk_image), SkPoint::Make(5, 5),
417 DlImageSampling::kLinear);
418 sk_sp<DisplayList> dl = builder.Build();
419 DlOpSpy dl_op_spy;
420 dl->Dispatch(dl_op_spy);
421 ASSERT_DID_DRAW(dl_op_spy, dl);
422 }
423 { // DrawImageRect
424 DisplayListBuilder builder;
425 DlPaint paint(DlColor::kBlack());
430 bitmap.allocPixels(info, 0);
431 auto sk_image = SkImages::RasterFromBitmap(bitmap);
432 builder.DrawImageRect(DlImage::Make(sk_image), SkRect::MakeWH(5, 5),
433 SkRect::MakeWH(5, 5), DlImageSampling::kLinear);
434 sk_sp<DisplayList> dl = builder.Build();
435 DlOpSpy dl_op_spy;
436 dl->Dispatch(dl_op_spy);
437 ASSERT_DID_DRAW(dl_op_spy, dl);
438 }
439 { // DrawImageNine
440 DisplayListBuilder builder;
441 DlPaint paint(DlColor::kBlack());
446 bitmap.allocPixels(info, 0);
447 auto sk_image = SkImages::RasterFromBitmap(bitmap);
448 builder.DrawImageNine(DlImage::Make(sk_image), SkIRect::MakeWH(5, 5),
449 SkRect::MakeWH(5, 5), DlFilterMode::kLinear);
450 sk_sp<DisplayList> dl = builder.Build();
451 DlOpSpy dl_op_spy;
452 dl->Dispatch(dl_op_spy);
453 ASSERT_DID_DRAW(dl_op_spy, dl);
454 }
455 { // DrawAtlas
456 DisplayListBuilder builder;
457 DlPaint paint(DlColor::kBlack());
462 bitmap.allocPixels(info, 0);
463 auto sk_image = SkImages::RasterFromBitmap(bitmap);
464 const SkRSXform xform[] = {SkRSXform::Make(1, 0, 0, 0)};
465 const SkRect tex[] = {SkRect::MakeXYWH(10, 10, 10, 10)};
466 SkRect cull_rect = SkRect::MakeWH(5, 5);
467 builder.DrawAtlas(DlImage::Make(sk_image), xform, tex, nullptr, 1,
468 DlBlendMode::kSrc, DlImageSampling::kLinear, &cull_rect);
469 sk_sp<DisplayList> dl = builder.Build();
470 DlOpSpy dl_op_spy;
471 dl->Dispatch(dl_op_spy);
472 ASSERT_DID_DRAW(dl_op_spy, dl);
473 }
474}

◆ TEST() [347/709]

flutter::testing::TEST ( DlOpSpy  ,
SetColor   
)

Definition at line 46 of file dl_op_spy_unittests.cc.

46 {
47 { // No Color set.
48 DisplayListBuilder builder;
50 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
51 sk_sp<DisplayList> dl = builder.Build();
52 DlOpSpy dl_op_spy;
53 dl->Dispatch(dl_op_spy);
54 ASSERT_DID_DRAW(dl_op_spy, dl);
55 }
56 { // Set transparent color.
57 DisplayListBuilder builder;
58 DlPaint paint(DlColor::kTransparent());
59 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
60 sk_sp<DisplayList> dl = builder.Build();
61 DlOpSpy dl_op_spy;
62 dl->Dispatch(dl_op_spy);
63 ASSERT_NO_DRAW(dl_op_spy, dl);
64 }
65 { // Set black color.
66 DisplayListBuilder builder;
67 DlPaint paint(DlColor::kBlack());
68 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
69 sk_sp<DisplayList> dl = builder.Build();
70 DlOpSpy dl_op_spy;
71 dl->Dispatch(dl_op_spy);
72 ASSERT_DID_DRAW(dl_op_spy, dl);
73 }
74}

◆ TEST() [348/709]

flutter::testing::TEST ( DlOpSpy  ,
SetColorSource   
)

Definition at line 76 of file dl_op_spy_unittests.cc.

76 {
77 { // Set null source
78 DisplayListBuilder builder;
80 paint.setColorSource(nullptr);
81 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
82 sk_sp<DisplayList> dl = builder.Build();
83 DlOpSpy dl_op_spy;
84 dl->Dispatch(dl_op_spy);
85 ASSERT_DID_DRAW(dl_op_spy, dl);
86 }
87 { // Set transparent color.
88 DisplayListBuilder builder;
90 auto color = DlColor::kTransparent();
91 DlColorColorSource color_source_transparent(color);
92 paint.setColorSource(color_source_transparent.shared());
93 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
94 sk_sp<DisplayList> dl = builder.Build();
95 DlOpSpy dl_op_spy;
96 dl->Dispatch(dl_op_spy);
97 ASSERT_NO_DRAW(dl_op_spy, dl);
98 }
99 { // Set black color.
100 DisplayListBuilder builder;
101 DlPaint paint;
102 auto color = DlColor::kBlack();
103 DlColorColorSource color_source_transparent(color);
104 paint.setColorSource(color_source_transparent.shared());
105 builder.DrawRect(SkRect::MakeWH(5, 5), paint);
106 sk_sp<DisplayList> dl = builder.Build();
107 DlOpSpy dl_op_spy;
108 dl->Dispatch(dl_op_spy);
109 ASSERT_DID_DRAW(dl_op_spy, dl);
110 }
111}

◆ TEST() [349/709]

flutter::testing::TEST ( DlVertexPainter  ,
DrawRectIntoVertices   
)

Definition at line 21 of file stopwatch_dl_unittests.cc.

21 {
22 auto painter = DlVertexPainter();
23
24 // Paint a red rectangle.
25 painter.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10), DlColor::kRed());
26
27 // Paint a blue rectangle.
28 painter.DrawRect(SkRect::MakeLTRB(10, 10, 20, 20), DlColor::kBlue());
29
30 // Convert the buffered vertices into a |DlVertices| object.
31 auto vertices = painter.IntoVertices();
32
33 // Verify the vertices.
34 EXPECT_EQ(vertices->mode(), DlVertexMode::kTriangles);
35 EXPECT_EQ(vertices->vertex_count(), 3 * 2 * 2);
36
37 auto const points = vertices->vertices();
38
39 {
40 // Extract the first 6 vertices (first rectangle).
41 SkPoint first_rect_vertices[6];
42 std::copy(points, points + 6, first_rect_vertices);
43 EXPECT_EQ(MakeRectFromVertices(first_rect_vertices),
44 SkRect::MakeLTRB(0, 0, 10, 10));
45 }
46
47 {
48 // Extract the next 6 vertices (second rectangle).
49 SkPoint second_rect_vertices[6];
50 std::copy(points + 6, points + 12, second_rect_vertices);
51 EXPECT_EQ(MakeRectFromVertices(second_rect_vertices),
52 SkRect::MakeLTRB(10, 10, 20, 20));
53 }
54
55 // Verify the colors (first 6 vertices are red, next 6 are blue).
56 auto const colors = vertices->colors();
57 EXPECT_EQ(colors[0], DlColor::kRed());
58 EXPECT_EQ(colors[1], DlColor::kRed());
59 EXPECT_EQ(colors[2], DlColor::kRed());
60 EXPECT_EQ(colors[3], DlColor::kRed());
61 EXPECT_EQ(colors[4], DlColor::kRed());
62 EXPECT_EQ(colors[5], DlColor::kRed());
63
64 EXPECT_EQ(colors[6], DlColor::kBlue());
65 EXPECT_EQ(colors[7], DlColor::kBlue());
66 EXPECT_EQ(colors[8], DlColor::kBlue());
67 EXPECT_EQ(colors[9], DlColor::kBlue());
68 EXPECT_EQ(colors[10], DlColor::kBlue());
69 EXPECT_EQ(colors[11], DlColor::kBlue());
70}
Provides canvas-like painting methods that actually build vertices.
static SkRect MakeRectFromVertices(SkPoint vertices[6])

◆ TEST() [350/709]

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

Definition at line 13 of file dpi_utils_unittests.cc.

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

◆ TEST() [351/709]

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

◆ TEST() [352/709]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithNoMutations   
)

Definition at line 12 of file embedded_view_params_unittests.cc.

12 {
13 MutatorsStack stack;
14 SkMatrix matrix;
15
16 EmbeddedViewParams params(matrix, SkSize::Make(1, 1), stack);
17 const SkRect& rect = params.finalBoundingRect();
18 ASSERT_TRUE(SkScalarNearlyEqual(rect.x(), 0));
19 ASSERT_TRUE(SkScalarNearlyEqual(rect.y(), 0));
20 ASSERT_TRUE(SkScalarNearlyEqual(rect.width(), 1));
21 ASSERT_TRUE(SkScalarNearlyEqual(rect.height(), 1));
22}
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
const EmbeddedViewParams * params

◆ TEST() [353/709]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithRotation45   
)

Definition at line 65 of file embedded_view_params_unittests.cc.

65 {
66 MutatorsStack stack;
67 SkMatrix matrix;
68 matrix.setRotate(45);
69 stack.PushTransform(matrix);
70
71 EmbeddedViewParams params(matrix, SkSize::Make(1, 1), stack);
72 const SkRect& rect = params.finalBoundingRect();
73 ASSERT_TRUE(SkScalarNearlyEqual(rect.x(), -sqrt(2) / 2));
74 ASSERT_TRUE(SkScalarNearlyEqual(rect.y(), 0));
75 ASSERT_TRUE(SkScalarNearlyEqual(rect.width(), sqrt(2)));
76 ASSERT_TRUE(SkScalarNearlyEqual(rect.height(), sqrt(2)));
77}
void PushTransform(const SkMatrix &matrix)

◆ TEST() [354/709]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithRotation90   
)

Definition at line 50 of file embedded_view_params_unittests.cc.

50 {
51 MutatorsStack stack;
52 SkMatrix matrix;
53 matrix.setRotate(90);
54 stack.PushTransform(matrix);
55
56 EmbeddedViewParams params(matrix, SkSize::Make(1, 1), stack);
57 const SkRect& rect = params.finalBoundingRect();
58
59 ASSERT_TRUE(SkScalarNearlyEqual(rect.x(), -1));
60 ASSERT_TRUE(SkScalarNearlyEqual(rect.y(), 0));
61 ASSERT_TRUE(SkScalarNearlyEqual(rect.width(), 1));
62 ASSERT_TRUE(SkScalarNearlyEqual(rect.height(), 1));
63}

◆ TEST() [355/709]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithScale   
)

Definition at line 24 of file embedded_view_params_unittests.cc.

24 {
25 MutatorsStack stack;
26 SkMatrix matrix = SkMatrix::Scale(2, 2);
27 stack.PushTransform(matrix);
28
29 EmbeddedViewParams params(matrix, SkSize::Make(1, 1), stack);
30 const SkRect& rect = params.finalBoundingRect();
31 ASSERT_TRUE(SkScalarNearlyEqual(rect.x(), 0));
32 ASSERT_TRUE(SkScalarNearlyEqual(rect.y(), 0));
33 ASSERT_TRUE(SkScalarNearlyEqual(rect.width(), 2));
34 ASSERT_TRUE(SkScalarNearlyEqual(rect.height(), 2));
35}

◆ TEST() [356/709]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithTranslate   
)

Definition at line 37 of file embedded_view_params_unittests.cc.

37 {
38 MutatorsStack stack;
39 SkMatrix matrix = SkMatrix::Translate(1, 1);
40 stack.PushTransform(matrix);
41
42 EmbeddedViewParams params(matrix, SkSize::Make(1, 1), stack);
43 const SkRect& rect = params.finalBoundingRect();
44 ASSERT_TRUE(SkScalarNearlyEqual(rect.x(), 1));
45 ASSERT_TRUE(SkScalarNearlyEqual(rect.y(), 1));
46 ASSERT_TRUE(SkScalarNearlyEqual(rect.width(), 1));
47 ASSERT_TRUE(SkScalarNearlyEqual(rect.height(), 1));
48}

◆ TEST() [357/709]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithTranslateScaleAndRotation   
)

Definition at line 79 of file embedded_view_params_unittests.cc.

80 {
81 SkMatrix matrix = SkMatrix::Translate(2, 2);
82 matrix.preScale(3, 3);
83 matrix.preRotate(90);
84
85 MutatorsStack stack;
86 stack.PushTransform(matrix);
87
88 EmbeddedViewParams params(matrix, SkSize::Make(1, 1), stack);
89 const SkRect& rect = params.finalBoundingRect();
90 ASSERT_TRUE(SkScalarNearlyEqual(rect.x(), -1));
91 ASSERT_TRUE(SkScalarNearlyEqual(rect.y(), 2));
92 ASSERT_TRUE(SkScalarNearlyEqual(rect.width(), 3));
93 ASSERT_TRUE(SkScalarNearlyEqual(rect.height(), 3));
94}

◆ TEST() [358/709]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterDamageIsFrozen   
)

Definition at line 52 of file embedder_frozen_unittests.cc.

52 {
56}
#define ASSERT_EQ_OFFSET(type1, type2, member)
A structure to represent a damage region.
Definition embedder.h:458

◆ TEST() [359/709]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterPointIsFrozen   
)

◆ TEST() [360/709]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterRectIsFrozen   
)

◆ TEST() [361/709]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterSemanticsCustomActionIsFrozen   
)

◆ TEST() [362/709]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterSemanticsNodeIsFrozen   
)

Definition at line 61 of file embedder_frozen_unittests.cc.

61 {
62 ASSERT_EQ(sizeof(FlutterSemanticsNode), sizeof(FrozenFlutterSemanticsNode));
63
65 struct_size);
70 text_selection_base);
72 text_selection_extent);
74 scroll_child_count);
76 scroll_index);
78 scroll_position);
80 scroll_extent_max);
82 scroll_extent_min);
89 increased_value);
91 decreased_value);
93 text_direction);
97 child_count);
99 children_in_traversal_order);
101 children_in_hit_test_order);
103 custom_accessibility_actions_count);
105 custom_accessibility_actions);
107 platform_view_id);
109}

◆ TEST() [363/709]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterTransformationIsFrozen   
)

◆ TEST() [364/709]

flutter::testing::TEST ( EmbedderProcTable  ,
AllPointersProvided   
)

Definition at line 20 of file embedder_unittests_proctable.cc.

20 {
21 FlutterEngineProcTable procs = {};
22 procs.struct_size = sizeof(FlutterEngineProcTable);
23 ASSERT_EQ(FlutterEngineGetProcAddresses(&procs), kSuccess);
24
25 void (**proc)() = reinterpret_cast<void (**)()>(&procs.CreateAOTData);
26 const uintptr_t end_address =
27 reinterpret_cast<uintptr_t>(&procs) + procs.struct_size;
28 while (reinterpret_cast<uintptr_t>(proc) < end_address) {
29 EXPECT_NE(*proc, nullptr);
30 ++proc;
31 }
32}
FlutterEngineResult FlutterEngineGetProcAddresses(FlutterEngineProcTable *table)
Gets the table of engine function pointers.
Definition embedder.cc:3329
Function-pointer-based versions of the APIs above.
Definition embedder.h:3317
FlutterEngineCreateAOTDataFnPtr CreateAOTData
Definition embedder.h:3321
size_t struct_size
The size of this struct. Must be sizeof(FlutterEngineProcs).
Definition embedder.h:3319

◆ TEST() [365/709]

flutter::testing::TEST ( EmbedderProcTable  ,
CallProc   
)

Definition at line 53 of file embedder_unittests_proctable.cc.

53 {
54 FlutterEngineProcTable procs = {};
55 procs.struct_size = sizeof(FlutterEngineProcTable);
56 ASSERT_EQ(FlutterEngineGetProcAddresses(&procs), kSuccess);
57
58 EXPECT_NE(procs.GetCurrentTime(), 0ULL);
59}
FlutterEngineGetCurrentTimeFnPtr GetCurrentTime
Definition embedder.h:3350

◆ TEST() [366/709]

flutter::testing::TEST ( EmbedderProcTable  ,
NoDuplicatePointers   
)

Definition at line 36 of file embedder_unittests_proctable.cc.

36 {
37 FlutterEngineProcTable procs = {};
38 procs.struct_size = sizeof(FlutterEngineProcTable);
39 ASSERT_EQ(FlutterEngineGetProcAddresses(&procs), kSuccess);
40
41 void (**proc)() = reinterpret_cast<void (**)()>(&procs.CreateAOTData);
42 const uintptr_t end_address =
43 reinterpret_cast<uintptr_t>(&procs) + procs.struct_size;
44 std::set<void (*)()> seen_procs;
45 while (reinterpret_cast<uintptr_t>(proc) < end_address) {
46 auto result = seen_procs.insert(*proc);
47 EXPECT_TRUE(result.second);
48 ++proc;
49 }
50}

◆ TEST() [367/709]

flutter::testing::TEST ( EmbedderTestNoFixture  ,
CanGetCurrentTimeInNanoseconds   
)

Definition at line 268 of file embedder_unittests.cc.

268 {
269 auto point1 = fml::TimePoint::FromEpochDelta(
271 auto point2 = fml::TimePoint::Now();
272
273 ASSERT_LT((point2 - point1), fml::TimeDelta::FromMilliseconds(1));
274}
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition time_delta.h:40
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition time_delta.h:46
static TimePoint Now()
Definition time_point.cc:49
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition time_point.h:43
uint64_t FlutterEngineGetCurrentTime()
Get the current time in nanoseconds from the clock used by the flutter engine. This is the system mon...
Definition embedder.cc:2949

◆ TEST() [368/709]

flutter::testing::TEST ( EmbedderTestNoFixture  ,
MustNotRunWithInvalidArgs   
)

Definition at line 58 of file embedder_unittests.cc.

58 {
61 context, EmbedderConfigBuilder::InitializationPreference::kNoInitialize);
62 auto engine = builder.LaunchEngine();
63 ASSERT_FALSE(engine.is_valid());
64}

◆ TEST() [369/709]

flutter::testing::TEST ( FlutterAppDelegateTest  ,
DoesNotCallDelegatesWithoutHandler   
)

Definition at line 32 of file FlutterAppDelegateTest.mm.

32 {
33 FlutterAppDelegate* appDelegate = [[FlutterAppDelegate alloc] init];
36 [appDelegate addApplicationLifecycleDelegate:noopDelegate];
37
38 [appDelegate application:NSApplication.sharedApplication openURLs:@[]];
39 // No EXPECT, since the test is that the call doesn't throw due to calling without checking that
40 // the method is implemented.
41}
void application:openURLs:(NSApplication *application, [openURLs] NSArray< NSURL * > *urls)
void addApplicationLifecycleDelegate:(NSObject< FlutterAppLifecycleDelegate > *delegate)

◆ TEST() [370/709]

flutter::testing::TEST ( FlutterAppDelegateTest  ,
OperURLsStopsAfterHandled   
)

Definition at line 57 of file FlutterAppDelegateTest.mm.

57 {
58 FlutterAppDelegate* appDelegate = [[FlutterAppDelegate alloc] init];
63 [appDelegate addApplicationLifecycleDelegate:firstDelegate];
64 [appDelegate addApplicationLifecycleDelegate:secondDelegate];
65
66 NSURL* URL = [NSURL URLWithString:@"https://flutter.dev"];
67 EXPECT_NE(URL, nil);
68 NSArray<NSURL*>* URLs = @[ URL ];
69 [appDelegate application:NSApplication.sharedApplication openURLs:URLs];
70
71 EXPECT_EQ([firstDelegate receivedURLs], URLs);
72 EXPECT_EQ([secondDelegate receivedURLs], nil);
73}
Definition dart.idl:68

◆ TEST() [371/709]

flutter::testing::TEST ( FlutterAppDelegateTest  ,
ReceivesOpenURLs   
)

Definition at line 43 of file FlutterAppDelegateTest.mm.

43 {
44 FlutterAppDelegate* appDelegate = [[FlutterAppDelegate alloc] init];
47 [appDelegate addApplicationLifecycleDelegate:delegate];
48
49 NSURL* URL = [NSURL URLWithString:@"https://flutter.dev"];
50 EXPECT_NE(URL, nil);
51 NSArray<NSURL*>* URLs = @[ URL ];
52 [appDelegate application:NSApplication.sharedApplication openURLs:URLs];
53
54 EXPECT_EQ([delegate receivedURLs], URLs);
55}

◆ TEST() [372/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidBecomeActive   
)

Definition at line 109 of file FlutterAppLifecycleDelegateTest.mm.

109 {
112 [registrar addDelegate:delegate];
113
114 NSNotification* didBecomeActive =
115 [NSNotification notificationWithName:NSApplicationDidBecomeActiveNotification object:nil];
116 [registrar handleDidBecomeActive:didBecomeActive];
117 EXPECT_EQ([delegate lastNotification], didBecomeActive);
118}
void addDelegate:(NSObject< FlutterAppLifecycleDelegate > *delegate)
void handleDidBecomeActive:(NSNotification *notification)

◆ TEST() [373/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidChangeOcclusionState   
)

Definition at line 209 of file FlutterAppLifecycleDelegateTest.mm.

209 {
212 [registrar addDelegate:delegate];
213
214 NSNotification* didChangeOcclusionState =
215 [NSNotification notificationWithName:NSApplicationDidChangeOcclusionStateNotification
216 object:nil];
217 if ([registrar respondsToSelector:@selector(handleDidChangeOcclusionState:)]) {
218 [registrar handleDidChangeOcclusionState:didChangeOcclusionState];
219 EXPECT_EQ([delegate lastNotification], didChangeOcclusionState);
220 }
221}
void handleDidChangeOcclusionState:(NSNotification *notification)

◆ TEST() [374/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidChangeScreenParameters   
)

Definition at line 197 of file FlutterAppLifecycleDelegateTest.mm.

197 {
200 [registrar addDelegate:delegate];
201
202 NSNotification* didChangeScreenParameters =
203 [NSNotification notificationWithName:NSApplicationDidChangeScreenParametersNotification
204 object:nil];
205 [registrar handleDidChangeScreenParameters:didChangeScreenParameters];
206 EXPECT_EQ([delegate lastNotification], didChangeScreenParameters);
207}
void handleDidChangeScreenParameters:(NSNotification *notification)

◆ TEST() [375/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidFinishLaunching   
)

Definition at line 87 of file FlutterAppLifecycleDelegateTest.mm.

87 {
90 [registrar addDelegate:delegate];
91
92 NSNotification* didFinishLaunching =
93 [NSNotification notificationWithName:NSApplicationDidFinishLaunchingNotification object:nil];
94 [registrar handleDidFinishLaunching:didFinishLaunching];
95 EXPECT_EQ([delegate lastNotification], didFinishLaunching);
96}
void handleDidFinishLaunching:(NSNotification *notification)

◆ TEST() [376/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidHide   
)

Definition at line 175 of file FlutterAppLifecycleDelegateTest.mm.

175 {
178 [registrar addDelegate:delegate];
179
180 NSNotification* didHide = [NSNotification notificationWithName:NSApplicationDidHideNotification
181 object:nil];
182 [registrar handleDidHide:didHide];
183 EXPECT_EQ([delegate lastNotification], didHide);
184}
void handleDidHide:(NSNotification *notification)

◆ TEST() [377/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidResignActive   
)

Definition at line 131 of file FlutterAppLifecycleDelegateTest.mm.

131 {
134 [registrar addDelegate:delegate];
135
136 NSNotification* didResignActive =
137 [NSNotification notificationWithName:NSApplicationDidResignActiveNotification object:nil];
138 [registrar handleDidResignActive:didResignActive];
139 EXPECT_EQ([delegate lastNotification], didResignActive);
140}
void handleDidResignActive:(NSNotification *notification)

◆ TEST() [378/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToDidUnhide   
)

Definition at line 186 of file FlutterAppLifecycleDelegateTest.mm.

186 {
189 [registrar addDelegate:delegate];
190
191 NSNotification* didUnhide =
192 [NSNotification notificationWithName:NSApplicationDidUnhideNotification object:nil];
193 [registrar handleDidUnhide:didUnhide];
194 EXPECT_EQ([delegate lastNotification], didUnhide);
195}
void handleDidUnhide:(NSNotification *notification)

◆ TEST() [379/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillBecomeActive   
)

Definition at line 98 of file FlutterAppLifecycleDelegateTest.mm.

98 {
101 [registrar addDelegate:delegate];
102
103 NSNotification* willBecomeActive =
104 [NSNotification notificationWithName:NSApplicationWillBecomeActiveNotification object:nil];
105 [registrar handleWillBecomeActive:willBecomeActive];
106 EXPECT_EQ([delegate lastNotification], willBecomeActive);
107}
void handleWillBecomeActive:(NSNotification *notification)

◆ TEST() [380/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillFinishLaunching   
)

Definition at line 76 of file FlutterAppLifecycleDelegateTest.mm.

76 {
79 [registrar addDelegate:delegate];
80
81 NSNotification* willFinishLaunching =
82 [NSNotification notificationWithName:NSApplicationWillFinishLaunchingNotification object:nil];
83 [registrar handleWillFinishLaunching:willFinishLaunching];
84 EXPECT_EQ([delegate lastNotification], willFinishLaunching);
85}
void handleWillFinishLaunching:(NSNotification *notification)

◆ TEST() [381/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillHide   
)

Definition at line 153 of file FlutterAppLifecycleDelegateTest.mm.

153 {
156 [registrar addDelegate:delegate];
157
158 NSNotification* willHide = [NSNotification notificationWithName:NSApplicationWillHideNotification
159 object:nil];
160 [registrar handleWillHide:willHide];
161 EXPECT_EQ([delegate lastNotification], willHide);
162}
void handleWillHide:(NSNotification *notification)

◆ TEST() [382/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillResignActive   
)

Definition at line 120 of file FlutterAppLifecycleDelegateTest.mm.

120 {
123 [registrar addDelegate:delegate];
124
125 NSNotification* willResignActive =
126 [NSNotification notificationWithName:NSApplicationWillResignActiveNotification object:nil];
127 [registrar handleWillResignActive:willResignActive];
128 EXPECT_EQ([delegate lastNotification], willResignActive);
129}
void handleWillResignActive:(NSNotification *notification)

◆ TEST() [383/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillTerminate   
)

Definition at line 142 of file FlutterAppLifecycleDelegateTest.mm.

142 {
145 [registrar addDelegate:delegate];
146
147 NSNotification* applicationWillTerminate =
148 [NSNotification notificationWithName:NSApplicationWillTerminateNotification object:nil];
149 [registrar handleWillTerminate:applicationWillTerminate];
150 EXPECT_EQ([delegate lastNotification], applicationWillTerminate);
151}
void handleWillTerminate:(NSNotification *notification)

◆ TEST() [384/709]

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
RespondsToWillUnhide   
)

Definition at line 164 of file FlutterAppLifecycleDelegateTest.mm.

164 {
167 [registrar addDelegate:delegate];
168
169 NSNotification* willUnhide =
170 [NSNotification notificationWithName:NSApplicationWillUnhideNotification object:nil];
171 [registrar handleWillUnhide:willUnhide];
172 EXPECT_EQ([delegate lastNotification], willUnhide);
173}
void handleWillUnhide:(NSNotification *notification)

◆ TEST() [385/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
BasicKeyEvent   
)

Definition at line 118 of file FlutterEmbedderKeyResponderTest.mm.

118 {
119 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
120 __block BOOL last_handled = TRUE;
122
124 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
125 void* _Nullable user_data) {
126 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
127 callback:callback
128 userData:user_data]];
129 }];
130
131 last_handled = FALSE;
132 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 123.0f, 0x100, @"a", @"a", FALSE, 0)
133 callback:^(BOOL handled) {
134 last_handled = handled;
135 }];
136
137 EXPECT_EQ([events count], 1u);
138 event = [events lastObject].data;
139 ASSERT_NE(event, nullptr);
140 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
141 EXPECT_EQ(event->timestamp, 123000000.0f);
142 EXPECT_EQ(event->physical, kPhysicalKeyA);
143 EXPECT_EQ(event->logical, kLogicalKeyA);
144 EXPECT_STREQ(event->character, "a");
145 EXPECT_EQ(event->synthesized, false);
146
147 EXPECT_EQ(last_handled, FALSE);
148 EXPECT_TRUE([[events lastObject] hasCallback]);
149 [[events lastObject] respond:TRUE];
150 EXPECT_EQ(last_handled, TRUE);
151
152 [events removeAllObjects];
153
154 last_handled = FALSE;
155 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", TRUE, kKeyCodeKeyA)
156 callback:^(BOOL handled) {
157 last_handled = handled;
158 }];
159
160 EXPECT_EQ([events count], 1u);
161 event = [events lastObject].data;
162 ASSERT_NE(event, nullptr);
163 EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
164 EXPECT_EQ(event->physical, kPhysicalKeyA);
165 EXPECT_EQ(event->logical, kLogicalKeyA);
166 EXPECT_STREQ(event->character, "a");
167 EXPECT_EQ(event->synthesized, false);
168
169 EXPECT_EQ(last_handled, FALSE);
170 EXPECT_TRUE([[events lastObject] hasCallback]);
171 [[events lastObject] respond:TRUE];
172 EXPECT_EQ(last_handled, TRUE);
173
174 [events removeAllObjects];
175
176 last_handled = TRUE;
177 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 124.0f, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
178 callback:^(BOOL handled) {
179 last_handled = handled;
180 }];
181
182 EXPECT_EQ([events count], 1u);
183 event = [events lastObject].data;
184 ASSERT_NE(event, nullptr);
185 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
186 EXPECT_EQ(event->timestamp, 124000000.0f);
187 EXPECT_EQ(event->physical, kPhysicalKeyA);
188 EXPECT_EQ(event->logical, kLogicalKeyA);
189 EXPECT_EQ(event->character, nullptr);
190 EXPECT_EQ(event->synthesized, false);
191
192 EXPECT_EQ(last_handled, TRUE);
193 EXPECT_TRUE([[events lastObject] hasCallback]);
194 [[events lastObject] respond:FALSE]; // Check if responding FALSE works
195 EXPECT_EQ(last_handled, FALSE);
196
197 [events removeAllObjects];
198}
@ kFlutterKeyEventTypeDown
Definition embedder.h:1074
@ kFlutterKeyEventTypeUp
Definition embedder.h:1073
@ kFlutterKeyEventTypeRepeat
Definition embedder.h:1075
void handleEvent:callback:(NSEvent *event, [callback] FlutterAsyncKeyCallback callback)
return FALSE
int BOOL

◆ TEST() [386/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
ConvertAbruptRepeatEventsToDown   
)

Definition at line 410 of file FlutterEmbedderKeyResponderTest.mm.

410 {
411 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
412 __block BOOL last_handled = TRUE;
414
416 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
417 void* _Nullable user_data) {
418 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
419 callback:callback
420 userData:user_data]];
421 }];
422
423 last_handled = TRUE;
424 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", TRUE, kKeyCodeKeyA)
425 callback:^(BOOL handled) {
426 last_handled = handled;
427 }];
428
429 EXPECT_EQ([events count], 1u);
430 event = [events lastObject].data;
431 ASSERT_NE(event, nullptr);
432 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
433 EXPECT_EQ(event->physical, kPhysicalKeyA);
434 EXPECT_EQ(event->logical, kLogicalKeyA);
435 EXPECT_STREQ(event->character, "a");
436 EXPECT_EQ(event->synthesized, false);
437 EXPECT_EQ(last_handled, TRUE);
438 [[events lastObject] respond:FALSE];
439 EXPECT_EQ(last_handled, FALSE);
440
441 [events removeAllObjects];
442}

◆ TEST() [387/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
ConvertCapsLockEvents   
)

Definition at line 1100 of file FlutterEmbedderKeyResponderTest.mm.

1100 {
1101 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1102 __block BOOL last_handled = TRUE;
1103 id keyEventCallback = ^(BOOL handled) {
1104 last_handled = handled;
1105 };
1107
1109 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1110 void* _Nullable user_data) {
1111 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1112 callback:callback
1113 userData:user_data]];
1114 }];
1115
1116 // In: CapsLock down
1117 // Out: CapsLock down & *CapsLock Up
1118 last_handled = FALSE;
1119 [responder
1120 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x10100, @"", @"", FALSE, kKeyCodeCapsLock)
1121 callback:keyEventCallback];
1122
1123 EXPECT_EQ([events count], 2u);
1124
1125 event = [events firstObject].data;
1126 ASSERT_NE(event, nullptr);
1127 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1128 EXPECT_EQ(event->physical, kPhysicalCapsLock);
1129 EXPECT_EQ(event->logical, kLogicalCapsLock);
1130 EXPECT_STREQ(event->character, nullptr);
1131 EXPECT_EQ(event->synthesized, false);
1132 EXPECT_TRUE([[events firstObject] hasCallback]);
1133
1134 event = [events lastObject].data;
1135 ASSERT_NE(event, nullptr);
1136 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1137 EXPECT_EQ(event->physical, kPhysicalCapsLock);
1138 EXPECT_EQ(event->logical, kLogicalCapsLock);
1139 EXPECT_STREQ(event->character, nullptr);
1140 EXPECT_EQ(event->synthesized, true);
1141 EXPECT_FALSE([[events lastObject] hasCallback]);
1142
1143 EXPECT_EQ(last_handled, FALSE);
1144 [[events firstObject] respond:TRUE];
1145 EXPECT_EQ(last_handled, TRUE);
1146
1147 [events removeAllObjects];
1148
1149 // In: CapsLock up
1150 // Out: CapsLock down & *CapsLock Up
1151 last_handled = FALSE;
1152 [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeCapsLock)
1153 callback:keyEventCallback];
1154
1155 EXPECT_EQ([events count], 2u);
1156
1157 event = [events firstObject].data;
1158 ASSERT_NE(event, nullptr);
1159 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1160 EXPECT_EQ(event->physical, kPhysicalCapsLock);
1161 EXPECT_EQ(event->logical, kLogicalCapsLock);
1162 EXPECT_STREQ(event->character, nullptr);
1163 EXPECT_EQ(event->synthesized, false);
1164 EXPECT_TRUE([[events firstObject] hasCallback]);
1165
1166 event = [events lastObject].data;
1167 ASSERT_NE(event, nullptr);
1168 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1169 EXPECT_EQ(event->physical, kPhysicalCapsLock);
1170 EXPECT_EQ(event->logical, kLogicalCapsLock);
1171 EXPECT_STREQ(event->character, nullptr);
1172 EXPECT_EQ(event->synthesized, true);
1173 EXPECT_FALSE([[events lastObject] hasCallback]);
1174
1175 EXPECT_EQ(last_handled, FALSE);
1176 [[events firstObject] respond:TRUE];
1177 EXPECT_EQ(last_handled, TRUE);
1178
1179 [events removeAllObjects];
1180}

◆ TEST() [388/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
IdentifyLeftAndRightModifiers   
)

Definition at line 720 of file FlutterEmbedderKeyResponderTest.mm.

720 {
721 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
723
725 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
726 void* _Nullable user_data) {
727 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
728 callback:callback
729 userData:user_data]];
730 }];
731
732 [responder
733 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
734 callback:^(BOOL handled){
735 }];
736
737 EXPECT_EQ([events count], 1u);
738 event = [events lastObject].data;
739 ASSERT_NE(event, nullptr);
740 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
741 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
742 EXPECT_EQ(event->logical, kLogicalShiftLeft);
743 EXPECT_STREQ(event->character, nullptr);
744 EXPECT_EQ(event->synthesized, false);
745 [[events lastObject] respond:TRUE];
746
747 [events removeAllObjects];
748
749 [responder
750 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20106, @"", @"", FALSE, kKeyCodeShiftRight)
751 callback:^(BOOL handled){
752 }];
753
754 EXPECT_EQ([events count], 1u);
755 event = [events lastObject].data;
756 ASSERT_NE(event, nullptr);
757 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
758 EXPECT_EQ(event->physical, kPhysicalShiftRight);
759 EXPECT_EQ(event->logical, kLogicalShiftRight);
760 EXPECT_STREQ(event->character, nullptr);
761 EXPECT_EQ(event->synthesized, false);
762 [[events lastObject] respond:TRUE];
763
764 [events removeAllObjects];
765
766 [responder
767 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20104, @"", @"", FALSE, kKeyCodeShiftLeft)
768 callback:^(BOOL handled){
769 }];
770
771 EXPECT_EQ([events count], 1u);
772 event = [events lastObject].data;
773 ASSERT_NE(event, nullptr);
774 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
775 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
776 EXPECT_EQ(event->logical, kLogicalShiftLeft);
777 EXPECT_STREQ(event->character, nullptr);
778 EXPECT_EQ(event->synthesized, false);
779 [[events lastObject] respond:TRUE];
780
781 [events removeAllObjects];
782
783 [responder
784 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
785 callback:^(BOOL handled){
786 }];
787
788 EXPECT_EQ([events count], 1u);
789 event = [events lastObject].data;
790 ASSERT_NE(event, nullptr);
791 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
792 EXPECT_EQ(event->physical, kPhysicalShiftRight);
793 EXPECT_EQ(event->logical, kLogicalShiftRight);
794 EXPECT_STREQ(event->character, nullptr);
795 EXPECT_EQ(event->synthesized, false);
796 [[events lastObject] respond:TRUE];
797
798 [events removeAllObjects];
799}

◆ TEST() [389/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
IgnoreDuplicateUpEvent   
)

Definition at line 379 of file FlutterEmbedderKeyResponderTest.mm.

379 {
380 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
382 __block BOOL last_handled = TRUE;
383
385 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
386 void* _Nullable user_data) {
387 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
388 callback:callback
389 userData:user_data]];
390 }];
391
392 last_handled = FALSE;
393 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
394 callback:^(BOOL handled) {
395 last_handled = handled;
396 }];
397
398 EXPECT_EQ([events count], 1u);
399 EXPECT_EQ(last_handled, TRUE);
400 event = [events lastObject].data;
401 ASSERT_NE(event, nullptr);
402 EXPECT_EQ(event->physical, 0ull);
403 EXPECT_EQ(event->logical, 0ull);
404 EXPECT_FALSE([[events lastObject] hasCallback]);
405 EXPECT_EQ(last_handled, TRUE);
406
407 [events removeAllObjects];
408}

◆ TEST() [390/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
MultipleCharacters   
)

Definition at line 274 of file FlutterEmbedderKeyResponderTest.mm.

274 {
275 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
277
279 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
280 void* _Nullable user_data) {
281 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
282 callback:callback
283 userData:user_data]];
284 }];
285
286 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0, @"àn", @"àn", FALSE, kKeyCodeKeyA)
287 callback:^(BOOL handled){
288 }];
289
290 EXPECT_EQ([events count], 1u);
291 event = [events lastObject].data;
292 ASSERT_NE(event, nullptr);
293 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
294 EXPECT_EQ(event->physical, kPhysicalKeyA);
295 EXPECT_EQ(event->logical, 0x1400000000ull);
296 EXPECT_STREQ(event->character, "àn");
297 EXPECT_EQ(event->synthesized, false);
298
299 [events removeAllObjects];
300
301 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0, @"a", @"a", FALSE, kKeyCodeKeyA)
302 callback:^(BOOL handled){
303 }];
304
305 EXPECT_EQ([events count], 1u);
306 event = [events lastObject].data;
307 ASSERT_NE(event, nullptr);
308 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
309 EXPECT_EQ(event->physical, kPhysicalKeyA);
310 EXPECT_EQ(event->logical, 0x1400000000ull);
311 EXPECT_STREQ(event->character, nullptr);
312 EXPECT_EQ(event->synthesized, false);
313
314 [events removeAllObjects];
315}

◆ TEST() [391/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
NonAsciiCharacters   
)

Definition at line 200 of file FlutterEmbedderKeyResponderTest.mm.

200 {
201 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
203
205 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
206 void* _Nullable user_data) {
207 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
208 callback:callback
209 userData:user_data]];
210 }];
211
212 [responder
213 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x80140, @"", @"", FALSE, kKeyCodeAltRight)
214 callback:^(BOOL handled){
215 }];
216
217 EXPECT_EQ([events count], 1u);
218 event = [events lastObject].data;
219 ASSERT_NE(event, nullptr);
220 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
221 EXPECT_EQ(event->physical, kPhysicalAltRight);
222 EXPECT_EQ(event->logical, kLogicalAltRight);
223 EXPECT_STREQ(event->character, nullptr);
224 EXPECT_EQ(event->synthesized, false);
225
226 [events removeAllObjects];
227
228 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x80140, @"∑", @"w", FALSE, kKeyCodeKeyW)
229 callback:^(BOOL handled){
230 }];
231
232 EXPECT_EQ([events count], 1u);
233 event = [events lastObject].data;
234 ASSERT_NE(event, nullptr);
235 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
236 EXPECT_EQ(event->physical, kPhysicalKeyW);
237 EXPECT_EQ(event->logical, kLogicalKeyW);
238 EXPECT_STREQ(event->character, "∑");
239 EXPECT_EQ(event->synthesized, false);
240
241 [events removeAllObjects];
242
243 [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeAltRight)
244 callback:^(BOOL handled){
245 }];
246
247 EXPECT_EQ([events count], 1u);
248 event = [events lastObject].data;
249 ASSERT_NE(event, nullptr);
250 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
251 EXPECT_EQ(event->physical, kPhysicalAltRight);
252 EXPECT_EQ(event->logical, kLogicalAltRight);
253 EXPECT_STREQ(event->character, nullptr);
254 EXPECT_EQ(event->synthesized, false);
255
256 [events removeAllObjects];
257
258 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"w", @"w", FALSE, kKeyCodeKeyW)
259 callback:^(BOOL handled){
260 }];
261
262 EXPECT_EQ([events count], 1u);
263 event = [events lastObject].data;
264 ASSERT_NE(event, nullptr);
265 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
266 EXPECT_EQ(event->physical, kPhysicalKeyW);
267 EXPECT_EQ(event->logical, kLogicalKeyW);
268 EXPECT_STREQ(event->character, nullptr);
269 EXPECT_EQ(event->synthesized, false);
270
271 [events removeAllObjects];
272}

◆ TEST() [392/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SpecialModiferFlags   
)

Definition at line 564 of file FlutterEmbedderKeyResponderTest.mm.

564 {
565 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
567
569 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
570 void* _Nullable user_data) {
571 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
572 callback:callback
573 userData:user_data]];
574 }];
575
576 // Keydown: Numpad1, F1, KeyA, ShiftLeft
577 // Then KeyUp: Numpad1, F1, KeyA, ShiftLeft
578
579 // Numpad 1
580 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x200100, @"1", @"1", FALSE, kKeyCodeNumpad1)
581 callback:^(BOOL handled){
582 }];
583
584 EXPECT_EQ([events count], 1u);
585 event = [events lastObject].data;
586 ASSERT_NE(event, nullptr);
587 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
588 EXPECT_EQ(event->physical, kPhysicalNumpad1);
589 EXPECT_EQ(event->logical, kLogicalNumpad1);
590 EXPECT_STREQ(event->character, "1");
591 EXPECT_EQ(event->synthesized, false);
592 [[events lastObject] respond:TRUE];
593
594 [events removeAllObjects];
595
596 // F1
597 [responder
598 handleEvent:keyEvent(NSEventTypeKeyDown, 0x800100, @"\uf704", @"\uf704", FALSE, kKeyCodeF1)
599 callback:^(BOOL handled){
600 }];
601
602 EXPECT_EQ([events count], 1u);
603 event = [events lastObject].data;
604 ASSERT_NE(event, nullptr);
605 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
606 EXPECT_EQ(event->physical, kPhysicalF1);
607 EXPECT_EQ(event->logical, kLogicalF1);
608 EXPECT_STREQ(event->character, nullptr);
609 EXPECT_EQ(event->synthesized, false);
610 [[events lastObject] respond:TRUE];
611
612 [events removeAllObjects];
613
614 // KeyA
615 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
616 callback:^(BOOL handled){
617 }];
618
619 EXPECT_EQ([events count], 1u);
620 event = [events lastObject].data;
621 ASSERT_NE(event, nullptr);
622 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
623 EXPECT_EQ(event->physical, kPhysicalKeyA);
624 EXPECT_EQ(event->logical, kLogicalKeyA);
625 EXPECT_STREQ(event->character, "a");
626 EXPECT_EQ(event->synthesized, false);
627 [[events lastObject] respond:TRUE];
628
629 [events removeAllObjects];
630
631 // ShiftLeft
632 [responder
633 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
634 callback:^(BOOL handled){
635 }];
636
637 EXPECT_EQ([events count], 1u);
638 event = [events lastObject].data;
639 ASSERT_NE(event, nullptr);
640 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
641 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
642 EXPECT_EQ(event->logical, kLogicalShiftLeft);
643 EXPECT_STREQ(event->character, nullptr);
644 EXPECT_EQ(event->synthesized, false);
645 [[events lastObject] respond:TRUE];
646
647 [events removeAllObjects];
648
649 // Numpad 1
650 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x220102, @"1", @"1", FALSE, kKeyCodeNumpad1)
651 callback:^(BOOL handled){
652 }];
653
654 EXPECT_EQ([events count], 1u);
655 event = [events lastObject].data;
656 ASSERT_NE(event, nullptr);
657 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
658 EXPECT_EQ(event->physical, kPhysicalNumpad1);
659 EXPECT_EQ(event->logical, kLogicalNumpad1);
660 EXPECT_STREQ(event->character, nullptr);
661 EXPECT_EQ(event->synthesized, false);
662 [[events lastObject] respond:TRUE];
663
664 [events removeAllObjects];
665
666 // F1
667 [responder
668 handleEvent:keyEvent(NSEventTypeKeyUp, 0x820102, @"\uF704", @"\uF704", FALSE, kKeyCodeF1)
669 callback:^(BOOL handled){
670 }];
671
672 EXPECT_EQ([events count], 1u);
673 event = [events lastObject].data;
674 ASSERT_NE(event, nullptr);
675 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
676 EXPECT_EQ(event->physical, kPhysicalF1);
677 EXPECT_EQ(event->logical, kLogicalF1);
678 EXPECT_STREQ(event->character, nullptr);
679 EXPECT_EQ(event->synthesized, false);
680 [[events lastObject] respond:TRUE];
681
682 [events removeAllObjects];
683
684 // KeyA
685 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x20102, @"a", @"a", FALSE, kKeyCodeKeyA)
686 callback:^(BOOL handled){
687 }];
688
689 EXPECT_EQ([events count], 1u);
690 event = [events lastObject].data;
691 ASSERT_NE(event, nullptr);
692 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
693 EXPECT_EQ(event->physical, kPhysicalKeyA);
694 EXPECT_EQ(event->logical, kLogicalKeyA);
695 EXPECT_STREQ(event->character, nullptr);
696 EXPECT_EQ(event->synthesized, false);
697 [[events lastObject] respond:TRUE];
698
699 [events removeAllObjects];
700
701 // ShiftLeft
702 [responder
703 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftLeft)
704 callback:^(BOOL handled){
705 }];
706
707 EXPECT_EQ([events count], 1u);
708 event = [events lastObject].data;
709 ASSERT_NE(event, nullptr);
710 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
711 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
712 EXPECT_EQ(event->logical, kLogicalShiftLeft);
713 EXPECT_STREQ(event->character, nullptr);
714 EXPECT_EQ(event->synthesized, false);
715 [[events lastObject] respond:TRUE];
716
717 [events removeAllObjects];
718}

◆ TEST() [393/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynchronizeCapsLockStateOnCapsLock   
)

Definition at line 1183 of file FlutterEmbedderKeyResponderTest.mm.

1183 {
1184 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1186 __block BOOL last_handled = TRUE;
1187 id keyEventCallback = ^(BOOL handled) {
1188 last_handled = handled;
1189 };
1190
1192 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1193 void* _Nullable user_data) {
1194 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1195 callback:callback
1196 userData:user_data]];
1197 }];
1198
1199 // In: CapsLock down
1200 // Out: (empty)
1201 last_handled = FALSE;
1202 [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeCapsLock)
1203 callback:keyEventCallback];
1204
1205 EXPECT_EQ([events count], 1u);
1206 EXPECT_EQ(last_handled, TRUE);
1207 event = [events lastObject].data;
1208 ASSERT_NE(event, nullptr);
1209 EXPECT_EQ(event->physical, 0ull);
1210 EXPECT_EQ(event->logical, 0ull);
1211 EXPECT_FALSE([[events lastObject] hasCallback]);
1212 EXPECT_EQ(last_handled, TRUE);
1213
1214 [events removeAllObjects];
1215}

◆ TEST() [394/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynchronizeCapsLockStateOnNormalKey   
)

Definition at line 1218 of file FlutterEmbedderKeyResponderTest.mm.

1218 {
1219 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1220 __block BOOL last_handled = TRUE;
1221 id keyEventCallback = ^(BOOL handled) {
1222 last_handled = handled;
1223 };
1225
1227 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1228 void* _Nullable user_data) {
1229 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1230 callback:callback
1231 userData:user_data]];
1232 }];
1233
1234 last_handled = FALSE;
1235 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x10100, @"A", @"a", FALSE, kKeyCodeKeyA)
1236 callback:keyEventCallback];
1237
1238 EXPECT_EQ([events count], 3u);
1239
1240 event = events[0].data;
1241 ASSERT_NE(event, nullptr);
1242 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1243 EXPECT_EQ(event->physical, kPhysicalCapsLock);
1244 EXPECT_EQ(event->logical, kLogicalCapsLock);
1245 EXPECT_STREQ(event->character, nullptr);
1246 EXPECT_EQ(event->synthesized, true);
1247 EXPECT_FALSE([events[0] hasCallback]);
1248
1249 event = events[1].data;
1250 ASSERT_NE(event, nullptr);
1251 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1252 EXPECT_EQ(event->physical, kPhysicalCapsLock);
1253 EXPECT_EQ(event->logical, kLogicalCapsLock);
1254 EXPECT_STREQ(event->character, nullptr);
1255 EXPECT_EQ(event->synthesized, true);
1256 EXPECT_FALSE([events[1] hasCallback]);
1257
1258 event = events[2].data;
1259 ASSERT_NE(event, nullptr);
1260 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1261 EXPECT_EQ(event->physical, kPhysicalKeyA);
1262 EXPECT_EQ(event->logical, kLogicalKeyA);
1263 EXPECT_STREQ(event->character, "A");
1264 EXPECT_EQ(event->synthesized, false);
1265 EXPECT_TRUE([events[2] hasCallback]);
1266
1267 EXPECT_EQ(last_handled, FALSE);
1268 [[events lastObject] respond:TRUE];
1269 EXPECT_EQ(last_handled, TRUE);
1270
1271 [events removeAllObjects];
1272}

◆ TEST() [395/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynthesizeForDuplicateDownEvent   
)

Definition at line 317 of file FlutterEmbedderKeyResponderTest.mm.

317 {
318 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
319 __block BOOL last_handled = TRUE;
321
323 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
324 void* _Nullable user_data) {
325 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
326 callback:callback
327 userData:user_data]];
328 }];
329
330 last_handled = TRUE;
331 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
332 callback:^(BOOL handled) {
333 last_handled = handled;
334 }];
335
336 EXPECT_EQ([events count], 1u);
337 event = [events lastObject].data;
338 ASSERT_NE(event, nullptr);
339 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
340 EXPECT_EQ(event->physical, kPhysicalKeyA);
341 EXPECT_EQ(event->logical, kLogicalKeyA);
342 EXPECT_STREQ(event->character, "a");
343 EXPECT_EQ(event->synthesized, false);
344 EXPECT_EQ(last_handled, TRUE);
345 [[events lastObject] respond:FALSE];
346 EXPECT_EQ(last_handled, FALSE);
347
348 [events removeAllObjects];
349
350 last_handled = TRUE;
351 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"à", @"à", FALSE, kKeyCodeKeyA)
352 callback:^(BOOL handled) {
353 last_handled = handled;
354 }];
355
356 EXPECT_EQ([events count], 2u);
357
358 event = [events firstObject].data;
359 ASSERT_NE(event, nullptr);
360 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
361 EXPECT_EQ(event->physical, kPhysicalKeyA);
362 EXPECT_EQ(event->logical, kLogicalKeyA);
363 EXPECT_STREQ(event->character, NULL);
364 EXPECT_EQ(event->synthesized, true);
365
366 event = [events lastObject].data;
367 ASSERT_NE(event, nullptr);
368 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
369 EXPECT_EQ(event->physical, kPhysicalKeyA);
370 EXPECT_EQ(event->logical, 0xE0ull /* à */);
371 EXPECT_STREQ(event->character, "à");
372 EXPECT_EQ(event->synthesized, false);
373 [[events lastObject] respond:FALSE];
374 EXPECT_EQ(last_handled, FALSE);
375
376 [events removeAllObjects];
377}

◆ TEST() [396/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynthesizeMissedModifierEvents   
)

Definition at line 806 of file FlutterEmbedderKeyResponderTest.mm.

806 {
807 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
808 __block BOOL last_handled = TRUE;
809 id keyEventCallback = ^(BOOL handled) {
810 last_handled = handled;
811 };
813
815 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
816 void* _Nullable user_data) {
817 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
818 callback:callback
819 userData:user_data]];
820 }];
821
822 // Case 1:
823 // In: L down, (L up), L down, L up
824 // Out: L down, L up
825 last_handled = FALSE;
826 [responder
827 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
828 callback:keyEventCallback];
829
830 EXPECT_EQ([events count], 1u);
831 event = [events lastObject].data;
832 ASSERT_NE(event, nullptr);
833 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
834 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
835 EXPECT_EQ(event->logical, kLogicalShiftLeft);
836 EXPECT_STREQ(event->character, nullptr);
837 EXPECT_EQ(event->synthesized, false);
838
839 EXPECT_EQ(last_handled, FALSE);
840 EXPECT_TRUE([[events lastObject] hasCallback]);
841 [[events lastObject] respond:TRUE];
842 EXPECT_EQ(last_handled, TRUE);
843
844 [events removeAllObjects];
845
846 last_handled = FALSE;
847 [responder
848 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
849 callback:keyEventCallback];
850
851 EXPECT_EQ([events count], 1u);
852 event = [events lastObject].data;
853 ASSERT_NE(event, nullptr);
854 EXPECT_EQ(event->physical, 0u);
855 EXPECT_EQ(event->logical, 0u);
856 EXPECT_FALSE([[events lastObject] hasCallback]);
857 EXPECT_EQ(last_handled, TRUE);
858 [events removeAllObjects];
859
860 last_handled = FALSE;
861 [responder
862 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftLeft)
863 callback:keyEventCallback];
864
865 EXPECT_EQ([events count], 1u);
866 event = [events lastObject].data;
867 ASSERT_NE(event, nullptr);
868 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
869 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
870 EXPECT_EQ(event->logical, kLogicalShiftLeft);
871 EXPECT_STREQ(event->character, nullptr);
872 EXPECT_EQ(event->synthesized, false);
873
874 EXPECT_EQ(last_handled, FALSE);
875 EXPECT_TRUE([[events lastObject] hasCallback]);
876 [[events lastObject] respond:TRUE];
877 EXPECT_EQ(last_handled, TRUE);
878
879 [events removeAllObjects];
880
881 // Case 2:
882 // In: (L down), L up
883 // Out:
884
885 last_handled = FALSE;
886 [responder
887 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftLeft)
888 callback:keyEventCallback];
889
890 EXPECT_EQ([events count], 1u);
891 event = [events lastObject].data;
892 ASSERT_NE(event, nullptr);
893 EXPECT_EQ(event->physical, 0u);
894 EXPECT_EQ(event->logical, 0u);
895 EXPECT_FALSE([[events lastObject] hasCallback]);
896 EXPECT_EQ(last_handled, TRUE);
897 [events removeAllObjects];
898
899 // Case 3:
900 // In: L down, (L up), (R down), R up
901 // Out: L down, *L up
902
903 last_handled = FALSE;
904 [responder
905 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
906 callback:keyEventCallback];
907
908 EXPECT_EQ([events count], 1u);
909 event = [events lastObject].data;
910 ASSERT_NE(event, nullptr);
911 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
912 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
913 EXPECT_EQ(event->logical, kLogicalShiftLeft);
914 EXPECT_STREQ(event->character, nullptr);
915 EXPECT_EQ(event->synthesized, false);
916
917 EXPECT_EQ(last_handled, FALSE);
918 EXPECT_TRUE([[events lastObject] hasCallback]);
919 [[events lastObject] respond:TRUE];
920 EXPECT_EQ(last_handled, TRUE);
921
922 [events removeAllObjects];
923
924 last_handled = FALSE;
925 [responder
926 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
927 callback:keyEventCallback];
928
929 EXPECT_EQ([events count], 1u);
930 event = [events lastObject].data;
931 ASSERT_NE(event, nullptr);
932 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
933 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
934 EXPECT_EQ(event->logical, kLogicalShiftLeft);
935 EXPECT_STREQ(event->character, nullptr);
936 EXPECT_EQ(event->synthesized, true);
937
938 // The primary event is automatically replied with TRUE, unrelated to the received event.
939 EXPECT_EQ(last_handled, TRUE);
940 EXPECT_FALSE([[events lastObject] hasCallback]);
941
942 [events removeAllObjects];
943
944 // Case 4:
945 // In: L down, R down, (L up), R up
946 // Out: L down, R down *L up & R up
947
948 last_handled = FALSE;
949 [responder
950 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", FALSE, kKeyCodeShiftLeft)
951 callback:keyEventCallback];
952
953 EXPECT_EQ([events count], 1u);
954 event = [events lastObject].data;
955 ASSERT_NE(event, nullptr);
956 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
957 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
958 EXPECT_EQ(event->logical, kLogicalShiftLeft);
959 EXPECT_STREQ(event->character, nullptr);
960 EXPECT_EQ(event->synthesized, false);
961
962 EXPECT_EQ(last_handled, FALSE);
963 EXPECT_TRUE([[events lastObject] hasCallback]);
964 [[events lastObject] respond:TRUE];
965 EXPECT_EQ(last_handled, TRUE);
966
967 [events removeAllObjects];
968
969 last_handled = FALSE;
970 [responder
971 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x20106, @"", @"", FALSE, kKeyCodeShiftRight)
972 callback:keyEventCallback];
973
974 EXPECT_EQ([events count], 1u);
975 event = [events lastObject].data;
976 ASSERT_NE(event, nullptr);
977 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
978 EXPECT_EQ(event->physical, kPhysicalShiftRight);
979 EXPECT_EQ(event->logical, kLogicalShiftRight);
980 EXPECT_STREQ(event->character, nullptr);
981 EXPECT_EQ(event->synthesized, false);
982
983 EXPECT_EQ(last_handled, FALSE);
984 EXPECT_TRUE([[events lastObject] hasCallback]);
985 [[events lastObject] respond:TRUE];
986 EXPECT_EQ(last_handled, TRUE);
987
988 [events removeAllObjects];
989
990 last_handled = FALSE;
991 [responder
992 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
993 callback:keyEventCallback];
994
995 EXPECT_EQ([events count], 2u);
996 event = [events firstObject].data;
997 ASSERT_NE(event, nullptr);
998 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
999 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
1000 EXPECT_EQ(event->logical, kLogicalShiftLeft);
1001 EXPECT_STREQ(event->character, nullptr);
1002 EXPECT_EQ(event->synthesized, true);
1003
1004 EXPECT_FALSE([[events firstObject] hasCallback]);
1005
1006 event = [events lastObject].data;
1007 ASSERT_NE(event, nullptr);
1008 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1009 EXPECT_EQ(event->physical, kPhysicalShiftRight);
1010 EXPECT_EQ(event->logical, kLogicalShiftRight);
1011 EXPECT_STREQ(event->character, nullptr);
1012 EXPECT_EQ(event->synthesized, false);
1013
1014 EXPECT_EQ(last_handled, FALSE);
1015 EXPECT_TRUE([[events lastObject] hasCallback]);
1016 [[events lastObject] respond:TRUE];
1017 EXPECT_EQ(last_handled, TRUE);
1018
1019 [events removeAllObjects];
1020}

◆ TEST() [397/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
SynthesizeMissedModifierEventsInNormalEvents   
)

Definition at line 1022 of file FlutterEmbedderKeyResponderTest.mm.

1022 {
1023 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
1024 __block BOOL last_handled = TRUE;
1025 id keyEventCallback = ^(BOOL handled) {
1026 last_handled = handled;
1027 };
1029
1031 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
1032 void* _Nullable user_data) {
1033 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
1034 callback:callback
1035 userData:user_data]];
1036 }];
1037
1038 // In: (LShift down), A down, (LShift up), A up
1039 // Out: *LS down & A down, *LS up & A up
1040
1041 last_handled = FALSE;
1042 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x20102, @"A", @"A", FALSE, kKeyCodeKeyA)
1043 callback:keyEventCallback];
1044
1045 EXPECT_EQ([events count], 2u);
1046 event = [events firstObject].data;
1047 ASSERT_NE(event, nullptr);
1048 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1049 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
1050 EXPECT_EQ(event->logical, kLogicalShiftLeft);
1051 EXPECT_STREQ(event->character, nullptr);
1052 EXPECT_EQ(event->synthesized, true);
1053 EXPECT_FALSE([[events firstObject] hasCallback]);
1054
1055 event = [events lastObject].data;
1056 ASSERT_NE(event, nullptr);
1057 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
1058 EXPECT_EQ(event->physical, kPhysicalKeyA);
1059 EXPECT_EQ(event->logical, kLogicalKeyA);
1060 EXPECT_STREQ(event->character, "A");
1061 EXPECT_EQ(event->synthesized, false);
1062 EXPECT_TRUE([[events lastObject] hasCallback]);
1063
1064 EXPECT_EQ(last_handled, FALSE);
1065 [[events lastObject] respond:TRUE];
1066 EXPECT_EQ(last_handled, TRUE);
1067
1068 [events removeAllObjects];
1069
1070 last_handled = FALSE;
1071 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
1072 callback:keyEventCallback];
1073
1074 EXPECT_EQ([events count], 2u);
1075 event = [events firstObject].data;
1076 ASSERT_NE(event, nullptr);
1077 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1078 EXPECT_EQ(event->physical, kPhysicalShiftLeft);
1079 EXPECT_EQ(event->logical, kLogicalShiftLeft);
1080 EXPECT_STREQ(event->character, nullptr);
1081 EXPECT_EQ(event->synthesized, true);
1082 EXPECT_FALSE([[events firstObject] hasCallback]);
1083
1084 event = [events lastObject].data;
1085 ASSERT_NE(event, nullptr);
1086 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
1087 EXPECT_EQ(event->physical, kPhysicalKeyA);
1088 EXPECT_EQ(event->logical, kLogicalKeyA);
1089 EXPECT_STREQ(event->character, nullptr);
1090 EXPECT_EQ(event->synthesized, false);
1091 EXPECT_TRUE([[events lastObject] hasCallback]);
1092
1093 EXPECT_EQ(last_handled, FALSE);
1094 [[events lastObject] respond:TRUE];
1095 EXPECT_EQ(last_handled, TRUE);
1096
1097 [events removeAllObjects];
1098}

◆ TEST() [398/709]

flutter::testing::TEST ( FlutterEmbedderKeyResponderUnittests  ,
ToggleModifiersDuringKeyTap   
)

Definition at line 448 of file FlutterEmbedderKeyResponderTest.mm.

448 {
449 __block NSMutableArray<TestKeyEvent*>* events = [[NSMutableArray<TestKeyEvent*> alloc] init];
451
453 initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback,
454 void* _Nullable user_data) {
455 [events addObject:[[TestKeyEvent alloc] initWithEvent:&event
456 callback:callback
457 userData:user_data]];
458 }];
459
460 [responder handleEvent:keyEvent(NSEventTypeFlagsChanged, 123.0f, 0x20104, @"", @"", FALSE,
461 kKeyCodeShiftRight)
462 callback:^(BOOL handled){
463 }];
464
465 EXPECT_EQ([events count], 1u);
466 event = [events lastObject].data;
467 ASSERT_NE(event, nullptr);
468 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
469 EXPECT_EQ(event->timestamp, 123000000.0f);
470 EXPECT_EQ(event->physical, kPhysicalShiftRight);
471 EXPECT_EQ(event->logical, kLogicalShiftRight);
472 EXPECT_STREQ(event->character, nullptr);
473 EXPECT_EQ(event->synthesized, false);
474 [[events lastObject] respond:TRUE];
475
476 [events removeAllObjects];
477
478 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x20104, @"A", @"A", FALSE, kKeyCodeKeyA)
479 callback:^(BOOL handled){
480 }];
481
482 EXPECT_EQ([events count], 1u);
483 event = [events lastObject].data;
484 ASSERT_NE(event, nullptr);
485 EXPECT_EQ(event->type, kFlutterKeyEventTypeDown);
486 EXPECT_EQ(event->physical, kPhysicalKeyA);
487 EXPECT_EQ(event->logical, kLogicalKeyA);
488 EXPECT_STREQ(event->character, "A");
489 EXPECT_EQ(event->synthesized, false);
490 [[events lastObject] respond:TRUE];
491
492 [events removeAllObjects];
493
494 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x20104, @"A", @"A", TRUE, kKeyCodeKeyA)
495 callback:^(BOOL handled){
496 }];
497
498 EXPECT_EQ([events count], 1u);
499 event = [events lastObject].data;
500 ASSERT_NE(event, nullptr);
501 EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
502 EXPECT_EQ(event->physical, kPhysicalKeyA);
503 EXPECT_EQ(event->logical, kLogicalKeyA);
504 EXPECT_STREQ(event->character, "A");
505 EXPECT_EQ(event->synthesized, false);
506 [[events lastObject] respond:TRUE];
507
508 [events removeAllObjects];
509
510 [responder
511 handleEvent:keyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", FALSE, kKeyCodeShiftRight)
512 callback:^(BOOL handled){
513 }];
514
515 EXPECT_EQ([events count], 1u);
516 event = [events lastObject].data;
517 ASSERT_NE(event, nullptr);
518 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
519 EXPECT_EQ(event->physical, kPhysicalShiftRight);
520 EXPECT_EQ(event->logical, kLogicalShiftRight);
521 EXPECT_STREQ(event->character, nullptr);
522 EXPECT_EQ(event->synthesized, false);
523 [[events lastObject] respond:TRUE];
524
525 [events removeAllObjects];
526
527 [responder handleEvent:keyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", TRUE, kKeyCodeKeyA)
528 callback:^(BOOL handled){
529 }];
530
531 EXPECT_EQ([events count], 1u);
532 event = [events lastObject].data;
533 ASSERT_NE(event, nullptr);
534 EXPECT_EQ(event->type, kFlutterKeyEventTypeRepeat);
535 EXPECT_EQ(event->physical, kPhysicalKeyA);
536 EXPECT_EQ(event->logical, kLogicalKeyA);
537 EXPECT_STREQ(event->character, "a");
538 EXPECT_EQ(event->synthesized, false);
539
540 [events removeAllObjects];
541
542 [responder handleEvent:keyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", FALSE, kKeyCodeKeyA)
543 callback:^(BOOL handled){
544 }];
545
546 EXPECT_EQ([events count], 1u);
547 event = [events lastObject].data;
548 ASSERT_NE(event, nullptr);
549 EXPECT_EQ(event->type, kFlutterKeyEventTypeUp);
550 EXPECT_EQ(event->physical, kPhysicalKeyA);
551 EXPECT_EQ(event->logical, kLogicalKeyA);
552 EXPECT_STREQ(event->character, nullptr);
553 EXPECT_EQ(event->synthesized, false);
554 [[events lastObject] respond:TRUE];
555
556 [events removeAllObjects];
557}

◆ TEST() [399/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
CorrectLogicalKeyForLayouts   
)

Definition at line 462 of file FlutterKeyboardManagerTest.mm.

462 {
463 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] correctLogicalKeyForLayouts]);
464}

◆ TEST() [400/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
DoublePrimaryResponder   
)

Definition at line 438 of file FlutterKeyboardManagerTest.mm.

438 {
439 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] doublePrimaryResponder]);
440}

◆ TEST() [401/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
EmptyNextResponder   
)

Definition at line 446 of file FlutterKeyboardManagerTest.mm.

446 {
447 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] emptyNextResponder]);
448}

◆ TEST() [402/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
GetPressedState   
)

Definition at line 450 of file FlutterKeyboardManagerTest.mm.

450 {
451 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] getPressedState]);
452}

◆ TEST() [403/709]

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

Definition at line 454 of file FlutterKeyboardManagerTest.mm.

454 {
455 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] keyboardChannelGetPressedState]);
456}

◆ TEST() [404/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
RacingConditionBetweenKeyAndText   
)

Definition at line 458 of file FlutterKeyboardManagerTest.mm.

458 {
459 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] racingConditionBetweenKeyAndText]);
460}

◆ TEST() [405/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
ShouldNotHoldStrongReferenceToViewDelegate   
)

Definition at line 466 of file FlutterKeyboardManagerTest.mm.

466 {
467 ASSERT_TRUE(
468 [[FlutterKeyboardManagerUnittestsObjC alloc] shouldNotHoldStrongReferenceToViewDelegate]);
469}

◆ TEST() [406/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
SingleFinalResponder   
)

Definition at line 442 of file FlutterKeyboardManagerTest.mm.

442 {
444}
FlutterTextInputPlugin * textInputPlugin

◆ TEST() [407/709]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
SinglePrimaryResponder   
)

Definition at line 434 of file FlutterKeyboardManagerTest.mm.

434 {
435 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] singlePrimaryResponder]);
436}

◆ TEST() [408/709]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
Basics   
)

Definition at line 32 of file FlutterPlatformNodeDelegateMacTest.mm.

32 {
33 FlutterViewController* viewController = CreateTestViewController();
36 auto bridge = viewController.accessibilityBridge.lock();
37 // Initialize ax node data.
39 root.id = 0;
40 root.flags = static_cast<FlutterSemanticsFlag>(0);
41 ;
42 root.actions = static_cast<FlutterSemanticsAction>(0);
43 root.text_selection_base = -1;
44 root.text_selection_extent = -1;
45 root.label = "accessibility";
46 root.hint = "";
47 root.value = "";
48 root.increased_value = "";
49 root.decreased_value = "";
50 root.tooltip = "";
51 root.child_count = 0;
52 root.custom_accessibility_actions_count = 0;
53 bridge->AddFlutterSemanticsNodeUpdate(root);
54
55 bridge->CommitUpdates();
56
57 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
58 // Verify the accessibility attribute matches.
59 NSAccessibilityElement* native_accessibility =
60 root_platform_node_delegate->GetNativeViewAccessible();
61 std::string value = [native_accessibility.accessibilityValue UTF8String];
62 EXPECT_TRUE(value == "accessibility");
63 EXPECT_EQ(native_accessibility.accessibilityRole, NSAccessibilityStaticTextRole);
64 EXPECT_EQ([native_accessibility.accessibilityChildren count], 0u);
65 [engine shutDownEngine];
66}
std::weak_ptr< flutter::AccessibilityBridgeMac > accessibilityBridge()

◆ TEST() [409/709]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
CanPerformAction   
)

Definition at line 149 of file FlutterPlatformNodeDelegateMacTest.mm.

149 {
150 FlutterViewController* viewController = CreateTestViewController();
152
153 // Attach the view to a NSWindow.
154 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
155 styleMask:NSBorderlessWindowMask
156 backing:NSBackingStoreBuffered
157 defer:NO];
158 window.contentView = viewController.view;
159
160 engine.semanticsEnabled = YES;
161 auto bridge = viewController.accessibilityBridge.lock();
162 // Initialize ax node data.
164 root.id = 0;
165 root.label = "root";
166 root.hint = "";
167 root.value = "";
168 root.increased_value = "";
169 root.decreased_value = "";
170 root.tooltip = "";
171 root.child_count = 1;
172 int32_t children[] = {1};
173 root.children_in_traversal_order = children;
174 root.custom_accessibility_actions_count = 0;
175 bridge->AddFlutterSemanticsNodeUpdate(root);
176
178 child1.id = 1;
179 child1.label = "child 1";
180 child1.hint = "";
181 child1.value = "";
182 child1.increased_value = "";
183 child1.decreased_value = "";
184 child1.tooltip = "";
185 child1.child_count = 0;
187 bridge->AddFlutterSemanticsNodeUpdate(child1);
188
189 bridge->CommitUpdates();
190
191 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
192
193 // Set up embedder API mock.
194 FlutterSemanticsAction called_action;
195 uint64_t called_id;
196
198 DispatchSemanticsAction,
199 ([&called_id, &called_action](auto engine, uint64_t id, FlutterSemanticsAction action,
200 const uint8_t* data, size_t data_length) {
201 called_id = id;
202 called_action = action;
203 return kSuccess;
204 }));
205
206 // Performs an AXAction.
207 ui::AXActionData action_data;
209 root_platform_node_delegate->AccessibilityPerformAction(action_data);
210
212 EXPECT_EQ(called_id, 1u);
213
214 [engine setViewController:nil];
215 [engine shutDownEngine];
216}
FlutterEngineProcTable & embedderAPI()
FlutterEngineDispatchSemanticsActionFnPtr DispatchSemanticsAction
Definition embedder.h:3343
const char * increased_value
Definition embedder.h:1368
const char * tooltip
A textual tooltip attached to the node.
Definition embedder.h:1395
size_t custom_accessibility_actions_count
The number of custom accessibility action associated with this node.
Definition embedder.h:1387
int32_t id
The unique identifier for this node.
Definition embedder.h:1335
const char * decreased_value
Definition embedder.h:1371
const char * label
A textual description of the node.
Definition embedder.h:1361
const char * hint
A brief description of the result of performing an action on the node.
Definition embedder.h:1363
const char * value
A textual description of the current value of the node.
Definition embedder.h:1365
ax::mojom::Action action

◆ TEST() [410/709]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
SelectableTextHasCorrectSemantics   
)

Definition at line 68 of file FlutterPlatformNodeDelegateMacTest.mm.

68 {
69 FlutterViewController* viewController = CreateTestViewController();
72 auto bridge = viewController.accessibilityBridge.lock();
73 // Initialize ax node data.
75 root.id = 0;
76 root.flags =
79 root.actions = static_cast<FlutterSemanticsAction>(0);
80 root.text_selection_base = 1;
81 root.text_selection_extent = 3;
82 root.label = "";
83 root.hint = "";
84 // Selectable text store its text in value
85 root.value = "selectable text";
86 root.increased_value = "";
87 root.decreased_value = "";
88 root.tooltip = "";
89 root.child_count = 0;
90 root.custom_accessibility_actions_count = 0;
91 bridge->AddFlutterSemanticsNodeUpdate(root);
92
93 bridge->CommitUpdates();
94
95 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
96 // Verify the accessibility attribute matches.
97 NSAccessibilityElement* native_accessibility =
98 root_platform_node_delegate->GetNativeViewAccessible();
99 std::string value = [native_accessibility.accessibilityValue UTF8String];
100 EXPECT_EQ(value, "selectable text");
101 EXPECT_EQ(native_accessibility.accessibilityRole, NSAccessibilityStaticTextRole);
102 EXPECT_EQ([native_accessibility.accessibilityChildren count], 0u);
103 NSRange selection = native_accessibility.accessibilitySelectedTextRange;
104 EXPECT_EQ(selection.location, 1u);
105 EXPECT_EQ(selection.length, 2u);
106 std::string selected_text = [native_accessibility.accessibilitySelectedText UTF8String];
107 EXPECT_EQ(selected_text, "el");
108}

◆ TEST() [411/709]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
SelectableTextWithoutSelectionReturnZeroRange   
)

Definition at line 110 of file FlutterPlatformNodeDelegateMacTest.mm.

110 {
111 FlutterViewController* viewController = CreateTestViewController();
114 auto bridge = viewController.accessibilityBridge.lock();
115 // Initialize ax node data.
117 root.id = 0;
118 root.flags =
121 root.actions = static_cast<FlutterSemanticsAction>(0);
122 root.text_selection_base = -1;
123 root.text_selection_extent = -1;
124 root.label = "";
125 root.hint = "";
126 // Selectable text store its text in value
127 root.value = "selectable text";
128 root.increased_value = "";
129 root.decreased_value = "";
130 root.tooltip = "";
131 root.child_count = 0;
132 root.custom_accessibility_actions_count = 0;
133 bridge->AddFlutterSemanticsNodeUpdate(root);
134
135 bridge->CommitUpdates();
136
137 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
138 // Verify the accessibility attribute matches.
139 NSAccessibilityElement* native_accessibility =
140 root_platform_node_delegate->GetNativeViewAccessible();
141 NSRange selection = native_accessibility.accessibilitySelectedTextRange;
142 EXPECT_TRUE(selection.location == NSNotFound);
143 EXPECT_EQ(selection.length, 0u);
144}

◆ TEST() [412/709]

flutter::testing::TEST ( FlutterPlatformNodeDelegateMac  ,
TextFieldUsesFlutterTextField   
)

Definition at line 220 of file FlutterPlatformNodeDelegateMacTest.mm.

220 {
221 FlutterViewController* viewController = CreateTestViewController();
223 [viewController loadView];
224
225 // Unit test localization is unnecessary.
226 // NOLINTNEXTLINE(clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker)
227 viewController.textInputPlugin.string = @"textfield";
228 // Creates a NSWindow so that the native text field can become first responder.
229 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
230 styleMask:NSBorderlessWindowMask
231 backing:NSBackingStoreBuffered
232 defer:NO];
233 window.contentView = viewController.view;
234 engine.semanticsEnabled = YES;
235
236 auto bridge = viewController.accessibilityBridge.lock();
237 // Initialize ax node data.
239 root.id = 0;
240 root.flags = static_cast<FlutterSemanticsFlag>(0);
241 root.actions = static_cast<FlutterSemanticsAction>(0);
242 root.label = "root";
243 root.hint = "";
244 root.value = "";
245 root.increased_value = "";
246 root.decreased_value = "";
247 root.tooltip = "";
248 root.child_count = 1;
249 int32_t children[] = {1};
250 root.children_in_traversal_order = children;
251 root.custom_accessibility_actions_count = 0;
252 root.rect = {0, 0, 100, 100}; // LTRB
253 root.transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
254 bridge->AddFlutterSemanticsNodeUpdate(root);
255
256 double rectSize = 50;
257 double transformFactor = 0.5;
258
260 child1.id = 1;
262 child1.actions = static_cast<FlutterSemanticsAction>(0);
263 child1.label = "";
264 child1.hint = "";
265 child1.value = "textfield";
266 child1.increased_value = "";
267 child1.decreased_value = "";
268 child1.tooltip = "";
269 child1.text_selection_base = -1;
270 child1.text_selection_extent = -1;
271 child1.child_count = 0;
273 child1.rect = {0, 0, rectSize, rectSize}; // LTRB
274 child1.transform = {transformFactor, 0, 0, 0, transformFactor, 0, 0, 0, 1};
275 bridge->AddFlutterSemanticsNodeUpdate(child1);
276
277 bridge->CommitUpdates();
278
279 auto child_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
280 // Verify the accessibility attribute matches.
281 id native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
282 EXPECT_EQ([native_accessibility isKindOfClass:[FlutterTextField class]], YES);
283 FlutterTextField* native_text_field = (FlutterTextField*)native_accessibility;
284
285 NSView* view = viewController.flutterView;
286 CGRect scaledBounds = [view convertRectToBacking:view.bounds];
287 CGSize scaledSize = scaledBounds.size;
288 double pixelRatio = view.bounds.size.width == 0 ? 1 : scaledSize.width / view.bounds.size.width;
289
290 double expectedFrameSize = rectSize * transformFactor / pixelRatio;
291 EXPECT_EQ(NSEqualRects(native_text_field.frame, NSMakeRect(0, 600 - expectedFrameSize,
292 expectedFrameSize, expectedFrameSize)),
293 YES);
294
295 [native_text_field startEditing];
296 EXPECT_EQ([native_text_field.stringValue isEqualToString:@"textfield"], YES);
297}
FlutterTextInputPlugin * textInputPlugin
int32_t text_selection_extent
The position at which the text selection terminates.
Definition embedder.h:1343
FlutterSemanticsAction actions
The set of semantics actions applicable to this node.
Definition embedder.h:1339
FlutterRect rect
The bounding box for this node in its coordinate system.
Definition embedder.h:1376
FlutterTransformation transform
Definition embedder.h:1379
int32_t text_selection_base
The position at which the text selection originates.
Definition embedder.h:1341
FlutterSemanticsFlag flags
The set of semantics flags associated with this node.
Definition embedder.h:1337

◆ TEST() [413/709]

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>();
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
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;
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();
147 child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
149 EXPECT_EQ(bounds.x(), 0);
150 EXPECT_EQ(bounds.y(), 0);
151 EXPECT_EQ(bounds.width(), 25);
152 EXPECT_EQ(bounds.height(), 25);
154}

◆ TEST() [414/709]

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>();
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
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;
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();
193 child1_node->GetBoundsRect(ui::AXCoordinateSystem::kScreenDIPs,
195 EXPECT_EQ(bounds.x(), 180);
196 EXPECT_EQ(bounds.y(), 180);
197 EXPECT_EQ(bounds.width(), 20);
198 EXPECT_EQ(bounds.height(), 20);
200}

◆ TEST() [415/709]

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>();
89 root.id = 0;
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() [416/709]

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>();
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
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;
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() [417/709]

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>();
44 root.id = 0;
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;
65 accessibility->AccessibilityPerformAction(action_data);
66 EXPECT_EQ(bridge->performed_actions.size(), size_t{1});
67 EXPECT_EQ(bridge->performed_actions[0],
69
71 accessibility->AccessibilityPerformAction(action_data);
72 EXPECT_EQ(bridge->performed_actions.size(), size_t{2});
73 EXPECT_EQ(
74 bridge->performed_actions[1],
76
78 accessibility->AccessibilityPerformAction(action_data);
79 EXPECT_EQ(bridge->performed_actions.size(), size_t{3});
80 EXPECT_EQ(bridge->performed_actions[2],
82}
@ kFlutterSemanticsActionShowOnScreen
A request to fully show the semantics node on screen.
Definition embedder.h:138
@ kFlutterSemanticsActionDidGainAccessibilityFocus
Indicate that the node has gained accessibility focus.
Definition embedder.h:152

◆ TEST() [418/709]

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>();
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
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;
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() [419/709]

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.
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.
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() [420/709]

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>();
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() [421/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestAcceptGesture   
)

Definition at line 164 of file FlutterPlatformViewControllerTest.mm.

164 {
165 FlutterPlatformViewController* platformViewController =
166 [[FlutterPlatformViewController alloc] init];
167 [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
168 withId:@"MockPlatformView"];
169
170 // Create the PlatformView.
171 const NSNumber* viewId = [NSNumber numberWithLongLong:2];
172 FlutterMethodCall* methodCallOnCreate = [FlutterMethodCall
173 methodCallWithMethodName:@"create"
174 arguments:@{@"id" : viewId, @"viewType" : @"MockPlatformView"}];
175 __block bool created = false;
176 FlutterResult resultOnCreate = ^(id result) {
177 // If a platform view is successfully created, the result is nil.
178 if (result == nil) {
179 created = true;
180 }
181 };
182 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
183
184 // Call acceptGesture.
185 FlutterMethodCall* methodCallAcceptGesture =
186 [FlutterMethodCall methodCallWithMethodName:@"acceptGesture" arguments:@{@"id" : viewId}];
187 __block bool acceptGestureCalled = false;
188 FlutterResult resultAcceptGesture = ^(id result) {
189 // If a acceptGesture is successful, the result is nil.
190 if (result == nil) {
191 acceptGestureCalled = true;
192 }
193 };
194 [platformViewController handleMethodCall:methodCallAcceptGesture result:resultAcceptGesture];
195
196 EXPECT_TRUE(created);
197 EXPECT_TRUE(acceptGestureCalled);
198}
void(^ FlutterResult)(id _Nullable result)

◆ TEST() [422/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestAcceptGestureOnMissingViewId   
)

Definition at line 200 of file FlutterPlatformViewControllerTest.mm.

200 {
201 FlutterPlatformViewController* platformViewController =
202 [[FlutterPlatformViewController alloc] init];
203 [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
204 withId:@"MockPlatformView"];
205
206 // Call rejectGesture.
207 FlutterMethodCall* methodCallAcceptGesture =
208 [FlutterMethodCall methodCallWithMethodName:@"acceptGesture" arguments:@{
209 @"id" : @20
210 }];
211 __block bool errored = false;
212 FlutterResult result = ^(id result) {
213 if ([result isKindOfClass:[FlutterError class]]) {
214 errored = true;
215 }
216 };
217 [platformViewController handleMethodCall:methodCallAcceptGesture result:result];
218
219 EXPECT_TRUE(errored);
220}

◆ TEST() [423/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestCreateAndDispose   
)

Definition at line 101 of file FlutterPlatformViewControllerTest.mm.

101 {
102 // Use id so we can access handleMethodCall method.
103 id platformViewController = [[FlutterPlatformViewController alloc] init];
104
106
107 [platformViewController registerViewFactory:factory withId:@"MockPlatformView"];
108
109 FlutterMethodCall* methodCallOnCreate =
110 [FlutterMethodCall methodCallWithMethodName:@"create"
111 arguments:@{
112 @"id" : @2,
113 @"viewType" : @"MockPlatformView"
114 }];
115
116 __block bool created = false;
117 FlutterResult resultOnCreate = ^(id result) {
118 // If a platform view is successfully created, the result is nil.
119 if (result == nil) {
120 created = true;
121 }
122 };
123
124 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
125
126 FlutterMethodCall* methodCallOnDispose =
127 [FlutterMethodCall methodCallWithMethodName:@"dispose"
128 arguments:[NSNumber numberWithLongLong:2]];
129
130 __block bool disposed = false;
131 FlutterResult resultOnDispose = ^(id result) {
132 // If a platform view is successfully created, the result is nil.
133 if (result == nil) {
134 disposed = true;
135 }
136 };
137
138 [platformViewController handleMethodCall:methodCallOnDispose result:resultOnDispose];
139
140 EXPECT_TRUE(created);
141 EXPECT_TRUE(disposed);
142}

◆ TEST() [424/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestCreatePlatformViewNoMatchingViewType   
)

Definition at line 14 of file FlutterPlatformViewControllerTest.mm.

14 {
15 // Use id so we can access handleMethodCall method.
16 id platformViewController = [[FlutterPlatformViewController alloc] init];
17
18 FlutterMethodCall* methodCall =
19 [FlutterMethodCall methodCallWithMethodName:@"create"
20 arguments:@{
21 @"id" : @2,
22 @"viewType" : @"FlutterPlatformViewMock"
23 }];
24
25 __block bool errored = false;
27 if ([result isKindOfClass:[FlutterError class]]) {
28 errored = true;
29 }
30 };
31
32 [platformViewController handleMethodCall:methodCall result:result];
33
34 // We expect the call to error since no factories are registered.
35 EXPECT_TRUE(errored);
36}

◆ TEST() [425/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestDisposeOnMissingViewId   
)

Definition at line 144 of file FlutterPlatformViewControllerTest.mm.

144 {
145 // Use id so we can access handleMethodCall method.
146 id platformViewController = [[FlutterPlatformViewController alloc] init];
147
148 FlutterMethodCall* methodCall =
149 [FlutterMethodCall methodCallWithMethodName:@"dispose"
150 arguments:[NSNumber numberWithLongLong:20]];
151
152 __block bool errored = false;
153 FlutterResult result = ^(id result) {
154 if ([result isKindOfClass:[FlutterError class]]) {
155 errored = true;
156 }
157 };
158
159 [platformViewController handleMethodCall:methodCall result:result];
160
161 EXPECT_TRUE(errored);
162}

◆ TEST() [426/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRegisterPlatformViewFactoryAndCreate   
)

Definition at line 38 of file FlutterPlatformViewControllerTest.mm.

38 {
39 // Use id so we can access handleMethodCall method.
40 id platformViewController = [[FlutterPlatformViewController alloc] init];
41
43
44 [platformViewController registerViewFactory:factory withId:@"MockPlatformView"];
45
46 NSDictionary* creationArgs = @{
47 @"album" : @"スコットとリバース",
48 @"releaseYear" : @2013,
49 @"artists" : @[ @"Scott Murphy", @"Rivers Cuomo" ],
50 @"playlist" : @[ @"おかしいやつ", @"ほどけていたんだ" ],
51 };
52 NSObject<FlutterMessageCodec>* codec = [factory createArgsCodec];
53 FlutterStandardTypedData* creationArgsData =
54 [FlutterStandardTypedData typedDataWithBytes:[codec encode:creationArgs]];
55
56 FlutterMethodCall* methodCall =
57 [FlutterMethodCall methodCallWithMethodName:@"create"
58 arguments:@{
59 @"id" : @2,
60 @"viewType" : @"MockPlatformView",
61 @"params" : creationArgsData,
62 }];
63
64 __block bool success = false;
66 // If a platform view is successfully created, the result is nil.
67 if (result == nil) {
68 success = true;
69 }
70 };
71 [platformViewController handleMethodCall:methodCall result:result];
72 EXPECT_TRUE(success);
73
74 // Verify PlatformView parameters are decoded correctly.
76 (TestFlutterPlatformView*)[platformViewController platformViewWithID:2];
77 ASSERT_TRUE(view != nil);
78 ASSERT_TRUE(view.args != nil);
79
80 // Verify string type.
81 NSString* album = [view.args objectForKey:@"album"];
82 EXPECT_TRUE([album isEqualToString:@"スコットとリバース"]);
83
84 // Verify int type.
85 NSNumber* releaseYear = [view.args objectForKey:@"releaseYear"];
86 EXPECT_EQ(releaseYear.intValue, 2013);
87
88 // Verify list/array types.
89 NSArray* artists = [view.args objectForKey:@"artists"];
90 ASSERT_TRUE(artists != nil);
91 ASSERT_EQ(artists.count, 2ul);
92 EXPECT_TRUE([artists[0] isEqualToString:@"Scott Murphy"]);
93 EXPECT_TRUE([artists[1] isEqualToString:@"Rivers Cuomo"]);
94
95 NSArray* playlist = [view.args objectForKey:@"playlist"];
96 ASSERT_EQ(playlist.count, 2ul);
97 EXPECT_TRUE([playlist[0] isEqualToString:@"おかしいやつ"]);
98 EXPECT_TRUE([playlist[1] isEqualToString:@"ほどけていたんだ"]);
99}
static void encode(uint8_t output[16], const uint32_t input[4])
Definition SkMD5.cpp:240
id args
Arguments passed via the params value in the create method call.

◆ TEST() [427/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRejectGesture   
)

Definition at line 222 of file FlutterPlatformViewControllerTest.mm.

222 {
223 FlutterPlatformViewController* platformViewController =
224 [[FlutterPlatformViewController alloc] init];
225 [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
226 withId:@"MockPlatformView"];
227
228 // Create the PlatformView.
229 const NSNumber* viewId = [NSNumber numberWithLongLong:2];
230 FlutterMethodCall* methodCallOnCreate = [FlutterMethodCall
231 methodCallWithMethodName:@"create"
232 arguments:@{@"id" : viewId, @"viewType" : @"MockPlatformView"}];
233 __block bool created = false;
234 FlutterResult resultOnCreate = ^(id result) {
235 // If a platform view is successfully created, the result is nil.
236 if (result == nil) {
237 created = true;
238 }
239 };
240 [platformViewController handleMethodCall:methodCallOnCreate result:resultOnCreate];
241
242 // Call rejectGesture.
243 FlutterMethodCall* methodCallRejectGesture =
244 [FlutterMethodCall methodCallWithMethodName:@"rejectGesture" arguments:@{@"id" : viewId}];
245 __block bool rejectGestureCalled = false;
246 FlutterResult resultRejectGesture = ^(id result) {
247 // If a rejectGesture is successful, the result is nil.
248 if (result == nil) {
249 rejectGestureCalled = true;
250 }
251 };
252 [platformViewController handleMethodCall:methodCallRejectGesture result:resultRejectGesture];
253
254 EXPECT_TRUE(created);
255 EXPECT_TRUE(rejectGestureCalled);
256}

◆ TEST() [428/709]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRejectGestureOnMissingViewId   
)

Definition at line 258 of file FlutterPlatformViewControllerTest.mm.

258 {
259 FlutterPlatformViewController* platformViewController =
260 [[FlutterPlatformViewController alloc] init];
261 [platformViewController registerViewFactory:[TestFlutterPlatformViewFactory alloc]
262 withId:@"MockPlatformView"];
263
264 // Call rejectGesture.
265 FlutterMethodCall* methodCallRejectGesture =
266 [FlutterMethodCall methodCallWithMethodName:@"rejectGesture" arguments:@{
267 @"id" : @20
268 }];
269 __block bool errored = false;
270 FlutterResult result = ^(id result) {
271 if ([result isKindOfClass:[FlutterError class]]) {
272 errored = true;
273 }
274 };
275 [platformViewController handleMethodCall:methodCallRejectGesture result:result];
276
277 EXPECT_TRUE(errored);
278}

◆ TEST() [429/709]

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}

◆ TEST() [430/709]

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}

◆ TEST() [431/709]

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}

◆ TEST() [432/709]

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}

◆ TEST() [433/709]

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}

◆ TEST() [434/709]

flutter::testing::TEST ( FlutterSurfaceManager  ,
BackBufferCacheDoesNotLeak   
)

Definition at line 96 of file FlutterSurfaceManagerTest.mm.

96 {
97 TestView* testView = [[TestView alloc] init];
98 FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
99 EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
100
101 auto surface1 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
102 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1) ] atTime:0 notify:nil];
103
104 EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
105
106 auto surface2 = [surfaceManager surfaceForSize:CGSizeMake(110, 110)];
107 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface2) ] atTime:0 notify:nil];
108
109 EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
110
111 auto surface3 = [surfaceManager surfaceForSize:CGSizeMake(120, 120)];
112 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface3) ] atTime:0 notify:nil];
113
114 // Cache should be cleaned during present and only contain the last visible
115 // surface(s).
116 EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
117 auto surfaceFromCache = [surfaceManager surfaceForSize:CGSizeMake(110, 110)];
118 EXPECT_EQ(surfaceFromCache, surface2);
119
120 // Submit empty surfaces until the one in cache gets to age >= kSurfaceEvictionAge, in which case
121 // it should be removed.
122
123 for (int i = 0; i < 30 /* kSurfaceEvictionAge */; ++i) {
124 [surfaceManager presentSurfaces:@[] atTime:0 notify:nil];
125 EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
126 }
127
128 [surfaceManager presentSurfaces:@[] atTime:0 notify:nil];
129 EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
130}
nonnull FlutterSurface * surfaceForSize:(CGSize size)
void presentSurfaces:atTime:notify:(nonnull NSArray< FlutterSurfacePresentInfo * > *surfaces,[atTime] CFTimeInterval presentationTime,[notify] nullable dispatch_block_t notify)
FlutterBackBufferCache * backBufferCache()
static FlutterSurfaceManager * CreateSurfaceManager(TestView *testView)

◆ TEST() [435/709]

flutter::testing::TEST ( FlutterSurfaceManager  ,
BackingStoreCacheSurfaceStuckInUse   
)

Definition at line 171 of file FlutterSurfaceManagerTest.mm.

171 {
172 TestView* testView = [[TestView alloc] init];
173 FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
174
175 auto surface1 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
176
177 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1) ] atTime:0 notify:nil];
178 // Pretend that compositor is holding on to the surface. The surface will be kept
179 // in cache until the age of kSurfaceEvictionAge is reached, and then evicted.
180 surface1.isInUseOverride = YES;
181
182 auto surface2 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
183 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface2) ] atTime:0 notify:nil];
184 EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
185
186 for (int i = 0; i < 30 /* kSurfaceEvictionAge */ - 1; ++i) {
187 auto surface3 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
188 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface3) ] atTime:0 notify:nil];
189 EXPECT_EQ(surfaceManager.backBufferCache.count, 2ul);
190 }
191
192 auto surface4 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
193 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface4) ] atTime:0 notify:nil];
194 // Surface in use should bet old enough at this point to be evicted.
195 EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
196}

◆ TEST() [436/709]

flutter::testing::TEST ( FlutterSurfaceManager  ,
LayerManagement   
)

Definition at line 202 of file FlutterSurfaceManagerTest.mm.

202 {
203 TestView* testView = [[TestView alloc] init];
204 FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
205
206 EXPECT_EQ(testView.layer.sublayers.count, 0ul);
207
208 auto surface1_1 = [surfaceManager surfaceForSize:CGSizeMake(50, 30)];
209 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1_1, CGPointMake(20, 10)) ]
210 atTime:0
211 notify:nil];
212
213 EXPECT_EQ(testView.layer.sublayers.count, 1ul);
214 EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(70, 40)));
215
216 auto surface2_1 = [surfaceManager surfaceForSize:CGSizeMake(50, 30)];
217 auto surface2_2 = [surfaceManager surfaceForSize:CGSizeMake(20, 20)];
218 [surfaceManager presentSurfaces:@[
219 CreatePresentInfo(surface2_1, CGPointMake(20, 10), 1),
220 CreatePresentInfo(surface2_2, CGPointMake(40, 50), 2,
221 {
222 FlutterRect{0, 0, 20, 20},
223 FlutterRect{40, 0, 60, 20},
224 })
225 ]
226 atTime:0
227 notify:nil];
228
229 EXPECT_EQ(testView.layer.sublayers.count, 2ul);
230 EXPECT_EQ(testView.layer.sublayers[0].zPosition, 1.0);
231 EXPECT_EQ(testView.layer.sublayers[1].zPosition, 2.0);
232 CALayer* firstOverlaySublayer;
233 {
234 NSArray<CALayer*>* sublayers = testView.layer.sublayers[1].sublayers;
235 EXPECT_EQ(sublayers.count, 2ul);
236 EXPECT_TRUE(CGRectEqualToRect(sublayers[0].frame, CGRectMake(0, 0, 10, 10)));
237 EXPECT_TRUE(CGRectEqualToRect(sublayers[1].frame, CGRectMake(20, 0, 10, 10)));
238 EXPECT_TRUE(CGRectEqualToRect(sublayers[0].contentsRect, CGRectMake(0, 0, 1, 1)));
239 EXPECT_TRUE(CGRectEqualToRect(sublayers[1].contentsRect, CGRectMake(2, 0, 1, 1)));
240 EXPECT_EQ(sublayers[0].contents, sublayers[1].contents);
241 firstOverlaySublayer = sublayers[0];
242 }
243 EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(70, 70)));
244
245 // Check second overlay sublayer is removed while first is reused and updated
246 [surfaceManager presentSurfaces:@[
247 CreatePresentInfo(surface2_1, CGPointMake(20, 10), 1),
248 CreatePresentInfo(surface2_2, CGPointMake(40, 50), 2,
249 {
250 FlutterRect{0, 10, 20, 20},
251 })
252 ]
253 atTime:0
254 notify:nil];
255 EXPECT_EQ(testView.layer.sublayers.count, 2ul);
256 {
257 NSArray<CALayer*>* sublayers = testView.layer.sublayers[1].sublayers;
258 EXPECT_EQ(sublayers.count, 1ul);
259 EXPECT_EQ(sublayers[0], firstOverlaySublayer);
260 EXPECT_TRUE(CGRectEqualToRect(sublayers[0].frame, CGRectMake(0, 5, 10, 5)));
261 }
262
263 // Check that second overlay sublayer is added back while first is reused and updated
264 [surfaceManager presentSurfaces:@[
265 CreatePresentInfo(surface2_1, CGPointMake(20, 10), 1),
266 CreatePresentInfo(surface2_2, CGPointMake(40, 50), 2,
267 {
268 FlutterRect{0, 0, 20, 20},
269 FlutterRect{40, 0, 60, 20},
270 })
271 ]
272 atTime:0
273 notify:nil];
274
275 EXPECT_EQ(testView.layer.sublayers.count, 2ul);
276 {
277 NSArray<CALayer*>* sublayers = testView.layer.sublayers[1].sublayers;
278 EXPECT_EQ(sublayers.count, 2ul);
279 EXPECT_EQ(sublayers[0], firstOverlaySublayer);
280 EXPECT_TRUE(CGRectEqualToRect(sublayers[0].frame, CGRectMake(0, 0, 10, 10)));
281 EXPECT_TRUE(CGRectEqualToRect(sublayers[1].frame, CGRectMake(20, 0, 10, 10)));
282 EXPECT_EQ(sublayers[0].contents, sublayers[1].contents);
283 }
284
285 auto surface3_1 = [surfaceManager surfaceForSize:CGSizeMake(50, 30)];
286 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface3_1, CGPointMake(20, 10)) ]
287 atTime:0
288 notify:nil];
289
290 EXPECT_EQ(testView.layer.sublayers.count, 1ul);
291 EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(70, 40)));
292
293 // Check removal of all surfaces.
294 [surfaceManager presentSurfaces:@[] atTime:0 notify:nil];
295 EXPECT_EQ(testView.layer.sublayers.count, 0ul);
296 EXPECT_TRUE(CGSizeEqualToSize(testView.presentedFrameSize, CGSizeMake(0, 0)));
297}

◆ TEST() [437/709]

flutter::testing::TEST ( FlutterSurfaceManager  ,
MetalTextureSizeMatchesSurfaceSize   
)

Definition at line 64 of file FlutterSurfaceManagerTest.mm.

64 {
65 TestView* testView = [[TestView alloc] init];
66 FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
67
68 // Get back buffer, lookup should work for borrowed surfaces util present.
69 auto surface = [surfaceManager surfaceForSize:CGSizeMake(100, 50)];
70 auto texture = surface.asFlutterMetalTexture;
71 id<MTLTexture> metalTexture = (__bridge id)texture.texture;
72 EXPECT_EQ(metalTexture.width, 100ul);
73 EXPECT_EQ(metalTexture.height, 50ul);
74 texture.destruction_callback(texture.user_data);
75}

◆ TEST() [438/709]

flutter::testing::TEST ( FlutterSurfaceManager  ,
SurfacesAreRecycled   
)

Definition at line 132 of file FlutterSurfaceManagerTest.mm.

132 {
133 TestView* testView = [[TestView alloc] init];
134 FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
135
136 EXPECT_EQ(surfaceManager.frontSurfaces.count, 0ul);
137
138 // Get first surface and present it.
139
140 auto surface1 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
141 EXPECT_TRUE(CGSizeEqualToSize(surface1.size, CGSizeMake(100, 100)));
142
143 EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
144 EXPECT_EQ(surfaceManager.frontSurfaces.count, 0ul);
145
146 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface1) ] atTime:0 notify:nil];
147
148 EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
149 EXPECT_EQ(surfaceManager.frontSurfaces.count, 1ul);
150 EXPECT_EQ(testView.layer.sublayers.count, 1ul);
151
152 // Get second surface and present it.
153
154 auto surface2 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
155 EXPECT_TRUE(CGSizeEqualToSize(surface2.size, CGSizeMake(100, 100)));
156
157 EXPECT_EQ(surfaceManager.backBufferCache.count, 0ul);
158
159 [surfaceManager presentSurfaces:@[ CreatePresentInfo(surface2) ] atTime:0 notify:nil];
160
161 // Check that current front surface returns to cache.
162 EXPECT_EQ(surfaceManager.backBufferCache.count, 1ul);
163 EXPECT_EQ(surfaceManager.frontSurfaces.count, 1ul);
164 EXPECT_EQ(testView.layer.sublayers.count, 1ull);
165
166 // Check that surface is properly reused.
167 auto surface3 = [surfaceManager surfaceForSize:CGSizeMake(100, 100)];
168 EXPECT_EQ(surface3, surface1);
169}

◆ TEST() [439/709]

flutter::testing::TEST ( FlutterSurfaceManager  ,
TestSurfaceLookupFromTexture   
)

Definition at line 77 of file FlutterSurfaceManagerTest.mm.

77 {
78 TestView* testView = [[TestView alloc] init];
79 FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(testView);
80
81 // Get back buffer, lookup should work for borrowed surfaces util present.
82 auto surface = [surfaceManager surfaceForSize:CGSizeMake(100, 50)];
83
84 // SurfaceManager should keep texture alive while borrowed.
85 auto texture = surface.asFlutterMetalTexture;
86 texture.destruction_callback(texture.user_data);
87
88 FlutterMetalTexture dummyTexture{.texture_id = 1, .texture = nullptr, .user_data = nullptr};
89 auto surface1 = [FlutterSurface fromFlutterMetalTexture:&dummyTexture];
90 EXPECT_EQ(surface1, nil);
91
92 auto surface2 = [FlutterSurface fromFlutterMetalTexture:&texture];
93 EXPECT_EQ(surface2, surface);
94}
nullable FlutterSurface * fromFlutterMetalTexture:(nonnull const FlutterMetalTexture *texture)

◆ TEST() [440/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
CanNotBecomeResponderIfNoViewController   
)

Definition at line 1986 of file FlutterTextInputPluginTest.mm.

1986 {
1987 FlutterEngine* engine = CreateTestEngine();
1988 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
1989 nibName:nil
1990 bundle:nil];
1991 [viewController loadView];
1992 // Creates a NSWindow so that the native text field can become first responder.
1993 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
1994 styleMask:NSBorderlessWindowMask
1995 backing:NSBackingStoreBuffered
1996 defer:NO];
1997 window.contentView = viewController.view;
1998
2000
2001 auto bridge = viewController.accessibilityBridge.lock();
2003 ui::AXTree tree;
2004 ui::AXNode ax_node(&tree, nullptr, 0, 0);
2005 ui::AXNodeData node_data;
2006 node_data.SetValue("initial text");
2007 ax_node.SetData(node_data);
2008 delegate.Init(viewController.accessibilityBridge, &ax_node);
2009 FlutterTextPlatformNode text_platform_node(&delegate, viewController);
2010
2011 FlutterTextField* textField = text_platform_node.GetNativeViewAccessible();
2012 EXPECT_EQ([textField becomeFirstResponder], YES);
2013 // Removes view controller.
2014 [engine setViewController:nil];
2015 FlutterTextPlatformNode text_platform_node_no_controller(&delegate, nil);
2016 textField = text_platform_node_no_controller.GetNativeViewAccessible();
2017 EXPECT_EQ([textField becomeFirstResponder], NO);
2018}
The ax platform node for a text field.
void SetValue(const std::string &value)

◆ TEST() [441/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
CanWorkWithFlutterTextField   
)

Definition at line 1921 of file FlutterTextInputPluginTest.mm.

1921 {
1922 FlutterEngine* engine = CreateTestEngine();
1923 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
1924 nibName:nil
1925 bundle:nil];
1926 [viewController loadView];
1927 // Create a NSWindow so that the native text field can become first responder.
1928 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
1929 styleMask:NSBorderlessWindowMask
1930 backing:NSBackingStoreBuffered
1931 defer:NO];
1932 window.contentView = viewController.view;
1933
1935
1936 auto bridge = viewController.accessibilityBridge.lock();
1938 ui::AXTree tree;
1939 ui::AXNode ax_node(&tree, nullptr, 0, 0);
1940 ui::AXNodeData node_data;
1941 node_data.SetValue("initial text");
1942 ax_node.SetData(node_data);
1943 delegate.Init(viewController.accessibilityBridge, &ax_node);
1944 {
1945 FlutterTextPlatformNode text_platform_node(&delegate, viewController);
1946
1947 FlutterTextFieldMock* mockTextField =
1948 [[FlutterTextFieldMock alloc] initWithPlatformNode:&text_platform_node
1949 fieldEditor:viewController.textInputPlugin];
1950 [viewController.view addSubview:mockTextField];
1951 [mockTextField startEditing];
1952
1953 NSDictionary* setClientConfig = @{
1954 @"inputAction" : @"action",
1955 @"inputType" : @{@"name" : @"inputName"},
1956 };
1957 FlutterMethodCall* methodCall =
1958 [FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
1959 arguments:@[ @(1), setClientConfig ]];
1960 FlutterResult result = ^(id result) {
1961 };
1962 [viewController.textInputPlugin handleMethodCall:methodCall result:result];
1963
1964 NSDictionary* arguments = @{
1965 @"text" : @"new text",
1966 @"selectionBase" : @(1),
1967 @"selectionExtent" : @(2),
1968 @"composingBase" : @(-1),
1969 @"composingExtent" : @(-1),
1970 };
1971 methodCall = [FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
1972 arguments:arguments];
1973 [viewController.textInputPlugin handleMethodCall:methodCall result:result];
1974 EXPECT_EQ([mockTextField.lastUpdatedString isEqualToString:@"new text"], YES);
1975 EXPECT_EQ(NSEqualRanges(mockTextField.lastUpdatedSelection, NSMakeRange(1, 1)), YES);
1976
1977 // This blocks the FlutterTextFieldMock, which is held onto by the main event
1978 // loop, from crashing.
1979 [mockTextField setPlatformNode:nil];
1980 }
1981
1982 // This verifies that clearing the platform node works.
1983 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
1984}
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
void setPlatformNode:(flutter::FlutterTextPlatformNode *node)

◆ TEST() [442/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
FirstResponderIsCorrect   
)

Definition at line 2053 of file FlutterTextInputPluginTest.mm.

2053 {
2054 FlutterEngine* engine = CreateTestEngine();
2055 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2056 nibName:nil
2057 bundle:nil];
2058 [viewController loadView];
2059
2060 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2061 styleMask:NSBorderlessWindowMask
2062 backing:NSBackingStoreBuffered
2063 defer:NO];
2064 window.contentView = viewController.view;
2065
2067
2068 [window makeFirstResponder:viewController.flutterView];
2069
2070 [viewController.textInputPlugin
2071 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.show" arguments:@[]]
2072 result:^(id){
2073 }];
2074
2075 ASSERT_TRUE(window.firstResponder == viewController.textInputPlugin);
2076
2078
2079 [viewController.textInputPlugin
2080 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.hide" arguments:@[]]
2081 result:^(id){
2082 }];
2083
2085 ASSERT_TRUE(window.firstResponder == viewController.flutterView);
2086}
BOOL acceptsFirstResponder()

◆ TEST() [443/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
HandleArrowKeyWhenImePopoverIsActive   
)

Definition at line 1901 of file FlutterTextInputPluginTest.mm.

1901 {
1902 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] handleArrowKeyWhenImePopoverIsActive]);
1903}

◆ TEST() [444/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
HasZeroSizeAndClipsToBounds   
)

Definition at line 2088 of file FlutterTextInputPluginTest.mm.

2088 {
2089 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
2090 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
2091 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
2092 [engineMock binaryMessenger])
2093 .andReturn(binaryMessengerMock);
2094
2095 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
2096 nibName:@""
2097 bundle:nil];
2098
2099 FlutterTextInputPlugin* plugin =
2100 [[FlutterTextInputPlugin alloc] initWithViewController:viewController];
2101
2102 ASSERT_TRUE(NSIsEmptyRect(plugin.frame));
2103 ASSERT_TRUE(plugin.clipsToBounds);
2104}
id CreateMockFlutterEngine(NSString *pasteboardString)

◆ TEST() [445/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
IsAddedAndRemovedFromViewHierarchy   
)

Definition at line 2020 of file FlutterTextInputPluginTest.mm.

2020 {
2021 FlutterEngine* engine = CreateTestEngine();
2022 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2023 nibName:nil
2024 bundle:nil];
2025 [viewController loadView];
2026
2027 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2028 styleMask:NSBorderlessWindowMask
2029 backing:NSBackingStoreBuffered
2030 defer:NO];
2031 window.contentView = viewController.view;
2032
2033 ASSERT_EQ(viewController.textInputPlugin.superview, nil);
2034 ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
2035
2036 [viewController.textInputPlugin
2037 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.show" arguments:@[]]
2038 result:^(id){
2039 }];
2040
2041 ASSERT_EQ(viewController.textInputPlugin.superview, viewController.view);
2042 ASSERT_TRUE(window.firstResponder == viewController.textInputPlugin);
2043
2044 [viewController.textInputPlugin
2045 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.hide" arguments:@[]]
2046 result:^(id){
2047 }];
2048
2049 ASSERT_EQ(viewController.textInputPlugin.superview, nil);
2050 ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
2051}

◆ TEST() [446/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenAutofillGroupIncludesPassword   
)

Definition at line 1859 of file FlutterTextInputPluginTest.mm.

1859 {
1860 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc]
1861 testAutocompleteDisabledWhenAutofillGroupIncludesPassword]);
1862}

◆ TEST() [447/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenAutofillNotSet   
)

Definition at line 1839 of file FlutterTextInputPluginTest.mm.

1839 {
1840 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenAutofillNotSet]);
1841}

◆ TEST() [448/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenObscureTextSet   
)

Definition at line 1851 of file FlutterTextInputPluginTest.mm.

1851 {
1852 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenObscureTextSet]);
1853}

◆ TEST() [449/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenPasswordAutofillSet   
)

Definition at line 1855 of file FlutterTextInputPluginTest.mm.

1855 {
1856 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenPasswordAutofillSet]);
1857}

◆ TEST() [450/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteEnabledWhenAutofillSet   
)

Definition at line 1843 of file FlutterTextInputPluginTest.mm.

1843 {
1844 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteEnabledWhenAutofillSet]);
1845}

◆ TEST() [451/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteEnabledWhenAutofillSetNoHint   
)

Definition at line 1847 of file FlutterTextInputPluginTest.mm.

1847 {
1848 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteEnabledWhenAutofillSetNoHint]);
1849}

◆ TEST() [452/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestClearClientDuringComposing   
)

Definition at line 1835 of file FlutterTextInputPluginTest.mm.

1835 {
1836 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testClearClientDuringComposing]);
1837}

◆ TEST() [453/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingRegionRemovedByFramework   
)

Definition at line 1831 of file FlutterTextInputPluginTest.mm.

1831 {
1832 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingRegionRemovedByFramework]);
1833}

◆ TEST() [454/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingWithDelta   
)

Definition at line 1885 of file FlutterTextInputPluginTest.mm.

1885 {
1886 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingWithDelta]);
1887}

◆ TEST() [455/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
testComposingWithDeltasWhenSelectionIsActive   
)

Definition at line 1889 of file FlutterTextInputPluginTest.mm.

1889 {
1890 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingWithDeltasWhenSelectionIsActive]);
1891}

◆ TEST() [456/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestEmptyCompositionRange   
)

Definition at line 1819 of file FlutterTextInputPluginTest.mm.

1819 {
1820 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testEmptyCompositionRange]);
1821}

◆ TEST() [457/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRange   
)

Definition at line 1864 of file FlutterTextInputPluginTest.mm.

1864 {
1865 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testFirstRectForCharacterRange]);
1866}

◆ TEST() [458/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRangeAtInfinity   
)

Definition at line 1868 of file FlutterTextInputPluginTest.mm.

1868 {
1869 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testFirstRectForCharacterRangeAtInfinity]);
1870}

◆ TEST() [459/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRangeWithEsotericAffineTransform   
)

Definition at line 1872 of file FlutterTextInputPluginTest.mm.

1872 {
1873 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc]
1874 testFirstRectForCharacterRangeWithEsotericAffineTransform]);
1875}

◆ TEST() [460/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestInsertNewLine   
)

Definition at line 1913 of file FlutterTextInputPluginTest.mm.

1913 {
1914 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testInsertNewLine]);
1915}

◆ TEST() [461/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestLocalTextAndSelectionUpdateAfterDelta   
)

Definition at line 1893 of file FlutterTextInputPluginTest.mm.

1893 {
1894 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testLocalTextAndSelectionUpdateAfterDelta]);
1895}

◆ TEST() [462/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestOperationsThatTriggerDelta   
)

Definition at line 1881 of file FlutterTextInputPluginTest.mm.

1881 {
1882 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testOperationsThatTriggerDelta]);
1883}

◆ TEST() [463/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestPerformKeyEquivalent   
)

Definition at line 1897 of file FlutterTextInputPluginTest.mm.

1897 {
1898 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testPerformKeyEquivalent]);
1899}

◆ TEST() [464/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSelectorsAreForwardedToFramework   
)

Definition at line 1909 of file FlutterTextInputPluginTest.mm.

1909 {
1910 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSelectorsAreForwardedToFramework]);
1911}

◆ TEST() [465/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSendActionDoNotInsertNewLine   
)

Definition at line 1917 of file FlutterTextInputPluginTest.mm.

1917 {
1918 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSendActionDoNotInsertNewLine]);
1919}

◆ TEST() [466/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetEditingStateWithTextEditingDelta   
)

Definition at line 1877 of file FlutterTextInputPluginTest.mm.

1877 {
1878 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetEditingStateWithTextEditingDelta]);
1879}

◆ TEST() [467/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetMarkedTextWithReplacementRange   
)

Definition at line 1827 of file FlutterTextInputPluginTest.mm.

1827 {
1828 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetMarkedTextWithReplacementRange]);
1829}

◆ TEST() [468/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetMarkedTextWithSelectionChange   
)

Definition at line 1823 of file FlutterTextInputPluginTest.mm.

1823 {
1824 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetMarkedTextWithSelectionChange]);
1825}

◆ TEST() [469/709]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
UnhandledKeyEquivalent   
)

Definition at line 1905 of file FlutterTextInputPluginTest.mm.

1905 {
1906 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] unhandledKeyEquivalent]);
1907}

◆ TEST() [470/709]

flutter::testing::TEST ( FlutterTextInputSemanticsObjectTest  ,
DoesInitialize   
)

Definition at line 27 of file FlutterTextInputSemanticsObjectTest.mm.

27 {
28 FlutterEngine* engine = CreateTestEngine();
29 {
31 nibName:nil
32 bundle:nil];
33 [viewController loadView];
34 // Create a NSWindow so that the native text field can become first responder.
35 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
36 styleMask:NSBorderlessWindowMask
37 backing:NSBackingStoreBuffered
38 defer:NO];
39 window.contentView = viewController.view;
40
41 engine.semanticsEnabled = YES;
42
43 auto bridge = viewController.accessibilityBridge.lock();
45 ui::AXTree tree;
46 ui::AXNode ax_node(&tree, nullptr, 0, 0);
47 ui::AXNodeData node_data;
48 node_data.SetValue("initial text");
49 ax_node.SetData(node_data);
50 delegate.Init(viewController.accessibilityBridge, &ax_node);
51 // Verify that a FlutterTextField is attached to the view.
52 FlutterTextPlatformNode text_platform_node(&delegate, viewController);
53 id native_accessibility = text_platform_node.GetNativeViewAccessible();
54 EXPECT_TRUE([native_accessibility isKindOfClass:[FlutterTextField class]]);
55 auto subviews = [viewController.view subviews];
56 EXPECT_EQ([subviews count], 2u);
57 EXPECT_TRUE([subviews[0] isKindOfClass:[FlutterTextField class]]);
58 FlutterTextField* nativeTextField = subviews[0];
59 EXPECT_EQ(text_platform_node.GetNativeViewAccessible(), nativeTextField);
60 }
61
62 [engine shutDownEngine];
63 engine = nil;
64 // Pump the event loop to make sure no stray nodes cause crashes after the
65 // engine has been destroyed.
66 // From issue: https://github.com/flutter/flutter/issues/115599
67 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
68}
void Init()

◆ TEST() [471/709]

flutter::testing::TEST ( FlutterViewEngineProviderUnittests  ,
GetViewReturnsTheCorrectView   
)

Definition at line 19 of file FlutterViewEngineProviderTest.mm.

19 {
20 FlutterViewEngineProvider* viewProvider;
21 id mockEngine = CreateMockFlutterEngine(@"");
22 __block id mockFlutterViewController;
23 OCMStub([mockEngine viewControllerForIdentifier:0])
24 .ignoringNonObjectArgs()
25 .andDo(^(NSInvocation* invocation) {
26 FlutterViewIdentifier viewIdentifier;
27 [invocation getArgument:&viewIdentifier atIndex:2];
28 if (viewIdentifier == kFlutterImplicitViewId) {
29 if (mockFlutterViewController != nil) {
30 [invocation setReturnValue:&mockFlutterViewController];
31 }
32 }
33 });
34 viewProvider = [[FlutterViewEngineProvider alloc] initWithEngine:mockEngine];
35
36 // When the view controller is not set, the returned view is nil.
37 EXPECT_EQ([viewProvider viewForIdentifier:0], nil);
38
39 // When the view controller is set, the returned view is the controller's view.
40 mockFlutterViewController = OCMStrictClassMock([FlutterViewController class]);
41 id mockView = OCMStrictClassMock([FlutterView class]);
42 OCMStub([mockFlutterViewController flutterView]).andReturn(mockView);
43 EXPECT_EQ([viewProvider viewForIdentifier:0], mockView);
44}
int64_t FlutterViewIdentifier

◆ TEST() [472/709]

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

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 = {};
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);
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}
std::vector< std::shared_ptr< FakeTexture > > textures
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
@ kFlutterDesktopGpuSurfaceTexture
void(* release_callback)(void *release_context)
FlutterDesktopGpuSurfaceTextureCallback callback
FlutterDesktopGpuSurfaceTextureConfig gpu_surface_config
size_t height
Height of the texture.
Definition embedder.h:384
int64_t texture_id
unsigned int UINT

◆ TEST() [474/709]

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 = {};
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);
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}
@ kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle
#define SUCCEEDED(hr)
void * HANDLE

◆ TEST() [475/709]

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}

◆ TEST() [476/709]

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);
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}
@ kFlutterDesktopPixelBufferTexture
FlutterDesktopPixelBufferTextureCallback callback
void(* release_callback)(void *release_context)
FlutterDesktopPixelBufferTextureConfig pixel_buffer_config

◆ TEST() [477/709]

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}

◆ TEST() [478/709]

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
135 registrar.UnregisterTexture(texture_id, [&]() { latch.Signal(); });
136 latch.Wait();
137 ASSERT_TRUE(unregister_called);
138}

◆ TEST() [479/709]

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
341 registrar.UnregisterTexture(1234, [&]() { latch.Signal(); });
342 latch.Wait();
343}

◆ TEST() [480/709]

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.
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.
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.
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.
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() [481/709]

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.
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}
std::shared_ptr< FlutterPlatformNodeDelegateWindows > node_delegate

◆ TEST() [482/709]

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.
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
455 node1.label = "prefecture";
456 node1.value = "Kyoto";
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();
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}

◆ TEST() [483/709]

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
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>(
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(),
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>(
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(),
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>(
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(),
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}
@ kFlutterSemanticsFlagIsCheckStateMixed
Whether the semantics node represents a tristate checkbox in mixed state.
Definition embedder.h:238

◆ TEST() [484/709]

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}
Mock for the |Context| base class.
struct MyStruct s
FlutterDesktopBinaryReply callback
std::function< void()> closure
Definition closure.h:14

◆ TEST() [485/709]

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

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

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}

◆ TEST() [488/709]

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

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}

◆ TEST() [490/709]

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.
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
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() [491/709]

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}

◆ TEST() [492/709]

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
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>(
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>(
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}
@ kFlutterSemanticsFlagHasExpandedState
Definition embedder.h:241
@ kFlutterSemanticsFlagIsExpanded
Whether a semantic node that hasExpandedState is currently expanded.
Definition embedder.h:243

◆ TEST() [493/709]

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
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>(
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(),
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>(
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(),
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}
@ kFlutterSemanticsFlagIsToggled
Definition embedder.h:210

◆ TEST() [494/709]

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

◆ TEST() [495/709]

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
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>(
1406 bridge->AddFlutterSemanticsNodeUpdate(root);
1407
1408 bridge->CommitUpdates();
1409 auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
1410 std::string tooltip = root_node->GetData().GetStringAttribute(
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() [496/709]

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}

◆ TEST() [497/709]

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

◆ TEST() [498/709]

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}
void SetSurface(std::unique_ptr< egl::WindowSurface > surface)

◆ TEST() [499/709]

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}

◆ TEST() [500/709]

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

◆ TEST() [501/709]

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

flutter::testing::TEST ( GLContextSwitchTest  ,
SwitchKeepsContextCurrentWhileInScope   
)

Definition at line 19 of file gl_context_switch_unittests.cc.

19 {
20 {
21 auto test_gl_context = std::make_unique<TestSwitchableGLContext>(0);
22 auto context_switch = GLContextSwitch(std::move(test_gl_context));
23 ASSERT_EQ(TestSwitchableGLContext::GetCurrentContext(), 0);
24 }
25 ASSERT_EQ(TestSwitchableGLContext::GetCurrentContext(), -1);
26}

◆ TEST() [503/709]

flutter::testing::TEST ( GPUSurfaceMetalImpeller  ,
AcquireFrameFromCAMetalLayerDoesNotRetainThis   
)

Definition at line 83 of file gpu_surface_metal_impeller_unittests.mm.

83 {
84 auto delegate = std::make_shared<TestGPUSurfaceMetalDelegate>();
85 delegate->SetDevice();
86 std::unique_ptr<Surface> surface =
87 std::make_unique<GPUSurfaceMetalImpeller>(delegate.get(), CreateImpellerContext());
88
89 ASSERT_TRUE(surface->IsValid());
90
91 auto frame = surface->AcquireFrame(SkISize::Make(100, 100));
92 ASSERT_TRUE(frame);
93
94 // Simulate a rasterizer teardown, e.g. due to going to the background.
95 surface.reset();
96
97 ASSERT_TRUE(frame->Submit());
98}
static FLUTTER_ASSERT_ARC std::shared_ptr< impeller::ContextMTL > CreateImpellerContext(const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)

◆ TEST() [504/709]

flutter::testing::TEST ( GPUSurfaceMetalImpeller  ,
AcquireFrameFromCAMetalLayerNullChecksDrawable   
)

Definition at line 72 of file gpu_surface_metal_impeller_unittests.mm.

72 {
73 auto delegate = std::make_shared<TestGPUSurfaceMetalDelegate>();
74 std::shared_ptr<Surface> surface =
75 std::make_shared<GPUSurfaceMetalImpeller>(delegate.get(), CreateImpellerContext());
76
77 ASSERT_TRUE(surface->IsValid());
78
79 auto frame = surface->AcquireFrame(SkISize::Make(100, 100));
80 ASSERT_EQ(frame, nullptr);
81}

◆ TEST() [505/709]

flutter::testing::TEST ( GPUSurfaceMetalImpeller  ,
CanCreateValidSurface   
)

Definition at line 65 of file gpu_surface_metal_impeller_unittests.mm.

65 {
66 auto delegate = std::make_shared<TestGPUSurfaceMetalDelegate>();
67 auto surface = std::make_shared<GPUSurfaceMetalImpeller>(delegate.get(), CreateImpellerContext());
68
69 ASSERT_TRUE(surface->IsValid());
70}

◆ TEST() [506/709]

flutter::testing::TEST ( GPUSurfaceMetalImpeller  ,
InvalidImpellerContextCreatesCausesSurfaceToBeInvalid   
)

Definition at line 58 of file gpu_surface_metal_impeller_unittests.mm.

58 {
59 auto delegate = std::make_shared<TestGPUSurfaceMetalDelegate>();
60 auto surface = std::make_shared<GPUSurfaceMetalImpeller>(delegate.get(), nullptr);
61
62 ASSERT_FALSE(surface->IsValid());
63}

◆ TEST() [507/709]

flutter::testing::TEST ( ImageDecoderNoGLTest  ,
ImpellerWideGamutDisplayP3   
)

Definition at line 76 of file image_decoder_no_gl_unittests.cc.

76 {
77#if defined(OS_FUCHSIA)
78 GTEST_SKIP() << "Fuchsia can't load the test fixtures.";
79#endif
80 auto data = flutter::testing::OpenFixtureAsSkData("DisplayP3Logo.png");
82 ASSERT_TRUE(image != nullptr);
83 ASSERT_EQ(SkISize::Make(100, 100), image->dimensions());
84
86 std::shared_ptr<ImageGenerator> generator =
87 registry.CreateCompatibleGenerator(data);
88 ASSERT_TRUE(generator);
89
90 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(data),
91 std::move(generator));
92
93 ASSERT_FALSE(
94 IsPngWithPLTE(descriptor->data()->bytes(), descriptor->data()->size()));
95
96#if IMPELLER_SUPPORTS_RENDERING
97 std::shared_ptr<impeller::Allocator> allocator =
98 std::make_shared<impeller::TestImpellerAllocator>();
99 std::optional<DecompressResult> wide_result =
100 ImageDecoderImpeller::DecompressTexture(
101 descriptor.get(), SkISize::Make(100, 100), {100, 100},
102 /*supports_wide_gamut=*/true, allocator);
103 ASSERT_TRUE(wide_result.has_value());
104 ASSERT_EQ(wide_result->image_info.colorType(), kRGBA_F16_SkColorType);
105 ASSERT_TRUE(wide_result->image_info.colorSpace()->isSRGB());
106
107 const SkPixmap& wide_pixmap = wide_result->sk_bitmap->pixmap();
108 const uint16_t* half_ptr = static_cast<const uint16_t*>(wide_pixmap.addr());
109 bool found_deep_red = false;
110 for (int i = 0; i < wide_pixmap.width() * wide_pixmap.height(); ++i) {
111 float red = HalfToFloat(*half_ptr++);
112 float green = HalfToFloat(*half_ptr++);
113 float blue = HalfToFloat(*half_ptr++);
114 half_ptr++; // alpha
115 if (fabsf(red - 1.0931f) < 0.01f && fabsf(green - -0.2268f) < 0.01f &&
116 fabsf(blue - -0.1501f) < 0.01f) {
117 found_deep_red = true;
118 break;
119 }
120 }
121
122 ASSERT_TRUE(found_deep_red);
123 std::optional<DecompressResult> narrow_result =
124 ImageDecoderImpeller::DecompressTexture(
125 descriptor.get(), SkISize::Make(100, 100), {100, 100},
126 /*supports_wide_gamut=*/false, allocator);
127
128 ASSERT_TRUE(narrow_result.has_value());
129 ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType);
130#endif // IMPELLER_SUPPORTS_RENDERING
131}
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
SkISize dimensions() const
Definition SkImage.h:297
int width() const
Definition SkPixmap.h:160
Keeps a priority-ordered registry of image generator builders to be used when decoding images....
std::shared_ptr< ImageGenerator > CreateCompatibleGenerator(const sk_sp< SkData > &buffer)
Walks the list of image generator builders in descending priority order until a compatible ImageGener...
float HalfToFloat(uint16_t half)

◆ TEST() [508/709]

flutter::testing::TEST ( ImageDecoderNoGLTest  ,
ImpellerWideGamutIndexedPng   
)

Definition at line 133 of file image_decoder_no_gl_unittests.cc.

133 {
134#if defined(OS_FUCHSIA)
135 GTEST_SKIP() << "Fuchsia can't load the test fixtures.";
136#endif
137 auto data = flutter::testing::OpenFixtureAsSkData("WideGamutIndexed.png");
139 ASSERT_TRUE(image != nullptr);
140 ASSERT_EQ(SkISize::Make(100, 100), image->dimensions());
141
142 ImageGeneratorRegistry registry;
143 std::shared_ptr<ImageGenerator> generator =
144 registry.CreateCompatibleGenerator(data);
145 ASSERT_TRUE(generator);
146
147 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(data),
148 std::move(generator));
149
150 ASSERT_TRUE(
151 IsPngWithPLTE(descriptor->data()->bytes(), descriptor->data()->size()));
152
153#if IMPELLER_SUPPORTS_RENDERING
154 std::shared_ptr<impeller::Allocator> allocator =
155 std::make_shared<impeller::TestImpellerAllocator>();
156 std::optional<DecompressResult> wide_result =
157 ImageDecoderImpeller::DecompressTexture(
158 descriptor.get(), SkISize::Make(100, 100), {100, 100},
159 /*supports_wide_gamut=*/true, allocator);
160 ASSERT_EQ(wide_result->image_info.colorType(), kBGR_101010x_XR_SkColorType);
161 ASSERT_TRUE(wide_result->image_info.colorSpace()->isSRGB());
162
163 const SkPixmap& wide_pixmap = wide_result->sk_bitmap->pixmap();
164 const uint32_t* pixel_ptr = static_cast<const uint32_t*>(wide_pixmap.addr());
165 bool found_deep_red = false;
166 for (int i = 0; i < wide_pixmap.width() * wide_pixmap.height(); ++i) {
167 uint32_t pixel = *pixel_ptr++;
168 float blue = DecodeBGR10((pixel >> 0) & 0x3ff);
169 float green = DecodeBGR10((pixel >> 10) & 0x3ff);
170 float red = DecodeBGR10((pixel >> 20) & 0x3ff);
171 if (fabsf(red - 1.0931f) < 0.01f && fabsf(green - -0.2268f) < 0.01f &&
172 fabsf(blue - -0.1501f) < 0.01f) {
173 found_deep_red = true;
174 break;
175 }
176 }
177
178 ASSERT_TRUE(found_deep_red);
179 std::optional<DecompressResult> narrow_result =
180 ImageDecoderImpeller::DecompressTexture(
181 descriptor.get(), SkISize::Make(100, 100), {100, 100},
182 /*supports_wide_gamut=*/false, allocator);
183
184 ASSERT_TRUE(narrow_result.has_value());
185 ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType);
186#endif // IMPELLER_SUPPORTS_RENDERING
187}
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition SkColorType.h:31

◆ TEST() [509/709]

flutter::testing::TEST ( ImageLRU  ,
CanClear   
)

Definition at line 40 of file image_lru_unittests.cc.

40 {
41 auto image = DlImage::Make(nullptr);
42 ImageLRU image_lru;
43
44 // Fill up the cache, nothing is removed
45 for (auto i = 0u; i < kImageReaderSwapchainSize; i++) {
46 EXPECT_EQ(image_lru.AddImage(image, i + 1), 0u);
47 }
48 image_lru.Clear();
49
50 // Expect no cache entries.
51 for (auto i = 0u; i < kImageReaderSwapchainSize; i++) {
52 EXPECT_EQ(image_lru.FindImage(i + 1), nullptr);
53 }
54}
HardwareBufferKey AddImage(const sk_sp< flutter::DlImage > &image, HardwareBufferKey key)
Add a new image to the cache with a key, returning the key of the LRU entry that was removed.
Definition image_lru.cc:42
sk_sp< flutter::DlImage > FindImage(std::optional< HardwareBufferKey > key)
Retrieve the image associated with the given [key], or nullptr.
Definition image_lru.cc:9
void Clear()
Remove all entires from the image cache.
Definition image_lru.cc:60

◆ TEST() [510/709]

flutter::testing::TEST ( ImageLRU  ,
CanStoreSingleImage   
)

Definition at line 11 of file image_lru_unittests.cc.

11 {
12 auto image = DlImage::Make(nullptr);
13 ImageLRU image_lru;
14
15 EXPECT_EQ(image_lru.FindImage(1), nullptr);
16
17 image_lru.AddImage(image, 1);
18
19 EXPECT_EQ(image_lru.FindImage(1), image);
20}

◆ TEST() [511/709]

flutter::testing::TEST ( ImageLRU  ,
EvictsLRU   
)

Definition at line 22 of file image_lru_unittests.cc.

22 {
23 auto image = DlImage::Make(nullptr);
24 ImageLRU image_lru;
25
26 // Fill up the cache, nothing is removed
27 for (auto i = 0u; i < kImageReaderSwapchainSize; i++) {
28 EXPECT_EQ(image_lru.AddImage(image, i + 1), 0u);
29 }
30 // Confirm each image is in the cache. This should keep the LRU
31 // order the same.
32 for (auto i = 0u; i < kImageReaderSwapchainSize; i++) {
33 EXPECT_EQ(image_lru.FindImage(i + 1), image);
34 }
35
36 // Insert new image and verify least recently used was removed.
37 EXPECT_EQ(image_lru.AddImage(image, 100), 1u);
38}

◆ TEST() [512/709]

flutter::testing::TEST ( Instrumentation  ,
GetCurrentSampleTest   
)

Definition at line 57 of file stopwatch_unittests.cc.

57 {
58 fml::Milliseconds frame_budget_90fps = fml::RefreshRateToFrameBudget(90);
59 FixedRefreshRateStopwatch stopwatch(frame_budget_90fps);
60 stopwatch.Start();
61 stopwatch.Stop();
62 EXPECT_EQ(stopwatch.GetCurrentSample(), size_t(1));
63}
Used for fixed refresh rate cases.
Definition stopwatch.h:77
std::chrono::duration< double, std::milli > Milliseconds
Definition time_delta.h:18
Milliseconds RefreshRateToFrameBudget(T refresh_rate)
Definition time_delta.h:24

◆ TEST() [513/709]

flutter::testing::TEST ( Instrumentation  ,
GetDefaultFrameBudgetTest   
)

Definition at line 25 of file stopwatch_unittests.cc.

25 {
26 fml::Milliseconds frame_budget_60fps = fml::RefreshRateToFrameBudget(60);
27 // The default constructor sets the frame_budget to 16.6667 (60 fps).
29 fml::Milliseconds actual_frame_budget = stopwatch.GetFrameBudget();
30 EXPECT_EQ(frame_budget_60fps, actual_frame_budget);
31}
fml::Milliseconds GetFrameBudget() const
All places which want to get frame_budget should call this function.
Definition stopwatch.cc:88

◆ TEST() [514/709]

flutter::testing::TEST ( Instrumentation  ,
GetFrameBudgetFromUpdaterTest   
)

Definition at line 40 of file stopwatch_unittests.cc.

40 {
42 fml::Milliseconds frame_budget_90fps = fml::RefreshRateToFrameBudget(90);
43 updater.SetFrameBudget(frame_budget_90fps);
44
45 Stopwatch stopwatch(updater);
46 fml::Milliseconds actual_frame_budget = stopwatch.GetFrameBudget();
47 EXPECT_EQ(frame_budget_90fps, actual_frame_budget);
48}
void SetFrameBudget(fml::Milliseconds budget)

◆ TEST() [515/709]

flutter::testing::TEST ( Instrumentation  ,
GetLapByIndexTest   
)

Definition at line 50 of file stopwatch_unittests.cc.

50 {
51 fml::Milliseconds frame_budget_90fps = fml::RefreshRateToFrameBudget(90);
52 FixedRefreshRateStopwatch stopwatch(frame_budget_90fps);
53 stopwatch.SetLapTime(fml::TimeDelta::FromMilliseconds(10));
54 EXPECT_EQ(stopwatch.GetLap(1), fml::TimeDelta::FromMilliseconds(10));
55}

◆ TEST() [516/709]

flutter::testing::TEST ( Instrumentation  ,
GetLapsCount   
)

Definition at line 65 of file stopwatch_unittests.cc.

65 {
66 fml::Milliseconds frame_budget_90fps = fml::RefreshRateToFrameBudget(90);
67 FixedRefreshRateStopwatch stopwatch(frame_budget_90fps);
68 stopwatch.SetLapTime(fml::TimeDelta::FromMilliseconds(10));
69 EXPECT_EQ(stopwatch.GetLapsCount(), size_t(120));
70}

◆ TEST() [517/709]

flutter::testing::TEST ( Instrumentation  ,
GetOneShotFrameBudgetTest   
)

Definition at line 33 of file stopwatch_unittests.cc.

33 {
34 fml::Milliseconds frame_budget_90fps = fml::RefreshRateToFrameBudget(90);
35 FixedRefreshRateStopwatch stopwatch(frame_budget_90fps);
36 fml::Milliseconds actual_frame_budget = stopwatch.GetFrameBudget();
37 EXPECT_EQ(frame_budget_90fps, actual_frame_budget);
38}

◆ TEST() [518/709]

flutter::testing::TEST ( JNIMock  ,
FlutterViewHandlePlatformMessage   
)

Definition at line 13 of file jni_mock_unittest.cc.

13 {
14 JNIMock mock;
15
16 auto message = std::make_unique<PlatformMessage>("<channel-name>", nullptr);
17 auto response_id = 1;
18
19 EXPECT_CALL(mock,
20 FlutterViewHandlePlatformMessage(
21 ::testing::Property(&std::unique_ptr<PlatformMessage>::get,
22 message.get()),
23 response_id));
24
25 mock.FlutterViewHandlePlatformMessage(std::move(message), response_id);
26}
virtual void FlutterViewHandlePlatformMessage(std::unique_ptr< flutter::PlatformMessage > message, int responseId)=0
Sends a platform message. The message may be empty.

◆ TEST() [519/709]

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}
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply

◆ TEST() [520/709]

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}

◆ TEST() [521/709]

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}
static constexpr char kScanCodeKey[]

◆ TEST() [522/709]

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}

◆ TEST() [523/709]

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,
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}
FlutterKeyEventCallback callback

◆ TEST() [524/709]

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

◆ TEST() [525/709]

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

◆ TEST() [526/709]

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

Definition at line 90 of file keyboard_key_embedder_handler_unittests.cc.

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

◆ TEST() [527/709]

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

◆ TEST() [528/709]

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

◆ TEST() [529/709]

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

◆ TEST() [530/709]

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

◆ TEST() [531/709]

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

◆ TEST() [532/709]

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

◆ TEST() [533/709]

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

◆ TEST() [534/709]

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

◆ TEST() [535/709]

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

◆ TEST() [536/709]

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

◆ TEST() [537/709]

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

◆ TEST() [538/709]

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

◆ TEST() [539/709]

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

◆ TEST() [540/709]

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

◆ TEST() [541/709]

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

◆ TEST() [542/709]

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>(
322 void* user_data) {},
323 key_state.Getter(), DefaultMapVkToScan);
324 handler.AddDelegate(std::move(embedder_handler));
325
326 // Dispatch a key event.
327 handler.KeyboardHook(kVirtualKeyA, kScanCodeKeyA, WM_KEYDOWN, 'a', false,
328 false, OnKeyEventResult);
329
330 std::map<uint64_t, uint64_t> pressed_state = handler.GetPressedState();
331 EXPECT_EQ(pressed_state.size(), 1);
332 EXPECT_EQ(pressed_state.at(kPhysicalKeyA), kLogicalKeyA);
333}
FlutterKeyEventCallback callback

◆ TEST() [543/709]

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>(
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}
static constexpr char kGetKeyboardStateMethod[]

◆ TEST() [544/709]

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

Test 1: One event that is handled by the framework

Test 2: Two events that are unhandled by the framework

Definition at line 208 of file keyboard_key_handler_unittests.cc.

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

◆ TEST() [545/709]

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}

◆ TEST() [546/709]

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

Definition at line 11 of file keyboard_utils_unittests.cc.

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

◆ TEST() [547/709]

flutter::testing::TEST ( KeyMappingTest  ,
HasExpectedValues   
)

Definition at line 20 of file KeyCodeMapTest.mm.

20 {
21 // Has Space
22 EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x31, 0x20, false}),
23 kLayoutGoals.end());
24 // Has Digit0
25 EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x1d, 0x30, true}),
26 kLayoutGoals.end());
27 // Has KeyA
28 EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x00, 0x61, true}),
29 kLayoutGoals.end());
30 // Has Equal
31 EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x18, 0x3d, false}),
32 kLayoutGoals.end());
33 // Has IntlBackslash
34 EXPECT_NE(
35 std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x0a, 0x200000020, false}),
36 kLayoutGoals.end());
37}
const std::vector< LayoutGoal > kLayoutGoals

◆ TEST() [548/709]

flutter::testing::TEST ( LayerStateStack  ,
AccessorsDieWithoutDelegate   
)

Definition at line 17 of file layer_state_stack_unittests.cc.

17 {
18 LayerStateStack state_stack;
19
20 EXPECT_DEATH_IF_SUPPORTED(state_stack.device_cull_rect(),
21 "LayerStateStack state queried without a delegate");
22 EXPECT_DEATH_IF_SUPPORTED(state_stack.local_cull_rect(),
23 "LayerStateStack state queried without a delegate");
24 EXPECT_DEATH_IF_SUPPORTED(state_stack.transform_3x3(),
25 "LayerStateStack state queried without a delegate");
26 EXPECT_DEATH_IF_SUPPORTED(state_stack.transform_4x4(),
27 "LayerStateStack state queried without a delegate");
28 EXPECT_DEATH_IF_SUPPORTED(state_stack.content_culled({}),
29 "LayerStateStack state queried without a delegate");
30 {
31 // state_stack.set_preroll_delegate(kGiantRect, SkMatrix::I());
32 auto mutator = state_stack.save();
33 mutator.applyOpacity({}, 0.5);
34 state_stack.clear_delegate();
35 auto restore = state_stack.applyState({}, 0);
36 }
37}
void applyOpacity(const SkRect &bounds, SkScalar opacity)
AutoRestore applyState(const SkRect &bounds, int can_apply_flags)
bool content_culled(const SkRect &content_bounds) const

◆ TEST() [549/709]

flutter::testing::TEST ( LayerStateStack  ,
ColorFilter   
)

Definition at line 209 of file layer_state_stack_unittests.cc.

209 {
210 SkRect rect = {10, 10, 20, 20};
211 std::shared_ptr<DlBlendColorFilter> outer_filter =
212 std::make_shared<DlBlendColorFilter>(DlColor::kYellow(),
213 DlBlendMode::kColorBurn);
214 std::shared_ptr<DlBlendColorFilter> inner_filter =
215 std::make_shared<DlBlendColorFilter>(DlColor::kRed(),
216 DlBlendMode::kColorBurn);
217
218 LayerStateStack state_stack;
219 state_stack.set_preroll_delegate(SkRect::MakeLTRB(0, 0, 50, 50));
220 {
221 auto mutator = state_stack.save();
222 mutator.applyColorFilter(rect, outer_filter);
223
224 ASSERT_EQ(state_stack.outstanding_color_filter(), outer_filter);
225
226 // Check nested color filters result in nested saveLayers
227 {
228 auto mutator2 = state_stack.save();
229 mutator.applyColorFilter(rect, inner_filter);
230
231 ASSERT_EQ(state_stack.outstanding_color_filter(), inner_filter);
232
233 // Verify output with applyState that does not accept color filters
234 {
235 DisplayListBuilder builder;
236 state_stack.set_delegate(&builder);
237 {
238 auto restore = state_stack.applyState(rect, 0);
239 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
240
242 state_stack.fill(paint);
243 builder.DrawRect(rect, paint);
244 }
245 state_stack.clear_delegate();
246
247 DisplayListBuilder expected;
248 DlPaint outer_save_paint = DlPaint().setColorFilter(outer_filter);
249 DlPaint inner_save_paint = DlPaint().setColorFilter(inner_filter);
250 expected.SaveLayer(&rect, &outer_save_paint);
251 expected.SaveLayer(&rect, &inner_save_paint);
252 expected.DrawRect(rect, DlPaint());
253 expected.Restore();
254 expected.Restore();
255 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
256 }
257
258 // Verify output with applyState that accepts color filters
259 {
260 SkRect rect = {10, 10, 20, 20};
261 DisplayListBuilder builder;
262 state_stack.set_delegate(&builder);
263 {
264 auto restore = state_stack.applyState(
265 rect, LayerStateStack::kCallerCanApplyColorFilter);
266 ASSERT_EQ(state_stack.outstanding_color_filter(), inner_filter);
267
268 DlPaint paint;
269 state_stack.fill(paint);
270 builder.DrawRect(rect, paint);
271 }
272 state_stack.clear_delegate();
273
274 DisplayListBuilder expected;
275 DlPaint save_paint = DlPaint().setColorFilter(outer_filter);
276 DlPaint draw_paint = DlPaint().setColorFilter(inner_filter);
277 expected.SaveLayer(&rect, &save_paint);
278 expected.DrawRect(rect, draw_paint);
279 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
280 }
281 }
282
283 ASSERT_EQ(state_stack.outstanding_color_filter(), outer_filter);
284 }
285
286 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
287}
void applyColorFilter(const SkRect &bounds, const std::shared_ptr< const DlColorFilter > &filter)
void fill(MutatorsStack *mutators)
void set_preroll_delegate(const SkRect &cull_rect, const SkMatrix &matrix)
void set_delegate(DlCanvas *canvas)
std::shared_ptr< const DlColorFilter > outstanding_color_filter() const
static void draw_paint(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)

◆ TEST() [550/709]

flutter::testing::TEST ( LayerStateStack  ,
ColorFilterAndImageFilterInteraction   
)

Definition at line 490 of file layer_state_stack_unittests.cc.

490 {
491 SkRect rect = {10, 10, 20, 20};
492 std::shared_ptr<DlBlendColorFilter> color_filter =
493 std::make_shared<DlBlendColorFilter>(DlColor::kYellow(),
494 DlBlendMode::kColorBurn);
495 std::shared_ptr<DlBlurImageFilter> image_filter =
496 std::make_shared<DlBlurImageFilter>(2.0f, 2.0f, DlTileMode::kClamp);
497
498 DisplayListBuilder builder;
499 LayerStateStack state_stack;
500 state_stack.set_delegate(&builder);
501 ASSERT_EQ(builder.GetSaveCount(), 1);
502
503 {
504 auto mutator1 = state_stack.save();
505 ASSERT_EQ(builder.GetSaveCount(), 1);
506 mutator1.applyColorFilter(rect, color_filter);
507 ASSERT_EQ(builder.GetSaveCount(), 1);
508
509 {
510 auto mutator2 = state_stack.save();
511 ASSERT_EQ(builder.GetSaveCount(), 1);
512 mutator2.applyImageFilter(rect, image_filter);
513
514 // color filter applied to image filter can be applied together
515 ASSERT_EQ(builder.GetSaveCount(), 1);
516 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
517 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
518 }
519 ASSERT_EQ(builder.GetSaveCount(), 1);
520 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
521 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
522 }
523 ASSERT_EQ(builder.GetSaveCount(), 1);
524 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
525 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
526
527 {
528 auto mutator1 = state_stack.save();
529 ASSERT_EQ(builder.GetSaveCount(), 1);
530 mutator1.applyImageFilter(rect, image_filter);
531 ASSERT_EQ(builder.GetSaveCount(), 1);
532
533 {
534 auto mutator2 = state_stack.save();
535 ASSERT_EQ(builder.GetSaveCount(), 1);
536 mutator2.applyColorFilter(rect, color_filter);
537
538 // The image filter will have been resolved by a saveLayer
539 ASSERT_EQ(builder.GetSaveCount(), 2);
540 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
541 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
542 }
543 ASSERT_EQ(builder.GetSaveCount(), 1);
544 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
545 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
546 }
547 ASSERT_EQ(builder.GetSaveCount(), 1);
548 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
549 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
550}
std::shared_ptr< const DlImageFilter > outstanding_image_filter() const

◆ TEST() [551/709]

flutter::testing::TEST ( LayerStateStack  ,
Defaults   
)

Definition at line 40 of file layer_state_stack_unittests.cc.

40 {
41 LayerStateStack state_stack;
42
43 ASSERT_EQ(state_stack.canvas_delegate(), nullptr);
44 ASSERT_EQ(state_stack.checkerboard_func(), nullptr);
45 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
46 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
47 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
48 ASSERT_EQ(state_stack.outstanding_bounds(), SkRect());
49
50 state_stack.set_preroll_delegate(kGiantRect, SkMatrix::I());
51 ASSERT_EQ(state_stack.device_cull_rect(), kGiantRect);
52 ASSERT_EQ(state_stack.local_cull_rect(), kGiantRect);
53 ASSERT_EQ(state_stack.transform_3x3(), SkMatrix::I());
54 ASSERT_EQ(state_stack.transform_4x4(), SkM44());
55
56 DlPaint dl_paint;
57 state_stack.fill(dl_paint);
58 ASSERT_EQ(dl_paint, DlPaint());
59}
#define SK_Scalar1
Definition SkScalar.h:18
CheckerboardFunc checkerboard_func() const
SkScalar outstanding_opacity() const

◆ TEST() [552/709]

flutter::testing::TEST ( LayerStateStack  ,
ImageFilter   
)

Definition at line 289 of file layer_state_stack_unittests.cc.

289 {
290 SkRect rect = {10, 10, 20, 20};
291 std::shared_ptr<DlBlurImageFilter> outer_filter =
292 std::make_shared<DlBlurImageFilter>(2.0f, 2.0f, DlTileMode::kClamp);
293 std::shared_ptr<DlBlurImageFilter> inner_filter =
294 std::make_shared<DlBlurImageFilter>(3.0f, 3.0f, DlTileMode::kClamp);
295 SkRect inner_src_rect = rect;
296 SkRect outer_src_rect;
297 ASSERT_EQ(inner_filter->map_local_bounds(rect, outer_src_rect),
298 &outer_src_rect);
299
300 LayerStateStack state_stack;
301 state_stack.set_preroll_delegate(SkRect::MakeLTRB(0, 0, 50, 50));
302 {
303 auto mutator = state_stack.save();
304 mutator.applyImageFilter(outer_src_rect, outer_filter);
305
306 ASSERT_EQ(state_stack.outstanding_image_filter(), outer_filter);
307
308 // Check nested color filters result in nested saveLayers
309 {
310 auto mutator2 = state_stack.save();
311 mutator.applyImageFilter(rect, inner_filter);
312
313 ASSERT_EQ(state_stack.outstanding_image_filter(), inner_filter);
314
315 // Verify output with applyState that does not accept color filters
316 {
317 DisplayListBuilder builder;
318 state_stack.set_delegate(&builder);
319 {
320 auto restore = state_stack.applyState(rect, 0);
321 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
322
324 state_stack.fill(paint);
325 builder.DrawRect(rect, paint);
326 }
327 state_stack.clear_delegate();
328
329 DisplayListBuilder expected;
330 DlPaint outer_save_paint = DlPaint().setImageFilter(outer_filter);
331 DlPaint inner_save_paint = DlPaint().setImageFilter(inner_filter);
332 expected.SaveLayer(&outer_src_rect, &outer_save_paint);
333 expected.SaveLayer(&inner_src_rect, &inner_save_paint);
334 expected.DrawRect(rect, DlPaint());
335 expected.Restore();
336 expected.Restore();
337 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
338 }
339
340 // Verify output with applyState that accepts color filters
341 {
342 SkRect rect = {10, 10, 20, 20};
343 DisplayListBuilder builder;
344 state_stack.set_delegate(&builder);
345 {
346 auto restore = state_stack.applyState(
347 rect, LayerStateStack::kCallerCanApplyImageFilter);
348 ASSERT_EQ(state_stack.outstanding_image_filter(), inner_filter);
349
350 DlPaint paint;
351 state_stack.fill(paint);
352 builder.DrawRect(rect, paint);
353 }
354 state_stack.clear_delegate();
355
356 DisplayListBuilder expected;
357 DlPaint save_paint = DlPaint().setImageFilter(outer_filter);
358 DlPaint draw_paint = DlPaint().setImageFilter(inner_filter);
359 expected.SaveLayer(&outer_src_rect, &save_paint);
360 expected.DrawRect(rect, draw_paint);
361 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
362 }
363 }
364
365 ASSERT_EQ(state_stack.outstanding_image_filter(), outer_filter);
366 }
367
368 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
369}
void applyImageFilter(const SkRect &bounds, const std::shared_ptr< const DlImageFilter > &filter)

◆ TEST() [553/709]

flutter::testing::TEST ( LayerStateStack  ,
OldDelegateIsRolledBack   
)

Definition at line 92 of file layer_state_stack_unittests.cc.

92 {
93 LayerStateStack state_stack;
94 DisplayListBuilder builder;
95 DisplayListBuilder builder2;
96 DlCanvas& canvas = builder2;
97
98 ASSERT_TRUE(builder.GetTransform().isIdentity());
99 ASSERT_TRUE(canvas.GetTransform().isIdentity());
100
101 state_stack.set_delegate(&builder);
102
103 ASSERT_TRUE(builder.GetTransform().isIdentity());
104 ASSERT_TRUE(canvas.GetTransform().isIdentity());
105
106 auto mutator = state_stack.save();
107 mutator.translate({10, 10});
108
109 ASSERT_EQ(builder.GetTransform(), SkMatrix::Translate(10, 10));
110 ASSERT_TRUE(canvas.GetTransform().isIdentity());
111
112 state_stack.set_delegate(&canvas);
113
114 ASSERT_TRUE(builder.GetTransform().isIdentity());
115 ASSERT_EQ(canvas.GetTransform(), SkMatrix::Translate(10, 10));
116
117 state_stack.set_preroll_delegate(SkRect::MakeWH(100, 100));
118
119 ASSERT_TRUE(builder.GetTransform().isIdentity());
120 ASSERT_TRUE(canvas.GetTransform().isIdentity());
121
122 state_stack.set_delegate(&builder);
123 state_stack.clear_delegate();
124
125 ASSERT_TRUE(builder.GetTransform().isIdentity());
126 ASSERT_TRUE(canvas.GetTransform().isIdentity());
127
128 state_stack.set_delegate(&canvas);
129 state_stack.clear_delegate();
130
131 ASSERT_TRUE(builder.GetTransform().isIdentity());
132 ASSERT_TRUE(canvas.GetTransform().isIdentity());
133}
bool isIdentity() const
Definition SkMatrix.h:223
virtual SkMatrix GetTransform() const =0
void translate(SkScalar tx, SkScalar ty)

◆ TEST() [554/709]

flutter::testing::TEST ( LayerStateStack  ,
Opacity   
)

Definition at line 135 of file layer_state_stack_unittests.cc.

135 {
136 SkRect rect = {10, 10, 20, 20};
137
138 LayerStateStack state_stack;
139 state_stack.set_preroll_delegate(SkRect::MakeLTRB(0, 0, 50, 50));
140 {
141 auto mutator = state_stack.save();
142 mutator.applyOpacity(rect, 0.5f);
143
144 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
145 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
146
147 // Check nested opacities multiply with each other
148 {
149 auto mutator2 = state_stack.save();
150 mutator.applyOpacity(rect, 0.5f);
151
152 ASSERT_EQ(state_stack.outstanding_opacity(), 0.25f);
153 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
154
155 // Verify output with applyState that does not accept opacity
156 {
157 DisplayListBuilder builder;
158 state_stack.set_delegate(&builder);
159 {
160 auto restore = state_stack.applyState(rect, 0);
161 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
162 ASSERT_EQ(state_stack.outstanding_bounds(), SkRect());
163
165 state_stack.fill(paint);
166 builder.DrawRect(rect, paint);
167 }
168 state_stack.clear_delegate();
169
170 DisplayListBuilder expected;
171 DlPaint save_paint =
172 DlPaint().setOpacity(state_stack.outstanding_opacity());
173 expected.SaveLayer(&rect, &save_paint);
174 expected.DrawRect(rect, DlPaint());
175 expected.Restore();
176 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
177 }
178
179 // Verify output with applyState that accepts opacity
180 {
181 DisplayListBuilder builder;
182 state_stack.set_delegate(&builder);
183 {
184 auto restore = state_stack.applyState(
185 rect, LayerStateStack::kCallerCanApplyOpacity);
186 ASSERT_EQ(state_stack.outstanding_opacity(), 0.25f);
187 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
188
189 DlPaint paint;
190 state_stack.fill(paint);
191 builder.DrawRect(rect, paint);
192 }
193 state_stack.clear_delegate();
194
195 DisplayListBuilder expected;
196 expected.DrawRect(rect, DlPaint().setOpacity(0.25f));
197 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
198 }
199 }
200
201 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
202 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
203 }
204
205 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
206 ASSERT_EQ(state_stack.outstanding_bounds(), SkRect());
207}

◆ TEST() [555/709]

flutter::testing::TEST ( LayerStateStack  ,
OpacityAndColorFilterInteraction   
)

Definition at line 371 of file layer_state_stack_unittests.cc.

371 {
372 SkRect rect = {10, 10, 20, 20};
373 std::shared_ptr<DlBlendColorFilter> color_filter =
374 std::make_shared<DlBlendColorFilter>(DlColor::kYellow(),
375 DlBlendMode::kColorBurn);
376
377 DisplayListBuilder builder;
378 LayerStateStack state_stack;
379 state_stack.set_delegate(&builder);
380 ASSERT_EQ(builder.GetSaveCount(), 1);
381
382 {
383 auto mutator1 = state_stack.save();
384 ASSERT_EQ(builder.GetSaveCount(), 1);
385 mutator1.applyOpacity(rect, 0.5f);
386 ASSERT_EQ(builder.GetSaveCount(), 1);
387
388 {
389 auto mutator2 = state_stack.save();
390 ASSERT_EQ(builder.GetSaveCount(), 1);
391 mutator2.applyColorFilter(rect, color_filter);
392
393 // The opacity will have been resolved by a saveLayer
394 ASSERT_EQ(builder.GetSaveCount(), 2);
395 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
396 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
397 }
398 ASSERT_EQ(builder.GetSaveCount(), 1);
399 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
400 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
401 }
402 ASSERT_EQ(builder.GetSaveCount(), 1);
403 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
404 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
405
406 {
407 auto mutator1 = state_stack.save();
408 ASSERT_EQ(builder.GetSaveCount(), 1);
409 mutator1.applyColorFilter(rect, color_filter);
410 ASSERT_EQ(builder.GetSaveCount(), 1);
411
412 {
413 auto mutator2 = state_stack.save();
414 ASSERT_EQ(builder.GetSaveCount(), 1);
415 mutator2.applyOpacity(rect, 0.5f);
416
417 // color filter applied to opacity can be applied together
418 ASSERT_EQ(builder.GetSaveCount(), 1);
419 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
420 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
421 }
422 ASSERT_EQ(builder.GetSaveCount(), 1);
423 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
424 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
425 }
426 ASSERT_EQ(builder.GetSaveCount(), 1);
427 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
428 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
429}

◆ TEST() [556/709]

flutter::testing::TEST ( LayerStateStack  ,
OpacityAndImageFilterInteraction   
)

Definition at line 431 of file layer_state_stack_unittests.cc.

431 {
432 SkRect rect = {10, 10, 20, 20};
433 std::shared_ptr<DlBlurImageFilter> image_filter =
434 std::make_shared<DlBlurImageFilter>(2.0f, 2.0f, DlTileMode::kClamp);
435
436 DisplayListBuilder builder;
437 LayerStateStack state_stack;
438 state_stack.set_delegate(&builder);
439 ASSERT_EQ(builder.GetSaveCount(), 1);
440
441 {
442 auto mutator1 = state_stack.save();
443 ASSERT_EQ(builder.GetSaveCount(), 1);
444 mutator1.applyOpacity(rect, 0.5f);
445 ASSERT_EQ(builder.GetSaveCount(), 1);
446
447 {
448 auto mutator2 = state_stack.save();
449 ASSERT_EQ(builder.GetSaveCount(), 1);
450 mutator2.applyImageFilter(rect, image_filter);
451
452 // opacity applied to image filter can be applied together
453 ASSERT_EQ(builder.GetSaveCount(), 1);
454 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
455 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
456 }
457 ASSERT_EQ(builder.GetSaveCount(), 1);
458 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
459 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
460 }
461 ASSERT_EQ(builder.GetSaveCount(), 1);
462 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
463 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
464
465 {
466 auto mutator1 = state_stack.save();
467 ASSERT_EQ(builder.GetSaveCount(), 1);
468 mutator1.applyImageFilter(rect, image_filter);
469 ASSERT_EQ(builder.GetSaveCount(), 1);
470
471 {
472 auto mutator2 = state_stack.save();
473 ASSERT_EQ(builder.GetSaveCount(), 1);
474 mutator2.applyOpacity(rect, 0.5f);
475
476 // The image filter will have been resolved by a saveLayer
477 ASSERT_EQ(builder.GetSaveCount(), 2);
478 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
479 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
480 }
481 ASSERT_EQ(builder.GetSaveCount(), 1);
482 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
483 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
484 }
485 ASSERT_EQ(builder.GetSaveCount(), 1);
486 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
487 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
488}

◆ TEST() [557/709]

flutter::testing::TEST ( LayerStateStack  ,
SingularDelegate   
)

Definition at line 61 of file layer_state_stack_unittests.cc.

61 {
62 LayerStateStack state_stack;
63 ASSERT_EQ(state_stack.canvas_delegate(), nullptr);
64
65 // Two different DlCanvas implementators
66 DisplayListBuilder builder;
67 DisplayListBuilder builder2;
68 DlCanvas& canvas = builder2;
69
70 // no delegate -> builder delegate
71 state_stack.set_delegate(&builder);
72 ASSERT_EQ(state_stack.canvas_delegate(), &builder);
73
74 // builder delegate -> DlCanvas delegate
75 state_stack.set_delegate(&canvas);
76 ASSERT_EQ(state_stack.canvas_delegate(), &canvas);
77
78 // DlCanvas delegate -> builder delegate
79 state_stack.set_delegate(&builder);
80 ASSERT_EQ(state_stack.canvas_delegate(), &builder);
81
82 // builder delegate -> no delegate
83 state_stack.clear_delegate();
84 ASSERT_EQ(state_stack.canvas_delegate(), nullptr);
85
86 // DlCanvas delegate -> no delegate
87 state_stack.set_delegate(&canvas);
88 state_stack.clear_delegate();
89 ASSERT_EQ(state_stack.canvas_delegate(), nullptr);
90}

◆ TEST() [558/709]

flutter::testing::TEST ( MathTest  ,
Constants   
)

Definition at line 13 of file math_unittests.cc.

13 {
14 // Don't use the constants in cmath as those aren't portable.
15 EXPECT_FLOAT_EQ(std::log2(math::kE), math::kLog2E);
16 EXPECT_FLOAT_EQ(std::log10(math::kE), math::kLog10E);
17 EXPECT_FLOAT_EQ(std::log(2.0f), math::kLogE2);
18 EXPECT_FLOAT_EQ(math::kPi / 2.0f, math::kPiOver2);
19 EXPECT_FLOAT_EQ(math::kPi / 4.0f, math::kPiOver4);
20 EXPECT_FLOAT_EQ(1.0f / math::kPi, math::k1OverPi);
21 EXPECT_FLOAT_EQ(2.0f / math::kPi, math::k2OverPi);
22 EXPECT_FLOAT_EQ(std::sqrt(2.0f), math::kSqrt2);
23 EXPECT_FLOAT_EQ(1.0f / std::sqrt(2.0f), math::k1OverSqrt2);
24}

◆ TEST() [559/709]

flutter::testing::TEST ( MockTextureTest  ,
Callbacks   
)

Definition at line 14 of file mock_texture_unittests.cc.

14 {
15 auto texture = std::make_shared<MockTexture>(0);
16
17 ASSERT_FALSE(texture->gr_context_created());
18 texture->OnGrContextCreated();
19 ASSERT_TRUE(texture->gr_context_created());
20
21 ASSERT_FALSE(texture->gr_context_destroyed());
22 texture->OnGrContextDestroyed();
23 ASSERT_TRUE(texture->gr_context_destroyed());
24
25 ASSERT_FALSE(texture->unregistered());
26 texture->OnTextureUnregistered();
27 ASSERT_TRUE(texture->unregistered());
28}

◆ TEST() [560/709]

flutter::testing::TEST ( MockTextureTest  ,
PaintCalls   
)

Definition at line 30 of file mock_texture_unittests.cc.

30 {
31 DisplayListBuilder builder;
32 const SkRect paint_bounds1 = SkRect::MakeWH(1.0f, 1.0f);
33 const SkRect paint_bounds2 = SkRect::MakeWH(2.0f, 2.0f);
34 const DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
35 const auto texture_image = MockTexture::MakeTestTexture(20, 20, 5);
36 auto texture = std::make_shared<MockTexture>(0, texture_image);
37
39 .canvas = &builder,
40 };
41 texture->Paint(context, paint_bounds1, false, sampling);
42 texture->Paint(context, paint_bounds2, true, sampling);
43
44 SkRect src1 = SkRect::Make(texture_image->bounds());
45 SkRect src2 = src1.makeInset(1.0, 1.0f);
46
47 DisplayListBuilder expected_builder;
48 expected_builder.DrawImageRect(texture_image, src1, paint_bounds1, sampling);
49 expected_builder.DrawImageRect(texture_image, src2, paint_bounds2, sampling);
51 DisplayListsEQ_Verbose(builder.Build(), expected_builder.Build()));
52}
void DrawImageRect(const sk_sp< DlImage > &image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast) override

◆ TEST() [561/709]

flutter::testing::TEST ( MockTextureTest  ,
PaintCallsWithLinearSampling   
)

Definition at line 54 of file mock_texture_unittests.cc.

54 {
55 DisplayListBuilder builder;
56 const SkRect paint_bounds1 = SkRect::MakeWH(1.0f, 1.0f);
57 const SkRect paint_bounds2 = SkRect::MakeWH(2.0f, 2.0f);
58 const auto sampling = DlImageSampling::kLinear;
59 const auto texture_image = MockTexture::MakeTestTexture(20, 20, 5);
60 auto texture = std::make_shared<MockTexture>(0, texture_image);
61
63 .canvas = &builder,
64 };
65 texture->Paint(context, paint_bounds1, false, sampling);
66 texture->Paint(context, paint_bounds2, true, sampling);
67
68 SkRect src1 = SkRect::Make(texture_image->bounds());
69 SkRect src2 = src1.makeInset(1.0, 1.0f);
70
71 DisplayListBuilder expected_builder;
72 expected_builder.DrawImageRect(texture_image, src1, paint_bounds1, sampling);
73 expected_builder.DrawImageRect(texture_image, src2, paint_bounds2, sampling);
75 DisplayListsEQ_Verbose(builder.Build(), expected_builder.Build()));
76}

◆ TEST() [562/709]

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

Definition at line 23 of file window_unittests.cc.

23 {
25 ASSERT_TRUE(TRUE);
26}
Mock for the |FlutterWindow| base class.
Definition mock_window.h:17

◆ TEST() [563/709]

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

Definition at line 364 of file window_unittests.cc.

364 {
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}
LRESULT InjectWindowMessage(UINT const message, WPARAM const wparam, LPARAM const lparam)
LONG_PTR LRESULT
UINT_PTR WPARAM

◆ TEST() [564/709]

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

Definition at line 28 of file window_unittests.cc.

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

◆ TEST() [565/709]

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

Definition at line 152 of file window_unittests.cc.

152 {
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,
158 .Times(1);
159
160 window.InjectWindowMessage(WM_MOUSEHWHEEL, MAKEWPARAM(0, scroll_amount), 0);
161}
@ kFlutterPointerDeviceKindMouse
Definition embedder.h:1006

◆ TEST() [566/709]

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

Definition at line 179 of file window_unittests.cc.

179 {
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}
LPARAM CreateKeyEventLparam(USHORT scancode, bool extended, bool was_down, USHORT repeat_count, bool context_code, bool transition_state)

◆ TEST() [567/709]

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

Definition at line 211 of file window_unittests.cc.

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

◆ TEST() [568/709]

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

Definition at line 230 of file window_unittests.cc.

230 {
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() [569/709]

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

Definition at line 251 of file window_unittests.cc.

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

◆ TEST() [570/709]

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

Definition at line 187 of file window_unittests.cc.

187 {
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() [571/709]

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

Definition at line 163 of file window_unittests.cc.

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

◆ TEST() [572/709]

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}
Mock for the |Window| base class.

◆ TEST() [573/709]

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

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

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

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

Definition at line 281 of file window_unittests.cc.

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

◆ TEST() [577/709]

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}

◆ TEST() [578/709]

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

Definition at line 195 of file window_unittests.cc.

195 {
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() [579/709]

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

Definition at line 203 of file window_unittests.cc.

203 {
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() [580/709]

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}

◆ TEST() [581/709]

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}

◆ TEST() [582/709]

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

Definition at line 33 of file window_unittests.cc.

33 {
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,
40 .Times(1);
41
42 window.InjectWindowMessage(WM_MOUSEWHEEL, MAKEWPARAM(0, scroll_amount), 0);
43}

◆ TEST() [583/709]

flutter::testing::TEST ( Mutator  ,
CopyConstructor   
)

Definition at line 224 of file mutators_stack_unittests.cc.

224 {
225 SkRect rect = SkRect::MakeEmpty();
226 Mutator mutator = Mutator(rect);
227 Mutator copy = Mutator(mutator);
228 ASSERT_TRUE(mutator == copy);
229
230 SkRRect rrect = SkRRect::MakeEmpty();
231 Mutator mutator2 = Mutator(rrect);
232 Mutator copy2 = Mutator(mutator2);
233 ASSERT_TRUE(mutator2 == copy2);
234
235 SkPath path;
236 Mutator mutator3 = Mutator(path);
237 Mutator copy3 = Mutator(mutator3);
238 ASSERT_TRUE(mutator3 == copy3);
239
240 SkMatrix matrix;
241 matrix.setIdentity();
242 Mutator mutator4 = Mutator(matrix);
243 Mutator copy4 = Mutator(mutator4);
244 ASSERT_TRUE(mutator4 == copy4);
245
246 int alpha = 240;
247 Mutator mutator5 = Mutator(alpha);
248 Mutator copy5 = Mutator(mutator5);
249 ASSERT_TRUE(mutator5 == copy5);
250
251 auto filter = std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
252 Mutator mutator6 = Mutator(filter, SkRect::MakeEmpty());
253 Mutator copy6 = Mutator(mutator6);
254 ASSERT_TRUE(mutator6 == copy6);
255}
static SkRRect MakeEmpty()
Definition SkRRect.h:142
Definition copy.py:1

◆ TEST() [584/709]

flutter::testing::TEST ( Mutator  ,
Equality   
)

Definition at line 257 of file mutators_stack_unittests.cc.

257 {
258 SkMatrix matrix;
259 matrix.setIdentity();
260 Mutator mutator = Mutator(matrix);
261 Mutator other_mutator = Mutator(matrix);
262 ASSERT_TRUE(mutator == other_mutator);
263
264 SkRect rect = SkRect::MakeEmpty();
265 Mutator mutator2 = Mutator(rect);
266 Mutator other_mutator2 = Mutator(rect);
267 ASSERT_TRUE(mutator2 == other_mutator2);
268
269 SkRRect rrect = SkRRect::MakeEmpty();
270 Mutator mutator3 = Mutator(rrect);
271 Mutator other_mutator3 = Mutator(rrect);
272 ASSERT_TRUE(mutator3 == other_mutator3);
273
274 SkPath path;
275 flutter::Mutator mutator4 = flutter::Mutator(path);
276 flutter::Mutator other_mutator4 = flutter::Mutator(path);
277 ASSERT_TRUE(mutator4 == other_mutator4);
278 ASSERT_FALSE(mutator2 == mutator);
279 int alpha = 240;
280 Mutator mutator5 = Mutator(alpha);
281 Mutator other_mutator5 = Mutator(alpha);
282 ASSERT_TRUE(mutator5 == other_mutator5);
283
284 auto filter1 = std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
285 auto filter2 = std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
286 Mutator mutator6 = Mutator(filter1, SkRect::MakeEmpty());
287 Mutator other_mutator6 = Mutator(filter2, SkRect::MakeEmpty());
288 ASSERT_TRUE(mutator6 == other_mutator6);
289}

◆ TEST() [585/709]

flutter::testing::TEST ( Mutator  ,
Initialization   
)

Definition at line 192 of file mutators_stack_unittests.cc.

192 {
193 SkRect rect = SkRect::MakeEmpty();
194 Mutator mutator = Mutator(rect);
195 ASSERT_TRUE(mutator.GetType() == MutatorType::kClipRect);
196 ASSERT_TRUE(mutator.GetRect() == rect);
197
198 SkRRect rrect = SkRRect::MakeEmpty();
199 Mutator mutator2 = Mutator(rrect);
200 ASSERT_TRUE(mutator2.GetType() == MutatorType::kClipRRect);
201 ASSERT_TRUE(mutator2.GetRRect() == rrect);
202
203 SkPath path;
204 Mutator mutator3 = Mutator(path);
205 ASSERT_TRUE(mutator3.GetType() == MutatorType::kClipPath);
206 ASSERT_TRUE(mutator3.GetPath() == path);
207
208 SkMatrix matrix;
209 matrix.setIdentity();
210 Mutator mutator4 = Mutator(matrix);
211 ASSERT_TRUE(mutator4.GetType() == MutatorType::kTransform);
212 ASSERT_TRUE(mutator4.GetMatrix() == matrix);
213
214 int alpha = 240;
215 Mutator mutator5 = Mutator(alpha);
216 ASSERT_TRUE(mutator5.GetType() == MutatorType::kOpacity);
217
218 auto filter = std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
219 Mutator mutator6 = Mutator(filter, SkRect::MakeEmpty());
220 ASSERT_TRUE(mutator6.GetType() == MutatorType::kBackdropFilter);
221 ASSERT_TRUE(mutator6.GetFilterMutation().GetFilter() == *filter);
222}
const DlImageFilter & GetFilter() const
const SkMatrix & GetMatrix() const
const ImageFilterMutation & GetFilterMutation() const
const MutatorType & GetType() const
const SkPath & GetPath() const
const SkRRect & GetRRect() const
const SkRect & GetRect() const

◆ TEST() [586/709]

flutter::testing::TEST ( Mutator  ,
UnEquality   
)

Definition at line 291 of file mutators_stack_unittests.cc.

291 {
292 SkRect rect = SkRect::MakeEmpty();
293 Mutator mutator = Mutator(rect);
294 SkMatrix matrix;
295 matrix.setIdentity();
296 Mutator not_equal_mutator = Mutator(matrix);
297 ASSERT_TRUE(not_equal_mutator != mutator);
298
299 int alpha = 240;
300 int alpha2 = 241;
301 Mutator mutator2 = Mutator(alpha);
302 Mutator other_mutator2 = Mutator(alpha2);
303 ASSERT_TRUE(mutator2 != other_mutator2);
304
305 auto filter = std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
306 auto filter2 =
307 std::make_shared<DlBlurImageFilter>(10, 10, DlTileMode::kClamp);
308 Mutator mutator3 = Mutator(filter, SkRect::MakeEmpty());
309 Mutator other_mutator3 = Mutator(filter2, SkRect::MakeEmpty());
310 ASSERT_TRUE(mutator3 != other_mutator3);
311}

◆ TEST() [587/709]

flutter::testing::TEST ( MutatorsStack  ,
CopyAndUpdateTheCopy   
)

Definition at line 26 of file mutators_stack_unittests.cc.

26 {
27 MutatorsStack stack;
28 auto rrect = SkRRect::MakeEmpty();
29 auto rect = SkRect::MakeEmpty();
30 stack.PushClipRect(rect);
31 stack.PushClipRRect(rrect);
33 copy.Pop();
34 copy.Pop();
35 ASSERT_TRUE(copy != stack);
36 ASSERT_TRUE(copy.is_empty());
37 ASSERT_TRUE(!stack.is_empty());
38 auto iter = stack.Bottom();
39 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kClipRRect);
40 ASSERT_TRUE(iter->get()->GetRRect() == rrect);
41 ++iter;
42 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kClipRect);
43 ASSERT_TRUE(iter->get()->GetRect() == rect);
44}
const std::vector< std::shared_ptr< Mutator > >::const_reverse_iterator Bottom() const
void PushClipRect(const SkRect &rect)
void PushClipRRect(const SkRRect &rrect)

◆ TEST() [588/709]

flutter::testing::TEST ( MutatorsStack  ,
CopyConstructor   
)

Definition at line 16 of file mutators_stack_unittests.cc.

16 {
17 MutatorsStack stack;
18 auto rrect = SkRRect::MakeEmpty();
19 auto rect = SkRect::MakeEmpty();
20 stack.PushClipRect(rect);
21 stack.PushClipRRect(rrect);
23 ASSERT_TRUE(copy == stack);
24}

◆ TEST() [589/709]

flutter::testing::TEST ( MutatorsStack  ,
Equality   
)

Definition at line 159 of file mutators_stack_unittests.cc.

159 {
160 MutatorsStack stack;
161 SkMatrix matrix = SkMatrix::Scale(1, 1);
162 stack.PushTransform(matrix);
163 SkRect rect = SkRect::MakeEmpty();
164 stack.PushClipRect(rect);
165 SkRRect rrect = SkRRect::MakeEmpty();
166 stack.PushClipRRect(rrect);
167 SkPath path;
168 stack.PushClipPath(path);
169 int alpha = 240;
170 stack.PushOpacity(alpha);
171 auto filter = std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
172 stack.PushBackdropFilter(filter, SkRect::MakeEmpty());
173
174 MutatorsStack stack_other;
175 SkMatrix matrix_other = SkMatrix::Scale(1, 1);
176 stack_other.PushTransform(matrix_other);
177 SkRect rect_other = SkRect::MakeEmpty();
178 stack_other.PushClipRect(rect_other);
179 SkRRect rrect_other = SkRRect::MakeEmpty();
180 stack_other.PushClipRRect(rrect_other);
181 SkPath other_path;
182 stack_other.PushClipPath(other_path);
183 int other_alpha = 240;
184 stack_other.PushOpacity(other_alpha);
185 auto other_filter =
186 std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
187 stack_other.PushBackdropFilter(other_filter, SkRect::MakeEmpty());
188
189 ASSERT_TRUE(stack == stack_other);
190}
void PushClipPath(const SkPath &path)
void PushOpacity(const int &alpha)
void PushBackdropFilter(const std::shared_ptr< const DlImageFilter > &filter, const SkRect &filter_rect)

◆ TEST() [590/709]

flutter::testing::TEST ( MutatorsStack  ,
Initialization   
)

Definition at line 11 of file mutators_stack_unittests.cc.

11 {
12 MutatorsStack stack;
13 ASSERT_TRUE(true);
14}

◆ TEST() [591/709]

flutter::testing::TEST ( MutatorsStack  ,
Pop   
)

Definition at line 116 of file mutators_stack_unittests.cc.

116 {
117 MutatorsStack stack;
118 SkMatrix matrix;
119 matrix.setIdentity();
120 stack.PushTransform(matrix);
121 stack.Pop();
122 auto iter = stack.Bottom();
123 ASSERT_TRUE(iter == stack.Top());
124}
const std::vector< std::shared_ptr< Mutator > >::const_reverse_iterator Top() const

◆ TEST() [592/709]

flutter::testing::TEST ( MutatorsStack  ,
PushBackdropFilter   
)

Definition at line 92 of file mutators_stack_unittests.cc.

92 {
93 MutatorsStack stack;
94 const int num_of_mutators = 10;
95 for (int i = 0; i < num_of_mutators; i++) {
96 auto filter = std::make_shared<DlBlurImageFilter>(i, 5, DlTileMode::kClamp);
97 stack.PushBackdropFilter(filter, SkRect::MakeXYWH(i, i, i, i));
98 }
99
100 auto iter = stack.Begin();
101 int i = 0;
102 while (iter != stack.End()) {
103 ASSERT_EQ(iter->get()->GetType(), MutatorType::kBackdropFilter);
104 ASSERT_EQ(iter->get()->GetFilterMutation().GetFilter().asBlur()->sigma_x(),
105 i);
106 ASSERT_EQ(iter->get()->GetFilterMutation().GetFilterRect().x(), i);
107 ASSERT_EQ(iter->get()->GetFilterMutation().GetFilterRect().x(), i);
108 ASSERT_EQ(iter->get()->GetFilterMutation().GetFilterRect().width(), i);
109 ASSERT_EQ(iter->get()->GetFilterMutation().GetFilterRect().height(), i);
110 ++iter;
111 ++i;
112 }
113 ASSERT_EQ(i, num_of_mutators);
114}
const std::vector< std::shared_ptr< Mutator > >::const_iterator End() const
const std::vector< std::shared_ptr< Mutator > >::const_iterator Begin() const

◆ TEST() [593/709]

flutter::testing::TEST ( MutatorsStack  ,
PushClipPath   
)

Definition at line 64 of file mutators_stack_unittests.cc.

64 {
65 MutatorsStack stack;
67 stack.PushClipPath(path);
68 auto iter = stack.Bottom();
69 ASSERT_TRUE(iter->get()->GetType() == flutter::MutatorType::kClipPath);
70 ASSERT_TRUE(iter->get()->GetPath() == path);
71}

◆ TEST() [594/709]

flutter::testing::TEST ( MutatorsStack  ,
PushClipRect   
)

Definition at line 46 of file mutators_stack_unittests.cc.

46 {
47 MutatorsStack stack;
48 auto rect = SkRect::MakeEmpty();
49 stack.PushClipRect(rect);
50 auto iter = stack.Bottom();
51 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kClipRect);
52 ASSERT_TRUE(iter->get()->GetRect() == rect);
53}

◆ TEST() [595/709]

flutter::testing::TEST ( MutatorsStack  ,
PushClipRRect   
)

Definition at line 55 of file mutators_stack_unittests.cc.

55 {
56 MutatorsStack stack;
57 auto rrect = SkRRect::MakeEmpty();
58 stack.PushClipRRect(rrect);
59 auto iter = stack.Bottom();
60 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kClipRRect);
61 ASSERT_TRUE(iter->get()->GetRRect() == rrect);
62}

◆ TEST() [596/709]

flutter::testing::TEST ( MutatorsStack  ,
PushOpacity   
)

Definition at line 83 of file mutators_stack_unittests.cc.

83 {
84 MutatorsStack stack;
85 int alpha = 240;
86 stack.PushOpacity(alpha);
87 auto iter = stack.Bottom();
88 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kOpacity);
89 ASSERT_TRUE(iter->get()->GetAlpha() == 240);
90}

◆ TEST() [597/709]

flutter::testing::TEST ( MutatorsStack  ,
PushTransform   
)

Definition at line 73 of file mutators_stack_unittests.cc.

73 {
74 MutatorsStack stack;
75 SkMatrix matrix;
76 matrix.setIdentity();
77 stack.PushTransform(matrix);
78 auto iter = stack.Bottom();
79 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kTransform);
80 ASSERT_TRUE(iter->get()->GetMatrix() == matrix);
81}

◆ TEST() [598/709]

flutter::testing::TEST ( MutatorsStack  ,
Traversal   
)

Definition at line 126 of file mutators_stack_unittests.cc.

126 {
127 MutatorsStack stack;
128 SkMatrix matrix;
129 matrix.setIdentity();
130 stack.PushTransform(matrix);
131 auto rect = SkRect::MakeEmpty();
132 stack.PushClipRect(rect);
133 auto rrect = SkRRect::MakeEmpty();
134 stack.PushClipRRect(rrect);
135 auto iter = stack.Bottom();
136 int index = 0;
137 while (iter != stack.Top()) {
138 switch (index) {
139 case 0:
140 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kClipRRect);
141 ASSERT_TRUE(iter->get()->GetRRect() == rrect);
142 break;
143 case 1:
144 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kClipRect);
145 ASSERT_TRUE(iter->get()->GetRect() == rect);
146 break;
147 case 2:
148 ASSERT_TRUE(iter->get()->GetType() == MutatorType::kTransform);
149 ASSERT_TRUE(iter->get()->GetMatrix() == matrix);
150 break;
151 default:
152 break;
153 }
154 ++iter;
155 ++index;
156 }
157}

◆ TEST() [599/709]

flutter::testing::TEST ( OffscreenSurfaceTest  ,
EmptySurfaceIsInvalid   
)

Definition at line 16 of file offscreen_surface_unittests.cc.

16 {
17 auto surface =
18 std::make_unique<OffscreenSurface>(nullptr, SkISize::MakeEmpty());
19 ASSERT_FALSE(surface->IsValid());
20}
static constexpr SkISize MakeEmpty()
Definition SkSize.h:22

◆ TEST() [600/709]

flutter::testing::TEST ( OffscreenSurfaceTest  ,
OnexOneSurfaceIsValid   
)

Definition at line 22 of file offscreen_surface_unittests.cc.

22 {
23 auto surface =
24 std::make_unique<OffscreenSurface>(nullptr, SkISize::Make(1, 1));
25 ASSERT_TRUE(surface->IsValid());
26}

◆ TEST() [601/709]

flutter::testing::TEST ( OffscreenSurfaceTest  ,
PaintSurfaceBlack   
)

Definition at line 28 of file offscreen_surface_unittests.cc.

28 {
29 auto surface =
30 std::make_unique<OffscreenSurface>(nullptr, SkISize::Make(1, 1));
31
32 DlCanvas* canvas = surface->GetCanvas();
33 canvas->Clear(DlColor::kBlack());
34 canvas->Flush();
35
36 auto raster_data = surface->GetRasterData(false);
37 const uint32_t* actual =
38 reinterpret_cast<const uint32_t*>(raster_data->data());
39
40 // picking black as the color since byte ordering seems to matter.
41 ASSERT_EQ(actual[0], 0xFF000000u);
42}
virtual void Flush()=0

◆ TEST() [602/709]

flutter::testing::TEST ( PerformanceOverlayLayer120fps  ,
Gold   
)

Definition at line 230 of file performance_overlay_layer_unittests.cc.

230 {
231 TestPerformanceOverlayLayerGold(120);
232}

◆ TEST() [603/709]

flutter::testing::TEST ( PerformanceOverlayLayer90fps  ,
Gold   
)

Definition at line 226 of file performance_overlay_layer_unittests.cc.

226 {
227 TestPerformanceOverlayLayerGold(90);
228}

◆ TEST() [604/709]

flutter::testing::TEST ( PerformanceOverlayLayerDefault  ,
Gold   
)

Definition at line 222 of file performance_overlay_layer_unittests.cc.

222 {
223 TestPerformanceOverlayLayerGold(60);
224}

◆ TEST() [605/709]

flutter::testing::TEST ( PipelineTest  ,
ConsumeOneVal   
)

Definition at line 21 of file pipeline_unittests.cc.

21 {
22 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(2);
23
24 Continuation continuation = pipeline->Produce();
25
26 const int test_val = 1;
28 continuation.Complete(std::make_unique<int>(test_val));
29 ASSERT_EQ(result.success, true);
30 ASSERT_EQ(result.is_first_item, true);
31
32 PipelineConsumeResult consume_result = pipeline->Consume(
33 [&test_val](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val); });
34
35 ASSERT_EQ(consume_result, PipelineConsumeResult::Done);
36}
PipelineProduceResult Complete(ResourcePtr resource)
Completes the continuation with the specified resource.
Definition pipeline.h:98
PipelineConsumeResult
Definition pipeline.h:29

◆ TEST() [606/709]

flutter::testing::TEST ( PipelineTest  ,
ContinuationCanOnlyBeUsedOnce   
)

Definition at line 38 of file pipeline_unittests.cc.

38 {
39 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(2);
40
41 Continuation continuation = pipeline->Produce();
42
43 const int test_val = 1;
45 continuation.Complete(std::make_unique<int>(test_val));
46 ASSERT_EQ(result.success, true);
47 ASSERT_EQ(result.is_first_item, true);
48
49 PipelineConsumeResult consume_result_1 = pipeline->Consume(
50 [&test_val](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val); });
51
52 result = continuation.Complete(std::make_unique<int>(test_val));
53 ASSERT_EQ(result.success, false);
54 ASSERT_EQ(consume_result_1, PipelineConsumeResult::Done);
55
56 PipelineConsumeResult consume_result_2 =
57 pipeline->Consume([](std::unique_ptr<int> v) { FAIL(); });
58
59 result = continuation.Complete(std::make_unique<int>(test_val));
60 ASSERT_EQ(result.success, false);
61 ASSERT_EQ(consume_result_2, PipelineConsumeResult::NoneAvailable);
62}
#define FAIL(name, result)

◆ TEST() [607/709]

flutter::testing::TEST ( PipelineTest  ,
ProduceIfEmptyDoesNotConsumeWhenQueueIsNotEmpty   
)

Definition at line 110 of file pipeline_unittests.cc.

110 {
111 const int depth = 2;
112 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
113
114 Continuation continuation_1 = pipeline->Produce();
115 Continuation continuation_2 = pipeline->ProduceIfEmpty();
116
117 const int test_val_1 = 1, test_val_2 = 2;
119 continuation_1.Complete(std::make_unique<int>(test_val_1));
120 ASSERT_EQ(result.success, true);
121 ASSERT_EQ(result.is_first_item, true);
122 result = continuation_2.Complete(std::make_unique<int>(test_val_2));
123 ASSERT_EQ(result.success, false);
124
125 PipelineConsumeResult consume_result_1 = pipeline->Consume(
126 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
127 ASSERT_EQ(consume_result_1, PipelineConsumeResult::Done);
128}

◆ TEST() [608/709]

flutter::testing::TEST ( PipelineTest  ,
ProduceIfEmptySuccessfulIfQueueIsEmpty   
)

Definition at line 130 of file pipeline_unittests.cc.

130 {
131 const int depth = 1;
132 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
133
134 Continuation continuation_1 = pipeline->ProduceIfEmpty();
135
136 const int test_val_1 = 1;
138 continuation_1.Complete(std::make_unique<int>(test_val_1));
139 ASSERT_EQ(result.success, true);
140 ASSERT_EQ(result.is_first_item, true);
141
142 PipelineConsumeResult consume_result_1 = pipeline->Consume(
143 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
144 ASSERT_EQ(consume_result_1, PipelineConsumeResult::Done);
145}

◆ TEST() [609/709]

flutter::testing::TEST ( PipelineTest  ,
PushingMoreThanDepthCompletesFirstSubmission   
)

Definition at line 64 of file pipeline_unittests.cc.

64 {
65 const int depth = 1;
66 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
67
68 Continuation continuation_1 = pipeline->Produce();
69 Continuation continuation_2 = pipeline->Produce();
70
71 const int test_val_1 = 1, test_val_2 = 2;
73 continuation_1.Complete(std::make_unique<int>(test_val_1));
74 ASSERT_EQ(result.success, true);
75 ASSERT_EQ(result.is_first_item, true);
76 result = continuation_2.Complete(std::make_unique<int>(test_val_2));
77 ASSERT_EQ(result.success, false);
78
79 PipelineConsumeResult consume_result_1 = pipeline->Consume(
80 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
81
82 ASSERT_EQ(consume_result_1, PipelineConsumeResult::Done);
83}

◆ TEST() [610/709]

flutter::testing::TEST ( PipelineTest  ,
PushingMultiProcessesInOrder   
)

Definition at line 85 of file pipeline_unittests.cc.

85 {
86 const int depth = 2;
87 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
88
89 Continuation continuation_1 = pipeline->Produce();
90 Continuation continuation_2 = pipeline->Produce();
91
92 const int test_val_1 = 1, test_val_2 = 2;
94 continuation_1.Complete(std::make_unique<int>(test_val_1));
95 ASSERT_EQ(result.success, true);
96 ASSERT_EQ(result.is_first_item, true);
97 result = continuation_2.Complete(std::make_unique<int>(test_val_2));
98 ASSERT_EQ(result.success, true);
99 ASSERT_EQ(result.is_first_item, false);
100
101 PipelineConsumeResult consume_result_1 = pipeline->Consume(
102 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
103 ASSERT_EQ(consume_result_1, PipelineConsumeResult::MoreAvailable);
104
105 PipelineConsumeResult consume_result_2 = pipeline->Consume(
106 [&test_val_2](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_2); });
107 ASSERT_EQ(consume_result_2, PipelineConsumeResult::Done);
108}

◆ TEST() [611/709]

flutter::testing::TEST ( PlatformViewEmbedderTest  ,
DeletionDisabledDispatch   
)

Definition at line 172 of file platform_view_embedder_unittests.cc.

172 {
173 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
174 ThreadHost::Type::kPlatform);
176 "HasPlatformMessageHandler", thread_host.platform_thread->GetTaskRunner(),
177 nullptr, nullptr, nullptr);
178 bool did_call = false;
179 {
181 task_runners.GetPlatformTaskRunner()->PostTask([&latch, task_runners,
182 &did_call] {
183 MockDelegate delegate;
185 PlatformViewEmbedder::PlatformDispatchTable platform_dispatch_table;
186 platform_dispatch_table.platform_message_response_callback =
187 [&did_call](std::unique_ptr<PlatformMessage> message) {
188 did_call = true;
189 };
190 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder;
191 auto embedder = std::make_unique<PlatformViewEmbedder>(
192 delegate, task_runners, software_dispatch_table,
193 platform_dispatch_table, external_view_embedder);
194 auto platform_message_handler = embedder->GetPlatformMessageHandler();
196 fml::MakeRefCounted<MockResponse>();
197 std::unique_ptr<PlatformMessage> message =
198 std::make_unique<PlatformMessage>("foo", response);
199 platform_message_handler->HandlePlatformMessage(std::move(message));
200 embedder.reset();
201 latch.Signal();
202 });
203 latch.Wait();
204 }
205 {
207 thread_host.platform_thread->GetTaskRunner()->PostTask(
208 [&latch] { latch.Signal(); });
209 latch.Wait();
210 }
211
212 EXPECT_FALSE(did_call);
213}
fml::RefPtr< fml::TaskRunner > GetPlatformTaskRunner() const
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Definition testing.cc:15
PlatformMessageResponseCallback platform_message_response_callback
The collection of all the threads used by the engine.
Definition thread_host.h:21

◆ TEST() [612/709]

flutter::testing::TEST ( PlatformViewEmbedderTest  ,
Dispatches   
)

Definition at line 127 of file platform_view_embedder_unittests.cc.

127 {
128 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
129 ThreadHost::Type::kPlatform);
131 "HasPlatformMessageHandler", thread_host.platform_thread->GetTaskRunner(),
132 nullptr, nullptr, nullptr);
133 bool did_call = false;
134 std::unique_ptr<PlatformViewEmbedder> embedder;
135 {
137 task_runners.GetPlatformTaskRunner()->PostTask([&latch, task_runners,
138 &did_call, &embedder] {
139 MockDelegate delegate;
141 PlatformViewEmbedder::PlatformDispatchTable platform_dispatch_table;
142 platform_dispatch_table.platform_message_response_callback =
143 [&did_call](std::unique_ptr<PlatformMessage> message) {
144 did_call = true;
145 };
146 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder;
147 embedder = std::make_unique<PlatformViewEmbedder>(
148 delegate, task_runners, software_dispatch_table,
149 platform_dispatch_table, external_view_embedder);
150 auto platform_message_handler = embedder->GetPlatformMessageHandler();
152 fml::MakeRefCounted<MockResponse>();
153 std::unique_ptr<PlatformMessage> message =
154 std::make_unique<PlatformMessage>("foo", response);
155 platform_message_handler->HandlePlatformMessage(std::move(message));
156 latch.Signal();
157 });
158 latch.Wait();
159 }
160 {
162 thread_host.platform_thread->GetTaskRunner()->PostTask([&latch, &embedder] {
163 embedder.reset();
164 latch.Signal();
165 });
166 latch.Wait();
167 }
168
169 EXPECT_TRUE(did_call);
170}

◆ TEST() [613/709]

flutter::testing::TEST ( PlatformViewEmbedderTest  ,
HasPlatformMessageHandler   
)

Definition at line 105 of file platform_view_embedder_unittests.cc.

105 {
106 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
107 ThreadHost::Type::kPlatform);
109 "HasPlatformMessageHandler", thread_host.platform_thread->GetTaskRunner(),
110 nullptr, nullptr, nullptr);
112 task_runners.GetPlatformTaskRunner()->PostTask([&latch, task_runners] {
113 MockDelegate delegate;
115 PlatformViewEmbedder::PlatformDispatchTable platform_dispatch_table;
116 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder;
117 auto embedder = std::make_unique<PlatformViewEmbedder>(
118 delegate, task_runners, software_dispatch_table,
119 platform_dispatch_table, external_view_embedder);
120
121 ASSERT_TRUE(embedder->GetPlatformMessageHandler());
122 latch.Signal();
123 });
124 latch.Wait();
125}

◆ TEST() [614/709]

flutter::testing::TEST ( PlatformViewShell  ,
UpdateSemanticsDoesFlutterViewUpdateCustomAccessibilityActions   
)

Definition at line 165 of file platform_view_android_delegate_unittests.cc.

166 {
167 auto jni_mock = std::make_shared<JNIMock>();
168 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
169
172 action0.id = 0;
173 action0.overrideId = 1;
174 action0.label = "label";
175 action0.hint = "hint";
176 actions.insert(std::make_pair(0, action0));
177
178 std::vector<uint8_t> expected_actions_buffer(16);
179 int32_t* actions_buffer_int32 =
180 reinterpret_cast<int32_t*>(&expected_actions_buffer[0]);
181 std::vector<std::string> expected_action_strings;
182 actions_buffer_int32[0] = action0.id;
183 actions_buffer_int32[1] = action0.overrideId;
184 actions_buffer_int32[2] = expected_action_strings.size();
185 expected_action_strings.push_back(action0.label);
186 actions_buffer_int32[3] = expected_action_strings.size();
187 expected_action_strings.push_back(action0.hint);
188
189 EXPECT_CALL(*jni_mock, FlutterViewUpdateCustomAccessibilityActions(
190 expected_actions_buffer, expected_action_strings));
191 // Creates empty update.
193 delegate->UpdateSemantics(update, actions);
194}
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates

◆ TEST() [615/709]

flutter::testing::TEST ( PlatformViewShell  ,
UpdateSemanticsDoesFlutterViewUpdateSemantics   
)

Definition at line 14 of file platform_view_android_delegate_unittests.cc.

14 {
15 auto jni_mock = std::make_shared<JNIMock>();
16 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
17
20 node0.id = 0;
21 node0.identifier = "identifier";
22 node0.label = "label";
23 node0.tooltip = "tooltip";
24 update.insert(std::make_pair(0, node0));
25
26 std::vector<uint8_t> expected_buffer(192);
27 std::vector<std::vector<uint8_t>> expected_string_attribute_args(0);
28 size_t position = 0;
29 int32_t* buffer_int32 = reinterpret_cast<int32_t*>(&expected_buffer[0]);
30 float* buffer_float32 = reinterpret_cast<float*>(&expected_buffer[0]);
31 std::vector<std::string> expected_strings;
32 buffer_int32[position++] = node0.id;
33 buffer_int32[position++] = node0.flags;
34 buffer_int32[position++] = node0.actions;
35 buffer_int32[position++] = node0.maxValueLength;
36 buffer_int32[position++] = node0.currentValueLength;
37 buffer_int32[position++] = node0.textSelectionBase;
38 buffer_int32[position++] = node0.textSelectionExtent;
39 buffer_int32[position++] = node0.platformViewId;
40 buffer_int32[position++] = node0.scrollChildren;
41 buffer_int32[position++] = node0.scrollIndex;
42 buffer_float32[position++] = static_cast<float>(node0.scrollPosition);
43 buffer_float32[position++] = static_cast<float>(node0.scrollExtentMax);
44 buffer_float32[position++] = static_cast<float>(node0.scrollExtentMin);
45 buffer_int32[position++] = expected_strings.size(); // node0.identifier
46 expected_strings.push_back(node0.identifier);
47 buffer_int32[position++] = expected_strings.size(); // node0.label
48 expected_strings.push_back(node0.label);
49 buffer_int32[position++] = -1; // node0.labelAttributes
50 buffer_int32[position++] = -1; // node0.value
51 buffer_int32[position++] = -1; // node0.valueAttributes
52 buffer_int32[position++] = -1; // node0.increasedValue
53 buffer_int32[position++] = -1; // node0.increasedValueAttributes
54 buffer_int32[position++] = -1; // node0.decreasedValue
55 buffer_int32[position++] = -1; // node0.decreasedValueAttributes
56 buffer_int32[position++] = -1; // node0.hint
57 buffer_int32[position++] = -1; // node0.hintAttributes
58 buffer_int32[position++] = expected_strings.size(); // node0.tooltip
59 expected_strings.push_back(node0.tooltip);
60 buffer_int32[position++] = node0.textDirection;
61 buffer_float32[position++] = node0.rect.left();
62 buffer_float32[position++] = node0.rect.top();
63 buffer_float32[position++] = node0.rect.right();
64 buffer_float32[position++] = node0.rect.bottom();
65 node0.transform.getColMajor(&buffer_float32[position]);
66 position += 16;
67 buffer_int32[position++] = 0; // node0.childrenInTraversalOrder.size();
68 buffer_int32[position++] = 0; // node0.customAccessibilityActions.size();
69 EXPECT_CALL(*jni_mock,
70 FlutterViewUpdateSemantics(expected_buffer, expected_strings,
71 expected_string_attribute_args));
72 // Creates empty custom actions.
74 delegate->UpdateSemantics(update, actions);
75}
void getColMajor(SkScalar v[]) const
Definition SkM44.h:256
constexpr float left() const
Definition SkRect.h:734
constexpr float top() const
Definition SkRect.h:741

◆ TEST() [616/709]

flutter::testing::TEST ( PlatformViewShell  ,
UpdateSemanticsDoesFlutterViewUpdateSemanticsWithStringAttribtes   
)

Definition at line 77 of file platform_view_android_delegate_unittests.cc.

78 {
79 auto jni_mock = std::make_shared<JNIMock>();
80 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
81
84 std::shared_ptr<SpellOutStringAttribute> spell_out_attribute =
85 std::make_shared<SpellOutStringAttribute>();
86 spell_out_attribute->start = 2;
87 spell_out_attribute->end = 4;
88 spell_out_attribute->type = flutter::StringAttributeType::kSpellOut;
89 std::shared_ptr<LocaleStringAttribute> locale_attribute =
90 std::make_shared<LocaleStringAttribute>();
91 locale_attribute->start = 1;
92 locale_attribute->end = 3;
93 locale_attribute->type = flutter::StringAttributeType::kLocale;
94 locale_attribute->locale = "en-US";
95 node0.id = 0;
96 node0.identifier = "identifier";
97 node0.label = "label";
98 node0.labelAttributes.push_back(spell_out_attribute);
99 node0.hint = "hint";
100 node0.hintAttributes.push_back(locale_attribute);
101 update.insert(std::make_pair(0, node0));
102
103 std::vector<uint8_t> expected_buffer(224);
104 std::vector<std::vector<uint8_t>> expected_string_attribute_args;
105 size_t position = 0;
106 int32_t* buffer_int32 = reinterpret_cast<int32_t*>(&expected_buffer[0]);
107 float* buffer_float32 = reinterpret_cast<float*>(&expected_buffer[0]);
108 std::vector<std::string> expected_strings;
109 buffer_int32[position++] = node0.id;
110 buffer_int32[position++] = node0.flags;
111 buffer_int32[position++] = node0.actions;
112 buffer_int32[position++] = node0.maxValueLength;
113 buffer_int32[position++] = node0.currentValueLength;
114 buffer_int32[position++] = node0.textSelectionBase;
115 buffer_int32[position++] = node0.textSelectionExtent;
116 buffer_int32[position++] = node0.platformViewId;
117 buffer_int32[position++] = node0.scrollChildren;
118 buffer_int32[position++] = node0.scrollIndex;
119 buffer_float32[position++] = static_cast<float>(node0.scrollPosition);
120 buffer_float32[position++] = static_cast<float>(node0.scrollExtentMax);
121 buffer_float32[position++] = static_cast<float>(node0.scrollExtentMin);
122 buffer_int32[position++] = expected_strings.size(); // node0.identifier
123 expected_strings.push_back(node0.identifier);
124 buffer_int32[position++] = expected_strings.size(); // node0.label
125 expected_strings.push_back(node0.label);
126 buffer_int32[position++] = 1; // node0.labelAttributes
127 buffer_int32[position++] = 2; // node0.labelAttributes[0].start
128 buffer_int32[position++] = 4; // node0.labelAttributes[0].end
129 buffer_int32[position++] = 0; // node0.labelAttributes[0].type
130 buffer_int32[position++] = -1; // node0.labelAttributes[0].args
131 buffer_int32[position++] = -1; // node0.value
132 buffer_int32[position++] = -1; // node0.valueAttributes
133 buffer_int32[position++] = -1; // node0.increasedValue
134 buffer_int32[position++] = -1; // node0.increasedValueAttributes
135 buffer_int32[position++] = -1; // node0.decreasedValue
136 buffer_int32[position++] = -1; // node0.decreasedValueAttributes
137 buffer_int32[position++] = expected_strings.size(); // node0.hint
138 expected_strings.push_back(node0.hint);
139 buffer_int32[position++] = 1; // node0.hintAttributes
140 buffer_int32[position++] = 1; // node0.hintAttributes[0].start
141 buffer_int32[position++] = 3; // node0.hintAttributes[0].end
142 buffer_int32[position++] = 1; // node0.hintAttributes[0].type
143 buffer_int32[position++] =
144 expected_string_attribute_args.size(); // node0.hintAttributes[0].args
145 expected_string_attribute_args.push_back(
146 {locale_attribute->locale.begin(), locale_attribute->locale.end()});
147 buffer_int32[position++] = -1; // node0.tooltip
148 buffer_int32[position++] = node0.textDirection;
149 buffer_float32[position++] = node0.rect.left();
150 buffer_float32[position++] = node0.rect.top();
151 buffer_float32[position++] = node0.rect.right();
152 buffer_float32[position++] = node0.rect.bottom();
153 node0.transform.getColMajor(&buffer_float32[position]);
154 position += 16;
155 buffer_int32[position++] = 0; // node0.childrenInTraversalOrder.size();
156 buffer_int32[position++] = 0; // node0.customAccessibilityActions.size();
157 EXPECT_CALL(*jni_mock,
158 FlutterViewUpdateSemantics(expected_buffer, expected_strings,
159 expected_string_attribute_args));
160 // Creates empty custom actions.
162 delegate->UpdateSemantics(update, actions);
163}
StringAttributes hintAttributes
StringAttributes labelAttributes

◆ TEST() [617/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
AlwaysForwardMoveEvent   
)

Definition at line 301 of file pointer_data_packet_converter_unittests.cc.

301 {
303 auto packet = std::make_unique<PointerDataPacket>(4);
305 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0, 0.0, 0.0, 0);
306 packet->SetPointerData(0, data);
307 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 0.0, 0.0, 1);
308 packet->SetPointerData(1, data);
309 // Creates a move event without a location change.
310 CreateSimulatedPointerData(data, PointerData::Change::kMove, 0, 0.0, 0.0, 1);
311 packet->SetPointerData(2, data);
312 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 0.0, 0.0, 0);
313 packet->SetPointerData(3, data);
314
315 auto converted_packet = converter.Convert(std::move(packet));
316
317 std::vector<PointerData> result;
318 UnpackPointerPacket(result, std::move(converted_packet));
319
320 ASSERT_EQ(result.size(), (size_t)4);
321 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
322 ASSERT_EQ(result[0].synthesized, 0);
323
324 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
325 ASSERT_EQ(result[1].pointer_identifier, 1);
326 ASSERT_EQ(result[1].synthesized, 0);
327
328 // Does not filter out the move event.
329 ASSERT_EQ(result[2].change, PointerData::Change::kMove);
330 ASSERT_EQ(result[2].pointer_identifier, 1);
331 ASSERT_EQ(result[2].synthesized, 0);
332
333 ASSERT_EQ(result[3].change, PointerData::Change::kUp);
334 ASSERT_EQ(result[3].pointer_identifier, 1);
335 ASSERT_EQ(result[3].synthesized, 0);
336}
void CreateSimulatedPointerData(PointerData &data, PointerData::Change change, int64_t device, double dx, double dy, int64_t buttons)
void UnpackPointerPacket(std::vector< PointerData > &output, std::unique_ptr< PointerDataPacket > packet)

◆ TEST() [618/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertPointerDataPacket   
)

Definition at line 146 of file pointer_data_packet_converter_unittests.cc.

146 {
148 auto packet = std::make_unique<PointerDataPacket>(6);
150 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0, 0.0, 0.0, 0);
151 packet->SetPointerData(0, data);
152 CreateSimulatedPointerData(data, PointerData::Change::kHover, 0, 3.0, 0.0, 0);
153 packet->SetPointerData(1, data);
154 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 3.0, 0.0, 1);
155 packet->SetPointerData(2, data);
156 CreateSimulatedPointerData(data, PointerData::Change::kMove, 0, 3.0, 4.0, 1);
157 packet->SetPointerData(3, data);
158 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 3.0, 4.0, 0);
159 packet->SetPointerData(4, data);
160 CreateSimulatedPointerData(data, PointerData::Change::kRemove, 0, 3.0, 4.0,
161 0);
162 packet->SetPointerData(5, data);
163 auto converted_packet = converter.Convert(std::move(packet));
164
165 std::vector<PointerData> result;
166 UnpackPointerPacket(result, std::move(converted_packet));
167
168 ASSERT_EQ(result.size(), (size_t)6);
169 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
170 ASSERT_EQ(result[0].synthesized, 0);
171
172 ASSERT_EQ(result[1].change, PointerData::Change::kHover);
173 ASSERT_EQ(result[1].synthesized, 0);
174 ASSERT_EQ(result[1].physical_delta_x, 3.0);
175 ASSERT_EQ(result[1].physical_delta_y, 0.0);
176
177 ASSERT_EQ(result[2].change, PointerData::Change::kDown);
178 ASSERT_EQ(result[2].pointer_identifier, 1);
179 ASSERT_EQ(result[2].synthesized, 0);
180
181 ASSERT_EQ(result[3].change, PointerData::Change::kMove);
182 ASSERT_EQ(result[3].pointer_identifier, 1);
183 ASSERT_EQ(result[3].synthesized, 0);
184 ASSERT_EQ(result[3].physical_delta_x, 0.0);
185 ASSERT_EQ(result[3].physical_delta_y, 4.0);
186
187 ASSERT_EQ(result[4].change, PointerData::Change::kUp);
188 ASSERT_EQ(result[4].pointer_identifier, 1);
189 ASSERT_EQ(result[4].synthesized, 0);
190
191 ASSERT_EQ(result[5].change, PointerData::Change::kRemove);
192 ASSERT_EQ(result[5].synthesized, 0);
193}

◆ TEST() [619/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertPointerSignals   
)

Definition at line 554 of file pointer_data_packet_converter_unittests.cc.

554 {
555 PointerData::SignalKind signal_kinds[] = {
556 PointerData::SignalKind::kScroll,
557 PointerData::SignalKind::kScrollInertiaCancel,
558 PointerData::SignalKind::kScale,
559 };
560 for (const PointerData::SignalKind& kind : signal_kinds) {
562 auto packet = std::make_unique<PointerDataPacket>(6);
564 CreateSimulatedMousePointerData(data, PointerData::Change::kAdd,
565 PointerData::SignalKind::kNone, 0, 0.0, 0.0,
566 0.0, 0.0, 0);
567 packet->SetPointerData(0, data);
568 CreateSimulatedMousePointerData(data, PointerData::Change::kAdd,
569 PointerData::SignalKind::kNone, 1, 0.0, 0.0,
570 0.0, 0.0, 0);
571 packet->SetPointerData(1, data);
572 CreateSimulatedMousePointerData(data, PointerData::Change::kDown,
573 PointerData::SignalKind::kNone, 1, 0.0, 0.0,
574 0.0, 0.0, 1);
575 packet->SetPointerData(2, data);
576 CreateSimulatedMousePointerData(data, PointerData::Change::kHover, kind, 0,
577 34.0, 34.0, 30.0, 0.0, 0);
578 packet->SetPointerData(3, data);
579 CreateSimulatedMousePointerData(data, PointerData::Change::kHover, kind, 1,
580 49.0, 49.0, 50.0, 0.0, 0);
581 packet->SetPointerData(4, data);
582 CreateSimulatedMousePointerData(data, PointerData::Change::kHover, kind, 2,
583 10.0, 20.0, 30.0, 40.0, 0);
584 packet->SetPointerData(5, data);
585 auto converted_packet = converter.Convert(std::move(packet));
586
587 std::vector<PointerData> result;
588 UnpackPointerPacket(result, std::move(converted_packet));
589
590 ASSERT_EQ(result.size(), (size_t)9);
591 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
592 ASSERT_EQ(result[0].signal_kind, PointerData::SignalKind::kNone);
593 ASSERT_EQ(result[0].device, 0);
594 ASSERT_EQ(result[0].physical_x, 0.0);
595 ASSERT_EQ(result[0].physical_y, 0.0);
596 ASSERT_EQ(result[0].synthesized, 0);
597
598 ASSERT_EQ(result[1].change, PointerData::Change::kAdd);
599 ASSERT_EQ(result[1].signal_kind, PointerData::SignalKind::kNone);
600 ASSERT_EQ(result[1].device, 1);
601 ASSERT_EQ(result[1].physical_x, 0.0);
602 ASSERT_EQ(result[1].physical_y, 0.0);
603 ASSERT_EQ(result[1].synthesized, 0);
604
605 ASSERT_EQ(result[2].change, PointerData::Change::kDown);
606 ASSERT_EQ(result[2].signal_kind, PointerData::SignalKind::kNone);
607 ASSERT_EQ(result[2].device, 1);
608 ASSERT_EQ(result[2].physical_x, 0.0);
609 ASSERT_EQ(result[2].physical_y, 0.0);
610 ASSERT_EQ(result[2].synthesized, 0);
611
612 // Converter will synthesize a hover to position for device 0.
613 ASSERT_EQ(result[3].change, PointerData::Change::kHover);
614 ASSERT_EQ(result[3].signal_kind, PointerData::SignalKind::kNone);
615 ASSERT_EQ(result[3].device, 0);
616 ASSERT_EQ(result[3].physical_x, 34.0);
617 ASSERT_EQ(result[3].physical_y, 34.0);
618 ASSERT_EQ(result[3].physical_delta_x, 34.0);
619 ASSERT_EQ(result[3].physical_delta_y, 34.0);
620 ASSERT_EQ(result[3].buttons, 0);
621 ASSERT_EQ(result[3].synthesized, 1);
622
623 ASSERT_EQ(result[4].change, PointerData::Change::kHover);
624 ASSERT_EQ(result[4].signal_kind, kind);
625 ASSERT_EQ(result[4].device, 0);
626 ASSERT_EQ(result[4].physical_x, 34.0);
627 ASSERT_EQ(result[4].physical_y, 34.0);
628 ASSERT_EQ(result[4].scroll_delta_x, 30.0);
629 ASSERT_EQ(result[4].scroll_delta_y, 0.0);
630
631 // Converter will synthesize a move to position for device 1.
632 ASSERT_EQ(result[5].change, PointerData::Change::kMove);
633 ASSERT_EQ(result[5].signal_kind, PointerData::SignalKind::kNone);
634 ASSERT_EQ(result[5].device, 1);
635 ASSERT_EQ(result[5].physical_x, 49.0);
636 ASSERT_EQ(result[5].physical_y, 49.0);
637 ASSERT_EQ(result[5].physical_delta_x, 49.0);
638 ASSERT_EQ(result[5].physical_delta_y, 49.0);
639 ASSERT_EQ(result[5].buttons, 1);
640 ASSERT_EQ(result[5].synthesized, 1);
641
642 ASSERT_EQ(result[6].change, PointerData::Change::kHover);
643 ASSERT_EQ(result[6].signal_kind, kind);
644 ASSERT_EQ(result[6].device, 1);
645 ASSERT_EQ(result[6].physical_x, 49.0);
646 ASSERT_EQ(result[6].physical_y, 49.0);
647 ASSERT_EQ(result[6].scroll_delta_x, 50.0);
648 ASSERT_EQ(result[6].scroll_delta_y, 0.0);
649
650 // Converter will synthesize an add for device 2.
651 ASSERT_EQ(result[7].change, PointerData::Change::kAdd);
652 ASSERT_EQ(result[7].signal_kind, PointerData::SignalKind::kNone);
653 ASSERT_EQ(result[7].device, 2);
654 ASSERT_EQ(result[7].physical_x, 10.0);
655 ASSERT_EQ(result[7].physical_y, 20.0);
656 ASSERT_EQ(result[7].synthesized, 1);
657
658 ASSERT_EQ(result[8].change, PointerData::Change::kHover);
659 ASSERT_EQ(result[8].signal_kind, kind);
660 ASSERT_EQ(result[8].device, 2);
661 ASSERT_EQ(result[8].physical_x, 10.0);
662 ASSERT_EQ(result[8].physical_y, 20.0);
663 ASSERT_EQ(result[8].scroll_delta_x, 30.0);
664 ASSERT_EQ(result[8].scroll_delta_y, 40.0);
665 }
666}

◆ TEST() [620/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertTrackpadGesture   
)

Definition at line 668 of file pointer_data_packet_converter_unittests.cc.

668 {
670 auto packet = std::make_unique<PointerDataPacket>(3);
672 CreateSimulatedTrackpadGestureData(data, PointerData::Change::kPanZoomStart,
673 0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
674 packet->SetPointerData(0, data);
675 CreateSimulatedTrackpadGestureData(data, PointerData::Change::kPanZoomUpdate,
676 0, 0.0, 0.0, 3.0, 4.0, 1.0, 0.0);
677 packet->SetPointerData(1, data);
678 CreateSimulatedTrackpadGestureData(data, PointerData::Change::kPanZoomEnd, 0,
679 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
680 packet->SetPointerData(2, data);
681 auto converted_packet = converter.Convert(std::move(packet));
682
683 std::vector<PointerData> result;
684 UnpackPointerPacket(result, std::move(converted_packet));
685
686 ASSERT_EQ(result.size(), (size_t)4);
687 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
688 ASSERT_EQ(result[0].device, 0);
689 ASSERT_EQ(result[0].synthesized, 1);
690
691 ASSERT_EQ(result[1].change, PointerData::Change::kPanZoomStart);
692 ASSERT_EQ(result[1].signal_kind, PointerData::SignalKind::kNone);
693 ASSERT_EQ(result[1].device, 0);
694 ASSERT_EQ(result[1].physical_x, 0.0);
695 ASSERT_EQ(result[1].physical_y, 0.0);
696 ASSERT_EQ(result[1].synthesized, 0);
697
698 ASSERT_EQ(result[2].change, PointerData::Change::kPanZoomUpdate);
699 ASSERT_EQ(result[2].signal_kind, PointerData::SignalKind::kNone);
700 ASSERT_EQ(result[2].device, 0);
701 ASSERT_EQ(result[2].physical_x, 0.0);
702 ASSERT_EQ(result[2].physical_y, 0.0);
703 ASSERT_EQ(result[2].pan_x, 3.0);
704 ASSERT_EQ(result[2].pan_y, 4.0);
705 ASSERT_EQ(result[2].pan_delta_x, 3.0);
706 ASSERT_EQ(result[2].pan_delta_y, 4.0);
707 ASSERT_EQ(result[2].scale, 1.0);
708 ASSERT_EQ(result[2].rotation, 0.0);
709 ASSERT_EQ(result[2].synthesized, 0);
710
711 ASSERT_EQ(result[3].change, PointerData::Change::kPanZoomEnd);
712 ASSERT_EQ(result[3].signal_kind, PointerData::SignalKind::kNone);
713 ASSERT_EQ(result[3].device, 0);
714 ASSERT_EQ(result[3].physical_x, 0.0);
715 ASSERT_EQ(result[3].physical_y, 0.0);
716 ASSERT_EQ(result[3].synthesized, 0);
717}
void CreateSimulatedTrackpadGestureData(PointerData &data, PointerData::Change change, int64_t device, double dx, double dy, double pan_x, double pan_y, double scale, double rotation)

◆ TEST() [621/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertViewId   
)

Definition at line 719 of file pointer_data_packet_converter_unittests.cc.

719 {
721 auto packet = std::make_unique<PointerDataPacket>(2);
723 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0, 0.0, 0.0, 0);
724 data.view_id = 100;
725 packet->SetPointerData(0, data);
726 CreateSimulatedPointerData(data, PointerData::Change::kHover, 0, 1.0, 0.0, 0);
727 data.view_id = 200;
728 packet->SetPointerData(1, data);
729 auto converted_packet = converter.Convert(std::move(packet));
730
731 std::vector<PointerData> result;
732 UnpackPointerPacket(result, std::move(converted_packet));
733
734 ASSERT_EQ(result.size(), (size_t)2);
735 ASSERT_EQ(result[0].view_id, 100);
736 ASSERT_EQ(result[1].view_id, 200);
737}

◆ TEST() [622/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanHandleThreeFingerGesture   
)

Definition at line 479 of file pointer_data_packet_converter_unittests.cc.

479 {
480 // Regression test https://github.com/flutter/flutter/issues/20517.
483 std::vector<PointerData> result;
484 // First finger down.
485 auto packet = std::make_unique<PointerDataPacket>(1);
486 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 0.0, 0.0, 1);
487 packet->SetPointerData(0, data);
488 auto converted_packet = converter.Convert(std::move(packet));
489 UnpackPointerPacket(result, std::move(converted_packet));
490 // Second finger down.
491 packet = std::make_unique<PointerDataPacket>(1);
492 CreateSimulatedPointerData(data, PointerData::Change::kDown, 1, 33.0, 44.0,
493 1);
494 packet->SetPointerData(0, data);
495 converted_packet = converter.Convert(std::move(packet));
496 UnpackPointerPacket(result, std::move(converted_packet));
497 // Triggers three cancels.
498 packet = std::make_unique<PointerDataPacket>(3);
499 CreateSimulatedPointerData(data, PointerData::Change::kCancel, 1, 33.0, 44.0,
500 0);
501 packet->SetPointerData(0, data);
502 CreateSimulatedPointerData(data, PointerData::Change::kCancel, 0, 0.0, 0.0,
503 0);
504 packet->SetPointerData(1, data);
505 CreateSimulatedPointerData(data, PointerData::Change::kCancel, 2, 40.0, 50.0,
506 0);
507 packet->SetPointerData(2, data);
508 converted_packet = converter.Convert(std::move(packet));
509 UnpackPointerPacket(result, std::move(converted_packet));
510
511 ASSERT_EQ(result.size(), (size_t)6);
512 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
513 ASSERT_EQ(result[0].device, 0);
514 ASSERT_EQ(result[0].physical_x, 0.0);
515 ASSERT_EQ(result[0].physical_y, 0.0);
516 ASSERT_EQ(result[0].synthesized, 1);
517 ASSERT_EQ(result[0].buttons, 0);
518
519 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
520 ASSERT_EQ(result[1].device, 0);
521 ASSERT_EQ(result[1].physical_x, 0.0);
522 ASSERT_EQ(result[1].physical_y, 0.0);
523 ASSERT_EQ(result[1].synthesized, 0);
524 ASSERT_EQ(result[1].buttons, 1);
525
526 ASSERT_EQ(result[2].change, PointerData::Change::kAdd);
527 ASSERT_EQ(result[2].device, 1);
528 ASSERT_EQ(result[2].physical_x, 33.0);
529 ASSERT_EQ(result[2].physical_y, 44.0);
530 ASSERT_EQ(result[2].synthesized, 1);
531 ASSERT_EQ(result[2].buttons, 0);
532
533 ASSERT_EQ(result[3].change, PointerData::Change::kDown);
534 ASSERT_EQ(result[3].device, 1);
535 ASSERT_EQ(result[3].physical_x, 33.0);
536 ASSERT_EQ(result[3].physical_y, 44.0);
537 ASSERT_EQ(result[3].synthesized, 0);
538 ASSERT_EQ(result[3].buttons, 1);
539
540 ASSERT_EQ(result[4].change, PointerData::Change::kCancel);
541 ASSERT_EQ(result[4].device, 1);
542 ASSERT_EQ(result[4].physical_x, 33.0);
543 ASSERT_EQ(result[4].physical_y, 44.0);
544 ASSERT_EQ(result[4].synthesized, 0);
545
546 ASSERT_EQ(result[5].change, PointerData::Change::kCancel);
547 ASSERT_EQ(result[5].device, 0);
548 ASSERT_EQ(result[5].physical_x, 0.0);
549 ASSERT_EQ(result[5].physical_y, 0.0);
550 ASSERT_EQ(result[5].synthesized, 0);
551 // Third cancel should be dropped
552}

◆ TEST() [623/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanSynthesizeAdd   
)

Definition at line 435 of file pointer_data_packet_converter_unittests.cc.

435 {
437 auto packet = std::make_unique<PointerDataPacket>(2);
439 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 330.0, 450.0,
440 1);
441 packet->SetPointerData(0, data);
442 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 0.0, 0.0, 0);
443 packet->SetPointerData(1, data);
444 auto converted_packet = converter.Convert(std::move(packet));
445
446 std::vector<PointerData> result;
447 UnpackPointerPacket(result, std::move(converted_packet));
448
449 ASSERT_EQ(result.size(), (size_t)4);
450 // A add should be synthesized.
451 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
452 ASSERT_EQ(result[0].physical_x, 330.0);
453 ASSERT_EQ(result[0].physical_y, 450.0);
454 ASSERT_EQ(result[0].synthesized, 1);
455 ASSERT_EQ(result[0].buttons, 0);
456
457 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
458 ASSERT_EQ(result[1].physical_x, 330.0);
459 ASSERT_EQ(result[1].physical_y, 450.0);
460 ASSERT_EQ(result[1].synthesized, 0);
461 ASSERT_EQ(result[1].buttons, 1);
462
463 // A move should be synthesized.
464 ASSERT_EQ(result[2].change, PointerData::Change::kMove);
465 ASSERT_EQ(result[2].physical_delta_x, -330.0);
466 ASSERT_EQ(result[2].physical_delta_y, -450.0);
467 ASSERT_EQ(result[2].physical_x, 0.0);
468 ASSERT_EQ(result[2].physical_y, 0.0);
469 ASSERT_EQ(result[2].synthesized, 1);
470 ASSERT_EQ(result[2].buttons, 1);
471
472 ASSERT_EQ(result[3].change, PointerData::Change::kUp);
473 ASSERT_EQ(result[3].physical_x, 0.0);
474 ASSERT_EQ(result[3].physical_y, 0.0);
475 ASSERT_EQ(result[3].synthesized, 0);
476 ASSERT_EQ(result[3].buttons, 0);
477}

◆ TEST() [624/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanSynthesizeDownAndUp   
)

Definition at line 195 of file pointer_data_packet_converter_unittests.cc.

195 {
197 auto packet = std::make_unique<PointerDataPacket>(4);
199 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0, 0.0, 0.0, 0);
200 packet->SetPointerData(0, data);
201 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 3.0, 0.0, 1);
202 packet->SetPointerData(1, data);
203 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 3.0, 4.0, 0);
204 packet->SetPointerData(2, data);
205 CreateSimulatedPointerData(data, PointerData::Change::kRemove, 0, 3.0, 4.0,
206 0);
207 packet->SetPointerData(3, data);
208 auto converted_packet = converter.Convert(std::move(packet));
209
210 std::vector<PointerData> result;
211 UnpackPointerPacket(result, std::move(converted_packet));
212
213 ASSERT_EQ(result.size(), (size_t)6);
214 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
215 ASSERT_EQ(result[0].synthesized, 0);
216
217 // A hover should be synthesized.
218 ASSERT_EQ(result[1].change, PointerData::Change::kHover);
219 ASSERT_EQ(result[1].synthesized, 1);
220 ASSERT_EQ(result[1].physical_delta_x, 3.0);
221 ASSERT_EQ(result[1].physical_delta_y, 0.0);
222 ASSERT_EQ(result[1].buttons, 0);
223
224 ASSERT_EQ(result[2].change, PointerData::Change::kDown);
225 ASSERT_EQ(result[2].pointer_identifier, 1);
226 ASSERT_EQ(result[2].synthesized, 0);
227 ASSERT_EQ(result[2].buttons, 1);
228
229 // A move should be synthesized.
230 ASSERT_EQ(result[3].change, PointerData::Change::kMove);
231 ASSERT_EQ(result[3].pointer_identifier, 1);
232 ASSERT_EQ(result[3].synthesized, 1);
233 ASSERT_EQ(result[3].physical_delta_x, 0.0);
234 ASSERT_EQ(result[3].physical_delta_y, 4.0);
235 ASSERT_EQ(result[3].buttons, 1);
236
237 ASSERT_EQ(result[4].change, PointerData::Change::kUp);
238 ASSERT_EQ(result[4].pointer_identifier, 1);
239 ASSERT_EQ(result[4].synthesized, 0);
240 ASSERT_EQ(result[4].buttons, 0);
241
242 ASSERT_EQ(result[5].change, PointerData::Change::kRemove);
243 ASSERT_EQ(result[5].synthesized, 0);
244}

◆ TEST() [625/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanUpdatePointerIdentifier   
)

Definition at line 246 of file pointer_data_packet_converter_unittests.cc.

246 {
248 auto packet = std::make_unique<PointerDataPacket>(7);
250 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0, 0.0, 0.0, 0);
251 packet->SetPointerData(0, data);
252 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 0.0, 0.0, 1);
253 packet->SetPointerData(1, data);
254 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 0.0, 0.0, 0);
255 packet->SetPointerData(2, data);
256 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 0.0, 0.0, 1);
257 packet->SetPointerData(3, data);
258 CreateSimulatedPointerData(data, PointerData::Change::kMove, 0, 3.0, 0.0, 1);
259 packet->SetPointerData(4, data);
260 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 3.0, 0.0, 0);
261 packet->SetPointerData(5, data);
262 CreateSimulatedPointerData(data, PointerData::Change::kRemove, 0, 3.0, 0.0,
263 0);
264 packet->SetPointerData(6, data);
265 auto converted_packet = converter.Convert(std::move(packet));
266
267 std::vector<PointerData> result;
268 UnpackPointerPacket(result, std::move(converted_packet));
269
270 ASSERT_EQ(result.size(), (size_t)7);
271 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
272 ASSERT_EQ(result[0].synthesized, 0);
273
274 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
275 ASSERT_EQ(result[1].pointer_identifier, 1);
276 ASSERT_EQ(result[1].synthesized, 0);
277
278 ASSERT_EQ(result[2].change, PointerData::Change::kUp);
279 ASSERT_EQ(result[2].pointer_identifier, 1);
280 ASSERT_EQ(result[2].synthesized, 0);
281
282 // Pointer count increase to 2.
283 ASSERT_EQ(result[3].change, PointerData::Change::kDown);
284 ASSERT_EQ(result[3].pointer_identifier, 2);
285 ASSERT_EQ(result[3].synthesized, 0);
286
287 ASSERT_EQ(result[4].change, PointerData::Change::kMove);
288 ASSERT_EQ(result[4].pointer_identifier, 2);
289 ASSERT_EQ(result[4].synthesized, 0);
290 ASSERT_EQ(result[4].physical_delta_x, 3.0);
291 ASSERT_EQ(result[4].physical_delta_y, 0.0);
292
293 ASSERT_EQ(result[5].change, PointerData::Change::kUp);
294 ASSERT_EQ(result[5].pointer_identifier, 2);
295 ASSERT_EQ(result[5].synthesized, 0);
296
297 ASSERT_EQ(result[6].change, PointerData::Change::kRemove);
298 ASSERT_EQ(result[6].synthesized, 0);
299}

◆ TEST() [626/709]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanWorkWithDifferentDevices   
)

Definition at line 338 of file pointer_data_packet_converter_unittests.cc.

338 {
340 auto packet = std::make_unique<PointerDataPacket>(12);
342 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0, 0.0, 0.0, 0);
343 packet->SetPointerData(0, data);
344 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 0.0, 0.0, 1);
345 packet->SetPointerData(1, data);
346 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 1, 0.0, 0.0, 0);
347 packet->SetPointerData(2, data);
348 CreateSimulatedPointerData(data, PointerData::Change::kDown, 1, 0.0, 0.0, 1);
349 packet->SetPointerData(3, data);
350 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 0.0, 0.0, 0);
351 packet->SetPointerData(4, data);
352 CreateSimulatedPointerData(data, PointerData::Change::kDown, 0, 0.0, 0.0, 1);
353 packet->SetPointerData(5, data);
354 CreateSimulatedPointerData(data, PointerData::Change::kMove, 1, 0.0, 4.0, 1);
355 packet->SetPointerData(6, data);
356 CreateSimulatedPointerData(data, PointerData::Change::kMove, 0, 3.0, 0.0, 1);
357 packet->SetPointerData(7, data);
358 CreateSimulatedPointerData(data, PointerData::Change::kUp, 1, 0.0, 4.0, 0);
359 packet->SetPointerData(8, data);
360 CreateSimulatedPointerData(data, PointerData::Change::kUp, 0, 3.0, 0.0, 0);
361 packet->SetPointerData(9, data);
362 CreateSimulatedPointerData(data, PointerData::Change::kRemove, 0, 3.0, 0.0,
363 0);
364 packet->SetPointerData(10, data);
365 CreateSimulatedPointerData(data, PointerData::Change::kRemove, 1, 0.0, 4.0,
366 0);
367 packet->SetPointerData(11, data);
368 auto converted_packet = converter.Convert(std::move(packet));
369
370 std::vector<PointerData> result;
371 UnpackPointerPacket(result, std::move(converted_packet));
372
373 ASSERT_EQ(result.size(), (size_t)12);
374 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
375 ASSERT_EQ(result[0].device, 0);
376 ASSERT_EQ(result[0].synthesized, 0);
377
378 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
379 ASSERT_EQ(result[1].device, 0);
380 ASSERT_EQ(result[1].pointer_identifier, 1);
381 ASSERT_EQ(result[1].synthesized, 0);
382
383 ASSERT_EQ(result[2].change, PointerData::Change::kAdd);
384 ASSERT_EQ(result[2].device, 1);
385 ASSERT_EQ(result[2].synthesized, 0);
386
387 ASSERT_EQ(result[3].change, PointerData::Change::kDown);
388 ASSERT_EQ(result[3].device, 1);
389 ASSERT_EQ(result[3].pointer_identifier, 2);
390 ASSERT_EQ(result[3].synthesized, 0);
391
392 ASSERT_EQ(result[4].change, PointerData::Change::kUp);
393 ASSERT_EQ(result[4].device, 0);
394 ASSERT_EQ(result[4].pointer_identifier, 1);
395 ASSERT_EQ(result[4].synthesized, 0);
396
397 ASSERT_EQ(result[5].change, PointerData::Change::kDown);
398 ASSERT_EQ(result[5].device, 0);
399 ASSERT_EQ(result[5].pointer_identifier, 3);
400 ASSERT_EQ(result[5].synthesized, 0);
401
402 ASSERT_EQ(result[6].change, PointerData::Change::kMove);
403 ASSERT_EQ(result[6].device, 1);
404 ASSERT_EQ(result[6].pointer_identifier, 2);
405 ASSERT_EQ(result[6].synthesized, 0);
406 ASSERT_EQ(result[6].physical_delta_x, 0.0);
407 ASSERT_EQ(result[6].physical_delta_y, 4.0);
408
409 ASSERT_EQ(result[7].change, PointerData::Change::kMove);
410 ASSERT_EQ(result[7].device, 0);
411 ASSERT_EQ(result[7].pointer_identifier, 3);
412 ASSERT_EQ(result[7].synthesized, 0);
413 ASSERT_EQ(result[7].physical_delta_x, 3.0);
414 ASSERT_EQ(result[7].physical_delta_y, 0.0);
415
416 ASSERT_EQ(result[8].change, PointerData::Change::kUp);
417 ASSERT_EQ(result[8].device, 1);
418 ASSERT_EQ(result[8].pointer_identifier, 2);
419 ASSERT_EQ(result[8].synthesized, 0);
420
421 ASSERT_EQ(result[9].change, PointerData::Change::kUp);
422 ASSERT_EQ(result[9].device, 0);
423 ASSERT_EQ(result[9].pointer_identifier, 3);
424 ASSERT_EQ(result[9].synthesized, 0);
425
426 ASSERT_EQ(result[10].change, PointerData::Change::kRemove);
427 ASSERT_EQ(result[10].device, 0);
428 ASSERT_EQ(result[10].synthesized, 0);
429
430 ASSERT_EQ(result[11].change, PointerData::Change::kRemove);
431 ASSERT_EQ(result[11].device, 1);
432 ASSERT_EQ(result[11].synthesized, 0);
433}

◆ TEST() [627/709]

flutter::testing::TEST ( PointerDataPacketTest  ,
CanGetLength   
)

Definition at line 63 of file pointer_data_packet_unittests.cc.

63 {
64 auto packet = std::make_unique<PointerDataPacket>(6);
65 ASSERT_EQ(packet->GetLength(), (size_t)6);
66}

◆ TEST() [628/709]

flutter::testing::TEST ( PointerDataPacketTest  ,
CanGetPointerData   
)

Definition at line 51 of file pointer_data_packet_unittests.cc.

51 {
52 auto packet = std::make_unique<PointerDataPacket>(1);
54 CreateSimpleSimulatedPointerData(data, PointerData::Change::kAdd, 1, 2.0, 3.0,
55 4);
56 packet->SetPointerData(0, data);
57
58 PointerData data_recovered = packet->GetPointerData(0);
59 ASSERT_EQ(data_recovered.physical_x, 2.0);
60 ASSERT_EQ(data_recovered.physical_y, 3.0);
61}
void CreateSimpleSimulatedPointerData(PointerData &data, PointerData::Change change, int64_t device, double dx, double dy, int64_t buttons)

◆ TEST() [629/709]

flutter::testing::TEST ( RasterCache  ,
AccessThresholdOfZeroDisablesCachingForDisplayList   
)

Definition at line 185 of file raster_cache_unittests.cc.

185 {
186 size_t threshold = 0;
187 flutter::RasterCache cache(threshold);
188
189 SkMatrix matrix = SkMatrix::I();
190
191 auto display_list = GetSampleDisplayList();
192
193 MockCanvas dummy_canvas(1000, 1000);
195
196 LayerStateStack preroll_state_stack;
197 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
198 LayerStateStack paint_state_stack;
199 preroll_state_stack.set_delegate(&dummy_canvas);
200
201 FixedRefreshRateStopwatch raster_time;
204 preroll_state_stack, &cache, &raster_time, &ui_time);
205 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
206 paint_state_stack, &cache, &raster_time, &ui_time);
207 auto& preroll_context = preroll_context_holder.preroll_context;
208 auto& paint_context = paint_context_holder.paint_context;
209
210 cache.BeginFrame();
211
212 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
213 false);
215 display_list_item, preroll_context, paint_context, matrix));
216 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
217}
PrerollContextHolder GetSamplePrerollContextHolder(LayerStateStack &state_stack, RasterCache *raster_cache, FixedRefreshRateStopwatch *raster_time, FixedRefreshRateStopwatch *ui_time)
bool RasterCacheItemPrerollAndTryToRasterCache(DisplayListRasterCacheItem &display_list_item, PrerollContext &context, PaintContext &paint_context, const SkMatrix &matrix)
PaintContextHolder GetSamplePaintContextHolder(LayerStateStack &state_stack, RasterCache *raster_cache, FixedRefreshRateStopwatch *raster_time, FixedRefreshRateStopwatch *ui_time)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition switches.h:191

◆ TEST() [630/709]

flutter::testing::TEST ( RasterCache  ,
ComputeDeviceRectBasedOnFractionalTranslation   
)

Definition at line 362 of file raster_cache_unittests.cc.

362 {
363 SkRect logical_rect = SkRect::MakeLTRB(0, 0, 300.2, 300.3);
364 SkMatrix ctm = SkMatrix::MakeAll(2.0, 0, 0, 0, 2.0, 0, 0, 0, 1);
365 auto result = RasterCacheUtil::GetDeviceBounds(logical_rect, ctm);
366 ASSERT_EQ(result, SkRect::MakeLTRB(0.0, 0.0, 600.4, 600.6));
367}

◆ TEST() [631/709]

flutter::testing::TEST ( RasterCache  ,
DeviceRectRoundOutForDisplayList   
)

Definition at line 372 of file raster_cache_unittests.cc.

372 {
373 size_t threshold = 1;
374 flutter::RasterCache cache(threshold);
375
376 SkRect logical_rect = SkRect::MakeLTRB(28, 0, 354.56731, 310.288);
377 DisplayListBuilder builder(logical_rect);
378 builder.DrawRect(logical_rect, DlPaint(DlColor::kRed()));
379 sk_sp<DisplayList> display_list = builder.Build();
380
381 SkMatrix ctm = SkMatrix::MakeAll(1.3312, 0, 233, 0, 1.3312, 206, 0, 0, 1);
383
384 MockCanvas canvas(1000, 1000);
385 canvas.SetTransform(ctm);
386
387 LayerStateStack preroll_state_stack;
388 preroll_state_stack.set_preroll_delegate(kGiantRect, ctm);
389 LayerStateStack paint_state_stack;
390 preroll_state_stack.set_delegate(&canvas);
391
392 FixedRefreshRateStopwatch raster_time;
395 preroll_state_stack, &cache, &raster_time, &ui_time);
396 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
397 paint_state_stack, &cache, &raster_time, &ui_time);
398 auto& preroll_context = preroll_context_holder.preroll_context;
399 auto& paint_context = paint_context_holder.paint_context;
400
401 cache.BeginFrame();
402 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
403 false);
404
406 display_list_item, preroll_context, paint_context, ctm));
407 ASSERT_FALSE(display_list_item.Draw(paint_context, &canvas, &paint));
408
409 cache.EndFrame();
410 cache.BeginFrame();
411
413 display_list_item, preroll_context, paint_context, ctm));
414 ASSERT_TRUE(display_list_item.Draw(paint_context, &canvas, &paint));
415
416 canvas.Translate(248, 0);
417 ASSERT_TRUE(cache.Draw(display_list_item.GetId().value(), canvas, &paint));
418 ASSERT_TRUE(display_list_item.Draw(paint_context, &canvas, &paint));
419}

◆ TEST() [632/709]

flutter::testing::TEST ( RasterCache  ,
DisplayListWithSingularMatrixIsNotCached   
)

Definition at line 539 of file raster_cache_unittests.cc.

539 {
540 size_t threshold = 2;
541 flutter::RasterCache cache(threshold);
542
543 SkMatrix matrices[] = {
544 SkMatrix::Scale(0, 1),
545 SkMatrix::Scale(1, 0),
546 SkMatrix::Skew(1, 1),
547 };
548 int matrix_count = sizeof(matrices) / sizeof(matrices[0]);
549
550 auto display_list = GetSampleDisplayList();
551
552 MockCanvas dummy_canvas(1000, 1000);
554
555 LayerStateStack preroll_state_stack;
556 preroll_state_stack.set_preroll_delegate(kGiantRect, SkMatrix::I());
557 LayerStateStack paint_state_stack;
558 preroll_state_stack.set_delegate(&dummy_canvas);
559
560 FixedRefreshRateStopwatch raster_time;
562 PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder(
563 preroll_state_stack, &cache, &raster_time, &ui_time);
564 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
565 paint_state_stack, &cache, &raster_time, &ui_time);
566 auto& preroll_context = preroll_context_holder.preroll_context;
567 auto& paint_context = paint_context_holder.paint_context;
568
569 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
570 false);
571
572 for (int i = 0; i < 10; i++) {
573 cache.BeginFrame();
574
575 for (int j = 0; j < matrix_count; j++) {
576 display_list_item.set_matrix(matrices[j]);
577 ASSERT_FALSE(RasterCacheItemPrerollAndTryToRasterCache(
578 display_list_item, preroll_context, paint_context, matrices[j]));
579 }
580
581 for (int j = 0; j < matrix_count; j++) {
582 dummy_canvas.SetTransform(matrices[j]);
583 ASSERT_FALSE(
584 display_list_item.Draw(paint_context, &dummy_canvas, &paint));
585 }
586
587 cache.EndFrame();
588 }
589}

◆ TEST() [633/709]

flutter::testing::TEST ( RasterCache  ,
EvictUnusedCacheEntries   
)

Definition at line 262 of file raster_cache_unittests.cc.

262 {
263 size_t threshold = 1;
264 flutter::RasterCache cache(threshold);
265
266 SkMatrix matrix = SkMatrix::I();
267
268 auto display_list_1 = GetSampleDisplayList();
269 auto display_list_2 = GetSampleDisplayList();
270
271 MockCanvas dummy_canvas(1000, 1000);
273
274 LayerStateStack preroll_state_stack;
275 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
276 LayerStateStack paint_state_stack;
277 preroll_state_stack.set_delegate(&dummy_canvas);
278
279 FixedRefreshRateStopwatch raster_time;
282 preroll_state_stack, &cache, &raster_time, &ui_time);
283 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
284 paint_state_stack, &cache, &raster_time, &ui_time);
285 auto& preroll_context = preroll_context_holder.preroll_context;
286 auto& paint_context = paint_context_holder.paint_context;
287
288 DisplayListRasterCacheItem display_list_item_1(display_list_1, SkPoint(),
289 true, false);
290 DisplayListRasterCacheItem display_list_item_2(display_list_2, SkPoint(),
291 true, false);
292
293 cache.BeginFrame();
294 RasterCacheItemPreroll(display_list_item_1, preroll_context, matrix);
295 RasterCacheItemPreroll(display_list_item_2, preroll_context, matrix);
296 cache.EvictUnusedCacheEntries();
297 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
298 ASSERT_FALSE(
299 RasterCacheItemTryToRasterCache(display_list_item_1, paint_context));
300 ASSERT_FALSE(
301 RasterCacheItemTryToRasterCache(display_list_item_2, paint_context));
302 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
303 ASSERT_FALSE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
304 ASSERT_FALSE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
305 cache.EndFrame();
306
307 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
308 ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
309 ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
310
311 cache.BeginFrame();
312 RasterCacheItemPreroll(display_list_item_1, preroll_context, matrix);
313 RasterCacheItemPreroll(display_list_item_2, preroll_context, matrix);
314 cache.EvictUnusedCacheEntries();
315 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
316 ASSERT_TRUE(
317 RasterCacheItemTryToRasterCache(display_list_item_1, paint_context));
318 ASSERT_TRUE(
319 RasterCacheItemTryToRasterCache(display_list_item_2, paint_context));
320 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 51248u);
321 ASSERT_TRUE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
322 ASSERT_TRUE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
323 cache.EndFrame();
324
325 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 51248u);
326 ASSERT_EQ(cache.picture_metrics().total_count(), 2u);
327 ASSERT_EQ(cache.picture_metrics().total_bytes(), 51248u);
328
329 cache.BeginFrame();
330 RasterCacheItemPreroll(display_list_item_1, preroll_context, matrix);
331 cache.EvictUnusedCacheEntries();
332 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 25624u);
333 ASSERT_TRUE(
334 RasterCacheItemTryToRasterCache(display_list_item_1, paint_context));
335 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 25624u);
336 ASSERT_TRUE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
337 cache.EndFrame();
338
339 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 25624u);
340 ASSERT_EQ(cache.picture_metrics().total_count(), 1u);
341 ASSERT_EQ(cache.picture_metrics().total_bytes(), 25624u);
342
343 cache.BeginFrame();
344 cache.EvictUnusedCacheEntries();
345 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
346 cache.EndFrame();
347
348 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
349 ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
350 ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
351
352 cache.BeginFrame();
353 ASSERT_FALSE(
354 cache.Draw(display_list_item_1.GetId().value(), dummy_canvas, &paint));
355 ASSERT_FALSE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
356 ASSERT_FALSE(
357 cache.Draw(display_list_item_2.GetId().value(), dummy_canvas, &paint));
358 ASSERT_FALSE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
359 cache.EndFrame();
360}

◆ TEST() [634/709]

flutter::testing::TEST ( RasterCache  ,
MetricsOmitUnpopulatedEntries   
)

Definition at line 34 of file raster_cache_unittests.cc.

34 {
35 size_t threshold = 2;
36 flutter::RasterCache cache(threshold);
37
38 SkMatrix matrix = SkMatrix::I();
39
40 auto display_list = GetSampleDisplayList();
41
42 MockCanvas dummy_canvas(1000, 1000);
44
45 LayerStateStack preroll_state_stack;
46 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
47 LayerStateStack paint_state_stack;
48 preroll_state_stack.set_delegate(&dummy_canvas);
49
50 FixedRefreshRateStopwatch raster_time;
53 preroll_state_stack, &cache, &raster_time, &ui_time);
55 paint_state_stack, &cache, &raster_time, &ui_time);
56 auto& preroll_context = preroll_context_holder.preroll_context;
57 auto& paint_context = paint_context_holder.paint_context;
58
59 cache.BeginFrame();
60 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
61 false);
62
63 // 1st access.
65 display_list_item, preroll_context, paint_context, matrix));
66 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
67
68 cache.EndFrame();
69 ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
70 ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
71 cache.BeginFrame();
72
73 // 2nd access.
75 display_list_item, preroll_context, paint_context, matrix));
76 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
77
78 cache.EndFrame();
79 ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
80 ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
81 cache.BeginFrame();
82
83 // Now Prepare should cache it.
85 display_list_item, preroll_context, paint_context, matrix));
86 ASSERT_TRUE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
87
88 cache.EndFrame();
89 ASSERT_EQ(cache.picture_metrics().total_count(), 1u);
90 // 80w * 80h * 4bpp + image object overhead
91 ASSERT_EQ(cache.picture_metrics().total_bytes(), 25624u);
92}

◆ TEST() [635/709]

flutter::testing::TEST ( RasterCache  ,
NaiveComplexityScoringDisplayList   
)

Definition at line 465 of file raster_cache_unittests.cc.

465 {
467 DisplayListNaiveComplexityCalculator::GetInstance();
468
469 size_t threshold = 1;
470 flutter::RasterCache cache(threshold);
471
472 SkMatrix matrix = SkMatrix::I();
473
474 // Five raster ops will not be cached
475 auto display_list = GetSampleDisplayList(5);
476 unsigned int complexity_score = calculator->Compute(display_list.get());
477
478 ASSERT_EQ(complexity_score, 5u);
479 ASSERT_EQ(display_list->op_count(), 5u);
480 ASSERT_FALSE(calculator->ShouldBeCached(complexity_score));
481
482 MockCanvas dummy_canvas(1000, 1000);
484
485 LayerStateStack preroll_state_stack;
486 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
487 LayerStateStack paint_state_stack;
488 preroll_state_stack.set_delegate(&dummy_canvas);
489
490 FixedRefreshRateStopwatch raster_time;
493 preroll_state_stack, &cache, &raster_time, &ui_time);
494 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
495 paint_state_stack, &cache, &raster_time, &ui_time);
496 auto& preroll_context = preroll_context_holder.preroll_context;
497 auto& paint_context = paint_context_holder.paint_context;
498
499 cache.BeginFrame();
500
501 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), false,
502 false);
503
505 display_list_item, preroll_context, paint_context, matrix));
506 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
507
508 cache.EndFrame();
509 cache.BeginFrame();
510
512 display_list_item, preroll_context, paint_context, matrix));
513 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
514
515 // Six raster ops should be cached
516 display_list = GetSampleDisplayList(6);
517 complexity_score = calculator->Compute(display_list.get());
518
519 ASSERT_EQ(complexity_score, 6u);
520 ASSERT_EQ(display_list->op_count(), 6u);
521 ASSERT_TRUE(calculator->ShouldBeCached(complexity_score));
522
523 DisplayListRasterCacheItem display_list_item_2 =
524 DisplayListRasterCacheItem(display_list, SkPoint(), false, false);
525 cache.BeginFrame();
526
528 display_list_item_2, preroll_context, paint_context, matrix));
529 ASSERT_FALSE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
530
531 cache.EndFrame();
532 cache.BeginFrame();
533
535 display_list_item_2, preroll_context, paint_context, matrix));
536 ASSERT_TRUE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
537}
virtual bool ShouldBeCached(unsigned int complexity_score)=0
virtual unsigned int Compute(const DisplayList *display_list)=0
bool Draw(const PaintContext &context, const DlPaint *paint) const override

◆ TEST() [636/709]

flutter::testing::TEST ( RasterCache  ,
NestedOpCountMetricUsedForDisplayList   
)

Definition at line 421 of file raster_cache_unittests.cc.

421 {
422 size_t threshold = 1;
423 flutter::RasterCache cache(threshold);
424
425 SkMatrix matrix = SkMatrix::I();
426
427 auto display_list = GetSampleNestedDisplayList();
428 ASSERT_EQ(display_list->op_count(), 1u);
429 ASSERT_EQ(display_list->op_count(true), 36u);
430
431 MockCanvas dummy_canvas(1000, 1000);
433
434 LayerStateStack preroll_state_stack;
435 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
436 LayerStateStack paint_state_stack;
437 preroll_state_stack.set_delegate(&dummy_canvas);
438
439 FixedRefreshRateStopwatch raster_time;
442 preroll_state_stack, &cache, &raster_time, &ui_time);
443 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
444 paint_state_stack, &cache, &raster_time, &ui_time);
445 auto& preroll_context = preroll_context_holder.preroll_context;
446 auto& paint_context = paint_context_holder.paint_context;
447
448 cache.BeginFrame();
449
450 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), false,
451 false);
452
454 display_list_item, preroll_context, paint_context, matrix));
455 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
456
457 cache.EndFrame();
458 cache.BeginFrame();
459
461 display_list_item, preroll_context, paint_context, matrix));
462 ASSERT_TRUE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
463}

◆ TEST() [637/709]

flutter::testing::TEST ( RasterCache  ,
PictureCacheLimitPerFrameIsRespectedWhenZeroForDisplayList   
)

Definition at line 219 of file raster_cache_unittests.cc.

219 {
220 size_t picture_cache_limit_per_frame = 0;
221 flutter::RasterCache cache(3, picture_cache_limit_per_frame);
222
223 SkMatrix matrix = SkMatrix::I();
224
225 auto display_list = GetSampleDisplayList();
226
227 MockCanvas dummy_canvas(1000, 1000);
229
230 LayerStateStack preroll_state_stack;
231 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
232 LayerStateStack paint_state_stack;
233 preroll_state_stack.set_delegate(&dummy_canvas);
234
235 FixedRefreshRateStopwatch raster_time;
238 preroll_state_stack, &cache, &raster_time, &ui_time);
239 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
240 paint_state_stack, &cache, &raster_time, &ui_time);
241 auto& preroll_context = preroll_context_holder.preroll_context;
242 auto& paint_context = paint_context_holder.paint_context;
243
244 cache.BeginFrame();
245
246 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
247 false);
248 // 1st access.
250 display_list_item, preroll_context, paint_context, matrix));
251 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
252 // 2nd access.
254 display_list_item, preroll_context, paint_context, matrix));
255 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
256 // the picture_cache_limit_per_frame = 0, so don't cache it
258 display_list_item, preroll_context, paint_context, matrix));
259 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
260}

◆ TEST() [638/709]

flutter::testing::TEST ( RasterCache  ,
PrepareLayerTransform   
)

Definition at line 591 of file raster_cache_unittests.cc.

591 {
592 SkRect child_bounds = SkRect::MakeLTRB(10, 10, 50, 50);
593 SkPath child_path = SkPath().addOval(child_bounds);
594 auto child_layer = MockLayer::Make(child_path);
595 auto blur_filter =
596 std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
597 auto blur_layer = std::make_shared<ImageFilterLayer>(blur_filter);
598 SkMatrix matrix = SkMatrix::Scale(2, 2);
599 auto transform_layer = std::make_shared<TransformLayer>(matrix);
600 SkMatrix cache_matrix = SkMatrix::Translate(-20, -20);
601 cache_matrix.preConcat(matrix);
602 child_layer->set_expected_paint_matrix(cache_matrix);
603
604 blur_layer->Add(child_layer);
605 transform_layer->Add(blur_layer);
606
607 size_t threshold = 2;
608 MockRasterCache cache(threshold);
609 MockCanvas dummy_canvas(1000, 1000);
610
611 LayerStateStack preroll_state_stack;
612 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
613 LayerStateStack paint_state_stack;
614 preroll_state_stack.set_delegate(&dummy_canvas);
615
616 FixedRefreshRateStopwatch raster_time;
618 std::vector<RasterCacheItem*> cache_items;
619
620 cache.BeginFrame();
621
622 auto preroll_holder = GetSamplePrerollContextHolder(
623 preroll_state_stack, &cache, &raster_time, &ui_time);
624 preroll_holder.preroll_context.raster_cached_entries = &cache_items;
625 transform_layer->Preroll(&preroll_holder.preroll_context);
626
627 auto paint_holder = GetSamplePaintContextHolder(paint_state_stack, &cache,
628 &raster_time, &ui_time);
629
630 cache.EvictUnusedCacheEntries();
631 LayerTree::TryToRasterCache(
632 *preroll_holder.preroll_context.raster_cached_entries,
633 &paint_holder.paint_context);
634
635 // Condition tested inside MockLayer::Paint against expected paint matrix.
636}
SkPath & addOval(const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW)
Definition SkPath.cpp:1101
A RasterCache implementation that simulates the act of rendering a Layer or DisplayList without the o...

◆ TEST() [639/709]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeyHashFunction   
)

Definition at line 638 of file raster_cache_unittests.cc.

638 {
640 auto hash_function = map.hash_function();
641 SkMatrix matrix = SkMatrix::I();
642 uint64_t id = 5;
643 RasterCacheKey layer_key(id, RasterCacheKeyType::kLayer, matrix);
644 RasterCacheKey display_list_key(id, RasterCacheKeyType::kDisplayList, matrix);
645 RasterCacheKey layer_children_key(id, RasterCacheKeyType::kLayerChildren,
646 matrix);
647
648 auto layer_cache_key_id = RasterCacheKeyID(id, RasterCacheKeyType::kLayer);
649 auto layer_hash_code = hash_function(layer_key);
650 ASSERT_EQ(layer_hash_code, layer_cache_key_id.GetHash());
651
652 auto display_list_cache_key_id =
653 RasterCacheKeyID(id, RasterCacheKeyType::kDisplayList);
654 auto display_list_hash_code = hash_function(display_list_key);
655 ASSERT_EQ(display_list_hash_code, display_list_cache_key_id.GetHash());
656
657 auto layer_children_cache_key_id =
658 RasterCacheKeyID(id, RasterCacheKeyType::kLayerChildren);
659 auto layer_children_hash_code = hash_function(layer_children_key);
660 ASSERT_EQ(layer_children_hash_code, layer_children_cache_key_id.GetHash());
661}
std::unordered_map< RasterCacheKey, Value, Hash, Equal > Map

◆ TEST() [640/709]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeyIDEqual   
)

Definition at line 735 of file raster_cache_unittests.cc.

735 {
736 RasterCacheKeyID first = RasterCacheKeyID(1, RasterCacheKeyType::kLayer);
737 RasterCacheKeyID second = RasterCacheKeyID(2, RasterCacheKeyType::kLayer);
738 RasterCacheKeyID third =
739 RasterCacheKeyID(1, RasterCacheKeyType::kLayerChildren);
740
741 ASSERT_NE(first, second);
742 ASSERT_NE(first, third);
743 ASSERT_NE(second, third);
744
745 RasterCacheKeyID fourth =
746 RasterCacheKeyID({first, second}, RasterCacheKeyType::kLayer);
747 RasterCacheKeyID fifth =
748 RasterCacheKeyID({first, second}, RasterCacheKeyType::kLayerChildren);
749 RasterCacheKeyID sixth =
750 RasterCacheKeyID({second, first}, RasterCacheKeyType::kLayerChildren);
751 ASSERT_NE(fourth, fifth);
752 ASSERT_NE(fifth, sixth);
753}

◆ TEST() [641/709]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeyIDHashCode   
)

Definition at line 755 of file raster_cache_unittests.cc.

755 {
756 uint64_t foo = 1;
757 uint64_t bar = 2;
758 RasterCacheKeyID first = RasterCacheKeyID(foo, RasterCacheKeyType::kLayer);
759 RasterCacheKeyID second = RasterCacheKeyID(bar, RasterCacheKeyType::kLayer);
760 std::size_t first_hash = first.GetHash();
761 std::size_t second_hash = second.GetHash();
762
763 ASSERT_EQ(first_hash, fml::HashCombine(foo, RasterCacheKeyType::kLayer));
764 ASSERT_EQ(second_hash, fml::HashCombine(bar, RasterCacheKeyType::kLayer));
765
766 RasterCacheKeyID third =
767 RasterCacheKeyID({first, second}, RasterCacheKeyType::kLayerChildren);
768 RasterCacheKeyID fourth =
769 RasterCacheKeyID({second, first}, RasterCacheKeyType::kLayerChildren);
770 std::size_t third_hash = third.GetHash();
771 std::size_t fourth_hash = fourth.GetHash();
772
773 ASSERT_EQ(third_hash, fml::HashCombine(RasterCacheKeyID::kDefaultUniqueID,
774 RasterCacheKeyType::kLayerChildren,
775 first.GetHash(), second.GetHash()));
776 ASSERT_EQ(fourth_hash, fml::HashCombine(RasterCacheKeyID::kDefaultUniqueID,
777 RasterCacheKeyType::kLayerChildren,
778 second.GetHash(), first.GetHash()));
779
780 // Verify that the cached hash code is correct.
781 ASSERT_EQ(first_hash, first.GetHash());
782 ASSERT_EQ(second_hash, second.GetHash());
783 ASSERT_EQ(third_hash, third.GetHash());
784 ASSERT_EQ(fourth_hash, fourth.GetHash());
785}
std::size_t GetHash() const
constexpr std::size_t HashCombine()

◆ TEST() [642/709]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeySameID   
)

Definition at line 663 of file raster_cache_unittests.cc.

663 {
665 SkMatrix matrix = SkMatrix::I();
666 uint64_t id = 5;
667 RasterCacheKey layer_key(id, RasterCacheKeyType::kLayer, matrix);
668 RasterCacheKey display_list_key(id, RasterCacheKeyType::kDisplayList, matrix);
669 RasterCacheKey layer_children_key(id, RasterCacheKeyType::kLayerChildren,
670 matrix);
671 map[layer_key] = 100;
672 map[display_list_key] = 300;
673 map[layer_children_key] = 400;
674
675 ASSERT_EQ(map[layer_key], 100);
676 ASSERT_EQ(map[display_list_key], 300);
677 ASSERT_EQ(map[layer_children_key], 400);
678}

◆ TEST() [643/709]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeySameType   
)

Definition at line 680 of file raster_cache_unittests.cc.

680 {
682 SkMatrix matrix = SkMatrix::I();
683
684 RasterCacheKeyType type = RasterCacheKeyType::kLayer;
685 RasterCacheKey layer_first_key(5, type, matrix);
686 RasterCacheKey layer_second_key(10, type, matrix);
687 RasterCacheKey layer_third_key(15, type, matrix);
688 map[layer_first_key] = 50;
689 map[layer_second_key] = 100;
690 map[layer_third_key] = 150;
691 ASSERT_EQ(map[layer_first_key], 50);
692 ASSERT_EQ(map[layer_second_key], 100);
693 ASSERT_EQ(map[layer_third_key], 150);
694
695 type = RasterCacheKeyType::kDisplayList;
696 RasterCacheKey picture_first_key(20, type, matrix);
697 RasterCacheKey picture_second_key(25, type, matrix);
698 RasterCacheKey picture_third_key(30, type, matrix);
699 map[picture_first_key] = 200;
700 map[picture_second_key] = 250;
701 map[picture_third_key] = 300;
702 ASSERT_EQ(map[picture_first_key], 200);
703 ASSERT_EQ(map[picture_second_key], 250);
704 ASSERT_EQ(map[picture_third_key], 300);
705
706 type = RasterCacheKeyType::kDisplayList;
707 RasterCacheKey display_list_first_key(35, type, matrix);
708 RasterCacheKey display_list_second_key(40, type, matrix);
709 RasterCacheKey display_list_third_key(45, type, matrix);
710 map[display_list_first_key] = 350;
711 map[display_list_second_key] = 400;
712 map[display_list_third_key] = 450;
713 ASSERT_EQ(map[display_list_first_key], 350);
714 ASSERT_EQ(map[display_list_second_key], 400);
715 ASSERT_EQ(map[display_list_third_key], 450);
716
717 type = RasterCacheKeyType::kLayerChildren;
718 RasterCacheKeyID foo = RasterCacheKeyID(10, RasterCacheKeyType::kLayer);
719 RasterCacheKeyID bar = RasterCacheKeyID(20, RasterCacheKeyType::kLayer);
720 RasterCacheKeyID baz = RasterCacheKeyID(30, RasterCacheKeyType::kLayer);
721 RasterCacheKey layer_children_first_key(
722 RasterCacheKeyID({foo, bar, baz}, type), matrix);
723 RasterCacheKey layer_children_second_key(
724 RasterCacheKeyID({foo, baz, bar}, type), matrix);
725 RasterCacheKey layer_children_third_key(
726 RasterCacheKeyID({baz, bar, foo}, type), matrix);
727 map[layer_children_first_key] = 100;
728 map[layer_children_second_key] = 200;
729 map[layer_children_third_key] = 300;
730 ASSERT_EQ(map[layer_children_first_key], 100);
731 ASSERT_EQ(map[layer_children_second_key], 200);
732 ASSERT_EQ(map[layer_children_third_key], 300);
733}
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition SkVx.h:680

◆ TEST() [644/709]

flutter::testing::TEST ( RasterCache  ,
SetCheckboardCacheImages   
)

Definition at line 146 of file raster_cache_unittests.cc.

146 {
147 size_t threshold = 1;
148 flutter::RasterCache cache(threshold);
149
150 SkMatrix matrix = SkMatrix::I();
151 auto display_list = GetSampleDisplayList();
152
153 LayerStateStack preroll_state_stack;
154 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
155
156 FixedRefreshRateStopwatch raster_time;
158 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
159 preroll_state_stack, &cache, &raster_time, &ui_time);
160 auto& paint_context = paint_context_holder.paint_context;
161 auto dummy_draw_function = [](DlCanvas* canvas) {};
162 bool did_draw_checkerboard = false;
163 auto draw_checkerboard = [&](DlCanvas* canvas, const SkRect&) {
164 did_draw_checkerboard = true;
165 };
166 RasterCache::Context r_context = {
167 // clang-format off
168 .gr_context = paint_context.gr_context,
169 .dst_color_space = paint_context.dst_color_space,
170 .matrix = matrix,
171 .logical_rect = display_list->bounds(),
172 .flow_type = "RasterCacheFlow::DisplayList",
173 // clang-format on
174 };
175
176 cache.SetCheckboardCacheImages(false);
177 cache.Rasterize(r_context, nullptr, dummy_draw_function, draw_checkerboard);
178 ASSERT_FALSE(did_draw_checkerboard);
179
180 cache.SetCheckboardCacheImages(true);
181 cache.Rasterize(r_context, nullptr, dummy_draw_function, draw_checkerboard);
182 ASSERT_TRUE(did_draw_checkerboard);
183}

◆ TEST() [645/709]

flutter::testing::TEST ( RasterCache  ,
SimpleInitialization   
)

Definition at line 29 of file raster_cache_unittests.cc.

29 {
31 ASSERT_TRUE(true);
32}

◆ TEST() [646/709]

flutter::testing::TEST ( RasterCache  ,
ThresholdIsRespectedForDisplayList   
)

Definition at line 94 of file raster_cache_unittests.cc.

94 {
95 size_t threshold = 2;
96 flutter::RasterCache cache(threshold);
97
98 SkMatrix matrix = SkMatrix::I();
99
100 auto display_list = GetSampleDisplayList();
101
102 MockCanvas dummy_canvas(1000, 1000);
104
105 LayerStateStack preroll_state_stack;
106 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
107 LayerStateStack paint_state_stack;
108 preroll_state_stack.set_delegate(&dummy_canvas);
109
110 FixedRefreshRateStopwatch raster_time;
113 preroll_state_stack, &cache, &raster_time, &ui_time);
114 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
115 paint_state_stack, &cache, &raster_time, &ui_time);
116 auto& preroll_context = preroll_context_holder.preroll_context;
117 auto& paint_context = paint_context_holder.paint_context;
118
119 cache.BeginFrame();
120
121 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
122 false);
123
124 // 1st access.
126 display_list_item, preroll_context, paint_context, matrix));
127 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
128
129 cache.EndFrame();
130 cache.BeginFrame();
131
132 // 2nd access.
134 display_list_item, preroll_context, paint_context, matrix));
135 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
136
137 cache.EndFrame();
138 cache.BeginFrame();
139
140 // Now Prepare should cache it.
142 display_list_item, preroll_context, paint_context, matrix));
143 ASSERT_TRUE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
144}

◆ TEST() [647/709]

flutter::testing::TEST ( RasterCacheUtilsTest  ,
SkM44IntegralTransCTM   
)

Definition at line 1013 of file raster_cache_unittests.cc.

1013 {
1014#define EXPECT_EQ_WITH_TRANSLATE(test, expected, tx, ty, label) \
1015 do { \
1016 EXPECT_EQ(test.rc(0, 0), expected.rc(0, 0)) << label; \
1017 EXPECT_EQ(test.rc(0, 1), expected.rc(0, 1)) << label; \
1018 EXPECT_EQ(test.rc(0, 2), expected.rc(0, 2)) << label; \
1019 EXPECT_EQ(test.rc(0, 3), tx) << label; \
1020 EXPECT_EQ(test.rc(1, 0), expected.rc(1, 0)) << label; \
1021 EXPECT_EQ(test.rc(1, 1), expected.rc(1, 1)) << label; \
1022 EXPECT_EQ(test.rc(1, 2), expected.rc(1, 2)) << label; \
1023 EXPECT_EQ(test.rc(1, 3), ty) << label; \
1024 EXPECT_EQ(test.rc(2, 0), expected.rc(2, 0)) << label; \
1025 EXPECT_EQ(test.rc(2, 1), expected.rc(2, 1)) << label; \
1026 EXPECT_EQ(test.rc(2, 2), expected.rc(2, 2)) << label; \
1027 EXPECT_EQ(test.rc(2, 3), expected.rc(2, 3)) << label; \
1028 EXPECT_EQ(test.rc(3, 0), expected.rc(3, 0)) << label; \
1029 EXPECT_EQ(test.rc(3, 1), expected.rc(3, 1)) << label; \
1030 EXPECT_EQ(test.rc(3, 2), expected.rc(3, 2)) << label; \
1031 EXPECT_EQ(test.rc(3, 3), expected.rc(3, 3)) << label; \
1032 } while (0)
1033
1034#define EXPECT_NON_INTEGER_TRANSLATION(matrix) \
1035 EXPECT_TRUE(SkScalarFraction(matrix.rc(0, 3)) != 0.0f || \
1036 SkScalarFraction(matrix.rc(1, 3)) != 0.0f)
1037
1038 for (int r = 0; r < 4; r++) {
1039 for (int c = 0; c < 4; c++) {
1040 bool snaps;
1041 switch (r) {
1042 case 0: // X equation
1043 if (c == 3) {
1044 continue; // TranslateX, the value we are testing, skip
1045 }
1046 snaps = (c == 0); // X Scale value yes, Skew by Y or Z no
1047 break;
1048 case 1: // Y equation
1049 if (c == 3) {
1050 continue; // TranslateY, the value we are testing, skip
1051 }
1052 snaps = (c == 1); // Y Scale value yes, Skew by X or Z no
1053 break;
1054 case 2: // Z equation, ignored, will snap
1055 snaps = true;
1056 break;
1057 case 3: // W equation, modifications prevent snapping
1058 snaps = false;
1059 break;
1060 default:
1062 }
1063 auto label = std::to_string(r) + ", " + std::to_string(c);
1064 SkM44 matrix = SkM44::Translate(10.7f, 12.1f);
1065 EXPECT_NON_INTEGER_TRANSLATION(matrix) << label;
1066 matrix.setRC(r, c, 0.5f);
1067 if (snaps) {
1068 SkM44 compute;
1069 SkM44 get = RasterCacheUtil::GetIntegralTransCTM(matrix);
1070 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute))
1071 << label;
1072 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 11.0f, 12.0f, label);
1073 EXPECT_EQ(get, compute) << label;
1074 } else {
1075 SkM44 compute;
1076 SkM44 get = RasterCacheUtil::GetIntegralTransCTM(matrix);
1077 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute))
1078 << label;
1079 EXPECT_EQ(get, matrix) << label;
1080 }
1081 }
1082 }
1083#undef EXPECT_NON_INTEGER_TRANSLATION
1084#undef EXPECT_EQ_WITH_TRANSLATE
1085}
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
Definition SkM44.h:225
#define FML_UNREACHABLE()
Definition logging.h:109
#define EXPECT_NON_INTEGER_TRANSLATION(matrix)
#define EXPECT_EQ_WITH_TRANSLATE(test, expected, expected_tx, expected_ty)

◆ TEST() [648/709]

flutter::testing::TEST ( RasterCacheUtilsTest  ,
SkMatrixIntegralTransCTM   
)

Definition at line 812 of file raster_cache_unittests.cc.

812 {
813#define EXPECT_EQ_WITH_TRANSLATE(test, expected, expected_tx, expected_ty) \
814 do { \
815 EXPECT_EQ(test[SkMatrix::kMScaleX], expected[SkMatrix::kMScaleX]); \
816 EXPECT_EQ(test[SkMatrix::kMSkewX], expected[SkMatrix::kMSkewX]); \
817 EXPECT_EQ(test[SkMatrix::kMScaleY], expected[SkMatrix::kMScaleY]); \
818 EXPECT_EQ(test[SkMatrix::kMSkewY], expected[SkMatrix::kMSkewY]); \
819 EXPECT_EQ(test[SkMatrix::kMSkewX], expected[SkMatrix::kMSkewX]); \
820 EXPECT_EQ(test[SkMatrix::kMPersp0], expected[SkMatrix::kMPersp0]); \
821 EXPECT_EQ(test[SkMatrix::kMPersp1], expected[SkMatrix::kMPersp1]); \
822 EXPECT_EQ(test[SkMatrix::kMPersp2], expected[SkMatrix::kMPersp2]); \
823 EXPECT_EQ(test[SkMatrix::kMTransX], expected_tx); \
824 EXPECT_EQ(test[SkMatrix::kMTransY], expected_ty); \
825 } while (0)
826
827#define EXPECT_NON_INTEGER_TRANSLATION(matrix) \
828 EXPECT_TRUE(SkScalarFraction(matrix[SkMatrix::kMTransX]) != 0.0f || \
829 SkScalarFraction(matrix[SkMatrix::kMTransY]) != 0.0f)
830
831 {
832 // Identity
833 SkMatrix matrix = SkMatrix::I();
834 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
835 SkMatrix compute;
836 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
837 EXPECT_EQ(get, matrix);
838 }
839 {
840 // Integer translate
841 SkMatrix matrix = SkMatrix::Translate(10.0f, 12.0f);
842 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
843 SkMatrix compute;
844 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
845 EXPECT_EQ(get, matrix);
846 }
847 {
848 // Fractional x translate
849 SkMatrix matrix = SkMatrix::Translate(10.2f, 12.0f);
851 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
852 SkMatrix compute;
853 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
854 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 10.0f, 12.0f);
855 EXPECT_EQ(get, compute);
856 }
857 {
858 // Fractional y translate
859 SkMatrix matrix = SkMatrix::Translate(10.0f, 12.3f);
861 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
862 SkMatrix compute;
863 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
864 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 10.0f, 12.0f);
865 EXPECT_EQ(get, compute);
866 }
867 {
868 // Fractional x & y translate
869 SkMatrix matrix = SkMatrix::Translate(10.7f, 12.3f);
871 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
872 SkMatrix compute;
873 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
874 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 11.0f, 12.0f);
875 EXPECT_EQ(get, compute);
876 }
877 {
878 // Scale
879 SkMatrix matrix = SkMatrix::Scale(2.0f, 3.0f);
880 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
881 SkMatrix compute;
882 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
883 EXPECT_EQ(get, matrix);
884 }
885 {
886 // Scale, Integer translate
887 SkMatrix matrix = SkMatrix::Scale(2.0f, 3.0f);
888 matrix.preTranslate(10.0f, 12.0f);
889 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
890 SkMatrix compute;
891 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
892 EXPECT_EQ(get, matrix);
893 }
894 {
895 // Scale, Fractional translate
896 SkMatrix matrix = SkMatrix::Scale(2.0f, 3.0f);
897 matrix.preTranslate(10.7f, 12.1f);
899 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
900 SkMatrix compute;
901 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
902 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 21.0f, 36.0f);
903 EXPECT_EQ(get, compute);
904 }
905 {
906 // Skew
907 SkMatrix matrix = SkMatrix::Skew(0.5f, 0.1f);
908 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
909 SkMatrix compute;
910 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
911 EXPECT_EQ(get, matrix);
912 }
913 {
914 // Skew, Fractional translate - should be NOP
915 SkMatrix matrix = SkMatrix::Skew(0.5f, 0.1f);
916 matrix.preTranslate(10.7f, 12.1f);
918 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
919 SkMatrix compute;
920 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
921 EXPECT_EQ(get, matrix);
922 }
923 {
924 // Rotate
926 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
927 SkMatrix compute;
928 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
929 EXPECT_EQ(get, matrix);
930 }
931 {
932 // Rotate, Fractional Translate - should be NOP
934 matrix.preTranslate(10.7f, 12.1f);
936 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
937 SkMatrix compute;
938 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
939 EXPECT_EQ(get, matrix);
940 }
941 {
942 // Perspective x
944 matrix.setPerspX(0.1);
945 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
946 SkMatrix compute;
947 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
948 EXPECT_EQ(get, matrix);
949 }
950 {
951 // Perspective x, Fractional Translate - should be NOP
953 matrix.setPerspX(0.1);
954 matrix.preTranslate(10.7f, 12.1f);
956 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
957 SkMatrix compute;
958 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
959 EXPECT_EQ(get, matrix);
960 }
961 {
962 // Perspective y
964 matrix.setPerspY(0.1);
965 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
966 SkMatrix compute;
967 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
968 EXPECT_EQ(get, matrix);
969 }
970 {
971 // Perspective y, Fractional Translate - should be NOP
973 matrix.setPerspY(0.1);
974 matrix.preTranslate(10.7f, 12.1f);
976 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
977 SkMatrix compute;
978 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
979 EXPECT_EQ(get, matrix);
980 }
981 {
982 // Perspective weight
983 // clang-format off
985 1.0f, 0.0f, 0.0f,
986 0.0f, 1.0f, 0.0f,
987 0.0f, 0.0f, 0.9f);
988 // clang-format on
989 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
990 SkMatrix compute;
991 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
992 EXPECT_EQ(get, matrix);
993 }
994 {
995 // Perspective weight, Fractional Translate - should be NOP
996 // clang-format off
998 1.0f, 0.0f, 0.0f,
999 0.0f, 1.0f, 0.0f,
1000 0.0f, 0.0f, 0.9f);
1001 // clang-format on
1002 matrix.preTranslate(10.7f, 12.1f);
1004 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
1005 SkMatrix compute;
1006 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
1007 EXPECT_EQ(get, matrix);
1008 }
1009#undef EXPECT_NON_INTEGER_TRANSLATION
1010#undef EXPECT_EQ_WITH_TRANSLATE
1011}

◆ TEST() [649/709]

flutter::testing::TEST ( ResourceCacheLimitCalculatorTest  ,
GetResourceCacheMaxBytes   
)

Definition at line 28 of file resource_cache_limit_calculator_unittests.cc.

28 {
29 ResourceCacheLimitCalculator calculator(800U);
30 auto item1 = std::make_unique<TestResourceCacheLimitItem>(100.0);
31 calculator.AddResourceCacheLimitItem(item1->GetWeakPtr());
32 EXPECT_EQ(calculator.GetResourceCacheMaxBytes(), static_cast<size_t>(100U));
33
34 auto item2 = std::make_unique<TestResourceCacheLimitItem>(200.0);
35 calculator.AddResourceCacheLimitItem(item2->GetWeakPtr());
36 EXPECT_EQ(calculator.GetResourceCacheMaxBytes(), static_cast<size_t>(300U));
37
38 auto item3 = std::make_unique<TestResourceCacheLimitItem>(300.0);
39 calculator.AddResourceCacheLimitItem(item3->GetWeakPtr());
40 EXPECT_EQ(calculator.GetResourceCacheMaxBytes(), static_cast<size_t>(600U));
41
42 auto item4 = std::make_unique<TestResourceCacheLimitItem>(400.0);
43 calculator.AddResourceCacheLimitItem(item4->GetWeakPtr());
44 EXPECT_EQ(calculator.GetResourceCacheMaxBytes(), static_cast<size_t>(800U));
45
46 item3.reset();
47 EXPECT_EQ(calculator.GetResourceCacheMaxBytes(), static_cast<size_t>(700U));
48
49 item2.reset();
50 EXPECT_EQ(calculator.GetResourceCacheMaxBytes(), static_cast<size_t>(500U));
51}

◆ TEST() [650/709]

flutter::testing::TEST ( RTree  ,
searchNonOverlappingDrawnRectsIgnoresNonDrawingRecords   
)

Definition at line 57 of file rtree_unittests.cc.

57 {
58 auto rtree_factory = RTreeFactory();
59 auto recorder = std::make_unique<SkPictureRecorder>();
60 auto recording_canvas =
61 recorder->beginRecording(SkRect::MakeIWH(1000, 1000), &rtree_factory);
62
63 auto rect_paint = SkPaint();
64 rect_paint.setColor(SkColors::kCyan);
65 rect_paint.setStyle(SkPaint::Style::kFill_Style);
66
67 // Creates two non drawing records.
68 recording_canvas->translate(100, 100);
69 // The result list should only contain the clipping rect.
70 recording_canvas->clipRect(SkRect::MakeLTRB(40, 40, 50, 50),
72 recording_canvas->drawRect(SkRect::MakeLTRB(20, 20, 80, 80), rect_paint);
73
74 recorder->finishRecordingAsPicture();
75
76 // The rtree has a translate, a clip and a rect record.
77 ASSERT_EQ(3, rtree_factory.getInstance()->getCount());
78
79 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
80 SkRect::MakeLTRB(0, 0, 1000, 1000));
81 ASSERT_EQ(1UL, hits.size());
82 ASSERT_EQ(*hits.begin(), SkRect::MakeLTRB(120, 120, 180, 180));
83}
constexpr SkColor4f kCyan
Definition SkColor.h:444
static SkRect MakeIWH(int w, int h)
Definition SkRect.h:623

◆ TEST() [651/709]

flutter::testing::TEST ( RTree  ,
searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase1   
)

Definition at line 116 of file rtree_unittests.cc.

116 {
117 auto rtree_factory = RTreeFactory();
118 auto recorder = std::make_unique<SkPictureRecorder>();
119 auto recording_canvas =
120 recorder->beginRecording(SkRect::MakeIWH(1000, 1000), &rtree_factory);
121
122 auto rect_paint = SkPaint();
123 rect_paint.setColor(SkColors::kCyan);
124 rect_paint.setStyle(SkPaint::Style::kFill_Style);
125
126 // Given the A, and B rects, which intersect with the query rect,
127 // the result list contains the three rectangles covering same area.
128 //
129 // +-----+ +-----+
130 // | A | | A |
131 // | +-----+ +---------+
132 // | | | | B |
133 // +---| B | +---+-----+
134 // | | | C |
135 // +-----+ +-----+
136
137 // A
138 recording_canvas->drawRect(SkRect::MakeLTRB(100, 100, 150, 150), rect_paint);
139 // B
140 recording_canvas->drawRect(SkRect::MakeLTRB(125, 125, 175, 175), rect_paint);
141
142 recorder->finishRecordingAsPicture();
143
144 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
145 SkRect::MakeXYWH(120, 120, 126, 126));
146 ASSERT_EQ(3UL, hits.size());
147 ASSERT_EQ(*hits.begin(), SkRect::MakeLTRB(100, 100, 150, 125));
148 ASSERT_EQ(*std::next(hits.begin(), 1), SkRect::MakeLTRB(100, 125, 175, 150));
149 ASSERT_EQ(*std::next(hits.begin(), 2), SkRect::MakeLTRB(125, 150, 175, 175));
150}

◆ TEST() [652/709]

flutter::testing::TEST ( RTree  ,
searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase2   
)

Definition at line 152 of file rtree_unittests.cc.

152 {
153 auto rtree_factory = RTreeFactory();
154 auto recorder = std::make_unique<SkPictureRecorder>();
155 auto recording_canvas =
156 recorder->beginRecording(SkRect::MakeIWH(1000, 1000), &rtree_factory);
157
158 auto rect_paint = SkPaint();
159 rect_paint.setColor(SkColors::kCyan);
160 rect_paint.setStyle(SkPaint::Style::kFill_Style);
161
162 // Given the A, B, and C rects that intersect with the query rect,
163 // there should be only C in the result list,
164 // since A and B are contained in C.
165 //
166 // +---------------------+
167 // | C |
168 // | +-----+ +-----+ |
169 // | | A | | B | |
170 // | +-----+ +-----+ |
171 // +---------------------+
172 // +-----+
173 // | D |
174 // +-----+
175
176 // A
177 recording_canvas->drawRect(SkRect::MakeLTRB(100, 100, 200, 200), rect_paint);
178 // B
179 recording_canvas->drawRect(SkRect::MakeLTRB(300, 100, 400, 200), rect_paint);
180 // C
181 recording_canvas->drawRect(SkRect::MakeLTRB(50, 50, 500, 250), rect_paint);
182 // D
183 recording_canvas->drawRect(SkRect::MakeLTRB(280, 100, 280, 320), rect_paint);
184
185 recorder->finishRecordingAsPicture();
186
187 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
188 SkRect::MakeLTRB(30, 30, 550, 270));
189 ASSERT_EQ(1UL, hits.size());
190 ASSERT_EQ(*hits.begin(), SkRect::MakeLTRB(50, 50, 500, 250));
191}

◆ TEST() [653/709]

flutter::testing::TEST ( RTree  ,
searchNonOverlappingDrawnRectsJoinRectsWhenIntersectedCase3   
)

Definition at line 193 of file rtree_unittests.cc.

193 {
194 auto rtree_factory = RTreeFactory();
195 auto recorder = std::make_unique<SkPictureRecorder>();
196 auto recording_canvas =
197 recorder->beginRecording(SkRect::MakeIWH(1000, 1000), &rtree_factory);
198
199 auto rect_paint = SkPaint();
200 rect_paint.setColor(SkColors::kCyan);
201 rect_paint.setStyle(SkPaint::Style::kFill_Style);
202
203 // Given the A, B, C and D rects that intersect with the query rect,
204 // the result list contains two rects - D and remainder of C
205 // these four rects.
206 //
207 // +------------------------------+
208 // | D |
209 // | +-----+ +-----+ +-----+ |
210 // | | A | | B | | C | |
211 // | +-----+ +-----+ | | |
212 // +----------------------| |-+
213 // +-----+
214 // +-----+
215 // | E |
216 // +-----+
217
218 // A
219 recording_canvas->drawRect(SkRect::MakeLTRB(100, 100, 200, 200), rect_paint);
220 // B
221 recording_canvas->drawRect(SkRect::MakeLTRB(300, 100, 400, 200), rect_paint);
222 // C
223 recording_canvas->drawRect(SkRect::MakeLTRB(500, 100, 600, 300), rect_paint);
224 // D
225 recording_canvas->drawRect(SkRect::MakeLTRB(50, 50, 620, 250), rect_paint);
226 // E
227 recording_canvas->drawRect(SkRect::MakeLTRB(280, 100, 280, 320), rect_paint);
228
229 recorder->finishRecordingAsPicture();
230
231 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
232 SkRect::MakeLTRB(30, 30, 550, 270));
233 ASSERT_EQ(2UL, hits.size());
234 ASSERT_EQ(*hits.begin(), SkRect::MakeLTRB(50, 50, 620, 250));
235 ASSERT_EQ(*std::next(hits.begin(), 1), SkRect::MakeLTRB(500, 250, 600, 300));
236}

◆ TEST() [654/709]

flutter::testing::TEST ( RTree  ,
searchNonOverlappingDrawnRectsMultipleRectIntersection   
)

Definition at line 85 of file rtree_unittests.cc.

85 {
86 auto rtree_factory = RTreeFactory();
87 auto recorder = std::make_unique<SkPictureRecorder>();
88 auto recording_canvas =
89 recorder->beginRecording(SkRect::MakeIWH(1000, 1000), &rtree_factory);
90
91 auto rect_paint = SkPaint();
92 rect_paint.setColor(SkColors::kCyan);
93 rect_paint.setStyle(SkPaint::Style::kFill_Style);
94
95 // Given the A, B that intersect with the query rect,
96 // there should be A and B in the result list since
97 // they don't intersect with each other.
98 //
99 // +-----+ +-----+
100 // | A | | B |
101 // +-----+ +-----+
102 // A
103 recording_canvas->drawRect(SkRect::MakeLTRB(100, 100, 200, 200), rect_paint);
104 // B
105 recording_canvas->drawRect(SkRect::MakeLTRB(300, 100, 400, 200), rect_paint);
106
107 recorder->finishRecordingAsPicture();
108
109 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
110 SkRect::MakeLTRB(0, 0, 1000, 1050));
111 ASSERT_EQ(2UL, hits.size());
112 ASSERT_EQ(*hits.begin(), SkRect::MakeLTRB(100, 100, 200, 200));
113 ASSERT_EQ(*std::next(hits.begin(), 1), SkRect::MakeLTRB(300, 100, 400, 200));
114}

◆ TEST() [655/709]

flutter::testing::TEST ( RTree  ,
searchNonOverlappingDrawnRectsNoIntersection   
)

Definition at line 15 of file rtree_unittests.cc.

15 {
16 auto rtree_factory = RTreeFactory();
17 auto recorder = std::make_unique<SkPictureRecorder>();
18 auto recording_canvas =
19 recorder->beginRecording(SkRect::MakeIWH(1000, 1000), &rtree_factory);
20
21 auto rect_paint = SkPaint();
22 rect_paint.setColor(SkColors::kCyan);
23 rect_paint.setStyle(SkPaint::Style::kFill_Style);
24
25 // If no rect is intersected with the query rect, then the result list is
26 // empty.
27 recording_canvas->drawRect(SkRect::MakeLTRB(20, 20, 40, 40), rect_paint);
28 recorder->finishRecordingAsPicture();
29
30 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
31 SkRect::MakeLTRB(40, 40, 80, 80));
32 ASSERT_TRUE(hits.empty());
33}

◆ TEST() [656/709]

flutter::testing::TEST ( RTree  ,
searchNonOverlappingDrawnRectsSingleRectIntersection   
)

Definition at line 35 of file rtree_unittests.cc.

35 {
36 auto rtree_factory = RTreeFactory();
37 auto recorder = std::make_unique<SkPictureRecorder>();
38 auto recording_canvas =
39 recorder->beginRecording(SkRect::MakeIWH(1000, 1000), &rtree_factory);
40
41 auto rect_paint = SkPaint();
42 rect_paint.setColor(SkColors::kCyan);
43 rect_paint.setStyle(SkPaint::Style::kFill_Style);
44
45 // Given a single rect A that intersects with the query rect,
46 // the result list contains this rect.
47 recording_canvas->drawRect(SkRect::MakeLTRB(120, 120, 160, 160), rect_paint);
48
49 recorder->finishRecordingAsPicture();
50
51 auto hits = rtree_factory.getInstance()->searchNonOverlappingDrawnRects(
52 SkRect::MakeLTRB(140, 140, 150, 150));
53 ASSERT_EQ(1UL, hits.size());
54 ASSERT_EQ(*hits.begin(), SkRect::MakeLTRB(120, 120, 160, 160));
55}

◆ TEST() [657/709]

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}

◆ TEST() [658/709]

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}

◆ TEST() [659/709]

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

Definition at line 80 of file settings_plugin_unittests.cc.

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

◆ TEST() [660/709]

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

Definition at line 55 of file settings_plugin_unittests.cc.

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

◆ TEST() [661/709]

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

Definition at line 42 of file settings_plugin_unittests.cc.

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

◆ TEST() [662/709]

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

Definition at line 68 of file settings_plugin_unittests.cc.

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

◆ TEST() [663/709]

flutter::testing::TEST ( SettingsTest  ,
FrameTimingSetsAndGetsProperly   
)

Definition at line 1505 of file shell_unittests.cc.

1505 {
1506 // Ensure that all phases are in kPhases.
1507 ASSERT_EQ(sizeof(FrameTiming::kPhases),
1508 FrameTiming::kCount * sizeof(FrameTiming::Phase));
1509
1510 int lastPhaseIndex = -1;
1511 FrameTiming timing;
1512 for (auto phase : FrameTiming::kPhases) {
1513 ASSERT_TRUE(phase > lastPhaseIndex); // Ensure that kPhases are in order.
1514 lastPhaseIndex = phase;
1515 auto fake_time =
1517 timing.Set(phase, fake_time);
1518 ASSERT_TRUE(timing.Get(phase) == fake_time);
1519 }
1520}
fml::TimePoint Set(Phase phase, fml::TimePoint value)
Definition settings.h:52
fml::TimePoint Get(Phase phase) const
Definition settings.h:51
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition time_delta.h:43

◆ TEST() [664/709]

flutter::testing::TEST ( SurfacePool  ,
DestroyLayers   
)

Definition at line 187 of file surface_pool_unittests.cc.

187 {
188 auto pool = std::make_unique<SurfacePool>();
189 auto jni_mock = std::make_shared<JNIMock>();
190
191 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(0);
192 pool->DestroyLayers(jni_mock);
193
194 auto gr_context = GrDirectContext::MakeMock(nullptr);
195 auto android_context =
196 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
197
198 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
199 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
200 .Times(1)
201 .WillOnce(Return(
202 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
203 0, window))));
204
205 auto surface_factory =
206 std::make_shared<TestAndroidSurfaceFactory>([gr_context, window]() {
207 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
208 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()));
209 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
210 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
211 return android_surface_mock;
212 });
213 pool->GetLayer(gr_context.get(), *android_context, jni_mock, surface_factory);
214
215 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces());
216
217 ASSERT_TRUE(pool->HasLayers());
218 pool->DestroyLayers(jni_mock);
219
220 ASSERT_FALSE(pool->HasLayers());
221 ASSERT_TRUE(pool->GetUnusedLayers().empty());
222}
AutoreleasePool pool

◆ TEST() [665/709]

flutter::testing::TEST ( SurfacePool  ,
DestroyLayersFrameSizeChanged   
)

Definition at line 224 of file surface_pool_unittests.cc.

224 {
225 auto pool = std::make_unique<SurfacePool>();
226 auto jni_mock = std::make_shared<JNIMock>();
227
228 auto gr_context = GrDirectContext::MakeMock(nullptr);
229 auto android_context =
230 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
231
232 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
233
234 auto surface_factory =
235 std::make_shared<TestAndroidSurfaceFactory>([gr_context, window]() {
236 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
237 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()));
238 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
239 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
240 return android_surface_mock;
241 });
242 pool->SetFrameSize(SkISize::Make(10, 10));
243 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(0);
244 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
245 .Times(1)
246 .WillOnce(Return(
247 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
248 0, window))));
249
250 ASSERT_FALSE(pool->HasLayers());
251
252 pool->GetLayer(gr_context.get(), *android_context, jni_mock, surface_factory);
253
254 ASSERT_TRUE(pool->HasLayers());
255
256 pool->SetFrameSize(SkISize::Make(20, 20));
257 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(1);
258 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
259 .Times(1)
260 .WillOnce(Return(
261 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
262 1, window))));
263 pool->GetLayer(gr_context.get(), *android_context, jni_mock, surface_factory);
264
265 ASSERT_TRUE(pool->GetUnusedLayers().empty());
266 ASSERT_TRUE(pool->HasLayers());
267}

◆ TEST() [666/709]

flutter::testing::TEST ( SurfacePool  ,
GetLayerAllocateOneLayer   
)

Definition at line 39 of file surface_pool_unittests.cc.

39 {
40 auto pool = std::make_unique<SurfacePool>();
41
42 auto gr_context = GrDirectContext::MakeMock(nullptr);
43 auto android_context =
44 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
45
46 auto jni_mock = std::make_shared<JNIMock>();
47 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
48 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
49 .WillOnce(Return(
50 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
51 0, window))));
52
53 auto surface_factory =
54 std::make_shared<TestAndroidSurfaceFactory>([gr_context, window]() {
55 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
56 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()));
57 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
58 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
59 return android_surface_mock;
60 });
61 auto layer = pool->GetLayer(gr_context.get(), *android_context, jni_mock,
62 surface_factory);
63
64 ASSERT_TRUE(pool->HasLayers());
65 ASSERT_NE(nullptr, layer);
66 ASSERT_EQ(reinterpret_cast<intptr_t>(gr_context.get()),
67 layer->gr_context_key);
68}

◆ TEST() [667/709]

flutter::testing::TEST ( SurfacePool  ,
GetLayerAllocateTwoLayers   
)

Definition at line 148 of file surface_pool_unittests.cc.

148 {
149 auto pool = std::make_unique<SurfacePool>();
150
151 auto gr_context = GrDirectContext::MakeMock(nullptr);
152 auto android_context =
153 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
154
155 auto jni_mock = std::make_shared<JNIMock>();
156 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
157 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
158 .Times(2)
159 .WillOnce(Return(
160 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
161 0, window))))
162 .WillOnce(Return(
163 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
164 1, window))));
165
166 auto surface_factory =
167 std::make_shared<TestAndroidSurfaceFactory>([gr_context, window]() {
168 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
169 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()));
170 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
171 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
172 return android_surface_mock;
173 });
174 auto layer_1 = pool->GetLayer(gr_context.get(), *android_context, jni_mock,
175 surface_factory);
176 auto layer_2 = pool->GetLayer(gr_context.get(), *android_context, jni_mock,
177 surface_factory);
178
179 ASSERT_TRUE(pool->HasLayers());
180 ASSERT_NE(nullptr, layer_1);
181 ASSERT_NE(nullptr, layer_2);
182 ASSERT_NE(layer_1, layer_2);
183 ASSERT_EQ(0, layer_1->id);
184 ASSERT_EQ(1, layer_2->id);
185}

◆ TEST() [668/709]

flutter::testing::TEST ( SurfacePool  ,
GetLayerRecycle   
)

Definition at line 103 of file surface_pool_unittests.cc.

103 {
104 auto pool = std::make_unique<SurfacePool>();
105
106 auto gr_context_1 = GrDirectContext::MakeMock(nullptr);
107 auto jni_mock = std::make_shared<JNIMock>();
108 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
109 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
110 .WillOnce(Return(
111 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
112 0, window))));
113
114 auto android_context =
115 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
116
117 auto gr_context_2 = GrDirectContext::MakeMock(nullptr);
118 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
119 [gr_context_1, gr_context_2, window]() {
120 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
121 // Allocate two GPU surfaces for each gr context.
122 EXPECT_CALL(*android_surface_mock,
123 CreateGPUSurface(gr_context_1.get()));
124 EXPECT_CALL(*android_surface_mock,
125 CreateGPUSurface(gr_context_2.get()));
126 // Set the native window once.
127 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
128 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
129 return android_surface_mock;
130 });
131 auto layer_1 = pool->GetLayer(gr_context_1.get(), *android_context, jni_mock,
132 surface_factory);
133
134 pool->RecycleLayers();
135
136 auto layer_2 = pool->GetLayer(gr_context_2.get(), *android_context, jni_mock,
137 surface_factory);
138
139 ASSERT_TRUE(pool->HasLayers());
140 ASSERT_NE(nullptr, layer_1);
141 ASSERT_EQ(layer_1, layer_2);
142 ASSERT_EQ(reinterpret_cast<intptr_t>(gr_context_2.get()),
143 layer_1->gr_context_key);
144 ASSERT_EQ(reinterpret_cast<intptr_t>(gr_context_2.get()),
145 layer_2->gr_context_key);
146}

◆ TEST() [669/709]

flutter::testing::TEST ( SurfacePool  ,
GetUnusedLayers   
)

Definition at line 70 of file surface_pool_unittests.cc.

70 {
71 auto pool = std::make_unique<SurfacePool>();
72
73 auto gr_context = GrDirectContext::MakeMock(nullptr);
74 auto android_context =
75 std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
76
77 auto jni_mock = std::make_shared<JNIMock>();
78 auto window = fml::MakeRefCounted<AndroidNativeWindow>(nullptr);
79 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
80 .WillOnce(Return(
81 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
82 0, window))));
83
84 auto surface_factory =
85 std::make_shared<TestAndroidSurfaceFactory>([gr_context, window]() {
86 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
87 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()));
88 EXPECT_CALL(*android_surface_mock, SetNativeWindow(window));
89 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true));
90 return android_surface_mock;
91 });
92 auto layer = pool->GetLayer(gr_context.get(), *android_context, jni_mock,
93 surface_factory);
94 ASSERT_EQ(0UL, pool->GetUnusedLayers().size());
95
96 pool->RecycleLayers();
97
98 ASSERT_TRUE(pool->HasLayers());
99 ASSERT_EQ(1UL, pool->GetUnusedLayers().size());
100 ASSERT_EQ(layer, pool->GetUnusedLayers()[0]);
101}

◆ TEST() [670/709]

flutter::testing::TEST ( SwitchesTest  ,
EnableAsserts   
)

Definition at line 127 of file switches_unittests.cc.

127 {
129 {"command", "--dart-flags=--enable-asserts"});
130 Settings settings = SettingsFromCommandLine(command_line);
131 ASSERT_EQ(settings.dart_flags.size(), 1ul);
132 EXPECT_EQ(settings.dart_flags[0], "--enable-asserts");
133}
Settings SettingsFromCommandLine(const fml::CommandLine &command_line)
Definition switches.cc:228
CommandLine CommandLineFromInitializerList(std::initializer_list< StringType > argv)

◆ TEST() [671/709]

flutter::testing::TEST ( SwitchesTest  ,
EnableEmbedderAPI   
)

Definition at line 90 of file switches_unittests.cc.

90 {
91 {
92 // enable
94 {"command", "--enable-embedder-api"});
95 Settings settings = SettingsFromCommandLine(command_line);
96 EXPECT_EQ(settings.enable_embedder_api, true);
97 }
98 {
99 // default
100 fml::CommandLine command_line =
102 Settings settings = SettingsFromCommandLine(command_line);
103 EXPECT_EQ(settings.enable_embedder_api, false);
104 }
105}

◆ TEST() [672/709]

flutter::testing::TEST ( SwitchesTest  ,
MsaaSamples   
)

Definition at line 72 of file switches_unittests.cc.

72 {
73 for (int samples : {0, 1, 2, 4, 8, 16}) {
75 {"command", ("--msaa-samples=" + std::to_string(samples)).c_str()});
76 Settings settings = SettingsFromCommandLine(command_line);
77 EXPECT_EQ(settings.msaa_samples, samples);
78 }
79 fml::CommandLine command_line =
80 fml::CommandLineFromInitializerList({"command", "--msaa-samples=3"});
81 Settings settings = SettingsFromCommandLine(command_line);
82 EXPECT_EQ(settings.msaa_samples, 0);
83
84 command_line =
85 fml::CommandLineFromInitializerList({"command", "--msaa-samples=foobar"});
86 settings = SettingsFromCommandLine(command_line);
87 EXPECT_EQ(settings.msaa_samples, 0);
88}

◆ TEST() [673/709]

flutter::testing::TEST ( SwitchesTest  ,
NoEnableImpeller   
)

Definition at line 107 of file switches_unittests.cc.

107 {
108 {
109 // enable
110 fml::CommandLine command_line =
111 fml::CommandLineFromInitializerList({"command", "--enable-impeller"});
112 EXPECT_TRUE(command_line.HasOption("enable-impeller"));
113 Settings settings = SettingsFromCommandLine(command_line);
114 EXPECT_EQ(settings.enable_impeller, true);
115 }
116 {
117 // disable
119 {"command", "--enable-impeller=false"});
120 EXPECT_TRUE(command_line.HasOption("enable-impeller"));
121 Settings settings = SettingsFromCommandLine(command_line);
122 EXPECT_EQ(settings.enable_impeller, false);
123 }
124}
bool HasOption(std::string_view name, size_t *index=nullptr) const

◆ TEST() [674/709]

flutter::testing::TEST ( SwitchesTest  ,
RouteParsedFlag   
)

Definition at line 62 of file switches_unittests.cc.

62 {
63 fml::CommandLine command_line =
64 fml::CommandLineFromInitializerList({"command", "--route=/animation"});
65 Settings settings = SettingsFromCommandLine(command_line);
66 EXPECT_EQ(settings.route, "/animation");
67 command_line = fml::CommandLineFromInitializerList({"command", "--route"});
68 settings = SettingsFromCommandLine(command_line);
69 EXPECT_TRUE(settings.route.empty());
70}

◆ TEST() [675/709]

flutter::testing::TEST ( SwitchesTest  ,
SkiaTraceAllowlistFlag   
)

Definition at line 19 of file switches_unittests.cc.

19 {
20 fml::CommandLine command_line =
22 Settings settings = SettingsFromCommandLine(command_line);
23#if !FLUTTER_RELEASE
24 EXPECT_TRUE(settings.trace_skia);
25 EXPECT_TRUE(settings.trace_skia_allowlist.has_value());
26 EXPECT_EQ(settings.trace_skia_allowlist->size(), 1ul);
27#else
28 EXPECT_FALSE(settings.trace_skia);
29#endif
30
31 command_line =
32 fml::CommandLineFromInitializerList({"command", "--trace-skia"});
33 settings = SettingsFromCommandLine(command_line);
34#if !FLUTTER_RELEASE
35 EXPECT_TRUE(settings.trace_skia);
36 EXPECT_FALSE(settings.trace_skia_allowlist.has_value());
37#else
38 EXPECT_FALSE(settings.trace_skia);
39#endif
40
42 {"command", "--trace-skia-allowlist=aaa,bbb,ccc"});
43 settings = SettingsFromCommandLine(command_line);
44#if !FLUTTER_RELEASE
45 EXPECT_TRUE(settings.trace_skia);
46 EXPECT_TRUE(settings.trace_skia_allowlist.has_value());
47 EXPECT_EQ(settings.trace_skia_allowlist->size(), 3ul);
48 EXPECT_EQ(settings.trace_skia_allowlist->back(), "ccc");
49#else
50 EXPECT_FALSE(settings.trace_skia);
51#endif
52}

◆ TEST() [676/709]

flutter::testing::TEST ( SwitchesTest  ,
TraceToFile   
)

Definition at line 54 of file switches_unittests.cc.

54 {
56 {"command", "--trace-to-file=trace.binpb"});
57 EXPECT_TRUE(command_line.HasOption("trace-to-file"));
58 Settings settings = SettingsFromCommandLine(command_line);
59 EXPECT_EQ(settings.trace_to_file, "trace.binpb");
60}

◆ TEST() [677/709]

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

Definition at line 16 of file system_utils_unittests.cc.

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

◆ TEST() [678/709]

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

Definition at line 26 of file system_utils_unittests.cc.

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

◆ TEST() [679/709]

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

Definition at line 96 of file system_utils_unittests.cc.

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

◆ TEST() [680/709]

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

Definition at line 53 of file system_utils_unittests.cc.

53 {
55 EXPECT_EQ(info.language, "en");
56 EXPECT_TRUE(info.region.empty());
57 EXPECT_TRUE(info.script.empty());
58}
LanguageInfo ParseLanguageName(std::wstring language_name)

◆ TEST() [681/709]

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

Definition at line 60 of file system_utils_unittests.cc.

60 {
62 EXPECT_EQ(info.language, "hu");
63 EXPECT_EQ(info.region, "HU");
64 EXPECT_TRUE(info.script.empty());
65}

◆ TEST() [682/709]

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

Definition at line 74 of file system_utils_unittests.cc.

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

◆ TEST() [683/709]

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

Definition at line 67 of file system_utils_unittests.cc.

67 {
69 EXPECT_EQ(info.language, "us");
70 EXPECT_TRUE(info.region.empty());
71 EXPECT_EQ(info.script, "Latn");
72}

◆ TEST() [684/709]

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

Definition at line 81 of file system_utils_unittests.cc.

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

◆ TEST() [685/709]

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

Definition at line 89 of file system_utils_unittests.cc.

89 {
91 EXPECT_EQ(info.language, "ale");
92 EXPECT_EQ(info.region, "ZZ");
93 EXPECT_TRUE(info.script.empty());
94}

◆ TEST() [686/709]

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

Definition at line 105 of file system_utils_unittests.cc.

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

◆ TEST() [687/709]

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

Definition at line 109 of file system_utils_unittests.cc.

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

◆ TEST() [688/709]

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

Definition at line 101 of file system_utils_unittests.cc.

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

◆ TEST() [689/709]

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

Definition at line 68 of file task_runner_unittests.cc.

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

◆ TEST() [690/709]

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

Definition at line 45 of file task_runner_unittests.cc.

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

◆ TEST() [691/709]

flutter::testing::TEST ( TestKeyboard  ,
CloneString   
)

Definition at line 13 of file test_keyboard_unittests.cc.

13 {
14 const char* str1 = "123";
15 char* cloned_str1 = clone_string(str1);
16 EXPECT_STREQ(str1, cloned_str1);
17 EXPECT_NE(str1, cloned_str1);
18 delete[] cloned_str1;
19
20 EXPECT_EQ(clone_string(nullptr), nullptr);
21};
char * clone_string(const char *string)

◆ TEST() [692/709]

flutter::testing::TEST ( TestKeyboard  ,
CreateKeyEventLparam   
)

Definition at line 23 of file test_keyboard_unittests.cc.

23 {
24 EXPECT_EQ(CreateKeyEventLparam(0x1, true, true), 0xC1010001);
25
26 EXPECT_EQ(CreateKeyEventLparam(0x05, false, false, 0, 1, 0), 0x20050000);
27};

◆ TEST() [693/709]

flutter::testing::TEST ( TextureRegistryTest  ,
CallsOnGrContextCreatedInInsertionOrder   
)

Definition at line 122 of file texture_unittests.cc.

122 {
123 TextureRegistry registry;
124 std::vector<int> create_order;
125 std::vector<int> destroy_order;
126 auto create = [&](int id) { create_order.push_back(id); };
127 auto destroy = [&](int id) { destroy_order.push_back(id); };
128 auto a = std::make_shared<TestContextListener>(5, create, destroy);
129 auto b = std::make_shared<TestContextListener>(4, create, destroy);
130 auto c = std::make_shared<TestContextListener>(3, create, destroy);
131 registry.RegisterContextListener(a->id, a);
132 registry.RegisterContextListener(b->id, b);
133 registry.RegisterContextListener(c->id, c);
134 registry.OnGrContextDestroyed();
135 registry.OnGrContextCreated();
136
137 EXPECT_THAT(create_order, ::testing::ElementsAre(5, 4, 3));
138 EXPECT_THAT(destroy_order, ::testing::ElementsAre(5, 4, 3));
139}
void RegisterContextListener(uintptr_t id, std::weak_ptr< ContextListener > image)
Definition texture.cc:26
int_closure destroy

◆ TEST() [694/709]

flutter::testing::TEST ( TextureRegistryTest  ,
GrContextCallbackTriggered   
)

Definition at line 60 of file texture_unittests.cc.

60 {
61 TextureRegistry registry;
62 auto mock_texture1 = std::make_shared<MockTexture>(0);
63 auto mock_texture2 = std::make_shared<MockTexture>(1);
64
65 registry.RegisterTexture(mock_texture1);
66 registry.RegisterTexture(mock_texture2);
67 ASSERT_FALSE(mock_texture1->gr_context_created());
68 ASSERT_FALSE(mock_texture2->gr_context_created());
69 ASSERT_FALSE(mock_texture1->gr_context_destroyed());
70 ASSERT_FALSE(mock_texture2->gr_context_destroyed());
71
72 registry.OnGrContextCreated();
73 ASSERT_TRUE(mock_texture1->gr_context_created());
74 ASSERT_TRUE(mock_texture2->gr_context_created());
75
76 registry.UnregisterTexture(0);
77 registry.OnGrContextDestroyed();
78 ASSERT_FALSE(mock_texture1->gr_context_destroyed());
79 ASSERT_TRUE(mock_texture2->gr_context_created());
80}
void RegisterTexture(const std::shared_ptr< Texture > &texture)
Definition texture.cc:19
void UnregisterTexture(int64_t id)
Definition texture.cc:38

◆ TEST() [695/709]

flutter::testing::TEST ( TextureRegistryTest  ,
RegisterTextureTwice   
)

Definition at line 82 of file texture_unittests.cc.

82 {
83 TextureRegistry registry;
84 auto mock_texture1 = std::make_shared<MockTexture>(0);
85 auto mock_texture2 = std::make_shared<MockTexture>(0);
86
87 registry.RegisterTexture(mock_texture1);
88 ASSERT_EQ(registry.GetTexture(0), mock_texture1);
89 registry.RegisterTexture(mock_texture2);
90 ASSERT_EQ(registry.GetTexture(0), mock_texture2);
91 ASSERT_FALSE(mock_texture1->unregistered());
92 ASSERT_FALSE(mock_texture2->unregistered());
93
94 registry.UnregisterTexture(0);
95 ASSERT_EQ(registry.GetTexture(0), nullptr);
96 ASSERT_FALSE(mock_texture1->unregistered());
97 ASSERT_TRUE(mock_texture2->unregistered());
98}
std::shared_ptr< Texture > GetTexture(int64_t id)
Definition texture.cc:93

◆ TEST() [696/709]

flutter::testing::TEST ( TextureRegistryTest  ,
ReuseSameTextureSlot   
)

Definition at line 100 of file texture_unittests.cc.

100 {
101 TextureRegistry registry;
102 auto mock_texture1 = std::make_shared<MockTexture>(0);
103 auto mock_texture2 = std::make_shared<MockTexture>(0);
104
105 registry.RegisterTexture(mock_texture1);
106 ASSERT_EQ(registry.GetTexture(0), mock_texture1);
107
108 registry.UnregisterTexture(0);
109 ASSERT_EQ(registry.GetTexture(0), nullptr);
110 ASSERT_TRUE(mock_texture1->unregistered());
111 ASSERT_FALSE(mock_texture2->unregistered());
112
113 registry.RegisterTexture(mock_texture2);
114 ASSERT_EQ(registry.GetTexture(0), mock_texture2);
115
116 registry.UnregisterTexture(0);
117 ASSERT_EQ(registry.GetTexture(0), nullptr);
118 ASSERT_TRUE(mock_texture1->unregistered());
119 ASSERT_TRUE(mock_texture2->unregistered());
120}

◆ TEST() [697/709]

flutter::testing::TEST ( TextureRegistryTest  ,
UnregisterTextureCallbackTriggered   
)

Definition at line 37 of file texture_unittests.cc.

37 {
38 TextureRegistry registry;
39 auto mock_texture1 = std::make_shared<MockTexture>(0);
40 auto mock_texture2 = std::make_shared<MockTexture>(1);
41
42 registry.RegisterTexture(mock_texture1);
43 registry.RegisterTexture(mock_texture2);
44 ASSERT_EQ(registry.GetTexture(0), mock_texture1);
45 ASSERT_EQ(registry.GetTexture(1), mock_texture2);
46 ASSERT_FALSE(mock_texture1->unregistered());
47 ASSERT_FALSE(mock_texture2->unregistered());
48
49 registry.UnregisterTexture(0);
50 ASSERT_EQ(registry.GetTexture(0), nullptr);
51 ASSERT_TRUE(mock_texture1->unregistered());
52 ASSERT_FALSE(mock_texture2->unregistered());
53
54 registry.UnregisterTexture(1);
55 ASSERT_EQ(registry.GetTexture(1), nullptr);
56 ASSERT_TRUE(mock_texture1->unregistered());
57 ASSERT_TRUE(mock_texture2->unregistered());
58}

◆ TEST() [698/709]

flutter::testing::TEST ( VariableRefreshRateDisplayTest  ,
Report0IfReporterSharedPointerIsDestroyedAfterDisplayCreation   
)

Definition at line 30 of file variable_refresh_rate_display_unittests.cc.

31 {
32 auto refresh_rate_reporter = std::make_shared<TestRefreshRateReporter>(60);
34 0, std::weak_ptr<TestRefreshRateReporter>(refresh_rate_reporter), 600,
35 800, 60);
36 refresh_rate_reporter.reset();
37 ASSERT_EQ(display.GetRefreshRate(), 0);
38}
A Display where the refresh rate can change over time.

◆ TEST() [699/709]

flutter::testing::TEST ( VariableRefreshRateDisplayTest  ,
Report0IfReporterSharedPointerIsDestroyedBeforeDisplayCreation   
)

Definition at line 40 of file variable_refresh_rate_display_unittests.cc.

41 {
42 auto refresh_rate_reporter = std::make_shared<TestRefreshRateReporter>(60);
43 refresh_rate_reporter.reset();
45 0, std::weak_ptr<TestRefreshRateReporter>(refresh_rate_reporter), 600,
46 800, 60);
47 ASSERT_EQ(display.GetRefreshRate(), 0);
48}

◆ TEST() [700/709]

flutter::testing::TEST ( VariableRefreshRateDisplayTest  ,
ReportCorrectInitialRefreshRate   
)

Definition at line 13 of file variable_refresh_rate_display_unittests.cc.

13 {
14 auto refresh_rate_reporter = std::make_shared<TestRefreshRateReporter>(60);
16 0, std::weak_ptr<TestRefreshRateReporter>(refresh_rate_reporter), 600,
17 800, 60);
18 ASSERT_EQ(display.GetRefreshRate(), 60);
19}

◆ TEST() [701/709]

flutter::testing::TEST ( VariableRefreshRateDisplayTest  ,
ReportCorrectRefreshRateWhenUpdated   
)

Definition at line 21 of file variable_refresh_rate_display_unittests.cc.

21 {
22 auto refresh_rate_reporter = std::make_shared<TestRefreshRateReporter>(60);
24 0, std::weak_ptr<TestRefreshRateReporter>(refresh_rate_reporter), 600,
25 800, 60);
26 refresh_rate_reporter->UpdateRefreshRate(30);
27 ASSERT_EQ(display.GetRefreshRate(), 30);
28}

◆ TEST() [702/709]

flutter::testing::TEST ( VsyncWaiterTest  ,
NoUnneededAwaitVsync   
)

Definition at line 27 of file vsync_waiter_unittests.cc.

27 {
29 std::string prefix = "vsync_waiter_test";
30
32 auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
33
34 const flutter::TaskRunners task_runners(prefix, task_runner, task_runner,
35 task_runner, task_runner);
36
37 TestVsyncWaiter vsync_waiter(task_runners);
38
39 vsync_waiter.ScheduleSecondaryCallback(1, [] {});
40 EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
41
42 vsync_waiter.ScheduleSecondaryCallback(2, [] {});
43 EXPECT_EQ(vsync_waiter.await_vsync_call_count_, 1);
44}
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const

◆ TEST() [703/709]

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

Definition at line 54 of file window_proc_delegate_manager_unittests.cc.

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

◆ TEST() [704/709]

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

Definition at line 163 of file window_proc_delegate_manager_unittests.cc.

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

◆ TEST() [705/709]

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

Definition at line 128 of file window_proc_delegate_manager_unittests.cc.

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

◆ TEST() [706/709]

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

Definition at line 102 of file window_proc_delegate_manager_unittests.cc.

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

◆ TEST() [707/709]

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

Definition at line 76 of file window_proc_delegate_manager_unittests.cc.

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

◆ TEST() [708/709]

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

Definition at line 192 of file window_proc_delegate_manager_unittests.cc.

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

◆ TEST() [709/709]

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

Definition at line 64 of file flutter_windows_unittests.cc.

64 {
65 FlutterDesktopEngineProperties properties = {};
66 properties.assets_path = L"";
67 properties.icu_data_path = L"icudtl.dat";
68 auto engine = FlutterDesktopEngineCreate(&properties);
69 ASSERT_NE(engine, nullptr);
71 EXPECT_NE(texture_registrar, nullptr);
73}
G_BEGIN_DECLS FlTextureRegistrar * texture_registrar
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
bool FlutterDesktopEngineDestroy(FlutterDesktopEngineRef engine_ref)
FlutterDesktopTextureRegistrarRef FlutterDesktopEngineGetTextureRegistrar(FlutterDesktopEngineRef engine)

◆ TEST_F() [1/876]

flutter::testing::TEST_F ( AccessibilityBridgeMacTest  ,
DoesNotSendAccessibilityCreateNotificationWhenHeadless   
)

Definition at line 213 of file AccessibilityBridgeMacTest.mm.

213 {
214 FlutterViewController* viewController = CreateTestViewController();
216
217 // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
218 // can query semantics information from.
220 auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
223 root.id = 0;
224 root.flags = static_cast<FlutterSemanticsFlag>(0);
225 root.actions = static_cast<FlutterSemanticsAction>(0);
226 root.text_selection_base = -1;
227 root.text_selection_extent = -1;
228 root.label = "root";
229 root.hint = "";
230 root.value = "";
231 root.increased_value = "";
232 root.decreased_value = "";
233 root.tooltip = "";
234 root.child_count = 0;
235 root.custom_accessibility_actions_count = 0;
236 bridge->AddFlutterSemanticsNodeUpdate(root);
237
238 bridge->CommitUpdates();
239 auto platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
240
241 // Creates a targeted event.
242 ui::AXTree tree;
243 ui::AXNode ax_node(&tree, nullptr, 0, 0);
244 ui::AXNodeData node_data;
245 node_data.id = 0;
246 ax_node.SetData(node_data);
247 std::vector<ui::AXEventIntent> intent;
248 ui::AXEventGenerator::EventParams event_params(ui::AXEventGenerator::Event::CHILDREN_CHANGED,
250 ui::AXEventGenerator::TargetedEvent targeted_event(&ax_node, event_params);
251
252 bridge->OnAccessibilityEvent(targeted_event);
253
254 // Does not send any notification if the engine is headless.
255 EXPECT_EQ(bridge->actual_notifications.size(), 0u);
256 [engine shutDownEngine];
257}

◆ TEST_F() [2/876]

flutter::testing::TEST_F ( AccessibilityBridgeMacTest  ,
DoesNotSendAccessibilityCreateNotificationWhenNoWindow   
)

Definition at line 259 of file AccessibilityBridgeMacTest.mm.

259 {
260 FlutterViewController* viewController = CreateTestViewController();
262
263 // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
264 // can query semantics information from.
266 auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
269 root.id = 0;
270 root.flags = static_cast<FlutterSemanticsFlag>(0);
271 root.actions = static_cast<FlutterSemanticsAction>(0);
272 root.text_selection_base = -1;
273 root.text_selection_extent = -1;
274 root.label = "root";
275 root.hint = "";
276 root.value = "";
277 root.increased_value = "";
278 root.decreased_value = "";
279 root.tooltip = "";
280 root.child_count = 0;
281 root.custom_accessibility_actions_count = 0;
282 bridge->AddFlutterSemanticsNodeUpdate(root);
283
284 bridge->CommitUpdates();
285 auto platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
286
287 // Creates a targeted event.
288 ui::AXTree tree;
289 ui::AXNode ax_node(&tree, nullptr, 0, 0);
290 ui::AXNodeData node_data;
291 node_data.id = 0;
292 ax_node.SetData(node_data);
293 std::vector<ui::AXEventIntent> intent;
294 ui::AXEventGenerator::EventParams event_params(ui::AXEventGenerator::Event::CHILDREN_CHANGED,
296 ui::AXEventGenerator::TargetedEvent targeted_event(&ax_node, event_params);
297
298 bridge->OnAccessibilityEvent(targeted_event);
299
300 // Does not send any notification if the flutter view is not attached to a NSWindow.
301 EXPECT_EQ(bridge->actual_notifications.size(), 0u);
302 [engine shutDownEngine];
303}

◆ TEST_F() [3/876]

flutter::testing::TEST_F ( AccessibilityBridgeMacWindowTest  ,
NonZeroRootNodeId   
)

Definition at line 147 of file AccessibilityBridgeMacTest.mm.

147 {
148 FlutterViewController* viewController = CreateTestViewController();
150 NSWindow* expectedTarget = GetWindow();
151 expectedTarget.contentView = viewController.view;
152
153 // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
154 // can query semantics information from.
156 auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
158
160 std::vector<int32_t> node1_children{2};
161 node1.id = 1;
162 node1.flags = static_cast<FlutterSemanticsFlag>(0);
163 node1.actions = static_cast<FlutterSemanticsAction>(0);
164 node1.text_selection_base = -1;
165 node1.text_selection_extent = -1;
166 node1.label = "node1";
167 node1.hint = "";
168 node1.value = "";
169 node1.increased_value = "";
170 node1.decreased_value = "";
171 node1.tooltip = "";
172 node1.child_count = node1_children.size();
173 node1.children_in_traversal_order = node1_children.data();
174 node1.children_in_hit_test_order = node1_children.data();
176
178 node2.id = 2;
179 node2.flags = static_cast<FlutterSemanticsFlag>(0);
180 node2.actions = static_cast<FlutterSemanticsAction>(0);
181 node2.text_selection_base = -1;
182 node2.text_selection_extent = -1;
183 node2.label = "node2";
184 node2.hint = "";
185 node2.value = "";
186 node2.increased_value = "";
187 node2.decreased_value = "";
188 node2.tooltip = "";
189 node2.child_count = 0;
191
192 bridge->AddFlutterSemanticsNodeUpdate(node1);
193 bridge->AddFlutterSemanticsNodeUpdate(node2);
194 bridge->CommitUpdates();
195
196 // Look up the root node delegate.
197 auto root_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
198 ASSERT_TRUE(root_delegate);
199 ASSERT_EQ(root_delegate->GetChildCount(), 1);
200
201 // Look up the child node delegate.
202 auto child_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(2).lock();
203 ASSERT_TRUE(child_delegate);
204 ASSERT_EQ(child_delegate->GetChildCount(), 0);
205
206 // Ensure a node with ID 0 does not exist.
207 auto invalid_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
208 ASSERT_FALSE(invalid_delegate);
209
210 [engine shutDownEngine];
211}
const int32_t * children_in_hit_test_order
Array of child node IDs in hit test order. Has length child_count.
Definition embedder.h:1385

◆ TEST_F() [4/876]

flutter::testing::TEST_F ( AccessibilityBridgeMacWindowTest  ,
SendsAccessibilityCreateNotificationFlutterViewWindow   
)

Definition at line 90 of file AccessibilityBridgeMacTest.mm.

90 {
91 FlutterViewController* viewController = CreateTestViewController();
93 NSWindow* expectedTarget = GetWindow();
94 expectedTarget.contentView = viewController.view;
95
96 // Setting up bridge so that the AccessibilityBridgeMacDelegateSpy
97 // can query semantics information from.
99 auto bridge = std::static_pointer_cast<AccessibilityBridgeMacSpy>(
102 root.id = 0;
103 root.flags = static_cast<FlutterSemanticsFlag>(0);
104 root.actions = static_cast<FlutterSemanticsAction>(0);
105 root.text_selection_base = -1;
106 root.text_selection_extent = -1;
107 root.label = "root";
108 root.hint = "";
109 root.value = "";
110 root.increased_value = "";
111 root.decreased_value = "";
112 root.tooltip = "";
113 root.child_count = 0;
114 root.custom_accessibility_actions_count = 0;
115 bridge->AddFlutterSemanticsNodeUpdate(root);
116
117 bridge->CommitUpdates();
118 auto platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
119
120 // Creates a targeted event.
121 ui::AXTree tree;
122 ui::AXNode ax_node(&tree, nullptr, 0, 0);
123 ui::AXNodeData node_data;
124 node_data.id = 0;
125 ax_node.SetData(node_data);
126 std::vector<ui::AXEventIntent> intent;
127 ui::AXEventGenerator::EventParams event_params(ui::AXEventGenerator::Event::CHILDREN_CHANGED,
129 ui::AXEventGenerator::TargetedEvent targeted_event(&ax_node, event_params);
130
131 bridge->OnAccessibilityEvent(targeted_event);
132
133 ASSERT_EQ(bridge->actual_notifications.size(), 1u);
134 auto target = bridge->actual_notifications.find([NSAccessibilityCreatedNotification UTF8String]);
135 ASSERT_NE(target, bridge->actual_notifications.end());
136 EXPECT_EQ(target->second, expectedTarget);
137 [engine shutDownEngine];
138}
uint32_t * target

◆ TEST_F() [5/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
EmptyFilter   
)

Definition at line 53 of file backdrop_filter_layer_unittests.cc.

53 {
54 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
55 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
56 const SkPath child_path = SkPath().addRect(child_bounds);
57 const DlPaint child_paint = DlPaint(DlColor::kYellow());
58 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
59 auto layer =
60 std::make_shared<BackdropFilterLayer>(nullptr, DlBlendMode::kSrcOver);
61 layer->Add(mock_layer);
62 auto parent = std::make_shared<ClipRectLayer>(child_bounds, Clip::kHardEdge);
63 parent->Add(layer);
64
65 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
66 parent->Preroll(preroll_context());
67 EXPECT_EQ(layer->paint_bounds(), child_bounds);
68 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
69 EXPECT_TRUE(layer->needs_painting(paint_context()));
70 EXPECT_EQ(mock_layer->parent_matrix(), initial_transform);
71
72 parent->Paint(display_list_paint_context());
73 DisplayListBuilder expected_builder;
74 /* (ClipRect)parent::Paint */ {
75 expected_builder.Save();
76 {
77 expected_builder.ClipRect(child_bounds, DlCanvas::ClipOp::kIntersect,
78 false);
79 /* (BackdropFilter)layer::Paint */ {
80 expected_builder.Save();
81 {
82 expected_builder.SaveLayer(&child_bounds, nullptr, nullptr);
83 {
84 /* mock_layer::Paint */ {
85 expected_builder.DrawPath(child_path, child_paint);
86 }
87 }
88 expected_builder.Restore();
89 }
90 expected_builder.Restore();
91 }
92 }
93 expected_builder.Restore();
94 }
95 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
96}
void SaveLayer(const SkRect *bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr) override
void ClipRect(const SkRect &rect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override

◆ TEST_F() [6/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
MultipleChildren   
)

Definition at line 198 of file backdrop_filter_layer_unittests.cc.

198 {
199 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
200 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 2.5f, 3.5f);
201 const SkPath child_path1 = SkPath().addRect(child_bounds);
202 const SkPath child_path2 =
203 SkPath().addRect(child_bounds.makeOffset(3.0f, 0.0f));
204 const DlPaint child_paint1 = DlPaint(DlColor::kYellow());
205 const DlPaint child_paint2 = DlPaint(DlColor::kCyan());
206 SkRect children_bounds = child_path1.getBounds();
207 children_bounds.join(child_path2.getBounds());
208 auto layer_filter =
209 std::make_shared<DlBlurImageFilter>(2.5, 3.2, DlTileMode::kClamp);
210 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
211 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
212 auto layer = std::make_shared<BackdropFilterLayer>(layer_filter,
213 DlBlendMode::kSrcOver);
214 layer->Add(mock_layer1);
215 layer->Add(mock_layer2);
216 auto parent =
217 std::make_shared<ClipRectLayer>(children_bounds, Clip::kHardEdge);
218 parent->Add(layer);
219
220 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
221 parent->Preroll(preroll_context());
222 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
223 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
224 EXPECT_EQ(layer->paint_bounds(), children_bounds);
225 EXPECT_EQ(layer->child_paint_bounds(), children_bounds);
226 EXPECT_TRUE(mock_layer1->needs_painting(paint_context()));
227 EXPECT_TRUE(mock_layer2->needs_painting(paint_context()));
228 EXPECT_TRUE(layer->needs_painting(paint_context()));
229 EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform);
230 EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform);
231
232 parent->Paint(display_list_paint_context());
233 DisplayListBuilder expected_builder;
234 /* (ClipRect)parent::Paint */ {
235 expected_builder.Save();
236 {
237 expected_builder.ClipRect(children_bounds, DlCanvas::ClipOp::kIntersect,
238 false);
239 /* (BackdropFilter)layer::Paint */ {
240 expected_builder.Save();
241 {
242 expected_builder.SaveLayer(&children_bounds, nullptr,
243 layer_filter.get());
244 {
245 /* mock_layer1::Paint */ {
246 expected_builder.DrawPath(child_path1, child_paint1);
247 }
248 /* mock_layer2::Paint */ {
249 expected_builder.DrawPath(child_path2, child_paint2);
250 }
251 }
252 expected_builder.Restore();
253 }
254 expected_builder.Restore();
255 }
256 }
257 expected_builder.Restore();
258 }
259 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
260}
void join(const SkRect &r)
Definition SkRect.cpp:126

◆ TEST_F() [7/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
Nested   
)

Definition at line 262 of file backdrop_filter_layer_unittests.cc.

262 {
263 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
264 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 2.5f, 3.5f);
265 const SkPath child_path1 = SkPath().addRect(child_bounds);
266 const SkPath child_path2 =
267 SkPath().addRect(child_bounds.makeOffset(3.0f, 0.0f));
268 const DlPaint child_paint1 = DlPaint(DlColor::kYellow());
269 const DlPaint child_paint2 = DlPaint(DlColor::kCyan());
270 SkRect children_bounds = child_path1.getBounds();
271 children_bounds.join(child_path2.getBounds());
272 auto layer_filter1 =
273 std::make_shared<DlBlurImageFilter>(2.5, 3.2, DlTileMode::kClamp);
274 auto layer_filter2 =
275 std::make_shared<DlBlurImageFilter>(2.7, 3.1, DlTileMode::kDecal);
276 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
277 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
278 auto layer1 = std::make_shared<BackdropFilterLayer>(layer_filter1,
279 DlBlendMode::kSrcOver);
280 auto layer2 = std::make_shared<BackdropFilterLayer>(layer_filter2,
281 DlBlendMode::kSrcOver);
282 layer2->Add(mock_layer2);
283 layer1->Add(mock_layer1);
284 layer1->Add(layer2);
285 auto parent =
286 std::make_shared<ClipRectLayer>(children_bounds, Clip::kHardEdge);
287 parent->Add(layer1);
288
289 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
290 parent->Preroll(preroll_context());
291
292 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
293 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
294 EXPECT_EQ(layer1->paint_bounds(), children_bounds);
295 EXPECT_EQ(layer2->paint_bounds(), children_bounds);
296 EXPECT_TRUE(mock_layer1->needs_painting(paint_context()));
297 EXPECT_TRUE(mock_layer2->needs_painting(paint_context()));
298 EXPECT_TRUE(layer1->needs_painting(paint_context()));
299 EXPECT_TRUE(layer2->needs_painting(paint_context()));
300 EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform);
301 EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform);
302
303 parent->Paint(display_list_paint_context());
304 DisplayListBuilder expected_builder;
305 /* (ClipRect)parent::Paint */ {
306 expected_builder.Save();
307 {
308 expected_builder.ClipRect(children_bounds, DlCanvas::ClipOp::kIntersect,
309 false);
310 /* (BackdropFilter)layer1::Paint */ {
311 expected_builder.Save();
312 {
313 expected_builder.SaveLayer(&children_bounds, nullptr,
314 layer_filter1.get());
315 {
316 /* mock_layer1::Paint */ {
317 expected_builder.DrawPath(child_path1, child_paint1);
318 }
319 /* (BackdropFilter)layer2::Paint */ {
320 expected_builder.Save();
321 {
322 expected_builder.SaveLayer(&children_bounds, nullptr,
323 layer_filter2.get());
324 {
325 /* mock_layer2::Paint */ {
326 expected_builder.DrawPath(child_path2, child_paint2);
327 }
328 }
329 expected_builder.Restore();
330 }
331 expected_builder.Restore();
332 }
333 }
334 expected_builder.Restore();
335 }
336 expected_builder.Restore();
337 }
338 }
339 expected_builder.Restore();
340 }
341 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
342}

◆ TEST_F() [8/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
NonSrcOverBlend   
)

Definition at line 146 of file backdrop_filter_layer_unittests.cc.

146 {
147 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
148 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
149 const SkPath child_path = SkPath().addRect(child_bounds);
150 const DlPaint child_paint = DlPaint(DlColor::kYellow());
151 auto layer_filter =
152 std::make_shared<DlBlurImageFilter>(2.5, 3.2, DlTileMode::kClamp);
153 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
154 auto layer =
155 std::make_shared<BackdropFilterLayer>(layer_filter, DlBlendMode::kSrc);
156 layer->Add(mock_layer);
157 auto parent = std::make_shared<ClipRectLayer>(child_bounds, Clip::kHardEdge);
158 parent->Add(layer);
159
160 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
161 parent->Preroll(preroll_context());
162 EXPECT_EQ(layer->paint_bounds(), child_bounds);
163 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
164 EXPECT_TRUE(layer->needs_painting(paint_context()));
165 EXPECT_EQ(mock_layer->parent_matrix(), initial_transform);
166
167 DlPaint filter_paint = DlPaint();
168 filter_paint.setBlendMode(DlBlendMode::kSrc);
169
170 parent->Paint(display_list_paint_context());
171 DisplayListBuilder expected_builder;
172 /* (ClipRect)parent::Paint */ {
173 expected_builder.Save();
174 {
175 expected_builder.ClipRect(child_bounds, DlCanvas::ClipOp::kIntersect,
176 false);
177 /* (BackdropFilter)layer::Paint */ {
178 expected_builder.Save();
179 {
180 DlPaint save_paint = DlPaint().setBlendMode(DlBlendMode::kSrc);
181 expected_builder.SaveLayer(&child_bounds, &save_paint,
182 layer_filter.get());
183 {
184 /* mock_layer::Paint */ {
185 expected_builder.DrawPath(child_path, child_paint);
186 }
187 }
188 expected_builder.Restore();
189 }
190 expected_builder.Restore();
191 }
192 }
193 expected_builder.Restore();
194 }
195 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
196}

◆ TEST_F() [9/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
OpacityInheritance   
)

Definition at line 378 of file backdrop_filter_layer_unittests.cc.

378 {
379 auto backdrop_filter = DlBlurImageFilter(5, 5, DlTileMode::kClamp);
380 const SkPath mock_path = SkPath().addRect(SkRect::MakeLTRB(0, 0, 10, 10));
381 const DlPaint mock_paint = DlPaint(DlColor::kRed());
382 const SkRect clip_rect = SkRect::MakeLTRB(0, 0, 100, 100);
383
384 auto clip = std::make_shared<ClipRectLayer>(clip_rect, Clip::kHardEdge);
385 auto parent = std::make_shared<OpacityLayer>(128, SkPoint::Make(0, 0));
386 auto layer = std::make_shared<BackdropFilterLayer>(backdrop_filter.shared(),
387 DlBlendMode::kSrcOver);
388 auto child = std::make_shared<MockLayer>(mock_path, mock_paint);
389 layer->Add(child);
390 parent->Add(layer);
391 clip->Add(parent);
392
393 clip->Preroll(preroll_context());
394
395 clip->Paint(display_list_paint_context());
396
397 DisplayListBuilder expected_builder(clip_rect);
398 /* ClipRectLayer::Paint */ {
399 expected_builder.Save();
400 {
401 expected_builder.ClipRect(clip_rect, DlCanvas::ClipOp::kIntersect, false);
402 /* OpacityLayer::Paint */ {
403 // NOP - it hands opacity down to BackdropFilterLayer
404 /* BackdropFilterLayer::Paint */ {
405 DlPaint save_paint;
406 save_paint.setAlpha(128);
407 expected_builder.SaveLayer(&clip_rect, &save_paint, &backdrop_filter);
408 {
409 /* MockLayer::Paint */ {
410 DlPaint child_paint;
411 child_paint.setColor(DlColor::kRed());
412 expected_builder.DrawPath(mock_path, child_paint);
413 }
414 }
415 expected_builder.Restore();
416 }
417 }
418 }
419 expected_builder.Restore();
420 }
421 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
422}

◆ TEST_F() [10/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
PaintBeforePrerollDies   
)

Definition at line 37 of file backdrop_filter_layer_unittests.cc.

37 {
38 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
39 const SkPath child_path = SkPath().addRect(child_bounds);
40 auto mock_layer = std::make_shared<MockLayer>(child_path);
41 auto filter = DlBlurImageFilter(5, 5, DlTileMode::kClamp);
42 auto layer = std::make_shared<BackdropFilterLayer>(filter.shared(),
43 DlBlendMode::kSrcOver);
44 layer->Add(mock_layer);
45
46 EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
47 EXPECT_EQ(layer->child_paint_bounds(), kEmptyRect);
48 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
49 "needs_painting\\(context\\)");
50}

◆ TEST_F() [11/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
PaintingEmptyLayerDies   
)

Definition at line 21 of file backdrop_filter_layer_unittests.cc.

21 {
22 auto filter = DlBlurImageFilter(5, 5, DlTileMode::kClamp);
23 auto layer = std::make_shared<BackdropFilterLayer>(filter.shared(),
24 DlBlendMode::kSrcOver);
25 auto parent = std::make_shared<ClipRectLayer>(kEmptyRect, Clip::kHardEdge);
26 parent->Add(layer);
27
28 parent->Preroll(preroll_context());
29 EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
30 EXPECT_EQ(layer->child_paint_bounds(), kEmptyRect);
31 EXPECT_FALSE(layer->needs_painting(paint_context()));
32
33 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
34 "needs_painting\\(context\\)");
35}

◆ TEST_F() [12/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
Readback   
)

Definition at line 344 of file backdrop_filter_layer_unittests.cc.

344 {
345 std::shared_ptr<DlImageFilter> no_filter;
346 auto layer_filter = DlBlurImageFilter(5, 5, DlTileMode::kClamp);
347 auto initial_transform = SkMatrix();
348
349 // BDF with filter always reads from surface
350 auto layer1 = std::make_shared<BackdropFilterLayer>(layer_filter.shared(),
351 DlBlendMode::kSrcOver);
352 preroll_context()->surface_needs_readback = false;
353 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
354 layer1->Preroll(preroll_context());
355 EXPECT_TRUE(preroll_context()->surface_needs_readback);
356
357 // BDF with no filter does not read from surface itself
358 auto layer2 =
359 std::make_shared<BackdropFilterLayer>(no_filter, DlBlendMode::kSrcOver);
360 preroll_context()->surface_needs_readback = false;
361 layer2->Preroll(preroll_context());
362 EXPECT_FALSE(preroll_context()->surface_needs_readback);
363
364 // BDF with no filter does not block prior readback value
365 preroll_context()->surface_needs_readback = true;
366 layer2->Preroll(preroll_context());
367 EXPECT_TRUE(preroll_context()->surface_needs_readback);
368
369 // BDF with no filter blocks child with readback
370 auto mock_layer = std::make_shared<MockLayer>(SkPath(), DlPaint());
371 mock_layer->set_fake_reads_surface(true);
372 layer2->Add(mock_layer);
373 preroll_context()->surface_needs_readback = false;
374 layer2->Preroll(preroll_context());
375 EXPECT_FALSE(preroll_context()->surface_needs_readback);
376}

◆ TEST_F() [13/876]

flutter::testing::TEST_F ( BackdropFilterLayerTest  ,
SimpleFilter   
)

Definition at line 98 of file backdrop_filter_layer_unittests.cc.

98 {
99 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
100 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
101 const SkPath child_path = SkPath().addRect(child_bounds);
102 const DlPaint child_paint = DlPaint(DlColor::kYellow());
103 auto layer_filter =
104 std::make_shared<DlBlurImageFilter>(2.5, 3.2, DlTileMode::kClamp);
105 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
106 auto layer = std::make_shared<BackdropFilterLayer>(layer_filter,
107 DlBlendMode::kSrcOver);
108 layer->Add(mock_layer);
109 auto parent = std::make_shared<ClipRectLayer>(child_bounds, Clip::kHardEdge);
110 parent->Add(layer);
111
112 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
113 parent->Preroll(preroll_context());
114 EXPECT_EQ(layer->paint_bounds(), child_bounds);
115 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
116 EXPECT_TRUE(layer->needs_painting(paint_context()));
117 EXPECT_EQ(mock_layer->parent_matrix(), initial_transform);
118
119 parent->Paint(display_list_paint_context());
120 DisplayListBuilder expected_builder;
121 /* (ClipRect)parent::Paint */ {
122 expected_builder.Save();
123 {
124 expected_builder.ClipRect(child_bounds, DlCanvas::ClipOp::kIntersect,
125 false);
126 /* (BackdropFilter)layer::Paint */ {
127 expected_builder.Save();
128 {
129 expected_builder.SaveLayer(&child_bounds, nullptr,
130 layer_filter.get());
131 {
132 /* mock_layer::Paint */ {
133 expected_builder.DrawPath(child_path, child_paint);
134 }
135 }
136 expected_builder.Restore();
137 }
138 expected_builder.Restore();
139 }
140 }
141 expected_builder.Restore();
142 }
143 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
144}

◆ TEST_F() [14/876]

flutter::testing::TEST_F ( BackdropLayerDiffTest  ,
BackdropLayer   
)

Definition at line 426 of file backdrop_filter_layer_unittests.cc.

426 {
427 auto filter = DlBlurImageFilter(10, 10, DlTileMode::kClamp);
428
429 {
430 // tests later assume 30px readback area, fail early if that's not the case
432 EXPECT_EQ(filter.get_input_device_bounds(SkIRect::MakeWH(10, 10),
434 &readback);
435 EXPECT_EQ(readback, SkIRect::MakeLTRB(-30, -30, 40, 40));
436 }
437
438 MockLayerTree l1(SkISize::Make(100, 100));
439 l1.root()->Add(std::make_shared<BackdropFilterLayer>(filter.shared(),
440 DlBlendMode::kSrcOver));
441
442 // no clip, effect over entire surface
443 auto damage = DiffLayerTree(l1, MockLayerTree(SkISize::Make(100, 100)));
444 EXPECT_EQ(damage.frame_damage, SkIRect::MakeWH(100, 100));
445
446 MockLayerTree l2(SkISize::Make(100, 100));
447
448 auto clip = std::make_shared<ClipRectLayer>(SkRect::MakeLTRB(20, 20, 60, 60),
449 Clip::kHardEdge);
450 clip->Add(std::make_shared<BackdropFilterLayer>(filter.shared(),
451 DlBlendMode::kSrcOver));
452 l2.root()->Add(clip);
453 damage = DiffLayerTree(l2, MockLayerTree(SkISize::Make(100, 100)));
454
455 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 90, 90));
456
457 MockLayerTree l3;
458 auto scale = std::make_shared<TransformLayer>(SkMatrix::Scale(2.0, 2.0));
459 scale->Add(clip);
460 l3.root()->Add(scale);
461
462 damage = DiffLayerTree(l3, MockLayerTree());
463 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 180, 180));
464
465 MockLayerTree l4;
466 l4.root()->Add(scale);
467
468 // path just outside of readback region, doesn't affect blur
469 auto path1 = SkPath().addRect(SkRect::MakeLTRB(180, 180, 190, 190));
470 l4.root()->Add(std::make_shared<MockLayer>(path1));
471 damage = DiffLayerTree(l4, l3);
472 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(180, 180, 190, 190));
473
474 MockLayerTree l5;
475 l5.root()->Add(scale);
476
477 // path just inside of readback region, must trigger backdrop repaint
478 auto path2 = SkPath().addRect(SkRect::MakeLTRB(179, 179, 189, 189));
479 l5.root()->Add(std::make_shared<MockLayer>(path2));
480 damage = DiffLayerTree(l5, l4);
481 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 190, 190));
482}
static void readback(const SkBitmap &src, int *result, int resultCount)
Definition BlurTest.cpp:264
static SkPath path1()
static SkPath path2()

◆ TEST_F() [15/876]

flutter::testing::TEST_F ( BackdropLayerDiffTest  ,
BackdropLayerInvalidTransform   
)

Definition at line 509 of file backdrop_filter_layer_unittests.cc.

509 {
510 auto filter = DlBlurImageFilter(10, 10, DlTileMode::kClamp);
511
512 {
513 // tests later assume 30px readback area, fail early if that's not the case
515 EXPECT_EQ(filter.get_input_device_bounds(SkIRect::MakeWH(10, 10),
517 &readback);
518 EXPECT_EQ(readback, SkIRect::MakeLTRB(-30, -30, 40, 40));
519 }
520
521 MockLayerTree l1(SkISize::Make(100, 100));
523 transform.setPerspX(0.1);
524 transform.setPerspY(0.1);
525
526 auto transform_layer = std::make_shared<TransformLayer>(transform);
527 l1.root()->Add(transform_layer);
528 transform_layer->Add(std::make_shared<BackdropFilterLayer>(
529 filter.shared(), DlBlendMode::kSrcOver));
530
531 auto damage = DiffLayerTree(l1, MockLayerTree(SkISize::Make(100, 100)));
532 EXPECT_EQ(damage.frame_damage, SkIRect::MakeWH(100, 100));
533}

◆ TEST_F() [16/876]

flutter::testing::TEST_F ( BackdropLayerDiffTest  ,
ReadbackOutsideOfPaintArea   
)

Definition at line 484 of file backdrop_filter_layer_unittests.cc.

484 {
485 auto filter = DlMatrixImageFilter(SkMatrix::Translate(50, 50),
486 DlImageSampling::kLinear);
487
488 MockLayerTree l1(SkISize::Make(100, 100));
489
490 auto clip = std::make_shared<ClipRectLayer>(SkRect::MakeLTRB(60, 60, 80, 80),
491 Clip::kHardEdge);
492 clip->Add(std::make_shared<BackdropFilterLayer>(filter.shared(),
493 DlBlendMode::kSrcOver));
494 l1.root()->Add(clip);
495 auto damage = DiffLayerTree(l1, MockLayerTree(SkISize::Make(100, 100)));
496
497 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(60 - 50, 60 - 50, 80, 80));
498
499 MockLayerTree l2(SkISize::Make(100, 100));
500 // path inside readback area must trigger whole readback repaint + filter
501 // repaint.
502 auto path2 = SkPath().addRect(SkRect::MakeXYWH(60 - 50, 60 - 50, 10, 10));
503 l2.root()->Add(clip);
504 l2.root()->Add(std::make_shared<MockLayer>(path2));
505 damage = DiffLayerTree(l2, l1);
506 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(60 - 50, 60 - 50, 80, 80));
507}

◆ TEST_F() [17/876]

flutter::testing::TEST_F ( CheckerBoardLayerTest  ,
ClipPathSaveLayerCheckBoard   
)

Definition at line 97 of file checkerboard_layertree_unittests.cc.

97 {
98 const SkMatrix initial_matrix = SkMatrix::Translate(0.5f, 1.0f);
99 const SkRect child_bounds = SkRect::MakeXYWH(1.0, 2.0, 2.0, 2.0);
100 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
101 const SkPath child_path = SkPath().addRect(child_bounds);
102 const SkPath layer_path =
103 SkPath().addRect(layer_bounds).addRect(layer_bounds);
104 const DlPaint child_paint = DlPaint(DlColor::kYellow());
105 const DlPaint clip_paint;
106 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
107 auto layer = std::make_shared<ClipPathLayer>(layer_path,
108 Clip::kAntiAliasWithSaveLayer);
109 layer->Add(mock_layer);
110
111 preroll_context()->state_stack.set_preroll_delegate(initial_matrix);
112 layer->Preroll(preroll_context());
113
114 // Untouched
115 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(), kGiantRect);
116 EXPECT_TRUE(preroll_context()->state_stack.is_empty());
117
118 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
119 EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
120 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
121 EXPECT_TRUE(layer->needs_painting(paint_context()));
122 EXPECT_EQ(mock_layer->parent_cull_rect(), layer_bounds);
123 EXPECT_EQ(mock_layer->parent_matrix(), initial_matrix);
124 EXPECT_EQ(mock_layer->parent_mutators(), std::vector({Mutator(layer_path)}));
125
126 layer->Paint(display_list_paint_context());
127 {
128 DisplayListBuilder expected_builder;
129 /* (ClipRect)layer::Paint */ {
130 expected_builder.Save();
131 {
132 expected_builder.ClipPath(layer_path, DlCanvas::ClipOp::kIntersect,
133 true);
134 expected_builder.SaveLayer(&child_bounds);
135 {
136 /* mock_layer::Paint */ {
137 expected_builder.DrawPath(child_path, child_paint);
138 }
139 }
140 expected_builder.Restore();
141 }
142 expected_builder.Restore();
143 }
145 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
146 }
147
148 reset_display_list();
149 layer->Paint(checkerboard_context());
150 {
151 DisplayListBuilder expected_builder;
152 /* (ClipRect)layer::Paint */ {
153 expected_builder.Save();
154 {
155 expected_builder.ClipPath(layer_path, DlCanvas::ClipOp::kIntersect,
156 true);
157 expected_builder.SaveLayer(&child_bounds);
158 {
159 /* mock_layer::Paint */ {
160 expected_builder.DrawPath(child_path, child_paint);
161 }
162 expected_builder.DrawRect(child_path.getBounds(),
163 checkerboard_paint());
164 }
165 expected_builder.Restore();
166 }
167 expected_builder.Restore();
168 }
170 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
171 }
172}
void ClipPath(const SkPath &path, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override

◆ TEST_F() [18/876]

flutter::testing::TEST_F ( CheckerBoardLayerTest  ,
ClipRectSaveLayerCheckBoard   
)

Definition at line 21 of file checkerboard_layertree_unittests.cc.

21 {
22 const SkMatrix initial_matrix = SkMatrix::Translate(0.5f, 1.0f);
23 const SkRect child_bounds = SkRect::MakeXYWH(1.0, 2.0, 2.0, 2.0);
24 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
25 const SkPath child_path = SkPath().addRect(child_bounds);
26 const DlPaint child_paint = DlPaint(DlColor::kYellow());
27 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
28 auto layer = std::make_shared<ClipRectLayer>(layer_bounds,
29 Clip::kAntiAliasWithSaveLayer);
30 layer->Add(mock_layer);
31
32 preroll_context()->state_stack.set_preroll_delegate(initial_matrix);
33 layer->Preroll(preroll_context());
34
35 // Untouched
36 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(), kGiantRect);
37 EXPECT_TRUE(preroll_context()->state_stack.is_empty());
38
39 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
40 EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
41 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
42 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
43 EXPECT_TRUE(layer->needs_painting(paint_context()));
44 EXPECT_EQ(mock_layer->parent_cull_rect(), layer_bounds);
45 EXPECT_EQ(mock_layer->parent_matrix(), initial_matrix);
46 EXPECT_EQ(mock_layer->parent_mutators(),
47 std::vector({Mutator(layer_bounds)}));
48
49 layer->Paint(display_list_paint_context());
50 {
51 DisplayListBuilder expected_builder;
52 /* (ClipRect)layer::Paint */ {
53 expected_builder.Save();
54 {
55 expected_builder.ClipRect(layer_bounds, DlCanvas::ClipOp::kIntersect,
56 true);
57 expected_builder.SaveLayer(&child_bounds);
58 {
59 /* mock_layer::Paint */ {
60 expected_builder.DrawPath(child_path, child_paint);
61 }
62 }
63 expected_builder.Restore();
64 }
65 expected_builder.Restore();
66 }
68 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
69 }
70
71 reset_display_list();
72 layer->Paint(checkerboard_context());
73 {
74 DisplayListBuilder expected_builder;
75 /* (ClipRect)layer::Paint */ {
76 expected_builder.Save();
77 {
78 expected_builder.ClipRect(layer_bounds, DlCanvas::ClipOp::kIntersect,
79 true);
80 expected_builder.SaveLayer(&child_bounds);
81 {
82 /* mock_layer::Paint */ {
83 expected_builder.DrawPath(child_path, child_paint);
84 }
85 expected_builder.DrawRect(child_path.getBounds(),
86 checkerboard_paint());
87 }
88 expected_builder.Restore();
89 }
90 expected_builder.Restore();
91 }
93 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
94 }
95}

◆ TEST_F() [19/876]

flutter::testing::TEST_F ( CheckerBoardLayerTest  ,
ClipRRectSaveLayerCheckBoard   
)

Definition at line 174 of file checkerboard_layertree_unittests.cc.

174 {
175 const SkMatrix initial_matrix = SkMatrix::Translate(0.5f, 1.0f);
176 const SkRect child_bounds = SkRect::MakeXYWH(1.0, 2.0, 2.0, 2.0);
177 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
178 const SkPath child_path = SkPath().addRect(child_bounds);
179 const SkRRect layer_rrect = SkRRect::MakeRectXY(layer_bounds, .1, .1);
180 const DlPaint child_paint = DlPaint(DlColor::kYellow());
181 const DlPaint clip_paint;
182 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
183 auto layer = std::make_shared<ClipRRectLayer>(layer_rrect,
184 Clip::kAntiAliasWithSaveLayer);
185 layer->Add(mock_layer);
186
187 preroll_context()->state_stack.set_preroll_delegate(initial_matrix);
188 layer->Preroll(preroll_context());
189
190 // Untouched
191 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(), kGiantRect);
192 EXPECT_TRUE(preroll_context()->state_stack.is_empty());
193
194 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
195 EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
196 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
197 EXPECT_TRUE(layer->needs_painting(paint_context()));
198 EXPECT_EQ(mock_layer->parent_cull_rect(), layer_bounds);
199 EXPECT_EQ(mock_layer->parent_matrix(), initial_matrix);
200 EXPECT_EQ(mock_layer->parent_mutators(), std::vector({Mutator(layer_rrect)}));
201
202 layer->Paint(display_list_paint_context());
203 {
204 DisplayListBuilder expected_builder;
205 /* (ClipRect)layer::Paint */ {
206 expected_builder.Save();
207 {
208 expected_builder.ClipRRect(layer_rrect, DlCanvas::ClipOp::kIntersect,
209 true);
210 expected_builder.SaveLayer(&child_bounds);
211 {
212 /* mock_layer::Paint */ {
213 expected_builder.DrawPath(child_path, child_paint);
214 }
215 }
216 expected_builder.Restore();
217 }
218 expected_builder.Restore();
219 }
221 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
222 }
223
224 reset_display_list();
225 layer->Paint(checkerboard_context());
226 {
227 DisplayListBuilder expected_builder;
228 /* (ClipRect)layer::Paint */ {
229 expected_builder.Save();
230 {
231 expected_builder.ClipRRect(layer_rrect, DlCanvas::ClipOp::kIntersect,
232 true);
233 expected_builder.SaveLayer(&child_bounds);
234 {
235 /* mock_layer::Paint */ {
236 expected_builder.DrawPath(child_path, child_paint);
237 }
238 expected_builder.DrawRect(child_path.getBounds(),
239 checkerboard_paint());
240 }
241 expected_builder.Restore();
242 }
243 expected_builder.Restore();
244 }
246 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
247 }
248}
void ClipRRect(const SkRRect &rrect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override

◆ TEST_F() [20/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
ChildOutsideBounds   
)

Definition at line 100 of file clip_path_layer_unittests.cc.

100 {
101 const SkMatrix initial_matrix = SkMatrix::Translate(0.5f, 1.0f);
102 const SkRect local_cull_bounds = SkRect::MakeXYWH(0.0, 0.0, 2.0, 4.0);
103 const SkRect device_cull_bounds = initial_matrix.mapRect(local_cull_bounds);
104 const SkRect child_bounds = SkRect::MakeXYWH(2.5, 5.0, 4.5, 4.0);
105 const SkRect clip_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
106 const SkPath child_path = SkPath().addRect(child_bounds);
107 const SkPath clip_path = SkPath().addRect(clip_bounds);
108 const DlPaint child_paint = DlPaint(DlColor::kYellow());
109 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
110 auto layer = std::make_shared<ClipPathLayer>(clip_path, Clip::kHardEdge);
111 layer->Add(mock_layer);
112
113 SkRect clip_cull_rect = local_cull_bounds;
114 ASSERT_TRUE(clip_cull_rect.intersect(clip_bounds));
115 SkRect clip_layer_bounds = child_bounds;
116 ASSERT_TRUE(clip_layer_bounds.intersect(clip_bounds));
117
118 // Set up both contexts to cull clipped child
119 preroll_context()->state_stack.set_preroll_delegate(device_cull_bounds,
120 initial_matrix);
121 paint_context().canvas->ClipRect(device_cull_bounds);
122 paint_context().canvas->Transform(initial_matrix);
123
124 layer->Preroll(preroll_context());
125 // Untouched
126 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(),
127 device_cull_bounds);
128 EXPECT_EQ(preroll_context()->state_stack.local_cull_rect(),
129 local_cull_bounds);
130 EXPECT_TRUE(preroll_context()->state_stack.is_empty());
131
132 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
133 EXPECT_EQ(layer->paint_bounds(), clip_layer_bounds);
134 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
135 EXPECT_EQ(mock_layer->parent_cull_rect(), clip_cull_rect);
136 EXPECT_EQ(mock_layer->parent_matrix(), initial_matrix);
137 EXPECT_EQ(mock_layer->parent_mutators(), std::vector({Mutator(clip_path)}));
138
139 EXPECT_FALSE(layer->needs_painting(paint_context()));
140 EXPECT_FALSE(mock_layer->needs_painting(paint_context()));
141 // Top level layer not visible so calling layer->Paint()
142 // would trip an FML_DCHECK
143}
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
bool intersect(const SkRect &r)
Definition SkRect.cpp:114

◆ TEST_F() [21/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
ClipNoneBehaviorDies   
)

Definition at line 27 of file clip_path_layer_unittests.cc.

27 {
28 EXPECT_DEATH_IF_SUPPORTED(
29 auto clip = std::make_shared<ClipPathLayer>(SkPath(), Clip::kNone),
30 "clip_behavior != Clip::kNone");
31}

◆ TEST_F() [22/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
EmptyClipDoesNotCullPlatformView   
)

Definition at line 547 of file clip_path_layer_unittests.cc.

547 {
548 const SkPoint view_offset = SkPoint::Make(0.0f, 0.0f);
549 const SkSize view_size = SkSize::Make(8.0f, 8.0f);
550 const int64_t view_id = 42;
551 auto platform_view =
552 std::make_shared<PlatformViewLayer>(view_offset, view_size, view_id);
553
554 auto layer_clip = SkPath().addRect(kEmptyRect);
555 auto clip = std::make_shared<ClipPathLayer>(layer_clip,
556 Clip::kAntiAliasWithSaveLayer);
557 clip->Add(platform_view);
558
559 auto embedder = MockViewEmbedder();
560 DisplayListBuilder fake_overlay_builder;
561 embedder.AddCanvas(&fake_overlay_builder);
562 preroll_context()->view_embedder = &embedder;
563 paint_context().view_embedder = &embedder;
564
565 clip->Preroll(preroll_context());
566 EXPECT_EQ(embedder.prerolled_views(), std::vector<int64_t>({view_id}));
567
568 clip->Paint(paint_context());
569 EXPECT_EQ(embedder.painted_views(), std::vector<int64_t>({view_id}));
570}
std::unique_ptr< flutter::PlatformViewIOS > platform_view

◆ TEST_F() [23/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
FullyContainedChild   
)

Definition at line 145 of file clip_path_layer_unittests.cc.

145 {
146 const SkMatrix initial_matrix = SkMatrix::Translate(0.5f, 1.0f);
147 const SkRect child_bounds = SkRect::MakeXYWH(1.0, 2.0, 2.0, 2.0);
148 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
149 const SkPath child_path =
150 SkPath().addRect(child_bounds).addOval(child_bounds.makeInset(0.1, 0.1));
151 const SkPath layer_path =
152 SkPath().addRect(layer_bounds).addOval(layer_bounds.makeInset(0.1, 0.1));
153 const DlPaint child_paint = DlPaint(DlColor::kYellow());
154 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
155 auto layer = std::make_shared<ClipPathLayer>(layer_path, Clip::kHardEdge);
156 layer->Add(mock_layer);
157
158 preroll_context()->state_stack.set_preroll_delegate(initial_matrix);
159 layer->Preroll(preroll_context());
160
161 // Untouched
162 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(), kGiantRect);
163 EXPECT_TRUE(preroll_context()->state_stack.is_empty());
164
165 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
166 EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
167 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
168 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
169 EXPECT_TRUE(layer->needs_painting(paint_context()));
170 EXPECT_EQ(mock_layer->parent_cull_rect(), layer_bounds);
171 EXPECT_EQ(mock_layer->parent_matrix(), initial_matrix);
172 EXPECT_EQ(mock_layer->parent_mutators(), std::vector({Mutator(layer_path)}));
173
174 layer->Paint(display_list_paint_context());
175 DisplayListBuilder expected_builder;
176 /* (ClipPath)layer::Paint */ {
177 expected_builder.Save();
178 {
179 expected_builder.ClipPath(layer_path);
180 /* mock_layer::Paint */ {
181 expected_builder.DrawPath(child_path, child_paint);
182 }
183 }
184 expected_builder.Restore();
185 }
186 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
187}

◆ TEST_F() [24/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
LayerCached   
)

Definition at line 504 of file clip_path_layer_unittests.cc.

504 {
505 auto path1 = SkPath().addRect({10, 10, 30, 30});
506 auto mock1 = MockLayer::MakeOpacityCompatible(path1);
507 auto layer_clip = SkPath()
508 .addRect(SkRect::MakeLTRB(5, 5, 25, 25))
509 .addOval(SkRect::MakeLTRB(20, 20, 40, 50));
510 auto layer = std::make_shared<ClipPathLayer>(layer_clip,
511 Clip::kAntiAliasWithSaveLayer);
512 layer->Add(mock1);
513
514 auto initial_transform = SkMatrix::Translate(50.0, 25.5);
515 SkMatrix cache_ctm = initial_transform;
516 DisplayListBuilder cache_canvas;
517 cache_canvas.Transform(cache_ctm);
518
519 use_mock_raster_cache();
520 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
521
522 const auto* clip_cache_item = layer->raster_cache_item();
523
524 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
525
526 layer->Preroll(preroll_context());
527 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
528
529 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
530 EXPECT_EQ(clip_cache_item->cache_state(), RasterCacheItem::CacheState::kNone);
531
532 layer->Preroll(preroll_context());
533 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
534 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
535 EXPECT_EQ(clip_cache_item->cache_state(), RasterCacheItem::CacheState::kNone);
536
537 layer->Preroll(preroll_context());
538 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
539 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)1);
540 EXPECT_EQ(clip_cache_item->cache_state(),
541 RasterCacheItem::CacheState::kCurrent);
543 EXPECT_TRUE(raster_cache()->Draw(clip_cache_item->GetId().value(),
544 cache_canvas, &paint));
545}
void Transform(const SkMatrix *matrix) override
static void Draw(SkCanvas *canvas, const SkRect &rect)

◆ TEST_F() [25/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
OpacityInheritancePainting   
)

Definition at line 399 of file clip_path_layer_unittests.cc.

399 {
400 auto path1 = SkPath().addRect({10, 10, 30, 30});
401 auto mock1 = MockLayer::MakeOpacityCompatible(path1);
402 auto path2 = SkPath().addRect({40, 40, 50, 50});
403 auto mock2 = MockLayer::MakeOpacityCompatible(path2);
404 auto layer_clip = SkPath()
405 .addRect(SkRect::MakeLTRB(5, 5, 25, 25))
406 .addOval(SkRect::MakeLTRB(45, 45, 55, 55));
407 auto clip_path_layer =
408 std::make_shared<ClipPathLayer>(layer_clip, Clip::kAntiAlias);
409 clip_path_layer->Add(mock1);
410 clip_path_layer->Add(mock2);
411
412 // ClipRectLayer will pass through compatibility from multiple
413 // non-overlapping compatible children
414 PrerollContext* context = preroll_context();
415 clip_path_layer->Preroll(context);
416 EXPECT_EQ(context->renderable_state_flags,
417 LayerStateStack::kCallerCanApplyOpacity);
418
419 int opacity_alpha = 0x7F;
420 SkPoint offset = SkPoint::Make(10, 10);
421 auto opacity_layer = std::make_shared<OpacityLayer>(opacity_alpha, offset);
422 opacity_layer->Add(clip_path_layer);
423 opacity_layer->Preroll(context);
424 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
425
426 DisplayListBuilder expected_builder;
427 /* OpacityLayer::Paint() */ {
428 expected_builder.Save();
429 {
430 expected_builder.Translate(offset.fX, offset.fY);
431 /* ClipRectLayer::Paint() */ {
432 expected_builder.Save();
433 expected_builder.ClipPath(layer_clip, ClipOp::kIntersect, true);
434 /* child layer1 paint */ {
435 expected_builder.DrawPath(path1, DlPaint().setAlpha(opacity_alpha));
436 }
437 /* child layer2 paint */ {
438 expected_builder.DrawPath(path2, DlPaint().setAlpha(opacity_alpha));
439 }
440 expected_builder.Restore();
441 }
442 }
443 expected_builder.Restore();
444 }
445
446 opacity_layer->Paint(display_list_paint_context());
447 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
448}

◆ TEST_F() [26/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
OpacityInheritanceSaveLayerPainting   
)

Definition at line 450 of file clip_path_layer_unittests.cc.

450 {
451 auto path1 = SkPath().addRect({10, 10, 30, 30});
452 auto mock1 = MockLayer::MakeOpacityCompatible(path1);
453 auto path2 = SkPath().addRect({20, 20, 40, 40});
454 auto mock2 = MockLayer::MakeOpacityCompatible(path2);
455 auto children_bounds = path1.getBounds();
456 children_bounds.join(path2.getBounds());
457 auto layer_clip = SkPath()
458 .addRect(SkRect::MakeLTRB(5, 5, 25, 25))
459 .addOval(SkRect::MakeLTRB(20, 20, 40, 50));
460 auto clip_path_layer = std::make_shared<ClipPathLayer>(
461 layer_clip, Clip::kAntiAliasWithSaveLayer);
462 clip_path_layer->Add(mock1);
463 clip_path_layer->Add(mock2);
464
465 // ClipRectLayer will pass through compatibility from multiple
466 // non-overlapping compatible children
467 PrerollContext* context = preroll_context();
468 clip_path_layer->Preroll(context);
469 EXPECT_EQ(context->renderable_state_flags, Layer::kSaveLayerRenderFlags);
470
471 int opacity_alpha = 0x7F;
472 SkPoint offset = SkPoint::Make(10, 10);
473 auto opacity_layer = std::make_shared<OpacityLayer>(opacity_alpha, offset);
474 opacity_layer->Add(clip_path_layer);
475 opacity_layer->Preroll(context);
476 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
477
478 DisplayListBuilder expected_builder;
479 /* OpacityLayer::Paint() */ {
480 expected_builder.Save();
481 {
482 expected_builder.Translate(offset.fX, offset.fY);
483 /* ClipRectLayer::Paint() */ {
484 expected_builder.Save();
485 expected_builder.ClipPath(layer_clip, ClipOp::kIntersect, true);
486 expected_builder.SaveLayer(&children_bounds,
487 &DlPaint().setAlpha(opacity_alpha));
488 /* child layer1 paint */ {
489 expected_builder.DrawPath(path1, DlPaint());
490 }
491 /* child layer2 paint */ { //
492 expected_builder.DrawPath(path2, DlPaint());
493 }
494 expected_builder.Restore();
495 }
496 }
497 expected_builder.Restore();
498 }
499
500 opacity_layer->Paint(display_list_paint_context());
501 EXPECT_TRUE(DisplayListsEQ_Verbose(expected_builder.Build(), display_list()));
502}

◆ TEST_F() [27/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
PaintingCulledLayerDies   
)

Definition at line 62 of file clip_path_layer_unittests.cc.

62 {
63 const SkMatrix initial_matrix = SkMatrix::Translate(0.5f, 1.0f);
64 const SkRect child_bounds = SkRect::MakeXYWH(1.0, 2.0, 2.0, 2.0);
65 const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
66 const SkRect distant_bounds = SkRect::MakeXYWH(100.0, 100.0, 10.0, 10.0);
67 const SkPath child_path = SkPath().addRect(child_bounds);
68 const SkPath layer_path = SkPath().addRect(layer_bounds);
69 auto mock_layer = std::make_shared<MockLayer>(child_path);
70 auto layer = std::make_shared<ClipPathLayer>(layer_path, Clip::kHardEdge);
71 layer->Add(mock_layer);
72
73 // Cull these children
74 preroll_context()->state_stack.set_preroll_delegate(distant_bounds,
75 initial_matrix);
76 layer->Preroll(preroll_context());
77
78 // Untouched
79 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(), distant_bounds);
80 EXPECT_TRUE(preroll_context()->state_stack.is_empty());
81
82 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
83 EXPECT_EQ(layer->paint_bounds(), child_bounds);
84 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
85 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
86 EXPECT_TRUE(layer->needs_painting(paint_context()));
87 EXPECT_EQ(mock_layer->parent_cull_rect(), kEmptyRect);
88 EXPECT_EQ(mock_layer->parent_matrix(), initial_matrix);
89 EXPECT_EQ(mock_layer->parent_mutators(), std::vector({Mutator(layer_path)}));
90
91 auto mutator = paint_context().state_stack.save();
92 mutator.clipRect(distant_bounds, false);
93 EXPECT_FALSE(mock_layer->needs_painting(paint_context()));
94 EXPECT_FALSE(layer->needs_painting(paint_context()));
95 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
96 "needs_painting\\(context\\)");
97}

◆ TEST_F() [28/876]

flutter::testing::TEST_F ( ClipPathLayerTest  ,
PartiallyContainedChild   
)

Definition at line 189 of file clip_path_layer_unittests.cc.

189 {
190 const SkMatrix initial_matrix = SkMatrix::Translate(0.5f, 1.0f);
191 const SkRect local_cull_bounds = SkRect::MakeXYWH(0.0, 0.0, 4.0, 5.5);
192 const SkRect device_cull_bounds = initial_matrix.mapRect(local_cull_bounds);
193 const SkRect child_bounds = SkRect::MakeXYWH(2.5, 5.0, 4.5, 4.0);
194 const SkRect clip_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);
195 const SkPath child_path =
196 SkPath().addRect(child_bounds).addOval(child_bounds.makeInset(0.1, 0.1));
197 const SkPath clip_path =
198 SkPath().addRect(clip_bounds).addOval(clip_bounds.makeInset(0.1, 0.1));
199 const DlPaint child_paint = DlPaint(DlColor::kYellow());
200 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
201 auto layer = std::make_shared<ClipPathLayer>(clip_path, Clip::kHardEdge);
202 layer->Add(mock_layer);
203
204 SkRect clip_cull_rect = local_cull_bounds;
205 ASSERT_TRUE(clip_cull_rect.intersect(clip_bounds));
206 SkRect clip_layer_bounds = child_bounds;
207 ASSERT_TRUE(clip_layer_bounds.intersect(clip_bounds));
208
209 // Cull child
210 preroll_context()->state_stack.set_preroll_delegate(device_cull_bounds,
211 initial_matrix);
212 layer->Preroll(preroll_context());
213
214 // Untouched
215 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(),
216 device_cull_bounds);
217 EXPECT_EQ(preroll_context()->state_stack.local_cull_rect(),
218 local_cull_bounds);
219 EXPECT_TRUE(preroll_context()->state_stack.is_empty());
220
221 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
222 EXPECT_EQ(layer->paint_bounds(), clip_layer_bounds);
223 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
224 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
225 EXPECT_TRUE(layer->needs_painting(paint_context()));
226 EXPECT_EQ(mock_layer->parent_cull_rect(), clip_cull_rect);
227 EXPECT_EQ(mock_layer->parent_matrix(), initial_matrix);
228 EXPECT_EQ(mock_layer->parent_mutators(), std::vector({Mutator(clip_path)}));
229
230 layer->Paint(display_list_paint_context());
231 DisplayListBuilder expected_builder;
232 /* (ClipPath)layer::Paint */ {
233 expected_builder.Save();
234 {
235 expected_builder.ClipPath(clip_path);
236 /* mock_layer::Paint */ {
237 expected_builder.DrawPath(child_path, child_paint);
238 }
239 }
240 expected_builder.Restore();
241 }
242 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
243}

◆ TEST_F() [29/876]

flutter::testing::TEST_F ( ClipRRectLayerTest  ,
NoSaveLayerShouldNotCache   
)

Definition at line 538 of file clip_rrect_layer_unittests.cc.

538 {
539 auto path1 = SkPath().addRect({10, 10, 30, 30});
540
541 auto mock1 = MockLayer::MakeOpacityCompatible(path1);
542 SkRect clip_rect = SkRect::MakeWH(500, 500);
543 SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 20, 20);
544 auto layer = std::make_shared<ClipRRectLayer>(clip_rrect, Clip::kAntiAlias);
545 layer->Add(mock1);
546
547 auto initial_transform = SkMatrix::Translate(50.0, 25.5);
548 SkMatrix cache_ctm = initial_transform;
549 SkCanvas cache_canvas;
550 cache_canvas.setMatrix(cache_ctm);
551
552 use_mock_raster_cache();
553 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
554
555 const auto* clip_cache_item = layer->raster_cache_item();
556
557 layer->Preroll(preroll_context());
558 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
559
560 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
561 EXPECT_EQ(clip_cache_item->cache_state(), RasterCacheItem::CacheState::kNone);
562
563 layer->Preroll(preroll_context());
564 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
565 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
566 EXPECT_EQ(clip_cache_item->cache_state(), RasterCacheItem::CacheState::kNone);
567
568 layer->Preroll(preroll_context());
569 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
570 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
571 EXPECT_EQ(clip_cache_item->cache_state(), RasterCacheItem::CacheState::kNone);
572}
void setMatrix(const SkM44 &matrix)

◆ TEST_F() [30/876]

flutter::testing::TEST_F ( ColorFilterLayerTest  ,
CacheChild   
)

Definition at line 257 of file color_filter_layer_unittests.cc.

257 {
258 auto layer_filter = DlSrgbToLinearGammaColorFilter::kInstance;
259 auto initial_transform = SkMatrix::Translate(50.0, 25.5);
260 auto other_transform = SkMatrix::Scale(1.0, 2.0);
261 const SkPath child_path = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
263 auto mock_layer = std::make_shared<MockLayer>(child_path);
264 auto layer = std::make_shared<ColorFilterLayer>(layer_filter);
265 layer->Add(mock_layer);
266
267 SkMatrix cache_ctm = initial_transform;
268 DisplayListBuilder cache_canvas;
269 cache_canvas.Transform(cache_ctm);
270 DisplayListBuilder other_canvas;
271 other_canvas.Transform(other_transform);
272
273 use_mock_raster_cache();
274 const auto* cacheable_color_filter_item = layer->raster_cache_item();
275
276 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
277 EXPECT_EQ(cacheable_color_filter_item->cache_state(),
278 RasterCacheItem::CacheState::kNone);
279 EXPECT_FALSE(cacheable_color_filter_item->GetId().has_value());
280
281 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
282 layer->Preroll(preroll_context());
283 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
284
285 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)1);
286 EXPECT_EQ(cacheable_color_filter_item->cache_state(),
287 RasterCacheItem::CacheState::kChildren);
288 EXPECT_EQ(
289 cacheable_color_filter_item->GetId().value(),
290 RasterCacheKeyID(RasterCacheKeyID::LayerChildrenIds(layer.get()).value(),
291 RasterCacheKeyType::kLayerChildren));
292 EXPECT_FALSE(raster_cache()->Draw(
293 cacheable_color_filter_item->GetId().value(), other_canvas, &paint));
294 EXPECT_TRUE(raster_cache()->Draw(cacheable_color_filter_item->GetId().value(),
295 cache_canvas, &paint));
296}

◆ TEST_F() [31/876]

flutter::testing::TEST_F ( ColorFilterLayerTest  ,
CacheChildren   
)

Definition at line 298 of file color_filter_layer_unittests.cc.

298 {
299 auto layer_filter = DlSrgbToLinearGammaColorFilter::kInstance;
300 auto initial_transform = SkMatrix::Translate(50.0, 25.5);
301 auto other_transform = SkMatrix::Scale(1.0, 2.0);
302 const SkPath child_path1 = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
303 const SkPath child_path2 = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
304 auto mock_layer1 = std::make_shared<MockLayer>(child_path1);
305 auto mock_layer2 = std::make_shared<MockLayer>(child_path2);
306 auto layer = std::make_shared<ColorFilterLayer>(layer_filter);
307 layer->Add(mock_layer1);
308 layer->Add(mock_layer2);
310
311 SkMatrix cache_ctm = initial_transform;
312 DisplayListBuilder cache_canvas;
313 cache_canvas.Transform(cache_ctm);
314 DisplayListBuilder other_canvas;
315 other_canvas.Transform(other_transform);
316
317 use_mock_raster_cache();
318
319 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
320 const auto* cacheable_color_filter_item = layer->raster_cache_item();
321 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
322
323 EXPECT_EQ(cacheable_color_filter_item->cache_state(),
324 RasterCacheItem::CacheState::kNone);
325 EXPECT_FALSE(cacheable_color_filter_item->GetId().has_value());
326
327 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
328 layer->Preroll(preroll_context());
329 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
330
331 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)1);
332 EXPECT_EQ(cacheable_color_filter_item->cache_state(),
333 RasterCacheItem::CacheState::kChildren);
334 EXPECT_EQ(
335 cacheable_color_filter_item->GetId().value(),
336 RasterCacheKeyID(RasterCacheKeyID::LayerChildrenIds(layer.get()).value(),
337 RasterCacheKeyType::kLayerChildren));
338 EXPECT_FALSE(raster_cache()->Draw(
339 cacheable_color_filter_item->GetId().value(), other_canvas, &paint));
340 EXPECT_TRUE(raster_cache()->Draw(cacheable_color_filter_item->GetId().value(),
341 cache_canvas, &paint));
342}

◆ TEST_F() [32/876]

flutter::testing::TEST_F ( ColorFilterLayerTest  ,
CacheColorFilterLayerSelf   
)

Definition at line 344 of file color_filter_layer_unittests.cc.

344 {
345 auto layer_filter = DlSrgbToLinearGammaColorFilter::kInstance;
346 auto initial_transform = SkMatrix::Translate(50.0, 25.5);
347 auto other_transform = SkMatrix::Scale(1.0, 2.0);
348 const SkPath child_path1 = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
349 const SkPath child_path2 = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
350 auto mock_layer1 = std::make_shared<MockLayer>(child_path1);
351 auto mock_layer2 = std::make_shared<MockLayer>(child_path2);
352 auto layer = std::make_shared<ColorFilterLayer>(layer_filter);
353 layer->Add(mock_layer1);
354 layer->Add(mock_layer2);
356
357 SkMatrix cache_ctm = initial_transform;
358 DisplayListBuilder cache_canvas;
359 cache_canvas.Transform(cache_ctm);
360 DisplayListBuilder other_canvas;
361 other_canvas.Transform(other_transform);
362
363 use_mock_raster_cache();
364 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
365 const auto* cacheable_color_filter_item = layer->raster_cache_item();
366
367 // frame 1.
368 layer->Preroll(preroll_context());
369 layer->Paint(paint_context());
370 // frame 2.
371 layer->Preroll(preroll_context());
372 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
373 // ColorFilterLayer default cache children.
374 EXPECT_EQ(cacheable_color_filter_item->cache_state(),
375 RasterCacheItem::CacheState::kChildren);
376 EXPECT_TRUE(raster_cache()->Draw(cacheable_color_filter_item->GetId().value(),
377 cache_canvas, &paint));
378 EXPECT_FALSE(raster_cache()->Draw(
379 cacheable_color_filter_item->GetId().value(), other_canvas, &paint));
380 layer->Paint(paint_context());
381
382 // frame 3.
383 layer->Preroll(preroll_context());
384 layer->Paint(paint_context());
385
386 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
387 // frame1,2 cache the ColorFilterLayer's children layer, frame3 cache the
388 // ColorFilterLayer
389 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)2);
390
391 // ColorFilterLayer default cache itself.
392 EXPECT_EQ(cacheable_color_filter_item->cache_state(),
393 RasterCacheItem::CacheState::kCurrent);
394 EXPECT_EQ(cacheable_color_filter_item->GetId(),
395 RasterCacheKeyID(layer->unique_id(), RasterCacheKeyType::kLayer));
396 EXPECT_TRUE(raster_cache()->Draw(cacheable_color_filter_item->GetId().value(),
397 cache_canvas, &paint));
398 EXPECT_FALSE(raster_cache()->Draw(
399 cacheable_color_filter_item->GetId().value(), other_canvas, &paint));
400}

◆ TEST_F() [33/876]

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

Definition at line 125 of file compositor_opengl_unittests.cc.

125 {
126 UseHeadlessEngine();
127
128 auto compositor = CompositorOpenGL{engine(), kMockResolver};
129
130 FlutterBackingStoreConfig config = {};
131 FlutterBackingStore backing_store = {};
132
133 EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
134 ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
135 ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
136}

◆ TEST_F() [34/876]

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

Definition at line 138 of file compositor_opengl_unittests.cc.

138 {
139 UseHeadlessEngine();
140
141 auto compositor = CompositorOpenGL{engine(), kMockResolver};
142
143 FlutterBackingStoreConfig config = {};
144 FlutterBackingStore backing_store = {};
145
146 EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(false));
147 EXPECT_FALSE(compositor.CreateBackingStore(config, &backing_store));
148}

◆ TEST_F() [35/876]

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

Definition at line 188 of file compositor_opengl_unittests.cc.

188 {
189 UseEngineWithView(/*add_surface = */ false);
190
191 auto compositor = CompositorOpenGL{engine(), kMockResolver};
192
193 FlutterBackingStoreConfig config = {};
194 FlutterBackingStore backing_store = {};
195
196 EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
197 ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
198
199 FlutterLayer layer = {};
201 layer.backing_store = &backing_store;
202 const FlutterLayer* layer_ptr = &layer;
203
204 EXPECT_FALSE(compositor.Present(view(), &layer_ptr, 1));
205
206 ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
207}
FlutterLayerContentType type
Definition embedder.h:1822
const FlutterBackingStore * backing_store
Definition embedder.h:1826

◆ TEST_F() [36/876]

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

Definition at line 150 of file compositor_opengl_unittests.cc.

150 {
151 UseEngineWithView();
152
153 auto compositor = CompositorOpenGL{engine(), kMockResolver};
154
155 FlutterBackingStoreConfig config = {};
156 FlutterBackingStore backing_store = {};
157
158 EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
159 ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
160
161 FlutterLayer layer = {};
163 layer.backing_store = &backing_store;
164 const FlutterLayer* layer_ptr = &layer;
165
166 EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
167 EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
168 EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
169 EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
170
171 ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
172}

◆ TEST_F() [37/876]

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

Definition at line 174 of file compositor_opengl_unittests.cc.

174 {
175 UseEngineWithView();
176
177 auto compositor = CompositorOpenGL{engine(), kMockResolver};
178
179 // The context will be bound twice: first to initialize the compositor, second
180 // to clear the surface.
181 EXPECT_CALL(*render_context(), MakeCurrent).WillOnce(Return(true));
182 EXPECT_CALL(*surface(), IsValid).WillRepeatedly(Return(true));
183 EXPECT_CALL(*surface(), MakeCurrent).WillOnce(Return(true));
184 EXPECT_CALL(*surface(), SwapBuffers).WillOnce(Return(true));
185 EXPECT_TRUE(compositor.Present(view(), nullptr, 0));
186}

◆ TEST_F() [38/876]

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

Definition at line 70 of file compositor_software_unittests.cc.

70 {
71 CompositorSoftware compositor;
72
73 FlutterBackingStoreConfig config = {};
74 FlutterBackingStore backing_store = {};
75
76 ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
77 ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
78}
bool CollectBackingStore(const FlutterBackingStore *store) override
|Compositor|
bool CreateBackingStore(const FlutterBackingStoreConfig &config, FlutterBackingStore *result) override
|Compositor|

◆ TEST_F() [39/876]

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

Definition at line 80 of file compositor_software_unittests.cc.

80 {
81 UseEngineWithView();
82
83 CompositorSoftware compositor;
84
85 FlutterBackingStoreConfig config = {};
86 FlutterBackingStore backing_store = {};
87
88 ASSERT_TRUE(compositor.CreateBackingStore(config, &backing_store));
89
90 FlutterLayer layer = {};
92 layer.backing_store = &backing_store;
93 const FlutterLayer* layer_ptr = &layer;
94
95 EXPECT_CALL(*view(), PresentSoftwareBitmap).WillOnce(Return(true));
96 EXPECT_TRUE(compositor.Present(view(), &layer_ptr, 1));
97
98 ASSERT_TRUE(compositor.CollectBackingStore(&backing_store));
99}
bool Present(FlutterWindowsView *view, const FlutterLayer **layers, size_t layers_count) override
|Compositor|

◆ TEST_F() [40/876]

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

Definition at line 101 of file compositor_software_unittests.cc.

101 {
102 UseEngineWithView();
103
104 CompositorSoftware compositor;
105
106 EXPECT_CALL(*view(), ClearSoftwareBitmap).WillOnce(Return(true));
107 EXPECT_TRUE(compositor.Present(view(), nullptr, 0));
108}

◆ TEST_F() [41/876]

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

Definition at line 117 of file compositor_software_unittests.cc.

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

◆ TEST_F() [42/876]

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

Definition at line 167 of file compositor_software_unittests.cc.

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

◆ TEST_F() [43/876]

flutter::testing::TEST_F ( ContainerLayerDiffTest  ,
LayerDeletion   
)

Definition at line 655 of file container_layer_unittests.cc.

655 {
656 auto path1 = SkPath().addRect(SkRect::MakeLTRB(0, 0, 50, 50));
657 auto path2 = SkPath().addRect(SkRect::MakeLTRB(100, 0, 150, 50));
658 auto path3 = SkPath().addRect(SkRect::MakeLTRB(200, 0, 250, 50));
659
660 auto c1 = CreateContainerLayer(std::make_shared<MockLayer>(path1));
661 auto c2 = CreateContainerLayer(std::make_shared<MockLayer>(path2));
662 auto c3 = CreateContainerLayer(std::make_shared<MockLayer>(path3));
663
664 MockLayerTree t1;
665 t1.root()->Add(c1);
666 t1.root()->Add(c2);
667 t1.root()->Add(c3);
668
669 auto damage = DiffLayerTree(t1, MockLayerTree());
670 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 250, 50));
671
672 MockLayerTree t2;
673 t2.root()->Add(c2);
674 t2.root()->Add(c3);
675
676 damage = DiffLayerTree(t2, t1);
677 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 50, 50));
678
679 MockLayerTree t3;
680 t3.root()->Add(c1);
681 t3.root()->Add(c3);
682
683 damage = DiffLayerTree(t3, t1);
684 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(100, 0, 150, 50));
685
686 MockLayerTree t4;
687 t4.root()->Add(c1);
688 t4.root()->Add(c2);
689
690 damage = DiffLayerTree(t4, t1);
691 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 50));
692
693 MockLayerTree t5;
694 t5.root()->Add(c1);
695
696 damage = DiffLayerTree(t5, t1);
697 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(100, 0, 250, 50));
698
699 MockLayerTree t6;
700 t6.root()->Add(c2);
701
702 damage = DiffLayerTree(t6, t1);
703 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 250, 50));
704
705 MockLayerTree t7;
706 t7.root()->Add(c3);
707
708 damage = DiffLayerTree(t7, t1);
709 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 150, 50));
710}
static SkPath path3()
virtual void Add(std::shared_ptr< Layer > layer)

◆ TEST_F() [44/876]

flutter::testing::TEST_F ( ContainerLayerDiffTest  ,
PictureInsertion   
)

Definition at line 618 of file container_layer_unittests.cc.

618 {
619 auto pic1 = CreateDisplayList(SkRect::MakeLTRB(0, 0, 50, 50));
620 auto pic2 = CreateDisplayList(SkRect::MakeLTRB(100, 0, 150, 50));
621 auto pic3 = CreateDisplayList(SkRect::MakeLTRB(200, 0, 250, 50));
622
623 MockLayerTree t1;
624 t1.root()->Add(CreateDisplayListLayer(pic1));
625 t1.root()->Add(CreateDisplayListLayer(pic2));
626
627 auto damage = DiffLayerTree(t1, MockLayerTree());
628 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 150, 50));
629
630 MockLayerTree t2;
631 t2.root()->Add(CreateDisplayListLayer(pic3));
632 t2.root()->Add(CreateDisplayListLayer(pic1));
633 t2.root()->Add(CreateDisplayListLayer(pic2));
634
635 damage = DiffLayerTree(t2, t1);
636 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 50));
637
638 MockLayerTree t3;
639 t3.root()->Add(CreateDisplayListLayer(pic1));
640 t3.root()->Add(CreateDisplayListLayer(pic3));
641 t3.root()->Add(CreateDisplayListLayer(pic2));
642
643 damage = DiffLayerTree(t3, t1);
644 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 50));
645
646 MockLayerTree t4;
647 t4.root()->Add(CreateDisplayListLayer(pic1));
648 t4.root()->Add(CreateDisplayListLayer(pic2));
649 t4.root()->Add(CreateDisplayListLayer(pic3));
650
651 damage = DiffLayerTree(t4, t1);
652 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 50));
653}

◆ TEST_F() [45/876]

flutter::testing::TEST_F ( ContainerLayerDiffTest  ,
PictureLayerInsertion   
)

Definition at line 566 of file container_layer_unittests.cc.

566 {
567 auto pic1 = CreateDisplayList(SkRect::MakeLTRB(0, 0, 50, 50));
568 auto pic2 = CreateDisplayList(SkRect::MakeLTRB(100, 0, 150, 50));
569 auto pic3 = CreateDisplayList(SkRect::MakeLTRB(200, 0, 250, 50));
570
571 MockLayerTree t1;
572
573 auto t1_c1 = CreateContainerLayer(CreateDisplayListLayer(pic1));
574 t1.root()->Add(t1_c1);
575
576 auto t1_c2 = CreateContainerLayer(CreateDisplayListLayer(pic2));
577 t1.root()->Add(t1_c2);
578
579 auto damage = DiffLayerTree(t1, MockLayerTree());
580 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 150, 50));
581
582 // Add in the middle
583
584 MockLayerTree t2;
585 auto t2_c1 = CreateContainerLayer(CreateDisplayListLayer(pic1));
586 t2_c1->AssignOldLayer(t1_c1.get());
587 t2.root()->Add(t2_c1);
588
589 t2.root()->Add(CreateDisplayListLayer(pic3));
590
591 auto t2_c2 = CreateContainerLayer(CreateDisplayListLayer(pic2));
592 t2_c2->AssignOldLayer(t1_c2.get());
593 t2.root()->Add(t2_c2);
594
595 damage = DiffLayerTree(t2, t1);
596 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 50));
597
598 // Add in the beginning
599
600 t2 = MockLayerTree();
601 t2.root()->Add(CreateDisplayListLayer(pic3));
602 t2.root()->Add(t2_c1);
603 t2.root()->Add(t2_c2);
604 damage = DiffLayerTree(t2, t1);
605 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 50));
606
607 // Add at the end
608
609 t2 = MockLayerTree();
610 t2.root()->Add(t2_c1);
611 t2.root()->Add(t2_c2);
612 t2.root()->Add(CreateDisplayListLayer(pic3));
613 damage = DiffLayerTree(t2, t1);
614 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 50));
615}

◆ TEST_F() [46/876]

flutter::testing::TEST_F ( ContainerLayerDiffTest  ,
ReplaceLayer   
)

Definition at line 712 of file container_layer_unittests.cc.

712 {
713 auto path1 = SkPath().addRect(SkRect::MakeLTRB(0, 0, 50, 50));
714 auto path2 = SkPath().addRect(SkRect::MakeLTRB(100, 0, 150, 50));
715 auto path3 = SkPath().addRect(SkRect::MakeLTRB(200, 0, 250, 50));
716
717 auto path1a = SkPath().addRect(SkRect::MakeLTRB(0, 100, 50, 150));
718 auto path2a = SkPath().addRect(SkRect::MakeLTRB(100, 100, 150, 150));
719 auto path3a = SkPath().addRect(SkRect::MakeLTRB(200, 100, 250, 150));
720
721 auto c1 = CreateContainerLayer(std::make_shared<MockLayer>(path1));
722 auto c2 = CreateContainerLayer(std::make_shared<MockLayer>(path2));
723 auto c3 = CreateContainerLayer(std::make_shared<MockLayer>(path3));
724
725 MockLayerTree t1;
726 t1.root()->Add(c1);
727 t1.root()->Add(c2);
728 t1.root()->Add(c3);
729
730 auto damage = DiffLayerTree(t1, MockLayerTree());
731 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 250, 50));
732
733 MockLayerTree t2;
734 t2.root()->Add(c1);
735 t2.root()->Add(c2);
736 t2.root()->Add(c3);
737
738 damage = DiffLayerTree(t2, t1);
739 EXPECT_TRUE(damage.frame_damage.isEmpty());
740
741 MockLayerTree t3;
742 t3.root()->Add(CreateContainerLayer({std::make_shared<MockLayer>(path1a)}));
743 t3.root()->Add(c2);
744 t3.root()->Add(c3);
745
746 damage = DiffLayerTree(t3, t1);
747 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 50, 150));
748
749 MockLayerTree t4;
750 t4.root()->Add(c1);
751 t4.root()->Add(CreateContainerLayer(std::make_shared<MockLayer>(path2a)));
752 t4.root()->Add(c3);
753
754 damage = DiffLayerTree(t4, t1);
755 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(100, 0, 150, 150));
756
757 MockLayerTree t5;
758 t5.root()->Add(c1);
759 t5.root()->Add(c2);
760 t5.root()->Add(CreateContainerLayer(std::make_shared<MockLayer>(path3a)));
761
762 damage = DiffLayerTree(t5, t1);
763 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 0, 250, 150));
764}

◆ TEST_F() [47/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
CollectionCacheableLayer   
)

Definition at line 528 of file container_layer_unittests.cc.

528 {
529 SkPath child_path;
530 child_path.addRect(5.0f, 6.0f, 20.5f, 21.5f);
531 DlPaint child_paint = DlPaint(DlColor::kGreen());
532 SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f);
533
534 auto mock_layer1 = std::make_shared<MockLayer>(SkPath(), child_paint);
535 auto mock_cacheable_container_layer1 =
536 std::make_shared<MockCacheableContainerLayer>();
537 auto mock_container_layer = std::make_shared<ContainerLayer>();
538 auto mock_cacheable_layer =
539 std::make_shared<MockCacheableLayer>(child_path, child_paint);
540 mock_cacheable_container_layer1->Add(mock_cacheable_layer);
541
542 // ContainerLayer
543 // |- MockLayer
544 // |- MockCacheableContainerLayer
545 // |- MockCacheableLayer
546 auto layer = std::make_shared<ContainerLayer>();
547 layer->Add(mock_cacheable_container_layer1);
548 layer->Add(mock_layer1);
549
550 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
551 layer->Preroll(preroll_context());
552 // raster cache is null, so no entry
553 ASSERT_EQ(preroll_context()->raster_cached_entries->size(),
554 static_cast<const unsigned long>(0));
555
556 use_mock_raster_cache();
557 // preroll_context()->raster_cache = raster_cache();
558 layer->Preroll(preroll_context());
559 ASSERT_EQ(preroll_context()->raster_cached_entries->size(),
560 static_cast<const unsigned long>(2));
561}

◆ TEST_F() [48/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
LayerWithParentHasPlatformView   
)

Definition at line 25 of file container_layer_unittests.cc.

25 {
26 auto layer = std::make_shared<ContainerLayer>();
27
28 preroll_context()->has_platform_view = true;
29 EXPECT_DEATH_IF_SUPPORTED(layer->Preroll(preroll_context()),
30 "!context->has_platform_view");
31}

◆ TEST_F() [49/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
LayerWithParentHasTextureLayer   
)

Definition at line 33 of file container_layer_unittests.cc.

33 {
34 auto layer = std::make_shared<ContainerLayer>();
35
36 preroll_context()->has_texture_layer = true;
37 EXPECT_DEATH_IF_SUPPORTED(layer->Preroll(preroll_context()),
38 "!context->has_texture_layer");
39}

◆ TEST_F() [50/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
LayerWithParentHasTextureLayerNeedsResetFlag   
)

Definition at line 67 of file container_layer_unittests.cc.

67 {
68 SkPath child_path1;
69 child_path1.addRect(5.0f, 6.0f, 20.5f, 21.5f);
70 SkPath child_path2;
71 child_path2.addRect(8.0f, 2.0f, 16.5f, 14.5f);
72 DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
73 DlPaint child_paint2 = DlPaint(DlColor::kGreen());
74
75 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
76 mock_layer1->set_fake_has_texture_layer(true);
77 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
78
79 auto root = std::make_shared<ContainerLayer>();
80 auto container_layer1 = std::make_shared<ContainerLayer>();
81 auto container_layer2 = std::make_shared<ContainerLayer>();
82 root->Add(container_layer1);
83 root->Add(container_layer2);
84 container_layer1->Add(mock_layer1);
85 container_layer2->Add(mock_layer2);
86
87 EXPECT_EQ(preroll_context()->has_texture_layer, false);
88 root->Preroll(preroll_context());
89 EXPECT_EQ(preroll_context()->has_texture_layer, true);
90 // The flag for holding texture layer from parent needs to be clear
91 EXPECT_EQ(mock_layer2->parent_has_texture_layer(), false);
92}

◆ TEST_F() [51/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
Multiple   
)

Definition at line 125 of file container_layer_unittests.cc.

125 {
126 SkPath child_path1;
127 child_path1.addRect(5.0f, 6.0f, 20.5f, 21.5f);
128 SkPath child_path2;
129 child_path2.addRect(8.0f, 2.0f, 16.5f, 14.5f);
130 DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
131 DlPaint child_paint2 = DlPaint(DlColor::kGreen());
132 SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f);
133
134 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
135 mock_layer1->set_fake_has_platform_view(true);
136 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
137 auto layer = std::make_shared<ContainerLayer>();
138 layer->Add(mock_layer1);
139 layer->Add(mock_layer2);
140
141 SkRect expected_total_bounds = child_path1.getBounds();
142 expected_total_bounds.join(child_path2.getBounds());
143 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
144 layer->Preroll(preroll_context());
145 EXPECT_TRUE(preroll_context()->has_platform_view);
146 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
147 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
148 EXPECT_EQ(layer->paint_bounds(), expected_total_bounds);
149 EXPECT_EQ(layer->child_paint_bounds(), layer->paint_bounds());
150 EXPECT_TRUE(mock_layer1->needs_painting(paint_context()));
151 EXPECT_TRUE(mock_layer2->needs_painting(paint_context()));
152 EXPECT_TRUE(layer->needs_painting(paint_context()));
153 EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform);
154 EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform);
155 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
156 EXPECT_EQ(mock_layer2->parent_cull_rect(),
157 kGiantRect); // Siblings are independent
158
159 layer->Paint(display_list_paint_context());
160 DisplayListBuilder expected_builder;
161 /* (Container)layer::Paint */ {
162 /* mock_layer1::Paint */ {
163 expected_builder.DrawPath(child_path1, child_paint1);
164 }
165 /* mock_layer2::Paint */ {
166 expected_builder.DrawPath(child_path2, child_paint2);
167 }
168 }
169 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
170}

◆ TEST_F() [52/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
MultipleWithEmpty   
)

Definition at line 172 of file container_layer_unittests.cc.

172 {
173 SkPath child_path1;
174 child_path1.addRect(5.0f, 6.0f, 20.5f, 21.5f);
175 DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
176 DlPaint child_paint2 = DlPaint(DlColor::kGreen());
177 SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f);
178
179 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
180 auto mock_layer2 = std::make_shared<MockLayer>(SkPath(), child_paint2);
181 auto layer = std::make_shared<ContainerLayer>();
182 layer->Add(mock_layer1);
183 layer->Add(mock_layer2);
184
185 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
186 layer->Preroll(preroll_context());
187 EXPECT_FALSE(preroll_context()->has_platform_view);
188 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
189 EXPECT_EQ(mock_layer2->paint_bounds(), SkPath().getBounds());
190 EXPECT_EQ(layer->paint_bounds(), child_path1.getBounds());
191 EXPECT_EQ(layer->child_paint_bounds(), layer->paint_bounds());
192 EXPECT_TRUE(mock_layer1->needs_painting(paint_context()));
193 EXPECT_FALSE(mock_layer2->needs_painting(paint_context()));
194 EXPECT_TRUE(layer->needs_painting(paint_context()));
195 EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform);
196 EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform);
197 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
198 EXPECT_EQ(mock_layer2->parent_cull_rect(), kGiantRect);
199
200 layer->Paint(display_list_paint_context());
201 DisplayListBuilder expected_builder;
202 /* (Container)layer::Paint */ {
203 /* mock_layer1::Paint */ {
204 expected_builder.DrawPath(child_path1, child_paint1);
205 }
206 // mock_layer2 not drawn due to needs_painting() returning false
207 }
208 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
209}

◆ TEST_F() [53/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
NeedsSystemComposite   
)

Definition at line 211 of file container_layer_unittests.cc.

211 {
212 SkPath child_path1;
213 child_path1.addRect(5.0f, 6.0f, 20.5f, 21.5f);
214 SkPath child_path2;
215 child_path2.addRect(8.0f, 2.0f, 16.5f, 14.5f);
216 DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
217 DlPaint child_paint2 = DlPaint(DlColor::kGreen());
218 SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f);
219
220 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
221 mock_layer1->set_fake_has_platform_view(false);
222 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
223 auto layer = std::make_shared<ContainerLayer>();
224 layer->Add(mock_layer1);
225 layer->Add(mock_layer2);
226
227 SkRect expected_total_bounds = child_path1.getBounds();
228 expected_total_bounds.join(child_path2.getBounds());
229 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
230 layer->Preroll(preroll_context());
231 EXPECT_FALSE(preroll_context()->has_platform_view);
232 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
233 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
234 EXPECT_EQ(layer->paint_bounds(), expected_total_bounds);
235 EXPECT_EQ(layer->child_paint_bounds(), layer->paint_bounds());
236 EXPECT_TRUE(mock_layer1->needs_painting(paint_context()));
237 EXPECT_TRUE(mock_layer2->needs_painting(paint_context()));
238 EXPECT_TRUE(layer->needs_painting(paint_context()));
239 EXPECT_EQ(mock_layer1->parent_matrix(), initial_transform);
240 EXPECT_EQ(mock_layer2->parent_matrix(), initial_transform);
241 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
242 EXPECT_EQ(mock_layer2->parent_cull_rect(), kGiantRect);
243
244 layer->Paint(display_list_paint_context());
245 DisplayListBuilder expected_builder;
246 /* (Container)layer::Paint */ {
247 /* mock_layer1::Paint */ {
248 expected_builder.DrawPath(child_path1, child_paint1);
249 }
250 /* mock_layer2::Paint */ {
251 expected_builder.DrawPath(child_path2, child_paint2);
252 }
253 }
254 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
255}

◆ TEST_F() [54/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
RasterCacheTest   
)

Definition at line 257 of file container_layer_unittests.cc.

257 {
258 // LTRB
259 const SkPath child_path1 = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
260 const SkPath child_path2 = SkPath().addRect(21.0f, 6.0f, 25.5f, 21.5f);
261 const SkPath child_path3 = SkPath().addRect(26.0f, 6.0f, 30.5f, 21.5f);
262 const DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
263 const DlPaint child_paint2 = DlPaint(DlColor::kGreen());
264 const DlPaint paint;
265 auto cacheable_container_layer1 =
266 MockCacheableContainerLayer::CacheLayerOrChildren();
267 auto cacheable_container_layer2 =
268 MockCacheableContainerLayer::CacheLayerOnly();
269 auto cacheable_container_layer11 =
270 MockCacheableContainerLayer::CacheLayerOrChildren();
271
272 auto cacheable_layer111 =
273 std::make_shared<MockCacheableLayer>(child_path3, paint);
274 // if the frame had rendered 2 frames, we will cache the cacheable_layer21
275 // layer
276 auto cacheable_layer21 =
277 std::make_shared<MockCacheableLayer>(child_path1, paint, 2);
278
279 // clang-format off
280// layer
281// |
282// ________________________________ ________________________________
283// | | |
284// cacheable_container_layer1 mock_layer2 cacheable_container_layer2
285// | |
286// cacheable_container_layer11 cacheable_layer21
287// |
288// cacheable_layer111
289 // clang-format on
290
291 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
292 auto mock_layer2 = std::make_shared<MockLayer>(SkPath(), child_paint2);
293 auto mock_layer3 = std::make_shared<MockLayer>(child_path2, paint);
294
295 cacheable_container_layer1->Add(mock_layer1);
296 cacheable_container_layer1->Add(mock_layer3);
297
298 cacheable_container_layer1->Add(cacheable_container_layer11);
299 cacheable_container_layer11->Add(cacheable_layer111);
300
301 cacheable_container_layer2->Add(cacheable_layer21);
302 auto layer = std::make_shared<ContainerLayer>();
303 layer->Add(cacheable_container_layer1);
304 layer->Add(mock_layer2);
305 layer->Add(cacheable_container_layer2);
306
307 DisplayListBuilder cache_canvas;
308 cache_canvas.TransformReset();
309
310 // Initial Preroll for check the layer paint bounds
311 layer->Preroll(preroll_context());
312
313 EXPECT_EQ(mock_layer1->paint_bounds(),
314 SkRect::MakeLTRB(5.f, 6.f, 20.5f, 21.5f));
315 EXPECT_EQ(mock_layer3->paint_bounds(),
316 SkRect::MakeLTRB(21.0f, 6.0f, 25.5f, 21.5f));
317 EXPECT_EQ(cacheable_layer111->paint_bounds(),
318 SkRect::MakeLTRB(26.0f, 6.0f, 30.5f, 21.5f));
319 EXPECT_EQ(cacheable_container_layer1->paint_bounds(),
320 SkRect::MakeLTRB(5.f, 6.f, 30.5f, 21.5f));
321
322 // the preroll context's raster cache is nullptr
323 EXPECT_EQ(preroll_context()->raster_cached_entries->size(),
324 static_cast<unsigned long>(0));
325 {
326 // frame1
327 use_mock_raster_cache();
328 preroll_context()->raster_cache->BeginFrame();
329 layer->Preroll(preroll_context());
330 preroll_context()->raster_cache->EvictUnusedCacheEntries();
331 // Cache the cacheable entries
332 LayerTree::TryToRasterCache(*(preroll_context()->raster_cached_entries),
333 &paint_context());
334
335 EXPECT_EQ(preroll_context()->raster_cached_entries->size(),
336 static_cast<unsigned long>(5));
337
338 // cacheable_container_layer1 will cache his children
339 EXPECT_EQ(cacheable_container_layer1->raster_cache_item()->cache_state(),
340 RasterCacheItem::CacheState::kChildren);
341 EXPECT_TRUE(raster_cache()->HasEntry(
342 cacheable_container_layer1->raster_cache_item()->GetId().value(),
343 SkMatrix::I()));
344
345 EXPECT_EQ(cacheable_container_layer11->raster_cache_item()->cache_state(),
346 RasterCacheItem::CacheState::kChildren);
347 EXPECT_TRUE(raster_cache()->HasEntry(
348 cacheable_container_layer11->raster_cache_item()->GetId().value(),
349 SkMatrix::I()));
350 EXPECT_FALSE(raster_cache()->Draw(
351 cacheable_container_layer11->raster_cache_item()->GetId().value(),
352 cache_canvas, &paint));
353
354 // The cacheable_layer111 should be cached when rended 3 frames
355 EXPECT_EQ(cacheable_layer111->raster_cache_item()->cache_state(),
356 RasterCacheItem::CacheState::kNone);
357 // render count < 2 don't cache it
358 EXPECT_EQ(cacheable_container_layer2->raster_cache_item()->cache_state(),
359 RasterCacheItem::CacheState::kNone);
360 preroll_context()->raster_cache->EndFrame();
361 }
362
363 {
364 // frame2
365 // new frame the layer tree will create new PrerollContext, so in here we
366 // clear the cached_entries
367 preroll_context()->raster_cached_entries->clear();
368 preroll_context()->raster_cache->BeginFrame();
369 layer->Preroll(preroll_context());
370 preroll_context()->raster_cache->EvictUnusedCacheEntries();
371
372 // Cache the cacheable entries
373 LayerTree::TryToRasterCache(*(preroll_context()->raster_cached_entries),
374 &paint_context());
375 EXPECT_EQ(preroll_context()->raster_cached_entries->size(),
376 static_cast<unsigned long>(5));
377 EXPECT_EQ(cacheable_container_layer1->raster_cache_item()->cache_state(),
378 RasterCacheItem::CacheState::kChildren);
379 EXPECT_TRUE(raster_cache()->HasEntry(
380 cacheable_container_layer1->raster_cache_item()->GetId().value(),
381 SkMatrix::I()));
382
383 EXPECT_EQ(cacheable_container_layer11->raster_cache_item()->cache_state(),
384 RasterCacheItem::CacheState::kChildren);
385 EXPECT_TRUE(raster_cache()->HasEntry(
386 cacheable_container_layer11->raster_cache_item()->GetId().value(),
387 SkMatrix::I()));
388 EXPECT_FALSE(raster_cache()->Draw(
389 cacheable_container_layer11->raster_cache_item()->GetId().value(),
390 cache_canvas, &paint));
391
392 EXPECT_EQ(cacheable_container_layer2->raster_cache_item()->cache_state(),
393 RasterCacheItem::CacheState::kNone);
394
395 // render count == 2 cache it
396 EXPECT_EQ(cacheable_layer21->raster_cache_item()->cache_state(),
397 RasterCacheItem::CacheState::kCurrent);
398 EXPECT_TRUE(raster_cache()->HasEntry(
399 cacheable_layer21->raster_cache_item()->GetId().value(),
400 SkMatrix::I()));
401 EXPECT_TRUE(raster_cache()->Draw(
402 cacheable_layer21->raster_cache_item()->GetId().value(), cache_canvas,
403 &paint));
404 preroll_context()->raster_cache->EndFrame();
405 }
406
407 {
408 // frame3
409 // new frame the layer tree will create new PrerollContext, so in here we
410 // clear the cached_entries
411 preroll_context()->raster_cache->BeginFrame();
412 preroll_context()->raster_cached_entries->clear();
413 layer->Preroll(preroll_context());
414 preroll_context()->raster_cache->EvictUnusedCacheEntries();
415 // Cache the cacheable entries
416 LayerTree::TryToRasterCache(*(preroll_context()->raster_cached_entries),
417 &paint_context());
418 EXPECT_EQ(preroll_context()->raster_cached_entries->size(),
419 static_cast<unsigned long>(5));
420 EXPECT_EQ(cacheable_container_layer1->raster_cache_item()->cache_state(),
421 RasterCacheItem::CacheState::kCurrent);
422 EXPECT_TRUE(raster_cache()->HasEntry(
423 cacheable_container_layer1->raster_cache_item()->GetId().value(),
424 SkMatrix::I()));
425 EXPECT_TRUE(raster_cache()->HasEntry(
426 cacheable_container_layer11->raster_cache_item()->GetId().value(),
427 SkMatrix::I()));
428 EXPECT_FALSE(raster_cache()->Draw(
429 cacheable_container_layer11->raster_cache_item()->GetId().value(),
430 cache_canvas, &paint));
431 // The 3td frame, we will cache the cacheable_layer111, but his ancestor has
432 // been cached, so cacheable_layer111 Draw is false
433 EXPECT_TRUE(raster_cache()->HasEntry(
434 cacheable_layer111->raster_cache_item()->GetId().value(),
435 SkMatrix::I()));
436 EXPECT_FALSE(raster_cache()->Draw(
437 cacheable_layer111->raster_cache_item()->GetId().value(), cache_canvas,
438 &paint));
439
440 // The third frame, we will cache the cacheable_container_layer2
441 EXPECT_EQ(cacheable_container_layer2->raster_cache_item()->cache_state(),
442 RasterCacheItem::CacheState::kCurrent);
443
444 EXPECT_TRUE(raster_cache()->HasEntry(
445 cacheable_layer21->raster_cache_item()->GetId().value(),
446 SkMatrix::I()));
447 preroll_context()->raster_cache->EndFrame();
448 }
449
450 {
451 preroll_context()->raster_cache->BeginFrame();
452 // frame4
453 preroll_context()->raster_cached_entries->clear();
454 layer->Preroll(preroll_context());
455 preroll_context()->raster_cache->EvictUnusedCacheEntries();
456 LayerTree::TryToRasterCache(*(preroll_context()->raster_cached_entries),
457 &paint_context());
458 preroll_context()->raster_cache->EndFrame();
459
460 // frame5
461 preroll_context()->raster_cache->BeginFrame();
462 preroll_context()->raster_cached_entries->clear();
463 layer->Preroll(preroll_context());
464 LayerTree::TryToRasterCache(*(preroll_context()->raster_cached_entries),
465 &paint_context());
466 preroll_context()->raster_cache->EndFrame();
467
468 // frame6
469 preroll_context()->raster_cache->BeginFrame();
470 preroll_context()->raster_cached_entries->clear();
471 layer->Preroll(preroll_context());
472 LayerTree::TryToRasterCache(*(preroll_context()->raster_cached_entries),
473 &paint_context());
474 preroll_context()->raster_cache->EndFrame();
475 }
476}
void TransformReset() override

◆ TEST_F() [55/876]

flutter::testing::TEST_F ( ContainerLayerTest  ,
Simple   
)

Definition at line 94 of file container_layer_unittests.cc.

94 {
95 SkPath child_path;
96 child_path.addRect(5.0f, 6.0f, 20.5f, 21.5f);
97 DlPaint child_paint = DlPaint(DlColor::kGreen());
98 SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f);
99
100 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
101 auto layer = std::make_shared<ContainerLayer>();
102 layer->Add(mock_layer);
103
104 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
105 layer->Preroll(preroll_context());
106 EXPECT_FALSE(preroll_context()->has_platform_view);
107 EXPECT_EQ(mock_layer->paint_bounds(), child_path.getBounds());
108 EXPECT_EQ(layer->paint_bounds(), child_path.getBounds());
109 EXPECT_EQ(layer->child_paint_bounds(), layer->paint_bounds());
110 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
111 EXPECT_TRUE(layer->needs_painting(paint_context()));
112 EXPECT_EQ(mock_layer->parent_matrix(), initial_transform);
113 EXPECT_EQ(mock_layer->parent_cull_rect(), kGiantRect);
114
115 layer->Paint(display_list_paint_context());
116 DisplayListBuilder expected_builder;
117 /* (Container)layer::Paint */ {
118 /* mock_layer::Paint */ {
119 expected_builder.DrawPath(child_path, child_paint);
120 }
121 }
122 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
123}

◆ TEST_F() [56/876]

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

Definition at line 97 of file cursor_handler_unittests.cc.

97 {
98 UseEngineWithView();
99
100 TestBinaryMessenger messenger;
101 CursorHandler cursor_handler(&messenger, engine());
102
103 EXPECT_CALL(*window(), UpdateFlutterCursor("click")).Times(1);
104
105 bool success = false;
106 MethodResultFunctions<> result_handler(
107 [&success](const EncodableValue* result) {
108 success = true;
109 EXPECT_EQ(result, nullptr);
110 },
111 nullptr, nullptr);
112
113 SimulateCursorMessage(&messenger, kActivateSystemCursorMethod,
114 std::make_unique<EncodableValue>(EncodableMap{
115 {EncodableValue("device"), EncodableValue(0)},
116 {EncodableValue("kind"), EncodableValue("click")},
117 }),
118 &result_handler);
119
120 EXPECT_TRUE(success);
121}
static NSString *const kActivateSystemCursorMethod
std::map< EncodableValue, EncodableValue > EncodableMap

◆ TEST_F() [57/876]

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

Definition at line 123 of file cursor_handler_unittests.cc.

123 {
124 UseHeadlessEngine();
125
126 TestBinaryMessenger messenger;
127 CursorHandler cursor_handler(&messenger, engine());
128
129 bool error = false;
130 MethodResultFunctions<> result_handler(
131 nullptr,
132 [&error](const std::string& error_code, const std::string& error_message,
133 const EncodableValue* value) {
134 error = true;
135 EXPECT_EQ(error_message,
136 "Cursor is not available in Windows headless mode");
137 },
138 nullptr);
139
140 SimulateCursorMessage(&messenger, kActivateSystemCursorMethod,
141 std::make_unique<EncodableValue>(EncodableMap{
142 {EncodableValue("device"), EncodableValue(0)},
143 {EncodableValue("kind"), EncodableValue("click")},
144 }),
145 &result_handler);
146
148}

◆ TEST_F() [58/876]

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

Definition at line 150 of file cursor_handler_unittests.cc.

150 {
151 UseEngineWithView();
152
153 TestBinaryMessenger messenger;
154 CursorHandler cursor_handler(&messenger, engine());
155
156 // Create a 4x4 raw BGRA test cursor buffer.
157 std::vector<uint8_t> buffer(4 * 4 * 4, 0);
158
159 bool success = false;
160 MethodResultFunctions<> result_handler(
161 [&success](const EncodableValue* result) {
162 success = true;
163 EXPECT_EQ(std::get<std::string>(*result), "hello");
164 },
165 nullptr, nullptr);
166
167 SimulateCursorMessage(&messenger, kCreateCustomCursorMethod,
168 std::make_unique<EncodableValue>(EncodableMap{
169 {EncodableValue("name"), EncodableValue("hello")},
170 {EncodableValue("buffer"), EncodableValue(buffer)},
171 {EncodableValue("width"), EncodableValue(4)},
172 {EncodableValue("height"), EncodableValue(4)},
173 {EncodableValue("hotX"), EncodableValue(0.0)},
174 {EncodableValue("hotY"), EncodableValue(0.0)},
175 }),
176 &result_handler);
177
178 EXPECT_TRUE(success);
179}
static constexpr char kCreateCustomCursorMethod[]

◆ TEST_F() [59/876]

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

Definition at line 291 of file cursor_handler_unittests.cc.

291 {
292 UseEngineWithView();
293
294 TestBinaryMessenger messenger;
295 CursorHandler cursor_handler(&messenger, engine());
296
297 // Create a 4x4 raw BGRA test cursor buffer.
298 std::vector<uint8_t> buffer(4 * 4 * 4, 0);
299
300 bool success = false;
301 MethodResultFunctions<> create_result_handler(nullptr, nullptr, nullptr);
302 MethodResultFunctions<> delete_result_handler(
303 [&success](const EncodableValue* result) {
304 success = true;
305 EXPECT_EQ(result, nullptr);
306 },
307 nullptr, nullptr);
308
309 SimulateCursorMessage(&messenger, kCreateCustomCursorMethod,
310 std::make_unique<EncodableValue>(EncodableMap{
311 {EncodableValue("name"), EncodableValue("hello")},
312 {EncodableValue("buffer"), EncodableValue(buffer)},
313 {EncodableValue("width"), EncodableValue(4)},
314 {EncodableValue("height"), EncodableValue(4)},
315 {EncodableValue("hotX"), EncodableValue(0.0)},
316 {EncodableValue("hotY"), EncodableValue(0.0)},
317 }),
318 &create_result_handler);
319
320 SimulateCursorMessage(&messenger, kDeleteCustomCursorMethod,
321 std::make_unique<EncodableValue>(EncodableMap{
322 {EncodableValue("name"), EncodableValue("hello")},
323 }),
324 &delete_result_handler);
325
326 EXPECT_TRUE(success);
327}
static constexpr char kDeleteCustomCursorMethod[]

◆ TEST_F() [60/876]

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

Definition at line 329 of file cursor_handler_unittests.cc.

329 {
330 UseEngineWithView();
331
332 TestBinaryMessenger messenger;
333 CursorHandler cursor_handler(&messenger, engine());
334
335 bool success = false;
336 MethodResultFunctions<> result_handler(
337 [&success](const EncodableValue* result) {
338 success = true;
339 EXPECT_EQ(result, nullptr);
340 },
341 nullptr, nullptr);
342
343 SimulateCursorMessage(&messenger, kDeleteCustomCursorMethod,
344 std::make_unique<EncodableValue>(EncodableMap{
345 {EncodableValue("name"), EncodableValue("fake")},
346 }),
347 &result_handler);
348
349 EXPECT_TRUE(success);
350}

◆ TEST_F() [61/876]

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

Definition at line 181 of file cursor_handler_unittests.cc.

181 {
182 UseEngineWithView();
183
184 TestBinaryMessenger messenger;
185 CursorHandler cursor_handler(&messenger, engine());
186
187 // Create a 4x4 raw BGRA test cursor buffer.
188 std::vector<uint8_t> buffer(4 * 4 * 4, 0);
189
190 bool success = false;
191 MethodResultFunctions<> create_result_handler(nullptr, nullptr, nullptr);
192 MethodResultFunctions<> set_result_handler(
193 [&success](const EncodableValue* result) {
194 success = true;
195 EXPECT_EQ(result, nullptr);
196 },
197 nullptr, nullptr);
198
199 EXPECT_CALL(*window(), SetFlutterCursor(/*cursor=*/NotNull())).Times(1);
200
201 SimulateCursorMessage(&messenger, kCreateCustomCursorMethod,
202 std::make_unique<EncodableValue>(EncodableMap{
203 {EncodableValue("name"), EncodableValue("hello")},
204 {EncodableValue("buffer"), EncodableValue(buffer)},
205 {EncodableValue("width"), EncodableValue(4)},
206 {EncodableValue("height"), EncodableValue(4)},
207 {EncodableValue("hotX"), EncodableValue(0.0)},
208 {EncodableValue("hotY"), EncodableValue(0.0)},
209 }),
210 &create_result_handler);
211
212 SimulateCursorMessage(&messenger, kSetCustomCursorMethod,
213 std::make_unique<EncodableValue>(EncodableMap{
214 {EncodableValue("name"), EncodableValue("hello")},
215 }),
216 &set_result_handler);
217
218 EXPECT_TRUE(success);
219}
static constexpr char kSetCustomCursorMethod[]

◆ TEST_F() [62/876]

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

Definition at line 221 of file cursor_handler_unittests.cc.

221 {
222 UseHeadlessEngine();
223
224 TestBinaryMessenger messenger;
225 CursorHandler cursor_handler(&messenger, engine());
226
227 // Create a 4x4 raw BGRA test cursor buffer.
228 std::vector<uint8_t> buffer(4 * 4 * 4, 0);
229
230 bool error = false;
231 MethodResultFunctions<> create_result_handler(nullptr, nullptr, nullptr);
232 MethodResultFunctions<> set_result_handler(
233 nullptr,
234 [&error](const std::string& error_code, const std::string& error_message,
235 const EncodableValue* value) {
236 error = true;
237 EXPECT_EQ(error_message,
238 "Cursor is not available in Windows headless mode");
239 },
240 nullptr);
241
242 SimulateCursorMessage(&messenger, kCreateCustomCursorMethod,
243 std::make_unique<EncodableValue>(EncodableMap{
244 {EncodableValue("name"), EncodableValue("hello")},
245 {EncodableValue("buffer"), EncodableValue(buffer)},
246 {EncodableValue("width"), EncodableValue(4)},
247 {EncodableValue("height"), EncodableValue(4)},
248 {EncodableValue("hotX"), EncodableValue(0.0)},
249 {EncodableValue("hotY"), EncodableValue(0.0)},
250 }),
251 &create_result_handler);
252
253 SimulateCursorMessage(&messenger, kSetCustomCursorMethod,
254 std::make_unique<EncodableValue>(EncodableMap{
255 {EncodableValue("name"), EncodableValue("hello")},
256 }),
257 &set_result_handler);
258
260}

◆ TEST_F() [63/876]

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

Definition at line 262 of file cursor_handler_unittests.cc.

262 {
263 UseEngineWithView();
264
265 TestBinaryMessenger messenger;
266 CursorHandler cursor_handler(&messenger, engine());
267
268 bool error = false;
269 MethodResultFunctions<> result_handler(
270 nullptr,
271 [&error](const std::string& error_code, const std::string& error_message,
272 const EncodableValue* value) {
273 error = true;
274 EXPECT_EQ(
275 error_message,
276 "The custom cursor identified by the argument key cannot be found");
277 },
278 nullptr);
279
280 EXPECT_CALL(*window(), SetFlutterCursor).Times(0);
281
282 SimulateCursorMessage(&messenger, kSetCustomCursorMethod,
283 std::make_unique<EncodableValue>(EncodableMap{
284 {EncodableValue("name"), EncodableValue("hello")},
285 }),
286 &result_handler);
287
289}

◆ TEST_F() [64/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
CanCreateServiceIsolate   
)

Definition at line 400 of file dart_isolate_unittests.cc.

400 {
401#if (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_DEBUG) && \
402 (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_PROFILE)
403 GTEST_SKIP();
404#endif
405 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
406 fml::AutoResetWaitableEvent service_isolate_latch;
407 auto settings = CreateSettingsForFixture();
408 settings.enable_vm_service = true;
409 settings.vm_service_port = 0;
410 settings.vm_service_host = "127.0.0.1";
411 settings.enable_service_port_fallback = true;
412 settings.service_isolate_create_callback = [&service_isolate_latch]() {
413 service_isolate_latch.Signal();
414 };
415 auto vm_ref = DartVMRef::Create(settings);
416 ASSERT_TRUE(vm_ref);
417 auto vm_data = vm_ref.GetVMData();
418 ASSERT_TRUE(vm_data);
419 TaskRunners task_runners(GetCurrentTestName(), //
420 GetCurrentTaskRunner(), //
421 GetCurrentTaskRunner(), //
422 GetCurrentTaskRunner(), //
423 GetCurrentTaskRunner() //
424 );
425
426 auto isolate_configuration =
427 IsolateConfiguration::InferFromSettings(settings);
428
429 UIDartState::Context context(task_runners);
430 context.advisory_script_uri = "main.dart";
431 context.advisory_script_entrypoint = "main";
432 auto weak_isolate = DartIsolate::CreateRunningRootIsolate(
433 vm_data->GetSettings(), // settings
434 vm_data->GetIsolateSnapshot(), // isolate snapshot
435 nullptr, // platform configuration
436 DartIsolate::Flags{}, // flags
437 nullptr, // root_isolate_create_callback
438 settings.isolate_create_callback, // isolate create callback
439 settings.isolate_shutdown_callback, // isolate shutdown callback
440 "main", // dart entrypoint
441 std::nullopt, // dart entrypoint library
442 {}, // dart entrypoint arguments
443 std::move(isolate_configuration), // isolate configuration
444 context // engine context
445 );
446
447 auto root_isolate = weak_isolate.lock();
448 ASSERT_TRUE(root_isolate);
449 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
450 service_isolate_latch.Wait();
451 ASSERT_TRUE(root_isolate->Shutdown());
452}

◆ TEST_F() [65/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
CanReceiveArguments   
)

Definition at line 374 of file dart_isolate_unittests.cc.

374 {
375 AddNativeCallback("NotifyNative",
379 Signal();
380 })));
381
382 const auto settings = CreateSettingsForFixture();
383 auto vm_ref = DartVMRef::Create(settings);
384 auto thread = CreateNewThread();
385 TaskRunners task_runners(GetCurrentTestName(), //
386 thread, //
387 thread, //
388 thread, //
389 thread //
390 );
391 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners,
392 "testCanReceiveArguments", {"arg1"},
393 GetDefaultKernelFilePath());
394 ASSERT_TRUE(isolate);
395 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
396
397 Wait();
398}
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
struct _Dart_NativeArguments * Dart_NativeArguments
Definition dart_api.h:3010
#define CREATE_NATIVE_ENTRY(native_entry)

◆ TEST_F() [66/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
CanRegisterNativeCallback   
)

Definition at line 252 of file dart_isolate_unittests.cc.

252 {
253 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
254 AddNativeCallback(
255 "NotifyNative",
256 CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) { Signal(); })));
257 const auto settings = CreateSettingsForFixture();
258 auto vm_ref = DartVMRef::Create(settings);
259 auto thread = CreateNewThread();
260 TaskRunners task_runners(GetCurrentTestName(), //
261 thread, //
262 thread, //
263 thread, //
264 thread //
265 );
266 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners,
267 "canRegisterNativeCallback", {},
268 GetDefaultKernelFilePath());
269 ASSERT_TRUE(isolate);
270 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
271 Wait();
272}

◆ TEST_F() [67/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
CanRunDartCodeCodeSynchronously   
)

Definition at line 158 of file dart_isolate_unittests.cc.

158 {
159 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
160 const auto settings = CreateSettingsForFixture();
161 auto vm_ref = DartVMRef::Create(settings);
162 TaskRunners task_runners(GetCurrentTestName(), //
163 GetCurrentTaskRunner(), //
164 GetCurrentTaskRunner(), //
165 GetCurrentTaskRunner(), //
166 GetCurrentTaskRunner() //
167 );
168 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
169 {}, GetDefaultKernelFilePath());
170
171 ASSERT_TRUE(isolate);
172 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
173 ASSERT_TRUE(isolate->RunInIsolateScope([]() -> bool {
174 if (tonic::CheckAndHandleError(::Dart_Invoke(
175 Dart_RootLibrary(), tonic::ToDart("sayHi"), 0, nullptr))) {
176 return false;
177 }
178 return true;
179 }));
180}
std::unique_ptr< AutoIsolateShutdown > RunDartCodeInIsolate(DartVMRef &vm_ref, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::shared_ptr< VolatilePathTracker > volatile_path_tracker, std::unique_ptr< PlatformConfiguration > platform_configuration)

◆ TEST_F() [68/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
DartPluginRegistrantFromBackgroundIsolate   
)

Definition at line 101 of file dart_plugin_registrant_unittests.cc.

101 {
102 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
103
104 std::vector<std::string> messages;
106
107 AddNativeCallback(
108 "PassMessage",
109 CREATE_NATIVE_ENTRY(([&latch, &messages](Dart_NativeArguments args) {
112 messages.push_back(message);
113 latch.Signal();
114 })));
115
116 auto settings = CreateSettingsForFixture();
117 auto did_throw_exception = false;
118 settings.unhandled_exception_callback = [&](const std::string& error,
119 const std::string& stack_trace) {
120 did_throw_exception = true;
121 return true;
122 };
123
124 auto vm_ref = DartVMRef::Create(settings);
125 auto thread = CreateNewThread();
126 TaskRunners task_runners(GetCurrentTestName(), //
127 thread, //
128 thread, //
129 thread, //
130 thread //
131 );
132
133 auto kernel_path =
134 fml::paths::JoinPaths({GetFixturesPath(), kKernelFileName});
135 auto isolate = RunDartCodeInIsolate(
136 vm_ref, settings, task_runners,
137 "callDartPluginRegistrantFromBackgroundIsolate", {}, kernel_path);
138
139 ASSERT_TRUE(isolate);
140 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
141
142 latch.Wait();
143
144 ASSERT_EQ(messages.size(), 1u);
145 ASSERT_EQ(messages[0],
146 "_PluginRegistrant.register() was called on background isolate");
147}

◆ TEST_F() [69/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
DartPluginRegistrantIsCalled   
)

Definition at line 562 of file dart_isolate_unittests.cc.

562 {
563 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
564
565 std::vector<std::string> messages;
567
568 AddNativeCallback(
569 "PassMessage",
570 CREATE_NATIVE_ENTRY(([&latch, &messages](Dart_NativeArguments args) {
573 messages.push_back(message);
574 latch.Signal();
575 })));
576
577 const auto settings = CreateSettingsForFixture();
578 auto vm_ref = DartVMRef::Create(settings);
579 auto thread = CreateNewThread();
580 TaskRunners task_runners(GetCurrentTestName(), //
581 thread, //
582 thread, //
583 thread, //
584 thread //
585 );
586 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners,
587 "mainForPluginRegistrantTest", {},
588 GetDefaultKernelFilePath());
589 ASSERT_TRUE(isolate);
590 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
591 latch.Wait();
592 ASSERT_EQ(messages.size(), 1u);
593 ASSERT_EQ(messages[0], "_PluginRegistrant.register() was called");
594}

◆ TEST_F() [70/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
DartPluginRegistrantIsNotPresent   
)

Definition at line 28 of file no_dart_plugin_registrant_unittests.cc.

28 {
29 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
30
31 std::vector<std::string> messages;
33
34 AddNativeCallback(
35 "PassMessage",
36 CREATE_NATIVE_ENTRY(([&latch, &messages](Dart_NativeArguments args) {
39 messages.push_back(message);
40 latch.Signal();
41 })));
42
43 auto settings = CreateSettingsForFixture();
44 auto did_throw_exception = false;
45 settings.unhandled_exception_callback = [&](const std::string& error,
46 const std::string& stack_trace) {
47 did_throw_exception = true;
48 return true;
49 };
50
51 auto vm_ref = DartVMRef::Create(settings);
52 auto thread = CreateNewThread();
53 TaskRunners task_runners(GetCurrentTestName(), //
54 thread, //
55 thread, //
56 thread, //
57 thread //
58 );
59
60 auto kernel_path =
61 fml::paths::JoinPaths({GetFixturesPath(), kKernelFileName});
62 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
63 {}, kernel_path);
64
65 ASSERT_TRUE(isolate);
66 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
67
68 latch.Wait();
69
70 ASSERT_EQ(messages.size(), 1u);
71 ASSERT_EQ(messages[0], "main() was called");
72 ASSERT_FALSE(did_throw_exception);
73}

◆ TEST_F() [71/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
DartPluginRegistrantIsPresent   
)

Definition at line 54 of file dart_plugin_registrant_unittests.cc.

54 {
55 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
56
57 std::vector<std::string> messages;
59
60 AddNativeCallback(
61 "PassMessage",
62 CREATE_NATIVE_ENTRY(([&latch, &messages](Dart_NativeArguments args) {
65 messages.push_back(message);
66 latch.Signal();
67 })));
68
69 auto settings = CreateSettingsForFixture();
70 auto did_throw_exception = false;
71 settings.unhandled_exception_callback = [&](const std::string& error,
72 const std::string& stack_trace) {
73 did_throw_exception = true;
74 return true;
75 };
76
77 auto vm_ref = DartVMRef::Create(settings);
78 auto thread = CreateNewThread();
79 TaskRunners task_runners(GetCurrentTestName(), //
80 thread, //
81 thread, //
82 thread, //
83 thread //
84 );
85
86 auto kernel_path =
87 fml::paths::JoinPaths({GetFixturesPath(), kKernelFileName});
88 auto isolate =
89 RunDartCodeInIsolate(vm_ref, settings, task_runners,
90 "mainForPluginRegistrantTest", {}, kernel_path);
91
92 ASSERT_TRUE(isolate);
93 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
94
95 latch.Wait();
96
97 ASSERT_EQ(messages.size(), 1u);
98 ASSERT_EQ(messages[0], "_PluginRegistrant.register() was called");
99}

◆ TEST_F() [72/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
DartPluginRegistrantNotFromBackgroundIsolate   
)

Definition at line 149 of file dart_plugin_registrant_unittests.cc.

149 {
150 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
151
152 std::vector<std::string> messages;
154
155 AddNativeCallback(
156 "PassMessage",
157 CREATE_NATIVE_ENTRY(([&latch, &messages](Dart_NativeArguments args) {
160 messages.push_back(message);
161 latch.Signal();
162 })));
163
164 auto settings = CreateSettingsForFixture();
165 auto did_throw_exception = false;
166 settings.unhandled_exception_callback = [&](const std::string& error,
167 const std::string& stack_trace) {
168 did_throw_exception = true;
169 return true;
170 };
171
172 auto vm_ref = DartVMRef::Create(settings);
173 auto thread = CreateNewThread();
174 TaskRunners task_runners(GetCurrentTestName(), //
175 thread, //
176 thread, //
177 thread, //
178 thread //
179 );
180
181 auto kernel_path =
182 fml::paths::JoinPaths({GetFixturesPath(), kKernelFileName});
183 auto isolate = RunDartCodeInIsolate(
184 vm_ref, settings, task_runners,
185 "dontCallDartPluginRegistrantFromBackgroundIsolate", {}, kernel_path);
186
187 ASSERT_TRUE(isolate);
188 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
189
190 latch.Wait();
191
192 ASSERT_EQ(messages.size(), 1u);
193 ASSERT_EQ(
194 messages[0],
195 "_PluginRegistrant.register() was not called on background isolate");
196}

◆ TEST_F() [73/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
DartPluginRegistrantWhenRegisteringBackgroundIsolate   
)

Definition at line 198 of file dart_plugin_registrant_unittests.cc.

198 {
199 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
200
201 std::vector<std::string> messages;
203
204 AddNativeCallback(
205 "PassMessage",
206 CREATE_NATIVE_ENTRY(([&latch, &messages](Dart_NativeArguments args) {
209 messages.push_back(message);
210 latch.Signal();
211 })));
212
213 auto settings = CreateSettingsForFixture();
214 auto did_throw_exception = false;
215 settings.unhandled_exception_callback = [&](const std::string& error,
216 const std::string& stack_trace) {
217 did_throw_exception = true;
218 return true;
219 };
220
221 auto vm_ref = DartVMRef::Create(settings);
222 auto thread = CreateNewThread();
223 TaskRunners task_runners(GetCurrentTestName(), //
224 thread, //
225 thread, //
226 thread, //
227 thread //
228 );
229
230 auto kernel_path =
231 fml::paths::JoinPaths({GetFixturesPath(), kKernelFileName});
232 auto isolate = RunDartCodeInIsolate(
233 vm_ref, settings, task_runners,
234 "registerBackgroundIsolateCallsDartPluginRegistrant", {}, kernel_path);
235
236 ASSERT_TRUE(isolate);
237 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
238
239 latch.Wait();
240
241 ASSERT_EQ(messages.size(), 1u);
242 ASSERT_EQ(messages[0],
243 "_PluginRegistrant.register() was called on background isolate");
244}

◆ TEST_F() [74/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
ImpellerFlagIsCorrectWhenFalse   
)

Definition at line 217 of file dart_isolate_unittests.cc.

217 {
218 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
219 auto settings = CreateSettingsForFixture();
220 settings.enable_impeller = false;
221 auto vm_ref = DartVMRef::Create(settings);
222 TaskRunners task_runners(GetCurrentTestName(), //
223 GetCurrentTaskRunner(), //
224 GetCurrentTaskRunner(), //
225 GetCurrentTaskRunner(), //
226 GetCurrentTaskRunner() //
227 );
228 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
229 {}, GetDefaultKernelFilePath());
230
231 ASSERT_TRUE(isolate);
232 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
233 ASSERT_TRUE(isolate->RunInIsolateScope([settings]() -> bool {
234 Dart_Handle dart_ui = ::Dart_LookupLibrary(tonic::ToDart("dart:ui"));
235 if (tonic::CheckAndHandleError(dart_ui)) {
236 return false;
237 }
238 Dart_Handle impeller_enabled =
239 ::Dart_GetField(dart_ui, tonic::ToDart("_impellerEnabled"));
240 if (tonic::CheckAndHandleError(impeller_enabled)) {
241 return false;
242 }
243 bool result;
245 Dart_BooleanValue(impeller_enabled, &result))) {
246 return false;
247 }
248 return result == settings.enable_impeller;
249 }));
250}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name)
DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, bool *value)
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33

◆ TEST_F() [75/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
ImpellerFlagIsCorrectWhenTrue   
)

Definition at line 182 of file dart_isolate_unittests.cc.

182 {
183 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
184 auto settings = CreateSettingsForFixture();
185 settings.enable_impeller = true;
186 auto vm_ref = DartVMRef::Create(settings);
187 TaskRunners task_runners(GetCurrentTestName(), //
188 GetCurrentTaskRunner(), //
189 GetCurrentTaskRunner(), //
190 GetCurrentTaskRunner(), //
191 GetCurrentTaskRunner() //
192 );
193 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
194 {}, GetDefaultKernelFilePath());
195
196 ASSERT_TRUE(isolate);
197 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
198 ASSERT_TRUE(isolate->RunInIsolateScope([settings]() -> bool {
199 Dart_Handle dart_ui = ::Dart_LookupLibrary(tonic::ToDart("dart:ui"));
200 if (tonic::CheckAndHandleError(dart_ui)) {
201 return false;
202 }
203 Dart_Handle impeller_enabled =
204 ::Dart_GetField(dart_ui, tonic::ToDart("_impellerEnabled"));
205 if (tonic::CheckAndHandleError(impeller_enabled)) {
206 return false;
207 }
208 bool result;
210 Dart_BooleanValue(impeller_enabled, &result))) {
211 return false;
212 }
213 return result == settings.enable_impeller;
214 }));
215}

◆ TEST_F() [76/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
InvalidLoadingUnitFails   
)

Definition at line 509 of file dart_isolate_unittests.cc.

509 {
510 if (!DartVM::IsRunningPrecompiledCode()) {
511 FML_LOG(INFO) << "Split AOT does not work in JIT mode";
512 return;
513 }
514 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
515 auto settings = CreateSettingsForFixture();
516 auto vm_ref = DartVMRef::Create(settings);
517 ASSERT_TRUE(vm_ref);
518 auto vm_data = vm_ref.GetVMData();
519 ASSERT_TRUE(vm_data);
520 TaskRunners task_runners(GetCurrentTestName(), //
521 GetCurrentTaskRunner(), //
522 GetCurrentTaskRunner(), //
523 GetCurrentTaskRunner(), //
524 GetCurrentTaskRunner() //
525 );
526 auto isolate_configuration =
527 IsolateConfiguration::InferFromSettings(settings);
528
529 UIDartState::Context context(task_runners);
530 context.advisory_script_uri = "main.dart";
531 context.advisory_script_entrypoint = "main";
532 auto weak_isolate = DartIsolate::CreateRunningRootIsolate(
533 vm_data->GetSettings(), // settings
534 vm_data->GetIsolateSnapshot(), // isolate snapshot
535 nullptr, // platform configuration
536 DartIsolate::Flags{}, // flags
537 nullptr, // root_isolate_create_callback
538 settings.isolate_create_callback, // isolate create callback
539 settings.isolate_shutdown_callback, // isolate shutdown callback
540 "main", // dart entrypoint
541 std::nullopt, // dart entrypoint library
542 {}, // dart entrypoint arguments
543 std::move(isolate_configuration), // isolate configuration
544 context // engine context
545 );
546
547 auto root_isolate = weak_isolate.lock();
548 ASSERT_TRUE(root_isolate);
549 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
550
551 auto isolate_data = std::make_unique<const fml::NonOwnedMapping>(
552 split_aot_symbols_.vm_isolate_data, 0);
553 auto isolate_instructions = std::make_unique<const fml::NonOwnedMapping>(
554 split_aot_symbols_.vm_isolate_instrs, 0);
555
556 // Invalid loading unit should fail gracefully with error message.
557 ASSERT_FALSE(root_isolate->LoadLoadingUnit(3, std::move(isolate_data),
558 std::move(isolate_instructions)));
559 ASSERT_TRUE(root_isolate->Shutdown());
560}

◆ TEST_F() [77/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
IsolateCanLoadAndRunDartCode   
)

Definition at line 126 of file dart_isolate_unittests.cc.

126 {
127 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
128 const auto settings = CreateSettingsForFixture();
129 auto vm_ref = DartVMRef::Create(settings);
130 TaskRunners task_runners(GetCurrentTestName(), //
131 GetCurrentTaskRunner(), //
132 GetCurrentTaskRunner(), //
133 GetCurrentTaskRunner(), //
134 GetCurrentTaskRunner() //
135 );
136 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
137 {}, GetDefaultKernelFilePath());
138 ASSERT_TRUE(isolate);
139 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
140}

◆ TEST_F() [78/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
IsolateCannotLoadAndRunUnknownDartEntrypoint   
)

Definition at line 142 of file dart_isolate_unittests.cc.

142 {
143 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
144 const auto settings = CreateSettingsForFixture();
145 auto vm_ref = DartVMRef::Create(settings);
146 TaskRunners task_runners(GetCurrentTestName(), //
147 GetCurrentTaskRunner(), //
148 GetCurrentTaskRunner(), //
149 GetCurrentTaskRunner(), //
150 GetCurrentTaskRunner() //
151 );
152 auto isolate =
153 RunDartCodeInIsolate(vm_ref, settings, task_runners, "thisShouldNotExist",
154 {}, GetDefaultKernelFilePath());
155 ASSERT_FALSE(isolate);
156}

◆ TEST_F() [79/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
IsolateCreateCallbacksTakeInstanceSettingsInsteadOfVMSettings   
)

Definition at line 481 of file dart_isolate_unittests.cc.

482 {
483 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
484 auto vm_settings = CreateSettingsForFixture();
485 auto vm_ref = DartVMRef::Create(vm_settings);
486 auto instance_settings = vm_settings;
487 size_t create_callback_count = 0u;
488 instance_settings.root_isolate_create_callback =
489 [&create_callback_count](const auto& isolate) {
490 ASSERT_EQ(isolate.GetPhase(), DartIsolate::Phase::Ready);
491 create_callback_count++;
492 ASSERT_NE(::Dart_CurrentIsolate(), nullptr);
493 };
494 TaskRunners task_runners(GetCurrentTestName(), //
495 GetCurrentTaskRunner(), //
496 GetCurrentTaskRunner(), //
497 GetCurrentTaskRunner(), //
498 GetCurrentTaskRunner() //
499 );
500 {
501 auto isolate = RunDartCodeInIsolate(vm_ref, instance_settings, task_runners,
502 "main", {}, GetDefaultKernelFilePath());
503 ASSERT_TRUE(isolate);
504 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
505 }
506 ASSERT_EQ(create_callback_count, 1u);
507}
DART_EXPORT Dart_Isolate Dart_CurrentIsolate(void)

◆ TEST_F() [80/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
IsolateShutdownCallbackIsInIsolateScope   
)

Definition at line 81 of file dart_isolate_unittests.cc.

81 {
82 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
83 auto settings = CreateSettingsForFixture();
84 auto vm_ref = DartVMRef::Create(settings);
85 ASSERT_TRUE(vm_ref);
86 auto vm_data = vm_ref.GetVMData();
87 ASSERT_TRUE(vm_data);
88 TaskRunners task_runners(GetCurrentTestName(), //
89 GetCurrentTaskRunner(), //
90 GetCurrentTaskRunner(), //
91 GetCurrentTaskRunner(), //
92 GetCurrentTaskRunner() //
93 );
94 auto isolate_configuration =
95 IsolateConfiguration::InferFromSettings(settings);
96
97 UIDartState::Context context(task_runners);
98 context.advisory_script_uri = "main.dart";
99 context.advisory_script_entrypoint = "main";
100 auto weak_isolate = DartIsolate::CreateRunningRootIsolate(
101 vm_data->GetSettings(), // settings
102 vm_data->GetIsolateSnapshot(), // isolate snapshot
103 nullptr, // platform configuration
104 DartIsolate::Flags{}, // flags
105 nullptr, // root_isolate_create_callback
106 settings.isolate_create_callback, // isolate create callback
107 settings.isolate_shutdown_callback, // isolate shutdown callback
108 "main", // dart entrypoint
109 std::nullopt, // dart entrypoint library
110 {}, // dart entrypoint arguments
111 std::move(isolate_configuration), // isolate configuration
112 context // engine context
113 );
114 auto root_isolate = weak_isolate.lock();
115 ASSERT_TRUE(root_isolate);
116 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
117 size_t destruction_callback_count = 0;
118 root_isolate->AddIsolateShutdownCallback([&destruction_callback_count]() {
119 ASSERT_NE(Dart_CurrentIsolate(), nullptr);
120 destruction_callback_count++;
121 });
122 ASSERT_TRUE(root_isolate->Shutdown());
123 ASSERT_EQ(destruction_callback_count, 1u);
124}

◆ TEST_F() [81/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
PlatformIsolateCreationAfterManagerShutdown   
)

Definition at line 971 of file dart_isolate_unittests.cc.

971 {
972 AddNativeCallback("PassMessage",
975
976 FakePlatformConfigurationClient client;
977 auto platform_configuration =
978 std::make_unique<PlatformConfiguration>(&client);
979
980 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
981 auto settings = CreateSettingsForFixture();
982 auto vm_ref = DartVMRef::Create(settings);
983 ASSERT_TRUE(vm_ref);
984 auto vm_data = vm_ref.GetVMData();
985 ASSERT_TRUE(vm_data);
986
987 auto platform_thread = CreateNewThread();
988 auto ui_thread = CreateNewThread();
989 TaskRunners task_runners(GetCurrentTestName(), // label
990 platform_thread, // platform
991 ui_thread, // raster
992 ui_thread, // ui
993 ui_thread // io
994 );
995 auto isolate =
996 RunDartCodeInIsolate(vm_ref, settings, task_runners, "emptyMain", {},
997 GetDefaultKernelFilePath(), {}, nullptr,
998 std::move(platform_configuration));
999 ASSERT_TRUE(isolate);
1000 auto root_isolate = isolate->get();
1001 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
1002
1003 // Shut down the manager on the platform thread.
1004 fml::AutoResetWaitableEvent manager_shutdown_latch;
1006 platform_thread,
1007 fml::MakeCopyable([&manager_shutdown_latch, &client]() mutable {
1008 client.mgr->ShutdownPlatformIsolates();
1009 manager_shutdown_latch.Signal();
1010 }));
1011 manager_shutdown_latch.Wait();
1012
1013 fml::AutoResetWaitableEvent ui_thread_latch;
1015 ui_thread, fml::MakeCopyable([&]() mutable {
1016 ASSERT_TRUE(isolate->RunInIsolateScope([root_isolate]() {
1017 Dart_Handle lib = Dart_RootLibrary();
1018 Dart_Handle entry_point =
1019 Dart_GetField(lib, tonic::ToDart("mainForPlatformIsolates"));
1020 char* error = nullptr;
1021 Dart_Isolate platform_isolate =
1022 root_isolate->CreatePlatformIsolate(entry_point, &error);
1023
1024 // Failed to create a platform isolate, but we've still re-entered the
1025 // root isolate.
1026 EXPECT_FALSE(error);
1027 EXPECT_FALSE(platform_isolate);
1028 EXPECT_EQ(Dart_CurrentIsolate(), root_isolate->isolate());
1029
1030 return true;
1031 }));
1032 ui_thread_latch.Signal();
1033 }));
1034 ui_thread_latch.Wait();
1035
1036 // root isolate will be auto-shutdown
1037}

◆ TEST_F() [82/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
PlatformIsolateCreationAndShutdown   
)

Definition at line 740 of file dart_isolate_unittests.cc.

740 {
741 fml::AutoResetWaitableEvent message_latch;
742 AddNativeCallback(
743 "PassMessage",
747 ASSERT_EQ("Platform isolate is ready", message);
748 message_latch.Signal();
749 })));
750
751 FakePlatformConfigurationClient client;
752 auto platform_configuration =
753 std::make_unique<PlatformConfiguration>(&client);
754 Dart_Isolate platform_isolate = nullptr;
755
756 {
757 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
758 auto settings = CreateSettingsForFixture();
759 auto vm_ref = DartVMRef::Create(settings);
760 ASSERT_TRUE(vm_ref);
761 auto vm_data = vm_ref.GetVMData();
762 ASSERT_TRUE(vm_data);
763
764 auto platform_thread = CreateNewThread();
765 auto ui_thread = CreateNewThread();
766 TaskRunners task_runners(GetCurrentTestName(), // label
767 platform_thread, // platform
768 ui_thread, // raster
769 ui_thread, // ui
770 ui_thread // io
771 );
772 auto isolate =
773 RunDartCodeInIsolate(vm_ref, settings, task_runners, "emptyMain", {},
774 GetDefaultKernelFilePath(), {}, nullptr,
775 std::move(platform_configuration));
776 ASSERT_TRUE(isolate);
777 auto root_isolate = isolate->get();
778 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
779 EXPECT_FALSE(
780 client.mgr->IsRegisteredForTestingOnly(root_isolate->isolate()));
781
782 // Post a task to the platform_thread that just waits, to delay execution of
783 // the platform isolate until we're ready.
784 fml::AutoResetWaitableEvent platform_thread_latch;
786 platform_thread, fml::MakeCopyable([&platform_thread_latch]() mutable {
787 platform_thread_latch.Wait();
788 }));
789
790 fml::AutoResetWaitableEvent ui_thread_latch;
792 ui_thread, fml::MakeCopyable([&]() mutable {
793 ASSERT_TRUE(
794 isolate->RunInIsolateScope([root_isolate, &platform_isolate]() {
795 Dart_Handle lib = Dart_RootLibrary();
796 Dart_Handle entry_point = Dart_GetField(
797 lib, tonic::ToDart("mainForPlatformIsolates"));
798 char* error = nullptr;
799 platform_isolate =
800 root_isolate->CreatePlatformIsolate(entry_point, &error);
801
802 EXPECT_FALSE(error);
803 EXPECT_TRUE(platform_isolate);
804 EXPECT_EQ(Dart_CurrentIsolate(), root_isolate->isolate());
805 return true;
806 }));
807 ui_thread_latch.Signal();
808 }));
809
810 ui_thread_latch.Wait();
811 ASSERT_TRUE(platform_isolate);
812 EXPECT_TRUE(client.mgr->IsRegisteredForTestingOnly(platform_isolate));
813
814 // Allow the platform isolate to run.
815 platform_thread_latch.Signal();
816
817 // Wait for a message from the platform isolate.
818 message_latch.Wait();
819
820 // root isolate will be auto-shutdown
821 }
822 EXPECT_FALSE(client.mgr->IsRegisteredForTestingOnly(platform_isolate));
823}
struct _Dart_Isolate * Dart_Isolate
Definition dart_api.h:88

◆ TEST_F() [83/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
PlatformIsolateEarlyShutdown   
)

Definition at line 825 of file dart_isolate_unittests.cc.

825 {
827 auto platform_configuration =
828 std::make_unique<PlatformConfiguration>(&client);
829
830 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
831 auto settings = CreateSettingsForFixture();
832 auto vm_ref = DartVMRef::Create(settings);
833 ASSERT_TRUE(vm_ref);
834 auto vm_data = vm_ref.GetVMData();
835 ASSERT_TRUE(vm_data);
836
837 auto platform_thread = CreateNewThread();
838 auto ui_thread = CreateNewThread();
839 TaskRunners task_runners(GetCurrentTestName(), // label
840 platform_thread, // platform
841 ui_thread, // raster
842 ui_thread, // ui
843 ui_thread // io
844 );
845 auto isolate =
846 RunDartCodeInIsolate(vm_ref, settings, task_runners, "emptyMain", {},
847 GetDefaultKernelFilePath(), {}, nullptr,
848 std::move(platform_configuration));
849 ASSERT_TRUE(isolate);
850 auto root_isolate = isolate->get();
851 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
852 EXPECT_FALSE(client.mgr->IsRegisteredForTestingOnly(root_isolate->isolate()));
853
854 fml::AutoResetWaitableEvent ui_thread_latch;
855 Dart_Isolate platform_isolate = nullptr;
857 ui_thread, fml::MakeCopyable([&]() mutable {
858 ASSERT_TRUE(
859 isolate->RunInIsolateScope([root_isolate, &platform_isolate]() {
860 Dart_Handle lib = Dart_RootLibrary();
861 Dart_Handle entry_point =
862 Dart_GetField(lib, tonic::ToDart("emptyMain"));
863 char* error = nullptr;
864 platform_isolate =
865 root_isolate->CreatePlatformIsolate(entry_point, &error);
866
867 EXPECT_FALSE(error);
868 EXPECT_TRUE(platform_isolate);
869 EXPECT_EQ(Dart_CurrentIsolate(), root_isolate->isolate());
870
871 return true;
872 }));
873 ui_thread_latch.Signal();
874 }));
875
876 ui_thread_latch.Wait();
877 ASSERT_TRUE(platform_isolate);
878 EXPECT_TRUE(client.mgr->IsRegisteredForTestingOnly(platform_isolate));
879
880 // Post a task to the platform thread to shut down the platform isolate.
881 fml::AutoResetWaitableEvent platform_thread_latch;
883 platform_thread,
884 fml::MakeCopyable([&platform_thread_latch, platform_isolate]() mutable {
885 Dart_EnterIsolate(platform_isolate);
887 platform_thread_latch.Signal();
888 }));
889 platform_thread_latch.Wait();
890
891 // The platform isolate should be shut down.
892 EXPECT_FALSE(client.mgr->IsRegisteredForTestingOnly(platform_isolate));
893
894 // root isolate will be auto-shutdown
895}
std::shared_ptr< PlatformIsolateManager > mgr
DART_EXPORT void Dart_ShutdownIsolate(void)
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)

◆ TEST_F() [84/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
PlatformIsolateMainThrowsError   
)

Definition at line 1125 of file dart_isolate_unittests.cc.

1125 {
1126 AddNativeCallback("PassMessage",
1129
1130 FakePlatformConfigurationClient client;
1131 auto platform_configuration =
1132 std::make_unique<PlatformConfiguration>(&client);
1133
1134 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
1135 auto settings = CreateSettingsForFixture();
1136 auto vm_ref = DartVMRef::Create(settings);
1137 ASSERT_TRUE(vm_ref);
1138 auto vm_data = vm_ref.GetVMData();
1139 ASSERT_TRUE(vm_data);
1140
1141 auto platform_thread = CreateNewThread();
1142 auto ui_thread = CreateNewThread();
1143 TaskRunners task_runners(GetCurrentTestName(), // label
1144 platform_thread, // platform
1145 ui_thread, // raster
1146 ui_thread, // ui
1147 ui_thread // io
1148 );
1149 auto isolate =
1150 RunDartCodeInIsolate(vm_ref, settings, task_runners, "emptyMain", {},
1151 GetDefaultKernelFilePath(), {}, nullptr,
1152 std::move(platform_configuration));
1153 ASSERT_TRUE(isolate);
1154 auto root_isolate = isolate->get();
1155 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
1156
1157 Dart_Isolate platform_isolate = nullptr;
1158 fml::AutoResetWaitableEvent ui_thread_latch;
1160 ui_thread, fml::MakeCopyable([&]() mutable {
1161 ASSERT_TRUE(
1162 isolate->RunInIsolateScope([root_isolate, &platform_isolate]() {
1163 Dart_Handle lib = Dart_RootLibrary();
1164 Dart_Handle entry_point = Dart_GetField(
1165 lib, tonic::ToDart("mainForPlatformIsolatesThrowError"));
1166 char* error = nullptr;
1167 platform_isolate =
1168 root_isolate->CreatePlatformIsolate(entry_point, &error);
1169
1170 EXPECT_FALSE(error);
1171 EXPECT_TRUE(platform_isolate);
1172 EXPECT_EQ(Dart_CurrentIsolate(), root_isolate->isolate());
1173
1174 return true;
1175 }));
1176 ui_thread_latch.Signal();
1177 }));
1178 ui_thread_latch.Wait();
1179 ASSERT_TRUE(platform_isolate);
1180 EXPECT_TRUE(client.mgr->IsRegisteredForTestingOnly(platform_isolate));
1181
1182 // Post a task to the platform_thread that runs after the platform isolate's
1183 // entry point, and wait for it to run.
1184 fml::AutoResetWaitableEvent epilogue_latch;
1186 platform_thread, fml::MakeCopyable([&epilogue_latch]() mutable {
1187 epilogue_latch.Signal();
1188 }));
1189 epilogue_latch.Wait();
1190
1191 // root isolate will be auto-shutdown
1192}

◆ TEST_F() [85/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
PlatformIsolateManagerShutdownBeforeMainRuns   
)

Definition at line 1039 of file dart_isolate_unittests.cc.

1039 {
1040 AddNativeCallback("PassMessage",
1043
1044 FakePlatformConfigurationClient client;
1045 auto platform_configuration =
1046 std::make_unique<PlatformConfiguration>(&client);
1047
1048 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
1049 auto settings = CreateSettingsForFixture();
1050 auto vm_ref = DartVMRef::Create(settings);
1051 ASSERT_TRUE(vm_ref);
1052 auto vm_data = vm_ref.GetVMData();
1053 ASSERT_TRUE(vm_data);
1054
1055 auto platform_thread = CreateNewThread();
1056 auto ui_thread = CreateNewThread();
1057 TaskRunners task_runners(GetCurrentTestName(), // label
1058 platform_thread, // platform
1059 ui_thread, // raster
1060 ui_thread, // ui
1061 ui_thread // io
1062 );
1063 auto isolate =
1064 RunDartCodeInIsolate(vm_ref, settings, task_runners, "emptyMain", {},
1065 GetDefaultKernelFilePath(), {}, nullptr,
1066 std::move(platform_configuration));
1067 ASSERT_TRUE(isolate);
1068 auto root_isolate = isolate->get();
1069 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
1070
1071 Dart_Isolate platform_isolate = nullptr;
1072
1073 // Post a task to the platform_thread that just waits, to delay execution of
1074 // the platform isolate until we're ready, and shutdown the manager just
1075 // before it runs.
1076 fml::AutoResetWaitableEvent platform_thread_latch;
1078 platform_thread, fml::MakeCopyable([&platform_thread_latch, &client,
1079 &platform_isolate]() mutable {
1080 platform_thread_latch.Wait();
1081 client.mgr->ShutdownPlatformIsolates();
1082 EXPECT_TRUE(platform_isolate);
1083 EXPECT_FALSE(client.mgr->IsRegisteredForTestingOnly(platform_isolate));
1084 }));
1085
1086 fml::AutoResetWaitableEvent ui_thread_latch;
1088 ui_thread, fml::MakeCopyable([&]() mutable {
1089 ASSERT_TRUE(
1090 isolate->RunInIsolateScope([root_isolate, &platform_isolate]() {
1091 Dart_Handle lib = Dart_RootLibrary();
1092 Dart_Handle entry_point =
1093 Dart_GetField(lib, tonic::ToDart("mainForPlatformIsolates"));
1094 char* error = nullptr;
1095 platform_isolate =
1096 root_isolate->CreatePlatformIsolate(entry_point, &error);
1097
1098 EXPECT_FALSE(error);
1099 EXPECT_TRUE(platform_isolate);
1100 EXPECT_EQ(Dart_CurrentIsolate(), root_isolate->isolate());
1101
1102 return true;
1103 }));
1104 ui_thread_latch.Signal();
1105 }));
1106 ui_thread_latch.Wait();
1107 ASSERT_TRUE(platform_isolate);
1108 EXPECT_TRUE(client.mgr->IsRegisteredForTestingOnly(platform_isolate));
1109
1110 // Allow the platform isolate to run, but its main is never run.
1111 platform_thread_latch.Signal();
1112
1113 // Post a task to the platform_thread that runs after the platform isolate's
1114 // entry point, and wait for it to run.
1115 fml::AutoResetWaitableEvent epilogue_latch;
1117 platform_thread, fml::MakeCopyable([&epilogue_latch]() mutable {
1118 epilogue_latch.Signal();
1119 }));
1120 epilogue_latch.Wait();
1121
1122 // root isolate will be auto-shutdown
1123}

◆ TEST_F() [86/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
PlatformIsolateSendAndReceive   
)

Definition at line 897 of file dart_isolate_unittests.cc.

897 {
898 fml::AutoResetWaitableEvent message_latch;
899 AddNativeCallback(
900 "PassMessage",
904 ASSERT_EQ("Platform isolate received: Hello from root isolate!",
905 message);
906 message_latch.Signal();
907 })));
908
909 FakePlatformConfigurationClient client;
910 auto platform_configuration =
911 std::make_unique<PlatformConfiguration>(&client);
912
913 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
914 auto settings = CreateSettingsForFixture();
915 auto vm_ref = DartVMRef::Create(settings);
916 ASSERT_TRUE(vm_ref);
917 auto vm_data = vm_ref.GetVMData();
918 ASSERT_TRUE(vm_data);
919
920 auto platform_thread = CreateNewThread();
921 auto ui_thread = CreateNewThread();
922 TaskRunners task_runners(GetCurrentTestName(), // label
923 platform_thread, // platform
924 ui_thread, // raster
925 ui_thread, // ui
926 ui_thread // io
927 );
928 auto isolate =
929 RunDartCodeInIsolate(vm_ref, settings, task_runners, "emptyMain", {},
930 GetDefaultKernelFilePath(), {}, nullptr,
931 std::move(platform_configuration));
932 ASSERT_TRUE(isolate);
933 auto root_isolate = isolate->get();
934 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
935
936 fml::AutoResetWaitableEvent ui_thread_latch;
937 Dart_Isolate platform_isolate = nullptr;
939 ui_thread, fml::MakeCopyable([&]() mutable {
940 ASSERT_TRUE(isolate->RunInIsolateScope([root_isolate,
941 &platform_isolate]() {
942 Dart_Handle lib = Dart_RootLibrary();
943 Dart_Handle entry_point = Dart_Invoke(
944 lib, tonic::ToDart("createEntryPointForPlatIsoSendAndRecvTest"),
945 0, nullptr);
946 char* error = nullptr;
947 platform_isolate =
948 root_isolate->CreatePlatformIsolate(entry_point, &error);
949 EXPECT_FALSE(error);
950 return true;
951 }));
952 ui_thread_latch.Signal();
953 }));
954 ui_thread_latch.Wait();
955
956 // Wait for a message from the platform isolate.
957 message_latch.Wait();
958
959 // Post a task to the platform_thread that runs after the platform isolate's
960 // entry point and all messages, and wait for it to run.
961 fml::AutoResetWaitableEvent epilogue_latch;
963 platform_thread, fml::MakeCopyable([&epilogue_latch]() mutable {
964 epilogue_latch.Signal();
965 }));
966 epilogue_latch.Wait();
967
968 // root isolate will be auto-shutdown
969}

◆ TEST_F() [87/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
RootIsolateCreateCallbackIsMadeOnceAndBeforeIsolateRunning   
)

Definition at line 454 of file dart_isolate_unittests.cc.

455 {
456 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
457 auto settings = CreateSettingsForFixture();
458 size_t create_callback_count = 0u;
459 settings.root_isolate_create_callback =
460 [&create_callback_count](const auto& isolate) {
461 ASSERT_EQ(isolate.GetPhase(), DartIsolate::Phase::Ready);
462 create_callback_count++;
463 ASSERT_NE(::Dart_CurrentIsolate(), nullptr);
464 };
465 auto vm_ref = DartVMRef::Create(settings);
466 TaskRunners task_runners(GetCurrentTestName(), //
467 GetCurrentTaskRunner(), //
468 GetCurrentTaskRunner(), //
469 GetCurrentTaskRunner(), //
470 GetCurrentTaskRunner() //
471 );
472 {
473 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
474 {}, GetDefaultKernelFilePath());
475 ASSERT_TRUE(isolate);
476 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
477 }
478 ASSERT_EQ(create_callback_count, 1u);
479}

◆ TEST_F() [88/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
RootIsolateCreationAndShutdown   
)

Definition at line 41 of file dart_isolate_unittests.cc.

41 {
42 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
43 auto settings = CreateSettingsForFixture();
44 auto vm_ref = DartVMRef::Create(settings);
45 ASSERT_TRUE(vm_ref);
46 auto vm_data = vm_ref.GetVMData();
47 ASSERT_TRUE(vm_data);
48 TaskRunners task_runners(GetCurrentTestName(), //
49 GetCurrentTaskRunner(), //
50 GetCurrentTaskRunner(), //
51 GetCurrentTaskRunner(), //
52 GetCurrentTaskRunner() //
53 );
54
55 auto isolate_configuration =
56 IsolateConfiguration::InferFromSettings(settings);
57
58 UIDartState::Context context(task_runners);
59 context.advisory_script_uri = "main.dart";
60 context.advisory_script_entrypoint = "main";
61 auto weak_isolate = DartIsolate::CreateRunningRootIsolate(
62 vm_data->GetSettings(), // settings
63 vm_data->GetIsolateSnapshot(), // isolate snapshot
64 nullptr, // platform configuration
65 DartIsolate::Flags{}, // flags
66 nullptr, // root_isolate_create_callback
67 settings.isolate_create_callback, // isolate create callback
68 settings.isolate_shutdown_callback, // isolate shutdown callback
69 "main", // dart entrypoint
70 std::nullopt, // dart entrypoint library
71 {}, // dart entrypoint arguments
72 std::move(isolate_configuration), // isolate configuration
73 context // engine context
74 );
75 auto root_isolate = weak_isolate.lock();
76 ASSERT_TRUE(root_isolate);
77 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
78 ASSERT_TRUE(root_isolate->Shutdown());
79}

◆ TEST_F() [89/876]

flutter::testing::TEST_F ( DartIsolateTest  ,
SpawningAnIsolateDoesNotReloadKernel   
)

Definition at line 596 of file dart_isolate_unittests.cc.

596 {
597 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
598 auto settings = CreateSettingsForFixture();
599 auto vm_ref = DartVMRef::Create(settings);
600 ASSERT_TRUE(vm_ref);
601 auto vm_data = vm_ref.GetVMData();
602 ASSERT_TRUE(vm_data);
603 TaskRunners task_runners(GetCurrentTestName(), //
604 GetCurrentTaskRunner(), //
605 GetCurrentTaskRunner(), //
606 GetCurrentTaskRunner(), //
607 GetCurrentTaskRunner() //
608 );
609
610 size_t get_kernel_count = 0u;
611 if (!DartVM::IsRunningPrecompiledCode()) {
612 ASSERT_TRUE(settings.application_kernels);
613 auto mappings = settings.application_kernels();
614 ASSERT_EQ(mappings.size(), 1u);
615
616 // This feels a little brittle, but the alternative seems to be making
617 // DartIsolate have virtual methods so it can be mocked or exposing weird
618 // test-only API on IsolateConfiguration.
619 settings.application_kernels = fml::MakeCopyable(
620 [&get_kernel_count,
621 mapping = std::move(mappings.front())]() mutable -> Mappings {
622 get_kernel_count++;
623 EXPECT_EQ(get_kernel_count, 1u)
624 << "Unexpectedly got more than one call for the kernel mapping.";
625 EXPECT_TRUE(mapping);
626 std::vector<std::unique_ptr<const fml::Mapping>> kernel_mappings;
627 if (mapping) {
628 kernel_mappings.emplace_back(std::move(mapping));
629 }
630 return kernel_mappings;
631 });
632 }
633
634 std::shared_ptr<DartIsolate> root_isolate;
635 {
636 auto isolate_configuration =
637 IsolateConfiguration::InferFromSettings(settings);
638
639 UIDartState::Context context(task_runners);
640 context.advisory_script_uri = "main.dart";
641 context.advisory_script_entrypoint = "main";
642 auto weak_isolate = DartIsolate::CreateRunningRootIsolate(
643 /*settings=*/vm_data->GetSettings(),
644 /*isolate_snapshot=*/vm_data->GetIsolateSnapshot(),
645 /*platform_configuration=*/nullptr,
646 /*flags=*/DartIsolate::Flags{},
647 /*root_isolate_create_callback=*/nullptr,
648 /*isolate_create_callback=*/settings.isolate_create_callback,
649 /*isolate_shutdown_callback=*/settings.isolate_shutdown_callback,
650 /*dart_entrypoint=*/"main",
651 /*dart_entrypoint_library=*/std::nullopt,
652 /*dart_entrypoint_args=*/{},
653 /*isolate_configuration=*/std::move(isolate_configuration),
654 /*context=*/context);
655 root_isolate = weak_isolate.lock();
656 }
657 ASSERT_TRUE(root_isolate);
658 ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running);
659 if (!DartVM::IsRunningPrecompiledCode()) {
660 ASSERT_EQ(get_kernel_count, 1u);
661 }
662
663 {
664 auto isolate_configuration = IsolateConfiguration::InferFromSettings(
665 /*settings=*/settings,
666 /*asset_manager=*/nullptr,
667 /*io_worker=*/nullptr,
668 /*launch_type=*/IsolateLaunchType::kExistingGroup);
669
670 UIDartState::Context context(task_runners);
671 context.advisory_script_uri = "main.dart";
672 context.advisory_script_entrypoint = "main";
673 auto weak_isolate = DartIsolate::CreateRunningRootIsolate(
674 /*settings=*/vm_data->GetSettings(),
675 /*isolate_snapshot=*/vm_data->GetIsolateSnapshot(),
676 /*platform_configuration=*/nullptr,
677 /*flags=*/DartIsolate::Flags{},
678 /*root_isolate_create_callback=*/nullptr,
679 /*isolate_create_callback=*/settings.isolate_create_callback,
680 /*isolate_shutdown_callback=*/settings.isolate_shutdown_callback,
681 /*dart_entrypoint=*/"main",
682 /*dart_entrypoint_library=*/std::nullopt,
683 /*dart_entrypoint_args=*/{},
684 /*isolate_configuration=*/std::move(isolate_configuration),
685 /*context=*/context,
686 /*spawning_isolate=*/root_isolate.get());
687 auto spawned_isolate = weak_isolate.lock();
688 ASSERT_TRUE(spawned_isolate);
689 ASSERT_EQ(spawned_isolate->GetPhase(), DartIsolate::Phase::Running);
690 if (!DartVM::IsRunningPrecompiledCode()) {
691 ASSERT_EQ(get_kernel_count, 1u);
692 }
693 ASSERT_TRUE(spawned_isolate->Shutdown());
694 }
695
696 ASSERT_TRUE(root_isolate->Shutdown());
697}

◆ TEST_F() [90/876]

flutter::testing::TEST_F ( DartLifecycleTest  ,
CanStartAndShutdownVM   
)

Definition at line 19 of file dart_lifecycle_unittests.cc.

19 {
20 auto settings = CreateSettingsForFixture();
21 settings.leak_vm = false;
22 settings.enable_vm_service = false;
23 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
24 {
25 auto vm_ref = DartVMRef::Create(settings);
26 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
27 }
28 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
29}

◆ TEST_F() [91/876]

flutter::testing::TEST_F ( DartLifecycleTest  ,
CanStartAndShutdownVMOverAndOver   
)

Definition at line 31 of file dart_lifecycle_unittests.cc.

31 {
32 auto settings = CreateSettingsForFixture();
33 settings.leak_vm = false;
34 settings.enable_vm_service = false;
35 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
36 auto count = DartVM::GetVMLaunchCount();
37 for (size_t i = 0; i < 10; i++) {
38 auto vm_ref = DartVMRef::Create(settings);
39 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
40 ASSERT_EQ(DartVM::GetVMLaunchCount(), count + 1);
41 count = DartVM::GetVMLaunchCount();
42 }
43 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
44}

◆ TEST_F() [92/876]

flutter::testing::TEST_F ( DartLifecycleTest  ,
DISABLED_ShuttingDownTheVMShutsDownAllIsolates   
)

Definition at line 88 of file dart_lifecycle_unittests.cc.

88 {
89 auto settings = CreateSettingsForFixture();
90 settings.leak_vm = false;
91 // Make sure the service protocol launches
92 settings.enable_vm_service = true;
93
94 auto thread_task_runner = CreateNewThread();
95
96 for (size_t i = 0; i < 3; i++) {
97 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
98
99 const auto last_launch_count = DartVM::GetVMLaunchCount();
100
101 auto vm_ref = DartVMRef::Create(settings);
102
103 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
104 ASSERT_EQ(last_launch_count + 1, DartVM::GetVMLaunchCount());
105
106 const size_t isolate_count = 5;
107
108 fml::CountDownLatch latch(isolate_count);
109 auto vm_data = vm_ref.GetVMData();
110 for (size_t i = 0; i < isolate_count; ++i) {
111 thread_task_runner->PostTask(
112 [vm_data, &settings, &latch, thread_task_runner]() {
113 ASSERT_TRUE(CreateAndRunRootIsolate(settings, *vm_data.get(),
114 thread_task_runner,
115 "testIsolateShutdown"));
116 latch.CountDown();
117 });
118 }
119
120 latch.Wait();
121 }
122 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
123}
static std::shared_ptr< DartIsolate > CreateAndRunRootIsolate(const Settings &settings, const DartVMData &vm, const fml::RefPtr< fml::TaskRunner > &task_runner, std::string entrypoint)

◆ TEST_F() [93/876]

flutter::testing::TEST_F ( DartPersistentHandleTest  ,
ClearAfterShutdown   
)

Definition at line 49 of file dart_persistent_handle_unittest.cc.

49 {
50 auto persistent_value = tonic::DartPersistentValue();
51
53 AddNativeCallback("GiveObjectToNative",
55 auto handle = Dart_GetNativeArgument(args, 0);
56
57 auto dart_state = tonic::DartState::Current();
58 ASSERT_TRUE(dart_state);
59 ASSERT_TRUE(tonic::DartState::Current());
60 persistent_value.Set(dart_state, handle);
61
62 event.Signal();
63 }));
64
65 ASSERT_TRUE(RunWithEntrypoint("callGiveObjectToNative"));
66 event.Wait();
67
68 running_isolate_->Shutdown();
69
71 task_runners_.GetUITaskRunner()->PostTask([&] {
72 persistent_value.Clear();
73 clear.Signal();
74 });
75 clear.Wait();
76}
static DartState * Current()
Definition dart_state.cc:56
TaskRunners task_runners_

◆ TEST_F() [94/876]

flutter::testing::TEST_F ( DartSecondaryIsolateTest  ,
CanLaunchSecondaryIsolates   
)

Definition at line 300 of file dart_isolate_unittests.cc.

300 {
301 AddNativeCallback("NotifyNative",
303 LatchCountDown();
304 })));
305 AddNativeCallback(
306 "PassMessage", CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
309 ASSERT_EQ("Hello from code is secondary isolate.", message);
310 LatchCountDown();
311 })));
312 auto settings = CreateSettingsForFixture();
313 settings.root_isolate_shutdown_callback = [this]() {
314 RootIsolateShutdownSignal();
315 };
316 settings.isolate_shutdown_callback = [this]() { ChildShutdownSignal(); };
317 auto vm_ref = DartVMRef::Create(settings);
318 auto thread = CreateNewThread();
319 TaskRunners task_runners(GetCurrentTestName(), //
320 thread, //
321 thread, //
322 thread, //
323 thread //
324 );
325 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners,
326 "testCanLaunchSecondaryIsolate", {},
328 ASSERT_TRUE(isolate);
329 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
330 ChildShutdownWait(); // wait for child isolate to shutdown first
331 ASSERT_FALSE(RootIsolateIsSignaled());
332 LatchWait(); // wait for last NotifyNative called by main isolate
333 // root isolate will be auto-shutdown
334}
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name)
std::string GetDefaultKernelFilePath()
Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixture...
Definition testing.cc:19

◆ TEST_F() [95/876]

flutter::testing::TEST_F ( DartState  ,
CurrentWithNullDataDoesNotSegfault   
)

Definition at line 16 of file dart_state_unittest.cc.

16 {
17 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
18 auto settings = CreateSettingsForFixture();
19 auto vm_snapshot = DartSnapshot::VMSnapshotFromSettings(settings);
20 auto isolate_snapshot = DartSnapshot::IsolateSnapshotFromSettings(settings);
21 auto vm_ref = DartVMRef::Create(settings, vm_snapshot, isolate_snapshot);
22 ASSERT_TRUE(vm_ref);
23 auto vm_data = vm_ref.GetVMData();
24 ASSERT_TRUE(vm_data);
25 TaskRunners task_runners(GetCurrentTestName(), //
26 GetCurrentTaskRunner(), //
27 GetCurrentTaskRunner(), //
28 GetCurrentTaskRunner(), //
29 GetCurrentTaskRunner() //
30 );
31 auto isolate_configuration =
32 IsolateConfiguration::InferFromSettings(settings);
33 Dart_IsolateFlags isolate_flags;
34 Dart_IsolateFlagsInitialize(&isolate_flags);
35 isolate_flags.null_safety =
36 isolate_configuration->IsNullSafetyEnabled(*isolate_snapshot);
37 isolate_flags.snapshot_is_dontneed_safe = isolate_snapshot->IsDontNeedSafe();
38 char* error;
40 "main.dart", "main", vm_data->GetIsolateSnapshot()->GetDataMapping(),
41 vm_data->GetIsolateSnapshot()->GetInstructionsMapping(), &isolate_flags,
42 nullptr, nullptr, &error);
43 ASSERT_FALSE(error) << error;
44 ::free(error);
45
46 ASSERT_FALSE(tonic::DartState::Current());
47
49 ASSERT_TRUE(Dart_CurrentIsolate() == nullptr);
50}
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroup(const char *script_uri, const char *name, const uint8_t *isolate_snapshot_data, const uint8_t *isolate_snapshot_instructions, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags *flags)
bool snapshot_is_dontneed_safe
Definition dart_api.h:595

◆ TEST_F() [96/876]

flutter::testing::TEST_F ( DartState  ,
IsShuttingDown   
)

Definition at line 52 of file dart_state_unittest.cc.

52 {
53 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
54 auto settings = CreateSettingsForFixture();
55 auto vm_ref = DartVMRef::Create(settings);
56 ASSERT_TRUE(vm_ref);
57 auto vm_data = vm_ref.GetVMData();
58 ASSERT_TRUE(vm_data);
59 TaskRunners task_runners(GetCurrentTestName(), //
60 GetCurrentTaskRunner(), //
61 GetCurrentTaskRunner(), //
62 GetCurrentTaskRunner(), //
63 GetCurrentTaskRunner() //
64 );
65 auto isolate_configuration =
66 IsolateConfiguration::InferFromSettings(settings);
67
68 UIDartState::Context context(std::move(task_runners));
69 context.advisory_script_uri = "main.dart";
70 context.advisory_script_entrypoint = "main";
71 auto weak_isolate = DartIsolate::CreateRunningRootIsolate(
72 vm_data->GetSettings(), // settings
73 vm_data->GetIsolateSnapshot(), // isolate snapshot
74 nullptr, // platform configuration
75 DartIsolate::Flags{}, // flags
76 nullptr, // root_isolate_create_callback
77 settings.isolate_create_callback, // isolate create callback
78 settings.isolate_shutdown_callback, // isolate shutdown callback
79 "main", // dart entrypoint
80 std::nullopt, // dart entrypoint library
81 {}, // dart entrypoint arguments
82 std::move(isolate_configuration), // isolate configuration
83 std::move(context) // engine context
84 );
85 auto root_isolate = weak_isolate.lock();
86 ASSERT_TRUE(root_isolate);
87
88 tonic::DartState* dart_state = root_isolate.get();
89 ASSERT_FALSE(dart_state->IsShuttingDown());
90
91 ASSERT_TRUE(root_isolate->Shutdown());
92
93 ASSERT_TRUE(dart_state->IsShuttingDown());
94}
bool IsShuttingDown()
Definition dart_state.h:74

◆ TEST_F() [97/876]

flutter::testing::TEST_F ( DartVMTest  ,
DisableTimelineEventHandler   
)

Definition at line 46 of file dart_vm_unittests.cc.

46 {
47 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
49 auto settings = CreateSettingsForFixture();
50 settings.enable_timeline_event_handler = false;
51 auto vm = DartVMRef::Create(settings);
53}
bool TraceHasTimelineEventHandler()
void TraceSetTimelineEventHandler(TimelineEventHandler handler)

◆ TEST_F() [98/876]

flutter::testing::TEST_F ( DartVMTest  ,
OldGenHeapSize   
)

Definition at line 36 of file dart_vm_unittests.cc.

36 {
37 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
38 auto settings = CreateSettingsForFixture();
39 settings.old_gen_heap_size = 1024;
40 auto vm = DartVMRef::Create(settings);
41 // There is no way to introspect on the heap size so we just assert the vm was
42 // created.
43 ASSERT_TRUE(vm);
44}

◆ TEST_F() [99/876]

flutter::testing::TEST_F ( DartVMTest  ,
SimpleInitialization   
)

Definition at line 16 of file dart_vm_unittests.cc.

16 {
17 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
18 auto vm = DartVMRef::Create(CreateSettingsForFixture());
19 ASSERT_TRUE(vm);
20}

◆ TEST_F() [100/876]

flutter::testing::TEST_F ( DartVMTest  ,
SimpleIsolateNameServer   
)

Definition at line 22 of file dart_vm_unittests.cc.

22 {
23 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
24 auto vm = DartVMRef::Create(CreateSettingsForFixture());
25 ASSERT_TRUE(vm);
26 ASSERT_TRUE(vm.GetVMData());
27 auto ns = vm->GetIsolateNameServer();
28 ASSERT_EQ(ns->LookupIsolatePortByName("foobar"), ILLEGAL_PORT);
29 ASSERT_FALSE(ns->RemoveIsolateNameMapping("foobar"));
30 ASSERT_TRUE(ns->RegisterIsolatePortWithName(123, "foobar"));
31 ASSERT_FALSE(ns->RegisterIsolatePortWithName(123, "foobar"));
32 ASSERT_EQ(ns->LookupIsolatePortByName("foobar"), 123);
33 ASSERT_TRUE(ns->RemoveIsolateNameMapping("foobar"));
34}
#define ILLEGAL_PORT
Definition dart_api.h:1530

◆ TEST_F() [101/876]

flutter::testing::TEST_F ( DartVMTest  ,
TraceGetTimelineMicrosDoesNotGetClockWhenSystraceIsEnabled   
)

Definition at line 55 of file dart_vm_unittests.cc.

55 {
56 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
57 auto settings = CreateSettingsForFixture();
58 settings.trace_systrace = true;
59 auto vm = DartVMRef::Create(settings);
61}
int64_t TraceGetTimelineMicros()

◆ TEST_F() [102/876]

flutter::testing::TEST_F ( DartWeakPersistentHandle  ,
ClearImmediately   
)

Definition at line 52 of file dart_weak_persistent_handle_unittest.cc.

52 {
53 auto weak_persistent_value = tonic::DartWeakPersistentValue();
54
56
57 AddNativeCallback(
58 "GiveObjectToNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
59 auto handle = Dart_GetNativeArgument(args, 0);
60
61 auto dart_state = tonic::DartState::Current();
62 ASSERT_TRUE(dart_state);
63 ASSERT_TRUE(tonic::DartState::Current());
64 weak_persistent_value.Set(dart_state, handle, nullptr, 0, NopFinalizer);
65
66 weak_persistent_value.Clear();
67
68 event.Signal();
69 }));
70
71 ASSERT_TRUE(RunWithEntrypoint("callGiveObjectToNative"));
72
73 event.Wait();
74}

◆ TEST_F() [103/876]

flutter::testing::TEST_F ( DartWeakPersistentHandle  ,
ClearLaterCc   
)

Definition at line 76 of file dart_weak_persistent_handle_unittest.cc.

76 {
77 auto weak_persistent_value = tonic::DartWeakPersistentValue();
78
80
81 AddNativeCallback(
82 "GiveObjectToNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
83 auto handle = Dart_GetNativeArgument(args, 0);
84
85 auto dart_state = tonic::DartState::Current();
86 ASSERT_TRUE(dart_state);
87 ASSERT_TRUE(tonic::DartState::Current());
88 weak_persistent_value.Set(dart_state, handle, nullptr, 0, NopFinalizer);
89
90 // Do not clear handle immediately.
91
92 event.Signal();
93 }));
94
95 ASSERT_TRUE(RunWithEntrypoint("callGiveObjectToNative"));
96
97 event.Wait();
98
99 ASSERT_TRUE(RunInIsolateScope([&weak_persistent_value]() -> bool {
100 // Clear on initiative of native.
101 weak_persistent_value.Clear();
102 return true;
103 }));
104}

◆ TEST_F() [104/876]

flutter::testing::TEST_F ( DartWeakPersistentHandle  ,
ClearLaterDart   
)

Definition at line 106 of file dart_weak_persistent_handle_unittest.cc.

106 {
107 auto weak_persistent_value = tonic::DartWeakPersistentValue();
108
110
111 AddNativeCallback(
112 "GiveObjectToNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
113 auto handle = Dart_GetNativeArgument(args, 0);
114
115 auto dart_state = tonic::DartState::Current();
116 ASSERT_TRUE(dart_state);
117 ASSERT_TRUE(tonic::DartState::Current());
118 weak_persistent_value.Set(dart_state, handle, nullptr, 0, NopFinalizer);
119
120 // Do not clear handle immediately.
121 }));
122
123 AddNativeCallback("SignalDone",
125 // Clear on initiative of Dart.
126 weak_persistent_value.Clear();
127
128 event.Signal();
129 }));
130
131 ASSERT_TRUE(RunWithEntrypoint("testClearLater"));
132
133 event.Wait();
134}

◆ TEST_F() [105/876]

flutter::testing::TEST_F ( DartWeakPersistentHandle  ,
ClearOnShutdown   
)

Definition at line 140 of file dart_weak_persistent_handle_unittest.cc.

140 {
142
143 AddNativeCallback("GiveObjectToNative",
145 auto handle = Dart_GetNativeArgument(args, 0);
146
147 auto dart_state = tonic::DartState::Current();
148 ASSERT_TRUE(dart_state);
149 ASSERT_TRUE(tonic::DartState::Current());
150
151 // The test is repeated, ensure the global var is
152 // cleared before use.
154
156 dart_state, handle, nullptr, 0, NopFinalizer);
157
158 // Do not clear handle, so it is cleared on shutdown.
159
160 event.Signal();
161 }));
162
163 ASSERT_TRUE(RunWithEntrypoint("callGiveObjectToNative"));
164
165 event.Wait();
166}
void Set(DartState *dart_state, Dart_Handle object, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
tonic::DartWeakPersistentValue global_weak_persistent_value

◆ TEST_F() [106/876]

flutter::testing::TEST_F ( DiffContextTest  ,
ClipAlignment   
)

Definition at line 10 of file diff_context_unittests.cc.

10 {
12 t1.root()->Add(CreateDisplayListLayer(
13 CreateDisplayList(SkRect::MakeLTRB(30, 30, 50, 50))));
14 auto damage = DiffLayerTree(t1, MockLayerTree(), SkIRect::MakeEmpty(), 0, 0);
15 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(30, 30, 50, 50));
16 EXPECT_EQ(damage.buffer_damage, SkIRect::MakeLTRB(30, 30, 50, 50));
17
18 damage = DiffLayerTree(t1, MockLayerTree(), SkIRect::MakeEmpty(), 1, 1);
19 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(30, 30, 50, 50));
20 EXPECT_EQ(damage.buffer_damage, SkIRect::MakeLTRB(30, 30, 50, 50));
21
22 damage = DiffLayerTree(t1, MockLayerTree(), SkIRect::MakeEmpty(), 8, 1);
23 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(24, 30, 56, 50));
24 EXPECT_EQ(damage.buffer_damage, SkIRect::MakeLTRB(24, 30, 56, 50));
25
26 damage = DiffLayerTree(t1, MockLayerTree(), SkIRect::MakeEmpty(), 1, 8);
27 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(30, 24, 50, 56));
28 EXPECT_EQ(damage.buffer_damage, SkIRect::MakeLTRB(30, 24, 50, 56));
29
30 damage = DiffLayerTree(t1, MockLayerTree(), SkIRect::MakeEmpty(), 16, 16);
31 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(16, 16, 64, 64));
32 EXPECT_EQ(damage.buffer_damage, SkIRect::MakeLTRB(16, 16, 64, 64));
33}

◆ TEST_F() [107/876]

flutter::testing::TEST_F ( DisplayListLayerDiffTest  ,
DisplayListCompare   
)

Definition at line 403 of file display_list_layer_unittests.cc.

403 {
404 MockLayerTree tree1;
405 auto display_list1 =
406 CreateDisplayList(SkRect::MakeLTRB(10, 10, 60, 60), DlColor::kGreen());
407 tree1.root()->Add(CreateDisplayListLayer(display_list1));
408
409 auto damage = DiffLayerTree(tree1, MockLayerTree());
410 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(10, 10, 60, 60));
411
412 MockLayerTree tree2;
413 // same DL, same offset
414 auto display_list2 =
415 CreateDisplayList(SkRect::MakeLTRB(10, 10, 60, 60), DlColor::kGreen());
416 tree2.root()->Add(CreateDisplayListLayer(display_list2));
417
418 damage = DiffLayerTree(tree2, tree1);
419 EXPECT_EQ(damage.frame_damage, SkIRect::MakeEmpty());
420
421 MockLayerTree tree3;
422 auto display_list3 =
423 CreateDisplayList(SkRect::MakeLTRB(10, 10, 60, 60), DlColor::kGreen());
424 // add offset
425 tree3.root()->Add(
426 CreateDisplayListLayer(display_list3, SkPoint::Make(10, 10)));
427
428 damage = DiffLayerTree(tree3, tree2);
429 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(10, 10, 70, 70));
430
431 MockLayerTree tree4;
432 // different color
433 auto display_list4 =
434 CreateDisplayList(SkRect::MakeLTRB(10, 10, 60, 60), DlColor::kRed());
435 tree4.root()->Add(
436 CreateDisplayListLayer(display_list4, SkPoint::Make(10, 10)));
437
438 damage = DiffLayerTree(tree4, tree3);
439 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(20, 20, 70, 70));
440}

◆ TEST_F() [108/876]

flutter::testing::TEST_F ( DisplayListLayerDiffTest  ,
FractionalTranslation   
)

Definition at line 377 of file display_list_layer_unittests.cc.

377 {
378 auto display_list = CreateDisplayList(SkRect::MakeLTRB(10, 10, 60, 60));
379
380 MockLayerTree tree1;
381 tree1.root()->Add(
382 CreateDisplayListLayer(display_list, SkPoint::Make(0.5, 0.5)));
383
384 auto damage =
385 DiffLayerTree(tree1, MockLayerTree(), SkIRect::MakeEmpty(), 0, 0,
386 /*use_raster_cache=*/false);
387 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(10, 10, 61, 61));
388}

◆ TEST_F() [109/876]

flutter::testing::TEST_F ( DisplayListLayerDiffTest  ,
FractionalTranslationWithRasterCache   
)

Definition at line 390 of file display_list_layer_unittests.cc.

390 {
391 auto display_list = CreateDisplayList(SkRect::MakeLTRB(10, 10, 60, 60));
392
393 MockLayerTree tree1;
394 tree1.root()->Add(
395 CreateDisplayListLayer(display_list, SkPoint::Make(0.5, 0.5)));
396
397 auto damage =
398 DiffLayerTree(tree1, MockLayerTree(), SkIRect::MakeEmpty(), 0, 0,
399 /*use_raster_cache=*/true);
400 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(11, 11, 61, 61));
401}

◆ TEST_F() [110/876]

flutter::testing::TEST_F ( DisplayListLayerDiffTest  ,
SimpleDisplayList   
)

Definition at line 357 of file display_list_layer_unittests.cc.

357 {
358 auto display_list = CreateDisplayList(SkRect::MakeLTRB(10, 10, 60, 60));
359
360 MockLayerTree tree1;
361 tree1.root()->Add(CreateDisplayListLayer(display_list));
362
363 auto damage = DiffLayerTree(tree1, MockLayerTree());
364 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(10, 10, 60, 60));
365
366 MockLayerTree tree2;
367 tree2.root()->Add(CreateDisplayListLayer(display_list));
368
369 damage = DiffLayerTree(tree2, tree1);
370 EXPECT_TRUE(damage.frame_damage.isEmpty());
371
372 MockLayerTree tree3;
373 damage = DiffLayerTree(tree3, tree2);
374 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(10, 10, 60, 60));
375}

◆ TEST_F() [111/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
CachedIncompatibleDisplayListOpacityInheritance   
)

Definition at line 226 of file display_list_layer_unittests.cc.

226 {
227 const SkPoint layer_offset = SkPoint::Make(1.5f, -0.5f);
228 const SkRect picture1_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
229 const SkRect picture2_bounds = SkRect::MakeLTRB(10.0f, 15.0f, 30.0f, 35.0f);
230 DisplayListBuilder builder;
231 builder.DrawRect(picture1_bounds, DlPaint());
232 builder.DrawRect(picture2_bounds, DlPaint());
233 auto display_list = builder.Build();
234 auto display_list_layer = std::make_shared<DisplayListLayer>(
235 layer_offset, display_list, true, false);
236 EXPECT_FALSE(display_list->can_apply_group_opacity());
237
238 use_skia_raster_cache();
239
240 auto context = preroll_context();
241 display_list_layer->Preroll(preroll_context());
242 EXPECT_EQ(context->renderable_state_flags, 0);
243
244 // Pump the DisplayListLayer until it is ready to cache its DL
245 display_list_layer->Preroll(preroll_context());
246 display_list_layer->Preroll(preroll_context());
247 display_list_layer->Preroll(preroll_context());
248 LayerTree::TryToRasterCache(*preroll_context()->raster_cached_entries,
249 &paint_context(), false);
250
251 int opacity_alpha = 0x7F;
252 SkPoint opacity_offset = SkPoint::Make(10.2, 10.2);
253 auto opacity_layer =
254 std::make_shared<OpacityLayer>(opacity_alpha, opacity_offset);
255 opacity_layer->Add(display_list_layer);
256 opacity_layer->Preroll(context);
257 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
258
259 auto display_list_bounds = picture1_bounds;
260 display_list_bounds.join(picture2_bounds);
261 auto save_layer_bounds =
262 display_list_bounds.makeOffset(layer_offset.fX, layer_offset.fY);
263 save_layer_bounds.roundOut(&save_layer_bounds);
264 auto opacity_integral_matrix =
265 RasterCacheUtil::GetIntegralTransCTM(SkMatrix::Translate(opacity_offset));
266 SkMatrix layer_offset_matrix = opacity_integral_matrix;
267 layer_offset_matrix.postTranslate(layer_offset.fX, layer_offset.fY);
268 auto layer_offset_integral_matrix =
269 RasterCacheUtil::GetIntegralTransCTM(layer_offset_matrix);
270 DisplayListBuilder expected(SkRect::MakeWH(1000, 1000));
271 /* opacity_layer::Paint() */ {
272 expected.Save();
273 {
274 expected.Translate(opacity_offset.fX, opacity_offset.fY);
275 expected.TransformReset();
276 expected.Transform(opacity_integral_matrix);
277 /* display_list_layer::Paint() */ {
278 expected.Save();
279 {
280 expected.Translate(layer_offset.fX, layer_offset.fY);
281 expected.TransformReset();
282 expected.Transform(layer_offset_integral_matrix);
283 context->raster_cache->Draw(display_list_layer->caching_key_id(),
284 expected,
285 &DlPaint().setAlpha(opacity_alpha));
286 }
287 expected.Restore();
288 }
289 }
290 expected.Restore();
291 }
292
293 opacity_layer->Paint(display_list_paint_context());
294 EXPECT_TRUE(DisplayListsEQ_Verbose(expected.Build(), this->display_list()));
295}
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:281

◆ TEST_F() [112/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
CachingDoesNotChangeCullRect   
)

Definition at line 101 of file display_list_layer_unittests.cc.

101 {
102 const SkPoint layer_offset = SkPoint::Make(10, 10);
103 DisplayListBuilder builder;
104 builder.DrawRect({10, 10, 20, 20}, DlPaint());
105 auto display_list = builder.Build();
106 auto layer = std::make_shared<DisplayListLayer>(layer_offset, display_list,
107 true, false);
108
109 SkRect original_cull_rect = preroll_context()->state_stack.device_cull_rect();
110 use_mock_raster_cache();
111 layer->Preroll(preroll_context());
112 ASSERT_EQ(preroll_context()->state_stack.device_cull_rect(),
113 original_cull_rect);
114}

◆ TEST_F() [113/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
DisplayListAccessCountDependsOnVisibility   
)

Definition at line 477 of file display_list_layer_unittests.cc.

477 {
478 const SkPoint layer_offset = SkPoint::Make(1.5f, -0.5f);
479 const SkRect picture_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
480 const SkRect missed_cull_rect = SkRect::MakeLTRB(100, 100, 200, 200);
481 const SkRect hit_cull_rect = SkRect::MakeLTRB(0, 0, 200, 200);
482 DisplayListBuilder builder;
483 builder.DrawRect(picture_bounds, DlPaint());
484 auto display_list = builder.Build();
485 auto layer = std::make_shared<DisplayListLayer>(layer_offset, display_list,
486 true, false);
487
488 auto raster_cache_item = layer->raster_cache_item();
489 use_mock_raster_cache();
490
491 // First Preroll the DisplayListLayer a few times where it does not intersect
492 // the cull rect. No caching progress should occur during this time, the
493 // access_count should remain 0 because the DisplayList was never "visible".
494 ASSERT_TRUE(preroll_context()->state_stack.is_empty());
495 preroll_context()->state_stack.set_preroll_delegate(missed_cull_rect);
496 for (int i = 0; i < 10; i++) {
497 preroll_context()->raster_cached_entries->clear();
498 layer->Preroll(preroll_context());
499 ASSERT_EQ(raster_cache_item->cache_state(), RasterCacheItem::kNone);
500 ASSERT_TRUE(raster_cache_item->GetId().has_value());
501 ASSERT_EQ(preroll_context()->raster_cache->GetAccessCount(
502 raster_cache_item->GetId().value(), SkMatrix::I()),
503 0);
504 ASSERT_EQ(preroll_context()->raster_cached_entries->size(), size_t(1));
505 ASSERT_EQ(preroll_context()->raster_cache->EstimatePictureCacheByteSize(),
506 size_t(0));
507 ASSERT_FALSE(raster_cache_item->TryToPrepareRasterCache(paint_context()));
508 ASSERT_FALSE(raster_cache_item->Draw(paint_context(), nullptr));
509 }
510
511 // Next Preroll the DisplayListLayer once where it does intersect
512 // the cull rect. No caching progress should occur during this time
513 // since this is the first frame in which it was visible, but the
514 // count should start incrementing.
515 ASSERT_TRUE(preroll_context()->state_stack.is_empty());
516 preroll_context()->state_stack.set_preroll_delegate(hit_cull_rect);
517 preroll_context()->raster_cached_entries->clear();
518 layer->Preroll(preroll_context());
519 ASSERT_EQ(raster_cache_item->cache_state(), RasterCacheItem::kNone);
520 ASSERT_TRUE(raster_cache_item->GetId().has_value());
521 ASSERT_EQ(preroll_context()->raster_cache->GetAccessCount(
522 raster_cache_item->GetId().value(), SkMatrix::I()),
523 1);
524 ASSERT_EQ(preroll_context()->raster_cached_entries->size(), size_t(1));
525 ASSERT_EQ(preroll_context()->raster_cache->EstimatePictureCacheByteSize(),
526 size_t(0));
527 ASSERT_FALSE(raster_cache_item->TryToPrepareRasterCache(paint_context()));
528 ASSERT_FALSE(raster_cache_item->Draw(paint_context(), nullptr));
529
530 // Now we can Preroll the DisplayListLayer again with a cull rect that
531 // it does not intersect and it should continue to count these operations
532 // even though it is not visible. No actual caching should occur yet,
533 // even though we will surpass its threshold.
534 ASSERT_TRUE(preroll_context()->state_stack.is_empty());
535 preroll_context()->state_stack.set_preroll_delegate(missed_cull_rect);
536 for (int i = 0; i < 10; i++) {
537 preroll_context()->raster_cached_entries->clear();
538 layer->Preroll(preroll_context());
539 ASSERT_EQ(raster_cache_item->cache_state(), RasterCacheItem::kNone);
540 ASSERT_TRUE(raster_cache_item->GetId().has_value());
541 ASSERT_EQ(preroll_context()->raster_cache->GetAccessCount(
542 raster_cache_item->GetId().value(), SkMatrix::I()),
543 i + 2);
544 ASSERT_EQ(preroll_context()->raster_cached_entries->size(), size_t(1));
545 ASSERT_EQ(preroll_context()->raster_cache->EstimatePictureCacheByteSize(),
546 size_t(0));
547 ASSERT_FALSE(raster_cache_item->TryToPrepareRasterCache(paint_context()));
548 ASSERT_FALSE(raster_cache_item->Draw(paint_context(), nullptr));
549 }
550
551 // Finally Preroll the DisplayListLayer again where it does intersect
552 // the cull rect. Since we should have exhausted our access count
553 // threshold in the loop above, these operations should result in the
554 // DisplayList being cached.
555 ASSERT_TRUE(preroll_context()->state_stack.is_empty());
556 preroll_context()->state_stack.set_preroll_delegate(hit_cull_rect);
557 preroll_context()->raster_cached_entries->clear();
558 layer->Preroll(preroll_context());
559 ASSERT_EQ(raster_cache_item->cache_state(), RasterCacheItem::kCurrent);
560 ASSERT_TRUE(raster_cache_item->GetId().has_value());
561 ASSERT_EQ(preroll_context()->raster_cache->GetAccessCount(
562 raster_cache_item->GetId().value(), SkMatrix::I()),
563 12);
564 ASSERT_EQ(preroll_context()->raster_cached_entries->size(), size_t(1));
565 ASSERT_EQ(preroll_context()->raster_cache->EstimatePictureCacheByteSize(),
566 size_t(0));
567 ASSERT_TRUE(raster_cache_item->TryToPrepareRasterCache(paint_context()));
568 ASSERT_GT(preroll_context()->raster_cache->EstimatePictureCacheByteSize(),
569 size_t(0));
570 ASSERT_TRUE(raster_cache_item->Draw(paint_context(), nullptr));
571}

◆ TEST_F() [114/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
IncompatibleDisplayListOpacityInheritance   
)

Definition at line 166 of file display_list_layer_unittests.cc.

166 {
167 const SkPoint layer_offset = SkPoint::Make(1.5f, -0.5f);
168 const SkRect picture1_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
169 const SkRect picture2_bounds = SkRect::MakeLTRB(10.0f, 15.0f, 30.0f, 35.0f);
170 DisplayListBuilder builder;
171 builder.DrawRect(picture1_bounds, DlPaint());
172 builder.DrawRect(picture2_bounds, DlPaint());
173 auto display_list = builder.Build();
174 auto display_list_layer = std::make_shared<DisplayListLayer>(
175 layer_offset, display_list, false, false);
176 EXPECT_FALSE(display_list->can_apply_group_opacity());
177
178 auto context = preroll_context();
179 display_list_layer->Preroll(preroll_context());
180 EXPECT_EQ(context->renderable_state_flags, 0);
181
182 int opacity_alpha = 0x7F;
183 SkPoint opacity_offset = SkPoint::Make(10, 10);
184 auto opacity_layer =
185 std::make_shared<OpacityLayer>(opacity_alpha, opacity_offset);
186 opacity_layer->Add(display_list_layer);
187 opacity_layer->Preroll(context);
188 EXPECT_FALSE(opacity_layer->children_can_accept_opacity());
189
190 DisplayListBuilder child_builder;
191 child_builder.DrawRect(picture1_bounds, DlPaint());
192 child_builder.DrawRect(picture2_bounds, DlPaint());
193 auto child_display_list = child_builder.Build();
194
195 auto display_list_bounds = picture1_bounds;
196 display_list_bounds.join(picture2_bounds);
197 auto save_layer_bounds =
198 display_list_bounds.makeOffset(layer_offset.fX, layer_offset.fY);
199 DisplayListBuilder expected_builder;
200 /* opacity_layer::Paint() */ {
201 expected_builder.Save();
202 {
203 expected_builder.Translate(opacity_offset.fX, opacity_offset.fY);
204 expected_builder.SaveLayer(&save_layer_bounds,
205 &DlPaint().setAlpha(opacity_alpha));
206 {
207 /* display_list_layer::Paint() */ {
208 expected_builder.Save();
209 {
210 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
211 expected_builder.DrawDisplayList(child_display_list);
212 }
213 expected_builder.Restore();
214 }
215 }
216 expected_builder.Restore();
217 }
218 expected_builder.Restore();
219 }
220
221 opacity_layer->Paint(display_list_paint_context());
223 DisplayListsEQ_Verbose(this->display_list(), expected_builder.Build()));
224}
void Translate(SkScalar tx, SkScalar ty) override

◆ TEST_F() [115/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
InvalidDisplayListDies   
)

Definition at line 62 of file display_list_layer_unittests.cc.

62 {
63 const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
64 auto layer = std::make_shared<DisplayListLayer>(
65 layer_offset, sk_sp<DisplayList>(), false, false);
66
67 // Crashes reading a nullptr.
68 EXPECT_DEATH_IF_SUPPORTED(layer->Preroll(preroll_context()), "");
69}

◆ TEST_F() [116/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
LayerTreeSnapshotsWhenEnabled   
)

Definition at line 442 of file display_list_layer_unittests.cc.

442 {
443 const SkPoint layer_offset = SkPoint::Make(1.5f, -0.5f);
444 const SkRect picture_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
445 DisplayListBuilder builder;
446 builder.DrawRect(picture_bounds, DlPaint());
447 auto display_list = builder.Build();
448 auto layer = std::make_shared<DisplayListLayer>(layer_offset, display_list,
449 false, false);
450
451 layer->Preroll(preroll_context());
452
453 enable_leaf_layer_tracing();
454 layer->Paint(paint_context());
455 disable_leaf_layer_tracing();
456
457 auto& snapshot_store = layer_snapshot_store();
458 EXPECT_EQ(1u, snapshot_store.Size());
459}

◆ TEST_F() [117/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
NoLayerTreeSnapshotsWhenDisabledByDefault   
)

Definition at line 461 of file display_list_layer_unittests.cc.

461 {
462 const SkPoint layer_offset = SkPoint::Make(1.5f, -0.5f);
463 const SkRect picture_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
464 DisplayListBuilder builder;
465 builder.DrawRect(picture_bounds, DlPaint());
466 auto display_list = builder.Build();
467 auto layer = std::make_shared<DisplayListLayer>(layer_offset, display_list,
468 false, false);
469
470 layer->Preroll(preroll_context());
471 layer->Paint(paint_context());
472
473 auto& snapshot_store = layer_snapshot_store();
474 EXPECT_EQ(0u, snapshot_store.Size());
475}

◆ TEST_F() [118/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
OverflowCachedDisplayListOpacityInheritance   
)

Definition at line 573 of file display_list_layer_unittests.cc.

573 {
574 use_mock_raster_cache();
575 PrerollContext* context = preroll_context();
576 int per_frame =
577 RasterCacheUtil::kDefaultPictureAndDisplayListCacheLimitPerFrame;
578 int layer_count = per_frame + 1;
579 SkPoint opacity_offset = {10, 10};
580 auto opacity_layer = std::make_shared<OpacityLayer>(0.5f, opacity_offset);
581 std::vector<std::shared_ptr<DisplayListLayer>> layers;
582 for (int i = 0; i < layer_count; i++) {
583 DisplayListBuilder builder(false);
584 builder.DrawRect({0, 0, 100, 100}, DlPaint());
585 builder.DrawRect({50, 50, 100, 100}, DlPaint());
586 auto display_list = builder.Build();
587 ASSERT_FALSE(display_list->can_apply_group_opacity());
588 SkPoint offset = {i * 200.0f, 0};
589
590 layers.push_back(
591 std::make_shared<DisplayListLayer>(offset, display_list, true, false));
592 opacity_layer->Add(layers.back());
593 }
594 for (size_t j = 0; j < context->raster_cache->access_threshold(); j++) {
595 context->raster_cache->BeginFrame();
596 for (int i = 0; i < layer_count; i++) {
597 context->renderable_state_flags = 0;
598 layers[i]->Preroll(context);
599 ASSERT_EQ(context->renderable_state_flags, 0) << "pass " << (j + 1);
600 }
601 }
602 opacity_layer->Preroll(context);
603 ASSERT_FALSE(opacity_layer->children_can_accept_opacity());
604 LayerTree::TryToRasterCache(*context->raster_cached_entries, &paint_context(),
605 false);
606 context->raster_cached_entries->clear();
607 context->raster_cache->BeginFrame();
608 for (int i = 0; i < per_frame; i++) {
609 context->renderable_state_flags = 0;
610 layers[i]->Preroll(context);
611 ASSERT_EQ(context->renderable_state_flags,
612 LayerStateStack::kCallerCanApplyOpacity)
613 << "layer " << (i + 1);
614 }
615 for (int i = per_frame; i < layer_count; i++) {
616 context->renderable_state_flags = 0;
617 layers[i]->Preroll(context);
618 ASSERT_EQ(context->renderable_state_flags, 0) << "layer " << (i + 1);
619 }
620 opacity_layer->Preroll(context);
621 ASSERT_FALSE(opacity_layer->children_can_accept_opacity());
622 LayerTree::TryToRasterCache(*context->raster_cached_entries, &paint_context(),
623 false);
624 context->raster_cached_entries->clear();
625 context->raster_cache->BeginFrame();
626 for (int i = 0; i < layer_count; i++) {
627 context->renderable_state_flags = 0;
628 layers[i]->Preroll(context);
629 ASSERT_EQ(context->renderable_state_flags,
630 LayerStateStack::kCallerCanApplyOpacity)
631 << "layer " << (i + 1);
632 }
633 opacity_layer->Preroll(context);
634 ASSERT_TRUE(opacity_layer->children_can_accept_opacity());
635}
size_t access_threshold() const
Return the number of frames that a picture must be prepared before it will be cached....
std::vector< RasterCacheItem * > * raster_cached_entries
Definition layer.h:84

◆ TEST_F() [119/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
PaintBeforePrerollInvalidDisplayListDies   
)

Definition at line 23 of file display_list_layer_unittests.cc.

23 {
24 const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
25 auto layer = std::make_shared<DisplayListLayer>(
26 layer_offset, sk_sp<DisplayList>(), false, false);
27
28 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "display_list_");
29}

◆ TEST_F() [120/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
RasterCachePreservesRTree   
)

Definition at line 297 of file display_list_layer_unittests.cc.

297 {
298 const SkRect picture1_bounds = SkRect::MakeXYWH(10, 10, 10, 10);
299 const SkRect picture2_bounds = SkRect::MakeXYWH(15, 15, 10, 10);
300 DisplayListBuilder builder(true);
301 builder.DrawRect(picture1_bounds, DlPaint());
302 builder.DrawRect(picture2_bounds, DlPaint());
303 auto display_list = builder.Build();
304 auto display_list_layer = std::make_shared<DisplayListLayer>(
305 SkPoint::Make(3, 3), display_list, true, false);
306
307 use_skia_raster_cache();
308
309 auto context = preroll_context();
310 {
311 auto mutator = context->state_stack.save();
312 mutator.transform(SkMatrix::Scale(2.0, 2.0));
313 display_list_layer->Preroll(preroll_context());
314 EXPECT_EQ(context->renderable_state_flags, 0);
315
316 // Pump the DisplayListLayer until it is ready to cache its DL
317 display_list_layer->Preroll(preroll_context());
318 display_list_layer->Preroll(preroll_context());
319 display_list_layer->Preroll(preroll_context());
320 LayerTree::TryToRasterCache(*preroll_context()->raster_cached_entries,
321 &paint_context(), false);
322 }
323
324 DisplayListBuilder expected_root_canvas(true);
325 expected_root_canvas.Scale(2.0, 2.0);
326 ASSERT_TRUE(context->raster_cache->Draw(display_list_layer->caching_key_id(),
327 expected_root_canvas, nullptr,
328 false));
329 auto root_canvas_dl = expected_root_canvas.Build();
330 const auto root_canvas_rects =
331 root_canvas_dl->rtree()->searchAndConsolidateRects(kGiantRect, true);
332 std::list<SkRect> root_canvas_rects_expected = {
333 SkRect::MakeLTRB(26, 26, 56, 56),
334 };
335 EXPECT_EQ(root_canvas_rects_expected, root_canvas_rects);
336
337 DisplayListBuilder expected_overlay_canvas(true);
338 expected_overlay_canvas.Scale(2.0, 2.0);
339 ASSERT_TRUE(context->raster_cache->Draw(display_list_layer->caching_key_id(),
340 expected_overlay_canvas, nullptr,
341 true));
342 auto overlay_canvas_dl = expected_overlay_canvas.Build();
343 const auto overlay_canvas_rects =
344 overlay_canvas_dl->rtree()->searchAndConsolidateRects(kGiantRect, true);
345
346 // Same bounds as root canvas, but preserves individual rects.
347 std::list<SkRect> overlay_canvas_rects_expected = {
348 SkRect::MakeLTRB(26, 26, 46, 36),
349 SkRect::MakeLTRB(26, 36, 56, 46),
350 SkRect::MakeLTRB(36, 46, 56, 56),
351 };
352 EXPECT_EQ(overlay_canvas_rects_expected, overlay_canvas_rects);
353};

◆ TEST_F() [121/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
SimpleDisplayList   
)

Definition at line 72 of file display_list_layer_unittests.cc.

72 {
73 const SkPoint layer_offset = SkPoint::Make(1.5f, -0.5f);
74 const SkRect picture_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
75 DisplayListBuilder builder;
76 builder.DrawRect(picture_bounds, DlPaint());
77 auto display_list = builder.Build();
78 auto layer = std::make_shared<DisplayListLayer>(layer_offset, display_list,
79 false, false);
80
81 layer->Preroll(preroll_context());
82 EXPECT_EQ(layer->paint_bounds(),
83 picture_bounds.makeOffset(layer_offset.fX, layer_offset.fY));
84 EXPECT_EQ(layer->display_list(), display_list.get());
85 EXPECT_TRUE(layer->needs_painting(paint_context()));
86
87 layer->Paint(display_list_paint_context());
88 DisplayListBuilder expected_builder;
89 /* (DisplayList)layer::Paint */ {
90 expected_builder.Save();
91 {
92 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
93 expected_builder.DrawDisplayList(display_list);
94 }
95 expected_builder.Restore();
96 }
98 DisplayListsEQ_Verbose(this->display_list(), expected_builder.Build()));
99}

◆ TEST_F() [122/876]

flutter::testing::TEST_F ( DisplayListLayerTest  ,
SimpleDisplayListOpacityInheritance   
)

Definition at line 116 of file display_list_layer_unittests.cc.

116 {
117 const SkPoint layer_offset = SkPoint::Make(1.5f, -0.5f);
118 const SkRect picture_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
119 DisplayListBuilder builder;
120 builder.DrawRect(picture_bounds, DlPaint());
121 auto display_list = builder.Build();
122 auto display_list_layer = std::make_shared<DisplayListLayer>(
123 layer_offset, display_list, false, false);
124 EXPECT_TRUE(display_list->can_apply_group_opacity());
125
126 auto context = preroll_context();
127 display_list_layer->Preroll(preroll_context());
128 EXPECT_EQ(context->renderable_state_flags,
129 LayerStateStack::kCallerCanApplyOpacity);
130
131 int opacity_alpha = 0x7F;
132 SkScalar opacity = opacity_alpha / 255.0;
133 SkPoint opacity_offset = SkPoint::Make(10, 10);
134 auto opacity_layer =
135 std::make_shared<OpacityLayer>(opacity_alpha, opacity_offset);
136 opacity_layer->Add(display_list_layer);
137 opacity_layer->Preroll(context);
138 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
139
140 DisplayListBuilder child_builder;
141 child_builder.DrawRect(picture_bounds, DlPaint());
142 auto child_display_list = child_builder.Build();
143
144 DisplayListBuilder expected_builder;
145 /* opacity_layer::Paint() */ {
146 expected_builder.Save();
147 {
148 expected_builder.Translate(opacity_offset.fX, opacity_offset.fY);
149 /* display_list_layer::Paint() */ {
150 expected_builder.Save();
151 {
152 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
153 expected_builder.DrawDisplayList(child_display_list, opacity);
154 }
155 expected_builder.Restore();
156 }
157 }
158 expected_builder.Restore();
159 }
160
161 opacity_layer->Paint(display_list_paint_context());
163 DisplayListsEQ_Verbose(this->display_list(), expected_builder.Build()));
164}

◆ TEST_F() [123/876]

flutter::testing::TEST_F ( DisplayListNopTest  ,
BlendModeAndColorAndFiltersByRendering   
)

Definition at line 4683 of file dl_rendering_unittests.cc.

4683 {
4684 auto test_mode_render = [this](DlBlendMode mode) {
4685 auto image_filter_nomtb = DlColorFilterImageFilter(color_filter_nomtb);
4686 auto image_filter_mtb = DlColorFilterImageFilter(color_filter_mtb);
4687 for (DlColor color : test_src_colors) {
4688 test_attributes_image(mode, color, nullptr, nullptr);
4689 test_attributes_image(mode, color, color_filter_nomtb.get(), nullptr);
4690 test_attributes_image(mode, color, color_filter_mtb.get(), nullptr);
4691 test_attributes_image(mode, color, nullptr, &image_filter_nomtb);
4692 test_attributes_image(mode, color, nullptr, &image_filter_mtb);
4693 }
4694 };
4695
4696#define TEST_MODE(V) test_mode_render(DlBlendMode::V);
4698#undef TEST_MODE
4699}
#define TEST_MODE(V)

◆ TEST_F() [124/876]

flutter::testing::TEST_F ( DisplayListNopTest  ,
BlendModeAndColorByRendering   
)

Definition at line 4670 of file dl_rendering_unittests.cc.

4670 {
4671 auto test_mode_render = [this](DlBlendMode mode) {
4672 // First check rendering a variety of colors onto image
4673 for (DlColor color : test_src_colors) {
4674 test_mode_color_via_rendering(mode, color);
4675 }
4676 };
4677
4678#define TEST_MODE(V) test_mode_render(DlBlendMode::V);
4680#undef TEST_MODE
4681}

◆ TEST_F() [125/876]

flutter::testing::TEST_F ( DisplayListNopTest  ,
BlendModeAndColorViaColorFilter   
)

Definition at line 4658 of file dl_rendering_unittests.cc.

4658 {
4659 auto test_mode_filter = [this](DlBlendMode mode) {
4660 for (DlColor color : test_src_colors) {
4661 test_mode_color_via_filter(mode, color);
4662 }
4663 };
4664
4665#define TEST_MODE(V) test_mode_filter(DlBlendMode::V);
4667#undef TEST_MODE
4668}

◆ TEST_F() [126/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
BlendColorFilterModifyTransparencyCheck   
)

Definition at line 4213 of file dl_rendering_unittests.cc.

4213 {
4214 auto test_mode_color = [](DlBlendMode mode, DlColor color) {
4215 std::stringstream desc_str;
4216 std::string mode_string = BlendModeToString(mode);
4217 desc_str << "blend[" << mode_string << ", " << color << "]";
4218 std::string desc = desc_str.str();
4219 DlBlendColorFilter filter(color, mode);
4220 if (filter.modifies_transparent_black()) {
4221 ASSERT_NE(DlBlendColorFilter::Make(color, mode), nullptr) << desc;
4222 }
4223
4224 DlPaint paint(DlColor(0x7f7f7f7f));
4225 DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);
4226
4227 DisplayListBuilder builder1;
4228 builder1.Translate(kTestCenter.fX, kTestCenter.fY);
4229 builder1.Rotate(45);
4230 builder1.Translate(-kTestCenter.fX, -kTestCenter.fY);
4231 builder1.DrawRect(kRenderBounds, paint);
4232 auto display_list1 = builder1.Build();
4233
4234 DisplayListBuilder builder2;
4235 builder2.Translate(kTestCenter.fX, kTestCenter.fY);
4236 builder2.Rotate(45);
4237 builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
4238 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4239 builder2.DrawRect(kRenderBounds, paint);
4240 builder2.Restore();
4241 auto display_list2 = builder2.Build();
4242
4243 for (auto& back_end : CanvasCompareTester::TestBackends) {
4244 auto provider = CanvasCompareTester::GetProvider(back_end);
4245 auto env = std::make_unique<RenderEnvironment>(
4246 provider.get(), PixelFormat::kN32PremulPixelFormat);
4247 auto results1 = env->getResult(display_list1);
4248 auto results2 = env->getResult(display_list2);
4249 int modified_transparent_pixels =
4250 CanvasCompareTester::countModifiedTransparentPixels(results1.get(),
4251 results2.get());
4252 EXPECT_EQ(filter.modifies_transparent_black(),
4253 modified_transparent_pixels != 0)
4254 << desc;
4255 }
4256 };
4257
4258 auto test_mode = [&test_mode_color](DlBlendMode mode) {
4259 test_mode_color(mode, DlColor::kTransparent());
4260 test_mode_color(mode, DlColor::kWhite());
4261 test_mode_color(mode, DlColor::kWhite().modulateOpacity(0.5));
4262 test_mode_color(mode, DlColor::kBlack());
4263 test_mode_color(mode, DlColor::kBlack().modulateOpacity(0.5));
4264 };
4265
4266#define TEST_MODE(V) test_mode(DlBlendMode::V);
4268#undef TEST_MODE
4269}
void Rotate(SkScalar degrees) override
Definition __init__.py:1
static std::string BlendModeToString(DlBlendMode mode)

◆ TEST_F() [127/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
BlendColorFilterOpacityCommuteCheck   
)

Definition at line 4271 of file dl_rendering_unittests.cc.

4271 {
4272 auto test_mode_color = [](DlBlendMode mode, DlColor color) {
4273 std::stringstream desc_str;
4274 std::string mode_string = BlendModeToString(mode);
4275 desc_str << "blend[" << mode_string << ", " << color << "]";
4276 std::string desc = desc_str.str();
4277 DlBlendColorFilter filter(color, mode);
4278 if (filter.can_commute_with_opacity()) {
4279 // If it can commute with opacity, then it might also be a NOP,
4280 // so we won't necessarily get a non-null return from |::Make()|
4281 } else {
4282 ASSERT_NE(DlBlendColorFilter::Make(color, mode), nullptr) << desc;
4283 }
4284
4285 DlPaint paint(DlColor(0x80808080));
4286 DlPaint opacity_save_paint = DlPaint().setOpacity(0.5);
4287 DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);
4288
4289 DisplayListBuilder builder1;
4290 builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
4291 builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
4292 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4293 builder1.DrawRect(kRenderBounds, paint);
4294 builder1.Restore();
4295 builder1.Restore();
4296 auto display_list1 = builder1.Build();
4297
4298 DisplayListBuilder builder2;
4299 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4300 builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
4301 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4302 builder2.DrawRect(kRenderBounds, paint);
4303 builder2.Restore();
4304 builder2.Restore();
4305 auto display_list2 = builder2.Build();
4306
4307 for (auto& back_end : CanvasCompareTester::TestBackends) {
4308 auto provider = CanvasCompareTester::GetProvider(back_end);
4309 auto env = std::make_unique<RenderEnvironment>(
4310 provider.get(), PixelFormat::kN32PremulPixelFormat);
4311 auto results1 = env->getResult(display_list1);
4312 auto results2 = env->getResult(display_list2);
4313 if (filter.can_commute_with_opacity()) {
4314 CanvasCompareTester::compareToReference(
4315 results2.get(), results1.get(), desc, nullptr, nullptr,
4316 DlColor::kTransparent(), true, kTestWidth, kTestHeight, true);
4317 } else {
4318 CanvasCompareTester::quickCompareToReference(
4319 results1.get(), results2.get(), false, desc);
4320 }
4321 }
4322 };
4323
4324 auto test_mode = [&test_mode_color](DlBlendMode mode) {
4325 test_mode_color(mode, DlColor::kTransparent());
4326 test_mode_color(mode, DlColor::kWhite());
4327 test_mode_color(mode, DlColor::kWhite().modulateOpacity(0.5));
4328 test_mode_color(mode, DlColor::kBlack());
4329 test_mode_color(mode, DlColor::kBlack().modulateOpacity(0.5));
4330 };
4331
4332#define TEST_MODE(V) test_mode(DlBlendMode::V);
4334#undef TEST_MODE
4335}
static constexpr int kTestHeight
static constexpr int kTestWidth

◆ TEST_F() [128/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAlphaColor   
)

Definition at line 2888 of file dl_rendering_unittests.cc.

2888 {
2889 // We use a non-opaque color to avoid obliterating any backdrop filter output
2890 CanvasCompareTester::RenderAll( //
2892 [=](const SkRenderContext& ctx) {
2893 ctx.canvas->drawColor(0x7FFF00FF);
2894 },
2895 [=](const DlRenderContext& ctx) {
2896 ctx.canvas->DrawColor(DlColor(0x7FFF00FF));
2897 },
2898 kDrawColorFlags));
2899}

◆ TEST_F() [129/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawArc   
)

Definition at line 3085 of file dl_rendering_unittests.cc.

3085 {
3086 CanvasCompareTester::RenderAll( //
3088 [=](const SkRenderContext& ctx) { //
3089 ctx.canvas->drawArc(kRenderBounds, 60, 330, false, ctx.paint);
3090 },
3091 [=](const DlRenderContext& ctx) { //
3092 ctx.canvas->DrawArc(kRenderBounds, 60, 330, false, ctx.paint);
3093 },
3094 kDrawArcNoCenterFlags));
3095}

◆ TEST_F() [130/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawArcCenter   
)

Definition at line 3097 of file dl_rendering_unittests.cc.

3097 {
3098 // Center arcs that inscribe nearly a whole circle except for a small
3099 // arc extent gap have 2 angles that may appear or disappear at the
3100 // various miter limits tested (0, 4, and 10).
3101 // The center angle here is 12 degrees which shows a miter
3102 // at limit=10, but not 0 or 4.
3103 // The arcs at the corners where it turns in towards the
3104 // center show miters at 4 and 10, but not 0.
3105 // Limit == 0, neither corner does a miter
3106 // Limit == 4, only the edge "turn-in" corners miter
3107 // Limit == 10, edge and center corners all miter
3108 CanvasCompareTester::RenderAll( //
3110 [=](const SkRenderContext& ctx) { //
3111 ctx.canvas->drawArc(kRenderBounds, 60, 360 - 12, true, ctx.paint);
3112 },
3113 [=](const DlRenderContext& ctx) { //
3114 ctx.canvas->DrawArc(kRenderBounds, 60, 360 - 12, true, ctx.paint);
3115 },
3116 kDrawArcWithCenterFlags)
3117 .set_draw_arc_center());
3118}

◆ TEST_F() [131/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAtlasLinear   
)

Definition at line 3598 of file dl_rendering_unittests.cc.

3598 {
3599 const SkRSXform xform[] = {
3600 // clang-format off
3601 { 1.2f, 0.0f, kRenderLeft, kRenderTop},
3602 { 0.0f, 1.2f, kRenderRight, kRenderTop},
3603 {-1.2f, 0.0f, kRenderRight, kRenderBottom},
3604 { 0.0f, -1.2f, kRenderLeft, kRenderBottom},
3605 // clang-format on
3606 };
3607 const SkRect tex[] = {
3608 // clang-format off
3613 // clang-format on
3614 };
3615 const SkColor sk_colors[] = {
3620 };
3621 const DlColor dl_colors[] = {
3622 DlColor::kBlue(),
3623 DlColor::kGreen(),
3624 DlColor::kYellow(),
3625 DlColor::kMagenta(),
3626 };
3627 const DlImageSampling dl_sampling = DlImageSampling::kLinear;
3628 const SkSamplingOptions sk_sampling = SkImageSampling::kLinear;
3629 CanvasCompareTester::RenderAll( //
3630 TestParameters(
3631 [=](const SkRenderContext& ctx) {
3632 ctx.canvas->drawAtlas(ctx.image.get(), xform, tex, sk_colors, 2,
3633 SkBlendMode::kSrcOver, sk_sampling, //
3634 nullptr, &ctx.paint);
3635 },
3636 [=](const DlRenderContext& ctx) {
3637 ctx.canvas->DrawAtlas(ctx.image, xform, tex, dl_colors, 2,
3638 DlBlendMode::kSrcOver, dl_sampling, //
3639 nullptr, &ctx.paint);
3640 },
3641 kDrawAtlasWithPaintFlags));
3642}
constexpr SkColor SK_ColorMAGENTA
Definition SkColor.h:147
constexpr int kRenderHalfHeight
RenderContext< DlCanvas *, const DlPaint &, sk_sp< DlImage > > DlRenderContext

◆ TEST_F() [132/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAtlasNearest   
)

Definition at line 3506 of file dl_rendering_unittests.cc.

3506 {
3507 const SkRSXform xform[] = {
3508 // clang-format off
3509 { 1.2f, 0.0f, kRenderLeft, kRenderTop},
3510 { 0.0f, 1.2f, kRenderRight, kRenderTop},
3511 {-1.2f, 0.0f, kRenderRight, kRenderBottom},
3512 { 0.0f, -1.2f, kRenderLeft, kRenderBottom},
3513 // clang-format on
3514 };
3515 const SkRect tex[] = {
3516 // clang-format off
3521 // clang-format on
3522 };
3523 const SkColor sk_colors[] = {
3528 };
3529 const DlColor dl_colors[] = {
3530 DlColor::kBlue(),
3531 DlColor::kGreen(),
3532 DlColor::kYellow(),
3533 DlColor::kMagenta(),
3534 };
3535 const DlImageSampling dl_sampling = DlImageSampling::kNearestNeighbor;
3536 const SkSamplingOptions sk_sampling = SkImageSampling::kNearestNeighbor;
3537 CanvasCompareTester::RenderAll( //
3538 TestParameters(
3539 [=](const SkRenderContext& ctx) {
3540 ctx.canvas->drawAtlas(ctx.image.get(), xform, tex, sk_colors, 4,
3541 SkBlendMode::kSrcOver, sk_sampling, nullptr,
3542 &ctx.paint);
3543 },
3544 [=](const DlRenderContext& ctx) {
3545 ctx.canvas->DrawAtlas(ctx.image, xform, tex, dl_colors, 4,
3546 DlBlendMode::kSrcOver, dl_sampling, nullptr,
3547 &ctx.paint);
3548 },
3549 kDrawAtlasWithPaintFlags));
3550}

◆ TEST_F() [133/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAtlasNearestNoPaint   
)

Definition at line 3552 of file dl_rendering_unittests.cc.

3552 {
3553 const SkRSXform xform[] = {
3554 // clang-format off
3555 { 1.2f, 0.0f, kRenderLeft, kRenderTop},
3556 { 0.0f, 1.2f, kRenderRight, kRenderTop},
3557 {-1.2f, 0.0f, kRenderRight, kRenderBottom},
3558 { 0.0f, -1.2f, kRenderLeft, kRenderBottom},
3559 // clang-format on
3560 };
3561 const SkRect tex[] = {
3562 // clang-format off
3567 // clang-format on
3568 };
3569 const SkColor sk_colors[] = {
3574 };
3575 const DlColor dl_colors[] = {
3576 DlColor::kBlue(),
3577 DlColor::kGreen(),
3578 DlColor::kYellow(),
3579 DlColor::kMagenta(),
3580 };
3581 const DlImageSampling dl_sampling = DlImageSampling::kNearestNeighbor;
3582 const SkSamplingOptions sk_sampling = SkImageSampling::kNearestNeighbor;
3583 CanvasCompareTester::RenderAll( //
3584 TestParameters(
3585 [=](const SkRenderContext& ctx) {
3586 ctx.canvas->drawAtlas(ctx.image.get(), xform, tex, sk_colors, 4,
3587 SkBlendMode::kSrcOver, sk_sampling, //
3588 nullptr, nullptr);
3589 },
3590 [=](const DlRenderContext& ctx) {
3591 ctx.canvas->DrawAtlas(ctx.image, xform, tex, dl_colors, 4,
3592 DlBlendMode::kSrcOver, dl_sampling, //
3593 nullptr, nullptr);
3594 },
3595 kDrawAtlasFlags));
3596}

◆ TEST_F() [134/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawCircle   
)

Definition at line 3007 of file dl_rendering_unittests.cc.

3007 {
3008 CanvasCompareTester::RenderAll( //
3010 [=](const SkRenderContext& ctx) { //
3011 ctx.canvas->drawCircle(kTestCenter, kRenderRadius, ctx.paint);
3012 },
3013 [=](const DlRenderContext& ctx) { //
3014 ctx.canvas->DrawCircle(kTestCenter, kRenderRadius, ctx.paint);
3015 },
3016 kDrawCircleFlags));
3017}

◆ TEST_F() [135/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawDiagonalLines   
)

Definition at line 2901 of file dl_rendering_unittests.cc.

2901 {
2902 SkPoint p1 = SkPoint::Make(kRenderLeft, kRenderTop);
2903 SkPoint p2 = SkPoint::Make(kRenderRight, kRenderBottom);
2904 SkPoint p3 = SkPoint::Make(kRenderLeft, kRenderBottom);
2905 SkPoint p4 = SkPoint::Make(kRenderRight, kRenderTop);
2906 // Adding some edge center to edge center diagonals to better fill
2907 // out the RRect Clip so bounds checking sees less empty bounds space.
2908 SkPoint p5 = SkPoint::Make(kRenderCenterX, kRenderTop);
2909 SkPoint p6 = SkPoint::Make(kRenderRight, kRenderCenterY);
2910 SkPoint p7 = SkPoint::Make(kRenderLeft, kRenderCenterY);
2911 SkPoint p8 = SkPoint::Make(kRenderCenterX, kRenderBottom);
2912
2913 CanvasCompareTester::RenderAll( //
2915 [=](const SkRenderContext& ctx) { //
2916 // Skia requires kStroke style on horizontal and vertical
2917 // lines to get the bounds correct.
2918 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
2919 SkPaint p = ctx.paint;
2920 p.setStyle(SkPaint::kStroke_Style);
2921 ctx.canvas->drawLine(p1, p2, p);
2922 ctx.canvas->drawLine(p3, p4, p);
2923 ctx.canvas->drawLine(p5, p6, p);
2924 ctx.canvas->drawLine(p7, p8, p);
2925 },
2926 [=](const DlRenderContext& ctx) { //
2927 ctx.canvas->DrawLine(p1, p2, ctx.paint);
2928 ctx.canvas->DrawLine(p3, p4, ctx.paint);
2929 ctx.canvas->DrawLine(p5, p6, ctx.paint);
2930 ctx.canvas->DrawLine(p7, p8, ctx.paint);
2931 },
2932 kDrawLineFlags)
2933 .set_draw_line());
2934}

◆ TEST_F() [136/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawDisplayList   
)

Definition at line 3663 of file dl_rendering_unittests.cc.

3663 {
3664 sk_sp<DisplayList> display_list = makeTestDisplayList();
3665 CanvasCompareTester::RenderAll( //
3667 [=](const SkRenderContext& ctx) { //
3668 DlSkCanvasAdapter(ctx.canvas).DrawDisplayList(display_list);
3669 },
3670 [=](const DlRenderContext& ctx) { //
3671 ctx.canvas->DrawDisplayList(display_list);
3672 },
3673 kDrawDisplayListFlags)
3674 .set_draw_display_list());
3675}
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
sk_sp< DisplayList > makeTestDisplayList()

◆ TEST_F() [137/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawDRRect   
)

Definition at line 3033 of file dl_rendering_unittests.cc.

3033 {
3034 SkRRect outer = SkRRect::MakeRectXY(kRenderBounds, kRenderCornerRadius,
3035 kRenderCornerRadius);
3036 SkRect inner_bounds = kRenderBounds.makeInset(30.0, 30.0);
3037 SkRRect inner = SkRRect::MakeRectXY(inner_bounds, kRenderCornerRadius,
3038 kRenderCornerRadius);
3039 CanvasCompareTester::RenderAll( //
3041 [=](const SkRenderContext& ctx) { //
3042 ctx.canvas->drawDRRect(outer, inner, ctx.paint);
3043 },
3044 [=](const DlRenderContext& ctx) { //
3045 ctx.canvas->DrawDRRect(outer, inner, ctx.paint);
3046 },
3047 kDrawDRRectFlags));
3048}
constexpr SkRect kRenderBounds

◆ TEST_F() [138/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawHorizontalLine   
)

Definition at line 2936 of file dl_rendering_unittests.cc.

2936 {
2937 SkPoint p1 = SkPoint::Make(kRenderLeft, kRenderCenterY);
2938 SkPoint p2 = SkPoint::Make(kRenderRight, kRenderCenterY);
2939
2940 CanvasCompareTester::RenderAll( //
2942 [=](const SkRenderContext& ctx) { //
2943 // Skia requires kStroke style on horizontal and vertical
2944 // lines to get the bounds correct.
2945 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
2946 SkPaint p = ctx.paint;
2947 p.setStyle(SkPaint::kStroke_Style);
2948 ctx.canvas->drawLine(p1, p2, p);
2949 },
2950 [=](const DlRenderContext& ctx) { //
2951 ctx.canvas->DrawLine(p1, p2, ctx.paint);
2952 },
2953 kDrawHVLineFlags)
2954 .set_draw_line()
2956}

◆ TEST_F() [139/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageLinear   
)

Definition at line 3389 of file dl_rendering_unittests.cc.

3389 {
3390 CanvasCompareTester::RenderAll( //
3392 [=](const SkRenderContext& ctx) {
3393 ctx.canvas->drawImage(ctx.image, kRenderLeft, kRenderTop,
3394 SkImageSampling::kLinear, &ctx.paint);
3395 },
3396 [=](const DlRenderContext& ctx) {
3397 ctx.canvas->DrawImage(ctx.image,
3398 SkPoint::Make(kRenderLeft, kRenderTop),
3399 DlImageSampling::kLinear, &ctx.paint);
3400 },
3401 kDrawImageWithPaintFlags));
3402}

◆ TEST_F() [140/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNearest   
)

Definition at line 3357 of file dl_rendering_unittests.cc.

3357 {
3358 CanvasCompareTester::RenderAll( //
3360 [=](const SkRenderContext& ctx) {
3361 ctx.canvas->drawImage(ctx.image, kRenderLeft, kRenderTop,
3362 SkImageSampling::kNearestNeighbor,
3363 &ctx.paint);
3364 },
3365 [=](const DlRenderContext& ctx) {
3366 ctx.canvas->DrawImage(ctx.image, //
3367 SkPoint::Make(kRenderLeft, kRenderTop),
3368 DlImageSampling::kNearestNeighbor,
3369 &ctx.paint);
3370 },
3371 kDrawImageWithPaintFlags));
3372}

◆ TEST_F() [141/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNearestNoPaint   
)

Definition at line 3374 of file dl_rendering_unittests.cc.

3374 {
3375 CanvasCompareTester::RenderAll( //
3377 [=](const SkRenderContext& ctx) {
3378 ctx.canvas->drawImage(ctx.image, kRenderLeft, kRenderTop,
3379 SkImageSampling::kNearestNeighbor, nullptr);
3380 },
3381 [=](const DlRenderContext& ctx) {
3382 ctx.canvas->DrawImage(ctx.image,
3383 SkPoint::Make(kRenderLeft, kRenderTop),
3384 DlImageSampling::kNearestNeighbor, nullptr);
3385 },
3386 kDrawImageFlags));
3387}

◆ TEST_F() [142/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNineLinear   
)

Definition at line 3490 of file dl_rendering_unittests.cc.

3490 {
3491 SkIRect src = SkIRect::MakeWH(kRenderWidth, kRenderHeight).makeInset(25, 25);
3492 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3493 CanvasCompareTester::RenderAll( //
3495 [=](const SkRenderContext& ctx) {
3496 ctx.canvas->drawImageNine(ctx.image.get(), src, dst,
3498 },
3499 [=](const DlRenderContext& ctx) {
3500 ctx.canvas->DrawImageNine(ctx.image, src, dst,
3501 DlFilterMode::kLinear, &ctx.paint);
3502 },
3503 kDrawImageNineWithPaintFlags));
3504}
SkIRect makeInset(int32_t dx, int32_t dy) const
Definition SkRect.h:332

◆ TEST_F() [143/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNineNearest   
)

Definition at line 3458 of file dl_rendering_unittests.cc.

3458 {
3459 SkIRect src = SkIRect::MakeWH(kRenderWidth, kRenderHeight).makeInset(25, 25);
3460 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3461 CanvasCompareTester::RenderAll( //
3463 [=](const SkRenderContext& ctx) {
3464 ctx.canvas->drawImageNine(ctx.image.get(), src, dst,
3466 },
3467 [=](const DlRenderContext& ctx) {
3468 ctx.canvas->DrawImageNine(ctx.image, src, dst,
3469 DlFilterMode::kNearest, &ctx.paint);
3470 },
3471 kDrawImageNineWithPaintFlags));
3472}

◆ TEST_F() [144/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNineNearestNoPaint   
)

Definition at line 3474 of file dl_rendering_unittests.cc.

3474 {
3475 SkIRect src = SkIRect::MakeWH(kRenderWidth, kRenderHeight).makeInset(25, 25);
3476 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3477 CanvasCompareTester::RenderAll( //
3479 [=](const SkRenderContext& ctx) {
3480 ctx.canvas->drawImageNine(ctx.image.get(), src, dst,
3481 SkFilterMode::kNearest, nullptr);
3482 },
3483 [=](const DlRenderContext& ctx) {
3484 ctx.canvas->DrawImageNine(ctx.image, src, dst,
3485 DlFilterMode::kNearest, nullptr);
3486 },
3487 kDrawImageNineFlags));
3488}

◆ TEST_F() [145/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageRectLinear   
)

Definition at line 3440 of file dl_rendering_unittests.cc.

3440 {
3441 SkRect src = SkRect::MakeIWH(kRenderWidth, kRenderHeight).makeInset(5, 5);
3442 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3443 CanvasCompareTester::RenderAll( //
3445 [=](const SkRenderContext& ctx) {
3446 ctx.canvas->drawImageRect(
3447 ctx.image, src, dst, SkImageSampling::kLinear, //
3449 },
3450 [=](const DlRenderContext& ctx) { //
3451 ctx.canvas->DrawImageRect(
3452 ctx.image, src, dst, DlImageSampling::kLinear, //
3453 &ctx.paint, DlCanvas::SrcRectConstraint::kFast);
3454 },
3455 kDrawImageRectWithPaintFlags));
3456}

◆ TEST_F() [146/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageRectNearest   
)

Definition at line 3404 of file dl_rendering_unittests.cc.

3404 {
3405 SkRect src = SkRect::MakeIWH(kRenderWidth, kRenderHeight).makeInset(5, 5);
3406 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3407 CanvasCompareTester::RenderAll( //
3409 [=](const SkRenderContext& ctx) {
3410 ctx.canvas->drawImageRect(
3411 ctx.image, src, dst, SkImageSampling::kNearestNeighbor,
3413 },
3414 [=](const DlRenderContext& ctx) {
3415 ctx.canvas->DrawImageRect(
3416 ctx.image, src, dst, DlImageSampling::kNearestNeighbor,
3417 &ctx.paint, DlCanvas::SrcRectConstraint::kFast);
3418 },
3419 kDrawImageRectWithPaintFlags));
3420}

◆ TEST_F() [147/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageRectNearestNoPaint   
)

Definition at line 3422 of file dl_rendering_unittests.cc.

3422 {
3423 SkRect src = SkRect::MakeIWH(kRenderWidth, kRenderHeight).makeInset(5, 5);
3424 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3425 CanvasCompareTester::RenderAll( //
3427 [=](const SkRenderContext& ctx) {
3428 ctx.canvas->drawImageRect(
3429 ctx.image, src, dst, SkImageSampling::kNearestNeighbor, //
3431 },
3432 [=](const DlRenderContext& ctx) {
3433 ctx.canvas->DrawImageRect(
3434 ctx.image, src, dst, DlImageSampling::kNearestNeighbor, //
3435 nullptr, DlCanvas::SrcRectConstraint::kFast);
3436 },
3437 kDrawImageRectFlags));
3438}

◆ TEST_F() [148/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawOpaqueColor   
)

Definition at line 2863 of file dl_rendering_unittests.cc.

2863 {
2864 // We use a non-opaque color to avoid obliterating any backdrop filter output
2865 CanvasCompareTester::RenderAll( //
2867 [=](const SkRenderContext& ctx) {
2868 // DrawColor is not tested against attributes because it is supposed
2869 // to ignore them. So, if the paint has an alpha, it is because we
2870 // are doing a saveLayer+backdrop test and we need to not flood over
2871 // the backdrop output with a solid color. So, we perform an alpha
2872 // drawColor for that case only.
2873 SkColor color = SkColorSetA(SK_ColorMAGENTA, ctx.paint.getAlpha());
2874 ctx.canvas->drawColor(color);
2875 },
2876 [=](const DlRenderContext& ctx) {
2877 // DrawColor is not tested against attributes because it is supposed
2878 // to ignore them. So, if the paint has an alpha, it is because we
2879 // are doing a saveLayer+backdrop test and we need to not flood over
2880 // the backdrop output with a solid color. So, we transfer the alpha
2881 // from the paint for that case only.
2882 ctx.canvas->DrawColor(
2883 DlColor::kMagenta().withAlpha(ctx.paint.getAlpha()));
2884 },
2885 kDrawColorFlags));
2886}

◆ TEST_F() [149/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawOval   
)

Definition at line 2993 of file dl_rendering_unittests.cc.

2993 {
2994 SkRect rect = kRenderBounds.makeInset(0, 10);
2995
2996 CanvasCompareTester::RenderAll( //
2998 [=](const SkRenderContext& ctx) { //
2999 ctx.canvas->drawOval(rect, ctx.paint);
3000 },
3001 [=](const DlRenderContext& ctx) { //
3002 ctx.canvas->DrawOval(rect, ctx.paint);
3003 },
3004 kDrawOvalFlags));
3005}

◆ TEST_F() [150/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPaint   
)

Definition at line 2851 of file dl_rendering_unittests.cc.

2851 {
2852 CanvasCompareTester::RenderAll( //
2854 [=](const SkRenderContext& ctx) { //
2855 ctx.canvas->drawPaint(ctx.paint);
2856 },
2857 [=](const DlRenderContext& ctx) { //
2858 ctx.canvas->DrawPaint(ctx.paint);
2859 },
2860 kDrawPaintFlags));
2861}

◆ TEST_F() [151/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPath   
)

Definition at line 3050 of file dl_rendering_unittests.cc.

3050 {
3051 SkPath path;
3052
3053 // unclosed lines to show some caps
3054 path.moveTo(kRenderLeft + 15, kRenderTop + 15);
3055 path.lineTo(kRenderRight - 15, kRenderBottom - 15);
3056 path.moveTo(kRenderLeft + 15, kRenderBottom - 15);
3057 path.lineTo(kRenderRight - 15, kRenderTop + 15);
3058
3059 path.addRect(kRenderBounds);
3060
3061 // miter diamonds horizontally and vertically to show miters
3062 path.moveTo(kVerticalMiterDiamondPoints[0]);
3063 for (int i = 1; i < kVerticalMiterDiamondPointCount; i++) {
3064 path.lineTo(kVerticalMiterDiamondPoints[i]);
3065 }
3066 path.close();
3067 path.moveTo(kHorizontalMiterDiamondPoints[0]);
3068 for (int i = 1; i < kHorizontalMiterDiamondPointCount; i++) {
3069 path.lineTo(kHorizontalMiterDiamondPoints[i]);
3070 }
3071 path.close();
3072
3073 CanvasCompareTester::RenderAll( //
3074 TestParameters(
3075 [=](const SkRenderContext& ctx) { //
3076 ctx.canvas->drawPath(path, ctx.paint);
3077 },
3078 [=](const DlRenderContext& ctx) { //
3079 ctx.canvas->DrawPath(path, ctx.paint);
3080 },
3081 kDrawPathFlags)
3082 .set_draw_path());
3083}
const int kVerticalMiterDiamondPointCount

◆ TEST_F() [152/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPointsAsLines   
)

Definition at line 3173 of file dl_rendering_unittests.cc.

3173 {
3174 const SkScalar x0 = kRenderLeft + 1;
3175 const SkScalar x1 = kRenderLeft + 16;
3176 const SkScalar x2 = kRenderRight - 16;
3177 const SkScalar x3 = kRenderRight - 1;
3178
3179 const SkScalar y0 = kRenderTop;
3180 const SkScalar y1 = kRenderTop + 16;
3181 const SkScalar y2 = kRenderBottom - 16;
3182 const SkScalar y3 = kRenderBottom;
3183
3184 // clang-format off
3185 const SkPoint points[] = {
3186 // Outer box
3187 {x0, y0}, {x3, y0},
3188 {x3, y0}, {x3, y3},
3189 {x3, y3}, {x0, y3},
3190 {x0, y3}, {x0, y0},
3191
3192 // Diagonals
3193 {x0, y0}, {x3, y3}, {x3, y0}, {x0, y3},
3194
3195 // Inner box
3196 {x1, y1}, {x2, y1},
3197 {x2, y1}, {x2, y2},
3198 {x2, y2}, {x1, y2},
3199 {x1, y2}, {x1, y1},
3200 };
3201 // clang-format on
3202
3203 const int count = sizeof(points) / sizeof(points[0]);
3204 ASSERT_TRUE((count & 1) == 0);
3205 CanvasCompareTester::RenderAll( //
3206 TestParameters(
3207 [=](const SkRenderContext& ctx) {
3208 // Skia requires kStroke style on horizontal and vertical
3209 // lines to get the bounds correct.
3210 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
3211 SkPaint p = ctx.paint;
3212 p.setStyle(SkPaint::kStroke_Style);
3214 ctx.canvas->drawPoints(mode, count, points, p);
3215 },
3216 [=](const DlRenderContext& ctx) {
3217 auto mode = PointMode::kLines;
3218 ctx.canvas->DrawPoints(mode, count, points, ctx.paint);
3219 },
3220 kDrawPointsAsLinesFlags));
3221}
@ kLines_PointMode
draw each pair of points as a line segment
Definition SkCanvas.h:1242

◆ TEST_F() [153/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPointsAsPoints   
)

Definition at line 3120 of file dl_rendering_unittests.cc.

3120 {
3121 // The +/- 16 points are designed to fall just inside the clips
3122 // that are tested against so we avoid lots of undrawn pixels
3123 // in the accumulated bounds.
3124 const SkScalar x0 = kRenderLeft;
3125 const SkScalar x1 = kRenderLeft + 16;
3126 const SkScalar x2 = (kRenderLeft + kRenderCenterX) * 0.5;
3127 const SkScalar x3 = kRenderCenterX + 0.1;
3128 const SkScalar x4 = (kRenderRight + kRenderCenterX) * 0.5;
3129 const SkScalar x5 = kRenderRight - 16;
3130 const SkScalar x6 = kRenderRight;
3131
3132 const SkScalar y0 = kRenderTop;
3133 const SkScalar y1 = kRenderTop + 16;
3134 const SkScalar y2 = (kRenderTop + kRenderCenterY) * 0.5;
3135 const SkScalar y3 = kRenderCenterY + 0.1;
3136 const SkScalar y4 = (kRenderBottom + kRenderCenterY) * 0.5;
3137 const SkScalar y5 = kRenderBottom - 16;
3138 const SkScalar y6 = kRenderBottom;
3139
3140 // clang-format off
3141 const SkPoint points[] = {
3142 {x0, y0}, {x1, y0}, {x2, y0}, {x3, y0}, {x4, y0}, {x5, y0}, {x6, y0},
3143 {x0, y1}, {x1, y1}, {x2, y1}, {x3, y1}, {x4, y1}, {x5, y1}, {x6, y1},
3144 {x0, y2}, {x1, y2}, {x2, y2}, {x3, y2}, {x4, y2}, {x5, y2}, {x6, y2},
3145 {x0, y3}, {x1, y3}, {x2, y3}, {x3, y3}, {x4, y3}, {x5, y3}, {x6, y3},
3146 {x0, y4}, {x1, y4}, {x2, y4}, {x3, y4}, {x4, y4}, {x5, y4}, {x6, y4},
3147 {x0, y5}, {x1, y5}, {x2, y5}, {x3, y5}, {x4, y5}, {x5, y5}, {x6, y5},
3148 {x0, y6}, {x1, y6}, {x2, y6}, {x3, y6}, {x4, y6}, {x5, y6}, {x6, y6},
3149 };
3150 // clang-format on
3151 const int count = sizeof(points) / sizeof(points[0]);
3152
3153 CanvasCompareTester::RenderAll( //
3154 TestParameters(
3155 [=](const SkRenderContext& ctx) {
3156 // Skia requires kStroke style on horizontal and vertical
3157 // lines to get the bounds correct.
3158 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
3159 SkPaint p = ctx.paint;
3160 p.setStyle(SkPaint::kStroke_Style);
3162 ctx.canvas->drawPoints(mode, count, points, p);
3163 },
3164 [=](const DlRenderContext& ctx) {
3165 auto mode = PointMode::kPoints;
3166 ctx.canvas->DrawPoints(mode, count, points, ctx.paint);
3167 },
3168 kDrawPointsAsPointsFlags)
3169 .set_draw_line()
3170 .set_ignores_dashes());
3171}
@ kPoints_PointMode
draw each point separately
Definition SkCanvas.h:1241

◆ TEST_F() [154/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPointsAsPolygon   
)

Definition at line 3223 of file dl_rendering_unittests.cc.

3223 {
3224 const SkPoint points1[] = {
3225 // RenderBounds box with a diamond
3226 SkPoint::Make(kRenderLeft, kRenderTop),
3227 SkPoint::Make(kRenderRight, kRenderTop),
3228 SkPoint::Make(kRenderRight, kRenderBottom),
3229 SkPoint::Make(kRenderLeft, kRenderBottom),
3230 SkPoint::Make(kRenderLeft, kRenderTop),
3231 SkPoint::Make(kRenderCenterX, kRenderTop),
3232 SkPoint::Make(kRenderRight, kRenderCenterY),
3233 SkPoint::Make(kRenderCenterX, kRenderBottom),
3234 SkPoint::Make(kRenderLeft, kRenderCenterY),
3235 };
3236 const int count1 = sizeof(points1) / sizeof(points1[0]);
3237
3238 CanvasCompareTester::RenderAll( //
3239 TestParameters(
3240 [=](const SkRenderContext& ctx) {
3241 // Skia requires kStroke style on horizontal and vertical
3242 // lines to get the bounds correct.
3243 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
3244 SkPaint p = ctx.paint;
3245 p.setStyle(SkPaint::kStroke_Style);
3247 ctx.canvas->drawPoints(mode, count1, points1, p);
3248 },
3249 [=](const DlRenderContext& ctx) {
3250 auto mode = PointMode::kPolygon;
3251 ctx.canvas->DrawPoints(mode, count1, points1, ctx.paint);
3252 },
3253 kDrawPointsAsPolygonFlags));
3254}
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition SkCanvas.h:1243

◆ TEST_F() [155/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawRect   
)

Definition at line 2980 of file dl_rendering_unittests.cc.

2980 {
2981 // Bounds are offset by 0.5 pixels to induce AA
2982 CanvasCompareTester::RenderAll( //
2984 [=](const SkRenderContext& ctx) { //
2985 ctx.canvas->drawRect(kRenderBounds.makeOffset(0.5, 0.5), ctx.paint);
2986 },
2987 [=](const DlRenderContext& ctx) { //
2988 ctx.canvas->DrawRect(kRenderBounds.makeOffset(0.5, 0.5), ctx.paint);
2989 },
2990 kDrawRectFlags));
2991}

◆ TEST_F() [156/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawRRect   
)

Definition at line 3019 of file dl_rendering_unittests.cc.

3019 {
3020 SkRRect rrect = SkRRect::MakeRectXY(kRenderBounds, kRenderCornerRadius,
3021 kRenderCornerRadius);
3022 CanvasCompareTester::RenderAll( //
3024 [=](const SkRenderContext& ctx) { //
3025 ctx.canvas->drawRRect(rrect, ctx.paint);
3026 },
3027 [=](const DlRenderContext& ctx) { //
3028 ctx.canvas->DrawRRect(rrect, ctx.paint);
3029 },
3030 kDrawRRectFlags));
3031}

◆ TEST_F() [157/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawShadow   
)

Definition at line 3724 of file dl_rendering_unittests.cc.

3724 {
3725 SkPath path;
3726 path.addRoundRect(
3727 {
3728 kRenderLeft + 10,
3729 kRenderTop,
3730 kRenderRight - 10,
3731 kRenderBottom - 20,
3732 },
3733 kRenderCornerRadius, kRenderCornerRadius);
3734 const DlColor color = DlColor::kDarkGrey();
3735 const SkScalar elevation = 5;
3736
3737 CanvasCompareTester::RenderAll( //
3738 TestParameters(
3739 [=](const SkRenderContext& ctx) { //
3740 DlSkCanvasDispatcher::DrawShadow(ctx.canvas, path, color, elevation,
3741 false, 1.0);
3742 },
3743 [=](const DlRenderContext& ctx) { //
3744 ctx.canvas->DrawShadow(path, color, elevation, false, 1.0);
3745 },
3746 kDrawShadowFlags),
3747 CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3));
3748}

◆ TEST_F() [158/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawShadowDpr   
)

Definition at line 3776 of file dl_rendering_unittests.cc.

3776 {
3777 SkPath path;
3778 path.addRoundRect(
3779 {
3780 kRenderLeft + 10,
3781 kRenderTop,
3782 kRenderRight - 10,
3783 kRenderBottom - 20,
3784 },
3785 kRenderCornerRadius, kRenderCornerRadius);
3786 const DlColor color = DlColor::kDarkGrey();
3787 const SkScalar elevation = 5;
3788
3789 CanvasCompareTester::RenderAll( //
3790 TestParameters(
3791 [=](const SkRenderContext& ctx) { //
3792 DlSkCanvasDispatcher::DrawShadow(ctx.canvas, path, color, elevation,
3793 false, 1.5);
3794 },
3795 [=](const DlRenderContext& ctx) { //
3796 ctx.canvas->DrawShadow(path, color, elevation, false, 1.5);
3797 },
3798 kDrawShadowFlags),
3799 CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3));
3800}

◆ TEST_F() [159/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawShadowTransparentOccluder   
)

Definition at line 3750 of file dl_rendering_unittests.cc.

3750 {
3751 SkPath path;
3752 path.addRoundRect(
3753 {
3754 kRenderLeft + 10,
3755 kRenderTop,
3756 kRenderRight - 10,
3757 kRenderBottom - 20,
3758 },
3759 kRenderCornerRadius, kRenderCornerRadius);
3760 const DlColor color = DlColor::kDarkGrey();
3761 const SkScalar elevation = 5;
3762
3763 CanvasCompareTester::RenderAll( //
3764 TestParameters(
3765 [=](const SkRenderContext& ctx) { //
3766 DlSkCanvasDispatcher::DrawShadow(ctx.canvas, path, color, elevation,
3767 true, 1.0);
3768 },
3769 [=](const DlRenderContext& ctx) { //
3770 ctx.canvas->DrawShadow(path, color, elevation, true, 1.0);
3771 },
3772 kDrawShadowFlags),
3773 CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3));
3774}

◆ TEST_F() [160/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawTextBlob   
)

Definition at line 3677 of file dl_rendering_unittests.cc.

3677 {
3678 // TODO(https://github.com/flutter/flutter/issues/82202): Remove once the
3679 // performance overlay can use Fuchsia's font manager instead of the empty
3680 // default.
3681#if defined(OS_FUCHSIA)
3682 GTEST_SKIP() << "Rendering comparisons require a valid default font manager";
3683#else
3684 sk_sp<SkTextBlob> blob =
3685 CanvasCompareTester::MakeTextBlob("Testing", kRenderHeight * 0.33f);
3686#ifdef IMPELLER_SUPPORTS_RENDERING
3688#endif // IMPELLER_SUPPORTS_RENDERING
3689 SkScalar render_y_1_3 = kRenderTop + kRenderHeight * 0.3;
3690 SkScalar render_y_2_3 = kRenderTop + kRenderHeight * 0.6;
3691 CanvasCompareTester::RenderAll( //
3693 [=](const SkRenderContext& ctx) {
3694 auto paint = ctx.paint;
3695 ctx.canvas->drawTextBlob(blob, kRenderLeft, render_y_1_3, paint);
3696 ctx.canvas->drawTextBlob(blob, kRenderLeft, render_y_2_3, paint);
3697 ctx.canvas->drawTextBlob(blob, kRenderLeft, kRenderBottom, paint);
3698 },
3699 [=](const DlRenderContext& ctx) {
3700 auto paint = ctx.paint;
3701 ctx.canvas->DrawTextBlob(blob, kRenderLeft, render_y_1_3, paint);
3702 ctx.canvas->DrawTextBlob(blob, kRenderLeft, render_y_2_3, paint);
3703 ctx.canvas->DrawTextBlob(blob, kRenderLeft, kRenderBottom, paint);
3704 },
3705#ifdef IMPELLER_SUPPORTS_RENDERING
3706 [=](const DlRenderContext& ctx) {
3707 auto paint = ctx.paint;
3708 ctx.canvas->DrawTextFrame(frame, kRenderLeft, render_y_1_3, paint);
3709 ctx.canvas->DrawTextFrame(frame, kRenderLeft, render_y_2_3, paint);
3710 ctx.canvas->DrawTextFrame(frame, kRenderLeft, kRenderBottom, paint);
3711 },
3712#endif // IMPELLER_SUPPORTS_RENDERING
3713 kDrawTextBlobFlags)
3714 .set_draw_text_blob(),
3715 // From examining the bounds differential for the "Default" case, the
3716 // SkTextBlob adds a padding of ~32 on the left, ~30 on the right,
3717 // ~12 on top and ~8 on the bottom, so we add 33h & 13v allowed
3718 // padding to the tolerance
3719 CanvasCompareTester::DefaultTolerance.addBoundsPadding(33, 13));
3720 EXPECT_TRUE(blob->unique());
3721#endif // OS_FUCHSIA
3722}
std::shared_ptr< TextFrame > MakeTextFrameFromTextBlobSkia(const sk_sp< SkTextBlob > &blob)

◆ TEST_F() [161/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawVerticalLine   
)

Definition at line 2958 of file dl_rendering_unittests.cc.

2958 {
2959 SkPoint p1 = SkPoint::Make(kRenderCenterX, kRenderTop);
2960 SkPoint p2 = SkPoint::Make(kRenderCenterY, kRenderBottom);
2961
2962 CanvasCompareTester::RenderAll( //
2964 [=](const SkRenderContext& ctx) { //
2965 // Skia requires kStroke style on horizontal and vertical
2966 // lines to get the bounds correct.
2967 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
2968 SkPaint p = ctx.paint;
2969 p.setStyle(SkPaint::kStroke_Style);
2970 ctx.canvas->drawLine(p1, p2, p);
2971 },
2972 [=](const DlRenderContext& ctx) { //
2973 ctx.canvas->DrawLine(p1, p2, ctx.paint);
2974 },
2975 kDrawHVLineFlags)
2976 .set_draw_line()
2978}

◆ TEST_F() [162/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawVerticesWithColors   
)

Definition at line 3256 of file dl_rendering_unittests.cc.

3256 {
3257 // Cover as many sides of the box with only 6 vertices:
3258 // +----------+
3259 // |xxxxxxxxxx|
3260 // | xxxxxx|
3261 // | xxx|
3262 // |xxx |
3263 // |xxxxxx |
3264 // |xxxxxxxxxx|
3265 // +----------|
3266 const SkPoint pts[6] = {
3267 // Upper-Right corner, full top, half right coverage
3268 SkPoint::Make(kRenderLeft, kRenderTop),
3269 SkPoint::Make(kRenderRight, kRenderTop),
3270 SkPoint::Make(kRenderRight, kRenderCenterY),
3271 // Lower-Left corner, full bottom, half left coverage
3272 SkPoint::Make(kRenderLeft, kRenderBottom),
3273 SkPoint::Make(kRenderLeft, kRenderCenterY),
3274 SkPoint::Make(kRenderRight, kRenderBottom),
3275 };
3276 const DlColor dl_colors[6] = {
3277 DlColor::kRed(), DlColor::kBlue(), DlColor::kGreen(),
3278 DlColor::kCyan(), DlColor::kYellow(), DlColor::kMagenta(),
3279 };
3280 const SkColor sk_colors[6] = {
3283 };
3284 const std::shared_ptr<DlVertices> dl_vertices =
3285 DlVertices::Make(DlVertexMode::kTriangles, 6, pts, nullptr, dl_colors);
3286 const auto sk_vertices =
3288 pts, nullptr, sk_colors);
3289
3290 CanvasCompareTester::RenderAll( //
3291 TestParameters(
3292 [=](const SkRenderContext& ctx) {
3293 ctx.canvas->drawVertices(sk_vertices, SkBlendMode::kSrcOver,
3294 ctx.paint);
3295 },
3296 [=](const DlRenderContext& ctx) {
3297 ctx.canvas->DrawVertices(dl_vertices, DlBlendMode::kSrcOver,
3298 ctx.paint);
3299 },
3300 kDrawVerticesFlags));
3301}
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])

◆ TEST_F() [163/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawVerticesWithImage   
)

Definition at line 3303 of file dl_rendering_unittests.cc.

3303 {
3304 // Cover as many sides of the box with only 6 vertices:
3305 // +----------+
3306 // |xxxxxxxxxx|
3307 // | xxxxxx|
3308 // | xxx|
3309 // |xxx |
3310 // |xxxxxx |
3311 // |xxxxxxxxxx|
3312 // +----------|
3313 const SkPoint pts[6] = {
3314 // Upper-Right corner, full top, half right coverage
3315 SkPoint::Make(kRenderLeft, kRenderTop),
3316 SkPoint::Make(kRenderRight, kRenderTop),
3317 SkPoint::Make(kRenderRight, kRenderCenterY),
3318 // Lower-Left corner, full bottom, half left coverage
3319 SkPoint::Make(kRenderLeft, kRenderBottom),
3320 SkPoint::Make(kRenderLeft, kRenderCenterY),
3321 SkPoint::Make(kRenderRight, kRenderBottom),
3322 };
3323 const SkPoint tex[6] = {
3324 SkPoint::Make(kRenderWidth / 2.0, 0),
3325 SkPoint::Make(0, kRenderHeight),
3326 SkPoint::Make(kRenderWidth, kRenderHeight),
3327 SkPoint::Make(kRenderWidth / 2, kRenderHeight),
3328 SkPoint::Make(0, 0),
3329 SkPoint::Make(kRenderWidth, 0),
3330 };
3331 const std::shared_ptr<DlVertices> dl_vertices =
3332 DlVertices::Make(DlVertexMode::kTriangles, 6, pts, tex, nullptr);
3333 const auto sk_vertices = SkVertices::MakeCopy(
3334 SkVertices::VertexMode::kTriangles_VertexMode, 6, pts, tex, nullptr);
3335
3336 CanvasCompareTester::RenderAll( //
3337 TestParameters(
3338 [=](const SkRenderContext& ctx) { //
3339 SkPaint v_paint = ctx.paint;
3340 if (v_paint.getShader() == nullptr) {
3341 v_paint.setShader(MakeColorSource(ctx.image));
3342 }
3343 ctx.canvas->drawVertices(sk_vertices, SkBlendMode::kSrcOver,
3344 v_paint);
3345 },
3346 [=](const DlRenderContext& ctx) { //
3347 DlPaint v_paint = ctx.paint;
3348 if (v_paint.getColorSource() == nullptr) {
3349 v_paint.setColorSource(MakeColorSource(ctx.image));
3350 }
3351 ctx.canvas->DrawVertices(dl_vertices, DlBlendMode::kSrcOver,
3352 v_paint);
3353 },
3354 kDrawVerticesFlags));
3355}
SkShader * getShader() const
Definition SkPaint.h:397
static std::shared_ptr< DlImageColorSource > MakeColorSource(const sk_sp< DlImage > &image)

◆ TEST_F() [164/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
MatrixColorFilterModifyTransparencyCheck   
)

Definition at line 4030 of file dl_rendering_unittests.cc.

4030 {
4031 auto test_matrix = [](int element, SkScalar value) {
4032 // clang-format off
4033 float matrix[] = {
4034 1, 0, 0, 0, 0,
4035 0, 1, 0, 0, 0,
4036 0, 0, 1, 0, 0,
4037 0, 0, 0, 1, 0,
4038 };
4039 // clang-format on
4040 std::string desc =
4041 "matrix[" + std::to_string(element) + "] = " + std::to_string(value);
4042 float original_value = matrix[element];
4043 matrix[element] = value;
4044 DlMatrixColorFilter filter(matrix);
4045 auto dl_filter = DlMatrixColorFilter::Make(matrix);
4046 bool is_identity = (dl_filter == nullptr || original_value == value);
4047
4048 DlPaint paint(DlColor(0x7f7f7f7f));
4049 DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);
4050
4051 DisplayListBuilder builder1;
4052 builder1.Translate(kTestCenter.fX, kTestCenter.fY);
4053 builder1.Rotate(45);
4054 builder1.Translate(-kTestCenter.fX, -kTestCenter.fY);
4055 builder1.DrawRect(kRenderBounds, paint);
4056 auto display_list1 = builder1.Build();
4057
4058 DisplayListBuilder builder2;
4059 builder2.Translate(kTestCenter.fX, kTestCenter.fY);
4060 builder2.Rotate(45);
4061 builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
4062 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4063 builder2.DrawRect(kRenderBounds, paint);
4064 builder2.Restore();
4065 auto display_list2 = builder2.Build();
4066
4067 for (auto& back_end : CanvasCompareTester::TestBackends) {
4068 auto provider = CanvasCompareTester::GetProvider(back_end);
4069 auto env = std::make_unique<RenderEnvironment>(
4070 provider.get(), PixelFormat::kN32PremulPixelFormat);
4071 auto results1 = env->getResult(display_list1);
4072 auto results2 = env->getResult(display_list2);
4073 CanvasCompareTester::quickCompareToReference(
4074 results1.get(), results2.get(), is_identity,
4075 desc + " filter affects rendering");
4076 int modified_transparent_pixels =
4077 CanvasCompareTester::countModifiedTransparentPixels(results1.get(),
4078 results2.get());
4079 EXPECT_EQ(filter.modifies_transparent_black(),
4080 modified_transparent_pixels != 0)
4081 << desc;
4082 }
4083 };
4084
4085 // Tests identity (matrix[0] already == 1 in an identity filter)
4086 test_matrix(0, 1);
4087 // test_matrix(19, 1);
4088 for (int i = 0; i < 20; i++) {
4089 test_matrix(i, -0.25);
4090 test_matrix(i, 0);
4091 test_matrix(i, 0.25);
4092 test_matrix(i, 1);
4093 test_matrix(i, 1.25);
4097 }
4098}
static bool is_identity(const SkMatrix &m)

◆ TEST_F() [165/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
MatrixColorFilterOpacityCommuteCheck   
)

Definition at line 4100 of file dl_rendering_unittests.cc.

4100 {
4101 auto test_matrix = [](int element, SkScalar value) {
4102 // clang-format off
4103 float matrix[] = {
4104 1, 0, 0, 0, 0,
4105 0, 1, 0, 0, 0,
4106 0, 0, 1, 0, 0,
4107 0, 0, 0, 1, 0,
4108 };
4109 // clang-format on
4110 std::string desc =
4111 "matrix[" + std::to_string(element) + "] = " + std::to_string(value);
4112 matrix[element] = value;
4113 auto filter = DlMatrixColorFilter::Make(matrix);
4114 EXPECT_EQ(std::isfinite(value), filter != nullptr);
4115
4116 DlPaint paint(DlColor(0x80808080));
4117 DlPaint opacity_save_paint = DlPaint().setOpacity(0.5);
4118 DlPaint filter_save_paint = DlPaint().setColorFilter(filter);
4119
4120 DisplayListBuilder builder1;
4121 builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
4122 builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
4123 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4124 builder1.DrawRect(kRenderBounds, paint);
4125 builder1.Restore();
4126 builder1.Restore();
4127 auto display_list1 = builder1.Build();
4128
4129 DisplayListBuilder builder2;
4130 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4131 builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
4132 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4133 builder2.DrawRect(kRenderBounds, paint);
4134 builder2.Restore();
4135 builder2.Restore();
4136 auto display_list2 = builder2.Build();
4137
4138 for (auto& back_end : CanvasCompareTester::TestBackends) {
4139 auto provider = CanvasCompareTester::GetProvider(back_end);
4140 auto env = std::make_unique<RenderEnvironment>(
4141 provider.get(), PixelFormat::kN32PremulPixelFormat);
4142 auto results1 = env->getResult(display_list1);
4143 auto results2 = env->getResult(display_list2);
4144 if (!filter || filter->can_commute_with_opacity()) {
4145 CanvasCompareTester::compareToReference(
4146 results2.get(), results1.get(), desc, nullptr, nullptr,
4147 DlColor::kTransparent(), true, kTestWidth, kTestHeight, true);
4148 } else {
4149 CanvasCompareTester::quickCompareToReference(
4150 results1.get(), results2.get(), false, desc);
4151 }
4152 }
4153 };
4154
4155 // Tests identity (matrix[0] already == 1 in an identity filter)
4156 test_matrix(0, 1);
4157 // test_matrix(19, 1);
4158 for (int i = 0; i < 20; i++) {
4159 test_matrix(i, -0.25);
4160 test_matrix(i, 0);
4161 test_matrix(i, 0.25);
4162 test_matrix(i, 1);
4163 test_matrix(i, 1.1);
4167 }
4168}
DlPaint & setOpacity(SkScalar opacity)
Definition dl_paint.h:79

◆ TEST_F() [166/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
SaveLayerClippedContentStillFilters   
)

Definition at line 3802 of file dl_rendering_unittests.cc.

3802 {
3803 // draw rect is just outside of render bounds on the right
3805 kRenderRight + 1, //
3806 kRenderTop, //
3808 kRenderBottom //
3809 );
3810 TestParameters test_params(
3811 [=](const SkRenderContext& ctx) {
3812 auto layer_filter =
3813 SkImageFilters::Blur(10.0f, 10.0f, SkTileMode::kDecal, nullptr);
3814 SkPaint layer_paint;
3815 layer_paint.setImageFilter(layer_filter);
3816 ctx.canvas->save();
3817 ctx.canvas->clipRect(kRenderBounds, SkClipOp::kIntersect, false);
3818 ctx.canvas->saveLayer(&kTestBounds2, &layer_paint);
3819 ctx.canvas->drawRect(draw_rect, ctx.paint);
3820 ctx.canvas->restore();
3821 ctx.canvas->restore();
3822 },
3823 [=](const DlRenderContext& ctx) {
3824 auto layer_filter =
3825 DlBlurImageFilter::Make(10.0f, 10.0f, DlTileMode::kDecal);
3826 DlPaint layer_paint;
3827 layer_paint.setImageFilter(layer_filter);
3828 ctx.canvas->Save();
3829 ctx.canvas->ClipRect(kRenderBounds, ClipOp::kIntersect, false);
3830 ctx.canvas->SaveLayer(&kTestBounds2, &layer_paint);
3831 ctx.canvas->DrawRect(draw_rect, ctx.paint);
3832 ctx.canvas->Restore();
3833 ctx.canvas->Restore();
3834 },
3835 kSaveLayerWithPaintFlags);
3836 CaseParameters case_params("Filtered SaveLayer with clipped content");
3837 BoundsTolerance tolerance = BoundsTolerance().addAbsolutePadding(6.0f, 6.0f);
3838
3839 for (auto& back_end : CanvasCompareTester::TestBackends) {
3840 auto provider = CanvasCompareTester::GetProvider(back_end);
3841 RenderEnvironment env = RenderEnvironment::MakeN32(provider.get());
3842 env.init_ref(kEmptySkSetup, test_params.sk_renderer(), //
3843 kEmptyDlSetup, test_params.dl_renderer(),
3844 test_params.imp_renderer());
3845 CanvasCompareTester::quickCompareToReference(env, "default");
3846 CanvasCompareTester::RenderWith(test_params, env, tolerance, case_params);
3847 }
3848}
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
static void draw_rect(SkCanvas *canvas, SkImage *, const SkRect &r, sk_sp< SkImageFilter > imf)
constexpr SkRect kTestBounds2

◆ TEST_F() [167/876]

flutter::testing::TEST_F ( DisplayListRendering  ,
SaveLayerConsolidation   
)

Definition at line 3850 of file dl_rendering_unittests.cc.

3850 {
3851 float commutable_color_matrix[]{
3852 // clang-format off
3853 0, 1, 0, 0, 0,
3854 0, 0, 1, 0, 0,
3855 1, 0, 0, 0, 0,
3856 0, 0, 0, 1, 0,
3857 // clang-format on
3858 };
3859 float non_commutable_color_matrix[]{
3860 // clang-format off
3861 0, 1, 0, .1, 0,
3862 0, 0, 1, .1, 0,
3863 1, 0, 0, .1, 0,
3864 0, 0, 0, .7, 0,
3865 // clang-format on
3866 };
3867 SkMatrix contract_matrix;
3868 contract_matrix.setScale(0.9f, 0.9f, kRenderCenterX, kRenderCenterY);
3869
3870 std::vector<SkScalar> opacities = {
3871 0,
3872 0.5f,
3873 SK_Scalar1,
3874 };
3875 std::vector<std::shared_ptr<DlColorFilter>> color_filters = {
3876 std::make_shared<DlBlendColorFilter>(DlColor::kCyan(),
3877 DlBlendMode::kSrcATop),
3878 std::make_shared<DlMatrixColorFilter>(commutable_color_matrix),
3879 std::make_shared<DlMatrixColorFilter>(non_commutable_color_matrix),
3880 DlSrgbToLinearGammaColorFilter::kInstance,
3881 DlLinearToSrgbGammaColorFilter::kInstance,
3882 };
3883 std::vector<std::shared_ptr<DlImageFilter>> image_filters = {
3884 std::make_shared<DlBlurImageFilter>(5.0f, 5.0f, DlTileMode::kDecal),
3885 std::make_shared<DlDilateImageFilter>(5.0f, 5.0f),
3886 std::make_shared<DlErodeImageFilter>(5.0f, 5.0f),
3887 std::make_shared<DlMatrixImageFilter>(contract_matrix,
3888 DlImageSampling::kLinear),
3889 };
3890
3891 auto render_content = [](DisplayListBuilder& builder) {
3892 builder.DrawRect(
3894 DlPaint(DlColor::kYellow()));
3895 builder.DrawRect(
3897 DlPaint(DlColor::kRed()));
3898 builder.DrawRect(
3900 DlPaint(DlColor::kBlue()));
3901 builder.DrawRect(
3903 DlPaint(DlColor::kRed().modulateOpacity(0.5f)));
3904 };
3905
3906 auto test_attributes_env =
3907 [render_content](DlPaint& paint1, DlPaint& paint2,
3908 const DlPaint& paint_both, bool same, bool rev_same,
3909 const std::string& desc1, const std::string& desc2,
3910 const RenderEnvironment* env) {
3911 DisplayListBuilder nested_builder;
3912 nested_builder.SaveLayer(&kTestBounds2, &paint1);
3913 nested_builder.SaveLayer(&kTestBounds2, &paint2);
3914 render_content(nested_builder);
3915 auto nested_results = env->getResult(nested_builder.Build());
3916
3917 DisplayListBuilder reverse_builder;
3918 reverse_builder.SaveLayer(&kTestBounds2, &paint2);
3919 reverse_builder.SaveLayer(&kTestBounds2, &paint1);
3920 render_content(reverse_builder);
3921 auto reverse_results = env->getResult(reverse_builder.Build());
3922
3923 DisplayListBuilder combined_builder;
3924 combined_builder.SaveLayer(&kTestBounds2, &paint_both);
3925 render_content(combined_builder);
3926 auto combined_results = env->getResult(combined_builder.Build());
3927
3928 // Set this boolean to true to test if combinations that are marked
3929 // as incompatible actually are compatible despite our predictions.
3930 // Some of the combinations that we treat as incompatible actually
3931 // are compatible with swapping the order of the operations, but
3932 // it would take a bit of new infrastructure to really identify
3933 // those combinations. The only hard constraint to test here is
3934 // when we claim that they are compatible and they aren't.
3935 const bool always = false;
3936
3937 if (always || same) {
3938 CanvasCompareTester::quickCompareToReference(
3939 nested_results.get(), combined_results.get(), same,
3940 "nested " + desc1 + " then " + desc2);
3941 }
3942 if (always || rev_same) {
3943 CanvasCompareTester::quickCompareToReference(
3944 reverse_results.get(), combined_results.get(), rev_same,
3945 "nested " + desc2 + " then " + desc1);
3946 }
3947 };
3948
3949 auto test_attributes = [test_attributes_env](DlPaint& paint1, DlPaint& paint2,
3950 const DlPaint& paint_both,
3951 bool same, bool rev_same,
3952 const std::string& desc1,
3953 const std::string& desc2) {
3954 for (auto& back_end : CanvasCompareTester::TestBackends) {
3955 auto provider = CanvasCompareTester::GetProvider(back_end);
3956 auto env = std::make_unique<RenderEnvironment>(
3957 provider.get(), PixelFormat::kN32PremulPixelFormat);
3958 test_attributes_env(paint1, paint2, paint_both, //
3959 same, rev_same, desc1, desc2, env.get());
3960 }
3961 };
3962
3963 // CF then Opacity should always work.
3964 // The reverse sometimes works.
3965 for (size_t cfi = 0; cfi < color_filters.size(); cfi++) {
3966 auto color_filter = color_filters[cfi];
3967 std::string cf_desc = "color filter #" + std::to_string(cfi + 1);
3968 DlPaint nested_paint1 = DlPaint().setColorFilter(color_filter);
3969
3970 for (size_t oi = 0; oi < opacities.size(); oi++) {
3971 SkScalar opacity = opacities[oi];
3972 std::string op_desc = "opacity " + std::to_string(opacity);
3973 DlPaint nested_paint2 = DlPaint().setOpacity(opacity);
3974
3975 DlPaint combined_paint = nested_paint1;
3976 combined_paint.setOpacity(opacity);
3977
3978 bool op_then_cf_works = opacity <= 0.0 || opacity >= 1.0 ||
3979 color_filter->can_commute_with_opacity();
3980
3981 test_attributes(nested_paint1, nested_paint2, combined_paint, true,
3982 op_then_cf_works, cf_desc, op_desc);
3983 }
3984 }
3985
3986 // Opacity then IF should always work.
3987 // The reverse can also work for some values of opacity.
3988 // The reverse should also theoretically work for some IFs, but we
3989 // get some rounding errors that are more than just trivial.
3990 for (size_t oi = 0; oi < opacities.size(); oi++) {
3991 SkScalar opacity = opacities[oi];
3992 std::string op_desc = "opacity " + std::to_string(opacity);
3993 DlPaint nested_paint1 = DlPaint().setOpacity(opacity);
3994
3995 for (size_t ifi = 0; ifi < image_filters.size(); ifi++) {
3996 auto image_filter = image_filters[ifi];
3997 std::string if_desc = "image filter #" + std::to_string(ifi + 1);
3998 DlPaint nested_paint2 = DlPaint().setImageFilter(image_filter);
3999
4000 DlPaint combined_paint = nested_paint1;
4001 combined_paint.setImageFilter(image_filter);
4002
4003 bool if_then_op_works = opacity <= 0.0 || opacity >= 1.0;
4004 test_attributes(nested_paint1, nested_paint2, combined_paint, true,
4005 if_then_op_works, op_desc, if_desc);
4006 }
4007 }
4008
4009 // CF then IF should always work.
4010 // The reverse might work, but we lack the infrastructure to check it.
4011 for (size_t cfi = 0; cfi < color_filters.size(); cfi++) {
4012 auto color_filter = color_filters[cfi];
4013 std::string cf_desc = "color filter #" + std::to_string(cfi + 1);
4014 DlPaint nested_paint1 = DlPaint().setColorFilter(color_filter);
4015
4016 for (size_t ifi = 0; ifi < image_filters.size(); ifi++) {
4017 auto image_filter = image_filters[ifi];
4018 std::string if_desc = "image filter #" + std::to_string(ifi + 1);
4019 DlPaint nested_paint2 = DlPaint().setImageFilter(image_filter);
4020
4021 DlPaint combined_paint = nested_paint1;
4022 combined_paint.setImageFilter(image_filter);
4023
4024 test_attributes(nested_paint1, nested_paint2, combined_paint, true, false,
4025 cf_desc, if_desc);
4026 }
4027 }
4028}
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:296

◆ TEST_F() [168/876]

flutter::testing::TEST_F ( DisplayListTest  ,
AllBlendModeNops   
)

Definition at line 711 of file display_list_unittests.cc.

711 {
712 DisplayListBuilder builder;
713 DlOpReceiver& receiver = ToReceiver(builder);
714 receiver.setBlendMode(DlBlendMode::kSrcOver);
715 sk_sp<DisplayList> dl = builder.Build();
716 ASSERT_EQ(dl->bytes(false), sizeof(DisplayList));
717 ASSERT_EQ(dl->bytes(true), sizeof(DisplayList));
718 ASSERT_EQ(dl->op_count(false), 0u);
719 ASSERT_EQ(dl->op_count(true), 0u);
720 EXPECT_EQ(dl->total_depth(), 0u);
721}
virtual void setBlendMode(DlBlendMode mode)=0

◆ TEST_F() [169/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderBoundsTransformComparedToSkia   
)

Definition at line 450 of file display_list_unittests.cc.

450 {
451 const SkRect frame_rect = SkRect::MakeLTRB(10, 10, 100, 100);
452 DisplayListBuilder builder(frame_rect);
453 SkPictureRecorder recorder;
454 SkCanvas* canvas = recorder.beginRecording(frame_rect);
455 ASSERT_EQ(builder.GetDestinationClipBounds(),
457 ASSERT_EQ(builder.GetLocalClipBounds().makeOutset(1, 1),
458 canvas->getLocalClipBounds());
459 ASSERT_EQ(builder.GetTransform(), canvas->getTotalMatrix());
460}
SkRect getLocalClipBounds() const
SkMatrix getTotalMatrix() const
SkIRect getDeviceClipBounds() const

◆ TEST_F() [170/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderCanBeReused   
)

Definition at line 252 of file display_list_unittests.cc.

252 {
253 DisplayListBuilder builder(kTestBounds);
254 builder.DrawRect(kTestBounds, DlPaint());
255 auto dl = builder.Build();
256 builder.DrawRect(kTestBounds, DlPaint());
257 auto dl2 = builder.Build();
258 ASSERT_TRUE(dl->Equals(dl2));
259}

◆ TEST_F() [171/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderClipBoundsAfterClipPath   
)

Definition at line 495 of file display_list_unittests.cc.

495 {
496 SkRect cull_rect = SkRect::MakeWH(100, 100);
497 SkPath clip_path = SkPath().addRect(10, 10, 15, 15).addRect(15, 15, 20, 20);
498 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 20, 20);
499 DisplayListBuilder builder(cull_rect);
500 builder.ClipPath(clip_path, ClipOp::kIntersect, false);
501 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
502}

◆ TEST_F() [172/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderClipBoundsAfterClipRect   
)

Definition at line 476 of file display_list_unittests.cc.

476 {
477 SkRect cull_rect = SkRect::MakeWH(100, 100);
478 SkRect clip_rect = SkRect::MakeLTRB(10, 10, 20, 20);
479 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 20, 20);
480 DisplayListBuilder builder(cull_rect);
481 builder.ClipRect(clip_rect, ClipOp::kIntersect, false);
482 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
483}

◆ TEST_F() [173/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderClipBoundsAfterClipRRect   
)

Definition at line 485 of file display_list_unittests.cc.

485 {
486 SkRect cull_rect = SkRect::MakeWH(100, 100);
487 SkRect clip_rect = SkRect::MakeLTRB(10, 10, 20, 20);
488 SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 2, 2);
489 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 20, 20);
490 DisplayListBuilder builder(cull_rect);
491 builder.ClipRRect(clip_rrect, ClipOp::kIntersect, false);
492 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
493}

◆ TEST_F() [174/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderInitialClipBounds   
)

Definition at line 462 of file display_list_unittests.cc.

462 {
463 SkRect cull_rect = SkRect::MakeWH(100, 100);
464 SkRect clip_bounds = SkRect::MakeWH(100, 100);
465 DisplayListBuilder builder(cull_rect);
466 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
467}

◆ TEST_F() [175/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderInitialClipBoundsNaN   
)

Definition at line 469 of file display_list_unittests.cc.

469 {
471 SkRect clip_bounds = SkRect::MakeEmpty();
472 DisplayListBuilder builder(cull_rect);
473 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
474}

◆ TEST_F() [176/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderInitialClipBoundsNonZero   
)

Definition at line 504 of file display_list_unittests.cc.

504 {
505 SkRect cull_rect = SkRect::MakeLTRB(10, 10, 100, 100);
506 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 100, 100);
507 DisplayListBuilder builder(cull_rect);
508 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
509}

◆ TEST_F() [177/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuildRestoresAttributes   
)

Definition at line 388 of file display_list_unittests.cc.

388 {
389 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
390 DisplayListBuilder builder(cull_rect);
391 DlOpReceiver& receiver = ToReceiver(builder);
392
393 receiver.setAntiAlias(true);
394 builder.Build();
395 check_defaults(builder, cull_rect);
396
397 receiver.setInvertColors(true);
398 builder.Build();
399 check_defaults(builder, cull_rect);
400
401 receiver.setColor(DlColor::kRed());
402 builder.Build();
403 check_defaults(builder, cull_rect);
404
405 receiver.setBlendMode(DlBlendMode::kColorBurn);
406 builder.Build();
407 check_defaults(builder, cull_rect);
408
409 receiver.setDrawStyle(DlDrawStyle::kStrokeAndFill);
410 builder.Build();
411 check_defaults(builder, cull_rect);
412
413 receiver.setStrokeWidth(300.0f);
414 builder.Build();
415 check_defaults(builder, cull_rect);
416
417 receiver.setStrokeMiter(300.0f);
418 builder.Build();
419 check_defaults(builder, cull_rect);
420
421 receiver.setStrokeCap(DlStrokeCap::kRound);
422 builder.Build();
423 check_defaults(builder, cull_rect);
424
425 receiver.setStrokeJoin(DlStrokeJoin::kRound);
426 builder.Build();
427 check_defaults(builder, cull_rect);
428
429 receiver.setColorSource(&kTestSource1);
430 builder.Build();
431 check_defaults(builder, cull_rect);
432
433 receiver.setColorFilter(&kTestMatrixColorFilter1);
434 builder.Build();
435 check_defaults(builder, cull_rect);
436
437 receiver.setImageFilter(&kTestBlurImageFilter1);
438 builder.Build();
439 check_defaults(builder, cull_rect);
440
441 receiver.setMaskFilter(&kTestMaskFilter1);
442 builder.Build();
443 check_defaults(builder, cull_rect);
444
445 receiver.setPathEffect(kTestPathEffect1.get());
446 builder.Build();
447 check_defaults(builder, cull_rect);
448}
virtual void setStrokeMiter(float limit)=0
virtual void setStrokeWidth(float width)=0
virtual void setMaskFilter(const DlMaskFilter *filter)=0
virtual void setColorFilter(const DlColorFilter *filter)=0
virtual void setAntiAlias(bool aa)=0
virtual void setStrokeJoin(DlStrokeJoin join)=0
virtual void setImageFilter(const DlImageFilter *filter)=0
virtual void setDrawStyle(DlDrawStyle style)=0
virtual void setPathEffect(const DlPathEffect *effect)=0
virtual void setColor(DlColor color)=0
virtual void setInvertColors(bool invert)=0
virtual void setStrokeCap(DlStrokeCap cap)=0

◆ TEST_F() [178/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuildRestoresClip   
)

Definition at line 371 of file display_list_unittests.cc.

371 {
372 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
373 DisplayListBuilder builder(cull_rect);
374
375 builder.ClipRect({0.0f, 0.0f, 10.0f, 10.0f});
376 builder.Build();
377 check_defaults(builder, cull_rect);
378
379 builder.ClipRRect(SkRRect::MakeRectXY({0.0f, 0.0f, 5.0f, 5.0f}, 2.0f, 2.0f));
380 builder.Build();
381 check_defaults(builder, cull_rect);
382
383 builder.ClipPath(SkPath().addOval({0.0f, 0.0f, 10.0f, 10.0f}));
384 builder.Build();
385 check_defaults(builder, cull_rect);
386}

◆ TEST_F() [179/876]

flutter::testing::TEST_F ( DisplayListTest  ,
BuildRestoresTransform   
)

Definition at line 310 of file display_list_unittests.cc.

310 {
311 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
312 DisplayListBuilder builder(cull_rect);
313
314 builder.Translate(10.0f, 10.0f);
315 builder.Build();
316 check_defaults(builder, cull_rect);
317
318 builder.Scale(10.0f, 10.0f);
319 builder.Build();
320 check_defaults(builder, cull_rect);
321
322 builder.Skew(0.1f, 0.1f);
323 builder.Build();
324 check_defaults(builder, cull_rect);
325
326 builder.Rotate(45.0f);
327 builder.Build();
328 check_defaults(builder, cull_rect);
329
330 builder.Transform(SkMatrix::Scale(10.0f, 10.0f));
331 builder.Build();
332 check_defaults(builder, cull_rect);
333
334 builder.Transform2DAffine(1.0f, 0.0f, 12.0f, //
335 0.0f, 1.0f, 35.0f);
336 builder.Build();
337 check_defaults(builder, cull_rect);
338
339 builder.Transform(SkM44(SkMatrix::Scale(10.0f, 10.0f)));
340 builder.Build();
341 check_defaults(builder, cull_rect);
342
343 builder.TransformFullPerspective(1.0f, 0.0f, 0.0f, 12.0f, //
344 0.0f, 1.0f, 0.0f, 35.0f, //
345 0.0f, 0.0f, 1.0f, 5.0f, //
346 0.0f, 0.0f, 0.0f, 1.0f);
347 builder.Build();
348 check_defaults(builder, cull_rect);
349}

◆ TEST_F() [180/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathAffectsClipBounds   
)

Definition at line 1908 of file display_list_unittests.cc.

1908 {
1909 DisplayListBuilder builder;
1910 DlOpReceiver& receiver = ToReceiver(builder);
1911 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
1912 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
1913 receiver.clipPath(clip, ClipOp::kIntersect, false);
1914
1915 // Save initial return values for testing restored values
1916 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1917 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1918 ASSERT_EQ(initial_local_bounds, clip_bounds);
1919 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1920
1921 receiver.save();
1922 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, false);
1923 // Both clip bounds have changed
1924 ASSERT_NE(builder.GetLocalClipBounds(), clip_bounds);
1925 ASSERT_NE(builder.GetDestinationClipBounds(), clip_bounds);
1926 // Previous return values have not changed
1927 ASSERT_EQ(initial_local_bounds, clip_bounds);
1928 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1929 receiver.restore();
1930
1931 // save/restore returned the values to their original values
1932 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1933 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1934
1935 receiver.save();
1936 receiver.scale(2, 2);
1937 SkRect scaled_clip_bounds = SkRect::MakeLTRB(4.1, 4.65, 11.2, 13.85);
1938 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_clip_bounds);
1939 // Destination bounds are unaffected by transform
1940 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
1941 receiver.restore();
1942
1943 // save/restore returned the values to their original values
1944 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1945 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1946}
virtual void save()=0
virtual void clipRect(const SkRect &rect, ClipOp clip_op, bool is_aa)=0
virtual void restore()=0
virtual void clipPath(const CacheablePath &cache, ClipOp clip_op, bool is_aa)
virtual void scale(SkScalar sx, SkScalar sy)=0

◆ TEST_F() [181/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathAffectsClipBoundsWithMatrix   
)

Definition at line 1988 of file display_list_unittests.cc.

1988 {
1989 DisplayListBuilder builder;
1990 DlOpReceiver& receiver = ToReceiver(builder);
1991 SkRect clip_bounds = SkRect::MakeLTRB(0, 0, 10, 10);
1992 SkPath clip1 = SkPath().addCircle(2.5, 2.5, 2.5).addCircle(7.5, 7.5, 2.5);
1993 SkPath clip2 = SkPath().addCircle(12.5, 12.5, 2.5).addCircle(17.5, 17.5, 2.5);
1994
1995 receiver.save();
1996 receiver.clipPath(clip1, ClipOp::kIntersect, false);
1997 receiver.translate(10, 0);
1998 receiver.clipPath(clip1, ClipOp::kIntersect, false);
1999 ASSERT_TRUE(builder.GetDestinationClipBounds().isEmpty());
2000 receiver.restore();
2001
2002 receiver.save();
2003 receiver.clipPath(clip1, ClipOp::kIntersect, false);
2004 receiver.translate(-10, -10);
2005 receiver.clipPath(clip2, ClipOp::kIntersect, false);
2006 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
2007 receiver.restore();
2008}
virtual void translate(SkScalar tx, SkScalar ty)=0

◆ TEST_F() [182/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathDoAAAffectsClipBounds   
)

Definition at line 1948 of file display_list_unittests.cc.

1948 {
1949 DisplayListBuilder builder;
1950 DlOpReceiver& receiver = ToReceiver(builder);
1951 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
1952 SkRect clip_expanded_bounds = SkRect::MakeLTRB(8, 9, 23, 28);
1953 receiver.clipPath(clip, ClipOp::kIntersect, true);
1954
1955 // Save initial return values for testing restored values
1956 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1957 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1958 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1959 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1960
1961 receiver.save();
1962 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, true);
1963 // Both clip bounds have changed
1964 ASSERT_NE(builder.GetLocalClipBounds(), clip_expanded_bounds);
1965 ASSERT_NE(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1966 // Previous return values have not changed
1967 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1968 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1969 receiver.restore();
1970
1971 // save/restore returned the values to their original values
1972 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1973 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1974
1975 receiver.save();
1976 receiver.scale(2, 2);
1977 SkRect scaled_expanded_bounds = SkRect::MakeLTRB(4, 4.5, 11.5, 14);
1978 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_expanded_bounds);
1979 // Destination bounds are unaffected by transform
1980 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1981 receiver.restore();
1982
1983 // save/restore returned the values to their original values
1984 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1985 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1986}

◆ TEST_F() [183/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathTriggersDeferredSave   
)

Definition at line 2674 of file display_list_unittests.cc.

2674 {
2675 DisplayListBuilder builder1;
2676 DlOpReceiver& receiver1 = ToReceiver(builder1);
2677 receiver1.save();
2678 receiver1.save();
2679 receiver1.clipPath(kTestPath1, ClipOp::kIntersect, true);
2680 receiver1.drawRect({0, 0, 100, 100});
2681 receiver1.restore();
2682 receiver1.transformFullPerspective(1, 0, 0, 0, //
2683 0, 1, 0, 0, //
2684 0, 0, 1, 0, //
2685 0, 0, 0, 1);
2686 receiver1.drawRect({0, 0, 100, 100});
2687 receiver1.restore();
2688 auto display_list1 = builder1.Build();
2689
2690 DisplayListBuilder builder2;
2691 DlOpReceiver& receiver2 = ToReceiver(builder2);
2692 receiver2.save();
2693 receiver2.clipPath(kTestPath1, ClipOp::kIntersect, true);
2694 receiver2.drawRect({0, 0, 100, 100});
2695 receiver2.restore();
2696 receiver2.transformFullPerspective(1, 0, 0, 0, //
2697 0, 1, 0, 0, //
2698 0, 0, 1, 0, //
2699 0, 0, 0, 1);
2700 receiver2.drawRect({0, 0, 100, 100});
2701 auto display_list2 = builder2.Build();
2702
2703 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2704}
virtual void drawRect(const SkRect &rect)=0
virtual void transformFullPerspective(SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt)=0

◆ TEST_F() [184/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathWithInvertFillTypeDoesNotAffectClipBounds   
)

Definition at line 2066 of file display_list_unittests.cc.

2066 {
2067 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
2068 DisplayListBuilder builder(cull_rect);
2069 DlOpReceiver& receiver = ToReceiver(builder);
2070 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2072 receiver.clipPath(clip, ClipOp::kIntersect, false);
2073
2074 ASSERT_EQ(builder.GetLocalClipBounds(), cull_rect);
2075 ASSERT_EQ(builder.GetDestinationClipBounds(), cull_rect);
2076}

◆ TEST_F() [185/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClippedSaveLayerContentAccountsForFilter   
)

Definition at line 544 of file display_list_unittests.cc.

544 {
545 SkRect cull_rect = SkRect::MakeLTRB(0.0f, 0.0f, 300.0f, 300.0f);
546 SkRect clip_rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
547 SkRect draw_rect = SkRect::MakeLTRB(50.0f, 140.0f, 99.0f, 160.0f);
548 auto filter = DlBlurImageFilter::Make(10.0f, 10.0f, DlTileMode::kDecal);
549 DlPaint layer_paint = DlPaint().setImageFilter(filter);
550
551 ASSERT_FALSE(clip_rect.intersects(draw_rect));
552 ASSERT_TRUE(cull_rect.contains(clip_rect));
553 ASSERT_TRUE(cull_rect.contains(draw_rect));
554
555 DisplayListBuilder builder;
556 builder.Save();
557 {
558 builder.ClipRect(clip_rect, ClipOp::kIntersect, false);
559 builder.SaveLayer(&cull_rect, &layer_paint);
560 { //
561 builder.DrawRect(draw_rect, DlPaint());
562 }
563 builder.Restore();
564 }
565 builder.Restore();
566 auto display_list = builder.Build();
567
568 ASSERT_EQ(display_list->op_count(), 6u);
569 EXPECT_EQ(display_list->total_depth(), 2u);
570
571 SkRect result_rect = draw_rect.makeOutset(30.0f, 30.0f);
572 ASSERT_TRUE(result_rect.intersect(clip_rect));
573 ASSERT_EQ(result_rect, SkRect::MakeLTRB(100.0f, 110.0f, 129.0f, 190.0f));
574 ASSERT_EQ(display_list->bounds(), result_rect);
575}
bool intersects(const SkRect &r) const
Definition SkRect.h:1121

◆ TEST_F() [186/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectAffectsClipBounds   
)

Definition at line 1705 of file display_list_unittests.cc.

1705 {
1706 DisplayListBuilder builder;
1707 DlOpReceiver& receiver = ToReceiver(builder);
1708 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1709 receiver.clipRect(clip_bounds, ClipOp::kIntersect, false);
1710
1711 // Save initial return values for testing restored values
1712 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1713 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1714 ASSERT_EQ(initial_local_bounds, clip_bounds);
1715 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1716
1717 receiver.save();
1718 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, false);
1719 // Both clip bounds have changed
1720 ASSERT_NE(builder.GetLocalClipBounds(), clip_bounds);
1721 ASSERT_NE(builder.GetDestinationClipBounds(), clip_bounds);
1722 // Previous return values have not changed
1723 ASSERT_EQ(initial_local_bounds, clip_bounds);
1724 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1725 receiver.restore();
1726
1727 // save/restore returned the values to their original values
1728 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1729 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1730
1731 receiver.save();
1732 receiver.scale(2, 2);
1733 SkRect scaled_clip_bounds = SkRect::MakeLTRB(5.1, 5.65, 10.2, 12.85);
1734 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_clip_bounds);
1735 // Destination bounds are unaffected by transform
1736 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
1737 receiver.restore();
1738
1739 // save/restore returned the values to their original values
1740 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1741 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1742}

◆ TEST_F() [187/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectAffectsClipBoundsWithMatrix   
)

Definition at line 1784 of file display_list_unittests.cc.

1784 {
1785 DisplayListBuilder builder;
1786 DlOpReceiver& receiver = ToReceiver(builder);
1787 SkRect clip_bounds_1 = SkRect::MakeLTRB(0, 0, 10, 10);
1788 SkRect clip_bounds_2 = SkRect::MakeLTRB(10, 10, 20, 20);
1789 receiver.save();
1790 receiver.clipRect(clip_bounds_1, ClipOp::kIntersect, false);
1791 receiver.translate(10, 0);
1792 receiver.clipRect(clip_bounds_1, ClipOp::kIntersect, false);
1793 ASSERT_TRUE(builder.GetDestinationClipBounds().isEmpty());
1794 receiver.restore();
1795
1796 receiver.save();
1797 receiver.clipRect(clip_bounds_1, ClipOp::kIntersect, false);
1798 receiver.translate(-10, -10);
1799 receiver.clipRect(clip_bounds_2, ClipOp::kIntersect, false);
1800 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds_1);
1801 receiver.restore();
1802}

◆ TEST_F() [188/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectDoAAAffectsClipBounds   
)

Definition at line 1744 of file display_list_unittests.cc.

1744 {
1745 DisplayListBuilder builder;
1746 DlOpReceiver& receiver = ToReceiver(builder);
1747 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1748 SkRect clip_expanded_bounds = SkRect::MakeLTRB(10, 11, 21, 26);
1749 receiver.clipRect(clip_bounds, ClipOp::kIntersect, true);
1750
1751 // Save initial return values for testing restored values
1752 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1753 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1754 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1755 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1756
1757 receiver.save();
1758 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, true);
1759 // Both clip bounds have changed
1760 ASSERT_NE(builder.GetLocalClipBounds(), clip_expanded_bounds);
1761 ASSERT_NE(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1762 // Previous return values have not changed
1763 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1764 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1765 receiver.restore();
1766
1767 // save/restore returned the values to their original values
1768 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1769 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1770
1771 receiver.save();
1772 receiver.scale(2, 2);
1773 SkRect scaled_expanded_bounds = SkRect::MakeLTRB(5, 5.5, 10.5, 13);
1774 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_expanded_bounds);
1775 // Destination bounds are unaffected by transform
1776 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1777 receiver.restore();
1778
1779 // save/restore returned the values to their original values
1780 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1781 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1782}

◆ TEST_F() [189/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectTriggersDeferredSave   
)

Definition at line 2606 of file display_list_unittests.cc.

2606 {
2607 DisplayListBuilder builder1;
2608 DlOpReceiver& receiver1 = ToReceiver(builder1);
2609 receiver1.save();
2610 receiver1.save();
2611 receiver1.clipRect(SkRect::MakeLTRB(0, 0, 100, 100), ClipOp::kIntersect,
2612 true);
2613 receiver1.drawRect({0, 0, 100, 100});
2614 receiver1.restore();
2615 receiver1.transformFullPerspective(1, 0, 0, 0, //
2616 0, 1, 0, 0, //
2617 0, 0, 1, 0, //
2618 0, 0, 0, 1);
2619 receiver1.drawRect({0, 0, 100, 100});
2620 receiver1.restore();
2621 auto display_list1 = builder1.Build();
2622
2623 DisplayListBuilder builder2;
2624 DlOpReceiver& receiver2 = ToReceiver(builder2);
2625 receiver2.save();
2626 receiver2.clipRect(SkRect::MakeLTRB(0, 0, 100, 100), ClipOp::kIntersect,
2627 true);
2628 receiver2.drawRect({0, 0, 100, 100});
2629 receiver2.restore();
2630 receiver2.transformFullPerspective(1, 0, 0, 0, //
2631 0, 1, 0, 0, //
2632 0, 0, 1, 0, //
2633 0, 0, 0, 1);
2634 receiver2.drawRect({0, 0, 100, 100});
2635 auto display_list2 = builder2.Build();
2636
2637 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2638}

◆ TEST_F() [190/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectAffectsClipBounds   
)

Definition at line 1804 of file display_list_unittests.cc.

1804 {
1805 DisplayListBuilder builder;
1806 DlOpReceiver& receiver = ToReceiver(builder);
1807 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1808 SkRRect clip = SkRRect::MakeRectXY(clip_bounds, 3, 2);
1809 receiver.clipRRect(clip, ClipOp::kIntersect, false);
1810
1811 // Save initial return values for testing restored values
1812 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1813 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1814 ASSERT_EQ(initial_local_bounds, clip_bounds);
1815 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1816
1817 receiver.save();
1818 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, false);
1819 // Both clip bounds have changed
1820 ASSERT_NE(builder.GetLocalClipBounds(), clip_bounds);
1821 ASSERT_NE(builder.GetDestinationClipBounds(), clip_bounds);
1822 // Previous return values have not changed
1823 ASSERT_EQ(initial_local_bounds, clip_bounds);
1824 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1825 receiver.restore();
1826
1827 // save/restore returned the values to their original values
1828 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1829 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1830
1831 receiver.save();
1832 receiver.scale(2, 2);
1833 SkRect scaled_clip_bounds = SkRect::MakeLTRB(5.1, 5.65, 10.2, 12.85);
1834 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_clip_bounds);
1835 // Destination bounds are unaffected by transform
1836 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
1837 receiver.restore();
1838
1839 // save/restore returned the values to their original values
1840 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1841 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1842}
virtual void clipRRect(const SkRRect &rrect, ClipOp clip_op, bool is_aa)=0

◆ TEST_F() [191/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectAffectsClipBoundsWithMatrix   
)

Definition at line 1885 of file display_list_unittests.cc.

1885 {
1886 DisplayListBuilder builder;
1887 DlOpReceiver& receiver = ToReceiver(builder);
1888 SkRect clip_bounds_1 = SkRect::MakeLTRB(0, 0, 10, 10);
1889 SkRect clip_bounds_2 = SkRect::MakeLTRB(10, 10, 20, 20);
1890 SkRRect clip1 = SkRRect::MakeRectXY(clip_bounds_1, 3, 2);
1891 SkRRect clip2 = SkRRect::MakeRectXY(clip_bounds_2, 3, 2);
1892
1893 receiver.save();
1894 receiver.clipRRect(clip1, ClipOp::kIntersect, false);
1895 receiver.translate(10, 0);
1896 receiver.clipRRect(clip1, ClipOp::kIntersect, false);
1897 ASSERT_TRUE(builder.GetDestinationClipBounds().isEmpty());
1898 receiver.restore();
1899
1900 receiver.save();
1901 receiver.clipRRect(clip1, ClipOp::kIntersect, false);
1902 receiver.translate(-10, -10);
1903 receiver.clipRRect(clip2, ClipOp::kIntersect, false);
1904 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds_1);
1905 receiver.restore();
1906}

◆ TEST_F() [192/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectDoAAAffectsClipBounds   
)

Definition at line 1844 of file display_list_unittests.cc.

1844 {
1845 DisplayListBuilder builder;
1846 DlOpReceiver& receiver = ToReceiver(builder);
1847 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1848 SkRect clip_expanded_bounds = SkRect::MakeLTRB(10, 11, 21, 26);
1849 SkRRect clip = SkRRect::MakeRectXY(clip_bounds, 3, 2);
1850 receiver.clipRRect(clip, ClipOp::kIntersect, true);
1851
1852 // Save initial return values for testing restored values
1853 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1854 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1855 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1856 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1857
1858 receiver.save();
1859 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, true);
1860 // Both clip bounds have changed
1861 ASSERT_NE(builder.GetLocalClipBounds(), clip_expanded_bounds);
1862 ASSERT_NE(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1863 // Previous return values have not changed
1864 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1865 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1866 receiver.restore();
1867
1868 // save/restore returned the values to their original values
1869 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1870 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1871
1872 receiver.save();
1873 receiver.scale(2, 2);
1874 SkRect scaled_expanded_bounds = SkRect::MakeLTRB(5, 5.5, 10.5, 13);
1875 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_expanded_bounds);
1876 // Destination bounds are unaffected by transform
1877 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1878 receiver.restore();
1879
1880 // save/restore returned the values to their original values
1881 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1882 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1883}

◆ TEST_F() [193/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectTriggersDeferredSave   
)

Definition at line 2640 of file display_list_unittests.cc.

2640 {
2641 DisplayListBuilder builder1;
2642 DlOpReceiver& receiver1 = ToReceiver(builder1);
2643 receiver1.save();
2644 receiver1.save();
2645 receiver1.clipRRect(kTestRRect, ClipOp::kIntersect, true);
2646
2647 receiver1.drawRect({0, 0, 100, 100});
2648 receiver1.restore();
2649 receiver1.transformFullPerspective(1, 0, 0, 0, //
2650 0, 1, 0, 0, //
2651 0, 0, 1, 0, //
2652 0, 0, 0, 1);
2653 receiver1.drawRect({0, 0, 100, 100});
2654 receiver1.restore();
2655 auto display_list1 = builder1.Build();
2656
2657 DisplayListBuilder builder2;
2658 DlOpReceiver& receiver2 = ToReceiver(builder2);
2659 receiver2.save();
2660 receiver2.clipRRect(kTestRRect, ClipOp::kIntersect, true);
2661
2662 receiver2.drawRect({0, 0, 100, 100});
2663 receiver2.restore();
2664 receiver2.transformFullPerspective(1, 0, 0, 0, //
2665 0, 1, 0, 0, //
2666 0, 0, 1, 0, //
2667 0, 0, 0, 1);
2668 receiver2.drawRect({0, 0, 100, 100});
2669 auto display_list2 = builder2.Build();
2670
2671 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2672}

◆ TEST_F() [194/876]

flutter::testing::TEST_F ( DisplayListTest  ,
CollapseMultipleNestedSaveRestore   
)

Definition at line 2323 of file display_list_unittests.cc.

2323 {
2324 DisplayListBuilder builder1;
2325 DlOpReceiver& receiver1 = ToReceiver(builder1);
2326 receiver1.save();
2327 receiver1.save();
2328 receiver1.save();
2329 receiver1.translate(10, 10);
2330 receiver1.scale(2, 2);
2331 receiver1.clipRect({10, 10, 20, 20}, ClipOp::kIntersect, false);
2332 receiver1.drawRect({0, 0, 100, 100});
2333 receiver1.restore();
2334 receiver1.restore();
2335 receiver1.restore();
2336 auto display_list1 = builder1.Build();
2337
2338 DisplayListBuilder builder2;
2339 DlOpReceiver& receiver2 = ToReceiver(builder2);
2340 receiver2.save();
2341 receiver2.translate(10, 10);
2342 receiver2.scale(2, 2);
2343 receiver2.clipRect({10, 10, 20, 20}, ClipOp::kIntersect, false);
2344 receiver2.drawRect({0, 0, 100, 100});
2345 receiver2.restore();
2346 auto display_list2 = builder2.Build();
2347
2348 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2349}

◆ TEST_F() [195/876]

flutter::testing::TEST_F ( DisplayListTest  ,
CollapseNestedSaveAndSaveLayerRestore   
)

Definition at line 2351 of file display_list_unittests.cc.

2351 {
2352 DisplayListBuilder builder1;
2353 DlOpReceiver& receiver1 = ToReceiver(builder1);
2354 receiver1.save();
2355 receiver1.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
2356 receiver1.drawRect({0, 0, 100, 100});
2357 receiver1.scale(2, 2);
2358 receiver1.restore();
2359 receiver1.restore();
2360 auto display_list1 = builder1.Build();
2361
2362 DisplayListBuilder builder2;
2363 DlOpReceiver& receiver2 = ToReceiver(builder2);
2364 receiver2.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
2365 receiver2.drawRect({0, 0, 100, 100});
2366 receiver2.scale(2, 2);
2367 receiver2.restore();
2368 auto display_list2 = builder2.Build();
2369
2370 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2371}
virtual void saveLayer(const SkRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr)=0

◆ TEST_F() [196/876]

flutter::testing::TEST_F ( DisplayListTest  ,
Defaults   
)

Definition at line 230 of file display_list_unittests.cc.

230 {
231 DisplayListBuilder builder;
232 check_defaults(builder);
233}

◆ TEST_F() [197/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipPathDoesNotAffectClipBounds   
)

Definition at line 2047 of file display_list_unittests.cc.

2047 {
2048 DisplayListBuilder builder;
2049 DlOpReceiver& receiver = ToReceiver(builder);
2050 SkPath diff_clip = SkPath().addRect({0, 0, 15, 15});
2051 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2052 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
2053 receiver.clipPath(clip, ClipOp::kIntersect, false);
2054
2055 // Save initial return values for testing after kDifference clip
2056 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2057 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2058 ASSERT_EQ(initial_local_bounds, clip_bounds);
2059 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2060
2061 receiver.clipPath(diff_clip, ClipOp::kDifference, false);
2062 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2063 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2064}

◆ TEST_F() [198/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipPathWithInvertFillTypeAffectsClipBounds   
)

Definition at line 2078 of file display_list_unittests.cc.

2078 {
2079 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
2080 DisplayListBuilder builder(cull_rect);
2081 DlOpReceiver& receiver = ToReceiver(builder);
2082 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2084 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
2085 receiver.clipPath(clip, ClipOp::kDifference, false);
2086
2087 ASSERT_EQ(builder.GetLocalClipBounds(), clip_bounds);
2088 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
2089}

◆ TEST_F() [199/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipRectDoesNotAffectClipBounds   
)

Definition at line 2010 of file display_list_unittests.cc.

2010 {
2011 DisplayListBuilder builder;
2012 DlOpReceiver& receiver = ToReceiver(builder);
2013 SkRect diff_clip = SkRect::MakeLTRB(0, 0, 15, 15);
2014 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
2015 receiver.clipRect(clip_bounds, ClipOp::kIntersect, false);
2016
2017 // Save initial return values for testing after kDifference clip
2018 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2019 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2020 ASSERT_EQ(initial_local_bounds, clip_bounds);
2021 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2022
2023 receiver.clipRect(diff_clip, ClipOp::kDifference, false);
2024 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2025 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2026}

◆ TEST_F() [200/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipRRectDoesNotAffectClipBounds   
)

Definition at line 2028 of file display_list_unittests.cc.

2028 {
2029 DisplayListBuilder builder;
2030 DlOpReceiver& receiver = ToReceiver(builder);
2031 SkRRect diff_clip = SkRRect::MakeRectXY({0, 0, 15, 15}, 1, 1);
2032 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
2033 SkRRect clip = SkRRect::MakeRectXY({10.2, 11.3, 20.4, 25.7}, 3, 2);
2034 receiver.clipRRect(clip, ClipOp::kIntersect, false);
2035
2036 // Save initial return values for testing after kDifference clip
2037 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2038 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2039 ASSERT_EQ(initial_local_bounds, clip_bounds);
2040 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2041
2042 receiver.clipRRect(diff_clip, ClipOp::kDifference, false);
2043 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2044 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2045}

◆ TEST_F() [201/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListFullPerspectiveTransformHandling   
)

Definition at line 968 of file display_list_unittests.cc.

968 {
969 // SkM44 constructor takes row-major order
971 // clang-format off
972 1, 2, 3, 4,
973 5, 6, 7, 8,
974 9, 10, 11, 12,
975 13, 14, 15, 16
976 // clang-format on
977 );
978
979 { // First test ==
980 DisplayListBuilder builder;
981 DlOpReceiver& receiver = ToReceiver(builder);
982 // receiver.transformFullPerspective takes row-major order
984 // clang-format off
985 1, 2, 3, 4,
986 5, 6, 7, 8,
987 9, 10, 11, 12,
988 13, 14, 15, 16
989 // clang-format on
990 );
991 sk_sp<DisplayList> display_list = builder.Build();
994 SkCanvas* canvas = surface->getCanvas();
995 // We can't use DlSkCanvas.DrawDisplayList as that method protects
996 // the canvas against mutations from the display list being drawn.
997 auto dispatcher = DlSkCanvasDispatcher(surface->getCanvas());
998 display_list->Dispatch(dispatcher);
999 SkM44 dl_matrix = canvas->getLocalToDevice();
1000 ASSERT_EQ(sk_matrix, dl_matrix);
1001 }
1002 { // Next test !=
1003 DisplayListBuilder builder;
1004 DlOpReceiver& receiver = ToReceiver(builder);
1005 // receiver.transformFullPerspective takes row-major order
1006 receiver.transformFullPerspective(
1007 // clang-format off
1008 1, 5, 9, 13,
1009 2, 6, 7, 11,
1010 3, 7, 11, 15,
1011 4, 8, 12, 16
1012 // clang-format on
1013 );
1014 sk_sp<DisplayList> display_list = builder.Build();
1017 SkCanvas* canvas = surface->getCanvas();
1018 // We can't use DlSkCanvas.DrawDisplayList as that method protects
1019 // the canvas against mutations from the display list being drawn.
1020 auto dispatcher = DlSkCanvasDispatcher(surface->getCanvas());
1021 display_list->Dispatch(dispatcher);
1022 SkM44 dl_matrix = canvas->getLocalToDevice();
1023 ASSERT_NE(sk_matrix, dl_matrix);
1024 }
1025}
SkM44 getLocalToDevice() const
SkMatrix sk_matrix

◆ TEST_F() [202/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListSaveLayerBoundsWithAlphaFilter   
)

Definition at line 756 of file display_list_unittests.cc.

756 {
757 SkRect build_bounds = SkRect::MakeLTRB(-100, -100, 200, 200);
758 SkRect save_bounds = SkRect::MakeWH(100, 100);
759 SkRect rect = SkRect::MakeLTRB(30, 30, 70, 70);
760 // clang-format off
761 const float color_matrix[] = {
762 0, 0, 0, 0, 0,
763 0, 1, 0, 0, 0,
764 0, 0, 1, 0, 0,
765 0, 0, 0, 1, 0,
766 };
767 // clang-format on
768 DlMatrixColorFilter base_color_filter(color_matrix);
769 // clang-format off
770 const float alpha_matrix[] = {
771 0, 0, 0, 0, 0,
772 0, 1, 0, 0, 0,
773 0, 0, 1, 0, 0,
774 0, 0, 0, 0, 1,
775 };
776 // clang-format on
777 DlMatrixColorFilter alpha_color_filter(alpha_matrix);
778 sk_sp<SkColorFilter> sk_alpha_color_filter =
779 SkColorFilters::Matrix(alpha_matrix);
780
781 {
782 // No tricky stuff, just verifying drawing a rect produces rect bounds
783 DisplayListBuilder builder(build_bounds);
784 DlOpReceiver& receiver = ToReceiver(builder);
785 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
786 receiver.drawRect(rect);
787 receiver.restore();
788 sk_sp<DisplayList> display_list = builder.Build();
789 ASSERT_EQ(display_list->bounds(), rect);
790 }
791
792 {
793 // Now checking that a normal color filter still produces rect bounds
794 DisplayListBuilder builder(build_bounds);
795 DlOpReceiver& receiver = ToReceiver(builder);
796 receiver.setColorFilter(&base_color_filter);
797 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
798 receiver.setColorFilter(nullptr);
799 receiver.drawRect(rect);
800 receiver.restore();
801 sk_sp<DisplayList> display_list = builder.Build();
802 ASSERT_EQ(display_list->bounds(), rect);
803 }
804
805 {
806 // Now checking how SkPictureRecorder deals with a color filter
807 // that modifies alpha channels (save layer bounds are meaningless
808 // under those circumstances)
809 SkPictureRecorder recorder;
810 SkRTreeFactory rtree_factory;
811 SkCanvas* canvas = recorder.beginRecording(build_bounds, &rtree_factory);
812 SkPaint p1;
813 p1.setColorFilter(sk_alpha_color_filter);
814 canvas->saveLayer(save_bounds, &p1);
815 SkPaint p2;
816 canvas->drawRect(rect, p2);
817 canvas->restore();
819 ASSERT_EQ(picture->cullRect(), build_bounds);
820 }
821
822 {
823 // Now checking that DisplayList has the same behavior that we
824 // saw in the SkPictureRecorder example above - returning the
825 // cull rect of the DisplayListBuilder when it encounters a
826 // save layer that modifies an unbounded region
827 DisplayListBuilder builder(build_bounds);
828 DlOpReceiver& receiver = ToReceiver(builder);
829 receiver.setColorFilter(&alpha_color_filter);
830 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
831 receiver.setColorFilter(nullptr);
832 receiver.drawRect(rect);
833 receiver.restore();
834 sk_sp<DisplayList> display_list = builder.Build();
835 ASSERT_EQ(display_list->bounds(), build_bounds);
836 }
837
838 {
839 // Verifying that the save layer bounds are not relevant
840 // to the behavior in the previous example
841 DisplayListBuilder builder(build_bounds);
842 DlOpReceiver& receiver = ToReceiver(builder);
843 receiver.setColorFilter(&alpha_color_filter);
844 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
845 receiver.setColorFilter(nullptr);
846 receiver.drawRect(rect);
847 receiver.restore();
848 sk_sp<DisplayList> display_list = builder.Build();
849 ASSERT_EQ(display_list->bounds(), build_bounds);
850 }
851
852 {
853 // Making sure hiding a ColorFilter as an ImageFilter will
854 // generate the same behavior as setting it as a ColorFilter
855 DisplayListBuilder builder(build_bounds);
856 DlOpReceiver& receiver = ToReceiver(builder);
857 DlColorFilterImageFilter color_filter_image_filter(base_color_filter);
858 receiver.setImageFilter(&color_filter_image_filter);
859 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
860 receiver.setImageFilter(nullptr);
861 receiver.drawRect(rect);
862 receiver.restore();
863 sk_sp<DisplayList> display_list = builder.Build();
864 ASSERT_EQ(display_list->bounds(), rect);
865 }
866
867 {
868 // Making sure hiding a problematic ColorFilter as an ImageFilter
869 // will generate the same behavior as setting it as a ColorFilter
870 DisplayListBuilder builder(build_bounds);
871 DlOpReceiver& receiver = ToReceiver(builder);
872 DlColorFilterImageFilter color_filter_image_filter(alpha_color_filter);
873 receiver.setImageFilter(&color_filter_image_filter);
874 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
875 receiver.setImageFilter(nullptr);
876 receiver.drawRect(rect);
877 receiver.restore();
878 sk_sp<DisplayList> display_list = builder.Build();
879 ASSERT_EQ(display_list->bounds(), build_bounds);
880 }
881
882 {
883 // Same as above (ImageFilter hiding ColorFilter) with no save bounds
884 DisplayListBuilder builder(build_bounds);
885 DlOpReceiver& receiver = ToReceiver(builder);
886 DlColorFilterImageFilter color_filter_image_filter(alpha_color_filter);
887 receiver.setImageFilter(&color_filter_image_filter);
888 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
889 receiver.setImageFilter(nullptr);
890 receiver.drawRect(rect);
891 receiver.restore();
892 sk_sp<DisplayList> display_list = builder.Build();
893 ASSERT_EQ(display_list->bounds(), build_bounds);
894 }
895
896 {
897 // Testing behavior with an unboundable blend mode
898 DisplayListBuilder builder(build_bounds);
899 DlOpReceiver& receiver = ToReceiver(builder);
900 receiver.setBlendMode(DlBlendMode::kClear);
901 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
902 receiver.setBlendMode(DlBlendMode::kSrcOver);
903 receiver.drawRect(rect);
904 receiver.restore();
905 sk_sp<DisplayList> display_list = builder.Build();
906 ASSERT_EQ(display_list->bounds(), build_bounds);
907 }
908
909 {
910 // Same as previous with no save bounds
911 DisplayListBuilder builder(build_bounds);
912 DlOpReceiver& receiver = ToReceiver(builder);
913 receiver.setBlendMode(DlBlendMode::kClear);
914 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
915 receiver.setBlendMode(DlBlendMode::kSrcOver);
916 receiver.drawRect(rect);
917 receiver.restore();
918 sk_sp<DisplayList> display_list = builder.Build();
919 ASSERT_EQ(display_list->bounds(), build_bounds);
920 }
921}
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition SkCanvas.cpp:500
void restore()
Definition SkCanvas.cpp:465
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
void setColorFilter(sk_sp< SkColorFilter > colorFilter)
sk_sp< SkPicture > finishRecordingAsPicture()
virtual SkRect cullRect() const =0
sk_sp< const SkPicture > picture
Definition SkRecords.h:299

◆ TEST_F() [203/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListsWithVaryingOpComparisons   
)

Definition at line 723 of file display_list_unittests.cc.

723 {
724 sk_sp<DisplayList> default_dl = Build(allGroups.size(), 0);
725 ASSERT_TRUE(default_dl->Equals(*default_dl)) << "Default == itself";
726 for (size_t gi = 0; gi < allGroups.size(); gi++) {
728 sk_sp<DisplayList> missing_dl = Build(gi, group.variants.size());
729 auto desc = "[Group " + group.op_name + " omitted]";
730 ASSERT_TRUE(missing_dl->Equals(*missing_dl)) << desc << " == itself";
731 ASSERT_FALSE(missing_dl->Equals(*default_dl)) << desc << " != Default";
732 ASSERT_FALSE(default_dl->Equals(*missing_dl)) << "Default != " << desc;
733 for (size_t vi = 0; vi < group.variants.size(); vi++) {
734 auto desc = "[Group " + group.op_name + " variant " +
735 std::to_string(vi + 1) + "]";
736 sk_sp<DisplayList> variant_dl = Build(gi, vi);
737 ASSERT_TRUE(variant_dl->Equals(*variant_dl)) << desc << " == itself";
738 if (vi == 0) {
739 ASSERT_TRUE(variant_dl->Equals(*default_dl)) << desc << " == Default";
740 ASSERT_TRUE(default_dl->Equals(*variant_dl)) << "Default == " << desc;
741 } else {
742 ASSERT_FALSE(variant_dl->Equals(*default_dl)) << desc << " != Default";
743 ASSERT_FALSE(default_dl->Equals(*variant_dl)) << "Default != " << desc;
744 }
745 if (group.variants[vi].is_empty()) {
746 ASSERT_TRUE(variant_dl->Equals(*missing_dl)) << desc << " != omitted";
747 ASSERT_TRUE(missing_dl->Equals(*variant_dl)) << "omitted != " << desc;
748 } else {
749 ASSERT_FALSE(variant_dl->Equals(*missing_dl)) << desc << " != omitted";
750 ASSERT_FALSE(missing_dl->Equals(*variant_dl)) << "omitted != " << desc;
751 }
752 }
753 }
754}
static std::vector< testing::DisplayListInvocationGroup > allGroups

◆ TEST_F() [204/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListTransformResetHandling   
)

Definition at line 1027 of file display_list_unittests.cc.

1027 {
1028 DisplayListBuilder builder;
1029 DlOpReceiver& receiver = ToReceiver(builder);
1030 receiver.scale(20.0, 20.0);
1031 receiver.transformReset();
1032 auto display_list = builder.Build();
1033 ASSERT_NE(display_list, nullptr);
1036 SkCanvas* canvas = surface->getCanvas();
1037 // We can't use DlSkCanvas.DrawDisplayList as that method protects
1038 // the canvas against mutations from the display list being drawn.
1039 auto dispatcher = DlSkCanvasDispatcher(surface->getCanvas());
1040 display_list->Dispatch(dispatcher);
1041 ASSERT_TRUE(canvas->getTotalMatrix().isIdentity());
1042}
virtual void transformReset()=0

◆ TEST_F() [205/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawSaveDrawCannotInheritOpacity   
)

Definition at line 3038 of file display_list_unittests.cc.

3038 {
3039 DisplayListBuilder builder;
3040 builder.DrawCircle({10, 10}, 5, DlPaint());
3041 builder.Save();
3042 builder.ClipRect({0, 0, 20, 20}, DlCanvas::ClipOp::kIntersect, false);
3043 builder.DrawRect({5, 5, 15, 15}, DlPaint());
3044 builder.Restore();
3045 auto display_list = builder.Build();
3046
3047 ASSERT_FALSE(display_list->can_apply_group_opacity());
3048}

◆ TEST_F() [206/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedOval   
)

Definition at line 3064 of file display_list_unittests.cc.

3064 {
3065 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3066 canvas.DrawOval(rect, paint);
3067 };
3068 check_inverted_bounds(renderer, "DrawOval");
3069}
virtual void DrawOval(const SkRect &bounds, const DlPaint &paint)=0

◆ TEST_F() [207/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedOvalPath   
)

Definition at line 3078 of file display_list_unittests.cc.

3078 {
3079 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3080 canvas.DrawPath(SkPath().addOval(rect), paint);
3081 };
3082 check_inverted_bounds(renderer, "DrawOvalPath");
3083}
virtual void DrawPath(const SkPath &path, const DlPaint &paint)=0

◆ TEST_F() [208/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRect   
)

Definition at line 3050 of file display_list_unittests.cc.

3050 {
3051 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3052 canvas.DrawRect(rect, paint);
3053 };
3054 check_inverted_bounds(renderer, "DrawRect");
3055}

◆ TEST_F() [209/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRectangularPath   
)

Definition at line 3071 of file display_list_unittests.cc.

3071 {
3072 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3073 canvas.DrawPath(SkPath().addRect(rect), paint);
3074 };
3075 check_inverted_bounds(renderer, "DrawRectangularPath");
3076}

◆ TEST_F() [210/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRoundRect   
)

Definition at line 3057 of file display_list_unittests.cc.

3057 {
3058 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3059 canvas.DrawRRect(SkRRect::MakeRectXY(rect, 2.0f, 2.0f), paint);
3060 };
3061 check_inverted_bounds(renderer, "DrawRoundRect");
3062}
virtual void DrawRRect(const SkRRect &rrect, const DlPaint &paint)=0

◆ TEST_F() [211/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRoundRectPathCCW   
)

Definition at line 3094 of file display_list_unittests.cc.

3094 {
3095 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3096 SkPath path = SkPath() //
3097 .addRoundRect(rect, 2.0f, 2.0f, SkPathDirection::kCCW);
3098 canvas.DrawPath(path, paint);
3099 };
3100 check_inverted_bounds(renderer, "DrawRoundRectPath Counter-Clockwise");
3101}
SkPath & addRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW)
Definition SkPath.cpp:1088

◆ TEST_F() [212/876]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRoundRectPathCW   
)

Definition at line 3085 of file display_list_unittests.cc.

3085 {
3086 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3087 SkPath path = SkPath() //
3088 .addRoundRect(rect, 2.0f, 2.0f, SkPathDirection::kCW);
3089 canvas.DrawPath(path, paint);
3090 };
3091 check_inverted_bounds(renderer, "DrawRoundRectPath Clockwise");
3092}

◆ TEST_F() [213/876]

flutter::testing::TEST_F ( DisplayListTest  ,
EmptyBuild   
)

Definition at line 235 of file display_list_unittests.cc.

235 {
236 DisplayListBuilder builder;
237 auto dl = builder.Build();
238 EXPECT_EQ(dl->op_count(), 0u);
239 EXPECT_EQ(dl->bytes(), sizeof(DisplayList));
240 EXPECT_EQ(dl->total_depth(), 0u);
241}

◆ TEST_F() [214/876]

flutter::testing::TEST_F ( DisplayListTest  ,
EmptyRebuild   
)

Definition at line 243 of file display_list_unittests.cc.

243 {
244 DisplayListBuilder builder;
245 auto dl1 = builder.Build();
246 auto dl2 = builder.Build();
247 auto dl3 = builder.Build();
248 ASSERT_TRUE(dl1->Equals(dl2));
249 ASSERT_TRUE(dl2->Equals(dl3));
250}

◆ TEST_F() [215/876]

flutter::testing::TEST_F ( DisplayListTest  ,
FlatDrawPointsProducesBounds   
)

Definition at line 2091 of file display_list_unittests.cc.

2091 {
2092 SkPoint horizontal_points[2] = {{10, 10}, {20, 10}};
2093 SkPoint vertical_points[2] = {{10, 10}, {10, 20}};
2094 {
2095 DisplayListBuilder builder;
2096 DlOpReceiver& receiver = ToReceiver(builder);
2097 receiver.drawPoints(PointMode::kPolygon, 2, horizontal_points);
2098 SkRect bounds = builder.Build()->bounds();
2099 EXPECT_TRUE(bounds.contains(10, 10));
2100 EXPECT_TRUE(bounds.contains(20, 10));
2101 EXPECT_GE(bounds.width(), 10);
2102 }
2103 {
2104 DisplayListBuilder builder;
2105 DlOpReceiver& receiver = ToReceiver(builder);
2106 receiver.drawPoints(PointMode::kPolygon, 2, vertical_points);
2107 SkRect bounds = builder.Build()->bounds();
2108 EXPECT_TRUE(bounds.contains(10, 10));
2109 EXPECT_TRUE(bounds.contains(10, 20));
2110 EXPECT_GE(bounds.height(), 10);
2111 }
2112 {
2113 DisplayListBuilder builder;
2114 DlOpReceiver& receiver = ToReceiver(builder);
2115 receiver.drawPoints(PointMode::kPoints, 1, horizontal_points);
2116 SkRect bounds = builder.Build()->bounds();
2117 EXPECT_TRUE(bounds.contains(10, 10));
2118 }
2119 {
2120 DisplayListBuilder builder;
2121 DlOpReceiver& receiver = ToReceiver(builder);
2122 receiver.setStrokeWidth(2);
2123 receiver.drawPoints(PointMode::kPolygon, 2, horizontal_points);
2124 SkRect bounds = builder.Build()->bounds();
2125 EXPECT_TRUE(bounds.contains(10, 10));
2126 EXPECT_TRUE(bounds.contains(20, 10));
2127 EXPECT_EQ(bounds, SkRect::MakeLTRB(9, 9, 21, 11));
2128 }
2129 {
2130 DisplayListBuilder builder;
2131 DlOpReceiver& receiver = ToReceiver(builder);
2132 receiver.setStrokeWidth(2);
2133 receiver.drawPoints(PointMode::kPolygon, 2, vertical_points);
2134 SkRect bounds = builder.Build()->bounds();
2135 EXPECT_TRUE(bounds.contains(10, 10));
2136 EXPECT_TRUE(bounds.contains(10, 20));
2137 EXPECT_EQ(bounds, SkRect::MakeLTRB(9, 9, 11, 21));
2138 }
2139 {
2140 DisplayListBuilder builder;
2141 DlOpReceiver& receiver = ToReceiver(builder);
2142 receiver.setStrokeWidth(2);
2143 receiver.drawPoints(PointMode::kPoints, 1, horizontal_points);
2144 SkRect bounds = builder.Build()->bounds();
2145 EXPECT_TRUE(bounds.contains(10, 10));
2146 EXPECT_EQ(bounds, SkRect::MakeLTRB(9, 9, 11, 11));
2147 }
2148}

◆ TEST_F() [216/876]

flutter::testing::TEST_F ( DisplayListTest  ,
FloodingSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3653 of file display_list_unittests.cc.

3653 {
3654 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3655 DlPaint save_paint;
3656 auto color_filter =
3657 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3658 ASSERT_TRUE(color_filter->modifies_transparent_black());
3659 save_paint.setColorFilter(color_filter);
3660 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3661 ASSERT_NE(clip_rect, rect);
3662 ASSERT_TRUE(clip_rect.contains(rect));
3663
3664 DisplayListBuilder builder;
3665 builder.ClipRect(clip_rect);
3666 builder.SaveLayer(nullptr, &save_paint);
3667 { //
3668 builder.DrawRect(rect, DlPaint());
3669 }
3670 builder.Restore();
3671 auto display_list = builder.Build();
3672
3673 SaveLayerBoundsExpector expector;
3674 expector.addComputedExpectation(rect);
3675 display_list->Dispatch(expector);
3676 EXPECT_TRUE(expector.all_bounds_checked());
3677}

◆ TEST_F() [217/876]

flutter::testing::TEST_F ( DisplayListTest  ,
FlutterSvgIssue661BoundsWereEmpty   
)

Definition at line 1453 of file display_list_unittests.cc.

1453 {
1454 // See https://github.com/dnfield/flutter_svg/issues/661
1455
1456 SkPath path1;
1458 path1.moveTo(25.54f, 37.52f);
1459 path1.cubicTo(20.91f, 37.52f, 16.54f, 33.39f, 13.62f, 30.58f);
1460 path1.lineTo(13, 30);
1461 path1.lineTo(12.45f, 29.42f);
1462 path1.cubicTo(8.39f, 25.15f, 1.61f, 18, 8.37f, 11.27f);
1463 path1.cubicTo(10.18f, 9.46f, 12.37f, 9.58f, 14.49f, 11.58f);
1464 path1.cubicTo(15.67f, 12.71f, 17.05f, 14.69f, 17.07f, 16.58f);
1465 path1.cubicTo(17.0968f, 17.458f, 16.7603f, 18.3081f, 16.14f, 18.93f);
1466 path1.cubicTo(15.8168f, 19.239f, 15.4653f, 19.5169f, 15.09f, 19.76f);
1467 path1.cubicTo(14.27f, 20.33f, 14.21f, 20.44f, 14.27f, 20.62f);
1468 path1.cubicTo(15.1672f, 22.3493f, 16.3239f, 23.9309f, 17.7f, 25.31f);
1469 path1.cubicTo(19.0791f, 26.6861f, 20.6607f, 27.8428f, 22.39f, 28.74f);
1470 path1.cubicTo(22.57f, 28.8f, 22.69f, 28.74f, 23.25f, 27.92f);
1471 path1.cubicTo(23.5f, 27.566f, 23.778f, 27.231f, 24.08f, 26.92f);
1472 path1.cubicTo(24.7045f, 26.3048f, 25.5538f, 25.9723f, 26.43f, 26);
1473 path1.cubicTo(28.29f, 26, 30.27f, 27.4f, 31.43f, 28.58f);
1474 path1.cubicTo(33.43f, 30.67f, 33.55f, 32.9f, 31.74f, 34.7f);
1475 path1.cubicTo(30.1477f, 36.4508f, 27.906f, 37.4704f, 25.54f, 37.52f);
1476 path1.close();
1477 path1.moveTo(11.17f, 12.23f);
1478 path1.cubicTo(10.6946f, 12.2571f, 10.2522f, 12.4819f, 9.95f, 12.85f);
1479 path1.cubicTo(5.12f, 17.67f, 8.95f, 22.5f, 14.05f, 27.85f);
1480 path1.lineTo(14.62f, 28.45f);
1481 path1.lineTo(15.16f, 28.96f);
1482 path1.cubicTo(20.52f, 34.06f, 25.35f, 37.89f, 30.16f, 33.06f);
1483 path1.cubicTo(30.83f, 32.39f, 31.25f, 31.56f, 29.81f, 30.06f);
1484 path1.cubicTo(28.9247f, 29.07f, 27.7359f, 28.4018f, 26.43f, 28.16f);
1485 path1.cubicTo(26.1476f, 28.1284f, 25.8676f, 28.2367f, 25.68f, 28.45f);
1486 path1.cubicTo(25.4633f, 28.6774f, 25.269f, 28.9252f, 25.1f, 29.19f);
1487 path1.cubicTo(24.53f, 30.01f, 23.47f, 31.54f, 21.54f, 30.79f);
1488 path1.lineTo(21.41f, 30.72f);
1489 path1.cubicTo(19.4601f, 29.7156f, 17.6787f, 28.4133f, 16.13f, 26.86f);
1490 path1.cubicTo(14.5748f, 25.3106f, 13.2693f, 23.5295f, 12.26f, 21.58f);
1491 path1.lineTo(12.2f, 21.44f);
1492 path1.cubicTo(11.45f, 19.51f, 12.97f, 18.44f, 13.8f, 17.88f);
1493 path1.cubicTo(14.061f, 17.706f, 14.308f, 17.512f, 14.54f, 17.3f);
1494 path1.cubicTo(14.7379f, 17.1067f, 14.8404f, 16.8359f, 14.82f, 16.56f);
1495 path1.cubicTo(14.5978f, 15.268f, 13.9585f, 14.0843f, 13, 13.19f);
1496 path1.cubicTo(12.5398f, 12.642f, 11.8824f, 12.2971f, 11.17f, 12.23f);
1497 path1.lineTo(11.17f, 12.23f);
1498 path1.close();
1499 path1.moveTo(27, 19.34f);
1500 path1.lineTo(24.74f, 19.34f);
1501 path1.cubicTo(24.7319f, 18.758f, 24.262f, 18.2881f, 23.68f, 18.28f);
1502 path1.lineTo(23.68f, 16.05f);
1503 path1.lineTo(23.7f, 16.05f);
1504 path1.cubicTo(25.5153f, 16.0582f, 26.9863f, 17.5248f, 27, 19.34f);
1505 path1.lineTo(27, 19.34f);
1506 path1.close();
1507 path1.moveTo(32.3f, 19.34f);
1508 path1.lineTo(30.07f, 19.34f);
1509 path1.cubicTo(30.037f, 15.859f, 27.171f, 13.011f, 23.69f, 13);
1510 path1.lineTo(23.69f, 10.72f);
1511 path1.cubicTo(28.415f, 10.725f, 32.3f, 14.615f, 32.3f, 19.34f);
1512 path1.close();
1513
1514 SkPath path2;
1516 path2.moveTo(37.5f, 19.33f);
1517 path2.lineTo(35.27f, 19.33f);
1518 path2.cubicTo(35.265f, 12.979f, 30.041f, 7.755f, 23.69f, 7.75f);
1519 path2.lineTo(23.69f, 5.52f);
1520 path2.cubicTo(31.264f, 5.525f, 37.495f, 11.756f, 37.5f, 19.33f);
1521 path2.close();
1522
1523 DisplayListBuilder builder;
1524 DlPaint paint = DlPaint(DlColor::kWhite()).setAntiAlias(true);
1525 {
1526 builder.Save();
1527 builder.ClipRect({0, 0, 100, 100}, ClipOp::kIntersect, true);
1528 {
1529 builder.Save();
1530 builder.Transform2DAffine(2.17391, 0, -2547.83, //
1531 0, 2.04082, -500);
1532 {
1533 builder.Save();
1534 builder.ClipRect({1172, 245, 1218, 294}, ClipOp::kIntersect, true);
1535 {
1536 builder.SaveLayer(nullptr, nullptr, nullptr);
1537 {
1538 builder.Save();
1539 builder.Transform2DAffine(1.4375, 0, 1164.09, //
1540 0, 1.53125, 236.548);
1541 builder.DrawPath(path1, paint);
1542 builder.Restore();
1543 }
1544 {
1545 builder.Save();
1546 builder.Transform2DAffine(1.4375, 0, 1164.09, //
1547 0, 1.53125, 236.548);
1548 builder.DrawPath(path2, paint);
1549 builder.Restore();
1550 }
1551 builder.Restore();
1552 }
1553 builder.Restore();
1554 }
1555 builder.Restore();
1556 }
1557 builder.Restore();
1558 }
1559 sk_sp<DisplayList> display_list = builder.Build();
1560 // Prior to the fix, the bounds were empty.
1561 EXPECT_FALSE(display_list->bounds().isEmpty());
1562 // These are just inside and outside of the expected bounds, but
1563 // testing float values can be flaky wrt minor changes in the bounds
1564 // calculations. If these lines have to be revised too often as the DL
1565 // implementation is improved and maintained, then we can eliminate
1566 // this test and just rely on the "rounded out" bounds test that follows.
1567 SkRect min_bounds = SkRect::MakeLTRB(0, 0.00191, 99.983, 100);
1568 SkRect max_bounds = SkRect::MakeLTRB(0, 0.00189, 99.985, 100);
1569 ASSERT_TRUE(max_bounds.contains(min_bounds));
1570 EXPECT_TRUE(max_bounds.contains(display_list->bounds()));
1571 EXPECT_TRUE(display_list->bounds().contains(min_bounds));
1572
1573 // This is the more practical result. The bounds are "almost" 0,0,100x100
1574 EXPECT_EQ(display_list->bounds().roundOut(), SkIRect::MakeWH(100, 100));
1575 EXPECT_EQ(display_list->op_count(), 19u);
1576 EXPECT_EQ(display_list->bytes(), sizeof(DisplayList) + 400u);
1577 EXPECT_EQ(display_list->total_depth(), 3u);
1578}

◆ TEST_F() [218/876]

flutter::testing::TEST_F ( DisplayListTest  ,
FullRotationsAreNop   
)

Definition at line 695 of file display_list_unittests.cc.

695 {
696 DisplayListBuilder builder;
697 DlOpReceiver& receiver = ToReceiver(builder);
698 receiver.rotate(0);
699 receiver.rotate(360);
700 receiver.rotate(720);
701 receiver.rotate(1080);
702 receiver.rotate(1440);
703 sk_sp<DisplayList> dl = builder.Build();
704 ASSERT_EQ(dl->bytes(false), sizeof(DisplayList));
705 ASSERT_EQ(dl->bytes(true), sizeof(DisplayList));
706 ASSERT_EQ(dl->op_count(false), 0u);
707 ASSERT_EQ(dl->op_count(true), 0u);
708 EXPECT_EQ(dl->total_depth(), 0u);
709}
virtual void rotate(SkScalar degrees)=0

◆ TEST_F() [219/876]

flutter::testing::TEST_F ( DisplayListTest  ,
FullTransformAffectsCurrentTransform   
)

Definition at line 1678 of file display_list_unittests.cc.

1678 {
1679 DisplayListBuilder builder;
1680 DlOpReceiver& receiver = ToReceiver(builder);
1681 receiver.transformFullPerspective(3, 0, 4, 12.3, //
1682 1, 5, 3, 14.5, //
1683 0, 0, 7, 16.2, //
1684 0, 0, 0, 1);
1685 SkMatrix matrix = SkMatrix::MakeAll(3, 0, 12.3, //
1686 1, 5, 14.5, //
1687 0, 0, 1);
1688 SkM44 m44 = SkM44(3, 0, 4, 12.3, //
1689 1, 5, 3, 14.5, //
1690 0, 0, 7, 16.2, //
1691 0, 0, 0, 1);
1692 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1693 SkMatrix cur_matrix = builder.GetTransform();
1694 ASSERT_EQ(cur_m44, m44);
1695 ASSERT_EQ(cur_matrix, matrix);
1696 receiver.translate(10, 10);
1697 // CurrentTransform has changed
1698 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1699 ASSERT_NE(builder.GetTransform(), cur_matrix);
1700 // Previous return values have not
1701 ASSERT_EQ(cur_m44, m44);
1702 ASSERT_EQ(cur_matrix, matrix);
1703}

◆ TEST_F() [220/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ImpellerPathPreferenceIsHonored   
)

Definition at line 3265 of file display_list_unittests.cc.

3265 {
3266 class Tester : virtual public DlOpReceiver,
3271 public:
3272 explicit Tester(bool prefer_impeller_paths)
3273 : prefer_impeller_paths_(prefer_impeller_paths) {}
3274
3275 bool PrefersImpellerPaths() const override {
3276 return prefer_impeller_paths_;
3277 }
3278
3279 void drawPath(const SkPath& path) override { skia_draw_path_calls_++; }
3280
3281 void drawPath(const CacheablePath& cache) override {
3282 impeller_draw_path_calls_++;
3283 }
3284
3285 void clipPath(const SkPath& path, ClipOp op, bool is_aa) override {
3286 skia_clip_path_calls_++;
3287 }
3288
3289 void clipPath(const CacheablePath& cache, ClipOp op, bool is_aa) override {
3290 impeller_clip_path_calls_++;
3291 }
3292
3293 virtual void drawShadow(const SkPath& sk_path,
3294 const DlColor color,
3295 const SkScalar elevation,
3296 bool transparent_occluder,
3297 SkScalar dpr) override {
3298 skia_draw_shadow_calls_++;
3299 }
3300
3301 virtual void drawShadow(const CacheablePath& cache,
3302 const DlColor color,
3303 const SkScalar elevation,
3304 bool transparent_occluder,
3305 SkScalar dpr) override {
3306 impeller_draw_shadow_calls_++;
3307 }
3308
3309 int skia_draw_path_calls() const { return skia_draw_path_calls_; }
3310 int skia_clip_path_calls() const { return skia_draw_path_calls_; }
3311 int skia_draw_shadow_calls() const { return skia_draw_path_calls_; }
3312 int impeller_draw_path_calls() const { return impeller_draw_path_calls_; }
3313 int impeller_clip_path_calls() const { return impeller_draw_path_calls_; }
3314 int impeller_draw_shadow_calls() const { return impeller_draw_path_calls_; }
3315
3316 private:
3317 const bool prefer_impeller_paths_;
3318 int skia_draw_path_calls_ = 0;
3319 int skia_clip_path_calls_ = 0;
3320 int skia_draw_shadow_calls_ = 0;
3321 int impeller_draw_path_calls_ = 0;
3322 int impeller_clip_path_calls_ = 0;
3323 int impeller_draw_shadow_calls_ = 0;
3324 };
3325
3326 DisplayListBuilder builder;
3327 builder.DrawPath(SkPath::Rect(SkRect::MakeLTRB(0, 0, 100, 100)), DlPaint());
3328 builder.ClipPath(SkPath::Rect(SkRect::MakeLTRB(0, 0, 100, 100)),
3329 ClipOp::kIntersect, true);
3330 builder.DrawShadow(SkPath::Rect(SkRect::MakeLTRB(20, 20, 80, 80)),
3331 DlColor::kBlue(), 1.0f, true, 1.0f);
3332 auto display_list = builder.Build();
3333
3334 {
3335 Tester skia_tester(false);
3336 display_list->Dispatch(skia_tester);
3337 EXPECT_EQ(skia_tester.skia_draw_path_calls(), 1);
3338 EXPECT_EQ(skia_tester.skia_clip_path_calls(), 1);
3339 EXPECT_EQ(skia_tester.skia_draw_shadow_calls(), 1);
3340 EXPECT_EQ(skia_tester.impeller_draw_path_calls(), 0);
3341 EXPECT_EQ(skia_tester.impeller_clip_path_calls(), 0);
3342 EXPECT_EQ(skia_tester.impeller_draw_shadow_calls(), 0);
3343 }
3344
3345 {
3346 Tester impeller_tester(true);
3347 display_list->Dispatch(impeller_tester);
3348 EXPECT_EQ(impeller_tester.skia_draw_path_calls(), 0);
3349 EXPECT_EQ(impeller_tester.skia_clip_path_calls(), 0);
3350 EXPECT_EQ(impeller_tester.skia_draw_shadow_calls(), 0);
3351 EXPECT_EQ(impeller_tester.impeller_draw_path_calls(), 1);
3352 EXPECT_EQ(impeller_tester.impeller_clip_path_calls(), 1);
3353 EXPECT_EQ(impeller_tester.impeller_draw_shadow_calls(), 1);
3354 }
3355}
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
Definition SkPath.cpp:3518
virtual void drawPath(const CacheablePath &cache)
virtual void drawShadow(const CacheablePath &cache, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr)
virtual bool PrefersImpellerPaths() const

◆ TEST_F() [221/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedDisplayListRTreesAreSparse   
)

prepare_rtree=

prepare_rtree=

Definition at line 2260 of file display_list_unittests.cc.

2260 {
2261 DisplayListBuilder nested_dl_builder(/**prepare_rtree=*/true);
2262 DlOpReceiver& nested_dl_receiver = ToReceiver(nested_dl_builder);
2263 nested_dl_receiver.drawRect({10, 10, 20, 20});
2264 nested_dl_receiver.drawRect({50, 50, 60, 60});
2265 auto nested_display_list = nested_dl_builder.Build();
2266
2267 DisplayListBuilder builder(/**prepare_rtree=*/true);
2268 DlOpReceiver& receiver = ToReceiver(builder);
2269 receiver.drawDisplayList(nested_display_list);
2270 auto display_list = builder.Build();
2271
2272 auto rtree = display_list->rtree();
2273 std::vector<SkRect> rects = {
2274 {10, 10, 20, 20},
2275 {50, 50, 60, 60},
2276 };
2277
2278 // Hitting both sub-dl drawRect calls
2279 test_rtree(rtree, {19, 19, 51, 51}, rects, {0, 1});
2280}
static void test_rtree(const sk_sp< const DlRTree > &rtree, const SkRect &query, std::vector< SkRect > expected_rects, const std::vector< int > &expected_indices)

◆ TEST_F() [222/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedFloodingSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3679 of file display_list_unittests.cc.

3679 {
3680 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3681 DlPaint save_paint;
3682 auto color_filter =
3683 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3684 ASSERT_TRUE(color_filter->modifies_transparent_black());
3685 save_paint.setColorFilter(color_filter);
3686 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3687 ASSERT_NE(clip_rect, rect);
3688 ASSERT_TRUE(clip_rect.contains(rect));
3689
3690 DisplayListBuilder builder;
3691 builder.ClipRect(clip_rect);
3692 builder.SaveLayer(nullptr, nullptr);
3693 {
3694 builder.SaveLayer(nullptr, &save_paint);
3695 { //
3696 builder.DrawRect(rect, DlPaint());
3697 }
3698 builder.Restore();
3699 }
3700 builder.Restore();
3701 auto display_list = builder.Build();
3702
3703 SaveLayerBoundsExpector expector;
3704 expector.addComputedExpectation(clip_rect);
3705 expector.addComputedExpectation(rect);
3706 display_list->Dispatch(expector);
3707 EXPECT_TRUE(expector.all_bounds_checked());
3708}

◆ TEST_F() [223/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedOpCountMetricsSameAsSkPicture   
)

Definition at line 923 of file display_list_unittests.cc.

923 {
924 SkPictureRecorder recorder;
925 recorder.beginRecording(SkRect::MakeWH(150, 100));
926 SkCanvas* canvas = recorder.getRecordingCanvas();
928 for (int y = 10; y <= 60; y += 10) {
929 for (int x = 10; x <= 60; x += 10) {
930 paint.setColor(((x + y) % 20) == 10 ? SK_ColorRED : SK_ColorBLUE);
931 canvas->drawRect(SkRect::MakeXYWH(x, y, 80, 80), paint);
932 }
933 }
934 SkPictureRecorder outer_recorder;
935 outer_recorder.beginRecording(SkRect::MakeWH(150, 100));
936 canvas = outer_recorder.getRecordingCanvas();
937 canvas->drawPicture(recorder.finishRecordingAsPicture());
938
939 auto picture = outer_recorder.finishRecordingAsPicture();
940 ASSERT_EQ(picture->approximateOpCount(), 1);
941 ASSERT_EQ(picture->approximateOpCount(true), 36);
942
943 DisplayListBuilder builder(SkRect::MakeWH(150, 100));
944 DlOpReceiver& receiver = ToReceiver(builder);
945 for (int y = 10; y <= 60; y += 10) {
946 for (int x = 10; x <= 60; x += 10) {
947 receiver.setColor(((x + y) % 20) == 10 ? DlColor(SK_ColorRED)
948 : DlColor(SK_ColorBLUE));
949 receiver.drawRect(SkRect::MakeXYWH(x, y, 80, 80));
950 }
951 }
952
953 DisplayListBuilder outer_builder(SkRect::MakeWH(150, 100));
954 DlOpReceiver& outer_receiver = ToReceiver(outer_builder);
955 outer_receiver.drawDisplayList(builder.Build());
956 auto display_list = outer_builder.Build();
957
958 ASSERT_EQ(display_list->op_count(), 1u);
959 ASSERT_EQ(display_list->op_count(true), 36u);
960 EXPECT_EQ(display_list->total_depth(), 37u);
961
962 ASSERT_EQ(picture->approximateOpCount(),
963 static_cast<int>(display_list->op_count()));
964 ASSERT_EQ(picture->approximateOpCount(true),
965 static_cast<int>(display_list->op_count(true)));
966}
void drawPicture(const SkPicture *picture)
Definition SkCanvas.h:1961
SkCanvas * getRecordingCanvas()
virtual int approximateOpCount(bool nested=false) const =0

◆ TEST_F() [224/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedSaveLayersCanBothSupportOpacityOptimization   
)

Definition at line 1333 of file display_list_unittests.cc.

1333 {
1334 SaveLayerOptions expected1 =
1335 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1336 SaveLayerOptions expected2 =
1337 SaveLayerOptions::kNoAttributes.with_can_distribute_opacity();
1338 SaveLayerOptionsExpector expector({expected1, expected2});
1339
1340 DisplayListBuilder builder;
1341 DlOpReceiver& receiver = ToReceiver(builder);
1342 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1343 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1344 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1345 receiver.drawRect({10, 10, 20, 20});
1346 receiver.restore();
1347 receiver.restore();
1348
1349 builder.Build()->Dispatch(expector);
1350 EXPECT_EQ(expector.save_layer_count(), 2);
1351}
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition SkColor.h:49
SaveLayerOptions with_can_distribute_opacity() const

◆ TEST_F() [225/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedSaveLayersMightInheritOpacity   
)

Definition at line 1309 of file display_list_unittests.cc.

1309 {
1310 SaveLayerOptions expected1 =
1311 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1312 SaveLayerOptions expected2 = SaveLayerOptions::kWithAttributes;
1313 SaveLayerOptions expected3 =
1314 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1315 SaveLayerOptionsExpector expector({expected1, expected2, expected3});
1316
1317 DisplayListBuilder builder;
1318 DlOpReceiver& receiver = ToReceiver(builder);
1319 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1320 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1321 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1322 receiver.drawRect({10, 10, 20, 20});
1323 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1324 receiver.drawRect({15, 15, 25, 25});
1325 receiver.restore();
1326 receiver.restore();
1327 receiver.restore();
1328
1329 builder.Build()->Dispatch(expector);
1330 EXPECT_EQ(expector.save_layer_count(), 3);
1331}

◆ TEST_F() [226/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPClipDoesNotTriggerDeferredSave   
)

Definition at line 2894 of file display_list_unittests.cc.

2894 {
2895 DisplayListBuilder builder1;
2896 DlOpReceiver& receiver1 = ToReceiver(builder1);
2897 receiver1.save();
2898 receiver1.save();
2900 ClipOp::kIntersect, true);
2901 receiver1.drawRect({0, 0, 100, 100});
2902 receiver1.restore();
2903 receiver1.drawRect({0, 0, 100, 100});
2904 receiver1.restore();
2905 auto display_list1 = builder1.Build();
2906
2907 DisplayListBuilder builder2;
2908 DlOpReceiver& receiver2 = ToReceiver(builder2);
2909 receiver2.drawRect({0, 0, 100, 100});
2910 receiver2.drawRect({0, 0, 100, 100});
2911 auto display_list2 = builder2.Build();
2912
2913 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2914}

◆ TEST_F() [227/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NopOperationsOmittedFromRecords   
)

Definition at line 3103 of file display_list_unittests.cc.

3103 {
3104 auto run_tests = [](const std::string& name,
3105 void init(DisplayListBuilder & builder, DlPaint & paint),
3106 uint32_t expected_op_count = 0u,
3107 uint32_t expected_total_depth = 0u) {
3108 auto run_one_test =
3109 [init](const std::string& name,
3110 void build(DisplayListBuilder & builder, DlPaint & paint),
3111 uint32_t expected_op_count = 0u,
3112 uint32_t expected_total_depth = 0u) {
3113 DisplayListBuilder builder;
3114 DlPaint paint;
3115 init(builder, paint);
3116 build(builder, paint);
3117 auto list = builder.Build();
3118 if (list->op_count() != expected_op_count) {
3119 FML_LOG(ERROR) << *list;
3120 }
3121 ASSERT_EQ(list->op_count(), expected_op_count) << name;
3122 EXPECT_EQ(list->total_depth(), expected_total_depth) << name;
3123 ASSERT_TRUE(list->bounds().isEmpty()) << name;
3124 };
3125 run_one_test(
3126 name + " DrawColor",
3127 [](DisplayListBuilder& builder, DlPaint& paint) {
3128 builder.DrawColor(paint.getColor(), paint.getBlendMode());
3129 },
3130 expected_op_count, expected_total_depth);
3131 run_one_test(
3132 name + " DrawPaint",
3133 [](DisplayListBuilder& builder, DlPaint& paint) {
3134 builder.DrawPaint(paint);
3135 },
3136 expected_op_count, expected_total_depth);
3137 run_one_test(
3138 name + " DrawRect",
3139 [](DisplayListBuilder& builder, DlPaint& paint) {
3140 builder.DrawRect({10, 10, 20, 20}, paint);
3141 },
3142 expected_op_count, expected_total_depth);
3143 run_one_test(
3144 name + " Other Draw Ops",
3145 [](DisplayListBuilder& builder, DlPaint& paint) {
3146 builder.DrawLine({10, 10}, {20, 20}, paint);
3147 builder.DrawOval({10, 10, 20, 20}, paint);
3148 builder.DrawCircle({50, 50}, 20, paint);
3149 builder.DrawRRect(SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5), paint);
3150 builder.DrawDRRect(SkRRect::MakeRectXY({5, 5, 100, 100}, 5, 5),
3151 SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5),
3152 paint);
3153 builder.DrawPath(kTestPath1, paint);
3154 builder.DrawArc({10, 10, 20, 20}, 45, 90, true, paint);
3155 SkPoint pts[] = {{10, 10}, {20, 20}};
3156 builder.DrawPoints(PointMode::kLines, 2, pts, paint);
3157 builder.DrawVertices(TestVertices1, DlBlendMode::kSrcOver, paint);
3158 builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear,
3159 &paint);
3160 builder.DrawImageRect(TestImage1, SkRect{0.0f, 0.0f, 10.0f, 10.0f},
3161 SkRect{10.0f, 10.0f, 25.0f, 25.0f},
3162 DlImageSampling::kLinear, &paint);
3163 builder.DrawImageNine(TestImage1, {10, 10, 20, 20},
3164 {10, 10, 100, 100}, DlFilterMode::kLinear,
3165 &paint);
3166 SkRSXform xforms[] = {{1, 0, 10, 10}, {0, 1, 10, 10}};
3167 SkRect rects[] = {{10, 10, 20, 20}, {10, 20, 30, 20}};
3168 builder.DrawAtlas(TestImage1, xforms, rects, nullptr, 2,
3169 DlBlendMode::kSrcOver, DlImageSampling::kLinear,
3170 nullptr, &paint);
3171 builder.DrawTextBlob(GetTestTextBlob(1), 10, 10, paint);
3172
3173 // Dst mode eliminates most rendering ops except for
3174 // the following two, so we'll prune those manually...
3175 if (paint.getBlendMode() != DlBlendMode::kDst) {
3176 builder.DrawDisplayList(TestDisplayList1, paint.getOpacity());
3177 builder.DrawShadow(kTestPath1, paint.getColor(), 1, true, 1);
3178 }
3179 },
3180 expected_op_count, expected_total_depth);
3181 run_one_test(
3182 name + " SaveLayer",
3183 [](DisplayListBuilder& builder, DlPaint& paint) {
3184 builder.SaveLayer(nullptr, &paint, nullptr);
3185 builder.DrawRect({10, 10, 20, 20}, DlPaint());
3186 builder.Restore();
3187 },
3188 expected_op_count, expected_total_depth);
3189 run_one_test(
3190 name + " inside Save",
3191 [](DisplayListBuilder& builder, DlPaint& paint) {
3192 builder.Save();
3193 builder.DrawRect({10, 10, 20, 20}, paint);
3194 builder.Restore();
3195 },
3196 expected_op_count, expected_total_depth);
3197 };
3198 run_tests("transparent color", //
3199 [](DisplayListBuilder& builder, DlPaint& paint) {
3200 paint.setColor(DlColor::kTransparent());
3201 });
3202 run_tests("0 alpha", //
3203 [](DisplayListBuilder& builder, DlPaint& paint) {
3204 // The transparent test above already tested transparent
3205 // black (all 0s), we set White color here so we can test
3206 // the case of all 1s with a 0 alpha
3207 paint.setColor(DlColor::kWhite());
3208 paint.setAlpha(0);
3209 });
3210 run_tests("BlendMode::kDst", //
3211 [](DisplayListBuilder& builder, DlPaint& paint) {
3212 paint.setBlendMode(DlBlendMode::kDst);
3213 });
3214 run_tests("Empty rect clip", //
3215 [](DisplayListBuilder& builder, DlPaint& paint) {
3216 builder.ClipRect(SkRect::MakeEmpty(), ClipOp::kIntersect, false);
3217 });
3218 run_tests("Empty rrect clip", //
3219 [](DisplayListBuilder& builder, DlPaint& paint) {
3220 builder.ClipRRect(SkRRect::MakeEmpty(), ClipOp::kIntersect,
3221 false);
3222 });
3223 run_tests("Empty path clip", //
3224 [](DisplayListBuilder& builder, DlPaint& paint) {
3225 builder.ClipPath(SkPath(), ClipOp::kIntersect, false);
3226 });
3227 run_tests("Transparent SaveLayer", //
3228 [](DisplayListBuilder& builder, DlPaint& paint) {
3229 DlPaint save_paint;
3230 save_paint.setColor(DlColor::kTransparent());
3231 builder.SaveLayer(nullptr, &save_paint);
3232 });
3233 run_tests("0 alpha SaveLayer", //
3234 [](DisplayListBuilder& builder, DlPaint& paint) {
3235 DlPaint save_paint;
3236 // The transparent test above already tested transparent
3237 // black (all 0s), we set White color here so we can test
3238 // the case of all 1s with a 0 alpha
3239 save_paint.setColor(DlColor::kWhite());
3240 save_paint.setAlpha(0);
3241 builder.SaveLayer(nullptr, &save_paint);
3242 });
3243 run_tests("Dst blended SaveLayer", //
3244 [](DisplayListBuilder& builder, DlPaint& paint) {
3245 DlPaint save_paint;
3246 save_paint.setBlendMode(DlBlendMode::kDst);
3247 builder.SaveLayer(nullptr, &save_paint);
3248 });
3249 run_tests(
3250 "Nop inside SaveLayer",
3251 [](DisplayListBuilder& builder, DlPaint& paint) {
3252 builder.SaveLayer(nullptr, nullptr);
3253 paint.setBlendMode(DlBlendMode::kDst);
3254 },
3255 2u, 1u);
3256 run_tests("DrawImage inside Culled SaveLayer", //
3257 [](DisplayListBuilder& builder, DlPaint& paint) {
3258 DlPaint save_paint;
3259 save_paint.setColor(DlColor::kTransparent());
3260 builder.SaveLayer(nullptr, &save_paint);
3261 builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear);
3262 });
3263}
Definition build.py:1

◆ TEST_F() [228/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPRotationDoesNotTriggerDeferredSave   
)

Definition at line 2748 of file display_list_unittests.cc.

2748 {
2749 DisplayListBuilder builder1;
2750 DlOpReceiver& receiver1 = ToReceiver(builder1);
2751 receiver1.save();
2752 receiver1.save();
2753 receiver1.rotate(360);
2754 receiver1.drawRect({0, 0, 100, 100});
2755 receiver1.restore();
2756 receiver1.drawRect({0, 0, 100, 100});
2757 receiver1.restore();
2758 auto display_list1 = builder1.Build();
2759
2760 DisplayListBuilder builder2;
2761 DlOpReceiver& receiver2 = ToReceiver(builder2);
2762 receiver2.drawRect({0, 0, 100, 100});
2763 receiver2.drawRect({0, 0, 100, 100});
2764 auto display_list2 = builder2.Build();
2765
2766 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2767}

◆ TEST_F() [229/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPScaleDoesNotTriggerDeferredSave   
)

Definition at line 2727 of file display_list_unittests.cc.

2727 {
2728 DisplayListBuilder builder1;
2729 DlOpReceiver& receiver1 = ToReceiver(builder1);
2730 receiver1.save();
2731 receiver1.save();
2732 receiver1.scale(1.0, 1.0);
2733 receiver1.drawRect({0, 0, 100, 100});
2734 receiver1.restore();
2735 receiver1.drawRect({0, 0, 100, 100});
2736 receiver1.restore();
2737 auto display_list1 = builder1.Build();
2738
2739 DisplayListBuilder builder2;
2740 DlOpReceiver& receiver2 = ToReceiver(builder2);
2741 receiver2.drawRect({0, 0, 100, 100});
2742 receiver2.drawRect({0, 0, 100, 100});
2743 auto display_list2 = builder2.Build();
2744
2745 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2746}

◆ TEST_F() [230/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPSkewDoesNotTriggerDeferredSave   
)

Definition at line 2769 of file display_list_unittests.cc.

2769 {
2770 DisplayListBuilder builder1;
2771 DlOpReceiver& receiver1 = ToReceiver(builder1);
2772 receiver1.save();
2773 receiver1.save();
2774 receiver1.skew(0, 0);
2775 receiver1.drawRect({0, 0, 100, 100});
2776 receiver1.restore();
2777 receiver1.drawRect({0, 0, 100, 100});
2778 receiver1.restore();
2779 auto display_list1 = builder1.Build();
2780
2781 DisplayListBuilder builder2;
2782 DlOpReceiver& receiver2 = ToReceiver(builder2);
2783 receiver2.drawRect({0, 0, 100, 100});
2784 receiver2.drawRect({0, 0, 100, 100});
2785 auto display_list2 = builder2.Build();
2786
2787 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2788}
virtual void skew(SkScalar sx, SkScalar sy)=0

◆ TEST_F() [231/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTransform2DDoesNotTriggerDeferredSave   
)

Definition at line 2818 of file display_list_unittests.cc.

2818 {
2819 DisplayListBuilder builder1;
2820 DlOpReceiver& receiver1 = ToReceiver(builder1);
2821 receiver1.save();
2822 receiver1.save();
2823 receiver1.transform2DAffine(1, 0, 0, 0, 1, 0);
2824 receiver1.drawRect({0, 0, 100, 100});
2825 receiver1.restore();
2826 receiver1.drawRect({0, 0, 100, 100});
2827 receiver1.restore();
2828 auto display_list1 = builder1.Build();
2829
2830 DisplayListBuilder builder2;
2831 DlOpReceiver& receiver2 = ToReceiver(builder2);
2832 receiver2.drawRect({0, 0, 100, 100});
2833 receiver2.drawRect({0, 0, 100, 100});
2834 auto display_list2 = builder2.Build();
2835
2836 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2837}
virtual void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt)=0

◆ TEST_F() [232/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTransformDoesNotTriggerDeferredSave   
)

Definition at line 2790 of file display_list_unittests.cc.

2790 {
2791 DisplayListBuilder builder1;
2792 DlOpReceiver& receiver1 = ToReceiver(builder1);
2793 receiver1.save();
2794 receiver1.save();
2795 receiver1.transformFullPerspective(1, 0, 0, 0, //
2796 0, 1, 0, 0, //
2797 0, 0, 1, 0, //
2798 0, 0, 0, 1);
2799 receiver1.drawRect({0, 0, 100, 100});
2800 receiver1.restore();
2801 receiver1.transformFullPerspective(1, 0, 0, 0, //
2802 0, 1, 0, 0, //
2803 0, 0, 1, 0, //
2804 0, 0, 0, 1);
2805 receiver1.drawRect({0, 0, 100, 100});
2806 receiver1.restore();
2807 auto display_list1 = builder1.Build();
2808
2809 DisplayListBuilder builder2;
2810 DlOpReceiver& receiver2 = ToReceiver(builder2);
2811 receiver2.drawRect({0, 0, 100, 100});
2812 receiver2.drawRect({0, 0, 100, 100});
2813 auto display_list2 = builder2.Build();
2814
2815 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2816}

◆ TEST_F() [233/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTransformFullPerspectiveDoesNotTriggerDeferredSave   
)

Definition at line 2839 of file display_list_unittests.cc.

2839 {
2840 {
2841 DisplayListBuilder builder1;
2842 DlOpReceiver& receiver1 = ToReceiver(builder1);
2843 receiver1.save();
2844 receiver1.save();
2845 receiver1.transformFullPerspective(1, 0, 0, 0, //
2846 0, 1, 0, 0, //
2847 0, 0, 1, 0, //
2848 0, 0, 0, 1);
2849 receiver1.drawRect({0, 0, 100, 100});
2850 receiver1.restore();
2851 receiver1.drawRect({0, 0, 100, 100});
2852 receiver1.restore();
2853 auto display_list1 = builder1.Build();
2854
2855 DisplayListBuilder builder2;
2856 DlOpReceiver& receiver2 = ToReceiver(builder2);
2857 receiver2.drawRect({0, 0, 100, 100});
2858 receiver2.drawRect({0, 0, 100, 100});
2859 auto display_list2 = builder2.Build();
2860
2861 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2862 }
2863
2864 {
2865 DisplayListBuilder builder1;
2866 DlOpReceiver& receiver1 = ToReceiver(builder1);
2867 receiver1.save();
2868 receiver1.save();
2869 receiver1.transformFullPerspective(1, 0, 0, 0, //
2870 0, 1, 0, 0, //
2871 0, 0, 1, 0, //
2872 0, 0, 0, 1);
2873 receiver1.transformReset();
2874 receiver1.drawRect({0, 0, 100, 100});
2875 receiver1.restore();
2876 receiver1.drawRect({0, 0, 100, 100});
2877 receiver1.restore();
2878 auto display_list1 = builder1.Build();
2879
2880 DisplayListBuilder builder2;
2881 DlOpReceiver& receiver2 = ToReceiver(builder2);
2882 receiver2.save();
2883 receiver2.transformReset();
2884 receiver2.drawRect({0, 0, 100, 100});
2885 receiver2.restore();
2886 receiver2.drawRect({0, 0, 100, 100});
2887
2888 auto display_list2 = builder2.Build();
2889
2890 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2891 }
2892}

◆ TEST_F() [234/876]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTranslateDoesNotTriggerDeferredSave   
)

Definition at line 2706 of file display_list_unittests.cc.

2706 {
2707 DisplayListBuilder builder1;
2708 DlOpReceiver& receiver1 = ToReceiver(builder1);
2709 receiver1.save();
2710 receiver1.save();
2711 receiver1.translate(0, 0);
2712 receiver1.drawRect({0, 0, 100, 100});
2713 receiver1.restore();
2714 receiver1.drawRect({0, 0, 100, 100});
2715 receiver1.restore();
2716 auto display_list1 = builder1.Build();
2717
2718 DisplayListBuilder builder2;
2719 DlOpReceiver& receiver2 = ToReceiver(builder2);
2720 receiver2.drawRect({0, 0, 100, 100});
2721 receiver2.drawRect({0, 0, 100, 100});
2722 auto display_list2 = builder2.Build();
2723
2724 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2725}

◆ TEST_F() [235/876]

flutter::testing::TEST_F ( DisplayListTest  ,
OverlappingOpsDoNotSupportGroupOpacity   
)

Definition at line 1145 of file display_list_unittests.cc.

1145 {
1146 DisplayListBuilder builder;
1147 DlOpReceiver& receiver = ToReceiver(builder);
1148 for (int i = 0; i < 10; i++) {
1149 receiver.drawRect(SkRect::MakeXYWH(i * 10, 0, 30, 30));
1150 }
1151 auto display_list = builder.Build();
1152 EXPECT_FALSE(display_list->can_apply_group_opacity());
1153}

◆ TEST_F() [236/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RemoveUnnecessarySaveRestorePairs   
)

Definition at line 2282 of file display_list_unittests.cc.

2282 {
2283 {
2284 DisplayListBuilder builder;
2285 DlOpReceiver& receiver = ToReceiver(builder);
2286 receiver.drawRect({10, 10, 20, 20});
2287 receiver.save(); // This save op is unnecessary
2288 receiver.drawRect({50, 50, 60, 60});
2289 receiver.restore();
2290
2291 DisplayListBuilder builder2;
2292 DlOpReceiver& receiver2 = ToReceiver(builder2);
2293 receiver2.drawRect({10, 10, 20, 20});
2294 receiver2.drawRect({50, 50, 60, 60});
2295 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), builder2.Build()));
2296 }
2297
2298 {
2299 DisplayListBuilder builder;
2300 DlOpReceiver& receiver = ToReceiver(builder);
2301 receiver.drawRect({10, 10, 20, 20});
2302 receiver.save();
2303 receiver.translate(1.0, 1.0);
2304 {
2305 receiver.save(); // unnecessary
2306 receiver.drawRect({50, 50, 60, 60});
2307 receiver.restore();
2308 }
2309
2310 receiver.restore();
2311
2312 DisplayListBuilder builder2;
2313 DlOpReceiver& receiver2 = ToReceiver(builder2);
2314 receiver2.drawRect({10, 10, 20, 20});
2315 receiver2.save();
2316 receiver2.translate(1.0, 1.0);
2317 { receiver2.drawRect({50, 50, 60, 60}); }
2318 receiver2.restore();
2319 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), builder2.Build()));
2320 }
2321}

◆ TEST_F() [237/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RemoveUnnecessarySaveRestorePairsInSetPaint   
)

Definition at line 2373 of file display_list_unittests.cc.

2373 {
2374 SkRect build_bounds = SkRect::MakeLTRB(-100, -100, 200, 200);
2375 SkRect rect = SkRect::MakeLTRB(30, 30, 70, 70);
2376 // clang-format off
2377 const float alpha_matrix[] = {
2378 0, 0, 0, 0, 0,
2379 0, 1, 0, 0, 0,
2380 0, 0, 1, 0, 0,
2381 0, 0, 0, 0, 1,
2382 };
2383 // clang-format on
2384 DlMatrixColorFilter alpha_color_filter(alpha_matrix);
2385 // Making sure hiding a problematic ColorFilter as an ImageFilter
2386 // will generate the same behavior as setting it as a ColorFilter
2387
2388 DlColorFilterImageFilter color_filter_image_filter(alpha_color_filter);
2389 {
2390 DisplayListBuilder builder(build_bounds);
2391 builder.Save();
2392 DlPaint paint;
2393 paint.setImageFilter(&color_filter_image_filter);
2394 builder.DrawRect(rect, paint);
2395 builder.Restore();
2396 sk_sp<DisplayList> display_list1 = builder.Build();
2397
2398 DisplayListBuilder builder2(build_bounds);
2399 DlPaint paint2;
2400 paint2.setImageFilter(&color_filter_image_filter);
2401 builder2.DrawRect(rect, paint2);
2402 sk_sp<DisplayList> display_list2 = builder2.Build();
2403 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2404 }
2405
2406 {
2407 DisplayListBuilder builder(build_bounds);
2408 builder.Save();
2409 builder.SaveLayer(&build_bounds);
2410 DlPaint paint;
2411 paint.setImageFilter(&color_filter_image_filter);
2412 builder.DrawRect(rect, paint);
2413 builder.Restore();
2414 builder.Restore();
2415 sk_sp<DisplayList> display_list1 = builder.Build();
2416
2417 DisplayListBuilder builder2(build_bounds);
2418 builder2.SaveLayer(&build_bounds);
2419 DlPaint paint2;
2420 paint2.setImageFilter(&color_filter_image_filter);
2421 builder2.DrawRect(rect, paint2);
2422 builder2.Restore();
2423 sk_sp<DisplayList> display_list2 = builder2.Build();
2424 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2425 }
2426}

◆ TEST_F() [238/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ResetTransformTriggersDeferredSave   
)

Definition at line 2518 of file display_list_unittests.cc.

2518 {
2519 DisplayListBuilder builder1;
2520 DlOpReceiver& receiver1 = ToReceiver(builder1);
2521 receiver1.save();
2522 receiver1.save();
2523 receiver1.transformReset();
2524 receiver1.drawRect({0, 0, 100, 100});
2525 receiver1.restore();
2526 receiver1.restore();
2527 auto display_list1 = builder1.Build();
2528
2529 DisplayListBuilder builder2;
2530 DlOpReceiver& receiver2 = ToReceiver(builder2);
2531 receiver2.save();
2532 receiver2.transformReset();
2533 receiver2.drawRect({0, 0, 100, 100});
2534 receiver2.restore();
2535 auto display_list2 = builder2.Build();
2536
2537 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2538}

◆ TEST_F() [239/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RotateAffectsCurrentTransform   
)

Definition at line 1618 of file display_list_unittests.cc.

1618 {
1619 DisplayListBuilder builder;
1620 DlOpReceiver& receiver = ToReceiver(builder);
1621 receiver.rotate(12.3);
1622 SkMatrix matrix = SkMatrix::RotateDeg(12.3);
1623 SkM44 m44 = SkM44(matrix);
1624 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1625 SkMatrix cur_matrix = builder.GetTransform();
1626 ASSERT_EQ(cur_m44, m44);
1627 ASSERT_EQ(cur_matrix, matrix);
1628 receiver.translate(10, 10);
1629 // CurrentTransform has changed
1630 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1631 ASSERT_NE(builder.GetTransform(), cur_matrix);
1632 // Previous return values have not
1633 ASSERT_EQ(cur_m44, m44);
1634 ASSERT_EQ(cur_matrix, matrix);
1635}

◆ TEST_F() [240/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RotatedSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3535 of file display_list_unittests.cc.

3535 {
3536 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3537
3538 DisplayListBuilder builder;
3539 builder.Rotate(45.0f);
3540 builder.SaveLayer(nullptr, nullptr);
3541 { //
3542 builder.DrawRect(rect, DlPaint());
3543 }
3544 builder.Restore();
3545 auto display_list = builder.Build();
3546
3547 SaveLayerBoundsExpector expector;
3548 expector.addComputedExpectation(rect);
3549 display_list->Dispatch(expector);
3550 EXPECT_TRUE(expector.all_bounds_checked());
3551}

◆ TEST_F() [241/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfClippedSaveLayerFilterScene   
)

Definition at line 2916 of file display_list_unittests.cc.

2916 {
2917 DisplayListBuilder builder(/*prepare_rtree=*/true);
2918 // blur filter with sigma=1 expands by 30 on all sides
2919 auto filter = DlBlurImageFilter(10.0, 10.0, DlTileMode::kClamp);
2920 DlPaint default_paint = DlPaint();
2921 DlPaint filter_paint = DlPaint().setImageFilter(&filter);
2922 builder.DrawRect({10, 10, 20, 20}, default_paint);
2923 builder.ClipRect({50, 50, 60, 60}, ClipOp::kIntersect, false);
2924 builder.SaveLayer(nullptr, &filter_paint);
2925 // the following rectangle will be expanded to 23,23,87,87
2926 // by the saveLayer filter during the restore operation
2927 // but it will then be clipped to 50,50,60,60
2928 builder.DrawRect({53, 53, 57, 57}, default_paint);
2929 builder.Restore();
2930 auto display_list = builder.Build();
2931 auto rtree = display_list->rtree();
2932 std::vector<SkRect> rects = {
2933 {10, 10, 20, 20},
2934 {50, 50, 60, 60},
2935 };
2936
2937 // Missing all drawRect calls
2938 test_rtree(rtree, {5, 5, 10, 10}, rects, {});
2939 test_rtree(rtree, {20, 20, 25, 25}, rects, {});
2940 test_rtree(rtree, {45, 45, 50, 50}, rects, {});
2941 test_rtree(rtree, {60, 60, 65, 65}, rects, {});
2942
2943 // Hitting just 1 of the drawRects
2944 test_rtree(rtree, {5, 5, 11, 11}, rects, {0});
2945 test_rtree(rtree, {19, 19, 25, 25}, rects, {0});
2946 test_rtree(rtree, {45, 45, 51, 51}, rects, {1});
2947 test_rtree(rtree, {59, 59, 65, 65}, rects, {1});
2948
2949 // Hitting both drawRect calls
2950 test_rtree(rtree, {19, 19, 51, 51}, rects, {0, 1});
2951}

◆ TEST_F() [242/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfSaveLayerFilterScene   
)

Definition at line 2225 of file display_list_unittests.cc.

2225 {
2226 DisplayListBuilder builder(/*prepare_rtree=*/true);
2227 // blur filter with sigma=1 expands by 3 on all sides
2228 auto filter = DlBlurImageFilter(1.0, 1.0, DlTileMode::kClamp);
2229 DlPaint default_paint = DlPaint();
2230 DlPaint filter_paint = DlPaint().setImageFilter(&filter);
2231 builder.DrawRect({10, 10, 20, 20}, default_paint);
2232 builder.SaveLayer(nullptr, &filter_paint);
2233 // the following rectangle will be expanded to 50,50,60,60
2234 // by the saveLayer filter during the restore operation
2235 builder.DrawRect({53, 53, 57, 57}, default_paint);
2236 builder.Restore();
2237 auto display_list = builder.Build();
2238 auto rtree = display_list->rtree();
2239 std::vector<SkRect> rects = {
2240 {10, 10, 20, 20},
2241 {50, 50, 60, 60},
2242 };
2243
2244 // Missing all drawRect calls
2245 test_rtree(rtree, {5, 5, 10, 10}, rects, {});
2246 test_rtree(rtree, {20, 20, 25, 25}, rects, {});
2247 test_rtree(rtree, {45, 45, 50, 50}, rects, {});
2248 test_rtree(rtree, {60, 60, 65, 65}, rects, {});
2249
2250 // Hitting just 1 of the drawRects
2251 test_rtree(rtree, {5, 5, 11, 11}, rects, {0});
2252 test_rtree(rtree, {19, 19, 25, 25}, rects, {0});
2253 test_rtree(rtree, {45, 45, 51, 51}, rects, {1});
2254 test_rtree(rtree, {59, 59, 65, 65}, rects, {1});
2255
2256 // Hitting both drawRect calls
2257 test_rtree(rtree, {19, 19, 51, 51}, rects, {0, 1});
2258}

◆ TEST_F() [243/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfSaveRestoreScene   
)

Definition at line 2195 of file display_list_unittests.cc.

2195 {
2196 DisplayListBuilder builder(/*prepare_rtree=*/true);
2197 DlOpReceiver& receiver = ToReceiver(builder);
2198 receiver.drawRect({10, 10, 20, 20});
2199 receiver.save();
2200 receiver.drawRect({50, 50, 60, 60});
2201 receiver.restore();
2202 auto display_list = builder.Build();
2203 auto rtree = display_list->rtree();
2204 std::vector<SkRect> rects = {
2205 {10, 10, 20, 20},
2206 {50, 50, 60, 60},
2207 };
2208
2209 // Missing all drawRect calls
2210 test_rtree(rtree, {5, 5, 10, 10}, rects, {});
2211 test_rtree(rtree, {20, 20, 25, 25}, rects, {});
2212 test_rtree(rtree, {45, 45, 50, 50}, rects, {});
2213 test_rtree(rtree, {60, 60, 65, 65}, rects, {});
2214
2215 // Hitting just 1 of the drawRects
2216 test_rtree(rtree, {5, 5, 11, 11}, rects, {0});
2217 test_rtree(rtree, {19, 19, 25, 25}, rects, {0});
2218 test_rtree(rtree, {45, 45, 51, 51}, rects, {1});
2219 test_rtree(rtree, {59, 59, 65, 65}, rects, {1});
2220
2221 // Hitting both drawRect calls
2222 test_rtree(rtree, {19, 19, 51, 51}, rects, {0, 1});
2223}

◆ TEST_F() [244/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfSimpleScene   
)

Definition at line 2167 of file display_list_unittests.cc.

2167 {
2168 DisplayListBuilder builder(/*prepare_rtree=*/true);
2169 DlOpReceiver& receiver = ToReceiver(builder);
2170 receiver.drawRect({10, 10, 20, 20});
2171 receiver.drawRect({50, 50, 60, 60});
2172 auto display_list = builder.Build();
2173 auto rtree = display_list->rtree();
2174 std::vector<SkRect> rects = {
2175 {10, 10, 20, 20},
2176 {50, 50, 60, 60},
2177 };
2178
2179 // Missing all drawRect calls
2180 test_rtree(rtree, {5, 5, 10, 10}, rects, {});
2181 test_rtree(rtree, {20, 20, 25, 25}, rects, {});
2182 test_rtree(rtree, {45, 45, 50, 50}, rects, {});
2183 test_rtree(rtree, {60, 60, 65, 65}, rects, {});
2184
2185 // Hitting just 1 of the drawRects
2186 test_rtree(rtree, {5, 5, 11, 11}, rects, {0});
2187 test_rtree(rtree, {19, 19, 25, 25}, rects, {0});
2188 test_rtree(rtree, {45, 45, 51, 51}, rects, {1});
2189 test_rtree(rtree, {59, 59, 65, 65}, rects, {1});
2190
2191 // Hitting both drawRect calls
2192 test_rtree(rtree, {19, 19, 51, 51}, rects, {0, 1});
2193}

◆ TEST_F() [245/876]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeRenderCulling   
)

Definition at line 2953 of file display_list_unittests.cc.

2953 {
2954 DisplayListBuilder main_builder(true);
2955 DlOpReceiver& main_receiver = ToReceiver(main_builder);
2956 main_receiver.drawRect({0, 0, 10, 10});
2957 main_receiver.drawRect({20, 0, 30, 10});
2958 main_receiver.drawRect({0, 20, 10, 30});
2959 main_receiver.drawRect({20, 20, 30, 30});
2960 auto main = main_builder.Build();
2961
2962 auto test = [main](SkIRect cull_rect, const sk_sp<DisplayList>& expected) {
2963 { // Test SkIRect culling
2964 DisplayListBuilder culling_builder;
2965 main->Dispatch(ToReceiver(culling_builder), cull_rect);
2966
2967 EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected));
2968 }
2969
2970 { // Test SkRect culling
2971 DisplayListBuilder culling_builder;
2972 main->Dispatch(ToReceiver(culling_builder), SkRect::Make(cull_rect));
2973
2974 EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected));
2975 }
2976 };
2977
2978 { // No rects
2979 SkIRect cull_rect = {11, 11, 19, 19};
2980
2981 DisplayListBuilder expected_builder;
2982 auto expected = expected_builder.Build();
2983
2984 test(cull_rect, expected);
2985 }
2986
2987 { // Rect 1
2988 SkIRect cull_rect = {9, 9, 19, 19};
2989
2990 DisplayListBuilder expected_builder;
2991 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
2992 expected_receiver.drawRect({0, 0, 10, 10});
2993 auto expected = expected_builder.Build();
2994
2995 test(cull_rect, expected);
2996 }
2997
2998 { // Rect 2
2999 SkIRect cull_rect = {11, 9, 21, 19};
3000
3001 DisplayListBuilder expected_builder;
3002 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
3003 expected_receiver.drawRect({20, 0, 30, 10});
3004 auto expected = expected_builder.Build();
3005
3006 test(cull_rect, expected);
3007 }
3008
3009 { // Rect 3
3010 SkIRect cull_rect = {9, 11, 19, 21};
3011
3012 DisplayListBuilder expected_builder;
3013 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
3014 expected_receiver.drawRect({0, 20, 10, 30});
3015 auto expected = expected_builder.Build();
3016
3017 test(cull_rect, expected);
3018 }
3019
3020 { // Rect 4
3021 SkIRect cull_rect = {11, 11, 21, 21};
3022
3023 DisplayListBuilder expected_builder;
3024 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
3025 expected_receiver.drawRect({20, 20, 30, 30});
3026 auto expected = expected_builder.Build();
3027
3028 test(cull_rect, expected);
3029 }
3030
3031 { // All 4 rects
3032 SkIRect cull_rect = {9, 9, 21, 21};
3033
3034 test(cull_rect, main);
3035 }
3036}
Definition main.py:1

◆ TEST_F() [246/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveContentDepthTest   
)

Definition at line 3851 of file display_list_unittests.cc.

3851 {
3852 DisplayListBuilder child_builder;
3853 child_builder.DrawRect({10, 10, 20, 20}, DlPaint()); // depth 1
3854 auto child = child_builder.Build();
3855
3856 DisplayListBuilder builder;
3857 builder.DrawRect({10, 10, 20, 20}, DlPaint()); // depth 1
3858
3859 builder.Save(); // covers depth 1->9
3860 {
3861 builder.Translate(5, 5);
3862 builder.DrawRect({10, 10, 20, 20}, DlPaint()); // depth 2
3863
3864 builder.DrawDisplayList(child, 1.0f); // depth 3 (content) + 4 (self)
3865
3866 builder.SaveLayer(nullptr, nullptr); // covers depth 5->6
3867 {
3868 builder.DrawRect({12, 12, 22, 22}, DlPaint()); // depth 5
3869 builder.DrawRect({14, 14, 24, 24}, DlPaint()); // depth 6
3870 }
3871 builder.Restore(); // layer is restored with depth 7
3872
3873 builder.DrawRect({16, 16, 26, 26}, DlPaint()); // depth 8
3874 builder.DrawRect({18, 18, 28, 28}, DlPaint()); // depth 9
3875 }
3876 builder.Restore();
3877
3878 builder.DrawRect({16, 16, 26, 26}, DlPaint()); // depth 10
3879 builder.DrawRect({18, 18, 28, 28}, DlPaint()); // depth 11
3880 auto display_list = builder.Build();
3881
3882 EXPECT_EQ(display_list->total_depth(), 11u);
3883
3884 DepthExpector expector({8, 2});
3885 display_list->Dispatch(expector);
3886}

◆ TEST_F() [247/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsClipDetectionSimpleClippedRect   
)

Definition at line 3785 of file display_list_unittests.cc.

3785 {
3786 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3787 SkRect save_rect = SkRect::MakeLTRB(50.0f, 50.0f, 110.0f, 110.0f);
3788 SkRect content_rect = SkRect::MakeLTRB(100.0f, 100.0f, 110.0f, 110.0f);
3789
3790 DisplayListBuilder builder;
3791 builder.SaveLayer(&save_rect, nullptr);
3792 { //
3793 builder.DrawRect(rect, DlPaint());
3794 }
3795 builder.Restore();
3796 auto display_list = builder.Build();
3797
3798 // A color filter is implicitly clipped to the draw bounds so the layer
3799 // bounds will be the same as the draw bounds.
3800 SaveLayerBoundsExpector expector;
3801 expector.addSuppliedExpectation(content_rect, true);
3802 display_list->Dispatch(expector);
3803 EXPECT_TRUE(expector.all_bounds_checked());
3804}

◆ TEST_F() [248/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsClipDetectionSimpleUnclippedRect   
)

Definition at line 3765 of file display_list_unittests.cc.

3765 {
3766 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3767 SkRect save_rect = SkRect::MakeLTRB(50.0f, 50.0f, 250.0f, 250.0f);
3768
3769 DisplayListBuilder builder;
3770 builder.SaveLayer(&save_rect, nullptr);
3771 { //
3772 builder.DrawRect(rect, DlPaint());
3773 }
3774 builder.Restore();
3775 auto display_list = builder.Build();
3776
3777 // A color filter is implicitly clipped to the draw bounds so the layer
3778 // bounds will be the same as the draw bounds.
3779 SaveLayerBoundsExpector expector;
3780 expector.addSuppliedExpectation(rect);
3781 display_list->Dispatch(expector);
3782 EXPECT_TRUE(expector.all_bounds_checked());
3783}

◆ TEST_F() [249/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfFloodingColorFilter   
)

Definition at line 3737 of file display_list_unittests.cc.

3737 {
3738 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3740 auto color_filter =
3741 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3742 ASSERT_TRUE(color_filter->modifies_transparent_black());
3743 draw_paint.setColorFilter(color_filter);
3744 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3745 ASSERT_NE(clip_rect, rect);
3746 ASSERT_TRUE(clip_rect.contains(rect));
3747
3748 DisplayListBuilder builder;
3749 builder.ClipRect(clip_rect);
3750 builder.SaveLayer(nullptr, nullptr);
3751 { //
3752 builder.DrawRect(rect, draw_paint);
3753 }
3754 builder.Restore();
3755 auto display_list = builder.Build();
3756
3757 // A color filter is implicitly clipped to the draw bounds so the layer
3758 // bounds will be the same as the draw bounds.
3759 SaveLayerBoundsExpector expector;
3760 expector.addComputedExpectation(rect);
3761 display_list->Dispatch(expector);
3762 EXPECT_TRUE(expector.all_bounds_checked());
3763}

◆ TEST_F() [250/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfFloodingImageFilter   
)

Definition at line 3710 of file display_list_unittests.cc.

3710 {
3711 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3713 auto color_filter =
3714 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3715 ASSERT_TRUE(color_filter->modifies_transparent_black());
3716 auto image_filter = DlColorFilterImageFilter::Make(color_filter);
3717 draw_paint.setImageFilter(image_filter);
3718 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3719 ASSERT_NE(clip_rect, rect);
3720 ASSERT_TRUE(clip_rect.contains(rect));
3721
3722 DisplayListBuilder builder;
3723 builder.ClipRect(clip_rect);
3724 builder.SaveLayer(nullptr, nullptr);
3725 { //
3726 builder.DrawRect(rect, draw_paint);
3727 }
3728 builder.Restore();
3729 auto display_list = builder.Build();
3730
3731 SaveLayerBoundsExpector expector;
3732 expector.addComputedExpectation(clip_rect);
3733 display_list->Dispatch(expector);
3734 EXPECT_TRUE(expector.all_bounds_checked());
3735}

◆ TEST_F() [251/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfImageBlurredRect   
)

Definition at line 3459 of file display_list_unittests.cc.

3459 {
3460 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3462 auto image_filter = DlBlurImageFilter::Make(2.0f, 3.0f, DlTileMode::kDecal);
3463 draw_paint.setImageFilter(image_filter);
3464
3465 DisplayListBuilder builder;
3466 builder.SaveLayer(nullptr, nullptr);
3467 { //
3468 builder.DrawRect(rect, draw_paint);
3469 }
3470 builder.Restore();
3471 auto display_list = builder.Build();
3472
3473 SaveLayerBoundsExpector expector;
3474 expector.addComputedExpectation(rect.makeOutset(6.0f, 9.0f));
3475 display_list->Dispatch(expector);
3476 EXPECT_TRUE(expector.all_bounds_checked());
3477}

◆ TEST_F() [252/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfMaskBlurredRect   
)

Definition at line 3439 of file display_list_unittests.cc.

3439 {
3440 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3442 auto mask_filter = DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 2.0f);
3443 draw_paint.setMaskFilter(mask_filter);
3444
3445 DisplayListBuilder builder;
3446 builder.SaveLayer(nullptr, nullptr);
3447 { //
3448 builder.DrawRect(rect, draw_paint);
3449 }
3450 builder.Restore();
3451 auto display_list = builder.Build();
3452
3453 SaveLayerBoundsExpector expector;
3454 expector.addComputedExpectation(rect.makeOutset(6.0f, 6.0f));
3455 display_list->Dispatch(expector);
3456 EXPECT_TRUE(expector.all_bounds_checked());
3457}

◆ TEST_F() [253/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfNestedSimpleRect   
)

Definition at line 3631 of file display_list_unittests.cc.

3631 {
3632 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3633
3634 DisplayListBuilder builder;
3635 builder.SaveLayer(nullptr, nullptr);
3636 { //
3637 builder.SaveLayer(nullptr, nullptr);
3638 { //
3639 builder.DrawRect(rect, DlPaint());
3640 }
3641 builder.Restore();
3642 }
3643 builder.Restore();
3644 auto display_list = builder.Build();
3645
3646 SaveLayerBoundsExpector expector;
3647 expector.addComputedExpectation(rect);
3648 expector.addComputedExpectation(rect);
3649 display_list->Dispatch(expector);
3650 EXPECT_TRUE(expector.all_bounds_checked());
3651}

◆ TEST_F() [254/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfRotatedSimpleRect   
)

Definition at line 3612 of file display_list_unittests.cc.

3612 {
3613 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3614
3615 DisplayListBuilder builder;
3616 builder.SaveLayer(nullptr, nullptr);
3617 { //
3618 builder.Rotate(45.0f);
3619 builder.DrawRect(rect, DlPaint());
3620 }
3621 builder.Restore();
3622 auto display_list = builder.Build();
3623
3624 SkMatrix matrix = SkMatrix::RotateDeg(45.0f);
3625 SaveLayerBoundsExpector expector;
3626 expector.addComputedExpectation(matrix.mapRect(rect));
3627 display_list->Dispatch(expector);
3628 EXPECT_TRUE(expector.all_bounds_checked());
3629}

◆ TEST_F() [255/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfScaledSimpleRect   
)

Definition at line 3593 of file display_list_unittests.cc.

3593 {
3594 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3595
3596 DisplayListBuilder builder;
3597 builder.SaveLayer(nullptr, nullptr);
3598 { //
3599 builder.Scale(10.0f, 10.0f);
3600 builder.DrawRect(rect, DlPaint());
3601 }
3602 builder.Restore();
3603 auto display_list = builder.Build();
3604
3605 SaveLayerBoundsExpector expector;
3606 expector.addComputedExpectation(
3607 SkRect::MakeLTRB(1000.0f, 1000.0f, 2000.0f, 2000.0f));
3608 display_list->Dispatch(expector);
3609 EXPECT_TRUE(expector.all_bounds_checked());
3610}

◆ TEST_F() [256/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3422 of file display_list_unittests.cc.

3422 {
3423 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3424
3425 DisplayListBuilder builder;
3426 builder.SaveLayer(nullptr, nullptr);
3427 { //
3428 builder.DrawRect(rect, DlPaint());
3429 }
3430 builder.Restore();
3431 auto display_list = builder.Build();
3432
3433 SaveLayerBoundsExpector expector;
3434 expector.addComputedExpectation(rect);
3435 display_list->Dispatch(expector);
3436 EXPECT_TRUE(expector.all_bounds_checked());
3437}

◆ TEST_F() [257/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfStrokedRect   
)

Definition at line 3479 of file display_list_unittests.cc.

3479 {
3480 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3483 draw_paint.setDrawStyle(DlDrawStyle::kStroke);
3484
3485 DisplayListBuilder builder;
3486 builder.SaveLayer(nullptr, nullptr);
3487 { //
3488 builder.DrawRect(rect, draw_paint);
3489 }
3490 builder.Restore();
3491 auto display_list = builder.Build();
3492
3493 SaveLayerBoundsExpector expector;
3494 expector.addComputedExpectation(rect.makeOutset(2.5f, 2.5f));
3495 display_list->Dispatch(expector);
3496 EXPECT_TRUE(expector.all_bounds_checked());
3497}

◆ TEST_F() [258/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfTranslatedSimpleRect   
)

Definition at line 3575 of file display_list_unittests.cc.

3575 {
3576 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3577
3578 DisplayListBuilder builder;
3579 builder.SaveLayer(nullptr, nullptr);
3580 { //
3581 builder.Translate(10.0f, 10.0f);
3582 builder.DrawRect(rect, DlPaint());
3583 }
3584 builder.Restore();
3585 auto display_list = builder.Build();
3586
3587 SaveLayerBoundsExpector expector;
3588 expector.addComputedExpectation(rect.makeOffset(10.0f, 10.0f));
3589 display_list->Dispatch(expector);
3590 EXPECT_TRUE(expector.all_bounds_checked());
3591}

◆ TEST_F() [259/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsSnapshotsImageFilter   
)

Definition at line 1223 of file display_list_unittests.cc.

1223 {
1224 DisplayListBuilder builder;
1225 DlOpReceiver& receiver = ToReceiver(builder);
1226 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1227 receiver.drawRect({50, 50, 100, 100});
1228 // This image filter should be ignored since it was not set before saveLayer
1229 receiver.setImageFilter(&kTestBlurImageFilter1);
1230 receiver.restore();
1231 SkRect bounds = builder.Build()->bounds();
1232 EXPECT_EQ(bounds, SkRect::MakeLTRB(50, 50, 100, 100));
1233}

◆ TEST_F() [260/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerColorFilterDoesNotInheritOpacity   
)

Definition at line 1370 of file display_list_unittests.cc.

1370 {
1371 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1372 SaveLayerOptionsExpector expector(expected);
1373
1374 DisplayListBuilder builder;
1375 DlOpReceiver& receiver = ToReceiver(builder);
1376 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1377 receiver.setColorFilter(&kTestMatrixColorFilter1);
1378 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1379 receiver.setColorFilter(nullptr);
1380 receiver.drawRect({10, 10, 20, 20});
1381 receiver.restore();
1382
1383 builder.Build()->Dispatch(expector);
1384 EXPECT_EQ(expector.save_layer_count(), 1);
1385}

◆ TEST_F() [261/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerColorFilterOnChildDoesNotInheritOpacity   
)

Definition at line 1421 of file display_list_unittests.cc.

1421 {
1422 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1423 SaveLayerOptionsExpector expector(expected);
1424
1425 DisplayListBuilder builder;
1426 DlOpReceiver& receiver = ToReceiver(builder);
1427 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1428 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1429 receiver.setColorFilter(&kTestMatrixColorFilter1);
1430 receiver.drawRect({10, 10, 20, 20});
1431 receiver.restore();
1432
1433 builder.Build()->Dispatch(expector);
1434 EXPECT_EQ(expector.save_layer_count(), 1);
1435}

◆ TEST_F() [262/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerFalseSupportsGroupOpacityOverlappingChidren   
)

Definition at line 1155 of file display_list_unittests.cc.

1155 {
1156 DisplayListBuilder builder;
1157 DlOpReceiver& receiver = ToReceiver(builder);
1158 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1159 for (int i = 0; i < 10; i++) {
1160 receiver.drawRect(SkRect::MakeXYWH(i * 10, 0, 30, 30));
1161 }
1162 receiver.restore();
1163 auto display_list = builder.Build();
1164 EXPECT_TRUE(display_list->can_apply_group_opacity());
1165}

◆ TEST_F() [263/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerFalseSupportsGroupOpacityWithChildSrcBlend   
)

Definition at line 1201 of file display_list_unittests.cc.

1201 {
1202 DisplayListBuilder builder;
1203 DlOpReceiver& receiver = ToReceiver(builder);
1204 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1205 receiver.setBlendMode(DlBlendMode::kSrc);
1206 receiver.drawRect({0, 0, 10, 10});
1207 receiver.restore();
1208 auto display_list = builder.Build();
1209 EXPECT_TRUE(display_list->can_apply_group_opacity());
1210}

◆ TEST_F() [264/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerFalseWithSrcBlendSupportsGroupOpacity   
)

Definition at line 1179 of file display_list_unittests.cc.

1179 {
1180 DisplayListBuilder builder;
1181 DlOpReceiver& receiver = ToReceiver(builder);
1182 receiver.setBlendMode(DlBlendMode::kSrc);
1183 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1184 receiver.drawRect({0, 0, 10, 10});
1185 receiver.restore();
1186 auto display_list = builder.Build();
1187 EXPECT_TRUE(display_list->can_apply_group_opacity());
1188}

◆ TEST_F() [265/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerImageFilterDoesNotInheritOpacity   
)

Definition at line 1353 of file display_list_unittests.cc.

1353 {
1354 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1355 SaveLayerOptionsExpector expector(expected);
1356
1357 DisplayListBuilder builder;
1358 DlOpReceiver& receiver = ToReceiver(builder);
1359 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1360 receiver.setImageFilter(&kTestBlurImageFilter1);
1361 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1362 receiver.setImageFilter(nullptr);
1363 receiver.drawRect({10, 10, 20, 20});
1364 receiver.restore();
1365
1366 builder.Build()->Dispatch(expector);
1367 EXPECT_EQ(expector.save_layer_count(), 1);
1368}

◆ TEST_F() [266/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerImageFilterOnChildInheritsOpacity   
)

Definition at line 1404 of file display_list_unittests.cc.

1404 {
1405 SaveLayerOptions expected =
1406 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1407 SaveLayerOptionsExpector expector(expected);
1408
1409 DisplayListBuilder builder;
1410 DlOpReceiver& receiver = ToReceiver(builder);
1411 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1412 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1413 receiver.setImageFilter(&kTestBlurImageFilter1);
1414 receiver.drawRect({10, 10, 20, 20});
1415 receiver.restore();
1416
1417 builder.Build()->Dispatch(expector);
1418 EXPECT_EQ(expector.save_layer_count(), 1);
1419}

◆ TEST_F() [267/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerNoAttributesInheritsOpacity   
)

Definition at line 1278 of file display_list_unittests.cc.

1278 {
1279 SaveLayerOptions expected =
1280 SaveLayerOptions::kNoAttributes.with_can_distribute_opacity();
1281 SaveLayerOptionsExpector expector(expected);
1282
1283 DisplayListBuilder builder;
1284 DlOpReceiver& receiver = ToReceiver(builder);
1285 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1286 receiver.drawRect({10, 10, 20, 20});
1287 receiver.restore();
1288
1289 builder.Build()->Dispatch(expector);
1290 EXPECT_EQ(expector.save_layer_count(), 1);
1291}

◆ TEST_F() [268/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerOneSimpleOpInheritsOpacity   
)

Definition at line 1262 of file display_list_unittests.cc.

1262 {
1263 SaveLayerOptions expected =
1264 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1265 SaveLayerOptionsExpector expector(expected);
1266
1267 DisplayListBuilder builder;
1268 DlOpReceiver& receiver = ToReceiver(builder);
1269 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1270 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1271 receiver.drawRect({10, 10, 20, 20});
1272 receiver.restore();
1273
1274 builder.Build()->Dispatch(expector);
1275 EXPECT_EQ(expector.save_layer_count(), 1);
1276}

◆ TEST_F() [269/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerSrcBlendDoesNotInheritOpacity   
)

Definition at line 1387 of file display_list_unittests.cc.

1387 {
1388 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1389 SaveLayerOptionsExpector expector(expected);
1390
1391 DisplayListBuilder builder;
1392 DlOpReceiver& receiver = ToReceiver(builder);
1393 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1394 receiver.setBlendMode(DlBlendMode::kSrc);
1395 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1396 receiver.setBlendMode(DlBlendMode::kSrcOver);
1397 receiver.drawRect({10, 10, 20, 20});
1398 receiver.restore();
1399
1400 builder.Build()->Dispatch(expector);
1401 EXPECT_EQ(expector.save_layer_count(), 1);
1402}

◆ TEST_F() [270/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerSrcBlendOnChildDoesNotInheritOpacity   
)

Definition at line 1437 of file display_list_unittests.cc.

1437 {
1438 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1439 SaveLayerOptionsExpector expector(expected);
1440
1441 DisplayListBuilder builder;
1442 DlOpReceiver& receiver = ToReceiver(builder);
1443 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1444 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1445 receiver.setBlendMode(DlBlendMode::kSrc);
1446 receiver.drawRect({10, 10, 20, 20});
1447 receiver.restore();
1448
1449 builder.Build()->Dispatch(expector);
1450 EXPECT_EQ(expector.save_layer_count(), 1);
1451}

◆ TEST_F() [271/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTrueSupportsGroupOpacityOverlappingChidren   
)

Definition at line 1167 of file display_list_unittests.cc.

1167 {
1168 DisplayListBuilder builder;
1169 DlOpReceiver& receiver = ToReceiver(builder);
1170 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1171 for (int i = 0; i < 10; i++) {
1172 receiver.drawRect(SkRect::MakeXYWH(i * 10, 0, 30, 30));
1173 }
1174 receiver.restore();
1175 auto display_list = builder.Build();
1176 EXPECT_TRUE(display_list->can_apply_group_opacity());
1177}

◆ TEST_F() [272/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTrueSupportsGroupOpacityWithChildSrcBlend   
)

Definition at line 1212 of file display_list_unittests.cc.

1212 {
1213 DisplayListBuilder builder;
1214 DlOpReceiver& receiver = ToReceiver(builder);
1215 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1216 receiver.setBlendMode(DlBlendMode::kSrc);
1217 receiver.drawRect({0, 0, 10, 10});
1218 receiver.restore();
1219 auto display_list = builder.Build();
1220 EXPECT_TRUE(display_list->can_apply_group_opacity());
1221}

◆ TEST_F() [273/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTrueWithSrcBlendDoesNotSupportGroupOpacity   
)

Definition at line 1190 of file display_list_unittests.cc.

1190 {
1191 DisplayListBuilder builder;
1192 DlOpReceiver& receiver = ToReceiver(builder);
1193 receiver.setBlendMode(DlBlendMode::kSrc);
1194 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1195 receiver.drawRect({0, 0, 10, 10});
1196 receiver.restore();
1197 auto display_list = builder.Build();
1198 EXPECT_FALSE(display_list->can_apply_group_opacity());
1199}

◆ TEST_F() [274/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTwoOverlappingOpsDoesNotInheritOpacity   
)

Definition at line 1293 of file display_list_unittests.cc.

1293 {
1294 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1295 SaveLayerOptionsExpector expector(expected);
1296
1297 DisplayListBuilder builder;
1298 DlOpReceiver& receiver = ToReceiver(builder);
1299 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1300 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1301 receiver.drawRect({10, 10, 20, 20});
1302 receiver.drawRect({15, 15, 25, 25});
1303 receiver.restore();
1304
1305 builder.Build()->Dispatch(expector);
1306 EXPECT_EQ(expector.save_layer_count(), 1);
1307}

◆ TEST_F() [275/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveRestoreRestoresClip   
)

Definition at line 351 of file display_list_unittests.cc.

351 {
352 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
353 DisplayListBuilder builder(cull_rect);
354
355 builder.Save();
356 builder.ClipRect({0.0f, 0.0f, 10.0f, 10.0f});
357 builder.Restore();
358 check_defaults(builder, cull_rect);
359
360 builder.Save();
361 builder.ClipRRect(SkRRect::MakeRectXY({0.0f, 0.0f, 5.0f, 5.0f}, 2.0f, 2.0f));
362 builder.Restore();
363 check_defaults(builder, cull_rect);
364
365 builder.Save();
366 builder.ClipPath(SkPath().addOval({0.0f, 0.0f, 10.0f, 10.0f}));
367 builder.Restore();
368 check_defaults(builder, cull_rect);
369}

◆ TEST_F() [276/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveRestoreRestoresTransform   
)

Definition at line 261 of file display_list_unittests.cc.

261 {
262 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
263 DisplayListBuilder builder(cull_rect);
264
265 builder.Save();
266 builder.Translate(10.0f, 10.0f);
267 builder.Restore();
268 check_defaults(builder, cull_rect);
269
270 builder.Save();
271 builder.Scale(10.0f, 10.0f);
272 builder.Restore();
273 check_defaults(builder, cull_rect);
274
275 builder.Save();
276 builder.Skew(0.1f, 0.1f);
277 builder.Restore();
278 check_defaults(builder, cull_rect);
279
280 builder.Save();
281 builder.Rotate(45.0f);
282 builder.Restore();
283 check_defaults(builder, cull_rect);
284
285 builder.Save();
286 builder.Transform(SkMatrix::Scale(10.0f, 10.0f));
287 builder.Restore();
288 check_defaults(builder, cull_rect);
289
290 builder.Save();
291 builder.Transform2DAffine(1.0f, 0.0f, 12.0f, //
292 0.0f, 1.0f, 35.0f);
293 builder.Restore();
294 check_defaults(builder, cull_rect);
295
296 builder.Save();
297 builder.Transform(SkM44(SkMatrix::Scale(10.0f, 10.0f)));
298 builder.Restore();
299 check_defaults(builder, cull_rect);
300
301 builder.Save();
302 builder.TransformFullPerspective(1.0f, 0.0f, 0.0f, 12.0f, //
303 0.0f, 1.0f, 0.0f, 35.0f, //
304 0.0f, 0.0f, 1.0f, 5.0f, //
305 0.0f, 0.0f, 0.0f, 1.0f);
306 builder.Restore();
307 check_defaults(builder, cull_rect);
308}

◆ TEST_F() [277/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ScaleAffectsCurrentTransform   
)

Definition at line 1599 of file display_list_unittests.cc.

1599 {
1600 DisplayListBuilder builder;
1601 DlOpReceiver& receiver = ToReceiver(builder);
1602 receiver.scale(12.3, 14.5);
1603 SkMatrix matrix = SkMatrix::Scale(12.3, 14.5);
1604 SkM44 m44 = SkM44(matrix);
1605 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1606 SkMatrix cur_matrix = builder.GetTransform();
1607 ASSERT_EQ(cur_m44, m44);
1608 ASSERT_EQ(cur_matrix, matrix);
1609 receiver.translate(10, 10);
1610 // CurrentTransform has changed
1611 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1612 ASSERT_NE(builder.GetTransform(), cur_matrix);
1613 // Previous return values have not
1614 ASSERT_EQ(cur_m44, m44);
1615 ASSERT_EQ(cur_matrix, matrix);
1616}

◆ TEST_F() [278/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ScaledSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3517 of file display_list_unittests.cc.

3517 {
3518 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3519
3520 DisplayListBuilder builder;
3521 builder.Scale(10.0f, 10.0f);
3522 builder.SaveLayer(nullptr, nullptr);
3523 { //
3524 builder.DrawRect(rect, DlPaint());
3525 }
3526 builder.Restore();
3527 auto display_list = builder.Build();
3528
3529 SaveLayerBoundsExpector expector;
3530 expector.addComputedExpectation(rect);
3531 display_list->Dispatch(expector);
3532 EXPECT_TRUE(expector.all_bounds_checked());
3533}

◆ TEST_F() [279/876]

flutter::testing::TEST_F ( DisplayListTest  ,
ScaleTriggersDeferredSave   
)

Definition at line 2584 of file display_list_unittests.cc.

2584 {
2585 DisplayListBuilder builder1;
2586 DlOpReceiver& receiver1 = ToReceiver(builder1);
2587 receiver1.save();
2588 receiver1.save();
2589 receiver1.scale(0.5, 0.5);
2590 receiver1.drawRect({0, 0, 100, 100});
2591 receiver1.restore();
2592 receiver1.restore();
2593 auto display_list1 = builder1.Build();
2594
2595 DisplayListBuilder builder2;
2596 DlOpReceiver& receiver2 = ToReceiver(builder2);
2597 receiver2.save();
2598 receiver2.scale(0.5, 0.5);
2599 receiver2.drawRect({0, 0, 100, 100});
2600 receiver2.restore();
2601 auto display_list2 = builder2.Build();
2602
2603 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2604}

◆ TEST_F() [280/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsAreEqualWithOrWithoutRtree   
)

Definition at line 669 of file display_list_unittests.cc.

669 {
670 for (auto& group : allGroups) {
671 for (size_t i = 0; i < group.variants.size(); i++) {
672 DisplayListBuilder builder1(/*prepare_rtree=*/false);
673 DisplayListBuilder builder2(/*prepare_rtree=*/true);
674 group.variants[i].Invoke(ToReceiver(builder1));
675 group.variants[i].Invoke(ToReceiver(builder2));
676 sk_sp<DisplayList> dl1 = builder1.Build();
677 sk_sp<DisplayList> dl2 = builder2.Build();
678
679 auto desc = group.op_name + "(variant " + std::to_string(i + 1) + " )";
680 ASSERT_EQ(dl1->op_count(false), dl2->op_count(false)) << desc;
681 ASSERT_EQ(dl1->bytes(false), dl2->bytes(false)) << desc;
682 ASSERT_EQ(dl1->op_count(true), dl2->op_count(true)) << desc;
683 ASSERT_EQ(dl1->bytes(true), dl2->bytes(true)) << desc;
684 EXPECT_EQ(dl1->total_depth(), dl2->total_depth()) << desc;
685 ASSERT_EQ(dl1->bounds(), dl2->bounds()) << desc;
686 ASSERT_EQ(dl1->total_depth(), dl2->total_depth()) << desc;
687 ASSERT_TRUE(DisplayListsEQ_Verbose(dl1, dl2)) << desc;
688 ASSERT_TRUE(DisplayListsEQ_Verbose(dl2, dl2)) << desc;
689 ASSERT_EQ(dl1->rtree().get(), nullptr) << desc;
690 ASSERT_NE(dl2->rtree().get(), nullptr) << desc;
691 }
692 }
693}

◆ TEST_F() [281/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsCompareToEachOther   
)

Definition at line 632 of file display_list_unittests.cc.

632 {
633 for (auto& group : allGroups) {
634 std::vector<sk_sp<DisplayList>> lists_a;
635 std::vector<sk_sp<DisplayList>> lists_b;
636 for (size_t i = 0; i < group.variants.size(); i++) {
637 lists_a.push_back(Build(group.variants[i]));
638 lists_b.push_back(Build(group.variants[i]));
639 }
640
641 for (size_t i = 0; i < lists_a.size(); i++) {
642 sk_sp<DisplayList> listA = lists_a[i];
643 for (size_t j = 0; j < lists_b.size(); j++) {
644 sk_sp<DisplayList> listB = lists_b[j];
645 auto desc = group.op_name + "(variant " + std::to_string(i + 1) +
646 " ==? variant " + std::to_string(j + 1) + ")";
647 if (i == j ||
648 (group.variants[i].is_empty() && group.variants[j].is_empty())) {
649 // They are the same variant, or both variants are NOPs
650 ASSERT_EQ(listA->op_count(false), listB->op_count(false)) << desc;
651 ASSERT_EQ(listA->bytes(false), listB->bytes(false)) << desc;
652 ASSERT_EQ(listA->op_count(true), listB->op_count(true)) << desc;
653 ASSERT_EQ(listA->bytes(true), listB->bytes(true)) << desc;
654 EXPECT_EQ(listA->total_depth(), listB->total_depth()) << desc;
655 ASSERT_EQ(listA->bounds(), listB->bounds()) << desc;
656 ASSERT_TRUE(listA->Equals(*listB)) << desc;
657 ASSERT_TRUE(listB->Equals(*listA)) << desc;
658 } else {
659 // No assertion on op/byte counts or bounds
660 // they may or may not be equal between variants
661 ASSERT_FALSE(listA->Equals(*listB)) << desc;
662 ASSERT_FALSE(listB->Equals(*listA)) << desc;
663 }
664 }
665 }
666 }
667}

◆ TEST_F() [282/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsNotEqualEmpty   
)

Definition at line 590 of file display_list_unittests.cc.

590 {
592 for (auto& group : allGroups) {
593 for (size_t i = 0; i < group.variants.size(); i++) {
594 sk_sp<DisplayList> dl = Build(group.variants[i]);
595 auto desc =
596 group.op_name + "(variant " + std::to_string(i + 1) + " != empty)";
597 if (group.variants[i].is_empty()) {
598 ASSERT_TRUE(DisplayListsEQ_Verbose(dl, empty));
599 ASSERT_TRUE(empty->Equals(*dl)) << desc;
600 } else {
601 ASSERT_TRUE(DisplayListsNE_Verbose(dl, empty));
602 ASSERT_FALSE(empty->Equals(*dl)) << desc;
603 }
604 }
605 }
606}

◆ TEST_F() [283/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsRecapturedAreEqual   
)

Definition at line 608 of file display_list_unittests.cc.

608 {
609 for (auto& group : allGroups) {
610 for (size_t i = 0; i < group.variants.size(); i++) {
611 sk_sp<DisplayList> dl = Build(group.variants[i]);
612 // Verify recapturing the replay of the display list is Equals()
613 // when dispatching directly from the DL to another builder
614 DisplayListBuilder copy_builder;
615 DlOpReceiver& r = ToReceiver(copy_builder);
616 dl->Dispatch(r);
617 sk_sp<DisplayList> copy = copy_builder.Build();
618 auto desc =
619 group.op_name + "(variant " + std::to_string(i + 1) + " == copy)";
620 ASSERT_EQ(copy->op_count(false), dl->op_count(false)) << desc;
621 ASSERT_EQ(copy->bytes(false), dl->bytes(false)) << desc;
622 ASSERT_EQ(copy->op_count(true), dl->op_count(true)) << desc;
623 ASSERT_EQ(copy->bytes(true), dl->bytes(true)) << desc;
624 EXPECT_EQ(copy->total_depth(), dl->total_depth()) << desc;
625 ASSERT_EQ(copy->bounds(), dl->bounds()) << desc;
626 ASSERT_TRUE(copy->Equals(*dl)) << desc;
627 ASSERT_TRUE(dl->Equals(*copy)) << desc;
628 }
629 }
630}

◆ TEST_F() [284/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpSizes   
)

Definition at line 577 of file display_list_unittests.cc.

577 {
578 for (auto& group : allGroups) {
579 for (size_t i = 0; i < group.variants.size(); i++) {
580 auto& invocation = group.variants[i];
581 sk_sp<DisplayList> dl = Build(invocation);
582 auto desc = group.op_name + "(variant " + std::to_string(i + 1) + ")";
583 ASSERT_EQ(dl->op_count(false), invocation.op_count()) << desc;
584 ASSERT_EQ(dl->bytes(false), invocation.byte_count()) << desc;
585 EXPECT_EQ(dl->total_depth(), invocation.depth_accumulated()) << desc;
586 }
587 }
588}

◆ TEST_F() [285/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpsMightSupportGroupOpacityBlendMode   
)

Definition at line 1044 of file display_list_unittests.cc.

1044 {
1045 auto run_tests = [](const std::string& name,
1046 void build(DlOpReceiver & receiver), bool expect_for_op,
1047 bool expect_with_kSrc) {
1048 {
1049 // First test is the draw op, by itself
1050 // (usually supports group opacity)
1051 DisplayListBuilder builder;
1052 DlOpReceiver& receiver = ToReceiver(builder);
1053 build(receiver);
1054 auto display_list = builder.Build();
1055 EXPECT_EQ(display_list->can_apply_group_opacity(), expect_for_op)
1056 << "{" << std::endl
1057 << " " << name << std::endl
1058 << "}";
1059 }
1060 {
1061 // Second test i the draw op with kSrc,
1062 // (usually fails group opacity)
1063 DisplayListBuilder builder;
1064 DlOpReceiver& receiver = ToReceiver(builder);
1065 receiver.setBlendMode(DlBlendMode::kSrc);
1066 build(receiver);
1067 auto display_list = builder.Build();
1068 EXPECT_EQ(display_list->can_apply_group_opacity(), expect_with_kSrc)
1069 << "{" << std::endl
1070 << " receiver.setBlendMode(kSrc);" << std::endl
1071 << " " << name << std::endl
1072 << "}";
1073 }
1074 };
1075
1076#define RUN_TESTS(body) \
1077 run_tests(#body, [](DlOpReceiver& receiver) { body }, true, false)
1078#define RUN_TESTS2(body, expect) \
1079 run_tests(#body, [](DlOpReceiver& receiver) { body }, expect, expect)
1080
1081 RUN_TESTS(receiver.drawPaint(););
1082 RUN_TESTS2(receiver.drawColor(DlColor(SK_ColorRED), DlBlendMode::kSrcOver);
1083 , true);
1084 RUN_TESTS2(receiver.drawColor(DlColor(SK_ColorRED), DlBlendMode::kSrc);
1085 , false);
1086 RUN_TESTS(receiver.drawLine({0, 0}, {10, 10}););
1087 RUN_TESTS(receiver.drawRect({0, 0, 10, 10}););
1088 RUN_TESTS(receiver.drawOval({0, 0, 10, 10}););
1089 RUN_TESTS(receiver.drawCircle({10, 10}, 5););
1090 RUN_TESTS(receiver.drawRRect(SkRRect::MakeRectXY({0, 0, 10, 10}, 2, 2)););
1091 RUN_TESTS(receiver.drawDRRect(SkRRect::MakeRectXY({0, 0, 10, 10}, 2, 2),
1092 SkRRect::MakeRectXY({2, 2, 8, 8}, 2, 2)););
1093 RUN_TESTS(receiver.drawPath(
1094 SkPath().addOval({0, 0, 10, 10}).addOval({5, 5, 15, 15})););
1095 RUN_TESTS(receiver.drawArc({0, 0, 10, 10}, 0, math::kPi, true););
1096 RUN_TESTS2(
1097 receiver.drawPoints(PointMode::kPoints, TestPointCount, kTestPoints);
1098 , false);
1099 RUN_TESTS2(receiver.drawVertices(TestVertices1.get(), DlBlendMode::kSrc);
1100 , false);
1101 RUN_TESTS(receiver.drawImage(TestImage1, {0, 0}, kLinearSampling, true););
1102 RUN_TESTS2(receiver.drawImage(TestImage1, {0, 0}, kLinearSampling, false);
1103 , true);
1104 RUN_TESTS(receiver.drawImageRect(TestImage1, {10, 10, 20, 20}, {0, 0, 10, 10},
1105 kNearestSampling, true,
1106 DlCanvas::SrcRectConstraint::kFast););
1107 RUN_TESTS2(receiver.drawImageRect(TestImage1, {10, 10, 20, 20},
1108 {0, 0, 10, 10}, kNearestSampling, false,
1109 DlCanvas::SrcRectConstraint::kFast);
1110 , true);
1111 RUN_TESTS(receiver.drawImageNine(TestImage2, {20, 20, 30, 30}, {0, 0, 20, 20},
1112 DlFilterMode::kLinear, true););
1113 RUN_TESTS2(
1114 receiver.drawImageNine(TestImage2, {20, 20, 30, 30}, {0, 0, 20, 20},
1115 DlFilterMode::kLinear, false);
1116 , true);
1117 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
1118 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
1119 RUN_TESTS2(
1120 receiver.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
1121 DlBlendMode::kSrcIn, kNearestSampling, nullptr, true);
1122 , false);
1123 RUN_TESTS2(
1124 receiver.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
1125 DlBlendMode::kSrcIn, kNearestSampling, nullptr, false);
1126 , false);
1127 EXPECT_TRUE(TestDisplayList1->can_apply_group_opacity());
1128 RUN_TESTS2(receiver.drawDisplayList(TestDisplayList1);, true);
1129 {
1130 static DisplayListBuilder builder;
1131 builder.DrawRect({0, 0, 10, 10}, DlPaint());
1132 builder.DrawRect({5, 5, 15, 15}, DlPaint());
1133 static auto display_list = builder.Build();
1134 RUN_TESTS2(receiver.drawDisplayList(display_list);, false);
1135 }
1136 RUN_TESTS2(receiver.drawTextBlob(GetTestTextBlob(1), 0, 0);, false);
1137 RUN_TESTS2(
1138 receiver.drawShadow(kTestPath1, DlColor(SK_ColorBLACK), 1.0, false, 1.0);
1139 , false);
1140
1141#undef RUN_TESTS2
1142#undef RUN_TESTS
1143}
virtual void drawImageRect(const sk_sp< DlImage > image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, bool render_with_attributes, SrcRectConstraint constraint=SrcRectConstraint::kFast)=0
virtual void drawArc(const SkRect &oval_bounds, SkScalar start_degrees, SkScalar sweep_degrees, bool use_center)=0
virtual void drawImage(const sk_sp< DlImage > image, const SkPoint point, DlImageSampling sampling, bool render_with_attributes)=0
virtual void drawCircle(const SkPoint &center, SkScalar radius)=0
virtual void drawVertices(const DlVertices *vertices, DlBlendMode mode)=0
virtual void drawPoints(PointMode mode, uint32_t count, const SkPoint points[])=0
virtual void drawOval(const SkRect &bounds)=0
virtual void drawRRect(const SkRRect &rrect)=0
virtual void drawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1)=0
virtual void drawDRRect(const SkRRect &outer, const SkRRect &inner)=0
virtual void drawImageNine(const sk_sp< DlImage > image, const SkIRect &center, const SkRect &dst, DlFilterMode filter, bool render_with_attributes)=0
virtual void drawColor(DlColor color, DlBlendMode mode)=0
virtual void drawAtlas(const sk_sp< DlImage > atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const SkRect *cull_rect, bool render_with_attributes)=0
virtual void drawLine(const SkPoint &p0, const SkPoint &p1)=0
virtual void drawPaint()=0
virtual void drawTextBlob(const sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y)=0
#define RUN_TESTS2(body, expect)
#define RUN_TESTS(body)

◆ TEST_F() [286/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SkewAffectsCurrentTransform   
)

Definition at line 1637 of file display_list_unittests.cc.

1637 {
1638 DisplayListBuilder builder;
1639 DlOpReceiver& receiver = ToReceiver(builder);
1640 receiver.skew(12.3, 14.5);
1641 SkMatrix matrix = SkMatrix::Skew(12.3, 14.5);
1642 SkM44 m44 = SkM44(matrix);
1643 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1644 SkMatrix cur_matrix = builder.GetTransform();
1645 ASSERT_EQ(cur_m44, m44);
1646 ASSERT_EQ(cur_matrix, matrix);
1647 receiver.translate(10, 10);
1648 // CurrentTransform has changed
1649 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1650 ASSERT_NE(builder.GetTransform(), cur_matrix);
1651 // Previous return values have not
1652 ASSERT_EQ(cur_m44, m44);
1653 ASSERT_EQ(cur_matrix, matrix);
1654}

◆ TEST_F() [287/876]

flutter::testing::TEST_F ( DisplayListTest  ,
SkewTriggersDeferredSave   
)

Definition at line 2540 of file display_list_unittests.cc.

2540 {
2541 DisplayListBuilder builder1;
2542 DlOpReceiver& receiver1 = ToReceiver(builder1);
2543 receiver1.save();
2544 receiver1.save();
2545 receiver1.skew(10, 10);
2546 receiver1.drawRect({0, 0, 100, 100});
2547 receiver1.restore();
2548 receiver1.restore();
2549 auto display_list1 = builder1.Build();
2550
2551 DisplayListBuilder builder2;
2552 DlOpReceiver& receiver2 = ToReceiver(builder2);
2553 receiver2.save();
2554 receiver2.skew(10, 10);
2555 receiver2.drawRect({0, 0, 100, 100});
2556 receiver2.restore();
2557 auto display_list2 = builder2.Build();
2558
2559 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2560}

◆ TEST_F() [288/876]

flutter::testing::TEST_F ( DisplayListTest  ,
Transform2DTriggersDeferredSave   
)

Definition at line 2468 of file display_list_unittests.cc.

2468 {
2469 DisplayListBuilder builder1;
2470 DlOpReceiver& receiver1 = ToReceiver(builder1);
2471 receiver1.save();
2472 receiver1.save();
2473 receiver1.transform2DAffine(0, 1, 12, 1, 0, 33);
2474 receiver1.drawRect({0, 0, 100, 100});
2475 receiver1.restore();
2476 receiver1.restore();
2477 auto display_list1 = builder1.Build();
2478
2479 DisplayListBuilder builder2;
2480 DlOpReceiver& receiver2 = ToReceiver(builder2);
2481 receiver2.save();
2482 receiver2.transform2DAffine(0, 1, 12, 1, 0, 33);
2483 receiver2.drawRect({0, 0, 100, 100});
2484 receiver2.restore();
2485 auto display_list2 = builder2.Build();
2486
2487 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2488}

◆ TEST_F() [289/876]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformAffectsCurrentTransform   
)

Definition at line 1656 of file display_list_unittests.cc.

1656 {
1657 DisplayListBuilder builder;
1658 DlOpReceiver& receiver = ToReceiver(builder);
1659 receiver.transform2DAffine(3, 0, 12.3, //
1660 1, 5, 14.5);
1661 SkMatrix matrix = SkMatrix::MakeAll(3, 0, 12.3, //
1662 1, 5, 14.5, //
1663 0, 0, 1);
1664 SkM44 m44 = SkM44(matrix);
1665 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1666 SkMatrix cur_matrix = builder.GetTransform();
1667 ASSERT_EQ(cur_m44, m44);
1668 ASSERT_EQ(cur_matrix, matrix);
1669 receiver.translate(10, 10);
1670 // CurrentTransform has changed
1671 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1672 ASSERT_NE(builder.GetTransform(), cur_matrix);
1673 // Previous return values have not
1674 ASSERT_EQ(cur_m44, m44);
1675 ASSERT_EQ(cur_matrix, matrix);
1676}

◆ TEST_F() [290/876]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformPerspectiveTriggersDeferredSave   
)

Definition at line 2490 of file display_list_unittests.cc.

2490 {
2491 DisplayListBuilder builder1;
2492 DlOpReceiver& receiver1 = ToReceiver(builder1);
2493 receiver1.save();
2494 receiver1.save();
2495 receiver1.transformFullPerspective(0, 1, 0, 12, //
2496 1, 0, 0, 33, //
2497 3, 2, 5, 29, //
2498 0, 0, 0, 12);
2499 receiver1.drawRect({0, 0, 100, 100});
2500 receiver1.restore();
2501 receiver1.restore();
2502 auto display_list1 = builder1.Build();
2503
2504 DisplayListBuilder builder2;
2505 DlOpReceiver& receiver2 = ToReceiver(builder2);
2506 receiver2.save();
2507 receiver2.transformFullPerspective(0, 1, 0, 12, //
2508 1, 0, 0, 33, //
2509 3, 2, 5, 29, //
2510 0, 0, 0, 12);
2511 receiver2.drawRect({0, 0, 100, 100});
2512 receiver2.restore();
2513 auto display_list2 = builder2.Build();
2514
2515 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2516}

◆ TEST_F() [291/876]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformResetSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3553 of file display_list_unittests.cc.

3553 {
3554 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3555 SkRect rect_doubled = SkMatrix::Scale(2.0f, 2.0f).mapRect(rect);
3556
3557 DisplayListBuilder builder;
3558 builder.Scale(10.0f, 10.0f);
3559 builder.SaveLayer(nullptr, nullptr);
3560 builder.TransformReset();
3561 builder.Scale(20.0f, 20.0f);
3562 // Net local transform for saveLayer is Scale(2, 2)
3563 { //
3564 builder.DrawRect(rect, DlPaint());
3565 }
3566 builder.Restore();
3567 auto display_list = builder.Build();
3568
3569 SaveLayerBoundsExpector expector;
3570 expector.addComputedExpectation(rect_doubled);
3571 display_list->Dispatch(expector);
3572 EXPECT_TRUE(expector.all_bounds_checked());
3573}

◆ TEST_F() [292/876]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformTriggersDeferredSave   
)

Definition at line 2428 of file display_list_unittests.cc.

2428 {
2429 DisplayListBuilder builder1;
2430 DlOpReceiver& receiver1 = ToReceiver(builder1);
2431 receiver1.save();
2432 receiver1.save();
2433 receiver1.transformFullPerspective(1, 0, 0, 10, //
2434 0, 1, 0, 100, //
2435 0, 0, 1, 0, //
2436 0, 0, 0, 1);
2437 receiver1.drawRect({0, 0, 100, 100});
2438 receiver1.restore();
2439 receiver1.transformFullPerspective(1, 0, 0, 10, //
2440 0, 1, 0, 100, //
2441 0, 0, 1, 0, //
2442 0, 0, 0, 1);
2443 receiver1.drawRect({0, 0, 100, 100});
2444 receiver1.restore();
2445 auto display_list1 = builder1.Build();
2446
2447 DisplayListBuilder builder2;
2448 DlOpReceiver& receiver2 = ToReceiver(builder2);
2449 receiver2.save();
2450 receiver2.transformFullPerspective(1, 0, 0, 10, //
2451 0, 1, 0, 100, //
2452 0, 0, 1, 0, //
2453 0, 0, 0, 1);
2454 receiver2.drawRect({0, 0, 100, 100});
2455 receiver2.restore();
2456 receiver2.save();
2457 receiver2.transformFullPerspective(1, 0, 0, 10, //
2458 0, 1, 0, 100, //
2459 0, 0, 1, 0, //
2460 0, 0, 0, 1);
2461 receiver2.drawRect({0, 0, 100, 100});
2462 receiver2.restore();
2463 auto display_list2 = builder2.Build();
2464
2465 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2466}

◆ TEST_F() [293/876]

flutter::testing::TEST_F ( DisplayListTest  ,
TranslateAffectsCurrentTransform   
)

Definition at line 1580 of file display_list_unittests.cc.

1580 {
1581 DisplayListBuilder builder;
1582 DlOpReceiver& receiver = ToReceiver(builder);
1583 receiver.translate(12.3, 14.5);
1584 SkMatrix matrix = SkMatrix::Translate(12.3, 14.5);
1585 SkM44 m44 = SkM44(matrix);
1586 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1587 SkMatrix cur_matrix = builder.GetTransform();
1588 ASSERT_EQ(cur_m44, m44);
1589 ASSERT_EQ(cur_matrix, matrix);
1590 receiver.translate(10, 10);
1591 // CurrentTransform has changed
1592 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1593 ASSERT_NE(builder.GetTransform(), cur_matrix);
1594 // Previous return values have not
1595 ASSERT_EQ(cur_m44, m44);
1596 ASSERT_EQ(cur_matrix, matrix);
1597}

◆ TEST_F() [294/876]

flutter::testing::TEST_F ( DisplayListTest  ,
TranslatedSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3499 of file display_list_unittests.cc.

3499 {
3500 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3501
3502 DisplayListBuilder builder;
3503 builder.Translate(10.0f, 10.0f);
3504 builder.SaveLayer(nullptr, nullptr);
3505 { //
3506 builder.DrawRect(rect, DlPaint());
3507 }
3508 builder.Restore();
3509 auto display_list = builder.Build();
3510
3511 SaveLayerBoundsExpector expector;
3512 expector.addComputedExpectation(rect);
3513 display_list->Dispatch(expector);
3514 EXPECT_TRUE(expector.all_bounds_checked());
3515}

◆ TEST_F() [295/876]

flutter::testing::TEST_F ( DisplayListTest  ,
TranslateTriggersDeferredSave   
)

Definition at line 2562 of file display_list_unittests.cc.

2562 {
2563 DisplayListBuilder builder1;
2564 DlOpReceiver& receiver1 = ToReceiver(builder1);
2565 receiver1.save();
2566 receiver1.save();
2567 receiver1.translate(10, 10);
2568 receiver1.drawRect({0, 0, 100, 100});
2569 receiver1.restore();
2570 receiver1.restore();
2571 auto display_list1 = builder1.Build();
2572
2573 DisplayListBuilder builder2;
2574 DlOpReceiver& receiver2 = ToReceiver(builder2);
2575 receiver2.save();
2576 receiver2.translate(10, 10);
2577 receiver2.drawRect({0, 0, 100, 100});
2578 receiver2.restore();
2579 auto display_list2 = builder2.Build();
2580
2581 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2582}

◆ TEST_F() [296/876]

flutter::testing::TEST_F ( DisplayListTest  ,
UnclippedSaveLayerContentAccountsForFilter   
)

Definition at line 511 of file display_list_unittests.cc.

511 {
512 SkRect cull_rect = SkRect::MakeLTRB(0.0f, 0.0f, 300.0f, 300.0f);
513 SkRect clip_rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
514 SkRect draw_rect = SkRect::MakeLTRB(50.0f, 140.0f, 101.0f, 160.0f);
515 auto filter = DlBlurImageFilter::Make(10.0f, 10.0f, DlTileMode::kDecal);
516 DlPaint layer_paint = DlPaint().setImageFilter(filter);
517
518 ASSERT_TRUE(clip_rect.intersects(draw_rect));
519 ASSERT_TRUE(cull_rect.contains(clip_rect));
520 ASSERT_TRUE(cull_rect.contains(draw_rect));
521
522 DisplayListBuilder builder;
523 builder.Save();
524 {
525 builder.ClipRect(clip_rect, ClipOp::kIntersect, false);
526 builder.SaveLayer(&cull_rect, &layer_paint);
527 { //
528 builder.DrawRect(draw_rect, DlPaint());
529 }
530 builder.Restore();
531 }
532 builder.Restore();
533 auto display_list = builder.Build();
534
535 ASSERT_EQ(display_list->op_count(), 6u);
536 EXPECT_EQ(display_list->total_depth(), 2u);
537
538 SkRect result_rect = draw_rect.makeOutset(30.0f, 30.0f);
539 ASSERT_TRUE(result_rect.intersect(clip_rect));
540 ASSERT_EQ(result_rect, SkRect::MakeLTRB(100.0f, 110.0f, 131.0f, 190.0f));
541 ASSERT_EQ(display_list->bounds(), result_rect);
542}

◆ TEST_F() [297/876]

flutter::testing::TEST_F ( EmbedderA11yTest  ,
A11yStringAttributes   
)

Definition at line 275 of file embedder_a11y_unittests.cc.

275 {
276#if defined(OS_FUCHSIA)
277 GTEST_SKIP() << "This test crashes on Fuchsia. https://fxbug.dev/87493 ";
278#else
279
280 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
281
282 fml::AutoResetWaitableEvent signal_native_latch;
283
284 // Called by the Dart text fixture on the UI thread to signal that the C++
285 // unittest should resume.
286 context.AddNativeCallback(
287 "SignalNativeTest",
288 CREATE_NATIVE_ENTRY(([&signal_native_latch](Dart_NativeArguments) {
289 signal_native_latch.Signal();
290 })));
291
292 fml::AutoResetWaitableEvent semantics_update_latch;
293 context.SetSemanticsUpdateCallback2(
294 [&](const FlutterSemanticsUpdate2* update) {
295 ASSERT_EQ(update->node_count, size_t(1));
296 ASSERT_EQ(update->custom_action_count, size_t(0));
297
298 auto node = update->nodes[0];
299
300 // Verify label
301 {
302 ASSERT_EQ(std::string(node->label), "What is the meaning of life?");
303 ASSERT_EQ(node->label_attribute_count, size_t(2));
304
305 ASSERT_EQ(node->label_attributes[0]->start, size_t(0));
306 ASSERT_EQ(node->label_attributes[0]->end, size_t(28));
307 ASSERT_EQ(node->label_attributes[0]->type,
309 ASSERT_EQ(std::string(node->label_attributes[0]->locale->locale),
310 "en");
311
312 ASSERT_EQ(node->label_attributes[1]->start, size_t(0));
313 ASSERT_EQ(node->label_attributes[1]->end, size_t(1));
314 ASSERT_EQ(node->label_attributes[1]->type,
316 }
317
318 // Verify hint
319 {
320 ASSERT_EQ(std::string(node->hint), "It's a number");
321 ASSERT_EQ(node->hint_attribute_count, size_t(2));
322
323 ASSERT_EQ(node->hint_attributes[0]->start, size_t(0));
324 ASSERT_EQ(node->hint_attributes[0]->end, size_t(1));
325 ASSERT_EQ(node->hint_attributes[0]->type,
327 ASSERT_EQ(std::string(node->hint_attributes[0]->locale->locale),
328 "en");
329
330 ASSERT_EQ(node->hint_attributes[1]->start, size_t(2));
331 ASSERT_EQ(node->hint_attributes[1]->end, size_t(3));
332 ASSERT_EQ(node->hint_attributes[1]->type,
334 ASSERT_EQ(std::string(node->hint_attributes[1]->locale->locale),
335 "fr");
336 }
337
338 // Verify value
339 {
340 ASSERT_EQ(std::string(node->value), "42");
341 ASSERT_EQ(node->value_attribute_count, size_t(1));
342
343 ASSERT_EQ(node->value_attributes[0]->start, size_t(0));
344 ASSERT_EQ(node->value_attributes[0]->end, size_t(2));
345 ASSERT_EQ(node->value_attributes[0]->type,
347 ASSERT_EQ(std::string(node->value_attributes[0]->locale->locale),
348 "en-US");
349 }
350
351 // Verify increased value
352 {
353 ASSERT_EQ(std::string(node->increased_value), "43");
354 ASSERT_EQ(node->increased_value_attribute_count, size_t(2));
355
356 ASSERT_EQ(node->increased_value_attributes[0]->start, size_t(0));
357 ASSERT_EQ(node->increased_value_attributes[0]->end, size_t(1));
358 ASSERT_EQ(node->increased_value_attributes[0]->type,
360
361 ASSERT_EQ(node->increased_value_attributes[1]->start, size_t(1));
362 ASSERT_EQ(node->increased_value_attributes[1]->end, size_t(2));
363 ASSERT_EQ(node->increased_value_attributes[1]->type,
365 }
366
367 // Verify decreased value
368 {
369 ASSERT_EQ(std::string(node->decreased_value), "41");
370 ASSERT_EQ(node->decreased_value_attribute_count, size_t(0));
371 ASSERT_EQ(node->decreased_value_attributes, nullptr);
372 }
373
374 semantics_update_latch.Signal();
375 });
376
377 EmbedderConfigBuilder builder(context);
378 builder.SetSoftwareRendererConfig();
379 builder.SetDartEntrypoint("a11y_string_attributes");
380
381 auto engine = builder.LaunchEngine();
382 ASSERT_TRUE(engine.is_valid());
383
384 // 1: Enable semantics.
387
388 // 2: Wait for semantics update callback on platform (current) thread.
389 signal_native_latch.Wait();
391 semantics_update_latch.Wait();
392#endif // OS_FUCHSIA
393}
void RunExpiredTasksNow()
FlutterEngineResult FlutterEngineUpdateSemanticsEnabled(FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled)
Enable or disable accessibility semantics.
Definition embedder.cc:2821
@ kSpellOut
Definition embedder.h:1200
@ kLocale
Definition embedder.h:1202
A batch of updates to semantics nodes and custom actions.
Definition embedder.h:1502

◆ TEST_F() [298/876]

flutter::testing::TEST_F ( EmbedderA11yTest  ,
A11yTreeIsConsistentUsingV1Callbacks   
)

Definition at line 572 of file embedder_a11y_unittests.cc.

572 {
573 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
574
575 fml::AutoResetWaitableEvent signal_native_latch;
576
577 // Called by the Dart text fixture on the UI thread to signal that the C++
578 // unittest should resume.
579 context.AddNativeCallback(
580 "SignalNativeTest",
581 CREATE_NATIVE_ENTRY(([&signal_native_latch](Dart_NativeArguments) {
582 signal_native_latch.Signal();
583 })));
584
585 // Called by test fixture on UI thread to pass data back to this test.
586 NativeEntry notify_semantics_enabled_callback;
587 context.AddNativeCallback(
588 "NotifySemanticsEnabled",
590 ([&notify_semantics_enabled_callback](Dart_NativeArguments args) {
591 ASSERT_NE(notify_semantics_enabled_callback, nullptr);
592 notify_semantics_enabled_callback(args);
593 })));
594
595 NativeEntry notify_accessibility_features_callback;
596 context.AddNativeCallback(
597 "NotifyAccessibilityFeatures",
599 [&notify_accessibility_features_callback](Dart_NativeArguments args) {
600 ASSERT_NE(notify_accessibility_features_callback, nullptr);
601 notify_accessibility_features_callback(args);
602 })));
603
604 NativeEntry notify_semantics_action_callback;
605 context.AddNativeCallback(
606 "NotifySemanticsAction",
608 ([&notify_semantics_action_callback](Dart_NativeArguments args) {
609 ASSERT_NE(notify_semantics_action_callback, nullptr);
610 notify_semantics_action_callback(args);
611 })));
612
613 fml::AutoResetWaitableEvent semantics_node_latch;
614 fml::AutoResetWaitableEvent semantics_action_latch;
615
616 int node_batch_end_count = 0;
617 int action_batch_end_count = 0;
618
619 int node_count = 0;
620 context.SetSemanticsNodeCallback([&](const FlutterSemanticsNode* node) {
621 if (node->id == kFlutterSemanticsNodeIdBatchEnd) {
622 ++node_batch_end_count;
623 semantics_node_latch.Signal();
624 } else {
625 // Batches should be completed after all nodes are received.
626 ASSERT_EQ(0, node_batch_end_count);
627 ASSERT_EQ(0, action_batch_end_count);
628
629 ++node_count;
630 ASSERT_EQ(1.0, node->transform.scaleX);
631 ASSERT_EQ(2.0, node->transform.skewX);
632 ASSERT_EQ(3.0, node->transform.transX);
633 ASSERT_EQ(4.0, node->transform.skewY);
634 ASSERT_EQ(5.0, node->transform.scaleY);
635 ASSERT_EQ(6.0, node->transform.transY);
636 ASSERT_EQ(7.0, node->transform.pers0);
637 ASSERT_EQ(8.0, node->transform.pers1);
638 ASSERT_EQ(9.0, node->transform.pers2);
639 ASSERT_EQ(std::strncmp(kTooltip, node->tooltip, sizeof(kTooltip) - 1), 0);
640
641 if (node->id == 128) {
642 ASSERT_EQ(0x3f3, node->platform_view_id);
643 } else {
644 ASSERT_EQ(0, node->platform_view_id);
645 }
646 }
647 });
648
649 int action_count = 0;
650 context.SetSemanticsCustomActionCallback(
653 ++action_batch_end_count;
654 semantics_action_latch.Signal();
655 } else {
656 // Batches should be completed after all actions are received.
657 ASSERT_EQ(0, node_batch_end_count);
658 ASSERT_EQ(0, action_batch_end_count);
659
660 ++action_count;
661 }
662 });
663
664 EmbedderConfigBuilder builder(context);
665 builder.SetSoftwareRendererConfig();
666 builder.SetDartEntrypoint("a11y_main");
667
668 auto engine = builder.LaunchEngine();
669 ASSERT_TRUE(engine.is_valid());
670
671 // 1: Wait for initial notifySemanticsEnabled(false).
672 fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
673 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
674 Dart_Handle exception = nullptr;
675 bool enabled =
677 ASSERT_FALSE(enabled);
678 notify_semantics_enabled_latch.Signal();
679 };
680 notify_semantics_enabled_latch.Wait();
681
682 // Prepare notifyAccessibilityFeatures callback.
683 fml::AutoResetWaitableEvent notify_features_latch;
684 notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
685 Dart_Handle exception = nullptr;
686 bool enabled =
688 ASSERT_FALSE(enabled);
689 notify_features_latch.Signal();
690 };
691
692 // 2: Enable semantics. Wait for notifySemanticsEnabled(true).
693 fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
694 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
695 Dart_Handle exception = nullptr;
696 bool enabled =
698 ASSERT_TRUE(enabled);
699 notify_semantics_enabled_latch_2.Signal();
700 };
703 notify_semantics_enabled_latch_2.Wait();
704
705 // 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
706 notify_features_latch.Wait();
707
708 // 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
709 fml::AutoResetWaitableEvent notify_features_latch_2;
710 notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
711 Dart_Handle exception = nullptr;
712 bool enabled =
714 ASSERT_TRUE(enabled);
715 notify_features_latch_2.Signal();
716 };
720 notify_features_latch_2.Wait();
721
722 // 5: Wait for UpdateSemantics callback on platform (current) thread.
723 signal_native_latch.Wait();
725 semantics_node_latch.Wait();
726 semantics_action_latch.Wait();
727 ASSERT_EQ(4, node_count);
728 ASSERT_EQ(1, node_batch_end_count);
729 ASSERT_EQ(1, action_count);
730 ASSERT_EQ(1, action_batch_end_count);
731
732 // 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
733 fml::AutoResetWaitableEvent notify_semantics_action_latch;
734 notify_semantics_action_callback = [&](Dart_NativeArguments args) {
735 Dart_Handle exception = nullptr;
736 int64_t node_id =
738 ASSERT_EQ(42, node_id);
739
740 int64_t action_id =
742 ASSERT_EQ(static_cast<int32_t>(flutter::SemanticsAction::kTap), action_id);
743
744 std::vector<int64_t> semantic_args =
746 exception);
747 ASSERT_THAT(semantic_args, ElementsAre(2, 1));
748 notify_semantics_action_latch.Signal();
749 };
750 std::vector<uint8_t> bytes({2, 1});
752 engine.get(), 42, kFlutterSemanticsActionTap, &bytes[0], bytes.size());
754 notify_semantics_action_latch.Wait();
755
756 // 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
757 fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
758 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
759 Dart_Handle exception = nullptr;
760 bool enabled =
762 ASSERT_FALSE(enabled);
763 notify_semantics_enabled_latch_3.Signal();
764 };
767 notify_semantics_enabled_latch_3.Wait();
768}
const int32_t kFlutterSemanticsNodeIdBatchEnd
Definition embedder.cc:104
const int32_t kFlutterSemanticsCustomActionIdBatchEnd
Definition embedder.cc:105
FlutterEngineResult FlutterEngineDispatchSemanticsAction(FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t node_id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length)
Dispatch a semantics action to the specified semantics node.
Definition embedder.cc:2849
FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature flags)
Sets additional accessibility features.
Definition embedder.cc:2835
@ kFlutterAccessibilityFeatureReduceMotion
Definition embedder.h:103
std::function< void(Dart_NativeArguments)> NativeEntry
FlutterTransformation transform
Definition embedder.h:1304
const char * tooltip
A textual tooltip attached to the node.
Definition embedder.h:1320
FlutterPlatformViewIdentifier platform_view_id
Definition embedder.h:1318
int32_t id
The unique identifier for this node.
Definition embedder.h:1260
double transY
vertical translation
Definition embedder.h:287
double pers2
perspective scale factor
Definition embedder.h:293
double skewX
horizontal skew factor
Definition embedder.h:279
double pers0
input x-axis perspective factor
Definition embedder.h:289
double scaleX
horizontal scale factor
Definition embedder.h:277
double skewY
vertical skew factor
Definition embedder.h:283
double scaleY
vertical scale factor
Definition embedder.h:285
double pers1
input y-axis perspective factor
Definition embedder.h:291
double transX
horizontal translation
Definition embedder.h:281

◆ TEST_F() [299/876]

flutter::testing::TEST_F ( EmbedderA11yTest  ,
A11yTreeIsConsistentUsingV2Callbacks   
)

Definition at line 395 of file embedder_a11y_unittests.cc.

395 {
396#if defined(OS_FUCHSIA)
397 GTEST_SKIP() << "This test crashes on Fuchsia. https://fxbug.dev/87493 ";
398#else
399
400 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
401
402 fml::AutoResetWaitableEvent signal_native_latch;
403
404 // Called by the Dart text fixture on the UI thread to signal that the C++
405 // unittest should resume.
406 context.AddNativeCallback(
407 "SignalNativeTest",
408 CREATE_NATIVE_ENTRY(([&signal_native_latch](Dart_NativeArguments) {
409 signal_native_latch.Signal();
410 })));
411
412 // Called by test fixture on UI thread to pass data back to this test.
413 NativeEntry notify_semantics_enabled_callback;
414 context.AddNativeCallback(
415 "NotifySemanticsEnabled",
417 ([&notify_semantics_enabled_callback](Dart_NativeArguments args) {
418 ASSERT_NE(notify_semantics_enabled_callback, nullptr);
419 notify_semantics_enabled_callback(args);
420 })));
421
422 NativeEntry notify_accessibility_features_callback;
423 context.AddNativeCallback(
424 "NotifyAccessibilityFeatures",
426 [&notify_accessibility_features_callback](Dart_NativeArguments args) {
427 ASSERT_NE(notify_accessibility_features_callback, nullptr);
428 notify_accessibility_features_callback(args);
429 })));
430
431 NativeEntry notify_semantics_action_callback;
432 context.AddNativeCallback(
433 "NotifySemanticsAction",
435 ([&notify_semantics_action_callback](Dart_NativeArguments args) {
436 ASSERT_NE(notify_semantics_action_callback, nullptr);
437 notify_semantics_action_callback(args);
438 })));
439
440 fml::AutoResetWaitableEvent semantics_update_latch;
441 context.SetSemanticsUpdateCallback([&](const FlutterSemanticsUpdate* update) {
442 ASSERT_EQ(size_t(4), update->nodes_count);
443 ASSERT_EQ(size_t(1), update->custom_actions_count);
444
445 for (size_t i = 0; i < update->nodes_count; i++) {
446 const FlutterSemanticsNode* node = update->nodes + i;
447
448 ASSERT_EQ(1.0, node->transform.scaleX);
449 ASSERT_EQ(2.0, node->transform.skewX);
450 ASSERT_EQ(3.0, node->transform.transX);
451 ASSERT_EQ(4.0, node->transform.skewY);
452 ASSERT_EQ(5.0, node->transform.scaleY);
453 ASSERT_EQ(6.0, node->transform.transY);
454 ASSERT_EQ(7.0, node->transform.pers0);
455 ASSERT_EQ(8.0, node->transform.pers1);
456 ASSERT_EQ(9.0, node->transform.pers2);
457 ASSERT_EQ(std::strncmp(kTooltip, node->tooltip, sizeof(kTooltip) - 1), 0);
458
459 if (node->id == 128) {
460 ASSERT_EQ(0x3f3, node->platform_view_id);
461 } else {
462 ASSERT_NE(kFlutterSemanticsNodeIdBatchEnd, node->id);
463 ASSERT_EQ(0, node->platform_view_id);
464 }
465 }
466
467 semantics_update_latch.Signal();
468 });
469
470 EmbedderConfigBuilder builder(context);
471 builder.SetSoftwareRendererConfig();
472 builder.SetDartEntrypoint("a11y_main");
473
474 auto engine = builder.LaunchEngine();
475 ASSERT_TRUE(engine.is_valid());
476
477 // 1: Wait for initial notifySemanticsEnabled(false).
478 fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
479 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
480 Dart_Handle exception = nullptr;
481 bool enabled =
483 ASSERT_FALSE(enabled);
484 notify_semantics_enabled_latch.Signal();
485 };
486 notify_semantics_enabled_latch.Wait();
487
488 // Prepare notifyAccessibilityFeatures callback.
489 fml::AutoResetWaitableEvent notify_features_latch;
490 notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
491 Dart_Handle exception = nullptr;
492 bool enabled =
494 ASSERT_FALSE(enabled);
495 notify_features_latch.Signal();
496 };
497
498 // 2: Enable semantics. Wait for notifySemanticsEnabled(true).
499 fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
500 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
501 Dart_Handle exception = nullptr;
502 bool enabled =
504 ASSERT_TRUE(enabled);
505 notify_semantics_enabled_latch_2.Signal();
506 };
509 notify_semantics_enabled_latch_2.Wait();
510
511 // 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
512 notify_features_latch.Wait();
513
514 // 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
515 fml::AutoResetWaitableEvent notify_features_latch_2;
516 notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
517 Dart_Handle exception = nullptr;
518 bool enabled =
520 ASSERT_TRUE(enabled);
521 notify_features_latch_2.Signal();
522 };
526 notify_features_latch_2.Wait();
527
528 // 5: Wait for UpdateSemantics callback on platform (current) thread.
529 signal_native_latch.Wait();
531 semantics_update_latch.Wait();
532
533 // 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
534 fml::AutoResetWaitableEvent notify_semantics_action_latch;
535 notify_semantics_action_callback = [&](Dart_NativeArguments args) {
536 Dart_Handle exception = nullptr;
537 int64_t node_id =
539 ASSERT_EQ(42, node_id);
540
541 int64_t action_id =
543 ASSERT_EQ(static_cast<int32_t>(flutter::SemanticsAction::kTap), action_id);
544
545 std::vector<int64_t> semantic_args =
547 exception);
548 ASSERT_THAT(semantic_args, ElementsAre(2, 1));
549 notify_semantics_action_latch.Signal();
550 };
551 std::vector<uint8_t> bytes({2, 1});
553 engine.get(), 42, kFlutterSemanticsActionTap, &bytes[0], bytes.size());
555 notify_semantics_action_latch.Wait();
556
557 // 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
558 fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
559 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
560 Dart_Handle exception = nullptr;
561 bool enabled =
563 ASSERT_FALSE(enabled);
564 notify_semantics_enabled_latch_3.Signal();
565 };
568 notify_semantics_enabled_latch_3.Wait();
569#endif // OS_FUCHSIA
570}

◆ TEST_F() [300/876]

flutter::testing::TEST_F ( EmbedderA11yTest  ,
A11yTreeIsConsistentUsingV3Callbacks   
)

Definition at line 96 of file embedder_a11y_unittests.cc.

96 {
97#if defined(OS_FUCHSIA)
98 GTEST_SKIP() << "This test crashes on Fuchsia. https://fxbug.dev/87493 ";
99#else
100
101 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
102
103 fml::AutoResetWaitableEvent signal_native_latch;
104
105 // Called by the Dart text fixture on the UI thread to signal that the C++
106 // unittest should resume.
107 context.AddNativeCallback(
108 "SignalNativeTest",
109 CREATE_NATIVE_ENTRY(([&signal_native_latch](Dart_NativeArguments) {
110 signal_native_latch.Signal();
111 })));
112
113 // Called by test fixture on UI thread to pass data back to this test.
114 NativeEntry notify_semantics_enabled_callback;
115 context.AddNativeCallback(
116 "NotifySemanticsEnabled",
118 ([&notify_semantics_enabled_callback](Dart_NativeArguments args) {
119 ASSERT_NE(notify_semantics_enabled_callback, nullptr);
120 notify_semantics_enabled_callback(args);
121 })));
122
123 NativeEntry notify_accessibility_features_callback;
124 context.AddNativeCallback(
125 "NotifyAccessibilityFeatures",
127 [&notify_accessibility_features_callback](Dart_NativeArguments args) {
128 ASSERT_NE(notify_accessibility_features_callback, nullptr);
129 notify_accessibility_features_callback(args);
130 })));
131
132 NativeEntry notify_semantics_action_callback;
133 context.AddNativeCallback(
134 "NotifySemanticsAction",
136 ([&notify_semantics_action_callback](Dart_NativeArguments args) {
137 ASSERT_NE(notify_semantics_action_callback, nullptr);
138 notify_semantics_action_callback(args);
139 })));
140
141 fml::AutoResetWaitableEvent semantics_update_latch;
142 context.SetSemanticsUpdateCallback2(
143 [&](const FlutterSemanticsUpdate2* update) {
144 ASSERT_EQ(size_t(4), update->node_count);
145 ASSERT_EQ(size_t(1), update->custom_action_count);
146
147 for (size_t i = 0; i < update->node_count; i++) {
148 const FlutterSemanticsNode2* node = update->nodes[i];
149
150 ASSERT_EQ(1.0, node->transform.scaleX);
151 ASSERT_EQ(2.0, node->transform.skewX);
152 ASSERT_EQ(3.0, node->transform.transX);
153 ASSERT_EQ(4.0, node->transform.skewY);
154 ASSERT_EQ(5.0, node->transform.scaleY);
155 ASSERT_EQ(6.0, node->transform.transY);
156 ASSERT_EQ(7.0, node->transform.pers0);
157 ASSERT_EQ(8.0, node->transform.pers1);
158 ASSERT_EQ(9.0, node->transform.pers2);
159 ASSERT_EQ(std::strncmp(kTooltip, node->tooltip, sizeof(kTooltip) - 1),
160 0);
161
162 if (node->id == 128) {
163 ASSERT_EQ(0x3f3, node->platform_view_id);
164 } else {
165 ASSERT_NE(kFlutterSemanticsNodeIdBatchEnd, node->id);
166 ASSERT_EQ(0, node->platform_view_id);
167 }
168 }
169
170 semantics_update_latch.Signal();
171 });
172
173 EmbedderConfigBuilder builder(context);
174 builder.SetSoftwareRendererConfig();
175 builder.SetDartEntrypoint("a11y_main");
176
177 auto engine = builder.LaunchEngine();
178 ASSERT_TRUE(engine.is_valid());
179
180 // 1: Wait for initial notifySemanticsEnabled(false).
181 fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
182 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
183 Dart_Handle exception = nullptr;
184 bool enabled =
186 ASSERT_FALSE(enabled);
187 notify_semantics_enabled_latch.Signal();
188 };
189 notify_semantics_enabled_latch.Wait();
190
191 // Prepare notifyAccessibilityFeatures callback.
192 fml::AutoResetWaitableEvent notify_features_latch;
193 notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
194 Dart_Handle exception = nullptr;
195 bool enabled =
197 ASSERT_FALSE(enabled);
198 notify_features_latch.Signal();
199 };
200
201 // 2: Enable semantics. Wait for notifySemanticsEnabled(true).
202 fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
203 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
204 Dart_Handle exception = nullptr;
205 bool enabled =
207 ASSERT_TRUE(enabled);
208 notify_semantics_enabled_latch_2.Signal();
209 };
212 notify_semantics_enabled_latch_2.Wait();
213
214 // 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
215 notify_features_latch.Wait();
216
217 // 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
218 fml::AutoResetWaitableEvent notify_features_latch_2;
219 notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
220 Dart_Handle exception = nullptr;
221 bool enabled =
223 ASSERT_TRUE(enabled);
224 notify_features_latch_2.Signal();
225 };
229 notify_features_latch_2.Wait();
230
231 // 5: Wait for UpdateSemantics callback on platform (current) thread.
232 signal_native_latch.Wait();
234 semantics_update_latch.Wait();
235
236 // 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
237 fml::AutoResetWaitableEvent notify_semantics_action_latch;
238 notify_semantics_action_callback = [&](Dart_NativeArguments args) {
239 Dart_Handle exception = nullptr;
240 int64_t node_id =
242 ASSERT_EQ(42, node_id);
243
244 int64_t action_id =
246 ASSERT_EQ(static_cast<int32_t>(flutter::SemanticsAction::kTap), action_id);
247
248 std::vector<int64_t> semantic_args =
250 exception);
251 ASSERT_THAT(semantic_args, ElementsAre(2, 1));
252 notify_semantics_action_latch.Signal();
253 };
254 std::vector<uint8_t> bytes({2, 1});
256 engine.get(), 42, kFlutterSemanticsActionTap, &bytes[0], bytes.size());
258 notify_semantics_action_latch.Wait();
259
260 // 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
261 fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
262 notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
263 Dart_Handle exception = nullptr;
264 bool enabled =
266 ASSERT_FALSE(enabled);
267 notify_semantics_enabled_latch_3.Signal();
268 };
271 notify_semantics_enabled_latch_3.Wait();
272#endif // OS_FUCHSIA
273}
FlutterPlatformViewIdentifier platform_view_id
Definition embedder.h:1393

◆ TEST_F() [301/876]

flutter::testing::TEST_F ( EmbedderTest  ,
AddViewSchedulesFrame   
)

Test that adding a view schedules a frame.

Definition at line 1319 of file embedder_unittests.cc.

1319 {
1320 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1321 EmbedderConfigBuilder builder(context);
1322 builder.SetSoftwareRendererConfig();
1323 builder.SetDartEntrypoint("add_view_schedules_frame");
1325 context.AddNativeCallback(
1326 "SignalNativeTest",
1328 [&latch](Dart_NativeArguments args) { latch.Signal(); }));
1329
1330 fml::AutoResetWaitableEvent check_latch;
1331 context.AddNativeCallback(
1332 "SignalNativeCount",
1334 [&check_latch](Dart_NativeArguments args) { check_latch.Signal(); }));
1335
1336 auto engine = builder.LaunchEngine();
1337 ASSERT_TRUE(engine.is_valid());
1338
1339 // Wait for the application to attach the listener.
1340 latch.Wait();
1341
1342 FlutterWindowMetricsEvent metrics = {};
1343 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
1344 metrics.width = 800;
1345 metrics.height = 600;
1346 metrics.pixel_ratio = 1.0;
1347 metrics.view_id = 123;
1348
1351 info.view_id = 123;
1352 info.view_metrics = &metrics;
1353 info.add_view_callback = [](const FlutterAddViewResult* result) {
1354 EXPECT_TRUE(result->added);
1355 };
1356 ASSERT_EQ(FlutterEngineAddView(engine.get(), &info), kSuccess);
1357
1358 check_latch.Wait();
1359}
FLUTTER_EXPORT FlutterEngineResult FlutterEngineAddView(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterAddViewInfo *info)
Adds a view.
Definition embedder.cc:2187
size_t height
Physical height of the window.
Definition embedder.h:845
int64_t view_id
The view that this event is describing.
Definition embedder.h:863
double pixel_ratio
Scale factor for the physical screen.
Definition embedder.h:847
size_t width
Physical width of the window.
Definition embedder.h:843

◆ TEST_F() [302/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ArcEndCapsAreDrawnCorrectly   
)

Definition at line 2912 of file embedder_gl_unittests.cc.

2912 {
2913 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2914
2915 EmbedderConfigBuilder builder(context);
2916 builder.SetOpenGLRendererConfig(SkISize::Make(800, 1024));
2917 builder.SetCompositor();
2918 builder.SetDartEntrypoint("arc_end_caps_correct");
2919 builder.SetRenderTargetType(
2920 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
2921
2922 const auto root_surface_transformation = SkMatrix()
2923 .preScale(1.0, -1.0)
2924 .preTranslate(1024.0, -800.0)
2925 .preRotate(90.0);
2926
2927 context.SetRootSurfaceTransformation(root_surface_transformation);
2928
2929 auto engine = builder.LaunchEngine();
2930
2931 auto scene_image = context.GetNextSceneImage();
2932
2933 ASSERT_TRUE(engine.is_valid());
2934
2935 FlutterWindowMetricsEvent event = {};
2936 event.struct_size = sizeof(event);
2937 event.width = 800;
2938 event.height = 1024;
2939 event.pixel_ratio = 1.0;
2941 kSuccess);
2942
2943 ASSERT_TRUE(ImageMatchesFixture("arc_end_caps.png", scene_image));
2944}
SkMatrix & preRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:462
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:315

◆ TEST_F() [303/876]

flutter::testing::TEST_F ( EmbedderTest  ,
BackingStoresCorrespondToTheirViews   
)

Test that the backing store is created with the correct view ID, is used for the correct view, and is cached according to their views.

The test involves two frames:

  1. The first frame renders the implicit view and the second view.
  2. The second frame renders the implicit view and the third view.

The test verifies that:

  • Each backing store is created with a valid view ID.
  • Each backing store is presented for the view that it was created for.
  • Both frames render the expected sets of views.
  • By the end of frame 1, only 2 backing stores were created.
  • By the end of frame 2, only 3 backing stores were created. This ensures that the backing store for the 2nd view is not reused for the 3rd view.

Definition at line 1832 of file embedder_unittests.cc.

1832 {
1833 constexpr FlutterViewId kSecondViewId = 123;
1834 constexpr FlutterViewId kThirdViewId = 456;
1835 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1836
1837 EmbedderConfigBuilder builder(context);
1838 builder.SetDartEntrypoint("render_all_views");
1839 builder.SetSoftwareRendererConfig(SkISize::Make(800, 600));
1840 builder.SetCompositor();
1841
1843 context.GetCompositor().GetGrContext(),
1844 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
1845
1846 // The variables needed by the callbacks of the compositor.
1847 struct CompositorUserData {
1849 // Each latch is signaled when its corresponding view is presented.
1850 fml::AutoResetWaitableEvent latch_implicit;
1851 fml::AutoResetWaitableEvent latch_second;
1852 fml::AutoResetWaitableEvent latch_third;
1853 // Whether the respective view should be rendered in the frame.
1854 bool second_expected;
1855 bool third_expected;
1856 // The total number of backing stores created to verify caching.
1857 int backing_stores_created;
1858 };
1859 CompositorUserData compositor_user_data{
1860 .producer = &producer,
1861 .backing_stores_created = 0,
1862 };
1863
1864 builder.GetCompositor() = FlutterCompositor{
1865 .struct_size = sizeof(FlutterCompositor),
1866 .user_data = reinterpret_cast<void*>(&compositor_user_data),
1867 .create_backing_store_callback =
1868 [](const FlutterBackingStoreConfig* config,
1869 FlutterBackingStore* backing_store_out, void* user_data) {
1870 // Verify that the backing store comes with the correct view ID.
1871 EXPECT_TRUE(config->view_id == 0 ||
1872 config->view_id == kSecondViewId ||
1873 config->view_id == kThirdViewId);
1874 auto compositor_user_data =
1875 reinterpret_cast<CompositorUserData*>(user_data);
1876 compositor_user_data->backing_stores_created += 1;
1877 bool result = compositor_user_data->producer->Create(
1878 config, backing_store_out);
1879 // The created backing store has a user_data that records the view
1880 // that the store is created for.
1881 backing_store_out->user_data =
1882 reinterpret_cast<void*>(config->view_id);
1883 return result;
1884 },
1885 .collect_backing_store_callback = [](const FlutterBackingStore* renderer,
1886 void* user_data) { return true; },
1887 .present_layers_callback = nullptr,
1888 .avoid_backing_store_cache = false,
1889 .present_view_callback =
1890 [](const FlutterPresentViewInfo* info) {
1891 EXPECT_EQ(info->layers_count, 1u);
1892 // Verify that the given layer's backing store has the same view ID
1893 // as the target view.
1894 int64_t store_view_id = reinterpret_cast<int64_t>(
1895 info->layers[0]->backing_store->user_data);
1896 EXPECT_EQ(store_view_id, info->view_id);
1897 auto compositor_user_data =
1898 reinterpret_cast<CompositorUserData*>(info->user_data);
1899 // Verify that the respective views are rendered.
1900 switch (info->view_id) {
1901 case 0:
1902 compositor_user_data->latch_implicit.Signal();
1903 break;
1904 case kSecondViewId:
1905 EXPECT_TRUE(compositor_user_data->second_expected);
1906 compositor_user_data->latch_second.Signal();
1907 break;
1908 case kThirdViewId:
1909 EXPECT_TRUE(compositor_user_data->third_expected);
1910 compositor_user_data->latch_third.Signal();
1911 break;
1912 default:
1914 }
1915 return true;
1916 },
1917 };
1918
1919 compositor_user_data.second_expected = true;
1920 compositor_user_data.third_expected = false;
1921
1922 /*=== First frame ===*/
1923
1924 auto engine = builder.LaunchEngine();
1925 ASSERT_TRUE(engine.is_valid());
1926
1927 // Give the implicit view a non-zero size so that it renders something.
1928 FlutterWindowMetricsEvent metrics_implicit = {
1930 .width = 800,
1931 .height = 600,
1932 .pixel_ratio = 1.0,
1933 .view_id = 0,
1934 };
1935 ASSERT_EQ(
1936 FlutterEngineSendWindowMetricsEvent(engine.get(), &metrics_implicit),
1937 kSuccess);
1938
1939 // Add the second view.
1940 FlutterWindowMetricsEvent metrics_add = {
1942 .width = 800,
1943 .height = 600,
1944 .pixel_ratio = 1.0,
1945 .view_id = kSecondViewId,
1946 };
1947
1948 FlutterAddViewInfo add_view_info = {};
1949 add_view_info.struct_size = sizeof(FlutterAddViewInfo);
1950 add_view_info.view_id = kSecondViewId;
1951 add_view_info.view_metrics = &metrics_add;
1952 add_view_info.add_view_callback = [](const FlutterAddViewResult* result) {
1953 ASSERT_TRUE(result->added);
1954 };
1955
1956 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_view_info), kSuccess);
1957
1958 compositor_user_data.latch_implicit.Wait();
1959 compositor_user_data.latch_second.Wait();
1960
1961 /*=== Second frame ===*/
1962
1963 compositor_user_data.second_expected = false;
1964 compositor_user_data.third_expected = true;
1965 EXPECT_EQ(compositor_user_data.backing_stores_created, 2);
1966
1967 // Remove the second view
1968 FlutterRemoveViewInfo remove_view_info = {};
1969 remove_view_info.struct_size = sizeof(FlutterRemoveViewInfo);
1970 remove_view_info.view_id = kSecondViewId;
1971 remove_view_info.remove_view_callback =
1972 [](const FlutterRemoveViewResult* result) {
1973 ASSERT_TRUE(result->removed);
1974 };
1975 ASSERT_EQ(FlutterEngineRemoveView(engine.get(), &remove_view_info), kSuccess);
1976
1977 // Add the third view.
1978 add_view_info.view_id = kThirdViewId;
1979 metrics_add.view_id = kThirdViewId;
1980 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_view_info), kSuccess);
1981 // Adding the view should have scheduled a frame.
1982
1983 compositor_user_data.latch_implicit.Wait();
1984 compositor_user_data.latch_third.Wait();
1985 EXPECT_EQ(compositor_user_data.backing_stores_created, 3);
1986}
FLUTTER_EXPORT FlutterEngineResult FlutterEngineRemoveView(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterRemoveViewInfo *info)
Removes a view.
Definition embedder.cc:2248
FlutterAddViewCallback add_view_callback
Definition embedder.h:911
FlutterViewId view_id
The identifier for the view to add. This must be unique.
Definition embedder.h:891
const FlutterWindowMetricsEvent * view_metrics
Definition embedder.h:896
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
Definition embedder.h:1885
FlutterRemoveViewCallback remove_view_callback
Definition embedder.h:959
FlutterViewId view_id
Definition embedder.h:942

◆ TEST_F() [304/876]

flutter::testing::TEST_F ( EmbedderTest  ,
BackToBackKeyEventResponsesCorrectlyInvoked   
)

Definition at line 3220 of file embedder_unittests.cc.

3220 {
3222 fml::AutoResetWaitableEvent sync_latch;
3224
3225 // One of the threads that the callback will be posted to is the platform
3226 // thread. So we cannot wait for assertions to complete on the platform
3227 // thread. Create a new thread to manage the engine instance and wait for
3228 // assertions on the test thread.
3229 auto platform_task_runner = CreateNewThread("platform_thread");
3230
3231 platform_task_runner->PostTask([&]() {
3232 auto& context =
3233 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3234
3235 EmbedderConfigBuilder builder(context);
3236 builder.SetSoftwareRendererConfig();
3237 builder.SetDartEntrypoint("key_data_echo");
3238 context.AddNativeCallback(
3239 "SignalNativeTest",
3241 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
3242
3243 context.AddNativeCallback(
3244 "EchoKeyEvent", CREATE_NATIVE_ENTRY([](Dart_NativeArguments args) {}));
3245
3246 engine = builder.LaunchEngine();
3247 ASSERT_TRUE(engine.is_valid());
3248
3249 sync_latch.Signal();
3250 });
3251 sync_latch.Wait();
3252 ready.Wait();
3253
3254 // Dispatch a single event
3255 FlutterKeyEvent event{
3256 .struct_size = sizeof(FlutterKeyEvent),
3257 .timestamp = 1000,
3259 .physical = 0x00070005,
3260 .logical = 0x00000000062,
3261 .character = nullptr,
3262 .synthesized = false,
3264 };
3265
3266 // Dispatch two events back to back, using the same callback on different
3267 // user_data
3268 KeyEventUserData user_data2{
3269 .latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3270 .returned = false,
3271 };
3272 KeyEventUserData user_data3{
3273 .latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3274 .returned = false,
3275 };
3276 auto callback23 = [](bool handled, void* untyped_user_data) {
3277 KeyEventUserData* user_data =
3278 reinterpret_cast<KeyEventUserData*>(untyped_user_data);
3279 EXPECT_EQ(handled, false);
3280 user_data->returned = true;
3281 user_data->latch->Signal();
3282 };
3283 platform_task_runner->PostTask([&]() {
3284 FlutterEngineSendKeyEvent(engine.get(), &event, callback23, &user_data2);
3285 FlutterEngineSendKeyEvent(engine.get(), &event, callback23, &user_data3);
3286 });
3287 user_data2.latch->Wait();
3288 user_data3.latch->Wait();
3289
3290 EXPECT_TRUE(user_data2.returned);
3291 EXPECT_TRUE(user_data3.returned);
3292
3293 fml::AutoResetWaitableEvent shutdown_latch;
3294 platform_task_runner->PostTask([&]() {
3295 engine.reset();
3296 shutdown_latch.Signal();
3297 });
3298 shutdown_latch.Wait();
3299}
FlutterEngineResult FlutterEngineSendKeyEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Sends a key event to the engine. The framework will decide whether to handle this event in a synchron...
Definition embedder.cc:2575
@ kFlutterKeyEventDeviceTypeKeyboard
Definition embedder.h:1079
size_t struct_size
The size of this struct. Must be sizeof(FlutterKeyEvent).
Definition embedder.h:1110

◆ TEST_F() [305/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanAddView   
)

Test that a view can be added to a running engine.

Definition at line 1271 of file embedder_unittests.cc.

1271 {
1272 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1273 EmbedderConfigBuilder builder(context);
1274 builder.SetSoftwareRendererConfig();
1275 builder.SetDartEntrypoint("window_metrics_event_all_view_ids");
1276
1277 fml::AutoResetWaitableEvent ready_latch, message_latch;
1278 context.AddNativeCallback(
1279 "SignalNativeTest",
1281 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
1282
1283 std::string message;
1284 context.AddNativeCallback("SignalNativeMessage",
1286 message =
1289 message_latch.Signal();
1290 }));
1291
1292 auto engine = builder.LaunchEngine();
1293 ASSERT_TRUE(engine.is_valid());
1294
1295 ready_latch.Wait();
1296
1297 FlutterWindowMetricsEvent metrics = {};
1298 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
1299 metrics.width = 800;
1300 metrics.height = 600;
1301 metrics.pixel_ratio = 1.0;
1302 metrics.view_id = 123;
1303
1306 info.view_id = 123;
1307 info.view_metrics = &metrics;
1308 info.add_view_callback = [](const FlutterAddViewResult* result) {
1309 EXPECT_TRUE(result->added);
1310 };
1311 ASSERT_EQ(FlutterEngineAddView(engine.get(), &info), kSuccess);
1312 message_latch.Wait();
1313 ASSERT_EQ("View IDs: [0, 123]", message);
1314}

◆ TEST_F() [306/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanCreateAndCollectAValidElfSource   
)

Definition at line 2385 of file embedder_unittests.cc.

2385 {
2386 if (!DartVM::IsRunningPrecompiledCode()) {
2387 GTEST_SKIP();
2388 return;
2389 }
2390 FlutterEngineAOTDataSource data_in = {};
2391 FlutterEngineAOTData data_out = nullptr;
2392
2393 // Collecting a null object should be allowed
2394 ASSERT_EQ(FlutterEngineCollectAOTData(data_out), kSuccess);
2395
2396 const auto elf_path =
2397 fml::paths::JoinPaths({GetFixturesPath(), kDefaultAOTAppELFFileName});
2398
2400 data_in.elf_path = elf_path.c_str();
2401
2402 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kSuccess);
2403 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2404 ASSERT_EQ(data_in.elf_path, elf_path.c_str());
2405 ASSERT_NE(data_out, nullptr);
2406
2407 ASSERT_EQ(FlutterEngineCollectAOTData(data_out), kSuccess);
2408}
FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data)
Collects the AOT data.
Definition embedder.cc:1476
FlutterEngineResult FlutterEngineCreateAOTData(const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out)
Creates the necessary data structures to launch a Flutter Dart application in AOT mode....
Definition embedder.cc:1422
@ kFlutterEngineAOTDataSourceTypeElfPath
Definition embedder.h:2108
FlutterEngineAOTDataSourceType type
Definition embedder.h:2114
const char * elf_path
Absolute path to an ELF library file.
Definition embedder.h:2117

◆ TEST_F() [307/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanCreateAndCollectCallbacks   
)

Creates a platform message response callbacks, does NOT send them, and immediately collects the same.

Definition at line 330 of file embedder_unittests.cc.

330 {
331 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
332 EmbedderConfigBuilder builder(context);
333 builder.SetSoftwareRendererConfig();
334 builder.SetDartEntrypoint("platform_messages_response");
335 context.AddNativeCallback(
336 "SignalNativeTest",
338
339 auto engine = builder.LaunchEngine();
340 ASSERT_TRUE(engine.is_valid());
341
342 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
343 auto callback = [](const uint8_t* data, size_t size,
344 void* user_data) -> void {};
346 engine.get(), callback, nullptr, &response_handle);
347 ASSERT_EQ(result, kSuccess);
348 ASSERT_NE(response_handle, nullptr);
349
351 response_handle);
352 ASSERT_EQ(result, kSuccess);
353}
FlutterEngineResult FlutterPlatformMessageCreateResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterDataCallback data_callback, void *user_data, FlutterPlatformMessageResponseHandle **response_out)
Creates a platform message response handle that allows the embedder to set a native callback for a re...
Definition embedder.cc:2681
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
Collects the handle created using FlutterPlatformMessageCreateResponseHandle.
Definition embedder.cc:2716

◆ TEST_F() [308/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanCreateEmbedderWithCustomRenderTaskRunner   
)

Asserts that embedders can provide a task runner for the render thread.

Definition at line 2065 of file embedder_gl_unittests.cc.

2065 {
2066 std::mutex engine_mutex;
2068 fml::AutoResetWaitableEvent task_latch;
2069 bool task_executed = false;
2070 EmbedderTestTaskRunner render_task_runner(
2071 CreateNewThread("custom_render_thread"), [&](FlutterTask task) {
2072 std::scoped_lock engine_lock(engine_mutex);
2073 if (engine.is_valid()) {
2074 ASSERT_EQ(FlutterEngineRunTask(engine.get(), &task), kSuccess);
2075 task_executed = true;
2076 task_latch.Signal();
2077 }
2078 });
2079 EmbedderConfigBuilder builder(
2080 GetEmbedderContext(EmbedderTestContextType::kOpenGLContext));
2081 builder.SetDartEntrypoint("can_render_scene_without_custom_compositor");
2082 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
2083 builder.SetRenderTaskRunner(
2084 &render_task_runner.GetFlutterTaskRunnerDescription());
2085
2086 {
2087 std::scoped_lock lock(engine_mutex);
2088 engine = builder.InitializeEngine();
2089 }
2090
2091 ASSERT_EQ(FlutterEngineRunInitialized(engine.get()), kSuccess);
2092
2093 ASSERT_TRUE(engine.is_valid());
2094
2095 FlutterWindowMetricsEvent event = {};
2096 event.struct_size = sizeof(event);
2097 event.width = 800;
2098 event.height = 600;
2099 event.pixel_ratio = 1.0;
2101 kSuccess);
2102 task_latch.Wait();
2103 ASSERT_TRUE(task_executed);
2104 ASSERT_EQ(FlutterEngineDeinitialize(engine.get()), kSuccess);
2105
2106 {
2107 std::scoped_lock engine_lock(engine_mutex);
2108 engine.reset();
2109 }
2110}
A task runner that we expect the embedder to provide but whose implementation is a real FML task runn...
FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterTask *task)
Inform the engine to run the specified task. This task has been given to the engine via the FlutterTa...
Definition embedder.cc:2953
FLUTTER_EXPORT FlutterEngineResult FlutterEngineDeinitialize(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Stops running the Flutter engine instance. After this call, the embedder is also guaranteed that no m...
Definition embedder.cc:2291
FlutterEngineResult FlutterEngineRunInitialized(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Runs an initialized engine instance. An engine can be initialized via FlutterEngineInitialize....
Definition embedder.cc:2148

◆ TEST_F() [309/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanCreateInitializedEngine   
)

Test that an engine can be initialized but not run.

Definition at line 1213 of file embedder_unittests.cc.

1213 {
1214 EmbedderConfigBuilder builder(
1215 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
1216 builder.SetSoftwareRendererConfig();
1217 auto engine = builder.InitializeEngine();
1218 ASSERT_TRUE(engine.is_valid());
1219 engine.reset();
1220}

◆ TEST_F() [310/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanCreateOpenGLRenderingEngine   
)

Definition at line 54 of file embedder_gl_unittests.cc.

54 {
56 GetEmbedderContext(EmbedderTestContextType::kOpenGLContext));
57 builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
58 auto engine = builder.LaunchEngine();
59 ASSERT_TRUE(engine.is_valid());
60}

◆ TEST_F() [311/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanDeinitializeAnEngine   
)

Test that an engine can be deinitialized.

Definition at line 1240 of file embedder_unittests.cc.

1240 {
1241 EmbedderConfigBuilder builder(
1242 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
1243 builder.SetSoftwareRendererConfig();
1244 auto engine = builder.InitializeEngine();
1245 ASSERT_TRUE(engine.is_valid());
1246 ASSERT_EQ(FlutterEngineRunInitialized(engine.get()), kSuccess);
1247 // Cannot re-run an already running engine.
1249 ASSERT_EQ(FlutterEngineDeinitialize(engine.get()), kSuccess);
1250 // It is ok to deinitialize an engine multiple times.
1251 ASSERT_EQ(FlutterEngineDeinitialize(engine.get()), kSuccess);
1252
1253 // Sending events to a deinitialized engine fails.
1254 FlutterWindowMetricsEvent event = {};
1255 event.struct_size = sizeof(event);
1256 event.width = 800;
1257 event.height = 600;
1258 event.pixel_ratio = 1.0;
1259 event.physical_view_inset_top = 0.0;
1260 event.physical_view_inset_right = 0.0;
1261 event.physical_view_inset_bottom = 0.0;
1262 event.physical_view_inset_left = 0.0;
1265 engine.reset();
1266}

◆ TEST_F() [312/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanGetVulkanEmbedderContext   
)

Definition at line 49 of file embedder_gl_unittests.cc.

49 {
50 auto& context = GetEmbedderContext(EmbedderTestContextType::kVulkanContext);
51 EmbedderConfigBuilder builder(context);
52}

◆ TEST_F() [313/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanInvokeCustomEntrypoint   
)

Definition at line 91 of file embedder_unittests.cc.

91 {
92 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
93 static fml::AutoResetWaitableEvent latch;
95 latch.Signal();
96 };
97 context.AddNativeCallback("SayHiFromCustomEntrypoint", entrypoint);
98 EmbedderConfigBuilder builder(context);
99 builder.SetSoftwareRendererConfig();
100 builder.SetDartEntrypoint("customEntrypoint");
101 auto engine = builder.LaunchEngine();
102 latch.Wait();
103 ASSERT_TRUE(engine.is_valid());
104}
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition dart_api.h:3198

◆ TEST_F() [314/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanInvokeCustomEntrypointMacro   
)

Definition at line 106 of file embedder_unittests.cc.

106 {
107 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
108
112
113 // Can be defined separately.
114 auto entry1 = [&latch1](Dart_NativeArguments args) {
115 FML_LOG(INFO) << "In Callback 1";
116 latch1.Signal();
117 };
118 auto native_entry1 = CREATE_NATIVE_ENTRY(entry1);
119 context.AddNativeCallback("SayHiFromCustomEntrypoint1", native_entry1);
120
121 // Can be wrapped in the args.
122 auto entry2 = [&latch2](Dart_NativeArguments args) {
123 FML_LOG(INFO) << "In Callback 2";
124 latch2.Signal();
125 };
126 context.AddNativeCallback("SayHiFromCustomEntrypoint2",
127 CREATE_NATIVE_ENTRY(entry2));
128
129 // Everything can be inline.
130 context.AddNativeCallback(
131 "SayHiFromCustomEntrypoint3",
133 FML_LOG(INFO) << "In Callback 3";
134 latch3.Signal();
135 }));
136
137 EmbedderConfigBuilder builder(context);
138 builder.SetSoftwareRendererConfig();
139 builder.SetDartEntrypoint("customEntrypoint1");
140 auto engine = builder.LaunchEngine();
141 latch1.Wait();
142 latch2.Wait();
143 latch3.Wait();
144 ASSERT_TRUE(engine.is_valid());
145}

◆ TEST_F() [315/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanLaunchAndShutdownWithAValidElfSource   
)

Definition at line 2410 of file embedder_unittests.cc.

2410 {
2411 if (!DartVM::IsRunningPrecompiledCode()) {
2412 GTEST_SKIP();
2413 return;
2414 }
2415 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2416
2418 context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
2419
2420 EmbedderConfigBuilder builder(
2421 context,
2422 EmbedderConfigBuilder::InitializationPreference::kAOTDataInitialize);
2423
2424 builder.SetSoftwareRendererConfig();
2425
2426 auto engine = builder.LaunchEngine();
2427 ASSERT_TRUE(engine.is_valid());
2428
2429 // Wait for the root isolate to launch.
2430 latch.Wait();
2431 engine.reset();
2432}

◆ TEST_F() [316/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanLaunchAndShutdownWithValidProjectArgs   
)

Definition at line 66 of file embedder_unittests.cc.

66 {
67 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
69 context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
70 EmbedderConfigBuilder builder(context);
71 builder.SetSoftwareRendererConfig();
72 auto engine = builder.LaunchEngine();
73 ASSERT_TRUE(engine.is_valid());
74 // Wait for the root isolate to launch.
75 latch.Wait();
76 engine.reset();
77}

◆ TEST_F() [317/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanLaunchEngineWithInvalidJITSnapshots   
)

The embedder must be able to run in JIT mode even when the specfied snapshots are invalid. It should be able to resolve them as it would when the snapshots are not specified.

Definition at line 2617 of file embedder_unittests.cc.

2617 {
2618 // This test is only relevant in JIT mode.
2619 if (DartVM::IsRunningPrecompiledCode()) {
2620 GTEST_SKIP();
2621 return;
2622 }
2623
2624 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2625 EmbedderConfigBuilder builder(context);
2626 builder.SetSoftwareRendererConfig();
2627
2628 // Explicitly define the locations of the JIT snapshots
2629 builder.GetProjectArgs().isolate_snapshot_data =
2630 reinterpret_cast<const uint8_t*>("invalid_snapshot_data");
2631 builder.GetProjectArgs().isolate_snapshot_instructions =
2632 reinterpret_cast<const uint8_t*>("invalid_snapshot_instructions");
2633
2634 auto engine = builder.LaunchEngine();
2635 ASSERT_TRUE(engine.is_valid());
2637}

◆ TEST_F() [318/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanLaunchEngineWithSomeSpecifiedJITSnapshots   
)

The embedder must be able to run in JIT mode when only some snapshots are specified.

Definition at line 2584 of file embedder_unittests.cc.

2584 {
2585 // This test is only relevant in JIT mode.
2586 if (DartVM::IsRunningPrecompiledCode()) {
2587 GTEST_SKIP();
2588 return;
2589 }
2590
2591 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2592 EmbedderConfigBuilder builder(context);
2593 builder.SetSoftwareRendererConfig();
2594
2595 // Construct the location of valid JIT snapshots.
2596 const std::string src_path = GetSourcePath();
2597 const std::string vm_snapshot_data =
2598 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_DATA});
2599 const std::string vm_snapshot_instructions =
2600 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_INSTRUCTIONS});
2601
2602 // Explicitly define the locations of the JIT snapshots
2603 builder.GetProjectArgs().vm_snapshot_data =
2604 reinterpret_cast<const uint8_t*>(vm_snapshot_data.c_str());
2605 builder.GetProjectArgs().vm_snapshot_instructions =
2606 reinterpret_cast<const uint8_t*>(vm_snapshot_instructions.c_str());
2607
2608 auto engine = builder.LaunchEngine();
2609 ASSERT_TRUE(engine.is_valid());
2610}
const uint8_t * vm_snapshot_data
Definition main_impl.cc:56
const uint8_t * vm_snapshot_instructions
Definition main_impl.cc:57

◆ TEST_F() [319/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanLaunchEngineWithSpecifiedJITSnapshots   
)

The embedder must be able to run explicitly specified snapshots in JIT mode (i.e. when those are present in known locations).

Definition at line 2544 of file embedder_unittests.cc.

2544 {
2545 // This test is only relevant in JIT mode.
2546 if (DartVM::IsRunningPrecompiledCode()) {
2547 GTEST_SKIP();
2548 return;
2549 }
2550
2551 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2552 EmbedderConfigBuilder builder(context);
2553 builder.SetSoftwareRendererConfig();
2554
2555 // Construct the location of valid JIT snapshots.
2556 const std::string src_path = GetSourcePath();
2557 const std::string vm_snapshot_data =
2558 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_DATA});
2559 const std::string vm_snapshot_instructions =
2560 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_INSTRUCTIONS});
2561 const std::string isolate_snapshot_data =
2562 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_DATA});
2563 const std::string isolate_snapshot_instructions =
2564 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_INSTRUCTIONS});
2565
2566 // Explicitly define the locations of the JIT snapshots
2567 builder.GetProjectArgs().vm_snapshot_data =
2568 reinterpret_cast<const uint8_t*>(vm_snapshot_data.c_str());
2569 builder.GetProjectArgs().vm_snapshot_instructions =
2570 reinterpret_cast<const uint8_t*>(vm_snapshot_instructions.c_str());
2571 builder.GetProjectArgs().isolate_snapshot_data =
2572 reinterpret_cast<const uint8_t*>(isolate_snapshot_data.c_str());
2573 builder.GetProjectArgs().isolate_snapshot_instructions =
2574 reinterpret_cast<const uint8_t*>(isolate_snapshot_instructions.c_str());
2575
2576 auto engine = builder.LaunchEngine();
2577 ASSERT_TRUE(engine.is_valid());
2578}
const uint8_t * isolate_snapshot_data
const uint8_t * isolate_snapshot_instructions

◆ TEST_F() [320/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanLaunchEngineWithUnspecifiedJITSnapshots   
)

The embedder must be able to launch even when the snapshots are not explicitly defined in JIT mode. It must be able to resolve those snapshots.

Definition at line 2643 of file embedder_unittests.cc.

2643 {
2644 // This test is only relevant in JIT mode.
2645 if (DartVM::IsRunningPrecompiledCode()) {
2646 GTEST_SKIP();
2647 return;
2648 }
2649
2650 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2651 EmbedderConfigBuilder builder(context);
2652 builder.SetSoftwareRendererConfig();
2653
2654 ASSERT_EQ(builder.GetProjectArgs().vm_snapshot_data, nullptr);
2655 ASSERT_EQ(builder.GetProjectArgs().vm_snapshot_instructions, nullptr);
2656 ASSERT_EQ(builder.GetProjectArgs().isolate_snapshot_data, nullptr);
2657 ASSERT_EQ(builder.GetProjectArgs().isolate_snapshot_instructions, nullptr);
2658
2659 auto engine = builder.LaunchEngine();
2660 ASSERT_TRUE(engine.is_valid());
2661}

◆ TEST_F() [321/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CannotAddDuplicateViews   
)

Test that a view cannot be added if its ID already exists.

Definition at line 1445 of file embedder_unittests.cc.

1445 {
1446 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1447 EmbedderConfigBuilder builder(context);
1448 builder.SetSoftwareRendererConfig();
1449 builder.SetDartEntrypoint("window_metrics_event_all_view_ids");
1450
1451 fml::AutoResetWaitableEvent ready_latch, message_latch;
1452 context.AddNativeCallback(
1453 "SignalNativeTest",
1455 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
1456
1457 std::string message;
1458 context.AddNativeCallback("SignalNativeMessage",
1460 message =
1463 message_latch.Signal();
1464 }));
1465
1466 auto engine = builder.LaunchEngine();
1467 ASSERT_TRUE(engine.is_valid());
1468
1469 ready_latch.Wait();
1470
1471 // Add view 123.
1472 struct Captures {
1473 std::atomic<int> count = 0;
1474 fml::AutoResetWaitableEvent failure_latch;
1475 };
1476 Captures captures;
1477
1478 FlutterWindowMetricsEvent metrics = {};
1479 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
1480 metrics.width = 800;
1481 metrics.height = 600;
1482 metrics.pixel_ratio = 1.0;
1483 metrics.view_id = 123;
1484
1485 FlutterAddViewInfo add_info = {};
1486 add_info.struct_size = sizeof(FlutterAddViewInfo);
1487 add_info.view_id = 123;
1488 add_info.view_metrics = &metrics;
1489 add_info.user_data = &captures;
1490 add_info.add_view_callback = [](const FlutterAddViewResult* result) {
1491 auto captures = reinterpret_cast<Captures*>(result->user_data);
1492
1493 int count = captures->count.fetch_add(1);
1494
1495 if (count == 0) {
1496 ASSERT_TRUE(result->added);
1497 } else {
1498 EXPECT_FALSE(result->added);
1499 captures->failure_latch.Signal();
1500 }
1501 };
1502 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_info), kSuccess);
1503 message_latch.Wait();
1504 ASSERT_EQ(message, "View IDs: [0, 123]");
1505 ASSERT_FALSE(captures.failure_latch.IsSignaledForTest());
1506
1507 // Add view 123 a second time.
1508 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_info), kSuccess);
1509 captures.failure_latch.Wait();
1510 ASSERT_EQ(captures.count, 2);
1511 ASSERT_FALSE(message_latch.IsSignaledForTest());
1512}

◆ TEST_F() [322/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CannotProvideMultipleSemanticsCallbacks   
)

Definition at line 34 of file embedder_a11y_unittests.cc.

34 {
35 {
37 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
38 builder.SetSoftwareRendererConfig();
39 builder.GetProjectArgs().update_semantics_callback =
40 [](const FlutterSemanticsUpdate* update, void* user_data) {};
41 builder.GetProjectArgs().update_semantics_callback2 =
42 [](const FlutterSemanticsUpdate2* update, void* user_data) {};
43 auto engine = builder.InitializeEngine();
44 ASSERT_FALSE(engine.is_valid());
45 engine.reset();
46 }
47
48 {
49 EmbedderConfigBuilder builder(
50 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
51 builder.SetSoftwareRendererConfig();
52 builder.GetProjectArgs().update_semantics_callback2 =
53 [](const FlutterSemanticsUpdate2* update, void* user_data) {};
54 builder.GetProjectArgs().update_semantics_node_callback =
55 [](const FlutterSemanticsNode* update, void* user_data) {};
56 builder.GetProjectArgs().update_semantics_custom_action_callback =
58 auto engine = builder.InitializeEngine();
59 ASSERT_FALSE(engine.is_valid());
60 engine.reset();
61 }
62
63 {
64 EmbedderConfigBuilder builder(
65 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
66 builder.SetSoftwareRendererConfig();
67 builder.GetProjectArgs().update_semantics_callback =
68 [](const FlutterSemanticsUpdate* update, void* user_data) {};
69 builder.GetProjectArgs().update_semantics_node_callback =
70 [](const FlutterSemanticsNode* update, void* user_data) {};
71 builder.GetProjectArgs().update_semantics_custom_action_callback =
73 auto engine = builder.InitializeEngine();
74 ASSERT_FALSE(engine.is_valid());
75 engine.reset();
76 }
77
78 {
79 EmbedderConfigBuilder builder(
80 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
81 builder.SetSoftwareRendererConfig();
82 builder.GetProjectArgs().update_semantics_callback2 =
83 [](const FlutterSemanticsUpdate2* update, void* user_data) {};
84 builder.GetProjectArgs().update_semantics_callback =
85 [](const FlutterSemanticsUpdate* update, void* user_data) {};
86 builder.GetProjectArgs().update_semantics_node_callback =
87 [](const FlutterSemanticsNode* update, void* user_data) {};
88 builder.GetProjectArgs().update_semantics_custom_action_callback =
90 auto engine = builder.InitializeEngine();
91 ASSERT_FALSE(engine.is_valid());
92 engine.reset();
93 }
94}

◆ TEST_F() [323/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CannotRemoveImplicitView   
)

The implicit view is a special view that the engine and framework assume can always be rendered to. Test that this view cannot be removed.

Definition at line 1425 of file embedder_unittests.cc.

1425 {
1426 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1427 EmbedderConfigBuilder builder(context);
1428 builder.SetSoftwareRendererConfig();
1429
1430 auto engine = builder.LaunchEngine();
1431 ASSERT_TRUE(engine.is_valid());
1432
1435 info.view_id = kFlutterImplicitViewId;
1436 info.remove_view_callback = [](const FlutterRemoveViewResult* result) {
1437 FAIL();
1438 };
1440}
constexpr int64_t kFlutterImplicitViewId
Definition constants.h:35

◆ TEST_F() [324/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CannotRemoveUnknownView   
)

Test that attempting to remove a view that does not exist fails as expected.

Definition at line 1582 of file embedder_unittests.cc.

1582 {
1583 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1584 EmbedderConfigBuilder builder(context);
1585 builder.SetSoftwareRendererConfig();
1586
1587 auto engine = builder.LaunchEngine();
1588 ASSERT_TRUE(engine.is_valid());
1589
1593 info.view_id = 123;
1594 info.user_data = &latch;
1595 info.remove_view_callback = [](const FlutterRemoveViewResult* result) {
1596 EXPECT_FALSE(result->removed);
1597 reinterpret_cast<fml::AutoResetWaitableEvent*>(result->user_data)->Signal();
1598 };
1599 ASSERT_EQ(FlutterEngineRemoveView(engine.get(), &info), kSuccess);
1600 latch.Wait();
1601}

◆ TEST_F() [325/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanPostTaskToAllNativeThreads   
)

Definition at line 2221 of file embedder_unittests.cc.

2221 {
2223 size_t worker_count = 0;
2224 fml::AutoResetWaitableEvent sync_latch;
2225
2226 // One of the threads that the callback will be posted to is the platform
2227 // thread. So we cannot wait for assertions to complete on the platform
2228 // thread. Create a new thread to manage the engine instance and wait for
2229 // assertions on the test thread.
2230 auto platform_task_runner = CreateNewThread("platform_thread");
2231
2232 platform_task_runner->PostTask([&]() {
2233 auto& context =
2234 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2235
2236 EmbedderConfigBuilder builder(context);
2237 builder.SetSoftwareRendererConfig();
2238
2239 engine = builder.LaunchEngine();
2240
2241 ASSERT_TRUE(engine.is_valid());
2242
2243 worker_count = ToEmbedderEngine(engine.get())
2244 ->GetShell()
2245 .GetDartVM()
2247 ->GetWorkerCount();
2248
2249 sync_latch.Signal();
2250 });
2251
2252 sync_latch.Wait();
2253
2254 const auto engine_threads_count = worker_count + 4u;
2255
2256 struct Captures {
2257 // Waits the adequate number of callbacks to fire.
2258 fml::CountDownLatch latch;
2259
2260 // This class will be accessed from multiple threads concurrently to track
2261 // thread specific information that is later checked. All updates to fields
2262 // in this struct must be made with this mutex acquired.
2263
2264 std::mutex captures_mutex;
2265 // Ensures that the expect number of distinct threads were serviced.
2266 std::set<std::thread::id> thread_ids;
2267
2268 size_t platform_threads_count = 0;
2269 size_t render_threads_count = 0;
2270 size_t ui_threads_count = 0;
2271 size_t worker_threads_count = 0;
2272
2273 explicit Captures(size_t count) : latch(count) {}
2274 };
2275
2276 Captures captures(engine_threads_count);
2277
2278 platform_task_runner->PostTask([&]() {
2280 engine.get(),
2281 [](FlutterNativeThreadType type, void* baton) {
2282 auto captures = reinterpret_cast<Captures*>(baton);
2283 {
2284 std::scoped_lock lock(captures->captures_mutex);
2285 switch (type) {
2286 case kFlutterNativeThreadTypeRender:
2287 captures->render_threads_count++;
2288 break;
2289 case kFlutterNativeThreadTypeWorker:
2290 captures->worker_threads_count++;
2291 break;
2292 case kFlutterNativeThreadTypeUI:
2293 captures->ui_threads_count++;
2294 break;
2295 case kFlutterNativeThreadTypePlatform:
2296 captures->platform_threads_count++;
2297 break;
2298 }
2299 captures->thread_ids.insert(std::this_thread::get_id());
2300 }
2301 captures->latch.CountDown();
2302 },
2303 &captures),
2304 kSuccess);
2305 });
2306
2307 captures.latch.Wait();
2308 ASSERT_EQ(captures.thread_ids.size(), engine_threads_count);
2309 ASSERT_EQ(captures.platform_threads_count, 1u);
2310 ASSERT_EQ(captures.render_threads_count, 1u);
2311 ASSERT_EQ(captures.ui_threads_count, 1u);
2312 ASSERT_EQ(captures.worker_threads_count, worker_count + 1u /* for IO */);
2313
2314 platform_task_runner->PostTask([&]() {
2315 engine.reset();
2316 sync_latch.Signal();
2317 });
2318 sync_latch.Wait();
2319
2320 // The engine should have already been destroyed on the platform task runner.
2321 ASSERT_FALSE(engine.is_valid());
2322}
std::shared_ptr< fml::ConcurrentMessageLoop > GetConcurrentMessageLoop()
The concurrent message loop hosts threads that are used by the engine to perform tasks long running b...
Definition dart_vm.cc:550
DartVM * GetDartVM()
Get a pointer to the Dart VM used by this running shell instance.
Definition shell.cc:828
FlutterEngineResult FlutterEnginePostCallbackOnAllNativeThreads(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterNativeThreadCallback callback, void *user_data)
Schedule a callback to be run on all engine managed threads. The engine will attempt to service this ...
Definition embedder.cc:3207
FlutterNativeThreadType
Definition embedder.h:2084
flutter::EmbedderEngine * ToEmbedderEngine(const FlutterEngine &engine)

◆ TEST_F() [326/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanQueryDartAOTMode   
)

Definition at line 2074 of file embedder_unittests.cc.

2074 {
2077}
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
Definition dart_vm.cc:205
bool FlutterEngineRunsAOTCompiledDartCode(void)
Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading re...
Definition embedder.cc:3057

◆ TEST_F() [327/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanReloadSystemFonts   
)

Definition at line 276 of file embedder_unittests.cc.

276 {
277 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
278 EmbedderConfigBuilder builder(context);
279 builder.SetSoftwareRendererConfig();
280 auto engine = builder.LaunchEngine();
281 ASSERT_TRUE(engine.is_valid());
282
284 ASSERT_EQ(result, kSuccess);
285}
FlutterEngineResult FlutterEngineReloadSystemFonts(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Reloads the system fonts in engine.
Definition embedder.cc:2896

◆ TEST_F() [328/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRemoveView   
)

Test that a view that was added can be removed.

Definition at line 1364 of file embedder_unittests.cc.

1364 {
1365 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1366 EmbedderConfigBuilder builder(context);
1367 builder.SetSoftwareRendererConfig();
1368 builder.SetDartEntrypoint("window_metrics_event_all_view_ids");
1369
1370 fml::AutoResetWaitableEvent ready_latch, message_latch;
1371 context.AddNativeCallback(
1372 "SignalNativeTest",
1374 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
1375
1376 std::string message;
1377 context.AddNativeCallback("SignalNativeMessage",
1379 message =
1382 message_latch.Signal();
1383 }));
1384
1385 auto engine = builder.LaunchEngine();
1386 ASSERT_TRUE(engine.is_valid());
1387
1388 ready_latch.Wait();
1389
1390 // Add view 123.
1391 FlutterWindowMetricsEvent metrics = {};
1392 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
1393 metrics.width = 800;
1394 metrics.height = 600;
1395 metrics.pixel_ratio = 1.0;
1396 metrics.view_id = 123;
1397
1398 FlutterAddViewInfo add_info = {};
1399 add_info.struct_size = sizeof(FlutterAddViewInfo);
1400 add_info.view_id = 123;
1401 add_info.view_metrics = &metrics;
1402 add_info.add_view_callback = [](const FlutterAddViewResult* result) {
1403 ASSERT_TRUE(result->added);
1404 };
1405 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_info), kSuccess);
1406 message_latch.Wait();
1407 ASSERT_EQ(message, "View IDs: [0, 123]");
1408
1409 // Remove view 123.
1410 FlutterRemoveViewInfo remove_info = {};
1411 remove_info.struct_size = sizeof(FlutterAddViewInfo);
1412 remove_info.view_id = 123;
1413 remove_info.remove_view_callback = [](const FlutterRemoveViewResult* result) {
1414 EXPECT_TRUE(result->removed);
1415 };
1416 ASSERT_EQ(FlutterEngineRemoveView(engine.get(), &remove_info), kSuccess);
1417 message_latch.Wait();
1418 ASSERT_EQ(message, "View IDs: [0]");
1419}

◆ TEST_F() [329/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderGradientWithCompositorOnNonRootLayerWithXform   
)

Definition at line 1814 of file embedder_gl_unittests.cc.

1814 {
1815 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1816
1817 // This must match the transformation provided in the
1818 // |CanRenderGradientWithoutCompositorWithXform| test to ensure that
1819 // transforms are consistent respected.
1820 const auto root_surface_transformation =
1821 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
1822
1823 context.SetRootSurfaceTransformation(root_surface_transformation);
1824
1825 EmbedderConfigBuilder builder(context);
1826
1827 builder.SetDartEntrypoint("render_gradient_on_non_root_backing_store");
1828 builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
1829 builder.SetCompositor();
1830 builder.SetRenderTargetType(
1831 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
1832
1833 context.GetCompositor().SetNextPresentCallback(
1834 [&](FlutterViewId view_id, const FlutterLayer** layers,
1835 size_t layers_count) {
1836 ASSERT_EQ(layers_count, 3u);
1837
1838 // Layer Root
1839 {
1840 FlutterBackingStore backing_store = *layers[0]->backing_store;
1841 backing_store.type = kFlutterBackingStoreTypeOpenGL;
1842 backing_store.did_update = true;
1844
1845 FlutterRect paint_region_rects[] = {
1846 FlutterRectMakeLTRB(0, 0, 600, 800),
1847 };
1848 FlutterRegion paint_region = {
1849 .struct_size = sizeof(FlutterRegion),
1850 .rects_count = 1,
1851 .rects = paint_region_rects,
1852 };
1853 FlutterBackingStorePresentInfo present_info = {
1855 .paint_region = &paint_region,
1856 };
1857
1858 FlutterLayer layer = {};
1859 layer.struct_size = sizeof(layer);
1861 layer.backing_store = &backing_store;
1862 layer.size = FlutterSizeMake(600.0, 800.0);
1863 layer.offset = FlutterPointMake(0.0, 0.0);
1864 layer.backing_store_present_info = &present_info;
1865
1866 ASSERT_EQ(*layers[0], layer);
1867 }
1868
1869 // Layer 1
1870 {
1873 platform_view.identifier = 1;
1874
1875 FlutterLayer layer = {};
1876 layer.struct_size = sizeof(layer);
1879 layer.size = FlutterSizeMake(200.0, 100.0);
1880 layer.offset = FlutterPointMake(0.0, 700.0);
1881
1882 ASSERT_EQ(*layers[1], layer);
1883 }
1884
1885 // Layer 2
1886 {
1887 FlutterBackingStore backing_store = *layers[2]->backing_store;
1888 backing_store.type = kFlutterBackingStoreTypeOpenGL;
1889 backing_store.did_update = true;
1891
1892 FlutterRect paint_region_rects[] = {
1893 FlutterRectMakeLTRB(0, 0, 600, 800),
1894 };
1895 FlutterRegion paint_region = {
1896 .struct_size = sizeof(FlutterRegion),
1897 .rects_count = 1,
1898 .rects = paint_region_rects,
1899 };
1900 FlutterBackingStorePresentInfo present_info = {
1902 .paint_region = &paint_region,
1903 };
1904
1905 FlutterLayer layer = {};
1906 layer.struct_size = sizeof(layer);
1908 layer.backing_store = &backing_store;
1909 layer.size = FlutterSizeMake(600.0, 800.0);
1910 layer.offset = FlutterPointMake(0.0, 0.0);
1911 layer.backing_store_present_info = &present_info;
1912
1913 ASSERT_EQ(*layers[2], layer);
1914 }
1915 });
1916
1917 context.GetCompositor().SetPlatformViewRendererCallback(
1918 [&](const FlutterLayer& layer,
1919 GrDirectContext* context) -> sk_sp<SkImage> {
1920 auto surface = CreateRenderSurface(layer, context);
1921 auto canvas = surface->getCanvas();
1922 FML_CHECK(canvas != nullptr);
1923
1924 switch (layer.platform_view->identifier) {
1925 case 1: {
1926 FML_CHECK(layer.size.width == 200);
1927 FML_CHECK(layer.size.height == 100);
1928 // This is occluded anyway. We just want to make sure we see this.
1929 } break;
1930 default:
1931 // Asked to render an unknown platform view.
1932 FML_CHECK(false)
1933 << "Test was asked to composite an unknown platform view.";
1934 }
1935
1936 return surface->makeImageSnapshot();
1937 });
1938
1939 auto rendered_scene = context.GetNextSceneImage();
1940
1941 auto engine = builder.LaunchEngine();
1942 ASSERT_TRUE(engine.is_valid());
1943
1944 // Send a window metrics events so frames may be scheduled.
1945 FlutterWindowMetricsEvent event = {};
1946 event.struct_size = sizeof(event);
1947 // Flutter still thinks it is 800 x 600.
1948 event.width = 800;
1949 event.height = 600;
1950 event.pixel_ratio = 1.0;
1952 kSuccess);
1953
1954 ASSERT_TRUE(ImageMatchesFixture("gradient_xform.png", rendered_scene));
1955}
@ kFlutterLayerContentTypePlatformView
Indicates that the contents of this layer are determined by the embedder.
Definition embedder.h:1793
FlutterSize FlutterSizeMake(double width, double height)
FlutterRect FlutterRectMakeLTRB(double l, double t, double r, double b)
FlutterPoint FlutterPointMake(double x, double y)
sk_sp< SkSurface > CreateRenderSurface(const FlutterLayer &layer, GrDirectContext *context)
FlutterBackingStorePresentInfo * backing_store_present_info
Definition embedder.h:1839
const FlutterPlatformView * platform_view
Definition embedder.h:1829
size_t struct_size
This size of this struct. Must be sizeof(FlutterLayer).
Definition embedder.h:1819
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformView).
Definition embedder.h:1714
FlutterPlatformViewIdentifier identifier
Definition embedder.h:1718
A region represented by a collection of non-overlapping rectangles.
Definition embedder.h:1797
size_t struct_size
The size of this struct. Must be sizeof(FlutterRegion).
Definition embedder.h:1799

◆ TEST_F() [330/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderGradientWithCompositorWithXform   
)

Definition at line 1643 of file embedder_gl_unittests.cc.

1643 {
1644 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1645
1646 // This must match the transformation provided in the
1647 // |CanRenderGradientWithoutCompositorWithXform| test to ensure that
1648 // transforms are consistent respected.
1649 const auto root_surface_transformation =
1650 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
1651
1652 context.SetRootSurfaceTransformation(root_surface_transformation);
1653
1654 EmbedderConfigBuilder builder(context);
1655
1656 builder.SetDartEntrypoint("render_gradient");
1657 builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
1658 builder.SetCompositor();
1659 builder.SetRenderTargetType(
1660 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
1661
1662 auto rendered_scene = context.GetNextSceneImage();
1663
1664 auto engine = builder.LaunchEngine();
1665 ASSERT_TRUE(engine.is_valid());
1666
1667 // Send a window metrics events so frames may be scheduled.
1668 FlutterWindowMetricsEvent event = {};
1669 event.struct_size = sizeof(event);
1670 // Flutter still thinks it is 800 x 600.
1671 event.width = 800;
1672 event.height = 600;
1673 event.pixel_ratio = 1.0;
1675 kSuccess);
1676
1677 ASSERT_TRUE(ImageMatchesFixture("gradient_xform.png", rendered_scene));
1678}

◆ TEST_F() [331/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderGradientWithMetal   
)

Definition at line 38 of file embedder_metal_unittests.mm.

38 {
39 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
40
41 EmbedderConfigBuilder builder(context);
42
43 builder.SetDartEntrypoint("render_gradient");
44 builder.SetMetalRendererConfig(SkISize::Make(800, 600));
45
46 auto rendered_scene = context.GetNextSceneImage();
47
48 auto engine = builder.LaunchEngine();
49 ASSERT_TRUE(engine.is_valid());
50
51 // Send a window metrics events so frames may be scheduled.
53 event.struct_size = sizeof(event);
54 event.width = 800;
55 event.height = 600;
56 event.pixel_ratio = 1.0;
58
59 // TODO (https://github.com/flutter/flutter/issues/73590): re-enable once
60 // we are able to figure out why this fails on the bots.
61 // ASSERT_TRUE(ImageMatchesFixture("gradient_metal.png", rendered_scene));
62}

◆ TEST_F() [332/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderGradientWithoutCompositorWithXform   
)

Definition at line 1581 of file embedder_gl_unittests.cc.

1581 {
1582 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1583
1584 const auto root_surface_transformation =
1585 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
1586
1587 context.SetRootSurfaceTransformation(root_surface_transformation);
1588
1589 EmbedderConfigBuilder builder(context);
1590
1591 const auto surface_size = SkISize::Make(600, 800);
1592
1593 builder.SetDartEntrypoint("render_gradient");
1594 builder.SetOpenGLRendererConfig(surface_size);
1595
1596 auto rendered_scene = context.GetNextSceneImage();
1597
1598 auto engine = builder.LaunchEngine();
1599 ASSERT_TRUE(engine.is_valid());
1600
1601 // Send a window metrics events so frames may be scheduled.
1602 FlutterWindowMetricsEvent event = {};
1603 event.struct_size = sizeof(event);
1604 // Flutter still thinks it is 800 x 600.
1605 event.width = 800;
1606 event.height = 600;
1607 event.pixel_ratio = 1.0;
1609 kSuccess);
1610
1611 ASSERT_TRUE(ImageMatchesFixture("gradient_xform.png", rendered_scene));
1612}

◆ TEST_F() [333/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderImplicitView   
)

Definition at line 644 of file embedder_unittests.cc.

644 {
645 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
646
647 EmbedderConfigBuilder builder(context);
648 builder.SetSoftwareRendererConfig(SkISize::Make(800, 600));
649 builder.SetCompositor();
650 builder.SetDartEntrypoint("render_implicit_view");
651 builder.SetRenderTargetType(
652 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
653
655
656 context.GetCompositor().SetNextPresentCallback(
657 [&](FlutterViewId view_id, const FlutterLayer** layers,
658 size_t layers_count) {
659 ASSERT_EQ(view_id, kFlutterImplicitViewId);
660 latch.Signal();
661 });
662
663 auto engine = builder.LaunchEngine();
664
665 FlutterWindowMetricsEvent event = {};
666 event.struct_size = sizeof(event);
667 event.width = 300;
668 event.height = 200;
669 event.pixel_ratio = 1.0;
671 kSuccess);
672 ASSERT_TRUE(engine.is_valid());
673 latch.Wait();
674}

◆ TEST_F() [334/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderImplicitViewUsingPresentLayersCallback   
)

Definition at line 676 of file embedder_unittests.cc.

676 {
677 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
678
679 EmbedderConfigBuilder builder(context);
680 builder.SetSoftwareRendererConfig(SkISize::Make(800, 600));
681 builder.SetCompositor(/* avoid_backing_store_cache = */ false,
682 /* use_present_layers_callback = */ true);
683 builder.SetDartEntrypoint("render_implicit_view");
684 builder.SetRenderTargetType(
685 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
686
688
689 context.GetCompositor().SetNextPresentCallback(
690 [&](FlutterViewId view_id, const FlutterLayer** layers,
691 size_t layers_count) {
692 ASSERT_EQ(view_id, kFlutterImplicitViewId);
693 latch.Signal();
694 });
695
696 auto engine = builder.LaunchEngine();
697
698 FlutterWindowMetricsEvent event = {};
699 event.struct_size = sizeof(event);
700 event.width = 300;
701 event.height = 200;
702 event.pixel_ratio = 1.0;
704 kSuccess);
705 ASSERT_TRUE(engine.is_valid());
706 latch.Wait();
707}

◆ TEST_F() [335/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderMultipleViews   
)

Test the engine can present to multiple views.

Definition at line 1755 of file embedder_unittests.cc.

1755 {
1756 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1757 EmbedderConfigBuilder builder(context);
1758 builder.SetSoftwareRendererConfig();
1759 builder.SetCompositor();
1760 builder.SetDartEntrypoint("render_all_views");
1761
1762 builder.SetRenderTargetType(
1763 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
1764
1765 fml::AutoResetWaitableEvent latch0, latch123;
1766 context.GetCompositor().SetPresentCallback(
1767 [&](FlutterViewId view_id, const FlutterLayer** layers,
1768 size_t layers_count) {
1769 switch (view_id) {
1770 case 0:
1771 latch0.Signal();
1772 break;
1773 case 123:
1774 latch123.Signal();
1775 break;
1776 default:
1778 }
1779 },
1780 /* one_shot= */ false);
1781
1782 auto engine = builder.LaunchEngine();
1783 ASSERT_TRUE(engine.is_valid());
1784
1785 // Give the implicit view a non-zero size so that it renders something.
1786 FlutterWindowMetricsEvent metrics0 = {};
1787 metrics0.struct_size = sizeof(FlutterWindowMetricsEvent);
1788 metrics0.width = 800;
1789 metrics0.height = 600;
1790 metrics0.pixel_ratio = 1.0;
1791 metrics0.view_id = 0;
1792 ASSERT_EQ(FlutterEngineSendWindowMetricsEvent(engine.get(), &metrics0),
1793 kSuccess);
1794
1795 // Add view 123.
1796 FlutterWindowMetricsEvent metrics123 = {};
1797 metrics123.struct_size = sizeof(FlutterWindowMetricsEvent);
1798 metrics123.width = 800;
1799 metrics123.height = 600;
1800 metrics123.pixel_ratio = 1.0;
1801 metrics123.view_id = 123;
1802
1803 FlutterAddViewInfo add_view_info = {};
1804 add_view_info.struct_size = sizeof(FlutterAddViewInfo);
1805 add_view_info.view_id = 123;
1806 add_view_info.view_metrics = &metrics123;
1807 add_view_info.add_view_callback = [](const FlutterAddViewResult* result) {
1808 ASSERT_TRUE(result->added);
1809 };
1810
1811 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_view_info), kSuccess);
1812
1813 latch0.Wait();
1814 latch123.Wait();
1815}

◆ TEST_F() [336/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderSceneWithoutCustomCompositor   
)

Definition at line 1495 of file embedder_gl_unittests.cc.

1495 {
1496 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1497
1498 EmbedderConfigBuilder builder(context);
1499
1500 builder.SetDartEntrypoint("can_render_scene_without_custom_compositor");
1501 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
1502
1503 auto rendered_scene = context.GetNextSceneImage();
1504
1505 auto engine = builder.LaunchEngine();
1506 ASSERT_TRUE(engine.is_valid());
1507
1508 // Send a window metrics events so frames may be scheduled.
1509 FlutterWindowMetricsEvent event = {};
1510 event.struct_size = sizeof(event);
1511 event.width = 800;
1512 event.height = 600;
1513 event.pixel_ratio = 1.0;
1515 kSuccess);
1516
1517 ASSERT_TRUE(ImageMatchesFixture("scene_without_custom_compositor.png",
1518 rendered_scene));
1519}

◆ TEST_F() [337/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderSceneWithoutCustomCompositorMetal   
)

Definition at line 242 of file embedder_metal_unittests.mm.

242 {
243 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
244
245 EmbedderConfigBuilder builder(context);
246
247 builder.SetDartEntrypoint("can_render_scene_without_custom_compositor");
248 builder.SetMetalRendererConfig(SkISize::Make(800, 600));
249
250 auto rendered_scene = context.GetNextSceneImage();
251
252 auto engine = builder.LaunchEngine();
253 ASSERT_TRUE(engine.is_valid());
254
255 // Send a window metrics events so frames may be scheduled.
256 FlutterWindowMetricsEvent event = {};
257 event.struct_size = sizeof(event);
258 event.width = 800;
259 event.height = 600;
260 event.pixel_ratio = 1.0;
262
263 ASSERT_TRUE(ImageMatchesFixture("scene_without_custom_compositor.png", rendered_scene));
264}

◆ TEST_F() [338/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderSceneWithoutCustomCompositorWithTransformation   
)

Definition at line 1521 of file embedder_gl_unittests.cc.

1521 {
1522 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1523
1524 const auto root_surface_transformation =
1525 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
1526
1527 context.SetRootSurfaceTransformation(root_surface_transformation);
1528
1529 EmbedderConfigBuilder builder(context);
1530
1531 builder.SetDartEntrypoint("can_render_scene_without_custom_compositor");
1532 builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
1533
1534 auto rendered_scene = context.GetNextSceneImage();
1535
1536 auto engine = builder.LaunchEngine();
1537 ASSERT_TRUE(engine.is_valid());
1538
1539 // Send a window metrics events so frames may be scheduled.
1540 FlutterWindowMetricsEvent event = {};
1541 event.struct_size = sizeof(event);
1542
1543 // Flutter still thinks it is 800 x 600.
1544 event.width = 800;
1545 event.height = 600;
1546 event.pixel_ratio = 1.0;
1548 kSuccess);
1549
1550 ASSERT_TRUE(ImageMatchesFixture(
1551 "scene_without_custom_compositor_with_xform.png", rendered_scene));
1552}

◆ TEST_F() [339/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderWithImpellerOpenGL   
)

Definition at line 4749 of file embedder_gl_unittests.cc.

4749 {
4750 EmbedderTestContextGL& context = static_cast<EmbedderTestContextGL&>(
4751 GetEmbedderContext(EmbedderTestContextType::kOpenGLContext));
4752 EmbedderConfigBuilder builder(context);
4753
4754 bool present_called = false;
4755 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
4756 [&present_called](FlutterPresentInfo present_info) {
4757 present_called = true;
4758 });
4759
4760 builder.AddCommandLineArgument("--enable-impeller");
4761 builder.SetDartEntrypoint("render_impeller_gl_test");
4762 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4763 builder.SetCompositor();
4764 builder.SetRenderTargetType(
4765 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
4766
4767 auto rendered_scene = context.GetNextSceneImage();
4768
4769 auto engine = builder.LaunchEngine();
4770 ASSERT_TRUE(engine.is_valid());
4771
4772 // Bind to an arbitrary FBO in order to verify that Impeller binds to the
4773 // provided FBO during rendering.
4774 typedef void (*glGenFramebuffersProc)(GLsizei n, GLuint* ids);
4775 typedef void (*glBindFramebufferProc)(GLenum target, GLuint framebuffer);
4776 auto glGenFramebuffers = reinterpret_cast<glGenFramebuffersProc>(
4777 context.GLGetProcAddress("glGenFramebuffers"));
4778 auto glBindFramebuffer = reinterpret_cast<glBindFramebufferProc>(
4779 context.GLGetProcAddress("glBindFramebuffer"));
4780 const flutter::Shell& shell = ToEmbedderEngine(engine.get())->GetShell();
4781 fml::AutoResetWaitableEvent raster_event;
4782 shell.GetTaskRunners().GetRasterTaskRunner()->PostTask([&] {
4783 GLuint fbo;
4784 glGenFramebuffers(1, &fbo);
4785 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
4786 raster_event.Signal();
4787 });
4788 raster_event.Wait();
4789
4790 // Send a window metrics events so frames may be scheduled.
4791 FlutterWindowMetricsEvent event = {};
4792 event.struct_size = sizeof(event);
4793 event.width = 800;
4794 event.height = 600;
4795 event.pixel_ratio = 1.0;
4797 kSuccess);
4798
4799 ASSERT_TRUE(ImageMatchesFixture(
4800 FixtureNameForBackend(EmbedderTestContextType::kOpenGLContext,
4801 "impeller_gl_test.png"),
4802 rendered_scene));
4803
4804 // The scene will be rendered by the compositor, and the surface present
4805 // callback should not be invoked.
4806 ASSERT_FALSE(present_called);
4807}
std::future< sk_sp< SkImage > > GetNextSceneImage()
std::string FixtureNameForBackend(EmbedderTestContextType backend, const std::string &name)
Prepends a prefix to the name which is unique to the test context type. This is useful for tests that...

◆ TEST_F() [340/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanReuseViewIds   
)

Test that a removed view's ID can be reused to add a new view.

Definition at line 1517 of file embedder_unittests.cc.

1517 {
1518 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1519 EmbedderConfigBuilder builder(context);
1520 builder.SetSoftwareRendererConfig();
1521 builder.SetDartEntrypoint("window_metrics_event_all_view_ids");
1522
1523 fml::AutoResetWaitableEvent ready_latch, message_latch;
1524 context.AddNativeCallback(
1525 "SignalNativeTest",
1527 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
1528
1529 std::string message;
1530 context.AddNativeCallback("SignalNativeMessage",
1532 message =
1535 message_latch.Signal();
1536 }));
1537
1538 auto engine = builder.LaunchEngine();
1539 ASSERT_TRUE(engine.is_valid());
1540
1541 ready_latch.Wait();
1542
1543 // Add view 123.
1544 FlutterWindowMetricsEvent metrics = {};
1545 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
1546 metrics.width = 800;
1547 metrics.height = 600;
1548 metrics.pixel_ratio = 1.0;
1549 metrics.view_id = 123;
1550
1551 FlutterAddViewInfo add_info = {};
1552 add_info.struct_size = sizeof(FlutterAddViewInfo);
1553 add_info.view_id = 123;
1554 add_info.view_metrics = &metrics;
1555 add_info.add_view_callback = [](const FlutterAddViewResult* result) {
1556 ASSERT_TRUE(result->added);
1557 };
1558 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_info), kSuccess);
1559 message_latch.Wait();
1560 ASSERT_EQ(message, "View IDs: [0, 123]");
1561
1562 // Remove view 123.
1563 FlutterRemoveViewInfo remove_info = {};
1564 remove_info.struct_size = sizeof(FlutterAddViewInfo);
1565 remove_info.view_id = 123;
1566 remove_info.remove_view_callback = [](const FlutterRemoveViewResult* result) {
1567 ASSERT_TRUE(result->removed);
1568 };
1569 ASSERT_EQ(FlutterEngineRemoveView(engine.get(), &remove_info), kSuccess);
1570 message_latch.Wait();
1571 ASSERT_EQ(message, "View IDs: [0]");
1572
1573 // Re-add view 123.
1574 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_info), kSuccess);
1575 message_latch.Wait();
1576 ASSERT_EQ(message, "View IDs: [0, 123]");
1577}

◆ TEST_F() [341/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRunInitializedEngine   
)

Test that an initialized engine can be run exactly once.

Definition at line 1225 of file embedder_unittests.cc.

1225 {
1226 EmbedderConfigBuilder builder(
1227 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
1228 builder.SetSoftwareRendererConfig();
1229 auto engine = builder.InitializeEngine();
1230 ASSERT_TRUE(engine.is_valid());
1231 ASSERT_EQ(FlutterEngineRunInitialized(engine.get()), kSuccess);
1232 // Cannot re-run an already running engine.
1234 engine.reset();
1235}

◆ TEST_F() [342/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanScheduleFrame   
)

Definition at line 3363 of file embedder_unittests.cc.

3363 {
3364 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3365 EmbedderConfigBuilder builder(context);
3366 builder.SetSoftwareRendererConfig();
3367 builder.SetDartEntrypoint("can_schedule_frame");
3369 context.AddNativeCallback(
3370 "SignalNativeTest",
3372 [&latch](Dart_NativeArguments args) { latch.Signal(); }));
3373
3374 fml::AutoResetWaitableEvent check_latch;
3375 context.AddNativeCallback(
3376 "SignalNativeCount",
3378 [&check_latch](Dart_NativeArguments args) { check_latch.Signal(); }));
3379
3380 auto engine = builder.LaunchEngine();
3381 ASSERT_TRUE(engine.is_valid());
3382
3383 // Wait for the application to attach the listener.
3384 latch.Wait();
3385
3386 ASSERT_EQ(FlutterEngineScheduleFrame(engine.get()), kSuccess);
3387
3388 check_latch.Wait();
3389}
FlutterEngineResult FlutterEngineScheduleFrame(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Schedule a new frame to redraw the content.
Definition embedder.cc:3287

◆ TEST_F() [343/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSendLowMemoryNotification   
)

Definition at line 2203 of file embedder_unittests.cc.

2203 {
2204 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2205
2206 EmbedderConfigBuilder builder(context);
2207 builder.SetSoftwareRendererConfig();
2208
2209 auto engine = builder.LaunchEngine();
2210
2211 ASSERT_TRUE(engine.is_valid());
2212
2213 // TODO(chinmaygarde): The shell ought to have a mechanism for notification
2214 // dispatch that engine subsystems can register handlers to. This would allow
2215 // the raster cache and the secondary context caches to respond to
2216 // notifications. Once that is in place, this test can be updated to actually
2217 // ensure that the dispatched message is visible to engine subsystems.
2219}
FlutterEngineResult FlutterEngineNotifyLowMemoryWarning(FLUTTER_API_SYMBOL(FlutterEngine) raw_engine)
Posts a low memory notification to a running engine instance. The engine will do its best to release ...
Definition embedder.cc:3185

◆ TEST_F() [344/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSendPointer   
)

Send a pointer event to Dart and wait until the Dart code signals it received the event.

Definition at line 3478 of file embedder_unittests.cc.

3478 {
3479 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3480 EmbedderConfigBuilder builder(context);
3481 builder.SetSoftwareRendererConfig();
3482 builder.SetDartEntrypoint("pointer_data_packet");
3483
3484 fml::AutoResetWaitableEvent ready_latch, count_latch, message_latch;
3485 context.AddNativeCallback(
3486 "SignalNativeTest",
3488 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3489 context.AddNativeCallback(
3490 "SignalNativeCount",
3494 ASSERT_EQ(count, 1);
3495 count_latch.Signal();
3496 }));
3497 context.AddNativeCallback(
3498 "SignalNativeMessage",
3502 ASSERT_EQ("PointerData(viewId: 0, x: 123.0, y: 456.0)", message);
3503 message_latch.Signal();
3504 }));
3505
3506 auto engine = builder.LaunchEngine();
3507 ASSERT_TRUE(engine.is_valid());
3508
3509 ready_latch.Wait();
3510
3511 FlutterPointerEvent pointer_event = {};
3512 pointer_event.struct_size = sizeof(FlutterPointerEvent);
3513 pointer_event.phase = FlutterPointerPhase::kAdd;
3514 pointer_event.x = 123;
3515 pointer_event.y = 456;
3516 pointer_event.timestamp = static_cast<size_t>(1234567890);
3517 pointer_event.view_id = 0;
3518
3520 FlutterEngineSendPointerEvent(engine.get(), &pointer_event, 1);
3521 ASSERT_EQ(result, kSuccess);
3522
3523 count_latch.Wait();
3524 message_latch.Wait();
3525}
FlutterEngineResult FlutterEngineSendPointerEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count)
Definition embedder.cc:2423
@ kAdd
Definition embedder.h:988
FlutterEngineResult
Definition embedder.h:72
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
Definition embedder.h:1034
FlutterViewId view_id
The identifier of the view that received the pointer event.
Definition embedder.h:1069
double y
The y coordinate of the pointer event in physical pixels.
Definition embedder.h:1043
double x
The x coordinate of the pointer event in physical pixels.
Definition embedder.h:1041
FlutterPointerPhase phase
Definition embedder.h:1035

◆ TEST_F() [345/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSendPointerEventWithViewId   
)

Send a pointer event to Dart and wait until the Dart code echos with the view ID.

Definition at line 3529 of file embedder_unittests.cc.

3529 {
3530 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3531 EmbedderConfigBuilder builder(context);
3532 builder.SetSoftwareRendererConfig();
3533 builder.SetDartEntrypoint("pointer_data_packet_view_id");
3534
3535 fml::AutoResetWaitableEvent ready_latch, count_latch, message_latch;
3536 context.AddNativeCallback(
3537 "SignalNativeTest",
3539 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3540 context.AddNativeCallback(
3541 "SignalNativeMessage",
3545 ASSERT_EQ("ViewID: 2", message);
3546 message_latch.Signal();
3547 }));
3548
3549 auto engine = builder.LaunchEngine();
3550 ASSERT_TRUE(engine.is_valid());
3551
3552 ready_latch.Wait();
3553
3554 FlutterPointerEvent pointer_event = {};
3555 pointer_event.struct_size = sizeof(FlutterPointerEvent);
3556 pointer_event.phase = FlutterPointerPhase::kAdd;
3557 pointer_event.x = 123;
3558 pointer_event.y = 456;
3559 pointer_event.timestamp = static_cast<size_t>(1234567890);
3560 pointer_event.view_id = 2;
3561
3563 FlutterEngineSendPointerEvent(engine.get(), &pointer_event, 1);
3564 ASSERT_EQ(result, kSuccess);
3565
3566 message_latch.Wait();
3567}

◆ TEST_F() [346/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSetCustomLogMessageCallback   
)

Tests that setting a custom log callback works as expected and defaults to using tag "flutter".

Definition at line 535 of file embedder_unittests.cc.

535 {
536 fml::AutoResetWaitableEvent callback_latch;
537 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
538 EmbedderConfigBuilder builder(context);
539 builder.SetDartEntrypoint("custom_logger");
540 builder.SetSoftwareRendererConfig();
541 context.SetLogMessageCallback(
542 [&callback_latch](const char* tag, const char* message) {
543 EXPECT_EQ(std::string(tag), "flutter");
544 EXPECT_EQ(std::string(message), "hello world");
545 callback_latch.Signal();
546 });
547 auto engine = builder.LaunchEngine();
548 ASSERT_TRUE(engine.is_valid());
549 callback_latch.Wait();
550}

◆ TEST_F() [347/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSetCustomLogTag   
)

Tests that setting a custom log tag works.

Definition at line 554 of file embedder_unittests.cc.

554 {
555 fml::AutoResetWaitableEvent callback_latch;
556 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
557 EmbedderConfigBuilder builder(context);
558 builder.SetDartEntrypoint("custom_logger");
559 builder.SetSoftwareRendererConfig();
560 builder.SetLogTag("butterfly");
561 context.SetLogMessageCallback(
562 [&callback_latch](const char* tag, const char* message) {
563 EXPECT_EQ(std::string(tag), "butterfly");
564 EXPECT_EQ(std::string(message), "hello world");
565 callback_latch.Signal();
566 });
567 auto engine = builder.LaunchEngine();
568 ASSERT_TRUE(engine.is_valid());
569 callback_latch.Wait();
570}

◆ TEST_F() [348/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSetNextFrameCallback   
)

Definition at line 3391 of file embedder_unittests.cc.

3391 {
3392 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3393 EmbedderConfigBuilder builder(context);
3394 builder.SetSoftwareRendererConfig();
3395 builder.SetDartEntrypoint("draw_solid_red");
3396
3397 auto engine = builder.LaunchEngine();
3398 ASSERT_TRUE(engine.is_valid());
3399
3400 // Register the callback that is executed once the next frame is drawn.
3401 fml::AutoResetWaitableEvent callback_latch;
3402 VoidCallback callback = [](void* user_data) {
3403 fml::AutoResetWaitableEvent* callback_latch =
3405
3406 callback_latch->Signal();
3407 };
3408
3410 &callback_latch);
3411 ASSERT_EQ(result, kSuccess);
3412
3413 // Send a window metrics events so frames may be scheduled.
3414 FlutterWindowMetricsEvent event = {};
3415 event.struct_size = sizeof(event);
3416 event.width = 800;
3417 event.height = 600;
3418 event.pixel_ratio = 1.0;
3419 event.physical_view_inset_top = 0.0;
3420 event.physical_view_inset_right = 0.0;
3421 event.physical_view_inset_bottom = 0.0;
3422 event.physical_view_inset_left = 0.0;
3424 kSuccess);
3425
3426 callback_latch.Wait();
3427}
FlutterEngineResult FlutterEngineSetNextFrameCallback(FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *user_data)
Schedule a callback to be called after the next frame is drawn. This must be called from the platform...
Definition embedder.cc:3299

◆ TEST_F() [349/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSpecifyCustomPlatformTaskRunner   
)

Definition at line 204 of file embedder_unittests.cc.

204 {
205 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
207
208 // Run the test on its own thread with a message loop so that it can safely
209 // pump its event loop while we wait for all the conditions to be checked.
210 auto platform_task_runner = CreateNewThread("test_platform_thread");
211 static std::mutex engine_mutex;
212 static bool signaled_once = false;
214
215 EmbedderTestTaskRunner test_task_runner(
216 platform_task_runner, [&](FlutterTask task) {
217 std::scoped_lock lock(engine_mutex);
218 if (!engine.is_valid()) {
219 return;
220 }
221 // There may be multiple tasks posted but we only need to check
222 // assertions once.
223 if (signaled_once) {
224 FlutterEngineRunTask(engine.get(), &task);
225 return;
226 }
227
228 signaled_once = true;
229 ASSERT_TRUE(engine.is_valid());
230 ASSERT_EQ(FlutterEngineRunTask(engine.get(), &task), kSuccess);
231 latch.Signal();
232 });
233
234 platform_task_runner->PostTask([&]() {
235 EmbedderConfigBuilder builder(context);
236 const auto task_runner_description =
237 test_task_runner.GetFlutterTaskRunnerDescription();
238 builder.SetSoftwareRendererConfig();
239 builder.SetPlatformTaskRunner(&task_runner_description);
240 builder.SetDartEntrypoint("invokePlatformTaskRunner");
241 std::scoped_lock lock(engine_mutex);
242 engine = builder.LaunchEngine();
243 ASSERT_TRUE(engine.is_valid());
244 });
245
246 // Signaled when all the assertions are checked.
247 latch.Wait();
248 ASSERT_TRUE(engine.is_valid());
249
250 // Since the engine was started on its own thread, it must be killed there as
251 // well.
253 platform_task_runner->PostTask(fml::MakeCopyable([&]() mutable {
254 std::scoped_lock lock(engine_mutex);
255 engine.reset();
256
257 // There may still be pending tasks on the platform thread that were queued
258 // by the test_task_runner. Signal the latch after these tasks have been
259 // consumed.
260 platform_task_runner->PostTask([&kill_latch] { kill_latch.Signal(); });
261 }));
262 kill_latch.Wait();
263
264 ASSERT_TRUE(signaled_once);
265 signaled_once = false;
266}

◆ TEST_F() [350/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSuccessfullyPopulateSpecificJITSnapshotCallbacks   
)

PopulateJITSnapshotMappingCallbacks should successfully change the callbacks of the snapshots in the engine's settings when JIT snapshots are explicitly defined.

Definition at line 2446 of file embedder_unittests.cc.

2446 {
2447// TODO(#107263): Inconsistent snapshot paths in the Linux Fuchsia FEMU test.
2448#if defined(OS_FUCHSIA)
2449 GTEST_SKIP() << "Inconsistent paths in Fuchsia.";
2450#else
2451
2452 // This test is only relevant in JIT mode.
2453 if (DartVM::IsRunningPrecompiledCode()) {
2454 GTEST_SKIP();
2455 return;
2456 }
2457
2458 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2459 EmbedderConfigBuilder builder(context);
2460 builder.SetSoftwareRendererConfig();
2461
2462 // Construct the location of valid JIT snapshots.
2463 const std::string src_path = GetSourcePath();
2464 const std::string vm_snapshot_data =
2465 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_DATA});
2466 const std::string vm_snapshot_instructions =
2467 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_INSTRUCTIONS});
2468 const std::string isolate_snapshot_data =
2469 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_DATA});
2470 const std::string isolate_snapshot_instructions =
2471 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_INSTRUCTIONS});
2472
2473 // Explicitly define the locations of the JIT snapshots
2474 builder.GetProjectArgs().vm_snapshot_data =
2475 reinterpret_cast<const uint8_t*>(vm_snapshot_data.c_str());
2476 builder.GetProjectArgs().vm_snapshot_instructions =
2477 reinterpret_cast<const uint8_t*>(vm_snapshot_instructions.c_str());
2478 builder.GetProjectArgs().isolate_snapshot_data =
2479 reinterpret_cast<const uint8_t*>(isolate_snapshot_data.c_str());
2480 builder.GetProjectArgs().isolate_snapshot_instructions =
2481 reinterpret_cast<const uint8_t*>(isolate_snapshot_instructions.c_str());
2482
2483 auto engine = builder.LaunchEngine();
2484
2486 const Settings settings = shell.GetSettings();
2487
2488 ASSERT_NE(settings.vm_snapshot_data(), nullptr);
2489 ASSERT_NE(settings.vm_snapshot_instr(), nullptr);
2490 ASSERT_NE(settings.isolate_snapshot_data(), nullptr);
2491 ASSERT_NE(settings.isolate_snapshot_instr(), nullptr);
2492 ASSERT_NE(settings.dart_library_sources_kernel(), nullptr);
2493#endif // OS_FUCHSIA
2494}

◆ TEST_F() [351/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSwapOutVulkanCalls   
)

Definition at line 98 of file embedder_vk_unittests.cc.

98 {
99 auto& context = GetEmbedderContext(EmbedderTestContextType::kVulkanContext);
101 context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
102 EmbedderConfigBuilder builder(context);
103 builder.SetVulkanRendererConfig(
104 SkISize::Make(1024, 1024),
106 const char* name) -> void* {
107 if (StrcmpFixed(name, "vkGetInstanceProcAddr") == 0) {
108 g_vulkan_proc_info.get_instance_proc_addr =
109 reinterpret_cast<decltype(vkGetInstanceProcAddr)*>(
110 EmbedderTestContextVulkan::InstanceProcAddr(user_data,
111 instance, name));
112 return reinterpret_cast<void*>(GetInstanceProcAddr);
113 }
114 return EmbedderTestContextVulkan::InstanceProcAddr(user_data, instance,
115 name);
116 });
117 auto engine = builder.LaunchEngine();
118 ASSERT_TRUE(engine.is_valid());
119 // Wait for the root isolate to launch.
120 latch.Wait();
121 engine.reset();
122 EXPECT_TRUE(g_vulkan_proc_info.did_call_queue_submit);
123}
void * FlutterVulkanInstanceHandle
Alias for VkInstance.
Definition embedder.h:706
VkInstance instance
Definition main.cc:48
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)

◆ TEST_F() [352/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanTerminateCleanly   
)

Definition at line 147 of file embedder_unittests.cc.

147 {
148 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
149 EmbedderConfigBuilder builder(context);
150 builder.SetSoftwareRendererConfig();
151 builder.SetDartEntrypoint("terminateExitCodeHandler");
152 auto engine = builder.LaunchEngine();
153 ASSERT_TRUE(engine.is_valid());
154}

◆ TEST_F() [353/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CanUpdateLocales   
)

Definition at line 1988 of file embedder_unittests.cc.

1988 {
1989 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1990 EmbedderConfigBuilder builder(context);
1991 builder.SetSoftwareRendererConfig();
1992 builder.SetDartEntrypoint("can_receive_locale_updates");
1994 context.AddNativeCallback(
1995 "SignalNativeTest",
1997 [&latch](Dart_NativeArguments args) { latch.Signal(); }));
1998
1999 fml::AutoResetWaitableEvent check_latch;
2000 context.AddNativeCallback(
2001 "SignalNativeCount",
2005 2);
2006 check_latch.Signal();
2007 }));
2008
2009 auto engine = builder.LaunchEngine();
2010 ASSERT_TRUE(engine.is_valid());
2011
2012 // Wait for the application to attach the listener.
2013 latch.Wait();
2014
2015 FlutterLocale locale1 = {};
2016 locale1.struct_size = sizeof(locale1);
2017 locale1.language_code = ""; // invalid
2018 locale1.country_code = "US";
2019 locale1.script_code = "";
2020 locale1.variant_code = nullptr;
2021
2022 FlutterLocale locale2 = {};
2023 locale2.struct_size = sizeof(locale2);
2024 locale2.language_code = "zh";
2025 locale2.country_code = "CN";
2026 locale2.script_code = "Hans";
2027 locale2.variant_code = nullptr;
2028
2029 std::vector<const FlutterLocale*> locales;
2030 locales.push_back(&locale1);
2031 locales.push_back(&locale2);
2032
2033 ASSERT_EQ(
2034 FlutterEngineUpdateLocales(engine.get(), locales.data(), locales.size()),
2036
2037 // Fix the invalid code.
2038 locale1.language_code = "en";
2039
2040 ASSERT_EQ(
2041 FlutterEngineUpdateLocales(engine.get(), locales.data(), locales.size()),
2042 kSuccess);
2043
2044 check_latch.Wait();
2045}
FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterLocale **locales, size_t locales_count)
Notify a running engine instance that the locale has been updated. The preferred locale must be the f...
Definition embedder.cc:2998
const char * language_code
Definition embedder.h:1939
size_t struct_size
This size of this struct. Must be sizeof(FlutterLocale).
Definition embedder.h:1935
const char * script_code
Definition embedder.h:1949
const char * country_code
Definition embedder.h:1944
const char * variant_code
Definition embedder.h:1954

◆ TEST_F() [354/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ClipsAreCorrectlyCalculated   
)

Definition at line 2946 of file embedder_gl_unittests.cc.

2946 {
2947 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2948
2949 EmbedderConfigBuilder builder(context);
2950 builder.SetOpenGLRendererConfig(SkISize::Make(400, 300));
2951 builder.SetCompositor();
2952 builder.SetDartEntrypoint("scene_builder_with_clips");
2953 builder.SetRenderTargetType(
2954 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
2955
2956 const auto root_surface_transformation =
2957 SkMatrix().preTranslate(0, 400).preRotate(-90, 0, 0);
2958
2959 context.SetRootSurfaceTransformation(root_surface_transformation);
2960
2962 context.GetCompositor().SetNextPresentCallback(
2963 [&](FlutterViewId view_id, const FlutterLayer** layers,
2964 size_t layers_count) {
2965 ASSERT_EQ(layers_count, 2u);
2966
2967 {
2970 platform_view.identifier = 42;
2971
2972 FlutterLayer layer = {};
2973 layer.struct_size = sizeof(layer);
2976 layer.size = FlutterSizeMake(300.0, 400.0);
2977 layer.offset = FlutterPointMake(0.0, 0.0);
2978
2979 ASSERT_EQ(*layers[0], layer);
2980
2981 bool clip_assertions_checked = false;
2982
2983 // The total transformation on the stack upto the platform view.
2984 const auto total_xformation =
2985 GetTotalMutationTransformationMatrix(layers[0]->platform_view);
2986
2987 FilterMutationsByType(
2988 layers[0]->platform_view,
2990 [&](const auto& mutation) {
2991 FlutterRect clip = mutation.clip_rect;
2992
2993 // The test is only set up to supply one clip. Make sure it is
2994 // the one we expect.
2995 const auto rect_to_compare =
2996 SkRect::MakeLTRB(10.0, 10.0, 390, 290);
2997 ASSERT_EQ(clip, FlutterRectMake(rect_to_compare));
2998
2999 // This maps the clip from device space into surface space.
3000 SkRect mapped;
3001 ASSERT_TRUE(total_xformation.mapRect(&mapped, rect_to_compare));
3002 ASSERT_EQ(mapped, SkRect::MakeLTRB(10, 10, 290, 390));
3003 clip_assertions_checked = true;
3004 });
3005
3006 ASSERT_TRUE(clip_assertions_checked);
3007 }
3008
3009 latch.Signal();
3010 });
3011
3012 auto engine = builder.LaunchEngine();
3013 ASSERT_TRUE(engine.is_valid());
3014
3015 FlutterWindowMetricsEvent event = {};
3016 event.struct_size = sizeof(event);
3017 event.width = 400;
3018 event.height = 300;
3019 event.pixel_ratio = 1.0;
3021 kSuccess);
3022
3023 latch.Wait();
3024}
@ kFlutterPlatformViewMutationTypeClipRect
Definition embedder.h:1692
FlutterRect FlutterRectMake(const SkRect &rect)

◆ TEST_F() [355/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ComplexClipsAreCorrectlyCalculated   
)

Definition at line 3026 of file embedder_gl_unittests.cc.

3026 {
3027 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3028
3029 EmbedderConfigBuilder builder(context);
3030 builder.SetOpenGLRendererConfig(SkISize::Make(1024, 600));
3031 builder.SetCompositor();
3032 builder.SetDartEntrypoint("scene_builder_with_complex_clips");
3033 builder.SetRenderTargetType(
3034 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
3035
3036 const auto root_surface_transformation =
3037 SkMatrix().preTranslate(0, 1024).preRotate(-90, 0, 0);
3038
3039 context.SetRootSurfaceTransformation(root_surface_transformation);
3040
3042 context.GetCompositor().SetNextPresentCallback(
3043 [&](FlutterViewId view_id, const FlutterLayer** layers,
3044 size_t layers_count) {
3045 ASSERT_EQ(layers_count, 2u);
3046
3047 {
3050 platform_view.identifier = 42;
3051
3052 FlutterLayer layer = {};
3053 layer.struct_size = sizeof(layer);
3056 layer.size = FlutterSizeMake(600.0, 1024.0);
3057 layer.offset = FlutterPointMake(0.0, -256.0);
3058
3059 ASSERT_EQ(*layers[0], layer);
3060
3061 const auto** mutations = platform_view.mutations;
3062
3063 ASSERT_EQ(mutations[0]->type,
3065 ASSERT_EQ(SkMatrixMake(mutations[0]->transformation),
3066 root_surface_transformation);
3067
3068 ASSERT_EQ(mutations[1]->type,
3070 ASSERT_EQ(SkRectMake(mutations[1]->clip_rect),
3071 SkRect::MakeLTRB(0.0, 0.0, 1024.0, 600.0));
3072
3073 ASSERT_EQ(mutations[2]->type,
3075 ASSERT_EQ(SkMatrixMake(mutations[2]->transformation),
3076 SkMatrix::Translate(512.0, 0.0));
3077
3078 ASSERT_EQ(mutations[3]->type,
3080 ASSERT_EQ(SkRectMake(mutations[3]->clip_rect),
3081 SkRect::MakeLTRB(0.0, 0.0, 512.0, 600.0));
3082
3083 ASSERT_EQ(mutations[4]->type,
3085 ASSERT_EQ(SkMatrixMake(mutations[4]->transformation),
3086 SkMatrix::Translate(-256.0, 0.0));
3087
3088 ASSERT_EQ(mutations[5]->type,
3090 ASSERT_EQ(SkRectMake(mutations[5]->clip_rect),
3091 SkRect::MakeLTRB(0.0, 0.0, 1024.0, 600.0));
3092 }
3093
3094 latch.Signal();
3095 });
3096
3097 auto engine = builder.LaunchEngine();
3098 ASSERT_TRUE(engine.is_valid());
3099
3100 FlutterWindowMetricsEvent event = {};
3101 event.struct_size = sizeof(event);
3102 event.width = 1024;
3103 event.height = 600;
3104 event.pixel_ratio = 1.0;
3106 kSuccess);
3107
3108 latch.Wait();
3109}
SkRect SkRectMake(const FlutterRect &rect)

◆ TEST_F() [356/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorCanPostOnlyPlatformViews   
)

Definition at line 3344 of file embedder_gl_unittests.cc.

3344 {
3345 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3346
3347 EmbedderConfigBuilder builder(context);
3348 builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
3349 builder.SetCompositor();
3350 builder.SetDartEntrypoint("compositor_can_post_only_platform_views");
3351 builder.SetRenderTargetType(
3352 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
3353
3355
3356 context.GetCompositor().SetNextPresentCallback(
3357 [&](FlutterViewId view_id, const FlutterLayer** layers,
3358 size_t layers_count) {
3359 ASSERT_EQ(layers_count, 2u);
3360
3361 // Layer 0
3362 {
3365 platform_view.identifier = 42;
3366 FlutterLayer layer = {};
3367 layer.struct_size = sizeof(layer);
3370 layer.size = FlutterSizeMake(300.0, 200.0);
3371 layer.offset = FlutterPointMake(0.0, 0.0);
3372
3373 ASSERT_EQ(*layers[0], layer);
3374 }
3375
3376 // Layer 1
3377 {
3380 platform_view.identifier = 24;
3381 FlutterLayer layer = {};
3382 layer.struct_size = sizeof(layer);
3385 layer.size = FlutterSizeMake(300.0, 200.0);
3386 layer.offset = FlutterPointMake(0.0, 0.0);
3387
3388 ASSERT_EQ(*layers[1], layer);
3389 }
3390 latch.Signal();
3391 });
3392
3393 auto engine = builder.LaunchEngine();
3394
3395 FlutterWindowMetricsEvent event = {};
3396 event.struct_size = sizeof(event);
3397 event.width = 300;
3398 event.height = 200;
3399 event.pixel_ratio = 1.0;
3401 kSuccess);
3402 ASSERT_TRUE(engine.is_valid());
3403 latch.Wait();
3404
3405 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
3406}

◆ TEST_F() [357/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorCanPostZeroLayersForPresentation   
)

Definition at line 3310 of file embedder_gl_unittests.cc.

3310 {
3311 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3312
3313 EmbedderConfigBuilder builder(context);
3314 builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
3315 builder.SetCompositor();
3316 builder.SetDartEntrypoint("empty_scene_posts_zero_layers_to_compositor");
3317 builder.SetRenderTargetType(
3318 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
3319
3321
3322 context.GetCompositor().SetNextPresentCallback(
3323 [&](FlutterViewId view_id, const FlutterLayer** layers,
3324 size_t layers_count) {
3325 ASSERT_EQ(layers_count, 0u);
3326 latch.Signal();
3327 });
3328
3329 auto engine = builder.LaunchEngine();
3330
3331 FlutterWindowMetricsEvent event = {};
3332 event.struct_size = sizeof(event);
3333 event.width = 300;
3334 event.height = 200;
3335 event.pixel_ratio = 1.0;
3337 kSuccess);
3338 ASSERT_TRUE(engine.is_valid());
3339 latch.Wait();
3340
3341 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
3342}

◆ TEST_F() [358/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderKnownScene   
)

Test the layer structure and pixels rendered when using a custom compositor.

Definition at line 686 of file embedder_gl_unittests.cc.

686 {
687 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
688
689 EmbedderConfigBuilder builder(context);
690 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
691 builder.SetCompositor();
692 builder.SetDartEntrypoint("can_composite_platform_views_with_known_scene");
693
694 builder.SetRenderTargetType(
695 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
696
697 fml::CountDownLatch latch(5);
698
699 auto scene_image = context.GetNextSceneImage();
700
701 context.GetCompositor().SetNextPresentCallback(
702 [&](FlutterViewId view_id, const FlutterLayer** layers,
703 size_t layers_count) {
704 ASSERT_EQ(layers_count, 5u);
705
706 // Layer Root
707 {
708 FlutterBackingStore backing_store = *layers[0]->backing_store;
709 backing_store.type = kFlutterBackingStoreTypeOpenGL;
710 backing_store.did_update = true;
712
713 FlutterRect paint_region_rects[] = {
714 FlutterRectMakeLTRB(0, 0, 800, 600),
715 };
716 FlutterRegion paint_region = {
717 .struct_size = sizeof(FlutterRegion),
718 .rects_count = 1,
719 .rects = paint_region_rects,
720 };
721 FlutterBackingStorePresentInfo present_info = {
723 .paint_region = &paint_region,
724 };
725
726 FlutterLayer layer = {};
727 layer.struct_size = sizeof(layer);
729 layer.backing_store = &backing_store;
730 layer.size = FlutterSizeMake(800.0, 600.0);
731 layer.offset = FlutterPointMake(0.0, 0.0);
732 layer.backing_store_present_info = &present_info;
733
734 ASSERT_EQ(*layers[0], layer);
735 }
736
737 // Layer 1
738 {
741 platform_view.identifier = 1;
742
743 FlutterLayer layer = {};
744 layer.struct_size = sizeof(layer);
747 layer.size = FlutterSizeMake(50.0, 150.0);
748 layer.offset = FlutterPointMake(20.0, 20.0);
749
750 ASSERT_EQ(*layers[1], layer);
751 }
752
753 // Layer 2
754 {
755 FlutterBackingStore backing_store = *layers[2]->backing_store;
756 backing_store.type = kFlutterBackingStoreTypeOpenGL;
757 backing_store.did_update = true;
759
760 FlutterRect paint_region_rects[] = {
761 FlutterRectMakeLTRB(30, 30, 80, 180),
762 };
763 FlutterRegion paint_region = {
764 .struct_size = sizeof(FlutterRegion),
765 .rects_count = 1,
766 .rects = paint_region_rects,
767 };
768 FlutterBackingStorePresentInfo present_info = {
770 .paint_region = &paint_region,
771 };
772
773 FlutterLayer layer = {};
774 layer.struct_size = sizeof(layer);
776 layer.backing_store = &backing_store;
777 layer.size = FlutterSizeMake(800.0, 600.0);
778 layer.offset = FlutterPointMake(0.0, 0.0);
779 layer.backing_store_present_info = &present_info;
780
781 ASSERT_EQ(*layers[2], layer);
782 }
783
784 // Layer 3
785 {
788 platform_view.identifier = 2;
789
790 FlutterLayer layer = {};
791 layer.struct_size = sizeof(layer);
794 layer.size = FlutterSizeMake(50.0, 150.0);
795 layer.offset = FlutterPointMake(40.0, 40.0);
796
797 ASSERT_EQ(*layers[3], layer);
798 }
799
800 // Layer 4
801 {
802 FlutterBackingStore backing_store = *layers[4]->backing_store;
803 backing_store.type = kFlutterBackingStoreTypeOpenGL;
804 backing_store.did_update = true;
806
807 FlutterRect paint_region_rects[] = {
808 FlutterRectMakeLTRB(50, 50, 100, 200),
809 };
810 FlutterRegion paint_region = {
811 .struct_size = sizeof(FlutterRegion),
812 .rects_count = 1,
813 .rects = paint_region_rects,
814 };
815 FlutterBackingStorePresentInfo present_info = {
817 .paint_region = &paint_region,
818 };
819
820 FlutterLayer layer = {};
821 layer.struct_size = sizeof(layer);
823 layer.backing_store = &backing_store;
824 layer.size = FlutterSizeMake(800.0, 600.0);
825 layer.offset = FlutterPointMake(0.0, 0.0);
826 layer.backing_store_present_info = &present_info;
827
828 ASSERT_EQ(*layers[4], layer);
829 }
830
831 latch.CountDown();
832 });
833
834 context.GetCompositor().SetPlatformViewRendererCallback(
835 [&](const FlutterLayer& layer,
836 GrDirectContext* context) -> sk_sp<SkImage> {
837 auto surface = CreateRenderSurface(layer, context);
838 auto canvas = surface->getCanvas();
839 FML_CHECK(canvas != nullptr);
840
841 switch (layer.platform_view->identifier) {
842 case 1: {
844 // See dart test for total order.
845 paint.setColor(SK_ColorGREEN);
846 paint.setAlpha(127);
847 const auto& rect =
848 SkRect::MakeWH(layer.size.width, layer.size.height);
849 canvas->drawRect(rect, paint);
850 latch.CountDown();
851 } break;
852 case 2: {
854 // See dart test for total order.
855 paint.setColor(SK_ColorMAGENTA);
856 paint.setAlpha(127);
857 const auto& rect =
858 SkRect::MakeWH(layer.size.width, layer.size.height);
859 canvas->drawRect(rect, paint);
860 latch.CountDown();
861 } break;
862 default:
863 // Asked to render an unknown platform view.
864 FML_CHECK(false)
865 << "Test was asked to composite an unknown platform view.";
866 }
867
868 return surface->makeImageSnapshot();
869 });
870
871 context.AddNativeCallback(
872 "SignalNativeTest",
874 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
875
876 auto engine = builder.LaunchEngine();
877
878 // Send a window metrics events so frames may be scheduled.
879 FlutterWindowMetricsEvent event = {};
880 event.struct_size = sizeof(event);
881 event.width = 800;
882 event.height = 600;
883 event.pixel_ratio = 1.0;
885 kSuccess);
886 ASSERT_TRUE(engine.is_valid());
887
888 latch.Wait();
889
890 ASSERT_TRUE(ImageMatchesFixture("compositor.png", scene_image));
891
892 // There should no present calls on the root surface.
893 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
894}

◆ TEST_F() [359/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderKnownSceneMetal   
)

Definition at line 316 of file embedder_metal_unittests.mm.

316 {
317 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
318
319 EmbedderConfigBuilder builder(context);
320 builder.SetMetalRendererConfig(SkISize::Make(800, 600));
321 builder.SetCompositor();
322 builder.SetDartEntrypoint("can_composite_platform_views_with_known_scene");
323
324 builder.SetRenderTargetType(EmbedderTestBackingStoreProducer::RenderTargetType::kMetalTexture);
325
326 fml::CountDownLatch latch(5);
327
328 auto scene_image = context.GetNextSceneImage();
329
330 context.GetCompositor().SetNextPresentCallback(
331 [&](FlutterViewId view_id, const FlutterLayer** layers, size_t layers_count) {
332 ASSERT_EQ(layers_count, 5u);
333
334 // Layer Root
335 {
336 FlutterBackingStore backing_store = *layers[0]->backing_store;
337 backing_store.type = kFlutterBackingStoreTypeMetal;
338 backing_store.did_update = true;
339
340 FlutterRect paint_region_rects[] = {
341 FlutterRectMakeLTRB(0, 0, 800, 600),
342 };
343 FlutterRegion paint_region = {
344 .struct_size = sizeof(FlutterRegion),
345 .rects_count = 1,
346 .rects = paint_region_rects,
347 };
348 FlutterBackingStorePresentInfo present_info = {
350 .paint_region = &paint_region,
351 };
352
353 FlutterLayer layer = {};
354 layer.struct_size = sizeof(layer);
356 layer.backing_store = &backing_store;
357 layer.size = FlutterSizeMake(800.0, 600.0);
358 layer.offset = FlutterPointMake(0.0, 0.0);
359 layer.backing_store_present_info = &present_info;
360
361 ASSERT_EQ(*layers[0], layer);
362 }
363
364 // Layer 1
365 {
368 platform_view.identifier = 1;
369
370 FlutterLayer layer = {};
371 layer.struct_size = sizeof(layer);
374 layer.size = FlutterSizeMake(50.0, 150.0);
375 layer.offset = FlutterPointMake(20.0, 20.0);
376
377 ASSERT_EQ(*layers[1], layer);
378 }
379
380 // Layer 2
381 {
382 FlutterBackingStore backing_store = *layers[2]->backing_store;
383 backing_store.type = kFlutterBackingStoreTypeMetal;
384 backing_store.did_update = true;
385
386 FlutterRect paint_region_rects[] = {
387 FlutterRectMakeLTRB(30, 30, 80, 180),
388 };
389 FlutterRegion paint_region = {
390 .struct_size = sizeof(FlutterRegion),
391 .rects_count = 1,
392 .rects = paint_region_rects,
393 };
394 FlutterBackingStorePresentInfo present_info = {
396 .paint_region = &paint_region,
397 };
398
399 FlutterLayer layer = {};
400 layer.struct_size = sizeof(layer);
402 layer.backing_store = &backing_store;
403 layer.size = FlutterSizeMake(800.0, 600.0);
404 layer.offset = FlutterPointMake(0.0, 0.0);
405 layer.backing_store_present_info = &present_info;
406
407 ASSERT_EQ(*layers[2], layer);
408 }
409
410 // Layer 3
411 {
414 platform_view.identifier = 2;
415
416 FlutterLayer layer = {};
417 layer.struct_size = sizeof(layer);
420 layer.size = FlutterSizeMake(50.0, 150.0);
421 layer.offset = FlutterPointMake(40.0, 40.0);
422
423 ASSERT_EQ(*layers[3], layer);
424 }
425
426 // Layer 4
427 {
428 FlutterBackingStore backing_store = *layers[4]->backing_store;
429 backing_store.type = kFlutterBackingStoreTypeMetal;
430 backing_store.did_update = true;
431
432 FlutterRect paint_region_rects[] = {
433 FlutterRectMakeLTRB(50, 50, 100, 200),
434 };
435 FlutterRegion paint_region = {
436 .struct_size = sizeof(FlutterRegion),
437 .rects_count = 1,
438 .rects = paint_region_rects,
439 };
440 FlutterBackingStorePresentInfo present_info = {
442 .paint_region = &paint_region,
443 };
444
445 FlutterLayer layer = {};
446 layer.struct_size = sizeof(layer);
448 layer.backing_store = &backing_store;
449 layer.size = FlutterSizeMake(800.0, 600.0);
450 layer.offset = FlutterPointMake(0.0, 0.0);
451 layer.backing_store_present_info = &present_info;
452
453 ASSERT_EQ(*layers[4], layer);
454 }
455
456 latch.CountDown();
457 });
458
459 context.GetCompositor().SetPlatformViewRendererCallback(
460 [&](const FlutterLayer& layer, GrDirectContext* context) -> sk_sp<SkImage> {
461 auto surface = CreateRenderSurface(layer, context);
462 auto canvas = surface->getCanvas();
463 FML_CHECK(canvas != nullptr);
464
465 switch (layer.platform_view->identifier) {
466 case 1: {
468 // See dart test for total order.
469 paint.setColor(SK_ColorGREEN);
470 paint.setAlpha(127);
471 const auto& rect = SkRect::MakeWH(layer.size.width, layer.size.height);
472 canvas->drawRect(rect, paint);
473 latch.CountDown();
474 } break;
475 case 2: {
477 // See dart test for total order.
478 paint.setColor(SK_ColorMAGENTA);
479 paint.setAlpha(127);
480 const auto& rect = SkRect::MakeWH(layer.size.width, layer.size.height);
481 canvas->drawRect(rect, paint);
482 latch.CountDown();
483 } break;
484 default:
485 // Asked to render an unknown platform view.
486 FML_CHECK(false) << "Test was asked to composite an unknown platform view.";
487 }
488
489 return surface->makeImageSnapshot();
490 });
491
492 context.AddNativeCallback(
493 "SignalNativeTest",
494 CREATE_NATIVE_ENTRY([&latch](Dart_NativeArguments args) { latch.CountDown(); }));
495
496 auto engine = builder.LaunchEngine();
497
498 // Send a window metrics events so frames may be scheduled.
499 FlutterWindowMetricsEvent event = {};
500 event.struct_size = sizeof(event);
501 // Flutter still thinks it is 800 x 600. Only the root surface is rotated.
502 event.width = 800;
503 event.height = 600;
504 event.pixel_ratio = 1.0;
506 ASSERT_TRUE(engine.is_valid());
507
508 latch.Wait();
509
510 ASSERT_TRUE(ImageMatchesFixture("compositor.png", scene_image));
511}

◆ TEST_F() [360/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurfaceWithRootSurfaceXformation   
)

Definition at line 2309 of file embedder_gl_unittests.cc.

2311 {
2312 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2313
2314 EmbedderConfigBuilder builder(context);
2315 builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
2316 builder.SetCompositor();
2317 builder.SetDartEntrypoint("can_display_platform_view_with_pixel_ratio");
2318
2319 builder.SetRenderTargetType(
2320 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
2321
2322 const auto root_surface_transformation =
2323 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
2324
2325 context.SetRootSurfaceTransformation(root_surface_transformation);
2326
2327 auto rendered_scene = context.GetNextSceneImage();
2328 fml::CountDownLatch latch(1);
2329
2330 context.GetCompositor().SetNextPresentCallback(
2331 [&](FlutterViewId view_id, const FlutterLayer** layers,
2332 size_t layers_count) {
2333 ASSERT_EQ(layers_count, 3u);
2334
2335 // Layer 0 (Root)
2336 {
2337 FlutterBackingStore backing_store = *layers[0]->backing_store;
2338 backing_store.type = kFlutterBackingStoreTypeOpenGL;
2339 backing_store.did_update = true;
2341
2342 FlutterRect paint_region_rects[] = {
2343 FlutterRectMakeLTRB(0, 0, 600, 800),
2344 };
2345 FlutterRegion paint_region = {
2346 .struct_size = sizeof(FlutterRegion),
2347 .rects_count = 1,
2348 .rects = paint_region_rects,
2349 };
2350 FlutterBackingStorePresentInfo present_info = {
2352 .paint_region = &paint_region,
2353 };
2354
2355 FlutterLayer layer = {};
2356 layer.struct_size = sizeof(layer);
2358 layer.backing_store = &backing_store;
2359 layer.size = FlutterSizeMake(600.0, 800.0);
2360 layer.offset = FlutterPointMake(0.0, 0.0);
2361 layer.backing_store_present_info = &present_info;
2362
2363 ASSERT_EQ(*layers[0], layer);
2364 }
2365
2366 // Layer 1
2367 {
2370 platform_view.identifier = 42;
2371
2372 FlutterLayer layer = {};
2373 layer.struct_size = sizeof(layer);
2376 layer.size = FlutterSizeMake(560.0, 800.0);
2377 layer.offset = FlutterPointMake(40.0, 0.0);
2378
2379 ASSERT_EQ(*layers[1], layer);
2380 }
2381
2382 // Layer 2
2383 {
2384 FlutterBackingStore backing_store = *layers[2]->backing_store;
2385 backing_store.type = kFlutterBackingStoreTypeOpenGL;
2386 backing_store.did_update = true;
2388
2389 FlutterRect paint_region_rects[] = {
2390 FlutterRectMakeLTRB(0, 0, 600, 800),
2391 };
2392 FlutterRegion paint_region = {
2393 .struct_size = sizeof(FlutterRegion),
2394 .rects_count = 1,
2395 .rects = paint_region_rects,
2396 };
2397 FlutterBackingStorePresentInfo present_info = {
2399 .paint_region = &paint_region,
2400 };
2401
2402 FlutterLayer layer = {};
2403 layer.struct_size = sizeof(layer);
2405 layer.backing_store = &backing_store;
2406 layer.size = FlutterSizeMake(600.0, 800.0);
2407 layer.offset = FlutterPointMake(0.0, 0.0);
2408 layer.backing_store_present_info = &present_info;
2409
2410 ASSERT_EQ(*layers[2], layer);
2411 }
2412
2413 latch.CountDown();
2414 });
2415
2416 auto engine = builder.LaunchEngine();
2417
2418 // Send a window metrics events so frames may be scheduled.
2419 FlutterWindowMetricsEvent event = {};
2420 event.struct_size = sizeof(event);
2421 event.width = 400 * 2.0;
2422 event.height = 300 * 2.0;
2423 event.pixel_ratio = 2.0;
2425 kSuccess);
2426 ASSERT_TRUE(engine.is_valid());
2427
2428 latch.Wait();
2429
2430 ASSERT_TRUE(ImageMatchesFixture("dpr_xform.png", rendered_scene));
2431}

◆ TEST_F() [361/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderKnownSceneWithRootSurfaceTransformation   
)

Test the layer structure and pixels rendered when using a custom compositor with a root surface transformation.

Definition at line 1277 of file embedder_gl_unittests.cc.

1278 {
1279 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1280
1281 EmbedderConfigBuilder builder(context);
1282 builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
1283 builder.SetCompositor();
1284 builder.SetDartEntrypoint("can_composite_platform_views_with_known_scene");
1285
1286 builder.SetRenderTargetType(
1287 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
1288
1289 // This must match the transformation provided in the
1290 // |CanRenderGradientWithoutCompositorWithXform| test to ensure that
1291 // transforms are consistent respected.
1292 const auto root_surface_transformation =
1293 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
1294
1295 context.SetRootSurfaceTransformation(root_surface_transformation);
1296
1297 fml::CountDownLatch latch(5);
1298
1299 auto scene_image = context.GetNextSceneImage();
1300
1301 context.GetCompositor().SetNextPresentCallback(
1302 [&](FlutterViewId view_id, const FlutterLayer** layers,
1303 size_t layers_count) {
1304 ASSERT_EQ(layers_count, 5u);
1305
1306 // Layer Root
1307 {
1308 FlutterBackingStore backing_store = *layers[0]->backing_store;
1309 backing_store.type = kFlutterBackingStoreTypeOpenGL;
1310 backing_store.did_update = true;
1312
1313 FlutterRect paint_region_rects[] = {
1314 FlutterRectMakeLTRB(0, 0, 600, 800),
1315 };
1316 FlutterRegion paint_region = {
1317 .struct_size = sizeof(FlutterRegion),
1318 .rects_count = 1,
1319 .rects = paint_region_rects,
1320 };
1321 FlutterBackingStorePresentInfo present_info = {
1323 .paint_region = &paint_region,
1324 };
1325
1326 FlutterLayer layer = {};
1327 layer.struct_size = sizeof(layer);
1329 layer.backing_store = &backing_store;
1330 layer.size = FlutterSizeMake(600.0, 800.0);
1331 layer.offset = FlutterPointMake(0.0, 0.0);
1332 layer.backing_store_present_info = &present_info;
1333
1334 ASSERT_EQ(*layers[0], layer);
1335 }
1336
1337 // Layer 1
1338 {
1341 platform_view.identifier = 1;
1342
1343 FlutterLayer layer = {};
1344 layer.struct_size = sizeof(layer);
1347 layer.size = FlutterSizeMake(150.0, 50.0);
1348 layer.offset = FlutterPointMake(20.0, 730.0);
1349
1350 ASSERT_EQ(*layers[1], layer);
1351 }
1352
1353 // Layer 2
1354 {
1355 FlutterBackingStore backing_store = *layers[2]->backing_store;
1356 backing_store.type = kFlutterBackingStoreTypeOpenGL;
1357 backing_store.did_update = true;
1359
1360 FlutterRect paint_region_rects[] = {
1361 FlutterRectMakeLTRB(30, 720, 180, 770),
1362 };
1363 FlutterRegion paint_region = {
1364 .struct_size = sizeof(FlutterRegion),
1365 .rects_count = 1,
1366 .rects = paint_region_rects,
1367 };
1368 FlutterBackingStorePresentInfo present_info = {
1370 .paint_region = &paint_region,
1371 };
1372
1373 FlutterLayer layer = {};
1374 layer.struct_size = sizeof(layer);
1376 layer.backing_store = &backing_store;
1377 layer.size = FlutterSizeMake(600.0, 800.0);
1378 layer.offset = FlutterPointMake(0.0, 0.0);
1379 layer.backing_store_present_info = &present_info;
1380
1381 ASSERT_EQ(*layers[2], layer);
1382 }
1383
1384 // Layer 3
1385 {
1388 platform_view.identifier = 2;
1389
1390 FlutterLayer layer = {};
1391 layer.struct_size = sizeof(layer);
1394 layer.size = FlutterSizeMake(150.0, 50.0);
1395 layer.offset = FlutterPointMake(40.0, 710.0);
1396
1397 ASSERT_EQ(*layers[3], layer);
1398 }
1399
1400 // Layer 4
1401 {
1402 FlutterBackingStore backing_store = *layers[4]->backing_store;
1403 backing_store.type = kFlutterBackingStoreTypeOpenGL;
1404 backing_store.did_update = true;
1406
1407 FlutterRect paint_region_rects[] = {
1408 FlutterRectMakeLTRB(50, 700, 200, 750),
1409 };
1410 FlutterRegion paint_region = {
1411 .struct_size = sizeof(FlutterRegion),
1412 .rects_count = 1,
1413 .rects = paint_region_rects,
1414 };
1415 FlutterBackingStorePresentInfo present_info = {
1417 .paint_region = &paint_region,
1418 };
1419
1420 FlutterLayer layer = {};
1421 layer.struct_size = sizeof(layer);
1423 layer.backing_store = &backing_store;
1424 layer.size = FlutterSizeMake(600.0, 800.0);
1425 layer.offset = FlutterPointMake(0.0, 0.0);
1426 layer.backing_store_present_info = &present_info;
1427
1428 ASSERT_EQ(*layers[4], layer);
1429 }
1430
1431 latch.CountDown();
1432 });
1433
1434 context.GetCompositor().SetPlatformViewRendererCallback(
1435 [&](const FlutterLayer& layer,
1436 GrDirectContext* context) -> sk_sp<SkImage> {
1437 auto surface = CreateRenderSurface(layer, context);
1438 auto canvas = surface->getCanvas();
1439 FML_CHECK(canvas != nullptr);
1440
1441 switch (layer.platform_view->identifier) {
1442 case 1: {
1443 SkPaint paint;
1444 // See dart test for total order.
1445 paint.setColor(SK_ColorGREEN);
1446 paint.setAlpha(127);
1447 const auto& rect =
1448 SkRect::MakeWH(layer.size.width, layer.size.height);
1449 canvas->drawRect(rect, paint);
1450 latch.CountDown();
1451 } break;
1452 case 2: {
1453 SkPaint paint;
1454 // See dart test for total order.
1455 paint.setColor(SK_ColorMAGENTA);
1456 paint.setAlpha(127);
1457 const auto& rect =
1458 SkRect::MakeWH(layer.size.width, layer.size.height);
1459 canvas->drawRect(rect, paint);
1460 latch.CountDown();
1461 } break;
1462 default:
1463 // Asked to render an unknown platform view.
1464 FML_CHECK(false)
1465 << "Test was asked to composite an unknown platform view.";
1466 }
1467
1468 return surface->makeImageSnapshot();
1469 });
1470
1471 context.AddNativeCallback(
1472 "SignalNativeTest",
1474 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
1475
1476 auto engine = builder.LaunchEngine();
1477
1478 // Send a window metrics events so frames may be scheduled.
1479 FlutterWindowMetricsEvent event = {};
1480 event.struct_size = sizeof(event);
1481 // Flutter still thinks it is 800 x 600. Only the root surface is rotated.
1482 event.width = 800;
1483 event.height = 600;
1484 event.pixel_ratio = 1.0;
1486 kSuccess);
1487 ASSERT_TRUE(engine.is_valid());
1488
1489 latch.Wait();
1490
1491 ASSERT_TRUE(ImageMatchesFixture("compositor_root_surface_xformation.png",
1492 scene_image));
1493}

◆ TEST_F() [362/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor   
)

Test the layer structure and pixels rendered when using a custom software compositor.

Definition at line 718 of file embedder_unittests.cc.

719 {
720#endif // FML_OS_MACOSX && FML_ARCH_CPU_ARM64
721
722 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
723
724 EmbedderConfigBuilder builder(context);
725 builder.SetSoftwareRendererConfig(SkISize::Make(800, 600));
726 builder.SetCompositor();
727 builder.SetDartEntrypoint("can_composite_platform_views_with_known_scene");
728
729 builder.SetRenderTargetType(
730 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
731
732 fml::CountDownLatch latch(5);
733
734 auto scene_image = context.GetNextSceneImage();
735
736 context.GetCompositor().SetNextPresentCallback(
737 [&](FlutterViewId view_id, const FlutterLayer** layers,
738 size_t layers_count) {
739 ASSERT_EQ(layers_count, 5u);
740
741 // Layer Root
742 {
743 FlutterBackingStore backing_store = *layers[0]->backing_store;
745 backing_store.did_update = true;
746 backing_store.software.height = 600;
747
748 FlutterRect paint_region_rects[] = {
749 FlutterRectMakeLTRB(0, 0, 800, 600),
750 };
751 FlutterRegion paint_region = {
752 .struct_size = sizeof(FlutterRegion),
753 .rects_count = 1,
754 .rects = paint_region_rects,
755 };
756 FlutterBackingStorePresentInfo present_info = {
758 .paint_region = &paint_region,
759 };
760
761 FlutterLayer layer = {};
762 layer.struct_size = sizeof(layer);
764 layer.backing_store = &backing_store;
765 layer.size = FlutterSizeMake(800.0, 600.0);
766 layer.offset = FlutterPointMake(0.0, 0.0);
767 layer.backing_store_present_info = &present_info;
768
769 ASSERT_EQ(*layers[0], layer);
770 }
771
772 // Layer 1
773 {
776 platform_view.identifier = 1;
777
778 FlutterLayer layer = {};
779 layer.struct_size = sizeof(layer);
782 layer.size = FlutterSizeMake(50.0, 150.0);
783 layer.offset = FlutterPointMake(20.0, 20.0);
784
785 ASSERT_EQ(*layers[1], layer);
786 }
787
788 // Layer 2
789 {
790 FlutterBackingStore backing_store = *layers[2]->backing_store;
792 backing_store.did_update = true;
793 backing_store.software.height = 600;
794
795 FlutterRect paint_region_rects[] = {
796 FlutterRectMakeLTRB(30, 30, 80, 180),
797 };
798 FlutterRegion paint_region = {
799 .struct_size = sizeof(FlutterRegion),
800 .rects_count = 1,
801 .rects = paint_region_rects,
802 };
803 FlutterBackingStorePresentInfo present_info = {
805 .paint_region = &paint_region,
806 };
807
808 FlutterLayer layer = {};
809 layer.struct_size = sizeof(layer);
811 layer.backing_store = &backing_store;
812 layer.size = FlutterSizeMake(800.0, 600.0);
813 layer.offset = FlutterPointMake(0.0, 0.0);
814 layer.backing_store_present_info = &present_info;
815
816 ASSERT_EQ(*layers[2], layer);
817 }
818
819 // Layer 3
820 {
823 platform_view.identifier = 2;
824
825 FlutterLayer layer = {};
826 layer.struct_size = sizeof(layer);
829 layer.size = FlutterSizeMake(50.0, 150.0);
830 layer.offset = FlutterPointMake(40.0, 40.0);
831
832 ASSERT_EQ(*layers[3], layer);
833 }
834
835 // Layer 4
836 {
837 FlutterBackingStore backing_store = *layers[4]->backing_store;
839 backing_store.did_update = true;
840 backing_store.software.height = 600;
841
842 FlutterRect paint_region_rects[] = {
843 FlutterRectMakeLTRB(50, 50, 100, 200),
844 };
845 FlutterRegion paint_region = {
846 .struct_size = sizeof(FlutterRegion),
847 .rects_count = 1,
848 .rects = paint_region_rects,
849 };
850 FlutterBackingStorePresentInfo present_info = {
852 .paint_region = &paint_region,
853 };
854
855 FlutterLayer layer = {};
856 layer.struct_size = sizeof(layer);
858 layer.backing_store = &backing_store;
859 layer.size = FlutterSizeMake(800.0, 600.0);
860 layer.offset = FlutterPointMake(0.0, 0.0);
861 layer.backing_store_present_info = &present_info;
862
863 ASSERT_EQ(*layers[4], layer);
864 }
865
866 latch.CountDown();
867 });
868
869 context.GetCompositor().SetPlatformViewRendererCallback(
870 [&](const FlutterLayer& layer, GrDirectContext*
871 /* don't use because software compositor */) -> sk_sp<SkImage> {
873 layer, nullptr /* null because software compositor */);
874 auto canvas = surface->getCanvas();
875 FML_CHECK(canvas != nullptr);
876
877 switch (layer.platform_view->identifier) {
878 case 1: {
880 // See dart test for total order.
881 paint.setColor(SK_ColorGREEN);
882 paint.setAlpha(127);
883 const auto& rect =
884 SkRect::MakeWH(layer.size.width, layer.size.height);
885 canvas->drawRect(rect, paint);
886 latch.CountDown();
887 } break;
888 case 2: {
890 // See dart test for total order.
891 paint.setColor(SK_ColorMAGENTA);
892 paint.setAlpha(127);
893 const auto& rect =
894 SkRect::MakeWH(layer.size.width, layer.size.height);
895 canvas->drawRect(rect, paint);
896 latch.CountDown();
897 } break;
898 default:
899 // Asked to render an unknown platform view.
900 FML_CHECK(false)
901 << "Test was asked to composite an unknown platform view.";
902 }
903
904 return surface->makeImageSnapshot();
905 });
906
907 context.AddNativeCallback(
908 "SignalNativeTest",
910 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
911
912 auto engine = builder.LaunchEngine();
913
914 // Send a window metrics events so frames may be scheduled.
915 FlutterWindowMetricsEvent event = {};
916 event.struct_size = sizeof(event);
917 event.width = 800;
918 event.height = 600;
919 event.pixel_ratio = 1.0;
920 event.physical_view_inset_top = 0.0;
921 event.physical_view_inset_right = 0.0;
922 event.physical_view_inset_bottom = 0.0;
923 event.physical_view_inset_left = 0.0;
925 kSuccess);
926 ASSERT_TRUE(engine.is_valid());
927
928 latch.Wait();
929
930 ASSERT_TRUE(ImageMatchesFixture("compositor_software.png", scene_image));
931
932 // There should no present calls on the root surface.
933 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
934}
size_t height
The number of rows in the allocation.
Definition embedder.h:1625

◆ TEST_F() [363/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderToOpenGLFramebuffer   
)

Must be able to render to a custom compositor whose render targets are fully complete OpenGL textures.

Definition at line 105 of file embedder_gl_unittests.cc.

105 {
106 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
107
108 EmbedderConfigBuilder builder(context);
109 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
110 builder.SetCompositor();
111 builder.SetDartEntrypoint("can_composite_platform_views");
112
113 builder.SetRenderTargetType(
114 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
115
116 fml::CountDownLatch latch(3);
117 context.GetCompositor().SetNextPresentCallback(
118 [&](FlutterViewId view_id, const FlutterLayer** layers,
119 size_t layers_count) {
120 ASSERT_EQ(layers_count, 3u);
121
122 {
123 FlutterBackingStore backing_store = *layers[0]->backing_store;
124 backing_store.struct_size = sizeof(backing_store);
125 backing_store.type = kFlutterBackingStoreTypeOpenGL;
126 backing_store.did_update = true;
128
129 FlutterRect paint_region_rects[] = {
130 FlutterRectMakeLTRB(0, 0, 800, 600),
131 };
132 FlutterRegion paint_region = {
133 .struct_size = sizeof(FlutterRegion),
134 .rects_count = 1,
135 .rects = paint_region_rects,
136 };
137 FlutterBackingStorePresentInfo present_info = {
139 .paint_region = &paint_region,
140 };
141
142 FlutterLayer layer = {};
143 layer.struct_size = sizeof(layer);
145 layer.backing_store = &backing_store;
146 layer.size = FlutterSizeMake(800.0, 600.0);
147 layer.offset = FlutterPointMake(0, 0);
148 layer.backing_store_present_info = &present_info;
149
150 ASSERT_EQ(*layers[0], layer);
151 }
152
153 {
156 platform_view.identifier = 42;
157
158 FlutterLayer layer = {};
159 layer.struct_size = sizeof(layer);
162 layer.size = FlutterSizeMake(123.0, 456.0);
163 layer.offset = FlutterPointMake(1.0, 2.0);
164
165 ASSERT_EQ(*layers[1], layer);
166 }
167
168 {
169 FlutterBackingStore backing_store = *layers[2]->backing_store;
170 backing_store.struct_size = sizeof(backing_store);
171 backing_store.type = kFlutterBackingStoreTypeOpenGL;
172 backing_store.did_update = true;
174
175 FlutterRect paint_region_rects[] = {
176 FlutterRectMakeLTRB(2, 3, 800, 600),
177 };
178 FlutterRegion paint_region = {
179 .struct_size = sizeof(FlutterRegion),
180 .rects_count = 1,
181 .rects = paint_region_rects,
182 };
183 FlutterBackingStorePresentInfo present_info = {
185 .paint_region = &paint_region,
186 };
187
188 FlutterLayer layer = {};
189 layer.struct_size = sizeof(layer);
191 layer.backing_store = &backing_store;
192 layer.size = FlutterSizeMake(800.0, 600.0);
193 layer.offset = FlutterPointMake(0.0, 0.0);
194 layer.backing_store_present_info = &present_info;
195
196 ASSERT_EQ(*layers[2], layer);
197 }
198
199 latch.CountDown();
200 });
201
202 context.AddNativeCallback(
203 "SignalNativeTest",
205 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
206
207 auto engine = builder.LaunchEngine();
208
209 // Send a window metrics events so frames may be scheduled.
210 FlutterWindowMetricsEvent event = {};
211 event.struct_size = sizeof(event);
212 event.width = 800;
213 event.height = 600;
214 event.pixel_ratio = 1.0;
216 kSuccess);
217 ASSERT_TRUE(engine.is_valid());
218
219 latch.Wait();
220}
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStore).
Definition embedder.h:1754

◆ TEST_F() [364/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderToOpenGLTexture   
)

Must be able to render using a custom compositor whose render targets for the individual layers are OpenGL textures.

Definition at line 444 of file embedder_gl_unittests.cc.

444 {
445 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
446
447 EmbedderConfigBuilder builder(context);
448 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
449 builder.SetCompositor();
450 builder.SetDartEntrypoint("can_composite_platform_views");
451
452 builder.SetRenderTargetType(
453 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
454
455 fml::CountDownLatch latch(3);
456 context.GetCompositor().SetNextPresentCallback(
457 [&](FlutterViewId view_id, const FlutterLayer** layers,
458 size_t layers_count) {
459 ASSERT_EQ(layers_count, 3u);
460
461 {
462 FlutterBackingStore backing_store = *layers[0]->backing_store;
463 backing_store.struct_size = sizeof(backing_store);
464 backing_store.type = kFlutterBackingStoreTypeOpenGL;
465 backing_store.did_update = true;
467
468 FlutterRect paint_region_rects[] = {
469 FlutterRectMakeLTRB(0, 0, 800, 600),
470 };
471 FlutterRegion paint_region = {
472 .struct_size = sizeof(FlutterRegion),
473 .rects_count = 1,
474 .rects = paint_region_rects,
475 };
476 FlutterBackingStorePresentInfo present_info = {
478 .paint_region = &paint_region,
479 };
480
481 FlutterLayer layer = {};
482 layer.struct_size = sizeof(layer);
484 layer.backing_store = &backing_store;
485 layer.size = FlutterSizeMake(800.0, 600.0);
486 layer.offset = FlutterPointMake(0, 0);
487 layer.backing_store_present_info = &present_info;
488
489 ASSERT_EQ(*layers[0], layer);
490 }
491
492 {
495 platform_view.identifier = 42;
496
497 FlutterLayer layer = {};
498 layer.struct_size = sizeof(layer);
501 layer.size = FlutterSizeMake(123.0, 456.0);
502 layer.offset = FlutterPointMake(1.0, 2.0);
503
504 ASSERT_EQ(*layers[1], layer);
505 }
506
507 {
508 FlutterBackingStore backing_store = *layers[2]->backing_store;
509 backing_store.struct_size = sizeof(backing_store);
510 backing_store.type = kFlutterBackingStoreTypeOpenGL;
511 backing_store.did_update = true;
513
514 FlutterRect paint_region_rects[] = {
515 FlutterRectMakeLTRB(2, 3, 800, 600),
516 };
517 FlutterRegion paint_region = {
518 .struct_size = sizeof(FlutterRegion),
519 .rects_count = 1,
520 .rects = paint_region_rects,
521 };
522 FlutterBackingStorePresentInfo present_info = {
524 .paint_region = &paint_region,
525 };
526
527 FlutterLayer layer = {};
528 layer.struct_size = sizeof(layer);
530 layer.backing_store = &backing_store;
531 layer.size = FlutterSizeMake(800.0, 600.0);
532 layer.offset = FlutterPointMake(0.0, 0.0);
533 layer.backing_store_present_info = &present_info;
534
535 ASSERT_EQ(*layers[2], layer);
536 }
537
538 latch.CountDown();
539 });
540
541 context.AddNativeCallback(
542 "SignalNativeTest",
544 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
545
546 auto engine = builder.LaunchEngine();
547
548 // Send a window metrics events so frames may be scheduled.
549 FlutterWindowMetricsEvent event = {};
550 event.struct_size = sizeof(event);
551 event.width = 800;
552 event.height = 600;
553 event.pixel_ratio = 1.0;
555 kSuccess);
556 ASSERT_TRUE(engine.is_valid());
557
558 latch.Wait();
559}

◆ TEST_F() [365/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderToSoftwareBuffer   
)

Must be able to render using a custom compositor whose render target for the individual layers are software buffers.

Definition at line 565 of file embedder_gl_unittests.cc.

565 {
566 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
567
568 EmbedderConfigBuilder builder(context);
569 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
570 builder.SetCompositor();
571 builder.SetDartEntrypoint("can_composite_platform_views");
572
573 builder.SetRenderTargetType(
574 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
575
576 fml::CountDownLatch latch(3);
577 context.GetCompositor().SetNextPresentCallback(
578 [&](FlutterViewId view_id, const FlutterLayer** layers,
579 size_t layers_count) {
580 ASSERT_EQ(layers_count, 3u);
581
582 {
583 FlutterBackingStore backing_store = *layers[0]->backing_store;
584 backing_store.struct_size = sizeof(backing_store);
586 backing_store.did_update = true;
587 ASSERT_FLOAT_EQ(
588 backing_store.software.row_bytes * backing_store.software.height,
589 800 * 4 * 600.0);
590
591 FlutterRect paint_region_rects[] = {
592 FlutterRectMakeLTRB(0, 0, 800, 600),
593 };
594 FlutterRegion paint_region = {
595 .struct_size = sizeof(FlutterRegion),
596 .rects_count = 1,
597 .rects = paint_region_rects,
598 };
599 FlutterBackingStorePresentInfo present_info = {
601 .paint_region = &paint_region,
602 };
603
604 FlutterLayer layer = {};
605 layer.struct_size = sizeof(layer);
607 layer.backing_store = &backing_store;
608 layer.size = FlutterSizeMake(800.0, 600.0);
609 layer.offset = FlutterPointMake(0, 0);
610 layer.backing_store_present_info = &present_info;
611
612 ASSERT_EQ(*layers[0], layer);
613 }
614
615 {
618 platform_view.identifier = 42;
619
620 FlutterLayer layer = {};
621 layer.struct_size = sizeof(layer);
624 layer.size = FlutterSizeMake(123.0, 456.0);
625 layer.offset = FlutterPointMake(1.0, 2.0);
626
627 ASSERT_EQ(*layers[1], layer);
628 }
629
630 {
631 FlutterBackingStore backing_store = *layers[2]->backing_store;
632 backing_store.struct_size = sizeof(backing_store);
634 backing_store.did_update = true;
635
636 FlutterRect paint_region_rects[] = {
637 FlutterRectMakeLTRB(2, 3, 800, 600),
638 };
639 FlutterRegion paint_region = {
640 .struct_size = sizeof(FlutterRegion),
641 .rects_count = 1,
642 .rects = paint_region_rects,
643 };
644 FlutterBackingStorePresentInfo present_info = {
646 .paint_region = &paint_region,
647 };
648
649 FlutterLayer layer = {};
650 layer.struct_size = sizeof(layer);
652 layer.backing_store = &backing_store;
653 layer.size = FlutterSizeMake(800.0, 600.0);
654 layer.offset = FlutterPointMake(0.0, 0.0);
655 layer.backing_store_present_info = &present_info;
656
657 ASSERT_EQ(*layers[2], layer);
658 }
659
660 latch.CountDown();
661 });
662
663 context.AddNativeCallback(
664 "SignalNativeTest",
666 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
667
668 auto engine = builder.LaunchEngine();
669
670 // Send a window metrics events so frames may be scheduled.
671 FlutterWindowMetricsEvent event = {};
672 event.struct_size = sizeof(event);
673 event.width = 800;
674 event.height = 600;
675 event.pixel_ratio = 1.0;
677 kSuccess);
678 ASSERT_TRUE(engine.is_valid());
679
680 latch.Wait();
681}
size_t row_bytes
The number of bytes in a single row of the allocation.
Definition embedder.h:1623

◆ TEST_F() [366/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderWithPlatformLayerOnBottom   
)

Test the layer structure and pixels rendered when using a custom compositor and ensure that a redundant layer is not added.

Definition at line 1150 of file embedder_gl_unittests.cc.

1150 {
1151 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1152
1153 EmbedderConfigBuilder builder(context);
1154 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
1155 builder.SetCompositor();
1156 builder.SetDartEntrypoint(
1157 "can_composite_platform_views_with_platform_layer_on_bottom");
1158
1159 builder.SetRenderTargetType(
1160 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
1161
1162 fml::CountDownLatch latch(3);
1163
1164 auto scene_image = context.GetNextSceneImage();
1165
1166 context.GetCompositor().SetNextPresentCallback(
1167 [&](FlutterViewId view_id, const FlutterLayer** layers,
1168 size_t layers_count) {
1169 ASSERT_EQ(layers_count, 2u);
1170
1171 // Layer Root
1172 {
1173 FlutterBackingStore backing_store = *layers[0]->backing_store;
1174 backing_store.type = kFlutterBackingStoreTypeOpenGL;
1175 backing_store.did_update = true;
1177
1178 FlutterRect paint_region_rects[] = {
1179 FlutterRectMakeLTRB(0, 0, 800, 600),
1180 };
1181 FlutterRegion paint_region = {
1182 .struct_size = sizeof(FlutterRegion),
1183 .rects_count = 1,
1184 .rects = paint_region_rects,
1185 };
1186 FlutterBackingStorePresentInfo present_info = {
1188 .paint_region = &paint_region,
1189 };
1190
1191 FlutterLayer layer = {};
1192 layer.struct_size = sizeof(layer);
1194 layer.backing_store = &backing_store;
1195 layer.size = FlutterSizeMake(800.0, 600.0);
1196 layer.offset = FlutterPointMake(0.0, 0.0);
1197 layer.backing_store_present_info = &present_info;
1198
1199 ASSERT_EQ(*layers[0], layer);
1200 }
1201
1202 // Layer 1
1203 {
1206 platform_view.identifier = 1;
1207
1208 FlutterLayer layer = {};
1209 layer.struct_size = sizeof(layer);
1212 layer.size = FlutterSizeMake(50.0, 150.0);
1213 layer.offset = FlutterPointMake(20.0, 20.0);
1214
1215 ASSERT_EQ(*layers[1], layer);
1216 }
1217
1218 latch.CountDown();
1219 });
1220
1221 context.GetCompositor().SetPlatformViewRendererCallback(
1222 [&](const FlutterLayer& layer,
1223 GrDirectContext* context) -> sk_sp<SkImage> {
1224 auto surface = CreateRenderSurface(layer, context);
1225 auto canvas = surface->getCanvas();
1226 FML_CHECK(canvas != nullptr);
1227
1228 switch (layer.platform_view->identifier) {
1229 case 1: {
1230 SkPaint paint;
1231 // See dart test for total order.
1232 paint.setColor(SK_ColorGREEN);
1233 paint.setAlpha(127);
1234 const auto& rect =
1235 SkRect::MakeWH(layer.size.width, layer.size.height);
1236 canvas->drawRect(rect, paint);
1237 latch.CountDown();
1238 } break;
1239 default:
1240 // Asked to render an unknown platform view.
1241 FML_CHECK(false)
1242 << "Test was asked to composite an unknown platform view.";
1243 }
1244
1245 return surface->makeImageSnapshot();
1246 });
1247
1248 context.AddNativeCallback(
1249 "SignalNativeTest",
1251 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
1252
1253 auto engine = builder.LaunchEngine();
1254
1255 // Send a window metrics events so frames may be scheduled.
1256 FlutterWindowMetricsEvent event = {};
1257 event.struct_size = sizeof(event);
1258 event.width = 800;
1259 event.height = 600;
1260 event.pixel_ratio = 1.0;
1262 kSuccess);
1263 ASSERT_TRUE(engine.is_valid());
1264
1265 latch.Wait();
1266
1267 ASSERT_TRUE(ImageMatchesFixture(
1268 "compositor_with_platform_layer_on_bottom.png", scene_image));
1269
1270 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 1u);
1271}

◆ TEST_F() [367/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderWithRootLayerOnly   
)

Test the layer structure and pixels rendered when using a custom compositor and a single layer.

Definition at line 1068 of file embedder_gl_unittests.cc.

1068 {
1069 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1070
1071 EmbedderConfigBuilder builder(context);
1072 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
1073 builder.SetCompositor();
1074 builder.SetDartEntrypoint(
1075 "can_composite_platform_views_with_root_layer_only");
1076
1077 builder.SetRenderTargetType(
1078 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
1079
1080 fml::CountDownLatch latch(3);
1081
1082 auto scene_image = context.GetNextSceneImage();
1083
1084 context.GetCompositor().SetNextPresentCallback(
1085 [&](FlutterViewId view_id, const FlutterLayer** layers,
1086 size_t layers_count) {
1087 ASSERT_EQ(layers_count, 1u);
1088
1089 // Layer Root
1090 {
1091 FlutterBackingStore backing_store = *layers[0]->backing_store;
1092 backing_store.type = kFlutterBackingStoreTypeOpenGL;
1093 backing_store.did_update = true;
1095
1096 FlutterRect paint_region_rects[] = {
1097 FlutterRectMakeLTRB(0, 0, 800, 600),
1098 };
1099 FlutterRegion paint_region = {
1100 .struct_size = sizeof(FlutterRegion),
1101 .rects_count = 1,
1102 .rects = paint_region_rects,
1103 };
1104 FlutterBackingStorePresentInfo present_info = {
1106 .paint_region = &paint_region,
1107 };
1108
1109 FlutterLayer layer = {};
1110 layer.struct_size = sizeof(layer);
1112 layer.backing_store = &backing_store;
1113 layer.size = FlutterSizeMake(800.0, 600.0);
1114 layer.offset = FlutterPointMake(0.0, 0.0);
1115 layer.backing_store_present_info = &present_info;
1116
1117 ASSERT_EQ(*layers[0], layer);
1118 }
1119
1120 latch.CountDown();
1121 });
1122
1123 context.AddNativeCallback(
1124 "SignalNativeTest",
1126 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
1127
1128 auto engine = builder.LaunchEngine();
1129
1130 // Send a window metrics events so frames may be scheduled.
1131 FlutterWindowMetricsEvent event = {};
1132 event.struct_size = sizeof(event);
1133 event.width = 800;
1134 event.height = 600;
1135 event.pixel_ratio = 1.0;
1137 kSuccess);
1138 ASSERT_TRUE(engine.is_valid());
1139
1140 latch.Wait();
1141
1142 ASSERT_TRUE(
1143 ImageMatchesFixture("compositor_with_root_layer_only.png", scene_image));
1144}

◆ TEST_F() [368/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorRenderTargetsAreInStableOrder   
)

Definition at line 3454 of file embedder_gl_unittests.cc.

3454 {
3455 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3456
3457 EmbedderConfigBuilder builder(context);
3458 builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
3459 builder.SetCompositor();
3460 builder.SetDartEntrypoint("render_targets_are_in_stable_order");
3461 builder.SetRenderTargetType(
3462 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
3463
3464 fml::CountDownLatch latch(2);
3465
3466 context.AddNativeCallback("SignalNativeTest",
3468 latch.CountDown();
3469 }));
3470
3471 size_t frame_count = 0;
3472 std::vector<void*> first_frame_backing_store_user_data;
3473 context.GetCompositor().SetPresentCallback(
3474 [&](FlutterViewId view_id, const FlutterLayer** layers,
3475 size_t layers_count) {
3476 ASSERT_EQ(layers_count, 20u);
3477
3478 if (first_frame_backing_store_user_data.empty()) {
3479 for (size_t i = 0; i < layers_count; ++i) {
3480 if (layers[i]->type == kFlutterLayerContentTypeBackingStore) {
3481 first_frame_backing_store_user_data.push_back(
3482 layers[i]->backing_store->user_data);
3483 }
3484 }
3485 return;
3486 }
3487
3488 ASSERT_EQ(first_frame_backing_store_user_data.size(), 10u);
3489
3490 frame_count++;
3491 std::vector<void*> backing_store_user_data;
3492 for (size_t i = 0; i < layers_count; ++i) {
3493 if (layers[i]->type == kFlutterLayerContentTypeBackingStore) {
3494 backing_store_user_data.push_back(
3495 layers[i]->backing_store->user_data);
3496 }
3497 }
3498
3499 ASSERT_EQ(backing_store_user_data.size(), 10u);
3500
3501 ASSERT_EQ(first_frame_backing_store_user_data, backing_store_user_data);
3502
3503 if (frame_count == 20) {
3504 latch.CountDown();
3505 }
3506 },
3507 false // one shot
3508 );
3509
3510 auto engine = builder.LaunchEngine();
3511 ASSERT_TRUE(engine.is_valid());
3512
3513 FlutterWindowMetricsEvent event = {};
3514 event.struct_size = sizeof(event);
3515 event.width = 300;
3516 event.height = 200;
3517 event.pixel_ratio = 1.0;
3519 kSuccess);
3520
3521 latch.Wait();
3522}

◆ TEST_F() [369/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorRenderTargetsAreRecycled   
)

Definition at line 3408 of file embedder_gl_unittests.cc.

3408 {
3409 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3410
3411 EmbedderConfigBuilder builder(context);
3412 builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
3413 builder.SetCompositor();
3414 builder.SetDartEntrypoint("render_targets_are_recycled");
3415 builder.SetRenderTargetType(
3416 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
3417
3418 fml::CountDownLatch latch(2);
3419
3420 context.AddNativeCallback("SignalNativeTest",
3422 latch.CountDown();
3423 }));
3424
3425 context.GetCompositor().SetNextPresentCallback(
3426 [&](FlutterViewId view_id, const FlutterLayer** layers,
3427 size_t layers_count) {
3428 ASSERT_EQ(layers_count, 20u);
3429 latch.CountDown();
3430 });
3431
3432 auto engine = builder.LaunchEngine();
3433 ASSERT_TRUE(engine.is_valid());
3434
3435 FlutterWindowMetricsEvent event = {};
3436 event.struct_size = sizeof(event);
3437 event.width = 300;
3438 event.height = 200;
3439 event.pixel_ratio = 1.0;
3441 kSuccess);
3442
3443 latch.Wait();
3444 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 10u);
3445 ASSERT_EQ(context.GetCompositor().GetBackingStoresCreatedCount(), 10u);
3446 ASSERT_EQ(context.GetCompositor().GetBackingStoresCollectedCount(), 0u);
3447 // Killing the engine should immediately collect all pending render targets.
3448 engine.reset();
3449 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
3450 ASSERT_EQ(context.GetCompositor().GetBackingStoresCreatedCount(), 10u);
3451 ASSERT_EQ(context.GetCompositor().GetBackingStoresCollectedCount(), 10u);
3452}

◆ TEST_F() [370/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorRenderTargetsNotRecycledWhenAvoidsCacheSet   
)

Definition at line 4263 of file embedder_gl_unittests.cc.

4263 {
4264 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4265
4266 EmbedderConfigBuilder builder(context);
4267 builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
4268 builder.SetCompositor(/*avoid_backing_store_cache=*/true);
4269 builder.SetDartEntrypoint("render_targets_are_recycled");
4270 builder.SetRenderTargetType(
4271 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
4272
4273 const unsigned num_frames = 8;
4274 const unsigned num_engine_layers = 10;
4275 const unsigned num_backing_stores = num_frames * num_engine_layers;
4276 fml::CountDownLatch latch(1 + num_frames); // 1 for native test signal.
4277
4278 context.AddNativeCallback("SignalNativeTest",
4280 latch.CountDown();
4281 }));
4282
4283 context.GetCompositor().SetPresentCallback(
4284 [&](FlutterViewId view_id, const FlutterLayer** layers,
4285 size_t layers_count) {
4286 ASSERT_EQ(layers_count, 20u);
4287 latch.CountDown();
4288 },
4289 /*one_shot=*/false);
4290
4291 auto engine = builder.LaunchEngine();
4292 ASSERT_TRUE(engine.is_valid());
4293
4294 FlutterWindowMetricsEvent event = {};
4295 event.struct_size = sizeof(event);
4296 event.width = 300;
4297 event.height = 200;
4298 event.pixel_ratio = 1.0;
4300 kSuccess);
4301
4302 latch.Wait();
4303
4304 ASSERT_EQ(context.GetCompositor().GetBackingStoresCreatedCount(),
4305 num_backing_stores);
4306 // Killing the engine should collect all the frames.
4307 engine.reset();
4308 ASSERT_EQ(context.GetCompositor().GetPendingBackingStoresCount(), 0u);
4309}

◆ TEST_F() [371/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CreateInvalidBackingstoreMetalTexture   
)

Definition at line 513 of file embedder_metal_unittests.mm.

513 {
514 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
515 EmbedderConfigBuilder builder(context);
516 builder.SetMetalRendererConfig(SkISize::Make(800, 600));
517 builder.SetCompositor();
518 builder.SetRenderTargetType(EmbedderTestBackingStoreProducer::RenderTargetType::kMetalTexture);
519 builder.SetDartEntrypoint("invalid_backingstore");
520
521 class TestCollectOnce {
522 public:
523 // Collect() should only be called once
524 void Collect() {
525 ASSERT_FALSE(collected_);
526 collected_ = true;
527 }
528
529 private:
530 bool collected_ = false;
531 };
533
534 builder.GetCompositor().create_backing_store_callback =
535 [](const FlutterBackingStoreConfig* config, //
536 FlutterBackingStore* backing_store_out, //
537 void* user_data //
538 ) {
539 backing_store_out->type = kFlutterBackingStoreTypeMetal;
540 // Deliberately set this to be invalid
541 backing_store_out->user_data = nullptr;
542 backing_store_out->metal.texture.texture = 0;
543 backing_store_out->metal.struct_size = sizeof(FlutterMetalBackingStore);
544 backing_store_out->metal.texture.user_data = new TestCollectOnce();
545 backing_store_out->metal.texture.destruction_callback = [](void* user_data) {
546 reinterpret_cast<TestCollectOnce*>(user_data)->Collect();
547 };
548 return true;
549 };
550
551 context.AddNativeCallback(
552 "SignalNativeTest",
553 CREATE_NATIVE_ENTRY([&latch](Dart_NativeArguments args) { latch.Signal(); }));
554
555 auto engine = builder.LaunchEngine();
556
557 // Send a window metrics events so frames may be scheduled.
558 FlutterWindowMetricsEvent event = {};
559 event.struct_size = sizeof(event);
560 event.width = 800;
561 event.height = 600;
562 event.pixel_ratio = 1.0;
564 ASSERT_TRUE(engine.is_valid());
565 latch.Wait();
566}

◆ TEST_F() [372/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CreateInvalidBackingstoreOpenGLFramebuffer   
)

Definition at line 4467 of file embedder_gl_unittests.cc.

4467 {
4468 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4469 EmbedderConfigBuilder builder(context);
4470 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4471 builder.SetCompositor();
4472 builder.SetRenderTargetType(
4473 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
4474 builder.SetDartEntrypoint("invalid_backingstore");
4475
4476 class TestCollectOnce {
4477 public:
4478 // Collect() should only be called once
4479 void Collect() {
4480 ASSERT_FALSE(collected_);
4481 collected_ = true;
4482 }
4483
4484 private:
4485 bool collected_ = false;
4486 };
4488
4489 builder.GetCompositor().create_backing_store_callback =
4490 [](const FlutterBackingStoreConfig* config, //
4491 FlutterBackingStore* backing_store_out, //
4492 void* user_data //
4493 ) {
4494 backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
4495 // Deliberately set this to be invalid
4496 backing_store_out->user_data = nullptr;
4497 backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer;
4498 backing_store_out->open_gl.framebuffer.target = 0;
4499 backing_store_out->open_gl.framebuffer.name = 0;
4500 static TestCollectOnce collect_once_user_data;
4501 collect_once_user_data = {};
4502 backing_store_out->open_gl.framebuffer.user_data =
4503 &collect_once_user_data;
4504 backing_store_out->open_gl.framebuffer.destruction_callback =
4505 [](void* user_data) {
4506 reinterpret_cast<TestCollectOnce*>(user_data)->Collect();
4507 };
4508 return true;
4509 };
4510
4511 context.AddNativeCallback(
4512 "SignalNativeTest",
4514 [&latch](Dart_NativeArguments args) { latch.Signal(); }));
4515
4516 auto engine = builder.LaunchEngine();
4517
4518 // Send a window metrics events so frames may be scheduled.
4519 FlutterWindowMetricsEvent event = {};
4520 event.struct_size = sizeof(event);
4521 event.width = 800;
4522 event.height = 600;
4523 event.pixel_ratio = 1.0;
4525 kSuccess);
4526 ASSERT_TRUE(engine.is_valid());
4527 latch.Wait();
4528}

◆ TEST_F() [373/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CreateInvalidBackingstoreOpenGLTexture   
)

Definition at line 4404 of file embedder_gl_unittests.cc.

4404 {
4405 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4406 EmbedderConfigBuilder builder(context);
4407 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4408 builder.SetCompositor();
4409 builder.SetRenderTargetType(
4410 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
4411 builder.SetDartEntrypoint("invalid_backingstore");
4412
4413 class TestCollectOnce {
4414 public:
4415 // Collect() should only be called once
4416 void Collect() {
4417 ASSERT_FALSE(collected_);
4418 collected_ = true;
4419 }
4420
4421 private:
4422 bool collected_ = false;
4423 };
4425
4426 builder.GetCompositor().create_backing_store_callback =
4427 [](const FlutterBackingStoreConfig* config, //
4428 FlutterBackingStore* backing_store_out, //
4429 void* user_data //
4430 ) {
4431 backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
4432 // Deliberately set this to be invalid
4433 backing_store_out->user_data = nullptr;
4434 backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeTexture;
4435 backing_store_out->open_gl.texture.target = 0;
4436 backing_store_out->open_gl.texture.name = 0;
4437 backing_store_out->open_gl.texture.format = 0;
4438 static TestCollectOnce collect_once_user_data;
4439 collect_once_user_data = {};
4440 backing_store_out->open_gl.texture.user_data = &collect_once_user_data;
4441 backing_store_out->open_gl.texture.destruction_callback =
4442 [](void* user_data) {
4443 reinterpret_cast<TestCollectOnce*>(user_data)->Collect();
4444 };
4445 return true;
4446 };
4447
4448 context.AddNativeCallback(
4449 "SignalNativeTest",
4451 [&latch](Dart_NativeArguments args) { latch.Signal(); }));
4452
4453 auto engine = builder.LaunchEngine();
4454
4455 // Send a window metrics events so frames may be scheduled.
4456 FlutterWindowMetricsEvent event = {};
4457 event.struct_size = sizeof(event);
4458 event.width = 800;
4459 event.height = 600;
4460 event.pixel_ratio = 1.0;
4462 kSuccess);
4463 ASSERT_TRUE(engine.is_valid());
4464 latch.Wait();
4465}

◆ TEST_F() [374/876]

flutter::testing::TEST_F ( EmbedderTest  ,
CustomCompositorMustWorkWithCustomTaskRunner   
)

Custom compositor must play nicely with a custom task runner. The raster thread merging mechanism must not interfere with the custom compositor.

Definition at line 900 of file embedder_gl_unittests.cc.

900 {
901 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
902
903 EmbedderConfigBuilder builder(context);
904
905 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
906 builder.SetCompositor();
907 builder.SetDartEntrypoint("can_composite_platform_views");
908
909 auto platform_task_runner = CreateNewThread("test_platform_thread");
910 static std::mutex engine_mutex;
913
914 EmbedderTestTaskRunner test_task_runner(
915 platform_task_runner, [&](FlutterTask task) {
916 std::scoped_lock lock(engine_mutex);
917 if (!engine.is_valid()) {
918 return;
919 }
920 ASSERT_EQ(FlutterEngineRunTask(engine.get(), &task), kSuccess);
921 });
922
923 builder.SetRenderTargetType(
924 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
925
926 fml::CountDownLatch latch(3);
927 context.GetCompositor().SetNextPresentCallback(
928 [&](FlutterViewId view_id, const FlutterLayer** layers,
929 size_t layers_count) {
930 ASSERT_EQ(layers_count, 3u);
931
932 {
933 FlutterBackingStore backing_store = *layers[0]->backing_store;
934 backing_store.struct_size = sizeof(backing_store);
935 backing_store.type = kFlutterBackingStoreTypeOpenGL;
936 backing_store.did_update = true;
938
939 FlutterRect paint_region_rects[] = {
940 FlutterRectMakeLTRB(0, 0, 800, 600),
941 };
942 FlutterRegion paint_region = {
943 .struct_size = sizeof(FlutterRegion),
944 .rects_count = 1,
945 .rects = paint_region_rects,
946 };
947 FlutterBackingStorePresentInfo present_info = {
949 .paint_region = &paint_region,
950 };
951
952 FlutterLayer layer = {};
953 layer.struct_size = sizeof(layer);
955 layer.backing_store = &backing_store;
956 layer.size = FlutterSizeMake(800.0, 600.0);
957 layer.offset = FlutterPointMake(0, 0);
958 layer.backing_store_present_info = &present_info;
959
960 ASSERT_EQ(*layers[0], layer);
961 }
962
963 {
966 platform_view.identifier = 42;
967
968 FlutterRect paint_region_rects[] = {
969 FlutterRectMakeLTRB(2, 3, 800, 600),
970 };
971 FlutterRegion paint_region = {
972 .struct_size = sizeof(FlutterRegion),
973 .rects_count = 1,
974 .rects = paint_region_rects,
975 };
976 FlutterBackingStorePresentInfo present_info = {
978 .paint_region = &paint_region,
979 };
980
981 FlutterLayer layer = {};
982 layer.struct_size = sizeof(layer);
985 layer.size = FlutterSizeMake(123.0, 456.0);
986 layer.offset = FlutterPointMake(1.0, 2.0);
987 layer.backing_store_present_info = &present_info;
988
989 ASSERT_EQ(*layers[1], layer);
990 }
991
992 {
993 FlutterBackingStore backing_store = *layers[2]->backing_store;
994 backing_store.struct_size = sizeof(backing_store);
995 backing_store.type = kFlutterBackingStoreTypeOpenGL;
996 backing_store.did_update = true;
998
999 FlutterRect paint_region_rects[] = {
1000 FlutterRectMakeLTRB(2, 3, 800, 600),
1001 };
1002 FlutterRegion paint_region = {
1003 .struct_size = sizeof(FlutterRegion),
1004 .rects_count = 1,
1005 .rects = paint_region_rects,
1006 };
1007 FlutterBackingStorePresentInfo present_info = {
1009 .paint_region = &paint_region,
1010 };
1011
1012 FlutterLayer layer = {};
1013 layer.struct_size = sizeof(layer);
1015 layer.backing_store = &backing_store;
1016 layer.size = FlutterSizeMake(800.0, 600.0);
1017 layer.offset = FlutterPointMake(0.0, 0.0);
1018 layer.backing_store_present_info = &present_info;
1019
1020 ASSERT_EQ(*layers[2], layer);
1021 }
1022
1023 latch.CountDown();
1024 });
1025
1026 const auto task_runner_description =
1027 test_task_runner.GetFlutterTaskRunnerDescription();
1028
1029 builder.SetPlatformTaskRunner(&task_runner_description);
1030
1031 context.AddNativeCallback(
1032 "SignalNativeTest",
1034 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
1035
1036 platform_task_runner->PostTask([&]() {
1037 std::scoped_lock lock(engine_mutex);
1038 engine = builder.LaunchEngine();
1039 ASSERT_TRUE(engine.is_valid());
1040
1041 // Send a window metrics events so frames may be scheduled.
1042 FlutterWindowMetricsEvent event = {};
1043 event.struct_size = sizeof(event);
1044 event.width = 800;
1045 event.height = 600;
1046 event.pixel_ratio = 1.0;
1048 kSuccess);
1049 ASSERT_TRUE(engine.is_valid());
1050 sync_latch.Signal();
1051 });
1052 sync_latch.Wait();
1053
1054 latch.Wait();
1055
1056 platform_task_runner->PostTask([&]() {
1057 std::scoped_lock lock(engine_mutex);
1058 engine.reset();
1059 sync_latch.Signal();
1060 });
1061 sync_latch.Wait();
1062}
int64_t FlutterViewId
Definition embedder.h:273

◆ TEST_F() [375/876]

flutter::testing::TEST_F ( EmbedderTest  ,
DartEntrypointArgs   
)

Definition at line 595 of file embedder_unittests.cc.

595 {
596 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
597 EmbedderConfigBuilder builder(context);
598 builder.SetSoftwareRendererConfig();
599 builder.AddDartEntrypointArgument("foo");
600 builder.AddDartEntrypointArgument("bar");
601 builder.SetDartEntrypoint("dart_entrypoint_args");
602 fml::AutoResetWaitableEvent callback_latch;
603 std::vector<std::string> callback_args;
604 auto nativeArgumentsCallback = [&callback_args,
605 &callback_latch](Dart_NativeArguments args) {
606 Dart_Handle exception = nullptr;
607 callback_args =
609 args, 0, exception);
610 callback_latch.Signal();
611 };
612 context.AddNativeCallback("NativeArgumentsCallback",
613 CREATE_NATIVE_ENTRY(nativeArgumentsCallback));
614 auto engine = builder.LaunchEngine();
615 callback_latch.Wait();
616 ASSERT_EQ(callback_args[0], "foo");
617 ASSERT_EQ(callback_args[1], "bar");
618}

◆ TEST_F() [376/876]

flutter::testing::TEST_F ( EmbedderTest  ,
DISABLED_CanLaunchAndShutdownMultipleTimes   
)

Definition at line 80 of file embedder_unittests.cc.

80 {
82 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
83 builder.SetSoftwareRendererConfig();
84 for (size_t i = 0; i < 3; ++i) {
85 auto engine = builder.LaunchEngine();
86 ASSERT_TRUE(engine.is_valid());
87 FML_LOG(INFO) << "Engine launch count: " << i + 1;
88 }
89}

◆ TEST_F() [377/876]

flutter::testing::TEST_F ( EmbedderTest  ,
EmptySceneIsAcceptable   
)

Definition at line 2856 of file embedder_gl_unittests.cc.

2856 {
2857 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2858
2859 EmbedderConfigBuilder builder(context);
2860 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
2861 builder.SetCompositor();
2862 builder.SetDartEntrypoint("empty_scene");
2864 context.AddNativeCallback(
2865 "SignalNativeTest",
2867
2868 auto engine = builder.LaunchEngine();
2869
2870 ASSERT_TRUE(engine.is_valid());
2871
2872 FlutterWindowMetricsEvent event = {};
2873 event.struct_size = sizeof(event);
2874 event.width = 800;
2875 event.height = 600;
2876 event.pixel_ratio = 1.0;
2878 kSuccess);
2879 latch.Wait();
2880}

◆ TEST_F() [378/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ExecutableNameNotNull   
)

Definition at line 156 of file embedder_unittests.cc.

156 {
157 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
158
159 // Supply a callback to Dart for the test fixture to pass Platform.executable
160 // back to us.
162 context.AddNativeCallback(
163 "NotifyStringValue", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
164 const auto dart_string = tonic::DartConverter<std::string>::FromDart(
166 EXPECT_EQ("/path/to/binary", dart_string);
167 latch.Signal();
168 }));
169
170 EmbedderConfigBuilder builder(context);
171 builder.SetSoftwareRendererConfig();
172 builder.SetDartEntrypoint("executableNameNotNull");
173 builder.SetExecutableName("/path/to/binary");
174 auto engine = builder.LaunchEngine();
175 latch.Wait();
176}

◆ TEST_F() [379/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ExternalTextureGLRefreshedTooOften   
)

Definition at line 4530 of file embedder_gl_unittests.cc.

4530 {
4532 auto context = surface.GetGrContext();
4533
4534 typedef void (*glGenTexturesProc)(uint32_t n, uint32_t* textures);
4535 typedef void (*glFinishProc)();
4536
4537 glGenTexturesProc glGenTextures;
4538 glFinishProc glFinish;
4539
4540 glGenTextures = reinterpret_cast<glGenTexturesProc>(
4541 surface.GetProcAddress("glGenTextures"));
4542 glFinish = reinterpret_cast<glFinishProc>(surface.GetProcAddress("glFinish"));
4543
4544 uint32_t name;
4545 glGenTextures(1, &name);
4546
4547 bool resolve_called = false;
4548
4550 [&](int64_t, size_t, size_t) {
4551 resolve_called = true;
4552 auto res = std::make_unique<FlutterOpenGLTexture>();
4553 res->target = GL_TEXTURE_2D;
4554 res->name = name;
4555 res->format = GL_RGBA8;
4556 res->user_data = nullptr;
4557 res->destruction_callback = [](void*) {};
4558 res->width = res->height = 100;
4559 return res;
4560 });
4561 EmbedderExternalTextureGL texture(1, callback);
4562
4563 auto skia_surface = surface.GetOnscreenSurface();
4564 DlSkCanvasAdapter canvas(skia_surface->getCanvas());
4565
4566 Texture* texture_ = &texture;
4567 Texture::PaintContext ctx{
4568 .canvas = &canvas,
4569 .gr_context = context.get(),
4570 };
4571 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false,
4572 DlImageSampling::kLinear);
4573
4574 EXPECT_TRUE(resolve_called);
4575 resolve_called = false;
4576
4577 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false,
4578 DlImageSampling::kLinear);
4579
4580 EXPECT_FALSE(resolve_called);
4581
4582 texture_->MarkNewFrameAvailable();
4583 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false,
4584 DlImageSampling::kLinear);
4585
4586 EXPECT_TRUE(resolve_called);
4587
4588 glFinish();
4589}
std::function< std::unique_ptr< FlutterOpenGLTexture >(int64_t, size_t, size_t)> ExternalTextureCallback

◆ TEST_F() [380/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ExternalTextureMetal   
)

Definition at line 77 of file embedder_metal_unittests.mm.

77 {
78 EmbedderTestContextMetal& context = reinterpret_cast<EmbedderTestContextMetal&>(
79 GetEmbedderContext(EmbedderTestContextType::kMetalContext));
80
81 const auto texture_size = SkISize::Make(800, 600);
82 const int64_t texture_id = 1;
83
84 TestMetalContext* metal_context = context.GetTestMetalContext();
85 TestMetalContext::TextureInfo texture_info = metal_context->CreateMetalTexture(texture_size);
86
88 GetSurfaceFromTexture(metal_context->GetSkiaContext(), texture_size, texture_info.texture);
89 auto canvas = surface->getCanvas();
90 canvas->clear(SK_ColorRED);
91 metal_context->GetSkiaContext()->flushAndSubmit();
92
93 std::vector<FlutterMetalTextureHandle> textures{texture_info.texture};
94
96 [&](int64_t id, size_t w, size_t h, FlutterMetalExternalTexture* output) {
97 EXPECT_TRUE(w == texture_size.width());
98 EXPECT_TRUE(h == texture_size.height());
100 output->num_textures = 1;
101 output->height = h;
102 output->width = w;
104 output->textures = textures.data();
105 return true;
106 });
107
108 EmbedderConfigBuilder builder(context);
109
110 builder.SetDartEntrypoint("render_texture");
111 builder.SetMetalRendererConfig(texture_size);
112
113 auto engine = builder.LaunchEngine();
114 ASSERT_TRUE(engine.is_valid());
115
117
118 auto rendered_scene = context.GetNextSceneImage();
119
120 // Send a window metrics events so frames may be scheduled.
121 FlutterWindowMetricsEvent event = {};
122 event.struct_size = sizeof(event);
123 event.width = texture_size.width();
124 event.height = texture_size.height();
125 event.pixel_ratio = 1.0;
127
128 ASSERT_TRUE(ImageMatchesFixture("external_texture_metal.png", rendered_scene));
129}
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
sk_sp< GrDirectContext > GetSkiaContext() const
TextureInfo CreateMetalTexture(const SkISize &size)
Returns texture_id = -1 when texture creation fails.
void SetExternalTextureCallback(TestExternalTextureCallback external_texture_frame_callback)
FlutterEngineResult FlutterEngineRegisterExternalTexture(FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
Register an external texture with a unique (per engine) identifier. Only rendering backends that supp...
Definition embedder.cc:2763
@ kRGBA
Definition embedder.h:605
static sk_sp< SkSurface > GetSurfaceFromTexture(const sk_sp< GrDirectContext > &skia_context, SkISize texture_size, void *texture)

◆ TEST_F() [381/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ExternalTextureMetalRefreshedTooOften   
)

Definition at line 568 of file embedder_metal_unittests.mm.

568 {
569 EmbedderTestContextMetal& context = reinterpret_cast<EmbedderTestContextMetal&>(
570 GetEmbedderContext(EmbedderTestContextType::kMetalContext));
571
572 TestMetalContext* metal_context = context.GetTestMetalContext();
573 auto metal_texture = metal_context->CreateMetalTexture(SkISize::Make(100, 100));
574
575 std::vector<FlutterMetalTextureHandle> textures{metal_texture.texture};
576
577 bool resolve_called = false;
578
580 resolve_called = true;
581 auto res = std::make_unique<FlutterMetalExternalTexture>();
582 res->struct_size = sizeof(FlutterMetalExternalTexture);
583 res->width = res->height = 100;
585 res->textures = textures.data();
586 res->num_textures = 1;
587 return res;
588 });
589 EmbedderExternalTextureMetal texture(1, callback);
590
591 auto surface = TestMetalSurface::Create(*metal_context, SkISize::Make(100, 100));
592 auto skia_surface = surface->GetSurface();
593 DlSkCanvasAdapter canvas(skia_surface->getCanvas());
594
595 Texture* texture_ = &texture;
596 DlImageSampling sampling = DlImageSampling::kLinear;
597 Texture::PaintContext ctx{
598 .canvas = &canvas,
599 .gr_context = surface->GetGrContext().get(),
600 };
601 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false, sampling);
602
603 EXPECT_TRUE(resolve_called);
604 resolve_called = false;
605
606 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false, sampling);
607
608 EXPECT_FALSE(resolve_called);
609
610 texture_->MarkNewFrameAvailable();
611
612 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false, sampling);
613
614 EXPECT_TRUE(resolve_called);
615}
std::function< std::unique_ptr< FlutterMetalExternalTexture >(int64_t, size_t, size_t)> ExternalTextureCallback

◆ TEST_F() [382/876]

flutter::testing::TEST_F ( EmbedderTest  ,
FrameInfoContainsValidWidthAndHeight   
)

Definition at line 3524 of file embedder_gl_unittests.cc.

3524 {
3525 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3526
3527 EmbedderConfigBuilder builder(context);
3528 builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
3529 builder.SetDartEntrypoint("push_frames_over_and_over");
3530
3531 const auto root_surface_transformation =
3532 SkMatrix().preTranslate(0, 1024).preRotate(-90, 0, 0);
3533
3534 context.SetRootSurfaceTransformation(root_surface_transformation);
3535
3536 auto engine = builder.LaunchEngine();
3537
3538 // Send a window metrics events so frames may be scheduled.
3539 static FlutterWindowMetricsEvent event = {};
3540 event.struct_size = sizeof(event);
3541 event.width = 1024;
3542 event.height = 600;
3543 event.pixel_ratio = 1.0;
3545 kSuccess);
3546 ASSERT_TRUE(engine.is_valid());
3547
3548 static fml::CountDownLatch frame_latch(10);
3549
3550 context.AddNativeCallback("SignalNativeTest",
3552 /* Nothing to do. */
3553 }));
3554
3555 static_cast<EmbedderTestContextGL&>(context).SetGLGetFBOCallback(
3556 [](FlutterFrameInfo frame_info) {
3557 // width and height are rotated by 90 deg
3558 ASSERT_EQ(frame_info.size.width, event.height);
3559 ASSERT_EQ(frame_info.size.height, event.width);
3560
3561 frame_latch.CountDown();
3562 });
3563
3564 frame_latch.Wait();
3565}
FlutterUIntSize size
The size of the surface that will be backed by the fbo.
Definition embedder.h:477
uint32_t height
Definition embedder.h:431
uint32_t width
Definition embedder.h:430

◆ TEST_F() [383/876]

flutter::testing::TEST_F ( EmbedderTest  ,
IgnoresWindowMetricsEventForUnknownView   
)

Definition at line 3610 of file embedder_unittests.cc.

3610 {
3611 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3612 EmbedderConfigBuilder builder(context);
3613 builder.SetSoftwareRendererConfig();
3614 builder.SetDartEntrypoint("window_metrics_event_view_id");
3615
3616 fml::AutoResetWaitableEvent ready_latch, message_latch;
3617 context.AddNativeCallback(
3618 "SignalNativeTest",
3620 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3621
3622 context.AddNativeCallback(
3623 "SignalNativeMessage",
3627 // Message latch should only be signaled once as the bad
3628 // view metric should be dropped by the engine.
3629 ASSERT_FALSE(message_latch.IsSignaledForTest());
3630 ASSERT_EQ("Changed: [0]", message);
3631 message_latch.Signal();
3632 }));
3633
3634 auto engine = builder.LaunchEngine();
3635 ASSERT_TRUE(engine.is_valid());
3636
3637 ready_latch.Wait();
3638
3639 // Send a window metric for a nonexistent view, which should be dropped by the
3640 // engine.
3641 FlutterWindowMetricsEvent bad_event = {};
3642 bad_event.struct_size = sizeof(FlutterWindowMetricsEvent);
3643 bad_event.width = 200;
3644 bad_event.height = 300;
3645 bad_event.pixel_ratio = 1.5;
3646 bad_event.view_id = 100;
3647
3650 ASSERT_EQ(result, kSuccess);
3651
3652 // Send a window metric for a valid view. The engine notifies the Dart app.
3653 FlutterWindowMetricsEvent event = {};
3654 event.struct_size = sizeof(FlutterWindowMetricsEvent);
3655 event.width = 200;
3656 event.height = 300;
3657 event.pixel_ratio = 1.5;
3658 event.view_id = 0;
3659
3661 ASSERT_EQ(result, kSuccess);
3662
3663 message_latch.Wait();
3664}

◆ TEST_F() [384/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ImplicitViewNotNull   
)

Definition at line 178 of file embedder_unittests.cc.

178 {
179 // TODO(loicsharma): Update this test when embedders can opt-out
180 // of the implicit view.
181 // See: https://github.com/flutter/flutter/issues/120306
182 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
183
184 bool implicitViewNotNull = false;
186 context.AddNativeCallback(
187 "NotifyBoolValue", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
188 implicitViewNotNull = tonic::DartConverter<bool>::FromDart(
190 latch.Signal();
191 }));
192
193 EmbedderConfigBuilder builder(context);
194 builder.SetSoftwareRendererConfig();
195 builder.SetDartEntrypoint("implicitViewNotNull");
196 auto engine = builder.LaunchEngine();
197 latch.Wait();
198
199 EXPECT_TRUE(implicitViewNotNull);
200}

◆ TEST_F() [385/876]

flutter::testing::TEST_F ( EmbedderTest  ,
InvalidAOTDataSourcesMustReturnError   
)

Definition at line 2324 of file embedder_unittests.cc.

2324 {
2325 if (!DartVM::IsRunningPrecompiledCode()) {
2326 GTEST_SKIP();
2327 return;
2328 }
2329 FlutterEngineAOTDataSource data_in = {};
2330 FlutterEngineAOTData data_out = nullptr;
2331
2332 // Null source specified.
2333 ASSERT_EQ(FlutterEngineCreateAOTData(nullptr, &data_out), kInvalidArguments);
2334 ASSERT_EQ(data_out, nullptr);
2335
2336 // Null data_out specified.
2337 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, nullptr), kInvalidArguments);
2338
2339 // Invalid FlutterEngineAOTDataSourceType type specified.
2340 // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
2341 data_in.type = static_cast<FlutterEngineAOTDataSourceType>(-1);
2342 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2343 ASSERT_EQ(data_out, nullptr);
2344
2345 // Invalid ELF path specified.
2347 data_in.elf_path = nullptr;
2348 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2349 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2350 ASSERT_EQ(data_in.elf_path, nullptr);
2351 ASSERT_EQ(data_out, nullptr);
2352
2353 // Invalid ELF path specified.
2354 data_in.elf_path = "";
2355 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2356 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2357 ASSERT_EQ(data_in.elf_path, "");
2358 ASSERT_EQ(data_out, nullptr);
2359
2360 // Could not find VM snapshot data.
2361 data_in.elf_path = "/bin/true";
2362 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2363 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2364 ASSERT_EQ(data_in.elf_path, "/bin/true");
2365 ASSERT_EQ(data_out, nullptr);
2366}
FlutterEngineAOTDataSourceType
AOT data source type.
Definition embedder.h:2107

◆ TEST_F() [386/876]

flutter::testing::TEST_F ( EmbedderTest  ,
InvalidFlutterWindowMetricsEvent   
)

Definition at line 2663 of file embedder_unittests.cc.

2663 {
2664 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2665 EmbedderConfigBuilder builder(context);
2666 builder.SetSoftwareRendererConfig();
2667 auto engine = builder.LaunchEngine();
2668
2669 ASSERT_TRUE(engine.is_valid());
2670
2671 FlutterWindowMetricsEvent event = {};
2672 event.struct_size = sizeof(event);
2673 event.width = 800;
2674 event.height = 600;
2675 event.pixel_ratio = 0.0;
2676 event.physical_view_inset_top = 0.0;
2677 event.physical_view_inset_right = 0.0;
2678 event.physical_view_inset_bottom = 0.0;
2679 event.physical_view_inset_left = 0.0;
2680
2681 // Pixel ratio must be positive.
2684
2685 event.pixel_ratio = 1.0;
2686 event.physical_view_inset_top = -1.0;
2687 event.physical_view_inset_right = -1.0;
2688 event.physical_view_inset_bottom = -1.0;
2689 event.physical_view_inset_left = -1.0;
2690
2691 // Physical view insets must be non-negative.
2694
2695 event.physical_view_inset_top = 700;
2696 event.physical_view_inset_right = 900;
2697 event.physical_view_inset_bottom = 700;
2698 event.physical_view_inset_left = 900;
2699
2700 // Top/bottom insets cannot be greater than height.
2701 // Left/right insets cannot be greater than width.
2704}

◆ TEST_F() [387/876]

flutter::testing::TEST_F ( EmbedderTest  ,
InvalidPlatformMessages   
)

Tests that a null platform message cannot be send if the message_size isn't equals to 0.

Definition at line 512 of file embedder_unittests.cc.

512 {
513 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
514 EmbedderConfigBuilder builder(context);
515 builder.SetSoftwareRendererConfig();
516 auto engine = builder.LaunchEngine();
517
518 ASSERT_TRUE(engine.is_valid());
519
520 FlutterPlatformMessage platform_message = {};
521 platform_message.struct_size = sizeof(FlutterPlatformMessage);
522 platform_message.channel = "test_channel";
523 platform_message.message = nullptr;
524 platform_message.message_size = 1;
525 platform_message.response_handle = nullptr; // No response needed.
526
527 auto result =
528 FlutterEngineSendPlatformMessage(engine.get(), &platform_message);
529 ASSERT_EQ(result, kInvalidArguments);
530}
FlutterEngineResult FlutterEngineSendPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *flutter_message)
Definition embedder.cc:2630
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformMessage).
Definition embedder.h:1162
const FlutterPlatformMessageResponseHandle * response_handle
Definition embedder.h:1172
const char * channel
Definition embedder.h:1163
const uint8_t * message
Definition embedder.h:1164

◆ TEST_F() [388/876]

flutter::testing::TEST_F ( EmbedderTest  ,
IsolateServiceIdSent   
)

Definition at line 287 of file embedder_unittests.cc.

287 {
288 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
290
291 fml::Thread thread;
293 std::string isolate_message;
294
295 thread.GetTaskRunner()->PostTask([&]() {
296 EmbedderConfigBuilder builder(context);
297 builder.SetSoftwareRendererConfig();
298 builder.SetDartEntrypoint("main");
299 builder.SetPlatformMessageCallback(
300 [&](const FlutterPlatformMessage* message) {
301 if (strcmp(message->channel, "flutter/isolate") == 0) {
302 isolate_message = {reinterpret_cast<const char*>(message->message),
303 message->message_size};
304 latch.Signal();
305 }
306 });
307 engine = builder.LaunchEngine();
308 ASSERT_TRUE(engine.is_valid());
309 });
310
311 // Wait for the isolate ID message and check its format.
312 latch.Wait();
313 ASSERT_EQ(isolate_message.find("isolates/"), 0ul);
314
315 // Since the engine was started on its own thread, it must be killed there as
316 // well.
318 thread.GetTaskRunner()->PostTask(
319 fml::MakeCopyable([&engine, &kill_latch]() mutable {
320 engine.reset();
321 kill_latch.Signal();
322 }));
323 kill_latch.Wait();
324}

◆ TEST_F() [389/876]

flutter::testing::TEST_F ( EmbedderTest  ,
JITSnapshotCallbacksFailWithInvalidLocation   
)

PopulateJITSnapshotMappingCallbacks should still be able to successfully change the callbacks of the snapshots in the engine's settings when JIT snapshots are explicitly defined. However, if those snapshot locations are invalid, the callbacks should return a nullptr.

Definition at line 2502 of file embedder_unittests.cc.

2502 {
2503// TODO(#107263): Inconsistent snapshot paths in the Linux Fuchsia FEMU test.
2504#if defined(OS_FUCHSIA)
2505 GTEST_SKIP() << "Inconsistent paths in Fuchsia.";
2506#else
2507
2508 // This test is only relevant in JIT mode.
2509 if (DartVM::IsRunningPrecompiledCode()) {
2510 GTEST_SKIP();
2511 return;
2512 }
2513
2514 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2515 EmbedderConfigBuilder builder(context);
2516 builder.SetSoftwareRendererConfig();
2517
2518 // Explicitly define the locations of the invalid JIT snapshots
2519 builder.GetProjectArgs().vm_snapshot_data =
2520 reinterpret_cast<const uint8_t*>("invalid_vm_data");
2521 builder.GetProjectArgs().vm_snapshot_instructions =
2522 reinterpret_cast<const uint8_t*>("invalid_vm_instructions");
2523 builder.GetProjectArgs().isolate_snapshot_data =
2524 reinterpret_cast<const uint8_t*>("invalid_snapshot_data");
2525 builder.GetProjectArgs().isolate_snapshot_instructions =
2526 reinterpret_cast<const uint8_t*>("invalid_snapshot_instructions");
2527
2528 auto engine = builder.LaunchEngine();
2529
2531 const Settings settings = shell.GetSettings();
2532
2533 ASSERT_EQ(settings.vm_snapshot_data(), nullptr);
2534 ASSERT_EQ(settings.vm_snapshot_instr(), nullptr);
2535 ASSERT_EQ(settings.isolate_snapshot_data(), nullptr);
2536 ASSERT_EQ(settings.isolate_snapshot_instr(), nullptr);
2537#endif // OS_FUCHSIA
2538}

◆ TEST_F() [390/876]

flutter::testing::TEST_F ( EmbedderTest  ,
KeyDataAreBuffered   
)

Definition at line 3026 of file embedder_unittests.cc.

3026 {
3027 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
3028 std::vector<FlutterKeyEvent> echoed_events;
3029
3030 auto native_echo_event = [&](Dart_NativeArguments args) {
3031 echoed_events.push_back(FlutterKeyEvent{
3032 .timestamp =
3033 static_cast<double>(tonic::DartConverter<uint64_t>::FromDart(
3035 .type =
3044 .device_type = UnserializeKeyEventDeviceType(
3047 });
3048
3049 message_latch->Signal();
3050 };
3051
3052 auto platform_task_runner = CreateNewThread("platform_thread");
3053
3054 UniqueEngine engine;
3056 platform_task_runner->PostTask([&]() {
3057 auto& context =
3058 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3059 EmbedderConfigBuilder builder(context);
3060 builder.SetSoftwareRendererConfig();
3061 builder.SetDartEntrypoint("key_data_late_echo");
3062 builder.SetPlatformMessageCallback(
3063 [&](const FlutterPlatformMessage* message) {
3065 engine.get(), message->response_handle, nullptr, 0);
3066 });
3067 context.AddNativeCallback(
3068 "SignalNativeTest",
3070 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
3071
3072 context.AddNativeCallback("EchoKeyEvent",
3073 CREATE_NATIVE_ENTRY(native_echo_event));
3074
3075 engine = builder.LaunchEngine();
3076 ASSERT_TRUE(engine.is_valid());
3077 });
3078 ready.Wait();
3079
3080 FlutterKeyEvent sample_event{
3081 .struct_size = sizeof(FlutterKeyEvent),
3083 .physical = 0x00070004,
3084 .logical = 0x00000000061,
3085 .character = "A",
3086 .synthesized = false,
3088 };
3089
3090 // Send an event.
3091 sample_event.timestamp = 1.0l;
3092 platform_task_runner->PostTask([&]() {
3093 FlutterEngineSendKeyEvent(engine.get(), &sample_event, nullptr, nullptr);
3094 message_latch->Signal();
3095 });
3096 message_latch->Wait();
3097
3098 // Should not receive echos because the callback is not set yet.
3099 EXPECT_EQ(echoed_events.size(), 0u);
3100
3101 // Send an empty message to 'test/starts_echo' to start echoing.
3102 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
3104 engine.get(), [](const uint8_t* data, size_t size, void* user_data) {},
3105 nullptr, &response_handle);
3106
3109 .channel = "test/starts_echo",
3110 .message = nullptr,
3111 .message_size = 0,
3112 .response_handle = response_handle,
3113 };
3114
3115 platform_task_runner->PostTask([&]() {
3118 ASSERT_EQ(result, kSuccess);
3119
3121 });
3122
3123 // message_latch->Wait();
3124 message_latch->Wait();
3125 // All previous events should be received now.
3126 EXPECT_EQ(echoed_events.size(), 1u);
3127
3128 // Send a second event.
3129 sample_event.timestamp = 10.0l;
3130 platform_task_runner->PostTask([&]() {
3131 FlutterEngineSendKeyEvent(engine.get(), &sample_event, nullptr, nullptr);
3132 });
3133 message_latch->Wait();
3134
3135 // The event should be echoed, too.
3136 EXPECT_EQ(echoed_events.size(), 2u);
3137
3138 fml::AutoResetWaitableEvent shutdown_latch;
3139 platform_task_runner->PostTask([&]() {
3140 engine.reset();
3141 shutdown_latch.Signal();
3142 });
3143 shutdown_latch.Wait();
3144}
FlutterEngineResult FlutterEngineSendPlatformMessageResponse(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Send a response from the native side to a platform message from the Dart Flutter application.
Definition embedder.cc:2731
FlutterKeyEventType UnserializeKeyEventType(uint64_t kind)
FlutterKeyEventDeviceType UnserializeKeyEventDeviceType(uint64_t source)

◆ TEST_F() [391/876]

flutter::testing::TEST_F ( EmbedderTest  ,
KeyDataIsCorrectlySerialized   
)

Definition at line 2902 of file embedder_unittests.cc.

2902 {
2903 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
2904 uint64_t echoed_char;
2905 FlutterKeyEvent echoed_event;
2906 echoed_event.struct_size = sizeof(FlutterKeyEvent);
2907
2908 auto native_echo_event = [&](Dart_NativeArguments args) {
2909 echoed_event.type =
2912 echoed_event.timestamp =
2913 static_cast<double>(tonic::DartConverter<uint64_t>::FromDart(
2921 echoed_event.synthesized =
2923 echoed_event.device_type =
2926
2927 message_latch->Signal();
2928 };
2929
2930 auto platform_task_runner = CreateNewThread("platform_thread");
2931
2932 UniqueEngine engine;
2934 platform_task_runner->PostTask([&]() {
2935 auto& context =
2936 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2937 EmbedderConfigBuilder builder(context);
2938 builder.SetSoftwareRendererConfig();
2939 builder.SetDartEntrypoint("key_data_echo");
2940 builder.SetPlatformMessageCallback(
2941 [&](const FlutterPlatformMessage* message) {
2943 engine.get(), message->response_handle, nullptr, 0);
2944 });
2945 context.AddNativeCallback(
2946 "SignalNativeTest",
2948 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
2949
2950 context.AddNativeCallback("EchoKeyEvent",
2951 CREATE_NATIVE_ENTRY(native_echo_event));
2952
2953 engine = builder.LaunchEngine();
2954 ASSERT_TRUE(engine.is_valid());
2955 });
2956
2957 ready.Wait();
2958
2959 // A normal down event
2960 const FlutterKeyEvent down_event_upper_a{
2961 .struct_size = sizeof(FlutterKeyEvent),
2962 .timestamp = 1,
2964 .physical = 0x00070004,
2965 .logical = 0x00000000061,
2966 .character = "A",
2967 .synthesized = false,
2969 };
2970 platform_task_runner->PostTask([&]() {
2971 FlutterEngineSendKeyEvent(engine.get(), &down_event_upper_a, nullptr,
2972 nullptr);
2973 });
2974 message_latch->Wait();
2975
2976 ExpectKeyEventEq(echoed_event, down_event_upper_a);
2977 EXPECT_EQ(echoed_char, 0x41llu);
2978
2979 // A repeat event with multi-byte character
2980 const FlutterKeyEvent repeat_event_wide_char{
2981 .struct_size = sizeof(FlutterKeyEvent),
2982 .timestamp = 1000,
2984 .physical = 0x00070005,
2985 .logical = 0x00000000062,
2986 .character = "∆",
2987 .synthesized = false,
2989 };
2990 platform_task_runner->PostTask([&]() {
2991 FlutterEngineSendKeyEvent(engine.get(), &repeat_event_wide_char, nullptr,
2992 nullptr);
2993 });
2994 message_latch->Wait();
2995
2996 ExpectKeyEventEq(echoed_event, repeat_event_wide_char);
2997 EXPECT_EQ(echoed_char, 0x2206llu);
2998
2999 // An up event with no character, synthesized
3000 const FlutterKeyEvent up_event{
3001 .struct_size = sizeof(FlutterKeyEvent),
3002 .timestamp = 1000000,
3004 .physical = 0x00070006,
3005 .logical = 0x00000000063,
3006 .character = nullptr,
3007 .synthesized = true,
3009 };
3010 platform_task_runner->PostTask([&]() {
3011 FlutterEngineSendKeyEvent(engine.get(), &up_event, nullptr, nullptr);
3012 });
3013 message_latch->Wait();
3014
3015 ExpectKeyEventEq(echoed_event, up_event);
3016 EXPECT_EQ(echoed_char, 0llu);
3017
3018 fml::AutoResetWaitableEvent shutdown_latch;
3019 platform_task_runner->PostTask([&]() {
3020 engine.reset();
3021 shutdown_latch.Signal();
3022 });
3023 shutdown_latch.Wait();
3024}
void ExpectKeyEventEq(const FlutterKeyEvent &subject, const FlutterKeyEvent &baseline)

◆ TEST_F() [392/876]

flutter::testing::TEST_F ( EmbedderTest  ,
KeyDataResponseIsCorrectlyInvoked   
)

Definition at line 3146 of file embedder_unittests.cc.

3146 {
3148 fml::AutoResetWaitableEvent sync_latch;
3150
3151 // One of the threads that the key data callback will be posted to is the
3152 // platform thread. So we cannot wait for assertions to complete on the
3153 // platform thread. Create a new thread to manage the engine instance and wait
3154 // for assertions on the test thread.
3155 auto platform_task_runner = CreateNewThread("platform_thread");
3156
3157 platform_task_runner->PostTask([&]() {
3158 auto& context =
3159 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3160 EmbedderConfigBuilder builder(context);
3161 builder.SetSoftwareRendererConfig();
3162 builder.SetDartEntrypoint("key_data_echo");
3163 context.AddNativeCallback(
3164 "SignalNativeTest",
3166 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
3167 context.AddNativeCallback(
3168 "EchoKeyEvent", CREATE_NATIVE_ENTRY([](Dart_NativeArguments args) {}));
3169
3170 engine = builder.LaunchEngine();
3171 ASSERT_TRUE(engine.is_valid());
3172
3173 sync_latch.Signal();
3174 });
3175 sync_latch.Wait();
3176 ready.Wait();
3177
3178 // Dispatch a single event
3179 FlutterKeyEvent event{
3180 .struct_size = sizeof(FlutterKeyEvent),
3181 .timestamp = 1000,
3183 .physical = 0x00070005,
3184 .logical = 0x00000000062,
3185 .character = nullptr,
3187 };
3188
3189 KeyEventUserData user_data1{
3190 .latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3191 };
3192 // Entrypoint `key_data_echo` returns `event.synthesized` as `handled`.
3193 event.synthesized = true;
3194 platform_task_runner->PostTask([&]() {
3195 // Test when the response callback is empty.
3196 // It should not cause a crash.
3197 FlutterEngineSendKeyEvent(engine.get(), &event, nullptr, nullptr);
3198
3199 // Test when the response callback is non-empty.
3200 // It should be invoked (so that the latch can be unlocked.)
3202 engine.get(), &event,
3203 [](bool handled, void* untyped_user_data) {
3204 KeyEventUserData* user_data =
3205 reinterpret_cast<KeyEventUserData*>(untyped_user_data);
3206 EXPECT_EQ(handled, true);
3207 user_data->latch->Signal();
3208 },
3209 &user_data1);
3210 });
3211 user_data1.latch->Wait();
3212 fml::AutoResetWaitableEvent shutdown_latch;
3213 platform_task_runner->PostTask([&]() {
3214 engine.reset();
3215 shutdown_latch.Signal();
3216 });
3217 shutdown_latch.Wait();
3218}

◆ TEST_F() [393/876]

flutter::testing::TEST_F ( EmbedderTest  ,
LaunchFailsWhenMultiplePresentCallbacks   
)

Either present_layers_callback or present_view_callback must be provided, but not both, otherwise the engine must fail to launch instead of failing to render a frame at a later point in time.

Definition at line 86 of file embedder_gl_unittests.cc.

86 {
87 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
88 EmbedderConfigBuilder builder(context);
89 builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
90 builder.SetCompositor();
91 builder.GetCompositor().present_layers_callback =
92 [](const FlutterLayer** layers, size_t layers_count, void* user_data) {
93 return true;
94 };
95 builder.GetCompositor().present_view_callback =
96 [](const FlutterPresentViewInfo* info) { return true; };
97 auto engine = builder.LaunchEngine();
98 ASSERT_FALSE(engine.is_valid());
99}

◆ TEST_F() [394/876]

flutter::testing::TEST_F ( EmbedderTest  ,
LocalizationCallbacksCalled   
)

Definition at line 2047 of file embedder_unittests.cc.

2047 {
2048 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2050 context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
2051 EmbedderConfigBuilder builder(context);
2052 builder.SetSoftwareRendererConfig();
2053 auto engine = builder.LaunchEngine();
2054 ASSERT_TRUE(engine.is_valid());
2055 // Wait for the root isolate to launch.
2056 latch.Wait();
2057
2059 std::vector<std::string> supported_locales;
2060 supported_locales.push_back("es");
2061 supported_locales.push_back("MX");
2062 supported_locales.push_back("");
2063 auto result = shell.GetPlatformView()->ComputePlatformResolvedLocales(
2064 supported_locales);
2065
2066 ASSERT_EQ((*result).size(), supported_locales.size()); // 3
2067 ASSERT_EQ((*result)[0], supported_locales[0]);
2068 ASSERT_EQ((*result)[1], supported_locales[1]);
2069 ASSERT_EQ((*result)[2], supported_locales[2]);
2070
2071 engine.reset();
2072}

◆ TEST_F() [395/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MetalCompositorMustBeAbleToRenderPlatformViews   
)

Definition at line 131 of file embedder_metal_unittests.mm.

131 {
132 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
133
134 EmbedderConfigBuilder builder(context);
135 builder.SetMetalRendererConfig(SkISize::Make(800, 600));
136 builder.SetCompositor();
137 builder.SetDartEntrypoint("can_composite_platform_views");
138
139 builder.SetRenderTargetType(EmbedderTestBackingStoreProducer::RenderTargetType::kMetalTexture);
140
141 fml::CountDownLatch latch(3);
142 context.GetCompositor().SetNextPresentCallback(
143 [&](FlutterViewId view_id, const FlutterLayer** layers, size_t layers_count) {
144 ASSERT_EQ(layers_count, 3u);
145
146 {
147 FlutterBackingStore backing_store = *layers[0]->backing_store;
148 backing_store.struct_size = sizeof(backing_store);
149 backing_store.type = kFlutterBackingStoreTypeMetal;
150 backing_store.did_update = true;
151
152 FlutterRect paint_region_rects[] = {
153 FlutterRectMakeLTRB(0, 0, 800, 600),
154 };
155 FlutterRegion paint_region = {
156 .struct_size = sizeof(FlutterRegion),
157 .rects_count = 1,
158 .rects = paint_region_rects,
159 };
160 FlutterBackingStorePresentInfo present_info = {
162 .paint_region = &paint_region,
163 };
164
165 FlutterLayer layer = {};
166 layer.struct_size = sizeof(layer);
168 layer.backing_store = &backing_store;
169 layer.size = FlutterSizeMake(800.0, 600.0);
170 layer.offset = FlutterPointMake(0, 0);
171 layer.backing_store_present_info = &present_info;
172
173 ASSERT_EQ(*layers[0], layer);
174 }
175
176 {
179 platform_view.identifier = 42;
180
181 FlutterLayer layer = {};
182 layer.struct_size = sizeof(layer);
185 layer.size = FlutterSizeMake(123.0, 456.0);
186 layer.offset = FlutterPointMake(1.0, 2.0);
187
188 ASSERT_EQ(*layers[1], layer);
189 }
190
191 {
192 FlutterBackingStore backing_store = *layers[2]->backing_store;
193 backing_store.struct_size = sizeof(backing_store);
194 backing_store.type = kFlutterBackingStoreTypeMetal;
195 backing_store.did_update = true;
196
197 FlutterRect paint_region_rects[] = {
198 FlutterRectMakeLTRB(2, 3, 800, 600),
199 };
200 FlutterRegion paint_region = {
201 .struct_size = sizeof(FlutterRegion),
202 .rects_count = 1,
203 .rects = paint_region_rects,
204 };
205 FlutterBackingStorePresentInfo present_info = {
207 .paint_region = &paint_region,
208 };
209
210 FlutterLayer layer = {};
211 layer.struct_size = sizeof(layer);
213 layer.backing_store = &backing_store;
214 layer.size = FlutterSizeMake(800.0, 600.0);
215 layer.offset = FlutterPointMake(0.0, 0.0);
216 layer.backing_store_present_info = &present_info;
217
218 ASSERT_EQ(*layers[2], layer);
219 }
220
221 latch.CountDown();
222 });
223
224 context.AddNativeCallback(
225 "SignalNativeTest",
226 CREATE_NATIVE_ENTRY([&latch](Dart_NativeArguments args) { latch.CountDown(); }));
227
228 auto engine = builder.LaunchEngine();
229
230 // Send a window metrics events so frames may be scheduled.
231 FlutterWindowMetricsEvent event = {};
232 event.struct_size = sizeof(event);
233 event.width = 800;
234 event.height = 600;
235 event.pixel_ratio = 1.0;
237 ASSERT_TRUE(engine.is_valid());
238
239 latch.Wait();
240}

◆ TEST_F() [396/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MultipleDisplaysWithSameDisplayIdIsInvalid   
)

Definition at line 4217 of file embedder_gl_unittests.cc.

4217 {
4218 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4219
4220 EmbedderConfigBuilder builder(context);
4221 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4222 builder.SetCompositor();
4223 builder.SetDartEntrypoint("empty_scene");
4225 context.AddNativeCallback(
4226 "SignalNativeTest",
4228
4229 auto engine = builder.LaunchEngine();
4230
4231 ASSERT_TRUE(engine.is_valid());
4232
4233 FlutterEngineDisplay display_1;
4234 display_1.struct_size = sizeof(FlutterEngineDisplay);
4235 display_1.display_id = 1;
4236 display_1.single_display = false;
4237 display_1.refresh_rate = 20;
4238
4239 FlutterEngineDisplay display_2;
4240 display_2.struct_size = sizeof(FlutterEngineDisplay);
4241 display_2.display_id = 1;
4242 display_2.single_display = false;
4243 display_2.refresh_rate = 60;
4244
4245 std::vector<FlutterEngineDisplay> displays = {display_1, display_2};
4246
4248 engine.get(), kFlutterEngineDisplaysUpdateTypeStartup, displays.data(),
4249 displays.size());
4250 ASSERT_NE(result, kSuccess);
4251
4252 FlutterWindowMetricsEvent event = {};
4253 event.struct_size = sizeof(event);
4254 event.width = 800;
4255 event.height = 600;
4256 event.pixel_ratio = 1.0;
4258 kSuccess);
4259
4260 latch.Wait();
4261}
FlutterEngineResult FlutterEngineNotifyDisplayUpdate(FLUTTER_API_SYMBOL(FlutterEngine) raw_engine, const FlutterEngineDisplaysUpdateType update_type, const FlutterEngineDisplay *embedder_displays, size_t display_count)
Posts updates corresponding to display changes to a running engine instance.
Definition embedder.cc:3246
@ kFlutterEngineDisplaysUpdateTypeStartup
Definition embedder.h:2004
size_t struct_size
This size of this struct. Must be sizeof(FlutterDisplay).
Definition embedder.h:1971
FlutterEngineDisplayId display_id
Definition embedder.h:1973

◆ TEST_F() [397/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MultipleDisplaysWithSingleDisplayTrueIsInvalid   
)

Definition at line 4171 of file embedder_gl_unittests.cc.

4171 {
4172 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4173
4174 EmbedderConfigBuilder builder(context);
4175 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4176 builder.SetCompositor();
4177 builder.SetDartEntrypoint("empty_scene");
4179 context.AddNativeCallback(
4180 "SignalNativeTest",
4182
4183 auto engine = builder.LaunchEngine();
4184
4185 ASSERT_TRUE(engine.is_valid());
4186
4187 FlutterEngineDisplay display_1;
4188 display_1.struct_size = sizeof(FlutterEngineDisplay);
4189 display_1.display_id = 1;
4190 display_1.single_display = true;
4191 display_1.refresh_rate = 20;
4192
4193 FlutterEngineDisplay display_2;
4194 display_2.struct_size = sizeof(FlutterEngineDisplay);
4195 display_2.display_id = 2;
4196 display_2.single_display = true;
4197 display_2.refresh_rate = 60;
4198
4199 std::vector<FlutterEngineDisplay> displays = {display_1, display_2};
4200
4202 engine.get(), kFlutterEngineDisplaysUpdateTypeStartup, displays.data(),
4203 displays.size());
4204 ASSERT_NE(result, kSuccess);
4205
4206 FlutterWindowMetricsEvent event = {};
4207 event.struct_size = sizeof(event);
4208 event.width = 800;
4209 event.height = 600;
4210 event.pixel_ratio = 1.0;
4212 kSuccess);
4213
4214 latch.Wait();
4215}

◆ TEST_F() [398/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWhenPopulateExistingDamageButNoOtherFBOCallback   
)

Definition at line 3636 of file embedder_gl_unittests.cc.

3637 {
3638 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3639
3640 EmbedderConfigBuilder builder(context);
3641 builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
3642 builder.GetRendererConfig().open_gl.fbo_callback = nullptr;
3643 builder.GetRendererConfig().open_gl.fbo_with_frame_info_callback = nullptr;
3644 builder.GetRendererConfig().open_gl.populate_existing_damage =
3645 [](void* context, const intptr_t id,
3646 FlutterDamage* existing_damage) -> void {
3647 return reinterpret_cast<EmbedderTestContextGL*>(context)
3648 ->GLPopulateExistingDamage(id, existing_damage);
3649 };
3650
3651 auto engine = builder.LaunchEngine();
3652 ASSERT_FALSE(engine.is_valid());
3653}

◆ TEST_F() [399/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWithBothFBOCallbacksSet   
)

Definition at line 3567 of file embedder_gl_unittests.cc.

3567 {
3568 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3569
3570 EmbedderConfigBuilder builder(context);
3571 builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
3572 builder.SetOpenGLFBOCallBack();
3573
3574 auto engine = builder.LaunchEngine();
3575 ASSERT_FALSE(engine.is_valid());
3576}

◆ TEST_F() [400/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWithBothPresentCallbacksSet   
)

Definition at line 3578 of file embedder_gl_unittests.cc.

3578 {
3579 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3580
3581 EmbedderConfigBuilder builder(context);
3582 builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
3583 builder.SetOpenGLPresentCallBack();
3584
3585 auto engine = builder.LaunchEngine();
3586 ASSERT_FALSE(engine.is_valid());
3587}

◆ TEST_F() [401/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWithMultipleAOTSources   
)

Definition at line 2368 of file embedder_unittests.cc.

2368 {
2369 if (!DartVM::IsRunningPrecompiledCode()) {
2370 GTEST_SKIP();
2371 return;
2372 }
2373 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2374
2375 EmbedderConfigBuilder builder(
2376 context,
2377 EmbedderConfigBuilder::InitializationPreference::kMultiAOTInitialize);
2378
2379 builder.SetSoftwareRendererConfig();
2380
2381 auto engine = builder.LaunchEngine();
2382 ASSERT_FALSE(engine.is_valid());
2383}

◆ TEST_F() [402/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustPreventEngineLaunchWhenRequiredCompositorArgsAreAbsent   
)

If an incorrectly configured compositor is set on the engine, the engine must fail to launch instead of failing to render a frame at a later point in time.

Definition at line 67 of file embedder_gl_unittests.cc.

68 {
69 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
70 EmbedderConfigBuilder builder(context);
71 builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
72 builder.SetCompositor();
73 builder.GetCompositor().create_backing_store_callback = nullptr;
74 builder.GetCompositor().collect_backing_store_callback = nullptr;
75 builder.GetCompositor().present_layers_callback = nullptr;
76 builder.GetCompositor().present_view_callback = nullptr;
77 auto engine = builder.LaunchEngine();
78 ASSERT_FALSE(engine.is_valid());
79}

◆ TEST_F() [403/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustRunWhenPopulateExistingDamageIsProvided   
)

Definition at line 3600 of file embedder_gl_unittests.cc.

3600 {
3601 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3602
3603 EmbedderConfigBuilder builder(context);
3604 builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
3605
3606 builder.GetRendererConfig().open_gl.populate_existing_damage =
3607 [](void* context, const intptr_t id,
3608 FlutterDamage* existing_damage) -> void {
3609 return reinterpret_cast<EmbedderTestContextGL*>(context)
3610 ->GLPopulateExistingDamage(id, existing_damage);
3611 };
3612
3613 auto engine = builder.LaunchEngine();
3614 ASSERT_TRUE(engine.is_valid());
3615}

◆ TEST_F() [404/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustRunWithPopulateExistingDamageAndFBOCallback   
)

Definition at line 3617 of file embedder_gl_unittests.cc.

3617 {
3618 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3619
3620 EmbedderConfigBuilder builder(context);
3621 builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
3622 builder.GetRendererConfig().open_gl.fbo_callback =
3623 [](void* context) -> uint32_t { return 0; };
3624 builder.GetRendererConfig().open_gl.fbo_with_frame_info_callback = nullptr;
3625 builder.GetRendererConfig().open_gl.populate_existing_damage =
3626 [](void* context, const intptr_t id,
3627 FlutterDamage* existing_damage) -> void {
3628 return reinterpret_cast<EmbedderTestContextGL*>(context)
3629 ->GLPopulateExistingDamage(id, existing_damage);
3630 };
3631
3632 auto engine = builder.LaunchEngine();
3633 ASSERT_TRUE(engine.is_valid());
3634}

◆ TEST_F() [405/876]

flutter::testing::TEST_F ( EmbedderTest  ,
MustStillRunWhenPopulateExistingDamageIsNotProvided   
)

Definition at line 3589 of file embedder_gl_unittests.cc.

3589 {
3590 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3591
3592 EmbedderConfigBuilder builder(context);
3593 builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
3594 builder.GetRendererConfig().open_gl.populate_existing_damage = nullptr;
3595
3596 auto engine = builder.LaunchEngine();
3597 ASSERT_TRUE(engine.is_valid());
3598}

◆ TEST_F() [406/876]

flutter::testing::TEST_F ( EmbedderTest  ,
NoLayerCreatedForNoOverlayOnTopOfPlatformLayer   
)

Test the layer structure and pixels rendered when using a custom software compositor, with a no overlay

Definition at line 1077 of file embedder_unittests.cc.

1077 {
1078 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1079
1080 EmbedderConfigBuilder builder(context);
1081 builder.SetSoftwareRendererConfig(SkISize::Make(800, 600));
1082 builder.SetCompositor();
1083 builder.SetDartEntrypoint("can_composite_platform_views_no_overlay");
1084
1085 builder.SetRenderTargetType(
1086 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
1087
1088 fml::CountDownLatch latch(4);
1089
1090 auto scene_image = context.GetNextSceneImage();
1091
1092 context.GetCompositor().SetNextPresentCallback(
1093 [&](FlutterViewId view_id, const FlutterLayer** layers,
1094 size_t layers_count) {
1095 ASSERT_EQ(layers_count, 2u);
1096
1097 // Layer Root
1098 {
1099 FlutterBackingStore backing_store = *layers[0]->backing_store;
1100 backing_store.type = kFlutterBackingStoreTypeSoftware;
1101 backing_store.did_update = true;
1102 backing_store.software.height = 600;
1103
1104 FlutterRect paint_region_rects[] = {
1105 FlutterRectMakeLTRB(0, 0, 800, 600),
1106 };
1107 FlutterRegion paint_region = {
1108 .struct_size = sizeof(FlutterRegion),
1109 .rects_count = 1,
1110 .rects = paint_region_rects,
1111 };
1112 FlutterBackingStorePresentInfo present_info = {
1114 .paint_region = &paint_region,
1115 };
1116
1117 FlutterLayer layer = {};
1118 layer.struct_size = sizeof(layer);
1120 layer.backing_store = &backing_store;
1121 layer.size = FlutterSizeMake(800.0, 600.0);
1122 layer.offset = FlutterPointMake(0.0, 0.0);
1123 layer.backing_store_present_info = &present_info;
1124
1125 ASSERT_EQ(*layers[0], layer);
1126 }
1127
1128 // Layer 1
1129 {
1132 platform_view.identifier = 1;
1133
1134 FlutterLayer layer = {};
1135 layer.struct_size = sizeof(layer);
1138 layer.size = FlutterSizeMake(50.0, 150.0);
1139 layer.offset = FlutterPointMake(20.0, 20.0);
1140
1141 ASSERT_EQ(*layers[1], layer);
1142 }
1143
1144 latch.CountDown();
1145 });
1146
1147 context.GetCompositor().SetPlatformViewRendererCallback(
1148 [&](const FlutterLayer& layer, GrDirectContext*
1149 /* don't use because software compositor */) -> sk_sp<SkImage> {
1151 layer, nullptr /* null because software compositor */);
1152 auto canvas = surface->getCanvas();
1153 FML_CHECK(canvas != nullptr);
1154
1155 switch (layer.platform_view->identifier) {
1156 case 1: {
1157 SkPaint paint;
1158 // See dart test for total order.
1159 paint.setColor(SK_ColorGREEN);
1160 paint.setAlpha(127);
1161 const auto& rect =
1162 SkRect::MakeWH(layer.size.width, layer.size.height);
1163 canvas->drawRect(rect, paint);
1164 latch.CountDown();
1165 } break;
1166 default:
1167 // Asked to render an unknown platform view.
1168 FML_CHECK(false)
1169 << "Test was asked to composite an unknown platform view.";
1170 }
1171
1172 return surface->makeImageSnapshot();
1173 });
1174
1175 context.AddNativeCallback(
1176 "SignalNativeTest",
1178 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
1179
1180 auto engine = builder.LaunchEngine();
1181
1182 // Send a window metrics events so frames may be scheduled.
1183 FlutterWindowMetricsEvent event = {};
1184 event.struct_size = sizeof(event);
1185 event.width = 800;
1186 event.height = 600;
1187 event.pixel_ratio = 1.0;
1188 event.physical_view_inset_top = 0.0;
1189 event.physical_view_inset_right = 0.0;
1190 event.physical_view_inset_bottom = 0.0;
1191 event.physical_view_inset_left = 0.0;
1193 kSuccess);
1194 ASSERT_TRUE(engine.is_valid());
1195
1196 latch.Wait();
1197
1198 // TODO(https://github.com/flutter/flutter/issues/53784): enable this on all
1199 // platforms.
1200#if !defined(FML_OS_LINUX)
1201 GTEST_SKIP() << "Skipping golden tests on non-Linux OSes";
1202#endif // FML_OS_LINUX
1203 ASSERT_TRUE(ImageMatchesFixture(
1204 "compositor_platform_layer_with_no_overlay.png", scene_image));
1205
1206 // There should no present calls on the root surface.
1207 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
1208}

◆ TEST_F() [407/876]

flutter::testing::TEST_F ( EmbedderTest  ,
NoLayerCreatedForTransparentOverlayOnTopOfPlatformLayer   
)

Test the layer structure and pixels rendered when using a custom software compositor, with a transparent overlay

Definition at line 940 of file embedder_unittests.cc.

940 {
941 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
942
943 EmbedderConfigBuilder builder(context);
944 builder.SetSoftwareRendererConfig(SkISize::Make(800, 600));
945 builder.SetCompositor();
946 builder.SetDartEntrypoint("can_composite_platform_views_transparent_overlay");
947
948 builder.SetRenderTargetType(
949 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
950
951 fml::CountDownLatch latch(4);
952
953 auto scene_image = context.GetNextSceneImage();
954
955 context.GetCompositor().SetNextPresentCallback(
956 [&](FlutterViewId view_id, const FlutterLayer** layers,
957 size_t layers_count) {
958 ASSERT_EQ(layers_count, 2u);
959
960 // Layer Root
961 {
962 FlutterBackingStore backing_store = *layers[0]->backing_store;
964 backing_store.did_update = true;
965 backing_store.software.height = 600;
966
967 FlutterRect paint_region_rects[] = {
968 FlutterRectMakeLTRB(0, 0, 800, 600),
969 };
970 FlutterRegion paint_region = {
971 .struct_size = sizeof(FlutterRegion),
972 .rects_count = 1,
973 .rects = paint_region_rects,
974 };
975 FlutterBackingStorePresentInfo present_info = {
977 .paint_region = &paint_region,
978 };
979
980 FlutterLayer layer = {};
981 layer.struct_size = sizeof(layer);
983 layer.backing_store = &backing_store;
984 layer.size = FlutterSizeMake(800.0, 600.0);
985 layer.offset = FlutterPointMake(0.0, 0.0);
986 layer.backing_store_present_info = &present_info;
987
988 ASSERT_EQ(*layers[0], layer);
989 }
990
991 // Layer 1
992 {
995 platform_view.identifier = 1;
996
997 FlutterLayer layer = {};
998 layer.struct_size = sizeof(layer);
1001 layer.size = FlutterSizeMake(50.0, 150.0);
1002 layer.offset = FlutterPointMake(20.0, 20.0);
1003
1004 ASSERT_EQ(*layers[1], layer);
1005 }
1006
1007 latch.CountDown();
1008 });
1009
1010 context.GetCompositor().SetPlatformViewRendererCallback(
1011 [&](const FlutterLayer& layer, GrDirectContext*
1012 /* don't use because software compositor */) -> sk_sp<SkImage> {
1014 layer, nullptr /* null because software compositor */);
1015 auto canvas = surface->getCanvas();
1016 FML_CHECK(canvas != nullptr);
1017
1018 switch (layer.platform_view->identifier) {
1019 case 1: {
1020 SkPaint paint;
1021 // See dart test for total order.
1022 paint.setColor(SK_ColorGREEN);
1023 paint.setAlpha(127);
1024 const auto& rect =
1025 SkRect::MakeWH(layer.size.width, layer.size.height);
1026 canvas->drawRect(rect, paint);
1027 latch.CountDown();
1028 } break;
1029 default:
1030 // Asked to render an unknown platform view.
1031 FML_CHECK(false)
1032 << "Test was asked to composite an unknown platform view.";
1033 }
1034
1035 return surface->makeImageSnapshot();
1036 });
1037
1038 context.AddNativeCallback(
1039 "SignalNativeTest",
1041 [&latch](Dart_NativeArguments args) { latch.CountDown(); }));
1042
1043 auto engine = builder.LaunchEngine();
1044
1045 // Send a window metrics events so frames may be scheduled.
1046 FlutterWindowMetricsEvent event = {};
1047 event.struct_size = sizeof(event);
1048 event.width = 800;
1049 event.height = 600;
1050 event.pixel_ratio = 1.0;
1051 event.physical_view_inset_top = 0.0;
1052 event.physical_view_inset_right = 0.0;
1053 event.physical_view_inset_bottom = 0.0;
1054 event.physical_view_inset_left = 0.0;
1056 kSuccess);
1057 ASSERT_TRUE(engine.is_valid());
1058
1059 latch.Wait();
1060
1061 // TODO(https://github.com/flutter/flutter/issues/53784): enable this on all
1062 // platforms.
1063#if !defined(FML_OS_LINUX)
1064 GTEST_SKIP() << "Skipping golden tests on non-Linux OSes";
1065#endif // FML_OS_LINUX
1066 ASSERT_TRUE(ImageMatchesFixture(
1067 "compositor_platform_layer_with_no_overlay.png", scene_image));
1068
1069 // There should no present calls on the root surface.
1070 ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
1071}

◆ TEST_F() [408/876]

flutter::testing::TEST_F ( EmbedderTest  ,
NullPlatformMessagesCanBeSent   
)

Tests that a null platform message can be sent.

Definition at line 470 of file embedder_unittests.cc.

470 {
471 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
472 EmbedderConfigBuilder builder(context);
473 builder.SetSoftwareRendererConfig();
474 builder.SetDartEntrypoint("null_platform_messages");
475
477 context.AddNativeCallback(
478 "SignalNativeTest",
480 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
481 context.AddNativeCallback(
482 "SignalNativeMessage",
484 auto received_message = tonic::DartConverter<std::string>::FromDart(
486 ASSERT_EQ("true", received_message);
487 message.Signal();
488 })));
489
490 auto engine = builder.LaunchEngine();
491
492 ASSERT_TRUE(engine.is_valid());
493 ready.Wait();
494
495 FlutterPlatformMessage platform_message = {};
496 platform_message.struct_size = sizeof(FlutterPlatformMessage);
497 platform_message.channel = "test_channel";
498 platform_message.message = nullptr;
499 platform_message.message_size = 0;
500 platform_message.response_handle = nullptr; // No response needed.
501
502 auto result =
503 FlutterEngineSendPlatformMessage(engine.get(), &platform_message);
504 ASSERT_EQ(result, kSuccess);
505 message.Wait();
506}

◆ TEST_F() [409/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ObjectsCanBePostedViaPorts   
)

Definition at line 3111 of file embedder_gl_unittests.cc.

3111 {
3112 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3113 EmbedderConfigBuilder builder(context);
3114 builder.SetOpenGLRendererConfig(SkISize::Make(800, 1024));
3115 builder.SetDartEntrypoint("objects_can_be_posted");
3116
3117 // Synchronously acquire the send port from the Dart end. We will be using
3118 // this to send message. The Dart end will just echo those messages back to us
3119 // for inspection.
3122 context.AddNativeCallback("SignalNativeCount",
3126 event.Signal();
3127 }));
3128 auto engine = builder.LaunchEngine();
3129 ASSERT_TRUE(engine.is_valid());
3130 event.Wait();
3131 ASSERT_NE(port, 0);
3132
3133 using Trampoline = std::function<void(Dart_Handle message)>;
3134 Trampoline trampoline;
3135
3136 context.AddNativeCallback("SendObjectToNativeCode",
3138 FML_CHECK(trampoline);
3139 auto trampoline_copy = trampoline;
3140 trampoline = nullptr;
3141 trampoline_copy(Dart_GetNativeArgument(args, 0));
3142 }));
3143
3144 // Check null.
3145 {
3146 FlutterEngineDartObject object = {};
3148 trampoline = [&](Dart_Handle handle) {
3149 ASSERT_TRUE(Dart_IsNull(handle));
3150 event.Signal();
3151 };
3152 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3153 kSuccess);
3154 event.Wait();
3155 }
3156
3157 // Check bool.
3158 {
3159 FlutterEngineDartObject object = {};
3161 object.bool_value = true;
3162 trampoline = [&](Dart_Handle handle) {
3163 ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(handle));
3164 event.Signal();
3165 };
3166 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3167 kSuccess);
3168 event.Wait();
3169 }
3170
3171 // Check int32.
3172 {
3173 FlutterEngineDartObject object = {};
3175 object.int32_value = 1988;
3176 trampoline = [&](Dart_Handle handle) {
3177 ASSERT_EQ(tonic::DartConverter<int32_t>::FromDart(handle), 1988);
3178 event.Signal();
3179 };
3180 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3181 kSuccess);
3182 event.Wait();
3183 }
3184
3185 // Check int64.
3186 {
3187 FlutterEngineDartObject object = {};
3189 object.int64_value = 1988;
3190 trampoline = [&](Dart_Handle handle) {
3191 ASSERT_EQ(tonic::DartConverter<int64_t>::FromDart(handle), 1988);
3192 event.Signal();
3193 };
3194 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3195 kSuccess);
3196 event.Wait();
3197 }
3198
3199 // Check double.
3200 {
3201 FlutterEngineDartObject object = {};
3203 object.double_value = 1988.0;
3204 trampoline = [&](Dart_Handle handle) {
3205 ASSERT_DOUBLE_EQ(tonic::DartConverter<double>::FromDart(handle), 1988.0);
3206 event.Signal();
3207 };
3208 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3209 kSuccess);
3210 event.Wait();
3211 }
3212
3213 // Check string.
3214 {
3215 const char* message = "Hello. My name is Inigo Montoya.";
3216 FlutterEngineDartObject object = {};
3218 object.string_value = message;
3219 trampoline = [&](Dart_Handle handle) {
3221 std::string{message});
3222 event.Signal();
3223 };
3224 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3225 kSuccess);
3226 event.Wait();
3227 }
3228
3229 // Check buffer (copied out).
3230 {
3231 std::vector<uint8_t> message;
3232 message.resize(1988);
3233
3234 ASSERT_TRUE(MemsetPatternSetOrCheck(
3235 message, MemsetPatternOp::kMemsetPatternOpSetBuffer));
3236
3238
3239 buffer.struct_size = sizeof(buffer);
3240 buffer.user_data = nullptr;
3241 buffer.buffer_collect_callback = nullptr;
3242 buffer.buffer = message.data();
3243 buffer.buffer_size = message.size();
3244
3245 FlutterEngineDartObject object = {};
3247 object.buffer_value = &buffer;
3248 trampoline = [&](Dart_Handle handle) {
3249 intptr_t length = 0;
3250 Dart_ListLength(handle, &length);
3251 ASSERT_EQ(length, 1988);
3252 // TODO(chinmaygarde); The std::vector<uint8_t> specialization for
3253 // DartConvertor in tonic is broken which is preventing the buffer
3254 // being checked here. Fix tonic and strengthen this check. For now, just
3255 // the buffer length is checked.
3256 event.Signal();
3257 };
3258 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3259 kSuccess);
3260 event.Wait();
3261 }
3262
3263 std::vector<uint8_t> message;
3264 fml::AutoResetWaitableEvent buffer_released_latch;
3265
3266 // Check buffer (caller own buffer with zero copy transfer).
3267 {
3268 message.resize(1988);
3269
3270 ASSERT_TRUE(MemsetPatternSetOrCheck(
3271 message, MemsetPatternOp::kMemsetPatternOpSetBuffer));
3272
3274
3275 buffer.struct_size = sizeof(buffer);
3276 buffer.user_data = &buffer_released_latch;
3277 buffer.buffer_collect_callback = +[](void* user_data) {
3278 reinterpret_cast<fml::AutoResetWaitableEvent*>(user_data)->Signal();
3279 };
3280 buffer.buffer = message.data();
3281 buffer.buffer_size = message.size();
3282
3283 FlutterEngineDartObject object = {};
3285 object.buffer_value = &buffer;
3286 trampoline = [&](Dart_Handle handle) {
3287 intptr_t length = 0;
3288 Dart_ListLength(handle, &length);
3289 ASSERT_EQ(length, 1988);
3290 // TODO(chinmaygarde); The std::vector<uint8_t> specialization for
3291 // DartConvertor in tonic is broken which is preventing the buffer
3292 // being checked here. Fix tonic and strengthen this check. For now, just
3293 // the buffer length is checked.
3294 event.Signal();
3295 };
3296 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
3297 kSuccess);
3298 event.Wait();
3299 }
3300
3301 engine.reset();
3302
3303 // We cannot determine when the VM will GC objects that might have external
3304 // typed data finalizers. Since we need to ensure that we correctly wired up
3305 // finalizers from the embedders, we force the VM to collect all objects but
3306 // just shutting it down.
3307 buffer_released_latch.Wait();
3308}
DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t *length)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
FlutterEngineResult FlutterEnginePostDartObject(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterEngineDartPort port, const FlutterEngineDartObject *object)
Posts a Dart object to specified send port. The corresponding receive port for send port can be in an...
Definition embedder.cc:3061
@ kFlutterEngineDartObjectTypeString
Definition embedder.h:2016
@ kFlutterEngineDartObjectTypeBool
Definition embedder.h:2012
@ kFlutterEngineDartObjectTypeDouble
Definition embedder.h:2015
@ kFlutterEngineDartObjectTypeInt32
Definition embedder.h:2013
@ kFlutterEngineDartObjectTypeBuffer
Definition embedder.h:2019
@ kFlutterEngineDartObjectTypeInt64
Definition embedder.h:2014
@ kFlutterEngineDartObjectTypeNull
Definition embedder.h:2011
int64_t FlutterEngineDartPort
Definition embedder.h:2008
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
Definition switches.h:87
size_t struct_size
The size of this struct. Must be sizeof(FlutterEngineDartBuffer).
Definition embedder.h:2024
FlutterEngineDartObjectType type
Definition embedder.h:2067

◆ TEST_F() [410/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ObjectsPostedViaPortsServicedOnSecondaryTaskHeap   
)

Definition at line 4354 of file embedder_gl_unittests.cc.

4354 {
4355 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4356 EmbedderConfigBuilder builder(context);
4357 builder.SetOpenGLRendererConfig(SkISize::Make(800, 1024));
4358 builder.SetDartEntrypoint("objects_can_be_posted");
4359
4360 // Synchronously acquire the send port from the Dart end. We will be using
4361 // this to send message. The Dart end will just echo those messages back to us
4362 // for inspection.
4365 context.AddNativeCallback("SignalNativeCount",
4369 event.Signal();
4370 }));
4371 auto engine = builder.LaunchEngine();
4372 ASSERT_TRUE(engine.is_valid());
4373 event.Wait();
4374 ASSERT_NE(port, 0);
4375
4376 using Trampoline = std::function<void(Dart_Handle message)>;
4377 Trampoline trampoline;
4378
4379 context.AddNativeCallback("SendObjectToNativeCode",
4381 FML_CHECK(trampoline);
4382 auto trampoline_copy = trampoline;
4383 trampoline = nullptr;
4384 trampoline_copy(Dart_GetNativeArgument(args, 0));
4385 }));
4386
4387 // Send a boolean value and assert that it's received by the right heap.
4388 {
4389 FlutterEngineDartObject object = {};
4391 object.bool_value = true;
4392 trampoline = [&](Dart_Handle handle) {
4393 ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(handle));
4395 EXPECT_EQ(task_grade, fml::TaskSourceGrade::kDartEventLoop);
4396 event.Signal();
4397 };
4398 ASSERT_EQ(FlutterEnginePostDartObject(engine.get(), port, &object),
4399 kSuccess);
4400 event.Wait();
4401 }
4402}
static TaskSourceGrade GetCurrentTaskSourceGrade()

◆ TEST_F() [411/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformMessagesCanBeSentWithoutResponseHandles   
)

Tests that a platform message can be sent with no response handle. Instead of the platform message integrity checked via a response handle, a native callback with the response is invoked to assert integrity.

Definition at line 425 of file embedder_unittests.cc.

425 {
426 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
427 EmbedderConfigBuilder builder(context);
428 builder.SetSoftwareRendererConfig();
429 builder.SetDartEntrypoint("platform_messages_no_response");
430
431 const std::string message_data = "Hello but don't call me back.";
432
434 context.AddNativeCallback(
435 "SignalNativeTest",
437 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
438 context.AddNativeCallback(
439 "SignalNativeMessage",
441 ([&message, &message_data](Dart_NativeArguments args) {
442 auto received_message = tonic::DartConverter<std::string>::FromDart(
444 ASSERT_EQ(received_message, message_data);
445 message.Signal();
446 })));
447
448 auto engine = builder.LaunchEngine();
449
450 ASSERT_TRUE(engine.is_valid());
451 ready.Wait();
452
453 FlutterPlatformMessage platform_message = {};
454 platform_message.struct_size = sizeof(FlutterPlatformMessage);
455 platform_message.channel = "test_channel";
456 platform_message.message =
457 reinterpret_cast<const uint8_t*>(message_data.data());
458 platform_message.message_size = message_data.size();
459 platform_message.response_handle = nullptr; // No response needed.
460
461 auto result =
462 FlutterEngineSendPlatformMessage(engine.get(), &platform_message);
463 ASSERT_EQ(result, kSuccess);
464 message.Wait();
465}

◆ TEST_F() [412/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformMessagesCanReceiveResponse   
)

Sends platform messages to Dart code than simply echoes the contents of the message back to the embedder. The embedder registers a native callback to intercept that message.

Definition at line 360 of file embedder_unittests.cc.

360 {
361 struct Captures {
363 std::thread::id thread_id;
364 };
365 Captures captures;
366
367 CreateNewThread()->PostTask([&]() {
368 captures.thread_id = std::this_thread::get_id();
369 auto& context =
370 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
371 EmbedderConfigBuilder builder(context);
372 builder.SetSoftwareRendererConfig();
373 builder.SetDartEntrypoint("platform_messages_response");
374
376 context.AddNativeCallback(
377 "SignalNativeTest",
379 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
380
381 auto engine = builder.LaunchEngine();
382 ASSERT_TRUE(engine.is_valid());
383
384 static std::string kMessageData = "Hello from embedder.";
385
386 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
387 auto callback = [](const uint8_t* data, size_t size,
388 void* user_data) -> void {
389 ASSERT_EQ(size, kMessageData.size());
390 ASSERT_EQ(strncmp(reinterpret_cast<const char*>(kMessageData.data()),
391 reinterpret_cast<const char*>(data), size),
392 0);
393 auto captures = reinterpret_cast<Captures*>(user_data);
394 ASSERT_EQ(captures->thread_id, std::this_thread::get_id());
395 captures->latch.Signal();
396 };
398 engine.get(), callback, &captures, &response_handle);
399 ASSERT_EQ(result, kSuccess);
400
403 message.channel = "test_channel";
404 message.message = reinterpret_cast<const uint8_t*>(kMessageData.data());
405 message.message_size = kMessageData.size();
406 message.response_handle = response_handle;
407
408 ready.Wait();
410 ASSERT_EQ(result, kSuccess);
411
413 response_handle);
414 ASSERT_EQ(result, kSuccess);
415 });
416
417 captures.latch.Wait();
418}

◆ TEST_F() [413/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformThreadIsolatesWithCustomPlatformTaskRunner   
)

Definition at line 3697 of file embedder_unittests.cc.

3697 {
3698 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3699 static fml::AutoResetWaitableEvent latch;
3700
3701 static std::thread::id ffi_call_thread_id;
3702 static void (*ffi_signal_native_test)() = []() -> void {
3703 ffi_call_thread_id = std::this_thread::get_id();
3704 latch.Signal();
3705 };
3706
3707 Dart_FfiNativeResolver ffi_resolver = [](const char* name,
3708 uintptr_t args_n) -> void* {
3709 if (std::string_view(name) == "FFISignalNativeTest") {
3710 return reinterpret_cast<void*>(ffi_signal_native_test);
3711 }
3712 return nullptr;
3713 };
3714
3715 // The test's Dart code will call this native function which overrides the
3716 // FFI resolver. After that, the Dart code will invoke the FFI function
3717 // using runOnPlatformThread.
3718 context.AddNativeCallback(
3719 "SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
3721 }));
3722
3723 auto platform_task_runner = CreateNewThread("test_platform_thread");
3724
3726
3727 EmbedderTestTaskRunner test_task_runner(
3728 platform_task_runner, [&](FlutterTask task) {
3729 if (!engine.is_valid()) {
3730 return;
3731 }
3732 FlutterEngineRunTask(engine.get(), &task);
3733 });
3734
3735 std::thread::id platform_thread_id;
3736 platform_task_runner->PostTask([&]() {
3737 platform_thread_id = std::this_thread::get_id();
3738
3739 EmbedderConfigBuilder builder(context);
3740 const auto task_runner_description =
3741 test_task_runner.GetFlutterTaskRunnerDescription();
3742 builder.SetSoftwareRendererConfig();
3743 builder.SetPlatformTaskRunner(&task_runner_description);
3744 builder.SetDartEntrypoint("invokePlatformThreadIsolate");
3745 builder.AddCommandLineArgument("--enable-platform-isolates");
3746 engine = builder.LaunchEngine();
3747 ASSERT_TRUE(engine.is_valid());
3748 });
3749
3750 latch.Wait();
3751
3752 fml::AutoResetWaitableEvent kill_latch;
3753 platform_task_runner->PostTask(fml::MakeCopyable([&]() mutable {
3754 engine.reset();
3755
3756 platform_task_runner->PostTask([&kill_latch] { kill_latch.Signal(); });
3757 }));
3758 kill_latch.Wait();
3759
3760 // Check that the FFI call was executed on the platform thread.
3761 ASSERT_EQ(platform_thread_id, ffi_call_thread_id);
3762}
DART_EXPORT Dart_Handle Dart_SetFfiNativeResolver(Dart_Handle library, Dart_FfiNativeResolver resolver)
void *(* Dart_FfiNativeResolver)(const char *name, uintptr_t args_n)
Definition dart_api.h:3253
DART_EXPORT Dart_Handle Dart_RootLibrary(void)
fml::UniqueObject< FlutterEngine, UniqueEngineTraits > UniqueEngine

◆ TEST_F() [414/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformViewMutatorsAreValidWithPixelRatio   
)

Definition at line 2627 of file embedder_gl_unittests.cc.

2627 {
2628 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2629
2630 EmbedderConfigBuilder builder(context);
2631 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
2632 builder.SetCompositor();
2633 builder.SetDartEntrypoint("platform_view_mutators_with_pixel_ratio");
2634
2635 builder.SetRenderTargetType(
2636 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
2637
2638 fml::CountDownLatch latch(1);
2639 context.GetCompositor().SetNextPresentCallback(
2640 [&](FlutterViewId view_id, const FlutterLayer** layers,
2641 size_t layers_count) {
2642 ASSERT_EQ(layers_count, 2u);
2643
2644 // Layer 0 (Root)
2645 {
2646 FlutterBackingStore backing_store = *layers[0]->backing_store;
2647 backing_store.type = kFlutterBackingStoreTypeOpenGL;
2648 backing_store.did_update = true;
2650
2651 FlutterRect paint_region_rects[] = {
2652 FlutterRectMakeLTRB(0, 0, 800, 600),
2653 };
2654 FlutterRegion paint_region = {
2655 .struct_size = sizeof(FlutterRegion),
2656 .rects_count = 1,
2657 .rects = paint_region_rects,
2658 };
2659 FlutterBackingStorePresentInfo present_info = {
2661 .paint_region = &paint_region,
2662 };
2663
2664 FlutterLayer layer = {};
2665 layer.struct_size = sizeof(layer);
2667 layer.backing_store = &backing_store;
2668 layer.size = FlutterSizeMake(800.0, 600.0);
2669 layer.offset = FlutterPointMake(0.0, 0.0);
2670 layer.backing_store_present_info = &present_info;
2671
2672 ASSERT_EQ(*layers[0], layer);
2673 }
2674
2675 // Layer 2
2676 {
2679 platform_view.identifier = 42;
2680 platform_view.mutations_count = 3;
2681
2682 FlutterLayer layer = {};
2683 layer.struct_size = sizeof(layer);
2686 layer.size = FlutterSizeMake(800.0, 600.0);
2687 layer.offset = FlutterPointMake(0.0, 0.0);
2688
2689 ASSERT_EQ(*layers[1], layer);
2690
2691 // There are no ordering guarantees.
2692 for (size_t i = 0; i < platform_view.mutations_count; i++) {
2693 FlutterPlatformViewMutation mutation = *platform_view.mutations[i];
2694 switch (mutation.type) {
2696 mutation.clip_rounded_rect =
2698 SkRect::MakeLTRB(5.0, 5.0, 400.0 - 5.0, 300.0 - 5.0),
2699 7.0, 7.0));
2700 break;
2703 mutation.clip_rect = FlutterRectMake(
2704 SkRect::MakeXYWH(5.0, 5.0, 400.0 - 10.0, 300.0 - 10.0));
2705 break;
2708 mutation.opacity = 128.0 / 255.0;
2709 break;
2712 mutation.transformation =
2714 break;
2715 }
2716
2717 ASSERT_EQ(*platform_view.mutations[i], mutation);
2718 }
2719 }
2720 latch.CountDown();
2721 });
2722
2723 auto engine = builder.LaunchEngine();
2724
2725 // Send a window metrics events so frames may be scheduled.
2726 FlutterWindowMetricsEvent event = {};
2727 event.struct_size = sizeof(event);
2728 event.width = 800;
2729 event.height = 600;
2730 event.pixel_ratio = 2.0;
2732 kSuccess);
2733 ASSERT_TRUE(engine.is_valid());
2734
2735 latch.Wait();
2736}
@ kFlutterPlatformViewMutationTypeClipRoundedRect
Definition embedder.h:1695
@ kFlutterPlatformViewMutationTypeOpacity
Definition embedder.h:1689
FlutterTransformation FlutterTransformationMake(const SkMatrix &matrix)
FlutterRoundedRect FlutterRoundedRectMake(const SkRRect &rect)
FlutterTransformation transformation
Definition embedder.h:1708
FlutterRoundedRect clip_rounded_rect
Definition embedder.h:1707

◆ TEST_F() [415/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformViewMutatorsAreValidWithPixelRatioAndRootSurfaceTransformation   
)

Definition at line 2738 of file embedder_gl_unittests.cc.

2739 {
2740 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2741
2742 EmbedderConfigBuilder builder(context);
2743 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
2744 builder.SetCompositor();
2745 builder.SetDartEntrypoint("platform_view_mutators_with_pixel_ratio");
2746
2747 builder.SetRenderTargetType(
2748 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
2749
2750 static const auto root_surface_transformation =
2751 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
2752
2753 context.SetRootSurfaceTransformation(root_surface_transformation);
2754
2755 fml::CountDownLatch latch(1);
2756 context.GetCompositor().SetNextPresentCallback(
2757 [&](FlutterViewId view_id, const FlutterLayer** layers,
2758 size_t layers_count) {
2759 ASSERT_EQ(layers_count, 2u);
2760
2761 // Layer 0 (Root)
2762 {
2763 FlutterBackingStore backing_store = *layers[0]->backing_store;
2764 backing_store.type = kFlutterBackingStoreTypeOpenGL;
2765 backing_store.did_update = true;
2767
2768 FlutterRect paint_region_rects[] = {
2769 FlutterRectMakeLTRB(0, 0, 600, 800),
2770 };
2771 FlutterRegion paint_region = {
2772 .struct_size = sizeof(FlutterRegion),
2773 .rects_count = 1,
2774 .rects = paint_region_rects,
2775 };
2776 FlutterBackingStorePresentInfo present_info = {
2778 .paint_region = &paint_region,
2779 };
2780
2781 FlutterLayer layer = {};
2782 layer.struct_size = sizeof(layer);
2784 layer.backing_store = &backing_store;
2785 layer.size = FlutterSizeMake(600.0, 800.0);
2786 layer.offset = FlutterPointMake(0.0, 0.0);
2787 layer.backing_store_present_info = &present_info;
2788
2789 ASSERT_EQ(*layers[0], layer);
2790 }
2791
2792 // Layer 2
2793 {
2796 platform_view.identifier = 42;
2797 platform_view.mutations_count = 4;
2798
2799 FlutterLayer layer = {};
2800 layer.struct_size = sizeof(layer);
2803 layer.size = FlutterSizeMake(600.0, 800.0);
2804 layer.offset = FlutterPointMake(0.0, 0.0);
2805
2806 ASSERT_EQ(*layers[1], layer);
2807
2808 // There are no ordering guarantees.
2809 for (size_t i = 0; i < platform_view.mutations_count; i++) {
2810 FlutterPlatformViewMutation mutation = *platform_view.mutations[i];
2811 switch (mutation.type) {
2813 mutation.clip_rounded_rect =
2815 SkRect::MakeLTRB(5.0, 5.0, 400.0 - 5.0, 300.0 - 5.0),
2816 7.0, 7.0));
2817 break;
2820 mutation.clip_rect = FlutterRectMake(
2821 SkRect::MakeXYWH(5.0, 5.0, 400.0 - 10.0, 300.0 - 10.0));
2822 break;
2825 mutation.opacity = 128.0 / 255.0;
2826 break;
2829 mutation.transformation =
2830 FlutterTransformationMake(root_surface_transformation);
2831
2832 break;
2833 }
2834
2835 ASSERT_EQ(*platform_view.mutations[i], mutation);
2836 }
2837 }
2838 latch.CountDown();
2839 });
2840
2841 auto engine = builder.LaunchEngine();
2842
2843 // Send a window metrics events so frames may be scheduled.
2844 FlutterWindowMetricsEvent event = {};
2845 event.struct_size = sizeof(event);
2846 event.width = 800;
2847 event.height = 600;
2848 event.pixel_ratio = 2.0;
2850 kSuccess);
2851 ASSERT_TRUE(engine.is_valid());
2852
2853 latch.Wait();
2854}

◆ TEST_F() [416/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PopulateExistingDamageReceivesInvalidID   
)

Definition at line 3990 of file embedder_gl_unittests.cc.

3990 {
3991 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3992
3993 EmbedderConfigBuilder builder(context);
3994 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
3995 builder.SetDartEntrypoint("render_gradient_retained");
3996 builder.GetRendererConfig().open_gl.populate_existing_damage =
3997 [](void* context, const intptr_t id,
3998 FlutterDamage* existing_damage) -> void {
3999 return reinterpret_cast<EmbedderTestContextGL*>(context)
4000 ->GLPopulateExistingDamage(id, existing_damage);
4001 };
4002
4003 // Return a bad FBO ID on purpose.
4004 builder.GetRendererConfig().open_gl.fbo_with_frame_info_callback =
4005 [](void* context, const FlutterFrameInfo* frame_info) -> uint32_t {
4006 return 123;
4007 };
4008
4009 auto engine = builder.LaunchEngine();
4010 ASSERT_TRUE(engine.is_valid());
4011
4012 context.AddNativeCallback("SignalNativeTest",
4014 /* Nothing to do. */
4015 }));
4016
4017 const uint32_t window_fbo_id =
4018 static_cast<EmbedderTestContextGL&>(context).GetWindowFBOId();
4019 static_cast<EmbedderTestContextGL&>(context)
4020 .SetGLPopulateExistingDamageCallback(
4021 [window_fbo_id = window_fbo_id](intptr_t id,
4022 FlutterDamage* existing_damage) {
4023 ASSERT_NE(id, window_fbo_id);
4024 existing_damage->num_rects = 0;
4025 existing_damage->damage = nullptr;
4026 });
4027
4028 // Send a window metrics events so frames may be scheduled.
4029 FlutterWindowMetricsEvent event = {};
4030 event.struct_size = sizeof(event);
4031 event.width = 800;
4032 event.height = 600;
4033 event.pixel_ratio = 1.0;
4035 kSuccess);
4036}
size_t num_rects
The number of rectangles within the damage region.
Definition embedder.h:462
FlutterRect * damage
The actual damage region(s) in question.
Definition embedder.h:464

◆ TEST_F() [417/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PopulateExistingDamageReceivesValidID   
)

Definition at line 3953 of file embedder_gl_unittests.cc.

3953 {
3954 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3955
3956 EmbedderConfigBuilder builder(context);
3957 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
3958 builder.SetDartEntrypoint("render_gradient_retained");
3959 builder.GetRendererConfig().open_gl.populate_existing_damage =
3960 [](void* context, const intptr_t id,
3961 FlutterDamage* existing_damage) -> void {
3962 return reinterpret_cast<EmbedderTestContextGL*>(context)
3963 ->GLPopulateExistingDamage(id, existing_damage);
3964 };
3965
3966 auto engine = builder.LaunchEngine();
3967 ASSERT_TRUE(engine.is_valid());
3968
3969 const uint32_t window_fbo_id =
3970 static_cast<EmbedderTestContextGL&>(context).GetWindowFBOId();
3971 static_cast<EmbedderTestContextGL&>(context)
3972 .SetGLPopulateExistingDamageCallback(
3973 [window_fbo_id = window_fbo_id](intptr_t id,
3974 FlutterDamage* existing_damage) {
3975 ASSERT_EQ(id, window_fbo_id);
3976 existing_damage->num_rects = 0;
3977 existing_damage->damage = nullptr;
3978 });
3979
3980 // Send a window metrics events so frames may be scheduled.
3981 FlutterWindowMetricsEvent event = {};
3982 event.struct_size = sizeof(event);
3983 event.width = 800;
3984 event.height = 600;
3985 event.pixel_ratio = 1.0;
3987 kSuccess);
3988}

◆ TEST_F() [418/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoContainsValidFBOId   
)

Definition at line 3655 of file embedder_gl_unittests.cc.

3655 {
3656 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3657
3658 EmbedderConfigBuilder builder(context);
3659 builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
3660 builder.SetDartEntrypoint("push_frames_over_and_over");
3661
3662 const auto root_surface_transformation =
3663 SkMatrix().preTranslate(0, 1024).preRotate(-90, 0, 0);
3664
3665 context.SetRootSurfaceTransformation(root_surface_transformation);
3666
3667 auto engine = builder.LaunchEngine();
3668
3669 // Send a window metrics events so frames may be scheduled.
3670 FlutterWindowMetricsEvent event = {};
3671 event.struct_size = sizeof(event);
3672 event.width = 1024;
3673 event.height = 600;
3674 event.pixel_ratio = 1.0;
3676 kSuccess);
3677 ASSERT_TRUE(engine.is_valid());
3678
3679 static fml::CountDownLatch frame_latch(10);
3680
3681 context.AddNativeCallback("SignalNativeTest",
3683 /* Nothing to do. */
3684 }));
3685
3686 const uint32_t window_fbo_id =
3687 static_cast<EmbedderTestContextGL&>(context).GetWindowFBOId();
3688 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
3689 [window_fbo_id = window_fbo_id](FlutterPresentInfo present_info) {
3690 ASSERT_EQ(present_info.fbo_id, window_fbo_id);
3691
3692 frame_latch.CountDown();
3693 });
3694
3695 frame_latch.Wait();
3696}
uint32_t fbo_id
Id of the fbo backing the surface that was presented.
Definition embedder.h:499

◆ TEST_F() [419/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesEmptyDamage   
)

Definition at line 3784 of file embedder_gl_unittests.cc.

3784 {
3785 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3786
3787 EmbedderConfigBuilder builder(context);
3788 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
3789 builder.SetDartEntrypoint("render_gradient_retained");
3790 builder.GetRendererConfig().open_gl.populate_existing_damage =
3791 [](void* context, const intptr_t id,
3792 FlutterDamage* existing_damage) -> void {
3793 return reinterpret_cast<EmbedderTestContextGL*>(context)
3794 ->GLPopulateExistingDamage(id, existing_damage);
3795 };
3796
3797 // Return no existing damage on purpose.
3798 static_cast<EmbedderTestContextGL&>(context)
3799 .SetGLPopulateExistingDamageCallback(
3800 [](const intptr_t id, FlutterDamage* existing_damage_ptr) {
3801 const size_t num_rects = 1;
3802 // The array must be valid after the callback returns.
3803 static FlutterRect existing_damage_rects[num_rects] = {
3804 FlutterRect{0, 0, 0, 0}};
3805 existing_damage_ptr->num_rects = num_rects;
3806 existing_damage_ptr->damage = existing_damage_rects;
3807 });
3808
3809 auto engine = builder.LaunchEngine();
3810 ASSERT_TRUE(engine.is_valid());
3811
3813
3814 // First frame should be entirely rerendered.
3815 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
3816 [&](FlutterPresentInfo present_info) {
3817 const size_t num_rects = 1;
3818 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
3819 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
3820 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
3821 ASSERT_EQ(present_info.frame_damage.damage->right, 800);
3822 ASSERT_EQ(present_info.frame_damage.damage->bottom, 600);
3823
3824 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
3825 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
3826 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
3827 ASSERT_EQ(present_info.buffer_damage.damage->right, 800);
3828 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 600);
3829
3830 latch.Signal();
3831 });
3832
3833 // Send a window metrics events so frames may be scheduled.
3834 FlutterWindowMetricsEvent event = {};
3835 event.struct_size = sizeof(event);
3836 event.width = 800;
3837 event.height = 600;
3838 event.pixel_ratio = 1.0;
3840 kSuccess);
3841 latch.Wait();
3842
3843 // Because it's the same as the first frame, the second frame should not be
3844 // rerendered assuming there is no existing damage.
3845 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
3846 [&](FlutterPresentInfo present_info) {
3847 const size_t num_rects = 1;
3848 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
3849 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
3850 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
3851 ASSERT_EQ(present_info.frame_damage.damage->right, 0);
3852 ASSERT_EQ(present_info.frame_damage.damage->bottom, 0);
3853
3854 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
3855 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
3856 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
3857 ASSERT_EQ(present_info.buffer_damage.damage->right, 0);
3858 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 0);
3859
3860 latch.Signal();
3861 });
3862
3864 kSuccess);
3865 latch.Wait();
3866}
FlutterDamage frame_damage
Damage representing the area that the compositor needs to render.
Definition embedder.h:501
FlutterDamage buffer_damage
Damage used to set the buffer's damage region.
Definition embedder.h:503
double bottom
Definition embedder.h:439
double top
Definition embedder.h:437
double left
Definition embedder.h:436
double right
Definition embedder.h:438

◆ TEST_F() [420/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesFullDamageWhenExistingDamageIsWholeScreen   
)

Definition at line 3698 of file embedder_gl_unittests.cc.

3699 {
3700 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3701
3702 EmbedderConfigBuilder builder(context);
3703 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
3704 builder.SetDartEntrypoint("render_gradient_retained");
3705 builder.GetRendererConfig().open_gl.populate_existing_damage =
3706 [](void* context, const intptr_t id,
3707 FlutterDamage* existing_damage) -> void {
3708 return reinterpret_cast<EmbedderTestContextGL*>(context)
3709 ->GLPopulateExistingDamage(id, existing_damage);
3710 };
3711
3712 // Return existing damage as the entire screen on purpose.
3713 static_cast<EmbedderTestContextGL&>(context)
3714 .SetGLPopulateExistingDamageCallback(
3715 [](const intptr_t id, FlutterDamage* existing_damage_ptr) {
3716 const size_t num_rects = 1;
3717 // The array must be valid after the callback returns.
3718 static FlutterRect existing_damage_rects[num_rects] = {
3719 FlutterRect{0, 0, 800, 600}};
3720 existing_damage_ptr->num_rects = num_rects;
3721 existing_damage_ptr->damage = existing_damage_rects;
3722 });
3723
3724 auto engine = builder.LaunchEngine();
3725 ASSERT_TRUE(engine.is_valid());
3726
3728
3729 // First frame should be entirely rerendered.
3730 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
3731 [&](FlutterPresentInfo present_info) {
3732 const size_t num_rects = 1;
3733 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
3734 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
3735 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
3736 ASSERT_EQ(present_info.frame_damage.damage->right, 800);
3737 ASSERT_EQ(present_info.frame_damage.damage->bottom, 600);
3738
3739 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
3740 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
3741 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
3742 ASSERT_EQ(present_info.buffer_damage.damage->right, 800);
3743 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 600);
3744
3745 latch.Signal();
3746 });
3747
3748 // Send a window metrics events so frames may be scheduled.
3749 FlutterWindowMetricsEvent event = {};
3750 event.struct_size = sizeof(event);
3751 event.width = 800;
3752 event.height = 600;
3753 event.pixel_ratio = 1.0;
3755 kSuccess);
3756 latch.Wait();
3757
3758 // Because it's the same as the first frame, the second frame damage should
3759 // be empty but, because there was a full existing buffer damage, the buffer
3760 // damage should be the entire screen.
3761 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
3762 [&](FlutterPresentInfo present_info) {
3763 const size_t num_rects = 1;
3764 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
3765 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
3766 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
3767 ASSERT_EQ(present_info.frame_damage.damage->right, 0);
3768 ASSERT_EQ(present_info.frame_damage.damage->bottom, 0);
3769
3770 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
3771 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
3772 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
3773 ASSERT_EQ(present_info.buffer_damage.damage->right, 800);
3774 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 600);
3775
3776 latch.Signal();
3777 });
3778
3780 kSuccess);
3781 latch.Wait();
3782}

◆ TEST_F() [421/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesFullScreenDamageWhenPopulateExistingDamageIsNotProvided   
)

Definition at line 4591 of file embedder_gl_unittests.cc.

4593 {
4594 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4595
4596 EmbedderConfigBuilder builder(context);
4597 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4598 builder.SetDartEntrypoint("render_gradient_retained");
4599 builder.GetRendererConfig().open_gl.populate_existing_damage = nullptr;
4600
4601 auto engine = builder.LaunchEngine();
4602 ASSERT_TRUE(engine.is_valid());
4603
4605
4606 // First frame should be entirely rerendered.
4607 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
4608 [&](FlutterPresentInfo present_info) {
4609 const size_t num_rects = 1;
4610 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
4611 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
4612 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
4613 ASSERT_EQ(present_info.frame_damage.damage->right, 800);
4614 ASSERT_EQ(present_info.frame_damage.damage->bottom, 600);
4615
4616 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
4617 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
4618 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
4619 ASSERT_EQ(present_info.buffer_damage.damage->right, 800);
4620 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 600);
4621
4622 latch.Signal();
4623 });
4624
4625 // Send a window metrics events so frames may be scheduled.
4626 FlutterWindowMetricsEvent event = {};
4627 event.struct_size = sizeof(event);
4628 event.width = 800;
4629 event.height = 600;
4630 event.pixel_ratio = 1.0;
4632 kSuccess);
4633 latch.Wait();
4634
4635 // Since populate_existing_damage is not provided, the partial repaint
4636 // functionality is actually disabled. So, the next frame should be entirely
4637 // new frame.
4638 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
4639 [&](FlutterPresentInfo present_info) {
4640 const size_t num_rects = 1;
4641 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
4642 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
4643 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
4644 ASSERT_EQ(present_info.frame_damage.damage->right, 800);
4645 ASSERT_EQ(present_info.frame_damage.damage->bottom, 600);
4646
4647 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
4648 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
4649 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
4650 ASSERT_EQ(present_info.buffer_damage.damage->right, 800);
4651 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 600);
4652
4653 latch.Signal();
4654 });
4655
4657 kSuccess);
4658 latch.Wait();
4659}

◆ TEST_F() [422/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesJoinedDamageWhenExistingDamageContainsMultipleRects   
)

Definition at line 4661 of file embedder_gl_unittests.cc.

4662 {
4663 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4664
4665 EmbedderConfigBuilder builder(context);
4666 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4667 builder.SetDartEntrypoint("render_gradient_retained");
4668 builder.GetRendererConfig().open_gl.populate_existing_damage =
4669 [](void* context, const intptr_t id,
4670 FlutterDamage* existing_damage) -> void {
4671 return reinterpret_cast<EmbedderTestContextGL*>(context)
4672 ->GLPopulateExistingDamage(id, existing_damage);
4673 };
4674
4675 // Return existing damage as the entire screen on purpose.
4676 static_cast<EmbedderTestContextGL&>(context)
4677 .SetGLPopulateExistingDamageCallback(
4678 [](const intptr_t id, FlutterDamage* existing_damage_ptr) {
4679 const size_t num_rects = 2;
4680 // The array must be valid after the callback returns.
4681 static FlutterRect existing_damage_rects[num_rects] = {
4682 FlutterRect{100, 150, 200, 250},
4683 FlutterRect{200, 250, 300, 350},
4684 };
4685 existing_damage_ptr->num_rects = num_rects;
4686 existing_damage_ptr->damage = existing_damage_rects;
4687 });
4688
4689 auto engine = builder.LaunchEngine();
4690 ASSERT_TRUE(engine.is_valid());
4691
4693
4694 // First frame should be entirely rerendered.
4695 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
4696 [&](FlutterPresentInfo present_info) {
4697 const size_t num_rects = 1;
4698 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
4699 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
4700 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
4701 ASSERT_EQ(present_info.frame_damage.damage->right, 800);
4702 ASSERT_EQ(present_info.frame_damage.damage->bottom, 600);
4703
4704 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
4705 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
4706 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
4707 ASSERT_EQ(present_info.buffer_damage.damage->right, 800);
4708 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 600);
4709
4710 latch.Signal();
4711 });
4712
4713 // Send a window metrics events so frames may be scheduled.
4714 FlutterWindowMetricsEvent event = {};
4715 event.struct_size = sizeof(event);
4716 event.width = 800;
4717 event.height = 600;
4718 event.pixel_ratio = 1.0;
4720 kSuccess);
4721 latch.Wait();
4722
4723 // Because it's the same as the first frame, the second frame damage should
4724 // be empty but, because there was a full existing buffer damage, the buffer
4725 // damage should be the entire screen.
4726 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
4727 [&](FlutterPresentInfo present_info) {
4728 const size_t num_rects = 1;
4729 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
4730 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
4731 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
4732 ASSERT_EQ(present_info.frame_damage.damage->right, 0);
4733 ASSERT_EQ(present_info.frame_damage.damage->bottom, 0);
4734
4735 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
4736 ASSERT_EQ(present_info.buffer_damage.damage->left, 100);
4737 ASSERT_EQ(present_info.buffer_damage.damage->top, 150);
4738 ASSERT_EQ(present_info.buffer_damage.damage->right, 300);
4739 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 350);
4740
4741 latch.Signal();
4742 });
4743
4745 kSuccess);
4746 latch.Wait();
4747}

◆ TEST_F() [423/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesPartialDamage   
)

Definition at line 3868 of file embedder_gl_unittests.cc.

3868 {
3869 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3870
3871 EmbedderConfigBuilder builder(context);
3872 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
3873 builder.SetDartEntrypoint("render_gradient_retained");
3874 builder.GetRendererConfig().open_gl.populate_existing_damage =
3875 [](void* context, const intptr_t id,
3876 FlutterDamage* existing_damage) -> void {
3877 return reinterpret_cast<EmbedderTestContextGL*>(context)
3878 ->GLPopulateExistingDamage(id, existing_damage);
3879 };
3880
3881 // Return existing damage as only part of the screen on purpose.
3882 static_cast<EmbedderTestContextGL&>(context)
3883 .SetGLPopulateExistingDamageCallback(
3884 [&](const intptr_t id, FlutterDamage* existing_damage_ptr) {
3885 const size_t num_rects = 1;
3886 // The array must be valid after the callback returns.
3887 static FlutterRect existing_damage_rects[num_rects] = {
3888 FlutterRect{200, 150, 400, 300}};
3889 existing_damage_ptr->num_rects = num_rects;
3890 existing_damage_ptr->damage = existing_damage_rects;
3891 });
3892
3893 auto engine = builder.LaunchEngine();
3894 ASSERT_TRUE(engine.is_valid());
3895
3897
3898 // First frame should be entirely rerendered.
3899 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
3900 [&](FlutterPresentInfo present_info) {
3901 const size_t num_rects = 1;
3902 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
3903 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
3904 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
3905 ASSERT_EQ(present_info.frame_damage.damage->right, 800);
3906 ASSERT_EQ(present_info.frame_damage.damage->bottom, 600);
3907
3908 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
3909 ASSERT_EQ(present_info.buffer_damage.damage->left, 0);
3910 ASSERT_EQ(present_info.buffer_damage.damage->top, 0);
3911 ASSERT_EQ(present_info.buffer_damage.damage->right, 800);
3912 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 600);
3913
3914 latch.Signal();
3915 });
3916
3917 // Send a window metrics events so frames may be scheduled.
3918 FlutterWindowMetricsEvent event = {};
3919 event.struct_size = sizeof(event);
3920 event.width = 800;
3921 event.height = 600;
3922 event.pixel_ratio = 1.0;
3924 kSuccess);
3925 latch.Wait();
3926
3927 // Because it's the same as the first frame, the second frame damage should be
3928 // empty but, because there was a partial existing damage, the buffer damage
3929 // should represent that partial damage area.
3930 static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
3931 [&](FlutterPresentInfo present_info) {
3932 const size_t num_rects = 1;
3933 ASSERT_EQ(present_info.frame_damage.num_rects, num_rects);
3934 ASSERT_EQ(present_info.frame_damage.damage->left, 0);
3935 ASSERT_EQ(present_info.frame_damage.damage->top, 0);
3936 ASSERT_EQ(present_info.frame_damage.damage->right, 0);
3937 ASSERT_EQ(present_info.frame_damage.damage->bottom, 0);
3938
3939 ASSERT_EQ(present_info.buffer_damage.num_rects, num_rects);
3940 ASSERT_EQ(present_info.buffer_damage.damage->left, 200);
3941 ASSERT_EQ(present_info.buffer_damage.damage->top, 150);
3942 ASSERT_EQ(present_info.buffer_damage.damage->right, 400);
3943 ASSERT_EQ(present_info.buffer_damage.damage->bottom, 300);
3944
3945 latch.Signal();
3946 });
3947
3949 kSuccess);
3950 latch.Wait();
3951}

◆ TEST_F() [424/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PushingMutlipleFramesSetsUpNewRecordingCanvasWithCustomCompositor   
)

Definition at line 2433 of file embedder_gl_unittests.cc.

2434 {
2435 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2436
2437 EmbedderConfigBuilder builder(context);
2438 builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
2439 builder.SetCompositor();
2440 builder.SetDartEntrypoint("push_frames_over_and_over");
2441
2442 builder.SetRenderTargetType(
2443 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
2444
2445 const auto root_surface_transformation =
2446 SkMatrix().preTranslate(0, 1024).preRotate(-90, 0, 0);
2447
2448 context.SetRootSurfaceTransformation(root_surface_transformation);
2449
2450 auto engine = builder.LaunchEngine();
2451
2452 // Send a window metrics events so frames may be scheduled.
2453 FlutterWindowMetricsEvent event = {};
2454 event.struct_size = sizeof(event);
2455 event.width = 1024;
2456 event.height = 600;
2457 event.pixel_ratio = 1.0;
2459 kSuccess);
2460 ASSERT_TRUE(engine.is_valid());
2461
2462 constexpr size_t frames_expected = 10;
2463 fml::CountDownLatch frame_latch(frames_expected);
2464 std::atomic_size_t frames_seen = 0;
2465 context.AddNativeCallback("SignalNativeTest",
2467 frames_seen++;
2468 frame_latch.CountDown();
2469 }));
2470 frame_latch.Wait();
2471
2472 ASSERT_GE(frames_seen, frames_expected);
2473
2474 FlutterEngineShutdown(engine.release());
2475}
FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Shuts down a Flutter engine instance. The engine handle is no longer valid for any calls in the embed...
Definition embedder.cc:2303

◆ TEST_F() [425/876]

flutter::testing::TEST_F ( EmbedderTest  ,
PushingMutlipleFramesSetsUpNewRecordingCanvasWithoutCustomCompositor   
)

Definition at line 2477 of file embedder_gl_unittests.cc.

2478 {
2479 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2480
2481 EmbedderConfigBuilder builder(context);
2482 builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
2483 builder.SetDartEntrypoint("push_frames_over_and_over");
2484
2485 const auto root_surface_transformation =
2486 SkMatrix().preTranslate(0, 1024).preRotate(-90, 0, 0);
2487
2488 context.SetRootSurfaceTransformation(root_surface_transformation);
2489
2490 auto engine = builder.LaunchEngine();
2491
2492 // Send a window metrics events so frames may be scheduled.
2493 FlutterWindowMetricsEvent event = {};
2494 event.struct_size = sizeof(event);
2495 event.width = 1024;
2496 event.height = 600;
2497 event.pixel_ratio = 1.0;
2499 kSuccess);
2500 ASSERT_TRUE(engine.is_valid());
2501
2502 constexpr size_t frames_expected = 10;
2503 fml::CountDownLatch frame_latch(frames_expected);
2504 std::atomic_size_t frames_seen = 0;
2505 context.AddNativeCallback("SignalNativeTest",
2507 frames_seen++;
2508 frame_latch.CountDown();
2509 }));
2510 frame_latch.Wait();
2511
2512 ASSERT_GE(frames_seen, frames_expected);
2513
2514 FlutterEngineShutdown(engine.release());
2515}

◆ TEST_F() [426/876]

flutter::testing::TEST_F ( EmbedderTest  ,
RasterCacheDisabledWithPlatformViews   
)

Layers in a hierarchy containing a platform view should not be cached. The other layers in the hierarchy should be, however.

Definition at line 225 of file embedder_gl_unittests.cc.

225 {
226 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
227
228 EmbedderConfigBuilder builder(context);
229 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
230 builder.SetCompositor();
231 builder.SetDartEntrypoint("can_composite_platform_views_with_opacity");
232
233 builder.SetRenderTargetType(
234 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
235
237 fml::CountDownLatch verify(1);
238
239 context.GetCompositor().SetNextPresentCallback(
240 [&](FlutterViewId view_id, const FlutterLayer** layers,
241 size_t layers_count) {
242 ASSERT_EQ(layers_count, 3u);
243
244 {
245 FlutterBackingStore backing_store = *layers[0]->backing_store;
246 backing_store.struct_size = sizeof(backing_store);
247 backing_store.type = kFlutterBackingStoreTypeOpenGL;
248 backing_store.did_update = true;
250
251 FlutterRect paint_region_rects[] = {
252 FlutterRectMakeLTRB(0, 0, 800, 600),
253 };
254 FlutterRegion paint_region = {
255 .struct_size = sizeof(FlutterRegion),
256 .rects_count = 1,
257 .rects = paint_region_rects,
258 };
259 FlutterBackingStorePresentInfo present_info = {
261 .paint_region = &paint_region,
262 };
263
264 FlutterLayer layer = {};
265 layer.struct_size = sizeof(layer);
267 layer.backing_store = &backing_store;
268 layer.size = FlutterSizeMake(800.0, 600.0);
269 layer.offset = FlutterPointMake(0, 0);
270 layer.backing_store_present_info = &present_info;
271
272 ASSERT_EQ(*layers[0], layer);
273 }
274
275 {
278 platform_view.identifier = 42;
279
280 FlutterLayer layer = {};
281 layer.struct_size = sizeof(layer);
284 layer.size = FlutterSizeMake(123.0, 456.0);
285 layer.offset = FlutterPointMake(1.0, 2.0);
286
287 ASSERT_EQ(*layers[1], layer);
288 }
289
290 {
291 FlutterBackingStore backing_store = *layers[2]->backing_store;
292 backing_store.struct_size = sizeof(backing_store);
293 backing_store.type = kFlutterBackingStoreTypeOpenGL;
294 backing_store.did_update = true;
296
297 FlutterRect paint_region_rects[] = {
298 FlutterRectMakeLTRB(3, 3, 800, 600),
299 };
300 FlutterRegion paint_region = {
301 .struct_size = sizeof(FlutterRegion),
302 .rects_count = 1,
303 .rects = paint_region_rects,
304 };
305 FlutterBackingStorePresentInfo present_info = {
307 .paint_region = &paint_region,
308 };
309
310 FlutterLayer layer = {};
311 layer.struct_size = sizeof(layer);
313 layer.backing_store = &backing_store;
314 layer.size = FlutterSizeMake(800.0, 600.0);
315 layer.offset = FlutterPointMake(0.0, 0.0);
316 layer.backing_store_present_info = &present_info;
317
318 ASSERT_EQ(*layers[2], layer);
319 }
320
321 setup.CountDown();
322 });
323
324 context.AddNativeCallback(
325 "SignalNativeTest",
327 [&setup](Dart_NativeArguments args) { setup.CountDown(); }));
328
329 UniqueEngine engine = builder.LaunchEngine();
330
331 // Send a window metrics events so frames may be scheduled.
332 FlutterWindowMetricsEvent event = {};
333 event.struct_size = sizeof(event);
334 event.width = 800;
335 event.height = 600;
336 event.pixel_ratio = 1.0;
338 kSuccess);
339 ASSERT_TRUE(engine.is_valid());
340
341 setup.Wait();
343 shell.GetTaskRunners().GetRasterTaskRunner()->PostTask([&] {
344 const flutter::RasterCache& raster_cache =
345 shell.GetRasterizer()->compositor_context()->raster_cache();
346 // 3 layers total, but one of them had the platform view. So the cache
347 // should only have 2 entries.
348 ASSERT_EQ(raster_cache.GetCachedEntriesCount(), 2u);
349 verify.CountDown();
350 });
351
352 verify.Wait();
353}
size_t GetCachedEntriesCount() const
Definition setup.py:1

◆ TEST_F() [427/876]

flutter::testing::TEST_F ( EmbedderTest  ,
RasterCacheEnabled   
)

The RasterCache should normally be enabled.

Definition at line 358 of file embedder_gl_unittests.cc.

358 {
359 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
360
361 EmbedderConfigBuilder builder(context);
362 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
363 builder.SetCompositor();
364 builder.SetDartEntrypoint("can_composite_with_opacity");
365
366 builder.SetRenderTargetType(
367 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
368
370 fml::CountDownLatch verify(1);
371
372 context.GetCompositor().SetNextPresentCallback(
373 [&](FlutterViewId view_id, const FlutterLayer** layers,
374 size_t layers_count) {
375 ASSERT_EQ(layers_count, 1u);
376
377 {
378 FlutterBackingStore backing_store = *layers[0]->backing_store;
379 backing_store.struct_size = sizeof(backing_store);
380 backing_store.type = kFlutterBackingStoreTypeOpenGL;
381 backing_store.did_update = true;
383
384 FlutterRect paint_region_rects[] = {
385 FlutterRectMakeLTRB(0, 0, 800, 600),
386 };
387 FlutterRegion paint_region = {
388 .struct_size = sizeof(FlutterRegion),
389 .rects_count = 1,
390 .rects = paint_region_rects,
391 };
392 FlutterBackingStorePresentInfo present_info = {
394 .paint_region = &paint_region,
395 };
396
397 FlutterLayer layer = {};
398 layer.struct_size = sizeof(layer);
400 layer.backing_store = &backing_store;
401 layer.size = FlutterSizeMake(800.0, 600.0);
402 layer.offset = FlutterPointMake(0, 0);
403 layer.backing_store_present_info = &present_info;
404
405 ASSERT_EQ(*layers[0], layer);
406 }
407
408 setup.CountDown();
409 });
410
411 context.AddNativeCallback(
412 "SignalNativeTest",
414 [&setup](Dart_NativeArguments args) { setup.CountDown(); }));
415
416 UniqueEngine engine = builder.LaunchEngine();
417
418 // Send a window metrics events so frames may be scheduled.
419 FlutterWindowMetricsEvent event = {};
420 event.struct_size = sizeof(event);
421 event.width = 800;
422 event.height = 600;
423 event.pixel_ratio = 1.0;
425 kSuccess);
426 ASSERT_TRUE(engine.is_valid());
427
428 setup.Wait();
430 shell.GetTaskRunners().GetRasterTaskRunner()->PostTask([&] {
431 const flutter::RasterCache& raster_cache =
432 shell.GetRasterizer()->compositor_context()->raster_cache();
433 ASSERT_EQ(raster_cache.GetCachedEntriesCount(), 1u);
434 verify.CountDown();
435 });
436
437 verify.Wait();
438}

◆ TEST_F() [428/876]

flutter::testing::TEST_F ( EmbedderTest  ,
RegisterChannelListener   
)

Definition at line 3666 of file embedder_unittests.cc.

3666 {
3667 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3668
3671 bool listening = false;
3672 context.AddNativeCallback(
3673 "SignalNativeTest",
3675 context.SetChannelUpdateCallback([&](const FlutterChannelUpdate* update) {
3676 EXPECT_STREQ(update->channel, "test/listen");
3677 EXPECT_TRUE(update->listening);
3678 listening = true;
3679 latch2.Signal();
3680 });
3681
3682 EmbedderConfigBuilder builder(context);
3683 builder.SetSoftwareRendererConfig();
3684 builder.SetDartEntrypoint("channel_listener_response");
3685
3686 auto engine = builder.LaunchEngine();
3687 ASSERT_TRUE(engine.is_valid());
3688
3689 latch.Wait();
3690 // Drain tasks posted to platform thread task runner.
3692 latch2.Wait();
3693
3694 ASSERT_TRUE(listening);
3695}
An update to whether a message channel has a listener set or not.
Definition embedder.h:1533

◆ TEST_F() [429/876]

flutter::testing::TEST_F ( EmbedderTest  ,
SceneWithNoRootContainerIsAcceptable   
)

Definition at line 2882 of file embedder_gl_unittests.cc.

2882 {
2883 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2884
2885 EmbedderConfigBuilder builder(context);
2886 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
2887 builder.SetCompositor();
2888 builder.SetRenderTargetType(
2889 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
2890 builder.SetDartEntrypoint("scene_with_no_container");
2892 context.AddNativeCallback(
2893 "SignalNativeTest",
2895
2896 auto engine = builder.LaunchEngine();
2897
2898 ASSERT_TRUE(engine.is_valid());
2899
2900 FlutterWindowMetricsEvent event = {};
2901 event.struct_size = sizeof(event);
2902 event.width = 800;
2903 event.height = 600;
2904 event.pixel_ratio = 1.0;
2906 kSuccess);
2907 latch.Wait();
2908}

◆ TEST_F() [430/876]

flutter::testing::TEST_F ( EmbedderTest  ,
SetSingleDisplayConfigurationWithDisplayId   
)

Definition at line 4038 of file embedder_gl_unittests.cc.

4038 {
4039 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4040
4041 EmbedderConfigBuilder builder(context);
4042 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4043 builder.SetCompositor();
4044 builder.SetDartEntrypoint("empty_scene");
4046 context.AddNativeCallback(
4047 "SignalNativeTest",
4049
4050 auto engine = builder.LaunchEngine();
4051
4052 ASSERT_TRUE(engine.is_valid());
4053
4054 FlutterEngineDisplay display;
4055 display.struct_size = sizeof(FlutterEngineDisplay);
4056 display.display_id = 1;
4057 display.refresh_rate = 20;
4058
4059 std::vector<FlutterEngineDisplay> displays = {display};
4060
4062 engine.get(), kFlutterEngineDisplaysUpdateTypeStartup, displays.data(),
4063 displays.size());
4064 ASSERT_EQ(result, kSuccess);
4065
4067 ASSERT_EQ(shell.GetMainDisplayRefreshRate(), display.refresh_rate);
4068
4069 FlutterWindowMetricsEvent event = {};
4070 event.struct_size = sizeof(event);
4071 event.width = 800;
4072 event.height = 600;
4073 event.pixel_ratio = 1.0;
4075 kSuccess);
4076
4077 latch.Wait();
4078}

◆ TEST_F() [431/876]

flutter::testing::TEST_F ( EmbedderTest  ,
SetSingleDisplayConfigurationWithoutDisplayId   
)

Definition at line 4080 of file embedder_gl_unittests.cc.

4080 {
4081 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4082
4083 EmbedderConfigBuilder builder(context);
4084 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4085 builder.SetCompositor();
4086 builder.SetDartEntrypoint("empty_scene");
4088 context.AddNativeCallback(
4089 "SignalNativeTest",
4091
4092 auto engine = builder.LaunchEngine();
4093
4094 ASSERT_TRUE(engine.is_valid());
4095
4096 FlutterEngineDisplay display;
4097 display.struct_size = sizeof(FlutterEngineDisplay);
4098 display.single_display = true;
4099 display.refresh_rate = 20;
4100
4101 std::vector<FlutterEngineDisplay> displays = {display};
4102
4104 engine.get(), kFlutterEngineDisplaysUpdateTypeStartup, displays.data(),
4105 displays.size());
4106 ASSERT_EQ(result, kSuccess);
4107
4109 ASSERT_EQ(shell.GetMainDisplayRefreshRate(), display.refresh_rate);
4110
4111 FlutterWindowMetricsEvent event = {};
4112 event.struct_size = sizeof(event);
4113 event.width = 800;
4114 event.height = 600;
4115 event.pixel_ratio = 1.0;
4117 kSuccess);
4118
4119 latch.Wait();
4120}

◆ TEST_F() [432/876]

flutter::testing::TEST_F ( EmbedderTest  ,
SetValidMultiDisplayConfiguration   
)

Definition at line 4122 of file embedder_gl_unittests.cc.

4122 {
4123 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4124
4125 EmbedderConfigBuilder builder(context);
4126 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4127 builder.SetCompositor();
4128 builder.SetDartEntrypoint("empty_scene");
4130 context.AddNativeCallback(
4131 "SignalNativeTest",
4133
4134 auto engine = builder.LaunchEngine();
4135
4136 ASSERT_TRUE(engine.is_valid());
4137
4138 FlutterEngineDisplay display_1;
4139 display_1.struct_size = sizeof(FlutterEngineDisplay);
4140 display_1.display_id = 1;
4141 display_1.single_display = false;
4142 display_1.refresh_rate = 20;
4143
4144 FlutterEngineDisplay display_2;
4145 display_2.struct_size = sizeof(FlutterEngineDisplay);
4146 display_2.display_id = 2;
4147 display_2.single_display = false;
4148 display_2.refresh_rate = 60;
4149
4150 std::vector<FlutterEngineDisplay> displays = {display_1, display_2};
4151
4153 engine.get(), kFlutterEngineDisplaysUpdateTypeStartup, displays.data(),
4154 displays.size());
4155 ASSERT_EQ(result, kSuccess);
4156
4158 ASSERT_EQ(shell.GetMainDisplayRefreshRate(), display_1.refresh_rate);
4159
4160 FlutterWindowMetricsEvent event = {};
4161 event.struct_size = sizeof(event);
4162 event.width = 800;
4163 event.height = 600;
4164 event.pixel_ratio = 1.0;
4166 kSuccess);
4167
4168 latch.Wait();
4169}

◆ TEST_F() [433/876]

flutter::testing::TEST_F ( EmbedderTest  ,
SnapshotRenderTargetScalesDownToDriverMax   
)

Definition at line 4311 of file embedder_gl_unittests.cc.

4311 {
4312 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4313
4314 EmbedderConfigBuilder builder(context);
4315 builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
4316 builder.SetCompositor();
4317
4318 auto max_size = context.GetCompositor().GetGrContext()->maxRenderTargetSize();
4319
4320 context.AddIsolateCreateCallback([&]() {
4321 Dart_Handle snapshot_large_scene = Dart_GetField(
4322 Dart_RootLibrary(), tonic::ToDart("snapshot_large_scene"));
4323 tonic::DartInvoke(snapshot_large_scene, {tonic::ToDart<int64_t>(max_size)});
4324 });
4325
4327 context.AddNativeCallback(
4328 "SnapshotsCallback", CREATE_NATIVE_ENTRY(([&](Dart_NativeArguments args) {
4329 auto get_arg = [&args](int index) {
4330 Dart_Handle dart_image = Dart_GetNativeArgument(args, index);
4331 Dart_Handle internal_image =
4332 Dart_GetField(dart_image, tonic::ToDart("_image"));
4334 internal_image);
4335 };
4336
4337 CanvasImage* big_image = get_arg(0);
4338 ASSERT_EQ(big_image->width(), max_size);
4339 ASSERT_EQ(big_image->height(), max_size / 2);
4340
4341 CanvasImage* small_image = get_arg(1);
4342 ASSERT_TRUE(ImageMatchesFixture("snapshot_large_scene.png",
4343 small_image->image()->skia_image()));
4344
4345 latch.Signal();
4346 })));
4347
4348 UniqueEngine engine = builder.LaunchEngine();
4349 ASSERT_TRUE(engine.is_valid());
4350
4351 latch.Wait();
4352}
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)

◆ TEST_F() [434/876]

flutter::testing::TEST_F ( EmbedderTest  ,
TextureDestructionCallbackCalledWithoutCustomCompositorMetal   
)

Definition at line 266 of file embedder_metal_unittests.mm.

266 {
267 EmbedderTestContextMetal& context = reinterpret_cast<EmbedderTestContextMetal&>(
268 GetEmbedderContext(EmbedderTestContextType::kMetalContext));
269 EmbedderConfigBuilder builder(context);
270 builder.SetMetalRendererConfig(SkISize::Make(800, 600));
271 builder.SetDartEntrypoint("texture_destruction_callback_called_without_custom_compositor");
272
273 struct CollectContext {
274 int present_count = 0;
275 int collect_count = 0;
277 };
278
279 auto collect_context = std::make_unique<CollectContext>();
280 context.SetNextDrawableCallback([&context, &collect_context](const FlutterFrameInfo* frame_info) {
281 auto texture_info = context.GetTestMetalSurface()->GetTextureInfo();
282
285 texture.texture_id = texture_info.texture_id;
286 texture.texture = reinterpret_cast<FlutterMetalTextureHandle>(texture_info.texture);
287 texture.user_data = collect_context.get();
288 texture.destruction_callback = [](void* user_data) {
289 CollectContext* callback_collect_context = reinterpret_cast<CollectContext*>(user_data);
290 ASSERT_TRUE(callback_collect_context->present_count > 0);
291 callback_collect_context->collect_count++;
292 callback_collect_context->latch.Signal();
293 };
294 return texture;
295 });
296 context.SetPresentCallback([&context, &collect_context](int64_t texture_id) {
297 collect_context->present_count++;
298 return context.GetTestMetalContext()->Present(texture_id);
299 });
300
301 auto engine = builder.LaunchEngine();
302
303 // Send a window metrics events so frames may be scheduled.
304 FlutterWindowMetricsEvent event = {};
305 event.struct_size = sizeof(event);
306 event.width = 800;
307 event.height = 600;
308 event.pixel_ratio = 1.0;
310 ASSERT_TRUE(engine.is_valid());
311
312 collect_context->latch.Wait();
313 EXPECT_EQ(collect_context->collect_count, 1);
314}
bool Present(int64_t texture_id)
void SetNextDrawableCallback(NextDrawableCallback next_drawable_callback)
void SetPresentCallback(PresentCallback present_callback)
const void * FlutterMetalTextureHandle
Alias for id<MTLTexture>.
Definition embedder.h:600
size_t struct_size
The size of this struct. Must be sizeof(FlutterMetalTexture).
Definition embedder.h:649

◆ TEST_F() [435/876]

flutter::testing::TEST_F ( EmbedderTest  ,
VerifyB141980393   
)

Definition at line 1957 of file embedder_gl_unittests.cc.

1957 {
1958 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1959
1960 EmbedderConfigBuilder builder(context);
1961
1962 // The Flutter application is 800 x 600 but rendering on a surface that is 600
1963 // x 800 achieved using a root surface transformation.
1964 const auto root_surface_transformation =
1965 SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
1966 const auto flutter_application_rect = SkRect::MakeWH(800, 600);
1967 const auto root_surface_rect =
1968 root_surface_transformation.mapRect(flutter_application_rect);
1969
1970 ASSERT_DOUBLE_EQ(root_surface_rect.width(), 600.0);
1971 ASSERT_DOUBLE_EQ(root_surface_rect.height(), 800.0);
1972
1973 // Configure the fixture for the surface transformation.
1974 context.SetRootSurfaceTransformation(root_surface_transformation);
1975
1976 // Configure the Flutter project args for the root surface transformation.
1977 builder.SetOpenGLRendererConfig(
1978 SkISize::Make(root_surface_rect.width(), root_surface_rect.height()));
1979
1980 // Use a compositor instead of rendering directly to the surface.
1981 builder.SetCompositor();
1982 builder.SetRenderTargetType(
1983 EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
1984
1985 builder.SetDartEntrypoint("verify_b141980393");
1986
1988
1989 context.GetCompositor().SetNextPresentCallback(
1990 [&](FlutterViewId view_id, const FlutterLayer** layers,
1991 size_t layers_count) {
1992 ASSERT_EQ(layers_count, 1u);
1993
1994 // Layer Root
1995 {
1998 platform_view.identifier = 1337;
1999
2000 FlutterLayer layer = {};
2001 layer.struct_size = sizeof(layer);
2004
2005 // From the Dart side. These dimensions match those specified in Dart
2006 // code and are free of root surface transformations.
2007 const double unxformed_top_margin = 31.0;
2008 const double unxformed_bottom_margin = 37.0;
2009 const auto unxformed_platform_view_rect = SkRect::MakeXYWH(
2010 0.0, // x
2011 unxformed_top_margin, // y (top margin)
2012 800, // width
2013 600 - unxformed_top_margin - unxformed_bottom_margin // height
2014 );
2015
2016 // The platform views are in the coordinate space of the root surface
2017 // with top-left origin. The embedder has specified a transformation
2018 // to this surface which it must account for in the coordinates it
2019 // receives here.
2020 const auto xformed_platform_view_rect =
2021 root_surface_transformation.mapRect(unxformed_platform_view_rect);
2022
2023 // Spell out the value that we are going to be checking below for
2024 // clarity.
2025 ASSERT_EQ(xformed_platform_view_rect,
2026 SkRect::MakeXYWH(31.0, // x
2027 0.0, // y
2028 532.0, // width
2029 800.0 // height
2030 ));
2031
2032 // Verify that the engine is giving us the right size and offset.
2033 layer.offset = FlutterPointMake(xformed_platform_view_rect.x(),
2034 xformed_platform_view_rect.y());
2035 layer.size = FlutterSizeMake(xformed_platform_view_rect.width(),
2036 xformed_platform_view_rect.height());
2037
2038 ASSERT_EQ(*layers[0], layer);
2039 }
2040
2041 latch.Signal();
2042 });
2043
2044 auto engine = builder.LaunchEngine();
2045
2046 // Send a window metrics events so frames may be scheduled.
2047 FlutterWindowMetricsEvent event = {};
2048 event.struct_size = sizeof(event);
2049
2050 // The Flutter application is 800 x 600 rendering on a surface 600 x 800
2051 // achieved via a root surface transformation.
2052 event.width = flutter_application_rect.width();
2053 event.height = flutter_application_rect.height();
2054 event.pixel_ratio = 1.0;
2056 kSuccess);
2057 ASSERT_TRUE(engine.is_valid());
2058
2059 latch.Wait();
2060}

◆ TEST_F() [436/876]

flutter::testing::TEST_F ( EmbedderTest  ,
VerifyB143464703WithSoftwareBackend   
)

Definition at line 2079 of file embedder_unittests.cc.

2079 {
2080 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2081
2082 EmbedderConfigBuilder builder(context);
2083 builder.SetSoftwareRendererConfig(SkISize::Make(1024, 600));
2084 builder.SetCompositor();
2085 builder.SetDartEntrypoint("verify_b143464703");
2086
2087 builder.SetRenderTargetType(
2088 EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
2089
2090 // setup the screenshot promise.
2091 auto rendered_scene = context.GetNextSceneImage();
2092
2093 fml::CountDownLatch latch(1);
2094 context.GetCompositor().SetNextPresentCallback(
2095 [&](FlutterViewId view_id, const FlutterLayer** layers,
2096 size_t layers_count) {
2097 ASSERT_EQ(layers_count, 2u);
2098
2099 // Layer 0 (Root)
2100 {
2101 FlutterBackingStore backing_store = *layers[0]->backing_store;
2102 backing_store.type = kFlutterBackingStoreTypeSoftware;
2103 backing_store.did_update = true;
2104
2105 FlutterRect paint_region_rects[] = {
2106 FlutterRectMakeLTRB(0, 0, 1024, 600),
2107 };
2108 FlutterRegion paint_region = {
2109 .struct_size = sizeof(FlutterRegion),
2110 .rects_count = 1,
2111 .rects = paint_region_rects,
2112 };
2113 FlutterBackingStorePresentInfo present_info = {
2115 .paint_region = &paint_region,
2116 };
2117
2118 FlutterLayer layer = {};
2119 layer.struct_size = sizeof(layer);
2121 layer.backing_store = &backing_store;
2122 layer.size = FlutterSizeMake(1024.0, 600.0);
2123 layer.offset = FlutterPointMake(0.0, 0.0);
2124 layer.backing_store_present_info = &present_info;
2125
2126 ASSERT_EQ(*layers[0], layer);
2127 }
2128
2129 // Layer 1
2130 {
2133 platform_view.identifier = 42;
2134
2135 FlutterLayer layer = {};
2136 layer.struct_size = sizeof(layer);
2139 layer.size = FlutterSizeMake(1024.0, 540.0);
2140 layer.offset = FlutterPointMake(135.0, 60.0);
2141
2142 ASSERT_EQ(*layers[1], layer);
2143 }
2144
2145 latch.CountDown();
2146 });
2147
2148 context.GetCompositor().SetPlatformViewRendererCallback(
2149 [](const FlutterLayer& layer,
2150 GrDirectContext* context) -> sk_sp<SkImage> {
2152 layer, nullptr /* null because software compositor */);
2153 auto canvas = surface->getCanvas();
2154 FML_CHECK(canvas != nullptr);
2155
2156 switch (layer.platform_view->identifier) {
2157 case 42: {
2158 SkPaint paint;
2159 // See dart test for total order.
2160 paint.setColor(SK_ColorGREEN);
2161 paint.setAlpha(127);
2162 const auto& rect =
2163 SkRect::MakeWH(layer.size.width, layer.size.height);
2164 canvas->drawRect(rect, paint);
2165 } break;
2166 default:
2167 // Asked to render an unknown platform view.
2168 FML_CHECK(false)
2169 << "Test was asked to composite an unknown platform view.";
2170 }
2171
2172 return surface->makeImageSnapshot();
2173 });
2174
2175 auto engine = builder.LaunchEngine();
2176
2177 // Send a window metrics events so frames may be scheduled.
2178 FlutterWindowMetricsEvent event = {};
2179 event.struct_size = sizeof(event);
2180 event.width = 1024;
2181 event.height = 600;
2182 event.pixel_ratio = 1.0;
2183 event.physical_view_inset_top = 0.0;
2184 event.physical_view_inset_right = 0.0;
2185 event.physical_view_inset_bottom = 0.0;
2186 event.physical_view_inset_left = 0.0;
2188 kSuccess);
2189 ASSERT_TRUE(engine.is_valid());
2190
2191 // wait for scene to be rendered.
2192 latch.Wait();
2193
2194 // TODO(https://github.com/flutter/flutter/issues/53784): enable this on all
2195 // platforms.
2196#if !defined(FML_OS_LINUX)
2197 GTEST_SKIP() << "Skipping golden tests on non-Linux OSes";
2198#endif // FML_OS_LINUX
2199 ASSERT_TRUE(
2200 ImageMatchesFixture("verifyb143464703_soft_noxform.png", rendered_scene));
2201}

◆ TEST_F() [437/876]

flutter::testing::TEST_F ( EmbedderTest  ,
ViewOperationsOrdered   
)

View operations - adding, removing, sending window metrics - must execute in order even though they are asynchronous. This is necessary to ensure the embedder's and engine's states remain synchronized.

Definition at line 1608 of file embedder_unittests.cc.

1608 {
1609 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
1610 EmbedderConfigBuilder builder(context);
1611 builder.SetSoftwareRendererConfig();
1612 builder.SetDartEntrypoint("window_metrics_event_all_view_ids");
1613
1614 fml::AutoResetWaitableEvent ready_latch;
1615 context.AddNativeCallback(
1616 "SignalNativeTest",
1618 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
1619
1620 std::atomic<int> message_count = 0;
1621 context.AddNativeCallback("SignalNativeMessage",
1623 message_count.fetch_add(1);
1624 }));
1625
1626 auto engine = builder.LaunchEngine();
1627 ASSERT_TRUE(engine.is_valid());
1628
1629 ready_latch.Wait();
1630
1631 // Enqueue multiple view operations at once:
1632 //
1633 // 1. Add view 123 - This must succeed.
1634 // 2. Add duplicate view 123 - This must fail asynchronously.
1635 // 3. Add second view 456 - This must succeed.
1636 // 4. Remove second view 456 - This must succeed.
1637 //
1638 // The engine must execute view operations asynchronously in serial order.
1639 // If step 2 succeeds instead of step 1, this indicates the engine did not
1640 // execute the view operations in the correct order. If step 4 fails,
1641 // this indicates the engine did not wait until the add second view completed.
1642 FlutterWindowMetricsEvent metrics123 = {};
1643 metrics123.struct_size = sizeof(FlutterWindowMetricsEvent);
1644 metrics123.width = 800;
1645 metrics123.height = 600;
1646 metrics123.pixel_ratio = 1.0;
1647 metrics123.view_id = 123;
1648
1649 FlutterWindowMetricsEvent metrics456 = {};
1650 metrics456.struct_size = sizeof(FlutterWindowMetricsEvent);
1651 metrics456.width = 800;
1652 metrics456.height = 600;
1653 metrics456.pixel_ratio = 1.0;
1654 metrics456.view_id = 456;
1655
1656 struct Captures {
1657 fml::AutoResetWaitableEvent add_first_view;
1658 fml::AutoResetWaitableEvent add_duplicate_view;
1659 fml::AutoResetWaitableEvent add_second_view;
1660 fml::AutoResetWaitableEvent remove_second_view;
1661 };
1662 Captures captures;
1663
1664 // Add view 123.
1665 FlutterAddViewInfo add_view_info = {};
1666 add_view_info.struct_size = sizeof(FlutterAddViewInfo);
1667 add_view_info.view_id = 123;
1668 add_view_info.view_metrics = &metrics123;
1669 add_view_info.user_data = &captures;
1670 add_view_info.add_view_callback = [](const FlutterAddViewResult* result) {
1671 auto captures = reinterpret_cast<Captures*>(result->user_data);
1672
1673 ASSERT_TRUE(result->added);
1674 ASSERT_FALSE(captures->add_first_view.IsSignaledForTest());
1675 ASSERT_FALSE(captures->add_duplicate_view.IsSignaledForTest());
1676 ASSERT_FALSE(captures->add_second_view.IsSignaledForTest());
1677 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
1678
1679 captures->add_first_view.Signal();
1680 };
1681
1682 // Add duplicate view 123.
1683 FlutterAddViewInfo add_duplicate_view_info = {};
1684 add_duplicate_view_info.struct_size = sizeof(FlutterAddViewInfo);
1685 add_duplicate_view_info.view_id = 123;
1686 add_duplicate_view_info.view_metrics = &metrics123;
1687 add_duplicate_view_info.user_data = &captures;
1688 add_duplicate_view_info.add_view_callback =
1689 [](const FlutterAddViewResult* result) {
1690 auto captures = reinterpret_cast<Captures*>(result->user_data);
1691
1692 ASSERT_FALSE(result->added);
1693 ASSERT_TRUE(captures->add_first_view.IsSignaledForTest());
1694 ASSERT_FALSE(captures->add_duplicate_view.IsSignaledForTest());
1695 ASSERT_FALSE(captures->add_second_view.IsSignaledForTest());
1696 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
1697
1698 captures->add_duplicate_view.Signal();
1699 };
1700
1701 // Add view 456.
1702 FlutterAddViewInfo add_second_view_info = {};
1703 add_second_view_info.struct_size = sizeof(FlutterAddViewInfo);
1704 add_second_view_info.view_id = 456;
1705 add_second_view_info.view_metrics = &metrics456;
1706 add_second_view_info.user_data = &captures;
1707 add_second_view_info.add_view_callback =
1708 [](const FlutterAddViewResult* result) {
1709 auto captures = reinterpret_cast<Captures*>(result->user_data);
1710
1711 ASSERT_TRUE(result->added);
1712 ASSERT_TRUE(captures->add_first_view.IsSignaledForTest());
1713 ASSERT_TRUE(captures->add_duplicate_view.IsSignaledForTest());
1714 ASSERT_FALSE(captures->add_second_view.IsSignaledForTest());
1715 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
1716
1717 captures->add_second_view.Signal();
1718 };
1719
1720 // Remove view 456.
1721 FlutterRemoveViewInfo remove_second_view_info = {};
1722 remove_second_view_info.struct_size = sizeof(FlutterRemoveViewInfo);
1723 remove_second_view_info.view_id = 456;
1724 remove_second_view_info.user_data = &captures;
1725 remove_second_view_info.remove_view_callback =
1726 [](const FlutterRemoveViewResult* result) {
1727 auto captures = reinterpret_cast<Captures*>(result->user_data);
1728
1729 ASSERT_TRUE(result->removed);
1730 ASSERT_TRUE(captures->add_first_view.IsSignaledForTest());
1731 ASSERT_TRUE(captures->add_duplicate_view.IsSignaledForTest());
1732 ASSERT_TRUE(captures->add_second_view.IsSignaledForTest());
1733 ASSERT_FALSE(captures->remove_second_view.IsSignaledForTest());
1734
1735 captures->remove_second_view.Signal();
1736 };
1737
1738 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_view_info), kSuccess);
1739 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_duplicate_view_info),
1740 kSuccess);
1741 ASSERT_EQ(FlutterEngineAddView(engine.get(), &add_second_view_info),
1742 kSuccess);
1743 ASSERT_EQ(FlutterEngineRemoveView(engine.get(), &remove_second_view_info),
1744 kSuccess);
1745 captures.remove_second_view.Wait();
1746 captures.add_second_view.Wait();
1747 captures.add_duplicate_view.Wait();
1748 captures.add_first_view.Wait();
1749 ASSERT_EQ(message_count, 3);
1750}

◆ TEST_F() [438/876]

flutter::testing::TEST_F ( EmbedderTest  ,
VMAndIsolateSnapshotSizesAreRedundantInAOTMode   
)

These snapshots may be materialized from symbols and the size field may not be relevant. Since this information is redundant, engine launch should not be gated on a non-zero buffer size.

Definition at line 625 of file embedder_unittests.cc.

625 {
626 if (!DartVM::IsRunningPrecompiledCode()) {
627 GTEST_SKIP();
628 return;
629 }
630 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
631 EmbedderConfigBuilder builder(context);
632 builder.SetSoftwareRendererConfig();
633
634 // The fixture sets this up correctly. Intentionally mess up the args.
635 builder.GetProjectArgs().vm_snapshot_data_size = 0;
636 builder.GetProjectArgs().vm_snapshot_instructions_size = 0;
637 builder.GetProjectArgs().isolate_snapshot_data_size = 0;
638 builder.GetProjectArgs().isolate_snapshot_instructions_size = 0;
639
640 auto engine = builder.LaunchEngine();
641 ASSERT_TRUE(engine.is_valid());
642}

◆ TEST_F() [439/876]

flutter::testing::TEST_F ( EmbedderTest  ,
VMShutsDownWhenNoEnginesInProcess   
)

Asserts behavior of FlutterProjectArgs::shutdown_dart_vm_when_done (which is set to true by default in these unit-tests).

Definition at line 576 of file embedder_unittests.cc.

576 {
577 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
578 EmbedderConfigBuilder builder(context);
579 builder.SetSoftwareRendererConfig();
580 const auto launch_count = DartVM::GetVMLaunchCount();
581
582 {
583 auto engine = builder.LaunchEngine();
584 ASSERT_EQ(launch_count + 1u, DartVM::GetVMLaunchCount());
585 }
586
587 {
588 auto engine = builder.LaunchEngine();
589 ASSERT_EQ(launch_count + 2u, DartVM::GetVMLaunchCount());
590 }
591}

◆ TEST_F() [440/876]

flutter::testing::TEST_F ( EmbedderTest  ,
VsyncCallbackPostedIntoFuture   
)

Definition at line 3307 of file embedder_unittests.cc.

3307 {
3309 fml::AutoResetWaitableEvent present_latch;
3310 fml::AutoResetWaitableEvent vsync_latch;
3311
3312 // One of the threads that the callback (FlutterEngineOnVsync) will be posted
3313 // to is the platform thread. So we cannot wait for assertions to complete on
3314 // the platform thread. Create a new thread to manage the engine instance and
3315 // wait for assertions on the test thread.
3316 auto platform_task_runner = CreateNewThread("platform_thread");
3317
3318 platform_task_runner->PostTask([&]() {
3319 auto& context =
3320 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3321
3322 context.SetVsyncCallback([&](intptr_t baton) {
3323 platform_task_runner->PostTask([baton = baton, &engine, &vsync_latch]() {
3324 FlutterEngineOnVsync(engine.get(), baton, NanosFromEpoch(16),
3325 NanosFromEpoch(32));
3326 vsync_latch.Signal();
3327 });
3328 });
3329 context.AddNativeCallback(
3330 "SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
3331 present_latch.Signal();
3332 }));
3333
3334 EmbedderConfigBuilder builder(context);
3335 builder.SetSoftwareRendererConfig();
3336 builder.SetupVsyncCallback();
3337 builder.SetDartEntrypoint("empty_scene");
3338 engine = builder.LaunchEngine();
3339 ASSERT_TRUE(engine.is_valid());
3340
3341 // Send a window metrics events so frames may be scheduled.
3342 FlutterWindowMetricsEvent event = {};
3343 event.struct_size = sizeof(event);
3344 event.width = 800;
3345 event.height = 600;
3346 event.pixel_ratio = 1.0;
3347
3349 kSuccess);
3350 });
3351
3352 vsync_latch.Wait();
3353 present_latch.Wait();
3354
3355 fml::AutoResetWaitableEvent shutdown_latch;
3356 platform_task_runner->PostTask([&]() {
3357 engine.reset();
3358 shutdown_latch.Signal();
3359 });
3360 shutdown_latch.Wait();
3361}
FlutterEngineResult FlutterEngineOnVsync(FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos)
Notify the engine that a vsync event occurred. A baton passed to the platform via the vsync callback ...
Definition embedder.cc:2869

◆ TEST_F() [441/876]

flutter::testing::TEST_F ( EmbedderTest  ,
WindowMetricsEventDefaultsToImplicitView   
)

Definition at line 3569 of file embedder_unittests.cc.

3569 {
3570 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3571 EmbedderConfigBuilder builder(context);
3572 builder.SetSoftwareRendererConfig();
3573 builder.SetDartEntrypoint("window_metrics_event_view_id");
3574
3575 fml::AutoResetWaitableEvent ready_latch, message_latch;
3576 context.AddNativeCallback(
3577 "SignalNativeTest",
3579 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3580 context.AddNativeCallback(
3581 "SignalNativeMessage",
3585 ASSERT_EQ("Changed: [0]", message);
3586 message_latch.Signal();
3587 }));
3588
3589 auto engine = builder.LaunchEngine();
3590 ASSERT_TRUE(engine.is_valid());
3591
3592 ready_latch.Wait();
3593
3594 FlutterWindowMetricsEvent event = {};
3595 // Simulate an event that comes from an old version of embedder.h that doesn't
3596 // have the view_id field.
3597 event.struct_size = offsetof(FlutterWindowMetricsEvent, view_id);
3598 event.width = 200;
3599 event.height = 300;
3600 event.pixel_ratio = 1.5;
3601 // Skip assigning event.view_id here to test the default behavior.
3602
3605 ASSERT_EQ(result, kSuccess);
3606
3607 message_latch.Wait();
3608}

◆ TEST_F() [442/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallClassMemberFunction   
)

Definition at line 320 of file ffi_native_unittest.cc.

320 {
321 DoCallThroughTest<void, decltype(&MyNativeClass::MyTestFunction),
322 &MyNativeClass::MyTestFunction>(
323 "MyNativeClass::MyTestFunction", "callMyTestFunction");
324}

◆ TEST_F() [443/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallClassMemberMethod   
)

Definition at line 335 of file ffi_native_unittest.cc.

335 {
336 DoCallThroughTest<MyNativeClass, decltype(&MyNativeClass::MyTestMethod),
337 &MyNativeClass::MyTestMethod>("MyNativeClass::MyTestMethod",
338 "callMyTestMethod");
339}

◆ TEST_F() [444/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoBool   
)

Definition at line 158 of file ffi_native_unittest.cc.

158 {
159 DoCallThroughTest<void, decltype(&EchoBool), &EchoBool>("EchoBool",
160 "callEchoBool");
161}

◆ TEST_F() [445/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoDouble   
)

Definition at line 198 of file ffi_native_unittest.cc.

198 {
199 DoCallThroughTest<void, decltype(&EchoDouble), &EchoDouble>("EchoDouble",
200 "callEchoDouble");
201}

◆ TEST_F() [446/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoHandle   
)

Definition at line 217 of file ffi_native_unittest.cc.

217 {
218 DoCallThroughTest<void, decltype(&EchoHandle), &EchoHandle>("EchoHandle",
219 "callEchoHandle");
220}

◆ TEST_F() [447/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoIntPtr   
)

Definition at line 175 of file ffi_native_unittest.cc.

175 {
176 DoCallThroughTest<void, decltype(&EchoIntPtr), &EchoIntPtr>("EchoIntPtr",
177 "callEchoIntPtr");
178}

◆ TEST_F() [448/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoString   
)

Definition at line 234 of file ffi_native_unittest.cc.

234 {
235 DoCallThroughTest<void, decltype(&EchoString), &EchoString>("EchoString",
236 "callEchoString");
237}

◆ TEST_F() [449/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoTypedList   
)

Definition at line 308 of file ffi_native_unittest.cc.

308 {
309 DoCallThroughTest<void, decltype(&EchoTypedList), &EchoTypedList>(
310 "EchoTypedList", "callEchoTypedList");
311}

◆ TEST_F() [450/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoU16String   
)

Definition at line 251 of file ffi_native_unittest.cc.

251 {
252 DoCallThroughTest<void, decltype(&EchoU16String), &EchoU16String>(
253 "EchoU16String", "callEchoU16String");
254}

◆ TEST_F() [451/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoVector   
)

Definition at line 268 of file ffi_native_unittest.cc.

268 {
269 DoCallThroughTest<void, decltype(&EchoVector), &EchoVector>("EchoVector",
270 "callEchoVector");
271}

◆ TEST_F() [452/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallEchoWrappable   
)

Definition at line 285 of file ffi_native_unittest.cc.

285 {
286 DoCallThroughTest<void, decltype(&EchoWrappable), &EchoWrappable>(
287 "EchoWrappable", "callEchoWrappable");
288}

◆ TEST_F() [453/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
FfiBindingCallNop   
)

Definition at line 142 of file ffi_native_unittest.cc.

142 {
143 DoCallThroughTest<void, decltype(&Nop), &Nop>("Nop", "callNop");
144}

◆ TEST_F() [454/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseClassMemberFunction   
)

Definition at line 326 of file ffi_native_unittest.cc.

326 {
327 DoSerialiseTest<void, decltype(&MyNativeClass::MyTestFunction),
328 &MyNativeClass::MyTestFunction>(
329 /*leaf=*/false, "Int32", "int", "Pointer, Int32, Handle",
330 "Pointer, int, Object");
331}

◆ TEST_F() [455/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseClassMemberMethod   
)

Definition at line 341 of file ffi_native_unittest.cc.

341 {
342 DoSerialiseTest<MyNativeClass, decltype(&MyNativeClass::MyTestMethod),
343 &MyNativeClass::MyTestMethod>(
344 /*leaf=*/false, "Handle", "Object", "Pointer, Int64", "Pointer, int");
345}

◆ TEST_F() [456/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoBool   
)

Definition at line 163 of file ffi_native_unittest.cc.

163 {
164 DoSerialiseTest<void, decltype(&EchoBool), &EchoBool>(
165 /*leaf=*/true, "Bool", "bool", "Bool", "bool");
166}

◆ TEST_F() [457/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoDouble   
)

Definition at line 203 of file ffi_native_unittest.cc.

203 {
204 DoSerialiseTest<void, decltype(&EchoDouble), &EchoDouble>(
205 /*leaf=*/true, "Double", "double", "Double", "double");
206}

◆ TEST_F() [458/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoHandle   
)

Definition at line 222 of file ffi_native_unittest.cc.

222 {
223 DoSerialiseTest<void, decltype(&EchoHandle), &EchoHandle>(
224 /*leaf=*/false, "Handle", "Object", "Handle", "Object");
225}

◆ TEST_F() [459/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoIntPtr   
)

Definition at line 180 of file ffi_native_unittest.cc.

180 {
181 if (sizeof(intptr_t) == 8) {
182 DoSerialiseTest<void, decltype(&EchoIntPtr), &EchoIntPtr>(
183 /*leaf=*/true, "Int64", "int", "Int64", "int");
184 } else {
185 EXPECT_EQ(sizeof(intptr_t), 4ul);
186 DoSerialiseTest<void, decltype(&EchoIntPtr), &EchoIntPtr>(
187 /*leaf=*/true, "Int32", "int", "Int32", "int");
188 }
189}

◆ TEST_F() [460/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoString   
)

Definition at line 239 of file ffi_native_unittest.cc.

239 {
240 DoSerialiseTest<void, decltype(&EchoString), &EchoString>(
241 /*leaf=*/false, "Handle", "String", "Handle", "String");
242}

◆ TEST_F() [461/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoTypedList   
)

Definition at line 313 of file ffi_native_unittest.cc.

313 {
314 DoSerialiseTest<void, decltype(&EchoTypedList), &EchoTypedList>(
315 /*leaf=*/false, "Handle", "Object", "Handle", "Object");
316}

◆ TEST_F() [462/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoU16String   
)

Definition at line 256 of file ffi_native_unittest.cc.

256 {
257 DoSerialiseTest<void, decltype(&EchoU16String), &EchoU16String>(
258 /*leaf=*/false, "Handle", "String", "Handle", "String");
259}

◆ TEST_F() [463/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoVector   
)

Definition at line 273 of file ffi_native_unittest.cc.

273 {
274 DoSerialiseTest<void, decltype(&EchoVector), &EchoVector>(
275 /*leaf=*/false, "Handle", "List", "Handle", "List");
276}

◆ TEST_F() [464/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseEchoWrappable   
)

Definition at line 290 of file ffi_native_unittest.cc.

290 {
291 if (sizeof(intptr_t) == 8) {
292 DoSerialiseTest<void, decltype(&EchoWrappable), &EchoWrappable>(
293 /*leaf=*/true, "Int64", "int", "Pointer", "Pointer");
294 } else {
295 EXPECT_EQ(sizeof(intptr_t), 4ul);
296 DoSerialiseTest<void, decltype(&EchoWrappable), &EchoWrappable>(
297 /*leaf=*/true, "Int32", "int", "Pointer", "Pointer");
298 }
299}

◆ TEST_F() [465/876]

flutter::testing::TEST_F ( FfiNativeTest  ,
SerialiseNop   
)

Definition at line 146 of file ffi_native_unittest.cc.

146 {
147 DoSerialiseTest<void, decltype(&Nop), &Nop>(
148 /*leaf=*/true, "Void", "void", "", "");
149}

◆ TEST_F() [466/876]

flutter::testing::TEST_F ( FileLoaderTest  ,
CanonicalizesFileUrlCorrectly   
)

Definition at line 16 of file file_loader_unittests.cc.

16 {
17 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
18 auto settings = CreateSettingsForFixture();
19 auto vm_snapshot = DartSnapshot::VMSnapshotFromSettings(settings);
20 auto isolate_snapshot = DartSnapshot::IsolateSnapshotFromSettings(settings);
21 auto vm_ref = DartVMRef::Create(settings, vm_snapshot, isolate_snapshot);
22 ASSERT_TRUE(vm_ref);
23
24 TaskRunners task_runners(GetCurrentTestName(), //
25 GetCurrentTaskRunner(), //
26 GetCurrentTaskRunner(), //
27 GetCurrentTaskRunner(), //
28 GetCurrentTaskRunner() //
29 );
30 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
31 {}, GetDefaultKernelFilePath());
32 ASSERT_TRUE(isolate);
33
34 ASSERT_TRUE(isolate->RunInIsolateScope([]() {
35 tonic::FileLoader file_loader;
36 std::string original_url = "file:///Users/test/foo";
37 Dart_Handle dart_url = tonic::StdStringToDart(original_url);
38 auto canonicalized_url = file_loader.CanonicalizeURL(Dart_Null(), dart_url);
39 EXPECT_TRUE(canonicalized_url);
40 EXPECT_EQ(tonic::StdStringFromDart(canonicalized_url), original_url);
41 return true;
42 }));
43}

◆ TEST_F() [467/876]

flutter::testing::TEST_F ( FlutterChannelKeyResponderTest  ,
BasicKeyEvent   
)

Definition at line 75 of file FlutterChannelKeyResponderTest.mm.

75 {
76 __block NSMutableArray<NSNumber*>* responses = [[NSMutableArray<NSNumber*> alloc] init];
77 FakeMessageChannel* channel = [[FakeMessageChannel alloc] init];
79 [[FlutterChannelKeyResponder alloc] initWithChannel:channel];
80
81 // Initial empty modifiers.
82 //
83 // This can happen when user opens window while modifier key is pressed and then releases the
84 // modifier. No events should be sent, but the callback should still be called.
85 // Regression test for https://github.com/flutter/flutter/issues/87339.
86 channel.nextResponse = @{@"handled" : @YES};
87 [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", NO, 60)
88 callback:^(BOOL handled) {
89 [responses addObject:@(handled)];
90 }];
91
92 EXPECT_EQ([channel.messages count], 0u);
93 ASSERT_EQ([responses count], 1u);
94 EXPECT_EQ([responses[0] boolValue], YES);
95 [responses removeAllObjects];
96
97 // Key down
98 channel.nextResponse = @{@"handled" : @YES};
99 [responder handleEvent:CreateKeyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", NO, 0)
100 callback:^(BOOL handled) {
101 [responses addObject:@(handled)];
102 }];
103
104 ASSERT_EQ([channel.messages count], 1u);
105 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
106 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
107 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
108 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x0);
109 EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "a");
110 EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");
111
112 ASSERT_EQ([responses count], 1u);
113 EXPECT_EQ([[responses lastObject] boolValue], YES);
114
115 [channel.messages removeAllObjects];
116 [responses removeAllObjects];
117
118 // Key up
119 channel.nextResponse = @{@"handled" : @NO};
120 [responder handleEvent:CreateKeyEvent(NSEventTypeKeyUp, 0x100, @"a", @"a", NO, 0)
121 callback:^(BOOL handled) {
122 [responses addObject:@(handled)];
123 }];
124
125 ASSERT_EQ([channel.messages count], 1u);
126 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
127 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keyup");
128 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
129 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0);
130 EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "a");
131 EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");
132
133 ASSERT_EQ([responses count], 1u);
134 EXPECT_EQ([[responses lastObject] boolValue], NO);
135
136 [channel.messages removeAllObjects];
137 [responses removeAllObjects];
138
139 // LShift down
140 channel.nextResponse = @{@"handled" : @YES};
141 [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x20102, @"", @"", NO, 56)
142 callback:^(BOOL handled) {
143 [responses addObject:@(handled)];
144 }];
145
146 ASSERT_EQ([channel.messages count], 1u);
147 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
148 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
149 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 56);
150 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x20002);
151
152 ASSERT_EQ([responses count], 1u);
153 EXPECT_EQ([[responses lastObject] boolValue], YES);
154
155 [channel.messages removeAllObjects];
156 [responses removeAllObjects];
157
158 // RShift down
159 channel.nextResponse = @{@"handled" : @NO};
160 [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x20006, @"", @"", NO, 60)
161 callback:^(BOOL handled) {
162 [responses addObject:@(handled)];
163 }];
164
165 ASSERT_EQ([channel.messages count], 1u);
166 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
167 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
168 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 60);
169 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x20006);
170
171 ASSERT_EQ([responses count], 1u);
172 EXPECT_EQ([[responses lastObject] boolValue], NO);
173
174 [channel.messages removeAllObjects];
175 [responses removeAllObjects];
176
177 // LShift up
178 channel.nextResponse = @{@"handled" : @NO};
179 [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x20104, @"", @"", NO, 56)
180 callback:^(BOOL handled) {
181 [responses addObject:@(handled)];
182 }];
183
184 ASSERT_EQ([channel.messages count], 1u);
185 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
186 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keyup");
187 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 56);
188 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x20004);
189
190 ASSERT_EQ([responses count], 1u);
191 EXPECT_EQ([[responses lastObject] boolValue], NO);
192
193 [channel.messages removeAllObjects];
194 [responses removeAllObjects];
195
196 // RShift up
197 channel.nextResponse = @{@"handled" : @NO};
198 [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0, @"", @"", NO, 60)
199 callback:^(BOOL handled) {
200 [responses addObject:@(handled)];
201 }];
202
203 ASSERT_EQ([channel.messages count], 1u);
204 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
205 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keyup");
206 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 60);
207 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0);
208
209 ASSERT_EQ([responses count], 1u);
210 EXPECT_EQ([[responses lastObject] boolValue], NO);
211
212 [channel.messages removeAllObjects];
213 [responses removeAllObjects];
214
215 // RShift up again, should be ignored and not produce a keydown event, but the
216 // callback should be called.
217 channel.nextResponse = @{@"handled" : @NO};
218 [responder handleEvent:CreateKeyEvent(NSEventTypeFlagsChanged, 0x100, @"", @"", NO, 60)
219 callback:^(BOOL handled) {
220 [responses addObject:@(handled)];
221 }];
222
223 EXPECT_EQ([channel.messages count], 0u);
224 ASSERT_EQ([responses count], 1u);
225 EXPECT_EQ([responses[0] boolValue], YES);
226}
void handleEvent:callback:(NSEvent *event, [callback] FlutterAsyncKeyCallback callback)

◆ TEST_F() [468/876]

flutter::testing::TEST_F ( FlutterChannelKeyResponderTest  ,
EmptyResponseIsTakenAsHandled   
)

Definition at line 228 of file FlutterChannelKeyResponderTest.mm.

228 {
229 __block NSMutableArray<NSNumber*>* responses = [[NSMutableArray<NSNumber*> alloc] init];
230 FakeMessageChannel* channel = [[FakeMessageChannel alloc] init];
231 FlutterChannelKeyResponder* responder =
232 [[FlutterChannelKeyResponder alloc] initWithChannel:channel];
233
234 channel.nextResponse = nil;
235 [responder handleEvent:CreateKeyEvent(NSEventTypeKeyDown, 0x100, @"a", @"a", NO, 0)
236 callback:^(BOOL handled) {
237 [responses addObject:@(handled)];
238 }];
239
240 ASSERT_EQ([channel.messages count], 1u);
241 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
242 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
243 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
244 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0);
245 EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "a");
246 EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "a");
247
248 ASSERT_EQ([responses count], 1u);
249 EXPECT_EQ([[responses lastObject] boolValue], YES);
250}

◆ TEST_F() [469/876]

flutter::testing::TEST_F ( FlutterChannelKeyResponderTest  ,
FollowsLayoutMap   
)

Definition at line 252 of file FlutterChannelKeyResponderTest.mm.

252 {
253 __block NSMutableArray<NSNumber*>* responses = [[NSMutableArray<NSNumber*> alloc] init];
254 FakeMessageChannel* channel = [[FakeMessageChannel alloc] init];
255 FlutterChannelKeyResponder* responder =
256 [[FlutterChannelKeyResponder alloc] initWithChannel:channel];
257
258 NSMutableDictionary<NSNumber*, NSNumber*>* layoutMap =
259 [NSMutableDictionary<NSNumber*, NSNumber*> dictionary];
260 responder.layoutMap = layoutMap;
261 // French layout
262 layoutMap[@(kVK_ANSI_A)] = @(kLogicalKeyQ);
263
264 channel.nextResponse = @{@"handled" : @YES};
265 [responder handleEvent:CreateKeyEvent(NSEventTypeKeyDown, kVK_ANSI_A, @"q", @"q", NO, 0)
266 callback:^(BOOL handled) {
267 [responses addObject:@(handled)];
268 }];
269
270 ASSERT_EQ([channel.messages count], 1u);
271 EXPECT_STREQ([[channel.messages lastObject][@"keymap"] UTF8String], "macos");
272 EXPECT_STREQ([[channel.messages lastObject][@"type"] UTF8String], "keydown");
273 EXPECT_EQ([[channel.messages lastObject][@"keyCode"] intValue], 0);
274 EXPECT_EQ([[channel.messages lastObject][@"modifiers"] intValue], 0x0);
275 EXPECT_STREQ([[channel.messages lastObject][@"characters"] UTF8String], "q");
276 EXPECT_STREQ([[channel.messages lastObject][@"charactersIgnoringModifiers"] UTF8String], "q");
277 EXPECT_EQ([channel.messages lastObject][@"specifiedLogicalKey"], @(kLogicalKeyQ));
278
279 ASSERT_EQ([responses count], 1u);
280 EXPECT_EQ([[responses lastObject] boolValue], YES);
281
282 [channel.messages removeAllObjects];
283 [responses removeAllObjects];
284}
NSMutableDictionary< NSNumber *, NSNumber * > * layoutMap

◆ TEST_F() [470/876]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTexture   
)

Definition at line 131 of file FlutterEmbedderExternalTextureTest.mm.

131 {
132 // Constants.
133 const size_t width = 100;
134 const size_t height = 100;
135 const int64_t texture_id = 1;
136
137 // Set up the surface.
138 FlutterDarwinContextMetalSkia* darwinContextMetal =
139 [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
141 GrDirectContext* grContext = darwinContextMetal.mainContext.get();
143
144 // Create a texture.
145 TestExternalTexture* testExternalTexture =
146 [[TestExternalTexture alloc] initWidth:width
147 height:height
148 pixelFormatType:kCVPixelFormatType_32BGRA];
149 FlutterExternalTexture* textureHolder =
150 [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
151 darwinMetalContext:darwinContextMetal];
152
153 // Callback to resolve the texture.
155 size_t h) {
156 EXPECT_TRUE(w == width);
157 EXPECT_TRUE(h == height);
158
159 auto texture = std::make_unique<FlutterMetalExternalTexture>();
160 [textureHolder populateTexture:texture.get()];
161
162 EXPECT_TRUE(texture->num_textures == 1);
163 EXPECT_TRUE(texture->textures != nullptr);
165 return texture;
166 };
167
168 // Render the texture.
169 std::unique_ptr<flutter::Texture> texture =
170 std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
171 SkRect bounds = SkRect::MakeWH(info.width(), info.height());
172 DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
173 DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
175 .canvas = &canvas,
176 .gr_context = grContext,
177 };
178 texture->Paint(context, bounds, /*freeze=*/false, sampling);
179
180 gpuSurface->makeImageSnapshot();
181}
BOOL populateTexture:(nonnull FlutterMetalExternalTexture *metalTexture)

◆ TEST_F() [471/876]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTextureYUVA   
)

Definition at line 183 of file FlutterEmbedderExternalTextureTest.mm.

183 {
184 // Constants.
185 const size_t width = 100;
186 const size_t height = 100;
187 const int64_t texture_id = 1;
188
189 // Set up the surface.
190 FlutterDarwinContextMetalSkia* darwinContextMetal =
191 [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
193 GrDirectContext* grContext = darwinContextMetal.mainContext.get();
195
196 // Create a texture.
197 TestExternalTexture* testExternalTexture =
198 [[TestExternalTexture alloc] initWidth:width
199 height:height
200 pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange];
201 FlutterExternalTexture* textureHolder =
202 [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
203 darwinMetalContext:darwinContextMetal];
204
205 // Callback to resolve the texture.
207 size_t h) {
208 EXPECT_TRUE(w == width);
209 EXPECT_TRUE(h == height);
210
211 auto texture = std::make_unique<FlutterMetalExternalTexture>();
212 [textureHolder populateTexture:texture.get()];
213
214 EXPECT_TRUE(texture->num_textures == 2);
215 EXPECT_TRUE(texture->textures != nullptr);
217 EXPECT_TRUE(texture->yuv_color_space ==
219 return texture;
220 };
221
222 // Render the texture.
223 std::unique_ptr<flutter::Texture> texture =
224 std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
225 SkRect bounds = SkRect::MakeWH(info.width(), info.height());
226 DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
227 DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
229 .canvas = &canvas,
230 .gr_context = grContext,
231 };
232 texture->Paint(context, bounds, /*freeze=*/false, sampling);
233
234 gpuSurface->makeImageSnapshot();
235}
@ kBT601LimitedRange
Definition embedder.h:611
@ kYUVA
Definition embedder.h:604

◆ TEST_F() [472/876]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateExternalTextureYUVA2   
)

Definition at line 237 of file FlutterEmbedderExternalTextureTest.mm.

237 {
238 // Constants.
239 const size_t width = 100;
240 const size_t height = 100;
241 const int64_t texture_id = 1;
242
243 // Set up the surface.
244 FlutterDarwinContextMetalSkia* darwinContextMetal =
245 [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
247 GrDirectContext* grContext = darwinContextMetal.mainContext.get();
249
250 // Create a texture.
251 TestExternalTexture* testExternalTexture =
252 [[TestExternalTexture alloc] initWidth:width
253 height:height
254 pixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange];
255 FlutterExternalTexture* textureHolder =
256 [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
257 darwinMetalContext:darwinContextMetal];
258
259 // Callback to resolve the texture.
261 size_t h) {
262 EXPECT_TRUE(w == width);
263 EXPECT_TRUE(h == height);
264
265 auto texture = std::make_unique<FlutterMetalExternalTexture>();
266 [textureHolder populateTexture:texture.get()];
267
268 EXPECT_TRUE(texture->num_textures == 2);
269 EXPECT_TRUE(texture->textures != nullptr);
271 EXPECT_TRUE(texture->yuv_color_space ==
273 return texture;
274 };
275
276 // Render the texture.
277 std::unique_ptr<flutter::Texture> texture =
278 std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
279 SkRect bounds = SkRect::MakeWH(info.width(), info.height());
280 DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
281 DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
283 .canvas = &canvas,
284 .gr_context = grContext,
285 };
286 texture->Paint(context, bounds, /*freeze=*/false, sampling);
287
288 gpuSurface->makeImageSnapshot();
289}
@ kBT601FullRange
Definition embedder.h:610

◆ TEST_F() [473/876]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestPopulateUnsupportedExternalTexture   
)

Definition at line 291 of file FlutterEmbedderExternalTextureTest.mm.

291 {
292 // Constants.
293 const size_t width = 100;
294 const size_t height = 100;
295 const int64_t texture_id = 1;
296
297 // Set up the surface.
298 FlutterDarwinContextMetalSkia* darwinContextMetal =
299 [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
301 GrDirectContext* grContext = darwinContextMetal.mainContext.get();
303
304 // Create a texture.
305 TestExternalTexture* testExternalTexture =
306 [[TestExternalTexture alloc] initWidth:width
307 height:height
308 pixelFormatType:kCVPixelFormatType_420YpCbCr8PlanarFullRange];
309 FlutterExternalTexture* textureHolder =
310 [[FlutterExternalTexture alloc] initWithFlutterTexture:testExternalTexture
311 darwinMetalContext:darwinContextMetal];
312
313 // Callback to resolve the texture.
315 size_t h) {
316 EXPECT_TRUE(w == width);
317 EXPECT_TRUE(h == height);
318
319 auto texture = std::make_unique<FlutterMetalExternalTexture>();
320 EXPECT_FALSE([textureHolder populateTexture:texture.get()]);
321 return nullptr;
322 };
323
324 // Render the texture.
325 std::unique_ptr<flutter::Texture> texture =
326 std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
327 SkRect bounds = SkRect::MakeWH(info.width(), info.height());
328 DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
329 DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
331 .canvas = &canvas,
332 .gr_context = grContext,
333 };
334 texture->Paint(context, bounds, /*freeze=*/false, sampling);
335}

◆ TEST_F() [474/876]

flutter::testing::TEST_F ( FlutterEmbedderExternalTextureTest  ,
TestTextureResolution   
)

Definition at line 73 of file FlutterEmbedderExternalTextureTest.mm.

73 {
74 // Constants.
75 const size_t width = 100;
76 const size_t height = 100;
77 const int64_t texture_id = 1;
78
79 // Set up the surface.
80 FlutterDarwinContextMetalSkia* darwinContextMetal =
81 [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
83 GrDirectContext* grContext = darwinContextMetal.mainContext.get();
85
86 // Create a texture.
87 MTLTextureDescriptor* textureDescriptor = [[MTLTextureDescriptor alloc] init];
88 textureDescriptor.pixelFormat = MTLPixelFormatBGRA8Unorm;
89 textureDescriptor.width = width;
90 textureDescriptor.height = height;
91 textureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
92 id<MTLTexture> mtlTexture =
93 [darwinContextMetal.device newTextureWithDescriptor:textureDescriptor];
94 std::vector<FlutterMetalTextureHandle> textures = {
95 (__bridge FlutterMetalTextureHandle)mtlTexture,
96 };
97
98 // Callback to resolve the texture.
100 size_t h) {
101 EXPECT_TRUE(w == width);
102 EXPECT_TRUE(h == height);
103
104 auto texture = std::make_unique<FlutterMetalExternalTexture>();
105 texture->struct_size = sizeof(FlutterMetalExternalTexture);
106 texture->num_textures = 1;
107 texture->height = h;
108 texture->width = w;
110 texture->textures = textures.data();
111 return texture;
112 };
113
114 // Render the texture.
115 std::unique_ptr<flutter::Texture> texture =
116 std::make_unique<EmbedderExternalTextureMetal>(texture_id, callback);
117 SkRect bounds = SkRect::MakeWH(info.width(), info.height());
118 DlImageSampling sampling = DlImageSampling::kNearestNeighbor;
119 DlSkCanvasAdapter canvas(gpuSurface->getCanvas());
121 .canvas = &canvas,
122 .gr_context = grContext,
123 };
124 texture->Paint(context, bounds, /*freeze=*/false, sampling);
125
126 ASSERT_TRUE(mtlTexture != nil);
127
128 gpuSurface->makeImageSnapshot();
129}

◆ TEST_F() [475/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanLaunch   
)

Definition at line 142 of file FlutterEngineTest.mm.

142 {
143 FlutterEngine* engine = GetFlutterEngine();
144 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
145 ASSERT_TRUE(engine.running);
146}

◆ TEST_F() [476/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanLogToStdout   
)

Definition at line 205 of file FlutterEngineTest.mm.

205 {
206 // Block until completion of print statement.
208 AddNativeCallback("SignalNativeTest",
210
211 // Replace stdout stream buffer with our own.
212 StreamCapture stdout_capture(&std::cout);
213
214 // Launch the test entrypoint.
215 FlutterEngine* engine = GetFlutterEngine();
216 EXPECT_TRUE([engine runWithEntrypoint:@"canLogToStdout"]);
217 ASSERT_TRUE(engine.running);
218
219 latch.Wait();
220
221 stdout_capture.Stop();
222
223 // Verify hello world was written to stdout.
224 EXPECT_TRUE(stdout_capture.GetOutput().find("Hello logging") != std::string::npos);
225}

◆ TEST_F() [477/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanToggleAccessibility   
)

Definition at line 286 of file FlutterEngineTest.mm.

286 {
287 FlutterEngine* engine = GetFlutterEngine();
288 // Capture the update callbacks before the embedder API initializes.
289 auto original_init = engine.embedderAPI.Initialize;
290 std::function<void(const FlutterSemanticsUpdate2*, void*)> update_semantics_callback;
292 Initialize, ([&update_semantics_callback, &original_init](
293 size_t version, const FlutterRendererConfig* config,
294 const FlutterProjectArgs* args, void* user_data, auto engine_out) {
295 update_semantics_callback = args->update_semantics_callback2;
296 return original_init(version, config, args, user_data, engine_out);
297 }));
298 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
299 // Set up view controller.
300 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
301 nibName:nil
302 bundle:nil];
303 [viewController loadView];
304 // Enable the semantics.
305 bool enabled_called = false;
307 MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&enabled_called](auto engine, bool enabled) {
308 enabled_called = enabled;
309 return kSuccess;
310 }));
312 EXPECT_TRUE(enabled_called);
313 // Send flutter semantics updates.
315 root.id = 0;
316 root.flags = static_cast<FlutterSemanticsFlag>(0);
317 root.actions = static_cast<FlutterSemanticsAction>(0);
318 root.text_selection_base = -1;
319 root.text_selection_extent = -1;
320 root.label = "root";
321 root.hint = "";
322 root.value = "";
323 root.increased_value = "";
324 root.decreased_value = "";
325 root.tooltip = "";
326 root.child_count = 1;
327 int32_t children[] = {1};
328 root.children_in_traversal_order = children;
329 root.custom_accessibility_actions_count = 0;
330
332 child1.id = 1;
333 child1.flags = static_cast<FlutterSemanticsFlag>(0);
334 child1.actions = static_cast<FlutterSemanticsAction>(0);
335 child1.text_selection_base = -1;
336 child1.text_selection_extent = -1;
337 child1.label = "child 1";
338 child1.hint = "";
339 child1.value = "";
340 child1.increased_value = "";
341 child1.decreased_value = "";
342 child1.tooltip = "";
343 child1.child_count = 0;
345
347 update.node_count = 2;
348 FlutterSemanticsNode2* nodes[] = {&root, &child1};
349 update.nodes = nodes;
350 update.custom_action_count = 0;
351 update_semantics_callback(&update, (__bridge void*)engine);
352
353 // Verify the accessibility tree is attached to the flutter view.
354 EXPECT_EQ([engine.viewController.flutterView.accessibilityChildren count], 1u);
355 NSAccessibilityElement* native_root = engine.viewController.flutterView.accessibilityChildren[0];
356 std::string root_label = [native_root.accessibilityLabel UTF8String];
357 EXPECT_TRUE(root_label == "root");
358 EXPECT_EQ(native_root.accessibilityRole, NSAccessibilityGroupRole);
359 EXPECT_EQ([native_root.accessibilityChildren count], 1u);
360 NSAccessibilityElement* native_child1 = native_root.accessibilityChildren[0];
361 std::string child1_value = [native_child1.accessibilityValue UTF8String];
362 EXPECT_TRUE(child1_value == "child 1");
363 EXPECT_EQ(native_child1.accessibilityRole, NSAccessibilityStaticTextRole);
364 EXPECT_EQ([native_child1.accessibilityChildren count], 0u);
365 // Disable the semantics.
366 bool semanticsEnabled = true;
368 MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&semanticsEnabled](auto engine, bool enabled) {
369 semanticsEnabled = enabled;
370 return kSuccess;
371 }));
373 EXPECT_FALSE(semanticsEnabled);
374 // Verify the accessibility tree is removed from the view.
375 EXPECT_EQ([engine.viewController.flutterView.accessibilityChildren count], 0u);
376
377 [engine setViewController:nil];
378}
FlutterViewController * viewController
FlutterEngineInitializeFnPtr Initialize
Definition embedder.h:3325
FlutterEngineUpdateSemanticsEnabledFnPtr UpdateSemanticsEnabled
Definition embedder.h:3341

◆ TEST_F() [478/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CanToggleAccessibilityWhenHeadless   
)

Definition at line 380 of file FlutterEngineTest.mm.

380 {
381 FlutterEngine* engine = GetFlutterEngine();
382 // Capture the update callbacks before the embedder API initializes.
383 auto original_init = engine.embedderAPI.Initialize;
384 std::function<void(const FlutterSemanticsUpdate2*, void*)> update_semantics_callback;
386 Initialize, ([&update_semantics_callback, &original_init](
387 size_t version, const FlutterRendererConfig* config,
388 const FlutterProjectArgs* args, void* user_data, auto engine_out) {
389 update_semantics_callback = args->update_semantics_callback2;
390 return original_init(version, config, args, user_data, engine_out);
391 }));
392 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
393
394 // Enable the semantics without attaching a view controller.
395 bool enabled_called = false;
397 MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&enabled_called](auto engine, bool enabled) {
398 enabled_called = enabled;
399 return kSuccess;
400 }));
402 EXPECT_TRUE(enabled_called);
403 // Send flutter semantics updates.
405 root.id = 0;
406 root.flags = static_cast<FlutterSemanticsFlag>(0);
407 root.actions = static_cast<FlutterSemanticsAction>(0);
408 root.text_selection_base = -1;
409 root.text_selection_extent = -1;
410 root.label = "root";
411 root.hint = "";
412 root.value = "";
413 root.increased_value = "";
414 root.decreased_value = "";
415 root.tooltip = "";
416 root.child_count = 1;
417 int32_t children[] = {1};
418 root.children_in_traversal_order = children;
419 root.custom_accessibility_actions_count = 0;
420
422 child1.id = 1;
423 child1.flags = static_cast<FlutterSemanticsFlag>(0);
424 child1.actions = static_cast<FlutterSemanticsAction>(0);
425 child1.text_selection_base = -1;
426 child1.text_selection_extent = -1;
427 child1.label = "child 1";
428 child1.hint = "";
429 child1.value = "";
430 child1.increased_value = "";
431 child1.decreased_value = "";
432 child1.tooltip = "";
433 child1.child_count = 0;
435
437 update.node_count = 2;
438 FlutterSemanticsNode2* nodes[] = {&root, &child1};
439 update.nodes = nodes;
440 update.custom_action_count = 0;
441 // This call updates semantics for the implicit view, which does not exist,
442 // and therefore this call is invalid. But the engine should not crash.
443 update_semantics_callback(&update, (__bridge void*)engine);
444
445 // No crashes.
446 EXPECT_EQ(engine.viewController, nil);
447
448 // Disable the semantics.
449 bool semanticsEnabled = true;
451 MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&semanticsEnabled](auto engine, bool enabled) {
452 semanticsEnabled = enabled;
453 return kSuccess;
454 }));
456 EXPECT_FALSE(semanticsEnabled);
457 // Still no crashes
458 EXPECT_EQ(engine.viewController, nil);
459}

◆ TEST_F() [479/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
Compositor   
)

Definition at line 502 of file FlutterEngineTest.mm.

502 {
503 NSString* fixtures = @(flutter::testing::GetFixturesPath());
504 FlutterDartProject* project = [[FlutterDartProject alloc]
505 initWithAssetsPath:fixtures
506 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
507 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:project];
508
509 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
510 nibName:nil
511 bundle:nil];
512 [viewController loadView];
513 [viewController viewDidLoad];
514 viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
515
516 EXPECT_TRUE([engine runWithEntrypoint:@"canCompositePlatformViews"]);
517
518 [engine.platformViewController registerViewFactory:[[TestPlatformViewFactory alloc] init]
519 withId:@"factory_id"];
520 [engine.platformViewController
521 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"create"
522 arguments:@{
523 @"id" : @(42),
524 @"viewType" : @"factory_id",
525 }]
526 result:^(id result){
527 }];
528
529 [engine.testThreadSynchronizer blockUntilFrameAvailable];
530
531 CALayer* rootLayer = viewController.flutterView.layer;
532
533 // There are two layers with Flutter contents and one view
534 EXPECT_EQ(rootLayer.sublayers.count, 2u);
535 EXPECT_EQ(viewController.flutterView.subviews.count, 1u);
536
537 // TODO(gw280): add support for screenshot tests in this test harness
538
539 [engine shutDownEngine];
540}

◆ TEST_F() [480/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
CompositorIgnoresUnknownView   
)

Definition at line 542 of file FlutterEngineTest.mm.

542 {
543 FlutterEngine* engine = GetFlutterEngine();
544 auto original_init = engine.embedderAPI.Initialize;
545 ::FlutterCompositor compositor;
547 Initialize, ([&compositor, &original_init](
548 size_t version, const FlutterRendererConfig* config,
549 const FlutterProjectArgs* args, void* user_data, auto engine_out) {
550 compositor = *args->compositor;
551 return original_init(version, config, args, user_data, engine_out);
552 }));
553
554 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
555 nibName:nil
556 bundle:nil];
557 [viewController loadView];
558
559 EXPECT_TRUE([engine runWithEntrypoint:@"empty"]);
560
563 .size = FlutterSize{10, 10},
564 };
565 FlutterBackingStore backing_store = {};
566 EXPECT_NE(compositor.create_backing_store_callback, nullptr);
568 compositor.create_backing_store_callback(&config, &backing_store, compositor.user_data));
569
570 FlutterLayer layer{
572 .backing_store = &backing_store,
573 };
574 std::vector<FlutterLayer*> layers = {&layer};
575
578 .view_id = 123,
579 .layers = const_cast<const FlutterLayer**>(layers.data()),
580 .layers_count = 1,
581 .user_data = compositor.user_data,
582 };
583 EXPECT_NE(compositor.present_view_callback, nullptr);
584 EXPECT_FALSE(compositor.present_view_callback(&info));
585 EXPECT_TRUE(compositor.collect_backing_store_callback(&backing_store, compositor.user_data));
586
587 (void)viewController;
588 [engine shutDownEngine];
589}
size_t struct_size
The size of this struct. Must be sizeof(FlutterBackingStoreConfig).
Definition embedder.h:1780
FlutterBackingStoreCreateCallback create_backing_store_callback
Definition embedder.h:1901
FlutterPresentViewCallback present_view_callback
Definition embedder.h:1930
FlutterBackingStoreCollectCallback collect_backing_store_callback
Definition embedder.h:1906
A structure to represent the width and height.
Definition embedder.h:421

◆ TEST_F() [481/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DartEntrypointArguments   
)

Definition at line 591 of file FlutterEngineTest.mm.

591 {
592 NSString* fixtures = @(flutter::testing::GetFixturesPath());
593 FlutterDartProject* project = [[FlutterDartProject alloc]
594 initWithAssetsPath:fixtures
595 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
596
597 project.dartEntrypointArguments = @[ @"arg1", @"arg2" ];
598 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:project];
599
600 bool called = false;
601 auto original_init = engine.embedderAPI.Initialize;
603 Initialize, ([&called, &original_init](size_t version, const FlutterRendererConfig* config,
604 const FlutterProjectArgs* args, void* user_data,
605 FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
606 called = true;
607 EXPECT_EQ(args->dart_entrypoint_argc, 2);
608 NSString* arg1 = [[NSString alloc] initWithCString:args->dart_entrypoint_argv[0]
609 encoding:NSUTF8StringEncoding];
610 NSString* arg2 = [[NSString alloc] initWithCString:args->dart_entrypoint_argv[1]
611 encoding:NSUTF8StringEncoding];
612
613 EXPECT_TRUE([arg1 isEqualToString:@"arg1"]);
614 EXPECT_TRUE([arg2 isEqualToString:@"arg2"]);
615
616 return original_init(version, config, args, user_data, engine_out);
617 }));
618
619 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
620 EXPECT_TRUE(called);
621}

◆ TEST_F() [482/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DISABLED_BackgroundIsBlack   
)

Definition at line 227 of file FlutterEngineTest.mm.

227 {
228 FlutterEngine* engine = GetFlutterEngine();
229
230 // Latch to ensure the entire layer tree has been generated and presented.
232 AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
233 CALayer* rootLayer = engine.viewController.flutterView.layer;
234 EXPECT_TRUE(rootLayer.backgroundColor != nil);
235 if (rootLayer.backgroundColor != nil) {
236 NSColor* actualBackgroundColor =
237 [NSColor colorWithCGColor:rootLayer.backgroundColor];
238 EXPECT_EQ(actualBackgroundColor, [NSColor blackColor]);
239 }
240 latch.Signal();
241 }));
242
243 // Launch the test entrypoint.
244 EXPECT_TRUE([engine runWithEntrypoint:@"backgroundTest"]);
245 ASSERT_TRUE(engine.running);
246
247 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
248 nibName:nil
249 bundle:nil];
250 [viewController loadView];
251 viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
252
253 latch.Wait();
254}

◆ TEST_F() [483/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DISABLED_CanOverrideBackgroundColor   
)

Definition at line 256 of file FlutterEngineTest.mm.

256 {
257 FlutterEngine* engine = GetFlutterEngine();
258
259 // Latch to ensure the entire layer tree has been generated and presented.
261 AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
262 CALayer* rootLayer = engine.viewController.flutterView.layer;
263 EXPECT_TRUE(rootLayer.backgroundColor != nil);
264 if (rootLayer.backgroundColor != nil) {
265 NSColor* actualBackgroundColor =
266 [NSColor colorWithCGColor:rootLayer.backgroundColor];
267 EXPECT_EQ(actualBackgroundColor, [NSColor whiteColor]);
268 }
269 latch.Signal();
270 }));
271
272 // Launch the test entrypoint.
273 EXPECT_TRUE([engine runWithEntrypoint:@"backgroundTest"]);
274 ASSERT_TRUE(engine.running);
275
276 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
277 nibName:nil
278 bundle:nil];
279 [viewController loadView];
280 viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
281 viewController.flutterView.backgroundColor = [NSColor whiteColor];
282
283 latch.Wait();
284}

◆ TEST_F() [484/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
DisplaySizeIsInPhysicalPixel   
)

Definition at line 1218 of file FlutterEngineTest.mm.

1218 {
1219 NSString* fixtures = @(testing::GetFixturesPath());
1220 FlutterDartProject* project = [[FlutterDartProject alloc]
1221 initWithAssetsPath:fixtures
1222 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
1223 project.rootIsolateCreateCallback = FlutterEngineTest::IsolateCreateCallback;
1224 MockableFlutterEngine* engine = [[MockableFlutterEngine alloc] initWithName:@"foobar"
1225 project:project
1226 allowHeadlessExecution:true];
1227 BOOL updated = NO;
1228 auto original_update_displays = engine.embedderAPI.NotifyDisplayUpdate;
1230 NotifyDisplayUpdate, ([&updated, &original_update_displays](
1231 auto engine, auto update_type, auto* displays, auto display_count) {
1232 EXPECT_EQ(display_count, 1UL);
1233 EXPECT_EQ(displays->display_id, 10UL);
1234 EXPECT_EQ(displays->width, 60UL);
1235 EXPECT_EQ(displays->height, 80UL);
1236 EXPECT_EQ(displays->device_pixel_ratio, 2UL);
1237 updated = YES;
1238 return original_update_displays(engine, update_type, displays, display_count);
1239 }));
1240 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1241 EXPECT_TRUE(updated);
1242 [engine shutDownEngine];
1243 engine = nil;
1244}
void(* rootIsolateCreateCallback)(void *_Nullable)

◆ TEST_F() [485/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
FlutterBinaryMessengerDoesNotRetainEngine   
)

Definition at line 629 of file FlutterEngineTest.mm.

629 {
630 __weak FlutterEngine* weakEngine;
631 id<FlutterBinaryMessenger> binaryMessenger = nil;
632 @autoreleasepool {
633 // Create a test engine.
634 NSString* fixtures = @(flutter::testing::GetFixturesPath());
635 FlutterDartProject* project = [[FlutterDartProject alloc]
636 initWithAssetsPath:fixtures
637 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
638 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
639 project:project
640 allowHeadlessExecution:YES];
641 weakEngine = engine;
642 binaryMessenger = engine.binaryMessenger;
643 }
644
645 // Once the engine has been deallocated, verify the weak engine pointer is nil, and thus not
646 // retained by the relay.
647 EXPECT_NE(binaryMessenger, nil);
648 EXPECT_EQ(weakEngine, nil);
649}
NSObject< FlutterBinaryMessenger > * binaryMessenger

◆ TEST_F() [486/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
FlutterTextureRegistryDoesNotReturnEngine   
)

Definition at line 653 of file FlutterEngineTest.mm.

653 {
654 __weak FlutterEngine* weakEngine;
655 id<FlutterTextureRegistry> textureRegistry;
656 @autoreleasepool {
657 // Create a test engine.
658 NSString* fixtures = @(flutter::testing::GetFixturesPath());
659 FlutterDartProject* project = [[FlutterDartProject alloc]
660 initWithAssetsPath:fixtures
661 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
662 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
663 project:project
664 allowHeadlessExecution:YES];
665 id<FlutterPluginRegistrar> registrar = [engine registrarForPlugin:@"MyPlugin"];
666 textureRegistry = registrar.textures;
667 }
668
669 // Once the engine has been deallocated, verify the weak engine pointer is nil, and thus not
670 // retained via the texture registry.
671 EXPECT_NE(textureRegistry, nil);
672 EXPECT_EQ(weakEngine, nil);
673}

◆ TEST_F() [487/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ForwardsPluginDelegateRegistration   
)

Definition at line 1131 of file FlutterEngineTest.mm.

1131 {
1132 id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1133 FakeLifecycleProvider* fakeAppDelegate = [[FakeLifecycleProvider alloc] init];
1134 [NSApplication sharedApplication].delegate = fakeAppDelegate;
1135
1136 FakeAppDelegatePlugin* plugin = [[FakeAppDelegatePlugin alloc] init];
1138
1139 [[engine registrarForPlugin:@"TestPlugin"] addApplicationDelegate:plugin];
1140
1141 EXPECT_TRUE([fakeAppDelegate hasDelegate:plugin]);
1142
1143 [NSApplication sharedApplication].delegate = previousDelegate;
1144}

◆ TEST_F() [488/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HandleAccessibilityEvent   
)

Definition at line 1037 of file FlutterEngineTest.mm.

1037 {
1038 __block BOOL announced = NO;
1039 id engineMock = CreateMockFlutterEngine(nil);
1040
1041 OCMStub([engineMock announceAccessibilityMessage:[OCMArg any]
1042 withPriority:NSAccessibilityPriorityMedium])
1043 .andDo((^(NSInvocation* invocation) {
1044 announced = TRUE;
1045 [invocation retainArguments];
1046 NSString* message;
1047 [invocation getArgument:&message atIndex:2];
1048 EXPECT_EQ(message, @"error message");
1049 }));
1050
1051 NSDictionary<NSString*, id>* annotatedEvent =
1052 @{@"type" : @"announce",
1053 @"data" : @{@"message" : @"error message"}};
1054
1055 [engineMock handleAccessibilityEvent:annotatedEvent];
1056
1057 EXPECT_TRUE(announced);
1058}

◆ TEST_F() [489/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HandleLifecycleStates   
)

Definition at line 1060 of file FlutterEngineTest.mm.

1060 {
1061 __block flutter::AppLifecycleState sentState;
1062 id engineMock = CreateMockFlutterEngine(nil);
1063
1064 // Have to enumerate all the values because OCMStub can't capture
1065 // non-Objective-C object arguments.
1066 OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kDetached])
1067 .andDo((^(NSInvocation* invocation) {
1069 }));
1070 OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kResumed])
1071 .andDo((^(NSInvocation* invocation) {
1073 }));
1074 OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kInactive])
1075 .andDo((^(NSInvocation* invocation) {
1077 }));
1078 OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kHidden])
1079 .andDo((^(NSInvocation* invocation) {
1081 }));
1082 OCMStub([engineMock setApplicationState:flutter::AppLifecycleState::kPaused])
1083 .andDo((^(NSInvocation* invocation) {
1085 }));
1086
1087 __block NSApplicationOcclusionState visibility = NSApplicationOcclusionStateVisible;
1088 id mockApplication = OCMPartialMock([NSApplication sharedApplication]);
1089 OCMStub((NSApplicationOcclusionState)[mockApplication occlusionState])
1090 .andDo(^(NSInvocation* invocation) {
1091 [invocation setReturnValue:&visibility];
1092 });
1093
1094 NSNotification* willBecomeActive =
1095 [[NSNotification alloc] initWithName:NSApplicationWillBecomeActiveNotification
1096 object:nil
1097 userInfo:nil];
1098 NSNotification* willResignActive =
1099 [[NSNotification alloc] initWithName:NSApplicationWillResignActiveNotification
1100 object:nil
1101 userInfo:nil];
1102
1103 NSNotification* didChangeOcclusionState;
1104 didChangeOcclusionState =
1105 [[NSNotification alloc] initWithName:NSApplicationDidChangeOcclusionStateNotification
1106 object:nil
1107 userInfo:nil];
1108
1109 [engineMock handleDidChangeOcclusionState:didChangeOcclusionState];
1110 EXPECT_EQ(sentState, flutter::AppLifecycleState::kInactive);
1111
1112 [engineMock handleWillBecomeActive:willBecomeActive];
1113 EXPECT_EQ(sentState, flutter::AppLifecycleState::kResumed);
1114
1115 [engineMock handleWillResignActive:willResignActive];
1116 EXPECT_EQ(sentState, flutter::AppLifecycleState::kInactive);
1117
1118 visibility = 0;
1119 [engineMock handleDidChangeOcclusionState:didChangeOcclusionState];
1120 EXPECT_EQ(sentState, flutter::AppLifecycleState::kHidden);
1121
1122 [engineMock handleWillBecomeActive:willBecomeActive];
1123 EXPECT_EQ(sentState, flutter::AppLifecycleState::kHidden);
1124
1125 [engineMock handleWillResignActive:willResignActive];
1126 EXPECT_EQ(sentState, flutter::AppLifecycleState::kHidden);
1127
1128 [mockApplication stopMocking];
1129}

◆ TEST_F() [490/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HandlesTerminationRequest   
)

Definition at line 943 of file FlutterEngineTest.mm.

943 {
944 id engineMock = CreateMockFlutterEngine(nil);
945 __block NSString* nextResponse = @"exit";
946 __block BOOL triedToTerminate = NO;
947 FlutterEngineTerminationHandler* terminationHandler =
948 [[FlutterEngineTerminationHandler alloc] initWithEngine:engineMock
949 terminator:^(id sender) {
950 triedToTerminate = TRUE;
951 // Don't actually terminate, of course.
952 }];
953 OCMStub([engineMock terminationHandler]).andReturn(terminationHandler);
954 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
955 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
956 [engineMock binaryMessenger])
957 .andReturn(binaryMessengerMock);
958 OCMStub([engineMock sendOnChannel:@"flutter/platform"
959 message:[OCMArg any]
960 binaryReply:[OCMArg any]])
961 .andDo((^(NSInvocation* invocation) {
962 [invocation retainArguments];
964 NSData* returnedMessage;
965 [invocation getArgument:&callback atIndex:4];
966 if ([nextResponse isEqualToString:@"error"]) {
967 FlutterError* errorResponse = [FlutterError errorWithCode:@"Error"
968 message:@"Failed"
969 details:@"Details"];
970 returnedMessage =
971 [[FlutterJSONMethodCodec sharedInstance] encodeErrorEnvelope:errorResponse];
972 } else {
973 NSDictionary* responseDict = @{@"response" : nextResponse};
974 returnedMessage =
975 [[FlutterJSONMethodCodec sharedInstance] encodeSuccessEnvelope:responseDict];
976 }
977 callback(returnedMessage);
978 }));
979 __block NSString* calledAfterTerminate = @"";
980 FlutterResult appExitResult = ^(id result) {
981 NSDictionary* resultDict = result;
982 calledAfterTerminate = resultDict[@"response"];
983 };
984 FlutterMethodCall* methodExitApplication =
985 [FlutterMethodCall methodCallWithMethodName:@"System.exitApplication"
986 arguments:@{@"type" : @"cancelable"}];
987
988 // Always terminate when the binding isn't ready (which is the default).
989 triedToTerminate = NO;
990 calledAfterTerminate = @"";
991 nextResponse = @"cancel";
992 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
993 EXPECT_STREQ([calledAfterTerminate UTF8String], "");
994 EXPECT_TRUE(triedToTerminate);
995
996 // Once the binding is ready, handle the request.
997 terminationHandler.acceptingRequests = YES;
998 triedToTerminate = NO;
999 calledAfterTerminate = @"";
1000 nextResponse = @"exit";
1001 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1002 EXPECT_STREQ([calledAfterTerminate UTF8String], "exit");
1003 EXPECT_TRUE(triedToTerminate);
1004
1005 triedToTerminate = NO;
1006 calledAfterTerminate = @"";
1007 nextResponse = @"cancel";
1008 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1009 EXPECT_STREQ([calledAfterTerminate UTF8String], "cancel");
1010 EXPECT_FALSE(triedToTerminate);
1011
1012 // Check that it doesn't crash on error.
1013 triedToTerminate = NO;
1014 calledAfterTerminate = @"";
1015 nextResponse = @"error";
1016 [engineMock handleMethodCall:methodExitApplication result:appExitResult];
1017 EXPECT_STREQ([calledAfterTerminate UTF8String], "");
1018 EXPECT_TRUE(triedToTerminate);
1019}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterBinaryReply)(NSData *_Nullable reply)
instancetype errorWithCode:message:details:(NSString *code,[message] NSString *_Nullable message,[details] id _Nullable details)
instancetype sharedInstance()

◆ TEST_F() [491/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HasNonNullExecutableName   
)

Definition at line 148 of file FlutterEngineTest.mm.

148 {
149 FlutterEngine* engine = GetFlutterEngine();
150 std::string executable_name = [[engine executableName] UTF8String];
151 ASSERT_FALSE(executable_name.empty());
152
153 // Block until notified by the Dart test of the value of Platform.executable.
155 AddNativeCallback("NotifyStringValue", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
156 const auto dart_string = tonic::DartConverter<std::string>::FromDart(
158 EXPECT_EQ(executable_name, dart_string);
159 latch.Signal();
160 }));
161
162 // Launch the test entrypoint.
163 EXPECT_TRUE([engine runWithEntrypoint:@"executableNameNotNull"]);
164
165 latch.Wait();
166}

◆ TEST_F() [492/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HasStringsWhenPasteboardEmpty   
)

Definition at line 788 of file FlutterEngineTest.mm.

788 {
789 id engineMock = CreateMockFlutterEngine(nil);
790
791 // Call hasStrings and expect it to be false.
792 __block bool calledAfterClear = false;
793 __block bool valueAfterClear;
794 FlutterResult resultAfterClear = ^(id result) {
795 calledAfterClear = true;
796 NSNumber* valueNumber = [result valueForKey:@"value"];
797 valueAfterClear = [valueNumber boolValue];
798 };
799 FlutterMethodCall* methodCallAfterClear =
800 [FlutterMethodCall methodCallWithMethodName:@"Clipboard.hasStrings" arguments:nil];
801 [engineMock handleMethodCall:methodCallAfterClear result:resultAfterClear];
802 EXPECT_TRUE(calledAfterClear);
803 EXPECT_FALSE(valueAfterClear);
804}

◆ TEST_F() [493/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
HasStringsWhenPasteboardFull   
)

Definition at line 806 of file FlutterEngineTest.mm.

806 {
807 id engineMock = CreateMockFlutterEngine(@"some string");
808
809 // Call hasStrings and expect it to be true.
810 __block bool called = false;
811 __block bool value;
812 FlutterResult result = ^(id result) {
813 called = true;
814 NSNumber* valueNumber = [result valueForKey:@"value"];
815 value = [valueNumber boolValue];
816 };
817 FlutterMethodCall* methodCall =
818 [FlutterMethodCall methodCallWithMethodName:@"Clipboard.hasStrings" arguments:nil];
819 [engineMock handleMethodCall:methodCall result:result];
820 EXPECT_TRUE(called);
821 EXPECT_TRUE(value);
822}

◆ TEST_F() [494/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
IgnoresTerminationRequestIfNotFlutterAppDelegate   
)

Definition at line 1021 of file FlutterEngineTest.mm.

1021 {
1022 id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1023 id<NSApplicationDelegate> plainDelegate = [[PlainAppDelegate alloc] init];
1024 [NSApplication sharedApplication].delegate = plainDelegate;
1025
1026 // Creating the engine shouldn't fail here, even though the delegate isn't a
1027 // FlutterAppDelegate.
1029
1030 // Asking to terminate the app should cancel.
1031 EXPECT_EQ([[[NSApplication sharedApplication] delegate] applicationShouldTerminate:NSApp],
1032 NSTerminateCancel);
1033
1034 [NSApplication sharedApplication].delegate = previousDelegate;
1035}

◆ TEST_F() [495/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ManageControllersIfInitiatedByController   
)

Definition at line 880 of file FlutterEngineTest.mm.

880 {
881 NSString* fixtures = @(flutter::testing::GetFixturesPath());
882 FlutterDartProject* project = [[FlutterDartProject alloc]
883 initWithAssetsPath:fixtures
884 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
885
887 FlutterViewController* viewController1;
888
889 @autoreleasepool {
890 // Create FVC1.
891 viewController1 = [[FlutterViewController alloc] initWithProject:project];
892 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
893
894 engine = viewController1.engine;
896
897 // Create FVC2 based on the same engine.
898 FlutterViewController* viewController2 = [[FlutterViewController alloc] initWithEngine:engine
899 nibName:nil
900 bundle:nil];
901 EXPECT_EQ(engine.viewController, viewController2);
902 }
903 // FVC2 is deallocated but FVC1 is retained.
904
905 EXPECT_EQ(engine.viewController, nil);
906
907 engine.viewController = viewController1;
908 EXPECT_EQ(engine.viewController, viewController1);
909 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
910}

◆ TEST_F() [496/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ManageControllersIfInitiatedByEngine   
)

Definition at line 912 of file FlutterEngineTest.mm.

912 {
913 // Don't create the engine with `CreateMockFlutterEngine`, because it adds
914 // additional references to FlutterViewControllers, which is crucial to this
915 // test case.
916 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"io.flutter"
917 project:nil
918 allowHeadlessExecution:NO];
919 FlutterViewController* viewController1;
920
921 @autoreleasepool {
922 viewController1 = [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil];
923 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
924 EXPECT_EQ(engine.viewController, viewController1);
925
927
928 FlutterViewController* viewController2 = [[FlutterViewController alloc] initWithEngine:engine
929 nibName:nil
930 bundle:nil];
931 EXPECT_EQ(viewController2.viewIdentifier, 0ll);
932 EXPECT_EQ(engine.viewController, viewController2);
933 }
934 // FVC2 is deallocated but FVC1 is retained.
935
936 EXPECT_EQ(engine.viewController, nil);
937
938 engine.viewController = viewController1;
939 EXPECT_EQ(engine.viewController, viewController1);
940 EXPECT_EQ(viewController1.viewIdentifier, 0ll);
941}

◆ TEST_F() [497/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
MessengerCleanupConnectionWorks   
)

Definition at line 731 of file FlutterEngineTest.mm.

731 {
732 FlutterEngine* engine = GetFlutterEngine();
733 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
734
735 NSString* channel = @"_test_";
736 NSData* channel_data = [channel dataUsingEncoding:NSUTF8StringEncoding];
737
738 // Mock SendPlatformMessage so that if a message is sent to
739 // "test/send_message", act as if the framework has sent an empty message to
740 // the channel marked by the `sendOnChannel:message:` call's message.
742 SendPlatformMessage, ([](auto engine_, auto message_) {
743 if (strcmp(message_->channel, "test/send_message") == 0) {
744 // The simplest message that is acceptable to a method channel.
745 std::string message = R"|({"method": "a"})|";
746 std::string channel(reinterpret_cast<const char*>(message_->message),
747 message_->message_size);
748 reinterpret_cast<EmbedderEngine*>(engine_)
749 ->GetShell()
750 .GetPlatformView()
751 ->HandlePlatformMessage(std::make_unique<PlatformMessage>(
752 channel.c_str(), fml::MallocMapping::Copy(message.c_str(), message.length()),
753 fml::RefPtr<PlatformMessageResponse>()));
754 }
755 return kSuccess;
756 }));
757
758 __block int record = 0;
759
760 FlutterMethodChannel* channel1 =
762 binaryMessenger:engine.binaryMessenger
764 [channel1 setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
765 record += 1;
766 }];
767
768 [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
769 EXPECT_EQ(record, 1);
770
771 FlutterMethodChannel* channel2 =
773 binaryMessenger:engine.binaryMessenger
775 [channel2 setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
776 record += 10;
777 }];
778
779 [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
780 EXPECT_EQ(record, 11);
781
782 [channel1 setMethodCallHandler:nil];
783
784 [engine.binaryMessenger sendOnChannel:@"test/send_message" message:channel_data];
785 EXPECT_EQ(record, 21);
786}
void setMethodCallHandler:(FlutterMethodCallHandler _Nullable handler)
instancetype methodChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMethodCodec > *codec)

◆ TEST_F() [498/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
MessengerSend   
)

Definition at line 186 of file FlutterEngineTest.mm.

186 {
187 FlutterEngine* engine = GetFlutterEngine();
188 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
189
190 NSData* test_message = [@"a message" dataUsingEncoding:NSUTF8StringEncoding];
191 bool called = false;
192
194 SendPlatformMessage, ([&called, test_message](auto engine, auto message) {
195 called = true;
196 EXPECT_STREQ(message->channel, "test");
197 EXPECT_EQ(memcmp(message->message, test_message.bytes, message->message_size), 0);
198 return kSuccess;
199 }));
200
201 [engine.binaryMessenger sendOnChannel:@"test" message:test_message];
202 EXPECT_TRUE(called);
203}

◆ TEST_F() [499/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
NativeCallbacks   
)

Definition at line 486 of file FlutterEngineTest.mm.

486 {
488 bool latch_called = false;
489 AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
490 latch_called = true;
491 latch.Signal();
492 }));
493
494 FlutterEngine* engine = GetFlutterEngine();
495 EXPECT_TRUE([engine runWithEntrypoint:@"nativeCallback"]);
496 ASSERT_TRUE(engine.running);
497
498 latch.Wait();
499 ASSERT_TRUE(latch_called);
500}

◆ TEST_F() [500/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
NotificationsUpdateDisplays   
)

Definition at line 1188 of file FlutterEngineTest.mm.

1188 {
1189 BOOL updated = NO;
1190 FlutterEngine* engine = GetFlutterEngine();
1191 auto original_set_viewport_metrics = engine.embedderAPI.SendWindowMetricsEvent;
1193 SendWindowMetricsEvent,
1194 ([&updated, &original_set_viewport_metrics](auto engine, auto* window_metrics) {
1195 updated = YES;
1196 return original_set_viewport_metrics(engine, window_metrics);
1197 }));
1198
1199 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1200
1201 updated = NO;
1202 [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1203 object:nil];
1204 // No VC.
1205 EXPECT_FALSE(updated);
1206
1207 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
1208 nibName:nil
1209 bundle:nil];
1210 [viewController loadView];
1211 viewController.flutterView.frame = CGRectMake(0, 0, 800, 600);
1212
1213 [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidChangeScreenNotification
1214 object:nil];
1215 EXPECT_TRUE(updated);
1216}

◆ TEST_F() [501/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ProducesAccessibilityTreeWhenAddingViews   
)

Definition at line 461 of file FlutterEngineTest.mm.

461 {
462 FlutterEngine* engine = GetFlutterEngine();
463 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
464
465 // Enable the semantics without attaching a view controller.
466 bool enabled_called = false;
468 MOCK_ENGINE_PROC(UpdateSemanticsEnabled, ([&enabled_called](auto engine, bool enabled) {
469 enabled_called = enabled;
470 return kSuccess;
471 }));
473 EXPECT_TRUE(enabled_called);
474
475 EXPECT_EQ(engine.viewController, nil);
476
477 // Assign the view controller after enabling semantics
478 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
479 nibName:nil
480 bundle:nil];
482
483 EXPECT_NE(viewController.accessibilityBridge.lock(), nullptr);
484}

◆ TEST_F() [502/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
PublishedValueNilForUnknownPlugin   
)

Definition at line 675 of file FlutterEngineTest.mm.

675 {
676 NSString* fixtures = @(flutter::testing::GetFixturesPath());
677 FlutterDartProject* project = [[FlutterDartProject alloc]
678 initWithAssetsPath:fixtures
679 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
680 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
681 project:project
682 allowHeadlessExecution:YES];
683
684 EXPECT_EQ([engine valuePublishedByPlugin:@"NoSuchPlugin"], nil);
685}

◆ TEST_F() [503/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
PublishedValueNSNullIfNoPublishedValue   
)

Definition at line 687 of file FlutterEngineTest.mm.

687 {
688 NSString* fixtures = @(flutter::testing::GetFixturesPath());
689 FlutterDartProject* project = [[FlutterDartProject alloc]
690 initWithAssetsPath:fixtures
691 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
692 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
693 project:project
694 allowHeadlessExecution:YES];
695 NSString* pluginName = @"MyPlugin";
696 // Request the registarar to register the plugin as existing.
697 [engine registrarForPlugin:pluginName];
698
699 // The documented behavior is that a plugin that exists but hasn't published
700 // anything returns NSNull, rather than nil, as on iOS.
701 EXPECT_EQ([engine valuePublishedByPlugin:pluginName], [NSNull null]);
702}

◆ TEST_F() [504/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
PublishedValueReturnsLastPublished   
)

Definition at line 704 of file FlutterEngineTest.mm.

704 {
705 NSString* fixtures = @(flutter::testing::GetFixturesPath());
706 FlutterDartProject* project = [[FlutterDartProject alloc]
707 initWithAssetsPath:fixtures
708 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
709 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test"
710 project:project
711 allowHeadlessExecution:YES];
712 NSString* pluginName = @"MyPlugin";
713 id<FlutterPluginRegistrar> registrar = [engine registrarForPlugin:pluginName];
714
715 NSString* firstValue = @"A published value";
716 NSArray* secondValue = @[ @"A different published value" ];
717
718 [registrar publish:firstValue];
719 EXPECT_EQ([engine valuePublishedByPlugin:pluginName], firstValue);
720
721 [registrar publish:secondValue];
722 EXPECT_EQ([engine valuePublishedByPlugin:pluginName], secondValue);
723}

◆ TEST_F() [505/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ResponseAfterEngineDied   
)

Definition at line 824 of file FlutterEngineTest.mm.

824 {
825 FlutterEngine* engine = GetFlutterEngine();
827 initWithName:@"foo"
828 binaryMessenger:engine.binaryMessenger
830 __block BOOL didCallCallback = NO;
831 [channel setMessageHandler:^(id message, FlutterReply callback) {
832 ShutDownEngine();
833 callback(nil);
834 didCallCallback = YES;
835 }];
836 EXPECT_TRUE([engine runWithEntrypoint:@"sendFooMessage"]);
837 engine = nil;
838
839 while (!didCallCallback) {
840 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
841 }
842}
void setMessageHandler:(FlutterMessageHandler _Nullable handler)

◆ TEST_F() [506/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ResponseFromBackgroundThread   
)

Definition at line 844 of file FlutterEngineTest.mm.

844 {
845 FlutterEngine* engine = GetFlutterEngine();
847 initWithName:@"foo"
848 binaryMessenger:engine.binaryMessenger
850 __block BOOL didCallCallback = NO;
851 [channel setMessageHandler:^(id message, FlutterReply callback) {
852 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
853 callback(nil);
854 dispatch_async(dispatch_get_main_queue(), ^{
855 didCallCallback = YES;
856 });
857 });
858 }];
859 EXPECT_TRUE([engine runWithEntrypoint:@"sendFooMessage"]);
860
861 while (!didCallCallback) {
862 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
863 }
864}

◆ TEST_F() [507/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
RunWithEntrypointUpdatesDisplayConfig   
)

Definition at line 1167 of file FlutterEngineTest.mm.

1167 {
1168 BOOL updated = NO;
1169 FlutterEngine* engine = GetFlutterEngine();
1170 auto original_update_displays = engine.embedderAPI.NotifyDisplayUpdate;
1172 NotifyDisplayUpdate, ([&updated, &original_update_displays](
1173 auto engine, auto update_type, auto* displays, auto display_count) {
1174 updated = YES;
1175 return original_update_displays(engine, update_type, displays, display_count);
1176 }));
1177
1178 EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
1179 EXPECT_TRUE(updated);
1180
1181 updated = NO;
1182 [[NSNotificationCenter defaultCenter]
1183 postNotificationName:NSApplicationDidChangeScreenParametersNotification
1184 object:nil];
1185 EXPECT_TRUE(updated);
1186}

◆ TEST_F() [508/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
Switches   
)

Definition at line 169 of file FlutterEngineTest.mm.

169 {
170 setenv("FLUTTER_ENGINE_SWITCHES", "2", 1);
171 setenv("FLUTTER_ENGINE_SWITCH_1", "abc", 1);
172 setenv("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"", 1);
173
174 FlutterEngine* engine = GetFlutterEngine();
175 std::vector<std::string> switches = engine.switches;
176 ASSERT_EQ(switches.size(), 2UL);
177 EXPECT_EQ(switches[0], "--abc");
178 EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
179
180 unsetenv("FLUTTER_ENGINE_SWITCHES");
181 unsetenv("FLUTTER_ENGINE_SWITCH_1");
182 unsetenv("FLUTTER_ENGINE_SWITCH_2");
183}
std::vector< std::string > switches()

◆ TEST_F() [509/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
ThreadSynchronizerNotBlockingRasterThreadAfterShutdown   
)

Definition at line 866 of file FlutterEngineTest.mm.

866 {
867 FlutterThreadSynchronizer* threadSynchronizer = [[FlutterThreadSynchronizer alloc] init];
868 [threadSynchronizer shutdown];
869
870 std::thread rasterThread([&threadSynchronizer] {
871 [threadSynchronizer performCommitForView:kImplicitViewId
872 size:CGSizeMake(100, 100)
873 notify:^{
874 }];
875 });
876
877 rasterThread.join();
878}
void performCommitForView:size:notify:(FlutterViewIdentifier viewIdentifier,[size] CGSize size,[notify] nonnull dispatch_block_t notify)

◆ TEST_F() [510/876]

flutter::testing::TEST_F ( FlutterEngineTest  ,
UnregistersPluginsOnEngineDestruction   
)

Definition at line 1146 of file FlutterEngineTest.mm.

1146 {
1147 id<NSApplicationDelegate> previousDelegate = [[NSApplication sharedApplication] delegate];
1148 FakeLifecycleProvider* fakeAppDelegate = [[FakeLifecycleProvider alloc] init];
1149 [NSApplication sharedApplication].delegate = fakeAppDelegate;
1150
1151 FakeAppDelegatePlugin* plugin = [[FakeAppDelegatePlugin alloc] init];
1152
1153 @autoreleasepool {
1154 FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
1155
1156 [[engine registrarForPlugin:@"TestPlugin"] addApplicationDelegate:plugin];
1157 EXPECT_TRUE([fakeAppDelegate hasDelegate:plugin]);
1158 }
1159
1160 // When the engine is released, it should unregister any plugins it had
1161 // registered on its behalf.
1162 EXPECT_FALSE([fakeAppDelegate hasDelegate:plugin]);
1163
1164 [NSApplication sharedApplication].delegate = previousDelegate;
1165}

◆ TEST_F() [511/876]

flutter::testing::TEST_F ( FlutterMenuPluginTest  ,
TestSetMenu   
)

Definition at line 84 of file FlutterMenuPluginTest.mm.

84 {
85 // Build a simulation of the default main menu.
86 NSMenu* mainMenu = [[NSMenu alloc] init];
87 NSMenuItem* appNameMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"APP_NAME", nil)
88 action:nil
89 keyEquivalent:@""];
90 NSMenu* submenu =
91 [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Prexisting APP_NAME menu", nil)];
92 [submenu addItem:[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About APP_NAME", nil)
93 action:nil
94 keyEquivalent:@""]];
95 appNameMenu.submenu = submenu;
96 [mainMenu addItem:appNameMenu];
97 [NSApp setMainMenu:mainMenu];
98
99 FakePluginRegistrar* registrar = [[FakePluginRegistrar alloc] init];
101 FlutterMenuPlugin* plugin = [registrar plugin];
102
103 NSDictionary* testMenus = @{
104 @"0" : @[
105 @{
106 @"id" : [NSNumber numberWithInt:1],
107 @"label" : @"APP_NAME",
108 @"enabled" : @(YES),
109 @"children" : @[
110 @{
111 @"id" : [NSNumber numberWithInt:3],
112 @"platformProvidedMenu" : @(static_cast<int>(flutter::PlatformProvidedMenu::kQuit)),
113 @"enabled" : @(YES),
114 },
115 @{
116 @"id" : [NSNumber numberWithInt:2],
117 @"label" : @"APP_NAME Info",
118 @"enabled" : @(YES),
119 @"shortcutTrigger" : [NSNumber numberWithUnsignedLongLong:0x61],
120 @"shortcutModifiers" : [NSNumber numberWithUnsignedInt:0],
121 },
122 ],
123 },
124 @{
125 @"id" : [NSNumber numberWithInt:4],
126 @"label" : @"Help for APP_NAME",
127 @"enabled" : @(YES),
128 @"children" : @[
129 @{
130 @"id" : [NSNumber numberWithInt:5],
131 @"label" : @"Help me!",
132 @"enabled" : @(YES),
133 },
134 @{
135 @"id" : [NSNumber numberWithInt:6],
136 @"label" : @"",
137 @"enabled" : @(NO),
138 @"isDivider" : @(YES),
139 },
140 @{
141 @"id" : [NSNumber numberWithInt:7],
142 @"label" : @"Search help",
143 @"enabled" : @(NO),
144 },
145 ],
146 },
147 ],
148 };
149
150 __block id available = @NO;
151 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"Menu.isPluginAvailable"
152 arguments:nil]
153 result:^(id _Nullable result) {
154 available = result;
155 }];
156
157 EXPECT_TRUE(available);
158
160 arguments:testMenus]
161 result:^(id _Nullable result){
162 }];
163
164 EXPECT_EQ([NSApp.mainMenu numberOfItems], 2);
165 NSMenuItem* firstMenu = [NSApp.mainMenu itemAtIndex:0];
166 EXPECT_TRUE([[firstMenu title] isEqualToString:@"flutter_desktop_darwin_unittests"]);
167 EXPECT_EQ([firstMenu tag], 1);
168 EXPECT_TRUE([firstMenu isEnabled]);
169 EXPECT_FALSE([firstMenu isHidden]);
170 EXPECT_TRUE([[firstMenu keyEquivalent] isEqualToString:@"\0"]);
171
172 EXPECT_EQ([[firstMenu submenu] numberOfItems], 1);
173 NSMenuItem* firstItem = [[firstMenu submenu] itemAtIndex:0];
174 EXPECT_TRUE([[firstItem title] isEqualToString:@"flutter_desktop_darwin_unittests Info"]);
175 EXPECT_TRUE([[firstItem keyEquivalent] isEqualToString:@"a"]);
176 EXPECT_TRUE([firstItem isEnabled]);
177 EXPECT_FALSE([firstItem isHidden]);
179 [NSStringFromSelector([firstItem action]) isEqualToString:@"flutterMenuItemSelected:"]);
180 EXPECT_EQ([firstItem tag], 2);
181
182 NSMenuItem* secondMenu = [NSApp.mainMenu itemAtIndex:1];
183 EXPECT_TRUE([[secondMenu title] isEqualToString:@"Help for flutter_desktop_darwin_unittests"]);
184 EXPECT_EQ([secondMenu tag], 4);
185 EXPECT_TRUE([secondMenu isEnabled]);
186 EXPECT_FALSE([secondMenu isHidden]);
187
188 EXPECT_EQ([[secondMenu submenu] numberOfItems], 3);
189 NSMenuItem* secondMenuFirst = [[secondMenu submenu] itemAtIndex:0];
190 EXPECT_TRUE([[secondMenuFirst title] isEqualToString:@"Help me!"]);
191 EXPECT_TRUE([secondMenuFirst isEnabled]);
192 EXPECT_FALSE([secondMenuFirst isHidden]);
194 [NSStringFromSelector([secondMenuFirst action]) isEqualToString:@"flutterMenuItemSelected:"]);
195 EXPECT_EQ([secondMenuFirst tag], 5);
196
197 NSMenuItem* secondMenuDivider = [[secondMenu submenu] itemAtIndex:1];
198 EXPECT_TRUE([[secondMenuDivider title] isEqualToString:@""]);
199 EXPECT_TRUE([[secondMenuDivider keyEquivalent] isEqualToString:@""]);
200 EXPECT_FALSE([secondMenuDivider isEnabled]);
201 EXPECT_FALSE([secondMenuDivider isHidden]);
202 EXPECT_EQ([secondMenuDivider action], nil);
203 EXPECT_EQ([secondMenuDivider tag], 0);
204
205 NSMenuItem* secondMenuLast = [[secondMenu submenu] itemAtIndex:2];
206 EXPECT_TRUE([[secondMenuLast title] isEqualToString:@"Search help"]);
207 EXPECT_FALSE([secondMenuLast isEnabled]);
208 EXPECT_FALSE([secondMenuLast isHidden]);
210 [NSStringFromSelector([secondMenuLast action]) isEqualToString:@"flutterMenuItemSelected:"]);
211 EXPECT_EQ([secondMenuLast tag], 7);
212}
id< FlutterPlugin > plugin
void registerWithRegistrar:(nonnull id< FlutterPluginRegistrar > registrar)
void handleMethodCall:result:(FlutterMethodCall *call, [result] FlutterResult result)

◆ TEST_F() [512/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestCtrlTabKeyEventIsPropagated   
)

Definition at line 261 of file FlutterViewControllerTest.mm.

261 {
262 id mockEngine = GetMockEngine();
263 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testCtrlTabKeyEventIsPropagated:mockEngine]);
264}

◆ TEST_F() [513/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestFlagsChangedEventsArePropagatedIfNotHandled   
)

Definition at line 272 of file FlutterViewControllerTest.mm.

272 {
273 id mockEngine = GetMockEngine();
274 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc]
275 testFlagsChangedEventsArePropagatedIfNotHandled:mockEngine]);
276}

◆ TEST_F() [514/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
testFlutterViewIsConfigured   
)

Definition at line 314 of file FlutterViewControllerTest.mm.

314 {
315 id mockEngine = GetMockEngine();
316 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testFlutterViewIsConfigured:mockEngine]);
317}

◆ TEST_F() [515/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyboardIsRestartedOnEngineRestart   
)

Definition at line 278 of file FlutterViewControllerTest.mm.

278 {
279 id mockEngine = GetMockEngine();
280 ASSERT_TRUE(
281 [[FlutterViewControllerTestObjC alloc] testKeyboardIsRestartedOnEngineRestart:mockEngine]);
282}

◆ TEST_F() [516/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEquivalentIsPassedToTextInputPlugin   
)

Definition at line 266 of file FlutterViewControllerTest.mm.

266 {
267 id mockEngine = GetMockEngine();
268 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc]
269 testKeyEquivalentIsPassedToTextInputPlugin:mockEngine]);
270}

◆ TEST_F() [517/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEventsAreNotPropagatedIfHandled   
)

Definition at line 255 of file FlutterViewControllerTest.mm.

255 {
256 id mockEngine = GetMockEngine();
257 ASSERT_TRUE(
258 [[FlutterViewControllerTestObjC alloc] testKeyEventsAreNotPropagatedIfHandled:mockEngine]);
259}

◆ TEST_F() [518/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEventsArePropagatedIfNotHandled   
)

Definition at line 249 of file FlutterViewControllerTest.mm.

249 {
250 id mockEngine = GetMockEngine();
251 ASSERT_TRUE(
252 [[FlutterViewControllerTestObjC alloc] testKeyEventsArePropagatedIfNotHandled:mockEngine]);
253}

◆ TEST_F() [519/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestKeyEventsAreSentToFramework   
)

Definition at line 244 of file FlutterViewControllerTest.mm.

244 {
245 id mockEngine = GetMockEngine();
246 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testKeyEventsAreSentToFramework:mockEngine]);
247}

◆ TEST_F() [520/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestModifierKeysAreSynthesizedOnMouseMove   
)

Definition at line 302 of file FlutterViewControllerTest.mm.

302 {
303 id mockEngine = GetMockEngine();
304 ASSERT_TRUE(
305 [[FlutterViewControllerTestObjC alloc] testModifierKeysAreSynthesizedOnMouseMove:mockEngine]);
306}

◆ TEST_F() [521/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestmouseAndGestureEventsAreHandledSeparately   
)

Definition at line 290 of file FlutterViewControllerTest.mm.

290 {
291 id mockEngine = GetMockEngine();
292 ASSERT_TRUE(
293 [[FlutterViewControllerTestObjC alloc] mouseAndGestureEventsAreHandledSeparately:mockEngine]);
294}

◆ TEST_F() [522/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestMouseDownUpEventsSentToNextResponder   
)

Definition at line 296 of file FlutterViewControllerTest.mm.

296 {
297 id mockEngine = GetMockEngine();
298 ASSERT_TRUE(
299 [[FlutterViewControllerTestObjC alloc] testMouseDownUpEventsSentToNextResponder:mockEngine]);
300}

◆ TEST_F() [523/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
TestTrackpadGesturesAreSentToFramework   
)

Definition at line 284 of file FlutterViewControllerTest.mm.

284 {
285 id mockEngine = GetMockEngine();
286 ASSERT_TRUE(
287 [[FlutterViewControllerTestObjC alloc] testTrackpadGesturesAreSentToFramework:mockEngine]);
288}

◆ TEST_F() [524/876]

flutter::testing::TEST_F ( FlutterViewControllerMockEngineTest  ,
testViewWillAppearCalledMultipleTimes   
)

Definition at line 308 of file FlutterViewControllerTest.mm.

308 {
309 id mockEngine = GetMockEngine();
310 ASSERT_TRUE(
311 [[FlutterViewControllerTestObjC alloc] testViewWillAppearCalledMultipleTimes:mockEngine]);
312}

◆ TEST_F() [525/876]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
CanSetMouseTrackingModeBeforeViewLoaded   
)

Definition at line 234 of file FlutterViewControllerTest.mm.

234 {
235 NSString* fixtures = @(testing::GetFixturesPath());
236 FlutterDartProject* project = [[FlutterDartProject alloc]
237 initWithAssetsPath:fixtures
238 ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
239 FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project];
240 viewController.mouseTrackingMode = kFlutterMouseTrackingModeInActiveApp;
241 ASSERT_EQ(viewController.mouseTrackingMode, kFlutterMouseTrackingModeInActiveApp);
242}
FlutterMouseTrackingMode mouseTrackingMode

◆ TEST_F() [526/876]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
FlutterViewAcceptsFirstMouse   
)

Definition at line 203 of file FlutterViewControllerTest.mm.

203 {
204 FlutterViewController* viewControllerMock = CreateMockViewController();
205 [viewControllerMock loadView];
206 EXPECT_EQ([viewControllerMock.flutterView acceptsFirstMouse:nil], YES);
207}

◆ TEST_F() [527/876]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
HasViewThatHidesOtherViewsInAccessibility   
)

Definition at line 182 of file FlutterViewControllerTest.mm.

182 {
183 FlutterViewController* viewControllerMock = CreateMockViewController();
184
185 [viewControllerMock loadView];
186 auto subViews = [viewControllerMock.view subviews];
187
188 EXPECT_EQ([subViews count], 1u);
189 EXPECT_EQ(subViews[0], viewControllerMock.flutterView);
190
191 NSTextField* textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 1, 1)];
192 [viewControllerMock.view addSubview:textField];
193
194 subViews = [viewControllerMock.view subviews];
195 EXPECT_EQ([subViews count], 2u);
196
197 auto accessibilityChildren = viewControllerMock.view.accessibilityChildren;
198 // The accessibilityChildren should only contains the FlutterView.
199 EXPECT_EQ([accessibilityChildren count], 1u);
200 EXPECT_EQ(accessibilityChildren[0], viewControllerMock.flutterView);
201}

◆ TEST_F() [528/876]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
ReparentsPluginWhenAccessibilityDisabled   
)

Definition at line 209 of file FlutterViewControllerTest.mm.

209 {
210 FlutterEngine* engine = CreateTestEngine();
211 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
212 nibName:nil
213 bundle:nil];
214 [viewController loadView];
215 // Creates a NSWindow so that sub view can be first responder.
216 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
217 styleMask:NSBorderlessWindowMask
218 backing:NSBackingStoreBuffered
219 defer:NO];
220 window.contentView = viewController.view;
221 NSView* dummyView = [[NSView alloc] initWithFrame:CGRectZero];
222 [viewController.view addSubview:dummyView];
223 // Attaches FlutterTextInputPlugin to the view;
224 [dummyView addSubview:viewController.textInputPlugin];
225 // Makes sure the textInputPlugin can be the first responder.
226 EXPECT_TRUE([window makeFirstResponder:viewController.textInputPlugin]);
227 EXPECT_EQ([window firstResponder], viewController.textInputPlugin);
228 EXPECT_FALSE(viewController.textInputPlugin.superview == viewController.view);
229 [viewController onAccessibilityStatusChanged:NO];
230 // FlutterView becomes child of view controller
232}

◆ TEST_F() [529/876]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testLookupKeyAssets   
)

Definition at line 319 of file FlutterViewControllerTest.mm.

319 {
320 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssets]);
321}

◆ TEST_F() [530/876]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testLookupKeyAssetsWithPackage   
)

Definition at line 323 of file FlutterViewControllerTest.mm.

323 {
324 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssetsWithPackage]);
325}

◆ TEST_F() [531/876]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testViewControllerIsReleased   
)

Definition at line 327 of file FlutterViewControllerTest.mm.

327 {
328 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testViewControllerIsReleased]);
329}

◆ TEST_F() [532/876]

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

Definition at line 657 of file flutter_windows_engine_unittests.cc.

657 {
658 auto& context = GetContext();
659 WindowsConfigBuilder builder{context};
660 builder.SetDartEntrypoint("sendAccessibilityAnnouncement");
661
662 bool done = false;
663 auto native_entry =
665 context.AddNativeFunction("Signal", native_entry);
666
667 EnginePtr engine{builder.RunHeadless()};
668 ASSERT_NE(engine, nullptr);
669
670 ui::AXPlatformNodeDelegateBase parent_delegate;
671 AlertPlatformNodeDelegate delegate{parent_delegate};
672
673 auto window_binding_handler =
674 std::make_unique<NiceMock<MockWindowBindingHandler>>();
675 EXPECT_CALL(*window_binding_handler, GetAlertDelegate)
676 .WillOnce(Return(&delegate));
677
678 auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
679 MockFlutterWindowsView view{windows_engine,
680 std::move(window_binding_handler)};
681 EngineModifier modifier{windows_engine};
682 modifier.SetImplicitView(&view);
683
684 windows_engine->UpdateSemanticsEnabled(true);
685
686 EXPECT_CALL(view, NotifyWinEventWrapper).Times(1);
687
688 // Rely on timeout mechanism in CI.
689 while (!done) {
690 windows_engine->task_runner()->ProcessTasks();
691 }
692}
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
Definition DM.cpp:263

◆ TEST_F() [533/876]

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

Definition at line 695 of file flutter_windows_engine_unittests.cc.

695 {
696 auto& context = GetContext();
697 WindowsConfigBuilder builder{context};
698 builder.SetDartEntrypoint("sendAccessibilityAnnouncement");
699
700 bool done = false;
701 auto native_entry =
703 context.AddNativeFunction("Signal", native_entry);
704
705 EnginePtr engine{builder.RunHeadless()};
706 ASSERT_NE(engine, nullptr);
707
708 auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
709 windows_engine->UpdateSemanticsEnabled(true);
710
711 // Rely on timeout mechanism in CI.
712 while (!done) {
713 windows_engine->task_runner()->ProcessTasks();
714 }
715}

◆ TEST_F() [534/876]

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

Definition at line 719 of file flutter_windows_engine_unittests.cc.

719 {
720 fml::testing::LogCapture log_capture;
721
722 auto& context = GetContext();
723 WindowsConfigBuilder builder{context};
724 builder.SetDartEntrypoint("sendAccessibilityTooltipEvent");
725
726 bool done = false;
727 auto native_entry =
729 context.AddNativeFunction("Signal", native_entry);
730
731 ViewControllerPtr controller{builder.Run()};
732 ASSERT_NE(controller, nullptr);
733
734 auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
735 auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine);
736 windows_engine->UpdateSemanticsEnabled(true);
737
738 // Rely on timeout mechanism in CI.
739 while (!done) {
740 windows_engine->task_runner()->ProcessTasks();
741 }
742
743 // Verify no error was logged.
744 // Regression test for:
745 // https://github.com/flutter/flutter/issues/144274
746 EXPECT_EQ(log_capture.str().find("tooltip"), std::string::npos);
747}
std::string str() const
Definition logging.cc:122
FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(FlutterDesktopViewControllerRef controller)

◆ TEST_F() [535/876]

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

Definition at line 510 of file flutter_windows_engine_unittests.cc.

510 {
511 FlutterWindowsEngineBuilder builder{GetContext()};
512 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
513 EngineModifier modifier(engine.get());
514
515 MockEmbedderApiForKeyboard(modifier,
516 std::make_shared<MockKeyResponseController>());
517
518 engine->Run();
519
520 // Verify that destruction handlers don't overwrite each other.
521 int result1 = 0;
522 int result2 = 0;
523 engine->AddPluginRegistrarDestructionCallback(
525 auto result = reinterpret_cast<int*>(ref);
526 *result = 1;
527 },
528 reinterpret_cast<FlutterDesktopPluginRegistrarRef>(&result1));
529 engine->AddPluginRegistrarDestructionCallback(
531 auto result = reinterpret_cast<int*>(ref);
532 *result = 2;
533 },
534 reinterpret_cast<FlutterDesktopPluginRegistrarRef>(&result2));
535
536 engine->Stop();
537 EXPECT_EQ(result1, 1);
538 EXPECT_EQ(result2, 2);
539}

◆ TEST_F() [536/876]

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

Definition at line 1268 of file flutter_windows_engine_unittests.cc.

1268 {
1269 FlutterWindowsEngineBuilder builder{GetContext()};
1270 auto engine = builder.Build();
1271
1272 EngineModifier modifier{engine.get()};
1273
1274 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1275 modifier.embedder_api().AddView = MOCK_ENGINE_PROC(
1276 AddView,
1278 const FlutterAddViewInfo* info) { return kInternalInconsistency; });
1279
1280 ASSERT_TRUE(engine->Run());
1281
1282 // Create the first view. This is the implicit view and isn't added to the
1283 // engine.
1284 auto implicit_window = std::make_unique<NiceMock<MockWindowBindingHandler>>();
1285
1286 std::unique_ptr<FlutterWindowsView> implicit_view =
1287 engine->CreateView(std::move(implicit_window));
1288
1289 EXPECT_TRUE(implicit_view);
1290
1291 // Create a second view. The embedder attempts to add it to the engine.
1292 auto second_window = std::make_unique<NiceMock<MockWindowBindingHandler>>();
1293
1294 EXPECT_DEBUG_DEATH(engine->CreateView(std::move(second_window)),
1295 "FlutterEngineAddView returned an unexpected result");
1296}
@ kInternalInconsistency
Definition embedder.h:76

◆ TEST_F() [537/876]

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

Definition at line 992 of file flutter_windows_engine_unittests.cc.

992 {
993 FlutterWindowsEngineBuilder builder{GetContext()};
994
995 auto engine = builder.Build();
996 auto window_binding_handler =
997 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
998 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
999
1000 EngineModifier modifier(engine.get());
1001 modifier.SetImplicitView(&view);
1002 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1003 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1004 EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(false));
1005 modifier.SetLifecycleManager(std::move(handler));
1006 engine->lifecycle_manager()->BeginProcessingExit();
1007
1008 engine->lifecycle_manager()->ExternalWindowMessage(0, WM_CLOSE, 0, 0);
1009}

◆ TEST_F() [538/876]

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

Definition at line 1011 of file flutter_windows_engine_unittests.cc.

1011 {
1012 FlutterWindowsEngineBuilder builder{GetContext()};
1013
1014 auto engine = builder.Build();
1015 auto window_binding_handler =
1016 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1017 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1018
1019 EngineModifier modifier(engine.get());
1020 modifier.SetImplicitView(&view);
1021 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1022 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1023 EXPECT_CALL(*handler, SetLifecycleState(AppLifecycleState::kResumed))
1024 .Times(1);
1025 modifier.SetLifecycleManager(std::move(handler));
1026 engine->Run();
1027}

◆ TEST_F() [539/876]

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

Definition at line 1217 of file flutter_windows_engine_unittests.cc.

1217 {
1218 FlutterWindowsEngineBuilder builder{GetContext()};
1219 builder.SetDartEntrypoint("enableLifecycleToFrom");
1220
1221 auto engine = builder.Build();
1222 auto window_binding_handler =
1223 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1224 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1225
1226 EngineModifier modifier(engine.get());
1227 modifier.SetImplicitView(&view);
1228 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1229
1230 bool lifecycle_began = false;
1231 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1232 EXPECT_CALL(*handler, SetLifecycleState).Times(1);
1233 handler->begin_processing_callback = [&]() { lifecycle_began = true; };
1234 modifier.SetLifecycleManager(std::move(handler));
1235
1236 engine->Run();
1237
1238 while (!lifecycle_began) {
1239 engine->task_runner()->ProcessTasks();
1240 }
1241}

◆ TEST_F() [540/876]

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

Definition at line 167 of file flutter_windows_engine_unittests.cc.

167 {
168 FlutterWindowsEngineBuilder builder{GetContext()};
169 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
170 EngineModifier modifier(engine.get());
171 bool on_vsync_called = false;
172
173 modifier.embedder_api().GetCurrentTime =
174 MOCK_ENGINE_PROC(GetCurrentTime, ([]() -> uint64_t { return 1; }));
175 modifier.embedder_api().OnVsync = MOCK_ENGINE_PROC(
176 OnVsync,
177 ([&on_vsync_called, engine_instance = engine.get()](
178 FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton,
179 uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos) {
180 EXPECT_EQ(baton, 1);
181 EXPECT_EQ(frame_start_time_nanos, 16600000);
182 EXPECT_EQ(frame_target_time_nanos, 33200000);
183 on_vsync_called = true;
184 return kSuccess;
185 }));
186 modifier.SetStartTime(0);
187 modifier.SetFrameInterval(16600000);
188
189 engine->OnVsync(1);
190
191 EXPECT_TRUE(on_vsync_called);
192}
#define GetCurrentTime()

◆ TEST_F() [541/876]

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

Definition at line 464 of file flutter_windows_engine_unittests.cc.

464 {
465 FlutterWindowsEngineBuilder builder{GetContext()};
466 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
467 EngineModifier modifier(engine.get());
468
469 bool called = false;
470 std::string message = "Hello";
471 modifier.embedder_api().DispatchSemanticsAction = MOCK_ENGINE_PROC(
472 DispatchSemanticsAction,
473 ([&called, &message](auto engine, auto target, auto action, auto data,
474 auto data_length) {
475 called = true;
476 EXPECT_EQ(target, 42);
478 EXPECT_EQ(memcmp(data, message.c_str(), message.size()), 0);
479 EXPECT_EQ(data_length, message.size());
480 return kSuccess;
481 }));
482
483 auto data = fml::MallocMapping::Copy(message.c_str(), message.size());
484 engine->DispatchSemanticsAction(42, kFlutterSemanticsActionDismiss,
485 std::move(data));
486 EXPECT_TRUE(called);
487}
static MallocMapping Copy(const T *begin, const T *end)
Definition mapping.h:162
@ kFlutterSemanticsActionDismiss
A request that the node should be dismissed.
Definition embedder.h:158

◆ TEST_F() [542/876]

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

Definition at line 972 of file flutter_windows_engine_unittests.cc.

972 {
973 FlutterWindowsEngineBuilder builder{GetContext()};
974
975 auto engine = builder.Build();
976 auto window_binding_handler =
977 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
978 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
979
980 EngineModifier modifier(engine.get());
981 modifier.SetImplicitView(&view);
982 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
983 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
984 EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(false));
985 modifier.SetLifecycleManager(std::move(handler));
986 engine->lifecycle_manager()->BeginProcessingExit();
987
988 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
989 0);
990}

◆ TEST_F() [543/876]

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

Definition at line 1116 of file flutter_windows_engine_unittests.cc.

1116 {
1117 FlutterWindowsEngineBuilder builder{GetContext()};
1118 builder.SetDartEntrypoint("enableLifecycleTest");
1119 bool finished = false;
1120
1121 auto engine = builder.Build();
1122 auto window_binding_handler =
1123 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1124 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1125
1126 EngineModifier modifier(engine.get());
1127 modifier.SetImplicitView(&view);
1128 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1129 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1130 EXPECT_CALL(*handler, SetLifecycleState)
1131 .WillRepeatedly([handler_ptr = handler.get()](AppLifecycleState state) {
1132 handler_ptr->WindowsLifecycleManager::SetLifecycleState(state);
1133 });
1134 modifier.SetLifecycleManager(std::move(handler));
1135
1136 auto binary_messenger =
1137 std::make_unique<BinaryMessengerImpl>(engine->messenger());
1138 // Mark the test only as completed on receiving an inactive state message.
1139 binary_messenger->SetMessageHandler(
1140 "flutter/unittest", [&finished](const uint8_t* message,
1141 size_t message_size, BinaryReply reply) {
1142 std::string contents(message, message + message_size);
1143 EXPECT_NE(contents.find("AppLifecycleState.inactive"),
1144 std::string::npos);
1145 finished = true;
1146 char response[] = "";
1147 reply(reinterpret_cast<uint8_t*>(response), 0);
1148 });
1149
1150 engine->Run();
1151
1152 // Test that setting the state before enabling lifecycle does nothing.
1153 HWND hwnd = reinterpret_cast<HWND>(1);
1154 view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1155 view.OnWindowStateEvent(hwnd, WindowStateEvent::kHide);
1156 EXPECT_FALSE(finished);
1157
1158 // Test that we can set the state afterwards.
1159
1160 engine->lifecycle_manager()->BeginProcessingLifecycle();
1161 view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1162
1163 while (!finished) {
1164 engine->task_runner()->ProcessTasks();
1165 }
1166}

◆ TEST_F() [544/876]

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

Definition at line 1058 of file flutter_windows_engine_unittests.cc.

1058 {
1059 FlutterWindowsEngineBuilder builder{GetContext()};
1060
1061 auto engine = builder.Build();
1062 auto window_binding_handler =
1063 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1064 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1065
1066 EngineModifier modifier(engine.get());
1067 modifier.SetImplicitView(&view);
1068 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1069 // Sets lifecycle state to resumed.
1070 engine->Run();
1071
1072 // Ensure HWND(1) is in the set of visible windows before hiding it.
1073 engine->ProcessExternalWindowMessage(reinterpret_cast<HWND>(1), WM_SHOWWINDOW,
1074 TRUE, NULL);
1075 engine->ProcessExternalWindowMessage(reinterpret_cast<HWND>(1), WM_SHOWWINDOW,
1076 FALSE, NULL);
1077
1078 EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1079 AppLifecycleState::kHidden);
1080}

◆ TEST_F() [545/876]

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

Definition at line 573 of file flutter_windows_engine_unittests.cc.

573 {
574 FlutterWindowsEngineBuilder builder{GetContext()};
575 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
576 EXPECT_EQ(engine->GetExecutableName(), "flutter_windows_unittests.exe");
577}

◆ TEST_F() [546/876]

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

Definition at line 1082 of file flutter_windows_engine_unittests.cc.

1082 {
1083 FlutterWindowsEngineBuilder builder{GetContext()};
1084 HWND outer = reinterpret_cast<HWND>(1);
1085 HWND inner = reinterpret_cast<HWND>(2);
1086
1087 auto engine = builder.Build();
1088 auto window_binding_handler =
1089 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1090 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1091 ON_CALL(view, GetWindowHandle).WillByDefault([=]() { return inner; });
1092
1093 EngineModifier modifier(engine.get());
1094 modifier.SetImplicitView(&view);
1095 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1096 // Sets lifecycle state to resumed.
1097 engine->Run();
1098
1099 // Show both top-level and Flutter window.
1100 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1101 outer, WM_SHOWWINDOW, TRUE, NULL);
1102 view.OnWindowStateEvent(inner, WindowStateEvent::kShow);
1103 view.OnWindowStateEvent(inner, WindowStateEvent::kFocus);
1104
1105 EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1106 AppLifecycleState::kResumed);
1107
1108 // Hide Flutter window, but not top level window.
1109 view.OnWindowStateEvent(inner, WindowStateEvent::kHide);
1110
1111 // The top-level window is still visible, so we ought not enter hidden state.
1112 EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1113 AppLifecycleState::kInactive);
1114}

◆ TEST_F() [547/876]

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

Definition at line 953 of file flutter_windows_engine_unittests.cc.

953 {
954 FlutterWindowsEngineBuilder builder{GetContext()};
955
956 auto engine = builder.Build();
957 auto window_binding_handler =
958 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
959 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
960
961 EngineModifier modifier(engine.get());
962 modifier.SetImplicitView(&view);
963 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
964 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
965 EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(0);
966 modifier.SetLifecycleManager(std::move(handler));
967
968 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
969 0);
970}

◆ TEST_F() [548/876]

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

Definition at line 1168 of file flutter_windows_engine_unittests.cc.

1168 {
1169 FlutterWindowsEngineBuilder builder{GetContext()};
1170 builder.SetDartEntrypoint("enableLifecycleToFrom");
1171 bool enabled_lifecycle = false;
1172 bool dart_responded = false;
1173
1174 auto engine = builder.Build();
1175 auto window_binding_handler =
1176 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1177 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1178
1179 EngineModifier modifier(engine.get());
1180 modifier.SetImplicitView(&view);
1181 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1182 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
1183 EXPECT_CALL(*handler, SetLifecycleState)
1184 .WillRepeatedly([handler_ptr = handler.get()](AppLifecycleState state) {
1185 handler_ptr->WindowsLifecycleManager::SetLifecycleState(state);
1186 });
1187 handler->begin_processing_callback = [&]() { enabled_lifecycle = true; };
1188 modifier.SetLifecycleManager(std::move(handler));
1189
1190 auto binary_messenger =
1191 std::make_unique<BinaryMessengerImpl>(engine->messenger());
1192 binary_messenger->SetMessageHandler(
1193 "flutter/unittest",
1194 [&](const uint8_t* message, size_t message_size, BinaryReply reply) {
1195 std::string contents(message, message + message_size);
1196 EXPECT_NE(contents.find("AppLifecycleState."), std::string::npos);
1197 dart_responded = true;
1198 char response[] = "";
1199 reply(reinterpret_cast<uint8_t*>(response), 0);
1200 });
1201
1202 engine->Run();
1203
1204 while (!enabled_lifecycle) {
1205 engine->task_runner()->ProcessTasks();
1206 }
1207
1208 HWND hwnd = reinterpret_cast<HWND>(1);
1209 view.OnWindowStateEvent(hwnd, WindowStateEvent::kShow);
1210 view.OnWindowStateEvent(hwnd, WindowStateEvent::kHide);
1211
1212 while (!dart_responded) {
1213 engine->task_runner()->ProcessTasks();
1214 }
1215}

◆ TEST_F() [549/876]

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

Definition at line 1029 of file flutter_windows_engine_unittests.cc.

1029 {
1030 FlutterWindowsEngineBuilder builder{GetContext()};
1031
1032 auto engine = builder.Build();
1033 auto window_binding_handler =
1034 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
1035 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
1036
1037 EngineModifier modifier(engine.get());
1038 modifier.SetImplicitView(&view);
1039 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1040 engine->Run();
1041
1042 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1043 (HWND)1, WM_SIZE, SIZE_RESTORED, 0);
1044 EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1045 AppLifecycleState::kResumed);
1046
1047 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1048 (HWND)1, WM_SIZE, SIZE_MINIMIZED, 0);
1049 EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1050 AppLifecycleState::kHidden);
1051
1052 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
1053 (HWND)1, WM_SIZE, SIZE_RESTORED, 0);
1054 EXPECT_EQ(engine->lifecycle_manager()->GetLifecycleState(),
1055 AppLifecycleState::kInactive);
1056}

◆ TEST_F() [550/876]

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

Definition at line 354 of file flutter_windows_engine_unittests.cc.

354 {
355 FlutterWindowsEngineBuilder builder{GetContext()};
356 builder.SetDartEntrypoint("hiPlatformChannels");
357
358 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
359
360 EngineModifier modifier(engine.get());
361 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
362
363 auto binary_messenger =
364 std::make_unique<BinaryMessengerImpl>(engine->messenger());
365
366 engine->Run();
367 bool did_call_callback = false;
368 bool did_call_reply = false;
369 bool did_call_dart_reply = false;
370 std::string channel = "hi";
371 std::unique_ptr<std::thread> reply_thread;
372 binary_messenger->SetMessageHandler(
373 channel,
374 [&did_call_callback, &did_call_dart_reply, &reply_thread](
375 const uint8_t* message, size_t message_size, BinaryReply reply) {
376 if (message_size == 5) {
377 EXPECT_EQ(message[0], static_cast<uint8_t>('h'));
378 reply_thread.reset(new std::thread([reply = std::move(reply)]() {
379 char response[] = {'b', 'y', 'e'};
380 reply(reinterpret_cast<uint8_t*>(response), 3);
381 }));
382 did_call_callback = true;
383 } else {
384 EXPECT_EQ(message_size, 3);
385 EXPECT_EQ(message[0], static_cast<uint8_t>('b'));
386 did_call_dart_reply = true;
387 }
388 });
389 char payload[] = {'h', 'e', 'l', 'l', 'o'};
390 binary_messenger->Send(
391 channel, reinterpret_cast<uint8_t*>(payload), 5,
392 [&did_call_reply](const uint8_t* reply, size_t reply_size) {
393 EXPECT_EQ(reply_size, 5);
394 EXPECT_EQ(reply[0], static_cast<uint8_t>('h'));
395 did_call_reply = true;
396 });
397 // Rely on timeout mechanism in CI.
398 while (!did_call_callback || !did_call_reply || !did_call_dart_reply) {
399 engine->task_runner()->ProcessTasks();
400 }
401 ASSERT_TRUE(reply_thread);
402 reply_thread->join();
403}

◆ TEST_F() [551/876]

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

Definition at line 309 of file flutter_windows_engine_unittests.cc.

309 {
310 FlutterWindowsEngineBuilder builder{GetContext()};
311 builder.SetDartEntrypoint("hiPlatformChannels");
312
313 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
314 EngineModifier modifier(engine.get());
315 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
316
317 auto binary_messenger =
318 std::make_unique<BinaryMessengerImpl>(engine->messenger());
319
320 engine->Run();
321 bool did_call_callback = false;
322 bool did_call_reply = false;
323 bool did_call_dart_reply = false;
324 std::string channel = "hi";
325 binary_messenger->SetMessageHandler(
326 channel,
327 [&did_call_callback, &did_call_dart_reply](
328 const uint8_t* message, size_t message_size, BinaryReply reply) {
329 if (message_size == 5) {
330 EXPECT_EQ(message[0], static_cast<uint8_t>('h'));
331 char response[] = {'b', 'y', 'e'};
332 reply(reinterpret_cast<uint8_t*>(response), 3);
333 did_call_callback = true;
334 } else {
335 EXPECT_EQ(message_size, 3);
336 EXPECT_EQ(message[0], static_cast<uint8_t>('b'));
337 did_call_dart_reply = true;
338 }
339 });
340 char payload[] = {'h', 'e', 'l', 'l', 'o'};
341 binary_messenger->Send(
342 channel, reinterpret_cast<uint8_t*>(payload), 5,
343 [&did_call_reply](const uint8_t* reply, size_t reply_size) {
344 EXPECT_EQ(reply_size, 5);
345 EXPECT_EQ(reply[0], static_cast<uint8_t>('h'));
346 did_call_reply = true;
347 });
348 // Rely on timeout mechanism in CI.
349 while (!did_call_callback || !did_call_reply || !did_call_dart_reply) {
350 engine->task_runner()->ProcessTasks();
351 }
352}

◆ TEST_F() [552/876]

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

Definition at line 622 of file flutter_windows_engine_unittests.cc.

622 {
623 FlutterWindowsEngineBuilder builder{GetContext()};
624 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
625 EngineModifier modifier(engine.get());
626
627 modifier.embedder_api().PostRenderThreadTask = MOCK_ENGINE_PROC(
628 PostRenderThreadTask, ([](auto engine, auto callback, auto context) {
629 callback(context);
630 return kSuccess;
631 }));
632
633 bool called = false;
634 engine->PostRasterThreadTask([&called]() { called = true; });
635
636 EXPECT_TRUE(called);
637}

◆ TEST_F() [553/876]

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

Definition at line 1243 of file flutter_windows_engine_unittests.cc.

1243 {
1244 FlutterWindowsEngineBuilder builder{GetContext()};
1245 builder.SetDartEntrypoint("sendCreatePlatformViewMethod");
1246 auto engine = builder.Build();
1247
1248 EngineModifier modifier{engine.get()};
1249 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1250
1251 bool received_call = false;
1252
1253 auto manager = std::make_unique<MockPlatformViewManager>(engine.get());
1254 EXPECT_CALL(*manager, AddPlatformView)
1255 .WillOnce([&](PlatformViewId id, std::string_view type_name) {
1256 received_call = true;
1257 return true;
1258 });
1259 modifier.SetPlatformViewPlugin(std::move(manager));
1260
1261 engine->Run();
1262
1263 while (!received_call) {
1264 engine->task_runner()->ProcessTasks();
1265 }
1266}
int64_t PlatformViewId

◆ TEST_F() [554/876]

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

Definition at line 1298 of file flutter_windows_engine_unittests.cc.

1298 {
1299 FlutterWindowsEngineBuilder builder{GetContext()};
1300 builder.SetDartEntrypoint("sendCreatePlatformViewMethod");
1301 auto engine = builder.Build();
1302
1303 EngineModifier modifier{engine.get()};
1304
1305 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
1306 modifier.embedder_api().RemoveView = MOCK_ENGINE_PROC(
1307 RemoveView,
1310
1311 ASSERT_TRUE(engine->Run());
1312 EXPECT_DEBUG_DEATH(engine->RemoveView(123),
1313 "FlutterEngineRemoveView returned an unexpected result");
1314}

◆ TEST_F() [555/876]

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

Definition at line 51 of file flutter_windows_engine_unittests.cc.

51 {
52 FlutterWindowsEngineBuilder builder{GetContext()};
53 builder.AddDartEntrypointArgument("arg1");
54 builder.AddDartEntrypointArgument("arg2");
55
56 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
57 EngineModifier modifier(engine.get());
58
59 // The engine should be run with expected configuration values.
60 bool run_called = false;
61 modifier.embedder_api().Run = MOCK_ENGINE_PROC(
62 Run, ([&run_called, engine_instance = engine.get()](
63 size_t version, const FlutterRendererConfig* config,
64 const FlutterProjectArgs* args, void* user_data,
65 FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
66 run_called = true;
67 *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
68
69 EXPECT_EQ(version, FLUTTER_ENGINE_VERSION);
70 EXPECT_NE(config, nullptr);
71 // We have an EGL manager, so this should be using OpenGL.
72 EXPECT_EQ(config->type, kOpenGL);
73 EXPECT_EQ(user_data, engine_instance);
74 // Spot-check arguments.
75 EXPECT_NE(args->assets_path, nullptr);
76 EXPECT_NE(args->icu_data_path, nullptr);
77 EXPECT_EQ(args->dart_entrypoint_argc, 2U);
78 EXPECT_EQ(strcmp(args->dart_entrypoint_argv[0], "arg1"), 0);
79 EXPECT_EQ(strcmp(args->dart_entrypoint_argv[1], "arg2"), 0);
80 EXPECT_NE(args->platform_message_callback, nullptr);
81 EXPECT_NE(args->custom_task_runners, nullptr);
82 EXPECT_NE(args->custom_task_runners->thread_priority_setter, nullptr);
83 EXPECT_EQ(args->custom_dart_entrypoint, nullptr);
84 EXPECT_NE(args->vsync_callback, nullptr);
85 EXPECT_EQ(args->update_semantics_callback, nullptr);
86 EXPECT_NE(args->update_semantics_callback2, nullptr);
87 EXPECT_EQ(args->update_semantics_node_callback, nullptr);
88 EXPECT_EQ(args->update_semantics_custom_action_callback, nullptr);
89
90 args->custom_task_runners->thread_priority_setter(
92 EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
93 THREAD_PRIORITY_ABOVE_NORMAL);
94 return kSuccess;
95 }));
96 // Accessibility updates must do nothing when the embedder engine is mocked
97 modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
98 UpdateAccessibilityFeatures,
101
102 // It should send locale info.
103 bool update_locales_called = false;
104 modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
105 UpdateLocales,
106 ([&update_locales_called](auto engine, const FlutterLocale** locales,
107 size_t locales_count) {
108 update_locales_called = true;
109
110 EXPECT_GT(locales_count, 0);
111 EXPECT_NE(locales, nullptr);
112
113 return kSuccess;
114 }));
115
116 // And it should send initial settings info.
117 bool settings_message_sent = false;
118 modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
119 SendPlatformMessage,
120 ([&settings_message_sent](auto engine, auto message) {
121 if (std::string(message->channel) == std::string("flutter/settings")) {
122 settings_message_sent = true;
123 }
124
125 return kSuccess;
126 }));
127
128 // And it should send display info.
129 bool notify_display_update_called = false;
130 modifier.SetFrameInterval(16600000); // 60 fps.
131 modifier.embedder_api().NotifyDisplayUpdate = MOCK_ENGINE_PROC(
132 NotifyDisplayUpdate,
133 ([&notify_display_update_called, engine_instance = engine.get()](
135 const FlutterEngineDisplaysUpdateType update_type,
136 const FlutterEngineDisplay* embedder_displays,
137 size_t display_count) {
138 EXPECT_EQ(update_type, kFlutterEngineDisplaysUpdateTypeStartup);
139 EXPECT_EQ(display_count, 1);
140
141 FlutterEngineDisplay display = embedder_displays[0];
142
143 EXPECT_EQ(display.display_id, 0);
144 EXPECT_EQ(display.single_display, true);
145 EXPECT_EQ(std::floor(display.refresh_rate), 60.0);
146
147 notify_display_update_called = true;
148 return kSuccess;
149 }));
150
151 // Set the EGL manager to !nullptr to test ANGLE rendering.
152 modifier.SetEGLManager(std::make_unique<egl::MockManager>());
153
154 engine->Run();
155
156 EXPECT_TRUE(run_called);
157 EXPECT_TRUE(update_locales_called);
158 EXPECT_TRUE(settings_message_sent);
159 EXPECT_TRUE(notify_display_update_called);
160
161 // Ensure that deallocation doesn't call the actual Shutdown with the bogus
162 // engine pointer that the overridden Run returned.
163 modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
164 modifier.ReleaseEGLManager();
165}
@ kOpenGL
Definition embedder.h:80
@ kRaster
Suitable for thread which raster data.
Definition embedder.h:264
#define FLUTTER_ENGINE_VERSION
Definition embedder.h:70
FlutterRendererType type
Definition embedder.h:825

◆ TEST_F() [556/876]

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

Definition at line 39 of file flutter_windows_engine_unittests.cc.

39 {
40 FlutterWindowsEngineBuilder builder{GetContext()};
41 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
42
43 EngineModifier modifier(engine.get());
44 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
45
46 ASSERT_TRUE(engine->Run());
47 ASSERT_EQ(engine->view(kImplicitViewId), nullptr);
48 ASSERT_EQ(engine->view(123), nullptr);
49}

◆ TEST_F() [557/876]

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

Definition at line 247 of file flutter_windows_engine_unittests.cc.

247 {
248 FlutterWindowsEngineBuilder builder{GetContext()};
249 builder.SetSwitches({"--enable-impeller=true"});
250 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
251 EngineModifier modifier(engine.get());
252
253 modifier.embedder_api().NotifyDisplayUpdate =
254 MOCK_ENGINE_PROC(NotifyDisplayUpdate,
255 ([engine_instance = engine.get()](
257 const FlutterEngineDisplaysUpdateType update_type,
258 const FlutterEngineDisplay* embedder_displays,
259 size_t display_count) { return kSuccess; }));
260
261 // Accessibility updates must do nothing when the embedder engine is mocked
262 modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
263 UpdateAccessibilityFeatures,
266
267 // Stub out UpdateLocales and SendPlatformMessage as we don't have a fully
268 // initialized engine instance.
269 modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
270 UpdateLocales, ([](auto engine, const FlutterLocale** locales,
271 size_t locales_count) { return kSuccess; }));
272 modifier.embedder_api().SendPlatformMessage =
273 MOCK_ENGINE_PROC(SendPlatformMessage,
274 ([](auto engine, auto message) { return kSuccess; }));
275
276 // Set the EGL manager to nullptr to test software fallback path.
277 modifier.SetEGLManager(nullptr);
278
279 EXPECT_FALSE(engine->Run());
280}

◆ TEST_F() [558/876]

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

Definition at line 194 of file flutter_windows_engine_unittests.cc.

194 {
195 FlutterWindowsEngineBuilder builder{GetContext()};
196 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
197 EngineModifier modifier(engine.get());
198
199 modifier.embedder_api().NotifyDisplayUpdate =
200 MOCK_ENGINE_PROC(NotifyDisplayUpdate,
201 ([engine_instance = engine.get()](
203 const FlutterEngineDisplaysUpdateType update_type,
204 const FlutterEngineDisplay* embedder_displays,
205 size_t display_count) { return kSuccess; }));
206
207 // The engine should be run with expected configuration values.
208 bool run_called = false;
209 modifier.embedder_api().Run = MOCK_ENGINE_PROC(
210 Run, ([&run_called, engine_instance = engine.get()](
211 size_t version, const FlutterRendererConfig* config,
212 const FlutterProjectArgs* args, void* user_data,
213 FLUTTER_API_SYMBOL(FlutterEngine) * engine_out) {
214 run_called = true;
215 *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(1);
216 // We don't have an EGL Manager, so we should be using software.
217 EXPECT_EQ(config->type, kSoftware);
218 return kSuccess;
219 }));
220 // Accessibility updates must do nothing when the embedder engine is mocked
221 modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
222 UpdateAccessibilityFeatures,
225
226 // Stub out UpdateLocales and SendPlatformMessage as we don't have a fully
227 // initialized engine instance.
228 modifier.embedder_api().UpdateLocales = MOCK_ENGINE_PROC(
229 UpdateLocales, ([](auto engine, const FlutterLocale** locales,
230 size_t locales_count) { return kSuccess; }));
231 modifier.embedder_api().SendPlatformMessage =
232 MOCK_ENGINE_PROC(SendPlatformMessage,
233 ([](auto engine, auto message) { return kSuccess; }));
234
235 // Set the EGL manager to nullptr to test software fallback path.
236 modifier.SetEGLManager(nullptr);
237
238 engine->Run();
239
240 EXPECT_TRUE(run_called);
241
242 // Ensure that deallocation doesn't call the actual Shutdown with the bogus
243 // engine pointer that the overridden Run returned.
244 modifier.embedder_api().Shutdown = [](auto engine) { return kSuccess; };
245}
@ kSoftware
Definition embedder.h:81

◆ TEST_F() [559/876]

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

Definition at line 541 of file flutter_windows_engine_unittests.cc.

541 {
542 FlutterWindowsEngineBuilder builder{GetContext()};
543 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
544 EngineModifier modifier(engine.get());
545
546 bool called = false;
547 modifier.embedder_api().ScheduleFrame =
548 MOCK_ENGINE_PROC(ScheduleFrame, ([&called](auto engine) {
549 called = true;
550 return kSuccess;
551 }));
552
553 engine->ScheduleFrame();
554 EXPECT_TRUE(called);
555}

◆ TEST_F() [560/876]

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

Definition at line 282 of file flutter_windows_engine_unittests.cc.

282 {
283 FlutterWindowsEngineBuilder builder{GetContext()};
284 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
285 EngineModifier modifier(engine.get());
286
287 const char* channel = "test";
288 const std::vector<uint8_t> test_message = {1, 2, 3, 4};
289
290 // Without a response, SendPlatformMessage should be a simple pass-through.
291 bool called = false;
292 modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
293 SendPlatformMessage, ([&called, test_message](auto engine, auto message) {
294 called = true;
295 EXPECT_STREQ(message->channel, "test");
296 EXPECT_EQ(message->message_size, test_message.size());
297 EXPECT_EQ(memcmp(message->message, test_message.data(),
298 message->message_size),
299 0);
300 EXPECT_EQ(message->response_handle, nullptr);
301 return kSuccess;
302 }));
303
304 engine->SendPlatformMessage(channel, test_message.data(), test_message.size(),
305 nullptr, nullptr);
306 EXPECT_TRUE(called);
307}

◆ TEST_F() [561/876]

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

Definition at line 405 of file flutter_windows_engine_unittests.cc.

405 {
406 FlutterWindowsEngineBuilder builder{GetContext()};
407 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
408 EngineModifier modifier(engine.get());
409
410 const char* channel = "test";
411 const std::vector<uint8_t> test_message = {1, 2, 3, 4};
412 auto* dummy_response_handle =
413 reinterpret_cast<FlutterPlatformMessageResponseHandle*>(5);
414 const FlutterDesktopBinaryReply reply_handler = [](auto... args) {};
415 void* reply_user_data = reinterpret_cast<void*>(6);
416
417 // When a response is requested, a handle should be created, passed as part
418 // of the message, and then released.
419 bool create_response_handle_called = false;
420 modifier.embedder_api().PlatformMessageCreateResponseHandle =
422 PlatformMessageCreateResponseHandle,
423 ([&create_response_handle_called, &reply_handler, reply_user_data,
424 dummy_response_handle](auto engine, auto reply, auto user_data,
425 auto response_handle) {
426 create_response_handle_called = true;
427 EXPECT_EQ(reply, reply_handler);
428 EXPECT_EQ(user_data, reply_user_data);
429 EXPECT_NE(response_handle, nullptr);
430 *response_handle = dummy_response_handle;
431 return kSuccess;
432 }));
433 bool release_response_handle_called = false;
434 modifier.embedder_api().PlatformMessageReleaseResponseHandle =
436 PlatformMessageReleaseResponseHandle,
437 ([&release_response_handle_called, dummy_response_handle](
438 auto engine, auto response_handle) {
439 release_response_handle_called = true;
440 EXPECT_EQ(response_handle, dummy_response_handle);
441 return kSuccess;
442 }));
443 bool send_message_called = false;
444 modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
445 SendPlatformMessage, ([&send_message_called, test_message,
446 dummy_response_handle](auto engine, auto message) {
447 send_message_called = true;
448 EXPECT_STREQ(message->channel, "test");
449 EXPECT_EQ(message->message_size, test_message.size());
450 EXPECT_EQ(memcmp(message->message, test_message.data(),
451 message->message_size),
452 0);
453 EXPECT_EQ(message->response_handle, dummy_response_handle);
454 return kSuccess;
455 }));
456
457 engine->SendPlatformMessage(channel, test_message.data(), test_message.size(),
458 reply_handler, reply_user_data);
459 EXPECT_TRUE(create_response_handle_called);
460 EXPECT_TRUE(release_response_handle_called);
461 EXPECT_TRUE(send_message_called);
462}
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)

◆ TEST_F() [562/876]

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

Definition at line 557 of file flutter_windows_engine_unittests.cc.

557 {
558 FlutterWindowsEngineBuilder builder{GetContext()};
559 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
560 EngineModifier modifier(engine.get());
561
562 bool called = false;
563 modifier.embedder_api().SetNextFrameCallback = MOCK_ENGINE_PROC(
564 SetNextFrameCallback, ([&called](auto engine, auto callback, auto data) {
565 called = true;
566 return kSuccess;
567 }));
568
569 engine->SetNextFrameCallback([]() {});
570 EXPECT_TRUE(called);
571}

◆ TEST_F() [563/876]

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

Definition at line 489 of file flutter_windows_engine_unittests.cc.

489 {
490 WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kBackground);
491 EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
492 THREAD_PRIORITY_BELOW_NORMAL);
493
494 WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kDisplay);
495 EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
496 THREAD_PRIORITY_ABOVE_NORMAL);
497
498 WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kRaster);
499 EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
500 THREAD_PRIORITY_ABOVE_NORMAL);
501
502 // FlutterThreadPriority::kNormal does not change thread priority, reset to 0
503 // here.
504 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
505
506 WindowsPlatformThreadPrioritySetter(FlutterThreadPriority::kNormal);
507 EXPECT_EQ(GetThreadPriority(GetCurrentThread()), THREAD_PRIORITY_NORMAL);
508}
@ kBackground
Suitable for threads that shouldn't disrupt high priority work.
Definition embedder.h:258
@ kDisplay
Suitable for threads which generate data for the display.
Definition embedder.h:262
@ kNormal
Default priority level.
Definition embedder.h:260

◆ TEST_F() [564/876]

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

Definition at line 774 of file flutter_windows_engine_unittests.cc.

774 {
775 FlutterWindowsEngineBuilder builder{GetContext()};
776 builder.SetDartEntrypoint("exitTestExit");
777 bool finished = false;
778
779 auto engine = builder.Build();
780 auto window_binding_handler =
781 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
782 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
783
784 EngineModifier modifier(engine.get());
785 modifier.SetImplicitView(&view);
786 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
787 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
788 EXPECT_CALL(*handler, SetLifecycleState(AppLifecycleState::kResumed));
789 EXPECT_CALL(*handler, Quit)
790 .WillOnce([&finished](std::optional<HWND> hwnd,
791 std::optional<WPARAM> wparam,
792 std::optional<LPARAM> lparam,
793 UINT exit_code) { finished = exit_code == 0; });
794 EXPECT_CALL(*handler, IsLastWindowOfProcess).WillRepeatedly(Return(true));
795 modifier.SetLifecycleManager(std::move(handler));
796
797 engine->lifecycle_manager()->BeginProcessingExit();
798
799 engine->Run();
800
801 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
802 0);
803
804 // The test will only succeed when this while loop exits. Otherwise it will
805 // timeout.
806 while (!finished) {
807 engine->task_runner()->ProcessTasks();
808 }
809}

◆ TEST_F() [565/876]

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

Definition at line 811 of file flutter_windows_engine_unittests.cc.

811 {
812 FlutterWindowsEngineBuilder builder{GetContext()};
813 builder.SetDartEntrypoint("exitTestCancel");
814 bool did_call = false;
815
816 auto engine = builder.Build();
817 auto window_binding_handler =
818 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
819 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
820
821 EngineModifier modifier(engine.get());
822 modifier.SetImplicitView(&view);
823 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
824 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
825 EXPECT_CALL(*handler, SetLifecycleState(AppLifecycleState::kResumed));
826 EXPECT_CALL(*handler, IsLastWindowOfProcess).WillRepeatedly(Return(true));
827 EXPECT_CALL(*handler, Quit).Times(0);
828 modifier.SetLifecycleManager(std::move(handler));
829 engine->lifecycle_manager()->BeginProcessingExit();
830
831 auto binary_messenger =
832 std::make_unique<BinaryMessengerImpl>(engine->messenger());
833 binary_messenger->SetMessageHandler(
834 "flutter/platform", [&did_call](const uint8_t* message,
835 size_t message_size, BinaryReply reply) {
836 std::string contents(message, message + message_size);
837 EXPECT_NE(contents.find("\"method\":\"System.exitApplication\""),
838 std::string::npos);
839 EXPECT_NE(contents.find("\"type\":\"required\""), std::string::npos);
840 EXPECT_NE(contents.find("\"exitCode\":0"), std::string::npos);
841 did_call = true;
842 char response[] = "";
843 reply(reinterpret_cast<uint8_t*>(response), 0);
844 });
845
846 engine->Run();
847
848 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
849 0);
850
851 while (!did_call) {
852 engine->task_runner()->ProcessTasks();
853 }
854}

◆ TEST_F() [566/876]

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

Definition at line 919 of file flutter_windows_engine_unittests.cc.

919 {
920 FlutterWindowsEngineBuilder builder{GetContext()};
921 builder.SetDartEntrypoint("exitTestExit");
922 bool finished = false;
923
924 auto engine = builder.Build();
925 auto window_binding_handler =
926 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
927 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
928
929 EngineModifier modifier(engine.get());
930 modifier.SetImplicitView(&view);
931 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
932 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
933 EXPECT_CALL(*handler, SetLifecycleState(AppLifecycleState::kResumed));
934 EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce([&finished]() {
935 finished = true;
936 return false;
937 });
938 // Quit should not be called when there is more than one window.
939 EXPECT_CALL(*handler, Quit).Times(0);
940 modifier.SetLifecycleManager(std::move(handler));
941 engine->lifecycle_manager()->BeginProcessingExit();
942
943 engine->Run();
944
945 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
946 0);
947
948 while (!finished) {
949 engine->task_runner()->ProcessTasks();
950 }
951}

◆ TEST_F() [567/876]

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

Definition at line 859 of file flutter_windows_engine_unittests.cc.

859 {
860 FlutterWindowsEngineBuilder builder{GetContext()};
861 builder.SetDartEntrypoint("exitTestExit");
862 bool second_close = false;
863
864 auto engine = builder.Build();
865 auto window_binding_handler =
866 std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
867 MockFlutterWindowsView view(engine.get(), std::move(window_binding_handler));
868
869 EngineModifier modifier(engine.get());
870 modifier.SetImplicitView(&view);
871 modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; };
872 auto handler = std::make_unique<MockWindowsLifecycleManager>(engine.get());
873 EXPECT_CALL(*handler, SetLifecycleState(AppLifecycleState::kResumed));
874 EXPECT_CALL(*handler, IsLastWindowOfProcess).WillOnce(Return(true));
875 EXPECT_CALL(*handler, Quit)
876 .WillOnce([handler_ptr = handler.get()](
877 std::optional<HWND> hwnd, std::optional<WPARAM> wparam,
878 std::optional<LPARAM> lparam, UINT exit_code) {
879 handler_ptr->WindowsLifecycleManager::Quit(hwnd, wparam, lparam,
880 exit_code);
881 });
882 EXPECT_CALL(*handler, DispatchMessage)
883 .WillRepeatedly(
884 [&engine](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
885 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(
886 hwnd, msg, wparam, lparam);
887 });
888 modifier.SetLifecycleManager(std::move(handler));
889 engine->lifecycle_manager()->BeginProcessingExit();
890
891 engine->Run();
892
893 // This delegate will be registered after the lifecycle manager, so it will be
894 // called only when a message is not consumed by the lifecycle manager. This
895 // should be called on the second, synthesized WM_CLOSE message that the
896 // lifecycle manager posts.
897 engine->window_proc_delegate_manager()->RegisterTopLevelWindowProcDelegate(
898 [](HWND hwnd, UINT message, WPARAM wpar, LPARAM lpar, void* user_data,
899 LRESULT* result) {
900 switch (message) {
901 case WM_CLOSE: {
902 bool* called = reinterpret_cast<bool*>(user_data);
903 *called = true;
904 return true;
905 }
906 }
907 return false;
908 },
909 reinterpret_cast<void*>(&second_close));
910
911 engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0,
912 0);
913
914 while (!second_close) {
915 engine->task_runner()->ProcessTasks();
916 }
917}
#define DispatchMessage

◆ TEST_F() [568/876]

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

Definition at line 581 of file flutter_windows_engine_unittests.cc.

581 {
582 auto windows_proc_table = std::make_shared<MockWindowsProcTable>();
583 EXPECT_CALL(*windows_proc_table, GetHighContrastEnabled)
584 .WillOnce(Return(true))
585 .WillOnce(Return(false));
586
587 FlutterWindowsEngineBuilder builder{GetContext()};
588 builder.SetWindowsProcTable(windows_proc_table);
589 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
590 EngineModifier modifier(engine.get());
591
592 std::optional<FlutterAccessibilityFeature> engine_flags;
593 modifier.embedder_api().UpdateAccessibilityFeatures = MOCK_ENGINE_PROC(
594 UpdateAccessibilityFeatures, ([&engine_flags](auto engine, auto flags) {
595 engine_flags = flags;
596 return kSuccess;
597 }));
598 modifier.embedder_api().SendPlatformMessage = MOCK_ENGINE_PROC(
599 SendPlatformMessage,
600 [](auto engine, const auto message) { return kSuccess; });
601
602 // 1: High contrast is enabled.
603 engine->UpdateHighContrastMode();
604
605 EXPECT_TRUE(engine->high_contrast_enabled());
606 EXPECT_TRUE(engine_flags.has_value());
608 engine_flags.value() &
610
611 // 2: High contrast is disabled.
612 engine_flags.reset();
613 engine->UpdateHighContrastMode();
614
615 EXPECT_FALSE(engine->high_contrast_enabled());
616 EXPECT_TRUE(engine_flags.has_value());
617 EXPECT_FALSE(
618 engine_flags.value() &
620}
@ kFlutterAccessibilityFeatureHighContrast
Request that UI be rendered with darker colors.
Definition embedder.h:105

◆ TEST_F() [569/876]

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

Definition at line 310 of file flutter_window_unittests.cc.

310 {
311 MockFlutterWindow win32window;
312
313 EXPECT_EQ(win32window.GetNativeViewAccessible(), nullptr);
314}

◆ TEST_F() [570/876]

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

Definition at line 318 of file flutter_window_unittests.cc.

318 {
319 std::unique_ptr<FlutterWindowsEngine> engine =
320 FlutterWindowsEngineBuilder{GetContext()}.Build();
321 auto win32window = std::make_unique<MockFlutterWindow>();
322 EXPECT_CALL(*win32window.get(), GetAxFragmentRootDelegate())
323 .WillRepeatedly(Return(nullptr));
324 EXPECT_CALL(*win32window.get(), OnWindowStateEvent).Times(AnyNumber());
325 EXPECT_CALL(*win32window.get(), GetWindowHandle).Times(AnyNumber());
326 MockFlutterWindowsView view{engine.get(), std::move(win32window)};
327 std::wstring message = L"Test alert";
328 EXPECT_CALL(view, NotifyWinEventWrapper(_, ax::mojom::Event::kAlert))
329 .Times(1);
330 view.AnnounceAlert(message);
331
332 IAccessible* alert = view.AlertNode();
333 VARIANT self{.vt = VT_I4, .lVal = CHILDID_SELF};
334 BSTR strptr;
335 alert->get_accName(self, &strptr);
336 EXPECT_EQ(message, strptr);
337
338 alert->get_accDescription(self, &strptr);
339 EXPECT_EQ(message, strptr);
340
341 alert->get_accValue(self, &strptr);
342 EXPECT_EQ(message, strptr);
343
344 VARIANT role;
345 alert->get_accRole(self, &role);
346 EXPECT_EQ(role.vt, VT_I4);
347 EXPECT_EQ(role.lVal, ROLE_SYSTEM_ALERT);
348}

◆ TEST_F() [571/876]

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

Definition at line 382 of file flutter_window_unittests.cc.

382 {
383 MockFlutterWindow win32window;
384 EXPECT_CALL(win32window, GetWindowHandle)
385 .WillRepeatedly(Return(reinterpret_cast<HWND>(1)));
386 EXPECT_CALL(win32window, OnWindowStateEvent)
387 .WillRepeatedly([&](WindowStateEvent event) {
388 win32window.FlutterWindow::OnWindowStateEvent(event);
389 });
390 EXPECT_CALL(win32window, OnResize).Times(1);
391
392 // Restore
393 win32window.InjectWindowMessage(WM_SIZE, 0, MAKEWORD(1, 1));
394
395 // Focus
396 win32window.InjectWindowMessage(WM_SETFOCUS, 0, 0);
397
398 MockWindowBindingHandlerDelegate delegate;
399 bool focused = false;
400 bool restored = false;
401 EXPECT_CALL(delegate, OnWindowStateEvent)
402 .WillRepeatedly([&](HWND hwnd, WindowStateEvent event) {
403 if (event == WindowStateEvent::kFocus) {
404 focused = true;
405 } else if (event == WindowStateEvent::kShow) {
406 restored = true;
407 }
408 });
409
410 win32window.SetView(&delegate);
411 EXPECT_TRUE(focused);
412 EXPECT_TRUE(restored);
413}
WindowStateEvent
An event representing a change in window state that may update the.

◆ TEST_F() [572/876]

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

Definition at line 118 of file flutter_window_unittests.cc.

118 {
119 FlutterWindow window(800, 600);
120 ASSERT_TRUE(TRUE);
121}

◆ TEST_F() [573/876]

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

Definition at line 350 of file flutter_window_unittests.cc.

350 {
351 MockFlutterWindow win32window;
352 EXPECT_CALL(win32window, GetWindowHandle)
353 .WillRepeatedly(Return(reinterpret_cast<HWND>(1)));
355
356 WindowStateEvent last_event;
357 EXPECT_CALL(delegate, OnWindowStateEvent)
358 .WillRepeatedly([&last_event](HWND hwnd, WindowStateEvent event) {
359 last_event = event;
360 });
361 EXPECT_CALL(win32window, OnWindowStateEvent)
362 .WillRepeatedly([&](WindowStateEvent event) {
363 win32window.FlutterWindow::OnWindowStateEvent(event);
364 });
365 EXPECT_CALL(win32window, OnResize).Times(AnyNumber());
366
367 win32window.SetView(&delegate);
368
369 win32window.InjectWindowMessage(WM_SIZE, 0, 0);
370 EXPECT_EQ(last_event, WindowStateEvent::kHide);
371
372 win32window.InjectWindowMessage(WM_SIZE, 0, MAKEWORD(1, 1));
373 EXPECT_EQ(last_event, WindowStateEvent::kShow);
374
375 win32window.InjectWindowMessage(WM_SETFOCUS, 0, 0);
376 EXPECT_EQ(last_event, WindowStateEvent::kFocus);
377
378 win32window.InjectWindowMessage(WM_KILLFOCUS, 0, 0);
379 EXPECT_EQ(last_event, WindowStateEvent::kUnfocus);
380}

◆ TEST_F() [574/876]

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

Definition at line 123 of file flutter_window_unittests.cc.

123 {
124 FlutterWindow win32window(100, 100);
125 int old_handle_count = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
126
127 constexpr size_t row_bytes = 100 * 4;
128 constexpr size_t height = 100;
129 std::array<char, row_bytes * height> allocation;
130 win32window.OnBitmapSurfaceUpdated(allocation.data(), row_bytes, height);
131
132 int new_handle_count = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
133 // Check GDI resources leak
134 EXPECT_EQ(old_handle_count, new_handle_count);
135}

◆ TEST_F() [575/876]

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

Definition at line 153 of file flutter_window_unittests.cc.

153 {
154 MockFlutterWindow win32window;
155 EXPECT_CALL(win32window, GetDpiScale()).WillOnce(Return(1.5));
156
157 Rect expected_cursor_rect(Point(15, 30), Size(45, 60));
158 EXPECT_CALL(win32window, UpdateCursorRect(expected_cursor_rect)).Times(1);
159
160 Rect cursor_rect(Point(10, 20), Size(30, 40));
161 win32window.OnCursorRectUpdated(cursor_rect);
162}

◆ TEST_F() [576/876]

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

Definition at line 140 of file flutter_window_unittests.cc.

140 {
141 MockFlutterWindow win32window;
142 EXPECT_CALL(win32window, GetDpiScale()).WillOnce(Return(1.0));
143
144 Rect cursor_rect(Point(10, 20), Size(30, 40));
145 EXPECT_CALL(win32window, UpdateCursorRect(cursor_rect)).Times(1);
146
147 win32window.OnCursorRectUpdated(cursor_rect);
148}

◆ TEST_F() [577/876]

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

Definition at line 164 of file flutter_window_unittests.cc.

164 {
165 FlutterWindow win32window(100, 100);
167 EXPECT_CALL(delegate, OnWindowStateEvent).Times(AnyNumber());
168 win32window.SetView(&delegate);
169
170 // Move
171 EXPECT_CALL(delegate,
172 OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindMouse,
173 kDefaultPointerDeviceId, 0))
174 .Times(1);
175 EXPECT_CALL(delegate,
176 OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindTouch,
177 kDefaultPointerDeviceId, 0))
178 .Times(1);
179 EXPECT_CALL(delegate,
180 OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindStylus,
181 kDefaultPointerDeviceId, 0))
182 .Times(1);
183
184 // Down
185 EXPECT_CALL(
186 delegate,
187 OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindMouse,
188 kDefaultPointerDeviceId, kFlutterPointerButtonMousePrimary))
189 .Times(1);
190 EXPECT_CALL(
191 delegate,
192 OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindTouch,
193 kDefaultPointerDeviceId, kFlutterPointerButtonMousePrimary))
194 .Times(1);
195 EXPECT_CALL(
196 delegate,
197 OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
198 kDefaultPointerDeviceId, kFlutterPointerButtonMousePrimary))
199 .Times(1);
200
201 // Up
202 EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindMouse,
203 kDefaultPointerDeviceId,
205 .Times(1);
206 EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindTouch,
207 kDefaultPointerDeviceId,
209 .Times(1);
210 EXPECT_CALL(delegate, OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindStylus,
211 kDefaultPointerDeviceId,
213 .Times(1);
214
215 // Leave
216 EXPECT_CALL(delegate,
217 OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindMouse,
218 kDefaultPointerDeviceId))
219 .Times(1);
220 EXPECT_CALL(delegate,
221 OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindTouch,
222 kDefaultPointerDeviceId))
223 .Times(1);
224 EXPECT_CALL(delegate,
225 OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindStylus,
226 kDefaultPointerDeviceId))
227 .Times(1);
228
229 win32window.OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindMouse,
230 kDefaultPointerDeviceId, 0);
231 win32window.OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindMouse,
232 kDefaultPointerDeviceId, WM_LBUTTONDOWN);
233 win32window.OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindMouse,
234 kDefaultPointerDeviceId, WM_LBUTTONDOWN);
235 win32window.OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindMouse,
236 kDefaultPointerDeviceId);
237
238 // Touch
239 win32window.OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindTouch,
240 kDefaultPointerDeviceId, 0);
241 win32window.OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindTouch,
242 kDefaultPointerDeviceId, WM_LBUTTONDOWN);
243 win32window.OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindTouch,
244 kDefaultPointerDeviceId, WM_LBUTTONDOWN);
245 win32window.OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindTouch,
246 kDefaultPointerDeviceId);
247
248 // Pen
249 win32window.OnPointerMove(10.0, 10.0, kFlutterPointerDeviceKindStylus,
250 kDefaultPointerDeviceId, 0);
251 win32window.OnPointerDown(10.0, 10.0, kFlutterPointerDeviceKindStylus,
252 kDefaultPointerDeviceId, WM_LBUTTONDOWN);
253 win32window.OnPointerUp(10.0, 10.0, kFlutterPointerDeviceKindStylus,
254 kDefaultPointerDeviceId, WM_LBUTTONDOWN);
255 win32window.OnPointerLeave(10.0, 10.0, kFlutterPointerDeviceKindStylus,
256 kDefaultPointerDeviceId);
257
258 // Destruction of win32window sends a HIDE update. In situ, the window is
259 // owned by the delegate, and so is destructed first. Not so here.
260 win32window.SetView(nullptr);
261}
virtual void OnPointerMove(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, int modifiers_state)=0
@ kFlutterPointerButtonMousePrimary
Definition embedder.h:1015
@ kFlutterPointerDeviceKindTouch
Definition embedder.h:1007
@ kFlutterPointerDeviceKindStylus
Definition embedder.h:1008

◆ TEST_F() [578/876]

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

Definition at line 265 of file flutter_window_unittests.cc.

265 {
266 MockFlutterWindow win32window;
268 EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
269 win32window.SetView(&delegate);
270
271 EXPECT_CALL(win32window, GetWindowHandle).WillOnce([&win32window]() {
272 return win32window.FlutterWindow::GetWindowHandle();
273 });
274 EXPECT_CALL(win32window, GetScrollOffsetMultiplier).WillOnce(Return(120.0f));
275
276 EXPECT_CALL(delegate,
277 OnScroll(_, _, 0, 0, 120.0f, kFlutterPointerDeviceKindMouse,
278 kDefaultPointerDeviceId))
279 .Times(1);
280
281 win32window.OnScroll(0.0f, 0.0f, kFlutterPointerDeviceKindMouse,
282 kDefaultPointerDeviceId);
283}
virtual void OnScroll(double x, double y, double delta_x, double delta_y, int scroll_offset_multiplier, FlutterPointerDeviceKind device_kind, int32_t device_id)=0

◆ TEST_F() [579/876]

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

Definition at line 296 of file flutter_window_unittests.cc.

296 {
297 MockFlutterWindow win32window;
299 EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
300 win32window.SetView(&delegate);
301
302 EXPECT_CALL(delegate, OnHighContrastChanged).Times(1);
303
304 win32window.InjectWindowMessage(WM_THEMECHANGED, 0, 0);
305}

◆ TEST_F() [580/876]

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

Definition at line 285 of file flutter_window_unittests.cc.

285 {
286 MockFlutterWindow win32window;
288 EXPECT_CALL(win32window, OnWindowStateEvent).Times(AnyNumber());
289 win32window.SetView(&delegate);
290
291 EXPECT_CALL(delegate, OnWindowRepaint()).Times(1);
292
293 win32window.InjectWindowMessage(WM_PAINT, 0, 0);
294}

◆ TEST_F() [581/876]

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

Definition at line 415 of file flutter_window_unittests.cc.

415 {
416 FlutterWindow win32window(100, 100);
417 win32window.UpdateFlutterCursor("text");
418 HCURSOR cursor = ::GetCursor();
419 EXPECT_EQ(cursor, ::LoadCursor(nullptr, IDC_IBEAM));
420}

◆ TEST_F() [582/876]

flutter::testing::TEST_F ( FuchsiaShellTest  ,
LocaltimesVaryOnTimezoneChanges   
)

Definition at line 166 of file shell_fuchsia_unittests.cc.

166 {
167#if defined(OS_FUCHSIA)
168 GTEST_SKIP()
169 << "This test fails after the CF V2 migration. https://fxbug.dev/110019 ";
170#else
171
172 // See fixtures/shell_test.dart, the callback NotifyLocalTime is declared
173 // there.
175 std::string dart_isolate_time_str;
176 AddNativeCallback("NotifyLocalTime", CREATE_NATIVE_ENTRY([&](auto args) {
177 dart_isolate_time_str =
180 latch.Signal();
181 }));
182
183 // As long as this is set, the isolate will keep rerunning its only task.
184 bool continue_fixture = true;
185 fml::AutoResetWaitableEvent fixture_latch;
186 AddNativeCallback("WaitFixture", CREATE_NATIVE_ENTRY([&](auto args) {
187 // Wait for the test fixture to advance.
188 fixture_latch.Wait();
190 args, continue_fixture);
191 }));
192
193 auto settings = CreateSettingsForFixture();
194 auto configuration = RunConfiguration::InferFromSettings(settings);
195 configuration.SetEntrypoint("timezonesChange");
196
197 std::unique_ptr<Shell> shell = CreateShell(settings);
198 ASSERT_NE(shell.get(), nullptr);
199 ASSERT_TRUE(ValidateShell(shell.get()));
200 RunEngine(shell.get(), std::move(configuration));
201 latch.Wait(); // After this point, the fixture is at waitFixture().
202
203 // Start with the local timezone, ensure that the isolate and the test
204 // fixture are the same.
205 SetTimezone(GetLocalTimezone());
206 AssertTimezone(GetLocalTimezone(), GetSettings());
207 std::string expected = GetLocalTime();
208 std::string actual = "undefined";
209 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
210 actual = dart_isolate_time_str;
211 FML_LOG(INFO) << "reference: " << expected << ", actual: " << actual;
212 return expected == actual;
213 });
214 ASSERT_EQ(expected, actual)
215 << "The Dart isolate was expected to show the same time as the test "
216 << "fixture eventually, but that didn't happen after multiple retries.";
217
218 // Set a new timezone, which is hopefully different from the local one.
219 SetTimezone("America/New_York");
220 AssertTimezone("America/New_York", GetSettings());
221 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
222 actual = dart_isolate_time_str;
223 FML_LOG(INFO) << "reference: " << expected << ", actual: " << actual;
224 return expected != actual;
225 });
226 ASSERT_NE(expected, actual)
227 << "The Dart isolate was expected to show a time different from the test "
228 << "fixture eventually, but that didn't happen after multiple retries.";
229
230 // Set a new isolate timezone, and check that the reported time is eventually
231 // different from what it used to be prior to the change.
232 SetTimezone("Europe/Amsterdam");
233 AssertTimezone("Europe/Amsterdam", GetSettings());
234 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
235 actual = dart_isolate_time_str;
236 FML_LOG(INFO) << "reference: " << expected << ", actual: " << actual;
237 return expected != actual;
238 });
239 ASSERT_NE(expected, actual)
240 << "The Dart isolate was expected to show a time different from the "
241 << "prior timezone eventually, but that didn't happen after multiple "
242 << "retries.";
243
244 // Let's try to bring the timezone back to the old one.
245 expected = actual;
246 SetTimezone("America/New_York");
247 AssertTimezone("America/New_York", GetSettings());
248 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
249 actual = dart_isolate_time_str;
250 FML_LOG(INFO) << "reference: " << expected << ", actual: " << actual;
251 return expected != actual;
252 });
253 ASSERT_NE(expected, actual)
254 << "The Dart isolate was expected to show a time different from the "
255 << "prior timezone eventually, but that didn't happen after multiple "
256 << "retries.";
257
258 // Tell the isolate to exit its loop.
259 ASSERT_FALSE(fixture_latch.IsSignaledForTest());
260 continue_fixture = false;
261 fixture_latch.Signal();
262 DestroyShell(std::move(shell));
263#endif // OS_FUCHSIA
264}

◆ TEST_F() [583/876]

flutter::testing::TEST_F ( HooksTest  ,
HooksUnitTests   
)

Definition at line 26 of file hooks_unittests.cc.

26 {
27 auto settings = CreateSettingsForFixture();
28
29 TaskRunners task_runners(GetCurrentTestName(), // label
30 GetCurrentTaskRunner(), // platform
31 CreateNewThread("raster"), // raster
32 CreateNewThread("ui"), // ui
33 CreateNewThread("io") // io
34 );
35
36 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
37
38 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
39 ASSERT_TRUE(shell->IsSetup());
40
41 auto call_hook = [](Dart_NativeArguments args) {
43 CHECK_DART_ERROR(hook_name);
44
45 Dart_Handle ui_library = Dart_LookupLibrary(tonic::ToDart("dart:ui"));
46 CHECK_DART_ERROR(ui_library);
47
48 Dart_Handle hook = Dart_GetField(ui_library, hook_name);
49 CHECK_DART_ERROR(hook);
50
51 Dart_Handle arg_count_handle = Dart_GetNativeArgument(args, 1);
52 CHECK_DART_ERROR(arg_count_handle);
53
54 int64_t arg_count;
55 Dart_IntegerToInt64(arg_count_handle, &arg_count);
56
57 std::vector<Dart_Handle> hook_args;
58 for (int i = 0; i < static_cast<int>(arg_count); i++) {
59 hook_args.push_back(Dart_GetNativeArgument(args, 2 + i));
60 CHECK_DART_ERROR(hook_args.back());
61 }
62
63 Dart_Handle hook_result =
64 Dart_InvokeClosure(hook, hook_args.size(), hook_args.data());
65 CHECK_DART_ERROR(hook_result);
66 };
67
68 auto finished = [&message_latch](Dart_NativeArguments args) {
69 message_latch->Signal();
70 };
71 AddNativeCallback("CallHook", CREATE_NATIVE_ENTRY(call_hook));
72 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finished));
73
74 auto configuration = RunConfiguration::InferFromSettings(settings);
75 configuration.SetEntrypoint("hooksTests");
76
77 shell->RunEngine(std::move(configuration), [](auto result) {
78 ASSERT_EQ(result, Engine::RunStatus::Success);
79 });
80
81 message_latch->Wait();
82 DestroyShell(std::move(shell), task_runners);
83}
DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, int64_t *value)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
#define CHECK_DART_ERROR(name)

◆ TEST_F() [584/876]

flutter::testing::TEST_F ( ImageDisposeTest  ,
ImageReleasedAfterFrameAndDisposePictureAndLayer   
)

Definition at line 40 of file image_dispose_unittests.cc.

40 {
41 auto native_capture_image_and_picture = [&](Dart_NativeArguments args) {
42 auto image_handle = Dart_GetNativeArgument(args, 0);
43 auto native_image_handle =
44 Dart_GetField(image_handle, Dart_NewStringFromCString("_image"));
45 ASSERT_FALSE(Dart_IsError(native_image_handle))
46 << Dart_GetError(native_image_handle);
47 ASSERT_FALSE(Dart_IsNull(native_image_handle));
48 CanvasImage* image = GetNativePeer<CanvasImage>(native_image_handle);
49 Picture* picture = GetNativePeer<Picture>(Dart_GetNativeArgument(args, 1));
50 ASSERT_FALSE(image->image()->unique());
51 ASSERT_FALSE(picture->display_list()->unique());
52 current_display_list_ = picture->display_list();
53 current_image_ = image->image();
54 };
55
56 auto native_finish = [&](Dart_NativeArguments args) {
57 message_latch_.Signal();
58 };
59
60 Settings settings = CreateSettingsForFixture();
61 fml::CountDownLatch frame_latch{2};
62 settings.frame_rasterized_callback = [&frame_latch](const FrameTiming& t) {
63 frame_latch.CountDown();
64 };
65 auto task_runner = CreateNewThread();
66 TaskRunners task_runners("test", // label
67 GetCurrentTaskRunner(), // platform
68 task_runner, // raster
69 task_runner, // ui
70 task_runner // io
71 );
72
73 AddNativeCallback("CaptureImageAndPicture",
74 CREATE_NATIVE_ENTRY(native_capture_image_and_picture));
75 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(native_finish));
76
77 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
78
79 ASSERT_TRUE(shell->IsSetup());
80
81 SetViewportMetrics(shell.get(), 800, 600);
82
83 shell->GetPlatformView()->NotifyCreated();
84
85 auto configuration = RunConfiguration::InferFromSettings(settings);
86 configuration.SetEntrypoint("pumpImage");
87
88 shell->RunEngine(std::move(configuration), [&](auto result) {
89 ASSERT_EQ(result, Engine::RunStatus::Success);
90 });
91 message_latch_.Wait();
92
93 ASSERT_TRUE(current_display_list_);
94 ASSERT_TRUE(current_image_);
95
96 // Wait for 2 frames to be rasterized. The 2nd frame releases resources of the
97 // 1st frame.
98 frame_latch.Wait();
99
100 // Force a drain the SkiaUnrefQueue. The engine does this normally as frames
101 // pump, but we force it here to make the test more deterministic.
102 message_latch_.Reset();
103 task_runner->PostTask([&, io_manager = shell->GetIOManager()]() {
104 io_manager->GetSkiaUnrefQueue()->Drain();
105 message_latch_.Signal();
106 });
107 message_latch_.Wait();
108
109 if (current_display_list_) {
110 EXPECT_TRUE(current_display_list_->unique());
111 current_display_list_.reset();
112 }
113
114 EXPECT_TRUE(current_image_->unique());
115 current_image_.reset();
116
117 shell->GetPlatformView()->NotifyDestroyed();
118 DestroyShell(std::move(shell), task_runners);
119}
bool unique() const
Definition SkRefCnt.h:50
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
fml::RefPtr< fml::TaskRunner > GetCurrentTaskRunner()

◆ TEST_F() [585/876]

flutter::testing::TEST_F ( ImageFilterLayerDiffTest  ,
ImageFilterLayer   
)

Definition at line 625 of file image_filter_layer_unittests.cc.

625 {
626 auto dl_blur_filter =
627 std::make_shared<DlBlurImageFilter>(10, 10, DlTileMode::kClamp);
628 {
629 // tests later assume 30px paint area, fail early if that's not the case
630 SkIRect input_bounds;
631 dl_blur_filter->get_input_device_bounds(SkIRect::MakeWH(10, 10),
632 SkMatrix::I(), input_bounds);
633 EXPECT_EQ(input_bounds, SkIRect::MakeLTRB(-30, -30, 40, 40));
634 }
635
636 MockLayerTree l1;
637 auto filter_layer = std::make_shared<ImageFilterLayer>(dl_blur_filter);
638 auto path = SkPath().addRect(SkRect::MakeLTRB(100, 100, 110, 110));
639 filter_layer->Add(std::make_shared<MockLayer>(path));
640 l1.root()->Add(filter_layer);
641
642 auto damage = DiffLayerTree(l1, MockLayerTree());
643 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(70, 70, 140, 140));
644
645 MockLayerTree l2;
646 auto scale = std::make_shared<TransformLayer>(SkMatrix::Scale(2.0, 2.0));
647 scale->Add(filter_layer);
648 l2.root()->Add(scale);
649
650 damage = DiffLayerTree(l2, MockLayerTree());
651 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(140, 140, 280, 280));
652
653 MockLayerTree l3;
654 l3.root()->Add(scale);
655
656 // path outside of ImageFilterLayer
657 auto path1 = SkPath().addRect(SkRect::MakeLTRB(130, 130, 140, 140));
658 l3.root()->Add(std::make_shared<MockLayer>(path1));
659 damage = DiffLayerTree(l3, l2);
660 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(130, 130, 140, 140));
661
662 // path intersecting ImageFilterLayer, shouldn't trigger entire
663 // ImageFilterLayer repaint
664 MockLayerTree l4;
665 l4.root()->Add(scale);
666 auto path2 = SkPath().addRect(SkRect::MakeLTRB(130, 130, 141, 141));
667 l4.root()->Add(std::make_shared<MockLayer>(path2));
668 damage = DiffLayerTree(l4, l3);
669 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(130, 130, 141, 141));
670}

◆ TEST_F() [586/876]

flutter::testing::TEST_F ( ImageFilterLayerDiffTest  ,
ImageFilterLayerInflatestChildSize   
)

Definition at line 672 of file image_filter_layer_unittests.cc.

672 {
673 auto dl_blur_filter =
674 std::make_shared<DlBlurImageFilter>(10, 10, DlTileMode::kClamp);
675
676 {
677 // tests later assume 30px paint area, fail early if that's not the case
678 SkIRect input_bounds;
679 dl_blur_filter->get_input_device_bounds(SkIRect::MakeWH(10, 10),
680 SkMatrix::I(), input_bounds);
681 EXPECT_EQ(input_bounds, SkIRect::MakeLTRB(-30, -30, 40, 40));
682 }
683
684 MockLayerTree l1;
685
686 // Use nested filter layers to check if both contribute to child bounds
687 auto filter_layer_1_1 = std::make_shared<ImageFilterLayer>(dl_blur_filter);
688 auto filter_layer_1_2 = std::make_shared<ImageFilterLayer>(dl_blur_filter);
689 filter_layer_1_1->Add(filter_layer_1_2);
690 auto path = SkPath().addRect(SkRect::MakeLTRB(100, 100, 110, 110));
691 filter_layer_1_2->Add(
692 std::make_shared<MockLayer>(path, DlPaint(DlColor::kYellow())));
693 l1.root()->Add(filter_layer_1_1);
694
695 // second layer tree with identical filter layers but different child layer
696 MockLayerTree l2;
697 auto filter_layer2_1 = std::make_shared<ImageFilterLayer>(dl_blur_filter);
698 filter_layer2_1->AssignOldLayer(filter_layer_1_1.get());
699 auto filter_layer2_2 = std::make_shared<ImageFilterLayer>(dl_blur_filter);
700 filter_layer2_2->AssignOldLayer(filter_layer_1_2.get());
701 filter_layer2_1->Add(filter_layer2_2);
702 filter_layer2_2->Add(
703 std::make_shared<MockLayer>(path, DlPaint(DlColor::kRed())));
704 l2.root()->Add(filter_layer2_1);
705
706 DiffLayerTree(l1, MockLayerTree());
707 auto damage = DiffLayerTree(l2, l1);
708
709 // ensure that filter properly inflated child size
710 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(40, 40, 170, 170));
711}

◆ TEST_F() [587/876]

flutter::testing::TEST_F ( ImageFilterLayerTest  ,
CacheImageFilterLayerSelf   
)

Definition at line 470 of file image_filter_layer_unittests.cc.

470 {
471 auto dl_image_filter = std::make_shared<DlMatrixImageFilter>(
472 SkMatrix(), DlImageSampling::kMipmapLinear);
473
474 auto initial_transform = SkMatrix::Translate(50.0, 25.5);
475 auto other_transform = SkMatrix::Scale(1.0, 2.0);
476 auto child_rect = SkRect::MakeWH(5.0f, 5.0f);
477 const SkPath child_path = SkPath().addRect(child_rect);
478 auto mock_layer = std::make_shared<MockLayer>(child_path);
479 auto offset = SkPoint::Make(53.8, 24.4);
480 auto layer = std::make_shared<ImageFilterLayer>(dl_image_filter, offset);
481 layer->Add(mock_layer);
482
483 SkMatrix cache_ctm = initial_transform;
484 DisplayListBuilder cache_canvas;
485 cache_canvas.Transform(cache_ctm);
486 DisplayListBuilder other_canvas;
487 other_canvas.Transform(other_transform);
489
490 SkMatrix snapped_matrix = SkMatrix::MakeAll( //
491 1, 0, SkScalarRoundToScalar(offset.fX), //
492 0, 1, SkScalarRoundToScalar(offset.fY), //
493 0, 0, 1);
494
495 use_mock_raster_cache();
496 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
497 const auto* cacheable_image_filter_item = layer->raster_cache_item();
498 // frame 1.
499 layer->Preroll(preroll_context());
500
501 layer->Paint(display_list_paint_context());
502 {
503 DisplayListBuilder expected_builder;
504 /* (ImageFilter)layer::Paint */ {
505 expected_builder.Save();
506 {
507 expected_builder.Translate(offset.fX, offset.fY);
508 // Snap to pixel translation due to use of raster cache
509 expected_builder.TransformReset();
510 expected_builder.Transform(snapped_matrix);
511 DlPaint save_paint = DlPaint().setImageFilter(dl_image_filter);
512 expected_builder.SaveLayer(&child_rect, &save_paint);
513 {
514 /* mock_layer::Paint */ {
515 expected_builder.DrawPath(child_path, DlPaint());
516 }
517 }
518 expected_builder.Restore();
519 }
520 expected_builder.Restore();
521 }
523 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
524 }
525
526 // frame 2.
527 layer->Preroll(preroll_context());
528 layer->Paint(display_list_paint_context());
529 // frame 3.
530 layer->Preroll(preroll_context());
531 layer->Paint(display_list_paint_context());
532
533 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
534 // frame1,2 cache the ImageFilter's children layer, frame3 cache the
535 // ImageFilterLayer
536 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)2);
537
538 // ImageFilterLayer default cache itself.
539 EXPECT_EQ(cacheable_image_filter_item->cache_state(),
540 RasterCacheItem::CacheState::kCurrent);
541 EXPECT_EQ(cacheable_image_filter_item->GetId(),
542 RasterCacheKeyID(layer->unique_id(), RasterCacheKeyType::kLayer));
543 EXPECT_TRUE(raster_cache()->Draw(cacheable_image_filter_item->GetId().value(),
544 cache_canvas, &paint));
545 EXPECT_FALSE(raster_cache()->Draw(
546 cacheable_image_filter_item->GetId().value(), other_canvas, &paint));
547
548 layer->Preroll(preroll_context());
549
550 reset_display_list();
551 layer->Paint(display_list_paint_context());
552 {
553 DisplayListBuilder expected_builder;
554 /* (ImageFilter)layer::Paint */ {
555 expected_builder.Save();
556 {
558 raster_cache()->Draw(cacheable_image_filter_item->GetId().value(),
559 expected_builder, nullptr));
560 }
561 expected_builder.Restore();
562 }
564 DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
565 }
566}
#define SkScalarRoundToScalar(x)
Definition SkScalar.h:32

◆ TEST_F() [588/876]

flutter::testing::TEST_F ( ImageFilterLayerTest  ,
EmptyFilterWithOffset   
)

Definition at line 713 of file image_filter_layer_unittests.cc.

713 {
714 const SkRect child_bounds = SkRect::MakeLTRB(10.0f, 11.0f, 19.0f, 20.0f);
715 const SkPath child_path = SkPath().addRect(child_bounds);
716 const DlPaint child_paint = DlPaint(DlColor::kYellow());
717 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
718 const SkPoint offset = SkPoint::Make(5.0f, 6.0f);
719 auto layer = std::make_shared<ImageFilterLayer>(nullptr, offset);
720 layer->Add(mock_layer);
721
722 layer->Preroll(preroll_context());
723 EXPECT_EQ(layer->paint_bounds(), child_bounds.makeOffset(offset));
724}

◆ TEST_F() [589/876]

flutter::testing::TEST_F ( ImageFilterLayerTest  ,
SimpleFilterBounds   
)

Definition at line 171 of file image_filter_layer_unittests.cc.

171 {
172 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
173 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
174 const SkPath child_path = SkPath().addRect(child_bounds);
175 const DlPaint child_paint = DlPaint(DlColor::kYellow());
176 const SkMatrix filter_transform = SkMatrix::Scale(2.0, 2.0);
177
178 auto dl_image_filter = std::make_shared<DlMatrixImageFilter>(
179 filter_transform, DlImageSampling::kMipmapLinear);
180 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
181 auto layer = std::make_shared<ImageFilterLayer>(dl_image_filter);
182 layer->Add(mock_layer);
183
184 const SkRect filter_bounds = SkRect::MakeLTRB(10.0f, 12.0f, 42.0f, 44.0f);
185
186 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
187 layer->Preroll(preroll_context());
188 EXPECT_EQ(layer->paint_bounds(), filter_bounds);
189 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
190 EXPECT_TRUE(layer->needs_painting(paint_context()));
191 EXPECT_EQ(mock_layer->parent_matrix(), initial_transform);
192
193 DisplayListBuilder expected_builder;
194 /* ImageFilterLayer::Paint() */ {
195 DlPaint dl_paint;
196 dl_paint.setImageFilter(dl_image_filter.get());
197 expected_builder.SaveLayer(&child_bounds, &dl_paint);
198 {
199 /* MockLayer::Paint() */ {
200 expected_builder.DrawPath(child_path, DlPaint(DlColor::kYellow()));
201 }
202 }
203 }
204 expected_builder.Restore();
205 auto expected_display_list = expected_builder.Build();
206
207 layer->Paint(display_list_paint_context());
208 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_display_list));
209}

◆ TEST_F() [590/876]

flutter::testing::TEST_F ( ImageFilterLayerTest  ,
SimpleFilterWithOffset   
)

Definition at line 119 of file image_filter_layer_unittests.cc.

119 {
120 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
121 const SkRect initial_cull_rect = SkRect::MakeLTRB(0, 0, 100, 100);
122 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
123 const SkPath child_path = SkPath().addRect(child_bounds);
124 const DlPaint child_paint = DlPaint(DlColor::kYellow());
125 const SkPoint layer_offset = SkPoint::Make(5.5, 6.5);
126 auto dl_image_filter = std::make_shared<DlMatrixImageFilter>(
127 SkMatrix(), DlImageSampling::kMipmapLinear);
128 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
129 auto layer =
130 std::make_shared<ImageFilterLayer>(dl_image_filter, layer_offset);
131 layer->Add(mock_layer);
132
133 SkMatrix child_matrix = initial_transform;
134 child_matrix.preTranslate(layer_offset.fX, layer_offset.fY);
135 const SkRect child_rounded_bounds =
136 SkRect::MakeLTRB(10.5f, 12.5f, 26.5f, 28.5f);
137
138 preroll_context()->state_stack.set_preroll_delegate(initial_cull_rect,
139 initial_transform);
140 layer->Preroll(preroll_context());
141 EXPECT_EQ(layer->paint_bounds(), child_rounded_bounds);
142 EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
143 EXPECT_TRUE(layer->needs_painting(paint_context()));
144 EXPECT_EQ(mock_layer->parent_matrix(), child_matrix);
145 EXPECT_EQ(preroll_context()->state_stack.device_cull_rect(),
146 initial_cull_rect);
147
148 DisplayListBuilder expected_builder;
149 /* ImageFilterLayer::Paint() */ {
150 expected_builder.Save();
151 {
152 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
153 DlPaint dl_paint;
154 dl_paint.setImageFilter(dl_image_filter.get());
155 expected_builder.SaveLayer(&child_bounds, &dl_paint);
156 {
157 /* MockLayer::Paint() */ {
158 expected_builder.DrawPath(child_path, DlPaint(DlColor::kYellow()));
159 }
160 }
161 expected_builder.Restore();
162 }
163 expected_builder.Restore();
164 }
165 auto expected_display_list = expected_builder.Build();
166
167 layer->Paint(display_list_paint_context());
168 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_display_list));
169}

◆ TEST_F() [591/876]

flutter::testing::TEST_F ( IsolateStartupFailureTest  ,
HandlesIsolateInitializationFailureCorrectly   
)

Definition at line 348 of file dart_isolate_unittests.cc.

349 {
350 AddNativeCallback("MakeNextIsolateSpawnFail",
353 })));
354 AddNativeCallback("NotifyNative",
356 ([this](Dart_NativeArguments args) { NotifyDone(); })));
357 auto settings = CreateSettingsForFixture();
358 auto vm_ref = DartVMRef::Create(settings);
359 auto thread = CreateNewThread();
360 TaskRunners task_runners(GetCurrentTestName(), //
361 thread, //
362 thread, //
363 thread, //
364 thread //
365 );
366 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners,
367 "testIsolateStartupFailure", {},
369 ASSERT_TRUE(isolate);
370 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
371 WaitForDone();
372}
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library)

◆ TEST_F() [592/876]

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

Definition at line 1240 of file keyboard_unittests.cc.

1240 {
1241 KeyboardTester tester{GetContext()};
1242 tester.Responding(false);
1243
1244 // German Keyboard layout
1245
1246 // Press AltGr, which Win32 precedes with a ContrlLeft down.
1247 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1248 KeyStateChange{VK_LCONTROL, true, true},
1249 WmKeyDownInfo{VK_LCONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1250 kWmResultZero),
1251 KeyStateChange{VK_RMENU, true, true},
1252 WmKeyDownInfo{VK_MENU, kScanCodeAlt, kExtended, kWasUp}.Build(
1253 kWmResultZero)});
1254
1255 EXPECT_EQ(tester.key_calls.size(), 2);
1257 kPhysicalControlLeft, kLogicalControlLeft, "",
1258 kNotSynthesized);
1260 kPhysicalAltRight, kLogicalAltRight, "",
1261 kNotSynthesized);
1262 tester.clear_key_calls();
1263 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1264
1265 // Press Q
1266 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1267 WmKeyDownInfo{kVirtualKeyQ, kScanCodeKeyQ, kNotExtended, kWasUp}.Build(
1268 kWmResultZero),
1269 WmCharInfo{'@', kScanCodeKeyQ, kNotExtended, kWasUp}.Build(
1270 kWmResultZero)});
1271
1272 EXPECT_EQ(tester.key_calls.size(), 2);
1274 kPhysicalKeyQ, kLogicalKeyQ, "@", kNotSynthesized);
1275 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"@");
1276 tester.clear_key_calls();
1277 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1278
1279 // Release Q
1280 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1281 WmKeyUpInfo{kVirtualKeyQ, kScanCodeKeyQ, kNotExtended}.Build(
1282 kWmResultZero)});
1283
1284 EXPECT_EQ(tester.key_calls.size(), 1);
1286 kPhysicalKeyQ, kLogicalKeyQ, "", kNotSynthesized);
1287 tester.clear_key_calls();
1288 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1289
1290 // Release AltGr. Win32 doesn't dispatch ControlLeft up. Instead Flutter will
1291 // forge one. The AltGr is a system key, therefore will be handled by Win32's
1292 // default WndProc.
1293 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1294 KeyStateChange{VK_LCONTROL, false, true},
1295 ExpectForgedMessage{
1296 WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1297 kWmResultZero)},
1298 KeyStateChange{VK_RMENU, false, true},
1299 WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kExtended}.Build(
1300 kWmResultDefault)});
1301
1302 EXPECT_EQ(tester.key_calls.size(), 2);
1304 kPhysicalControlLeft, kLogicalControlLeft, "",
1305 kNotSynthesized);
1307 kPhysicalAltRight, kLogicalAltRight, "",
1308 kNotSynthesized);
1309 tester.clear_key_calls();
1310 // The sys key up must not be redispatched. The forged ControlLeft up will.
1311 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1312}
#define EXPECT_CALL_IS_TEXT(_key_call, u16_string)
#define EXPECT_CALL_IS_EVENT(_key_call, _type, _physical, _logical, _character, _synthesized)
struct flutter::testing::WmKeyDownInfo WmKeyDownInfo
struct flutter::testing::WmSysKeyUpInfo WmSysKeyUpInfo
struct flutter::testing::WmKeyUpInfo WmKeyUpInfo

◆ TEST_F() [593/876]

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

Definition at line 1327 of file keyboard_unittests.cc.

1327 {
1328 KeyboardTester tester{GetContext()};
1329 tester.Responding(false);
1330
1331 // 1. AltGr down.
1332
1333 // The key down event causes a ControlLeft down and a AltRight (extended
1334 // AltLeft) down.
1335 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1336 KeyStateChange{VK_LCONTROL, true, true},
1337 WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1338 kWmResultZero),
1339 KeyStateChange{VK_RMENU, true, true},
1340 WmKeyDownInfo{VK_MENU, kScanCodeAlt, kExtended, kWasUp}.Build(
1341 kWmResultZero)});
1342
1343 EXPECT_EQ(tester.key_calls.size(), 2);
1345 kPhysicalControlLeft, kLogicalControlLeft, "",
1346 kNotSynthesized);
1348 kPhysicalAltRight, kLogicalAltRight, "",
1349 kNotSynthesized);
1350 tester.clear_key_calls();
1351 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1352
1353 // 2. AltGr up.
1354
1355 // The key up event only causes a AltRight (extended AltLeft) up.
1356 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1357 KeyStateChange{VK_LCONTROL, false, true},
1358 ExpectForgedMessage{
1359 WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1360 kWmResultZero)},
1361 KeyStateChange{VK_RMENU, false, true},
1362 WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kExtended}.Build(
1363 kWmResultDefault)});
1364 EXPECT_EQ(tester.key_calls.size(), 2);
1366 kPhysicalControlLeft, kLogicalControlLeft, "",
1367 kNotSynthesized);
1369 kPhysicalAltRight, kLogicalAltRight, "",
1370 kNotSynthesized);
1371 tester.clear_key_calls();
1372 // The sys key up must not be redispatched. The forged ControlLeft up will.
1373 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1374
1375 // 3. AltGr down (or: ControlLeft down then AltRight down.)
1376
1377 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1378 KeyStateChange{VK_LCONTROL, true, false},
1379 WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1380 kWmResultZero),
1381 KeyStateChange{VK_RMENU, true, true},
1382 WmKeyDownInfo{VK_MENU, kScanCodeAlt, kExtended, kWasUp}.Build(
1383 kWmResultZero)});
1384
1385 EXPECT_EQ(tester.key_calls.size(), 2);
1387 kPhysicalControlLeft, kLogicalControlLeft, "",
1388 kNotSynthesized);
1390 kPhysicalAltRight, kLogicalAltRight, "",
1391 kNotSynthesized);
1392 tester.clear_key_calls();
1393 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1394
1395 // 4. AltGr up.
1396
1397 // The key up event only causes a AltRight (extended AltLeft) up.
1398 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1399 KeyStateChange{VK_LCONTROL, false, false},
1400 ExpectForgedMessage{
1401 WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1402 kWmResultZero)},
1403 KeyStateChange{VK_RMENU, false, false},
1404 WmSysKeyUpInfo{VK_MENU, kScanCodeAlt, kExtended}.Build(
1405 kWmResultDefault)});
1406 EXPECT_EQ(tester.key_calls.size(), 2);
1408 kPhysicalControlLeft, kLogicalControlLeft, "",
1409 kNotSynthesized);
1411 kPhysicalAltRight, kLogicalAltRight, "",
1412 kNotSynthesized);
1413 tester.clear_key_calls();
1414 // The sys key up must not be redispatched. The forged ControlLeft up will.
1415 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1416
1417 // 5. For key sequence 2: a real ControlLeft up.
1418 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1419 WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1420 kWmResultZero)});
1421 EXPECT_EQ(tester.key_calls.size(), 1);
1423 kNotSynthesized);
1424 tester.clear_key_calls();
1425 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
1426}

◆ TEST_F() [594/876]

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

Definition at line 837 of file keyboard_unittests.cc.

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

◆ TEST_F() [595/876]

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

Definition at line 870 of file keyboard_unittests.cc.

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

◆ TEST_F() [596/876]

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

Definition at line 631 of file keyboard_unittests.cc.

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

◆ TEST_F() [597/876]

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

Definition at line 662 of file keyboard_unittests.cc.

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

◆ TEST_F() [598/876]

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

Definition at line 1150 of file keyboard_unittests.cc.

1150 {
1151 KeyboardTester tester{GetContext()};
1152 tester.Responding(false);
1153
1154 // US Keyboard layout
1155
1156 // Press ControlLeft
1157 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1158 KeyStateChange{VK_LCONTROL, true, true},
1159 WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1160 kWmResultZero)});
1161
1162 EXPECT_EQ(tester.key_calls.size(), 1);
1164 kPhysicalControlLeft, kLogicalControlLeft, "",
1165 kNotSynthesized);
1166 tester.clear_key_calls();
1167 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1168
1169 // Press 1
1170 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1171 WmKeyDownInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended, kWasUp}
1172 .Build(kWmResultZero)});
1173
1174 EXPECT_EQ(tester.key_calls.size(), 1);
1176 kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1177 tester.clear_key_calls();
1178 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1179
1180 // Release 1
1181 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1182 WmKeyUpInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended}.Build(
1183 kWmResultZero)});
1184
1185 EXPECT_EQ(tester.key_calls.size(), 1);
1187 kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1188 tester.clear_key_calls();
1189 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1190
1191 // Release ControlLeft
1192 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1193 KeyStateChange{VK_LCONTROL, false, true},
1194 WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1195 kWmResultZero)});
1196
1197 EXPECT_EQ(tester.key_calls.size(), 1);
1199 kPhysicalControlLeft, kLogicalControlLeft, "",
1200 kNotSynthesized);
1201 tester.clear_key_calls();
1202 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1203}

◆ TEST_F() [599/876]

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

Definition at line 1092 of file keyboard_unittests.cc.

1092 {
1093 KeyboardTester tester{GetContext()};
1094 tester.Responding(false);
1095
1096 // US Keyboard layout
1097
1098 // Press ControlLeft
1099 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1100 KeyStateChange{VK_LCONTROL, true, true},
1101 WmKeyDownInfo{VK_CONTROL, kScanCodeControl, kNotExtended, kWasUp}.Build(
1102 kWmResultZero)});
1103
1104 EXPECT_EQ(tester.key_calls.size(), 1);
1106 kPhysicalControlLeft, kLogicalControlLeft, "",
1107 kNotSynthesized);
1108 tester.clear_key_calls();
1109 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1110
1111 // Press A
1112 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1114 kWmResultZero),
1115 WmCharInfo{0x01, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1116 kWmResultZero)});
1117
1118 EXPECT_EQ(tester.key_calls.size(), 1);
1120 kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
1121 tester.clear_key_calls();
1122 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1123
1124 // Release A
1125 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1127 kWmResultZero)});
1128
1129 EXPECT_EQ(tester.key_calls.size(), 1);
1131 kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
1132 tester.clear_key_calls();
1133 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1134
1135 // Release ControlLeft
1136 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1137 KeyStateChange{VK_LCONTROL, false, true},
1138 WmKeyUpInfo{VK_CONTROL, kScanCodeControl, kNotExtended}.Build(
1139 kWmResultZero)});
1140
1141 EXPECT_EQ(tester.key_calls.size(), 1);
1143 kPhysicalControlLeft, kLogicalControlLeft, "",
1144 kNotSynthesized);
1145 tester.clear_key_calls();
1146 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1147}

◆ TEST_F() [600/876]

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

Definition at line 771 of file keyboard_unittests.cc.

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

◆ TEST_F() [601/876]

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

Definition at line 804 of file keyboard_unittests.cc.

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

◆ TEST_F() [602/876]

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

Definition at line 1430 of file keyboard_unittests.cc.

1430 {
1431 KeyboardTester tester{GetContext()};
1432 tester.Responding(false);
1433
1434 tester.SetLayout(LayoutFrench);
1435
1436 // Press ^¨ (US: Left bracket)
1437 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1438 WmKeyDownInfo{0xDD, kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1439 kWmResultZero),
1440 WmDeadCharInfo{'^', kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1441 kWmResultZero)});
1442
1443 EXPECT_EQ(tester.key_calls.size(), 1);
1445 kPhysicalBracketLeft, kLogicalBracketRight, "^",
1446 kNotSynthesized);
1447 tester.clear_key_calls();
1448 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1449
1450 // Release ^¨
1451 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1452 WmKeyUpInfo{0xDD, kScanCodeBracketLeft, kNotExtended}.Build(
1453 kWmResultZero)});
1454
1455 EXPECT_EQ(tester.key_calls.size(), 1);
1457 kPhysicalBracketLeft, kLogicalBracketRight, "",
1458 kNotSynthesized);
1459 tester.clear_key_calls();
1460 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1461
1462 // Press E
1463 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1464 WmKeyDownInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1465 kWmResultZero),
1466 WmCharInfo{0xEA, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1467 kWmResultZero)});
1468
1469 EXPECT_EQ(tester.key_calls.size(), 2);
1471 kPhysicalKeyE, kLogicalKeyE, "ê", kNotSynthesized);
1472 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"ê");
1473 tester.clear_key_calls();
1474 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1475
1476 // Release E
1477 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1478 WmKeyUpInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended}.Build(
1479 kWmResultZero)});
1480
1481 EXPECT_EQ(tester.key_calls.size(), 1);
1483 kPhysicalKeyE, kLogicalKeyE, "", kNotSynthesized);
1484 tester.clear_key_calls();
1485 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1486}

◆ TEST_F() [603/876]

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

Definition at line 1574 of file keyboard_unittests.cc.

1574 {
1575 KeyboardTester tester{GetContext()};
1576 tester.Responding(false);
1577
1578 tester.SetLayout(LayoutFrench);
1579
1580 // Press ^¨ (US: Left bracket)
1581 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1582 WmKeyDownInfo{0xDD, kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1583 kWmResultZero),
1584 WmDeadCharInfo{'^', kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1585 kWmResultZero)});
1586
1587 EXPECT_EQ(tester.key_calls.size(), 1);
1589 kPhysicalBracketLeft, kLogicalBracketRight, "^",
1590 kNotSynthesized);
1591 tester.clear_key_calls();
1592 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1593
1594 // Release ^¨
1595 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1596 WmKeyUpInfo{0xDD, kScanCodeBracketLeft, kNotExtended}.Build(
1597 kWmResultZero)});
1598
1599 EXPECT_EQ(tester.key_calls.size(), 1);
1601 kPhysicalBracketLeft, kLogicalBracketRight, "",
1602 kNotSynthesized);
1603 tester.clear_key_calls();
1604 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1605
1606 // Press 1
1607 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1608 WmKeyDownInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended, kWasUp}
1609 .Build(kWmResultZero),
1610 WmCharInfo{'^', kScanCodeDigit1, kNotExtended, kWasUp}.Build(
1611 kWmResultZero),
1612 WmCharInfo{'&', kScanCodeDigit1, kNotExtended, kWasUp}.Build(
1613 kWmResultZero)});
1614
1615 EXPECT_EQ(tester.key_calls.size(), 3);
1617 kPhysicalDigit1, kLogicalDigit1, "^", kNotSynthesized);
1618 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"^");
1619 EXPECT_CALL_IS_TEXT(tester.key_calls[2], u"&");
1620 tester.clear_key_calls();
1621 // TODO(dkwingsmt): This count should probably be 3. Currently the '^'
1622 // message is redispatched due to being part of the KeyDown session, which is
1623 // not handled by the framework, while the '&' message is not redispatched
1624 // for being a standalone message. We should resolve this inconsistency.
1625 // https://github.com/flutter/flutter/issues/98306
1626 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1627
1628 // Release 1
1629 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1630 WmKeyUpInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended}.Build(
1631 kWmResultZero)});
1632
1633 EXPECT_EQ(tester.key_calls.size(), 1);
1635 kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1636 tester.clear_key_calls();
1637 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1638}

◆ TEST_F() [604/876]

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

Definition at line 1643 of file keyboard_unittests.cc.

1643 {
1644 KeyboardTester tester{GetContext()};
1645 tester.Responding(false);
1646
1647 // US INTL layout.
1648
1649 // Press `
1650 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1651 WmKeyDownInfo{0xC0, kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1652 kWmResultZero),
1653 WmDeadCharInfo{'`', kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1654 kWmResultZero)});
1655
1656 EXPECT_EQ(tester.key_calls.size(), 1);
1658 kPhysicalBackquote, kLogicalBackquote, "`",
1659 kNotSynthesized);
1660 tester.clear_key_calls();
1661 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1662
1663 // Release `
1664 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1665 WmKeyUpInfo{0xC0, kScanCodeBackquote, kNotExtended}.Build(
1666 kWmResultZero)});
1667
1668 EXPECT_EQ(tester.key_calls.size(), 1);
1670 kPhysicalBackquote, kLogicalBackquote, "",
1671 kNotSynthesized);
1672 tester.clear_key_calls();
1673 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1674
1675 // Press ` again.
1676 // The response should be slow.
1677 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
1678 tester.LateResponding(
1679 [&recorded_callbacks](
1680 const FlutterKeyEvent* event,
1681 MockKeyResponseController::ResponseCallback callback) {
1682 recorded_callbacks.push_back(callback);
1683 });
1684
1685 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1686 WmKeyDownInfo{0xC0, kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1687 kWmResultZero),
1688 WmCharInfo{'`', kScanCodeBackquote, kNotExtended, kWasUp, kBeingReleased,
1689 kNoContext, 1, /*bit25*/ true}
1690 .Build(kWmResultZero),
1691 WmCharInfo{'`', kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1692 kWmResultZero)});
1693
1694 EXPECT_EQ(recorded_callbacks.size(), 1);
1695 EXPECT_EQ(tester.key_calls.size(), 1);
1697 kPhysicalBackquote, kLogicalBackquote, "`",
1698 kNotSynthesized);
1699 tester.clear_key_calls();
1700 // Key down event responded with false.
1701 recorded_callbacks.front()(false);
1702 EXPECT_EQ(tester.key_calls.size(), 2);
1703 EXPECT_CALL_IS_TEXT(tester.key_calls[0], u"`");
1704 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"`");
1705 tester.clear_key_calls();
1706 // TODO(dkwingsmt): This count should probably be 3. See the comment above
1707 // that is marked with the same issue.
1708 // https://github.com/flutter/flutter/issues/98306
1709 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1710
1711 tester.Responding(false);
1712
1713 // Release `
1714 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1715 WmKeyUpInfo{0xC0, kScanCodeBackquote, kNotExtended}.Build(
1716 kWmResultZero)});
1717
1718 EXPECT_EQ(tester.key_calls.size(), 1);
1720 kPhysicalBackquote, kLogicalBackquote, "",
1721 kNotSynthesized);
1722 tester.clear_key_calls();
1723 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1724}

◆ TEST_F() [605/876]

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

Definition at line 1493 of file keyboard_unittests.cc.

1493 {
1494 KeyboardTester tester{GetContext()};
1495 tester.Responding(false);
1496
1497 // Press ShiftLeft
1498 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1499 KeyStateChange{VK_LSHIFT, true, true},
1500 WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
1501 kWmResultZero)});
1502
1503 EXPECT_EQ(tester.key_calls.size(), 1);
1505 kPhysicalShiftLeft, kLogicalShiftLeft, "",
1506 kNotSynthesized);
1507 tester.clear_key_calls();
1508 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1509
1510 // Press 6^
1511 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1512 WmKeyDownInfo{'6', kScanCodeDigit6, kNotExtended, kWasUp}.Build(
1513 kWmResultZero),
1514 WmDeadCharInfo{'^', kScanCodeDigit6, kNotExtended, kWasUp}.Build(
1515 kWmResultZero)});
1516
1517 EXPECT_EQ(tester.key_calls.size(), 1);
1519 kPhysicalDigit6, kLogicalDigit6, "6", kNotSynthesized);
1520 tester.clear_key_calls();
1521 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1522
1523 // Release 6^
1524 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1525 WmKeyUpInfo{'6', kScanCodeDigit6, kNotExtended}.Build(kWmResultZero)});
1526
1527 EXPECT_EQ(tester.key_calls.size(), 1);
1529 kPhysicalDigit6, kLogicalDigit6, "", kNotSynthesized);
1530 tester.clear_key_calls();
1531 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1532
1533 // Release ShiftLeft
1534 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1535 KeyStateChange{VK_LSHIFT, false, true},
1537 kWmResultZero)});
1538
1539 EXPECT_EQ(tester.key_calls.size(), 1);
1541 kPhysicalShiftLeft, kLogicalShiftLeft, "",
1542 kNotSynthesized);
1543 tester.clear_key_calls();
1544 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1545
1546 // Press E
1547 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1548 WmKeyDownInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1549 kWmResultZero),
1550 WmCharInfo{0xEA, kScanCodeKeyE, kNotExtended, kWasUp}.Build(
1551 kWmResultZero)});
1552
1553 EXPECT_EQ(tester.key_calls.size(), 2);
1555 kPhysicalKeyE, kLogicalKeyE, "ê", kNotSynthesized);
1556 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"ê");
1557 tester.clear_key_calls();
1558 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1559
1560 // Release E
1561 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1562 WmKeyUpInfo{kVirtualKeyE, kScanCodeKeyE, kNotExtended}.Build(
1563 kWmResultZero)});
1564
1565 EXPECT_EQ(tester.key_calls.size(), 1);
1567 kPhysicalKeyE, kLogicalKeyE, "", kNotSynthesized);
1568 tester.clear_key_calls();
1569 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1570}
constexpr int kScanCodeShiftLeft

◆ TEST_F() [606/876]

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

Definition at line 1207 of file keyboard_unittests.cc.

1207 {
1208 KeyboardTester tester{GetContext()};
1209 tester.Responding(false);
1210
1211 tester.SetLayout(LayoutFrench);
1212
1213 // Press 1
1214 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1215 WmKeyDownInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended, kWasUp}
1216 .Build(kWmResultZero),
1217 WmCharInfo{'&', kScanCodeDigit1, kNotExtended, kWasUp}.Build(
1218 kWmResultZero)});
1219
1220 EXPECT_EQ(tester.key_calls.size(), 2);
1222 kPhysicalDigit1, kLogicalDigit1, "&", kNotSynthesized);
1223 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"&");
1224 tester.clear_key_calls();
1225 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1226
1227 // Release 1
1228 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1229 WmKeyUpInfo{kVirtualDigit1, kScanCodeDigit1, kNotExtended}.Build(
1230 kWmResultZero)});
1231
1232 EXPECT_EQ(tester.key_calls.size(), 1);
1234 kPhysicalDigit1, kLogicalDigit1, "", kNotSynthesized);
1235 tester.clear_key_calls();
1236 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1237}

◆ TEST_F() [607/876]

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

Definition at line 2466 of file keyboard_unittests.cc.

2466 {
2467 KeyboardTester tester{GetContext()};
2468 tester.Responding(false);
2469
2470 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2471 WmKeyDownInfo{VK_CAPITAL, 0, kNotExtended}.Build(),
2472 WmKeyUpInfo{VK_CAPITAL, 0, kNotExtended}.Build()});
2473
2474 tester.clear_key_calls();
2475}

◆ TEST_F() [608/876]

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

Definition at line 1992 of file keyboard_unittests.cc.

1992 {
1993 KeyboardTester tester{GetContext()};
1994 tester.Responding(false);
1995
1996 // US Keyboard layout.
1997
1998 // There should be preceding key events to make the keyboard into IME mode.
1999 // Omit them in this test since they are not relavent.
2000
2001 // Press CtrlRight in IME mode.
2002 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2003 KeyStateChange{VK_RCONTROL, true, false},
2004 WmKeyDownInfo{VK_PROCESSKEY, kScanCodeControl, kExtended, kWasUp}.Build(
2005 kWmResultZero)});
2006
2007 EXPECT_EQ(tester.key_calls.size(), 1);
2009 kNotSynthesized);
2010 tester.clear_key_calls();
2011 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2012}

◆ TEST_F() [609/876]

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

Definition at line 568 of file keyboard_unittests.cc.

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

◆ TEST_F() [610/876]

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

Definition at line 599 of file keyboard_unittests.cc.

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

◆ TEST_F() [611/876]

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

Definition at line 905 of file keyboard_unittests.cc.

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

◆ TEST_F() [612/876]

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

Definition at line 937 of file keyboard_unittests.cc.

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

◆ TEST_F() [613/876]

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

Definition at line 1727 of file keyboard_unittests.cc.

1727 {
1728 KeyboardTester tester{GetContext()};
1729 tester.Responding(false);
1730
1731 // Gothic Keyboard layout. (We need a layout that yields non-BMP characters
1732 // without IME, which is actually very rare.)
1733
1734 // Press key W of a US keyboard, which should yield character '𐍅'.
1735 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1736 WmKeyDownInfo{kVirtualKeyW, kScanCodeKeyW, kNotExtended, kWasUp}.Build(
1737 kWmResultZero),
1738 WmCharInfo{0xd800, kScanCodeKeyW, kNotExtended, kWasUp}.Build(
1739 kWmResultZero),
1740 WmCharInfo{0xdf45, kScanCodeKeyW, kNotExtended, kWasUp}.Build(
1741 kWmResultZero)});
1742
1743 const char* st = tester.key_calls[0].key_event.character;
1744
1745 EXPECT_EQ(tester.key_calls.size(), 2);
1747 kPhysicalKeyW, kLogicalKeyW, "𐍅", kNotSynthesized);
1748 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"𐍅");
1749 tester.clear_key_calls();
1750 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 3);
1751
1752 // Release W
1753 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1754 WmKeyUpInfo{kVirtualKeyW, kScanCodeKeyW, kNotExtended}.Build(
1755 kWmResultZero)});
1756
1757 EXPECT_EQ(tester.key_calls.size(), 1);
1759 kPhysicalKeyW, kLogicalKeyW, "", kNotSynthesized);
1760 tester.clear_key_calls();
1761 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1762}

◆ TEST_F() [614/876]

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

Definition at line 971 of file keyboard_unittests.cc.

971 {
972 KeyboardTester tester{GetContext()};
973 tester.Responding(true);
974
975 // Press A
976 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
977 WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
978 kWmResultZero),
979 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
980 kWmResultZero)});
981
982 // Hold A
983 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
985 kWmResultZero),
986 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasDown}.Build(
987 kWmResultZero)});
988
989 EXPECT_EQ(tester.key_calls.size(), 2);
991 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
993 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
994 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
995}

◆ TEST_F() [615/876]

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

Definition at line 1000 of file keyboard_unittests.cc.

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

◆ TEST_F() [616/876]

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

Definition at line 1032 of file keyboard_unittests.cc.

1032 {
1033 KeyboardTester tester{GetContext()};
1034 tester.Responding(false);
1035
1036 // US Keyboard layout
1037
1038 // Press ShiftLeft
1039 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1040 KeyStateChange{VK_LSHIFT, true, true},
1041 WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
1042 kWmResultZero)});
1043
1044 EXPECT_EQ(tester.key_calls.size(), 1);
1046 kPhysicalShiftLeft, kLogicalShiftLeft, "",
1047 kNotSynthesized);
1048 tester.clear_key_calls();
1049 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1050
1051 // Press A
1052 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1054 kWmResultZero),
1055 WmCharInfo{'A', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
1056 kWmResultZero)});
1057
1058 EXPECT_EQ(tester.key_calls.size(), 2);
1060 kPhysicalKeyA, kLogicalKeyA, "A", kNotSynthesized);
1061 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"A");
1062 tester.clear_key_calls();
1063 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
1064
1065 // Release ShiftLeft
1066 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1067 KeyStateChange{VK_LSHIFT, false, true},
1069 kWmResultZero)});
1070
1071 EXPECT_EQ(tester.key_calls.size(), 1);
1073 kPhysicalShiftLeft, kLogicalShiftLeft, "",
1074 kNotSynthesized);
1075 tester.clear_key_calls();
1076 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1077
1078 // Release A
1079 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1081 kWmResultZero)});
1082
1083 EXPECT_EQ(tester.key_calls.size(), 1);
1085 kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
1086 tester.clear_key_calls();
1087 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1088}

◆ TEST_F() [617/876]

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

Definition at line 693 of file keyboard_unittests.cc.

693 {
694 KeyboardTester tester{GetContext()};
695 tester.Responding(false);
696
697 // US Keyboard layout
698
699 // Press ShiftLeft
700 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
701 KeyStateChange{VK_LSHIFT, true, false},
702 WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
703 kWmResultZero)});
704
705 EXPECT_EQ(tester.key_calls.size(), 1);
707 kPhysicalShiftLeft, kLogicalShiftLeft, "",
708 kNotSynthesized);
709 tester.clear_key_calls();
710 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
711
712 // Hold ShiftLeft
713 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
715 kWmResultZero)});
716
717 EXPECT_EQ(tester.key_calls.size(), 1);
719 kPhysicalShiftLeft, kLogicalShiftLeft, "",
720 kNotSynthesized);
721 tester.clear_key_calls();
722 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
723
724 // Release ShiftLeft
725 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
726 KeyStateChange{VK_LSHIFT, false, true},
728 kWmResultZero)});
729
730 EXPECT_EQ(tester.key_calls.size(), 1);
732 kPhysicalShiftLeft, kLogicalShiftLeft, "",
733 kNotSynthesized);
734 tester.clear_key_calls();
735 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
736}

◆ TEST_F() [618/876]

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

Definition at line 738 of file keyboard_unittests.cc.

738 {
739 KeyboardTester tester{GetContext()};
740 tester.Responding(false);
741
742 // US Keyboard layout
743
744 // Press ShiftRight
745 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
746 KeyStateChange{VK_RSHIFT, true, false},
747 WmKeyDownInfo{VK_SHIFT, kScanCodeShiftRight, kNotExtended, kWasUp}.Build(
748 kWmResultZero)});
749
750 EXPECT_EQ(tester.key_calls.size(), 1);
752 kPhysicalShiftRight, kLogicalShiftRight, "",
753 kNotSynthesized);
754 tester.clear_key_calls();
755 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
756
757 // Release ShiftRight
758 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
759 KeyStateChange{VK_RSHIFT, false, true},
761 kWmResultZero)});
762
763 EXPECT_EQ(tester.key_calls.size(), 1);
765 kPhysicalShiftRight, kLogicalShiftRight, "",
766 kNotSynthesized);
767 tester.clear_key_calls();
768 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
769}
constexpr int kScanCodeShiftRight

◆ TEST_F() [619/876]

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

Definition at line 2059 of file keyboard_unittests.cc.

2059 {
2060 KeyboardTester tester{GetContext()};
2061
2062 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2063
2064 // Store callbacks to manually call them.
2065 tester.LateResponding(
2066 [&recorded_callbacks](
2067 const FlutterKeyEvent* event,
2068 MockKeyResponseController::ResponseCallback callback) {
2069 recorded_callbacks.push_back(callback);
2070 });
2071
2072 // Press A
2073 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2074 WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2075 kWmResultZero),
2076 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2077 kWmResultZero)});
2078
2079 // Hold A
2080 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2082 kWmResultZero),
2083 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasDown}.Build(
2084 kWmResultZero)});
2085
2086 EXPECT_EQ(tester.key_calls.size(), 1);
2088 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2089 EXPECT_EQ(recorded_callbacks.size(), 1);
2090 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2091
2092 // The first response.
2093 recorded_callbacks.front()(false);
2094
2095 EXPECT_EQ(tester.key_calls.size(), 3);
2096 EXPECT_EQ(recorded_callbacks.size(), 2);
2097 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2099 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2100 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2101
2102 // The second response.
2103 recorded_callbacks.back()(false);
2104
2105 EXPECT_EQ(tester.key_calls.size(), 4);
2106 EXPECT_CALL_IS_TEXT(tester.key_calls[3], u"a");
2107 tester.clear_key_calls();
2108 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2109}

◆ TEST_F() [620/876]

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

Definition at line 2122 of file keyboard_unittests.cc.

2122 {
2123 KeyboardTester tester{GetContext()};
2124 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2125
2126 // Store callbacks to manually call them.
2127 tester.LateResponding(
2128 [&recorded_callbacks](
2129 const FlutterKeyEvent* event,
2130 MockKeyResponseController::ResponseCallback callback) {
2131 recorded_callbacks.push_back(callback);
2132 });
2133
2134 // Press A
2135 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2136 WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2137 kWmResultZero),
2138 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2139 kWmResultZero)});
2140
2141 EXPECT_EQ(tester.key_calls.size(), 1);
2143 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2144 tester.clear_key_calls();
2145 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2146
2147 // Release A
2148 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2150 kWmResultZero)});
2151
2152 EXPECT_EQ(tester.key_calls.size(), 0);
2153 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2154
2155 // The first down event responded with false.
2156 EXPECT_EQ(recorded_callbacks.size(), 1);
2157 recorded_callbacks.front()(false);
2158
2159 EXPECT_EQ(tester.key_calls.size(), 2);
2160 EXPECT_CALL_IS_TEXT(tester.key_calls[0], u"a");
2162 kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2163 tester.clear_key_calls();
2164 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2165
2166 // Press A again
2167 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2169 kWmResultZero),
2170 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2171 kWmResultZero)});
2172
2173 // Nothing more was dispatched because the first up event hasn't been
2174 // responded yet.
2175 EXPECT_EQ(recorded_callbacks.size(), 2);
2176 EXPECT_EQ(tester.key_calls.size(), 0);
2177 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2178
2179 // The first up event responded with false, which was redispatched, and caused
2180 // the down event to be dispatched.
2181 recorded_callbacks.back()(false);
2182 EXPECT_EQ(tester.key_calls.size(), 1);
2184 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2185 tester.clear_key_calls();
2186 EXPECT_EQ(recorded_callbacks.size(), 3);
2187 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2188
2189 // Release A again
2190 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2192 kWmResultZero)});
2193
2194 EXPECT_EQ(tester.key_calls.size(), 0);
2195 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2196}

◆ TEST_F() [621/876]

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

Definition at line 1764 of file keyboard_unittests.cc.

1764 {
1765 KeyboardTester tester{GetContext()};
1766 tester.Responding(false);
1767
1768 // Two dummy events used to trigger synthesization.
1769 Win32Message event1 =
1770 WmKeyDownInfo{VK_BACK, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
1771 kWmResultZero);
1772 Win32Message event2 =
1773 WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
1774 kWmResultZero);
1775
1776 // ShiftLeft
1777 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1778 KeyStateChange{VK_LSHIFT, true, true}, event1});
1779 EXPECT_EQ(tester.key_calls.size(), 2);
1781 kPhysicalShiftLeft, kLogicalShiftLeft, "", kSynthesized);
1782 tester.clear_key_calls();
1783 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1784
1785 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1786 KeyStateChange{VK_LSHIFT, false, true}, event2});
1787 EXPECT_EQ(tester.key_calls.size(), 2);
1789 kPhysicalShiftLeft, kLogicalShiftLeft, "", kSynthesized);
1790 tester.clear_key_calls();
1791 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1792
1793 // ShiftRight
1794 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1795 KeyStateChange{VK_RSHIFT, true, true}, event1});
1796 EXPECT_EQ(tester.key_calls.size(), 2);
1798 kPhysicalShiftRight, kLogicalShiftRight, "",
1799 kSynthesized);
1800 tester.clear_key_calls();
1801 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1802
1803 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1804 KeyStateChange{VK_RSHIFT, false, true}, event2});
1805 EXPECT_EQ(tester.key_calls.size(), 2);
1807 kPhysicalShiftRight, kLogicalShiftRight, "",
1808 kSynthesized);
1809 tester.clear_key_calls();
1810 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1811
1812 // ControlLeft
1813 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1814 KeyStateChange{VK_LCONTROL, true, true}, event1});
1815 EXPECT_EQ(tester.key_calls.size(), 2);
1817 kPhysicalControlLeft, kLogicalControlLeft, "",
1818 kSynthesized);
1819 tester.clear_key_calls();
1820 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1821
1822 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1823 KeyStateChange{VK_LCONTROL, false, true}, event2});
1824 EXPECT_EQ(tester.key_calls.size(), 2);
1826 kPhysicalControlLeft, kLogicalControlLeft, "",
1827 kSynthesized);
1828 tester.clear_key_calls();
1829 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1830
1831 // ControlRight
1832 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1833 KeyStateChange{VK_RCONTROL, true, true}, event1});
1834 EXPECT_EQ(tester.key_calls.size(), 2);
1836 kPhysicalControlRight, kLogicalControlRight, "",
1837 kSynthesized);
1838 tester.clear_key_calls();
1839 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1840
1841 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1842 KeyStateChange{VK_RCONTROL, false, true}, event2});
1843 EXPECT_EQ(tester.key_calls.size(), 2);
1845 kPhysicalControlRight, kLogicalControlRight, "",
1846 kSynthesized);
1847 tester.clear_key_calls();
1848 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1849
1850 // AltLeft
1851 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1852 KeyStateChange{VK_LMENU, true, true}, event1});
1853 EXPECT_EQ(tester.key_calls.size(), 2);
1855 kPhysicalAltLeft, kLogicalAltLeft, "", kSynthesized);
1856 tester.clear_key_calls();
1857 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1858
1859 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1860 KeyStateChange{VK_LMENU, false, true}, event2});
1861 EXPECT_EQ(tester.key_calls.size(), 2);
1863 kPhysicalAltLeft, kLogicalAltLeft, "", kSynthesized);
1864 tester.clear_key_calls();
1865 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1866
1867 // AltRight
1868 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1869 KeyStateChange{VK_RMENU, true, true}, event1});
1870 EXPECT_EQ(tester.key_calls.size(), 2);
1872 kPhysicalAltRight, kLogicalAltRight, "", kSynthesized);
1873 tester.clear_key_calls();
1874 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1875
1876 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1877 KeyStateChange{VK_RMENU, false, true}, event2});
1878 EXPECT_EQ(tester.key_calls.size(), 2);
1880 kPhysicalAltRight, kLogicalAltRight, "", kSynthesized);
1881 tester.clear_key_calls();
1882 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1883
1884 // MetaLeft
1885 tester.InjectKeyboardChanges(
1886 std::vector<KeyboardChange>{KeyStateChange{VK_LWIN, true, true}, event1});
1887 EXPECT_EQ(tester.key_calls.size(), 2);
1889 kPhysicalMetaLeft, kLogicalMetaLeft, "", kSynthesized);
1890 tester.clear_key_calls();
1891 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1892
1893 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1894 KeyStateChange{VK_LWIN, false, true}, event2});
1895 EXPECT_EQ(tester.key_calls.size(), 2);
1897 kPhysicalMetaLeft, kLogicalMetaLeft, "", kSynthesized);
1898 tester.clear_key_calls();
1899 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1900
1901 // MetaRight
1902 tester.InjectKeyboardChanges(
1903 std::vector<KeyboardChange>{KeyStateChange{VK_RWIN, true, true}, event1});
1904 EXPECT_EQ(tester.key_calls.size(), 2);
1906 kPhysicalMetaRight, kLogicalMetaRight, "", kSynthesized);
1907 tester.clear_key_calls();
1908 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1909
1910 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1911 KeyStateChange{VK_RWIN, false, true}, event2});
1912 EXPECT_EQ(tester.key_calls.size(), 2);
1914 kPhysicalMetaRight, kLogicalMetaRight, "", kSynthesized);
1915 tester.clear_key_calls();
1916 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1917
1918 // CapsLock, phase 0 -> 2 -> 0.
1919 // (For phases, see |SynchronizeCriticalToggledStates|.)
1920 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1921 KeyStateChange{VK_CAPITAL, false, true}, event1});
1922 EXPECT_EQ(tester.key_calls.size(), 3);
1924 kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1926 kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1927 tester.clear_key_calls();
1928 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1929
1930 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1931 KeyStateChange{VK_CAPITAL, false, false}, event2});
1932 EXPECT_EQ(tester.key_calls.size(), 3);
1934 kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1936 kPhysicalCapsLock, kLogicalCapsLock, "", kSynthesized);
1937 tester.clear_key_calls();
1938 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1939
1940 // ScrollLock, phase 0 -> 1 -> 3
1941 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1942 KeyStateChange{VK_SCROLL, true, true}, event1});
1943 EXPECT_EQ(tester.key_calls.size(), 2);
1945 kPhysicalScrollLock, kLogicalScrollLock, "",
1946 kSynthesized);
1947 tester.clear_key_calls();
1948 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1949
1950 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1951 KeyStateChange{VK_SCROLL, true, false}, event2});
1952 EXPECT_EQ(tester.key_calls.size(), 3);
1954 kPhysicalScrollLock, kLogicalScrollLock, "",
1955 kSynthesized);
1957 kPhysicalScrollLock, kLogicalScrollLock, "",
1958 kSynthesized);
1959 tester.clear_key_calls();
1960 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1961
1962 // NumLock, phase 0 -> 3 -> 2
1963 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1964 KeyStateChange{VK_NUMLOCK, true, false}, event1});
1965 // TODO(dkwingsmt): Synthesizing from phase 0 to 3 should yield a full key
1966 // tap and a key down. Fix the algorithm so that the following result becomes
1967 // 4 keycalls with an extra pair of key down and up.
1968 // https://github.com/flutter/flutter/issues/98533
1969 EXPECT_EQ(tester.key_calls.size(), 2);
1971 kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
1972 tester.clear_key_calls();
1973 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1974
1975 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
1976 KeyStateChange{VK_NUMLOCK, false, true}, event2});
1977 EXPECT_EQ(tester.key_calls.size(), 4);
1979 kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
1981 kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
1983 kPhysicalNumLock, kLogicalNumLock, "", kSynthesized);
1984 tester.clear_key_calls();
1985 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1986}

◆ TEST_F() [622/876]

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

Definition at line 2198 of file keyboard_unittests.cc.

2198 {
2199 KeyboardTester tester{GetContext()};
2200 tester.Responding(false);
2201
2202 // US Keyboard layout
2203
2204 tester.InjectPlatformMessage(
2205 "flutter/textinput", "TextInput.setClient",
2206 R"|([108, {"inputAction": "TextInputAction.none"}])|");
2207
2208 // Press Enter
2209 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2210 WmKeyDownInfo{VK_RETURN, kScanCodeEnter, kNotExtended, kWasUp}.Build(
2211 kWmResultZero),
2212 WmCharInfo{'\n', kScanCodeEnter, kNotExtended, kWasUp}.Build(
2213 kWmResultZero)});
2214
2215 EXPECT_EQ(tester.key_calls.size(), 2);
2217 kPhysicalEnter, kLogicalEnter, "", kNotSynthesized);
2219 tester.key_calls[1],
2220 "{"
2221 R"|("method":"TextInputClient.performAction",)|"
2222 R"|("args":[108,"TextInputAction.none"])|"
2223 "}");
2224 tester.clear_key_calls();
2225 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2226
2227 // Release Enter
2228 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2229 WmKeyUpInfo{VK_RETURN, kScanCodeEnter, kNotExtended}.Build(
2230 kWmResultZero)});
2231
2232 EXPECT_EQ(tester.key_calls.size(), 1);
2234 kPhysicalEnter, kLogicalEnter, "", kNotSynthesized);
2235 tester.clear_key_calls();
2236 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2237
2238 // Make sure OnText is not obstructed after pressing Enter.
2239 //
2240 // Regression test for https://github.com/flutter/flutter/issues/97706.
2241
2242 // Press A
2243 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2245 kWmResultZero),
2246 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2247 kWmResultZero)});
2248
2249 EXPECT_EQ(tester.key_calls.size(), 2);
2251 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2252 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2253 tester.clear_key_calls();
2254
2255 // Release A
2256 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2258 kWmResultZero)});
2259
2260 EXPECT_EQ(tester.key_calls.size(), 1);
2262 kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2263 tester.clear_key_calls();
2264}
#define EXPECT_CALL_IS_TEXT_METHOD_CALL(_key_call, json_string)

◆ TEST_F() [623/876]

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

Definition at line 2020 of file keyboard_unittests.cc.

2020 {
2021 KeyboardTester tester{GetContext()};
2022 tester.Responding(true);
2023
2024 // US Keyboard layout.
2025
2026 // Press CtrlRight in IME mode.
2027 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2028 KeyStateChange{VK_LSHIFT, true, false},
2029 WmKeyDownInfo{VK_SHIFT, kScanCodeShiftLeft, kNotExtended, kWasUp}.Build(
2030 kWmResultZero),
2031 WmKeyDownInfo{VK_PROCESSKEY, kScanCodeDigit2, kNotExtended, kWasUp}.Build(
2032 kWmResultZero),
2033 KeyStateChange{VK_LSHIFT, false, true},
2034 WmKeyUpInfo{VK_PROCESSKEY, kScanCodeShiftLeft, kNotExtended}.Build(
2035 kWmResultZero),
2036 WmKeyUpInfo{'2', kScanCodeDigit2, kNotExtended, kWasUp}.Build(
2037 kWmResultZero)});
2038
2039 EXPECT_EQ(tester.key_calls.size(), 4);
2041 kPhysicalShiftLeft, kLogicalShiftLeft, "",
2042 kNotSynthesized);
2044 kNotSynthesized);
2046 kPhysicalShiftLeft, kLogicalShiftLeft, "",
2047 kNotSynthesized);
2049 kNotSynthesized);
2050 tester.clear_key_calls();
2051}

◆ TEST_F() [624/876]

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

Definition at line 2266 of file keyboard_unittests.cc.

2266 {
2267 // In this test, the user presses the folloing keys:
2268 //
2269 // Key Current text
2270 // ===========================
2271 // A a
2272 // F à
2273 //
2274 // And the Backspace event is responded immediately.
2275
2276 KeyboardTester tester{GetContext()};
2277 tester.Responding(false);
2278
2279 // US Keyboard layout
2280
2281 // Press A
2282 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2283 WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2284 kWmResultZero),
2285 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2286 kWmResultZero)});
2287
2288 EXPECT_EQ(tester.key_calls.size(), 2);
2290 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2291 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2292 tester.clear_key_calls();
2293 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2294
2295 // Release A
2296 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2298 kWmResultZero)});
2299
2300 EXPECT_EQ(tester.key_calls.size(), 1);
2302 kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2303 tester.clear_key_calls();
2304 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2305
2306 // Press F, which is translated to:
2307 //
2308 // Backspace down, char & up, then VK_PACKET('à').
2309 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2310 WmKeyDownInfo{VK_BACK, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2311 kWmResultZero),
2312 WmCharInfo{0x8, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2313 kWmResultZero),
2314 WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
2315 kWmResultZero),
2316 WmKeyDownInfo{VK_PACKET, 0, kNotExtended, kWasUp}.Build(kWmResultDefault),
2317 WmCharInfo{0xe0 /*'à'*/, 0, kNotExtended, kWasUp}.Build(kWmResultZero),
2318 WmKeyUpInfo{VK_PACKET, 0, kNotExtended}.Build(kWmResultDefault)});
2319
2320 EXPECT_EQ(tester.key_calls.size(), 3);
2322 kPhysicalBackspace, kLogicalBackspace, "",
2323 kNotSynthesized);
2325 kPhysicalBackspace, kLogicalBackspace, "",
2326 kNotSynthesized);
2327 EXPECT_CALL_IS_TEXT(tester.key_calls[2], u"à");
2328 tester.clear_key_calls();
2329 // TODO(dkwingsmt): This count should probably be 4. Currently the CHAR 0x8
2330 // message is redispatched due to being part of the KeyDown session, which is
2331 // not handled by the framework, while the 'à' message is not redispatched
2332 // for being a standalone message. We should resolve this inconsistency.
2333 // https://github.com/flutter/flutter/issues/98306
2334 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 3);
2335
2336 // Release F
2337 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2338 WmKeyUpInfo{kVirtualKeyF, kScanCodeKeyF, kNotExtended,
2339 /* overwrite_prev_state_0 */ true}
2340 .Build(kWmResultZero)});
2341
2342 EXPECT_EQ(tester.key_calls.size(), 1);
2344 kNotSynthesized);
2345 tester.clear_key_calls();
2346 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2347}

◆ TEST_F() [625/876]

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

Definition at line 2456 of file keyboard_unittests.cc.

2456 {
2458}
void VietnameseTelexAddDiacriticWithSlowResponse(WindowsTestContext &context, bool backspace_response)

◆ TEST_F() [626/876]

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

Definition at line 2460 of file keyboard_unittests.cc.

2460 {
2462}

◆ TEST_F() [627/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
Multiple   
)

Definition at line 102 of file layer_tree_unittests.cc.

102 {
103 const SkPath child_path1 = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
104 const SkPath child_path2 = SkPath().addRect(8.0f, 2.0f, 16.5f, 14.5f);
105 const DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
106 const DlPaint child_paint2 = DlPaint(DlColor::kGreen());
107 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
108 mock_layer1->set_fake_has_platform_view(true);
109 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
110 auto layer = std::make_shared<ContainerLayer>();
111 layer->Add(mock_layer1);
112 layer->Add(mock_layer2);
113
114 SkRect expected_total_bounds = child_path1.getBounds();
115 expected_total_bounds.join(child_path2.getBounds());
116 auto layer_tree = BuildLayerTree(LayerTree::Config{
117 .root_layer = layer,
118 });
119 layer_tree->Preroll(frame());
120 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
121 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
122 EXPECT_EQ(layer->paint_bounds(), expected_total_bounds);
123 EXPECT_FALSE(mock_layer1->is_empty());
124 EXPECT_FALSE(mock_layer2->is_empty());
125 EXPECT_FALSE(layer->is_empty());
126 EXPECT_EQ(mock_layer1->parent_matrix(), root_transform());
127 EXPECT_EQ(mock_layer2->parent_matrix(), root_transform());
128 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
129 EXPECT_EQ(mock_layer2->parent_cull_rect(),
130 kGiantRect); // Siblings are independent
131
132 layer_tree->Paint(frame());
133 EXPECT_EQ(
134 mock_canvas().draw_calls(),
135 std::vector({MockCanvas::DrawCall{
136 0, MockCanvas::DrawPathData{child_path1, child_paint1}},
137 MockCanvas::DrawCall{0, MockCanvas::DrawPathData{
138 child_path2, child_paint2}}}));
139}
std::shared_ptr< Layer > root_layer
Definition layer_tree.h:25

◆ TEST_F() [628/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
MultipleWithEmpty   
)

Definition at line 141 of file layer_tree_unittests.cc.

141 {
142 const SkPath child_path1 = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
143 const DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
144 const DlPaint child_paint2 = DlPaint(DlColor::kGreen());
145 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
146 auto mock_layer2 = std::make_shared<MockLayer>(SkPath(), child_paint2);
147 auto layer = std::make_shared<ContainerLayer>();
148 layer->Add(mock_layer1);
149 layer->Add(mock_layer2);
150
151 auto layer_tree = BuildLayerTree(LayerTree::Config{
152 .root_layer = layer,
153 });
154 layer_tree->Preroll(frame());
155 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
156 EXPECT_EQ(mock_layer2->paint_bounds(), SkPath().getBounds());
157 EXPECT_EQ(layer->paint_bounds(), child_path1.getBounds());
158 EXPECT_FALSE(mock_layer1->is_empty());
159 EXPECT_TRUE(mock_layer2->is_empty());
160 EXPECT_FALSE(layer->is_empty());
161 EXPECT_EQ(mock_layer1->parent_matrix(), root_transform());
162 EXPECT_EQ(mock_layer2->parent_matrix(), root_transform());
163 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
164 EXPECT_EQ(mock_layer2->parent_cull_rect(), kGiantRect);
165
166 layer_tree->Paint(frame());
167 EXPECT_EQ(mock_canvas().draw_calls(),
168 std::vector({MockCanvas::DrawCall{
169 0, MockCanvas::DrawPathData{child_path1, child_paint1}}}));
170}

◆ TEST_F() [629/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
NeedsSystemComposite   
)

Definition at line 172 of file layer_tree_unittests.cc.

172 {
173 const SkPath child_path1 = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
174 const SkPath child_path2 = SkPath().addRect(8.0f, 2.0f, 16.5f, 14.5f);
175 const DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
176 const DlPaint child_paint2 = DlPaint(DlColor::kGreen());
177 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
178 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
179 auto layer = std::make_shared<ContainerLayer>();
180 layer->Add(mock_layer1);
181 layer->Add(mock_layer2);
182
183 SkRect expected_total_bounds = child_path1.getBounds();
184 expected_total_bounds.join(child_path2.getBounds());
185 auto layer_tree = BuildLayerTree(LayerTree::Config{
186 .root_layer = layer,
187 });
188 layer_tree->Preroll(frame());
189 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
190 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
191 EXPECT_EQ(layer->paint_bounds(), expected_total_bounds);
192 EXPECT_FALSE(mock_layer1->is_empty());
193 EXPECT_FALSE(mock_layer2->is_empty());
194 EXPECT_FALSE(layer->is_empty());
195 EXPECT_EQ(mock_layer1->parent_matrix(), root_transform());
196 EXPECT_EQ(mock_layer2->parent_matrix(), root_transform());
197 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
198 EXPECT_EQ(mock_layer2->parent_cull_rect(), kGiantRect);
199
200 layer_tree->Paint(frame());
201 EXPECT_EQ(
202 mock_canvas().draw_calls(),
203 std::vector({MockCanvas::DrawCall{
204 0, MockCanvas::DrawPathData{child_path1, child_paint1}},
205 MockCanvas::DrawCall{0, MockCanvas::DrawPathData{
206 child_path2, child_paint2}}}));
207}

◆ TEST_F() [630/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
PaintBeforePrerollDies   
)

Definition at line 58 of file layer_tree_unittests.cc.

58 {
59 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
60 SkPath child_path;
61 child_path.addRect(child_bounds);
62 auto mock_layer = std::make_shared<MockLayer>(child_path);
63 auto layer = std::make_shared<ContainerLayer>();
64 layer->Add(mock_layer);
65
66 auto layer_tree = BuildLayerTree(LayerTree::Config{
67 .root_layer = layer,
68 });
69 EXPECT_EQ(mock_layer->paint_bounds(), kEmptyRect);
70 EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
71 EXPECT_TRUE(mock_layer->is_empty());
72 EXPECT_TRUE(layer->is_empty());
73
74 layer_tree->Paint(frame());
75 EXPECT_EQ(mock_canvas().draw_calls(), std::vector<MockCanvas::DrawCall>());
76}

◆ TEST_F() [631/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
PaintContextInitialization   
)

Definition at line 249 of file layer_tree_unittests.cc.

249 {
250 LayerStateStack state_stack;
251 FixedRefreshRateStopwatch mock_raster_time;
252 FixedRefreshRateStopwatch mock_ui_time;
253 std::shared_ptr<TextureRegistry> mock_registry;
254
255 auto expect_defaults = [&state_stack, &mock_raster_time, &mock_ui_time,
256 &mock_registry](const PaintContext& context) {
257 EXPECT_EQ(&context.state_stack, &state_stack);
258 EXPECT_EQ(context.canvas, nullptr);
259 EXPECT_EQ(context.gr_context, nullptr);
260 EXPECT_EQ(context.view_embedder, nullptr);
261 EXPECT_EQ(&context.raster_time, &mock_raster_time);
262 EXPECT_EQ(&context.ui_time, &mock_ui_time);
263 EXPECT_EQ(context.texture_registry.get(), mock_registry.get());
264 EXPECT_EQ(context.raster_cache, nullptr);
265 EXPECT_EQ(context.state_stack.checkerboard_func(), nullptr);
266
267 EXPECT_EQ(context.enable_leaf_layer_tracing, false);
268 EXPECT_EQ(context.layer_snapshot_store, nullptr);
269 };
270
271 // These 4 initializers are required because they are handled by reference
272 PaintContext context{
273 .state_stack = state_stack,
274 .raster_time = mock_raster_time,
275 .ui_time = mock_ui_time,
276 .texture_registry = mock_registry,
277 };
278 expect_defaults(context);
279}
LayerStateStack & state_stack
Definition layer.h:100

◆ TEST_F() [632/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
PaintingEmptyLayerDies   
)

Definition at line 45 of file layer_tree_unittests.cc.

45 {
46 auto layer = std::make_shared<ContainerLayer>();
47
48 auto layer_tree = BuildLayerTree(LayerTree::Config{
49 .root_layer = layer,
50 });
51 layer_tree->Preroll(frame());
52 EXPECT_EQ(layer->paint_bounds(), SkRect::MakeEmpty());
53 EXPECT_TRUE(layer->is_empty());
54
55 layer_tree->Paint(frame());
56}

◆ TEST_F() [633/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
PrerollContextInitialization   
)

Definition at line 209 of file layer_tree_unittests.cc.

209 {
210 LayerStateStack state_stack;
211 state_stack.set_preroll_delegate(kGiantRect, SkMatrix::I());
212 FixedRefreshRateStopwatch mock_raster_time;
213 FixedRefreshRateStopwatch mock_ui_time;
214 std::shared_ptr<TextureRegistry> mock_registry;
215
216 auto expect_defaults = [&state_stack, &mock_raster_time, &mock_ui_time,
217 &mock_registry](const PrerollContext& context) {
218 EXPECT_EQ(context.raster_cache, nullptr);
219 EXPECT_EQ(context.gr_context, nullptr);
220 EXPECT_EQ(context.view_embedder, nullptr);
221 EXPECT_EQ(&context.state_stack, &state_stack);
222 EXPECT_EQ(context.dst_color_space, nullptr);
223 EXPECT_EQ(context.state_stack.device_cull_rect(), kGiantRect);
224 EXPECT_EQ(context.state_stack.transform_3x3(), SkMatrix::I());
225 EXPECT_EQ(context.state_stack.transform_4x4(), SkM44());
226 EXPECT_EQ(context.surface_needs_readback, false);
227
228 EXPECT_EQ(&context.raster_time, &mock_raster_time);
229 EXPECT_EQ(&context.ui_time, &mock_ui_time);
230 EXPECT_EQ(context.texture_registry.get(), mock_registry.get());
231
232 EXPECT_EQ(context.has_platform_view, false);
233 EXPECT_EQ(context.has_texture_layer, false);
234
235 EXPECT_EQ(context.renderable_state_flags, 0);
236 EXPECT_EQ(context.raster_cached_entries, nullptr);
237 };
238
239 // These 4 initializers are required because they are handled by reference
240 PrerollContext context{
241 .state_stack = state_stack,
242 .raster_time = mock_raster_time,
243 .ui_time = mock_ui_time,
244 .texture_registry = mock_registry,
245 };
246 expect_defaults(context);
247}
LayerStateStack & state_stack
Definition layer.h:58

◆ TEST_F() [634/876]

flutter::testing::TEST_F ( LayerTreeTest  ,
Simple   
)

Definition at line 78 of file layer_tree_unittests.cc.

78 {
79 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
80 const SkPath child_path = SkPath().addRect(child_bounds);
81 const DlPaint child_paint = DlPaint(DlColor::kCyan());
82 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
83 auto layer = std::make_shared<ContainerLayer>();
84 layer->Add(mock_layer);
85
86 auto layer_tree = BuildLayerTree(LayerTree::Config{
87 .root_layer = layer,
88 });
89 layer_tree->Preroll(frame());
90 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
91 EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
92 EXPECT_FALSE(mock_layer->is_empty());
93 EXPECT_FALSE(layer->is_empty());
94 EXPECT_EQ(mock_layer->parent_matrix(), root_transform());
95
96 layer_tree->Paint(frame());
97 EXPECT_EQ(mock_canvas().draw_calls(),
98 std::vector({MockCanvas::DrawCall{
99 0, MockCanvas::DrawPathData{child_path, child_paint}}}));
100}

◆ TEST_F() [635/876]

flutter::testing::TEST_F ( MockCanvasTest  ,
DrawCalls   
)

Definition at line 21 of file mock_canvas_unittests.cc.

21 {
22 const SkRect rect = SkRect::MakeWH(5.0f, 5.0f);
23 const DlPaint paint = DlPaint(DlColor::kGreen());
24 const auto expected_draw_calls = std::vector{
26
27 mock_canvas().DrawRect(rect, paint);
28 EXPECT_EQ(mock_canvas().draw_calls(), expected_draw_calls);
29}

◆ TEST_F() [636/876]

flutter::testing::TEST_F ( MockCanvasTest  ,
DrawRRectDies   
)

Definition at line 16 of file mock_canvas_unittests.cc.

16 {
17 EXPECT_DEATH_IF_SUPPORTED(mock_canvas().DrawRRect(SkRRect(), DlPaint()), "");
18}

◆ TEST_F() [637/876]

flutter::testing::TEST_F ( MockLayerTest  ,
FakePlatformView   
)

Definition at line 67 of file mock_layer_unittests.cc.

67 {
68 auto layer = std::make_shared<MockLayer>(SkPath(), DlPaint());
69 layer->set_fake_has_platform_view(true);
70 EXPECT_EQ(preroll_context()->has_platform_view, false);
71
72 layer->Preroll(preroll_context());
73 EXPECT_EQ(preroll_context()->has_platform_view, true);
74}

◆ TEST_F() [638/876]

flutter::testing::TEST_F ( MockLayerTest  ,
FlagGetSet   
)

Definition at line 99 of file mock_layer_unittests.cc.

99 {
100 auto mock_layer = std::make_shared<MockLayer>(SkPath());
101
102 EXPECT_EQ(mock_layer->parent_has_platform_view(), false);
103 mock_layer->set_parent_has_platform_view(true);
104 EXPECT_EQ(mock_layer->parent_has_platform_view(), true);
105
106 EXPECT_EQ(mock_layer->parent_has_texture_layer(), false);
107 mock_layer->set_parent_has_texture_layer(true);
108 EXPECT_EQ(mock_layer->parent_has_texture_layer(), true);
109
110 EXPECT_EQ(mock_layer->fake_has_platform_view(), false);
111 mock_layer->set_fake_has_platform_view(true);
112 EXPECT_EQ(mock_layer->fake_has_platform_view(), true);
113
114 EXPECT_EQ(mock_layer->fake_reads_surface(), false);
115 mock_layer->set_fake_reads_surface(true);
116 EXPECT_EQ(mock_layer->fake_reads_surface(), true);
117
118 EXPECT_EQ(mock_layer->fake_opacity_compatible(), false);
119 mock_layer->set_fake_opacity_compatible(true);
120 EXPECT_EQ(mock_layer->fake_opacity_compatible(), true);
121
122 EXPECT_EQ(mock_layer->fake_has_texture_layer(), false);
123 mock_layer->set_fake_has_texture_layer(true);
124 EXPECT_EQ(mock_layer->fake_has_texture_layer(), true);
125}

◆ TEST_F() [639/876]

flutter::testing::TEST_F ( MockLayerTest  ,
SaveLayerOnLeafNodesCanvas   
)

Definition at line 76 of file mock_layer_unittests.cc.

76 {
77 auto layer = std::make_shared<MockLayer>(SkPath(), DlPaint());
78 layer->set_fake_has_platform_view(true);
79 EXPECT_EQ(preroll_context()->has_platform_view, false);
80
81 layer->Preroll(preroll_context());
82 EXPECT_EQ(preroll_context()->has_platform_view, true);
83}

◆ TEST_F() [640/876]

flutter::testing::TEST_F ( MockLayerTest  ,
SimpleParams   
)

Definition at line 36 of file mock_layer_unittests.cc.

36 {
37 const SkPath path = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
38 const DlPaint paint = DlPaint(DlColor::kBlue());
39 const SkMatrix start_matrix = SkMatrix::Translate(1.0f, 2.0f);
40 const SkMatrix scale_matrix = SkMatrix::Scale(0.5f, 0.5f);
41 const SkMatrix combined_matrix = SkMatrix::Concat(start_matrix, scale_matrix);
42 const SkRect local_cull_rect = SkRect::MakeWH(5.0f, 5.0f);
43 const SkRect device_cull_rect = combined_matrix.mapRect(local_cull_rect);
44 const bool parent_has_platform_view = true;
45 auto layer = std::make_shared<MockLayer>(path, paint);
46
47 preroll_context()->state_stack.set_preroll_delegate(device_cull_rect,
48 start_matrix);
49 auto mutator = preroll_context()->state_stack.save();
50 mutator.transform(scale_matrix);
51 preroll_context()->has_platform_view = parent_has_platform_view;
52 layer->Preroll(preroll_context());
53 EXPECT_EQ(preroll_context()->has_platform_view, false);
54 EXPECT_EQ(layer->paint_bounds(), path.getBounds());
55 EXPECT_TRUE(layer->needs_painting(paint_context()));
56 EXPECT_EQ(layer->parent_mutators(), std::vector{Mutator(scale_matrix)});
57 EXPECT_EQ(layer->parent_matrix(), combined_matrix);
58 EXPECT_EQ(layer->parent_cull_rect(), local_cull_rect);
59 EXPECT_EQ(layer->parent_has_platform_view(), parent_has_platform_view);
60
61 layer->Paint(paint_context());
62 EXPECT_EQ(mock_canvas().draw_calls(),
63 std::vector({MockCanvas::DrawCall{
65}

◆ TEST_F() [641/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
CullRectIsTransformed   
)

Definition at line 472 of file opacity_layer_unittests.cc.

472 {
473 auto clip_rect_layer = std::make_shared<ClipRectLayer>(
474 SkRect::MakeLTRB(0, 0, 10, 10), Clip::kHardEdge);
475 auto opacity_layer =
476 std::make_shared<OpacityLayer>(128, SkPoint::Make(20, 20));
477 auto mock_layer = std::make_shared<MockLayer>(SkPath());
478 clip_rect_layer->Add(opacity_layer);
479 opacity_layer->Add(mock_layer);
480 clip_rect_layer->Preroll(preroll_context());
481 EXPECT_EQ(mock_layer->parent_cull_rect().fLeft, -20);
482 EXPECT_EQ(mock_layer->parent_cull_rect().fTop, -20);
483}

◆ TEST_F() [642/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
FullyOpaque   
)

Definition at line 205 of file opacity_layer_unittests.cc.

205 {
206 const SkPath child_path = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
207 const SkPoint layer_offset = SkPoint::Make(0.5f, 1.5f);
208 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 0.5f);
209 const SkMatrix layer_transform =
210 SkMatrix::Translate(layer_offset.fX, layer_offset.fY);
211 const DlPaint child_paint = DlPaint(DlColor::kGreen());
212 const SkRect expected_layer_bounds =
213 layer_transform.mapRect(child_path.getBounds());
214 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
215 auto layer = std::make_shared<OpacityLayer>(SK_AlphaOPAQUE, layer_offset);
216 layer->Add(mock_layer);
217
218 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
219 layer->Preroll(preroll_context());
220 EXPECT_EQ(mock_layer->paint_bounds(), child_path.getBounds());
221 EXPECT_EQ(layer->paint_bounds(), expected_layer_bounds);
222 EXPECT_EQ(layer->child_paint_bounds(), child_path.getBounds());
223 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
224 EXPECT_TRUE(layer->needs_painting(paint_context()));
225 EXPECT_EQ(mock_layer->parent_matrix(),
226 SkMatrix::Concat(initial_transform, layer_transform));
227 EXPECT_EQ(mock_layer->parent_mutators(),
228 std::vector({Mutator(layer_transform)}));
229
230 DisplayListBuilder expected_builder;
231 /* (Opacity)layer::Paint */ {
232 expected_builder.Save();
233 {
234 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
235 // Opaque alpha needs no SaveLayer, just recurse into painting mock_layer
236 /* mock_layer::Paint */ {
237 expected_builder.DrawPath(child_path, child_paint);
238 }
239 }
240 expected_builder.Restore();
241 }
242 layer->Paint(display_list_paint_context());
243 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
244}
constexpr SkAlpha SK_AlphaOPAQUE
Definition SkColor.h:94

◆ TEST_F() [643/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
FullyOpaqueWithFractionalValues   
)

Definition at line 678 of file opacity_layer_unittests.cc.

678 {
679 use_mock_raster_cache(); // Ensure pixel-snapped alignment.
680
681 const SkPath child_path = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
682 const SkPoint layer_offset = SkPoint::Make(0.5f, 1.5f);
683 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 0.5f);
684 const DlPaint child_paint = DlPaint(DlColor::kGreen());
685 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
686 auto layer = std::make_shared<OpacityLayer>(SK_AlphaOPAQUE, layer_offset);
687 layer->Add(mock_layer);
688
689 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
690 layer->Preroll(preroll_context());
691
692 auto expected_builder = DisplayListBuilder();
693 /* (Opacity)layer::Paint */ {
694 expected_builder.Save();
695 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
696 // Opaque alpha needs no SaveLayer, just recurse into painting mock_layer
697 // but since we use the mock raster cache we pixel snap the transform
698 expected_builder.TransformReset();
699 expected_builder.Transform2DAffine(
700 1, 0, SkScalarRoundToScalar(layer_offset.fX), //
701 0, 1, SkScalarRoundToScalar(layer_offset.fY));
702 /* mock_layer::Paint */ {
703 expected_builder.DrawPath(child_path, child_paint);
704 }
705 expected_builder.Restore();
706 }
707 sk_sp<DisplayList> expected_display_list = expected_builder.Build();
708
709 layer->Paint(display_list_paint_context());
710 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_display_list));
711}

◆ TEST_F() [644/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
FullyTransparent   
)

Definition at line 246 of file opacity_layer_unittests.cc.

246 {
247 const SkRect child_bounds = SkRect::MakeWH(5.0f, 5.0f);
248 const SkPath child_path = SkPath().addRect(child_bounds);
249 const SkPoint layer_offset = SkPoint::Make(0.5f, 1.5f);
250 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 0.5f);
251 const SkMatrix layer_transform =
252 SkMatrix::Translate(layer_offset.fX, layer_offset.fY);
253 const DlPaint child_paint = DlPaint(DlColor::kGreen());
254 const SkRect expected_layer_bounds =
255 layer_transform.mapRect(child_path.getBounds());
256 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
257 auto layer =
258 std::make_shared<OpacityLayer>(SK_AlphaTRANSPARENT, layer_offset);
259 layer->Add(mock_layer);
260
261 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
262 layer->Preroll(preroll_context());
263 EXPECT_EQ(mock_layer->paint_bounds(), child_path.getBounds());
264 EXPECT_EQ(layer->paint_bounds(), expected_layer_bounds);
265 EXPECT_EQ(layer->child_paint_bounds(), child_path.getBounds());
266 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
267 EXPECT_TRUE(layer->needs_painting(paint_context()));
268 EXPECT_EQ(mock_layer->parent_matrix(),
269 SkMatrix::Concat(initial_transform, layer_transform));
270 EXPECT_EQ(
271 mock_layer->parent_mutators(),
272 std::vector({Mutator(layer_transform), Mutator(SK_AlphaTRANSPARENT)}));
273
274 DisplayListBuilder expected_builder;
275 /* (Opacity)layer::Paint */ {
276 expected_builder.Save();
277 {
278 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
279 /* (Opacity)layer::PaintChildren */ {
280 DlPaint save_paint(DlPaint().setOpacity(layer->opacity()));
281 expected_builder.SaveLayer(&child_bounds, &save_paint);
282 /* mock_layer::Paint */ {
283 expected_builder.DrawPath(child_path, child_paint);
284 }
285 expected_builder.Restore();
286 }
287 }
288 expected_builder.Restore();
289 }
290 layer->Paint(display_list_paint_context());
291 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
292}
constexpr SkAlpha SK_AlphaTRANSPARENT
Definition SkColor.h:89

◆ TEST_F() [645/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
FullyTransparentDoesNotCullPlatformView   
)

Definition at line 713 of file opacity_layer_unittests.cc.

713 {
714 const SkPoint opacity_offset = SkPoint::Make(0.5f, 1.5f);
715 const SkPoint view_offset = SkPoint::Make(0.0f, 0.0f);
716 const SkSize view_size = SkSize::Make(8.0f, 8.0f);
717 const int64_t view_id = 42;
718 auto platform_view =
719 std::make_shared<PlatformViewLayer>(view_offset, view_size, view_id);
720
721 auto opacity =
722 std::make_shared<OpacityLayer>(SK_AlphaTRANSPARENT, opacity_offset);
723 opacity->Add(platform_view);
724
725 auto embedder = MockViewEmbedder();
726 DisplayListBuilder fake_overlay_builder;
727 embedder.AddCanvas(&fake_overlay_builder);
728 preroll_context()->view_embedder = &embedder;
729 paint_context().view_embedder = &embedder;
730
731 opacity->Preroll(preroll_context());
732 EXPECT_EQ(embedder.prerolled_views(), std::vector<int64_t>({view_id}));
733
734 opacity->Paint(paint_context());
735 EXPECT_EQ(embedder.painted_views(), std::vector<int64_t>({view_id}));
736}

◆ TEST_F() [646/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
HalfTransparent   
)

Definition at line 294 of file opacity_layer_unittests.cc.

294 {
295 const SkPath child_path = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
296 const SkPoint layer_offset = SkPoint::Make(0.5f, 1.5f);
297 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 0.5f);
298 const SkMatrix layer_transform =
299 SkMatrix::Translate(layer_offset.fX, layer_offset.fY);
300 const DlPaint child_paint = DlPaint(DlColor::kGreen());
301 const SkRect expected_layer_bounds =
302 layer_transform.mapRect(child_path.getBounds());
303 const SkAlpha alpha_half = 255 / 2;
304 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
305 auto layer = std::make_shared<OpacityLayer>(alpha_half, layer_offset);
306 layer->Add(mock_layer);
307
308 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
309 layer->Preroll(preroll_context());
310 EXPECT_EQ(mock_layer->paint_bounds(), child_path.getBounds());
311 EXPECT_EQ(layer->paint_bounds(), expected_layer_bounds);
312 EXPECT_EQ(layer->child_paint_bounds(), child_path.getBounds());
313 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
314 EXPECT_TRUE(layer->needs_painting(paint_context()));
315 EXPECT_EQ(mock_layer->parent_matrix(),
316 SkMatrix::Concat(initial_transform, layer_transform));
317 EXPECT_EQ(mock_layer->parent_mutators(),
318 std::vector({Mutator(layer_transform), Mutator(alpha_half)}));
319
320 SkRect opacity_bounds;
321 expected_layer_bounds.makeOffset(-layer_offset.fX, -layer_offset.fY)
322 .roundOut(&opacity_bounds);
323 DlPaint save_paint = DlPaint().setAlpha(alpha_half);
324 DlPaint child_dl_paint = DlPaint(DlColor::kGreen());
325
326 auto expected_builder = DisplayListBuilder();
327 /* (Opacity)layer::Paint */ {
328 expected_builder.Save();
329 expected_builder.Translate(layer_offset.fX, layer_offset.fY);
330 /* (Opacity)layer::PaintChildren */ {
331 expected_builder.SaveLayer(&opacity_bounds, &save_paint);
332 /* mock_layer::Paint */ {
333 expected_builder.DrawPath(child_path, child_dl_paint);
334 }
335 expected_builder.Restore();
336 }
337 expected_builder.Restore();
338 }
339 sk_sp<DisplayList> expected_display_list = expected_builder.Build();
340
341 layer->Paint(display_list_paint_context());
342 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_display_list));
343}
uint8_t SkAlpha
Definition SkColor.h:26
void roundOut(SkIRect *dst) const
Definition SkRect.h:1241

◆ TEST_F() [647/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
OpacityInheritanceCompatibleChild   
)

Definition at line 485 of file opacity_layer_unittests.cc.

485 {
486 auto opacity_layer =
487 std::make_shared<OpacityLayer>(128, SkPoint::Make(20, 20));
488 auto mock_layer = MockLayer::MakeOpacityCompatible(SkPath());
489 opacity_layer->Add(mock_layer);
490
491 PrerollContext* context = preroll_context();
492 opacity_layer->Preroll(context);
493 EXPECT_EQ(context->renderable_state_flags,
494 LayerStateStack::kCallerCanApplyOpacity);
495 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
496}

◆ TEST_F() [648/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
OpacityInheritanceIncompatibleChild   
)

Definition at line 498 of file opacity_layer_unittests.cc.

498 {
499 auto opacity_layer =
500 std::make_shared<OpacityLayer>(128, SkPoint::Make(20, 20));
501 auto mock_layer = MockLayer::Make(SkPath());
502 opacity_layer->Add(mock_layer);
503
504 PrerollContext* context = preroll_context();
505 opacity_layer->Preroll(context);
506 EXPECT_EQ(context->renderable_state_flags,
507 LayerStateStack::kCallerCanApplyOpacity);
508 EXPECT_FALSE(opacity_layer->children_can_accept_opacity());
509}

◆ TEST_F() [649/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
OpacityInheritanceNestedWithCompatibleChild   
)

Definition at line 557 of file opacity_layer_unittests.cc.

557 {
558 SkPoint offset1 = SkPoint::Make(10, 20);
559 SkPoint offset2 = SkPoint::Make(20, 10);
560 SkPath mock_path = SkPath::Rect({10, 10, 20, 20});
561 auto opacity_layer_1 = std::make_shared<OpacityLayer>(128, offset1);
562 auto opacity_layer_2 = std::make_shared<OpacityLayer>(64, offset2);
563 auto mock_layer = MockLayer::MakeOpacityCompatible(mock_path);
564 opacity_layer_2->Add(mock_layer);
565 opacity_layer_1->Add(opacity_layer_2);
566
567 PrerollContext* context = preroll_context();
568 opacity_layer_1->Preroll(context);
569 EXPECT_EQ(context->renderable_state_flags,
570 LayerStateStack::kCallerCanApplyOpacity);
571 EXPECT_TRUE(opacity_layer_1->children_can_accept_opacity());
572 EXPECT_TRUE(opacity_layer_2->children_can_accept_opacity());
573
574 DlPaint savelayer_paint;
575 SkScalar inherited_opacity = 128 * 1.0 / SK_AlphaOPAQUE;
576 inherited_opacity *= 64 * 1.0 / SK_AlphaOPAQUE;
577 savelayer_paint.setOpacity(inherited_opacity);
578
579 DisplayListBuilder expected_builder;
580 /* opacity_layer_1::Paint */ {
581 expected_builder.Save();
582 {
583 expected_builder.Translate(offset1.fX, offset1.fY);
584 /* opacity_layer_2::Paint */ {
585 expected_builder.Save();
586 {
587 expected_builder.Translate(offset2.fX, offset2.fY);
588 /* mock_layer::Paint */ {
589 expected_builder.DrawPath(mock_path,
590 DlPaint().setOpacity(inherited_opacity));
591 }
592 }
593 expected_builder.Restore();
594 }
595 }
596 expected_builder.Restore();
597 }
598
599 opacity_layer_1->Paint(display_list_paint_context());
600 EXPECT_TRUE(DisplayListsEQ_Verbose(expected_builder.Build(), display_list()));
601}

◆ TEST_F() [650/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
OpacityInheritanceNestedWithIncompatibleChild   
)

Definition at line 603 of file opacity_layer_unittests.cc.

603 {
604 SkPoint offset1 = SkPoint::Make(10, 20);
605 SkPoint offset2 = SkPoint::Make(20, 10);
606 SkPath mock_path = SkPath::Rect({10, 10, 20, 20});
607 auto opacity_layer_1 = std::make_shared<OpacityLayer>(128, offset1);
608 auto opacity_layer_2 = std::make_shared<OpacityLayer>(64, offset2);
609 auto mock_layer = MockLayer::Make(mock_path);
610 opacity_layer_2->Add(mock_layer);
611 opacity_layer_1->Add(opacity_layer_2);
612
613 PrerollContext* context = preroll_context();
614 opacity_layer_1->Preroll(context);
615 EXPECT_EQ(context->renderable_state_flags,
616 LayerStateStack::kCallerCanApplyOpacity);
617 EXPECT_TRUE(opacity_layer_1->children_can_accept_opacity());
618 EXPECT_FALSE(opacity_layer_2->children_can_accept_opacity());
619
620 DlPaint savelayer_paint;
621 SkScalar inherited_opacity = 128 * 1.0 / SK_AlphaOPAQUE;
622 inherited_opacity *= 64 * 1.0 / SK_AlphaOPAQUE;
623 savelayer_paint.setOpacity(inherited_opacity);
624
625 DisplayListBuilder expected_builder;
626 /* opacity_layer_1::Paint */ {
627 expected_builder.Save();
628 {
629 expected_builder.Translate(offset1.fX, offset1.fY);
630 /* opacity_layer_2::Paint */ {
631 expected_builder.Save();
632 {
633 expected_builder.Translate(offset2.fX, offset2.fY);
634 expected_builder.SaveLayer(&mock_layer->paint_bounds(),
635 &savelayer_paint);
636 /* mock_layer::Paint */ {
637 expected_builder.DrawPath(mock_path, DlPaint());
638 }
639 }
640 expected_builder.Restore();
641 }
642 }
643 expected_builder.Restore();
644 }
645
646 opacity_layer_1->Paint(display_list_paint_context());
647 EXPECT_TRUE(DisplayListsEQ_Verbose(expected_builder.Build(), display_list()));
648}

◆ TEST_F() [651/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
OpacityInheritanceThroughContainer   
)

Definition at line 511 of file opacity_layer_unittests.cc.

511 {
512 auto opacity_layer =
513 std::make_shared<OpacityLayer>(128, SkPoint::Make(20, 20));
514 auto container_layer = std::make_shared<ContainerLayer>();
515 auto mock_layer = MockLayer::MakeOpacityCompatible(SkPath());
516 container_layer->Add(mock_layer);
517 opacity_layer->Add(container_layer);
518
519 PrerollContext* context = preroll_context();
520 opacity_layer->Preroll(context);
521 EXPECT_EQ(context->renderable_state_flags,
522 LayerStateStack::kCallerCanApplyOpacity);
523 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
524}

◆ TEST_F() [652/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
OpacityInheritanceThroughImageFilter   
)

Definition at line 541 of file opacity_layer_unittests.cc.

541 {
542 auto opacity_layer =
543 std::make_shared<OpacityLayer>(128, SkPoint::Make(20, 20));
544 auto filter_layer = std::make_shared<ImageFilterLayer>(
545 std::make_shared<DlBlurImageFilter>(5.0, 5.0, DlTileMode::kClamp));
546 auto mock_layer = MockLayer::MakeOpacityCompatible(SkPath());
547 filter_layer->Add(mock_layer);
548 opacity_layer->Add(filter_layer);
549
550 PrerollContext* context = preroll_context();
551 opacity_layer->Preroll(context);
552 EXPECT_EQ(context->renderable_state_flags,
553 LayerStateStack::kCallerCanApplyOpacity);
554 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
555}

◆ TEST_F() [653/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
OpacityInheritanceThroughTransform   
)

Definition at line 526 of file opacity_layer_unittests.cc.

526 {
527 auto opacity_layer =
528 std::make_shared<OpacityLayer>(128, SkPoint::Make(20, 20));
529 auto transformLayer = std::make_shared<TransformLayer>(SkMatrix::Scale(2, 2));
530 auto mock_layer = MockLayer::MakeOpacityCompatible(SkPath());
531 transformLayer->Add(mock_layer);
532 opacity_layer->Add(transformLayer);
533
534 PrerollContext* context = preroll_context();
535 opacity_layer->Preroll(context);
536 EXPECT_EQ(context->renderable_state_flags,
537 LayerStateStack::kCallerCanApplyOpacity);
538 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
539}

◆ TEST_F() [654/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
ShouldNotCacheChildren   
)

Definition at line 173 of file opacity_layer_unittests.cc.

173 {
175 auto opacity_layer =
176 std::make_shared<OpacityLayer>(128, SkPoint::Make(20, 20));
177 auto mock_layer = MockLayer::MakeOpacityCompatible(SkPath());
178 opacity_layer->Add(mock_layer);
179
180 PrerollContext* context = preroll_context();
181
182 use_mock_raster_cache();
183
184 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
185
186 const auto* cacheable_opacity_item = opacity_layer->raster_cache_item();
187
188 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
189 EXPECT_EQ(cacheable_opacity_item->cache_state(),
190 RasterCacheItem::CacheState::kNone);
191 EXPECT_FALSE(cacheable_opacity_item->GetId().has_value());
192
193 opacity_layer->Preroll(preroll_context());
194
195 EXPECT_EQ(context->renderable_state_flags,
196 LayerStateStack::kCallerCanApplyOpacity);
197 EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
198 LayerTree::TryToRasterCache(cacheable_items(), &paint_context());
199 EXPECT_EQ(raster_cache()->GetLayerCachedEntriesCount(), (size_t)0);
200 EXPECT_EQ(cacheable_opacity_item->cache_state(),
201 RasterCacheItem::CacheState::kNone);
202 EXPECT_FALSE(cacheable_opacity_item->Draw(paint_context(), &paint));
203}

◆ TEST_F() [655/876]

flutter::testing::TEST_F ( OpacityLayerTest  ,
TranslateChildren   
)

Definition at line 60 of file opacity_layer_unittests.cc.

60 {
61 SkPath child_path1;
62 child_path1.addRect(10.0f, 10.0f, 20.0f, 20.f);
63 DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
64 auto layer = std::make_shared<OpacityLayer>(0.5, SkPoint::Make(10, 10));
65 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
66 layer->Add(mock_layer1);
67
68 auto initial_transform = SkMatrix::Scale(2.0, 2.0);
69 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
70 layer->Preroll(preroll_context());
71
72 SkRect layer_bounds = mock_layer1->paint_bounds();
73 mock_layer1->parent_matrix().mapRect(&layer_bounds);
74
75 EXPECT_EQ(layer_bounds, SkRect::MakeXYWH(40, 40, 20, 20));
76}

◆ TEST_F() [656/876]

flutter::testing::TEST_F ( PainterTest  ,
DrawDashedLineSkia   
)

Definition at line 147 of file paragraph_unittests.cc.

147 {
148 PretendImpellerIsEnabled(false);
149
150 auto recorder = DlOpRecorder();
151 draw(makeDecoratedStyle(txt::TextDecorationStyle::kDashed))
152 ->Dispatch(recorder);
153
154 // Skia draws a dashed underline as a filled rectangle with a path effect.
155 EXPECT_EQ(recorder.lineCount(), 1);
156 EXPECT_TRUE(recorder.hasPathEffect());
157}
A custom |DlOpReceiver| that records some |DlOps| it receives.

◆ TEST_F() [657/876]

flutter::testing::TEST_F ( PainterTest  ,
DrawsSolidLineSkia   
)

Definition at line 134 of file paragraph_unittests.cc.

134 {
135 PretendImpellerIsEnabled(false);
136
137 auto recorder = DlOpRecorder();
138 draw(makeDecoratedStyle(txt::TextDecorationStyle::kSolid))
139 ->Dispatch(recorder);
140
141 // Skia may draw a solid underline as a filled rectangle:
142 // https://skia.googlesource.com/skia/+/refs/heads/main/modules/skparagraph/src/Decorations.cpp#91
143 EXPECT_EQ(recorder.rectCount(), 1);
144 EXPECT_FALSE(recorder.hasPathEffect());
145}

◆ TEST_F() [658/876]

flutter::testing::TEST_F ( PerformanceOverlayLayerTest  ,
InvalidOptions   
)

Definition at line 146 of file performance_overlay_layer_unittests.cc.

146 {
147 const SkRect layer_bounds = SkRect::MakeLTRB(0.0f, 0.0f, 64.0f, 64.0f);
148 const uint64_t overlay_opts = 0;
149 auto layer = std::make_shared<PerformanceOverlayLayer>(overlay_opts);
150
151 // TODO(): Note calling code has to call set_paint_bounds right now. Make
152 // this a constructor parameter and move the set_paint_bounds into Preroll
153 layer->set_paint_bounds(layer_bounds);
154
155 layer->Preroll(preroll_context());
156 EXPECT_EQ(layer->paint_bounds(), layer_bounds);
157 EXPECT_TRUE(layer->needs_painting(paint_context()));
158
159 // Nothing is drawn if options are invalid (0).
160 layer->Paint(paint_context());
161 EXPECT_EQ(mock_canvas().draw_calls(), std::vector<MockCanvas::DrawCall>());
162}

◆ TEST_F() [659/876]

flutter::testing::TEST_F ( PerformanceOverlayLayerTest  ,
MarkAsDirtyWhenResized   
)

Definition at line 197 of file performance_overlay_layer_unittests.cc.

197 {
198 // Regression test for https://github.com/flutter/flutter/issues/54188
199
200 // Create a PerformanceOverlayLayer.
201 const uint64_t overlay_opts = kVisualizeRasterizerStatistics;
202 auto layer = std::make_shared<PerformanceOverlayLayer>(overlay_opts);
203 layer->set_paint_bounds(SkRect::MakeLTRB(0.0f, 0.0f, 48.0f, 48.0f));
204 layer->Preroll(preroll_context());
205 layer->Paint(paint_context());
206 auto data = mock_canvas().draw_calls().front().data;
207 auto image_data = std::get<MockCanvas::DrawImageDataNoPaint>(data);
208 auto first_draw_width = image_data.image->width();
209
210 // Create a second PerformanceOverlayLayer with different bounds.
211 layer = std::make_shared<PerformanceOverlayLayer>(overlay_opts);
212 layer->set_paint_bounds(SkRect::MakeLTRB(0.0f, 0.0f, 64.0f, 64.0f));
213 layer->Preroll(preroll_context());
214 layer->Paint(paint_context());
215 data = mock_canvas().draw_calls().back().data;
216 image_data = std::get<MockCanvas::DrawImageDataNoPaint>(data);
217 auto refreshed_draw_width = image_data.image->width();
218
219 EXPECT_NE(first_draw_width, refreshed_draw_width);
220}
const int kVisualizeRasterizerStatistics

◆ TEST_F() [660/876]

flutter::testing::TEST_F ( PerformanceOverlayLayerTest  ,
SimpleRasterizerStatistics   
)

Definition at line 164 of file performance_overlay_layer_unittests.cc.

164 {
165 const SkRect layer_bounds = SkRect::MakeLTRB(0.0f, 0.0f, 64.0f, 64.0f);
166 const uint64_t overlay_opts = kDisplayRasterizerStatistics;
167 auto layer = std::make_shared<PerformanceOverlayLayer>(overlay_opts);
168
169 // TODO(): Note calling code has to call set_paint_bounds right now. Make
170 // this a constructor parameter and move the set_paint_bounds into Preroll
171 layer->set_paint_bounds(layer_bounds);
172
173 layer->Preroll(preroll_context());
174 EXPECT_EQ(layer->paint_bounds(), layer_bounds);
175 EXPECT_TRUE(layer->needs_painting(paint_context()));
176
177 layer->Paint(paint_context());
178 auto overlay_text = PerformanceOverlayLayer::MakeStatisticsText(
179 paint_context().raster_time, "Raster", "");
180 auto overlay_text_data = overlay_text->serialize(SkSerialProcs{});
181 // Historically SK_ColorGRAY (== 0xFF888888) was used here
182 DlPaint text_paint(DlColor(0xFF888888));
183 SkPoint text_position = SkPoint::Make(16.0f, 22.0f);
184
185 // TODO(https://github.com/flutter/flutter/issues/82202): Remove once the
186 // performance overlay can use Fuchsia's font manager instead of the empty
187 // default.
188#if defined(OS_FUCHSIA)
189 GTEST_SKIP() << "Expectation requires a valid default font manager";
190#endif // OS_FUCHSIA
191 EXPECT_EQ(mock_canvas().draw_calls(),
192 std::vector({MockCanvas::DrawCall{
193 0, MockCanvas::DrawTextData{overlay_text_data, text_paint,
194 text_position}}}));
195}
const int kDisplayRasterizerStatistics

◆ TEST_F() [661/876]

flutter::testing::TEST_F ( PersistentCacheTest  ,
CanLoadSkSLsFromAsset   
)

Definition at line 43 of file persistent_cache_unittests.cc.

43 {
44 // Avoid polluting unit tests output by hiding INFO level logging.
45 fml::LogSettings warning_only = {fml::kLogWarning};
46 fml::ScopedSetLogSettings scoped_set_log_settings(warning_only);
47
48 // The SkSL key is Base32 encoded. "IE" is the encoding of "A" and "II" is the
49 // encoding of "B".
50 //
51 // The SkSL data is Base64 encoded. "eA==" is the encoding of "x" and "eQ=="
52 // is the encoding of "y".
53 const std::string kTestJson =
54 "{\n"
55 " \"data\": {\n"
56 " \"IE\": \"eA==\",\n"
57 " \"II\": \"eQ==\"\n"
58 " }\n"
59 "}\n";
60
61 // Temp dir for the asset.
63
64 auto data = std::make_unique<fml::DataMapping>(
65 std::vector<uint8_t>{kTestJson.begin(), kTestJson.end()});
66 fml::WriteAtomically(asset_dir.fd(), PersistentCache::kAssetFileName, *data);
67
68 // 1st, test that RunConfiguration::InferFromSettings sets the asset manager.
69 ResetAssetManager();
70 auto settings = CreateSettingsForFixture();
71 settings.assets_path = asset_dir.path();
72 RunConfiguration::InferFromSettings(settings);
73 CheckTwoSkSLsAreLoaded();
74
75 // 2nd, test that the RunConfiguration constructor sets the asset manager.
76 // (Android is directly calling that constructor without InferFromSettings.)
77 ResetAssetManager();
78 auto asset_manager = std::make_shared<AssetManager>();
79 RunConfiguration config(nullptr, asset_manager);
80 asset_manager->PushBack(std::make_unique<DirectoryAssetBundle>(
81 fml::OpenDirectory(asset_dir.path().c_str(), false,
83 false));
84 CheckTwoSkSLsAreLoaded();
85
86 // 3rd, test the content of the SkSLs in the asset.
87 {
88 auto shaders = PersistentCache::GetCacheForProcess()->LoadSkSLs();
89 ASSERT_EQ(shaders.size(), 2u);
90
91 // Make sure that the 2 shaders are sorted by their keys. Their keys should
92 // be "A" and "B" (decoded from "II" and "IE").
93 if (shaders[0].key->bytes()[0] == 'B') {
94 std::swap(shaders[0], shaders[1]);
95 }
96
97 CheckTextSkData(shaders[0].key, "A");
98 CheckTextSkData(shaders[1].key, "B");
99 CheckTextSkData(shaders[0].value, "x");
100 CheckTextSkData(shaders[1].value, "y");
101 }
102
103 // Cleanup.
104 fml::UnlinkFile(asset_dir.fd(), PersistentCache::kAssetFileName);
105}
const UniqueFD & fd()
Definition file.h:147
const std::string & path() const
Definition file.h:146
static void CheckTextSkData(const sk_sp< SkData > &data, const std::string &expected)
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition file_posix.cc:97
constexpr LogSeverity kLogWarning
Definition log_level.h:14
bool UnlinkFile(const char *path)

◆ TEST_F() [662/876]

flutter::testing::TEST_F ( PersistentCacheTest  ,
CanPurgePersistentCache   
)

Definition at line 137 of file persistent_cache_unittests.cc.

137 {
139 ASSERT_TRUE(base_dir.fd().is_valid());
140 auto cache_dir = fml::CreateDirectory(
141 base_dir.fd(),
142 {"flutter_engine", GetFlutterEngineVersion(), "skia", GetSkiaVersion()},
144 PersistentCache::SetCacheDirectoryPath(base_dir.path());
145 PersistentCache::ResetCacheForProcess();
146
147 // Generate a dummy persistent cache.
148 fml::DataMapping test_data(std::string("test"));
149 ASSERT_TRUE(fml::WriteAtomically(cache_dir, "test", test_data));
150 auto file = fml::OpenFileReadOnly(cache_dir, "test");
151 ASSERT_TRUE(file.is_valid());
152
153 // Run engine with purge_persistent_cache to remove the dummy cache.
154 auto settings = CreateSettingsForFixture();
155 settings.purge_persistent_cache = true;
156 auto config = RunConfiguration::InferFromSettings(settings);
157 std::unique_ptr<Shell> shell = CreateShell(settings);
158 RunEngine(shell.get(), std::move(config));
159
160 // Verify that the dummy is purged.
161 file = fml::OpenFileReadOnly(cache_dir, "test");
162 ASSERT_FALSE(file.is_valid());
163
164 // Cleanup
166 DestroyShell(std::move(shell));
167}
bool is_valid() const
fml::UniqueFD OpenFileReadOnly(const fml::UniqueFD &base_directory, const char *path)
Definition file.cc:92
bool RemoveFilesInDirectory(const fml::UniqueFD &directory)
Definition file.cc:102
static fml::UniqueFD CreateDirectory(const fml::UniqueFD &base_directory, const std::vector< std::string > &components, FilePermission permission, size_t index)
Definition file.cc:12

◆ TEST_F() [663/876]

flutter::testing::TEST_F ( PersistentCacheTest  ,
CanRemoveOldPersistentCache   
)

Definition at line 107 of file persistent_cache_unittests.cc.

107 {
109 ASSERT_TRUE(base_dir.fd().is_valid());
110
111 fml::CreateDirectory(base_dir.fd(),
112 {"flutter_engine", GetFlutterEngineVersion(), "skia"},
114
115 constexpr char kOldEngineVersion[] = "old";
116 auto old_created = fml::CreateDirectory(
117 base_dir.fd(), {"flutter_engine", kOldEngineVersion, "skia"},
119 ASSERT_TRUE(old_created.is_valid());
120
121 PersistentCache::SetCacheDirectoryPath(base_dir.path());
122 PersistentCache::ResetCacheForProcess();
123
124 auto engine_dir = fml::OpenDirectoryReadOnly(base_dir.fd(), "flutter_engine");
125 auto current_dir =
127 auto old_dir = fml::OpenDirectoryReadOnly(engine_dir, kOldEngineVersion);
128
129 ASSERT_TRUE(engine_dir.is_valid());
130 ASSERT_TRUE(current_dir.is_valid());
131 ASSERT_FALSE(old_dir.is_valid());
132
133 // Cleanup
135}
const char * GetFlutterEngineVersion()
Definition version.cc:11
fml::UniqueFD OpenDirectoryReadOnly(const fml::UniqueFD &base_directory, const char *path)
Definition file.cc:97

◆ TEST_F() [664/876]

flutter::testing::TEST_F ( PersistentCacheTest  ,
PurgeAllowsFutureSkSLCache   
)

Definition at line 169 of file persistent_cache_unittests.cc.

169 {
170 sk_sp<SkData> shader_key = SkData::MakeWithCString("key");
171 sk_sp<SkData> shader_value = SkData::MakeWithCString("value");
172 std::string shader_filename = PersistentCache::SkKeyToFilePath(*shader_key);
173
175 ASSERT_TRUE(base_dir.fd().is_valid());
176 PersistentCache::SetCacheDirectoryPath(base_dir.path());
177 PersistentCache::ResetCacheForProcess();
178
179 // Run engine with purge_persistent_cache and cache_sksl.
180 auto settings = CreateSettingsForFixture();
181 settings.purge_persistent_cache = true;
182 settings.cache_sksl = true;
183 auto config = RunConfiguration::InferFromSettings(settings);
184 std::unique_ptr<Shell> shell = CreateShell(settings);
185 RunEngine(shell.get(), std::move(config));
186 auto persistent_cache = PersistentCache::GetCacheForProcess();
187 ASSERT_EQ(persistent_cache->LoadSkSLs().size(), 0u);
188
189 // Store the cache and verify it's valid.
190 StorePersistentCache(persistent_cache, *shader_key, *shader_value);
191 std::promise<bool> io_flushed;
192 shell->GetTaskRunners().GetIOTaskRunner()->PostTask(
193 [&io_flushed]() { io_flushed.set_value(true); });
194 io_flushed.get_future().get(); // Wait for the IO thread to flush the file.
195 ASSERT_GT(persistent_cache->LoadSkSLs().size(), 0u);
196
197 // Cleanup
199 DestroyShell(std::move(shell));
200}
static sk_sp< SkData > MakeWithCString(const char cstr[])
Definition SkData.cpp:195

◆ TEST_F() [665/876]

flutter::testing::TEST_F ( PlatformConfigurationTest  ,
GetWindowReturnsNullForNonexistentId   
)

Definition at line 109 of file platform_configuration_unittests.cc.

109 {
110 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
111
112 auto nativeValidateConfiguration =
113 [message_latch](Dart_NativeArguments args) {
114 PlatformConfiguration* configuration =
115 UIDartState::Current()->platform_configuration();
116
117 ASSERT_EQ(configuration->GetMetrics(1), nullptr);
118 ASSERT_EQ(configuration->GetMetrics(2), nullptr);
119
120 message_latch->Signal();
121 };
122
123 Settings settings = CreateSettingsForFixture();
124 TaskRunners task_runners("test", // label
125 GetCurrentTaskRunner(), // platform
126 CreateNewThread(), // raster
127 CreateNewThread(), // ui
128 CreateNewThread() // io
129 );
130
131 AddNativeCallback("ValidateConfiguration",
132 CREATE_NATIVE_ENTRY(nativeValidateConfiguration));
133
134 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
135
136 ASSERT_TRUE(shell->IsSetup());
137 auto run_configuration = RunConfiguration::InferFromSettings(settings);
138 run_configuration.SetEntrypoint("validateConfiguration");
139
140 shell->RunEngine(std::move(run_configuration), [&](auto result) {
141 ASSERT_EQ(result, Engine::RunStatus::Success);
142 });
143
144 message_latch->Wait();
145 DestroyShell(std::move(shell), task_runners);
146}
A class for holding and distributing platform-level information to and from the Dart code in Flutter'...
const ViewportMetrics * GetMetrics(int view_id)
Retrieves the viewport metrics with the given ID managed by the PlatformConfiguration.

◆ TEST_F() [666/876]

flutter::testing::TEST_F ( PlatformConfigurationTest  ,
Initialization   
)

Definition at line 24 of file platform_configuration_unittests.cc.

24 {
25 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
26
27 auto nativeValidateConfiguration =
28 [message_latch](Dart_NativeArguments args) {
29 PlatformConfiguration* configuration =
30 UIDartState::Current()->platform_configuration();
31 ASSERT_NE(configuration->GetMetrics(0), nullptr);
32 ASSERT_EQ(configuration->GetMetrics(0)->device_pixel_ratio, 1.0);
33 ASSERT_EQ(configuration->GetMetrics(0)->physical_width, 0.0);
34 ASSERT_EQ(configuration->GetMetrics(0)->physical_height, 0.0);
35
36 message_latch->Signal();
37 };
38
39 Settings settings = CreateSettingsForFixture();
40 TaskRunners task_runners("test", // label
41 GetCurrentTaskRunner(), // platform
42 CreateNewThread(), // raster
43 CreateNewThread(), // ui
44 CreateNewThread() // io
45 );
46
47 AddNativeCallback("ValidateConfiguration",
48 CREATE_NATIVE_ENTRY(nativeValidateConfiguration));
49
50 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
51
52 ASSERT_TRUE(shell->IsSetup());
53 auto run_configuration = RunConfiguration::InferFromSettings(settings);
54 run_configuration.SetEntrypoint("validateConfiguration");
55
56 shell->RunEngine(std::move(run_configuration), [&](auto result) {
57 ASSERT_EQ(result, Engine::RunStatus::Success);
58 });
59
60 message_latch->Wait();
61 DestroyShell(std::move(shell), task_runners);
62}

◆ TEST_F() [667/876]

flutter::testing::TEST_F ( PlatformConfigurationTest  ,
OnErrorDoesNotHandleError   
)

Definition at line 194 of file platform_configuration_unittests.cc.

194 {
195 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
196 std::string ex;
197 std::string st;
198 size_t throw_count = 0;
199
200 auto finish = [message_latch](Dart_NativeArguments args) {
201 message_latch->Signal();
202 };
203 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish));
204
205 Settings settings = CreateSettingsForFixture();
206 settings.unhandled_exception_callback =
207 [&ex, &st, &throw_count](const std::string& exception,
208 const std::string& stack_trace) -> bool {
209 throw_count += 1;
210 ex = exception;
211 st = stack_trace;
212 return true;
213 };
214
215 TaskRunners task_runners("test", // label
216 GetCurrentTaskRunner(), // platform
217 CreateNewThread(), // raster
218 CreateNewThread(), // ui
219 CreateNewThread() // io
220 );
221
222 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
223
224 ASSERT_TRUE(shell->IsSetup());
225 auto run_configuration = RunConfiguration::InferFromSettings(settings);
226 run_configuration.SetEntrypoint("customOnErrorFalse");
227
228 shell->RunEngine(std::move(run_configuration), [&](auto result) {
229 ASSERT_EQ(result, Engine::RunStatus::Success);
230 });
231
232 message_latch->Wait();
233
234 // Flush the UI task runner to make sure errors that were triggered had a turn
235 // to propagate.
236 task_runners.GetUITaskRunner()->PostTask(
237 [&message_latch]() { message_latch->Signal(); });
238 message_latch->Wait();
239
240 ASSERT_EQ(throw_count, 1ul);
241 ASSERT_EQ(ex, "Exception: false") << ex;
242 ASSERT_EQ(st.rfind("#0 customOnErrorFalse", 0), 0ul) << st;
243 DestroyShell(std::move(shell), task_runners);
244}

◆ TEST_F() [668/876]

flutter::testing::TEST_F ( PlatformConfigurationTest  ,
OnErrorHandlesError   
)

Definition at line 148 of file platform_configuration_unittests.cc.

148 {
149 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
150 bool did_throw = false;
151
152 auto finish = [message_latch](Dart_NativeArguments args) {
153 message_latch->Signal();
154 };
155 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish));
156
157 Settings settings = CreateSettingsForFixture();
158 settings.unhandled_exception_callback =
159 [&did_throw](const std::string& exception,
160 const std::string& stack_trace) -> bool {
161 did_throw = true;
162 return false;
163 };
164
165 TaskRunners task_runners("test", // label
166 GetCurrentTaskRunner(), // platform
167 CreateNewThread(), // raster
168 CreateNewThread(), // ui
169 CreateNewThread() // io
170 );
171
172 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
173
174 ASSERT_TRUE(shell->IsSetup());
175 auto run_configuration = RunConfiguration::InferFromSettings(settings);
176 run_configuration.SetEntrypoint("customOnErrorTrue");
177
178 shell->RunEngine(std::move(run_configuration), [&](auto result) {
179 ASSERT_EQ(result, Engine::RunStatus::Success);
180 });
181
182 message_latch->Wait();
183
184 // Flush the UI task runner to make sure errors that were triggered had a turn
185 // to propagate.
186 task_runners.GetUITaskRunner()->PostTask(
187 [&message_latch]() { message_latch->Signal(); });
188 message_latch->Wait();
189
190 ASSERT_FALSE(did_throw);
191 DestroyShell(std::move(shell), task_runners);
192}

◆ TEST_F() [669/876]

flutter::testing::TEST_F ( PlatformConfigurationTest  ,
OnErrorThrows   
)

Definition at line 246 of file platform_configuration_unittests.cc.

246 {
247 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
248 std::vector<std::string> errors;
249 size_t throw_count = 0;
250
251 auto finish = [message_latch](Dart_NativeArguments args) {
252 message_latch->Signal();
253 };
254 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish));
255
256 Settings settings = CreateSettingsForFixture();
257 settings.unhandled_exception_callback =
258 [&errors, &throw_count](const std::string& exception,
259 const std::string& stack_trace) -> bool {
260 throw_count += 1;
261 errors.push_back(exception);
262 errors.push_back(stack_trace);
263 return true;
264 };
265
266 TaskRunners task_runners("test", // label
267 GetCurrentTaskRunner(), // platform
268 CreateNewThread(), // raster
269 CreateNewThread(), // ui
270 CreateNewThread() // io
271 );
272
273 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
274
275 ASSERT_TRUE(shell->IsSetup());
276 auto run_configuration = RunConfiguration::InferFromSettings(settings);
277 run_configuration.SetEntrypoint("customOnErrorThrow");
278
279 shell->RunEngine(std::move(run_configuration), [&](auto result) {
280 ASSERT_EQ(result, Engine::RunStatus::Success);
281 });
282
283 message_latch->Wait();
284
285 // Flush the UI task runner to make sure errors that were triggered had a turn
286 // to propagate.
287 task_runners.GetUITaskRunner()->PostTask(
288 [&message_latch]() { message_latch->Signal(); });
289 message_latch->Wait();
290
291 ASSERT_EQ(throw_count, 2ul);
292 ASSERT_EQ(errors.size(), 4ul);
293 ASSERT_EQ(errors[0], "Exception: throw2") << errors[0];
294 ASSERT_EQ(errors[1].rfind("#0 customOnErrorThrow"), 0ul) << errors[1];
295 ASSERT_EQ(errors[2], "Exception: throw1") << errors[2];
296 ASSERT_EQ(errors[3].rfind("#0 customOnErrorThrow"), 0ul) << errors[3];
297
298 DestroyShell(std::move(shell), task_runners);
299}

◆ TEST_F() [670/876]

flutter::testing::TEST_F ( PlatformConfigurationTest  ,
SetDartPerformanceMode   
)

Definition at line 301 of file platform_configuration_unittests.cc.

301 {
302 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
303 auto finish = [message_latch](Dart_NativeArguments args) {
304 // call needs to happen on the UI thread.
308 message_latch->Signal();
309 };
310 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish));
311
312 Settings settings = CreateSettingsForFixture();
313
314 TaskRunners task_runners("test", // label
315 GetCurrentTaskRunner(), // platform
316 CreateNewThread(), // raster
317 CreateNewThread(), // ui
318 CreateNewThread() // io
319 );
320
321 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
322
323 ASSERT_TRUE(shell->IsSetup());
324 auto run_configuration = RunConfiguration::InferFromSettings(settings);
325 run_configuration.SetEntrypoint("setLatencyPerformanceMode");
326
327 shell->RunEngine(std::move(run_configuration), [&](auto result) {
328 ASSERT_EQ(result, Engine::RunStatus::Success);
329 });
330
331 message_latch->Wait();
332 DestroyShell(std::move(shell), task_runners);
333}
static float prev(float f)
Dart_PerformanceMode
Definition dart_api.h:1368
@ Dart_PerformanceMode_Default
Definition dart_api.h:1372
@ Dart_PerformanceMode_Latency
Definition dart_api.h:1379
DART_EXPORT Dart_PerformanceMode Dart_SetPerformanceMode(Dart_PerformanceMode mode)

◆ TEST_F() [671/876]

flutter::testing::TEST_F ( PlatformConfigurationTest  ,
WindowMetricsUpdate   
)

Definition at line 64 of file platform_configuration_unittests.cc.

64 {
65 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
66
67 auto nativeValidateConfiguration =
68 [message_latch](Dart_NativeArguments args) {
69 PlatformConfiguration* configuration =
70 UIDartState::Current()->platform_configuration();
71
72 ASSERT_NE(configuration->GetMetrics(0), nullptr);
73 bool has_view = configuration->UpdateViewMetrics(
74 0, ViewportMetrics{2.0, 10.0, 20.0, 22, 0});
75 ASSERT_TRUE(has_view);
76 ASSERT_EQ(configuration->GetMetrics(0)->device_pixel_ratio, 2.0);
77 ASSERT_EQ(configuration->GetMetrics(0)->physical_width, 10.0);
78 ASSERT_EQ(configuration->GetMetrics(0)->physical_height, 20.0);
79 ASSERT_EQ(configuration->GetMetrics(0)->physical_touch_slop, 22);
80
81 message_latch->Signal();
82 };
83
84 Settings settings = CreateSettingsForFixture();
85 TaskRunners task_runners("test", // label
86 GetCurrentTaskRunner(), // platform
87 CreateNewThread(), // raster
88 CreateNewThread(), // ui
89 CreateNewThread() // io
90 );
91
92 AddNativeCallback("ValidateConfiguration",
93 CREATE_NATIVE_ENTRY(nativeValidateConfiguration));
94
95 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
96
97 ASSERT_TRUE(shell->IsSetup());
98 auto run_configuration = RunConfiguration::InferFromSettings(settings);
99 run_configuration.SetEntrypoint("validateConfiguration");
100
101 shell->RunEngine(std::move(run_configuration), [&](auto result) {
102 ASSERT_EQ(result, Engine::RunStatus::Success);
103 });
104
105 message_latch->Wait();
106 DestroyShell(std::move(shell), task_runners);
107}
bool UpdateViewMetrics(int64_t view_id, const ViewportMetrics &metrics)
Update the view metrics for the specified view.

◆ TEST_F() [672/876]

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

Definition at line 267 of file platform_handler_unittests.cc.

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

◆ TEST_F() [673/876]

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

Definition at line 336 of file platform_handler_unittests.cc.

336 {
337 UseEngineWithView();
338
339 TestBinaryMessenger messenger;
340 PlatformHandler platform_handler(&messenger, engine(), []() {
341 auto clipboard = std::make_unique<MockScopedClipboard>();
342
343 EXPECT_CALL(*clipboard.get(), Open)
344 .Times(1)
345 .WillOnce(Return(kAccessDeniedErrorCode));
346
347 return clipboard;
348 });
349
350 std::string result =
351 SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
352
353 EXPECT_EQ(result, "[{\"value\":false}]");
354}
static constexpr int kAccessDeniedErrorCode

◆ TEST_F() [674/876]

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

Definition at line 309 of file platform_handler_unittests.cc.

309 {
310 UseEngineWithView();
311
312 TestBinaryMessenger messenger;
313 PlatformHandler platform_handler(&messenger, engine());
314
315 std::string result = SimulatePlatformMessage(
316 &messenger, kClipboardHasStringsFakeContentTypeMessage);
317
318 EXPECT_EQ(result, "[\"Clipboard error\",\"Unknown clipboard format\",null]");
319}

◆ TEST_F() [675/876]

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

Definition at line 356 of file platform_handler_unittests.cc.

356 {
357 UseEngineWithView();
358
359 TestBinaryMessenger messenger;
360 PlatformHandler platform_handler(&messenger, engine(), []() {
361 auto clipboard = std::make_unique<MockScopedClipboard>();
362
363 EXPECT_CALL(*clipboard.get(), Open)
364 .Times(1)
365 .WillOnce(Return(kArbitraryErrorCode));
366
367 return clipboard;
368 });
369
370 std::string result =
371 SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
372
373 EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to open clipboard\",1]");
374}

◆ TEST_F() [676/876]

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

Definition at line 321 of file platform_handler_unittests.cc.

321 {
322 UseHeadlessEngine();
323
324 TestBinaryMessenger messenger;
325 PlatformHandler platform_handler(&messenger, engine());
326
327 std::string result =
328 SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
329
330 EXPECT_EQ(result,
331 "[\"Clipboard error\",\"Clipboard is not available in Windows "
332 "headless mode\",null]");
333}

◆ TEST_F() [677/876]

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

Definition at line 288 of file platform_handler_unittests.cc.

288 {
289 UseEngineWithView();
290
291 TestBinaryMessenger messenger;
292 PlatformHandler platform_handler(&messenger, engine(), []() {
293 auto clipboard = std::make_unique<MockScopedClipboard>();
294
295 EXPECT_CALL(*clipboard.get(), Open)
296 .Times(1)
297 .WillOnce(Return(kErrorSuccess));
298 EXPECT_CALL(*clipboard.get(), HasString).Times(1).WillOnce(Return(false));
299
300 return clipboard;
301 });
302
303 std::string result =
304 SimulatePlatformMessage(&messenger, kClipboardHasStringsMessage);
305
306 EXPECT_EQ(result, "[{\"value\":false}]");
307}

◆ TEST_F() [678/876]

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

Definition at line 376 of file platform_handler_unittests.cc.

376 {
377 UseEngineWithView();
378
379 TestBinaryMessenger messenger;
380 PlatformHandler platform_handler(&messenger, engine(), []() {
381 auto clipboard = std::make_unique<MockScopedClipboard>();
382
383 EXPECT_CALL(*clipboard.get(), Open)
384 .Times(1)
385 .WillOnce(Return(kErrorSuccess));
386 EXPECT_CALL(*clipboard.get(), SetString)
387 .Times(1)
388 .WillOnce([](std::wstring string) {
389 EXPECT_EQ(string, L"hello");
390 return kErrorSuccess;
391 });
392
393 return clipboard;
394 });
395
396 std::string result =
397 SimulatePlatformMessage(&messenger, kClipboardSetDataMessage);
398
399 EXPECT_EQ(result, "[null]");
400}

◆ TEST_F() [679/876]

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

Definition at line 441 of file platform_handler_unittests.cc.

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

◆ TEST_F() [680/876]

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

Definition at line 461 of file platform_handler_unittests.cc.

461 {
462 UseEngineWithView();
463
464 TestBinaryMessenger messenger;
465 PlatformHandler platform_handler(&messenger, engine(), []() {
466 auto clipboard = std::make_unique<MockScopedClipboard>();
467
468 EXPECT_CALL(*clipboard.get(), Open)
469 .Times(1)
470 .WillOnce(Return(kErrorSuccess));
471 EXPECT_CALL(*clipboard.get(), SetString)
472 .Times(1)
473 .WillOnce(Return(kArbitraryErrorCode));
474
475 return clipboard;
476 });
477
478 std::string result =
479 SimulatePlatformMessage(&messenger, kClipboardSetDataMessage);
480
481 EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to set clipboard data\",1]");
482}

◆ TEST_F() [681/876]

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

Definition at line 427 of file platform_handler_unittests.cc.

427 {
428 UseHeadlessEngine();
429
430 TestBinaryMessenger messenger;
431 PlatformHandler platform_handler(&messenger, engine());
432
433 std::string result =
434 SimulatePlatformMessage(&messenger, kClipboardSetDataMessage);
435
436 EXPECT_EQ(result,
437 "[\"Clipboard error\",\"Clipboard is not available in Windows "
438 "headless mode\",null]");
439}

◆ TEST_F() [682/876]

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

Definition at line 403 of file platform_handler_unittests.cc.

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

◆ TEST_F() [683/876]

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

Definition at line 415 of file platform_handler_unittests.cc.

415 {
416 UseEngineWithView();
417
418 TestBinaryMessenger messenger;
419 PlatformHandler platform_handler(&messenger, engine());
420
421 std::string result =
422 SimulatePlatformMessage(&messenger, kClipboardSetDataUnknownTypeMessage);
423
424 EXPECT_EQ(result, "[\"Clipboard error\",\"Unknown clipboard format\",null]");
425}

◆ TEST_F() [684/876]

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

Definition at line 172 of file platform_handler_unittests.cc.

172 {
173 UseEngineWithView();
174
175 TestBinaryMessenger messenger;
176 PlatformHandler platform_handler(&messenger, engine(), []() {
177 auto clipboard = std::make_unique<MockScopedClipboard>();
178
179 EXPECT_CALL(*clipboard.get(), Open)
180 .Times(1)
181 .WillOnce(Return(kErrorSuccess));
182 EXPECT_CALL(*clipboard.get(), HasString).Times(1).WillOnce(Return(true));
183 EXPECT_CALL(*clipboard.get(), GetString)
184 .Times(1)
185 .WillOnce(Return(std::wstring(L"Hello world")));
186
187 return clipboard;
188 });
189
190 std::string result =
191 SimulatePlatformMessage(&messenger, kClipboardGetDataMessage);
192
193 EXPECT_EQ(result, "[{\"text\":\"Hello world\"}]");
194}

◆ TEST_F() [685/876]

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

Definition at line 196 of file platform_handler_unittests.cc.

196 {
197 UseEngineWithView();
198
199 TestBinaryMessenger messenger;
200 PlatformHandler platform_handler(&messenger, engine());
201
202 // Requesting an unknown content type is an error.
203 std::string result = SimulatePlatformMessage(
204 &messenger, kClipboardGetDataFakeContentTypeMessage);
205
206 EXPECT_EQ(result, "[\"Clipboard error\",\"Unknown clipboard format\",null]");
207}

◆ TEST_F() [686/876]

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

Definition at line 243 of file platform_handler_unittests.cc.

243 {
244 UseEngineWithView();
245
246 TestBinaryMessenger messenger;
247 PlatformHandler platform_handler(&messenger, engine(), []() {
248 auto clipboard = std::make_unique<MockScopedClipboard>();
249
250 EXPECT_CALL(*clipboard.get(), Open)
251 .Times(1)
252 .WillOnce(Return(kErrorSuccess));
253 EXPECT_CALL(*clipboard.get(), HasString).Times(1).WillOnce(Return(true));
254 EXPECT_CALL(*clipboard.get(), GetString)
255 .Times(1)
256 .WillOnce(Return(kArbitraryErrorCode));
257
258 return clipboard;
259 });
260
261 std::string result =
262 SimulatePlatformMessage(&messenger, kClipboardGetDataMessage);
263
264 EXPECT_EQ(result, "[\"Clipboard error\",\"Unable to get clipboard data\",1]");
265}

◆ TEST_F() [687/876]

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

Definition at line 223 of file platform_handler_unittests.cc.

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

◆ TEST_F() [688/876]

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

Definition at line 209 of file platform_handler_unittests.cc.

209 {
210 UseHeadlessEngine();
211
212 TestBinaryMessenger messenger;
213 PlatformHandler platform_handler(&messenger, engine());
214
215 std::string result =
216 SimulatePlatformMessage(&messenger, kClipboardGetDataMessage);
217
218 EXPECT_EQ(result,
219 "[\"Clipboard error\",\"Clipboard is not available in "
220 "Windows headless mode\",null]");
221}

◆ TEST_F() [689/876]

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

Definition at line 484 of file platform_handler_unittests.cc.

484 {
485 UseHeadlessEngine();
486
487 TestBinaryMessenger messenger;
488 MockPlatformHandler platform_handler(&messenger, engine());
489
490 EXPECT_CALL(platform_handler, SystemSoundPlay("SystemSoundType.alert", _))
491 .WillOnce([](const std::string& sound,
492 std::unique_ptr<MethodResult<rapidjson::Document>> result) {
493 result->Success();
494 });
495
496 std::string result =
497 SimulatePlatformMessage(&messenger, kSystemSoundTypeAlertMessage);
498
499 EXPECT_EQ(result, "[null]");
500}

◆ TEST_F() [690/876]

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

Definition at line 524 of file platform_handler_unittests.cc.

524 {
525 UseHeadlessEngine();
526 bool called_cancel = false;
527
528 TestBinaryMessenger messenger(
529 [&called_cancel](const std::string& channel, const uint8_t* message,
530 size_t size, BinaryReply reply) {
531 reply(reinterpret_cast<const uint8_t*>(kExitResponseCancelMessage),
532 sizeof(kExitResponseCancelMessage));
533 called_cancel = true;
534 });
535 MockPlatformHandler platform_handler(&messenger, engine());
536
537 EXPECT_CALL(platform_handler, QuitApplication).Times(0);
538
539 std::string result = SimulatePlatformMessage(
540 &messenger, kSystemExitApplicationCancelableMessage);
541 EXPECT_EQ(result, "[{\"response\":\"cancel\"}]");
542 EXPECT_TRUE(called_cancel);
543}

◆ TEST_F() [691/876]

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

Definition at line 545 of file platform_handler_unittests.cc.

545 {
546 UseHeadlessEngine();
547 bool called_cancel = false;
548 UINT exit_code = 0;
549
550 TestBinaryMessenger messenger(
551 [&called_cancel](const std::string& channel, const uint8_t* message,
552 size_t size, BinaryReply reply) {
553 reply(reinterpret_cast<const uint8_t*>(kExitResponseExitMessage),
554 sizeof(kExitResponseExitMessage));
555 called_cancel = true;
556 });
557 MockPlatformHandler platform_handler(&messenger, engine());
558
559 ON_CALL(platform_handler, QuitApplication)
560 .WillByDefault([&exit_code](std::optional<HWND> hwnd,
561 std::optional<WPARAM> wparam,
562 std::optional<LPARAM> lparam,
563 UINT ec) { exit_code = ec; });
564 EXPECT_CALL(platform_handler, QuitApplication).Times(1);
565
566 std::string result = SimulatePlatformMessage(
567 &messenger, kSystemExitApplicationCancelableMessage);
568 EXPECT_EQ(result, "[{\"response\":\"cancel\"}]");
569 EXPECT_TRUE(called_cancel);
570 EXPECT_EQ(exit_code, 2);
571}

◆ TEST_F() [692/876]

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

Definition at line 502 of file platform_handler_unittests.cc.

502 {
503 UseHeadlessEngine();
504 UINT exit_code = 0;
505
506 TestBinaryMessenger messenger([](const std::string& channel,
507 const uint8_t* message, size_t size,
508 BinaryReply reply) {});
509 MockPlatformHandler platform_handler(&messenger, engine());
510
511 ON_CALL(platform_handler, QuitApplication)
512 .WillByDefault([&exit_code](std::optional<HWND> hwnd,
513 std::optional<WPARAM> wparam,
514 std::optional<LPARAM> lparam,
515 UINT ec) { exit_code = ec; });
516 EXPECT_CALL(platform_handler, QuitApplication).Times(1);
517
518 std::string result = SimulatePlatformMessage(
519 &messenger, kSystemExitApplicationRequiredMessage);
520 EXPECT_EQ(result, "[{\"response\":\"exit\"}]");
521 EXPECT_EQ(exit_code, 1);
522}

◆ TEST_F() [693/876]

flutter::testing::TEST_F ( PlatformIsolateManagerTest  ,
EarlyShutdown   
)

Definition at line 162 of file platform_isolate_manager_unittests.cc.

162 {
163 TestWithRootIsolate([this]() {
165 EXPECT_FALSE(mgr.HasShutdown());
166
167 Dart_Isolate isolateA = CreateAndRegisterIsolate(&mgr);
168 ASSERT_TRUE(isolateA);
169 EXPECT_FALSE(IsolateIsShutdown(isolateA));
170 EXPECT_TRUE(IsolateWasRegistered(isolateA));
172
173 Dart_Isolate isolateB = CreateAndRegisterIsolate(&mgr);
174 ASSERT_TRUE(isolateB);
175 EXPECT_FALSE(IsolateIsShutdown(isolateB));
176 EXPECT_TRUE(IsolateWasRegistered(isolateB));
178
179 Dart_EnterIsolate(isolateA);
181 EXPECT_TRUE(IsolateIsShutdown(isolateA));
182 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateA));
183
184 Dart_EnterIsolate(isolateB);
186 EXPECT_TRUE(IsolateIsShutdown(isolateB));
187 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateB));
188
191
192 EXPECT_TRUE(IsolateIsShutdown(isolateA));
193 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateA));
194 EXPECT_TRUE(IsolateIsShutdown(isolateB));
195 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateB));
196 });
197}
bool IsRegisteredForTestingOnly(Dart_Isolate isolate)

◆ TEST_F() [694/876]

flutter::testing::TEST_F ( PlatformIsolateManagerTest  ,
MultithreadedCreation   
)

Definition at line 229 of file platform_isolate_manager_unittests.cc.

229 {
230 // Try to generate race conditions by creating Isolates on multiple threads,
231 // while shutting down the manager.
232 TestWithRootIsolate([this]() {
234 EXPECT_FALSE(mgr.HasShutdown());
235
236 std::atomic<bool> test_finished = false;
237 std::vector<std::thread> threads;
238 threads.reserve(10);
239 for (int i = 0; i < 10; ++i) {
240 threads.push_back(std::thread([this, &mgr, &test_finished]() {
241 for (int j = 0; j < 100; ++j) {
242 Dart_Isolate isolate = CreateAndRegisterIsolate(&mgr);
243 ASSERT_TRUE(isolate);
244
245 if (!IsolateWasRegistered(isolate)) {
246 Dart_EnterIsolate(isolate);
248 }
249 }
250 while (!test_finished.load()) {
251 // Wait for the test to finish, to avoid prematurely destroying thread
252 // local isolate_data_map_.
253 }
254 }));
255 }
256
259
260 test_finished = true;
261 for (auto& thread : threads) {
262 thread.join();
263 }
264 });
265}

◆ TEST_F() [695/876]

flutter::testing::TEST_F ( PlatformIsolateManagerTest  ,
OrdinaryFlow   
)

Definition at line 133 of file platform_isolate_manager_unittests.cc.

133 {
134 TestWithRootIsolate([this]() {
136 EXPECT_FALSE(mgr.HasShutdown());
137 EXPECT_FALSE(mgr.HasShutdownMaybeFalseNegative());
138
139 Dart_Isolate isolateA = CreateAndRegisterIsolate(&mgr);
140 ASSERT_TRUE(isolateA);
141 EXPECT_FALSE(IsolateIsShutdown(isolateA));
142 EXPECT_TRUE(IsolateWasRegistered(isolateA));
144
145 Dart_Isolate isolateB = CreateAndRegisterIsolate(&mgr);
146 ASSERT_TRUE(isolateB);
147 EXPECT_FALSE(IsolateIsShutdown(isolateB));
148 EXPECT_TRUE(IsolateWasRegistered(isolateB));
150
154
155 EXPECT_TRUE(IsolateIsShutdown(isolateA));
156 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateA));
157 EXPECT_TRUE(IsolateIsShutdown(isolateB));
158 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateB));
159 });
160}

◆ TEST_F() [696/876]

flutter::testing::TEST_F ( PlatformIsolateManagerTest  ,
RegistrationAfterShutdown   
)

Definition at line 199 of file platform_isolate_manager_unittests.cc.

199 {
200 TestWithRootIsolate([this]() {
202 EXPECT_FALSE(mgr.HasShutdown());
203
204 Dart_Isolate isolateA = CreateAndRegisterIsolate(&mgr);
205 ASSERT_TRUE(isolateA);
206 EXPECT_FALSE(IsolateIsShutdown(isolateA));
207 EXPECT_TRUE(IsolateWasRegistered(isolateA));
209
212
213 EXPECT_TRUE(IsolateIsShutdown(isolateA));
214 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateA));
215
216 Dart_Isolate isolateB = CreateAndRegisterIsolate(&mgr);
217 ASSERT_TRUE(isolateB);
218 EXPECT_FALSE(IsolateIsShutdown(isolateB));
219 EXPECT_FALSE(IsolateWasRegistered(isolateB));
220 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateB));
221
222 Dart_EnterIsolate(isolateB);
224 EXPECT_TRUE(IsolateIsShutdown(isolateB));
225 EXPECT_FALSE(mgr.IsRegisteredForTestingOnly(isolateB));
226 });
227}

◆ TEST_F() [697/876]

flutter::testing::TEST_F ( PlatformViewLayerTest  ,
ClippedPlatformViewPrerollsAndPaintsNothing   
)

Definition at line 42 of file platform_view_layer_unittests.cc.

42 {
43 const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
44 const SkSize layer_size = SkSize::Make(8.0f, 8.0f);
45 const SkRect child_clip = SkRect::MakeLTRB(20.0f, 20.0f, 40.0f, 40.0f);
46 const SkRect parent_clip = SkRect::MakeLTRB(50.0f, 50.0f, 80.0f, 80.0f);
47 const int64_t view_id = 0;
48 auto layer =
49 std::make_shared<PlatformViewLayer>(layer_offset, layer_size, view_id);
50 auto child_clip_layer =
51 std::make_shared<ClipRectLayer>(child_clip, Clip::kHardEdge);
52 auto parent_clip_layer =
53 std::make_shared<ClipRectLayer>(parent_clip, Clip::kHardEdge);
54 parent_clip_layer->Add(child_clip_layer);
55 child_clip_layer->Add(layer);
56
57 auto embedder = MockViewEmbedder();
58 preroll_context()->view_embedder = &embedder;
59
60 parent_clip_layer->Preroll(preroll_context());
61 EXPECT_TRUE(preroll_context()->has_platform_view);
62 EXPECT_EQ(layer->paint_bounds(),
63 SkRect::MakeSize(layer_size)
64 .makeOffset(layer_offset.fX, layer_offset.fY));
65 EXPECT_TRUE(layer->needs_painting(paint_context()));
66 EXPECT_TRUE(child_clip_layer->needs_painting(paint_context()));
67 EXPECT_TRUE(parent_clip_layer->needs_painting(paint_context()));
68 EXPECT_TRUE(layer->subtree_has_platform_view());
69 EXPECT_TRUE(child_clip_layer->subtree_has_platform_view());
70 EXPECT_TRUE(parent_clip_layer->subtree_has_platform_view());
71
72 parent_clip_layer->Paint(paint_context());
73 EXPECT_EQ(paint_context().canvas, &mock_canvas());
74 EXPECT_EQ(
75 mock_canvas().draw_calls(),
76 std::vector(
78 MockCanvas::DrawCall{
79 1, MockCanvas::ClipRectData{parent_clip, ClipOp::kIntersect,
80 MockCanvas::kHardClipEdgeStyle}},
81 MockCanvas::DrawCall{1, MockCanvas::SaveData{2}},
82 MockCanvas::DrawCall{
83 2, MockCanvas::ClipRectData{child_clip, ClipOp::kIntersect,
84 MockCanvas::kHardClipEdgeStyle}},
85 MockCanvas::DrawCall{2, MockCanvas::RestoreData{1}},
86 MockCanvas::DrawCall{1, MockCanvas::RestoreData{0}}}));
87}
static constexpr SkRect MakeSize(const SkSize &size)
Definition SkRect.h:633

◆ TEST_F() [698/876]

flutter::testing::TEST_F ( PlatformViewLayerTest  ,
NullViewEmbedderDoesntPrerollCompositeOrPaint   
)

Definition at line 22 of file platform_view_layer_unittests.cc.

22 {
23 const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
24 const SkSize layer_size = SkSize::Make(8.0f, 8.0f);
25 const int64_t view_id = 0;
26 auto layer =
27 std::make_shared<PlatformViewLayer>(layer_offset, layer_size, view_id);
28
29 layer->Preroll(preroll_context());
30 EXPECT_FALSE(preroll_context()->has_platform_view);
31 EXPECT_EQ(layer->paint_bounds(),
32 SkRect::MakeSize(layer_size)
33 .makeOffset(layer_offset.fX, layer_offset.fY));
34 EXPECT_TRUE(layer->needs_painting(paint_context()));
35 EXPECT_FALSE(layer->subtree_has_platform_view());
36
37 layer->Paint(paint_context());
38 EXPECT_EQ(paint_context().canvas, &mock_canvas());
39 EXPECT_EQ(mock_canvas().draw_calls(), std::vector<MockCanvas::DrawCall>());
40}

◆ TEST_F() [699/876]

flutter::testing::TEST_F ( PlatformViewLayerTest  ,
StateTransfer   
)

Definition at line 101 of file platform_view_layer_unittests.cc.

101 {
102 const SkMatrix transform1 = SkMatrix::Translate(5, 5);
103 const SkMatrix transform2 = SkMatrix::Translate(15, 15);
104 const SkMatrix combined_transform = SkMatrix::Translate(20, 20);
105 const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
106 const SkSize layer_size = SkSize::Make(8.0f, 8.0f);
107 const int64_t view_id = 0;
108 const SkPath path1 = SkPath().addOval({10, 10, 20, 20});
109 const SkPath path2 = SkPath().addOval({15, 15, 30, 30});
110
111 // transform_layer1
112 // |- child1
113 // |- platform_layer
114 // |- transform_layer2
115 // |- child2
116 auto transform_layer1 = std::make_shared<TransformLayer>(transform1);
117 auto transform_layer2 = std::make_shared<TransformLayer>(transform2);
118 auto platform_layer =
119 std::make_shared<PlatformViewLayer>(layer_offset, layer_size, view_id);
120 auto child1 = std::make_shared<MockLayer>(path1);
121 child1->set_expected_paint_matrix(transform1);
122 auto child2 = std::make_shared<MockLayer>(path2);
123 child2->set_expected_paint_matrix(combined_transform);
124 transform_layer1->Add(child1);
125 transform_layer1->Add(platform_layer);
126 transform_layer1->Add(transform_layer2);
127 transform_layer2->Add(child2);
128
129 auto embedder = MockViewEmbedder();
130 DisplayListBuilder builder({0, 0, 500, 500});
131 embedder.AddCanvas(&builder);
132
133 PrerollContext* preroll_ctx = preroll_context();
134 preroll_ctx->view_embedder = &embedder;
135 transform_layer1->Preroll(preroll_ctx);
136
137 PaintContext& paint_ctx = paint_context();
138 paint_ctx.view_embedder = &embedder;
139 transform_layer1->Paint(paint_ctx);
140}

◆ TEST_F() [700/876]

flutter::testing::TEST_F ( RasterCacheTest  ,
RasterCacheKeyIDLayerChildrenIds   
)

Definition at line 789 of file raster_cache_unittests.cc.

789 {
790 auto layer = std::make_shared<ContainerLayer>();
791
792 const SkPath child_path = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
793 auto mock_layer = std::make_shared<MockLayer>(child_path);
794 layer->Add(mock_layer);
795
796 auto display_list = GetSampleDisplayList();
797 auto display_list_layer = std::make_shared<DisplayListLayer>(
798 SkPoint::Make(0.0f, 0.0f), display_list, false, false);
799 layer->Add(display_list_layer);
800
801 auto ids = RasterCacheKeyID::LayerChildrenIds(layer.get()).value();
802 std::vector<RasterCacheKeyID> expected_ids;
803 expected_ids.emplace_back(
804 RasterCacheKeyID(mock_layer->unique_id(), RasterCacheKeyType::kLayer));
805 expected_ids.emplace_back(RasterCacheKeyID(display_list->unique_id(),
806 RasterCacheKeyType::kDisplayList));
807 ASSERT_EQ(expected_ids[0], mock_layer->caching_key_id());
808 ASSERT_EQ(expected_ids[1], display_list_layer->caching_key_id());
809 ASSERT_EQ(ids, expected_ids);
810}

◆ TEST_F() [701/876]

flutter::testing::TEST_F ( SemanticsUpdateBuilderTest  ,
CanHandleAttributedStrings   
)

Definition at line 15 of file semantics_update_builder_unittests.cc.

15 {
16 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
17
18 auto nativeSemanticsUpdate = [message_latch](Dart_NativeArguments args) {
19 auto handle = Dart_GetNativeArgument(args, 0);
20 intptr_t peer = 0;
23 ASSERT_FALSE(Dart_IsError(result));
24 SemanticsUpdate* update = reinterpret_cast<SemanticsUpdate*>(peer);
25 SemanticsNodeUpdates nodes = update->takeNodes();
26 ASSERT_EQ(nodes.size(), (size_t)1);
27 auto node = nodes.find(0)->second;
28 // Should match the updateNode in ui_test.dart.
29 ASSERT_EQ(node.label, "label");
30 ASSERT_EQ(node.labelAttributes.size(), (size_t)1);
31 ASSERT_EQ(node.labelAttributes[0]->start, 1);
32 ASSERT_EQ(node.labelAttributes[0]->end, 2);
33 ASSERT_EQ(node.labelAttributes[0]->type, StringAttributeType::kSpellOut);
34
35 ASSERT_EQ(node.value, "value");
36 ASSERT_EQ(node.valueAttributes.size(), (size_t)1);
37 ASSERT_EQ(node.valueAttributes[0]->start, 2);
38 ASSERT_EQ(node.valueAttributes[0]->end, 3);
39 ASSERT_EQ(node.valueAttributes[0]->type, StringAttributeType::kSpellOut);
40
41 ASSERT_EQ(node.hint, "hint");
42 ASSERT_EQ(node.hintAttributes.size(), (size_t)1);
43 ASSERT_EQ(node.hintAttributes[0]->start, 0);
44 ASSERT_EQ(node.hintAttributes[0]->end, 1);
45 ASSERT_EQ(node.hintAttributes[0]->type, StringAttributeType::kLocale);
46 auto local_attribute =
47 std::static_pointer_cast<LocaleStringAttribute>(node.hintAttributes[0]);
48 ASSERT_EQ(local_attribute->locale, "en-MX");
49
50 ASSERT_EQ(node.increasedValue, "increasedValue");
51 ASSERT_EQ(node.increasedValueAttributes.size(), (size_t)1);
52 ASSERT_EQ(node.increasedValueAttributes[0]->start, 4);
53 ASSERT_EQ(node.increasedValueAttributes[0]->end, 5);
54 ASSERT_EQ(node.increasedValueAttributes[0]->type,
55 StringAttributeType::kSpellOut);
56
57 ASSERT_EQ(node.decreasedValue, "decreasedValue");
58 ASSERT_EQ(node.decreasedValueAttributes.size(), (size_t)1);
59 ASSERT_EQ(node.decreasedValueAttributes[0]->start, 5);
60 ASSERT_EQ(node.decreasedValueAttributes[0]->end, 6);
61 ASSERT_EQ(node.decreasedValueAttributes[0]->type,
62 StringAttributeType::kSpellOut);
63 message_latch->Signal();
64 };
65
66 Settings settings = CreateSettingsForFixture();
67 TaskRunners task_runners("test", // label
68 GetCurrentTaskRunner(), // platform
69 CreateNewThread(), // raster
70 CreateNewThread(), // ui
71 CreateNewThread() // io
72 );
73
74 AddNativeCallback("SemanticsUpdate",
75 CREATE_NATIVE_ENTRY(nativeSemanticsUpdate));
76
77 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
78
79 ASSERT_TRUE(shell->IsSetup());
80 auto configuration = RunConfiguration::InferFromSettings(settings);
81 configuration.SetEntrypoint("sendSemanticsUpdate");
82
83 shell->RunEngine(std::move(configuration), [](auto result) {
84 ASSERT_EQ(result, Engine::RunStatus::Success);
85 });
86
87 message_latch->Wait();
88 DestroyShell(std::move(shell), task_runners);
89}
DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, int index, intptr_t *value)

◆ TEST_F() [702/876]

flutter::testing::TEST_F ( ShaderMaskLayerTest  ,
SimpleFilterWithRasterCacheLayerNotCached   
)

Definition at line 420 of file shader_mask_layer_unittests.cc.

420 {
421 use_mock_raster_cache(); // Ensure non-fractional alignment.
422
423 const SkMatrix initial_transform = SkMatrix::Translate(0.5f, 1.0f);
424 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
425 const SkRect layer_bounds = SkRect::MakeLTRB(2.0f, 4.0f, 6.5f, 6.5f);
426 const SkPath child_path = SkPath().addRect(child_bounds);
427 const DlPaint child_paint = DlPaint(DlColor::kYellow());
428 auto dl_filter = MakeFilter(DlColor::kBlue());
429 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
430 auto layer = std::make_shared<ShaderMaskLayer>(dl_filter, layer_bounds,
431 DlBlendMode::kSrc);
432 layer->Add(mock_layer);
433
434 preroll_context()->state_stack.set_preroll_delegate(initial_transform);
435 layer->Preroll(preroll_context());
436
437 DlPaint filter_paint;
438 filter_paint.setBlendMode(DlBlendMode::kSrc);
439 filter_paint.setColorSource(dl_filter);
440
441 layer->Paint(display_list_paint_context());
442 DisplayListBuilder expected_builder;
443 /* (ShaderMask)layer::Paint */ {
444 expected_builder.Save();
445 {
446 // The layer will notice that the CTM is already an integer matrix
447 // and will not perform an Integral CTM operation.
448 // expected_builder.TransformReset();
449 // expected_builder.Transform(SkMatrix());
450 expected_builder.SaveLayer(&child_bounds);
451 {
452 /* mock_layer::Paint */ {
453 expected_builder.DrawPath(child_path, child_paint);
454 }
455 expected_builder.Translate(layer_bounds.fLeft, layer_bounds.fTop);
456 expected_builder.DrawRect(
457 SkRect::MakeWH(layer_bounds.width(), layer_bounds.height()),
458 filter_paint);
459 }
460 expected_builder.Restore();
461 }
462 expected_builder.Restore();
463 }
464 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
465}
static std::shared_ptr< DlColorSource > MakeFilter(DlColor color)
constexpr float height() const
Definition SkRect.h:769
constexpr float width() const
Definition SkRect.h:762

◆ TEST_F() [703/876]

flutter::testing::TEST_F ( ShellIOManagerTest  ,
ItDoesNotCrashThatSkiaUnrefQueueDrainAfterIOManagerReset   
)

Definition at line 22 of file shell_io_manager_unittests.cc.

23 {
24 auto settings = CreateSettingsForFixture();
25 auto vm_ref = DartVMRef::Create(settings);
26 auto vm_data = vm_ref.GetVMData();
27 auto gif_mapping = flutter::testing::OpenFixtureAsSkData("hello_loop_2.gif");
28 ASSERT_TRUE(gif_mapping);
29
31 std::shared_ptr<ImageGenerator> gif_generator =
32 registry.CreateCompatibleGenerator(gif_mapping);
33 ASSERT_TRUE(gif_generator);
34
35 TaskRunners runners(GetCurrentTestName(), // label
36 CreateNewThread("platform"), // platform
37 CreateNewThread("raster"), // raster
38 CreateNewThread("ui"), // ui
39 CreateNewThread("io") // io
40 );
41
42 std::unique_ptr<TestGLSurface> gl_surface;
43 std::unique_ptr<ShellIOManager> io_manager;
45
46 // Setup the IO manager.
47 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
48 gl_surface = std::make_unique<TestGLSurface>(SkISize::Make(1, 1));
49 io_manager = std::make_unique<ShellIOManager>(
50 gl_surface->CreateGrContext(), std::make_shared<fml::SyncSwitch>(),
51 runners.GetIOTaskRunner(), nullptr,
52 fml::TimeDelta::FromMilliseconds(0));
53 });
54
55 auto isolate = RunDartCodeInIsolate(vm_ref, settings, runners, "emptyMain",
56 {}, GetDefaultKernelFilePath(),
57 io_manager->GetWeakIOManager());
58
59 PostTaskSync(runners.GetUITaskRunner(), [&]() {
60 fml::AutoResetWaitableEvent isolate_latch;
61
62 EXPECT_TRUE(isolate->RunInIsolateScope([&]() -> bool {
63 Dart_Handle library = Dart_RootLibrary();
64 if (Dart_IsError(library)) {
65 isolate_latch.Signal();
66 return false;
67 }
68 Dart_Handle closure =
69 Dart_GetField(library, Dart_NewStringFromCString("frameCallback"));
70 if (Dart_IsError(closure) || !Dart_IsClosure(closure)) {
71 isolate_latch.Signal();
72 return false;
73 }
74
75 codec = fml::MakeRefCounted<MultiFrameCodec>(std::move(gif_generator));
76 codec->getNextFrame(closure);
77 isolate_latch.Signal();
78 return true;
79 }));
80 isolate_latch.Wait();
81 });
82
83 // Destroy the IO manager
84 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
85 // 'SkiaUnrefQueue.Drain' will be called after 'io_manager.reset()' in this
86 // test, If the resource context has been destroyed at that time, it will
87 // crash.
88 //
89 // 'Drain()' currently checks whether the weak pointer is still valid or not
90 // before trying to call anything on it.
91 //
92 // However, calling 'unref' on the 'SkImage_Lazy' ends up freeing a
93 // 'GrBackendTexture'. That object seems to assume that something else is
94 // keeping the context alive. This seems like it might be a bad assumption
95 // on Skia's part, but in Skia's defense we're doing something pretty weird
96 // here by keeping GPU resident objects alive without keeping the
97 // 'GrDirectContext' alive ourselves.
98 //
99 // See https://github.com/flutter/flutter/issues/87895
100 io_manager.reset();
101 gl_surface.reset();
102 });
103}
void PostTaskSync(const fml::RefPtr< fml::TaskRunner > &task_runner, const std::function< void()> &function)

◆ TEST_F() [704/876]

flutter::testing::TEST_F ( ShellTest  ,
AllowedDartVMFlag   
)

Definition at line 661 of file shell_unittests.cc.

661 {
662 std::vector<const char*> flags = {
663 "--enable-isolate-groups",
664 "--no-enable-isolate-groups",
665 };
666#if !FLUTTER_RELEASE
667 flags.push_back("--max_profile_depth 1");
668 flags.push_back("--random_seed 42");
669 flags.push_back("--max_subtype_cache_entries=22");
670 if (!DartVM::IsRunningPrecompiledCode()) {
671 flags.push_back("--enable_mirrors");
672 }
673#endif
674
675 TestDartVmFlags(flags);
676}

◆ TEST_F() [705/876]

flutter::testing::TEST_F ( ShellTest  ,
AnimatorDoesNotNotifyDelegateIfPipelineIsNotEmpty   
)

Definition at line 209 of file animator_unittests.cc.

209 {
210 FakeAnimatorDelegate delegate;
211 TaskRunners task_runners = {
212 "test",
213 CreateNewThread(), // platform
214 CreateNewThread(), // raster
215 CreateNewThread(), // ui
216 CreateNewThread() // io
217 };
218
219 auto clock = std::make_shared<ShellTestVsyncClock>();
220 std::shared_ptr<Animator> animator;
221
222 auto flush_vsync_task = [&] {
224 task_runners.GetUITaskRunner()->PostTask([&] { ui_latch.Signal(); });
225 do {
226 clock->SimulateVSync();
228 };
229
230 // Create the animator on the UI task runner.
231 PostTaskSync(task_runners.GetUITaskRunner(), [&] {
232 auto vsync_waiter = static_cast<std::unique_ptr<VsyncWaiter>>(
233 std::make_unique<ShellTestVsyncWaiter>(task_runners, clock));
234 animator = std::make_unique<Animator>(delegate, task_runners,
235 std::move(vsync_waiter));
236 });
237
238 fml::AutoResetWaitableEvent begin_frame_latch;
239 // It must always be called when the method 'Animator::Render' is called,
240 // regardless of whether the pipeline is empty or not.
241 EXPECT_CALL(delegate, OnAnimatorUpdateLatestFrameTargetTime).Times(2);
242 // It will only be called once even though we call the method
243 // 'Animator::Render' twice. because it will only be called when the pipeline
244 // is empty.
245 EXPECT_CALL(delegate, OnAnimatorDraw).Times(1);
246
247 for (int i = 0; i < 2; i++) {
248 task_runners.GetUITaskRunner()->PostTask([&] {
249 EXPECT_CALL(delegate, OnAnimatorBeginFrame).WillOnce([&] {
250 auto layer_tree = std::make_unique<LayerTree>(LayerTree::Config(),
251 SkISize::Make(600, 800));
252 animator->Render(kImplicitViewId, std::move(layer_tree), 1.0);
253 begin_frame_latch.Signal();
254 });
255 animator->RequestFrame();
256 task_runners.GetPlatformTaskRunner()->PostTask(flush_vsync_task);
257 });
258 begin_frame_latch.Wait();
259 }
260
261 PostTaskSync(task_runners.GetUITaskRunner(), [&] { animator.reset(); });
262}
bool WaitWithTimeout(TimeDelta timeout)

◆ TEST_F() [706/876]

flutter::testing::TEST_F ( ShellTest  ,
AnimatorDoesNotNotifyIdleBeforeRender   
)

Definition at line 119 of file animator_unittests.cc.

119 {
120 FakeAnimatorDelegate delegate;
121 TaskRunners task_runners = {
122 "test",
123 CreateNewThread(), // platform
124 CreateNewThread(), // raster
125 CreateNewThread(), // ui
126 CreateNewThread() // io
127 };
128
129 auto clock = std::make_shared<ShellTestVsyncClock>();
131 std::shared_ptr<Animator> animator;
132
133 auto flush_vsync_task = [&] {
135 task_runners.GetUITaskRunner()->PostTask([&] { ui_latch.Signal(); });
136 do {
137 clock->SimulateVSync();
139 latch.Signal();
140 };
141
142 // Create the animator on the UI task runner.
143 task_runners.GetUITaskRunner()->PostTask([&] {
144 auto vsync_waiter = static_cast<std::unique_ptr<VsyncWaiter>>(
145 std::make_unique<ShellTestVsyncWaiter>(task_runners, clock));
146 animator = std::make_unique<Animator>(delegate, task_runners,
147 std::move(vsync_waiter));
148 latch.Signal();
149 });
150 latch.Wait();
151
152 // Validate it has not notified idle and start it. This will request a frame.
153 task_runners.GetUITaskRunner()->PostTask([&] {
154 ASSERT_FALSE(delegate.notify_idle_called_);
155 // Immediately request a frame saying it can reuse the last layer tree to
156 // avoid more calls to BeginFrame by the animator.
157 animator->RequestFrame(false);
158 task_runners.GetPlatformTaskRunner()->PostTask(flush_vsync_task);
159 });
160 latch.Wait();
161 ASSERT_FALSE(delegate.notify_idle_called_);
162
163 fml::AutoResetWaitableEvent render_latch;
164 // Validate it has not notified idle and try to render.
165 task_runners.GetUITaskRunner()->PostDelayedTask(
166 [&] {
167 ASSERT_FALSE(delegate.notify_idle_called_);
168 EXPECT_CALL(delegate, OnAnimatorBeginFrame).WillOnce([&] {
169 auto layer_tree = std::make_unique<LayerTree>(
170 LayerTree::Config(), SkISize::Make(600, 800));
171 animator->Render(kImplicitViewId, std::move(layer_tree), 1.0);
172 render_latch.Signal();
173 });
174 // Request a frame that builds a layer tree and renders a frame.
175 // When the frame is rendered, render_latch will be signaled.
176 animator->RequestFrame(true);
177 task_runners.GetPlatformTaskRunner()->PostTask(flush_vsync_task);
178 },
179 // See kNotifyIdleTaskWaitTime in animator.cc.
181 latch.Wait();
182 render_latch.Wait();
183
184 // A frame has been rendered, and the next frame request will notify idle.
185 // But at the moment there isn't another frame request, therefore it still
186 // hasn't notified idle.
187 task_runners.GetUITaskRunner()->PostTask([&] {
188 ASSERT_FALSE(delegate.notify_idle_called_);
189 // False to avoid getting cals to BeginFrame that will request more frames
190 // before we are ready.
191 animator->RequestFrame(false);
192 task_runners.GetPlatformTaskRunner()->PostTask(flush_vsync_task);
193 });
194 latch.Wait();
195
196 // Now it should notify idle. Make sure it is destroyed on the UI thread.
197 ASSERT_TRUE(delegate.notify_idle_called_);
198
199 task_runners.GetPlatformTaskRunner()->PostTask(flush_vsync_task);
200 latch.Wait();
201
202 task_runners.GetUITaskRunner()->PostTask([&] {
203 animator.reset();
204 latch.Signal();
205 });
206 latch.Wait();
207}
virtual void PostDelayedTask(const fml::closure &task, fml::TimeDelta delay)

◆ TEST_F() [707/876]

flutter::testing::TEST_F ( ShellTest  ,
AssetManagerMulti   
)

Definition at line 3099 of file shell_unittests.cc.

3099 {
3101 fml::UniqueFD asset_dir_fd = fml::OpenDirectory(
3102 asset_dir.path().c_str(), false, fml::FilePermission::kRead);
3103
3104 std::vector<std::string> filenames = {
3105 "good0",
3106 "bad0",
3107 "good1",
3108 "bad1",
3109 };
3110
3111 for (const auto& filename : filenames) {
3112 bool success = fml::WriteAtomically(asset_dir_fd, filename.c_str(),
3113 fml::DataMapping(filename));
3114 ASSERT_TRUE(success);
3115 }
3116
3117 AssetManager asset_manager;
3118 asset_manager.PushBack(
3119 std::make_unique<DirectoryAssetBundle>(std::move(asset_dir_fd), false));
3120
3121 auto mappings = asset_manager.GetAsMappings("(.*)", std::nullopt);
3122 EXPECT_EQ(mappings.size(), 4u);
3123
3124 std::vector<std::string> expected_results = {
3125 "good0",
3126 "good1",
3127 };
3128
3129 mappings = asset_manager.GetAsMappings("(.*)good(.*)", std::nullopt);
3130 ASSERT_EQ(mappings.size(), expected_results.size());
3131
3132 for (auto& mapping : mappings) {
3133 std::string result(reinterpret_cast<const char*>(mapping->GetMapping()),
3134 mapping->GetSize());
3135 EXPECT_NE(
3136 std::find(expected_results.begin(), expected_results.end(), result),
3137 expected_results.end());
3138 }
3139}

◆ TEST_F() [708/876]

flutter::testing::TEST_F ( ShellTest  ,
AssetManagerSingle   
)

Definition at line 3074 of file shell_unittests.cc.

3074 {
3076 fml::UniqueFD asset_dir_fd = fml::OpenDirectory(
3077 asset_dir.path().c_str(), false, fml::FilePermission::kRead);
3078
3079 std::string filename = "test_name";
3080 std::string content = "test_content";
3081
3082 bool success = fml::WriteAtomically(asset_dir_fd, filename.c_str(),
3084 ASSERT_TRUE(success);
3085
3086 AssetManager asset_manager;
3087 asset_manager.PushBack(
3088 std::make_unique<DirectoryAssetBundle>(std::move(asset_dir_fd), false));
3089
3090 auto mapping = asset_manager.GetAsMapping(filename);
3091 ASSERT_TRUE(mapping != nullptr);
3092
3093 std::string result(reinterpret_cast<const char*>(mapping->GetMapping()),
3094 mapping->GetSize());
3095
3096 ASSERT_TRUE(result == content);
3097}
std::unique_ptr< fml::Mapping > GetAsMapping(const std::string &asset_name) const override
bool PushBack(std::unique_ptr< AssetResolver > resolver)
Adds an asset resolver to the end of the resolver queue. Assets would be loaded from this resolver af...

◆ TEST_F() [709/876]

flutter::testing::TEST_F ( ShellTest  ,
CanCorrectlyPipePointerPacket   
)

Definition at line 305 of file input_events_unittests.cc.

305 {
306 // Sets up shell with test fixture.
307 auto settings = CreateSettingsForFixture();
308 std::unique_ptr<Shell> shell = CreateShell({
309 .settings = settings,
310 .platform_view_create_callback = ShellTestPlatformViewBuilder({
311 .simulate_vsync = true,
312 }),
313 });
314
315 auto configuration = RunConfiguration::InferFromSettings(settings);
316 configuration.SetEntrypoint("onPointerDataPacketMain");
317 // Sets up native handler.
318 fml::AutoResetWaitableEvent reportLatch;
319 std::vector<int64_t> result_sequence;
320 auto nativeOnPointerDataPacket = [&reportLatch, &result_sequence](
322 Dart_Handle exception = nullptr;
323 result_sequence = tonic::DartConverter<std::vector<int64_t>>::FromArguments(
324 args, 0, exception);
325 reportLatch.Signal();
326 };
327 // Starts engine.
328 AddNativeCallback("NativeOnPointerDataPacket",
329 CREATE_NATIVE_ENTRY(nativeOnPointerDataPacket));
330 ASSERT_TRUE(configuration.IsValid());
331 RunEngine(shell.get(), std::move(configuration));
332 // Starts test.
333 auto packet = std::make_unique<PointerDataPacket>(6);
334 PointerData data;
335 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0.0, 0.0);
336 packet->SetPointerData(0, data);
337 CreateSimulatedPointerData(data, PointerData::Change::kHover, 3.0, 0.0);
338 packet->SetPointerData(1, data);
339 CreateSimulatedPointerData(data, PointerData::Change::kDown, 3.0, 0.0);
340 packet->SetPointerData(2, data);
341 CreateSimulatedPointerData(data, PointerData::Change::kMove, 3.0, 4.0);
342 packet->SetPointerData(3, data);
343 CreateSimulatedPointerData(data, PointerData::Change::kUp, 3.0, 4.0);
344 packet->SetPointerData(4, data);
345 CreateSimulatedPointerData(data, PointerData::Change::kRemove, 3.0, 4.0);
346 packet->SetPointerData(5, data);
347 ShellTest::DispatchPointerData(shell.get(), std::move(packet));
348 ShellTest::VSyncFlush(shell.get());
349
350 reportLatch.Wait();
351 size_t expect_length = 6;
352 ASSERT_EQ(result_sequence.size(), expect_length);
353 ASSERT_EQ(PointerData::Change(result_sequence[0]), PointerData::Change::kAdd);
354 ASSERT_EQ(PointerData::Change(result_sequence[1]),
355 PointerData::Change::kHover);
356 ASSERT_EQ(PointerData::Change(result_sequence[2]),
357 PointerData::Change::kDown);
358 ASSERT_EQ(PointerData::Change(result_sequence[3]),
359 PointerData::Change::kMove);
360 ASSERT_EQ(PointerData::Change(result_sequence[4]), PointerData::Change::kUp);
361 ASSERT_EQ(PointerData::Change(result_sequence[5]),
362 PointerData::Change::kRemove);
363
364 // Cleans up shell.
365 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
366 DestroyShell(std::move(shell));
367 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
368}

◆ TEST_F() [710/876]

flutter::testing::TEST_F ( ShellTest  ,
CanCorrectlySynthesizePointerPacket   
)

Definition at line 370 of file input_events_unittests.cc.

370 {
371 // Sets up shell with test fixture.
372 auto settings = CreateSettingsForFixture();
373 std::unique_ptr<Shell> shell = CreateShell({
374 .settings = settings,
375 .platform_view_create_callback = ShellTestPlatformViewBuilder({
376 .simulate_vsync = true,
377 }),
378 });
379
380 auto configuration = RunConfiguration::InferFromSettings(settings);
381 configuration.SetEntrypoint("onPointerDataPacketMain");
382 // Sets up native handler.
383 fml::AutoResetWaitableEvent reportLatch;
384 std::vector<int64_t> result_sequence;
385 auto nativeOnPointerDataPacket = [&reportLatch, &result_sequence](
387 Dart_Handle exception = nullptr;
388 result_sequence = tonic::DartConverter<std::vector<int64_t>>::FromArguments(
389 args, 0, exception);
390 reportLatch.Signal();
391 };
392 // Starts engine.
393 AddNativeCallback("NativeOnPointerDataPacket",
394 CREATE_NATIVE_ENTRY(nativeOnPointerDataPacket));
395 ASSERT_TRUE(configuration.IsValid());
396 RunEngine(shell.get(), std::move(configuration));
397 // Starts test.
398 auto packet = std::make_unique<PointerDataPacket>(4);
399 PointerData data;
400 CreateSimulatedPointerData(data, PointerData::Change::kAdd, 0.0, 0.0);
401 packet->SetPointerData(0, data);
402 CreateSimulatedPointerData(data, PointerData::Change::kDown, 3.0, 0.0);
403 packet->SetPointerData(1, data);
404 CreateSimulatedPointerData(data, PointerData::Change::kUp, 3.0, 4.0);
405 packet->SetPointerData(2, data);
406 CreateSimulatedPointerData(data, PointerData::Change::kRemove, 3.0, 4.0);
407 packet->SetPointerData(3, data);
408 ShellTest::DispatchPointerData(shell.get(), std::move(packet));
409 ShellTest::VSyncFlush(shell.get());
410
411 reportLatch.Wait();
412 size_t expect_length = 6;
413 ASSERT_EQ(result_sequence.size(), expect_length);
414 ASSERT_EQ(PointerData::Change(result_sequence[0]), PointerData::Change::kAdd);
415 // The pointer data packet converter should synthesize a hover event.
416 ASSERT_EQ(PointerData::Change(result_sequence[1]),
417 PointerData::Change::kHover);
418 ASSERT_EQ(PointerData::Change(result_sequence[2]),
419 PointerData::Change::kDown);
420 // The pointer data packet converter should synthesize a move event.
421 ASSERT_EQ(PointerData::Change(result_sequence[3]),
422 PointerData::Change::kMove);
423 ASSERT_EQ(PointerData::Change(result_sequence[4]), PointerData::Change::kUp);
424 ASSERT_EQ(PointerData::Change(result_sequence[5]),
425 PointerData::Change::kRemove);
426
427 // Cleans up shell.
428 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
429 DestroyShell(std::move(shell));
430 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
431}

◆ TEST_F() [711/876]

flutter::testing::TEST_F ( ShellTest  ,
CanCreateImagefromDecompressedBytes   
)

Definition at line 1931 of file shell_unittests.cc.

1931 {
1932 Settings settings = CreateSettingsForFixture();
1933 auto task_runner = CreateNewThread();
1934
1935 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
1936 task_runner);
1937
1938 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
1939
1940 // Create the surface needed by rasterizer
1941 PlatformViewNotifyCreated(shell.get());
1942
1943 auto configuration = RunConfiguration::InferFromSettings(settings);
1944 configuration.SetEntrypoint("canCreateImageFromDecompressedData");
1945
1947 AddNativeCallback("NotifyWidthHeight",
1948 CREATE_NATIVE_ENTRY([&latch](auto args) {
1953 ASSERT_EQ(width, 10);
1954 ASSERT_EQ(height, 10);
1955 latch.Signal();
1956 }));
1957
1958 RunEngine(shell.get(), std::move(configuration));
1959
1960 latch.Wait();
1961 DestroyShell(std::move(shell), task_runners);
1962}

◆ TEST_F() [712/876]

flutter::testing::TEST_F ( ShellTest  ,
CanCreateShellsWithGLBackend   
)

Definition at line 3728 of file shell_unittests.cc.

3728 {
3729#if !SHELL_ENABLE_GL
3730 // GL emulation does not exist on Fuchsia.
3731 GTEST_SKIP();
3732#else
3733 auto settings = CreateSettingsForFixture();
3734 std::unique_ptr<Shell> shell = CreateShell({
3735 .settings = settings,
3736 .platform_view_create_callback = ShellTestPlatformViewBuilder({
3737 .rendering_backend = ShellTestPlatformView::BackendType::kGLBackend,
3738 }),
3739 });
3740 ASSERT_NE(shell, nullptr);
3741 ASSERT_TRUE(shell->IsSetup());
3742 auto configuration = RunConfiguration::InferFromSettings(settings);
3743 PlatformViewNotifyCreated(shell.get());
3744 configuration.SetEntrypoint("emptyMain");
3745 RunEngine(shell.get(), std::move(configuration));
3746 PumpOneFrame(shell.get());
3747 PlatformViewNotifyDestroyed(shell.get());
3748 DestroyShell(std::move(shell));
3749#endif // !SHELL_ENABLE_GL
3750}

◆ TEST_F() [713/876]

flutter::testing::TEST_F ( ShellTest  ,
CanCreateShellsWithMetalBackend   
)

Definition at line 3776 of file shell_unittests.cc.

3776 {
3777#if !SHELL_ENABLE_METAL
3778 GTEST_SKIP();
3779#else
3780 auto settings = CreateSettingsForFixture();
3781 std::unique_ptr<Shell> shell = CreateShell({
3782 .settings = settings,
3783 .platform_view_create_callback = ShellTestPlatformViewBuilder({
3784 .rendering_backend =
3785 ShellTestPlatformView::BackendType::kMetalBackend,
3786 }),
3787 });
3788 ASSERT_NE(shell, nullptr);
3789 ASSERT_TRUE(shell->IsSetup());
3790 auto configuration = RunConfiguration::InferFromSettings(settings);
3791 PlatformViewNotifyCreated(shell.get());
3792 configuration.SetEntrypoint("emptyMain");
3793 RunEngine(shell.get(), std::move(configuration));
3794 PumpOneFrame(shell.get());
3795 PlatformViewNotifyDestroyed(shell.get());
3796 DestroyShell(std::move(shell));
3797#endif // !SHELL_ENABLE_METAL
3798}

◆ TEST_F() [714/876]

flutter::testing::TEST_F ( ShellTest  ,
CanCreateShellsWithVulkanBackend   
)

Definition at line 3752 of file shell_unittests.cc.

3752 {
3753#if !SHELL_ENABLE_VULKAN
3754 GTEST_SKIP();
3755#else
3756 auto settings = CreateSettingsForFixture();
3757 std::unique_ptr<Shell> shell = CreateShell({
3758 .settings = settings,
3759 .platform_view_create_callback = ShellTestPlatformViewBuilder({
3760 .rendering_backend =
3761 ShellTestPlatformView::BackendType::kVulkanBackend,
3762 }),
3763 });
3764 ASSERT_NE(shell, nullptr);
3765 ASSERT_TRUE(shell->IsSetup());
3766 auto configuration = RunConfiguration::InferFromSettings(settings);
3767 PlatformViewNotifyCreated(shell.get());
3768 configuration.SetEntrypoint("emptyMain");
3769 RunEngine(shell.get(), std::move(configuration));
3770 PumpOneFrame(shell.get());
3771 PlatformViewNotifyDestroyed(shell.get());
3772 DestroyShell(std::move(shell));
3773#endif // !SHELL_ENABLE_VULKAN
3774}

◆ TEST_F() [715/876]

flutter::testing::TEST_F ( ShellTest  ,
CanRegisterImageDecoders   
)

Definition at line 2316 of file shell_unittests.cc.

2316 {
2318 AddNativeCallback("NotifyWidthHeight", CREATE_NATIVE_ENTRY([&](auto args) {
2323 ASSERT_EQ(width, 1);
2324 ASSERT_EQ(height, 1);
2325 latch.Signal();
2326 }));
2327
2328 auto settings = CreateSettingsForFixture();
2329 auto configuration = RunConfiguration::InferFromSettings(settings);
2330 configuration.SetEntrypoint("canRegisterImageDecoders");
2331 std::unique_ptr<Shell> shell = CreateShell(settings);
2332 ASSERT_NE(shell.get(), nullptr);
2333
2335 shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() {
2336 shell->RegisterImageDecoder(
2337 [](const sk_sp<SkData>& buffer) {
2338 return std::make_unique<SinglePixelImageGenerator>();
2339 },
2340 100);
2341 });
2342
2343 RunEngine(shell.get(), std::move(configuration));
2344 latch.Wait();
2345 DestroyShell(std::move(shell));
2346}

◆ TEST_F() [716/876]

flutter::testing::TEST_F ( ShellTest  ,
CanRemoveViewBeforeLaunchingIsolate   
)

Definition at line 4739 of file shell_unittests.cc.

4739 {
4740 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4741 Settings settings = CreateSettingsForFixture();
4743 "io.flutter.test." + GetCurrentTestName() + ".",
4744 ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
4745 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
4746 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4747 thread_host.raster_thread->GetTaskRunner(),
4748 thread_host.ui_thread->GetTaskRunner(),
4749 thread_host.io_thread->GetTaskRunner());
4750 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4751 ASSERT_TRUE(shell);
4752
4753 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell] {
4754 auto platform_view = shell->GetPlatformView();
4755
4756 // A view can be added and removed all before the isolate launches.
4757 // The pending add view operation is cancelled, the view is never
4758 // added to the Dart isolate.
4759 shell->GetPlatformView()->AddView(123, ViewportMetrics{1, 30, 1, 0, 0},
4760 [](bool added) { ASSERT_FALSE(added); });
4761 shell->GetPlatformView()->RemoveView(
4762 123, [](bool removed) { ASSERT_FALSE(removed); });
4763 });
4764
4765 bool first_report = true;
4766 std::map<int64_t, int64_t> view_widths;
4767 fml::AutoResetWaitableEvent report_latch;
4768 AddNativeCallback("NativeReportViewWidthsCallback",
4770 EXPECT_TRUE(first_report);
4771 first_report = false;
4772 ParseViewWidthsCallback(args, &view_widths);
4773 report_latch.Signal();
4774 }));
4775
4776 PlatformViewNotifyCreated(shell.get());
4777 auto configuration = RunConfiguration::InferFromSettings(settings);
4778 configuration.SetEntrypoint("testReportViewWidths");
4779 RunEngine(shell.get(), std::move(configuration));
4780
4781 report_latch.Wait();
4782 EXPECT_EQ(view_widths.size(), 1u);
4783
4784 PlatformViewNotifyDestroyed(shell.get());
4785 DestroyShell(std::move(shell), task_runners);
4786}
static void PostSync(const fml::RefPtr< fml::TaskRunner > &task_runner, const fml::closure &task)

◆ TEST_F() [717/876]

flutter::testing::TEST_F ( ShellTest  ,
CanScheduleFrameFromPlatform   
)

Definition at line 2076 of file shell_unittests.cc.

2076 {
2077 Settings settings = CreateSettingsForFixture();
2078 TaskRunners task_runners = GetTaskRunnersForFixture();
2080 AddNativeCallback(
2081 "NotifyNative",
2083 fml::AutoResetWaitableEvent check_latch;
2084 AddNativeCallback("NativeOnBeginFrame",
2086 check_latch.Signal();
2087 }));
2088 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
2089 ASSERT_TRUE(shell->IsSetup());
2090
2091 auto configuration = RunConfiguration::InferFromSettings(settings);
2092 configuration.SetEntrypoint("onBeginFrameWithNotifyNativeMain");
2093 RunEngine(shell.get(), std::move(configuration));
2094
2095 // Wait for the application to attach the listener.
2096 latch.Wait();
2097
2099 shell->GetTaskRunners().GetPlatformTaskRunner(),
2100 [&shell]() { shell->GetPlatformView()->ScheduleFrame(); });
2101 check_latch.Wait();
2102 DestroyShell(std::move(shell), task_runners);
2103}

◆ TEST_F() [718/876]

flutter::testing::TEST_F ( ShellTest  ,
ConvertPaintToDlPaint   
)

Definition at line 14 of file paint_unittests.cc.

14 {
15 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
16 DlPaint dl_paint;
17
18 auto nativeToDlPaint = [message_latch, &dl_paint](Dart_NativeArguments args) {
20 Dart_Handle paint_objects =
21 Dart_GetField(dart_paint, tonic::ToDart("_objects"));
22 Dart_Handle paint_data = Dart_GetField(dart_paint, tonic::ToDart("_data"));
23 Paint ui_paint(paint_objects, paint_data);
24 ui_paint.toDlPaint(dl_paint);
25 message_latch->Signal();
26 };
27
28 Settings settings = CreateSettingsForFixture();
29 TaskRunners task_runners("test", // label
30 GetCurrentTaskRunner(), // platform
31 CreateNewThread(), // raster
32 CreateNewThread(), // ui
33 CreateNewThread() // io
34 );
35
36 AddNativeCallback("ConvertPaintToDlPaint",
37 CREATE_NATIVE_ENTRY(nativeToDlPaint));
38
39 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
40
41 ASSERT_TRUE(shell->IsSetup());
42 auto configuration = RunConfiguration::InferFromSettings(settings);
43 configuration.SetEntrypoint("convertPaintToDlPaint");
44
45 shell->RunEngine(std::move(configuration), [](auto result) {
46 ASSERT_EQ(result, Engine::RunStatus::Success);
47 });
48
49 message_latch->Wait();
50 DestroyShell(std::move(shell), task_runners);
51
52 ASSERT_EQ(dl_paint.getBlendMode(), DlBlendMode::kModulate);
53 ASSERT_EQ(static_cast<uint32_t>(dl_paint.getColor().argb()), 0x11223344u);
54 ASSERT_EQ(*dl_paint.getColorFilter(),
55 DlBlendColorFilter(DlColor(0x55667788), DlBlendMode::kXor));
56 ASSERT_EQ(*dl_paint.getMaskFilter(),
57 DlBlurMaskFilter(DlBlurStyle::kInner, 0.75));
58 ASSERT_EQ(dl_paint.getDrawStyle(), DlDrawStyle::kStroke);
59}
DlColor getColor() const
Definition dl_paint.h:70
DlBlendMode getBlendMode() const
Definition dl_paint.h:84
DlDrawStyle getDrawStyle() const
Definition dl_paint.h:92
std::shared_ptr< const DlMaskFilter > getMaskFilter() const
Definition dl_paint.h:167
std::shared_ptr< const DlColorFilter > getColorFilter() const
Definition dl_paint.h:141
constexpr uint32_t argb() const
Definition dl_color.h:78

◆ TEST_F() [719/876]

flutter::testing::TEST_F ( ShellTest  ,
CreateCompatibleReturnsBuiltinImageGeneratorForValidImage   
)

Definition at line 34 of file image_generator_registry_unittests.cc.

34 {
36
37 // Fetch the generator and query for basic info
39 auto result = registry.CreateCompatibleGenerator(data);
40 auto info = result->GetInfo();
41 ASSERT_EQ(info.width(), 3024);
42 ASSERT_EQ(info.height(), 4032);
43}
static sk_sp< SkData > LoadValidImageFixture()

◆ TEST_F() [720/876]

flutter::testing::TEST_F ( ShellTest  ,
CreateCompatibleReturnsNullptrForInvalidImage   
)

Definition at line 45 of file image_generator_registry_unittests.cc.

45 {
48 ASSERT_EQ(result, nullptr);
49}
static sk_sp< SkData > MakeEmpty()
Definition SkData.cpp:94

◆ TEST_F() [721/876]

flutter::testing::TEST_F ( ShellTest  ,
DefaultGeneratorsTakePrecedentOverNegativePriority   
)

Definition at line 100 of file image_generator_registry_unittests.cc.

100 {
101 ImageGeneratorRegistry registry;
102
103 registry.AddFactory(
104 [](const sk_sp<SkData>& buffer) {
105 return std::make_unique<FakeImageGenerator>(1337);
106 },
107 -1);
108
109 // Fetch the generator and query for basic info.
110 auto result = registry.CreateCompatibleGenerator(LoadValidImageFixture());
111 // If the real width of the image pops out, then the default generator was
112 // returned rather than the fake one.
113 ASSERT_EQ(result->GetInfo().width(), 3024);
114}
void AddFactory(ImageGeneratorFactory factory, int32_t priority)
Install a new factory for image generators.

◆ TEST_F() [722/876]

flutter::testing::TEST_F ( ShellTest  ,
DefaultGeneratorsTakePrecedentOverZeroPriority   
)

Definition at line 116 of file image_generator_registry_unittests.cc.

116 {
117 ImageGeneratorRegistry registry;
118
119 registry.AddFactory(
120 [](const sk_sp<SkData>& buffer) {
121 return std::make_unique<FakeImageGenerator>(1337);
122 },
123 0);
124
125 // Fetch the generator and query for basic info.
126 auto result = registry.CreateCompatibleGenerator(LoadValidImageFixture());
127 // If the real width of the image pops out, then the default generator was
128 // returned rather than the fake one.
129 ASSERT_EQ(result->GetInfo().width(), 3024);
130}

◆ TEST_F() [723/876]

flutter::testing::TEST_F ( ShellTest  ,
DelayAtMostOneEventForFasterThanVSyncInputEvents   
)

Definition at line 210 of file input_events_unittests.cc.

210 {
211 // We don't use `constexpr int frame_time` here because MSVC doesn't handle
212 // it well with lambda capture.
213 UnitlessTime frame_time = 10;
214 UnitlessTime base_latency = 0.2 * frame_time;
215 Generator double_sampling = [frame_time, base_latency](int i) {
216 return static_cast<UnitlessTime>(i * 0.5 * frame_time + base_latency);
217 };
218 constexpr int n = 40;
219 std::vector<int> events_consumed_at_frame;
220 TestSimulatedInputEvents(this, n, base_latency, double_sampling, frame_time,
221 events_consumed_at_frame);
222
223 // Draw one extra frame due to delaying a pending packet for the next frame.
224 int frame_drawn = events_consumed_at_frame.size();
225 ASSERT_EQ(frame_drawn, n / 2 + 1);
226
227 for (int i = 0; i < n / 2; i += 1) {
228 ASSERT_GE(events_consumed_at_frame[i], 2 * i - 1);
229 }
230}
std::function< UnitlessTime(int)> Generator

◆ TEST_F() [724/876]

flutter::testing::TEST_F ( ShellTest  ,
DeterministicRenderingDisablesPathVolatility   
)

Definition at line 131 of file path_unittests.cc.

131 {
132 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
133
134 auto native_validate_path = [message_latch](Dart_NativeArguments args) {
135 auto handle = Dart_GetNativeArgument(args, 0);
136 intptr_t peer = 0;
138 handle, tonic::DartWrappable::kPeerIndex, &peer);
139 EXPECT_FALSE(Dart_IsError(result));
140 CanvasPath* path = reinterpret_cast<CanvasPath*>(peer);
141 EXPECT_TRUE(path);
142 EXPECT_FALSE(path->path().isVolatile());
143 std::shared_ptr<VolatilePathTracker> tracker =
144 UIDartState::Current()->GetVolatilePathTracker();
145 EXPECT_TRUE(tracker);
146 EXPECT_FALSE(tracker->enabled());
147
148 for (int i = 0; i < VolatilePathTracker::kFramesOfVolatility; i++) {
149 tracker->OnFrame();
150 EXPECT_FALSE(path->path().isVolatile());
151 }
152 EXPECT_FALSE(path->path().isVolatile());
153 message_latch->Signal();
154 };
155
156 Settings settings = CreateSettingsForFixture();
157 settings.skia_deterministic_rendering_on_cpu = true;
158 TaskRunners task_runners("test", // label
159 GetCurrentTaskRunner(), // platform
160 CreateNewThread(), // raster
161 CreateNewThread(), // ui
162 CreateNewThread() // io
163 );
164
165 AddNativeCallback("ValidatePath", CREATE_NATIVE_ENTRY(native_validate_path));
166
167 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
168
169 ASSERT_TRUE(shell->IsSetup());
170 auto configuration = RunConfiguration::InferFromSettings(settings);
171 configuration.SetEntrypoint("createPath");
172
173 shell->RunEngine(std::move(configuration), [](auto result) {
174 ASSERT_EQ(result, Engine::RunStatus::Success);
175 });
176
177 message_latch->Wait();
178
179 DestroyShell(std::move(shell), task_runners);
180}

◆ TEST_F() [725/876]

flutter::testing::TEST_F ( ShellTest  ,
DiesIfSoftwareRenderingAndImpellerAreEnabledDeathTest   
)

Definition at line 4415 of file shell_unittests.cc.

4415 {
4416#if defined(OS_FUCHSIA)
4417 GTEST_SKIP() << "Fuchsia";
4418#else
4419 ::testing::FLAGS_gtest_death_test_style = "threadsafe";
4420 Settings settings = CreateSettingsForFixture();
4421 settings.enable_impeller = true;
4422 settings.enable_software_rendering = true;
4423 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
4424 ThreadHost::Type::kPlatform);
4425 auto task_runner = thread_host.platform_thread->GetTaskRunner();
4426 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
4427 task_runner);
4428 EXPECT_DEATH_IF_SUPPORTED(
4429 CreateShell(settings, task_runners),
4430 "Software rendering is incompatible with Impeller.");
4431#endif // OS_FUCHSIA
4432}

◆ TEST_F() [726/876]

flutter::testing::TEST_F ( ShellTest  ,
DISABLED_DiscardLayerTreeOnResize   
)

Definition at line 2725 of file shell_unittests.cc.

2725 {
2726 auto settings = CreateSettingsForFixture();
2727
2728 SkISize wrong_size = SkISize::Make(400, 100);
2729 SkISize expected_size = SkISize::Make(400, 200);
2730
2731 fml::AutoResetWaitableEvent end_frame_latch;
2732 auto end_frame_callback =
2733 [&](bool should_merge_thread,
2734 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
2735 end_frame_latch.Signal();
2736 };
2737 auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
2738 std::move(end_frame_callback), PostPrerollResult::kSuccess, false);
2739 std::unique_ptr<Shell> shell = CreateShell({
2740 .settings = settings,
2741 .platform_view_create_callback = ShellTestPlatformViewBuilder({
2742 .shell_test_external_view_embedder = external_view_embedder,
2743 }),
2744 });
2745
2746 // Create the surface needed by rasterizer
2747 PlatformViewNotifyCreated(shell.get());
2748
2750 shell->GetTaskRunners().GetPlatformTaskRunner(),
2751 [&shell, &expected_size]() {
2752 shell->GetPlatformView()->SetViewportMetrics(
2753 kImplicitViewId,
2754 {1.0, static_cast<double>(expected_size.width()),
2755 static_cast<double>(expected_size.height()), 22, 0});
2756 });
2757
2758 auto configuration = RunConfiguration::InferFromSettings(settings);
2759 configuration.SetEntrypoint("emptyMain");
2760
2761 RunEngine(shell.get(), std::move(configuration));
2762
2763 PumpOneFrame(shell.get(), ViewContent::DummyView(
2764 static_cast<double>(wrong_size.width()),
2765 static_cast<double>(wrong_size.height())));
2766 end_frame_latch.Wait();
2767 // Wrong size, no frames are submitted.
2768 ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount());
2769
2770 PumpOneFrame(shell.get(), ViewContent::DummyView(
2771 static_cast<double>(expected_size.width()),
2772 static_cast<double>(expected_size.height())));
2773 end_frame_latch.Wait();
2774 // Expected size, 1 frame submitted.
2775 ASSERT_EQ(1, external_view_embedder->GetSubmittedFrameCount());
2776 ASSERT_EQ(expected_size, external_view_embedder->GetLastSubmittedFrameSize());
2777
2778 PlatformViewNotifyDestroyed(shell.get());
2779 DestroyShell(std::move(shell));
2780}

◆ TEST_F() [727/876]

flutter::testing::TEST_F ( ShellTest  ,
DISABLED_DiscardResubmittedLayerTreeOnResize   
)

Definition at line 2786 of file shell_unittests.cc.

2786 {
2787 auto settings = CreateSettingsForFixture();
2788
2789 SkISize origin_size = SkISize::Make(400, 100);
2790 SkISize new_size = SkISize::Make(400, 200);
2791
2792 fml::AutoResetWaitableEvent end_frame_latch;
2793
2794 fml::AutoResetWaitableEvent resize_latch;
2795
2796 std::shared_ptr<ShellTestExternalViewEmbedder> external_view_embedder;
2797 fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger_ref;
2798 auto end_frame_callback =
2799 [&](bool should_merge_thread,
2800 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
2801 if (!raster_thread_merger_ref) {
2802 raster_thread_merger_ref = raster_thread_merger;
2803 }
2804 if (should_merge_thread) {
2805 raster_thread_merger->MergeWithLease(10);
2806 external_view_embedder->UpdatePostPrerollResult(
2807 PostPrerollResult::kSuccess);
2808 }
2809 end_frame_latch.Signal();
2810
2811 if (should_merge_thread) {
2812 resize_latch.Wait();
2813 }
2814 };
2815
2816 external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
2817 std::move(end_frame_callback), PostPrerollResult::kResubmitFrame, true);
2818
2819 std::unique_ptr<Shell> shell = CreateShell({
2820 .settings = settings,
2821 .platform_view_create_callback = ShellTestPlatformViewBuilder({
2822 .shell_test_external_view_embedder = external_view_embedder,
2823 }),
2824 });
2825
2826 // Create the surface needed by rasterizer
2827 PlatformViewNotifyCreated(shell.get());
2828
2830 shell->GetTaskRunners().GetPlatformTaskRunner(),
2831 [&shell, &origin_size]() {
2832 shell->GetPlatformView()->SetViewportMetrics(
2833 kImplicitViewId,
2834 {1.0, static_cast<double>(origin_size.width()),
2835 static_cast<double>(origin_size.height()), 22, 0});
2836 });
2837
2838 auto configuration = RunConfiguration::InferFromSettings(settings);
2839 configuration.SetEntrypoint("emptyMain");
2840
2841 RunEngine(shell.get(), std::move(configuration));
2842
2843 PumpOneFrame(shell.get(), ViewContent::DummyView(
2844 static_cast<double>(origin_size.width()),
2845 static_cast<double>(origin_size.height())));
2846
2847 end_frame_latch.Wait();
2848 ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount());
2849
2851 shell->GetTaskRunners().GetPlatformTaskRunner(),
2852 [&shell, &new_size, &resize_latch]() {
2853 shell->GetPlatformView()->SetViewportMetrics(
2854 kImplicitViewId, {1.0, static_cast<double>(new_size.width()),
2855 static_cast<double>(new_size.height()), 22, 0});
2856 resize_latch.Signal();
2857 });
2858
2859 end_frame_latch.Wait();
2860
2861 // The frame resubmitted with origin size should be discarded after the
2862 // viewport metrics changed.
2863 ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount());
2864
2865 // Threads will be merged at the end of this frame.
2866 PumpOneFrame(shell.get(),
2867 ViewContent::DummyView(static_cast<double>(new_size.width()),
2868 static_cast<double>(new_size.height())));
2869
2870 end_frame_latch.Wait();
2871 ASSERT_TRUE(raster_thread_merger_ref->IsMerged());
2872 ASSERT_EQ(1, external_view_embedder->GetSubmittedFrameCount());
2873 ASSERT_EQ(new_size, external_view_embedder->GetLastSubmittedFrameSize());
2874
2875 PlatformViewNotifyDestroyed(shell.get());
2876 DestroyShell(std::move(shell));
2877}

◆ TEST_F() [728/876]

flutter::testing::TEST_F ( ShellTest  ,
DISABLED_SkipAndSubmitFrame   
)

Definition at line 1450 of file shell_unittests.cc.

1450 {
1451#if defined(OS_FUCHSIA)
1452 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
1453 "https://github.com/flutter/flutter/issues/59816 ";
1454#else
1455
1456 auto settings = CreateSettingsForFixture();
1457 fml::AutoResetWaitableEvent end_frame_latch;
1458 std::shared_ptr<ShellTestExternalViewEmbedder> external_view_embedder;
1459
1460 auto end_frame_callback =
1461 [&](bool should_resubmit_frame,
1462 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
1463 if (should_resubmit_frame && !raster_thread_merger->IsMerged()) {
1464 raster_thread_merger->MergeWithLease(10);
1465 external_view_embedder->UpdatePostPrerollResult(
1466 PostPrerollResult::kSuccess);
1467 }
1468 end_frame_latch.Signal();
1469 };
1470 external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1471 end_frame_callback, PostPrerollResult::kSkipAndRetryFrame, true);
1472
1473 auto shell = CreateShell({
1474 .settings = settings,
1475 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1476 .shell_test_external_view_embedder = external_view_embedder,
1477 }),
1478 });
1479
1480 PlatformViewNotifyCreated(shell.get());
1481
1482 auto configuration = RunConfiguration::InferFromSettings(settings);
1483 configuration.SetEntrypoint("emptyMain");
1484 RunEngine(shell.get(), std::move(configuration));
1485
1486 ASSERT_EQ(0, external_view_embedder->GetSubmittedFrameCount());
1487
1488 PumpOneFrame(shell.get());
1489
1490 // `EndFrame` changed the post preroll result to `kSuccess`.
1491 end_frame_latch.Wait();
1492
1493 // Let the resubmitted frame to run and `GetSubmittedFrameCount` should be
1494 // called.
1495 end_frame_latch.Wait();
1496 // 2 frames are submitted because `kSkipAndRetryFrame`, but only the 2nd frame
1497 // should be submitted with `external_view_embedder`, hence the below check.
1498 ASSERT_EQ(1, external_view_embedder->GetSubmittedFrameCount());
1499
1500 PlatformViewNotifyDestroyed(shell.get());
1501 DestroyShell(std::move(shell));
1502#endif // OS_FUCHSIA
1503}

◆ TEST_F() [729/876]

flutter::testing::TEST_F ( ShellTest  ,
DisallowedDartVMFlag   
)

Definition at line 642 of file shell_unittests.cc.

642 {
643#if defined(OS_FUCHSIA)
644 GTEST_SKIP() << "This test flakes on Fuchsia. https://fxbug.dev/110006 ";
645#else
646
647 // Run this test in a thread-safe manner, otherwise gtest will complain.
648 ::testing::FLAGS_gtest_death_test_style = "threadsafe";
649
650 const std::vector<fml::CommandLine::Option> options = {
651 fml::CommandLine::Option("dart-flags", "--verify_after_gc")};
652 fml::CommandLine command_line("", options, std::vector<std::string>());
653
654 // Upon encountering a disallowed Dart flag the process terminates.
655 const char* expected =
656 "Encountered disallowed Dart VM flag: --verify_after_gc";
657 ASSERT_DEATH(flutter::SettingsFromCommandLine(command_line), expected);
658#endif // OS_FUCHSIA
659}

◆ TEST_F() [730/876]

flutter::testing::TEST_F ( ShellTest  ,
EncodeImageAccessesSyncSwitch   
)

Definition at line 128 of file image_encoding_unittests.cc.

128 {
129 Settings settings = CreateSettingsForFixture();
130 TaskRunners task_runners("test", // label
131 GetCurrentTaskRunner(), // platform
132 CreateNewThread(), // raster
133 CreateNewThread(), // ui
134 CreateNewThread() // io
135 );
136
137 auto native_encode_image = [&](Dart_NativeArguments args) {
138 auto image_handle = Dart_GetNativeArgument(args, 0);
139 image_handle =
140 Dart_GetField(image_handle, Dart_NewStringFromCString("_image"));
141 ASSERT_FALSE(Dart_IsError(image_handle)) << Dart_GetError(image_handle);
142 ASSERT_FALSE(Dart_IsNull(image_handle));
143 auto format_handle = Dart_GetNativeArgument(args, 1);
144
145 intptr_t peer = 0;
147 image_handle, tonic::DartWrappable::kPeerIndex, &peer);
148 ASSERT_FALSE(Dart_IsError(result));
149 CanvasImage* canvas_image = reinterpret_cast<CanvasImage*>(peer);
150
151 int64_t format = -1;
152 result = Dart_IntegerToInt64(format_handle, &format);
153 ASSERT_FALSE(Dart_IsError(result));
154
155 auto io_manager = UIDartState::Current()->GetIOManager();
157
158 task_runners.GetIOTaskRunner()->PostTask([&]() {
159 auto is_gpu_disabled_sync_switch =
160 std::make_shared<const MockSyncSwitch>();
161 EXPECT_CALL(*is_gpu_disabled_sync_switch, Execute)
162 .WillOnce([](const MockSyncSwitch::Handlers& handlers) {
163 handlers.true_handler();
164 });
165 ConvertToRasterUsingResourceContext(canvas_image->image()->skia_image(),
166 io_manager->GetResourceContext(),
167 is_gpu_disabled_sync_switch);
168 latch.Signal();
169 });
170
171 latch.Wait();
172
173 message_latch.Signal();
174 };
175
176 AddNativeCallback("EncodeImage", CREATE_NATIVE_ENTRY(native_encode_image));
177
178 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
179
180 ASSERT_TRUE(shell->IsSetup());
181 auto configuration = RunConfiguration::InferFromSettings(settings);
182 configuration.SetEntrypoint("encodeImageProducesExternalUint8List");
183
184 shell->RunEngine(std::move(configuration), [&](auto result) {
185 ASSERT_EQ(result, Engine::RunStatus::Success);
186 });
187
188 message_latch.Wait();
189 DestroyShell(std::move(shell), task_runners);
190}
sk_sp< DlImage > image() const
Definition image.h:42
uint32_t uint32_t * format
sk_sp< SkImage > ConvertToRasterUsingResourceContext(const sk_sp< SkImage > &image, const fml::WeakPtr< GrDirectContext > &resource_context, const std::shared_ptr< const SyncSwitch > &is_gpu_disabled_sync_switch)

◆ TEST_F() [731/876]

flutter::testing::TEST_F ( ShellTest  ,
EncodeImageGivesExternalTypedData   
)

Definition at line 69 of file image_encoding_unittests.cc.

69 {
70 auto native_encode_image = [&](Dart_NativeArguments args) {
71 auto image_handle = Dart_GetNativeArgument(args, 0);
72 image_handle =
73 Dart_GetField(image_handle, Dart_NewStringFromCString("_image"));
74 ASSERT_FALSE(Dart_IsError(image_handle)) << Dart_GetError(image_handle);
75 ASSERT_FALSE(Dart_IsNull(image_handle));
76 auto format_handle = Dart_GetNativeArgument(args, 1);
77 auto callback_handle = Dart_GetNativeArgument(args, 2);
78
79 intptr_t peer = 0;
81 image_handle, tonic::DartWrappable::kPeerIndex, &peer);
82 ASSERT_FALSE(Dart_IsError(result));
83 CanvasImage* canvas_image = reinterpret_cast<CanvasImage*>(peer);
84
85 int64_t format = -1;
86 result = Dart_IntegerToInt64(format_handle, &format);
87 ASSERT_FALSE(Dart_IsError(result));
88
89 result = EncodeImage(canvas_image, format, callback_handle);
90 ASSERT_TRUE(Dart_IsNull(result));
91 };
92
93 auto nativeValidateExternal = [&](Dart_NativeArguments args) {
94 auto handle = Dart_GetNativeArgument(args, 0);
95
96 auto typed_data_type = Dart_GetTypeOfExternalTypedData(handle);
97 EXPECT_EQ(typed_data_type, Dart_TypedData_kUint8);
98
99 message_latch.Signal();
100 };
101
102 Settings settings = CreateSettingsForFixture();
103 TaskRunners task_runners("test", // label
104 GetCurrentTaskRunner(), // platform
105 CreateNewThread(), // raster
106 CreateNewThread(), // ui
107 CreateNewThread() // io
108 );
109
110 AddNativeCallback("EncodeImage", CREATE_NATIVE_ENTRY(native_encode_image));
111 AddNativeCallback("ValidateExternal",
112 CREATE_NATIVE_ENTRY(nativeValidateExternal));
113
114 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
115
116 ASSERT_TRUE(shell->IsSetup());
117 auto configuration = RunConfiguration::InferFromSettings(settings);
118 configuration.SetEntrypoint("encodeImageProducesExternalUint8List");
119
120 shell->RunEngine(std::move(configuration), [&](auto result) {
121 ASSERT_EQ(result, Engine::RunStatus::Success);
122 });
123
124 message_latch.Wait();
125 DestroyShell(std::move(shell), task_runners);
126}
DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData(Dart_Handle object)
@ Dart_TypedData_kUint8
Definition dart_api.h:2606
Dart_Handle EncodeImage(CanvasImage *canvas_image, int format, Dart_Handle callback_handle)

◆ TEST_F() [732/876]

flutter::testing::TEST_F ( ShellTest  ,
EngineLayerDisposeReleasesReference   
)

Definition at line 99 of file scene_builder_unittests.cc.

99 {
100 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
101
102 std::shared_ptr<ContainerLayer> root_layer;
103
104 auto capture_root_layer = [&root_layer](Dart_NativeArguments args) {
105 auto handle = Dart_GetNativeArgument(args, 0);
106 intptr_t peer = 0;
108 handle, tonic::DartWrappable::kPeerIndex, &peer);
109 ASSERT_FALSE(Dart_IsError(result));
110 SceneBuilder* scene_builder = reinterpret_cast<SceneBuilder*>(peer);
111 ASSERT_TRUE(scene_builder);
112 root_layer = scene_builder->layer_stack()[0];
113 ASSERT_TRUE(root_layer);
114 };
115
116 auto validate_layer_tree_counts = [&root_layer](Dart_NativeArguments args) {
117 // One for the EngineLayer, one for our pointer in the test.
118 EXPECT_EQ(root_layer->layers().front().use_count(), 2);
119 };
120
121 auto validate_engine_layer_dispose =
122 [message_latch, &root_layer](Dart_NativeArguments args) {
123 // Just one for our pointer now.
124 EXPECT_EQ(root_layer->layers().front().use_count(), 1);
125 root_layer.reset();
126 message_latch->Signal();
127 };
128
129 Settings settings = CreateSettingsForFixture();
130 TaskRunners task_runners("test", // label
131 GetCurrentTaskRunner(), // platform
132 CreateNewThread(), // raster
133 CreateNewThread(), // ui
134 CreateNewThread() // io
135 );
136
137 AddNativeCallback("CaptureRootLayer",
138 CREATE_NATIVE_ENTRY(capture_root_layer));
139 AddNativeCallback("ValidateLayerTreeCounts",
140 CREATE_NATIVE_ENTRY(validate_layer_tree_counts));
141 AddNativeCallback("ValidateEngineLayerDispose",
142 CREATE_NATIVE_ENTRY(validate_engine_layer_dispose));
143
144 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
145
146 ASSERT_TRUE(shell->IsSetup());
147 auto configuration = RunConfiguration::InferFromSettings(settings);
148 configuration.SetEntrypoint("validateEngineLayerDispose");
149
150 shell->RunEngine(std::move(configuration), [](auto result) {
151 ASSERT_EQ(result, Engine::RunStatus::Success);
152 });
153
154 message_latch->Wait();
155 DestroyShell(std::move(shell), task_runners);
156}
const std::vector< std::shared_ptr< ContainerLayer > > & layer_stack()

◆ TEST_F() [733/876]

flutter::testing::TEST_F ( ShellTest  ,
EngineRootIsolateLaunchesDontTakeVMDataSettings   
)

Definition at line 3051 of file shell_unittests.cc.

3051 {
3052 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3053 // Make sure the shell launch does not kick off the creation of the VM
3054 // instance by already creating one upfront.
3055 auto vm_settings = CreateSettingsForFixture();
3056 auto vm_ref = DartVMRef::Create(vm_settings);
3057 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3058
3059 auto settings = vm_settings;
3060 fml::AutoResetWaitableEvent isolate_create_latch;
3061 settings.root_isolate_create_callback = [&](const auto& isolate) {
3062 isolate_create_latch.Signal();
3063 };
3064 auto shell = CreateShell(settings);
3065 ASSERT_TRUE(ValidateShell(shell.get()));
3066 auto configuration = RunConfiguration::InferFromSettings(settings);
3067 ASSERT_TRUE(configuration.IsValid());
3068 RunEngine(shell.get(), std::move(configuration));
3069 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3070 DestroyShell(std::move(shell));
3071 isolate_create_latch.Wait();
3072}

◆ TEST_F() [734/876]

flutter::testing::TEST_F ( ShellTest  ,
ExternalEmbedderEndFrameIsCalledWhenPostPrerollResultIsResubmit   
)

Definition at line 994 of file shell_unittests.cc.

995 {
996#if defined(OS_FUCHSIA)
997 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
998 "https://github.com/flutter/flutter/issues/59816 ";
999#else
1000
1001 auto settings = CreateSettingsForFixture();
1002 fml::AutoResetWaitableEvent end_frame_latch;
1003 bool end_frame_called = false;
1004 auto end_frame_callback =
1005 [&](bool should_resubmit_frame,
1006 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
1007 ASSERT_TRUE(raster_thread_merger.get() != nullptr);
1008 ASSERT_TRUE(should_resubmit_frame);
1009 end_frame_called = true;
1010 end_frame_latch.Signal();
1011 };
1012 auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1013 end_frame_callback, PostPrerollResult::kResubmitFrame, true);
1014 auto shell = CreateShell({
1015 .settings = settings,
1016 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1017 .shell_test_external_view_embedder = external_view_embedder,
1018 }),
1019 });
1020
1021 // Create the surface needed by rasterizer
1022 PlatformViewNotifyCreated(shell.get());
1023
1024 auto configuration = RunConfiguration::InferFromSettings(settings);
1025 configuration.SetEntrypoint("emptyMain");
1026
1027 RunEngine(shell.get(), std::move(configuration));
1028
1029 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1030 auto display_list_layer = std::make_shared<DisplayListLayer>(
1031 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1032 root->Add(display_list_layer);
1033 };
1034
1035 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1036 end_frame_latch.Wait();
1037
1038 ASSERT_TRUE(end_frame_called);
1039
1040 DestroyShell(std::move(shell));
1041#endif // OS_FUCHSIA
1042}
static sk_sp< DisplayList > MakeSizedDisplayList(int width, int height)
std::function< void(std::shared_ptr< ContainerLayer > root)> LayerTreeBuilder
Definition shell_test.h:34

◆ TEST_F() [735/876]

flutter::testing::TEST_F ( ShellTest  ,
ExternalEmbedderNoThreadMerger   
)

Definition at line 865 of file shell_unittests.cc.

865 {
866 auto settings = CreateSettingsForFixture();
867 fml::AutoResetWaitableEvent end_frame_latch;
868 bool end_frame_called = false;
869 auto end_frame_callback =
870 [&](bool should_resubmit_frame,
871 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
872 ASSERT_TRUE(raster_thread_merger.get() == nullptr);
873 ASSERT_FALSE(should_resubmit_frame);
874 end_frame_called = true;
875 end_frame_latch.Signal();
876 };
877 auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
878 end_frame_callback, PostPrerollResult::kResubmitFrame, false);
879 auto shell = CreateShell({
880 .settings = settings,
881 .platform_view_create_callback = ShellTestPlatformViewBuilder({
882 .shell_test_external_view_embedder = external_view_embedder,
883 }),
884 });
885
886 // Create the surface needed by rasterizer
887 PlatformViewNotifyCreated(shell.get());
888
889 auto configuration = RunConfiguration::InferFromSettings(settings);
890 configuration.SetEntrypoint("emptyMain");
891
892 RunEngine(shell.get(), std::move(configuration));
893
894 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
895 auto display_list_layer = std::make_shared<DisplayListLayer>(
896 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
897 root->Add(display_list_layer);
898 };
899
900 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
901 end_frame_latch.Wait();
902 ASSERT_TRUE(end_frame_called);
903
904 DestroyShell(std::move(shell));
905}

◆ TEST_F() [736/876]

flutter::testing::TEST_F ( ShellTest  ,
FixturesAreFunctional   
)

Definition at line 536 of file shell_unittests.cc.

536 {
537 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
538 auto settings = CreateSettingsForFixture();
539 auto shell = CreateShell(settings);
540 ASSERT_TRUE(ValidateShell(shell.get()));
541
542 auto configuration = RunConfiguration::InferFromSettings(settings);
543 ASSERT_TRUE(configuration.IsValid());
544 configuration.SetEntrypoint("fixturesAreFunctionalMain");
545
547 AddNativeCallback(
548 "SayHiFromFixturesAreFunctionalMain",
549 CREATE_NATIVE_ENTRY([&main_latch](auto args) { main_latch.Signal(); }));
550
551 RunEngine(shell.get(), std::move(configuration));
552 main_latch.Wait();
553 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
554 DestroyShell(std::move(shell));
555 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
556}
static bool ValidateShell(Shell *shell)

◆ TEST_F() [737/876]

flutter::testing::TEST_F ( ShellTest  ,
FrameRasterizedCallbackIsCalled   
)

Definition at line 803 of file shell_unittests.cc.

803 {
804 auto settings = CreateSettingsForFixture();
805
806 FrameTiming timing;
807 fml::AutoResetWaitableEvent timingLatch;
808 settings.frame_rasterized_callback = [&timing,
809 &timingLatch](const FrameTiming& t) {
810 timing = t;
811 timingLatch.Signal();
812 };
813
814 std::unique_ptr<Shell> shell = CreateShell(settings);
815
816 // Wait to make |start| bigger than zero
817 using namespace std::chrono_literals;
818 std::this_thread::sleep_for(1ms);
819
820 // We MUST put |start| after |CreateShell()| because the clock source will be
821 // reset through |TimePoint::SetClockSource()| in
822 // |DartVMInitializer::Initialize()| within |CreateShell()|.
824
825 for (auto phase : FrameTiming::kPhases) {
826 timing.Set(phase, fml::TimePoint());
827 // Check that the time points are initially smaller than start, so
828 // CheckFrameTimings will fail if they're not properly set later.
829 ASSERT_TRUE(timing.Get(phase) < start);
830 }
831
832 // Create the surface needed by rasterizer
833 PlatformViewNotifyCreated(shell.get());
834
835 auto configuration = RunConfiguration::InferFromSettings(settings);
836 configuration.SetEntrypoint("onBeginFrameMain");
837
838 int64_t frame_target_time;
839 auto nativeOnBeginFrame = [&frame_target_time](Dart_NativeArguments args) {
840 Dart_Handle exception = nullptr;
841 frame_target_time =
843 };
844 AddNativeCallback("NativeOnBeginFrame",
845 CREATE_NATIVE_ENTRY(nativeOnBeginFrame));
846
847 RunEngine(shell.get(), std::move(configuration));
848 PumpOneFrame(shell.get());
849
850 // Check that timing is properly set. This implies that
851 // settings.frame_rasterized_callback is called.
852 timingLatch.Wait();
854 std::vector<FrameTiming> timings = {timing};
855 CheckFrameTimings(timings, start, finish);
856
857 // Check that onBeginFrame, which is the frame_target_time, is after
858 // FrameTiming's build start
859 int64_t build_start =
860 timing.Get(FrameTiming::kBuildStart).ToEpochDelta().ToMicroseconds();
861 ASSERT_GT(frame_target_time, build_start);
862 DestroyShell(std::move(shell));
863}
constexpr int64_t ToMicroseconds() const
Definition time_delta.h:62
TimeDelta ToEpochDelta() const
Definition time_point.h:52
static void CheckFrameTimings(const std::vector< FrameTiming > &timings, fml::TimePoint start, fml::TimePoint finish)

◆ TEST_F() [738/876]

flutter::testing::TEST_F ( ShellTest  ,
GetUsedThisFrameShouldBeSetBeforeEndFrame   
)

Definition at line 1404 of file shell_unittests.cc.

1404 {
1405 auto settings = CreateSettingsForFixture();
1406 fml::AutoResetWaitableEvent end_frame_latch;
1407 std::shared_ptr<ShellTestExternalViewEmbedder> external_view_embedder;
1408 bool used_this_frame = true;
1409 auto end_frame_callback =
1410 [&](bool should_resubmit_frame,
1411 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
1412 // We expect `used_this_frame` to be false.
1413 used_this_frame = external_view_embedder->GetUsedThisFrame();
1414 end_frame_latch.Signal();
1415 };
1416 external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1417 end_frame_callback, PostPrerollResult::kSuccess, true);
1418 auto shell = CreateShell({
1419 .settings = settings,
1420 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1421 .shell_test_external_view_embedder = external_view_embedder,
1422 }),
1423 });
1424
1425 // Create the surface needed by rasterizer
1426 PlatformViewNotifyCreated(shell.get());
1427
1428 auto configuration = RunConfiguration::InferFromSettings(settings);
1429 configuration.SetEntrypoint("emptyMain");
1430
1431 RunEngine(shell.get(), std::move(configuration));
1432
1433 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1434 auto display_list_layer = std::make_shared<DisplayListLayer>(
1435 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1436 root->Add(display_list_layer);
1437 };
1438 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1439 end_frame_latch.Wait();
1440 ASSERT_FALSE(used_this_frame);
1441
1442 // Validate the platform view can be recreated and destroyed again
1443 ValidateShell(shell.get());
1444
1445 DestroyShell(std::move(shell));
1446}

◆ TEST_F() [739/876]

flutter::testing::TEST_F ( ShellTest  ,
HandlesActualIphoneXsInputEvents   
)

Definition at line 232 of file input_events_unittests.cc.

232 {
233 // Actual delivery times measured on iPhone Xs, in the unit of frame_time
234 // (16.67ms for 60Hz).
235 static constexpr double iphone_xs_times[] = {0.15,
236 1.0773046874999999,
237 2.1738720703124996,
238 3.0579052734374996,
239 4.0890087890624995,
240 5.0952685546875,
241 6.1251708984375,
242 7.1253076171875,
243 8.125927734374999,
244 9.37248046875,
245 10.133950195312499,
246 11.161201171875,
247 12.226992187499999,
248 13.1443798828125,
249 14.440327148437499,
250 15.091684570312498,
251 16.138681640625,
252 17.126469726562497,
253 18.1592431640625,
254 19.371372070312496,
255 20.033774414062496,
256 21.021782226562497,
257 22.070053710937497,
258 23.325541992187496,
259 24.119648437499997,
260 25.084262695312496,
261 26.077866210937497,
262 27.036547851562496,
263 28.035073242187497,
264 29.081411132812498,
265 30.066064453124998,
266 31.089360351562497,
267 32.086142578125,
268 33.4618798828125,
269 34.14697265624999,
270 35.0513525390625,
271 36.136025390624994,
272 37.1618408203125,
273 38.144472656249995,
274 39.201123046875,
275 40.4339501953125,
276 41.1552099609375,
277 42.102128906249995,
278 43.0426318359375,
279 44.070131835937495,
280 45.08862304687499,
281 46.091469726562494};
282 constexpr int n = sizeof(iphone_xs_times) / sizeof(iphone_xs_times[0]);
283 // We don't use `constexpr int frame_time` here because MSVC doesn't handle
284 // it well with lambda capture.
285 UnitlessTime frame_time = 10000;
286 double base_latency_f = 0.0;
287 for (int i = 0; i < 10; i++) {
288 base_latency_f += 0.1;
289 // Everything is converted to int to avoid floating point error in
290 // TestSimulatedInputEvents.
291 UnitlessTime base_latency =
292 static_cast<UnitlessTime>(base_latency_f * frame_time);
293 Generator iphone_xs_generator = [frame_time, base_latency](int i) {
294 return base_latency +
295 static_cast<UnitlessTime>(iphone_xs_times[i] * frame_time);
296 };
297 std::vector<int> events_consumed_at_frame;
298 TestSimulatedInputEvents(this, n, base_latency, iphone_xs_generator,
299 frame_time, events_consumed_at_frame);
300 int frame_drawn = events_consumed_at_frame.size();
301 ASSERT_GE(frame_drawn, n - 1);
302 }
303}

◆ TEST_F() [740/876]

flutter::testing::TEST_F ( ShellTest  ,
IgnoresBadAddViewsBeforeLaunchingIsolate   
)

Definition at line 4790 of file shell_unittests.cc.

4790 {
4791 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4792 Settings settings = CreateSettingsForFixture();
4794 "io.flutter.test." + GetCurrentTestName() + ".",
4795 ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
4796 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
4797 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4798 thread_host.raster_thread->GetTaskRunner(),
4799 thread_host.ui_thread->GetTaskRunner(),
4800 thread_host.io_thread->GetTaskRunner());
4801 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4802 ASSERT_TRUE(shell);
4803
4804 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell] {
4805 auto platform_view = shell->GetPlatformView();
4806
4807 // Add the same view twice. The second time should fail.
4808 shell->GetPlatformView()->AddView(123, ViewportMetrics{1, 100, 1, 0, 0},
4809 [](bool added) { ASSERT_TRUE(added); });
4810
4811 shell->GetPlatformView()->AddView(123, ViewportMetrics{1, 200, 1, 0, 0},
4812 [](bool added) { ASSERT_FALSE(added); });
4813
4814 // Add another view. Previous failures should not affect this.
4815 shell->GetPlatformView()->AddView(456, ViewportMetrics{1, 300, 1, 0, 0},
4816 [](bool added) { ASSERT_TRUE(added); });
4817 });
4818
4819 bool first_report = true;
4820 std::map<int64_t, int64_t> view_widths;
4821 fml::AutoResetWaitableEvent report_latch;
4822 AddNativeCallback("NativeReportViewWidthsCallback",
4824 EXPECT_TRUE(first_report);
4825 first_report = false;
4826 ParseViewWidthsCallback(args, &view_widths);
4827 report_latch.Signal();
4828 }));
4829
4830 PlatformViewNotifyCreated(shell.get());
4831 auto configuration = RunConfiguration::InferFromSettings(settings);
4832 configuration.SetEntrypoint("testReportViewWidths");
4833 RunEngine(shell.get(), std::move(configuration));
4834
4835 report_latch.Wait();
4836 EXPECT_EQ(view_widths.size(), 3u);
4837 EXPECT_EQ(view_widths[0], 0);
4838 EXPECT_EQ(view_widths[123], 100);
4839 EXPECT_EQ(view_widths[456], 300);
4840
4841 PlatformViewNotifyDestroyed(shell.get());
4842 DestroyShell(std::move(shell), task_runners);
4843}
static void ParseViewWidthsCallback(const Dart_NativeArguments &args, std::map< int64_t, int64_t > *viewWidths)

◆ TEST_F() [741/876]

flutter::testing::TEST_F ( ShellTest  ,
IgnoresInvalidMetrics   
)

Definition at line 2879 of file shell_unittests.cc.

2879 {
2881 double last_device_pixel_ratio;
2882 double last_width;
2883 double last_height;
2884 auto native_report_device_pixel_ratio = [&](Dart_NativeArguments args) {
2885 auto dpr_handle = Dart_GetNativeArgument(args, 0);
2886 ASSERT_TRUE(Dart_IsDouble(dpr_handle));
2887 Dart_DoubleValue(dpr_handle, &last_device_pixel_ratio);
2888 ASSERT_FALSE(last_device_pixel_ratio == 0.0);
2889
2890 auto width_handle = Dart_GetNativeArgument(args, 1);
2891 ASSERT_TRUE(Dart_IsDouble(width_handle));
2892 Dart_DoubleValue(width_handle, &last_width);
2893 ASSERT_FALSE(last_width == 0.0);
2894
2895 auto height_handle = Dart_GetNativeArgument(args, 2);
2896 ASSERT_TRUE(Dart_IsDouble(height_handle));
2897 Dart_DoubleValue(height_handle, &last_height);
2898 ASSERT_FALSE(last_height == 0.0);
2899
2900 latch.Signal();
2901 };
2902
2903 Settings settings = CreateSettingsForFixture();
2904 auto task_runner = CreateNewThread();
2905 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
2906 task_runner);
2907
2908 AddNativeCallback("ReportMetrics",
2909 CREATE_NATIVE_ENTRY(native_report_device_pixel_ratio));
2910
2911 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
2912
2913 auto configuration = RunConfiguration::InferFromSettings(settings);
2914 configuration.SetEntrypoint("reportMetrics");
2915
2916 RunEngine(shell.get(), std::move(configuration));
2917
2918 task_runner->PostTask([&]() {
2919 // This one is invalid for having 0 pixel ratio.
2920 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
2921 {0.0, 400, 200, 22, 0});
2922 task_runner->PostTask([&]() {
2923 // This one is invalid for having 0 width.
2924 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
2925 {0.8, 0.0, 200, 22, 0});
2926 task_runner->PostTask([&]() {
2927 // This one is invalid for having 0 height.
2928 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
2929 {0.8, 400, 0.0, 22, 0});
2930 task_runner->PostTask([&]() {
2931 // This one makes it through.
2932 shell->GetPlatformView()->SetViewportMetrics(
2933 kImplicitViewId, {0.8, 400, 200.0, 22, 0});
2934 });
2935 });
2936 });
2937 });
2938 latch.Wait();
2939 ASSERT_EQ(last_device_pixel_ratio, 0.8);
2940 ASSERT_EQ(last_width, 400.0);
2941 ASSERT_EQ(last_height, 200.0);
2942 latch.Reset();
2943
2944 task_runner->PostTask([&]() {
2945 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
2946 {1.2, 600, 300, 22, 0});
2947 });
2948 latch.Wait();
2949 ASSERT_EQ(last_device_pixel_ratio, 1.2);
2950 ASSERT_EQ(last_width, 600.0);
2951 ASSERT_EQ(last_height, 300.0);
2952
2953 DestroyShell(std::move(shell), task_runners);
2954}
DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj, double *value)
DART_EXPORT bool Dart_IsDouble(Dart_Handle object)

◆ TEST_F() [742/876]

flutter::testing::TEST_F ( ShellTest  ,
IgnoresMetricsUpdateToInvalidView   
)

Definition at line 2956 of file shell_unittests.cc.

2956 {
2958 double last_device_pixel_ratio;
2959 // This callback will be called whenever any view's metrics change.
2960 auto native_report_device_pixel_ratio = [&](Dart_NativeArguments args) {
2961 // The correct call will have a DPR of 3.
2962 auto dpr_handle = Dart_GetNativeArgument(args, 0);
2963 ASSERT_TRUE(Dart_IsDouble(dpr_handle));
2964 Dart_DoubleValue(dpr_handle, &last_device_pixel_ratio);
2965 ASSERT_TRUE(last_device_pixel_ratio > 2.5);
2966
2967 latch.Signal();
2968 };
2969
2970 Settings settings = CreateSettingsForFixture();
2971 auto task_runner = CreateNewThread();
2972 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
2973 task_runner);
2974
2975 AddNativeCallback("ReportMetrics",
2976 CREATE_NATIVE_ENTRY(native_report_device_pixel_ratio));
2977
2978 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
2979
2980 auto configuration = RunConfiguration::InferFromSettings(settings);
2981 configuration.SetEntrypoint("reportMetrics");
2982
2983 RunEngine(shell.get(), std::move(configuration));
2984
2985 task_runner->PostTask([&]() {
2986 // This one is invalid for having an nonexistent view ID.
2987 // Also, it has a DPR of 2.0 for detection.
2988 shell->GetPlatformView()->SetViewportMetrics(2, {2.0, 400, 200, 22, 0});
2989 task_runner->PostTask([&]() {
2990 // This one is valid with DPR 3.0.
2991 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
2992 {3.0, 400, 200, 22, 0});
2993 });
2994 });
2995 latch.Wait();
2996 ASSERT_EQ(last_device_pixel_ratio, 3.0);
2997 latch.Reset();
2998
2999 DestroyShell(std::move(shell), task_runners);
3000}

◆ TEST_F() [743/876]

flutter::testing::TEST_F ( ShellTest  ,
ImageGeneratorRegistryNotNullAfterParentShellDestroyed   
)

Definition at line 3510 of file shell_unittests.cc.

3510 {
3511 auto settings = CreateSettingsForFixture();
3512 auto shell = CreateShell(settings);
3513 ASSERT_TRUE(ValidateShell(shell.get()));
3514
3515 std::unique_ptr<Shell> spawn;
3516
3517 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell, &settings,
3518 &spawn] {
3519 auto second_configuration = RunConfiguration::InferFromSettings(settings);
3520 ASSERT_TRUE(second_configuration.IsValid());
3521 second_configuration.SetEntrypoint("emptyMain");
3522 const std::string initial_route("/foo");
3523 MockPlatformViewDelegate platform_view_delegate;
3524 auto child = shell->Spawn(
3525 std::move(second_configuration), initial_route,
3526 [&platform_view_delegate](Shell& shell) {
3527 auto result = std::make_unique<MockPlatformView>(
3528 platform_view_delegate, shell.GetTaskRunners());
3529 ON_CALL(*result, CreateRenderingSurface())
3530 .WillByDefault(::testing::Invoke(
3531 [] { return std::make_unique<MockSurface>(); }));
3532 return result;
3533 },
3534 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
3535 spawn = std::move(child);
3536 });
3537
3538 PostSync(spawn->GetTaskRunners().GetUITaskRunner(), [&spawn] {
3539 std::shared_ptr<const DartIsolate> isolate =
3540 spawn->GetEngine()->GetRuntimeController()->GetRootIsolate().lock();
3541 ASSERT_TRUE(isolate);
3542 ASSERT_TRUE(isolate->GetImageGeneratorRegistry());
3543 });
3544
3545 // Destroy the parent shell.
3546 DestroyShell(std::move(shell));
3547
3548 PostSync(spawn->GetTaskRunners().GetUITaskRunner(), [&spawn] {
3549 std::shared_ptr<const DartIsolate> isolate =
3550 spawn->GetEngine()->GetRuntimeController()->GetRootIsolate().lock();
3551 ASSERT_TRUE(isolate);
3552 ASSERT_TRUE(isolate->GetImageGeneratorRegistry());
3553 });
3554 // Destroy the child shell.
3555 DestroyShell(std::move(spawn));
3556}

◆ TEST_F() [744/876]

flutter::testing::TEST_F ( ShellTest  ,
ImageGeneratorsWithSamePriorityCascadeChronologically   
)

Definition at line 132 of file image_generator_registry_unittests.cc.

132 {
133 ImageGeneratorRegistry registry;
134
135 // Add 2 factories with the same high priority.
136 registry.AddFactory(
137 [](const sk_sp<SkData>& buffer) {
138 return std::make_unique<FakeImageGenerator>(1337);
139 },
140 5);
141 registry.AddFactory(
142 [](const sk_sp<SkData>& buffer) {
143 return std::make_unique<FakeImageGenerator>(7777);
144 },
145 5);
146
147 // Feed empty data so that Skia's image generators will reject it, but ours
148 // won't.
150 ASSERT_EQ(result->GetInfo().width(), 1337);
151}

◆ TEST_F() [745/876]

flutter::testing::TEST_F ( ShellTest  ,
ImmutableBufferLoadsAssetOnBackgroundThread   
)

Definition at line 4043 of file shell_unittests.cc.

4043 {
4044 Settings settings = CreateSettingsForFixture();
4045 auto task_runner = CreateNewThread();
4046 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
4047 task_runner);
4048 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4049
4050 fml::CountDownLatch latch(1);
4051 AddNativeCallback("NotifyNative",
4052 CREATE_NATIVE_ENTRY([&](auto args) { latch.CountDown(); }));
4053
4054 // Create the surface needed by rasterizer
4055 PlatformViewNotifyCreated(shell.get());
4056
4057 auto configuration = RunConfiguration::InferFromSettings(settings);
4058 configuration.SetEntrypoint("testThatAssetLoadingHappensOnWorkerThread");
4059 auto asset_manager = configuration.GetAssetManager();
4060 auto test_resolver = std::make_unique<ThreadCheckingAssetResolver>(
4061 shell->GetDartVM()->GetConcurrentMessageLoop());
4062 auto leaked_resolver = test_resolver.get();
4063 asset_manager->PushBack(std::move(test_resolver));
4064
4065 RunEngine(shell.get(), std::move(configuration));
4066 PumpOneFrame(shell.get());
4067
4068 latch.Wait();
4069
4070 EXPECT_EQ(leaked_resolver->mapping_requests[0], "DoesNotExist");
4071
4072 PlatformViewNotifyDestroyed(shell.get());
4073 DestroyShell(std::move(shell), task_runners);
4074}

◆ TEST_F() [746/876]

flutter::testing::TEST_F ( ShellTest  ,
InitializeWithDifferentThreads   
)

Definition at line 407 of file shell_unittests.cc.

407 {
408 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
409 Settings settings = CreateSettingsForFixture();
410 std::string name_prefix = "io.flutter.test." + GetCurrentTestName() + ".";
412 name_prefix, ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
413 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
414 ASSERT_EQ(thread_host.name_prefix, name_prefix);
415
416 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
417 thread_host.raster_thread->GetTaskRunner(),
418 thread_host.ui_thread->GetTaskRunner(),
419 thread_host.io_thread->GetTaskRunner());
420 auto shell = CreateShell(settings, task_runners);
421 ASSERT_TRUE(ValidateShell(shell.get()));
422 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
423 DestroyShell(std::move(shell), task_runners);
424 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
425}

◆ TEST_F() [747/876]

flutter::testing::TEST_F ( ShellTest  ,
InitializeWithDisabledGpu   
)

Definition at line 491 of file shell_unittests.cc.

491 {
492 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
493 Settings settings = CreateSettingsForFixture();
494 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
495 ThreadHost::Type::kPlatform);
496 auto task_runner = thread_host.platform_thread->GetTaskRunner();
497 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
498 task_runner);
499 auto shell = CreateShell({
500 .settings = settings,
501 .task_runners = task_runners,
502 .is_gpu_disabled = true,
503 });
504 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
505 ASSERT_TRUE(ValidateShell(shell.get()));
506
507 bool is_disabled = false;
508 shell->GetIsGpuDisabledSyncSwitch()->Execute(
509 fml::SyncSwitch::Handlers().SetIfTrue([&] { is_disabled = true; }));
510 ASSERT_TRUE(is_disabled);
511
512 DestroyShell(std::move(shell), task_runners);
513 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
514}
Represents the 2 code paths available when calling |SyncSwitchExecute|.
Definition sync_switch.h:35

◆ TEST_F() [748/876]

flutter::testing::TEST_F ( ShellTest  ,
InitializeWithGPUAndPlatformThreadsTheSame   
)

Definition at line 516 of file shell_unittests.cc.

516 {
517 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
518 Settings settings = CreateSettingsForFixture();
519 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
520 ThreadHost::Type::kPlatform | ThreadHost::Type::kIo |
521 ThreadHost::Type::kUi);
522 TaskRunners task_runners(
523 "test",
524 thread_host.platform_thread->GetTaskRunner(), // platform
525 thread_host.platform_thread->GetTaskRunner(), // raster
526 thread_host.ui_thread->GetTaskRunner(), // ui
527 thread_host.io_thread->GetTaskRunner() // io
528 );
529 auto shell = CreateShell(settings, task_runners);
530 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
531 ASSERT_TRUE(ValidateShell(shell.get()));
532 DestroyShell(std::move(shell), task_runners);
533 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
534}

◆ TEST_F() [749/876]

flutter::testing::TEST_F ( ShellTest  ,
InitializeWithInvalidThreads   
)

Definition at line 398 of file shell_unittests.cc.

398 {
399 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
400 Settings settings = CreateSettingsForFixture();
401 TaskRunners task_runners("test", nullptr, nullptr, nullptr, nullptr);
402 auto shell = CreateShell(settings, task_runners);
403 ASSERT_FALSE(shell);
404 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
405}

◆ TEST_F() [750/876]

flutter::testing::TEST_F ( ShellTest  ,
InitializeWithMultipleThreadButCallingThreadAsPlatformThread   
)

Definition at line 456 of file shell_unittests.cc.

457 {
458 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
459 Settings settings = CreateSettingsForFixture();
460 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
461 ThreadHost::Type::kRaster | ThreadHost::Type::kIo |
462 ThreadHost::Type::kUi);
464 TaskRunners task_runners("test",
465 fml::MessageLoop::GetCurrent().GetTaskRunner(),
466 thread_host.raster_thread->GetTaskRunner(),
467 thread_host.ui_thread->GetTaskRunner(),
468 thread_host.io_thread->GetTaskRunner());
469 auto shell = Shell::Create(
470 flutter::PlatformData(), task_runners, settings,
471 [](Shell& shell) {
472 // This is unused in the platform view as we are not using the simulated
473 // vsync mechanism. We should have better DI in the tests.
474 const auto vsync_clock = std::make_shared<ShellTestVsyncClock>();
475 return ShellTestPlatformView::Create(
476 shell, shell.GetTaskRunners(), vsync_clock,
477 [task_runners = shell.GetTaskRunners()]() {
478 return static_cast<std::unique_ptr<VsyncWaiter>>(
479 std::make_unique<VsyncWaiterFallback>(task_runners));
480 },
481 ShellTestPlatformView::BackendType::kDefaultBackend, nullptr,
482 shell.GetIsGpuDisabledSyncSwitch());
483 },
484 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
485 ASSERT_TRUE(ValidateShell(shell.get()));
486 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
487 DestroyShell(std::move(shell), task_runners);
488 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
489}

◆ TEST_F() [751/876]

flutter::testing::TEST_F ( ShellTest  ,
InitializeWithSingleThread   
)

Definition at line 427 of file shell_unittests.cc.

427 {
428 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
429 Settings settings = CreateSettingsForFixture();
430 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
431 ThreadHost::Type::kPlatform);
432 auto task_runner = thread_host.platform_thread->GetTaskRunner();
433 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
434 task_runner);
435 auto shell = CreateShell(settings, task_runners);
436 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
437 ASSERT_TRUE(ValidateShell(shell.get()));
438 DestroyShell(std::move(shell), task_runners);
439 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
440}

◆ TEST_F() [752/876]

flutter::testing::TEST_F ( ShellTest  ,
InitializeWithSingleThreadWhichIsTheCallingThread   
)

Definition at line 442 of file shell_unittests.cc.

442 {
443 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
444 Settings settings = CreateSettingsForFixture();
446 auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
447 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
448 task_runner);
449 auto shell = CreateShell(settings, task_runners);
450 ASSERT_TRUE(ValidateShell(shell.get()));
451 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
452 DestroyShell(std::move(shell), task_runners);
453 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
454}

◆ TEST_F() [753/876]

flutter::testing::TEST_F ( ShellTest  ,
IOManagerInSpawnedShellIsNotNullAfterParentShellDestroyed   
)

Definition at line 3447 of file shell_unittests.cc.

3447 {
3448 auto settings = CreateSettingsForFixture();
3449 auto shell = CreateShell(settings);
3450 ASSERT_TRUE(ValidateShell(shell.get()));
3451
3452 PostSync(shell->GetTaskRunners().GetUITaskRunner(), [&shell] {
3453 // We must get engine on UI thread.
3454 auto runtime_controller = shell->GetEngine()->GetRuntimeController();
3455 PostSync(shell->GetTaskRunners().GetIOTaskRunner(),
3456 [&shell, &runtime_controller] {
3457 // We must get io_manager on IO thread.
3458 auto io_manager = runtime_controller->GetIOManager();
3459 // Check io_manager existence.
3460 ASSERT_NE(io_manager.get(), nullptr);
3461 ASSERT_NE(io_manager->GetSkiaUnrefQueue().get(), nullptr);
3462 // Get io_manager directly from shell and check its existence.
3463 ASSERT_NE(shell->GetIOManager().get(), nullptr);
3464 });
3465 });
3466
3467 std::unique_ptr<Shell> spawn;
3468
3469 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell, &settings,
3470 &spawn] {
3471 auto second_configuration = RunConfiguration::InferFromSettings(settings);
3472 ASSERT_TRUE(second_configuration.IsValid());
3473 second_configuration.SetEntrypoint("emptyMain");
3474 const std::string initial_route("/foo");
3475 MockPlatformViewDelegate platform_view_delegate;
3476 auto child = shell->Spawn(
3477 std::move(second_configuration), initial_route,
3478 [&platform_view_delegate](Shell& shell) {
3479 auto result = std::make_unique<MockPlatformView>(
3480 platform_view_delegate, shell.GetTaskRunners());
3481 ON_CALL(*result, CreateRenderingSurface())
3482 .WillByDefault(::testing::Invoke(
3483 [] { return std::make_unique<MockSurface>(); }));
3484 return result;
3485 },
3486 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
3487 spawn = std::move(child);
3488 });
3489 // Destroy the parent shell.
3490 DestroyShell(std::move(shell));
3491
3492 PostSync(spawn->GetTaskRunners().GetUITaskRunner(), [&spawn] {
3493 // We must get engine on UI thread.
3494 auto runtime_controller = spawn->GetEngine()->GetRuntimeController();
3495 PostSync(spawn->GetTaskRunners().GetIOTaskRunner(),
3496 [&spawn, &runtime_controller] {
3497 // We must get io_manager on IO thread.
3498 auto io_manager = runtime_controller->GetIOManager();
3499 // Check io_manager existence here.
3500 ASSERT_NE(io_manager.get(), nullptr);
3501 ASSERT_NE(io_manager->GetSkiaUnrefQueue().get(), nullptr);
3502 // Get io_manager directly from shell and check its existence.
3503 ASSERT_NE(spawn->GetIOManager().get(), nullptr);
3504 });
3505 });
3506 // Destroy the child shell.
3507 DestroyShell(std::move(spawn));
3508}

◆ TEST_F() [754/876]

flutter::testing::TEST_F ( ShellTest  ,
IOManagerIsSharedBetweenParentAndSpawnedShell   
)

Definition at line 3409 of file shell_unittests.cc.

3409 {
3410 auto settings = CreateSettingsForFixture();
3411 auto shell = CreateShell(settings);
3412 ASSERT_TRUE(ValidateShell(shell.get()));
3413
3414 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [this,
3415 &spawner = shell,
3416 &settings] {
3417 auto second_configuration = RunConfiguration::InferFromSettings(settings);
3418 ASSERT_TRUE(second_configuration.IsValid());
3419 second_configuration.SetEntrypoint("emptyMain");
3420 const std::string initial_route("/foo");
3421 MockPlatformViewDelegate platform_view_delegate;
3422 auto spawn = spawner->Spawn(
3423 std::move(second_configuration), initial_route,
3424 [&platform_view_delegate](Shell& shell) {
3425 auto result = std::make_unique<MockPlatformView>(
3426 platform_view_delegate, shell.GetTaskRunners());
3427 ON_CALL(*result, CreateRenderingSurface())
3428 .WillByDefault(::testing::Invoke(
3429 [] { return std::make_unique<MockSurface>(); }));
3430 return result;
3431 },
3432 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
3433 ASSERT_TRUE(ValidateShell(spawn.get()));
3434
3435 PostSync(spawner->GetTaskRunners().GetIOTaskRunner(), [&spawner, &spawn] {
3436 ASSERT_NE(spawner->GetIOManager().get(), nullptr);
3437 ASSERT_EQ(spawner->GetIOManager().get(), spawn->GetIOManager().get());
3438 });
3439
3440 // Destroy the child shell.
3441 DestroyShell(std::move(spawn));
3442 });
3443 // Destroy the parent shell.
3444 DestroyShell(std::move(shell));
3445}

◆ TEST_F() [755/876]

flutter::testing::TEST_F ( ShellTest  ,
IsolateCanAccessPersistentIsolateData   
)

Definition at line 2038 of file shell_unittests.cc.

2038 {
2039 const std::string message = "dummy isolate launch data.";
2040
2041 Settings settings = CreateSettingsForFixture();
2042 settings.persistent_isolate_data =
2043 std::make_shared<fml::DataMapping>(message);
2044 TaskRunners task_runners("test", // label
2045 GetCurrentTaskRunner(), // platform
2046 CreateNewThread(), // raster
2047 CreateNewThread(), // ui
2048 CreateNewThread() // io
2049 );
2050
2051 fml::AutoResetWaitableEvent message_latch;
2052 AddNativeCallback("NotifyMessage",
2054 const auto message_from_dart =
2057 ASSERT_EQ(message, message_from_dart);
2058 message_latch.Signal();
2059 }));
2060
2061 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
2062
2063 ASSERT_TRUE(shell->IsSetup());
2064 auto configuration = RunConfiguration::InferFromSettings(settings);
2065 configuration.SetEntrypoint("canAccessIsolateLaunchData");
2066
2068 shell->RunEngine(std::move(configuration), [&](auto result) {
2069 ASSERT_EQ(result, Engine::RunStatus::Success);
2070 });
2071
2072 message_latch.Wait();
2073 DestroyShell(std::move(shell), task_runners);
2074}

◆ TEST_F() [756/876]

flutter::testing::TEST_F ( ShellTest  ,
LastEntrypoint   
)

Definition at line 582 of file shell_unittests.cc.

582 {
583 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
584 auto settings = CreateSettingsForFixture();
585 auto shell = CreateShell(settings);
586 ASSERT_TRUE(ValidateShell(shell.get()));
587
588 auto configuration = RunConfiguration::InferFromSettings(settings);
589 ASSERT_TRUE(configuration.IsValid());
590 std::string entry_point = "fixturesAreFunctionalMain";
591 configuration.SetEntrypoint(entry_point);
592
594 std::string last_entry_point;
595 AddNativeCallback(
596 "SayHiFromFixturesAreFunctionalMain", CREATE_NATIVE_ENTRY([&](auto args) {
597 last_entry_point = shell->GetEngine()->GetLastEntrypoint();
598 main_latch.Signal();
599 }));
600
601 RunEngine(shell.get(), std::move(configuration));
602 main_latch.Wait();
603 EXPECT_EQ(entry_point, last_entry_point);
604 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
605 DestroyShell(std::move(shell));
606 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
607}

◆ TEST_F() [757/876]

flutter::testing::TEST_F ( ShellTest  ,
LastEntrypointArgs   
)

Definition at line 609 of file shell_unittests.cc.

609 {
610 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
611 auto settings = CreateSettingsForFixture();
612 auto shell = CreateShell(settings);
613 ASSERT_TRUE(ValidateShell(shell.get()));
614
615 auto configuration = RunConfiguration::InferFromSettings(settings);
616 ASSERT_TRUE(configuration.IsValid());
617 std::string entry_point = "fixturesAreFunctionalMain";
618 std::vector<std::string> entry_point_args = {"arg1"};
619 configuration.SetEntrypoint(entry_point);
620 configuration.SetEntrypointArgs(entry_point_args);
621
623 std::vector<std::string> last_entry_point_args;
624 AddNativeCallback(
625 "SayHiFromFixturesAreFunctionalMain", CREATE_NATIVE_ENTRY([&](auto args) {
626 last_entry_point_args = shell->GetEngine()->GetLastEntrypointArgs();
627 main_latch.Signal();
628 }));
629
630 RunEngine(shell.get(), std::move(configuration));
631 main_latch.Wait();
632#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
633 EXPECT_EQ(last_entry_point_args, entry_point_args);
634#else
635 ASSERT_TRUE(last_entry_point_args.empty());
636#endif
637 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
638 DestroyShell(std::move(shell));
639 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
640}

◆ TEST_F() [758/876]

flutter::testing::TEST_F ( ShellTest  ,
LocaltimesMatch   
)

Definition at line 2237 of file shell_unittests.cc.

2237 {
2239 std::string dart_isolate_time_str;
2240
2241 // See fixtures/shell_test.dart, the callback NotifyLocalTime is declared
2242 // there.
2243 AddNativeCallback("NotifyLocalTime", CREATE_NATIVE_ENTRY([&](auto args) {
2244 dart_isolate_time_str =
2247 latch.Signal();
2248 }));
2249
2250 auto settings = CreateSettingsForFixture();
2251 auto configuration = RunConfiguration::InferFromSettings(settings);
2252 configuration.SetEntrypoint("localtimesMatch");
2253 std::unique_ptr<Shell> shell = CreateShell(settings);
2254 ASSERT_NE(shell.get(), nullptr);
2255 RunEngine(shell.get(), std::move(configuration));
2256 latch.Wait();
2257
2258 char timestr[200];
2259 const time_t timestamp = time(nullptr);
2260 const struct tm* local_time = localtime(&timestamp);
2261 ASSERT_NE(local_time, nullptr)
2262 << "Could not get local time: errno=" << errno << ": " << strerror(errno);
2263 // Example: "2020-02-26 14" for 2pm on February 26, 2020.
2264 const size_t format_size =
2265 strftime(timestr, sizeof(timestr), "%Y-%m-%d %H", local_time);
2266 ASSERT_NE(format_size, 0UL)
2267 << "strftime failed: host time: " << std::string(timestr)
2268 << " dart isolate time: " << dart_isolate_time_str;
2269
2270 const std::string host_local_time_str = timestr;
2271
2272 ASSERT_EQ(dart_isolate_time_str, host_local_time_str)
2273 << "Local times in the dart isolate and the local time seen by the test "
2274 << "differ by more than 1 hour, but are expected to be about equal";
2275
2276 DestroyShell(std::move(shell));
2277}

◆ TEST_F() [759/876]

flutter::testing::TEST_F ( ShellTest  ,
MissAtMostOneFrameForIrregularInputEvents   
)

Definition at line 186 of file input_events_unittests.cc.

186 {
187 // We don't use `constexpr int frame_time` here because MSVC doesn't handle
188 // it well with lambda capture.
189 UnitlessTime frame_time = 10;
190 UnitlessTime base_latency = 0.5 * frame_time;
191 Generator extreme = [frame_time, base_latency](int i) {
192 return static_cast<UnitlessTime>(
193 i * frame_time + base_latency +
194 (i % 2 == 0 ? 0.1 * frame_time : 0.9 * frame_time));
195 };
196 constexpr int n = 40;
197 std::vector<int> events_consumed_at_frame;
198 TestSimulatedInputEvents(this, n, base_latency, extreme, frame_time,
199 events_consumed_at_frame);
200 int frame_drawn = events_consumed_at_frame.size();
201 ASSERT_GE(frame_drawn, n - 1);
202
203 // Make sure that it also works after an engine restart.
204 TestSimulatedInputEvents(this, n, base_latency, extreme, frame_time,
205 events_consumed_at_frame, true /* restart_engine */);
206 int frame_drawn_after_restart = events_consumed_at_frame.size();
207 ASSERT_GE(frame_drawn_after_restart, n - 1);
208}

◆ TEST_F() [760/876]

flutter::testing::TEST_F ( ShellTest  ,
MultipleFluttersSetResourceCacheBytes   
)

Definition at line 1680 of file shell_unittests.cc.

1680 {
1681 TaskRunners task_runners = GetTaskRunnersForFixture();
1682 auto settings = CreateSettingsForFixture();
1683 settings.resource_cache_max_bytes_threshold = 4000000U;
1684 GrMockOptions main_context_options;
1685 sk_sp<GrDirectContext> main_context =
1686 GrDirectContext::MakeMock(&main_context_options);
1687 Shell::CreateCallback<PlatformView> platform_view_create_callback =
1688 [task_runners, main_context](flutter::Shell& shell) {
1689 auto result = std::make_unique<TestPlatformView>(shell, task_runners);
1690 ON_CALL(*result, CreateRenderingSurface())
1691 .WillByDefault(::testing::Invoke([main_context] {
1692 auto surface = std::make_unique<MockSurface>();
1693 ON_CALL(*surface, GetContext())
1694 .WillByDefault(Return(main_context.get()));
1695 ON_CALL(*surface, IsValid()).WillByDefault(Return(true));
1696 ON_CALL(*surface, MakeRenderContextCurrent())
1697 .WillByDefault(::testing::Invoke([] {
1698 return std::make_unique<GLContextDefaultResult>(true);
1699 }));
1700 return surface;
1701 }));
1702 return result;
1703 };
1704
1705 auto shell = CreateShell({
1706 .settings = settings,
1707 .task_runners = task_runners,
1708 .platform_view_create_callback = platform_view_create_callback,
1709 });
1710
1711 // Create the surface needed by rasterizer
1712 PlatformViewNotifyCreated(shell.get());
1713
1714 auto configuration = RunConfiguration::InferFromSettings(settings);
1715 configuration.SetEntrypoint("emptyMain");
1716
1717 RunEngine(shell.get(), std::move(configuration));
1718 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() {
1719 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
1720 {1.0, 100, 100, 22, 0});
1721 });
1722
1723 // first cache bytes
1724 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1725 static_cast<size_t>(480000U));
1726
1727 auto shell_spawn_callback = [&]() {
1728 std::unique_ptr<Shell> spawn;
1729 PostSync(
1730 shell->GetTaskRunners().GetPlatformTaskRunner(),
1731 [this, &spawn, &spawner = shell, platform_view_create_callback]() {
1732 auto configuration =
1733 RunConfiguration::InferFromSettings(CreateSettingsForFixture());
1734 configuration.SetEntrypoint("emptyMain");
1735 spawn = spawner->Spawn(
1736 std::move(configuration), "", platform_view_create_callback,
1737 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
1738 ASSERT_NE(nullptr, spawn.get());
1739 ASSERT_TRUE(ValidateShell(spawn.get()));
1740 });
1741 return spawn;
1742 };
1743
1744 std::unique_ptr<Shell> second_shell = shell_spawn_callback();
1745 PlatformViewNotifyCreated(second_shell.get());
1746 PostSync(second_shell->GetTaskRunners().GetPlatformTaskRunner(),
1747 [&second_shell]() {
1748 second_shell->GetPlatformView()->SetViewportMetrics(
1749 kImplicitViewId, {1.0, 100, 100, 22, 0});
1750 });
1751 // first cache bytes + second cache bytes
1752 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1753 static_cast<size_t>(960000U));
1754
1755 PostSync(second_shell->GetTaskRunners().GetPlatformTaskRunner(),
1756 [&second_shell]() {
1757 second_shell->GetPlatformView()->SetViewportMetrics(
1758 kImplicitViewId, {1.0, 100, 300, 22, 0});
1759 });
1760 // first cache bytes + second cache bytes
1761 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1762 static_cast<size_t>(1920000U));
1763
1764 std::unique_ptr<Shell> third_shell = shell_spawn_callback();
1765 PlatformViewNotifyCreated(third_shell.get());
1766 PostSync(third_shell->GetTaskRunners().GetPlatformTaskRunner(),
1767 [&third_shell]() {
1768 third_shell->GetPlatformView()->SetViewportMetrics(
1769 kImplicitViewId, {1.0, 400, 100, 22, 0});
1770 });
1771 // first cache bytes + second cache bytes + third cache bytes
1772 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1773 static_cast<size_t>(3840000U));
1774
1775 PostSync(third_shell->GetTaskRunners().GetPlatformTaskRunner(),
1776 [&third_shell]() {
1777 third_shell->GetPlatformView()->SetViewportMetrics(
1778 kImplicitViewId, {1.0, 800, 100, 22, 0});
1779 });
1780 // max bytes threshold
1781 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1782 static_cast<size_t>(4000000U));
1783 DestroyShell(std::move(third_shell), task_runners);
1784 // max bytes threshold
1785 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1786 static_cast<size_t>(4000000U));
1787
1788 PostSync(second_shell->GetTaskRunners().GetPlatformTaskRunner(),
1789 [&second_shell]() {
1790 second_shell->GetPlatformView()->SetViewportMetrics(
1791 kImplicitViewId, {1.0, 100, 100, 22, 0});
1792 });
1793 // first cache bytes + second cache bytes
1794 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1795 static_cast<size_t>(960000U));
1796
1797 DestroyShell(std::move(second_shell), task_runners);
1798 DestroyShell(std::move(shell), task_runners);
1799}
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
Definition shell.h:119
static size_t GetRasterizerResourceCacheBytesSync(const Shell &shell)

◆ TEST_F() [761/876]

flutter::testing::TEST_F ( ShellTest  ,
NeedsReportTimingsIsSetWithCallback   
)

Definition at line 706 of file shell_unittests.cc.

706 {
707 auto settings = CreateSettingsForFixture();
708 std::unique_ptr<Shell> shell = CreateShell(settings);
709
710 // Create the surface needed by rasterizer
711 PlatformViewNotifyCreated(shell.get());
712
713 auto configuration = RunConfiguration::InferFromSettings(settings);
714 configuration.SetEntrypoint("dummyReportTimingsMain");
715
716 RunEngine(shell.get(), std::move(configuration));
717 PumpOneFrame(shell.get());
718 ASSERT_TRUE(GetNeedsReportTimings(shell.get()));
719 DestroyShell(std::move(shell));
720}

◆ TEST_F() [762/876]

flutter::testing::TEST_F ( ShellTest  ,
NoNeedToReportTimingsByDefault   
)

Definition at line 678 of file shell_unittests.cc.

678 {
679 auto settings = CreateSettingsForFixture();
680 std::unique_ptr<Shell> shell = CreateShell(settings);
681
682 // Create the surface needed by rasterizer
683 PlatformViewNotifyCreated(shell.get());
684
685 auto configuration = RunConfiguration::InferFromSettings(settings);
686 configuration.SetEntrypoint("emptyMain");
687
688 RunEngine(shell.get(), std::move(configuration));
689 PumpOneFrame(shell.get());
690 ASSERT_FALSE(GetNeedsReportTimings(shell.get()));
691
692 // This assertion may or may not be the direct result of needs_report_timings_
693 // being false. The count could be 0 simply because we just cleared
694 // unreported timings by reporting them. Hence this can't replace the
695 // ASSERT_FALSE(GetNeedsReportTimings(shell.get())) check. We added
696 // this assertion for an additional confidence that we're not pushing
697 // back to unreported timings unnecessarily.
698 //
699 // Conversely, do not assert UnreportedTimingsCount(shell.get()) to be
700 // positive in any tests. Otherwise those tests will be flaky as the clearing
701 // of unreported timings is unpredictive.
702 ASSERT_EQ(UnreportedTimingsCount(shell.get()), 0);
703 DestroyShell(std::move(shell));
704}

◆ TEST_F() [763/876]

flutter::testing::TEST_F ( ShellTest  ,
NotifyDestroyed   
)

Definition at line 4332 of file shell_unittests.cc.

4332 {
4333 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4334 Settings settings = CreateSettingsForFixture();
4335 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
4336 ThreadHost::Type::kPlatform | ThreadHost::kUi |
4337 ThreadHost::kIo | ThreadHost::kRaster);
4338 auto platform_task_runner = thread_host.platform_thread->GetTaskRunner();
4339 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4340 thread_host.raster_thread->GetTaskRunner(),
4341 thread_host.ui_thread->GetTaskRunner(),
4342 thread_host.io_thread->GetTaskRunner());
4343 auto shell = CreateShell(settings, task_runners);
4344 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
4345 ASSERT_TRUE(ValidateShell(shell.get()));
4346
4347 fml::CountDownLatch latch(1);
4348 AddNativeCallback("NotifyDestroyed", CREATE_NATIVE_ENTRY([&](auto args) {
4349 auto runtime_controller = const_cast<RuntimeController*>(
4350 shell->GetEngine()->GetRuntimeController());
4351 bool success = runtime_controller->NotifyDestroyed();
4352 EXPECT_TRUE(success);
4353 latch.CountDown();
4354 }));
4355
4356 auto configuration = RunConfiguration::InferFromSettings(settings);
4357 configuration.SetEntrypoint("callNotifyDestroyed");
4358 RunEngine(shell.get(), std::move(configuration));
4359
4360 latch.Wait();
4361
4362 DestroyShell(std::move(shell), task_runners);
4363 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4364}
virtual bool NotifyDestroyed()
Notify the Dart VM that the attached flutter view has been destroyed. This gives the Dart VM to perfo...

◆ TEST_F() [764/876]

flutter::testing::TEST_F ( ShellTest  ,
NotifyIdleNotCalledInLatencyMode   
)

Definition at line 4289 of file shell_unittests.cc.

4289 {
4290 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4291 Settings settings = CreateSettingsForFixture();
4292 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
4293 ThreadHost::Type::kPlatform | ThreadHost::kUi |
4294 ThreadHost::kIo | ThreadHost::kRaster);
4295 auto platform_task_runner = thread_host.platform_thread->GetTaskRunner();
4296 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4297 thread_host.raster_thread->GetTaskRunner(),
4298 thread_host.ui_thread->GetTaskRunner(),
4299 thread_host.io_thread->GetTaskRunner());
4300 auto shell = CreateShell(settings, task_runners);
4301 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
4302 ASSERT_TRUE(ValidateShell(shell.get()));
4303
4304 // we start off in balanced mode, where we expect idle notifications to
4305 // succeed. After the first `NotifyNativeBool` we expect to be in latency
4306 // mode, where we expect idle notifications to fail.
4307 fml::CountDownLatch latch(2);
4308 AddNativeCallback(
4309 "NotifyNativeBool", CREATE_NATIVE_ENTRY([&](auto args) {
4310 Dart_Handle exception = nullptr;
4311 bool is_in_latency_mode =
4313 auto runtime_controller = const_cast<RuntimeController*>(
4314 shell->GetEngine()->GetRuntimeController());
4315 bool success =
4316 runtime_controller->NotifyIdle(fml::TimeDelta::FromMicroseconds(
4317 Dart_TimelineGetMicros() + 100000));
4318 EXPECT_EQ(success, !is_in_latency_mode);
4319 latch.CountDown();
4320 }));
4321
4322 auto configuration = RunConfiguration::InferFromSettings(settings);
4323 configuration.SetEntrypoint("performanceModeImpactsNotifyIdle");
4324 RunEngine(shell.get(), std::move(configuration));
4325
4326 latch.Wait();
4327
4328 DestroyShell(std::move(shell), task_runners);
4329 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4330}
virtual bool NotifyIdle(fml::TimeDelta deadline)
Notify the Dart VM that no frame workloads are expected on the UI task runner till the specified dead...
DART_EXPORT int64_t Dart_TimelineGetMicros()

◆ TEST_F() [765/876]

flutter::testing::TEST_F ( ShellTest  ,
NotifyIdleRejectsPastAndNearFuture   
)

Definition at line 4244 of file shell_unittests.cc.

4244 {
4245 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4246 Settings settings = CreateSettingsForFixture();
4247 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
4248 ThreadHost::Type::kPlatform | ThreadHost::kUi |
4249 ThreadHost::kIo | ThreadHost::kRaster);
4250 auto platform_task_runner = thread_host.platform_thread->GetTaskRunner();
4251 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4252 thread_host.raster_thread->GetTaskRunner(),
4253 thread_host.ui_thread->GetTaskRunner(),
4254 thread_host.io_thread->GetTaskRunner());
4255 auto shell = CreateShell(settings, task_runners);
4256 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
4257 ASSERT_TRUE(ValidateShell(shell.get()));
4258
4260
4261 auto configuration = RunConfiguration::InferFromSettings(settings);
4262 configuration.SetEntrypoint("emptyMain");
4263 RunEngine(shell.get(), std::move(configuration));
4264
4266 task_runners.GetUITaskRunner(), [&latch, &shell]() {
4267 auto runtime_controller = const_cast<RuntimeController*>(
4268 shell->GetEngine()->GetRuntimeController());
4269
4270 auto now = fml::TimeDelta::FromMicroseconds(Dart_TimelineGetMicros());
4271
4272 EXPECT_FALSE(runtime_controller->NotifyIdle(
4273 now - fml::TimeDelta::FromMilliseconds(10)));
4274 EXPECT_FALSE(runtime_controller->NotifyIdle(now));
4275 EXPECT_FALSE(runtime_controller->NotifyIdle(
4276 now + fml::TimeDelta::FromNanoseconds(100)));
4277
4278 EXPECT_TRUE(runtime_controller->NotifyIdle(
4279 now + fml::TimeDelta::FromMilliseconds(100)));
4280 latch.Signal();
4281 });
4282
4283 latch.Wait();
4284
4285 DestroyShell(std::move(shell), task_runners);
4286 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4287}

◆ TEST_F() [766/876]

flutter::testing::TEST_F ( ShellTest  ,
OnPlatformViewCreatedWhenUIThreadIsBusy   
)

Definition at line 3874 of file shell_unittests.cc.

3874 {
3875 // This test will deadlock if the threading logic in
3876 // Shell::OnCreatePlatformView is wrong.
3877 auto settings = CreateSettingsForFixture();
3878 auto shell = CreateShell(settings);
3879
3881 fml::TaskRunner::RunNowOrPostTask(shell->GetTaskRunners().GetUITaskRunner(),
3882 [&latch]() { latch.Wait(); });
3883
3884 ShellTest::PlatformViewNotifyCreated(shell.get());
3885 latch.Signal();
3886
3887 DestroyShell(std::move(shell));
3888}

◆ TEST_F() [767/876]

flutter::testing::TEST_F ( ShellTest  ,
OnPlatformViewDestroyAfterMergingThreads   
)

Definition at line 1102 of file shell_unittests.cc.

1102 {
1103#if defined(OS_FUCHSIA)
1104 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
1105 "https://github.com/flutter/flutter/issues/59816 ";
1106#else
1107
1108 const int ThreadMergingLease = 10;
1109 auto settings = CreateSettingsForFixture();
1110 fml::AutoResetWaitableEvent end_frame_latch;
1111 std::shared_ptr<ShellTestExternalViewEmbedder> external_view_embedder;
1112
1113 auto end_frame_callback =
1114 [&](bool should_resubmit_frame,
1115 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
1116 if (should_resubmit_frame && !raster_thread_merger->IsMerged()) {
1117 raster_thread_merger->MergeWithLease(ThreadMergingLease);
1118
1119 ASSERT_TRUE(raster_thread_merger->IsMerged());
1120 external_view_embedder->UpdatePostPrerollResult(
1121 PostPrerollResult::kSuccess);
1122 }
1123 end_frame_latch.Signal();
1124 };
1125 external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1126 end_frame_callback, PostPrerollResult::kSuccess, true);
1127 // Set resubmit once to trigger thread merging.
1128 external_view_embedder->UpdatePostPrerollResult(
1129 PostPrerollResult::kResubmitFrame);
1130 auto shell = CreateShell({
1131 .settings = settings,
1132 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1133 .shell_test_external_view_embedder = external_view_embedder,
1134 }),
1135 });
1136
1137 // Create the surface needed by rasterizer
1138 PlatformViewNotifyCreated(shell.get());
1139
1140 auto configuration = RunConfiguration::InferFromSettings(settings);
1141 configuration.SetEntrypoint("emptyMain");
1142
1143 RunEngine(shell.get(), std::move(configuration));
1144
1145 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1146 auto display_list_layer = std::make_shared<DisplayListLayer>(
1147 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1148 root->Add(display_list_layer);
1149 };
1150
1151 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1152 // Pump one frame to trigger thread merging.
1153 end_frame_latch.Wait();
1154 // Pump another frame to ensure threads are merged and a regular layer tree is
1155 // submitted.
1156 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1157 // Threads are merged here. PlatformViewNotifyDestroy should be executed
1158 // successfully.
1160 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1161 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1163
1164 // Ensure threads are unmerged after platform view destroy
1166 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1167 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1168
1169 // Validate the platform view can be recreated and destroyed again
1170 ValidateShell(shell.get());
1171
1172 DestroyShell(std::move(shell));
1173#endif // OS_FUCHSIA
1174}
static bool RunsOnTheSameThread(TaskQueueId queue_a, TaskQueueId queue_b)
static void ValidateDestroyPlatformView(Shell *shell)

◆ TEST_F() [768/876]

flutter::testing::TEST_F ( ShellTest  ,
OnPlatformViewDestroyDisablesThreadMerger   
)

Definition at line 1044 of file shell_unittests.cc.

1044 {
1045#if defined(OS_FUCHSIA)
1046 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
1047 "https://github.com/flutter/flutter/issues/59816 ";
1048#else
1049
1050 auto settings = CreateSettingsForFixture();
1051 fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger;
1052 auto end_frame_callback =
1053 [&](bool should_resubmit_frame,
1055 raster_thread_merger = std::move(thread_merger);
1056 };
1057 auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1058 end_frame_callback, PostPrerollResult::kSuccess, true);
1059
1060 auto shell = CreateShell({
1061 .settings = settings,
1062 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1063 .shell_test_external_view_embedder = external_view_embedder,
1064 }),
1065 });
1066
1067 // Create the surface needed by rasterizer
1068 PlatformViewNotifyCreated(shell.get());
1069
1070 auto configuration = RunConfiguration::InferFromSettings(settings);
1071 configuration.SetEntrypoint("emptyMain");
1072
1073 RunEngine(shell.get(), std::move(configuration));
1074
1075 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1076 auto display_list_layer = std::make_shared<DisplayListLayer>(
1077 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1078 root->Add(display_list_layer);
1079 };
1080
1081 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1082
1083 auto result = shell->WaitForFirstFrame(fml::TimeDelta::Max());
1084 // Wait for the rasterizer to process the frame. WaitForFirstFrame only waits
1085 // for the Animator, but end_frame_callback is called by the Rasterizer.
1086 PostSync(shell->GetTaskRunners().GetRasterTaskRunner(), [] {});
1087 ASSERT_TRUE(result.ok()) << "Result: " << static_cast<int>(result.code())
1088 << ": " << result.message();
1089
1090 ASSERT_TRUE(raster_thread_merger->IsEnabled());
1091
1093 ASSERT_TRUE(raster_thread_merger->IsEnabled());
1094
1095 // Validate the platform view can be recreated and destroyed again
1096 ValidateShell(shell.get());
1097 ASSERT_TRUE(raster_thread_merger->IsEnabled());
1098 DestroyShell(std::move(shell));
1099#endif // OS_FUCHSIA
1100}
static constexpr TimeDelta Max()
Definition time_delta.h:37

◆ TEST_F() [769/876]

flutter::testing::TEST_F ( ShellTest  ,
OnPlatformViewDestroyWhenThreadsAreMerging   
)

Definition at line 1176 of file shell_unittests.cc.

1176 {
1177#if defined(OS_FUCHSIA)
1178 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
1179 "https://github.com/flutter/flutter/issues/59816 ";
1180#else
1181
1182 const int kThreadMergingLease = 10;
1183 auto settings = CreateSettingsForFixture();
1184 fml::AutoResetWaitableEvent end_frame_latch;
1185 auto end_frame_callback =
1186 [&](bool should_resubmit_frame,
1187 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
1188 if (should_resubmit_frame && !raster_thread_merger->IsMerged()) {
1189 raster_thread_merger->MergeWithLease(kThreadMergingLease);
1190 }
1191 end_frame_latch.Signal();
1192 };
1193 // Start with a regular layer tree with `PostPrerollResult::kSuccess` so we
1194 // can later check if the rasterizer is tore down using
1195 // |ValidateDestroyPlatformView|
1196 auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1197 end_frame_callback, PostPrerollResult::kSuccess, true);
1198
1199 auto shell = CreateShell({
1200 .settings = settings,
1201 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1202 .shell_test_external_view_embedder = external_view_embedder,
1203 }),
1204 });
1205
1206 // Create the surface needed by rasterizer
1207 PlatformViewNotifyCreated(shell.get());
1208
1209 auto configuration = RunConfiguration::InferFromSettings(settings);
1210 configuration.SetEntrypoint("emptyMain");
1211
1212 RunEngine(shell.get(), std::move(configuration));
1213
1214 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1215 auto display_list_layer = std::make_shared<DisplayListLayer>(
1216 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1217 root->Add(display_list_layer);
1218 };
1219
1220 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1221 // Pump one frame and threads aren't merged
1222 end_frame_latch.Wait();
1224 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1225 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1226
1227 // Pump a frame with `PostPrerollResult::kResubmitFrame` to start merging
1228 // threads
1229 external_view_embedder->UpdatePostPrerollResult(
1230 PostPrerollResult::kResubmitFrame);
1231 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1232
1233 // Now destroy the platform view immediately.
1234 // Two things can happen here:
1235 // 1. Threads haven't merged. 2. Threads has already merged.
1236 // |Shell:OnPlatformViewDestroy| should be able to handle both cases.
1238
1239 // Ensure threads are unmerged after platform view destroy
1241 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1242 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1243
1244 // Validate the platform view can be recreated and destroyed again
1245 ValidateShell(shell.get());
1246
1247 DestroyShell(std::move(shell));
1248#endif // OS_FUCHSIA
1249}

◆ TEST_F() [770/876]

flutter::testing::TEST_F ( ShellTest  ,
OnPlatformViewDestroyWithoutRasterThreadMerger   
)

Definition at line 1308 of file shell_unittests.cc.

1308 {
1309 auto settings = CreateSettingsForFixture();
1310
1311 auto shell = CreateShell(settings);
1312
1313 // Create the surface needed by rasterizer
1314 PlatformViewNotifyCreated(shell.get());
1315
1316 auto configuration = RunConfiguration::InferFromSettings(settings);
1317 configuration.SetEntrypoint("emptyMain");
1318
1319 RunEngine(shell.get(), std::move(configuration));
1320
1321 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1322 auto display_list_layer = std::make_shared<DisplayListLayer>(
1323 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1324 root->Add(display_list_layer);
1325 };
1326 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1327
1328 // Threads should not be merged.
1330 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1331 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1332 ValidateDestroyPlatformView(shell.get());
1333
1334 // Ensure threads are unmerged after platform view destroy
1336 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1337 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1338
1339 // Validate the platform view can be recreated and destroyed again
1340 ValidateShell(shell.get());
1341
1342 DestroyShell(std::move(shell));
1343}

◆ TEST_F() [771/876]

flutter::testing::TEST_F ( ShellTest  ,
OnPlatformViewDestroyWithStaticThreadMerging   
)

Definition at line 1346 of file shell_unittests.cc.

1346 {
1347#if defined(OS_FUCHSIA)
1348 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
1349 "https://github.com/flutter/flutter/issues/59816 ";
1350#else
1351
1352 auto settings = CreateSettingsForFixture();
1353 fml::AutoResetWaitableEvent end_frame_latch;
1354 auto end_frame_callback =
1355 [&](bool should_resubmit_frame,
1356 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
1357 end_frame_latch.Signal();
1358 };
1359 auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1360 end_frame_callback, PostPrerollResult::kSuccess, true);
1361 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
1362 ThreadHost::Type::kPlatform | ThreadHost::Type::kIo |
1363 ThreadHost::Type::kUi);
1364 TaskRunners task_runners(
1365 "test",
1366 thread_host.platform_thread->GetTaskRunner(), // platform
1367 thread_host.platform_thread->GetTaskRunner(), // raster
1368 thread_host.ui_thread->GetTaskRunner(), // ui
1369 thread_host.io_thread->GetTaskRunner() // io
1370 );
1371 auto shell = CreateShell({
1372 .settings = settings,
1373 .task_runners = task_runners,
1374 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1375 .shell_test_external_view_embedder = external_view_embedder,
1376 }),
1377 });
1378
1379 // Create the surface needed by rasterizer
1380 PlatformViewNotifyCreated(shell.get());
1381
1382 auto configuration = RunConfiguration::InferFromSettings(settings);
1383 configuration.SetEntrypoint("emptyMain");
1384
1385 RunEngine(shell.get(), std::move(configuration));
1386
1387 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1388 auto display_list_layer = std::make_shared<DisplayListLayer>(
1389 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1390 root->Add(display_list_layer);
1391 };
1392 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1393 end_frame_latch.Wait();
1394
1396
1397 // Validate the platform view can be recreated and destroyed again
1398 ValidateShell(shell.get());
1399
1400 DestroyShell(std::move(shell), task_runners);
1401#endif // OS_FUCHSIA
1402}

◆ TEST_F() [772/876]

flutter::testing::TEST_F ( ShellTest  ,
OnPlatformViewDestroyWithThreadMergerWhileThreadsAreUnmerged   
)

Definition at line 1251 of file shell_unittests.cc.

1252 {
1253#if defined(OS_FUCHSIA)
1254 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
1255 "https://github.com/flutter/flutter/issues/59816 ";
1256#else
1257
1258 auto settings = CreateSettingsForFixture();
1259 fml::AutoResetWaitableEvent end_frame_latch;
1260 auto end_frame_callback =
1261 [&](bool should_resubmit_frame,
1262 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
1263 end_frame_latch.Signal();
1264 };
1265 auto external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
1266 end_frame_callback, PostPrerollResult::kSuccess, true);
1267 auto shell = CreateShell({
1268 .settings = settings,
1269 .platform_view_create_callback = ShellTestPlatformViewBuilder({
1270 .shell_test_external_view_embedder = external_view_embedder,
1271 }),
1272 });
1273
1274 // Create the surface needed by rasterizer
1275 PlatformViewNotifyCreated(shell.get());
1276
1277 auto configuration = RunConfiguration::InferFromSettings(settings);
1278 configuration.SetEntrypoint("emptyMain");
1279
1280 RunEngine(shell.get(), std::move(configuration));
1281
1282 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
1283 auto display_list_layer = std::make_shared<DisplayListLayer>(
1284 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
1285 root->Add(display_list_layer);
1286 };
1287 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
1288 end_frame_latch.Wait();
1289
1290 // Threads should not be merged.
1292 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1293 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1295
1296 // Ensure threads are unmerged after platform view destroy
1298 shell->GetTaskRunners().GetRasterTaskRunner()->GetTaskQueueId(),
1299 shell->GetTaskRunners().GetPlatformTaskRunner()->GetTaskQueueId()));
1300
1301 // Validate the platform view can be recreated and destroyed again
1302 ValidateShell(shell.get());
1303
1304 DestroyShell(std::move(shell));
1305#endif // OS_FUCHSIA
1306}

◆ TEST_F() [773/876]

flutter::testing::TEST_F ( ShellTest  ,
OnServiceProtocolEstimateRasterCacheMemoryWorks   
)

Definition at line 2463 of file shell_unittests.cc.

2463 {
2464 Settings settings = CreateSettingsForFixture();
2465 std::unique_ptr<Shell> shell = CreateShell(settings);
2466
2467 // 1. Construct a picture and a picture layer to be raster cached.
2468 sk_sp<DisplayList> display_list = MakeSizedDisplayList(10, 10);
2469 auto display_list_layer = std::make_shared<DisplayListLayer>(
2470 SkPoint::Make(0, 0), MakeSizedDisplayList(100, 100), false, false);
2471 display_list_layer->set_paint_bounds(SkRect::MakeWH(100, 100));
2472
2473 // 2. Rasterize the picture and the picture layer in the raster cache.
2474 std::promise<bool> rasterized;
2475
2476 shell->GetTaskRunners().GetRasterTaskRunner()->PostTask(
2477 [&shell, &rasterized, &display_list, &display_list_layer] {
2478 std::vector<RasterCacheItem*> raster_cache_items;
2479 auto* compositor_context = shell->GetRasterizer()->compositor_context();
2480 auto& raster_cache = compositor_context->raster_cache();
2481
2482 LayerStateStack state_stack;
2483 FixedRefreshRateStopwatch raster_time;
2485 PaintContext paint_context = {
2486 // clang-format off
2487 .state_stack = state_stack,
2488 .canvas = nullptr,
2489 .gr_context = nullptr,
2490 .dst_color_space = nullptr,
2491 .view_embedder = nullptr,
2492 .raster_time = raster_time,
2493 .ui_time = ui_time,
2494 .texture_registry = nullptr,
2495 .raster_cache = &raster_cache,
2496 // clang-format on
2497 };
2498
2499 PrerollContext preroll_context = {
2500 // clang-format off
2501 .raster_cache = &raster_cache,
2502 .gr_context = nullptr,
2503 .view_embedder = nullptr,
2504 .state_stack = state_stack,
2505 .dst_color_space = nullptr,
2506 .surface_needs_readback = false,
2507 .raster_time = raster_time,
2508 .ui_time = ui_time,
2509 .texture_registry = nullptr,
2510 .has_platform_view = false,
2511 .has_texture_layer = false,
2512 .raster_cached_entries = &raster_cache_items,
2513 // clang-format on
2514 };
2515
2516 // 2.1. Rasterize the picture. Call Draw multiple times to pass the
2517 // access threshold (default to 3) so a cache can be generated.
2518 MockCanvas dummy_canvas;
2519 DlPaint paint;
2520 bool picture_cache_generated;
2521 DisplayListRasterCacheItem display_list_raster_cache_item(
2522 display_list, SkPoint(), true, false);
2523 for (int i = 0; i < 4; i += 1) {
2524 SkMatrix matrix = SkMatrix::I();
2525 state_stack.set_preroll_delegate(matrix);
2526 display_list_raster_cache_item.PrerollSetup(&preroll_context, matrix);
2527 display_list_raster_cache_item.PrerollFinalize(&preroll_context,
2528 matrix);
2529 picture_cache_generated =
2530 display_list_raster_cache_item.need_caching();
2531 state_stack.set_delegate(&dummy_canvas);
2532 display_list_raster_cache_item.TryToPrepareRasterCache(paint_context);
2533 display_list_raster_cache_item.Draw(paint_context, &dummy_canvas,
2534 &paint);
2535 }
2536 ASSERT_TRUE(picture_cache_generated);
2537
2538 // 2.2. Rasterize the picture layer.
2539 LayerRasterCacheItem layer_raster_cache_item(display_list_layer.get());
2540 state_stack.set_preroll_delegate(SkMatrix::I());
2541 layer_raster_cache_item.PrerollSetup(&preroll_context, SkMatrix::I());
2542 layer_raster_cache_item.PrerollFinalize(&preroll_context,
2543 SkMatrix::I());
2544 state_stack.set_delegate(&dummy_canvas);
2545 layer_raster_cache_item.TryToPrepareRasterCache(paint_context);
2546 layer_raster_cache_item.Draw(paint_context, &dummy_canvas, &paint);
2547 rasterized.set_value(true);
2548 });
2549 rasterized.get_future().wait();
2550
2551 // 3. Call the service protocol and check its output.
2552 ServiceProtocol::Handler::ServiceProtocolMap empty_params;
2553 rapidjson::Document document;
2554 OnServiceProtocol(
2555 shell.get(), ServiceProtocolEnum::kEstimateRasterCacheMemory,
2556 shell->GetTaskRunners().GetRasterTaskRunner(), empty_params, &document);
2557 rapidjson::StringBuffer buffer;
2558 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2559 document.Accept(writer);
2560 std::string expected_json =
2561 "{\"type\":\"EstimateRasterCacheMemory\",\"layerBytes\":40024,\"picture"
2562 "Bytes\":424}";
2563 std::string actual_json = buffer.GetString();
2564 ASSERT_EQ(actual_json, expected_json);
2565
2566 DestroyShell(std::move(shell));
2567}

◆ TEST_F() [774/876]

flutter::testing::TEST_F ( ShellTest  ,
OnServiceProtocolGetSkSLsWorks   
)

Definition at line 2348 of file shell_unittests.cc.

2348 {
2350 ASSERT_TRUE(base_dir.fd().is_valid());
2351 PersistentCache::SetCacheDirectoryPath(base_dir.path());
2352 PersistentCache::ResetCacheForProcess();
2353
2354 // Create 2 dummy SkSL cache file IE (base32 encoding of A), II (base32
2355 // encoding of B) with content x and y.
2356 std::vector<std::string> components = {
2357 "flutter_engine", GetFlutterEngineVersion(), "skia", GetSkiaVersion(),
2358 PersistentCache::kSkSLSubdirName};
2359 auto sksl_dir = fml::CreateDirectory(base_dir.fd(), components,
2361 const std::string x_key_str = "A";
2362 const std::string x_value_str = "x";
2363 sk_sp<SkData> x_key =
2364 SkData::MakeWithCopy(x_key_str.data(), x_key_str.size());
2365 sk_sp<SkData> x_value =
2366 SkData::MakeWithCopy(x_value_str.data(), x_value_str.size());
2367 auto x_data = PersistentCache::BuildCacheObject(*x_key, *x_value);
2368
2369 const std::string y_key_str = "B";
2370 const std::string y_value_str = "y";
2371 sk_sp<SkData> y_key =
2372 SkData::MakeWithCopy(y_key_str.data(), y_key_str.size());
2373 sk_sp<SkData> y_value =
2374 SkData::MakeWithCopy(y_value_str.data(), y_value_str.size());
2375 auto y_data = PersistentCache::BuildCacheObject(*y_key, *y_value);
2376
2377 ASSERT_TRUE(fml::WriteAtomically(sksl_dir, "x_cache", *x_data));
2378 ASSERT_TRUE(fml::WriteAtomically(sksl_dir, "y_cache", *y_data));
2379
2380 Settings settings = CreateSettingsForFixture();
2381 std::unique_ptr<Shell> shell = CreateShell(settings);
2383 rapidjson::Document document;
2384 OnServiceProtocol(shell.get(), ServiceProtocolEnum::kGetSkSLs,
2385 shell->GetTaskRunners().GetIOTaskRunner(), empty_params,
2386 &document);
2387 rapidjson::StringBuffer buffer;
2388 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2389 document.Accept(writer);
2390 DestroyShell(std::move(shell));
2391
2392 const std::string expected_json1 =
2393 "{\"type\":\"GetSkSLs\",\"SkSLs\":{\"II\":\"eQ==\",\"IE\":\"eA==\"}}";
2394 const std::string expected_json2 =
2395 "{\"type\":\"GetSkSLs\",\"SkSLs\":{\"IE\":\"eA==\",\"II\":\"eQ==\"}}";
2396 bool json_is_expected = (expected_json1 == buffer.GetString()) ||
2397 (expected_json2 == buffer.GetString());
2398 ASSERT_TRUE(json_is_expected) << buffer.GetString() << " is not equal to "
2399 << expected_json1 << " or " << expected_json2;
2400}
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition SkData.cpp:111
std::map< std::string_view, std::string_view > ServiceProtocolMap
const char * GetSkiaVersion()
Definition version.cc:15

◆ TEST_F() [775/876]

flutter::testing::TEST_F ( ShellTest  ,
OnServiceProtocolRenderFrameWithRasterStatsWorks   
)

Definition at line 2570 of file shell_unittests.cc.

2570 {
2571 auto settings = CreateSettingsForFixture();
2572 std::unique_ptr<Shell> shell = CreateShell(settings);
2573
2574 // Create the surface needed by rasterizer
2575 PlatformViewNotifyCreated(shell.get());
2576
2577 auto configuration = RunConfiguration::InferFromSettings(settings);
2578 configuration.SetEntrypoint("scene_with_red_box");
2579
2580 RunEngine(shell.get(), std::move(configuration));
2581 // Set a non-zero viewport metrics, otherwise the scene would be discarded.
2582 PostSync(shell->GetTaskRunners().GetUITaskRunner(),
2583 [engine = shell->GetEngine()]() {
2584 engine->SetViewportMetrics(kImplicitViewId,
2585 ViewportMetrics{1, 1, 1, 22, 0});
2586 });
2587 PumpOneFrame(shell.get(), ViewContent::NoViews());
2588
2590 rapidjson::Document document;
2591 OnServiceProtocol(
2592 shell.get(), ServiceProtocolEnum::kRenderFrameWithRasterStats,
2593 shell->GetTaskRunners().GetRasterTaskRunner(), empty_params, &document);
2594 rapidjson::StringBuffer buffer;
2595 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2596 document.Accept(writer);
2597
2598 // It would be better to parse out the json and check for the validity of
2599 // fields. Below checks approximate what needs to be checked, this can not be
2600 // an exact check since duration will not exactly match.
2601#ifdef SHELL_ENABLE_METAL
2602 std::string expected_json =
2603 "\"snapshot\":[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,3,32,0,"
2604 "0,2,88,8,6,0,0,0,154,118,130,112,0,0,0,1,115,82,71,66,0,174,206,28,233,"
2605 "0,0,0,4,115,66,73,84,8,8,8,8,124,8,100,136,0,0,7,103,73,68,65,84,120,"
2606 "156,237,206,65,13,192,48,0,3,177,211,248,115,78,73,172,234,199,70,224,"
2607 "86,91,45,0,0,128,203,190,215,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2608 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2609 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2610 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2611 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2612 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2613 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2614 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2615 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2616 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2617 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2618 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2619 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2620 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2621 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2622 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2623 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2624 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2625 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2626 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2627 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2628 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2629 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2630 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2631 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2632 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2633 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2634 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2635 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2636 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2637 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2638 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2639 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2640 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2641 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2642 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2643 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2644 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2645 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2646 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2647 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2648 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2649 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2650 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2651 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2652 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2653 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2654 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2655 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2656 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2657 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2658 "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
2659 "0,224,47,7,195,182,3,255,101,111,186,90,0,0,0,0,73,69,78,68,174,66,96,"
2660 "130]";
2661#else
2662 std::string expected_json =
2663 "\"snapshot\":[137,80,78,71,13,10,26,10,0,"
2664 "0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,1,115,"
2665 "82,71,66,0,174,206,28,233,0,0,0,4,115,66,73,84,8,8,8,8,124,8,100,136,0,"
2666 "0,0,13,73,68,65,84,8,153,99,248,207,192,240,31,0,5,0,1,255,171,206,54,"
2667 "137,0,0,0,0,73,69,78,68,174,66,96,130]";
2668#endif
2669 std::string actual_json = buffer.GetString();
2670
2671 EXPECT_THAT(actual_json, ::testing::HasSubstr(expected_json));
2672 EXPECT_THAT(actual_json,
2673 ::testing::HasSubstr("{\"type\":\"RenderFrameWithRasterStats\""));
2674 EXPECT_THAT(actual_json, ::testing::HasSubstr("\"duration_micros\""));
2675
2676 PlatformViewNotifyDestroyed(shell.get());
2677 DestroyShell(std::move(shell));
2678}

◆ TEST_F() [776/876]

flutter::testing::TEST_F ( ShellTest  ,
OnServiceProtocolSetAssetBundlePathWorks   
)

Definition at line 3002 of file shell_unittests.cc.

3002 {
3003 Settings settings = CreateSettingsForFixture();
3004 std::unique_ptr<Shell> shell = CreateShell(settings);
3005 RunConfiguration configuration =
3006 RunConfiguration::InferFromSettings(settings);
3007 configuration.SetEntrypoint("canAccessResourceFromAssetDir");
3008
3009 // Verify isolate can load a known resource with the
3010 // default asset directory - kernel_blob.bin
3012
3013 // Callback used to signal whether the resource was loaded successfully.
3014 bool can_access_resource = false;
3015 auto native_can_access_resource = [&can_access_resource,
3016 &latch](Dart_NativeArguments args) {
3017 Dart_Handle exception = nullptr;
3018 can_access_resource =
3020 latch.Signal();
3021 };
3022 AddNativeCallback("NotifyCanAccessResource",
3023 CREATE_NATIVE_ENTRY(native_can_access_resource));
3024
3025 // Callback used to delay the asset load until after the service
3026 // protocol method has finished.
3027 auto native_notify_set_asset_bundle_path =
3028 [&shell](Dart_NativeArguments args) {
3029 // Update the asset directory to a bonus path.
3031 params["assetDirectory"] = "assetDirectory";
3032 rapidjson::Document document;
3033 OnServiceProtocol(shell.get(), ServiceProtocolEnum::kSetAssetBundlePath,
3034 shell->GetTaskRunners().GetUITaskRunner(), params,
3035 &document);
3036 rapidjson::StringBuffer buffer;
3037 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3038 document.Accept(writer);
3039 };
3040 AddNativeCallback("NotifySetAssetBundlePath",
3041 CREATE_NATIVE_ENTRY(native_notify_set_asset_bundle_path));
3042
3043 RunEngine(shell.get(), std::move(configuration));
3044
3045 latch.Wait();
3046 ASSERT_TRUE(can_access_resource);
3047
3048 DestroyShell(std::move(shell));
3049}
Specifies all the configuration required by the runtime library to launch the root isolate....
void SetEntrypoint(std::string entrypoint)
Updates the main application entrypoint. If this is not set, the "main" method is used as the entrypo...

◆ TEST_F() [777/876]

flutter::testing::TEST_F ( ShellTest  ,
PathVolatilityGCRemovesPathFromTracker   
)

Definition at line 68 of file path_unittests.cc.

68 {
69 static_assert(VolatilePathTracker::kFramesOfVolatility > 1);
70 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
71
72 auto native_validate_path = [message_latch](Dart_NativeArguments args) {
73 auto handle = Dart_GetNativeArgument(args, 0);
74 intptr_t peer = 0;
77 EXPECT_FALSE(Dart_IsError(result));
78 CanvasPath* path = reinterpret_cast<CanvasPath*>(peer);
79 EXPECT_TRUE(path);
80 EXPECT_TRUE(path->path().isVolatile());
81 std::shared_ptr<VolatilePathTracker> tracker =
82 UIDartState::Current()->GetVolatilePathTracker();
83 EXPECT_TRUE(tracker);
84 EXPECT_EQ(GetLiveTrackedPathCount(tracker), 1ul);
85 EXPECT_TRUE(path->path().isVolatile());
86
87 tracker->OnFrame();
88 EXPECT_EQ(GetLiveTrackedPathCount(tracker), 1ul);
89 EXPECT_TRUE(path->path().isVolatile());
90
91 // simulate GC
92 path->Release();
93 EXPECT_EQ(GetLiveTrackedPathCount(tracker), 0ul);
94
95 tracker->OnFrame();
96 EXPECT_EQ(GetLiveTrackedPathCount(tracker), 0ul);
97
98 message_latch->Signal();
99 };
100
101 Settings settings = CreateSettingsForFixture();
102 TaskRunners task_runners("test", // label
103 GetCurrentTaskRunner(), // platform
104 CreateNewThread(), // raster
105 CreateNewThread(), // ui
106 CreateNewThread() // io
107 );
108
109 AddNativeCallback("ValidatePath", CREATE_NATIVE_ENTRY(native_validate_path));
110
111 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
112
113 ASSERT_TRUE(shell->IsSetup());
114 auto configuration = RunConfiguration::InferFromSettings(settings);
115 configuration.SetEntrypoint("createPath");
116
117 shell->RunEngine(std::move(configuration), [](auto result) {
118 ASSERT_EQ(result, Engine::RunStatus::Success);
119 });
120
121 message_latch->Wait();
122
123 DestroyShell(std::move(shell), task_runners);
124}

◆ TEST_F() [778/876]

flutter::testing::TEST_F ( ShellTest  ,
PathVolatilityOldPathsBecomeNonVolatile   
)

Definition at line 19 of file path_unittests.cc.

19 {
20 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
21
22 auto native_validate_path = [message_latch](Dart_NativeArguments args) {
23 auto handle = Dart_GetNativeArgument(args, 0);
24 intptr_t peer = 0;
27 EXPECT_FALSE(Dart_IsError(result));
28 CanvasPath* path = reinterpret_cast<CanvasPath*>(peer);
29 EXPECT_TRUE(path);
30 EXPECT_TRUE(path->path().isVolatile());
31 std::shared_ptr<VolatilePathTracker> tracker =
32 UIDartState::Current()->GetVolatilePathTracker();
33 EXPECT_TRUE(tracker);
34
35 for (int i = 0; i < VolatilePathTracker::kFramesOfVolatility; i++) {
36 EXPECT_TRUE(path->path().isVolatile());
37 tracker->OnFrame();
38 }
39 EXPECT_FALSE(path->path().isVolatile());
40 message_latch->Signal();
41 };
42
43 Settings settings = CreateSettingsForFixture();
44 TaskRunners task_runners("test", // label
45 GetCurrentTaskRunner(), // platform
46 CreateNewThread(), // raster
47 CreateNewThread(), // ui
48 CreateNewThread() // io
49 );
50
51 AddNativeCallback("ValidatePath", CREATE_NATIVE_ENTRY(native_validate_path));
52
53 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
54
55 ASSERT_TRUE(shell->IsSetup());
56 auto configuration = RunConfiguration::InferFromSettings(settings);
57 configuration.SetEntrypoint("createPath");
58
59 shell->RunEngine(std::move(configuration), [](auto result) {
60 ASSERT_EQ(result, Engine::RunStatus::Success);
61 });
62
63 message_latch->Wait();
64
65 DestroyShell(std::move(shell), task_runners);
66}

◆ TEST_F() [779/876]

flutter::testing::TEST_F ( ShellTest  ,
PictureToImageSync   
)

Definition at line 4076 of file shell_unittests.cc.

4076 {
4077#if !SHELL_ENABLE_GL
4078 // This test uses the GL backend.
4079 GTEST_SKIP();
4080#else
4081 auto settings = CreateSettingsForFixture();
4082 std::unique_ptr<Shell> shell = CreateShell({
4083 .settings = settings,
4084 .platform_view_create_callback = ShellTestPlatformViewBuilder({
4085 .rendering_backend = ShellTestPlatformView::BackendType::kGLBackend,
4086 }),
4087 });
4088
4089 AddNativeCallback("NativeOnBeforeToImageSync",
4090 CREATE_NATIVE_ENTRY([&](auto args) {
4091 // nop
4092 }));
4093
4094 fml::CountDownLatch latch(2);
4095 AddNativeCallback("NotifyNative", CREATE_NATIVE_ENTRY([&](auto args) {
4096 // Teardown and set up rasterizer again.
4097 PlatformViewNotifyDestroyed(shell.get());
4098 PlatformViewNotifyCreated(shell.get());
4099 latch.CountDown();
4100 }));
4101
4102 ASSERT_NE(shell, nullptr);
4103 ASSERT_TRUE(shell->IsSetup());
4104 auto configuration = RunConfiguration::InferFromSettings(settings);
4105 PlatformViewNotifyCreated(shell.get());
4106 configuration.SetEntrypoint("toImageSync");
4107 RunEngine(shell.get(), std::move(configuration));
4108 PumpOneFrame(shell.get());
4109
4110 latch.Wait();
4111
4112 PlatformViewNotifyDestroyed(shell.get());
4113 DestroyShell(std::move(shell));
4114#endif // !SHELL_ENABLE_GL
4115}

◆ TEST_F() [780/876]

flutter::testing::TEST_F ( ShellTest  ,
PictureToImageSyncImpellerNoSurface   
)

Definition at line 4117 of file shell_unittests.cc.

4117 {
4118#if !SHELL_ENABLE_METAL
4119 // This test uses the Metal backend.
4120 GTEST_SKIP();
4121#else
4122 auto settings = CreateSettingsForFixture();
4123 settings.enable_impeller = true;
4124 std::unique_ptr<Shell> shell = CreateShell({
4125 .settings = settings,
4126 .platform_view_create_callback = ShellTestPlatformViewBuilder({
4127 .rendering_backend =
4128 ShellTestPlatformView::BackendType::kMetalBackend,
4129 }),
4130 });
4131
4132 AddNativeCallback("NativeOnBeforeToImageSync",
4133 CREATE_NATIVE_ENTRY([&](auto args) {
4134 // nop
4135 }));
4136
4137 fml::CountDownLatch latch(2);
4138 AddNativeCallback("NotifyNative", CREATE_NATIVE_ENTRY([&](auto args) {
4139 // Teardown and set up rasterizer again.
4140 PlatformViewNotifyDestroyed(shell.get());
4141 PlatformViewNotifyCreated(shell.get());
4142 latch.CountDown();
4143 }));
4144
4145 ASSERT_NE(shell, nullptr);
4146 ASSERT_TRUE(shell->IsSetup());
4147 auto configuration = RunConfiguration::InferFromSettings(settings);
4148
4149 // Important: Do not create the platform view yet!
4150 // This test is making sure that the rasterizer can create the texture
4151 // as expected without a surface.
4152
4153 configuration.SetEntrypoint("toImageSync");
4154 RunEngine(shell.get(), std::move(configuration));
4155 PumpOneFrame(shell.get());
4156
4157 latch.Wait();
4158
4159 PlatformViewNotifyDestroyed(shell.get());
4160 DestroyShell(std::move(shell));
4161#endif // !SHELL_ENABLE_METAL
4162}

◆ TEST_F() [781/876]

flutter::testing::TEST_F ( ShellTest  ,
PlatformMessageResponseDart   
)

Definition at line 17 of file platform_message_response_dart_unittests.cc.

17 {
18 bool did_pass = false;
19 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
20 TaskRunners task_runners("test", // label
21 GetCurrentTaskRunner(), // platform
22 CreateNewThread(), // raster
23 CreateNewThread(), // ui
24 CreateNewThread() // io
25 );
26
27 auto nativeCallPlatformMessageResponseDart =
28 [ui_task_runner =
29 task_runners.GetUITaskRunner()](Dart_NativeArguments args) {
30 auto dart_state = std::make_shared<tonic::DartState>();
31 auto response = fml::MakeRefCounted<PlatformMessageResponseDart>(
34 ui_task_runner, "foobar");
35 uint8_t* data = static_cast<uint8_t*>(malloc(100));
36 auto mapping = std::make_unique<fml::MallocMapping>(data, 100);
37 response->Complete(std::move(mapping));
38 };
39
40 AddNativeCallback("CallPlatformMessageResponseDart",
41 CREATE_NATIVE_ENTRY(nativeCallPlatformMessageResponseDart));
42
43 auto nativeFinishCallResponse = [message_latch,
44 &did_pass](Dart_NativeArguments args) {
45 did_pass =
47 message_latch->Signal();
48 };
49
50 AddNativeCallback("FinishCallResponse",
51 CREATE_NATIVE_ENTRY(nativeFinishCallResponse));
52
53 Settings settings = CreateSettingsForFixture();
54
55 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
56
57 ASSERT_TRUE(shell->IsSetup());
58 auto configuration = RunConfiguration::InferFromSettings(settings);
59 configuration.SetEntrypoint("platformMessageResponseTest");
60
61 shell->RunEngine(std::move(configuration), [](auto result) {
62 ASSERT_EQ(result, Engine::RunStatus::Success);
63 });
64
65 message_latch->Wait();
66
67 ASSERT_TRUE(did_pass);
68 DestroyShell(std::move(shell), task_runners);
69}

◆ TEST_F() [782/876]

flutter::testing::TEST_F ( ShellTest  ,
PlatformMessageResponseDartPort   
)

Definition at line 17 of file platform_message_response_dart_port_unittests.cc.

17 {
18 bool did_pass = false;
19 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
20 TaskRunners task_runners("test", // label
21 GetCurrentTaskRunner(), // platform
22 CreateNewThread(), // raster
23 CreateNewThread(), // ui
24 CreateNewThread() // io
25 );
26
27 auto nativeCallPlatformMessageResponseDartPort =
28 [ui_task_runner =
29 task_runners.GetUITaskRunner()](Dart_NativeArguments args) {
30 auto dart_state = std::make_shared<tonic::DartState>();
31 auto response = fml::MakeRefCounted<PlatformMessageResponseDartPort>(
34 123, "foobar");
35 uint8_t* data = static_cast<uint8_t*>(malloc(100));
36 auto mapping = std::make_unique<fml::MallocMapping>(data, 100);
37 response->Complete(std::move(mapping));
38 };
39
40 AddNativeCallback(
41 "CallPlatformMessageResponseDartPort",
42 CREATE_NATIVE_ENTRY(nativeCallPlatformMessageResponseDartPort));
43
44 auto nativeFinishCallResponse = [message_latch,
45 &did_pass](Dart_NativeArguments args) {
46 did_pass =
48 message_latch->Signal();
49 };
50
51 AddNativeCallback("FinishCallResponse",
52 CREATE_NATIVE_ENTRY(nativeFinishCallResponse));
53
54 Settings settings = CreateSettingsForFixture();
55
56 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
57
58 ASSERT_TRUE(shell->IsSetup());
59 auto configuration = RunConfiguration::InferFromSettings(settings);
60 configuration.SetEntrypoint("platformMessagePortResponseTest");
61
62 shell->RunEngine(std::move(configuration), [](auto result) {
63 ASSERT_EQ(result, Engine::RunStatus::Success);
64 });
65
66 message_latch->Wait();
67
68 ASSERT_TRUE(did_pass);
69 DestroyShell(std::move(shell), task_runners);
70}

◆ TEST_F() [783/876]

flutter::testing::TEST_F ( ShellTest  ,
PluginUtilitiesCallbackHandleErrorHandling   
)

Definition at line 4215 of file shell_unittests.cc.

4215 {
4216 auto settings = CreateSettingsForFixture();
4217 std::unique_ptr<Shell> shell = CreateShell(settings);
4218
4220 bool test_passed;
4221 AddNativeCallback("NotifyNativeBool", CREATE_NATIVE_ENTRY([&](auto args) {
4222 Dart_Handle exception = nullptr;
4224 args, 0, exception);
4225 latch.Signal();
4226 }));
4227
4228 ASSERT_NE(shell, nullptr);
4229 ASSERT_TRUE(shell->IsSetup());
4230 auto configuration = RunConfiguration::InferFromSettings(settings);
4231 PlatformViewNotifyCreated(shell.get());
4232 configuration.SetEntrypoint("testPluginUtilitiesCallbackHandle");
4233 RunEngine(shell.get(), std::move(configuration));
4234 PumpOneFrame(shell.get());
4235
4236 latch.Wait();
4237
4238 ASSERT_TRUE(test_passed);
4239
4240 PlatformViewNotifyDestroyed(shell.get());
4241 DestroyShell(std::move(shell));
4242}

◆ TEST_F() [784/876]

flutter::testing::TEST_F ( ShellTest  ,
PositivePriorityTakesPrecedentOverDefaultGenerators   
)

Definition at line 85 of file image_generator_registry_unittests.cc.

85 {
87
88 const int fake_width = 1337;
89 registry.AddFactory(
90 [fake_width](const sk_sp<SkData>& buffer) {
91 return std::make_unique<FakeImageGenerator>(fake_width);
92 },
93 1);
94
95 // Fetch the generator and query for basic info.
96 auto result = registry.CreateCompatibleGenerator(LoadValidImageFixture());
97 ASSERT_EQ(result->GetInfo().width(), fake_width);
98}

◆ TEST_F() [785/876]

flutter::testing::TEST_F ( ShellTest  ,
PrefetchDefaultFontManager   
)

Definition at line 3833 of file shell_unittests.cc.

3833 {
3834 auto settings = CreateSettingsForFixture();
3835 settings.prefetched_default_font_manager = true;
3836 std::unique_ptr<Shell> shell;
3837
3838 auto get_font_manager_count = [&] {
3840 size_t font_manager_count;
3842 shell->GetTaskRunners().GetUITaskRunner(),
3843 [this, &shell, &latch, &font_manager_count]() {
3844 font_manager_count =
3845 GetFontCollection(shell.get())->GetFontManagersCount();
3846 latch.Signal();
3847 });
3848 latch.Wait();
3849 return font_manager_count;
3850 };
3851 size_t initial_font_manager_count = 0;
3852 settings.root_isolate_create_callback = [&](const auto& isolate) {
3853 ASSERT_GT(initial_font_manager_count, 0ul);
3854 // Should not have fetched the default font manager yet, since the root
3855 // isolate was only just created.
3856 ASSERT_EQ(get_font_manager_count(), initial_font_manager_count);
3857 };
3858
3859 shell = CreateShell(settings);
3860
3861 initial_font_manager_count = get_font_manager_count();
3862
3863 auto configuration = RunConfiguration::InferFromSettings(settings);
3864 configuration.SetEntrypoint("emptyMain");
3865 RunEngine(shell.get(), std::move(configuration));
3866
3867 // If the prefetched_default_font_manager flag is set, then the default font
3868 // manager will not be added until the engine starts running.
3869 ASSERT_EQ(get_font_manager_count(), initial_font_manager_count + 1);
3870
3871 DestroyShell(std::move(shell));
3872}

◆ TEST_F() [786/876]

flutter::testing::TEST_F ( ShellTest  ,
PrintsErrorWhenPlatformMessageSentFromWrongThread   
)

Definition at line 4366 of file shell_unittests.cc.

4366 {
4367#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_DEBUG || OS_FUCHSIA
4368 GTEST_SKIP() << "Test is for debug mode only on non-fuchsia targets.";
4369#else
4370 Settings settings = CreateSettingsForFixture();
4371 ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".",
4372 ThreadHost::Type::kPlatform);
4373 auto task_runner = thread_host.platform_thread->GetTaskRunner();
4374 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
4375 task_runner);
4376 auto shell = CreateShell(settings, task_runners);
4377
4378 {
4379 fml::testing::LogCapture log_capture;
4380
4381 // The next call will result in a thread checker violation.
4383 SendPlatformMessage(shell.get(), std::make_unique<PlatformMessage>(
4384 "com.test.plugin", nullptr));
4385
4386 EXPECT_THAT(
4387 log_capture.str(),
4388 ::testing::EndsWith(
4389 "The 'com.test.plugin' channel sent a message from native to "
4390 "Flutter on a non-platform thread. Platform channel messages "
4391 "must be sent on the platform thread. Failure to do so may "
4392 "result in data loss or crashes, and must be fixed in the "
4393 "plugin or application code creating that channel.\nSee "
4394 "https://docs.flutter.dev/platform-integration/"
4395 "platform-channels#channels-and-platform-threading for more "
4396 "information.\n"));
4397 }
4398
4399 {
4400 fml::testing::LogCapture log_capture;
4401
4402 // The next call will result in a thread checker violation.
4404 SendPlatformMessage(shell.get(), std::make_unique<PlatformMessage>(
4405 "com.test.plugin", nullptr));
4406
4407 EXPECT_EQ(log_capture.str(), "");
4408 }
4409
4410 DestroyShell(std::move(shell), task_runners);
4411 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4412#endif
4413}
static void DisableNextThreadCheckFailure()

◆ TEST_F() [787/876]

flutter::testing::TEST_F ( ShellTest  ,
PushBackdropFilterToVisitedPlatformViews   
)

Definition at line 907 of file shell_unittests.cc.

907 {
908#if defined(OS_FUCHSIA)
909 GTEST_SKIP() << "RasterThreadMerger flakes on Fuchsia. "
910 "https://github.com/flutter/flutter/issues/59816 ";
911#else
912
913 auto settings = CreateSettingsForFixture();
914
915 std::shared_ptr<ShellTestExternalViewEmbedder> external_view_embedder;
916
917 fml::AutoResetWaitableEvent end_frame_latch;
918 bool end_frame_called = false;
919 std::vector<int64_t> visited_platform_views;
920 MutatorsStack stack_50;
921 MutatorsStack stack_75;
922 auto end_frame_callback =
923 [&](bool should_resubmit_frame,
924 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
925 if (end_frame_called) {
926 return;
927 }
928 ASSERT_TRUE(raster_thread_merger.get() == nullptr);
929 ASSERT_FALSE(should_resubmit_frame);
930 end_frame_called = true;
931 visited_platform_views =
932 external_view_embedder->GetVisitedPlatformViews();
933 stack_50 = external_view_embedder->GetStack(50);
934 stack_75 = external_view_embedder->GetStack(75);
935 end_frame_latch.Signal();
936 };
937
938 external_view_embedder = std::make_shared<ShellTestExternalViewEmbedder>(
939 end_frame_callback, PostPrerollResult::kResubmitFrame, false);
940 auto shell = CreateShell({
941 .settings = settings,
942 .platform_view_create_callback = ShellTestPlatformViewBuilder({
943 .shell_test_external_view_embedder = external_view_embedder,
944 }),
945 });
946
947 // Create the surface needed by rasterizer
948 PlatformViewNotifyCreated(shell.get());
949
950 auto configuration = RunConfiguration::InferFromSettings(settings);
951 configuration.SetEntrypoint("emptyMain");
952
953 RunEngine(shell.get(), std::move(configuration));
954
955 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
956 auto platform_view_layer = std::make_shared<PlatformViewLayer>(
957 SkPoint::Make(10, 10), SkSize::Make(10, 10), 50);
958 root->Add(platform_view_layer);
959 auto transform_layer =
960 std::make_shared<TransformLayer>(SkMatrix::Translate(1, 1));
961 root->Add(transform_layer);
962 auto clip_rect_layer = std::make_shared<ClipRectLayer>(
963 SkRect::MakeLTRB(0, 0, 30, 30), Clip::kHardEdge);
964 transform_layer->Add(clip_rect_layer);
965 auto filter = std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
966 auto backdrop_filter_layer =
967 std::make_shared<BackdropFilterLayer>(filter, DlBlendMode::kSrcOver);
968 clip_rect_layer->Add(backdrop_filter_layer);
969 auto platform_view_layer2 = std::make_shared<PlatformViewLayer>(
970 SkPoint::Make(10, 10), SkSize::Make(10, 10), 75);
971 backdrop_filter_layer->Add(platform_view_layer2);
972 };
973
974 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
975 end_frame_latch.Wait();
976 ASSERT_EQ(visited_platform_views, (std::vector<int64_t>{50, 75}));
977 ASSERT_TRUE(stack_75.is_empty());
978 ASSERT_FALSE(stack_50.is_empty());
979
980 auto filter = DlBlurImageFilter(5, 5, DlTileMode::kClamp);
981 auto mutator = *stack_50.Begin();
982 ASSERT_EQ(mutator->GetType(), MutatorType::kBackdropFilter);
983 ASSERT_EQ(mutator->GetFilterMutation().GetFilter(), filter);
984 // Make sure the filterRect is in global coordinates (contains the (1,1)
985 // translation).
986 ASSERT_EQ(mutator->GetFilterMutation().GetFilterRect(),
987 SkRect::MakeLTRB(1, 1, 31, 31));
988
989 DestroyShell(std::move(shell));
990#endif // OS_FUCHSIA
991}

◆ TEST_F() [788/876]

flutter::testing::TEST_F ( ShellTest  ,
RasterizerMakeRasterSnapshot   
)

Definition at line 2432 of file shell_unittests.cc.

2432 {
2433 Settings settings = CreateSettingsForFixture();
2434 auto configuration = RunConfiguration::InferFromSettings(settings);
2435 auto task_runner = CreateNewThread();
2436 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
2437 task_runner);
2438 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
2439
2440 ASSERT_TRUE(ValidateShell(shell.get()));
2441 PlatformViewNotifyCreated(shell.get());
2442
2443 RunEngine(shell.get(), std::move(configuration));
2444
2445 auto latch = std::make_shared<fml::AutoResetWaitableEvent>();
2446
2447 PumpOneFrame(shell.get());
2448
2450 shell->GetTaskRunners().GetRasterTaskRunner(), [&shell, &latch]() {
2451 SnapshotDelegate* delegate =
2452 reinterpret_cast<Rasterizer*>(shell->GetRasterizer().get());
2453 sk_sp<DlImage> image = delegate->MakeRasterSnapshot(
2454 MakeSizedDisplayList(50, 50), SkISize::Make(50, 50));
2455 EXPECT_NE(image, nullptr);
2456
2457 latch->Signal();
2458 });
2459 latch->Wait();
2460 DestroyShell(std::move(shell), task_runners);
2461}

◆ TEST_F() [789/876]

flutter::testing::TEST_F ( ShellTest  ,
RasterizerScreenshot   
)

Definition at line 2402 of file shell_unittests.cc.

2402 {
2403 Settings settings = CreateSettingsForFixture();
2404 auto configuration = RunConfiguration::InferFromSettings(settings);
2405 auto task_runner = CreateNewThread();
2406 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
2407 task_runner);
2408 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
2409
2410 ASSERT_TRUE(ValidateShell(shell.get()));
2411 PlatformViewNotifyCreated(shell.get());
2412
2413 RunEngine(shell.get(), std::move(configuration));
2414
2415 auto latch = std::make_shared<fml::AutoResetWaitableEvent>();
2416
2417 PumpOneFrame(shell.get());
2418
2420 shell->GetTaskRunners().GetRasterTaskRunner(), [&shell, &latch]() {
2421 Rasterizer::Screenshot screenshot =
2422 shell->GetRasterizer()->ScreenshotLastLayerTree(
2423 Rasterizer::ScreenshotType::CompressedImage, true);
2424 EXPECT_NE(screenshot.data, nullptr);
2425
2426 latch->Signal();
2427 });
2428 latch->Wait();
2429 DestroyShell(std::move(shell), task_runners);
2430}

◆ TEST_F() [790/876]

flutter::testing::TEST_F ( ShellTest  ,
ReportTimingsIsCalled   
)

Definition at line 749 of file shell_unittests.cc.

749 {
750 auto settings = CreateSettingsForFixture();
751 std::unique_ptr<Shell> shell = CreateShell(settings);
752
753 // We MUST put |start| after |CreateShell| because the clock source will be
754 // reset through |TimePoint::SetClockSource()| in
755 // |DartVMInitializer::Initialize()| within |CreateShell()|.
757
758 // Create the surface needed by rasterizer
759 PlatformViewNotifyCreated(shell.get());
760
761 auto configuration = RunConfiguration::InferFromSettings(settings);
762 ASSERT_TRUE(configuration.IsValid());
763 configuration.SetEntrypoint("reportTimingsMain");
764 fml::AutoResetWaitableEvent reportLatch;
765 std::vector<int64_t> timestamps;
766 auto nativeTimingCallback = [&reportLatch,
767 &timestamps](Dart_NativeArguments args) {
768 Dart_Handle exception = nullptr;
769 ASSERT_EQ(timestamps.size(), 0ul);
770 timestamps = tonic::DartConverter<std::vector<int64_t>>::FromArguments(
771 args, 0, exception);
772 reportLatch.Signal();
773 };
774 AddNativeCallback("NativeReportTimingsCallback",
775 CREATE_NATIVE_ENTRY(nativeTimingCallback));
776 RunEngine(shell.get(), std::move(configuration));
777
778 // Pump many frames so we can trigger the report quickly instead of waiting
779 // for the 1 second threshold.
780 for (int i = 0; i < 200; i += 1) {
781 PumpOneFrame(shell.get());
782 }
783
784 reportLatch.Wait();
785 DestroyShell(std::move(shell));
786
788 ASSERT_TRUE(!timestamps.empty());
789 ASSERT_TRUE(timestamps.size() % FrameTiming::kCount == 0);
790 std::vector<FrameTiming> timings(timestamps.size() / FrameTiming::kCount);
791
792 for (size_t i = 0; i * FrameTiming::kCount < timestamps.size(); i += 1) {
793 for (auto phase : FrameTiming::kPhases) {
794 timings[i].Set(
795 phase,
797 timestamps[i * FrameTiming::kCount + phase])));
798 }
799 }
800 CheckFrameTimings(timings, start, finish);
801}

◆ TEST_F() [791/876]

flutter::testing::TEST_F ( ShellTest  ,
ReportTimingsIsCalledImmediatelyAfterTheFirstFrame   
)

Definition at line 1522 of file shell_unittests.cc.

1522 {
1523 auto settings = CreateSettingsForFixture();
1524 std::unique_ptr<Shell> shell = CreateShell(settings);
1525
1526 // Create the surface needed by rasterizer
1527 PlatformViewNotifyCreated(shell.get());
1528
1529 auto configuration = RunConfiguration::InferFromSettings(settings);
1530 ASSERT_TRUE(configuration.IsValid());
1531 configuration.SetEntrypoint("reportTimingsMain");
1532 fml::AutoResetWaitableEvent reportLatch;
1533 std::vector<int64_t> timestamps;
1534 auto nativeTimingCallback = [&reportLatch,
1535 &timestamps](Dart_NativeArguments args) {
1536 Dart_Handle exception = nullptr;
1537 ASSERT_EQ(timestamps.size(), 0ul);
1538 timestamps = tonic::DartConverter<std::vector<int64_t>>::FromArguments(
1539 args, 0, exception);
1540 reportLatch.Signal();
1541 };
1542 AddNativeCallback("NativeReportTimingsCallback",
1543 CREATE_NATIVE_ENTRY(nativeTimingCallback));
1544 ASSERT_TRUE(configuration.IsValid());
1545 RunEngine(shell.get(), std::move(configuration));
1546
1547 for (int i = 0; i < 10; i += 1) {
1548 PumpOneFrame(shell.get());
1549 }
1550
1551 reportLatch.Wait();
1552 DestroyShell(std::move(shell));
1553
1554 // Check for the immediate callback of the first frame that doesn't wait for
1555 // the other 9 frames to be rasterized.
1556 ASSERT_EQ(timestamps.size(), FrameTiming::kCount);
1557}

◆ TEST_F() [792/876]

flutter::testing::TEST_F ( ShellTest  ,
RuntimeStageBackendDefaultsToSkSLWithoutImpeller   
)

Definition at line 4845 of file shell_unittests.cc.

4845 {
4846 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4847 Settings settings = CreateSettingsForFixture();
4848 settings.enable_impeller = false;
4850 "io.flutter.test." + GetCurrentTestName() + ".",
4851 ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
4852 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
4853 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4854 thread_host.raster_thread->GetTaskRunner(),
4855 thread_host.ui_thread->GetTaskRunner(),
4856 thread_host.io_thread->GetTaskRunner());
4857 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4858 ASSERT_TRUE(shell);
4859
4861 AddNativeCallback("NotifyNative", CREATE_NATIVE_ENTRY([&latch](auto args) {
4862 auto backend =
4863 UIDartState::Current()->GetRuntimeStageBackend();
4864 EXPECT_EQ(backend, impeller::RuntimeStageBackend::kSkSL);
4865 latch.Signal();
4866 }));
4867
4868 auto configuration = RunConfiguration::InferFromSettings(settings);
4869 configuration.SetEntrypoint("mainNotifyNative");
4870 RunEngine(shell.get(), std::move(configuration));
4871
4872 latch.Wait();
4873
4874 DestroyShell(std::move(shell), task_runners);
4875}
const char * backend

◆ TEST_F() [793/876]

flutter::testing::TEST_F ( ShellTest  ,
SceneBuilderBuildAndSceneDisposeReleasesLayerStack   
)

Definition at line 22 of file scene_builder_unittests.cc.

22 {
23 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
24
25 // prevent ClearDartWrapper() from deleting the scene builder.
26 SceneBuilder* retained_scene_builder;
27 Scene* retained_scene;
28
29 auto validate_builder_has_layers =
30 [&retained_scene_builder](Dart_NativeArguments args) {
31 auto handle = Dart_GetNativeArgument(args, 0);
32 intptr_t peer = 0;
35 ASSERT_FALSE(Dart_IsError(result));
36 retained_scene_builder = reinterpret_cast<SceneBuilder*>(peer);
37 retained_scene_builder->AddRef();
38 ASSERT_TRUE(retained_scene_builder);
39 ASSERT_EQ(retained_scene_builder->layer_stack().size(), 2ul);
40 };
41
42 auto validate_builder_has_no_layers =
43 [&retained_scene_builder](Dart_NativeArguments args) {
44 ASSERT_EQ(retained_scene_builder->layer_stack().size(), 0ul);
45 retained_scene_builder->Release();
46 retained_scene_builder = nullptr;
47 };
48
49 auto capture_scene = [&retained_scene](Dart_NativeArguments args) {
50 auto handle = Dart_GetNativeArgument(args, 0);
51 intptr_t peer = 0;
54 ASSERT_FALSE(Dart_IsError(result));
55 retained_scene = reinterpret_cast<Scene*>(peer);
56 retained_scene->AddRef();
57 ASSERT_TRUE(retained_scene);
58 };
59
60 auto validate_scene_has_no_layers =
61 [message_latch, &retained_scene](Dart_NativeArguments args) {
62 EXPECT_FALSE(retained_scene->takeLayerTree(100, 100));
63 retained_scene->Release();
64 retained_scene = nullptr;
65 message_latch->Signal();
66 };
67
68 Settings settings = CreateSettingsForFixture();
69 TaskRunners task_runners("test", // label
70 GetCurrentTaskRunner(), // platform
71 CreateNewThread(), // raster
72 CreateNewThread(), // ui
73 CreateNewThread() // io
74 );
75
76 AddNativeCallback("ValidateBuilderHasLayers",
77 CREATE_NATIVE_ENTRY(validate_builder_has_layers));
78 AddNativeCallback("ValidateBuilderHasNoLayers",
79 CREATE_NATIVE_ENTRY(validate_builder_has_no_layers));
80
81 AddNativeCallback("CaptureScene", CREATE_NATIVE_ENTRY(capture_scene));
82 AddNativeCallback("ValidateSceneHasNoLayers",
83 CREATE_NATIVE_ENTRY(validate_scene_has_no_layers));
84
85 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
86
87 ASSERT_TRUE(shell->IsSetup());
88 auto configuration = RunConfiguration::InferFromSettings(settings);
89 configuration.SetEntrypoint("validateSceneBuilderAndScene");
90
91 shell->RunEngine(std::move(configuration), [](auto result) {
92 ASSERT_EQ(result, Engine::RunStatus::Success);
93 });
94
95 message_latch->Wait();
96 DestroyShell(std::move(shell), task_runners);
97}
std::unique_ptr< flutter::LayerTree > takeLayerTree(uint64_t width, uint64_t height)
Definition scene.cc:130

◆ TEST_F() [794/876]

flutter::testing::TEST_F ( ShellTest  ,
Screenshot   
)

Definition at line 2174 of file shell_unittests.cc.

2174 {
2175 auto settings = CreateSettingsForFixture();
2176 fml::AutoResetWaitableEvent firstFrameLatch;
2177 settings.frame_rasterized_callback =
2178 [&firstFrameLatch](const FrameTiming& t) { firstFrameLatch.Signal(); };
2179
2180 std::unique_ptr<Shell> shell = CreateShell(settings);
2181
2182 // Create the surface needed by rasterizer
2183 PlatformViewNotifyCreated(shell.get());
2184
2185 auto configuration = RunConfiguration::InferFromSettings(settings);
2186 configuration.SetEntrypoint("emptyMain");
2187
2188 RunEngine(shell.get(), std::move(configuration));
2189
2190 LayerTreeBuilder builder = [&](const std::shared_ptr<ContainerLayer>& root) {
2191 auto display_list_layer = std::make_shared<DisplayListLayer>(
2192 SkPoint::Make(10, 10), MakeSizedDisplayList(80, 80), false, false);
2193 root->Add(display_list_layer);
2194 };
2195
2196 PumpOneFrame(shell.get(), ViewContent::ImplicitView(100, 100, builder));
2197 firstFrameLatch.Wait();
2198
2199 std::promise<Rasterizer::Screenshot> screenshot_promise;
2200 auto screenshot_future = screenshot_promise.get_future();
2201
2203 shell->GetTaskRunners().GetRasterTaskRunner(),
2204 [&screenshot_promise, &shell]() {
2205 auto rasterizer = shell->GetRasterizer();
2206 screenshot_promise.set_value(rasterizer->ScreenshotLastLayerTree(
2207 Rasterizer::ScreenshotType::CompressedImage, false));
2208 });
2209
2210 auto fixtures_dir =
2211 fml::OpenDirectory(GetFixturesPath(), false, fml::FilePermission::kRead);
2212
2213 auto reference_png = fml::FileMapping::CreateReadOnly(
2214 fixtures_dir, "shelltest_screenshot.png");
2215
2216 // Use MakeWithoutCopy instead of MakeWithCString because we don't want to
2217 // encode the null sentinel
2218 sk_sp<SkData> reference_data = SkData::MakeWithoutCopy(
2219 reference_png->GetMapping(), reference_png->GetSize());
2220
2221 sk_sp<SkData> screenshot_data = screenshot_future.get().data;
2222 if (!reference_data->equals(screenshot_data.get())) {
2223 LogSkData(reference_data, "reference");
2224 LogSkData(screenshot_data, "screenshot");
2225 ASSERT_TRUE(false);
2226 }
2227
2228 DestroyShell(std::move(shell));
2229}

◆ TEST_F() [795/876]

flutter::testing::TEST_F ( ShellTest  ,
SecondaryIsolateBindingsAreSetupViaShellSettings   
)

Definition at line 558 of file shell_unittests.cc.

558 {
559 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
560 auto settings = CreateSettingsForFixture();
561 auto shell = CreateShell(settings);
562 ASSERT_TRUE(ValidateShell(shell.get()));
563
564 auto configuration = RunConfiguration::InferFromSettings(settings);
565 ASSERT_TRUE(configuration.IsValid());
566 configuration.SetEntrypoint("testCanLaunchSecondaryIsolate");
567
568 fml::CountDownLatch latch(2);
569 AddNativeCallback("NotifyNative", CREATE_NATIVE_ENTRY([&latch](auto args) {
570 latch.CountDown();
571 }));
572
573 RunEngine(shell.get(), std::move(configuration));
574
575 latch.Wait();
576
577 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
578 DestroyShell(std::move(shell));
579 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
580}

◆ TEST_F() [796/876]

flutter::testing::TEST_F ( ShellTest  ,
SecondaryVsyncCallbackShouldBeCalledAfterVsyncCallback   
)

Definition at line 2105 of file shell_unittests.cc.

2105 {
2106 bool is_on_begin_frame_called = false;
2107 bool is_secondary_callback_called = false;
2108 bool test_started = false;
2109 Settings settings = CreateSettingsForFixture();
2110 TaskRunners task_runners = GetTaskRunnersForFixture();
2112 AddNativeCallback(
2113 "NotifyNative",
2115 fml::CountDownLatch count_down_latch(2);
2116 AddNativeCallback("NativeOnBeginFrame",
2118 if (!test_started) {
2119 return;
2120 }
2121 EXPECT_FALSE(is_on_begin_frame_called);
2122 EXPECT_FALSE(is_secondary_callback_called);
2123 is_on_begin_frame_called = true;
2124 count_down_latch.CountDown();
2125 }));
2126 std::unique_ptr<Shell> shell = CreateShell({
2127 .settings = settings,
2128 .task_runners = task_runners,
2129 });
2130 ASSERT_TRUE(shell->IsSetup());
2131
2132 auto configuration = RunConfiguration::InferFromSettings(settings);
2133 configuration.SetEntrypoint("onBeginFrameWithNotifyNativeMain");
2134 RunEngine(shell.get(), std::move(configuration));
2135
2136 // Wait for the application to attach the listener.
2137 latch.Wait();
2138
2140 shell->GetTaskRunners().GetUITaskRunner(), [&]() {
2141 shell->GetEngine()->ScheduleSecondaryVsyncCallback(0, [&]() {
2142 if (!test_started) {
2143 return;
2144 }
2145 EXPECT_TRUE(is_on_begin_frame_called);
2146 EXPECT_FALSE(is_secondary_callback_called);
2147 is_secondary_callback_called = true;
2148 count_down_latch.CountDown();
2149 });
2150 shell->GetEngine()->ScheduleFrame();
2151 test_started = true;
2152 });
2153 count_down_latch.Wait();
2154 EXPECT_TRUE(is_on_begin_frame_called);
2155 EXPECT_TRUE(is_secondary_callback_called);
2156 DestroyShell(std::move(shell), task_runners);
2157}

◆ TEST_F() [797/876]

flutter::testing::TEST_F ( ShellTest  ,
SetResourceCacheSize   
)

Definition at line 1801 of file shell_unittests.cc.

1801 {
1802 Settings settings = CreateSettingsForFixture();
1803 auto task_runner = CreateNewThread();
1804 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
1805 task_runner);
1806 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
1807
1808 // Create the surface needed by rasterizer
1809 PlatformViewNotifyCreated(shell.get());
1810
1811 auto configuration = RunConfiguration::InferFromSettings(settings);
1812 configuration.SetEntrypoint("emptyMain");
1813
1814 RunEngine(shell.get(), std::move(configuration));
1815 PumpOneFrame(shell.get());
1816
1817 // The Vulkan and GL backends set different default values for the resource
1818 // cache size. The default backend (specified by the default param of
1819 // `CreateShell` in this test) will only resolve to Vulkan (in
1820 // `ShellTestPlatformView::Create`) if GL is disabled. This situation arises
1821 // when targeting the Fuchsia Emulator.
1822#if defined(SHELL_ENABLE_VULKAN) && !defined(SHELL_ENABLE_GL)
1823 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1825#elif defined(SHELL_ENABLE_METAL)
1826 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1827 static_cast<size_t>(256 * (1 << 20)));
1828#else
1829 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1830 static_cast<size_t>(24 * (1 << 20)));
1831#endif
1832
1834 shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() {
1835 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
1836 {1.0, 400, 200, 22, 0});
1837 });
1838 PumpOneFrame(shell.get());
1839
1840 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), 3840000U);
1841
1842 std::string request_json = R"json({
1843 "method": "Skia.setResourceCacheMaxBytes",
1844 "args": 10000
1845 })json";
1846 auto data =
1847 fml::MallocMapping::Copy(request_json.c_str(), request_json.length());
1848 auto platform_message = std::make_unique<PlatformMessage>(
1849 "flutter/skia", std::move(data), nullptr);
1850 SendEnginePlatformMessage(shell.get(), std::move(platform_message));
1851 PumpOneFrame(shell.get());
1852 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), 10000U);
1853
1855 shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() {
1856 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
1857 {1.0, 800, 400, 22, 0});
1858 });
1859 PumpOneFrame(shell.get());
1860
1861 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), 10000U);
1862 DestroyShell(std::move(shell), task_runners);
1863}
static const size_t kGrCacheMaxByteSize

◆ TEST_F() [798/876]

flutter::testing::TEST_F ( ShellTest  ,
SetResourceCacheSizeEarly   
)

Definition at line 1865 of file shell_unittests.cc.

1865 {
1866 Settings settings = CreateSettingsForFixture();
1867 auto task_runner = CreateNewThread();
1868 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
1869 task_runner);
1870 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
1871
1873 shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() {
1874 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
1875 {1.0, 400, 200, 22, 0});
1876 });
1877 PumpOneFrame(shell.get());
1878
1879 // Create the surface needed by rasterizer
1880 PlatformViewNotifyCreated(shell.get());
1881
1882 auto configuration = RunConfiguration::InferFromSettings(settings);
1883 configuration.SetEntrypoint("emptyMain");
1884
1885 RunEngine(shell.get(), std::move(configuration));
1886 PumpOneFrame(shell.get());
1887
1888 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1889 static_cast<size_t>(3840000U));
1890 DestroyShell(std::move(shell), task_runners);
1891}

◆ TEST_F() [799/876]

flutter::testing::TEST_F ( ShellTest  ,
SetResourceCacheSizeNotifiesDart   
)

Definition at line 1893 of file shell_unittests.cc.

1893 {
1894 Settings settings = CreateSettingsForFixture();
1895 auto task_runner = CreateNewThread();
1896 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
1897 task_runner);
1898 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
1899
1901 shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() {
1902 shell->GetPlatformView()->SetViewportMetrics(kImplicitViewId,
1903 {1.0, 400, 200, 22, 0});
1904 });
1905 PumpOneFrame(shell.get());
1906
1907 // Create the surface needed by rasterizer
1908 PlatformViewNotifyCreated(shell.get());
1909
1910 auto configuration = RunConfiguration::InferFromSettings(settings);
1911 configuration.SetEntrypoint("testSkiaResourceCacheSendsResponse");
1912
1913 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1914 static_cast<size_t>(3840000U));
1915
1917 AddNativeCallback("NotifyNative", CREATE_NATIVE_ENTRY([&latch](auto args) {
1918 latch.Signal();
1919 }));
1920
1921 RunEngine(shell.get(), std::move(configuration));
1922 PumpOneFrame(shell.get());
1923
1924 latch.Wait();
1925
1926 EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell),
1927 static_cast<size_t>(10000U));
1928 DestroyShell(std::move(shell), task_runners);
1929}

◆ TEST_F() [800/876]

flutter::testing::TEST_F ( ShellTest  ,
ShellCanAddViewOrRemoveView   
)

Definition at line 4484 of file shell_unittests.cc.

4484 {
4485 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4486 Settings settings = CreateSettingsForFixture();
4488 "io.flutter.test." + GetCurrentTestName() + ".",
4489 ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
4490 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
4491 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4492 thread_host.raster_thread->GetTaskRunner(),
4493 thread_host.ui_thread->GetTaskRunner(),
4494 thread_host.io_thread->GetTaskRunner());
4495 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4496 ASSERT_TRUE(shell);
4497
4498 bool hasImplicitView;
4499 std::vector<int64_t> viewIds;
4500 fml::AutoResetWaitableEvent reportLatch;
4501 auto nativeViewIdsCallback = [&reportLatch, &hasImplicitView,
4502 &viewIds](Dart_NativeArguments args) {
4503 ParseViewIdsCallback(args, &hasImplicitView, &viewIds);
4504 reportLatch.Signal();
4505 };
4506 AddNativeCallback("NativeReportViewIdsCallback",
4507 CREATE_NATIVE_ENTRY(nativeViewIdsCallback));
4508
4509 PlatformViewNotifyCreated(shell.get());
4510 auto configuration = RunConfiguration::InferFromSettings(settings);
4511 configuration.SetEntrypoint("testReportViewIds");
4512 RunEngine(shell.get(), std::move(configuration));
4513
4514 reportLatch.Wait();
4515 ASSERT_TRUE(hasImplicitView);
4516 ASSERT_EQ(viewIds.size(), 1u);
4517 ASSERT_EQ(viewIds[0], 0ll);
4518
4519 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell] {
4520 shell->GetPlatformView()->AddView(2, ViewportMetrics{},
4521 [](bool added) { EXPECT_TRUE(added); });
4522 });
4523 reportLatch.Wait();
4524 ASSERT_TRUE(hasImplicitView);
4525 ASSERT_EQ(viewIds.size(), 2u);
4526 ASSERT_EQ(viewIds[1], 2ll);
4527
4528 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell] {
4529 shell->GetPlatformView()->RemoveView(
4530 2, [](bool removed) { ASSERT_TRUE(removed); });
4531 });
4532 reportLatch.Wait();
4533 ASSERT_TRUE(hasImplicitView);
4534 ASSERT_EQ(viewIds.size(), 1u);
4535 ASSERT_EQ(viewIds[0], 0ll);
4536
4537 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell] {
4538 shell->GetPlatformView()->AddView(4, ViewportMetrics{},
4539 [](bool added) { EXPECT_TRUE(added); });
4540 });
4541 reportLatch.Wait();
4542 ASSERT_TRUE(hasImplicitView);
4543 ASSERT_EQ(viewIds.size(), 2u);
4544 ASSERT_EQ(viewIds[1], 4ll);
4545
4546 PlatformViewNotifyDestroyed(shell.get());
4547 DestroyShell(std::move(shell), task_runners);
4548}
static void ParseViewIdsCallback(const Dart_NativeArguments &args, bool *hasImplicitView, std::vector< int64_t > *viewIds)

◆ TEST_F() [801/876]

flutter::testing::TEST_F ( ShellTest  ,
ShellCannotAddDuplicateViewId   
)

Definition at line 4551 of file shell_unittests.cc.

4551 {
4552 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4553 Settings settings = CreateSettingsForFixture();
4555 "io.flutter.test." + GetCurrentTestName() + ".",
4556 ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
4557 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
4558 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4559 thread_host.raster_thread->GetTaskRunner(),
4560 thread_host.ui_thread->GetTaskRunner(),
4561 thread_host.io_thread->GetTaskRunner());
4562 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4563 ASSERT_TRUE(shell);
4564
4565 bool has_implicit_view;
4566 std::vector<int64_t> view_ids;
4567 fml::AutoResetWaitableEvent report_latch;
4568 AddNativeCallback("NativeReportViewIdsCallback",
4570 ParseViewIdsCallback(args, &has_implicit_view, &view_ids);
4571 report_latch.Signal();
4572 }));
4573
4574 PlatformViewNotifyCreated(shell.get());
4575 auto configuration = RunConfiguration::InferFromSettings(settings);
4576 configuration.SetEntrypoint("testReportViewIds");
4577 RunEngine(shell.get(), std::move(configuration));
4578
4579 report_latch.Wait();
4580 ASSERT_TRUE(has_implicit_view);
4581 ASSERT_EQ(view_ids.size(), 1u);
4582 ASSERT_EQ(view_ids[0], kImplicitViewId);
4583
4584 // Add view 123.
4586 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell,
4587 &add_latch] {
4588 shell->GetPlatformView()->AddView(123, ViewportMetrics{}, [&](bool added) {
4589 EXPECT_TRUE(added);
4590 add_latch.Signal();
4591 });
4592 });
4593
4594 add_latch.Wait();
4595
4596 report_latch.Wait();
4597 ASSERT_EQ(view_ids.size(), 2u);
4598 ASSERT_EQ(view_ids[0], kImplicitViewId);
4599 ASSERT_EQ(view_ids[1], 123);
4600
4601 // Attempt to add duplicate view ID 123. This should fail.
4602 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell,
4603 &add_latch] {
4604 shell->GetPlatformView()->AddView(123, ViewportMetrics{}, [&](bool added) {
4605 EXPECT_FALSE(added);
4606 add_latch.Signal();
4607 });
4608 });
4609
4610 add_latch.Wait();
4611
4612 PlatformViewNotifyDestroyed(shell.get());
4613 DestroyShell(std::move(shell), task_runners);
4614}

◆ TEST_F() [802/876]

flutter::testing::TEST_F ( ShellTest  ,
ShellCannotRemoveNonexistentId   
)

Definition at line 4617 of file shell_unittests.cc.

4617 {
4618 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4619 Settings settings = CreateSettingsForFixture();
4621 "io.flutter.test." + GetCurrentTestName() + ".",
4622 ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
4623 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
4624 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4625 thread_host.raster_thread->GetTaskRunner(),
4626 thread_host.ui_thread->GetTaskRunner(),
4627 thread_host.io_thread->GetTaskRunner());
4628 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4629 ASSERT_TRUE(shell);
4630
4631 bool has_implicit_view;
4632 std::vector<int64_t> view_ids;
4633 fml::AutoResetWaitableEvent report_latch;
4634 AddNativeCallback("NativeReportViewIdsCallback",
4636 ParseViewIdsCallback(args, &has_implicit_view, &view_ids);
4637 report_latch.Signal();
4638 }));
4639
4640 PlatformViewNotifyCreated(shell.get());
4641 auto configuration = RunConfiguration::InferFromSettings(settings);
4642 configuration.SetEntrypoint("testReportViewIds");
4643 RunEngine(shell.get(), std::move(configuration));
4644
4645 report_latch.Wait();
4646 ASSERT_TRUE(has_implicit_view);
4647 ASSERT_EQ(view_ids.size(), 1u);
4648 ASSERT_EQ(view_ids[0], kImplicitViewId);
4649
4650 // Remove view 123. This should fail as this view doesn't exist.
4651 fml::AutoResetWaitableEvent remove_latch;
4652 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(),
4653 [&shell, &remove_latch] {
4654 shell->GetPlatformView()->RemoveView(123, [&](bool removed) {
4655 EXPECT_FALSE(removed);
4656 remove_latch.Signal();
4657 });
4658 });
4659
4660 remove_latch.Wait();
4661
4662 PlatformViewNotifyDestroyed(shell.get());
4663 DestroyShell(std::move(shell), task_runners);
4664}

◆ TEST_F() [803/876]

flutter::testing::TEST_F ( ShellTest  ,
ShellFlushesPlatformStatesByMain   
)

Definition at line 4687 of file shell_unittests.cc.

4687 {
4688 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4689 Settings settings = CreateSettingsForFixture();
4691 "io.flutter.test." + GetCurrentTestName() + ".",
4692 ThreadHost::Type::kPlatform | ThreadHost::Type::kRaster |
4693 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
4694 TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(),
4695 thread_host.raster_thread->GetTaskRunner(),
4696 thread_host.ui_thread->GetTaskRunner(),
4697 thread_host.io_thread->GetTaskRunner());
4698 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4699 ASSERT_TRUE(shell);
4700
4701 PostSync(shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell] {
4702 auto platform_view = shell->GetPlatformView();
4703 // The construtor for ViewportMetrics{_, width, _, _, _} (only the 2nd
4704 // argument matters in this test).
4705 platform_view->SetViewportMetrics(0, ViewportMetrics{1, 10, 1, 0, 0});
4706 shell->GetPlatformView()->AddView(1, ViewportMetrics{1, 30, 1, 0, 0},
4707 [](bool added) { ASSERT_TRUE(added); });
4708 platform_view->SetViewportMetrics(0, ViewportMetrics{1, 20, 1, 0, 0});
4709 });
4710
4711 bool first_report = true;
4712 std::map<int64_t, int64_t> viewWidths;
4713 fml::AutoResetWaitableEvent reportLatch;
4714 auto nativeViewWidthsCallback = [&reportLatch, &viewWidths,
4715 &first_report](Dart_NativeArguments args) {
4716 EXPECT_TRUE(first_report);
4717 first_report = false;
4718 ParseViewWidthsCallback(args, &viewWidths);
4719 reportLatch.Signal();
4720 };
4721 AddNativeCallback("NativeReportViewWidthsCallback",
4722 CREATE_NATIVE_ENTRY(nativeViewWidthsCallback));
4723
4724 PlatformViewNotifyCreated(shell.get());
4725 auto configuration = RunConfiguration::InferFromSettings(settings);
4726 configuration.SetEntrypoint("testReportViewWidths");
4727 RunEngine(shell.get(), std::move(configuration));
4728
4729 reportLatch.Wait();
4730 EXPECT_EQ(viewWidths.size(), 2u);
4731 EXPECT_EQ(viewWidths[0], 20ll);
4732 EXPECT_EQ(viewWidths[1], 30ll);
4733
4734 PlatformViewNotifyDestroyed(shell.get());
4735 DestroyShell(std::move(shell), task_runners);
4736}

◆ TEST_F() [804/876]

flutter::testing::TEST_F ( ShellTest  ,
ShellStartsWithImplicitView   
)

Definition at line 4449 of file shell_unittests.cc.

4449 {
4450 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4451 Settings settings = CreateSettingsForFixture();
4452 auto task_runner = CreateNewThread();
4453 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
4454 task_runner);
4455 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4456 ASSERT_TRUE(shell);
4457
4458 bool hasImplicitView;
4459 std::vector<int64_t> viewIds;
4460 fml::AutoResetWaitableEvent reportLatch;
4461 auto nativeViewIdsCallback = [&reportLatch, &hasImplicitView,
4462 &viewIds](Dart_NativeArguments args) {
4463 ParseViewIdsCallback(args, &hasImplicitView, &viewIds);
4464 reportLatch.Signal();
4465 };
4466 AddNativeCallback("NativeReportViewIdsCallback",
4467 CREATE_NATIVE_ENTRY(nativeViewIdsCallback));
4468
4469 PlatformViewNotifyCreated(shell.get());
4470 auto configuration = RunConfiguration::InferFromSettings(settings);
4471 configuration.SetEntrypoint("testReportViewIds");
4472 RunEngine(shell.get(), std::move(configuration));
4473 reportLatch.Wait();
4474
4475 ASSERT_TRUE(hasImplicitView);
4476 ASSERT_EQ(viewIds.size(), 1u);
4477 ASSERT_EQ(viewIds[0], 0ll);
4478
4479 PlatformViewNotifyDestroyed(shell.get());
4480 DestroyShell(std::move(shell), task_runners);
4481}

◆ TEST_F() [805/876]

flutter::testing::TEST_F ( ShellTest  ,
SingleFrameCodecAccuratelyReportsSize   
)

Definition at line 19 of file single_frame_codec_unittests.cc.

19 {
20 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
21
22 auto validate_codec = [](Dart_NativeArguments args) {
23 auto handle = Dart_GetNativeArgument(args, 0);
24 intptr_t peer = 0;
27 ASSERT_FALSE(Dart_IsError(result));
28 };
29 auto finish = [message_latch](Dart_NativeArguments args) {
30 message_latch->Signal();
31 };
32
33 Settings settings = CreateSettingsForFixture();
34 TaskRunners task_runners("test", // label
35 GetCurrentTaskRunner(), // platform
36 CreateNewThread(), // raster
37 CreateNewThread(), // ui
38 CreateNewThread() // io
39 );
40
41 AddNativeCallback("ValidateCodec", CREATE_NATIVE_ENTRY(validate_codec));
42 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish));
43
44 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
45
46 ASSERT_TRUE(shell->IsSetup());
47 auto configuration = RunConfiguration::InferFromSettings(settings);
48 configuration.SetEntrypoint("createSingleFrameCodec");
49
50 shell->RunEngine(std::move(configuration), [](auto result) {
51 ASSERT_EQ(result, Engine::RunStatus::Success);
52 });
53
54 message_latch->Wait();
55 DestroyShell(std::move(shell), task_runners);
56}

◆ TEST_F() [806/876]

flutter::testing::TEST_F ( ShellTest  ,
Spawn   
)

Definition at line 3204 of file shell_unittests.cc.

3204 {
3205 auto settings = CreateSettingsForFixture();
3206 auto shell = CreateShell(settings);
3207 ASSERT_TRUE(ValidateShell(shell.get()));
3208
3209 auto configuration = RunConfiguration::InferFromSettings(settings);
3210 ASSERT_TRUE(configuration.IsValid());
3211 configuration.SetEntrypoint("fixturesAreFunctionalMain");
3212
3213 auto second_configuration = RunConfiguration::InferFromSettings(settings);
3214 ASSERT_TRUE(second_configuration.IsValid());
3215 second_configuration.SetEntrypoint("testCanLaunchSecondaryIsolate");
3216
3217 const std::string initial_route("/foo");
3218
3219 fml::AutoResetWaitableEvent main_latch;
3220 std::string last_entry_point;
3221 // Fulfill native function for the first Shell's entrypoint.
3222 AddNativeCallback(
3223 "SayHiFromFixturesAreFunctionalMain", CREATE_NATIVE_ENTRY([&](auto args) {
3224 last_entry_point = shell->GetEngine()->GetLastEntrypoint();
3225 main_latch.Signal();
3226 }));
3227 // Fulfill native function for the second Shell's entrypoint.
3228 fml::CountDownLatch second_latch(2);
3229 AddNativeCallback(
3230 // The Dart native function names aren't very consistent but this is
3231 // just the native function name of the second vm entrypoint in the
3232 // fixture.
3233 "NotifyNative",
3234 CREATE_NATIVE_ENTRY([&](auto args) { second_latch.CountDown(); }));
3235
3236 RunEngine(shell.get(), std::move(configuration));
3237 main_latch.Wait();
3238 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3239 // Check first Shell ran the first entrypoint.
3240 ASSERT_EQ("fixturesAreFunctionalMain", last_entry_point);
3241
3242 PostSync(
3243 shell->GetTaskRunners().GetPlatformTaskRunner(),
3244 [this, &spawner = shell, &second_configuration, &second_latch,
3245 initial_route]() {
3246 MockPlatformViewDelegate platform_view_delegate;
3247 auto spawn = spawner->Spawn(
3248 std::move(second_configuration), initial_route,
3249 [&platform_view_delegate](Shell& shell) {
3250 auto result = std::make_unique<MockPlatformView>(
3251 platform_view_delegate, shell.GetTaskRunners());
3252 ON_CALL(*result, CreateRenderingSurface())
3253 .WillByDefault(::testing::Invoke(
3254 [] { return std::make_unique<MockSurface>(); }));
3255 return result;
3256 },
3257 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
3258 ASSERT_NE(nullptr, spawn.get());
3259 ASSERT_TRUE(ValidateShell(spawn.get()));
3260
3261 PostSync(spawner->GetTaskRunners().GetUITaskRunner(), [&spawn, &spawner,
3262 initial_route] {
3263 // Check second shell ran the second entrypoint.
3264 ASSERT_EQ("testCanLaunchSecondaryIsolate",
3265 spawn->GetEngine()->GetLastEntrypoint());
3266 ASSERT_EQ(initial_route, spawn->GetEngine()->InitialRoute());
3267
3268 ASSERT_NE(spawner->GetEngine()
3269 ->GetRuntimeController()
3270 ->GetRootIsolateGroup(),
3271 0u);
3272 ASSERT_EQ(spawner->GetEngine()
3273 ->GetRuntimeController()
3274 ->GetRootIsolateGroup(),
3275 spawn->GetEngine()
3276 ->GetRuntimeController()
3277 ->GetRootIsolateGroup());
3278 auto spawner_snapshot_delegate = spawner->GetEngine()
3279 ->GetRuntimeController()
3280 ->GetSnapshotDelegate();
3281 auto spawn_snapshot_delegate =
3282 spawn->GetEngine()->GetRuntimeController()->GetSnapshotDelegate();
3283 PostSync(spawner->GetTaskRunners().GetRasterTaskRunner(),
3284 [spawner_snapshot_delegate, spawn_snapshot_delegate] {
3285 ASSERT_NE(spawner_snapshot_delegate.get(),
3286 spawn_snapshot_delegate.get());
3287 });
3288 });
3289 PostSync(
3290 spawner->GetTaskRunners().GetIOTaskRunner(), [&spawner, &spawn] {
3291 ASSERT_EQ(spawner->GetIOManager()->GetResourceContext().get(),
3292 spawn->GetIOManager()->GetResourceContext().get());
3293 });
3294
3295 // Before destroying the shell, wait for expectations of the spawned
3296 // isolate to be met.
3297 second_latch.Wait();
3298
3299 DestroyShell(std::move(spawn));
3300 });
3301
3302 DestroyShell(std::move(shell));
3303 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3304}

◆ TEST_F() [807/876]

flutter::testing::TEST_F ( ShellTest  ,
SpawnWithDartEntrypointArgs   
)

Definition at line 3306 of file shell_unittests.cc.

3306 {
3307 auto settings = CreateSettingsForFixture();
3308 auto shell = CreateShell(settings);
3309 ASSERT_TRUE(ValidateShell(shell.get()));
3310
3311 auto configuration = RunConfiguration::InferFromSettings(settings);
3312 ASSERT_TRUE(configuration.IsValid());
3313 configuration.SetEntrypoint("canReceiveArgumentsWhenEngineRun");
3314 const std::vector<std::string> entrypoint_args{"foo", "bar"};
3315 configuration.SetEntrypointArgs(entrypoint_args);
3316
3317 auto second_configuration = RunConfiguration::InferFromSettings(settings);
3318 ASSERT_TRUE(second_configuration.IsValid());
3319 second_configuration.SetEntrypoint("canReceiveArgumentsWhenEngineSpawn");
3320 const std::vector<std::string> second_entrypoint_args{"arg1", "arg2"};
3321 second_configuration.SetEntrypointArgs(second_entrypoint_args);
3322
3323 const std::string initial_route("/foo");
3324
3325 fml::AutoResetWaitableEvent main_latch;
3326 std::string last_entry_point;
3327 // Fulfill native function for the first Shell's entrypoint.
3328 AddNativeCallback("NotifyNativeWhenEngineRun",
3332 last_entry_point =
3333 shell->GetEngine()->GetLastEntrypoint();
3334 main_latch.Signal();
3335 })));
3336
3337 fml::AutoResetWaitableEvent second_latch;
3338 // Fulfill native function for the second Shell's entrypoint.
3339 AddNativeCallback("NotifyNativeWhenEngineSpawn",
3343 last_entry_point =
3344 shell->GetEngine()->GetLastEntrypoint();
3345 second_latch.Signal();
3346 })));
3347
3348 RunEngine(shell.get(), std::move(configuration));
3349 main_latch.Wait();
3350 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3351 // Check first Shell ran the first entrypoint.
3352 ASSERT_EQ("canReceiveArgumentsWhenEngineRun", last_entry_point);
3353
3354 PostSync(
3355 shell->GetTaskRunners().GetPlatformTaskRunner(),
3356 [this, &spawner = shell, &second_configuration, &second_latch,
3357 initial_route]() {
3358 MockPlatformViewDelegate platform_view_delegate;
3359 auto spawn = spawner->Spawn(
3360 std::move(second_configuration), initial_route,
3361 [&platform_view_delegate](Shell& shell) {
3362 auto result = std::make_unique<MockPlatformView>(
3363 platform_view_delegate, shell.GetTaskRunners());
3364 ON_CALL(*result, CreateRenderingSurface())
3365 .WillByDefault(::testing::Invoke(
3366 [] { return std::make_unique<MockSurface>(); }));
3367 return result;
3368 },
3369 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
3370 ASSERT_NE(nullptr, spawn.get());
3371 ASSERT_TRUE(ValidateShell(spawn.get()));
3372
3373 PostSync(spawner->GetTaskRunners().GetUITaskRunner(),
3374 [&spawn, &spawner, initial_route] {
3375 // Check second shell ran the second entrypoint.
3376 ASSERT_EQ("canReceiveArgumentsWhenEngineSpawn",
3377 spawn->GetEngine()->GetLastEntrypoint());
3378 ASSERT_EQ(initial_route, spawn->GetEngine()->InitialRoute());
3379
3380 ASSERT_NE(spawner->GetEngine()
3381 ->GetRuntimeController()
3382 ->GetRootIsolateGroup(),
3383 0u);
3384 ASSERT_EQ(spawner->GetEngine()
3385 ->GetRuntimeController()
3386 ->GetRootIsolateGroup(),
3387 spawn->GetEngine()
3388 ->GetRuntimeController()
3389 ->GetRootIsolateGroup());
3390 });
3391
3392 PostSync(
3393 spawner->GetTaskRunners().GetIOTaskRunner(), [&spawner, &spawn] {
3394 ASSERT_EQ(spawner->GetIOManager()->GetResourceContext().get(),
3395 spawn->GetIOManager()->GetResourceContext().get());
3396 });
3397
3398 // Before destroying the shell, wait for expectations of the spawned
3399 // isolate to be met.
3400 second_latch.Wait();
3401
3402 DestroyShell(std::move(spawn));
3403 });
3404
3405 DestroyShell(std::move(shell));
3406 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3407}

◆ TEST_F() [808/876]

flutter::testing::TEST_F ( ShellTest  ,
SpawnWorksWithOnError   
)

Definition at line 3975 of file shell_unittests.cc.

3975 {
3976 auto settings = CreateSettingsForFixture();
3977 auto shell = CreateShell(settings);
3978 ASSERT_TRUE(ValidateShell(shell.get()));
3979
3980 auto configuration = RunConfiguration::InferFromSettings(settings);
3981 ASSERT_TRUE(configuration.IsValid());
3982 configuration.SetEntrypoint("onErrorA");
3983
3984 auto second_configuration = RunConfiguration::InferFromSettings(settings);
3985 ASSERT_TRUE(second_configuration.IsValid());
3986 second_configuration.SetEntrypoint("onErrorB");
3987
3988 fml::CountDownLatch latch(2);
3989
3990 AddNativeCallback(
3991 "NotifyErrorA", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
3992 auto string_handle = Dart_GetNativeArgument(args, 0);
3993 const char* c_str;
3994 Dart_StringToCString(string_handle, &c_str);
3995 EXPECT_STREQ(c_str, "Exception: I should be coming from A");
3996 latch.CountDown();
3997 }));
3998
3999 AddNativeCallback(
4000 "NotifyErrorB", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
4001 auto string_handle = Dart_GetNativeArgument(args, 0);
4002 const char* c_str;
4003 Dart_StringToCString(string_handle, &c_str);
4004 EXPECT_STREQ(c_str, "Exception: I should be coming from B");
4005 latch.CountDown();
4006 }));
4007
4008 RunEngine(shell.get(), std::move(configuration));
4009
4010 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
4011
4012 PostSync(
4013 shell->GetTaskRunners().GetPlatformTaskRunner(),
4014 [this, &spawner = shell, &second_configuration, &latch]() {
4015 ::testing::NiceMock<MockPlatformViewDelegate> platform_view_delegate;
4016 auto spawn = spawner->Spawn(
4017 std::move(second_configuration), "",
4018 [&platform_view_delegate](Shell& shell) {
4019 auto result =
4020 std::make_unique<::testing::NiceMock<MockPlatformView>>(
4021 platform_view_delegate, shell.GetTaskRunners());
4022 ON_CALL(*result, CreateRenderingSurface())
4023 .WillByDefault(::testing::Invoke([] {
4024 return std::make_unique<::testing::NiceMock<MockSurface>>();
4025 }));
4026 return result;
4027 },
4028 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
4029 ASSERT_NE(nullptr, spawn.get());
4030 ASSERT_TRUE(ValidateShell(spawn.get()));
4031
4032 // Before destroying the shell, wait for expectations of the spawned
4033 // isolate to be met.
4034 latch.Wait();
4035
4036 DestroyShell(std::move(spawn));
4037 });
4038
4039 DestroyShell(std::move(shell));
4040 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4041}

◆ TEST_F() [809/876]

flutter::testing::TEST_F ( ShellTest  ,
TextureFrameMarkedAvailableAndUnregister   
)

Definition at line 2001 of file shell_unittests.cc.

2001 {
2002 Settings settings = CreateSettingsForFixture();
2003 auto configuration = RunConfiguration::InferFromSettings(settings);
2004 auto task_runner = CreateNewThread();
2005 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
2006 task_runner);
2007 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
2008
2009 ASSERT_TRUE(ValidateShell(shell.get()));
2010 PlatformViewNotifyCreated(shell.get());
2011
2012 RunEngine(shell.get(), std::move(configuration));
2013
2014 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
2015 std::make_shared<fml::AutoResetWaitableEvent>();
2016
2017 std::shared_ptr<MockTexture> mockTexture =
2018 std::make_shared<MockTexture>(0, latch);
2019
2021 shell->GetTaskRunners().GetRasterTaskRunner(), [&]() {
2022 shell->GetPlatformView()->RegisterTexture(mockTexture);
2023 shell->GetPlatformView()->MarkTextureFrameAvailable(0);
2024 });
2025 latch->Wait();
2026
2027 EXPECT_EQ(mockTexture->frames_available(), 1);
2028
2030 shell->GetTaskRunners().GetRasterTaskRunner(),
2031 [&]() { shell->GetPlatformView()->UnregisterTexture(0); });
2032 latch->Wait();
2033
2034 EXPECT_EQ(mockTexture->unregistered(), true);
2035 DestroyShell(std::move(shell), task_runners);
2036}

◆ TEST_F() [810/876]

flutter::testing::TEST_F ( ShellTest  ,
UIWorkAfterOnPlatformViewDestroyed   
)

Definition at line 3890 of file shell_unittests.cc.

3890 {
3891 auto settings = CreateSettingsForFixture();
3892 auto shell = CreateShell(settings);
3893 auto configuration = RunConfiguration::InferFromSettings(settings);
3894 configuration.SetEntrypoint("drawFrames");
3895
3897 fml::AutoResetWaitableEvent notify_native_latch;
3898 AddNativeCallback("NotifyNative", CREATE_NATIVE_ENTRY([&](auto args) {
3899 notify_native_latch.Signal();
3900 latch.Wait();
3901 }));
3902
3903 RunEngine(shell.get(), std::move(configuration));
3904 // Wait to make sure we get called back from Dart and thus have latched
3905 // the UI thread before we create/destroy the platform view.
3906 notify_native_latch.Wait();
3907
3908 ShellTest::PlatformViewNotifyCreated(shell.get());
3909
3910 fml::AutoResetWaitableEvent destroy_latch;
3912 shell->GetTaskRunners().GetPlatformTaskRunner(),
3913 [&shell, &destroy_latch]() {
3914 shell->GetPlatformView()->NotifyDestroyed();
3915 destroy_latch.Signal();
3916 });
3917
3918 destroy_latch.Wait();
3919
3920 // Unlatch the UI thread and let it send us a scene to render.
3921 latch.Signal();
3922
3923 // Flush the UI task runner to make sure we process the render/scheduleFrame
3924 // request.
3925 fml::AutoResetWaitableEvent ui_flush_latch;
3927 shell->GetTaskRunners().GetUITaskRunner(),
3928 [&ui_flush_latch]() { ui_flush_latch.Signal(); });
3929 ui_flush_latch.Wait();
3930 DestroyShell(std::move(shell));
3931}

◆ TEST_F() [811/876]

flutter::testing::TEST_F ( ShellTest  ,
UpdateAssetResolverByTypeAppends   
)

Definition at line 3603 of file shell_unittests.cc.

3603 {
3604 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3605 Settings settings = CreateSettingsForFixture();
3606
3608 auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
3609 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
3610 task_runner);
3611 auto shell = CreateShell(settings, task_runners);
3612 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3613 ASSERT_TRUE(ValidateShell(shell.get()));
3614
3615 auto configuration = RunConfiguration::InferFromSettings(settings);
3616 configuration.SetEntrypoint("emptyMain");
3617 auto asset_manager = configuration.GetAssetManager();
3618
3619 shell->RunEngine(std::move(configuration), [&](auto result) {
3620 ASSERT_EQ(result, Engine::RunStatus::Success);
3621 });
3622
3623 auto platform_view =
3624 std::make_unique<PlatformView>(*shell.get(), task_runners);
3625
3626 auto updated_resolver = std::make_unique<TestAssetResolver>(
3627 false, AssetResolver::AssetResolverType::kApkAssetProvider);
3628 ASSERT_FALSE(updated_resolver->IsValidAfterAssetManagerChange());
3629 platform_view->UpdateAssetResolverByType(
3630 std::move(updated_resolver),
3631 AssetResolver::AssetResolverType::kApkAssetProvider);
3632
3633 auto resolvers = asset_manager->TakeResolvers();
3634 ASSERT_EQ(resolvers.size(), 2ull);
3635 ASSERT_TRUE(resolvers[0]->IsValidAfterAssetManagerChange());
3636
3637 ASSERT_FALSE(resolvers[1]->IsValidAfterAssetManagerChange());
3638
3639 DestroyShell(std::move(shell), task_runners);
3640 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3641}

◆ TEST_F() [812/876]

flutter::testing::TEST_F ( ShellTest  ,
UpdateAssetResolverByTypeDoesNotReplaceMismatchType   
)

Definition at line 3681 of file shell_unittests.cc.

3681 {
3682 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3683 Settings settings = CreateSettingsForFixture();
3684
3686 auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
3687 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
3688 task_runner);
3689 auto shell = CreateShell(settings, task_runners);
3690 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3691 ASSERT_TRUE(ValidateShell(shell.get()));
3692
3693 auto configuration = RunConfiguration::InferFromSettings(settings);
3694 configuration.SetEntrypoint("emptyMain");
3695 auto asset_manager = configuration.GetAssetManager();
3696
3697 shell->RunEngine(std::move(configuration), [&](auto result) {
3698 ASSERT_EQ(result, Engine::RunStatus::Success);
3699 });
3700
3701 auto platform_view =
3702 std::make_unique<PlatformView>(*shell.get(), task_runners);
3703
3704 auto old_resolver = std::make_unique<TestAssetResolver>(
3705 true, AssetResolver::AssetResolverType::kAssetManager);
3706 ASSERT_TRUE(old_resolver->IsValid());
3707 asset_manager->PushBack(std::move(old_resolver));
3708
3709 auto updated_resolver = std::make_unique<TestAssetResolver>(
3710 false, AssetResolver::AssetResolverType::kApkAssetProvider);
3711 ASSERT_FALSE(updated_resolver->IsValidAfterAssetManagerChange());
3712 platform_view->UpdateAssetResolverByType(
3713 std::move(updated_resolver),
3714 AssetResolver::AssetResolverType::kApkAssetProvider);
3715
3716 auto resolvers = asset_manager->TakeResolvers();
3717 ASSERT_EQ(resolvers.size(), 3ull);
3718 ASSERT_TRUE(resolvers[0]->IsValidAfterAssetManagerChange());
3719
3720 ASSERT_TRUE(resolvers[1]->IsValidAfterAssetManagerChange());
3721
3722 ASSERT_FALSE(resolvers[2]->IsValidAfterAssetManagerChange());
3723
3724 DestroyShell(std::move(shell), task_runners);
3725 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3726}

◆ TEST_F() [813/876]

flutter::testing::TEST_F ( ShellTest  ,
UpdateAssetResolverByTypeNull   
)

Definition at line 3643 of file shell_unittests.cc.

3643 {
3644 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3645 Settings settings = CreateSettingsForFixture();
3647 "io.flutter.test." + GetCurrentTestName() + ".",
3648 ThreadHost::Type::kPlatform));
3649 auto task_runner = thread_host.platform_thread->GetTaskRunner();
3650 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
3651 task_runner);
3652 auto shell = CreateShell(settings, task_runners);
3653 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3654 ASSERT_TRUE(ValidateShell(shell.get()));
3655
3656 auto configuration = RunConfiguration::InferFromSettings(settings);
3657 configuration.SetEntrypoint("emptyMain");
3658 auto asset_manager = configuration.GetAssetManager();
3659 RunEngine(shell.get(), std::move(configuration));
3660
3661 auto platform_view =
3662 std::make_unique<PlatformView>(*shell.get(), task_runners);
3663
3664 auto old_resolver = std::make_unique<TestAssetResolver>(
3665 true, AssetResolver::AssetResolverType::kApkAssetProvider);
3666 ASSERT_TRUE(old_resolver->IsValid());
3667 asset_manager->PushBack(std::move(old_resolver));
3668
3669 platform_view->UpdateAssetResolverByType(
3670 nullptr, AssetResolver::AssetResolverType::kApkAssetProvider);
3671
3672 auto resolvers = asset_manager->TakeResolvers();
3673 ASSERT_EQ(resolvers.size(), 2ull);
3674 ASSERT_TRUE(resolvers[0]->IsValidAfterAssetManagerChange());
3675 ASSERT_TRUE(resolvers[1]->IsValidAfterAssetManagerChange());
3676
3677 DestroyShell(std::move(shell), task_runners);
3678 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3679}

◆ TEST_F() [814/876]

flutter::testing::TEST_F ( ShellTest  ,
UpdateAssetResolverByTypeReplaces   
)

Definition at line 3558 of file shell_unittests.cc.

3558 {
3559 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3560 Settings settings = CreateSettingsForFixture();
3561
3563 auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
3564 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
3565 task_runner);
3566 auto shell = CreateShell(settings, task_runners);
3567 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3568 ASSERT_TRUE(ValidateShell(shell.get()));
3569
3570 auto configuration = RunConfiguration::InferFromSettings(settings);
3571 configuration.SetEntrypoint("emptyMain");
3572 auto asset_manager = configuration.GetAssetManager();
3573
3574 shell->RunEngine(std::move(configuration), [&](auto result) {
3575 ASSERT_EQ(result, Engine::RunStatus::Success);
3576 });
3577
3578 auto platform_view =
3579 std::make_unique<PlatformView>(*shell.get(), task_runners);
3580
3581 auto old_resolver = std::make_unique<TestAssetResolver>(
3582 true, AssetResolver::AssetResolverType::kApkAssetProvider);
3583 ASSERT_TRUE(old_resolver->IsValid());
3584 asset_manager->PushBack(std::move(old_resolver));
3585
3586 auto updated_resolver = std::make_unique<TestAssetResolver>(
3587 false, AssetResolver::AssetResolverType::kApkAssetProvider);
3588 ASSERT_FALSE(updated_resolver->IsValidAfterAssetManagerChange());
3589 platform_view->UpdateAssetResolverByType(
3590 std::move(updated_resolver),
3591 AssetResolver::AssetResolverType::kApkAssetProvider);
3592
3593 auto resolvers = asset_manager->TakeResolvers();
3594 ASSERT_EQ(resolvers.size(), 2ull);
3595 ASSERT_TRUE(resolvers[0]->IsValidAfterAssetManagerChange());
3596
3597 ASSERT_FALSE(resolvers[1]->IsValidAfterAssetManagerChange());
3598
3599 DestroyShell(std::move(shell), task_runners);
3600 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3601}

◆ TEST_F() [815/876]

flutter::testing::TEST_F ( ShellTest  ,
UserTagSetOnStartup   
)

Definition at line 3800 of file shell_unittests.cc.

3800 {
3801 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3802 // Make sure the shell launch does not kick off the creation of the VM
3803 // instance by already creating one upfront.
3804 auto vm_settings = CreateSettingsForFixture();
3805 auto vm_ref = DartVMRef::Create(vm_settings);
3806 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3807
3808 auto settings = vm_settings;
3809 fml::AutoResetWaitableEvent isolate_create_latch;
3810
3811 // ensure that "AppStartUpTag" is set during isolate creation.
3812 settings.root_isolate_create_callback = [&](const DartIsolate& isolate) {
3813 Dart_Handle current_tag = Dart_GetCurrentUserTag();
3814 Dart_Handle startup_tag = Dart_NewUserTag("AppStartUp");
3815 EXPECT_TRUE(Dart_IdentityEquals(current_tag, startup_tag));
3816
3817 isolate_create_latch.Signal();
3818 };
3819
3820 auto shell = CreateShell(settings);
3821 ASSERT_TRUE(ValidateShell(shell.get()));
3822
3823 auto configuration = RunConfiguration::InferFromSettings(settings);
3824 ASSERT_TRUE(configuration.IsValid());
3825
3826 RunEngine(shell.get(), std::move(configuration));
3827 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
3828
3829 DestroyShell(std::move(shell));
3830 isolate_create_latch.Wait();
3831}
Represents an instance of a live isolate. An isolate is a separate Dart execution context....
DART_EXPORT bool Dart_IdentityEquals(Dart_Handle obj1, Dart_Handle obj2)
DART_EXPORT Dart_Handle Dart_GetCurrentUserTag()
DART_EXPORT Dart_Handle Dart_NewUserTag(const char *label)

◆ TEST_F() [816/876]

flutter::testing::TEST_F ( ShellTest  ,
UsesPlatformMessageHandler   
)

Definition at line 3933 of file shell_unittests.cc.

3933 {
3934 TaskRunners task_runners = GetTaskRunnersForFixture();
3935 auto settings = CreateSettingsForFixture();
3936 MockPlatformViewDelegate platform_view_delegate;
3937 auto platform_message_handler =
3938 std::make_shared<MockPlatformMessageHandler>();
3939 int message_id = 1;
3940 EXPECT_CALL(*platform_message_handler, HandlePlatformMessage(_));
3941 EXPECT_CALL(*platform_message_handler,
3942 InvokePlatformMessageEmptyResponseCallback(message_id));
3943 Shell::CreateCallback<PlatformView> platform_view_create_callback =
3944 [&platform_view_delegate, task_runners,
3945 platform_message_handler](flutter::Shell& shell) {
3946 auto result = std::make_unique<MockPlatformView>(platform_view_delegate,
3947 task_runners);
3948 EXPECT_CALL(*result, GetPlatformMessageHandler())
3949 .WillOnce(Return(platform_message_handler));
3950 return result;
3951 };
3952 auto shell = CreateShell({
3953 .settings = settings,
3954 .task_runners = task_runners,
3955 .platform_view_create_callback = platform_view_create_callback,
3956 });
3957
3958 EXPECT_EQ(platform_message_handler, shell->GetPlatformMessageHandler());
3959 PostSync(task_runners.GetUITaskRunner(), [&shell]() {
3960 size_t data_size = 4;
3961 fml::MallocMapping bytes =
3962 fml::MallocMapping(static_cast<uint8_t*>(malloc(data_size)), data_size);
3963 fml::RefPtr<MockPlatformMessageResponse> response =
3964 MockPlatformMessageResponse::Create();
3965 auto message = std::make_unique<PlatformMessage>(
3966 /*channel=*/"foo", /*data=*/std::move(bytes), /*response=*/response);
3967 (static_cast<Engine::Delegate*>(shell.get()))
3968 ->OnEngineHandlePlatformMessage(std::move(message));
3969 });
3970 shell->GetPlatformMessageHandler()
3971 ->InvokePlatformMessageEmptyResponseCallback(message_id);
3972 DestroyShell(std::move(shell));
3973}

◆ TEST_F() [817/876]

flutter::testing::TEST_F ( ShellTest  ,
VSyncTargetTime   
)

Definition at line 55 of file animator_unittests.cc.

55 {
56 // Add native callbacks to listen for window.onBeginFrame
57 int64_t target_time;
58 fml::AutoResetWaitableEvent on_target_time_latch;
59 auto nativeOnBeginFrame = [&on_target_time_latch,
60 &target_time](Dart_NativeArguments args) {
61 Dart_Handle exception = nullptr;
62 target_time =
64 on_target_time_latch.Signal();
65 };
66 AddNativeCallback("NativeOnBeginFrame",
67 CREATE_NATIVE_ENTRY(nativeOnBeginFrame));
68
69 // Create all te prerequisites for a shell.
70 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
71 auto settings = CreateSettingsForFixture();
72
73 std::unique_ptr<Shell> shell;
74
75 TaskRunners task_runners = GetTaskRunnersForFixture();
76 // this is not used as we are not using simulated events.
77 const auto vsync_clock = std::make_shared<ShellTestVsyncClock>();
78 CreateVsyncWaiter create_vsync_waiter = [&]() {
79 return static_cast<std::unique_ptr<VsyncWaiter>>(
80 std::make_unique<ConstantFiringVsyncWaiter>(task_runners));
81 };
82
83 // create a shell with a constant firing vsync waiter.
84 auto platform_task = std::async(std::launch::async, [&]() {
86
87 shell = Shell::Create(
88 flutter::PlatformData(), task_runners, settings,
89 [vsync_clock, &create_vsync_waiter](Shell& shell) {
90 return ShellTestPlatformView::Create(
91 shell, shell.GetTaskRunners(), vsync_clock, create_vsync_waiter,
92 ShellTestPlatformView::BackendType::kDefaultBackend, nullptr,
93 shell.GetIsGpuDisabledSyncSwitch());
94 },
95 [](Shell& shell) { return std::make_unique<Rasterizer>(shell); });
96 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
97
98 auto configuration = RunConfiguration::InferFromSettings(settings);
99 ASSERT_TRUE(configuration.IsValid());
100 configuration.SetEntrypoint("onBeginFrameMain");
101
102 RunEngine(shell.get(), std::move(configuration));
103 });
104 platform_task.wait();
105 on_target_time_latch.Wait();
106 const auto vsync_waiter_target_time =
107 ConstantFiringVsyncWaiter::kFrameTargetTime;
108 ASSERT_EQ(vsync_waiter_target_time.ToEpochDelta().ToMicroseconds(),
109 target_time);
110
111 // validate that the latest target time has also been updated.
112 ASSERT_EQ(GetLatestFrameTargetTime(shell.get()), vsync_waiter_target_time);
113
114 // teardown.
115 DestroyShell(std::move(shell), task_runners);
116 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
117}

◆ TEST_F() [818/876]

flutter::testing::TEST_F ( ShellTest  ,
WaitForFirstFrame   
)

Definition at line 1559 of file shell_unittests.cc.

1559 {
1560 auto settings = CreateSettingsForFixture();
1561 std::unique_ptr<Shell> shell = CreateShell(settings);
1562
1563 // Create the surface needed by rasterizer
1564 PlatformViewNotifyCreated(shell.get());
1565
1566 auto configuration = RunConfiguration::InferFromSettings(settings);
1567 configuration.SetEntrypoint("emptyMain");
1568
1569 RunEngine(shell.get(), std::move(configuration));
1570 PumpOneFrame(shell.get());
1571 fml::Status result = shell->WaitForFirstFrame(fml::TimeDelta::Max());
1572 ASSERT_TRUE(result.ok());
1573
1574 DestroyShell(std::move(shell));
1575}

◆ TEST_F() [819/876]

flutter::testing::TEST_F ( ShellTest  ,
WaitForFirstFrameInlined   
)

Makes sure that WaitForFirstFrame works if we rendered a frame with the single-thread setup.

Definition at line 1639 of file shell_unittests.cc.

1639 {
1640 Settings settings = CreateSettingsForFixture();
1641 auto task_runner = CreateNewThread();
1642 TaskRunners task_runners("test", task_runner, task_runner, task_runner,
1643 task_runner);
1644 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
1645
1646 // Create the surface needed by rasterizer
1647 PlatformViewNotifyCreated(shell.get());
1648
1649 auto configuration = RunConfiguration::InferFromSettings(settings);
1650 configuration.SetEntrypoint("emptyMain");
1651
1652 RunEngine(shell.get(), std::move(configuration));
1653 PumpOneFrame(shell.get());
1655 task_runner->PostTask([&shell, &event] {
1656 fml::Status result = shell->WaitForFirstFrame(fml::TimeDelta::Max());
1657 ASSERT_FALSE(result.ok());
1659 event.Signal();
1660 });
1661 ASSERT_FALSE(event.WaitWithTimeout(fml::TimeDelta::Max()));
1662
1663 DestroyShell(std::move(shell), task_runners);
1664}

◆ TEST_F() [820/876]

flutter::testing::TEST_F ( ShellTest  ,
WaitForFirstFrameMultiple   
)

Definition at line 1615 of file shell_unittests.cc.

1615 {
1616 auto settings = CreateSettingsForFixture();
1617 std::unique_ptr<Shell> shell = CreateShell(settings);
1618
1619 // Create the surface needed by rasterizer
1620 PlatformViewNotifyCreated(shell.get());
1621
1622 auto configuration = RunConfiguration::InferFromSettings(settings);
1623 configuration.SetEntrypoint("emptyMain");
1624
1625 RunEngine(shell.get(), std::move(configuration));
1626 PumpOneFrame(shell.get());
1627 fml::Status result = shell->WaitForFirstFrame(fml::TimeDelta::Max());
1628 ASSERT_TRUE(result.ok());
1629 for (int i = 0; i < 100; ++i) {
1630 result = shell->WaitForFirstFrame(fml::TimeDelta::Zero());
1631 ASSERT_TRUE(result.ok());
1632 }
1633
1634 DestroyShell(std::move(shell));
1635}
static constexpr TimeDelta Zero()
Definition time_delta.h:33

◆ TEST_F() [821/876]

flutter::testing::TEST_F ( ShellTest  ,
WaitForFirstFrameTimeout   
)

Definition at line 1597 of file shell_unittests.cc.

1597 {
1598 auto settings = CreateSettingsForFixture();
1599 std::unique_ptr<Shell> shell = CreateShell(settings);
1600
1601 // Create the surface needed by rasterizer
1602 PlatformViewNotifyCreated(shell.get());
1603
1604 auto configuration = RunConfiguration::InferFromSettings(settings);
1605 configuration.SetEntrypoint("emptyMain");
1606
1607 RunEngine(shell.get(), std::move(configuration));
1608 fml::Status result = shell->WaitForFirstFrame(fml::TimeDelta::Zero());
1609 ASSERT_FALSE(result.ok());
1610 ASSERT_EQ(result.code(), fml::StatusCode::kDeadlineExceeded);
1611
1612 DestroyShell(std::move(shell));
1613}

◆ TEST_F() [822/876]

flutter::testing::TEST_F ( ShellTest  ,
WaitForFirstFrameZeroSizeFrame   
)

Definition at line 1577 of file shell_unittests.cc.

1577 {
1578 auto settings = CreateSettingsForFixture();
1579 std::unique_ptr<Shell> shell = CreateShell(settings);
1580
1581 // Create the surface needed by rasterizer
1582 PlatformViewNotifyCreated(shell.get());
1583
1584 auto configuration = RunConfiguration::InferFromSettings(settings);
1585 configuration.SetEntrypoint("emptyMain");
1586
1587 RunEngine(shell.get(), std::move(configuration));
1588 PumpOneFrame(shell.get(), ViewContent::DummyView({1.0, 0.0, 0.0, 22, 0}));
1589 fml::Status result = shell->WaitForFirstFrame(fml::TimeDelta::Zero());
1590 EXPECT_FALSE(result.ok());
1591 EXPECT_EQ(result.message(), "timeout");
1592 EXPECT_EQ(result.code(), fml::StatusCode::kDeadlineExceeded);
1593
1594 DestroyShell(std::move(shell));
1595}

◆ TEST_F() [823/876]

flutter::testing::TEST_F ( ShellTest  ,
WillLogWarningWhenImpellerIsOptedOut   
)

Definition at line 4933 of file shell_unittests.cc.

4933 {
4934#if !IMPELLER_SUPPORTS_RENDERING
4935 GTEST_SKIP() << "This platform doesn't support Impeller.";
4936#endif
4937 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
4938 Settings settings = CreateSettingsForFixture();
4939 settings.enable_impeller = false;
4940 settings.warn_on_impeller_opt_out = true;
4941 // Log captures are thread specific. Just put the shell in single threaded
4942 // configuration.
4943 const auto& runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
4944 TaskRunners task_runners("test", runner, runner, runner, runner);
4945 std::ostringstream stream;
4947 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
4948 ASSERT_TRUE(stream.str().find(
4949 "[Action Required] The application opted out of Impeller") !=
4950 std::string::npos);
4951 ASSERT_TRUE(shell);
4952 DestroyShell(std::move(shell), task_runners);
4953}
static void CaptureNextLog(std::ostringstream *stream)
Definition logging.cc:129

◆ TEST_F() [824/876]

flutter::testing::TEST_F ( SkiaGpuObjectTest  ,
ObjectDestructor   
)

Definition at line 100 of file skia_gpu_object_unittests.cc.

100 {
101 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
102 std::make_shared<fml::AutoResetWaitableEvent>();
103 fml::TaskQueueId dtor_task_queue_id(0);
104 auto object = sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id);
105 {
106 SkiaGPUObject<TestSkObject> sk_object(std::move(object), unref_queue());
107 // Verify that the default SkiaGPUObject dtor queues and unref.
108 }
109
110 latch->Wait();
111 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
112}

◆ TEST_F() [825/876]

flutter::testing::TEST_F ( SkiaGpuObjectTest  ,
ObjectReset   
)

Definition at line 114 of file skia_gpu_object_unittests.cc.

114 {
115 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
116 std::make_shared<fml::AutoResetWaitableEvent>();
117 fml::TaskQueueId dtor_task_queue_id(0);
119 sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id), unref_queue());
120 // Verify that explicitly resetting the GPU object queues and unref.
121 sk_object.reset();
122 ASSERT_EQ(sk_object.skia_object(), nullptr);
123 latch->Wait();
124 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
125}

◆ TEST_F() [826/876]

flutter::testing::TEST_F ( SkiaGpuObjectTest  ,
ObjectResetTwice   
)

Definition at line 127 of file skia_gpu_object_unittests.cc.

127 {
128 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
129 std::make_shared<fml::AutoResetWaitableEvent>();
130 fml::TaskQueueId dtor_task_queue_id(0);
132 sk_make_sp<TestSkObject>(latch, &dtor_task_queue_id), unref_queue());
133
134 sk_object.reset();
135 ASSERT_EQ(sk_object.skia_object(), nullptr);
136 sk_object.reset();
137 ASSERT_EQ(sk_object.skia_object(), nullptr);
138
139 latch->Wait();
140 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
141}

◆ TEST_F() [827/876]

flutter::testing::TEST_F ( SkiaGpuObjectTest  ,
QueueSimple   
)

Definition at line 89 of file skia_gpu_object_unittests.cc.

89 {
90 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
91 std::make_shared<fml::AutoResetWaitableEvent>();
92 fml::TaskQueueId dtor_task_queue_id(0);
93 SkRefCnt* ref_object = new TestSkObject(latch, &dtor_task_queue_id);
94
95 unref_queue()->Unref(ref_object);
96 latch->Wait();
97 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
98}

◆ TEST_F() [828/876]

flutter::testing::TEST_F ( SkiaGpuObjectTest  ,
UnrefResourceContextInTaskRunnerThread   
)

Definition at line 143 of file skia_gpu_object_unittests.cc.

143 {
144 std::shared_ptr<fml::AutoResetWaitableEvent> latch =
145 std::make_shared<fml::AutoResetWaitableEvent>();
147 fml::TaskQueueId dtor_task_queue_id(0);
148 unref_task_runner()->PostTask([&]() {
149 auto resource_context =
150 sk_make_sp<TestResourceContext>(latch, &dtor_task_queue_id);
151 unref_queue = fml::MakeRefCounted<UnrefQueue<TestResourceContext>>(
152 unref_task_runner(), fml::TimeDelta::FromSeconds(0),
153 std::move(resource_context));
154 latch->Signal();
155 });
156 latch->Wait();
157
158 // Delete the unref queue, it will schedule a task to unref the resource
159 // context in the task runner's thread.
160 unref_queue = nullptr;
161 latch->Wait();
162 // Verify that the resource context was destroyed in the task runner's thread.
163 ASSERT_EQ(dtor_task_queue_id, unref_task_runner()->GetTaskQueueId());
164}
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition time_delta.h:49

◆ TEST_F() [829/876]

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

Definition at line 207 of file text_input_plugin_unittest.cc.

207 {
208 UseHeadlessEngine();
209
210 TestBinaryMessenger messenger([](const std::string& channel,
211 const uint8_t* message, size_t message_size,
212 BinaryReply reply) {});
213
214 std::string reply;
215 BinaryReply reply_handler = [&reply](const uint8_t* reply_bytes,
216 size_t reply_size) {
217 reply = std::string(reinterpret_cast<const char*>(reply_bytes), reply_size);
218 };
219
220 TextInputPlugin handler(&messenger, engine());
221
222 auto& codec = JsonMethodCodec::GetInstance();
223 auto message = codec.EncodeMethodCall({"TextInput.clearClient", nullptr});
224 messenger.SimulateEngineMessage(kChannelName, message->data(),
225 message->size(), reply_handler);
226
227 EXPECT_EQ(reply,
228 "[\"Internal Consistency Error\",\"Text input is not available in "
229 "Windows headless mode\",null]");
230}
static NSString *const kChannelName

◆ TEST_F() [830/876]

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

Definition at line 188 of file text_input_plugin_unittest.cc.

188 {
189 UseEngineWithView();
190
191 TestBinaryMessenger messenger([](const std::string& channel,
192 const uint8_t* message, size_t message_size,
193 BinaryReply reply) {});
194 BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
195
196 TextInputPlugin handler(&messenger, engine());
197
198 EXPECT_CALL(*view(), OnResetImeComposing());
199
200 auto& codec = JsonMethodCodec::GetInstance();
201 auto message = codec.EncodeMethodCall({"TextInput.clearClient", nullptr});
202 messenger.SimulateEngineMessage(kChannelName, message->data(),
203 message->size(), reply_handler);
204}

◆ TEST_F() [831/876]

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

Definition at line 453 of file text_input_plugin_unittest.cc.

453 {
454 UseEngineWithView();
455
456 int selection_base = -1;
457 TestBinaryMessenger messenger([&](const std::string& channel,
458 const uint8_t* message, size_t size,
459 BinaryReply reply) {
460 auto method = JsonMethodCodec::GetInstance().DecodeMethodCall(
461 std::vector<uint8_t>(message, message + size));
462 if (method->method_name() == kUpdateEditingStateMethod) {
463 const auto& args = *method->arguments();
464 const auto& editing_state = args[1];
465 auto base = editing_state.FindMember(kSelectionBaseKey);
466 auto extent = editing_state.FindMember(kSelectionExtentKey);
467 ASSERT_NE(base, editing_state.MemberEnd());
468 ASSERT_TRUE(base->value.IsInt());
469 ASSERT_NE(extent, editing_state.MemberEnd());
470 ASSERT_TRUE(extent->value.IsInt());
471 selection_base = base->value.GetInt();
472 EXPECT_EQ(extent->value.GetInt(), selection_base);
473 }
474 });
475
476 TextInputPlugin plugin(&messenger, engine());
477
478 auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
479 auto& allocator = args->GetAllocator();
480 args->PushBack(123, allocator); // client_id
481 rapidjson::Value client_config(rapidjson::kObjectType);
482 args->PushBack(client_config, allocator);
483 auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall(
484 MethodCall<rapidjson::Document>(kSetClientMethod, std::move(args)));
485 EXPECT_TRUE(messenger.SimulateEngineMessage(
486 kChannelName, encoded->data(), encoded->size(),
487 [](const uint8_t* reply, size_t reply_size) {}));
488
489 plugin.ComposeBeginHook();
490 EXPECT_EQ(selection_base, 0);
491 plugin.ComposeChangeHook(u"abc", 3);
492 EXPECT_EQ(selection_base, 3);
493
494 plugin.ComposeCommitHook();
495 plugin.ComposeEndHook();
496 EXPECT_EQ(selection_base, 3);
497
498 plugin.ComposeBeginHook();
499 plugin.ComposeChangeHook(u"1", 1);
500 EXPECT_EQ(selection_base, 4);
501
502 plugin.ComposeChangeHook(u"12", 2);
503 EXPECT_EQ(selection_base, 5);
504
505 plugin.ComposeChangeHook(u"12", 1);
506 EXPECT_EQ(selection_base, 4);
507
508 plugin.ComposeChangeHook(u"12", 2);
509 EXPECT_EQ(selection_base, 5);
510}
static constexpr char kUpdateEditingStateMethod[]
static NSString *const kSetClientMethod
static NSString *const kSelectionBaseKey
static NSString *const kSelectionExtentKey

◆ TEST_F() [832/876]

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

Definition at line 583 of file text_input_plugin_unittest.cc.

583 {
584 UseHeadlessEngine();
585
586 TestBinaryMessenger messenger([](const std::string& channel,
587 const uint8_t* message, size_t message_size,
588 BinaryReply reply) {});
589
590 std::string reply;
591 BinaryReply reply_handler = [&reply](const uint8_t* reply_bytes,
592 size_t reply_size) {
593 reply = std::string(reinterpret_cast<const char*>(reply_bytes), reply_size);
594 };
595
596 TextInputPlugin handler(&messenger, engine());
597
598 auto& codec = JsonMethodCodec::GetInstance();
599
600 auto arguments =
601 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
602 auto& allocator = arguments->GetAllocator();
603
604 arguments->AddMember("x", 0, allocator);
605 arguments->AddMember("y", 0, allocator);
606 arguments->AddMember("width", 0, allocator);
607 arguments->AddMember("height", 0, allocator);
608
609 auto message = codec.EncodeMethodCall(
610 {"TextInput.setMarkedTextRect", std::move(arguments)});
611 messenger.SimulateEngineMessage(kChannelName, message->data(),
612 message->size(), reply_handler);
613
614 EXPECT_EQ(reply,
615 "[\"Internal Consistency Error\",\"Text input is not available in "
616 "Windows headless mode\",null]");
617}

◆ TEST_F() [833/876]

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

Definition at line 395 of file text_input_plugin_unittest.cc.

395 {
396 UseEngineWithView();
397
398 auto handled_message = CreateResponse(true);
399 auto unhandled_message = CreateResponse(false);
400 int received_scancode = 0;
401
402 TestBinaryMessenger messenger(
403 [&received_scancode, &handled_message, &unhandled_message](
404 const std::string& channel, const uint8_t* message,
405 size_t message_size, BinaryReply reply) {});
406
407 int redispatch_scancode = 0;
408 TextInputPlugin handler(&messenger, engine());
409
410 auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
411 auto& allocator = args->GetAllocator();
412 args->PushBack(123, allocator); // client_id
413
414 rapidjson::Value client_config(rapidjson::kObjectType);
415 client_config.AddMember(kEnableDeltaModel, true, allocator);
416
417 args->PushBack(client_config, allocator);
418 auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall(
420
421 EXPECT_TRUE(messenger.SimulateEngineMessage(
422 kChannelName, encoded->data(), encoded->size(),
423 [](const uint8_t* reply, size_t reply_size) {}));
424
425 handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
426 handler.ComposeBeginHook();
427 std::u16string text;
428 text.push_back('\n');
429 handler.ComposeChangeHook(text, 1);
430 handler.ComposeEndHook();
431
432 handler.KeyboardHook(0x4E, 100, WM_KEYDOWN, 'n', false, false);
433 handler.ComposeBeginHook();
434 std::u16string textN;
435 text.push_back('n');
436 handler.ComposeChangeHook(textN, 1);
437 handler.KeyboardHook(0x49, 100, WM_KEYDOWN, 'i', false, false);
438 std::u16string textNi;
439 text.push_back('n');
440 text.push_back('i');
441 handler.ComposeChangeHook(textNi, 2);
442 handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
443 std::u16string textChineseCharacter;
444 text.push_back(u'\u4F60');
445 handler.ComposeChangeHook(textChineseCharacter, 1);
446 handler.ComposeCommitHook();
447 handler.ComposeEndHook();
448
449 // Passes if it did not crash
450}
static NSString *const kEnableDeltaModel

◆ TEST_F() [834/876]

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

Definition at line 163 of file text_input_plugin_unittest.cc.

163 {
164 UseEngineWithView();
165
166 auto handled_message = CreateResponse(true);
167 auto unhandled_message = CreateResponse(false);
168 int received_scancode = 0;
169
170 TestBinaryMessenger messenger(
171 [&received_scancode, &handled_message, &unhandled_message](
172 const std::string& channel, const uint8_t* message,
173 size_t message_size, BinaryReply reply) {});
174
175 int redispatch_scancode = 0;
176 TextInputPlugin handler(&messenger, engine());
177
178 handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
179 handler.ComposeBeginHook();
180 std::u16string text;
181 text.push_back('\n');
182 handler.ComposeChangeHook(text, 1);
183 handler.ComposeEndHook();
184
185 // Passes if it did not crash
186}

◆ TEST_F() [835/876]

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

Definition at line 512 of file text_input_plugin_unittest.cc.

512 {
513 UseEngineWithView();
514
515 // A position of `EditableText`.
516 double view_x = 100;
517 double view_y = 200;
518
519 // A position and size of marked text, in `EditableText` local coordinates.
520 double ime_x = 3;
521 double ime_y = 4;
522 double ime_width = 50;
523 double ime_height = 60;
524
525 // Transformation matrix.
526 std::array<std::array<double, 4>, 4> editabletext_transform = {
527 1.0, 0.0, 0.0, view_x, //
528 0.0, 1.0, 0.0, view_y, //
529 0.0, 0.0, 0.0, 0.0, //
530 0.0, 0.0, 0.0, 1.0};
531
532 TestBinaryMessenger messenger([](const std::string& channel,
533 const uint8_t* message, size_t message_size,
534 BinaryReply reply) {});
535 BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
536
537 TextInputPlugin handler(&messenger, engine());
538
539 auto& codec = JsonMethodCodec::GetInstance();
540
541 EXPECT_CALL(*view(), OnCursorRectUpdated(Rect{{view_x, view_y}, {0, 0}}));
542
543 {
544 auto arguments =
545 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
546 auto& allocator = arguments->GetAllocator();
547
548 rapidjson::Value transoform(rapidjson::kArrayType);
549 for (int i = 0; i < 4 * 4; i++) {
550 // Pack 2-dimensional array by column-major order.
551 transoform.PushBack(editabletext_transform[i % 4][i / 4], allocator);
552 }
553
554 arguments->AddMember("transform", transoform, allocator);
555
556 auto message = codec.EncodeMethodCall(
557 {"TextInput.setEditableSizeAndTransform", std::move(arguments)});
558 messenger.SimulateEngineMessage(kChannelName, message->data(),
559 message->size(), reply_handler);
560 }
561
562 EXPECT_CALL(*view(),
563 OnCursorRectUpdated(Rect{{view_x + ime_x, view_y + ime_y},
564 {ime_width, ime_height}}));
565
566 {
567 auto arguments =
568 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
569 auto& allocator = arguments->GetAllocator();
570
571 arguments->AddMember("x", ime_x, allocator);
572 arguments->AddMember("y", ime_y, allocator);
573 arguments->AddMember("width", ime_width, allocator);
574 arguments->AddMember("height", ime_height, allocator);
575
576 auto message = codec.EncodeMethodCall(
577 {"TextInput.setMarkedTextRect", std::move(arguments)});
578 messenger.SimulateEngineMessage(kChannelName, message->data(),
579 message->size(), reply_handler);
580 }
581}

◆ TEST_F() [836/876]

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

Definition at line 234 of file text_input_plugin_unittest.cc.

234 {
235 UseEngineWithView();
236
237 bool sent_message = false;
238 TestBinaryMessenger messenger(
239 [&sent_message](const std::string& channel, const uint8_t* message,
240 size_t message_size,
241 BinaryReply reply) { sent_message = true; });
242 BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
243
244 TextInputPlugin handler(&messenger, engine());
245
246 auto& codec = JsonMethodCodec::GetInstance();
247
248 // Call TextInput.setClient to initialize the TextInputModel.
249 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
250 auto& allocator = arguments->GetAllocator();
251 arguments->PushBack(kDefaultClientId, allocator);
252 rapidjson::Value config(rapidjson::kObjectType);
253 config.AddMember("inputAction", "done", allocator);
254 config.AddMember("inputType", "text", allocator);
255 config.AddMember(kEnableDeltaModel, false, allocator);
256 arguments->PushBack(config, allocator);
257 auto message =
258 codec.EncodeMethodCall({"TextInput.setClient", std::move(arguments)});
259 messenger.SimulateEngineMessage("flutter/textinput", message->data(),
260 message->size(), reply_handler);
261
262 // ComposeBeginHook should send state update.
263 sent_message = false;
264 handler.ComposeBeginHook();
265 EXPECT_TRUE(sent_message);
266
267 // ComposeChangeHook should send state update.
268 sent_message = false;
269 handler.ComposeChangeHook(u"4", 1);
270 EXPECT_TRUE(sent_message);
271
272 // ComposeCommitHook should NOT send state update.
273 //
274 // Commit messages are always immediately followed by a change message or an
275 // end message, both of which will send an update. Sending intermediate state
276 // with a collapsed composing region will trigger the framework to assume
277 // composing has ended, which is not the case until a WM_IME_ENDCOMPOSING
278 // event is received in the main event loop, which will trigger a call to
279 // ComposeEndHook.
280 sent_message = false;
281 handler.ComposeCommitHook();
282 EXPECT_FALSE(sent_message);
283
284 // ComposeEndHook should send state update.
285 sent_message = false;
286 handler.ComposeEndHook();
287 EXPECT_TRUE(sent_message);
288}

◆ TEST_F() [837/876]

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

Definition at line 290 of file text_input_plugin_unittest.cc.

290 {
291 UseEngineWithView();
292
293 // Store messages as std::string for convenience.
294 std::vector<std::string> messages;
295
296 TestBinaryMessenger messenger(
297 [&messages](const std::string& channel, const uint8_t* message,
298 size_t message_size, BinaryReply reply) {
299 std::string last_message(reinterpret_cast<const char*>(message),
300 message_size);
301 messages.push_back(last_message);
302 });
303 BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
304
305 TextInputPlugin handler(&messenger, engine());
306
307 auto& codec = JsonMethodCodec::GetInstance();
308
309 // Call TextInput.setClient to initialize the TextInputModel.
310 auto set_client_arguments =
311 EncodedClientConfig("TextInputType.multiline", "TextInputAction.newline");
312 auto message = codec.EncodeMethodCall(
313 {"TextInput.setClient", std::move(set_client_arguments)});
314 messenger.SimulateEngineMessage("flutter/textinput", message->data(),
315 message->size(), reply_handler);
316
317 // Simulate a key down event for '\n'.
318 handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
319
320 // Two messages are expected, the first is TextInput.updateEditingState and
321 // the second is TextInputClient.performAction.
322 EXPECT_EQ(messages.size(), 2);
323
324 // Editing state should have been updated.
325 auto encoded_arguments = EncodedEditingState("\n", TextRange(1));
326 auto update_state_message = codec.EncodeMethodCall(
327 {kUpdateEditingStateMethod, std::move(encoded_arguments)});
328
329 EXPECT_TRUE(std::equal(update_state_message->begin(),
330 update_state_message->end(),
331 messages.front().begin()));
332
333 // TextInputClient.performAction should have been called.
334 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
335 auto& allocator = arguments->GetAllocator();
336 arguments->PushBack(kDefaultClientId, allocator);
337 arguments->PushBack(
338 rapidjson::Value("TextInputAction.newline", allocator).Move(), allocator);
339 auto invoke_action_message = codec.EncodeMethodCall(
340 {"TextInputClient.performAction", std::move(arguments)});
341
342 EXPECT_TRUE(std::equal(invoke_action_message->begin(),
343 invoke_action_message->end(),
344 messages.back().begin()));
345}
SkRange< size_t > TextRange
Definition TextStyle.h:337

◆ TEST_F() [838/876]

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

Definition at line 348 of file text_input_plugin_unittest.cc.

348 {
349 UseEngineWithView();
350
351 std::vector<std::vector<uint8_t>> messages;
352
353 TestBinaryMessenger messenger(
354 [&messages](const std::string& channel, const uint8_t* message,
355 size_t message_size, BinaryReply reply) {
356 int length = static_cast<int>(message_size);
357 std::vector<uint8_t> last_message(length);
358 memcpy(&last_message[0], &message[0], length * sizeof(uint8_t));
359 messages.push_back(last_message);
360 });
361 BinaryReply reply_handler = [](const uint8_t* reply, size_t reply_size) {};
362
363 TextInputPlugin handler(&messenger, engine());
364
365 auto& codec = JsonMethodCodec::GetInstance();
366
367 // Call TextInput.setClient to initialize the TextInputModel.
368 auto set_client_arguments =
369 EncodedClientConfig("TextInputType.multiline", "TextInputAction.send");
370 auto message = codec.EncodeMethodCall(
371 {"TextInput.setClient", std::move(set_client_arguments)});
372 messenger.SimulateEngineMessage("flutter/textinput", message->data(),
373 message->size(), reply_handler);
374
375 // Simulate a key down event for '\n'.
376 handler.KeyboardHook(VK_RETURN, 100, WM_KEYDOWN, '\n', false, false);
377
378 // Only a call to TextInputClient.performAction is expected.
379 EXPECT_EQ(messages.size(), 1);
380
381 // TextInputClient.performAction should have been called.
382 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
383 auto& allocator = arguments->GetAllocator();
384 arguments->PushBack(kDefaultClientId, allocator);
385 arguments->PushBack(
386 rapidjson::Value("TextInputAction.send", allocator).Move(), allocator);
387 auto invoke_action_message = codec.EncodeMethodCall(
388 {"TextInputClient.performAction", std::move(arguments)});
389
390 EXPECT_TRUE(std::equal(invoke_action_message->begin(),
391 invoke_action_message->end(),
392 messages.front().begin()));
393}

◆ TEST_F() [839/876]

flutter::testing::TEST_F ( TextureLayerDiffTest  ,
TextureInRetainedLayer   
)

Definition at line 101 of file texture_layer_unittests.cc.

101 {
102 MockLayerTree tree1;
103 auto container = std::make_shared<ContainerLayer>();
104 tree1.root()->Add(container);
105 auto layer = std::make_shared<TextureLayer>(SkPoint::Make(0, 0),
106 SkSize::Make(100, 100), 0, false,
107 DlImageSampling::kLinear);
108 container->Add(layer);
109
110 MockLayerTree tree2;
111 tree2.root()->Add(container); // retained layer
112
113 auto damage = DiffLayerTree(tree1, MockLayerTree());
114 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 100, 100));
115
116 damage = DiffLayerTree(tree2, tree1);
117 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 100, 100));
118}

◆ TEST_F() [840/876]

flutter::testing::TEST_F ( TextureLayerTest  ,
InvalidTexture   
)

Definition at line 19 of file texture_layer_unittests.cc.

19 {
20 const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
21 const SkSize layer_size = SkSize::Make(8.0f, 8.0f);
22 auto layer = std::make_shared<TextureLayer>(
23 layer_offset, layer_size, 0, false, DlImageSampling::kNearestNeighbor);
24
25 layer->Preroll(preroll_context());
26 EXPECT_EQ(layer->paint_bounds(),
27 (SkRect::MakeSize(layer_size)
28 .makeOffset(layer_offset.fX, layer_offset.fY)));
29 EXPECT_TRUE(layer->needs_painting(paint_context()));
30
31 layer->Paint(display_list_paint_context());
32 EXPECT_TRUE(display_list()->Equals(DisplayList()));
33}

◆ TEST_F() [841/876]

flutter::testing::TEST_F ( TextureLayerTest  ,
PaintingWithLinearSampling   
)

Definition at line 72 of file texture_layer_unittests.cc.

72 {
73 const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f);
74 const SkSize layer_size = SkSize::Make(8.0f, 8.0f);
75 const SkRect layer_bounds =
76 SkRect::MakeSize(layer_size).makeOffset(layer_offset.fX, layer_offset.fY);
77 const int64_t texture_id = 0;
78 const auto texture_image = MockTexture::MakeTestTexture(20, 20, 5);
79 auto mock_texture = std::make_shared<MockTexture>(texture_id, texture_image);
80 auto layer = std::make_shared<TextureLayer>(
81 layer_offset, layer_size, texture_id, false, DlImageSampling::kLinear);
82
83 // Ensure the texture is located by the Layer.
84 preroll_context()->texture_registry->RegisterTexture(mock_texture);
85
86 layer->Preroll(preroll_context());
87 EXPECT_EQ(layer->paint_bounds(), layer_bounds);
88 EXPECT_TRUE(layer->needs_painting(paint_context()));
89
90 layer->Paint(display_list_paint_context());
91 DisplayListBuilder expected_builder;
92 /* (Texture)layer::Paint */ {
93 expected_builder.DrawImageRect(texture_image, layer_bounds,
94 DlImageSampling::kLinear);
95 }
96 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
97}

◆ TEST_F() [842/876]

flutter::testing::TEST_F ( TransformLayerLayerDiffTest  ,
Transform   
)

Definition at line 477 of file transform_layer_unittests.cc.

477 {
478 auto path1 = SkPath().addRect(SkRect::MakeLTRB(0, 0, 50, 50));
479 auto m1 = std::make_shared<MockLayer>(path1);
480
481 auto transform1 =
482 std::make_shared<TransformLayer>(SkMatrix::Translate(10, 10));
483 transform1->Add(m1);
484
485 MockLayerTree t1;
486 t1.root()->Add(transform1);
487
488 auto damage = DiffLayerTree(t1, MockLayerTree());
489 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(10, 10, 60, 60));
490
491 auto transform2 =
492 std::make_shared<TransformLayer>(SkMatrix::Translate(20, 20));
493 transform2->Add(m1);
494 transform2->AssignOldLayer(transform1.get());
495
496 MockLayerTree t2;
497 t2.root()->Add(transform2);
498
499 damage = DiffLayerTree(t2, t1);
500 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(10, 10, 70, 70));
501
502 auto transform3 =
503 std::make_shared<TransformLayer>(SkMatrix::Translate(20, 20));
504 transform3->Add(m1);
505 transform3->AssignOldLayer(transform2.get());
506
507 MockLayerTree t3;
508 t3.root()->Add(transform3);
509
510 damage = DiffLayerTree(t3, t2);
511 EXPECT_EQ(damage.frame_damage, SkIRect::MakeEmpty());
512}

◆ TEST_F() [843/876]

flutter::testing::TEST_F ( TransformLayerLayerDiffTest  ,
TransformNested   
)

Definition at line 514 of file transform_layer_unittests.cc.

514 {
515 auto path1 = SkPath().addRect(SkRect::MakeLTRB(0, 0, 50, 50));
516 auto m1 = CreateContainerLayer(std::make_shared<MockLayer>(path1));
517 auto m2 = CreateContainerLayer(std::make_shared<MockLayer>(path1));
518 auto m3 = CreateContainerLayer(std::make_shared<MockLayer>(path1));
519
520 auto transform1 = std::make_shared<TransformLayer>(SkMatrix::Scale(2.0, 2.0));
521
522 auto transform1_1 =
523 std::make_shared<TransformLayer>(SkMatrix::Translate(10, 10));
524 transform1_1->Add(m1);
525 transform1->Add(transform1_1);
526
527 auto transform1_2 =
528 std::make_shared<TransformLayer>(SkMatrix::Translate(100, 100));
529 transform1_2->Add(m2);
530 transform1->Add(transform1_2);
531
532 auto transform1_3 =
533 std::make_shared<TransformLayer>(SkMatrix::Translate(200, 200));
534 transform1_3->Add(m3);
535 transform1->Add(transform1_3);
536
537 MockLayerTree l1;
538 l1.root()->Add(transform1);
539
540 auto damage = DiffLayerTree(l1, MockLayerTree());
541 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(20, 20, 500, 500));
542
543 auto transform2 = std::make_shared<TransformLayer>(SkMatrix::Scale(2.0, 2.0));
544
545 auto transform2_1 =
546 std::make_shared<TransformLayer>(SkMatrix::Translate(10, 10));
547 transform2_1->Add(m1);
548 transform2_1->AssignOldLayer(transform1_1.get());
549 transform2->Add(transform2_1);
550
551 // Offset 1px from transform1_2 so that they're not the same
552 auto transform2_2 =
553 std::make_shared<TransformLayer>(SkMatrix::Translate(100, 101));
554 transform2_2->Add(m2);
555 transform2_2->AssignOldLayer(transform1_2.get());
556 transform2->Add(transform2_2);
557
558 auto transform2_3 =
559 std::make_shared<TransformLayer>(SkMatrix::Translate(200, 200));
560 transform2_3->Add(m3);
561 transform2_3->AssignOldLayer(transform1_3.get());
562 transform2->Add(transform2_3);
563
564 MockLayerTree l2;
565 l2.root()->Add(transform2);
566
567 damage = DiffLayerTree(l2, l1);
568
569 // transform2 has not transform1 assigned as old layer, so it should be
570 // invalidated completely
571 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(20, 20, 500, 500));
572
573 // now diff the tree properly, the only difference being transform2_2 and
574 // transform_2_1
575 transform2->AssignOldLayer(transform1.get());
576 damage = DiffLayerTree(l2, l1);
577
578 EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(200, 200, 300, 302));
579}

◆ TEST_F() [844/876]

flutter::testing::TEST_F ( TransformLayerTest  ,
ComplexM44   
)

Definition at line 167 of file transform_layer_unittests.cc.

167 {
168 SkPath child_path;
169 child_path.addRect(5.0f, 6.0f, 20.5f, 21.5f);
170 SkMatrix initial_transform = SkMatrix::Translate(-2.0f, -2.0f);
171 SkRect local_cull_rect = SkRect::MakeXYWH(4.0f, 4.0f, 16.0f, 16.0f);
172 SkRect device_cull_rect = initial_transform.mapRect(local_cull_rect);
173 SkM44 layer_transform44 = SkM44();
174 layer_transform44.preTranslate(1.0f, 1.0f);
175 // 20 degrees around the X axis
176 layer_transform44.preConcat(SkM44::Rotate({1.0f, 0.0f, 0.0f}, M_PI / 9.0f));
177 // 10 degrees around the Y axis
178 layer_transform44.preConcat(SkM44::Rotate({0.0f, 1.0f, 0.0f}, M_PI / 18.0f));
179 SkM44 inverse_layer_transform44;
180 EXPECT_TRUE(layer_transform44.invert(&inverse_layer_transform44));
181 SkMatrix layer_transform = layer_transform44.asM33();
182 SkMatrix inverse_layer_transform = inverse_layer_transform44.asM33();
183
184 auto mock_layer = std::make_shared<MockLayer>(child_path, DlPaint());
185 auto layer = std::make_shared<TransformLayer>(layer_transform44);
186 layer->Add(mock_layer);
187
188 preroll_context()->state_stack.set_preroll_delegate(device_cull_rect,
189 initial_transform);
190 layer->Preroll(preroll_context());
191 EXPECT_EQ(mock_layer->paint_bounds(), child_path.getBounds());
192 EXPECT_EQ(layer->paint_bounds(),
193 layer_transform.mapRect(mock_layer->paint_bounds()));
194 EXPECT_EQ(layer->child_paint_bounds(), mock_layer->paint_bounds());
195 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
196 EXPECT_TRUE(layer->needs_painting(paint_context()));
197 EXPECT_EQ(mock_layer->parent_matrix(),
198 SkMatrix::Concat(initial_transform, layer_transform));
199
200 // Even having switched to binary-ieee friendly numbers for the
201 // initial conditions, these numbers which are based on a matrix
202 // concatenation and inversion still aren't exact, so we are using
203 // fuzzy float comparisons to check them.
204 SkRect parent_cull_rect = mock_layer->parent_cull_rect();
205 SkRect expect_parent_cull_rect =
206 inverse_layer_transform.mapRect(local_cull_rect);
207 EXPECT_FLOAT_EQ(parent_cull_rect.fLeft, expect_parent_cull_rect.fLeft);
208 EXPECT_FLOAT_EQ(parent_cull_rect.fTop, expect_parent_cull_rect.fTop);
209 EXPECT_FLOAT_EQ(parent_cull_rect.fRight, expect_parent_cull_rect.fRight);
210 EXPECT_FLOAT_EQ(parent_cull_rect.fBottom, expect_parent_cull_rect.fBottom);
211
212 EXPECT_EQ(mock_layer->parent_mutators(),
213 std::vector({Mutator(layer_transform)}));
214
215 layer->Paint(display_list_paint_context());
216 DisplayListBuilder expected_builder;
217 /* (Transform)layer::Paint */ {
218 expected_builder.Save();
219 {
220 expected_builder.Transform(layer_transform44);
221 /* mock_layer::Paint */ {
222 expected_builder.DrawPath(child_path, DlPaint());
223 }
224 }
225 expected_builder.Restore();
226 }
227 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
228}
static SkM44 Rotate(SkV3 axis, SkScalar radians)
Definition SkM44.h:239
SkM44 & preConcat(const SkM44 &m)
Definition SkM44.h:351
SkMatrix asM33() const
Definition SkM44.h:409
bool invert(SkM44 *inverse) const
Definition SkM44.cpp:247
SkM44 & preTranslate(SkScalar x, SkScalar y, SkScalar z=0)
Definition SkM44.cpp:89

◆ TEST_F() [845/876]

flutter::testing::TEST_F ( TransformLayerTest  ,
Identity   
)

Definition at line 42 of file transform_layer_unittests.cc.

42 {
43 SkPath child_path;
44 child_path.addRect(5.0f, 6.0f, 20.5f, 21.5f);
45 SkRect cull_rect = SkRect::MakeXYWH(2.0f, 2.0f, 14.0f, 14.0f);
46 auto mock_layer = std::make_shared<MockLayer>(child_path, DlPaint());
47 auto layer = std::make_shared<TransformLayer>(SkMatrix()); // identity
48 layer->Add(mock_layer);
49
50 preroll_context()->state_stack.set_preroll_delegate(cull_rect);
51 layer->Preroll(preroll_context());
52 EXPECT_EQ(mock_layer->paint_bounds(), child_path.getBounds());
53 EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
54 EXPECT_EQ(layer->child_paint_bounds(), mock_layer->paint_bounds());
55 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
56 EXPECT_TRUE(layer->needs_painting(paint_context()));
57 EXPECT_EQ(mock_layer->parent_matrix(), SkMatrix()); // identity
58 EXPECT_EQ(mock_layer->parent_cull_rect(), cull_rect);
59 EXPECT_EQ(mock_layer->parent_mutators().stack_count(), 0u);
60 EXPECT_EQ(mock_layer->parent_mutators(), MutatorsStack());
61
62 layer->Paint(display_list_paint_context());
63 DisplayListBuilder expected_builder;
64 /* (Transform)layer::Paint */ {
65 expected_builder.Save();
66 {
67 expected_builder.Transform(SkMatrix());
68 /* mock_layer::Paint */ {
69 expected_builder.DrawPath(child_path, DlPaint());
70 }
71 }
72 expected_builder.Restore();
73 }
74 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
75}

◆ TEST_F() [846/876]

flutter::testing::TEST_F ( TransformLayerTest  ,
NestedSeparated   
)

Definition at line 294 of file transform_layer_unittests.cc.

294 {
295 SkPath child_path;
296 child_path.addRect(5.0f, 6.0f, 20.5f, 21.5f);
297 SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f);
298 SkRect local_cull_rect = SkRect::MakeXYWH(2.0f, 2.0f, 14.0f, 14.0f);
299 SkRect device_cull_rect = initial_transform.mapRect(local_cull_rect);
300 SkMatrix layer1_transform = SkMatrix::Translate(2.5f, 2.5f);
301 SkMatrix layer2_transform = SkMatrix::Translate(3.5f, 3.5f);
302 SkMatrix inverse_layer1_transform, inverse_layer2_transform;
303 EXPECT_TRUE(layer1_transform.invert(&inverse_layer1_transform));
304 EXPECT_TRUE(layer2_transform.invert(&inverse_layer2_transform));
305 DlPaint child_paint1(DlColor::kBlue());
306 DlPaint child_paint2(DlColor::kGreen());
307
308 auto mock_layer1 = std::make_shared<MockLayer>(child_path, child_paint1);
309 auto mock_layer2 = std::make_shared<MockLayer>(child_path, child_paint2);
310 auto layer1 = std::make_shared<TransformLayer>(layer1_transform);
311 auto layer2 = std::make_shared<TransformLayer>(layer2_transform);
312 layer1->Add(mock_layer1);
313 layer1->Add(layer2);
314 layer2->Add(mock_layer2);
315
316 preroll_context()->state_stack.set_preroll_delegate(device_cull_rect,
317 initial_transform);
318 layer1->Preroll(preroll_context());
319 SkRect layer1_child_bounds = layer2->paint_bounds();
320 layer1_child_bounds.join(mock_layer1->paint_bounds());
321 SkRect expected_layer1_bounds = layer1_child_bounds;
322 layer1_transform.mapRect(&expected_layer1_bounds);
323
324 EXPECT_EQ(mock_layer2->paint_bounds(), child_path.getBounds());
325 EXPECT_EQ(layer2->paint_bounds(),
326 layer2_transform.mapRect(mock_layer2->paint_bounds()));
327 EXPECT_EQ(layer2->child_paint_bounds(), mock_layer2->paint_bounds());
328 EXPECT_EQ(mock_layer1->paint_bounds(), child_path.getBounds());
329 EXPECT_EQ(layer1->paint_bounds(), expected_layer1_bounds);
330 EXPECT_EQ(layer1->child_paint_bounds(), layer1_child_bounds);
331 EXPECT_TRUE(mock_layer2->needs_painting(paint_context()));
332 EXPECT_TRUE(layer2->needs_painting(paint_context()));
333 EXPECT_TRUE(mock_layer1->needs_painting(paint_context()));
334 EXPECT_TRUE(layer1->needs_painting(paint_context()));
335 EXPECT_EQ(mock_layer1->parent_matrix(),
336 SkMatrix::Concat(initial_transform, layer1_transform));
337 EXPECT_EQ(
338 mock_layer2->parent_matrix(),
339 SkMatrix::Concat(SkMatrix::Concat(initial_transform, layer1_transform),
340 layer2_transform));
341 EXPECT_EQ(mock_layer1->parent_cull_rect(),
342 inverse_layer1_transform.mapRect(local_cull_rect));
343 EXPECT_EQ(mock_layer2->parent_cull_rect(),
344 inverse_layer2_transform.mapRect(
345 inverse_layer1_transform.mapRect(local_cull_rect)));
346 EXPECT_EQ(mock_layer1->parent_mutators(),
347 std::vector({Mutator(layer1_transform)}));
348 EXPECT_EQ(
349 mock_layer2->parent_mutators(),
350 std::vector({Mutator(layer1_transform), Mutator(layer2_transform)}));
351
352 layer1->Paint(display_list_paint_context());
353 DisplayListBuilder expected_builder;
354 /* (Transform)layer1::Paint */ {
355 expected_builder.Save();
356 {
357 expected_builder.Transform(layer1_transform);
358 /* mock_layer::Paint */ {
359 expected_builder.DrawPath(child_path, child_paint1);
360 }
361 /* (Transform)layer1::Paint */ {
362 expected_builder.Save();
363 {
364 expected_builder.Transform(layer2_transform);
365 /* mock_layer::Paint */ {
366 expected_builder.DrawPath(child_path, child_paint2);
367 }
368 }
369 expected_builder.Restore();
370 }
371 }
372 expected_builder.Restore();
373 }
374 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
375}
bool invert(SkMatrix *inverse) const
Definition SkMatrix.h:1206

◆ TEST_F() [847/876]

flutter::testing::TEST_F ( TransformLayerTest  ,
SimpleM44   
)

Definition at line 122 of file transform_layer_unittests.cc.

122 {
123 SkPath child_path;
124 child_path.addRect(5.0f, 6.0f, 20.5f, 21.5f);
125 SkMatrix initial_transform = SkMatrix::Translate(-0.5f, -0.5f);
126 SkRect local_cull_rect = SkRect::MakeXYWH(2.0f, 2.0f, 14.0f, 14.0f);
127 SkRect device_cull_rect = initial_transform.mapRect(local_cull_rect);
128 SkMatrix layer_transform = SkMatrix::Translate(2.5f, 3.5f);
129 SkMatrix inverse_layer_transform;
130 EXPECT_TRUE(layer_transform.invert(&inverse_layer_transform));
131
132 auto mock_layer = std::make_shared<MockLayer>(child_path, DlPaint());
133 auto layer = std::make_shared<TransformLayer>(SkM44::Translate(2.5f, 3.5f));
134 layer->Add(mock_layer);
135
136 preroll_context()->state_stack.set_preroll_delegate(device_cull_rect,
137 initial_transform);
138 layer->Preroll(preroll_context());
139 EXPECT_EQ(mock_layer->paint_bounds(), child_path.getBounds());
140 EXPECT_EQ(layer->paint_bounds(),
141 layer_transform.mapRect(mock_layer->paint_bounds()));
142 EXPECT_EQ(layer->child_paint_bounds(), mock_layer->paint_bounds());
143 EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
144 EXPECT_TRUE(layer->needs_painting(paint_context()));
145 EXPECT_EQ(mock_layer->parent_matrix(),
146 SkMatrix::Concat(initial_transform, layer_transform));
147 EXPECT_EQ(mock_layer->parent_cull_rect(),
148 inverse_layer_transform.mapRect(local_cull_rect));
149 EXPECT_EQ(mock_layer->parent_mutators(),
150 std::vector({Mutator(layer_transform)}));
151
152 layer->Paint(display_list_paint_context());
153 DisplayListBuilder expected_builder;
154 /* (Transform)layer::Paint */ {
155 expected_builder.Save();
156 {
157 expected_builder.Transform(layer_transform);
158 /* mock_layer::Paint */ {
159 expected_builder.DrawPath(child_path, DlPaint());
160 }
161 }
162 expected_builder.Restore();
163 }
164 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
165}

◆ TEST_F() [848/876]

flutter::testing::TEST_F ( TypeConversionsTest  ,
CanConvertEmptyList   
)

Definition at line 54 of file type_conversions_unittests.cc.

54 {
56 AddNativeCallback(
57 "NotifySuccess", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
58 auto bool_handle = Dart_GetNativeArgument(args, 0);
59 ASSERT_FALSE(tonic::CheckAndHandleError(bool_handle));
60 ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(bool_handle));
61 event.Signal();
62 }));
63 AddNativeCallback(
64 "NotifyNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments) {
65 std::vector<int64_t> items;
66 auto items_handle = tonic::ToDart(items);
67 ASSERT_FALSE(tonic::CheckAndHandleError(items_handle));
68 tonic::DartInvokeField(::Dart_RootLibrary(), "testCanConvertEmptyList",
69 {items_handle});
70 }));
71 ASSERT_TRUE(RunWithEntrypoint("trampoline"));
72 event.Wait();
73}
Dart_Handle DartInvokeField(Dart_Handle target, const char *name, std::initializer_list< Dart_Handle > args)

◆ TEST_F() [849/876]

flutter::testing::TEST_F ( TypeConversionsTest  ,
CanConvertListOfDoubles   
)

Definition at line 100 of file type_conversions_unittests.cc.

100 {
102 AddNativeCallback(
103 "NotifySuccess", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
104 auto bool_handle = Dart_GetNativeArgument(args, 0);
105 ASSERT_FALSE(tonic::CheckAndHandleError(bool_handle));
106 ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(bool_handle));
107 event.Signal();
108 }));
109 AddNativeCallback(
110 "NotifyNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments) {
111 std::vector<double> items;
112 items.push_back(1.0);
113 items.push_back(2.0);
114 items.push_back(3.0);
115 items.push_back(4.0);
116 auto items_handle = tonic::ToDart(items);
117 ASSERT_FALSE(tonic::CheckAndHandleError(items_handle));
119 "testCanConvertListOfDoubles", {items_handle});
120 }));
121 ASSERT_TRUE(RunWithEntrypoint("trampoline"));
122 event.Wait();
123}

◆ TEST_F() [850/876]

flutter::testing::TEST_F ( TypeConversionsTest  ,
CanConvertListOfInts   
)

Definition at line 125 of file type_conversions_unittests.cc.

125 {
127 AddNativeCallback(
128 "NotifySuccess", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
129 auto bool_handle = Dart_GetNativeArgument(args, 0);
130 ASSERT_FALSE(tonic::CheckAndHandleError(bool_handle));
131 ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(bool_handle));
132 event.Signal();
133 }));
134 AddNativeCallback(
135 "NotifyNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments) {
136 std::vector<int32_t> items;
137 items.push_back(1);
138 items.push_back(2);
139 items.push_back(3);
140 items.push_back(4);
141 auto items_handle = tonic::ToDart(items);
142 ASSERT_FALSE(tonic::CheckAndHandleError(items_handle));
143 tonic::DartInvokeField(::Dart_RootLibrary(), "testCanConvertListOfInts",
144 {items_handle});
145 }));
146 ASSERT_TRUE(RunWithEntrypoint("trampoline"));
147 event.Wait();
148}

◆ TEST_F() [851/876]

flutter::testing::TEST_F ( TypeConversionsTest  ,
CanConvertListOfStrings   
)

Definition at line 75 of file type_conversions_unittests.cc.

75 {
77 AddNativeCallback(
78 "NotifySuccess", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
79 auto bool_handle = Dart_GetNativeArgument(args, 0);
80 ASSERT_FALSE(tonic::CheckAndHandleError(bool_handle));
81 ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(bool_handle));
82 event.Signal();
83 }));
84 AddNativeCallback(
85 "NotifyNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments) {
86 std::vector<std::string> items;
87 items.push_back("tinker");
88 items.push_back("tailor");
89 items.push_back("soldier");
90 items.push_back("sailor");
91 auto items_handle = tonic::ToDart(items);
92 ASSERT_FALSE(tonic::CheckAndHandleError(items_handle));
94 "testCanConvertListOfStrings", {items_handle});
95 }));
96 ASSERT_TRUE(RunWithEntrypoint("trampoline"));
97 event.Wait();
98}

◆ TEST_F() [852/876]

flutter::testing::TEST_F ( TypeConversionsTest  ,
TestFixture   
)

Definition at line 50 of file type_conversions_unittests.cc.

50 {
51 ASSERT_TRUE(RunWithEntrypoint("main"));
52}

◆ TEST_F() [853/876]

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

Definition at line 15 of file windows_lifecycle_manager_unittests.cc.

15 {
17 HWND win1 = reinterpret_cast<HWND>(1);
18 HWND win2 = reinterpret_cast<HWND>(2);
19
20 // Hidden to inactive upon window shown.
21 manager.SetLifecycleState(AppLifecycleState::kHidden);
22 manager.OnWindowStateEvent(win1, WindowStateEvent::kShow);
23 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
24
25 // Showing a second window does not change state.
26 manager.OnWindowStateEvent(win2, WindowStateEvent::kShow);
27 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
28
29 // Inactive to resumed upon window focus.
30 manager.OnWindowStateEvent(win2, WindowStateEvent::kFocus);
31 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
32
33 // Showing a second window does not change state.
34 manager.OnWindowStateEvent(win1, WindowStateEvent::kFocus);
35 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
36
37 // Unfocusing one window does not change state while another is focused.
38 manager.OnWindowStateEvent(win1, WindowStateEvent::kUnfocus);
39 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
40
41 // Unfocusing final remaining focused window transitions to inactive.
42 manager.OnWindowStateEvent(win2, WindowStateEvent::kUnfocus);
43 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
44
45 // Hiding one of two visible windows does not change state.
46 manager.OnWindowStateEvent(win2, WindowStateEvent::kHide);
47 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
48
49 // Hiding only visible window transitions to hidden.
50 manager.OnWindowStateEvent(win1, WindowStateEvent::kHide);
51 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
52
53 // Transition directly from resumed to hidden when the window is hidden.
54 manager.OnWindowStateEvent(win1, WindowStateEvent::kShow);
55 manager.OnWindowStateEvent(win1, WindowStateEvent::kFocus);
56 manager.OnWindowStateEvent(win1, WindowStateEvent::kHide);
57 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
58}

◆ TEST_F() [854/876]

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

Definition at line 574 of file flutter_windows_unittests.cc.

574 {
575 std::mutex mutex;
576 std::string view_ids;
577
578 auto& context = GetContext();
579 WindowsConfigBuilder builder(context);
580 builder.SetDartEntrypoint("onMetricsChangedSignalViewIds");
581
582 fml::AutoResetWaitableEvent ready_latch;
583 context.AddNativeFunction(
584 "Signal", CREATE_NATIVE_ENTRY(
585 [&](Dart_NativeArguments args) { ready_latch.Signal(); }));
586
587 context.AddNativeFunction(
588 "SignalStringValue", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
589 auto handle = Dart_GetNativeArgument(args, 0);
590 ASSERT_FALSE(Dart_IsError(handle));
591
592 std::scoped_lock lock{mutex};
594 }));
595
596 // Create the implicit view.
597 ViewControllerPtr first_controller{builder.Run()};
598 ASSERT_NE(first_controller, nullptr);
599
600 ready_latch.Wait();
601
602 // Create a second view.
604 FlutterDesktopViewControllerGetEngine(first_controller.get());
606 properties.width = 100;
607 properties.height = 100;
608 ViewControllerPtr second_controller{
610 ASSERT_NE(second_controller, nullptr);
611
612 // Pump messages for the Windows platform task runner until the view is added.
613 while (true) {
614 PumpMessage();
615 std::scoped_lock lock{mutex};
616 if (view_ids == "View IDs: [0, 1]") {
617 break;
618 }
619 }
620
621 // Delete the second view and pump messages for the Windows platform task
622 // runner until the view is removed.
623 second_controller.reset();
624 while (true) {
625 PumpMessage();
626 std::scoped_lock lock{mutex};
627 if (view_ids == "View IDs: [0]") {
628 break;
629 }
630 }
631}
FlutterDesktopViewControllerRef FlutterDesktopEngineCreateViewController(FlutterDesktopEngineRef engine, const FlutterDesktopViewControllerProperties *properties)
std::unique_ptr< FlutterDesktopViewController, ViewControllerDeleter > ViewControllerPtr

◆ TEST_F() [855/876]

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

Definition at line 152 of file flutter_windows_unittests.cc.

152 {
153 auto& context = GetContext();
154 WindowsConfigBuilder builder(context);
155 EnginePtr engine{builder.RunHeadless()};
156 ASSERT_NE(engine, nullptr);
157
158 // Create and then destroy a view controller that does not own its engine.
159 // This causes the engine to transition back to headless mode.
160 {
162 ViewControllerPtr controller{
164
165 ASSERT_NE(controller, nullptr);
166 }
167
168 // The engine is back in headless mode now.
169 ASSERT_NE(engine, nullptr);
170
171 auto engine_ptr = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
172 ASSERT_TRUE(engine_ptr->running());
173}
std::unique_ptr< FlutterDesktopEngine, EngineDeleter > EnginePtr

◆ TEST_F() [856/876]

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

Definition at line 411 of file flutter_windows_unittests.cc.

411 {
412 auto& context = GetContext();
413 WindowsConfigBuilder builder(context);
414 ViewControllerPtr controller{builder.Run()};
415 ASSERT_NE(controller, nullptr);
416 auto view = FlutterDesktopViewControllerGetView(controller.get());
417
418 Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter;
419 dxgi_adapter = FlutterDesktopViewGetGraphicsAdapter(view);
420 ASSERT_NE(dxgi_adapter, nullptr);
421 DXGI_ADAPTER_DESC desc{};
422 ASSERT_TRUE(SUCCEEDED(dxgi_adapter->GetDesc(&desc)));
423}
FlutterDesktopViewRef FlutterDesktopViewControllerGetView(FlutterDesktopViewControllerRef controller)
IDXGIAdapter * FlutterDesktopViewGetGraphicsAdapter(FlutterDesktopViewRef view)

◆ TEST_F() [857/876]

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

Definition at line 548 of file flutter_windows_unittests.cc.

548 {
549 auto& context = GetContext();
550 WindowsConfigBuilder builder(context);
551 builder.SetDartEntrypoint("sendGetKeyboardState");
552
553 std::atomic<bool> done = false;
554 context.AddNativeFunction(
555 "SignalStringValue", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
556 auto handle = Dart_GetNativeArgument(args, 0);
557 ASSERT_FALSE(Dart_IsError(handle));
559 EXPECT_EQ(value, "Success");
560 done = true;
561 }));
562
563 ViewControllerPtr controller{builder.Run()};
564 ASSERT_NE(controller, nullptr);
565
566 // Pump messages for the Windows platform task runner.
567 ::MSG msg;
568 while (!done) {
569 PumpMessage();
570 }
571}
struct tagMSG MSG

◆ TEST_F() [858/876]

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

Definition at line 400 of file flutter_windows_unittests.cc.

400 {
401 auto& context = GetContext();
402 WindowsConfigBuilder builder(context);
403 ViewControllerPtr controller{builder.Run()};
404 ASSERT_NE(controller, nullptr);
405 FlutterDesktopViewId view_id =
407
408 ASSERT_EQ(view_id, static_cast<FlutterDesktopViewId>(kImplicitViewId));
409}
int64_t FlutterDesktopViewId
FlutterDesktopViewId FlutterDesktopViewControllerGetViewId(FlutterDesktopViewControllerRef controller)

◆ TEST_F() [859/876]

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

Definition at line 201 of file flutter_windows_unittests.cc.

201 {
202 auto& context = GetContext();
203 WindowsConfigBuilder builder(context);
204 builder.SetDartEntrypoint("customEntrypoint");
205 EnginePtr engine{builder.InitializeEngine()};
206 ASSERT_NE(engine, nullptr);
207
208 ASSERT_FALSE(FlutterDesktopEngineRun(engine.get(), "conflictingEntrypoint"));
209}
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)

◆ TEST_F() [860/876]

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

Definition at line 103 of file flutter_windows_unittests.cc.

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

◆ TEST_F() [861/876]

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

Definition at line 116 of file flutter_windows_unittests.cc.

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

◆ TEST_F() [862/876]

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

Definition at line 126 of file flutter_windows_unittests.cc.

126 {
127 auto& context = GetContext();
128 WindowsConfigBuilder builder(context);
129 builder.SetDartEntrypoint("signalViewIds");
130 EnginePtr engine{builder.RunHeadless()};
131 ASSERT_NE(engine, nullptr);
132
133 std::string view_ids;
135 context.AddNativeFunction(
136 "SignalStringValue", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
137 auto handle = Dart_GetNativeArgument(args, 0);
138 ASSERT_FALSE(Dart_IsError(handle));
140 latch.Signal();
141 }));
142
143 ViewControllerPtr controller{builder.Run()};
144 ASSERT_NE(controller, nullptr);
145
146 // Verify a headless app has the implicit view.
147 latch.Wait();
148 EXPECT_EQ(view_ids, "View IDs: [0]");
149}

◆ TEST_F() [863/876]

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

Definition at line 76 of file flutter_windows_unittests.cc.

76 {
77 auto& context = GetContext();
78 WindowsConfigBuilder builder(context);
79 ViewControllerPtr controller{builder.Run()};
80 ASSERT_NE(controller, nullptr);
81}

◆ TEST_F() [864/876]

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

Definition at line 84 of file flutter_windows_unittests.cc.

84 {
85 // Replace stdout & stderr stream buffers with our own.
86 StreamCapture stdout_capture(&std::cout);
87 StreamCapture stderr_capture(&std::cerr);
88
89 auto& context = GetContext();
90 WindowsConfigBuilder builder(context);
91 ViewControllerPtr controller{builder.Run()};
92 ASSERT_NE(controller, nullptr);
93
94 stdout_capture.Stop();
95 stderr_capture.Stop();
96
97 // Verify stdout & stderr have no output.
98 EXPECT_TRUE(stdout_capture.GetOutput().empty());
99 EXPECT_TRUE(stderr_capture.GetOutput().empty());
100}

◆ TEST_F() [865/876]

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

Definition at line 176 of file flutter_windows_unittests.cc.

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

◆ TEST_F() [866/876]

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

Definition at line 503 of file flutter_windows_unittests.cc.

503 {
504 auto& context = GetContext();
505 WindowsConfigBuilder builder(context);
506 EnginePtr engine{builder.InitializeEngine()};
507 auto windows_engine = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
508 EngineModifier modifier{windows_engine};
509
510 auto lifecycle_manager =
511 std::make_unique<MockWindowsLifecycleManager>(windows_engine);
512 auto lifecycle_manager_ptr = lifecycle_manager.get();
513 modifier.SetLifecycleManager(std::move(lifecycle_manager));
514
515 EXPECT_CALL(*lifecycle_manager_ptr,
516 SetLifecycleState(AppLifecycleState::kResumed))
517 .WillOnce([lifecycle_manager_ptr](AppLifecycleState state) {
518 lifecycle_manager_ptr->WindowsLifecycleManager::SetLifecycleState(
519 state);
520 });
521
522 EXPECT_CALL(*lifecycle_manager_ptr,
523 SetLifecycleState(AppLifecycleState::kHidden))
524 .WillOnce([lifecycle_manager_ptr](AppLifecycleState state) {
525 lifecycle_manager_ptr->WindowsLifecycleManager::SetLifecycleState(
526 state);
527 });
528
529 // Create a controller. This launches the engine and sets the app lifecycle
530 // to the "resumed" state.
531 ViewControllerPtr controller{
533
535 FlutterDesktopViewControllerGetView(controller.get());
536 ASSERT_NE(view, nullptr);
537
538 HWND hwnd = FlutterDesktopViewGetHWND(view);
539 ASSERT_NE(hwnd, nullptr);
540
541 // Give the window a non-zero size to show it. This does not change the app
542 // lifecycle directly. However, destroying the view will now result in a
543 // "hidden" app lifecycle event.
544 ::MoveWindow(hwnd, /* X */ 0, /* Y */ 0, /* nWidth*/ 100, /* nHeight*/ 100,
545 /* bRepaint*/ false);
546}
struct FlutterDesktopView * FlutterDesktopViewRef
HWND FlutterDesktopViewGetHWND(FlutterDesktopViewRef controller)

◆ TEST_F() [867/876]

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

Definition at line 309 of file flutter_windows_unittests.cc.

309 {
310 struct Captures {
311 fml::AutoResetWaitableEvent frame_scheduled_latch;
312 fml::AutoResetWaitableEvent frame_drawn_latch;
313 std::thread::id thread_id;
314 bool done = false;
315 };
316 Captures captures;
317
318 CreateNewThread("test_platform_thread")->PostTask([&]() {
319 captures.thread_id = std::this_thread::get_id();
320
321 auto& context = GetContext();
322 WindowsConfigBuilder builder(context);
323 builder.SetDartEntrypoint("drawHelloWorld");
324
325 auto native_entry = CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
326 ASSERT_FALSE(captures.frame_drawn_latch.IsSignaledForTest());
327 captures.frame_scheduled_latch.Signal();
328 });
329 context.AddNativeFunction("NotifyFirstFrameScheduled", native_entry);
330
331 ViewControllerPtr controller{builder.Run()};
332 ASSERT_NE(controller, nullptr);
333
334 auto engine = FlutterDesktopViewControllerGetEngine(controller.get());
335
337 engine,
338 [](void* user_data) {
339 auto captures = static_cast<Captures*>(user_data);
340
341 ASSERT_TRUE(captures->frame_scheduled_latch.IsSignaledForTest());
342
343 // Callback should execute on platform thread.
344 ASSERT_EQ(std::this_thread::get_id(), captures->thread_id);
345
346 // Signal the test passed and end the Windows message loop.
347 captures->done = true;
348 captures->frame_drawn_latch.Signal();
349 },
350 &captures);
351
352 // Pump messages for the Windows platform task runner.
353 while (!captures.done) {
354 PumpMessage();
355 }
356 });
357
358 captures.frame_drawn_latch.Wait();
359}
void FlutterDesktopEngineSetNextFrameCallback(FlutterDesktopEngineRef engine, VoidCallback callback, void *user_data)

◆ TEST_F() [868/876]

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

Definition at line 254 of file flutter_windows_unittests.cc.

254 {
255 auto& context = GetContext();
256 WindowsConfigBuilder builder(context);
257 builder.SetDartEntrypoint("readPlatformExecutable");
258
259 std::string executable_name;
261 auto native_entry = CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
262 auto handle = Dart_GetNativeArgument(args, 0);
263 ASSERT_FALSE(Dart_IsError(handle));
264 executable_name = tonic::DartConverter<std::string>::FromDart(handle);
265 latch.Signal();
266 });
267 context.AddNativeFunction("SignalStringValue", native_entry);
268
269 ViewControllerPtr controller{builder.Run()};
270 ASSERT_NE(controller, nullptr);
271
272 // Wait until signalStringValue has been called.
273 latch.Wait();
274 EXPECT_EQ(executable_name, "flutter_windows_unittests.exe");
275}

◆ TEST_F() [869/876]

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

Definition at line 426 of file flutter_windows_unittests.cc.

426 {
427 auto& context = GetContext();
428 WindowsConfigBuilder builder(context);
429 ViewControllerPtr controller{builder.Run()};
430 ASSERT_NE(controller, nullptr);
431
436 FlutterDesktopViewRef implicit_view =
438
439 ASSERT_NE(implicit_view, nullptr);
440}
FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(FlutterDesktopEngineRef engine, const char *plugin_name)
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(FlutterDesktopPluginRegistrarRef controller)

◆ TEST_F() [870/876]

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

Definition at line 442 of file flutter_windows_unittests.cc.

442 {
443 auto& context = GetContext();
444 WindowsConfigBuilder builder(context);
445 ViewControllerPtr controller{builder.Run()};
446 ASSERT_NE(controller, nullptr);
447
452
453 FlutterDesktopViewId view_id =
457
459 registrar, static_cast<FlutterDesktopViewId>(123));
460
461 ASSERT_NE(view, nullptr);
462 ASSERT_EQ(view_123, nullptr);
463}
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetViewById(FlutterDesktopPluginRegistrarRef controller, FlutterDesktopViewId view_id)

◆ TEST_F() [871/876]

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

Definition at line 465 of file flutter_windows_unittests.cc.

465 {
466 auto& context = GetContext();
467 WindowsConfigBuilder builder(context);
468 EnginePtr engine{builder.RunHeadless()};
469 ASSERT_NE(engine, nullptr);
470
473
474 FlutterDesktopViewRef implicit_view =
477 registrar, static_cast<FlutterDesktopViewId>(123));
478
479 ASSERT_EQ(implicit_view, nullptr);
480 ASSERT_EQ(view_123, nullptr);
481}

◆ TEST_F() [872/876]

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

Definition at line 363 of file flutter_windows_unittests.cc.

363 {
364 auto& context = GetContext();
365 WindowsConfigBuilder builder(context);
366 builder.SetDartEntrypoint("renderImplicitView");
367
368 EnginePtr engine{builder.RunHeadless()};
369 ASSERT_NE(engine, nullptr);
370
371 bool done = false;
373 engine.get(),
374 [](void* user_data) {
375 // This executes on the platform thread.
376 auto done = reinterpret_cast<std::atomic<bool>*>(user_data);
377 *done = true;
378 },
379 &done);
380
381 // This app is in headless mode, however, the engine assumes the implicit
382 // view always exists. Send window metrics for the implicit view, causing
383 // the engine to present to the implicit view. The embedder must not crash.
384 auto engine_ptr = reinterpret_cast<FlutterWindowsEngine*>(engine.get());
385 FlutterWindowMetricsEvent metrics = {};
386 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
387 metrics.width = 100;
388 metrics.height = 100;
389 metrics.pixel_ratio = 1.0;
390 metrics.view_id = kImplicitViewId;
391 engine_ptr->SendWindowMetricsEvent(metrics);
392
393 // Pump messages for the Windows platform task runner.
394 while (!done) {
395 PumpMessage();
396 }
397}

◆ TEST_F() [873/876]

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

Definition at line 485 of file flutter_windows_unittests.cc.

485 {
486 auto& context = GetContext();
487 WindowsConfigBuilder builder(context);
488 EnginePtr engine{builder.InitializeEngine()};
489 EngineModifier modifier{
490 reinterpret_cast<FlutterWindowsEngine*>(engine.get())};
491
492 auto egl_manager = std::make_unique<HalfBrokenEGLManager>();
493 ASSERT_TRUE(egl_manager->IsValid());
494 modifier.SetEGLManager(std::move(egl_manager));
495
496 ViewControllerPtr controller{
498
499 ASSERT_NE(controller, nullptr);
500}

◆ TEST_F() [874/876]

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

Definition at line 212 of file flutter_windows_unittests.cc.

212 {
213 auto& context = GetContext();
214 WindowsConfigBuilder builder(context);
215 builder.SetDartEntrypoint("verifyNativeFunction");
216
218 auto native_entry =
220 context.AddNativeFunction("Signal", native_entry);
221
222 ViewControllerPtr controller{builder.Run()};
223 ASSERT_NE(controller, nullptr);
224
225 // Wait until signal has been called.
226 latch.Wait();
227}

◆ TEST_F() [875/876]

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

Definition at line 231 of file flutter_windows_unittests.cc.

231 {
232 auto& context = GetContext();
233 WindowsConfigBuilder builder(context);
234 builder.SetDartEntrypoint("verifyNativeFunctionWithParameters");
235
236 bool bool_value = false;
238 auto native_entry = CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
239 auto handle = Dart_GetNativeBooleanArgument(args, 0, &bool_value);
240 ASSERT_FALSE(Dart_IsError(handle));
241 latch.Signal();
242 });
243 context.AddNativeFunction("SignalBoolValue", native_entry);
244
245 ViewControllerPtr controller{builder.Run()};
246 ASSERT_NE(controller, nullptr);
247
248 // Wait until signalBoolValue has been called.
249 latch.Wait();
250 EXPECT_TRUE(bool_value);
251}
DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args, int index, bool *value)

◆ TEST_F() [876/876]

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

Definition at line 279 of file flutter_windows_unittests.cc.

279 {
280 auto& context = GetContext();
281 WindowsConfigBuilder builder(context);
282 builder.SetDartEntrypoint("verifyNativeFunctionWithReturn");
283
284 bool bool_value_to_return = true;
285 fml::CountDownLatch latch(2);
286 auto bool_return_entry = CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
287 Dart_SetBooleanReturnValue(args, bool_value_to_return);
288 latch.CountDown();
289 });
290 context.AddNativeFunction("SignalBoolReturn", bool_return_entry);
291
292 bool bool_value_passed = false;
293 auto bool_pass_entry = CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
294 auto handle = Dart_GetNativeBooleanArgument(args, 0, &bool_value_passed);
295 ASSERT_FALSE(Dart_IsError(handle));
296 latch.CountDown();
297 });
298 context.AddNativeFunction("SignalBoolValue", bool_pass_entry);
299
300 ViewControllerPtr controller{builder.Run()};
301 ASSERT_NE(controller, nullptr);
302
303 // Wait until signalBoolReturn and signalBoolValue have been called.
304 latch.Wait();
305 EXPECT_TRUE(bool_value_passed);
306}
DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args, bool retval)

◆ TEST_P() [1/6]

flutter::testing::TEST_P ( EmbedderTestMultiBackend  ,
CanCreateEmbedderWithCustomRenderTaskRunnerTheSameAsPlatformTaskRunner   
)

Asserts that the render task runner can be the same as the platform task runner.

Definition at line 2116 of file embedder_gl_unittests.cc.

2117 {
2118 // A new thread needs to be created for the platform thread because the test
2119 // can't wait for assertions to be completed on the same thread that services
2120 // platform task runner tasks.
2121 auto platform_task_runner = CreateNewThread("platform_thread");
2122
2123 static std::mutex engine_mutex;
2124 static UniqueEngine engine;
2125 fml::AutoResetWaitableEvent task_latch;
2126 bool task_executed = false;
2127 EmbedderTestTaskRunner common_task_runner(
2128 platform_task_runner, [&](FlutterTask task) {
2129 std::scoped_lock engine_lock(engine_mutex);
2130 if (engine.is_valid()) {
2131 ASSERT_EQ(FlutterEngineRunTask(engine.get(), &task), kSuccess);
2132 task_executed = true;
2133 task_latch.Signal();
2134 }
2135 });
2136
2137 platform_task_runner->PostTask([&]() {
2138 EmbedderTestContextType backend = GetParam();
2139 EmbedderConfigBuilder builder(GetEmbedderContext(backend));
2140 builder.SetDartEntrypoint("can_render_scene_without_custom_compositor");
2141 builder.SetRendererConfig(backend, SkISize::Make(800, 600));
2142 builder.SetRenderTaskRunner(
2143 &common_task_runner.GetFlutterTaskRunnerDescription());
2144 builder.SetPlatformTaskRunner(
2145 &common_task_runner.GetFlutterTaskRunnerDescription());
2146
2147 {
2148 std::scoped_lock lock(engine_mutex);
2149 engine = builder.InitializeEngine();
2150 }
2151
2152 ASSERT_EQ(FlutterEngineRunInitialized(engine.get()), kSuccess);
2153
2154 ASSERT_TRUE(engine.is_valid());
2155
2156 FlutterWindowMetricsEvent event = {};
2157 event.struct_size = sizeof(event);
2158 event.width = 800;
2159 event.height = 600;
2160 event.pixel_ratio = 1.0;
2162 kSuccess);
2163 });
2164
2165 task_latch.Wait();
2166
2167 // Don't use the task latch because that may be called multiple time
2168 // (including during the shutdown process).
2169 fml::AutoResetWaitableEvent shutdown_latch;
2170
2171 platform_task_runner->PostTask([&]() {
2172 ASSERT_TRUE(task_executed);
2173 ASSERT_EQ(FlutterEngineDeinitialize(engine.get()), kSuccess);
2174
2175 {
2176 std::scoped_lock engine_lock(engine_mutex);
2177 engine.reset();
2178 }
2179 shutdown_latch.Signal();
2180 });
2181
2182 shutdown_latch.Wait();
2183
2184 {
2185 std::scoped_lock engine_lock(engine_mutex);
2186 // Engine should have been killed by this point.
2187 ASSERT_FALSE(engine.is_valid());
2188 }
2189}

◆ TEST_P() [2/6]

flutter::testing::TEST_P ( EmbedderTestMultiBackend  ,
CanRenderGradientWithCompositor   
)

Definition at line 1614 of file embedder_gl_unittests.cc.

1614 {
1615 EmbedderTestContextType backend = GetParam();
1616 auto& context = GetEmbedderContext(backend);
1617
1618 EmbedderConfigBuilder builder(context);
1619
1620 builder.SetDartEntrypoint("render_gradient");
1621 builder.SetRendererConfig(backend, SkISize::Make(800, 600));
1622 builder.SetCompositor();
1623 builder.SetRenderTargetType(GetRenderTargetFromBackend(backend, true));
1624
1625 auto rendered_scene = context.GetNextSceneImage();
1626
1627 auto engine = builder.LaunchEngine();
1628 ASSERT_TRUE(engine.is_valid());
1629
1630 // Send a window metrics events so frames may be scheduled.
1631 FlutterWindowMetricsEvent event = {};
1632 event.struct_size = sizeof(event);
1633 event.width = 800;
1634 event.height = 600;
1635 event.pixel_ratio = 1.0;
1637 kSuccess);
1638
1639 ASSERT_TRUE(ImageMatchesFixture(
1640 FixtureNameForBackend(backend, "gradient.png"), rendered_scene));
1641}
EmbedderTestBackingStoreProducer::RenderTargetType GetRenderTargetFromBackend(EmbedderTestContextType backend, bool opengl_framebuffer)
Resolves a render target type for a given backend description. This is useful for tests that use Embe...

◆ TEST_P() [3/6]

flutter::testing::TEST_P ( EmbedderTestMultiBackend  ,
CanRenderGradientWithCompositorOnNonRootLayer   
)

Definition at line 1680 of file embedder_gl_unittests.cc.

1681 {
1682 EmbedderTestContextType backend = GetParam();
1683 auto& context = GetEmbedderContext(backend);
1684
1685 EmbedderConfigBuilder builder(context);
1686
1687 builder.SetDartEntrypoint("render_gradient_on_non_root_backing_store");
1688 builder.SetRendererConfig(backend, SkISize::Make(800, 600));
1689 builder.SetCompositor();
1690 builder.SetRenderTargetType(GetRenderTargetFromBackend(backend, true));
1691
1692 context.GetCompositor().SetNextPresentCallback(
1693 [&](FlutterViewId view_id, const FlutterLayer** layers,
1694 size_t layers_count) {
1695 ASSERT_EQ(layers_count, 3u);
1696
1697 // Layer Root
1698 {
1699 FlutterBackingStore backing_store = *layers[0]->backing_store;
1700 backing_store.did_update = true;
1701 ConfigureBackingStore(backing_store, backend, true);
1702
1703 FlutterRect paint_region_rects[] = {
1704 FlutterRectMakeLTRB(0, 0, 800, 600),
1705 };
1706 FlutterRegion paint_region = {
1707 .struct_size = sizeof(FlutterRegion),
1708 .rects_count = 1,
1709 .rects = paint_region_rects,
1710 };
1711 FlutterBackingStorePresentInfo present_info = {
1713 .paint_region = &paint_region,
1714 };
1715
1716 FlutterLayer layer = {};
1717 layer.struct_size = sizeof(layer);
1719 layer.backing_store = &backing_store;
1720 layer.size = FlutterSizeMake(800.0, 600.0);
1721 layer.offset = FlutterPointMake(0.0, 0.0);
1722 layer.backing_store_present_info = &present_info;
1723
1724 ASSERT_EQ(*layers[0], layer);
1725 }
1726
1727 // Layer 1
1728 {
1731 platform_view.identifier = 1;
1732
1733 FlutterLayer layer = {};
1734 layer.struct_size = sizeof(layer);
1737 layer.size = FlutterSizeMake(100.0, 200.0);
1738 layer.offset = FlutterPointMake(0.0, 0.0);
1739
1740 ASSERT_EQ(*layers[1], layer);
1741 }
1742
1743 // Layer 2
1744 {
1745 FlutterBackingStore backing_store = *layers[2]->backing_store;
1746 backing_store.did_update = true;
1747 ConfigureBackingStore(backing_store, backend, true);
1748
1749 FlutterRect paint_region_rects[] = {
1750 FlutterRectMakeLTRB(0, 0, 800, 600),
1751 };
1752 FlutterRegion paint_region = {
1753 .struct_size = sizeof(FlutterRegion),
1754 .rects_count = 1,
1755 .rects = paint_region_rects,
1756 };
1757 FlutterBackingStorePresentInfo present_info = {
1759 .paint_region = &paint_region,
1760 };
1761
1762 FlutterLayer layer = {};
1763 layer.struct_size = sizeof(layer);
1765 layer.backing_store = &backing_store;
1766 layer.size = FlutterSizeMake(800.0, 600.0);
1767 layer.offset = FlutterPointMake(0.0, 0.0);
1768 layer.backing_store_present_info = &present_info;
1769
1770 ASSERT_EQ(*layers[2], layer);
1771 }
1772 });
1773
1774 context.GetCompositor().SetPlatformViewRendererCallback(
1775 [&](const FlutterLayer& layer,
1776 GrDirectContext* context) -> sk_sp<SkImage> {
1777 auto surface = CreateRenderSurface(layer, context);
1778 auto canvas = surface->getCanvas();
1779 FML_CHECK(canvas != nullptr);
1780
1781 switch (layer.platform_view->identifier) {
1782 case 1: {
1783 FML_CHECK(layer.size.width == 100);
1784 FML_CHECK(layer.size.height == 200);
1785 // This is occluded anyway. We just want to make sure we see this.
1786 } break;
1787 default:
1788 // Asked to render an unknown platform view.
1789 FML_CHECK(false)
1790 << "Test was asked to composite an unknown platform view.";
1791 }
1792
1793 return surface->makeImageSnapshot();
1794 });
1795
1796 auto rendered_scene = context.GetNextSceneImage();
1797
1798 auto engine = builder.LaunchEngine();
1799 ASSERT_TRUE(engine.is_valid());
1800
1801 // Send a window metrics events so frames may be scheduled.
1802 FlutterWindowMetricsEvent event = {};
1803 event.struct_size = sizeof(event);
1804 event.width = 800;
1805 event.height = 600;
1806 event.pixel_ratio = 1.0;
1808 kSuccess);
1809
1810 ASSERT_TRUE(ImageMatchesFixture(
1811 FixtureNameForBackend(backend, "gradient.png"), rendered_scene));
1812}
void ConfigureBackingStore(FlutterBackingStore &backing_store, EmbedderTestContextType backend, bool opengl_framebuffer)
Configures per-backend properties for a given backing store.

◆ TEST_P() [4/6]

flutter::testing::TEST_P ( EmbedderTestMultiBackend  ,
CanRenderGradientWithoutCompositor   
)

Definition at line 1554 of file embedder_gl_unittests.cc.

1554 {
1555 EmbedderTestContextType backend = GetParam();
1556 auto& context = GetEmbedderContext(backend);
1557
1558 EmbedderConfigBuilder builder(context);
1559
1560 builder.SetDartEntrypoint("render_gradient");
1561 builder.SetRendererConfig(backend, SkISize::Make(800, 600));
1562
1563 auto rendered_scene = context.GetNextSceneImage();
1564
1565 auto engine = builder.LaunchEngine();
1566 ASSERT_TRUE(engine.is_valid());
1567
1568 // Send a window metrics events so frames may be scheduled.
1569 FlutterWindowMetricsEvent event = {};
1570 event.struct_size = sizeof(event);
1571 event.width = 800;
1572 event.height = 600;
1573 event.pixel_ratio = 1.0;
1575 kSuccess);
1576
1577 ASSERT_TRUE(ImageMatchesFixture(
1578 FixtureNameForBackend(backend, "gradient.png"), rendered_scene));
1579}

◆ TEST_P() [5/6]

flutter::testing::TEST_P ( EmbedderTestMultiBackend  ,
CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurface   
)

Definition at line 2191 of file embedder_gl_unittests.cc.

2192 {
2193 EmbedderTestContextType backend = GetParam();
2194 auto& context = GetEmbedderContext(backend);
2195
2196 EmbedderConfigBuilder builder(context);
2197 builder.SetRendererConfig(backend, SkISize::Make(800, 600));
2198 builder.SetCompositor();
2199 builder.SetDartEntrypoint("can_display_platform_view_with_pixel_ratio");
2200
2201 builder.SetRenderTargetType(GetRenderTargetFromBackend(backend, false));
2202
2203 fml::CountDownLatch latch(1);
2204
2205 auto rendered_scene = context.GetNextSceneImage();
2206
2207 context.GetCompositor().SetNextPresentCallback(
2208 [&](FlutterViewId view_id, const FlutterLayer** layers,
2209 size_t layers_count) {
2210 ASSERT_EQ(layers_count, 3u);
2211
2212 // Layer 0 (Root)
2213 {
2214 FlutterBackingStore backing_store = *layers[0]->backing_store;
2215 backing_store.did_update = true;
2216 ConfigureBackingStore(backing_store, backend, false);
2217
2218 FlutterRect paint_region_rects[] = {
2219 FlutterRectMakeLTRB(0, 0, 800, 600),
2220 };
2221 FlutterRegion paint_region = {
2222 .struct_size = sizeof(FlutterRegion),
2223 .rects_count = 1,
2224 .rects = paint_region_rects,
2225 };
2226 FlutterBackingStorePresentInfo present_info = {
2228 .paint_region = &paint_region,
2229 };
2230
2231 FlutterLayer layer = {};
2232 layer.struct_size = sizeof(layer);
2234 layer.backing_store = &backing_store;
2235 layer.size = FlutterSizeMake(800.0, 600.0);
2236 layer.offset = FlutterPointMake(0.0, 0.0);
2237 layer.backing_store_present_info = &present_info;
2238
2239 ASSERT_EQ(*layers[0], layer);
2240 }
2241
2242 // Layer 1
2243 {
2246 platform_view.identifier = 42;
2247
2248 FlutterLayer layer = {};
2249 layer.struct_size = sizeof(layer);
2252 layer.size = FlutterSizeMake(800.0, 560.0);
2253 layer.offset = FlutterPointMake(0.0, 40.0);
2254
2255 ASSERT_EQ(*layers[1], layer);
2256 }
2257
2258 // Layer 2
2259 {
2260 FlutterBackingStore backing_store = *layers[2]->backing_store;
2261 backing_store.did_update = true;
2262 ConfigureBackingStore(backing_store, backend, false);
2263
2264 FlutterRect paint_region_rects[] = {
2265 FlutterRectMakeLTRB(0, 0, 800, 600),
2266 };
2267 FlutterRegion paint_region = {
2268 .struct_size = sizeof(FlutterRegion),
2269 .rects_count = 1,
2270 .rects = paint_region_rects,
2271 };
2272 FlutterBackingStorePresentInfo present_info = {
2274 .paint_region = &paint_region,
2275 };
2276
2277 FlutterLayer layer = {};
2278 layer.struct_size = sizeof(layer);
2280 layer.backing_store = &backing_store;
2281 layer.size = FlutterSizeMake(800.0, 600.0);
2282 layer.offset = FlutterPointMake(0.0, 0.0);
2283 layer.backing_store_present_info = &present_info;
2284
2285 ASSERT_EQ(*layers[2], layer);
2286 }
2287
2288 latch.CountDown();
2289 });
2290
2291 auto engine = builder.LaunchEngine();
2292
2293 // Send a window metrics events so frames may be scheduled.
2294 FlutterWindowMetricsEvent event = {};
2295 event.struct_size = sizeof(event);
2296 event.width = 400 * 2.0;
2297 event.height = 300 * 2.0;
2298 event.pixel_ratio = 2.0;
2300 kSuccess);
2301 ASSERT_TRUE(engine.is_valid());
2302
2303 latch.Wait();
2304
2305 ASSERT_TRUE(ImageMatchesFixture(
2306 FixtureNameForBackend(backend, "dpr_noxform.png"), rendered_scene));
2307}

◆ TEST_P() [6/6]

flutter::testing::TEST_P ( EmbedderTestMultiBackend  ,
PlatformViewMutatorsAreValid   
)

Definition at line 2517 of file embedder_gl_unittests.cc.

2517 {
2518 EmbedderTestContextType backend = GetParam();
2519 auto& context = GetEmbedderContext(backend);
2520
2521 EmbedderConfigBuilder builder(context);
2522 builder.SetRendererConfig(backend, SkISize::Make(800, 600));
2523 builder.SetCompositor();
2524 builder.SetDartEntrypoint("platform_view_mutators");
2525
2526 builder.SetRenderTargetType(GetRenderTargetFromBackend(backend, false));
2527
2528 fml::CountDownLatch latch(1);
2529 context.GetCompositor().SetNextPresentCallback(
2530 [&](FlutterViewId view_id, const FlutterLayer** layers,
2531 size_t layers_count) {
2532 ASSERT_EQ(layers_count, 2u);
2533
2534 // Layer 0 (Root)
2535 {
2536 FlutterBackingStore backing_store = *layers[0]->backing_store;
2537 backing_store.did_update = true;
2538 ConfigureBackingStore(backing_store, backend, false);
2539
2540 FlutterRect paint_region_rects[] = {
2541 FlutterRectMakeLTRB(0, 0, 800, 600),
2542 };
2543 FlutterRegion paint_region = {
2544 .struct_size = sizeof(FlutterRegion),
2545 .rects_count = 1,
2546 .rects = paint_region_rects,
2547 };
2548 FlutterBackingStorePresentInfo present_info = {
2550 .paint_region = &paint_region,
2551 };
2552
2553 FlutterLayer layer = {};
2554 layer.struct_size = sizeof(layer);
2556 layer.backing_store = &backing_store;
2557 layer.size = FlutterSizeMake(800.0, 600.0);
2558 layer.offset = FlutterPointMake(0.0, 0.0);
2559 layer.backing_store_present_info = &present_info;
2560
2561 ASSERT_EQ(*layers[0], layer);
2562 }
2563
2564 // Layer 2
2565 {
2568 platform_view.identifier = 42;
2569 platform_view.mutations_count = 3;
2570
2571 FlutterLayer layer = {};
2572 layer.struct_size = sizeof(layer);
2575 layer.size = FlutterSizeMake(800.0, 600.0);
2576 layer.offset = FlutterPointMake(0.0, 0.0);
2577
2578 ASSERT_EQ(*layers[1], layer);
2579
2580 // There are no ordering guarantees.
2581 for (size_t i = 0; i < platform_view.mutations_count; i++) {
2582 FlutterPlatformViewMutation mutation = *platform_view.mutations[i];
2583 switch (mutation.type) {
2585 mutation.clip_rounded_rect =
2587 SkRect::MakeLTRB(10.0, 10.0, 800.0 - 10.0,
2588 600.0 - 10.0),
2589 14.0, 14.0));
2590 break;
2593 mutation.clip_rect = FlutterRectMake(
2594 SkRect::MakeXYWH(10.0, 10.0, 800.0 - 20.0, 600.0 - 20.0));
2595 break;
2598 mutation.opacity = 128.0 / 255.0;
2599 break;
2601 FML_CHECK(false)
2602 << "There should be no transformation in the test.";
2603 break;
2604 }
2605
2606 ASSERT_EQ(*platform_view.mutations[i], mutation);
2607 }
2608 }
2609 latch.CountDown();
2610 });
2611
2612 auto engine = builder.LaunchEngine();
2613
2614 // Send a window metrics events so frames may be scheduled.
2615 FlutterWindowMetricsEvent event = {};
2616 event.struct_size = sizeof(event);
2617 event.width = 800;
2618 event.height = 600;
2619 event.pixel_ratio = 1.0;
2621 kSuccess);
2622 ASSERT_TRUE(engine.is_valid());
2623
2624 latch.Wait();
2625}

◆ test_rtree()

static void flutter::testing::test_rtree ( const sk_sp< const DlRTree > &  rtree,
const SkRect query,
std::vector< SkRect expected_rects,
const std::vector< int > &  expected_indices 
)
static

Definition at line 2150 of file display_list_unittests.cc.

2153 {
2154 std::vector<int> indices;
2155 rtree->search(query, &indices);
2156 EXPECT_EQ(indices, expected_indices);
2157 EXPECT_EQ(indices.size(), expected_indices.size());
2158 std::list<SkRect> rects = rtree->searchAndConsolidateRects(query);
2159 // ASSERT_EQ(rects.size(), expected_indices.size());
2160 auto iterator = rects.cbegin();
2161 for (int i : expected_indices) {
2162 EXPECT_TRUE(iterator != rects.cend());
2163 EXPECT_EQ(*iterator++, expected_rects[i]);
2164 }
2165}

◆ TestBounds() [1/2]

static void flutter::testing::TestBounds ( const DlImageFilter filter,
const SkRect sourceBounds,
const SkPoint  expectedLocalOutputQuad[4] 
)
static

Definition at line 116 of file dl_image_filter_unittests.cc.

118 {
119 SkRect local_filter_bounds;
120 ASSERT_EQ(filter.map_local_bounds(sourceBounds, local_filter_bounds),
121 &local_filter_bounds);
122 ASSERT_TRUE(containsInclusive(local_filter_bounds, expectedLocalOutputQuad));
123
124 for (int scale = 1; scale <= 4; scale++) {
125 for (int skew = 0; skew < 8; skew++) {
126 for (int degrees = 0; degrees <= 360; degrees += 15) {
127 SkMatrix matrix;
128 matrix.setScale(scale, scale);
129 matrix.postSkew(skew / 8.0, skew / 8.0);
130 matrix.postRotate(degrees);
131 ASSERT_TRUE(matrix.invert(nullptr));
132 TestBoundsWithMatrix(filter, matrix, sourceBounds,
133 expectedLocalOutputQuad);
134 matrix.setPerspX(0.001);
135 matrix.setPerspY(0.001);
136 ASSERT_TRUE(matrix.invert(nullptr));
137 TestBoundsWithMatrix(filter, matrix, sourceBounds,
138 expectedLocalOutputQuad);
139 }
140 }
141 }
142}
virtual SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const =0
static void TestBoundsWithMatrix(const DlImageFilter &filter, const SkMatrix &matrix, const SkRect &sourceBounds, const SkPoint expectedLocalOutputQuad[4])

◆ TestBounds() [2/2]

static void flutter::testing::TestBounds ( const DlImageFilter filter,
const SkRect sourceBounds,
const SkRect expectedLocalOutputBounds 
)
static

Definition at line 144 of file dl_image_filter_unittests.cc.

146 {
147 SkPoint expected_local_output_quad[4];
148 expectedLocalOutputBounds.toQuad(expected_local_output_quad);
149 TestBounds(filter, sourceBounds, expected_local_output_quad);
150}
void toQuad(SkPoint quad[4]) const
Definition SkRect.cpp:50

◆ TestBoundsWithMatrix()

static void flutter::testing::TestBoundsWithMatrix ( const DlImageFilter filter,
const SkMatrix matrix,
const SkRect sourceBounds,
const SkPoint  expectedLocalOutputQuad[4] 
)
static

Definition at line 64 of file dl_image_filter_unittests.cc.

67 {
68 SkRect device_input_bounds = matrix.mapRect(sourceBounds);
69 SkPoint expected_output_quad[4];
70 matrix.mapPoints(expected_output_quad, expectedLocalOutputQuad, 4);
71
72 SkIRect device_filter_ibounds;
73 ASSERT_EQ(filter.map_device_bounds(device_input_bounds.roundOut(), matrix,
74 device_filter_ibounds),
75 &device_filter_ibounds);
76 ASSERT_TRUE(containsInclusive(device_filter_ibounds, expected_output_quad));
77
78 SkIRect reverse_input_ibounds;
79 ASSERT_EQ(filter.get_input_device_bounds(device_filter_ibounds, matrix,
80 reverse_input_ibounds),
81 &reverse_input_ibounds);
82 ASSERT_TRUE(containsInclusive(reverse_input_ibounds, device_input_bounds));
83}
virtual SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const =0
virtual SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const =0

◆ TestDartVmFlags()

static void flutter::testing::TestDartVmFlags ( std::vector< const char * > &  flags)
static

Definition at line 369 of file shell_unittests.cc.

369 {
370 std::string flags_string = CreateFlagsString(flags);
371 const std::vector<fml::CommandLine::Option> options = {
372 fml::CommandLine::Option("dart-flags", flags_string)};
373 fml::CommandLine command_line("", options, std::vector<std::string>());
375 EXPECT_EQ(settings.dart_flags.size(), flags.size());
376 for (size_t i = 0; i < flags.size(); ++i) {
377 EXPECT_EQ(settings.dart_flags[i], flags[i]);
378 }
379}
static std::string CreateFlagsString(std::vector< const char * > &flags)

◆ testEquals() [1/3]

void flutter::testing::testEquals ( const std::shared_ptr< const DlMaskFilter > &  a,
const std::shared_ptr< const DlMaskFilter > &  b 
)

Definition at line 82 of file dl_mask_filter_unittests.cc.

83 {
84 // a and b have the same nullness or values
85 ASSERT_TRUE(Equals(a, b));
86 ASSERT_FALSE(NotEquals(a, b));
87 ASSERT_TRUE(Equals(b, a));
88 ASSERT_FALSE(NotEquals(b, a));
89}
bool NotEquals(const T *a, const T *b)

◆ testEquals() [2/3]

void flutter::testing::testEquals ( const std::shared_ptr< const DlMaskFilter > &  a,
DlMaskFilter b 
)

Definition at line 65 of file dl_mask_filter_unittests.cc.

65 {
66 // a and b have the same nullness or values
67 ASSERT_TRUE(Equals(a, b));
68 ASSERT_FALSE(NotEquals(a, b));
69 ASSERT_TRUE(Equals(b, a));
70 ASSERT_FALSE(NotEquals(b, a));
71}

◆ testEquals() [3/3]

void flutter::testing::testEquals ( DlMaskFilter a,
DlMaskFilter b 
)

Definition at line 49 of file dl_mask_filter_unittests.cc.

49 {
50 // a and b have the same nullness or values
51 ASSERT_TRUE(Equals(a, b));
52 ASSERT_FALSE(NotEquals(a, b));
53 ASSERT_TRUE(Equals(b, a));
54 ASSERT_FALSE(NotEquals(b, a));
55}

◆ TestEquals()

template<class T >
static void flutter::testing::TestEquals ( T source1,
T source2 
)
static

Definition at line 16 of file dl_test_equality.h.

16 {
17 ASSERT_TRUE(source1 == source2);
18 ASSERT_TRUE(source2 == source1);
19 ASSERT_FALSE(source1 != source2);
20 ASSERT_FALSE(source2 != source1);
21 ASSERT_EQ(source1, source2);
22 ASSERT_EQ(source2, source1);
23 ASSERT_TRUE(Equals(&source1, &source2));
24 ASSERT_TRUE(Equals(&source2, &source1));
25}

◆ TestInvalidBounds()

static void flutter::testing::TestInvalidBounds ( const DlImageFilter filter,
const SkMatrix matrix,
const SkRect localInputBounds 
)
static

Definition at line 85 of file dl_image_filter_unittests.cc.

87 {
88 SkIRect device_input_bounds = matrix.mapRect(localInputBounds).roundOut();
89
90 SkRect local_filter_bounds;
91 ASSERT_EQ(filter.map_local_bounds(localInputBounds, local_filter_bounds),
92 nullptr);
93 ASSERT_EQ(local_filter_bounds, localInputBounds);
94
95 SkIRect device_filter_ibounds;
96 ASSERT_EQ(filter.map_device_bounds(device_input_bounds, matrix,
97 device_filter_ibounds),
98 nullptr);
99 ASSERT_EQ(device_filter_ibounds, device_input_bounds);
100
101 SkIRect reverse_input_ibounds;
102 ASSERT_EQ(filter.get_input_device_bounds(device_input_bounds, matrix,
103 reverse_input_ibounds),
104 nullptr);
105 ASSERT_EQ(reverse_input_ibounds, device_input_bounds);
106}

◆ TestLabel()

std::string flutter::testing::TestLabel ( const ::testing::TestInfo &  info)

Definition at line 36 of file logger_listener.cc.

36 {
37 return std::string{info.test_suite_name()} + "." + info.name();
38}

◆ testNotEquals() [1/3]

void flutter::testing::testNotEquals ( const std::shared_ptr< const DlMaskFilter > &  a,
const std::shared_ptr< const DlMaskFilter > &  b 
)

Definition at line 91 of file dl_mask_filter_unittests.cc.

92 {
93 // a and b do not have the same nullness or values
94 ASSERT_FALSE(Equals(a, b));
95 ASSERT_TRUE(NotEquals(a, b));
96 ASSERT_FALSE(Equals(b, a));
97 ASSERT_TRUE(NotEquals(b, a));
98}

◆ testNotEquals() [2/3]

void flutter::testing::testNotEquals ( const std::shared_ptr< const DlMaskFilter > &  a,
DlMaskFilter b 
)

Definition at line 73 of file dl_mask_filter_unittests.cc.

74 {
75 // a and b do not have the same nullness or values
76 ASSERT_FALSE(Equals(a, b));
77 ASSERT_TRUE(NotEquals(a, b));
78 ASSERT_FALSE(Equals(b, a));
79 ASSERT_TRUE(NotEquals(b, a));
80}

◆ testNotEquals() [3/3]

void flutter::testing::testNotEquals ( DlMaskFilter a,
DlMaskFilter b 
)

Definition at line 57 of file dl_mask_filter_unittests.cc.

57 {
58 // a and b do not have the same nullness or values
59 ASSERT_FALSE(Equals(a, b));
60 ASSERT_TRUE(NotEquals(a, b));
61 ASSERT_FALSE(Equals(b, a));
62 ASSERT_TRUE(NotEquals(b, a));
63}

◆ TestNotEquals()

template<class T >
static void flutter::testing::TestNotEquals ( T source1,
T source2,
const std::string &  label 
)
static

Definition at line 28 of file dl_test_equality.h.

28 {
29 ASSERT_FALSE(source1 == source2) << label;
30 ASSERT_FALSE(source2 == source1) << label;
31 ASSERT_TRUE(source1 != source2) << label;
32 ASSERT_TRUE(source2 != source1) << label;
33 ASSERT_NE(source1, source2) << label;
34 ASSERT_NE(source2, source1) << label;
35 ASSERT_TRUE(NotEquals(&source1, &source2));
36 ASSERT_TRUE(NotEquals(&source2, &source1));
37}

◆ TestSimulatedInputEvents()

static void flutter::testing::TestSimulatedInputEvents ( ShellTest fixture,
int  num_events,
UnitlessTime  base_latency,
Generator  delivery_time,
UnitlessTime  frame_time,
std::vector< UnitlessTime > &  events_consumed_at_frame,
bool  restart_engine = false 
)
static

Simulate n input events where the i-th one is delivered at delivery_time(i).

Simulation results will be written into events_consumed_at_frame whose length will be equal to the number of frames drawn. Each element in the vector is the number of input events consumed up to that frame. (We can't return such vector because ASSERT_TRUE requires return type of void.)

We assume (and check) that the delivery latency is some base latency plus a random latency where the random latency must be within one frame:

  1. latency = delivery_time(i) - j * frame_time = base_latency + random_latency
  2. 0 <= base_latency, 0 <= random_latency < frame_time

We also assume that there will be at least one input event per frame if there were no latency. Let j = floor( (delivery_time(i) - base_latency) / frame_time ) be the frame index if there were no latency. Then the set of j should be all integers from 0 to continuous_frame_count - 1 for some integer continuous_frame_count.

(Note that there coulds be multiple input events within one frame.)

The test here is insensitive to the choice of time unit as long as delivery_time and frame_time are in the same unit.

Definition at line 47 of file input_events_unittests.cc.

54 {
55 ///// Begin constructing shell ///////////////////////////////////////////////
56 auto settings = fixture->CreateSettingsForFixture();
57 std::unique_ptr<Shell> shell = fixture->CreateShell({
58 .settings = settings,
59 .platform_view_create_callback = ShellTestPlatformViewBuilder({
60 .simulate_vsync = true,
61 }),
62 });
63
64 auto configuration = RunConfiguration::InferFromSettings(settings);
65 configuration.SetEntrypoint("onPointerDataPacketMain");
66
67 // The following 4 variables are only accessed in the UI thread by
68 // nativeOnPointerDataPacket and nativeOnBeginFrame between their
69 // initializations and `shell.reset()`.
70 events_consumed_at_frame.clear();
71 bool will_draw_new_frame = true;
72 int events_consumed = 0;
73 int frame_drawn = 0;
74 auto nativeOnPointerDataPacket = [&events_consumed_at_frame,
75 &will_draw_new_frame, &events_consumed,
76 &frame_drawn](Dart_NativeArguments args) {
77 events_consumed += 1;
78 if (will_draw_new_frame) {
79 frame_drawn += 1;
80 will_draw_new_frame = false;
81 events_consumed_at_frame.push_back(events_consumed);
82 } else {
83 events_consumed_at_frame.back() = events_consumed;
84 }
85 };
86 fixture->AddNativeCallback("NativeOnPointerDataPacket",
87 CREATE_NATIVE_ENTRY(nativeOnPointerDataPacket));
88
89 ASSERT_TRUE(configuration.IsValid());
90 fixture->RunEngine(shell.get(), std::move(configuration));
91
92 if (restart_engine) {
93 auto new_configuration = RunConfiguration::InferFromSettings(settings);
94 new_configuration.SetEntrypoint("onPointerDataPacketMain");
95 ASSERT_TRUE(new_configuration.IsValid());
96 fixture->RestartEngine(shell.get(), std::move(new_configuration));
97 }
98 ///// End constructing shell /////////////////////////////////////////////////
99
100 ASSERT_GE(base_latency, 0);
101
102 // Check that delivery_time satisfies our assumptions.
103 int continuous_frame_count = 0;
104 for (int i = 0; i < num_events; i += 1) {
105 // j is the frame index of event i if there were no latency.
106 int j = static_cast<int>((delivery_time(i) - base_latency) / frame_time);
107 if (j == continuous_frame_count) {
108 continuous_frame_count += 1;
109 }
110 double random_latency = delivery_time(i) - j * frame_time - base_latency;
111 ASSERT_GE(random_latency, 0);
112 ASSERT_LT(random_latency, frame_time);
113
114 // If there were no latency, there should be at least one event per frame.
115 // Hence j should never skip any integer less than continuous_frame_count.
116 ASSERT_LT(j, continuous_frame_count);
117 }
118
119 // This has to be running on a different thread than Platform thread to avoid
120 // dead locks.
121 auto simulation = std::async(std::launch::async, [&]() {
122 // i is the input event's index.
123 // j is the frame's index.
124 for (int i = 0, j = 0; i < num_events; j += 1) {
125 double t = j * frame_time;
126 while (i < num_events && delivery_time(i) <= t) {
127 ShellTest::DispatchFakePointerData(shell.get());
128 i += 1;
129 }
130 ShellTest::VSyncFlush(shell.get(), &will_draw_new_frame);
131 }
132 // Finally, issue a vsync for the pending event that may be generated duing
133 // the last vsync.
134 ShellTest::VSyncFlush(shell.get(), &will_draw_new_frame);
135 });
136
137 simulation.wait();
138
139 TaskRunners task_runners = fixture->GetTaskRunnersForFixture();
141 task_runners.GetPlatformTaskRunner()->PostTask([&shell, &latch]() mutable {
142 shell.reset();
143 latch.Signal();
144 });
145 latch.Wait();
146
147 // Make sure that all events have been consumed so
148 // https://github.com/flutter/flutter/issues/40863 won't happen again.
149 ASSERT_EQ(events_consumed_at_frame.back(), num_events);
150}
void AddNativeCallback(const std::string &name, Dart_NativeFunction callback)
static void RunEngine(Shell *shell, RunConfiguration configuration)
Settings CreateSettingsForFixture() override
TaskRunners GetTaskRunnersForFixture()
std::unique_ptr< Shell > CreateShell(const Settings &settings, std::optional< TaskRunners > task_runners={})
static void RestartEngine(Shell *shell, RunConfiguration configuration)

◆ TestStatusAsString()

std::string flutter::testing::TestStatusAsString ( const ::testing::TestResult *  result)

Definition at line 20 of file logger_listener.cc.

20 {
21 if (result == nullptr) {
22 return "UNKNOWN";
23 }
24 if (result->Passed()) {
25 return "PASSED";
26 }
27 if (result->Skipped()) {
28 return "SKIPPED";
29 }
30 if (result->Failed()) {
31 return "FAILED";
32 }
33 return "UNKNOWN";
34}

◆ TestTimeAsString()

std::string flutter::testing::TestTimeAsString ( const ::testing::TestResult *  result)

Definition at line 40 of file logger_listener.cc.

40 {
41 if (result == nullptr) {
42 return "UNKNOWN";
43 }
44 return std::to_string(result->elapsed_time()) + " ms";
45}

◆ TestUnboundedBounds()

static void flutter::testing::TestUnboundedBounds ( DlImageFilter filter,
const SkRect sourceBounds,
const SkRect expectedOutputBounds,
const SkRect expectedInputBounds 
)
static

Definition at line 548 of file dl_image_filter_unittests.cc.

551 {
552 SkRect bounds;
553 EXPECT_EQ(filter.map_local_bounds(sourceBounds, bounds), nullptr);
554 EXPECT_EQ(bounds, expectedOutputBounds);
555
556 SkIRect ibounds;
557 EXPECT_EQ(
558 filter.map_device_bounds(sourceBounds.roundOut(), SkMatrix::I(), ibounds),
559 nullptr);
560 EXPECT_EQ(ibounds, expectedOutputBounds.roundOut());
561
562 EXPECT_EQ(filter.get_input_device_bounds(sourceBounds.roundOut(),
563 SkMatrix::I(), ibounds),
564 nullptr);
565 EXPECT_EQ(ibounds, expectedInputBounds.roundOut());
566}

◆ UnpackPointerPacket()

void flutter::testing::UnpackPointerPacket ( std::vector< PointerData > &  output,
std::unique_ptr< PointerDataPacket packet 
)

Definition at line 137 of file pointer_data_packet_converter_unittests.cc.

138 {
139 for (size_t i = 0; i < packet->GetLength(); i++) {
140 PointerData pointer_data = packet->GetPointerData(i);
141 output.push_back(pointer_data);
142 }
143 packet.reset();
144}

◆ UnserializeKeyEventDeviceType()

FlutterKeyEventDeviceType flutter::testing::UnserializeKeyEventDeviceType ( uint64_t  source)

Definition at line 2872 of file embedder_unittests.cc.

2872 {
2873 switch (source) {
2874 case 1:
2876 case 2:
2878 case 3:
2880 case 4:
2882 case 5:
2884 default:
2887 }
2888}
@ kFlutterKeyEventDeviceTypeDirectionalPad
Definition embedder.h:1080
@ kFlutterKeyEventDeviceTypeHdmi
Definition embedder.h:1083
@ kFlutterKeyEventDeviceTypeJoystick
Definition embedder.h:1082
@ kFlutterKeyEventDeviceTypeGamepad
Definition embedder.h:1081

◆ UnserializeKeyEventType()

FlutterKeyEventType flutter::testing::UnserializeKeyEventType ( uint64_t  kind)

Definition at line 2854 of file embedder_unittests.cc.

2854 {
2855 switch (kind) {
2856 case 1:
2858 case 2:
2860 case 3:
2862 default:
2865 }
2866}

◆ ValidateDestroyPlatformView()

static void flutter::testing::ValidateDestroyPlatformView ( Shell shell)
static

Definition at line 348 of file shell_unittests.cc.

348 {
349 ASSERT_TRUE(shell != nullptr);
350 ASSERT_TRUE(shell->IsSetup());
351
352 ASSERT_FALSE(RasterizerIsTornDown(shell));
353 ShellTest::PlatformViewNotifyDestroyed(shell);
354 ASSERT_TRUE(RasterizerIsTornDown(shell));
355}
static bool RasterizerIsTornDown(Shell *shell)

◆ ValidateShell()

static bool flutter::testing::ValidateShell ( Shell shell)
static

Definition at line 311 of file shell_unittests.cc.

311 {
312 if (!shell) {
313 return false;
314 }
315
316 if (!shell->IsSetup()) {
317 return false;
318 }
319
320 ShellTest::PlatformViewNotifyCreated(shell);
321
322 {
325 shell->GetTaskRunners().GetPlatformTaskRunner(), [shell, &latch]() {
326 shell->GetPlatformView()->NotifyDestroyed();
327 latch.Signal();
328 });
329 latch.Wait();
330 }
331
332 return true;
333}

◆ VerbToString()

std::string flutter::testing::VerbToString ( SkPath::Verb  type)

Definition at line 619 of file dl_benchmarks.cc.

619 {
620 switch (type) {
622 return "Lines";
624 return "Quads";
626 return "Conics";
628 return "Cubics";
629 default:
630 return "Unknown";
631 }
632}

◆ VertexModeToString()

std::string flutter::testing::VertexModeToString ( DlVertexMode  mode)

Definition at line 759 of file dl_benchmarks.cc.

759 {
760 switch (mode) {
761 case DlVertexMode::kTriangleStrip:
762 return "TriangleStrip";
763 case DlVertexMode::kTriangleFan:
764 return "TriangleFan";
765 case DlVertexMode::kTriangles:
766 return "Triangles";
767 }
768 return "Unknown";
769}

◆ VietnameseTelexAddDiacriticWithSlowResponse()

void flutter::testing::VietnameseTelexAddDiacriticWithSlowResponse ( WindowsTestContext context,
bool  backspace_response 
)

Definition at line 2349 of file keyboard_unittests.cc.

2350 {
2351 // In this test, the user presses the following keys:
2352 //
2353 // Key Current text
2354 // ===========================
2355 // A a
2356 // F à
2357 //
2358 // And the Backspace down event is responded slowly with `backspace_response`.
2359
2360 KeyboardTester tester{context};
2361 tester.Responding(false);
2362
2363 // US Keyboard layout
2364
2365 // Press A
2366 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2367 WmKeyDownInfo{kVirtualKeyA, kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2368 kWmResultZero),
2369 WmCharInfo{'a', kScanCodeKeyA, kNotExtended, kWasUp}.Build(
2370 kWmResultZero)});
2371
2372 EXPECT_EQ(tester.key_calls.size(), 2);
2374 kPhysicalKeyA, kLogicalKeyA, "a", kNotSynthesized);
2375 EXPECT_CALL_IS_TEXT(tester.key_calls[1], u"a");
2376 tester.clear_key_calls();
2377 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 2);
2378
2379 // Release A
2380 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2382 kWmResultZero)});
2383
2384 EXPECT_EQ(tester.key_calls.size(), 1);
2386 kPhysicalKeyA, kLogicalKeyA, "", kNotSynthesized);
2387 tester.clear_key_calls();
2388 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2389
2390 std::vector<MockKeyResponseController::ResponseCallback> recorded_callbacks;
2391 tester.LateResponding(
2392 [&recorded_callbacks](
2393 const FlutterKeyEvent* event,
2394 MockKeyResponseController::ResponseCallback callback) {
2395 recorded_callbacks.push_back(callback);
2396 });
2397
2398 // Press F, which is translated to:
2399 //
2400 // Backspace down, char & up, VK_PACKET('à').
2401 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2402 WmKeyDownInfo{VK_BACK, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2403 kWmResultZero),
2404 WmCharInfo{0x8, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2405 kWmResultZero),
2406 WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
2407 kWmResultZero),
2408 WmKeyDownInfo{VK_PACKET, 0, kNotExtended, kWasUp}.Build(kWmResultDefault),
2409 WmCharInfo{0xe0 /*'à'*/, 0, kNotExtended, kWasUp}.Build(kWmResultZero),
2410 WmKeyUpInfo{VK_PACKET, 0, kNotExtended}.Build(kWmResultDefault)});
2411
2412 // The Backspace event has not responded yet, therefore the char message must
2413 // hold. This is because when the framework is handling the Backspace event,
2414 // it will send a setEditingState message that updates the text state that has
2415 // the last character deleted (denoted by `string1`). Processing the char
2416 // message before then will cause the final text to set to `string1`.
2417 EXPECT_EQ(tester.key_calls.size(), 1);
2419 kPhysicalBackspace, kLogicalBackspace, "",
2420 kNotSynthesized);
2421 tester.clear_key_calls();
2422 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2423
2424 EXPECT_EQ(recorded_callbacks.size(), 1);
2425 recorded_callbacks[0](backspace_response);
2426
2427 EXPECT_EQ(tester.key_calls.size(), 1);
2429 kPhysicalBackspace, kLogicalBackspace, "",
2430 kNotSynthesized);
2431 tester.clear_key_calls();
2432 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(),
2433 backspace_response ? 0 : 2);
2434
2435 recorded_callbacks[1](false);
2436 EXPECT_EQ(tester.key_calls.size(), 1);
2437 EXPECT_CALL_IS_TEXT(tester.key_calls[0], u"à");
2438 tester.clear_key_calls();
2439 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
2440
2441 tester.Responding(false);
2442
2443 // Release F
2444 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
2445 WmKeyUpInfo{kVirtualKeyF, kScanCodeKeyF, kNotExtended,
2446 /* overwrite_prev_state_0 */ true}
2447 .Build(kWmResultZero)});
2448
2449 EXPECT_EQ(tester.key_calls.size(), 1);
2451 kNotSynthesized);
2452 tester.clear_key_calls();
2453 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
2454}

◆ WeakPtr()

template<class T >
auto flutter::testing::WeakPtr ( std::shared_ptr< T pointer)

Definition at line 67 of file test_timeout_listener.cc.

67 {
68 return std::weak_ptr<T>{pointer};
69}

◆ WriteImageToDisk()

bool flutter::testing::WriteImageToDisk ( const fml::UniqueFD directory,
const std::string &  name,
const sk_sp< SkImage > &  image 
)

Definition at line 134 of file embedder_unittests_util.cc.

136 {
137 if (!image) {
138 return false;
139 }
140
141 auto data = SkPngEncoder::Encode(nullptr, image.get(), {});
142
143 if (!data) {
144 return false;
145 }
146
147 fml::NonOwnedMapping mapping(static_cast<const uint8_t*>(data->data()),
148 data->size());
149 return WriteAtomically(directory, name.c_str(), mapping);
150}
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)

Variable Documentation

◆ allGroups

std::vector<testing::DisplayListInvocationGroup> flutter::testing::allGroups
static
Initial value:
=
std::vector< DisplayListInvocationGroup > CreateAllGroups()

Definition at line 43 of file display_list_unittests.cc.

◆ current_context

thread_local std::unique_ptr<int> flutter::testing::current_context
static

Definition at line 10 of file gl_context_switch_test.cc.

◆ gIsolateResolvers

std::map<Dart_Isolate, std::weak_ptr<TestDartNativeResolver> > flutter::testing::gIsolateResolvers
static

Definition at line 51 of file test_dart_native_resolver.cc.

◆ gIsolateResolversMutex

std::mutex flutter::testing::gIsolateResolversMutex
static

Definition at line 49 of file test_dart_native_resolver.cc.

◆ global_weak_persistent_value

tonic::DartWeakPersistentValue flutter::testing::global_weak_persistent_value
Initial value:

Definition at line 137 of file dart_weak_persistent_handle_unittest.cc.

◆ gProcessArgs

fml::CommandLine flutter::testing::gProcessArgs
static

Definition at line 10 of file test_args.cc.

◆ isolate_data_map_

thread_local std::unique_ptr<IsolateDataMap> flutter::testing::isolate_data_map_
static

Definition at line 33 of file platform_isolate_manager_unittests.cc.

◆ kArcSweepSetsToDraw

constexpr size_t flutter::testing::kArcSweepSetsToDraw = 1000
constexpr

Definition at line 79 of file dl_benchmarks.cc.

◆ kCirclesToDraw

constexpr size_t flutter::testing::kCirclesToDraw = 5000
constexpr

Definition at line 76 of file dl_benchmarks.cc.

◆ kColors

const DlColor flutter::testing::kColors[]
Initial value:
= {
DlColor::kGreen(),
DlColor::kYellow(),
DlColor::kBlue(),
}

Definition at line 31 of file dl_test_snippets.h.

31 {
32 DlColor::kGreen(),
33 DlColor::kYellow(),
34 DlColor::kBlue(),
35};

◆ kDefaultAOTAppELFFileName

constexpr const char* flutter::testing::kDefaultAOTAppELFFileName = "app_elf_snapshot.so"
inlineconstexpr

Definition at line 17 of file elf_loader.h.

◆ kDefaultAOTAppELFSplitFileName

constexpr const char* flutter::testing::kDefaultAOTAppELFSplitFileName
inlineconstexpr
Initial value:
=
"app_elf_snapshot.so-2.part.so"

Definition at line 24 of file elf_loader.h.

◆ kDRRectsToDraw

constexpr size_t flutter::testing::kDRRectsToDraw = 2000
constexpr

Definition at line 78 of file dl_benchmarks.cc.

◆ kElfFileName

const std::string flutter::testing::kElfFileName = "plugin_registrant_app_elf_snapshot.so"

Definition at line 23 of file dart_plugin_registrant_unittests.cc.

◆ kEmptyDlRenderer

const DlRenderer flutter::testing::kEmptyDlRenderer = [](const DlRenderContext&) {}
static

Definition at line 362 of file dl_rendering_unittests.cc.

362{};

◆ kEmptyDlSetup

const DlSetup flutter::testing::kEmptyDlSetup = [](const DlSetupContext&) {}
static

Definition at line 361 of file dl_rendering_unittests.cc.

361{};

◆ kEmptyRect

constexpr SkRect flutter::testing::kEmptyRect = SkRect::MakeEmpty()
staticconstexpr

Definition at line 30 of file mock_canvas.h.

◆ kEmptySkRenderer

const SkRenderer flutter::testing::kEmptySkRenderer = [](const SkRenderContext&) {}
static

Definition at line 360 of file dl_rendering_unittests.cc.

360{};

◆ kEmptySkSetup

const SkSetup flutter::testing::kEmptySkSetup = [](const SkSetupContext&) {}
static

Definition at line 359 of file dl_rendering_unittests.cc.

359{};

◆ kEndPoints

constexpr SkPoint flutter::testing::kEndPoints[]
constexpr
Initial value:
= {
{0, 0},
{100, 100},
}

Definition at line 27 of file dl_test_snippets.h.

27 {
28 {0, 0},
29 {100, 100},
30};

◆ kFixedCanvasSize

constexpr size_t flutter::testing::kFixedCanvasSize = 1024
constexpr

Definition at line 81 of file dl_benchmarks.cc.

◆ kHorizontalMiterDiamondPointCount

const int flutter::testing::kHorizontalMiterDiamondPointCount
Initial value:
=
sizeof(kHorizontalMiterDiamondPoints[0]))
const SkPoint kHorizontalMiterDiamondPoints[]

Definition at line 154 of file dl_rendering_unittests.cc.

◆ kHorizontalMiterDiamondPoints

const SkPoint flutter::testing::kHorizontalMiterDiamondPoints[]
Initial value:
= {
SkPoint::Make(kRenderCenterX, kYOffsetU3),
SkPoint::Make(kRenderLeft, kYOffsetU2),
SkPoint::Make(kRenderCenterX, kYOffsetU1),
SkPoint::Make(kRenderLeft, kYOffset0),
SkPoint::Make(kRenderCenterX, kYOffsetD1),
SkPoint::Make(kRenderLeft, kYOffsetD2),
SkPoint::Make(kRenderCenterX, kYOffsetD3),
SkPoint::Make(kRenderRight, kYOffsetD2),
SkPoint::Make(kRenderCenterX, kYOffsetD1),
SkPoint::Make(kRenderRight, kYOffset0),
SkPoint::Make(kRenderCenterX, kYOffsetU1),
SkPoint::Make(kRenderRight, kYOffsetU2),
SkPoint::Make(kRenderCenterX, kYOffsetU3),
}

Definition at line 134 of file dl_rendering_unittests.cc.

134 {
135 // Horizontal diamonds
136 // Same configuration as Vertical diamonds above but
137 // rotated 90 degrees
138 // clang-format off
139 SkPoint::Make(kRenderCenterX, kYOffsetU3),
140 SkPoint::Make(kRenderLeft, kYOffsetU2),
141 SkPoint::Make(kRenderCenterX, kYOffsetU1),
142 SkPoint::Make(kRenderLeft, kYOffset0),
143 SkPoint::Make(kRenderCenterX, kYOffsetD1),
144 SkPoint::Make(kRenderLeft, kYOffsetD2),
145 SkPoint::Make(kRenderCenterX, kYOffsetD3),
146 SkPoint::Make(kRenderRight, kYOffsetD2),
147 SkPoint::Make(kRenderCenterX, kYOffsetD1),
148 SkPoint::Make(kRenderRight, kYOffset0),
149 SkPoint::Make(kRenderCenterX, kYOffsetU1),
150 SkPoint::Make(kRenderRight, kYOffsetU2),
151 SkPoint::Make(kRenderCenterX, kYOffsetU3),
152 // clang-format on
153};

◆ kImagesToDraw

constexpr size_t flutter::testing::kImagesToDraw = 500
constexpr

Definition at line 80 of file dl_benchmarks.cc.

◆ kImplicitViewId

constexpr int64_t flutter::testing::kImplicitViewId = 0
constexpr

Definition at line 26 of file animator_unittests.cc.

◆ kInvertColorMatrix

constexpr float flutter::testing::kInvertColorMatrix[20]
constexpr
Initial value:
= {
-1.0, 0, 0, 1.0, 0,
0, -1.0, 0, 1.0, 0,
0, 0, -1.0, 1.0, 0,
1.0, 1.0, 1.0, 1.0, 0,
}

Definition at line 49 of file dl_test_snippets.h.

49 {
50 -1.0, 0, 0, 1.0, 0,
51 0, -1.0, 0, 1.0, 0,
52 0, 0, -1.0, 1.0, 0,
53 1.0, 1.0, 1.0, 1.0, 0,
54};

◆ kKernelFileName

const std::string flutter::testing::kKernelFileName = "plugin_registrant_kernel_blob.bin"

Definition at line 22 of file dart_plugin_registrant_unittests.cc.

◆ kLinearSampling

DlImageSampling flutter::testing::kLinearSampling = DlImageSampling::kLinear
static

Definition at line 69 of file dl_test_snippets.h.

◆ kLinesToDraw

constexpr size_t flutter::testing::kLinesToDraw = 10000
constexpr

Definition at line 73 of file dl_benchmarks.cc.

◆ kMatrix

const float flutter::testing::kMatrix[20]
static
Initial value:
= {
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
11, 12, 13, 14, 15,
16, 17, 18, 19, 20,
}

Definition at line 11 of file dl_color_filter_unittests.cc.

11 {
12 1, 2, 3, 4, 5, //
13 6, 7, 8, 9, 10, //
14 11, 12, 13, 14, 15, //
15 16, 17, 18, 19, 20, //
16};

◆ kMiter10DiamondOffsetX

constexpr SkScalar flutter::testing::kMiter10DiamondOffsetX = kRenderHeight * 0.051
constexpr

Definition at line 78 of file dl_rendering_unittests.cc.

◆ kMiter10DiamondOffsetY

constexpr SkScalar flutter::testing::kMiter10DiamondOffsetY = kRenderWidth * 0.051
constexpr

Definition at line 84 of file dl_rendering_unittests.cc.

◆ kMiter4DiamondOffsetX

constexpr SkScalar flutter::testing::kMiter4DiamondOffsetX = kRenderHeight * 0.14
constexpr

Definition at line 79 of file dl_rendering_unittests.cc.

◆ kMiter4DiamondOffsetY

constexpr SkScalar flutter::testing::kMiter4DiamondOffsetY = kRenderWidth * 0.14
constexpr

Definition at line 85 of file dl_rendering_unittests.cc.

◆ kMiterExtremeDiamondOffsetX

constexpr SkScalar flutter::testing::kMiterExtremeDiamondOffsetX = kRenderHeight * 0.04
constexpr

Definition at line 77 of file dl_rendering_unittests.cc.

◆ kMiterExtremeDiamondOffsetY

constexpr SkScalar flutter::testing::kMiterExtremeDiamondOffsetY = kRenderWidth * 0.04
constexpr

Definition at line 83 of file dl_rendering_unittests.cc.

◆ kNearestSampling

DlImageSampling flutter::testing::kNearestSampling = DlImageSampling::kNearestNeighbor
static

Definition at line 68 of file dl_test_snippets.h.

◆ kOvalsToDraw

constexpr size_t flutter::testing::kOvalsToDraw = 1000
constexpr

Definition at line 75 of file dl_benchmarks.cc.

◆ kRectsToDraw

constexpr size_t flutter::testing::kRectsToDraw = 5000
constexpr

Definition at line 74 of file dl_benchmarks.cc.

◆ kRenderBottom

constexpr int flutter::testing::kRenderBottom = kRenderTop + kRenderHeight
constexpr

Definition at line 56 of file dl_rendering_unittests.cc.

◆ kRenderBounds

constexpr SkRect flutter::testing::kRenderBounds
constexpr
Initial value:
=
SkRect::MakeLTRB(kRenderLeft, kRenderTop, kRenderRight, kRenderBottom)

Definition at line 64 of file dl_rendering_unittests.cc.

◆ kRenderCenterX

constexpr int flutter::testing::kRenderCenterX = (kRenderLeft + kRenderRight) / 2
constexpr

Definition at line 57 of file dl_rendering_unittests.cc.

◆ kRenderCenterY

constexpr int flutter::testing::kRenderCenterY = (kRenderTop + kRenderBottom) / 2
constexpr

Definition at line 58 of file dl_rendering_unittests.cc.

◆ kRenderCornerRadius

constexpr SkScalar flutter::testing::kRenderCornerRadius = kRenderRadius / 5.0
constexpr

Definition at line 60 of file dl_rendering_unittests.cc.

◆ kRenderHalfHeight

constexpr int flutter::testing::kRenderHalfHeight = 50
constexpr

Definition at line 52 of file dl_rendering_unittests.cc.

◆ kRenderHalfWidth

constexpr int flutter::testing::kRenderHalfWidth = 50
constexpr

Definition at line 51 of file dl_rendering_unittests.cc.

◆ kRenderHeight

constexpr int flutter::testing::kRenderHeight = 100
constexpr

Definition at line 50 of file dl_rendering_unittests.cc.

◆ kRenderLeft

constexpr int flutter::testing::kRenderLeft = (kTestWidth - kRenderWidth) / 2
constexpr

Definition at line 53 of file dl_rendering_unittests.cc.

◆ kRenderRadius

constexpr SkScalar flutter::testing::kRenderRadius = std::min(kRenderWidth, kRenderHeight) / 2.0
constexpr

Definition at line 59 of file dl_rendering_unittests.cc.

◆ kRenderRight

constexpr int flutter::testing::kRenderRight = kRenderLeft + kRenderWidth
constexpr

Definition at line 55 of file dl_rendering_unittests.cc.

◆ kRenderTop

constexpr int flutter::testing::kRenderTop = (kTestHeight - kRenderHeight) / 2
constexpr

Definition at line 54 of file dl_rendering_unittests.cc.

◆ kRenderWidth

constexpr int flutter::testing::kRenderWidth = 100
constexpr

Definition at line 49 of file dl_rendering_unittests.cc.

◆ kRotateColorMatrix

constexpr float flutter::testing::kRotateColorMatrix[20]
constexpr
Initial value:
= {
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
1, 0, 0, 0, 0,
0, 0, 0, 1, 0,
}

Definition at line 43 of file dl_test_snippets.h.

43 {
44 0, 1, 0, 0, 0,
45 0, 0, 1, 0, 0,
46 1, 0, 0, 0, 0,
47 0, 0, 0, 1, 0,
48};

◆ kRRectsToDraw

constexpr size_t flutter::testing::kRRectsToDraw = 5000
constexpr

Definition at line 77 of file dl_benchmarks.cc.

◆ kScanCodeKeyA

constexpr uint64_t flutter::testing::kScanCodeKeyA = 0x1e
constexpr

Definition at line 42 of file flutter_windows_view_unittests.cc.

◆ kSize

constexpr SkISize flutter::testing::kSize = SkISize::Make(64, 64)
constexpr

Definition at line 17 of file mock_canvas.cc.

◆ kStops

constexpr float flutter::testing::kStops[]
constexpr
Initial value:
= {
0.0,
0.5,
1.0,
}

Definition at line 36 of file dl_test_snippets.h.

36 {
37 0.0,
38 0.5,
39 1.0,
40};

◆ kTestAlphaColors

const DlColor flutter::testing::kTestAlphaColors[kTestStopCount]
static
Initial value:
= {
DlColor::kBlue().withAlpha(0x7F),
DlColor::kRed().withAlpha(0x2F),
DlColor::kGreen().withAlpha(0xCF),
}

Definition at line 65 of file dl_color_source_unittests.cc.

65 {
66 DlColor::kBlue().withAlpha(0x7F),
67 DlColor::kRed().withAlpha(0x2F),
68 DlColor::kGreen().withAlpha(0xCF),
69};

◆ kTestAlphaImage1

const sk_sp<DlImage> flutter::testing::kTestAlphaImage1
static
Initial value:
=
constexpr SkColor SK_ColorTRANSPARENT
Definition SkColor.h:99
static sk_sp< DlImage > MakeTestImage(int w, int h, SkColor color)

Definition at line 47 of file dl_color_source_unittests.cc.

◆ kTestBounds

constexpr SkRect flutter::testing::kTestBounds = SkRect::MakeLTRB(10, 10, 50, 60)
constexpr

Definition at line 187 of file dl_test_snippets.h.

◆ kTestBounds2

constexpr SkRect flutter::testing::kTestBounds2 = SkRect::MakeWH(kTestWidth, kTestHeight)
constexpr

Definition at line 63 of file dl_rendering_unittests.cc.

◆ kTestCenter

constexpr SkPoint flutter::testing::kTestCenter = SkPoint::Make(kTestWidth / 2, kTestHeight / 2)
constexpr

Definition at line 62 of file dl_rendering_unittests.cc.

◆ kTestColors [1/2]

const DlColor flutter::testing::kTestColors[2]
static
Initial value:
= {DlColor(0xFF000000),
DlColor(0xFFFFFFFF)}

Definition at line 27 of file dl_sk_paint_dispatcher_unittests.cc.

27 {DlColor(0xFF000000),
28 DlColor(0xFFFFFFFF)};

◆ kTestColors [2/2]

constexpr DlColor flutter::testing::kTestColors[kTestStopCount]
staticconstexpr
Initial value:
= {
DlColor::kRed(),
DlColor::kGreen(),
DlColor::kBlue(),
}

Definition at line 60 of file dl_color_source_unittests.cc.

60 {
61 DlColor::kRed(),
62 DlColor::kGreen(),
63 DlColor::kBlue(),
64};

◆ kTestDashes1

const SkScalar flutter::testing::kTestDashes1[] = {4.0, 2.0}

Definition at line 57 of file dl_test_snippets.h.

57{4.0, 2.0};

◆ kTestDashes2

const SkScalar flutter::testing::kTestDashes2[] = {1.0, 1.5}

Definition at line 58 of file dl_test_snippets.h.

58{1.0, 1.5};

◆ kTestHeight

constexpr int flutter::testing::kTestHeight = 200
constexpr

Definition at line 48 of file dl_rendering_unittests.cc.

◆ kTestImage1

const sk_sp<DlImage> flutter::testing::kTestImage1 = MakeTestImage(10, 10, SK_ColorGREEN)
static

Definition at line 46 of file dl_color_source_unittests.cc.

◆ kTestInnerRRect

const SkRRect flutter::testing::kTestInnerRRect
static
Initial value:

Definition at line 190 of file dl_test_snippets.h.

◆ kTestLinearGradient

const auto flutter::testing::kTestLinearGradient
static
Initial value:
=
DlColorSource::MakeLinear(SkPoint::Make(0.0f, 0.0f),
SkPoint::Make(100.0f, 100.0f),
2,
kTestColors,
kTestStops,
DlTileMode::kClamp,
nullptr)

Definition at line 30 of file dl_sk_paint_dispatcher_unittests.cc.

◆ kTestMatrix1 [1/2]

const SkMatrix flutter::testing::kTestMatrix1
static
Initial value:
=
0, 3, 12,
0, 0, 1)

Definition at line 50 of file dl_color_source_unittests.cc.

◆ kTestMatrix1 [2/2]

const SkMatrix flutter::testing::kTestMatrix1 = SkMatrix::Scale(2, 2)
static

Definition at line 200 of file dl_test_snippets.h.

◆ kTestMatrix2 [1/2]

const SkMatrix flutter::testing::kTestMatrix2
static
Initial value:
=
0, 7, 17,
0, 0, 1)

Definition at line 54 of file dl_color_source_unittests.cc.

◆ kTestMatrix2 [2/2]

const SkMatrix flutter::testing::kTestMatrix2 = SkMatrix::RotateDeg(45)
static

Definition at line 201 of file dl_test_snippets.h.

◆ kTestPath1

const SkPath flutter::testing::kTestPath1
static
Initial value:
=
SkPath::Polygon({{0, 0}, {10, 10}, {10, 0}, {0, 10}}, true)
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
Definition SkPath.cpp:3546

Definition at line 194 of file dl_test_snippets.h.

◆ kTestPath2

const SkPath flutter::testing::kTestPath2
static
Initial value:
=
SkPath::Polygon({{0, 0}, {10, 10}, {0, 10}, {10, 0}}, true)

Definition at line 196 of file dl_test_snippets.h.

◆ kTestPath3

const SkPath flutter::testing::kTestPath3
static
Initial value:
=
SkPath::Polygon({{0, 0}, {10, 10}, {10, 0}, {0, 10}}, false)

Definition at line 198 of file dl_test_snippets.h.

◆ kTestPathEffect1

const std::shared_ptr<DlPathEffect> flutter::testing::kTestPathEffect1
static
Initial value:
=
DlDashPathEffect::Make(kTestDashes1, 2, 0.0f)

Definition at line 178 of file dl_test_snippets.h.

◆ kTestPathEffect2

const std::shared_ptr<DlPathEffect> flutter::testing::kTestPathEffect2
static
Initial value:
=
DlDashPathEffect::Make(kTestDashes2, 2, 0.0f)

Definition at line 180 of file dl_test_snippets.h.

◆ kTestPathOval

const SkPath flutter::testing::kTestPathOval = SkPath::Oval(kTestBounds)
static

Definition at line 193 of file dl_test_snippets.h.

◆ kTestPathRect

const SkPath flutter::testing::kTestPathRect = SkPath::Rect(kTestBounds)
static

Definition at line 192 of file dl_test_snippets.h.

◆ kTestPoints

constexpr SkPoint flutter::testing::kTestPoints
staticconstexpr
Initial value:
= {
SkPoint::Make(5, 15),
SkPoint::Make(7, 18),
}

Definition at line 80 of file dl_color_source_unittests.cc.

80 {
81 SkPoint::Make(5, 15),
82 SkPoint::Make(7, 18),
83};

◆ kTestPoints2

constexpr SkPoint flutter::testing::kTestPoints2[2]
staticconstexpr
Initial value:
= {
SkPoint::Make(100, 115),
SkPoint::Make(107, 118),
}

Definition at line 84 of file dl_color_source_unittests.cc.

84 {
85 SkPoint::Make(100, 115),
86 SkPoint::Make(107, 118),
87};

◆ kTestRRect

const SkRRect flutter::testing::kTestRRect = SkRRect::MakeRectXY(kTestBounds, 5, 5)
static

Definition at line 188 of file dl_test_snippets.h.

◆ kTestRRectRect

const SkRRect flutter::testing::kTestRRectRect = SkRRect::MakeRect(kTestBounds)
static

Definition at line 189 of file dl_test_snippets.h.

◆ kTestRuntimeEffect1

const sk_sp<DlRuntimeEffect> flutter::testing::kTestRuntimeEffect1
static
Initial value:
=
DlRuntimeEffect::MakeSkia(
SkString("vec4 main(vec2 p) { return vec4(0); }"))
.effect)

Definition at line 35 of file dl_color_source_unittests.cc.

◆ kTestRuntimeEffect2

const sk_sp<DlRuntimeEffect> flutter::testing::kTestRuntimeEffect2
static
Initial value:
=
DlRuntimeEffect::MakeSkia(
SkString("vec4 main(vec2 p) { return vec4(1); }"))
.effect)

Definition at line 40 of file dl_color_source_unittests.cc.

◆ kTestSource2

const std::shared_ptr<DlColorSource> flutter::testing::kTestSource2
static
Initial value:
=
DlColorSource::MakeLinear(kEndPoints[0],
kEndPoints[1],
3,
kColors,
kStops,
DlTileMode::kMirror)

Definition at line 99 of file dl_test_snippets.h.

◆ kTestSource3

const std::shared_ptr<DlColorSource> flutter::testing::kTestSource3
static
Initial value:
=
DlColorSource::MakeRadial(kEndPoints[0],
10.0,
3,
kColors,
kStops,
DlTileMode::kMirror)

Definition at line 106 of file dl_test_snippets.h.

◆ kTestSource4

const std::shared_ptr<DlColorSource> flutter::testing::kTestSource4
static
Initial value:
=
DlColorSource::MakeConical(kEndPoints[0],
10.0,
kEndPoints[1],
200.0,
3,
kColors,
kStops,
DlTileMode::kDecal)

Definition at line 113 of file dl_test_snippets.h.

◆ kTestSource5

const std::shared_ptr<DlColorSource> flutter::testing::kTestSource5
static
Initial value:
=
DlColorSource::MakeSweep(kEndPoints[0],
0.0,
360.0,
3,
kColors,
kStops,
DlTileMode::kDecal)

Definition at line 122 of file dl_test_snippets.h.

◆ kTestStopCount

constexpr int flutter::testing::kTestStopCount = 3
staticconstexpr

Definition at line 59 of file dl_color_source_unittests.cc.

◆ kTestStops [1/2]

const float flutter::testing::kTestStops[2] = {0.0f, 1.0f}
static

Definition at line 29 of file dl_sk_paint_dispatcher_unittests.cc.

29{0.0f, 1.0f};

◆ kTestStops [2/2]

constexpr float flutter::testing::kTestStops[kTestStopCount]
staticconstexpr
Initial value:
= {
0.0f,
0.7f,
1.0f,
}

Definition at line 70 of file dl_color_source_unittests.cc.

70 {
71 0.0f,
72 0.7f,
73 1.0f,
74};

◆ kTestStops2

constexpr float flutter::testing::kTestStops2[kTestStopCount]
staticconstexpr
Initial value:
= {
0.0f,
0.3f,
1.0f,
}

Definition at line 75 of file dl_color_source_unittests.cc.

75 {
76 0.0f,
77 0.3f,
78 1.0f,
79};

◆ kTestWidth

constexpr int flutter::testing::kTestWidth = 200
constexpr

Definition at line 47 of file dl_rendering_unittests.cc.

◆ kTooltip

constexpr char flutter::testing::kTooltip[] = "tooltip"
staticconstexpr

Definition at line 32 of file embedder_a11y_unittests.cc.

◆ kVerticalMiterDiamondPointCount

const int flutter::testing::kVerticalMiterDiamondPointCount
Initial value:
=
sizeof(kVerticalMiterDiamondPoints[0])
constexpr SkPoint kVerticalMiterDiamondPoints[]

Definition at line 123 of file dl_rendering_unittests.cc.

◆ kVerticalMiterDiamondPoints

constexpr SkPoint flutter::testing::kVerticalMiterDiamondPoints[]
constexpr
Initial value:
= {
SkPoint::Make(kXOffsetL3, kRenderCenterY),
SkPoint::Make(kXOffsetL2, kRenderTop),
SkPoint::Make(kXOffsetL1, kRenderCenterY),
SkPoint::Make(kXOffset0, kRenderTop),
SkPoint::Make(kXOffsetR1, kRenderCenterY),
SkPoint::Make(kXOffsetR2, kRenderTop),
SkPoint::Make(kXOffsetR3, kRenderCenterY),
SkPoint::Make(kXOffsetR2, kRenderBottom),
SkPoint::Make(kXOffsetR1, kRenderCenterY),
SkPoint::Make(kXOffset0, kRenderBottom),
SkPoint::Make(kXOffsetL1, kRenderCenterY),
SkPoint::Make(kXOffsetL2, kRenderBottom),
SkPoint::Make(kXOffsetL3, kRenderCenterY),
}

Definition at line 99 of file dl_rendering_unittests.cc.

99 {
100 // Vertical diamonds:
101 // M10 M4 Mextreme
102 // /\ /|\ /\ top of RenderBounds
103 // / \ / | \ / \ to
104 // <----X--+--X----> RenderCenter
105 // \ / \ | / \ / to
106 // \/ \|/ \/ bottom of RenderBounds
107 // clang-format off
108 SkPoint::Make(kXOffsetL3, kRenderCenterY),
109 SkPoint::Make(kXOffsetL2, kRenderTop),
110 SkPoint::Make(kXOffsetL1, kRenderCenterY),
111 SkPoint::Make(kXOffset0, kRenderTop),
112 SkPoint::Make(kXOffsetR1, kRenderCenterY),
113 SkPoint::Make(kXOffsetR2, kRenderTop),
114 SkPoint::Make(kXOffsetR3, kRenderCenterY),
115 SkPoint::Make(kXOffsetR2, kRenderBottom),
116 SkPoint::Make(kXOffsetR1, kRenderCenterY),
117 SkPoint::Make(kXOffset0, kRenderBottom),
118 SkPoint::Make(kXOffsetL1, kRenderCenterY),
119 SkPoint::Make(kXOffsetL2, kRenderBottom),
120 SkPoint::Make(kXOffsetL3, kRenderCenterY),
121 // clang-format on
122};

◆ kVirtualKeyA

constexpr uint64_t flutter::testing::kVirtualKeyA = 0x41
constexpr

Definition at line 43 of file flutter_windows_view_unittests.cc.

◆ kWmResultDefault

constexpr LRESULT flutter::testing::kWmResultDefault = 0xDEADC0DE
constexpr

Definition at line 15 of file wm_builders.h.

◆ kWmResultDontCheck

constexpr LRESULT flutter::testing::kWmResultDontCheck = 0xFFFF1234
constexpr

Definition at line 16 of file wm_builders.h.

◆ kWmResultZero

constexpr LRESULT flutter::testing::kWmResultZero = 0
constexpr

Definition at line 14 of file wm_builders.h.

◆ kXOffset0

constexpr SkScalar flutter::testing::kXOffset0 = kRenderCenterX + 0.5
constexpr

Definition at line 92 of file dl_rendering_unittests.cc.

◆ kXOffsetL1

constexpr SkScalar flutter::testing::kXOffsetL1 = kXOffset0 - kMiter4DiamondOffsetX
constexpr

Definition at line 93 of file dl_rendering_unittests.cc.

◆ kXOffsetL2

constexpr SkScalar flutter::testing::kXOffsetL2 = kXOffsetL1 - kMiter10DiamondOffsetX
constexpr

Definition at line 94 of file dl_rendering_unittests.cc.

◆ kXOffsetL3

constexpr SkScalar flutter::testing::kXOffsetL3 = kXOffsetL2 - kMiter10DiamondOffsetX
constexpr

Definition at line 95 of file dl_rendering_unittests.cc.

◆ kXOffsetR1

constexpr SkScalar flutter::testing::kXOffsetR1 = kXOffset0 + kMiter4DiamondOffsetX
constexpr

Definition at line 96 of file dl_rendering_unittests.cc.

◆ kXOffsetR2

constexpr SkScalar flutter::testing::kXOffsetR2 = kXOffsetR1 + kMiterExtremeDiamondOffsetX
constexpr

Definition at line 97 of file dl_rendering_unittests.cc.

◆ kXOffsetR3

constexpr SkScalar flutter::testing::kXOffsetR3 = kXOffsetR2 + kMiterExtremeDiamondOffsetX
constexpr

Definition at line 98 of file dl_rendering_unittests.cc.

◆ kYOffset0

constexpr SkScalar flutter::testing::kYOffset0 = kRenderCenterY + 0.5
constexpr

Definition at line 127 of file dl_rendering_unittests.cc.

◆ kYOffsetD1

constexpr SkScalar flutter::testing::kYOffsetD1 = kXOffset0 + kMiter4DiamondOffsetY
constexpr

Definition at line 131 of file dl_rendering_unittests.cc.

◆ kYOffsetD2

constexpr SkScalar flutter::testing::kYOffsetD2 = kYOffsetD1 + kMiterExtremeDiamondOffsetY
constexpr

Definition at line 132 of file dl_rendering_unittests.cc.

◆ kYOffsetD3

constexpr SkScalar flutter::testing::kYOffsetD3 = kYOffsetD2 + kMiterExtremeDiamondOffsetY
constexpr

Definition at line 133 of file dl_rendering_unittests.cc.

◆ kYOffsetU1

constexpr SkScalar flutter::testing::kYOffsetU1 = kXOffset0 - kMiter4DiamondOffsetY
constexpr

Definition at line 128 of file dl_rendering_unittests.cc.

◆ kYOffsetU2

constexpr SkScalar flutter::testing::kYOffsetU2 = kYOffsetU1 - kMiter10DiamondOffsetY
constexpr

Definition at line 129 of file dl_rendering_unittests.cc.

◆ kYOffsetU3

constexpr SkScalar flutter::testing::kYOffsetU3 = kYOffsetU2 - kMiter10DiamondOffsetY
constexpr

Definition at line 130 of file dl_rendering_unittests.cc.

◆ raster_cache_items_

std::vector<RasterCacheItem*> flutter::testing::raster_cache_items_
static

Definition at line 49 of file mock_raster_cache.h.

◆ stored_response_controller

std::shared_ptr<MockKeyResponseController> flutter::testing::stored_response_controller
static

Definition at line 93 of file test_keyboard.cc.

◆ TestDisplayList1

sk_sp<DisplayList> flutter::testing::TestDisplayList1
static
Initial value:
=
static sk_sp< DisplayList > MakeTestDisplayList(int w, int h, SkColor color)

Definition at line 221 of file dl_test_snippets.h.

◆ TestDisplayList2

sk_sp<DisplayList> flutter::testing::TestDisplayList2
static
Initial value:

Definition at line 223 of file dl_test_snippets.h.

◆ TestImage1

auto flutter::testing::TestImage1 = MakeTestImage(40, 40, 5)
static

Definition at line 91 of file dl_test_snippets.h.

◆ TestImage2

auto flutter::testing::TestImage2 = MakeTestImage(50, 50, 5)
static

Definition at line 92 of file dl_test_snippets.h.

◆ TestSkImage

auto flutter::testing::TestSkImage = MakeTestImage(30, 30, 5)->skia_image()
static

Definition at line 93 of file dl_test_snippets.h.

◆ TestVertices1

std::shared_ptr<const DlVertices> flutter::testing::TestVertices1
static
Initial value:
=
DlVertices::Make(DlVertexMode::kTriangles,
3,
kTestPoints,
nullptr,
kColors)

Definition at line 203 of file dl_test_snippets.h.

◆ TestVertices2

std::shared_ptr<const DlVertices> flutter::testing::TestVertices2
static
Initial value:
=
DlVertices::Make(DlVertexMode::kTriangleFan,
3,
kTestPoints,
nullptr,
kColors)

Definition at line 209 of file dl_test_snippets.h.