Flutter Engine
The Flutter Engine
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  ClipExpector
 
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  ImageDecoderFixtureTest
 
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  SaveLayerExpector
 
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  TestDelegate
 
class  TestFlutterWindowsEngine
 
class  TestGLSurface
 
class  TestGPUSurfaceMetalDelegate
 
class  TestIOManager
 
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
 
class  UnknownImageGenerator
 An Image generator that pretends it can't recognize the data it was given. More...
 
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 BackdropFilterLayerTest = LayerTest
 
using BackdropLayerDiffTest = DiffContextTest
 
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 DlGoldenTest = impeller::DlPlayground
 
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, OOBSaveLayerContentCulledWithBlurFilter)
 
 TEST_F (DisplayListTest, OOBSaveLayerContentCulledWithMatrixFilter)
 
 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, LineOfNonOverlappingOpsSupportGroupOpacity)
 
 TEST_F (DisplayListTest, CrossOfNonOverlappingOpsSupportGroupOpacity)
 
 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, const std::string &file, int line)
 
 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)
 
 TEST_F (DisplayListTest, FloodingFilteredLayerPushesRestoreOpIndex)
 
 TEST_F (DisplayListTest, TransformingFilterSaveLayerSimpleContentBounds)
 
 TEST_F (DisplayListTest, TransformingFilterSaveLayerFloodedContentBounds)
 
 TEST_F (DisplayListTest, OpacityIncompatibleRenderOpInsideDeferredSave)
 
 TEST_F (DisplayListTest, MaxBlendModeEmptyDisplayList)
 
 TEST_F (DisplayListTest, MaxBlendModeSimpleRect)
 
 TEST_F (DisplayListTest, MaxBlendModeInsideNonDeferredSave)
 
 TEST_F (DisplayListTest, MaxBlendModeInsideDeferredSave)
 
 TEST_F (DisplayListTest, MaxBlendModeInsideSaveLayer)
 
 TEST_F (DisplayListTest, MaxBlendModeInsideNonDefaultBlendedSaveLayer)
 
 TEST_F (DisplayListTest, MaxBlendModeInsideComplexDeferredSaves)
 
 TEST_F (DisplayListTest, MaxBlendModeInsideComplexSaveLayers)
 
 TEST_F (DisplayListTest, BackdropDetectionEmptyDisplayList)
 
 TEST_F (DisplayListTest, BackdropDetectionSimpleRect)
 
 TEST_F (DisplayListTest, BackdropDetectionSimpleSaveLayer)
 
 TEST_F (DisplayListTest, BackdropDetectionNestedSaveLayer)
 
 TEST_F (DisplayListTest, DrawDisplayListForwardsMaxBlend)
 
 TEST_F (DisplayListTest, DrawDisplayListForwardsBackdropFlag)
 
 TEST_F (DisplayListTest, ClipRectCullingPixel6a)
 
 TEST_F (DisplayListTest, ClipRectCulling)
 
 TEST_F (DisplayListTest, ClipRectNonCulling)
 
 TEST_F (DisplayListTest, ClipRectNestedCulling)
 
 TEST_F (DisplayListTest, ClipRectNestedNonCulling)
 
 TEST_F (DisplayListTest, ClipRectNestedCullingComplex)
 
 TEST_F (DisplayListTest, ClipRectNestedNonCullingComplex)
 
 TEST_F (DisplayListTest, ClipRRectCulling)
 
 TEST_F (DisplayListTest, ClipRRectNonCulling)
 
 TEST_F (DisplayListTest, ClipPathNonCulling)
 
 TEST_F (DisplayListTest, ClipPathRectCulling)
 
 TEST_F (DisplayListTest, ClipPathRectNonCulling)
 
 TEST_F (DisplayListTest, ClipPathRRectCulling)
 
 TEST_F (DisplayListTest, ClipPathRRectNonCulling)
 
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 (DisplayListGeometryTypes, PointConversion)
 
 TEST (DisplayListGeometryTypes, RectConversion)
 
 TEST (DisplayListGeometryTypes, ISizeConversion)
 
 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, DrawDiagonalDashedLines)
 
 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 (DisplayListAccumulationRect, Constructor)
 
 TEST (DisplayListAccumulationRect, OnePoint)
 
 TEST (DisplayListAccumulationRect, TwoPoints)
 
 TEST (DisplayListAccumulationRect, ThreePoints)
 
 TEST (DisplayListAccumulationRect, EmptyRect)
 
 TEST (DisplayListAccumulationRect, TwoRects)
 
 TEST (DisplayListMatrixClipState, Constructor)
 
 TEST (DisplayListMatrixClipState, Constructor4x4)
 
 TEST (DisplayListMatrixClipState, TransformTo4x4)
 
 TEST (DisplayListMatrixClipState, SetTo4x4)
 
 TEST (DisplayListMatrixClipState, Translate)
 
 TEST (DisplayListMatrixClipState, Scale)
 
 TEST (DisplayListMatrixClipState, Skew)
 
 TEST (DisplayListMatrixClipState, Rotate)
 
 TEST (DisplayListMatrixClipState, Transform2DAffine)
 
 TEST (DisplayListMatrixClipState, TransformFullPerspectiveUsing3x3Matrix)
 
 TEST (DisplayListMatrixClipState, TransformFullPerspectiveUsing4x4Matrix)
 
 TEST (DisplayListMatrixClipState, ClipDifference)
 
 TEST (DisplayListMatrixClipState, ClipPathWithInvertFillType)
 
 TEST (DisplayListMatrixClipState, DiffClipPathWithInvertFillType)
 
 TEST (DisplayListMatrixClipState, MapAndClipRectTranslation)
 
 TEST (DisplayListMatrixClipState, MapAndClipRectScale)
 
 TEST (DisplayListMatrixClipState, RectCoverage)
 
 TEST (DisplayListMatrixClipState, RectCoverageAccuracy)
 
 TEST (DisplayListMatrixClipState, RectCoverageUnderScale)
 
 TEST (DisplayListMatrixClipState, RectCoverageUnderRotation)
 
 TEST (DisplayListMatrixClipState, OvalCoverage)
 
 TEST (DisplayListMatrixClipState, OvalCoverageUnderScale)
 
 TEST (DisplayListMatrixClipState, OvalCoverageUnderRotation)
 
 TEST (DisplayListMatrixClipState, RRectCoverage)
 
 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 (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, 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_P (DlGoldenTest, TextBlurMaskFilterRespectCTM)
 
 TEST_P (DlGoldenTest, TextBlurMaskFilterDisrespectCTM)
 
 INSTANTIATE_PLAYGROUND_SUITE (DlGoldenTest)
 
 TEST_P (DlGoldenTest, CanDrawPaint)
 
 TEST_P (DlGoldenTest, CanRenderImage)
 
 TEST_P (DlGoldenTest, Bug147807)
 
 TEST_P (DlGoldenTest, GaussianVsRRectBlur)
 
 TEST_P (DlGoldenTest, GaussianVsRRectBlurScaled)
 
 TEST_P (DlGoldenTest, GaussianVsRRectBlurScaledRotated)
 
 TEST_P (DlGoldenTest, DashedLinesTest)
 
 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 (ImageDecoderFixtureTest, CanCreateImageDecoder)
 
 TEST_F (ImageDecoderFixtureTest, InvalidImageResultsError)
 
 TEST_F (ImageDecoderFixtureTest, ValidImageResultsInSuccess)
 
 TEST_F (ImageDecoderFixtureTest, ImpellerUploadToSharedNoGpu)
 
 TEST_F (ImageDecoderFixtureTest, ImpellerNullColorspace)
 
 TEST_F (ImageDecoderFixtureTest, ImpellerPixelConversion32F)
 
 TEST_F (ImageDecoderFixtureTest, ImpellerWideGamutDisplayP3Opaque)
 
 TEST_F (ImageDecoderFixtureTest, ImpellerNonWideGamut)
 
 TEST_F (ImageDecoderFixtureTest, ExifDataIsRespectedOnDecode)
 
 TEST_F (ImageDecoderFixtureTest, CanDecodeWithoutAGPUContext)
 
 TEST_F (ImageDecoderFixtureTest, CanDecodeWithResizes)
 
 TEST (ImageDecoderTest, VerifyCodecRepeatCountsForGifAndWebPAreConsistentWithLoopCounts)
 
 TEST (ImageDecoderTest, VerifySimpleDecoding)
 
 TEST (ImageDecoderTest, ImagesWithTransparencyArePremulAlpha)
 
 TEST (ImageDecoderTest, VerifySubpixelDecodingPreservesExifOrientation)
 
 TEST_F (ImageDecoderFixtureTest, MultiFrameCodecCanBeCollectedBeforeIOTasksFinish)
 
 TEST_F (ImageDecoderFixtureTest, MultiFrameCodecDidAccessGpuDisabledSyncSwitch)
 
 TEST_F (ImageDecoderFixtureTest, MultiFrameCodecProducesATextureEvenIfGPUIsDisabledOnImpeller)
 
 TEST_F (ImageDecoderFixtureTest, NullCheckBuffer)
 
 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, DrawDashedLine)
 
 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, 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 (FlutterAppLifecycleDelegateTest, ReleasesDelegateOnDealloc)
 
 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, TestSelectorsNotForwardedToFrameworkIfNoClient)
 
 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. More...
 
 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. More...
 
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. More...
 
void ConfigureBackingStore (FlutterBackingStore &backing_store, EmbedderTestContextType backend, bool opengl_framebuffer)
 Configures per-backend properties for a given backing store. More...
 
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. More...
 
void fl_reset_received_gtk_log_levels ()
 Resets the recorded log levels. More...
 
GLogLevelFlags fl_get_received_gtk_log_levels ()
 Returns the recorded log levels. More...
 
 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)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
std::string GetDefaultKernelFilePath ()
 Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixturesPath(). More...
 
fml::UniqueFD OpenFixturesDirectory ()
 Opens the fixtures directory for the unit-test harness. More...
 
fml::UniqueFD OpenFixture (const std::string &fixture_name)
 Opens a fixture of the given file name. More...
 
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. More...
 
sk_sp< SkDataOpenFixtureAsSkData (const std::string &fixture_name)
 Opens a fixture of the given file name and returns a Skia SkData holding its contents. More...
 
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. More...
 
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. More...
 
const char * GetTestingAssetsPath ()
 Returns the directory containing assets shared across all tests. More...
 
 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]
 
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
 
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
 
static const std::string kEmojiFontFile
 
static const std::string kEmojiFontName
 

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

Definition at line 36 of file embedder_test_context.h.

◆ ClipOp

Definition at line 50 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.

◆ 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 2796 of file dl_rendering_unittests.cc.

◆ DisplayListTest

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

Definition at line 231 of file display_list_unittests.cc.

◆ DlGoldenTest

Definition at line 17 of file dl_golden_unittests.h.

◆ DlInvoker

Definition at line 24 of file dl_test_snippets.h.

◆ DlRenderContext

Definition at line 353 of file dl_rendering_unittests.cc.

◆ DlRenderer

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

Definition at line 359 of file dl_rendering_unittests.cc.

◆ DlSetup

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

Definition at line 358 of file dl_rendering_unittests.cc.

◆ DlSetupContext

Definition at line 350 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

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

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 184 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 365 of file dl_rendering_unittests.cc.

◆ PlatformViewLayerTest

Definition at line 18 of file platform_view_layer_unittests.cc.

◆ PointMode

Definition at line 51 of file display_list_unittests.cc.

◆ RasterCacheTest

Definition at line 748 of file raster_cache_unittests.cc.

◆ SemanticsActionCallback

Definition at line 32 of file embedder_test_context.h.

◆ SemanticsNodeCallback

Definition at line 31 of file embedder_test_context.h.

◆ SemanticsUpdateBuilderTest

Definition at line 13 of file semantics_update_builder_unittests.cc.

◆ SemanticsUpdateCallback

Definition at line 29 of file embedder_test_context.h.

◆ SemanticsUpdateCallback2

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 351 of file dl_rendering_unittests.cc.

◆ SkRenderer

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

Definition at line 357 of file dl_rendering_unittests.cc.

◆ SkSetup

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

Definition at line 356 of file dl_rendering_unittests.cc.

◆ SkSetupContext

Definition at line 349 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,
enum flutter::testing::WmFieldContext WmFieldContext

◆ WmFieldExtended

Enumerator
kNotExtended 
kExtended 

Definition at line 27 of file wm_builders.h.

27 {
28 kNotExtended = 0,
29 kExtended = 1,
enum flutter::testing::WmFieldExtended WmFieldExtended

◆ WmFieldPrevState

Enumerator
kWasUp 
kWasDown 

Definition at line 37 of file wm_builders.h.

37 {
38 kWasUp = 0,
39 kWasDown = 1,
enum flutter::testing::WmFieldPrevState WmFieldPrevState

◆ WmFieldTransitionState

Enumerator
kBeingReleased 
kBeingPressed 

Definition at line 42 of file wm_builders.h.

42 {
44 kBeingPressed = 1,
enum flutter::testing::WmFieldTransitionState 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:1134
uint64_t physical
Definition: embedder.h:1126
FlutterKeyEventType type
The event kind.
Definition: embedder.h:1118
const char * character
Definition: embedder.h:1137
#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
Definition: FontMgrTest.cpp:50
PODArray< SkColor > colors
Definition: SkRecords.h:276
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678

◆ BlendModeToString()

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

Definition at line 4210 of file dl_rendering_unittests.cc.

4210 {
4211 switch (mode) {
4212#define MODE_CASE(m) \
4213 case DlBlendMode::m: \
4214 return #m;
4216#undef MODE_CASE
4217 }
4218}
#define FOR_EACH_BLEND_MODE_ENUM(FUNC)
#define MODE_CASE(m)
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

◆ 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);
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
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}
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
Backend implementation of |DlCanvas| for |SkCanvas|.
Definition: dl_sk_canvas.h:20
const Paint & paint
Definition: color_source.cc:38
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)
constexpr size_t kArcSweepSetsToDraw
DlPaint GetPaintForRun(unsigned attributes)
static SkString to_string(int n)
Definition: nanobench.cpp:119
SeparatedVector2 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);
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)
Definition: SkPoint_impl.h:173

◆ 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);
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) {
369 case SkRRect::Type::kSimple_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;
375 case SkRRect::Type::kNinePatch_Type:
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;
381 case SkRRect::Type::kComplex_Type:
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
GLenum type
const SkRect & rect() const
Definition: SkRRect.h:264
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);
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
void clear(SkColor color)
Definition: SkCanvas.h:1199
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
Definition: bitmap.py:1
constexpr size_t kImagesToDraw
sk_sp< SkImage > ImageFromBitmapWithNewID(const SkBitmap &bitmap)
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);
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)
Definition: SkRect.h:32
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);
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);
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);
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);
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}
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
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);
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}
Definition: SkPath.h:59
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);
881 DlPaint paint = GetPaintForRun(attributes);
882
883 switch (mode) {
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 =
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);
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 const SkPoint kPoints[kNumLabels]
Definition: flippity.cpp:53
std::string PointModeToString(DlCanvas::PointMode mode)
std::vector< SkPoint > GetTestPoints(size_t count, SkISize canvas_size)
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);
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;
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);
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) {
288 case SkRRect::Type::kSimple_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;
294 case SkRRect::Type::kNinePatch_Type:
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;
300 case SkRRect::Type::kComplex_Type:
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;
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);
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) {
1251 case SkPath::Verb::kLine_Verb:
1252 GetLinesPath(path, 10, center, radius);
1253 break;
1254 case SkPath::Verb::kQuad_Verb:
1255 GetQuadsPath(path, 10, center, radius);
1256 break;
1257 case SkPath::Verb::kConic_Verb:
1258 GetConicsPath(path, 10, center, radius);
1259 break;
1260 case SkPath::Verb::kCubic_Verb:
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);
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}
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)
flutter::DlColor DlColor

◆ 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);
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);
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);
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
SkFont CreateTestFontOfSize(SkScalar scalar)

◆ 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);
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);
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::string VertexModeToString(DlVertexMode mode)
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);
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
friend class Iterator
Definition: SkRegion.h:677
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}
const GrXPFactory * Get(SkBlendMode mode)

◆ 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;
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}
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ 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}
const char * backend
@ kFlutterOpenGLTargetTypeFramebuffer
Definition: embedder.h:306
@ kFlutterOpenGLTargetTypeTexture
Definition: embedder.h:303
@ kFlutterBackingStoreTypeMetal
Specifies a Metal backing store. This is backed by a Metal texture.
Definition: embedder.h:1746
@ kFlutterBackingStoreTypeVulkan
Specifies a Vulkan backing store. This is backed by a Vulkan VkImage.
Definition: embedder.h:1748
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
Definition: embedder.h:1744
@ kFlutterBackingStoreTypeOpenGL
Definition: embedder.h:1742
FlutterBackingStoreType type
Specifies the type of backing store.
Definition: embedder.h:1762
FlutterOpenGLBackingStore open_gl
The description of the OpenGL backing store.
Definition: embedder.h:1768
FlutterOpenGLTargetType type
Definition: embedder.h:1610

◆ 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 SkIRect rect, const SkRect bounds)
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(
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 {"SetMaskFilter",
225 {
226 {0, 32, 0,
227 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter1); }, 0u,
228 2u},
229 {0, 32, 0,
230 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter2); }, 0u,
231 2u},
232 {0, 32, 0,
233 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter3); }, 0u,
234 2u},
235 {0, 32, 0,
236 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter4); }, 0u,
237 2u},
238 {0, 32, 0,
239 [](DlOpReceiver& r) { r.setMaskFilter(&kTestMaskFilter5); }, 0u,
240 2u},
241 {0, 0, 0, [](DlOpReceiver& r) { r.setMaskFilter(nullptr); }, 0u, 1u},
242 }},
243 };
244}
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.
static const DlComposeImageFilter kTestComposeImageFilter2(kTestBlurImageFilter2, kTestMatrixImageFilter1)
static const DlDilateImageFilter kTestDilateImageFilter2(6.0, 5.0)
static const std::shared_ptr< DlColorSource > kTestSource3
static const DlMatrixImageFilter kTestMatrixImageFilter1(SkMatrix::RotateDeg(45), kNearestSampling)
static const DlBlurMaskFilter kTestMaskFilter1(DlBlurStyle::kNormal, 3.0)
static const std::shared_ptr< DlColorSource > kTestSource4
static const DlBlurMaskFilter kTestMaskFilter4(DlBlurStyle::kInner, 3.0)
static const DlComposeImageFilter kTestComposeImageFilter1(kTestBlurImageFilter1, kTestMatrixImageFilter1)
static const DlColorFilterImageFilter kTestCFImageFilter2(kTestBlendColorFilter2)
static const DlErodeImageFilter kTestErodeImageFilter2(4.0, 3.0)
static const DlMatrixColorFilter kTestMatrixColorFilter2(kInvertColorMatrix)
static const DlBlurMaskFilter kTestMaskFilter3(DlBlurStyle::kSolid, 3.0)
static const DlImageColorSource kTestSource1(TestImage1, DlTileMode::kClamp, DlTileMode::kMirror, kLinearSampling)
static const DlBlurImageFilter kTestBlurImageFilter4(5.0, 5.0, DlTileMode::kDecal)
static const DlErodeImageFilter kTestErodeImageFilter3(3.0, 4.0)
static const DlMatrixImageFilter kTestMatrixImageFilter3(SkMatrix::RotateDeg(45), kLinearSampling)
static const DlColorFilterImageFilter kTestCFImageFilter1(kTestBlendColorFilter1)
static const std::shared_ptr< DlColorSource > kTestSource5
static const DlErodeImageFilter kTestErodeImageFilter1(4.0, 4.0)
static const std::shared_ptr< DlColorSource > kTestSource2
static const DlBlurMaskFilter kTestMaskFilter2(DlBlurStyle::kNormal, 5.0)
static const DlBlurImageFilter kTestBlurImageFilter2(6.0, 5.0, DlTileMode::kClamp)
static const DlBlendColorFilter kTestBlendColorFilter2(DlColor::kBlue(), DlBlendMode::kDstATop)
static const DlBlendColorFilter kTestBlendColorFilter1(DlColor::kRed(), DlBlendMode::kDstATop)
static const DlMatrixColorFilter kTestMatrixColorFilter1(kRotateColorMatrix)
static const DlBlendColorFilter kTestBlendColorFilter3(DlColor::kRed(), DlBlendMode::kDstIn)
static const DlMatrixImageFilter kTestMatrixImageFilter2(SkMatrix::RotateDeg(85), kNearestSampling)
static const DlBlurImageFilter kTestBlurImageFilter3(5.0, 6.0, DlTileMode::kClamp)
static const DlDilateImageFilter kTestDilateImageFilter1(5.0, 5.0)
static const DlBlurMaskFilter kTestMaskFilter5(DlBlurStyle::kOuter, 3.0)
static const DlDilateImageFilter kTestDilateImageFilter3(5.0, 6.0)
static const DlBlurImageFilter kTestBlurImageFilter1(5.0, 5.0, DlTileMode::kClamp)
static const DlComposeImageFilter kTestComposeImageFilter3(kTestBlurImageFilter1, kTestMatrixImageFilter2)
const myers::Point & get(const myers::Segment &)

◆ CreateAllClipOps()

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

Definition at line 401 of file dl_test_snippets.cc.

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

◆ CreateAllGroups()

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

Definition at line 971 of file dl_test_snippets.cc.

971 {
972 std::vector<DisplayListInvocationGroup> result;
973 auto all_attribute_ops = CreateAllAttributesOps();
974 std::move(all_attribute_ops.begin(), all_attribute_ops.end(),
975 std::back_inserter(result));
976 auto all_save_restore_ops = CreateAllSaveRestoreOps();
977 std::move(all_save_restore_ops.begin(), all_save_restore_ops.end(),
978 std::back_inserter(result));
979 auto all_transform_ops = CreateAllTransformOps();
980 std::move(all_transform_ops.begin(), all_transform_ops.end(),
981 std::back_inserter(result));
982 auto all_clip_ops = CreateAllClipOps();
983 std::move(all_clip_ops.begin(), all_clip_ops.end(),
984 std::back_inserter(result));
985 auto all_rendering_ops = CreateAllRenderingOps();
986 std::move(all_rendering_ops.begin(), all_rendering_ops.end(),
987 std::back_inserter(result));
988 return result;
989}
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 491 of file dl_test_snippets.cc.

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

◆ CreateAllSaveRestoreOps()

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

Definition at line 246 of file dl_test_snippets.cc.

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

◆ CreateAllTransformOps()

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

Definition at line 340 of file dl_test_snippets.cc.

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

◆ 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...
Definition: dart_vm_data.cc:67
const Settings & GetSettings() const
The settings object from which the Dart snapshots were inferred.
Definition: dart_vm_data.cc:59
#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...
Definition: ui_dart_state.h:45
#define ERROR(message)
Definition: elf_loader.cc:260

◆ 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)
Definition: context_mtl.mm:221

◆ 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
Definition: windows_types.h:60

◆ 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
static bool init()
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...

◆ 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 > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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:1837
double height
Definition: embedder.h:425
double width
Definition: embedder.h:424
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:172
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;
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}
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
@ kNone
Definition: layer.h:53

◆ 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 73 of file pointer_data_packet_converter_unittests.cc.

81 {
82 data.time_stamp = 0;
83 data.change = change;
84 data.kind = PointerData::DeviceKind::kMouse;
85 data.signal_kind = signal_kind;
86 data.device = device;
87 data.pointer_identifier = 0;
88 data.physical_x = dx;
89 data.physical_y = dy;
90 data.physical_delta_x = 0.0;
91 data.physical_delta_y = 0.0;
92 data.buttons = buttons;
93 data.obscured = 0;
94 data.synthesized = 0;
95 data.pressure = 0.0;
96 data.pressure_min = 0.0;
97 data.pressure_max = 0.0;
98 data.distance = 0.0;
99 data.distance_max = 0.0;
100 data.size = 0.0;
101 data.radius_major = 0.0;
102 data.radius_minor = 0.0;
103 data.radius_min = 0.0;
104 data.radius_max = 0.0;
105 data.orientation = 0.0;
106 data.tilt = 0.0;
107 data.platformData = 0;
108 data.scroll_delta_x = scroll_delta_x;
109 data.scroll_delta_y = scroll_delta_y;
110 data.view_id = kImplicitViewId;
111}
static constexpr FlutterViewId kImplicitViewId

◆ CreateSimulatedPointerData() [1/2]

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

Definition at line 161 of file input_events_unittests.cc.

164 {
165 data.time_stamp = 0;
166 data.change = change;
167 data.kind = PointerData::DeviceKind::kTouch;
169 data.device = 0;
170 data.pointer_identifier = 0;
171 data.physical_x = dx;
172 data.physical_y = dy;
173 data.physical_delta_x = 0.0;
174 data.physical_delta_y = 0.0;
175 data.buttons = 0;
176 data.obscured = 0;
177 data.synthesized = 0;
178 data.pressure = 0.0;
179 data.pressure_min = 0.0;
180 data.pressure_max = 0.0;
181 data.distance = 0.0;
182 data.distance_max = 0.0;
183 data.size = 0.0;
184 data.radius_major = 0.0;
185 data.radius_minor = 0.0;
186 data.radius_min = 0.0;
187 data.radius_max = 0.0;
188 data.orientation = 0.0;
189 data.tilt = 0.0;
190 data.platformData = 0;
191 data.scroll_delta_x = 0.0;
192 data.scroll_delta_y = 0.0;
193 data.view_id = kImplicitViewId;
194}

◆ 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 36 of file pointer_data_packet_converter_unittests.cc.

41 {
42 data.time_stamp = 0;
43 data.change = change;
44 data.kind = PointerData::DeviceKind::kTouch;
46 data.device = device;
47 data.pointer_identifier = 0;
48 data.physical_x = dx;
49 data.physical_y = dy;
50 data.physical_delta_x = 0.0;
51 data.physical_delta_y = 0.0;
52 data.buttons = buttons;
53 data.obscured = 0;
54 data.synthesized = 0;
55 data.pressure = 0.0;
56 data.pressure_min = 0.0;
57 data.pressure_max = 0.0;
58 data.distance = 0.0;
59 data.distance_max = 0.0;
60 data.size = 0.0;
61 data.radius_major = 0.0;
62 data.radius_minor = 0.0;
63 data.radius_min = 0.0;
64 data.radius_max = 0.0;
65 data.orientation = 0.0;
66 data.tilt = 0.0;
67 data.platformData = 0;
68 data.scroll_delta_x = 0.0;
69 data.scroll_delta_y = 0.0;
70 data.view_id = kImplicitViewId;
71}

◆ 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 113 of file pointer_data_packet_converter_unittests.cc.

121 {
122 data.time_stamp = 0;
123 data.change = change;
124 data.kind = PointerData::DeviceKind::kMouse;
126 data.device = device;
127 data.pointer_identifier = 0;
128 data.physical_x = dx;
129 data.physical_y = dy;
130 data.physical_delta_x = 0.0;
131 data.physical_delta_y = 0.0;
132 data.buttons = 0;
133 data.obscured = 0;
134 data.synthesized = 0;
135 data.pressure = 0.0;
136 data.pressure_min = 0.0;
137 data.pressure_max = 0.0;
138 data.distance = 0.0;
139 data.distance_max = 0.0;
140 data.size = 0.0;
141 data.radius_major = 0.0;
142 data.radius_minor = 0.0;
143 data.radius_min = 0.0;
144 data.radius_max = 0.0;
145 data.orientation = 0.0;
146 data.tilt = 0.0;
147 data.platformData = 0;
148 data.scroll_delta_x = 0.0;
149 data.scroll_delta_y = 0.0;
150 data.pan_x = pan_x;
151 data.pan_y = pan_y;
152 data.pan_delta_x = 0.0;
153 data.pan_delta_y = 0.0;
154 data.scale = scale;
155 data.rotation = rotation;
156 data.view_id = 0;
157}
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 991 of file dl_test_snippets.cc.

991 {
992 static constexpr const char* kTestFontFixture = "Roboto-Regular.ttf";
993 auto mapping = flutter::testing::OpenFixtureAsSkData(kTestFontFixture);
994 FML_CHECK(mapping);
995 return SkFont{txt::GetDefaultFontManager()->makeFromData(mapping), scalar};
996}
sk_sp< SkTypeface > makeFromData(sk_sp< SkData >, int ttcIndex=0) const
Definition: SkFontMgr.cpp:120
Definition: SkFont.h:35
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 sk_sp< const DisplayList > &a, const sk_sp< 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 sk_sp< const DisplayList > &a, const sk_sp< 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 171 of file dl_rendering_unittests.cc.

171 {
172 DlPaint p0, p1;
173 p0.setDrawStyle(DlDrawStyle::kFill);
174 p0.setColor(DlColor(0xff00fe00)); // off-green
175 p1.setDrawStyle(DlDrawStyle::kFill);
177 // Some pixels need some transparency for DstIn testing
178 p1.setAlpha(128);
179 int cbdim = 5;
180 int width = canvas->GetBaseLayerSize().width();
181 int height = canvas->GetBaseLayerSize().height();
182 for (int y = 0; y < width; y += cbdim) {
183 for (int x = 0; x < height; x += cbdim) {
184 DlPaint& cellp = ((x + y) & 1) == 0 ? p0 : p1;
185 canvas->DrawRect(SkRect::MakeXYWH(x, y, cbdim, cbdim), cellp);
186 }
187 }
188}
virtual void DrawRect(const SkRect &rect, const DlPaint &paint)=0
virtual SkISize GetBaseLayerSize() const =0
DlPaint & setColor(DlColor color)
Definition: dl_paint.h:70
DlPaint & setAlpha(uint8_t alpha)
Definition: dl_paint.h:76
DlPaint & setDrawStyle(DlDrawStyle style)
Definition: dl_paint.h:94
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 190 of file dl_rendering_unittests.cc.

190 {
191 DlSkCanvasAdapter dl_canvas(canvas);
192 DrawCheckerboard(&dl_canvas);
193}
static void DrawCheckerboard(SkCanvas *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 2894 of file embedder_unittests.cc.

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

◆ 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 2708 of file embedder_unittests.cc.

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

◆ expectSoftwareRenderingOutputMatches() [2/2]

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

Definition at line 2760 of file embedder_unittests.cc.

2764 {
2765 uint8_t* bytes = reinterpret_cast<uint8_t*>(&pixelvalue);
2767 test, std::move(entrypoint), pixfmt,
2768 std::vector<uint8_t>(bytes, bytes + sizeof(T)));
2769}
static void expectSoftwareRenderingOutputMatches(EmbedderTest &test, std::string entrypoint, FlutterSoftwarePixelFormat pixfmt, T pixelvalue)
#define T
Definition: precompiler.cc:65

◆ 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";
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 FlutterPlatformView *view, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
const FlutterPlatformViewMutation ** mutations
Definition: embedder.h:1736
size_t mutations_count
Definition: embedder.h:1723

◆ 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:1705

◆ 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}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ 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 }
42 log_writer_cb = writer;
43}
void fl_reset_received_gtk_log_levels()
Resets the recorded log levels.

◆ 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}
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)
Definition: task_runner.cc:55

◆ 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 {
17 builder.DrawRect(SkRect::MakeXYWH(10, 10, 80, 80), DlPaint(DlColor::kRed()));
18 return builder.Build();
19}
static const uint64_t kRed
flutter::DlPaint DlPaint
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 {
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 {
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}
static std::vector< RasterCacheItem * > raster_cache_items_

◆ 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()
Definition: message_loop.cc:27
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19

◆ 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)
Definition: CodecTest.cpp:106

◆ 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)
Definition: SkPoint_impl.h:269
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181

◆ GetTestTextBlob()

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

Definition at line 998 of file dl_test_snippets.cc.

998 {
999 static std::map<int, sk_sp<SkTextBlob>> text_blobs;
1000 auto it = text_blobs.find(index);
1001 if (it != text_blobs.end()) {
1002 return it->second;
1003 }
1004 std::string text = "TestBlob" + std::to_string(index);
1005 sk_sp<SkTextBlob> blob =
1006 SkTextBlob::MakeFromText(text.c_str(), text.size(),
1008 text_blobs.insert(std::make_pair(index, blob));
1009 return blob;
1010}
@ 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)
Definition: SkTextBlob.cpp:788
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()
Definition: message_loop.cc:76
virtual TaskQueueId GetTaskQueueId()
Definition: task_runner.cc:38
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 FlutterPlatformView *view)

◆ 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:1700
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, std::future< sk_sp< SkImage > > &scene_image)

◆ INSTANTIATE_PLAYGROUND_SUITE()

flutter::testing::INSTANTIATE_PLAYGROUND_SUITE ( DlGoldenTest  )

◆ 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 = "" 
)

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 = "" 
)

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 = "" 
)

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)
Definition: file_posix.cc:146
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.
Definition: elf_loader.cc:590

◆ 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 195 of file dl_rendering_unittests.cc.

196 {
197 return std::make_shared<DlImageColorSource>(image, //
198 DlTileMode::kRepeat, //
199 DlTileMode::kRepeat, //
201}

◆ MakeColorSource() [2/2]

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

Definition at line 203 of file dl_rendering_unittests.cc.

203 {
207}
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 };
34 2, colors, stops, DlTileMode::kRepeat);
35}
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
DlColor 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),
395 return builder.Build();
396}

◆ makeTestDisplayList()

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

Definition at line 3642 of file dl_rendering_unittests.cc.

3642 {
3644 DlPaint paint;
3645 paint.setDrawStyle(DlDrawStyle::kFill);
3646 paint.setColor(DlColor(SK_ColorRED));
3648 paint);
3649 paint.setColor(DlColor(SK_ColorBLUE));
3651 paint);
3652 paint.setColor(DlColor(SK_ColorGREEN));
3654 paint);
3655 paint.setColor(DlColor(SK_ColorYELLOW));
3656 builder.DrawRect(
3658 return builder.Build();
3659}
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr int kRenderCenterY
constexpr int kRenderCenterX

◆ MakeTestDisplayList()

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

Definition at line 208 of file dl_test_snippets.h.

208 {
211 return builder.Build();
212}
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 67 of file dl_test_snippets.h.

67 {
70 SkCanvas* canvas = surface->getCanvas();
71 SkPaint p0, p1;
76 p1.setAlpha(128);
77 for (int y = 0; y < w; y += checker_size) {
78 for (int x = 0; x < h; x += checker_size) {
79 SkPaint& cellp = ((x + y) & 1) == 0 ? p0 : p1;
80 canvas->drawRect(SkRect::MakeXYWH(x, y, checker_size, checker_size),
81 cellp);
82 }
83 }
84 return DlImage::Make(surface->makeImageSnapshot());
85}
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
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

◆ 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}
bool MemsetPatternSetOrCheck(std::vector< uint8_t > &buffer, MemsetPatternOp op)
Definition: testing.cc:120
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 buffer
Definition: switches.h:126

◆ 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
Definition: message_codec.h:29
struct _FlutterPlatformMessageResponseHandle FlutterPlatformMessageResponseHandle
Definition: embedder.h:1159
struct _FlutterEngine * FLUTTER_API_SYMBOL(FlutterEngine)
Definition: embedder.h:269
FlutterAccessibilityFeature
Definition: embedder.h:91
@ kInvalidArguments
Definition: embedder.h:75
FlutterEngineDisplaysUpdateType
Definition: embedder.h:2000
void(* FlutterKeyEventCallback)(bool, void *)
Definition: embedder.h:1155
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Win32Message message
static std::shared_ptr< MockKeyResponseController > stored_response_controller
FlutterEnginePlatformMessageReleaseResponseHandleFnPtr PlatformMessageReleaseResponseHandle
Definition: embedder.h:3337
FlutterEngineUpdateLocalesFnPtr UpdateLocales
Definition: embedder.h:3354
FlutterEngineSendKeyEventFnPtr SendKeyEvent
Definition: embedder.h:3332
FlutterEngineSendWindowMetricsEventFnPtr SendWindowMetricsEvent
Definition: embedder.h:3330
FlutterEngineShutdownFnPtr Shutdown
Definition: embedder.h:3326
FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate
Definition: embedder.h:3360
FlutterEngineSendPlatformMessageFnPtr SendPlatformMessage
Definition: embedder.h:3333
FlutterEnginePlatformMessageCreateResponseHandleFnPtr PlatformMessageCreateResponseHandle
Definition: embedder.h:3335
FlutterEngineSendPlatformMessageResponseFnPtr SendPlatformMessageResponse
Definition: embedder.h:3338
FlutterEngineRunFnPtr Run
Definition: embedder.h:3325
FlutterEngineUpdateAccessibilityFeaturesFnPtr UpdateAccessibilityFeatures
Definition: embedder.h:3344
void * user_data

◆ 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) {
601 case SkPath::Verb::kLine_Verb:
602 GetLinesPath(path, sides, p, radius);
603 break;
604 case SkPath::Verb::kQuad_Verb:
605 GetQuadsPath(path, sides, p, radius);
606 break;
607 case SkPath::Verb::kConic_Verb:
608 GetConicsPath(path, sides, p, radius);
609 break;
610 case SkPath::Verb::kCubic_Verb:
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
@ 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
Definition: SkColorSpace.h:93
static constexpr skcms_TransferFunction kRec2020
Definition: SkColorSpace.h:54
size_t minRowBytes() const
Definition: SkImageInfo.h:517
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 =
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}
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition: file_posix.cc:97

◆ operator<<() [1/24]

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

Definition at line 510 of file mock_canvas.cc.

511 {
512 return os << (style == MockCanvas::kSoftClipEdgeStyle ? "kSoftEdges"
513 : "kHardEdges");
514}

◆ operator<<() [2/24]

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

Definition at line 536 of file mock_canvas.cc.

537 {
538 return os << data.path << " " << data.clip_op << " " << data.style;
539}

◆ operator<<() [3/24]

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

Definition at line 516 of file mock_canvas.cc.

517 {
518 return os << data.rect << " " << data.clip_op << " " << data.style;
519}

◆ operator<<() [4/24]

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

Definition at line 526 of file mock_canvas.cc.

527 {
528 return os << data.rrect << " " << data.clip_op << " " << data.style;
529}

◆ operator<<() [5/24]

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

Definition at line 411 of file mock_canvas.cc.

412 {
413 return os << data.matrix;
414}

◆ operator<<() [6/24]

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

Definition at line 551 of file mock_canvas.cc.

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

◆ operator<<() [7/24]

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

Definition at line 541 of file mock_canvas.cc.

542 {
543 std::visit([&os](auto& d) { os << d; }, data);
544 return os;
545}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19

◆ operator<<() [8/24]

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

Definition at line 486 of file mock_canvas.cc.

487 {
488 auto dl = data.display_list;
489 return os << "[" << dl->unique_id() << " " << dl->op_count() << " "
490 << dl->bytes() << "] " << data.opacity;
491}

◆ operator<<() [9/24]

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

Definition at line 463 of file mock_canvas.cc.

464 {
465 return os << data.image << " " << data.x << " " << data.y << " "
466 << data.options << " " << data.paint;
467}

◆ operator<<() [10/24]

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

Definition at line 475 of file mock_canvas.cc.

476 {
477 return os << data.image << " " << data.x << " " << data.y << " "
478 << data.options;
479}

◆ operator<<() [11/24]

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

Definition at line 560 of file mock_canvas.cc.

561 {
562 return os << data.paint;
563}

◆ operator<<() [12/24]

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

Definition at line 441 of file mock_canvas.cc.

442 {
443 return os << data.path << " " << data.paint;
444}

◆ operator<<() [13/24]

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

Definition at line 431 of file mock_canvas.cc.

432 {
433 return os << data.rect << " " << data.paint;
434}

◆ operator<<() [14/24]

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

Definition at line 499 of file mock_canvas.cc.

500 {
501 return os << data.path << " " << data.color << " " << data.elevation << " "
502 << data.transparent_occluder << " " << data.dpr;
503}

◆ operator<<() [15/24]

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

Definition at line 452 of file mock_canvas.cc.

453 {
454 return os << data.serialized_text << " " << data.paint << " " << data.offset;
455}

◆ operator<<() [16/24]

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

Definition at line 401 of file mock_canvas.cc.

402 {
403 return os << data.restore_to_layer;
404}

◆ operator<<() [17/24]

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

Definition at line 379 of file mock_canvas.cc.

379 {
380 return os << data.save_to_layer;
381}

◆ operator<<() [18/24]

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

Definition at line 390 of file mock_canvas.cc.

391 {
392 return os << data.save_bounds << " " << data.restore_paint << " "
393 << data.backdrop_filter << " " << data.save_to_layer;
394}

◆ operator<<() [19/24]

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

Definition at line 421 of file mock_canvas.cc.

422 {
423 return os << data.matrix;
424}

◆ operator<<() [20/24]

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

Definition at line 363 of file mock_canvas.cc.

363 {
364 os << m.rc(0, 0) << ", " << m.rc(0, 1) << ", " << m.rc(0, 2) << ", "
365 << m.rc(0, 3) << std::endl;
366 os << m.rc(1, 0) << ", " << m.rc(1, 1) << ", " << m.rc(1, 2) << ", "
367 << m.rc(1, 3) << std::endl;
368 os << m.rc(2, 0) << ", " << m.rc(2, 1) << ", " << m.rc(2, 2) << ", "
369 << m.rc(2, 3) << std::endl;
370 os << m.rc(3, 0) << ", " << m.rc(3, 1) << ", " << m.rc(3, 2) << ", "
371 << m.rc(3, 3);
372 return os;
373}

◆ operator<<() [21/24]

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

Definition at line 356 of file mock_canvas.cc.

356 {
357 return os << "Valid: " << r.isValid()
358 << ", FillType: " << static_cast<int>(r.getFillType())
359 << ", Bounds: " << r.getBounds();
360}
SkPathFillType getFillType() const
Definition: SkPath.h:230
const SkRect & getBounds() const
Definition: SkPath.cpp:430
bool isValid() const
Definition: SkPath.cpp:438

◆ operator<<() [22/24]

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

Definition at line 342 of file mock_canvas.cc.

342 {
343 return os << "XY: " << r.fX << ", " << r.fY;
344}
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ operator<<() [23/24]

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

Definition at line 346 of file mock_canvas.cc.

346 {
347 return os << "LTRB: " << r.fLeft << ", " << r.fTop << ", " << r.fRight << ", "
348 << r.fBottom;
349}
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<<() [24/24]

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

Definition at line 351 of file mock_canvas.cc.

351 {
352 return os << "LTRB: " << r.rect().fLeft << ", " << r.rect().fTop << ", "
353 << r.rect().fRight << ", " << r.rect().fBottom;
354}

◆ 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 531 of file mock_canvas.cc.

532 {
533 return a.path == b.path && a.clip_op == b.clip_op && a.style == b.style;
534}

◆ operator==() [3/18]

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

Definition at line 505 of file mock_canvas.cc.

506 {
507 return a.rect == b.rect && a.clip_op == b.clip_op && a.style == b.style;
508}

◆ operator==() [4/18]

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

Definition at line 521 of file mock_canvas.cc.

522 {
523 return a.rrect == b.rrect && a.clip_op == b.clip_op && a.style == b.style;
524}

◆ operator==() [5/18]

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

Definition at line 406 of file mock_canvas.cc.

407 {
408 return a.matrix == b.matrix;
409}

◆ operator==() [6/18]

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

Definition at line 547 of file mock_canvas.cc.

547 {
548 return a.layer == b.layer && a.data == b.data;
549}

◆ operator==() [7/18]

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

Definition at line 481 of file mock_canvas.cc.

482 {
483 return a.display_list->Equals(b.display_list) && a.opacity == b.opacity;
484}

◆ operator==() [8/18]

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

Definition at line 457 of file mock_canvas.cc.

458 {
459 return a.image == b.image && a.x == b.x && a.y == b.y &&
460 a.options == b.options && a.paint == b.paint;
461}

◆ operator==() [9/18]

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

Definition at line 469 of file mock_canvas.cc.

470 {
471 return a.image == b.image && a.x == b.x && a.y == b.y &&
472 a.options == b.options;
473}

◆ operator==() [10/18]

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

Definition at line 555 of file mock_canvas.cc.

556 {
557 return a.paint == b.paint;
558}

◆ operator==() [11/18]

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

Definition at line 436 of file mock_canvas.cc.

437 {
438 return a.path == b.path && a.paint == b.paint;
439}

◆ operator==() [12/18]

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

Definition at line 426 of file mock_canvas.cc.

427 {
428 return a.rect == b.rect && a.paint == b.paint;
429}

◆ operator==() [13/18]

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

Definition at line 493 of file mock_canvas.cc.

494 {
495 return a.path == b.path && a.color == b.color && a.elevation == b.elevation &&
496 a.transparent_occluder == b.transparent_occluder && a.dpr == b.dpr;
497}

◆ operator==() [14/18]

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

Definition at line 446 of file mock_canvas.cc.

447 {
448 return a.serialized_text->equals(b.serialized_text.get()) &&
449 a.paint == b.paint && a.offset == b.offset;
450}

◆ operator==() [15/18]

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

Definition at line 396 of file mock_canvas.cc.

397 {
398 return a.restore_to_layer == b.restore_to_layer;
399}

◆ operator==() [16/18]

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

Definition at line 375 of file mock_canvas.cc.

375 {
376 return a.save_to_layer == b.save_to_layer;
377}

◆ operator==() [17/18]

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

Definition at line 383 of file mock_canvas.cc.

384 {
385 return a.save_bounds == b.save_bounds && a.restore_paint == b.restore_paint &&
386 Equals(a.backdrop_filter, b.backdrop_filter) &&
387 a.save_to_layer == b.save_to_layer;
388}
bool Equals(const T *a, const T *b)
Definition: dl_comparable.h:19

◆ operator==() [18/18]

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

Definition at line 416 of file mock_canvas.cc.

417 {
418 return a.matrix == b.matrix;
419}

◆ 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";
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
Definition: task_runner.cc:24
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
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ 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);
143 context.raster_cache->EvictUnusedCacheEntries();
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)

◆ 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}
bool equals(const SkData *other) const
Definition: SkData.cpp:43
static sk_sp< SkData > NormalizeImage(const sk_sp< SkImage > &image)

◆ 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:864
bool surface_needs_readback
Definition: layer.h:61

◆ 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
Definition: task_runners.cc:34
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57

◆ 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()
Definition: task_runner.cc:43
std::vector< std::unique_ptr< const fml::Mapping > > Mappings
Definition: settings.h:94
bool enable_impeller
Definition: settings.h:229

◆ SetArgsForProcess()

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

Definition at line 16 of file test_args.cc.

16 {
18}
char ** argv
Definition: library.h:9
CommandLine CommandLineFromArgcArgv(int argc, const char *const *argv)
Definition: command_line.h:233

◆ 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}
bool SurfacePixelDataMatchesBytes(std::future< SkSurface * > &surface_future, const std::vector< uint8_t > &bytes)

◆ 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/715]

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
FlutterSemanticsNode2 CreateSemanticsNode(int32_t id, const char *label, const std::vector< int32_t > *children=nullptr)
string root
Definition: scale_cpu.py:20

◆ TEST() [2/715]

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}

◆ TEST() [3/715]

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

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

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

◆ TEST() [6/715]

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],
236 EXPECT_EQ(bridge->accessibility_events[1],
238}
static constexpr AXID kInvalidAXID
Definition: ax_node.h:41
@ kFlutterSemanticsFlagIsFocused
Whether the semantic node currently holds the user's focus.
Definition: embedder.h:185
@ kFlutterSemanticsFlagIsTextField
Whether the semantic node represents a text field.
Definition: embedder.h:183
AXNode::AXID sel_anchor_object_id
Definition: ax_tree_data.h:62
AXNode::AXID sel_focus_object_id
Definition: ax_tree_data.h:65
int32_t sel_focus_offset
Definition: ax_tree_data.h:66
int32_t sel_anchor_offset
Definition: ax_tree_data.h:63

◆ TEST() [7/715]

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,
461 EXPECT_THAT(bridge->accessibility_events,
463}
const int32_t * children_in_traversal_order
Array of child node IDs in traversal order. Has length child_count.
Definition: embedder.h:1385
size_t child_count
The number of children this node has.
Definition: embedder.h:1383

◆ TEST() [8/715]

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,
359 EXPECT_THAT(bridge->accessibility_events,
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,
367 EXPECT_THAT(bridge->accessibility_events,
369}

◆ TEST() [9/715]

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);
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,
534 EXPECT_THAT(bridge->accessibility_events,
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,
542 EXPECT_THAT(bridge->accessibility_events,
544}

◆ TEST() [10/715]

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:177
@ kFlutterSemanticsFlagHasCheckedState
Definition: embedder.h:175

◆ TEST() [11/715]

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:230

◆ TEST() [12/715]

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

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:236
@ kFlutterSemanticsFlagIsEnabled
Whether a semantic node that hasEnabledState is currently enabled.
Definition: embedder.h:190
@ kFlutterSemanticsFlagIsFocusable
Whether the semantic node can hold the user's focus.
Definition: embedder.h:232
@ kFlutterSemanticsFlagHasEnabledState
Definition: embedder.h:188

◆ TEST() [14/715]

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:209

◆ TEST() [15/715]

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(
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
static void DispatchSemanticsAction(JNIEnv *env, jobject jcaller, jlong shell_holder, jint id, jint action, jobject args, jint args_position)
#define MOCK_ENGINE_PROC(proc, mock_impl)

◆ TEST() [16/715]

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

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

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

◆ TEST() [19/715]

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

◆ TEST() [20/715]

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),
320 {}}});
321 ASSERT_EQ(bridge->dispatched_events().size(), 1);
322 EXPECT_EQ(bridge->dispatched_events()[0].event_type,
324
325 ASSERT_EQ(bridge->focused_nodes().size(), 1);
326 EXPECT_EQ(bridge->focused_nodes()[0], 1);
327}

◆ TEST() [21/715]

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

◆ TEST() [22/715]

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

◆ TEST() [23/715]

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

◆ TEST() [24/715]

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

◆ TEST() [25/715]

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

◆ TEST() [26/715]

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

◆ TEST() [27/715]

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

◆ TEST() [28/715]

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

◆ TEST() [29/715]

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

◆ TEST() [30/715]

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

◆ TEST() [31/715]

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

◆ TEST() [32/715]

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

Definition at line 390 of file accessibility_bridge_windows_unittests.cc.

390 {
391 ExpectWinEventFromAXEventOnFocusNode(
394}

◆ TEST() [33/715]

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

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

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.
@ kSoftware
Definition: embedder.h:81

◆ TEST() [36/715]

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

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:38
GLFWwindow * window
Definition: main.cc:45
SK_API sk_sp< SkSurface > Null(int width, int height)
fml::RefPtr< fml::RasterThreadMerger > GetThreadMergerFromPlatformThread(fml::Thread *rasterizer_thread=nullptr)
flutter::DlCanvas DlCanvas
static constexpr SkSize Make(SkScalar w, SkScalar h)
Definition: SkSize.h:56

◆ TEST() [38/715]

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

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

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

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.
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}
constexpr SkColor4f kCyan
Definition: SkColor.h:444

◆ TEST() [42/715]

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

◆ TEST() [43/715]

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

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

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);
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/715]

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

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.
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/715]

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.
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/715]

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

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

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

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

Definition at line 13 of file platform_view_android_unittests.cc.

13 {
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/715]

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

Definition at line 29 of file platform_view_android_unittests.cc.

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

◆ TEST() [54/715]

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

Definition at line 122 of file android_shell_holder_unittests.cc.

122 {
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/715]

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

Definition at line 135 of file android_shell_holder_unittests.cc.

135 {
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);
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
void * malloc(size_t size)
Definition: allocation.cc:19

◆ TEST() [56/715]

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

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)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)

◆ TEST() [58/715]

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

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

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}
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)

◆ TEST() [61/715]

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

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);
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:132
constexpr SkColor4f kTransparent
Definition: SkColor.h:434

◆ TEST() [63/715]

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)
Definition: SkCanvas.cpp:1361
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
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/715]

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

Definition at line 12 of file context_options_unittests.cc.

12 {
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...
@ kRender
The context is used to render to a texture or renderbuffer.

◆ TEST() [65/715]

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::@2836::KeyboardChange::@76 content
ObjectPtr Invoke(const Library &lib, const char *name)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47
unsigned long DWORD
Definition: windows_types.h:22

◆ TEST() [66/715]

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

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

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

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

flutter::testing::TEST ( DisplayListAccumulationRect  ,
Constructor   
)

Definition at line 12 of file dl_accumulation_rect_unittests.cc.

12 {
13 AccumulationRect accumulator;
14
15 EXPECT_TRUE(accumulator.is_empty());
16 EXPECT_TRUE(accumulator.bounds().isEmpty());
17 EXPECT_FALSE(accumulator.overlap_detected());
18}
bool isEmpty() const
Definition: SkRect.h:693

◆ TEST() [71/715]

flutter::testing::TEST ( DisplayListAccumulationRect  ,
EmptyRect   
)

Definition at line 135 of file dl_accumulation_rect_unittests.cc.

135 {
136 auto test = [](DlScalar l, DlScalar t, DlScalar r, DlScalar b, //
137 SkRect bounds, //
138 bool should_be_empty, bool should_overlap,
139 const std::string& label) {
140 {
141 AccumulationRect accumulator;
142 accumulator.accumulate(SkRect::MakeLTRB(l, t, r, b));
143
144 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
145 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
146 EXPECT_EQ(accumulator.bounds(), bounds) << label;
147 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
148 }
149
150 {
151 AccumulationRect accumulator;
152 accumulator.accumulate(DlRect::MakeLTRB(l, t, r, b));
153
154 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
155 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
156 EXPECT_EQ(accumulator.bounds(), bounds) << label;
157 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
158 }
159
160 {
161 AccumulationRect content;
162 content.accumulate(l, t);
163 content.accumulate(r, b);
164 EXPECT_EQ(content.is_empty(), should_be_empty) << label;
165 EXPECT_EQ(content.bounds().isEmpty(), should_be_empty) << label;
166 // bounds for an accumulation by points may be different than the
167 // bounds for an accumulation by the rect they produce because
168 // construction by points has no "empty rejection" case.
169 if (!should_be_empty) {
170 EXPECT_EQ(content.bounds(), bounds) << label;
171 }
172 EXPECT_EQ(content.overlap_detected(), should_overlap) << label;
173
174 AccumulationRect accumulator;
175 accumulator.accumulate(content);
176
177 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
178 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
179 EXPECT_EQ(accumulator.bounds(), bounds) << label;
180 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
181 }
182 };
183
184 test(10.0f, 10.0f, 10.0f, 10.0f, SkRect::MakeLTRB(0.0f, 0.0f, 0.0f, 0.0f),
185 true, false, "Singular");
186 test(10.0f, 10.0f, 20.0f, 10.0f, SkRect::MakeLTRB(0.0f, 0.0f, 0.0f, 0.0f),
187 true, false, "Horizontal Empty");
188 test(10.0f, 10.0f, 10.0f, 20.0f, SkRect::MakeLTRB(0.0f, 0.0f, 0.0f, 0.0f),
189 true, false, "Vertical Empty");
190 test(10.0f, 10.0f, 20.0f, 20.0f, SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f),
191 false, false, "Non-Empty");
192}
void accumulate(SkScalar x, SkScalar y)
impeller::Scalar DlScalar

◆ TEST() [72/715]

flutter::testing::TEST ( DisplayListAccumulationRect  ,
OnePoint   
)

Definition at line 20 of file dl_accumulation_rect_unittests.cc.

20 {
21 AccumulationRect accumulator;
22 accumulator.accumulate(10.0f, 10.0f);
23
24 EXPECT_TRUE(accumulator.is_empty());
25 EXPECT_TRUE(accumulator.bounds().isEmpty());
26 EXPECT_FALSE(accumulator.overlap_detected());
27}

◆ TEST() [73/715]

flutter::testing::TEST ( DisplayListAccumulationRect  ,
ThreePoints   
)

Definition at line 79 of file dl_accumulation_rect_unittests.cc.

79 {
80 auto test = [](DlScalar x1, DlScalar y1, //
81 DlScalar x2, DlScalar y2, //
82 DlScalar x3, DlScalar y3, //
83 SkRect bounds, //
84 bool should_be_empty, bool should_overlap,
85 const std::string& label) {
86 {
87 AccumulationRect accumulator;
88 accumulator.accumulate(x1, y1);
89 accumulator.accumulate(x2, y2);
90 accumulator.accumulate(x3, y3);
91
92 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
93 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
94 EXPECT_EQ(accumulator.bounds(), bounds) << label;
95 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
96 }
97
98 {
99 AccumulationRect accumulator;
100 accumulator.accumulate(SkPoint::Make(x1, y1));
101 accumulator.accumulate(SkPoint::Make(x2, y2));
102 accumulator.accumulate(SkPoint::Make(x3, y3));
103
104 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
105 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
106 EXPECT_EQ(accumulator.bounds(), bounds) << label;
107 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
108 }
109
110 {
111 AccumulationRect accumulator;
112 accumulator.accumulate(DlPoint(x1, y1));
113 accumulator.accumulate(DlPoint(x2, y2));
114 accumulator.accumulate(DlPoint(x3, y3));
115
116 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
117 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
118 EXPECT_EQ(accumulator.bounds(), bounds) << label;
119 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
120 }
121 };
122
123 test(10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f,
124 SkRect::MakeLTRB(10.0f, 10.0f, 10.0f, 10.0f), true, false, "Same");
125 test(10.0f, 10.0f, 20.0f, 10.0f, 15.0f, 10.0f,
126 SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 10.0f), true, false, "Horizontal");
127 test(10.0f, 10.0f, 10.0f, 20.0f, 10.0f, 15.0f,
128 SkRect::MakeLTRB(10.0f, 10.0f, 10.0f, 20.0f), true, false, "Vertical");
129 test(10.0f, 10.0f, 20.0f, 20.0f, 25.0f, 15.0f,
130 SkRect::MakeLTRB(10.0f, 10.0f, 25.0f, 20.0f), false, false, "Disjoint");
131 test(10.0f, 10.0f, 20.0f, 20.0f, 15.0f, 15.0f,
132 SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f), false, true, "Inside");
133}
impeller::Point DlPoint

◆ TEST() [74/715]

flutter::testing::TEST ( DisplayListAccumulationRect  ,
TwoPoints   
)

Definition at line 29 of file dl_accumulation_rect_unittests.cc.

29 {
30 auto test = [](DlScalar x1, DlScalar y1, //
31 DlScalar x2, DlScalar y2, //
32 SkRect bounds, //
33 bool should_be_empty, bool should_overlap,
34 const std::string& label) {
35 {
36 AccumulationRect accumulator;
37 accumulator.accumulate(x1, y1);
38 accumulator.accumulate(x2, y2);
39
40 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
41 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
42 EXPECT_EQ(accumulator.bounds(), bounds) << label;
43 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
44 }
45
46 {
47 AccumulationRect accumulator;
48 accumulator.accumulate(SkPoint::Make(x1, y1));
49 accumulator.accumulate(SkPoint::Make(x2, y2));
50
51 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
52 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
53 EXPECT_EQ(accumulator.bounds(), bounds) << label;
54 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
55 }
56
57 {
58 AccumulationRect accumulator;
59 accumulator.accumulate(DlPoint(x1, y1));
60 accumulator.accumulate(DlPoint(x2, y2));
61
62 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
63 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
64 EXPECT_EQ(accumulator.bounds(), bounds) << label;
65 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
66 }
67 };
68
69 test(10.0f, 10.0f, 10.0f, 10.0f, SkRect::MakeLTRB(10.0f, 10.0f, 10.0f, 10.0f),
70 true, false, "Same");
71 test(10.0f, 10.0f, 20.0f, 10.0f, SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 10.0f),
72 true, false, "Horizontal");
73 test(10.0f, 10.0f, 10.0f, 20.0f, SkRect::MakeLTRB(10.0f, 10.0f, 10.0f, 20.0f),
74 true, false, "Vertical");
75 test(10.0f, 10.0f, 20.0f, 20.0f, SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f),
76 false, false, "Diagonal");
77}

◆ TEST() [75/715]

flutter::testing::TEST ( DisplayListAccumulationRect  ,
TwoRects   
)

Definition at line 194 of file dl_accumulation_rect_unittests.cc.

194 {
195 auto test = [](DlScalar l1, DlScalar t1, DlScalar r1, DlScalar b1, //
196 DlScalar l2, DlScalar t2, DlScalar r2, DlScalar b2, //
197 SkRect bounds, //
198 bool should_be_empty, bool should_overlap,
199 const std::string& label) {
200 {
201 AccumulationRect accumulator;
202 accumulator.accumulate(SkRect::MakeLTRB(l1, t1, r1, b1));
203 accumulator.accumulate(SkRect::MakeLTRB(l2, t2, r2, b2));
204
205 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
206 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
207 EXPECT_EQ(accumulator.bounds(), bounds) << label;
208 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
209 }
210
211 {
212 AccumulationRect accumulator;
213 accumulator.accumulate(DlRect::MakeLTRB(l1, t1, r1, b1));
214 accumulator.accumulate(DlRect::MakeLTRB(l2, t2, r2, b2));
215
216 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
217 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
218 EXPECT_EQ(accumulator.bounds(), bounds) << label;
219 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
220 }
221
222 {
223 AccumulationRect content1;
224 content1.accumulate(l1, t1);
225 content1.accumulate(r1, b1);
226
227 AccumulationRect content2;
228 content2.accumulate(l2, t2);
229 content2.accumulate(r2, b2);
230
231 AccumulationRect accumulator;
232 accumulator.accumulate(content1);
233 accumulator.accumulate(content2);
234
235 EXPECT_EQ(accumulator.is_empty(), should_be_empty) << label;
236 EXPECT_EQ(accumulator.bounds().isEmpty(), should_be_empty) << label;
237 EXPECT_EQ(accumulator.bounds(), bounds) << label;
238 EXPECT_EQ(accumulator.overlap_detected(), should_overlap) << label;
239 }
240 };
241
242 test(10.0f, 10.0f, 10.0f, 10.0f, //
243 20.0f, 20.0f, 20.0f, 20.0f, //
244 SkRect::MakeLTRB(0.0f, 0.0f, 0.0f, 0.0f), //
245 true, false, "Empty + Empty");
246 test(10.0f, 10.0f, 20.0f, 10.0f, //
247 10.0f, 10.0f, 10.0f, 20.0f, //
248 SkRect::MakeLTRB(0.0f, 0.0f, 0.0f, 0.0f), //
249 true, false, "Horizontal + Vertical");
250 test(10.0f, 10.0f, 10.0f, 10.0f, //
251 15.0f, 15.0f, 20.0f, 20.0f, //
252 SkRect::MakeLTRB(15.0f, 15.0f, 20.0f, 20.0f), //
253 false, false, "Empty + Non-Empty");
254 test(10.0f, 10.0f, 15.0f, 15.0f, //
255 20.0f, 20.0f, 20.0f, 20.0f, //
256 SkRect::MakeLTRB(10.0f, 10.0f, 15.0f, 15.0f), //
257 false, false, "Non-Empty + Empty");
258 test(10.0f, 10.0f, 15.0f, 15.0f, //
259 15.0f, 15.0f, 20.0f, 20.0f, //
260 SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f), //
261 false, false, "Abutting");
262 test(10.0f, 10.0f, 15.0f, 15.0f, //
263 16.0f, 16.0f, 20.0f, 20.0f, //
264 SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f), //
265 false, false, "Disjoint");
266 test(10.0f, 10.0f, 16.0f, 16.0f, //
267 15.0f, 15.0f, 20.0f, 20.0f, //
268 SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f), //
269 false, true, "Overlapping");
270}

◆ TEST() [76/715]

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}
constexpr SkColor4f kBlack
Definition: SkColor.h:435
static void arraysEqual(const uint32_t *ints, const DlColor *colors, int count)

◆ TEST() [77/715]

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

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

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

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

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}
static void TestEquals(T &source1, T &source2)

◆ TEST() [82/715]

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}
static void TestNotEquals(T &source1, T &source2, const std::string &label)

◆ TEST() [83/715]

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

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

◆ TEST() [85/715]

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

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

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

Definition at line 69 of file dl_color_filter_unittests.cc.

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

◆ TEST() [88/715]

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

Definition at line 59 of file dl_color_filter_unittests.cc.

59 {
60 DlMatrixColorFilter filter(kMatrix);
61}

◆ TEST() [89/715]

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

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

Definition at line 98 of file dl_color_filter_unittests.cc.

98 {
99 DlMatrixColorFilter filter1(kMatrix);
100 DlMatrixColorFilter filter2(kMatrix);
101 TestEquals(filter1, filter2);
102}

◆ TEST() [91/715]

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));
108 matrix[4] += 101;
110 TestNotEquals(filter1, filter2, "Matrix differs");
111}

◆ TEST() [92/715]

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

Definition at line 63 of file dl_color_filter_unittests.cc.

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

◆ TEST() [93/715]

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

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 };
121 ASSERT_FALSE(filter.modifies_transparent_black());
122}

◆ TEST() [95/715]

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

◆ TEST() [96/715]

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

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

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}
static sk_sp< SkShader > MakeConical(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
SkBitmap source
Definition: examples.cpp:28
static constexpr int kTestStopCount
static constexpr float kTestStops[kTestStopCount]
static const SkMatrix kTestMatrix1
static const DlColor kTestAlphaColors[kTestStopCount]

◆ TEST() [99/715]

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}
static const sk_sp< DlImage > kTestAlphaImage1

◆ TEST() [100/715]

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

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(
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}
static sk_sp< SkShader > MakeRadial(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)

◆ TEST() [102/715]

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(
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}
static sk_sp< SkShader > MakeSweep(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.

◆ TEST() [103/715]

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

Definition at line 99 of file dl_color_source_unittests.cc.

99 {
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() [104/715]

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

Definition at line 89 of file dl_color_source_unittests.cc.

◆ TEST() [105/715]

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

Definition at line 112 of file dl_color_source_unittests.cc.

112 {
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() [106/715]

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

Definition at line 124 of file dl_color_source_unittests.cc.

124 {
127 TestEquals(source1, source2);
128}

◆ TEST() [107/715]

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

Definition at line 130 of file dl_color_source_unittests.cc.

130 {
133 TestNotEquals(source1, source2, "Color differs");
134}

◆ TEST() [108/715]

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

Definition at line 93 of file dl_color_source_unittests.cc.

93 {
95 ASSERT_NE(source.shared().get(), &source);
96 ASSERT_EQ(*source.shared(), source);
97}

◆ TEST() [109/715]

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(
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}
static constexpr DlColor kTestColors[kTestStopCount]

◆ TEST() [110/715]

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(
472 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
473}

◆ TEST() [111/715]

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

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(
537 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
538 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
540 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
541 TestEquals(*source1, *source2);
542}

◆ TEST() [113/715]

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(
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(
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(
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(
587 kTestStops2, DlTileMode::kClamp, &kTestMatrix1);
588 TestNotEquals(*source1, *source2, "Stops differ");
589 }
590 {
591 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
593 kTestStops, DlTileMode::kMirror, &kTestMatrix1);
594 TestNotEquals(*source1, *source2, "Tile Mode differs");
595 }
596 {
597 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeConical(
599 kTestStops, DlTileMode::kClamp, &kTestMatrix2);
600 TestNotEquals(*source1, *source2, "Matrix differs");
601 }
602}
static constexpr float kTestStops2[kTestStopCount]
static const SkMatrix kTestMatrix2
static constexpr SkPoint kTestPoints2[2]

◆ TEST() [114/715]

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(
478 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
479 ASSERT_NE(source->shared().get(), source.get());
480 ASSERT_EQ(*source->shared().get(), *source.get());
481}

◆ TEST() [115/715]

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 &)
static const sk_sp< DlRuntimeEffect > kTestRuntimeEffect1
static const sk_sp< DlRuntimeEffect > kTestRuntimeEffect2
SkPaint ToSk(const DlPaint &paint)

◆ TEST() [116/715]

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

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,
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}
static const sk_sp< DlImage > kTestImage1

◆ TEST() [118/715]

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

◆ TEST() [119/715]

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

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

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

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,
144 ASSERT_NE(source.shared().get(), &source);
145 ASSERT_EQ(*source.shared(), source);
146}

◆ TEST() [123/715]

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

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(
234 DlTileMode::kClamp, &kTestMatrix1);
235}

◆ TEST() [125/715]

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

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(
295 DlTileMode::kClamp, &kTestMatrix1);
296 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
298 DlTileMode::kClamp, &kTestMatrix1);
299 TestEquals(*source1, *source2);
300}

◆ TEST() [127/715]

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(
305 DlTileMode::kClamp, &kTestMatrix1);
306 {
307 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
309 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
310 TestNotEquals(*source1, *source2, "Point 0 differs");
311 }
312 {
313 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
315 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
316 TestNotEquals(*source1, *source2, "Point 1 differs");
317 }
318 {
319 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
321 DlTileMode::kClamp, &kTestMatrix1);
322 TestNotEquals(*source1, *source2, "Stop count differs");
323 }
324 {
325 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
327 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
328 TestNotEquals(*source1, *source2, "Colors differ");
329 }
330 {
331 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
333 kTestStops2, DlTileMode::kClamp, &kTestMatrix1);
334 TestNotEquals(*source1, *source2, "Stops differ");
335 }
336 {
337 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
339 DlTileMode::kMirror, &kTestMatrix1);
340 TestNotEquals(*source1, *source2, "Tile Mode differs");
341 }
342 {
343 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeLinear(
345 DlTileMode::kClamp, &kTestMatrix2);
346 TestNotEquals(*source1, *source2, "Matrix differs");
347 }
348}

◆ TEST() [128/715]

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(
240 DlTileMode::kClamp, &kTestMatrix1);
241 ASSERT_NE(source->shared().get(), source.get());
242 ASSERT_EQ(*source->shared().get(), *source.get());
243}

◆ TEST() [129/715]

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

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(
353 DlTileMode::kClamp, &kTestMatrix1);
354}

◆ TEST() [131/715]

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

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(
414 DlTileMode::kClamp, &kTestMatrix1);
415 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
417 DlTileMode::kClamp, &kTestMatrix1);
418 TestEquals(*source1, *source2);
419}

◆ TEST() [133/715]

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(
424 DlTileMode::kClamp, &kTestMatrix1);
425 {
426 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
428 DlTileMode::kClamp, &kTestMatrix1);
429 TestNotEquals(*source1, *source2, "Center differs");
430 }
431 {
432 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
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(
446 DlTileMode::kClamp, &kTestMatrix1);
447 TestNotEquals(*source1, *source2, "Colors differ");
448 }
449 {
450 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
452 DlTileMode::kClamp, &kTestMatrix1);
453 TestNotEquals(*source1, *source2, "Stops differ");
454 }
455 {
456 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
458 DlTileMode::kMirror, &kTestMatrix1);
459 TestNotEquals(*source1, *source2, "Tile Mode differs");
460 }
461 {
462 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeRadial(
464 DlTileMode::kClamp, &kTestMatrix2);
465 TestNotEquals(*source1, *source2, "Matrix differs");
466 }
467}

◆ TEST() [134/715]

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(
359 DlTileMode::kClamp, &kTestMatrix1);
360 ASSERT_NE(source->shared().get(), source.get());
361 ASSERT_EQ(*source->shared().get(), *source.get());
362}

◆ TEST() [135/715]

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

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

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(
607 DlTileMode::kClamp, &kTestMatrix1);
608}

◆ TEST() [138/715]

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

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(
670 DlTileMode::kClamp, &kTestMatrix1);
671 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
673 DlTileMode::kClamp, &kTestMatrix1);
674 TestEquals(*source1, *source2);
675}

◆ TEST() [140/715]

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(
680 DlTileMode::kClamp, &kTestMatrix1);
681 {
682 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
684 DlTileMode::kClamp, &kTestMatrix1);
685 TestNotEquals(*source1, *source2, "Center differs");
686 }
687 {
688 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
690 DlTileMode::kClamp, &kTestMatrix1);
691 TestNotEquals(*source1, *source2, "Start Angle differs");
692 }
693 {
694 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
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(
708 kTestStops, DlTileMode::kClamp, &kTestMatrix1);
709 TestNotEquals(*source1, *source2, "Colors differ");
710 }
711 {
712 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
714 DlTileMode::kClamp, &kTestMatrix1);
715 TestNotEquals(*source1, *source2, "Stops differ");
716 }
717 {
718 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
720 DlTileMode::kMirror, &kTestMatrix1);
721 TestNotEquals(*source1, *source2, "Tile Mode differs");
722 }
723 {
724 std::shared_ptr<DlColorSource> source2 = DlColorSource::MakeSweep(
726 DlTileMode::kClamp, &kTestMatrix2);
727 TestNotEquals(*source1, *source2, "Matrix differs");
728 }
729}

◆ TEST() [141/715]

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(
613 DlTileMode::kClamp, &kTestMatrix1);
614 ASSERT_NE(source->shared().get(), source.get());
615 ASSERT_EQ(*source->shared().get(), *source.get());
616}

◆ TEST() [142/715]

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
Definition: dl_builder.cc:1077
sk_sp< DisplayList > Build()
Definition: dl_builder.cc:67

◆ TEST() [143/715]

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

flutter::testing::TEST ( DisplayListComplexity  ,
DrawArc   
)

Definition at line 281 of file dl_complexity_unittests.cc.

281 {
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() [145/715]

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

flutter::testing::TEST ( DisplayListComplexity  ,
DrawCircle   
)

Definition at line 242 of file dl_complexity_unittests.cc.

242 {
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() [147/715]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawDRRect   
)

Definition at line 266 of file dl_complexity_unittests.cc.

266 {
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() [148/715]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawImage   
)

Definition at line 353 of file dl_complexity_unittests.cc.

353 {
358 bitmap.allocPixels(info, 0);
360
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() [149/715]

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
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}
dest
Definition: zip.py:79

◆ TEST() [150/715]

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

flutter::testing::TEST ( DisplayListComplexity  ,
DrawOval   
)

Definition at line 231 of file dl_complexity_unittests.cc.

231 {
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() [152/715]

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:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition: SkPath.cpp:746
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition: SkPath.cpp:799
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
Definition: SkPath.cpp:766
SkPath & close()
Definition: SkPath.cpp:823
void DrawPath(const SkPath &path, const DlPaint &paint) override
Definition: dl_builder.cc:1204
SkPath quad_path()
Definition: overstroke.cpp:60
SkPath cubic_path()
Definition: overstroke.cpp:68

◆ TEST() [153/715]

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
Definition: dl_builder.cc:1305

◆ TEST() [154/715]

flutter::testing::TEST ( DisplayListComplexity  ,
DrawRRect   
)

Definition at line 253 of file dl_complexity_unittests.cc.

253 {
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() [155/715]

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
Definition: dl_builder.cc:1679

◆ TEST() [156/715]

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
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
Definition: dl_builder.cc:1630

◆ TEST() [157/715]

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

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

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

flutter::testing::TEST ( DisplayListComplexity  ,
SaveLayers   
)

Definition at line 134 of file dl_complexity_unittests.cc.

134 {
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() [161/715]

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_1.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() [162/715]

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
Definition: dl_builder.cc:1116

◆ TEST() [163/715]

flutter::testing::TEST ( DisplayListGeometryTypes  ,
ISizeConversion   
)

Definition at line 39 of file dl_geometry_types_unittests.cc.

39 {
40 SkISize sk_s = SkISize::Make(1.0f, 2.0f);
41 DlISize dl_s = DlISize(1.0f, 2.0f);
42
43 EXPECT_EQ(sk_s, ToSkISize(dl_s));
44 EXPECT_EQ(ToDlISize(sk_s), dl_s);
45
46 sk_s = SkISize::Make(1.0f, 2.0f);
47 dl_s = DlISize(1.0f, 3.0f);
48
49 EXPECT_NE(sk_s, ToSkISize(dl_s));
50 EXPECT_NE(ToDlISize(sk_s), dl_s);
51}
const DlISize & ToDlISize(const SkISize &size)
impeller::ISize32 DlISize
const SkISize & ToSkISize(const DlISize &size)
Definition: SkSize.h:16

◆ TEST() [164/715]

flutter::testing::TEST ( DisplayListGeometryTypes  ,
PointConversion   
)

Definition at line 11 of file dl_geometry_types_unittests.cc.

11 {
12 SkPoint sk_p = SkPoint::Make(1.0f, 2.0f);
13 DlPoint dl_p = DlPoint(1.0f, 2.0f);
14
15 EXPECT_EQ(sk_p, ToSkPoint(dl_p));
16 EXPECT_EQ(ToDlPoint(sk_p), dl_p);
17
18 sk_p = SkPoint::Make(1.0f, 2.0f);
19 dl_p = DlPoint(1.0f, 3.0f);
20
21 EXPECT_NE(sk_p, ToSkPoint(dl_p));
22 EXPECT_NE(ToDlPoint(sk_p), dl_p);
23}
const SkPoint & ToSkPoint(const DlPoint &point)
const DlPoint & ToDlPoint(const SkPoint &point)

◆ TEST() [165/715]

flutter::testing::TEST ( DisplayListGeometryTypes  ,
RectConversion   
)

Definition at line 25 of file dl_geometry_types_unittests.cc.

25 {
26 SkRect sk_r = SkRect::MakeLTRB(1.0f, 2.0f, 3.0f, 4.0f);
27 DlRect dl_r = DlRect::MakeLTRB(1.0f, 2.0f, 3.0f, 4.0f);
28
29 EXPECT_EQ(sk_r, ToSkRect(dl_r));
30 EXPECT_EQ(ToDlRect(sk_r), dl_r);
31
32 sk_r = SkRect::MakeLTRB(1.0f, 2.0f, 3.0f, 4.0f);
33 dl_r = DlRect::MakeLTRB(1.0f, 2.0f, 3.0f, 5.0f);
34
35 EXPECT_NE(sk_r, ToSkRect(dl_r));
36 EXPECT_NE(ToDlRect(sk_r), dl_r);
37}
const DlRect & ToDlRect(const SkRect &rect)
const SkRect & ToSkRect(const DlRect &rect)

◆ TEST() [166/715]

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

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 SkRect &expectedLocalOutputBounds)
SkRect makeOutset(float dx, float dy) const
Definition: SkRect.h:1002

◆ TEST() [168/715]

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

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

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

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

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

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

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

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

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

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

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

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

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()
Definition: SkMatrix.cpp:1544
static void TestInvalidBounds(const DlImageFilter &filter, const SkMatrix &matrix, const SkRect &localInputBounds)

◆ TEST() [181/715]

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

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

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

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),
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() [185/715]

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

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

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

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

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),
439 DlBlurImageFilter inner(5.0, 6.0, DlTileMode::kMirror);
440 DlComposeImageFilter filter(outer, inner);
441}

◆ TEST() [190/715]

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),
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() [191/715]

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),
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),
491 DlBlurImageFilter inner2(5.0, 6.0, DlTileMode::kMirror);
492 DlComposeImageFilter filter2(outer1, inner1);
493
494 TestEquals(filter1, filter2);
495}

◆ TEST() [192/715]

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),
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),
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() [193/715]

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),
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() [194/715]

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),
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),
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() [195/715]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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,
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,
790 SkImageFilter::MapDirection::kForward_MapDirection);
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,
812 SkImageFilter::MapDirection::kReverse_MapDirection);
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
SkSamplingOptions(SkFilterMode::kLinear))

◆ TEST() [213/715]

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

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),
365
366 ASSERT_NE(filter.asMatrix(), nullptr);
367 ASSERT_EQ(filter.asMatrix(), &filter);
368}

◆ TEST() [215/715]

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));
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() [216/715]

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),
348}

◆ TEST() [217/715]

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);
375
376 ASSERT_EQ(filter.matrix(), matrix);
377 ASSERT_EQ(filter.sampling(), DlImageSampling::kLinear);
378}

◆ TEST() [218/715]

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);
386
387 TestEquals(filter1, filter2);
388}

◆ TEST() [219/715]

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);
411 DlMatrixImageFilter filter3(matrix1, DlImageSampling::kNearestNeighbor);
412
413 TestNotEquals(filter1, filter2, "Matrix differs");
414 TestNotEquals(filter1, filter3, "Sampling differs");
415}

◆ TEST() [220/715]

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),
355
356 ASSERT_NE(filter.shared().get(), &filter);
357 ASSERT_EQ(*filter.shared(), filter);
358}

◆ TEST() [221/715]

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);
396
397 SkMatrix local_matrix = SkMatrix::Translate(10, 10);
398 TestEquals(*filter1.makeWithLocalMatrix(local_matrix),
399 *filter2.makeWithLocalMatrix(local_matrix));
400}

◆ TEST() [222/715]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurAsBlur   
)

Definition at line 23 of file dl_mask_filter_unittests.cc.

23 {
25 ASSERT_NE(filter.asBlur(), nullptr);
26 ASSERT_EQ(filter.asBlur(), &filter);
27}
@ kNormal
Default priority level.
Definition: embedder.h:262

◆ TEST() [223/715]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurConstructor   
)

Definition at line 13 of file dl_mask_filter_unittests.cc.

13 {
15}

◆ TEST() [224/715]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurContents   
)

Definition at line 29 of file dl_mask_filter_unittests.cc.

29 {
31 ASSERT_EQ(filter.style(), DlBlurStyle::kNormal);
32 ASSERT_EQ(filter.sigma(), 5.0);
33}

◆ TEST() [225/715]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurEquals   
)

Definition at line 35 of file dl_mask_filter_unittests.cc.

35 {
38 TestEquals(filter1, filter2);
39}

◆ TEST() [226/715]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurNotEquals   
)

Definition at line 41 of file dl_mask_filter_unittests.cc.

41 {
43 DlBlurMaskFilter filter2(DlBlurStyle::kInner, 5.0);
45 TestNotEquals(filter1, filter2, "Blur style differs");
46 TestNotEquals(filter1, filter3, "blur radius differs");
47}

◆ TEST() [227/715]

flutter::testing::TEST ( DisplayListMaskFilter  ,
BlurShared   
)

Definition at line 17 of file dl_mask_filter_unittests.cc.

17 {
19 ASSERT_NE(filter.shared().get(), &filter);
20 ASSERT_EQ(*filter.shared(), filter);
21}

◆ TEST() [228/715]

flutter::testing::TEST ( DisplayListMaskFilter  ,
ComparableTemplates   
)

Definition at line 100 of file dl_mask_filter_unittests.cc.

100 {
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(const std::shared_ptr< const DlMaskFilter > &a, const std::shared_ptr< const DlMaskFilter > &b)
void testEquals(const std::shared_ptr< const DlMaskFilter > &a, const std::shared_ptr< const DlMaskFilter > &b)

◆ TEST() [229/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
ClipDifference   
)

Definition at line 476 of file dl_matrix_clip_tracker_unittests.cc.

476 {
477 SkRect cull_rect = SkRect::MakeLTRB(20, 20, 40, 40);
478
479 auto non_reducing = [&cull_rect](const SkRect& diff_rect,
480 const std::string& label) {
481 {
483 state.clipRect(diff_rect, DlCanvas::ClipOp::kDifference, false);
484 EXPECT_EQ(state.device_cull_rect(), cull_rect) << label;
485 }
486 {
488 const SkRRect diff_rrect = SkRRect::MakeRect(diff_rect);
489 state.clipRRect(diff_rrect, DlCanvas::ClipOp::kDifference, false);
490 EXPECT_EQ(state.device_cull_rect(), cull_rect) << label << " (RRect)";
491 }
492 {
493 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
494 const SkPath diff_path = SkPath().addRect(diff_rect);
495 state.clipPath(diff_path, DlCanvas::ClipOp::kDifference, false);
496 EXPECT_EQ(state.device_cull_rect(), cull_rect) << label << " (RRect)";
497 }
498 };
499
500 auto reducing = [&cull_rect](const SkRect& diff_rect,
501 const SkRect& result_rect,
502 const std::string& label) {
503 EXPECT_TRUE(result_rect.isEmpty() || cull_rect.contains(result_rect));
504 {
505 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
506 state.clipRect(diff_rect, DlCanvas::ClipOp::kDifference, false);
507 EXPECT_EQ(state.device_cull_rect(), result_rect) << label;
508 }
509 {
510 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
511 const SkRRect diff_rrect = SkRRect::MakeRect(diff_rect);
512 state.clipRRect(diff_rrect, DlCanvas::ClipOp::kDifference, false);
513 EXPECT_EQ(state.device_cull_rect(), result_rect) << label << " (RRect)";
514 }
515 {
516 DisplayListMatrixClipState state(cull_rect, SkMatrix::I());
517 const SkPath diff_path = SkPath().addRect(diff_rect);
518 state.clipPath(diff_path, DlCanvas::ClipOp::kDifference, false);
519 EXPECT_EQ(state.device_cull_rect(), result_rect) << label << " (RRect)";
520 }
521 };
522
523 // Skim the corners and edge
524 non_reducing(SkRect::MakeLTRB(10, 10, 20, 20), "outside UL corner");
525 non_reducing(SkRect::MakeLTRB(20, 10, 40, 20), "Above");
526 non_reducing(SkRect::MakeLTRB(40, 10, 50, 20), "outside UR corner");
527 non_reducing(SkRect::MakeLTRB(40, 20, 50, 40), "Right");
528 non_reducing(SkRect::MakeLTRB(40, 40, 50, 50), "outside LR corner");
529 non_reducing(SkRect::MakeLTRB(20, 40, 40, 50), "Below");
530 non_reducing(SkRect::MakeLTRB(10, 40, 20, 50), "outside LR corner");
531 non_reducing(SkRect::MakeLTRB(10, 20, 20, 40), "Left");
532
533 // Overlap corners
534 non_reducing(SkRect::MakeLTRB(15, 15, 25, 25), "covering UL corner");
535 non_reducing(SkRect::MakeLTRB(35, 15, 45, 25), "covering UR corner");
536 non_reducing(SkRect::MakeLTRB(35, 35, 45, 45), "covering LR corner");
537 non_reducing(SkRect::MakeLTRB(15, 35, 25, 45), "covering LL corner");
538
539 // Overlap edges, but not across an entire side
540 non_reducing(SkRect::MakeLTRB(20, 15, 39, 25), "Top edge left-biased");
541 non_reducing(SkRect::MakeLTRB(21, 15, 40, 25), "Top edge, right biased");
542 non_reducing(SkRect::MakeLTRB(35, 20, 45, 39), "Right edge, top-biased");
543 non_reducing(SkRect::MakeLTRB(35, 21, 45, 40), "Right edge, bottom-biased");
544 non_reducing(SkRect::MakeLTRB(20, 35, 39, 45), "Bottom edge, left-biased");
545 non_reducing(SkRect::MakeLTRB(21, 35, 40, 45), "Bottom edge, right-biased");
546 non_reducing(SkRect::MakeLTRB(15, 20, 25, 39), "Left edge, top-biased");
547 non_reducing(SkRect::MakeLTRB(15, 21, 25, 40), "Left edge, bottom-biased");
548
549 // Slice all the way through the middle
550 non_reducing(SkRect::MakeLTRB(25, 15, 35, 45), "Vertical interior slice");
551 non_reducing(SkRect::MakeLTRB(15, 25, 45, 35), "Horizontal interior slice");
552
553 // Slice off each edge
554 reducing(SkRect::MakeLTRB(20, 15, 40, 25), //
555 SkRect::MakeLTRB(20, 25, 40, 40), //
556 "Slice off top");
557 reducing(SkRect::MakeLTRB(35, 20, 45, 40), //
558 SkRect::MakeLTRB(20, 20, 35, 40), //
559 "Slice off right");
560 reducing(SkRect::MakeLTRB(20, 35, 40, 45), //
561 SkRect::MakeLTRB(20, 20, 40, 35), //
562 "Slice off bottom");
563 reducing(SkRect::MakeLTRB(15, 20, 25, 40), //
564 SkRect::MakeLTRB(25, 20, 40, 40), //
565 "Slice off left");
566
567 // cull rect contains diff rect
568 non_reducing(SkRect::MakeLTRB(21, 21, 39, 39), "Contained, non-covering");
569
570 // cull rect equals diff rect
571 reducing(cull_rect, SkRect::MakeEmpty(), "Perfectly covering");
572
573 // diff rect contains cull rect
574 reducing(SkRect::MakeLTRB(15, 15, 45, 45), SkRect::MakeEmpty(), "Smothering");
575}
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595
bool contains(SkScalar x, SkScalar y) const
Definition: extension.cpp:19

◆ TEST() [230/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
ClipPathWithInvertFillType   
)

Definition at line 577 of file dl_matrix_clip_tracker_unittests.cc.

577 {
578 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
580 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
582 state.clipPath(clip, DlCanvas::ClipOp::kIntersect, false);
583
584 EXPECT_EQ(state.local_cull_rect(), cull_rect);
585 EXPECT_EQ(state.device_cull_rect(), cull_rect);
586}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1213
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235

◆ TEST() [231/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Constructor   
)

Definition at line 12 of file dl_matrix_clip_tracker_unittests.cc.

12 {
13 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
14 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
15 const SkMatrix matrix = SkMatrix::Scale(4, 4);
16 const SkM44 m44 = SkM44::Scale(4, 4);
17 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
18 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
19
20 DisplayListMatrixClipState state1(cull_rect, matrix);
21 DisplayListMatrixClipState state2(cull_rect, m44);
22 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
23
24 EXPECT_FALSE(state1.using_4x4_matrix());
25 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
26 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
27 EXPECT_EQ(state1.matrix_3x3(), matrix);
28 EXPECT_EQ(state1.matrix_4x4(), m44);
29 EXPECT_EQ(state1.matrix(), dl_matrix);
30
31 EXPECT_FALSE(state2.using_4x4_matrix());
32 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
33 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
34 EXPECT_EQ(state2.matrix_3x3(), matrix);
35 EXPECT_EQ(state2.matrix_4x4(), m44);
36 EXPECT_EQ(state2.matrix(), dl_matrix);
37
38 EXPECT_FALSE(state3.using_4x4_matrix());
39 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
40 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
41 EXPECT_EQ(state3.matrix_3x3(), matrix);
42 EXPECT_EQ(state3.matrix_4x4(), m44);
43 EXPECT_EQ(state3.matrix(), dl_matrix);
44}
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() [232/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Constructor4x4   
)

Definition at line 46 of file dl_matrix_clip_tracker_unittests.cc.

46 {
47 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
48 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
49 // clang-format off
50 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
51 0, 4, 0.5, 0,
52 0, 0, 4.0, 0,
53 0, 0, 0.0, 1);
54 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
55 0, 4, 0.5, 0,
56 0, 0, 4.0, 0,
57 0, 0, 0.0, 1);
58 // clang-format on
59 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
60
61 DisplayListMatrixClipState state1(cull_rect, m44);
62 DisplayListMatrixClipState state2(dl_cull_rect, dl_matrix);
63
64 EXPECT_TRUE(state1.using_4x4_matrix());
65 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
66 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
67 EXPECT_EQ(state1.matrix_4x4(), m44);
68 EXPECT_EQ(state1.matrix(), dl_matrix);
69
70 EXPECT_TRUE(state2.using_4x4_matrix());
71 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
72 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
73 EXPECT_EQ(state2.matrix_4x4(), m44);
74 EXPECT_EQ(state2.matrix(), dl_matrix);
75}

◆ TEST() [233/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
DiffClipPathWithInvertFillType   
)

Definition at line 588 of file dl_matrix_clip_tracker_unittests.cc.

588 {
589 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
591
592 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
594 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
595 state.clipPath(clip, DlCanvas::ClipOp::kDifference, false);
596
597 EXPECT_EQ(state.local_cull_rect(), clip_bounds);
598 EXPECT_EQ(state.device_cull_rect(), clip_bounds);
599}

◆ TEST() [234/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
MapAndClipRectScale   
)

Definition at line 684 of file dl_matrix_clip_tracker_unittests.cc.

684 {
685 DlRect cull_rect = DlRect::MakeLTRB(100.0f, 100.0f, 500.0f, 500.0f);
686 DlMatrix matrix = DlMatrix::MakeScale({2.0f, 4.0f, 1.0f});
688
689 {
690 // Empty width in src rect (before and after scaling)
691 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 100.0f, 110.0f);
692 EXPECT_FALSE(state.mapAndClipRect(&rect));
693 EXPECT_TRUE(rect.isEmpty());
694 }
695
696 {
697 // Empty height in src rect (before and after scaling)
698 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 110.0f, 100.0f);
699 EXPECT_FALSE(state.mapAndClipRect(&rect));
700 EXPECT_TRUE(rect.isEmpty());
701 }
702
703 {
704 // rect far outside of clip, even after scaling
705 SkRect rect = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
706 EXPECT_FALSE(state.mapAndClipRect(&rect));
707 EXPECT_TRUE(rect.isEmpty());
708 }
709
710 {
711 // Rect abuts clip left side after scaling
712 SkRect rect = SkRect::MakeLTRB(40.0f, 100.0f, 50.0f, 110.0f);
713 EXPECT_FALSE(state.mapAndClipRect(&rect));
714 EXPECT_TRUE(rect.isEmpty());
715 }
716
717 {
718 // Rect barely grazes clip left side after scaling
719 SkRect rect = SkRect::MakeLTRB(40.0f, 100.0f, 51.0f, 110.0f);
720 EXPECT_TRUE(state.mapAndClipRect(&rect));
721 EXPECT_EQ(rect, SkRect::MakeLTRB(100.0f, 400.0f, 102.0f, 440.0f));
722 }
723
724 {
725 // Rect abuts clip top after scaling
726 SkRect rect = SkRect::MakeLTRB(100.0f, 15.0f, 110.0f, 25.0f);
727 EXPECT_FALSE(state.mapAndClipRect(&rect));
728 EXPECT_TRUE(rect.isEmpty());
729 }
730
731 {
732 // Rect barely grazes clip top after scaling
733 SkRect rect = SkRect::MakeLTRB(100.0f, 15.0f, 110.0f, 26.0f);
734 EXPECT_TRUE(state.mapAndClipRect(&rect));
735 EXPECT_EQ(rect, SkRect::MakeLTRB(200.0f, 100.0f, 220.0f, 104.0f));
736 }
737
738 {
739 // Rect abuts clip right side after scaling
740 SkRect rect = SkRect::MakeLTRB(250.0f, 100.0f, 260.0f, 110.0f);
741 EXPECT_FALSE(state.mapAndClipRect(&rect));
742 EXPECT_TRUE(rect.isEmpty());
743 }
744
745 {
746 // Rect barely grazes clip right side after scaling
747 SkRect rect = SkRect::MakeLTRB(249.0f, 100.0f, 260.0f, 110.0f);
748 EXPECT_TRUE(state.mapAndClipRect(&rect));
749 EXPECT_EQ(rect, SkRect::MakeLTRB(498.0f, 400.0f, 500.0f, 440.0f));
750 }
751
752 {
753 // Rect abuts clip bottom after scaling
754 SkRect rect = SkRect::MakeLTRB(100.0f, 125.0f, 110.0f, 135.0f);
755 EXPECT_FALSE(state.mapAndClipRect(&rect));
756 EXPECT_TRUE(rect.isEmpty());
757 }
758
759 {
760 // Rect barely grazes clip bottom after scaling
761 SkRect rect = SkRect::MakeLTRB(100.0f, 124.0f, 110.0f, 135.0f);
762 EXPECT_TRUE(state.mapAndClipRect(&rect));
763 EXPECT_EQ(rect, SkRect::MakeLTRB(200.0f, 496.0f, 220.0f, 500.0f));
764 }
765}

◆ TEST() [235/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
MapAndClipRectTranslation   
)

Definition at line 601 of file dl_matrix_clip_tracker_unittests.cc.

601 {
602 DlRect cull_rect = DlRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
603 DlMatrix matrix = DlMatrix::MakeTranslation({10.0f, 20.0f, 1.0f});
605
606 {
607 // Empty width in src rect (before and after translation)
608 SkRect rect = SkRect::MakeLTRB(150.0f, 150.0f, 150.0f, 160.0f);
609 EXPECT_FALSE(state.mapAndClipRect(&rect));
610 EXPECT_TRUE(rect.isEmpty());
611 }
612
613 {
614 // Empty height in src rect (before and after translation)
615 SkRect rect = SkRect::MakeLTRB(150.0f, 150.0f, 160.0f, 150.0f);
616 EXPECT_FALSE(state.mapAndClipRect(&rect));
617 EXPECT_TRUE(rect.isEmpty());
618 }
619
620 {
621 // rect far outside of clip, even after translation
622 SkRect rect = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
623 EXPECT_FALSE(state.mapAndClipRect(&rect));
624 EXPECT_TRUE(rect.isEmpty());
625 }
626
627 {
628 // Rect abuts clip left side after translation
629 SkRect rect = SkRect::MakeLTRB(80.0f, 100.0f, 90.0f, 110.0f);
630 EXPECT_FALSE(state.mapAndClipRect(&rect));
631 EXPECT_TRUE(rect.isEmpty());
632 }
633
634 {
635 // Rect barely grazes clip left side after translation
636 SkRect rect = SkRect::MakeLTRB(80.0f, 100.0f, 91.0f, 110.0f);
637 EXPECT_TRUE(state.mapAndClipRect(&rect));
638 EXPECT_EQ(rect, SkRect::MakeLTRB(100.0f, 120.0f, 101.0f, 130.0f));
639 }
640
641 {
642 // Rect abuts clip top after translation
643 SkRect rect = SkRect::MakeLTRB(100.0f, 70.0f, 110.0f, 80.0f);
644 EXPECT_FALSE(state.mapAndClipRect(&rect));
645 EXPECT_TRUE(rect.isEmpty());
646 }
647
648 {
649 // Rect barely grazes clip top after translation
650 SkRect rect = SkRect::MakeLTRB(100.0f, 70.0f, 110.0f, 81.0f);
651 EXPECT_TRUE(state.mapAndClipRect(&rect));
652 EXPECT_EQ(rect, SkRect::MakeLTRB(110.0f, 100.0f, 120.0f, 101.0f));
653 }
654
655 {
656 // Rect abuts clip right side after translation
657 SkRect rect = SkRect::MakeLTRB(190.0f, 100.0f, 200.0f, 110.0f);
658 EXPECT_FALSE(state.mapAndClipRect(&rect));
659 EXPECT_TRUE(rect.isEmpty());
660 }
661
662 {
663 // Rect barely grazes clip right side after translation
664 SkRect rect = SkRect::MakeLTRB(189.0f, 100.0f, 200.0f, 110.0f);
665 EXPECT_TRUE(state.mapAndClipRect(&rect));
666 EXPECT_EQ(rect, SkRect::MakeLTRB(199.0f, 120.0f, 200.0f, 130.0f));
667 }
668
669 {
670 // Rect abuts clip bottom after translation
671 SkRect rect = SkRect::MakeLTRB(100.0f, 180.0f, 110.0f, 190.0f);
672 EXPECT_FALSE(state.mapAndClipRect(&rect));
673 EXPECT_TRUE(rect.isEmpty());
674 }
675
676 {
677 // Rect barely grazes clip bottom after translation
678 SkRect rect = SkRect::MakeLTRB(100.0f, 179.0f, 110.0f, 190.0f);
679 EXPECT_TRUE(state.mapAndClipRect(&rect));
680 EXPECT_EQ(rect, SkRect::MakeLTRB(110.0f, 199.0f, 120.0f, 200.0f));
681 }
682}

◆ TEST() [236/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
OvalCoverage   
)

Definition at line 858 of file dl_matrix_clip_tracker_unittests.cc.

858 {
859 DlRect cull = DlRect::MakeLTRB(-50.0f, -50.0f, 50.0f, 50.0f);
861 // The cull rect corners will be at (50, 50) so the oval needs to have
862 // a radius large enough to cover that - sqrt(2*50*50) == sqrt(2) * 50
863 // We pad by an ever so slight 0.02f to account for round off error and
864 // then use larger expansion/contractions of 0.1f to cover/not-cover it.
865 DlRect test = cull.Scale(impeller::kSqrt2).Expand(0.02f);
866
867 EXPECT_TRUE(state.oval_covers_cull(test));
868 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.1f, 0.0f, 0.0f, 0.0f)));
869 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.0f, 0.1f, 0.0f, 0.0f)));
870 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, 0.1f, 0.0f)));
871 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, 0.0f, 0.1f)));
872 EXPECT_FALSE(state.oval_covers_cull(test.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
873 EXPECT_FALSE(state.oval_covers_cull(test.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
874 EXPECT_FALSE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
875 EXPECT_FALSE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
876}
constexpr float kSqrt2
Definition: constants.h:47
constexpr TRect Scale(Type scale) const
Definition: rect.h:192
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
Definition: rect.h:605

◆ TEST() [237/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
OvalCoverageUnderRotation   
)

Definition at line 901 of file dl_matrix_clip_tracker_unittests.cc.

901 {
902 DlRect unit = DlRect::MakeLTRB(-1.0f, -1.0f, 1.0f, 1.0f);
903 DlRect cull = unit.Scale(50.0f);
904 // See above, test bounds need to be sqrt(2) larger for the inscribed
905 // oval to contain the cull rect. These tests are simpler than the scaled
906 // rectangle coverage tests because this expanded test oval will
907 // precisely cover the cull rect at all angles.
909 DlRect test_true = test.Expand(0.002f);
910 DlRect test_false = test.Expand(-0.002f);
911
912 for (int i = 0; i <= 360; i++) {
914 state.rotate(i);
915 EXPECT_TRUE(state.oval_covers_cull(test_true))
916 << " testing " << test_true << std::endl
917 << " contains " << state.local_cull_rect() << std::endl
918 << " at " << i << " degrees";
919 EXPECT_FALSE(state.oval_covers_cull(test_false))
920 << " testing " << test_false << std::endl
921 << " contains " << state.local_cull_rect() << std::endl
922 << " at " << i << " degrees";
923 }
924}

◆ TEST() [238/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
OvalCoverageUnderScale   
)

Definition at line 878 of file dl_matrix_clip_tracker_unittests.cc.

878 {
879 DlRect cull = DlRect::MakeLTRB(-50.0f, -50.0f, 50.0f, 50.0f);
881 state.scale(2.0f, 2.0f);
882 // The cull rect corners will be at (50, 50) so the oval needs to have
883 // a radius large enough to cover that - sqrt(2*50*50) == sqrt(2) * 50
884 // We pad by an ever so slight 0.02f to account for round off error and
885 // then use larger expansion/contractions of 0.1f to cover/not-cover it.
886 // We combine that with an additional scale 0.5f since we are viewing
887 // the cull rect under a 2.0 scale.
888 DlRect test = cull.Scale(0.5f * impeller::kSqrt2).Expand(0.02f);
889
890 EXPECT_TRUE(state.oval_covers_cull(test));
891 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.1f, 0.0f, 0.0f, 0.0f)));
892 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.0f, 0.1f, 0.0f, 0.0f)));
893 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, 0.1f, 0.0f)));
894 EXPECT_TRUE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, 0.0f, 0.1f)));
895 EXPECT_FALSE(state.oval_covers_cull(test.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
896 EXPECT_FALSE(state.oval_covers_cull(test.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
897 EXPECT_FALSE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
898 EXPECT_FALSE(state.oval_covers_cull(test.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
899}

◆ TEST() [239/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
RectCoverage   
)

Definition at line 767 of file dl_matrix_clip_tracker_unittests.cc.

767 {
768 DlRect rect = DlRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
770
771 EXPECT_TRUE(state.rect_covers_cull(rect));
772 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.1f, 0.0f, 0.0f, 0.0f)));
773 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.0f, 0.1f, 0.0f, 0.0f)));
774 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, 0.1f, 0.0f)));
775 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, 0.0f, 0.1f)));
776 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
777 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
778 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
779 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
780}

◆ TEST() [240/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
RectCoverageAccuracy   
)

Definition at line 782 of file dl_matrix_clip_tracker_unittests.cc.

782 {
783 // These particular values create bit errors if we use the path that
784 // tests for inclusion in local space, but work OK if we use a forward
785 // path that tests for inclusion in device space, due to the fact that
786 // the extra matrix inversion is just enough math to cause the transform
787 // to place the local space cull corners just outside the original rect.
788 // The test in device space only works under a simple scale, such as we
789 // use for DPR adjustments (and which are not always inversion friendly).
790
791 DlRect cull = DlRect::MakeLTRB(0.0f, 0.0f, 1080.0f, 2400.0f);
792 DlScalar DPR = 2.625;
793 DlRect rect = DlRect::MakeLTRB(0.0f, 0.0f, 1080.0f / DPR, 2400.0f / DPR);
794
796 state.scale(DPR, DPR);
797
798 EXPECT_TRUE(state.rect_covers_cull(rect));
799 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.1f, 0.0f, 0.0f, 0.0f)));
800 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.0f, 0.1f, 0.0f, 0.0f)));
801 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, 0.1f, 0.0f)));
802 EXPECT_TRUE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, 0.0f, 0.1f)));
803 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
804 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
805 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
806 EXPECT_FALSE(state.rect_covers_cull(rect.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
807}

◆ TEST() [241/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
RectCoverageUnderRotation   
)

Definition at line 826 of file dl_matrix_clip_tracker_unittests.cc.

826 {
827 DlRect rect = DlRect::MakeLTRB(-1.0f, -1.0f, 1.0f, 1.0f);
828 DlRect cull = rect.Scale(impeller::kSqrt2 * 25);
829 DlRect test = rect.Scale(50.0f);
830 DlRect test_true = test.Expand(0.002f);
831 DlRect test_false = test.Expand(-0.002f);
832
833 for (int i = 0; i <= 360; i++) {
835 state.rotate(i);
836 EXPECT_TRUE(state.rect_covers_cull(test_true))
837 << " testing " << test_true << std::endl
838 << " contains " << state.local_cull_rect() << std::endl
839 << " at " << i << " degrees";
840 if ((i % 90) == 45) {
841 // The cull rect is largest when viewed at multiples of 45
842 // degrees so we will fail to contain it at those angles
843 EXPECT_FALSE(state.rect_covers_cull(test_false))
844 << " testing " << test_false << std::endl
845 << " contains " << state.local_cull_rect() << std::endl
846 << " at " << i << " degrees";
847 } else {
848 // At other angles, the cull rect is not quite so big as to encroach
849 // upon the expanded test rectangle.
850 EXPECT_TRUE(state.rect_covers_cull(test_false))
851 << " testing " << test_false << std::endl
852 << " contains " << state.local_cull_rect() << std::endl
853 << " at " << i << " degrees";
854 }
855 }
856}

◆ TEST() [242/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
RectCoverageUnderScale   
)

Definition at line 809 of file dl_matrix_clip_tracker_unittests.cc.

809 {
810 DlRect rect = DlRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
812 state.scale(2.0f, 2.0f);
813
814 EXPECT_FALSE(state.rect_covers_cull(DlRect::MakeLTRB(100, 100, 200, 200)));
815 EXPECT_TRUE(state.rect_covers_cull(DlRect::MakeLTRB(50, 50, 100, 100)));
816 EXPECT_TRUE(state.rect_covers_cull(DlRect::MakeLTRB(49, 50, 100, 100)));
817 EXPECT_TRUE(state.rect_covers_cull(DlRect::MakeLTRB(50, 49, 100, 100)));
818 EXPECT_TRUE(state.rect_covers_cull(DlRect::MakeLTRB(50, 50, 101, 100)));
819 EXPECT_TRUE(state.rect_covers_cull(DlRect::MakeLTRB(50, 50, 100, 101)));
820 EXPECT_FALSE(state.rect_covers_cull(DlRect::MakeLTRB(51, 50, 100, 100)));
821 EXPECT_FALSE(state.rect_covers_cull(DlRect::MakeLTRB(50, 51, 100, 100)));
822 EXPECT_FALSE(state.rect_covers_cull(DlRect::MakeLTRB(50, 50, 99, 100)));
823 EXPECT_FALSE(state.rect_covers_cull(DlRect::MakeLTRB(50, 50, 100, 99)));
824}

◆ TEST() [243/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Rotate   
)

Definition at line 273 of file dl_matrix_clip_tracker_unittests.cc.

273 {
274 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
275 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
276 const SkMatrix matrix = SkMatrix::Scale(4, 4);
277 const SkM44 m44 = SkM44::Scale(4, 4);
278 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
279 const SkMatrix rotated_matrix =
281 const SkM44 rotated_m44 = SkM44(rotated_matrix);
282 const DlMatrix rotated_dl_matrix =
283 dl_matrix * DlMatrix::MakeRotationZ(DlDegrees(90));
284 const SkRect local_cull_rect = SkRect::MakeLTRB(10, -15, 20, -5);
285
286 DisplayListMatrixClipState state1(cull_rect, matrix);
287 DisplayListMatrixClipState state2(cull_rect, m44);
288 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
289 state1.rotate(90);
290 state2.rotate(90);
291 state3.rotate(90);
292
293 EXPECT_FALSE(state1.using_4x4_matrix());
294 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
295 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
296 EXPECT_EQ(state1.matrix_3x3(), rotated_matrix);
297 EXPECT_EQ(state1.matrix_4x4(), rotated_m44);
298 EXPECT_EQ(state1.matrix(), rotated_dl_matrix);
299
300 EXPECT_FALSE(state2.using_4x4_matrix());
301 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
302 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
303 EXPECT_EQ(state2.matrix_3x3(), rotated_matrix);
304 EXPECT_EQ(state2.matrix_4x4(), rotated_m44);
305 EXPECT_EQ(state2.matrix(), rotated_dl_matrix);
306
307 EXPECT_FALSE(state3.using_4x4_matrix());
308 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
309 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
310 EXPECT_EQ(state3.matrix_3x3(), rotated_matrix);
311 EXPECT_EQ(state3.matrix_4x4(), rotated_m44);
312 EXPECT_EQ(state3.matrix(), rotated_dl_matrix);
313}
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition: SkMatrix.h:1775
impeller::Degrees DlDegrees

◆ TEST() [244/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
RRectCoverage   
)

Definition at line 926 of file dl_matrix_clip_tracker_unittests.cc.

926 {
927 SkRect cull = SkRect::MakeLTRB(-50.0f, -50.0f, 50.0f, 50.0f);
929 // test_bounds need to contain
930 SkRect test = cull.makeOutset(2.0f, 2.0f);
931
932 // RRect of cull with no corners covers
933 EXPECT_TRUE(state.rrect_covers_cull(SkRRect::MakeRectXY(cull, 0.0f, 0.0f)));
934 // RRect of cull with even the tiniest corners does not cover
935 EXPECT_FALSE(
936 state.rrect_covers_cull(SkRRect::MakeRectXY(cull, 0.01f, 0.01f)));
937
938 // Expanded by 2.0 and then with a corner of 2.0 obviously still covers
939 EXPECT_TRUE(state.rrect_covers_cull(SkRRect::MakeRectXY(test, 2.0f, 2.0f)));
940 // The corner point of the cull rect is at (c-2, c-2) relative to the
941 // corner of the rrect bounds so we compute its disance to the center
942 // of the circular part and compare it to the radius of the corner (c)
943 // to find the corner radius where it will start to leave the rounded
944 // rectangle:
945 //
946 // +----------- +
947 // | __---^^ |
948 // | +/------- + |
949 // | / \ | c
950 // | /| \ c-2 |
951 // |/ | \ | |
952 // || | * + +
953 //
954 // sqrt(2*(c-2)*(c-2)) > c
955 // 2*(c-2)*(c-2) > c*c
956 // 2*(cc - 4c + 4) > cc
957 // 2cc - 8c + 8 > cc
958 // cc - 8c + 8 > 0
959 // c > 8 +/- sqrt(64 - 32) / 2
960 // c > ~6.828
961 // corners set to 6.82 should still cover the cull rect
962 EXPECT_TRUE(state.rrect_covers_cull(SkRRect::MakeRectXY(test, 6.82f, 6.82f)));
963 // but corners set to 6.83 should not cover the cull rect
964 EXPECT_FALSE(
965 state.rrect_covers_cull(SkRRect::MakeRectXY(test, 6.84f, 6.84f)));
966}

◆ TEST() [245/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Scale   
)

Definition at line 189 of file dl_matrix_clip_tracker_unittests.cc.

189 {
190 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
191 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
192 const SkMatrix matrix = SkMatrix::Scale(4, 4);
193 const SkM44 m44 = SkM44::Scale(4, 4);
194 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
195 // Scale factor carefully chosen to multiply cleanly and invert
196 // without any non-binary-power-of-2 approximation errors.
197 const SkMatrix scaled_matrix =
199 const SkM44 scaled_m44 = SkM44(scaled_matrix);
200 const DlMatrix scaled_dl_matrix = dl_matrix.Scale({0.5, 2, 1});
201 const SkRect local_cull_rect = SkRect::MakeLTRB(10, 5, 30, 10);
202
203 DisplayListMatrixClipState state1(cull_rect, matrix);
204 DisplayListMatrixClipState state2(cull_rect, m44);
205 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
206 state1.scale(0.5, 2);
207 state2.scale(0.5, 2);
208 state3.scale(0.5, 2);
209
210 EXPECT_FALSE(state1.using_4x4_matrix());
211 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
212 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
213 EXPECT_EQ(state1.matrix_3x3(), scaled_matrix);
214 EXPECT_EQ(state1.matrix_4x4(), scaled_m44);
215 EXPECT_EQ(state1.matrix(), scaled_dl_matrix);
216
217 EXPECT_FALSE(state2.using_4x4_matrix());
218 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
219 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
220 EXPECT_EQ(state2.matrix_3x3(), scaled_matrix);
221 EXPECT_EQ(state2.matrix_4x4(), scaled_m44);
222 EXPECT_EQ(state2.matrix(), scaled_dl_matrix);
223
224 EXPECT_FALSE(state3.using_4x4_matrix());
225 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
226 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
227 EXPECT_EQ(state3.matrix_3x3(), scaled_matrix);
228 EXPECT_EQ(state3.matrix_4x4(), scaled_m44);
229 EXPECT_EQ(state3.matrix(), scaled_dl_matrix);
230}
constexpr Matrix Scale(const Vector3 &s) const
Definition: matrix.h:252

◆ TEST() [246/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
SetTo4x4   
)

Definition at line 112 of file dl_matrix_clip_tracker_unittests.cc.

112 {
113 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
114 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
115 // clang-format off
116 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
117 0, 4, 0.5, 0,
118 0, 0, 4.0, 0,
119 0, 0, 0.0, 1);
120 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
121 0, 4, 0.5, 0,
122 0, 0, 4.0, 0,
123 0, 0, 0.0, 1);
124 // clang-format on
125 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
126
127 DisplayListMatrixClipState state1(cull_rect, SkMatrix::I());
128 DisplayListMatrixClipState state2(dl_cull_rect, DlMatrix());
129 EXPECT_FALSE(state1.using_4x4_matrix());
130 EXPECT_FALSE(state2.using_4x4_matrix());
131
132 state1.setTransform(m44);
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 state2.setTransform(dl_matrix);
140 EXPECT_TRUE(state2.using_4x4_matrix());
141 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
142 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
143 EXPECT_EQ(state2.matrix_4x4(), m44);
144 EXPECT_EQ(state2.matrix(), dl_matrix);
145}
impeller::Matrix DlMatrix

◆ TEST() [247/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Skew   
)

Definition at line 232 of file dl_matrix_clip_tracker_unittests.cc.

232 {
233 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
234 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
235 const SkMatrix matrix = SkMatrix::Scale(4, 4);
236 const SkM44 m44 = SkM44::Scale(4, 4);
237 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
238 const SkMatrix skewed_matrix =
240 const SkM44 skewed_m44 = SkM44(skewed_matrix);
241 const DlMatrix skewed_dl_matrix = dl_matrix * DlMatrix::MakeSkew(0.25, 0);
242 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 10, 12.5, 20);
243
244 DisplayListMatrixClipState state1(cull_rect, matrix);
245 DisplayListMatrixClipState state2(cull_rect, m44);
246 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
247 state1.skew(.25, 0);
248 state2.skew(.25, 0);
249 state3.skew(.25, 0);
250
251 EXPECT_FALSE(state1.using_4x4_matrix());
252 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
253 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
254 EXPECT_EQ(state1.matrix_3x3(), skewed_matrix);
255 EXPECT_EQ(state1.matrix_4x4(), skewed_m44);
256 EXPECT_EQ(state1.matrix(), skewed_dl_matrix);
257
258 EXPECT_FALSE(state2.using_4x4_matrix());
259 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
260 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
261 EXPECT_EQ(state2.matrix_3x3(), skewed_matrix);
262 EXPECT_EQ(state2.matrix_4x4(), skewed_m44);
263 EXPECT_EQ(state2.matrix(), skewed_dl_matrix);
264
265 EXPECT_FALSE(state3.using_4x4_matrix());
266 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
267 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
268 EXPECT_EQ(state3.matrix_3x3(), skewed_matrix);
269 EXPECT_EQ(state3.matrix_4x4(), skewed_m44);
270 EXPECT_EQ(state3.matrix(), skewed_dl_matrix);
271}
static SkMatrix Skew(SkScalar kx, SkScalar ky)
Definition: SkMatrix.h:124

◆ TEST() [248/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Transform2DAffine   
)

Definition at line 315 of file dl_matrix_clip_tracker_unittests.cc.

315 {
316 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
317 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
318 const SkMatrix matrix = SkMatrix::Scale(4, 4);
319 const SkM44 m44 = SkM44::Scale(4, 4);
320 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
321
322 const SkMatrix transformed_matrix =
324 0, 2, 6, //
325 0, 0, 1));
326 const SkM44 transformed_m44 = SkM44(transformed_matrix);
327 const DlMatrix transformed_dl_matrix =
328 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
329 0, 2, 0, 6, //
330 0, 0, 1, 0, //
331 0, 0, 0, 1);
332 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
333
334 DisplayListMatrixClipState state1(cull_rect, matrix);
335 DisplayListMatrixClipState state2(cull_rect, m44);
336 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
337 state1.transform2DAffine(2, 0, 5, //
338 0, 2, 6);
339 state2.transform2DAffine(2, 0, 5, //
340 0, 2, 6);
341 state3.transform2DAffine(2, 0, 5, //
342 0, 2, 6);
343
344 EXPECT_FALSE(state1.using_4x4_matrix());
345 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
346 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
347 EXPECT_EQ(state1.matrix_3x3(), transformed_matrix);
348 EXPECT_EQ(state1.matrix_4x4(), transformed_m44);
349 EXPECT_EQ(state1.matrix(), transformed_dl_matrix);
350
351 EXPECT_FALSE(state2.using_4x4_matrix());
352 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
353 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
354 EXPECT_EQ(state2.matrix_3x3(), transformed_matrix);
355 EXPECT_EQ(state2.matrix_4x4(), transformed_m44);
356 EXPECT_EQ(state2.matrix(), transformed_dl_matrix);
357
358 EXPECT_FALSE(state3.using_4x4_matrix());
359 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
360 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
361 EXPECT_EQ(state3.matrix_3x3(), transformed_matrix);
362 EXPECT_EQ(state3.matrix_4x4(), transformed_m44);
363 EXPECT_EQ(state3.matrix(), transformed_dl_matrix);
364}

◆ TEST() [249/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
TransformFullPerspectiveUsing3x3Matrix   
)

Definition at line 366 of file dl_matrix_clip_tracker_unittests.cc.

366 {
367 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
368 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
369 const SkMatrix matrix = SkMatrix::Scale(4, 4);
370 const SkM44 m44 = SkM44::Scale(4, 4);
371 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
372
373 const SkMatrix transformed_matrix =
375 0, 2, 6, //
376 0, 0, 1));
377 const SkM44 transformed_m44 = SkM44(transformed_matrix);
378 const DlMatrix transformed_dl_matrix =
379 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
380 0, 2, 0, 6, //
381 0, 0, 1, 0, //
382 0, 0, 0, 1);
383 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
384
385 DisplayListMatrixClipState state1(cull_rect, matrix);
386 DisplayListMatrixClipState state2(cull_rect, m44);
387 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
388 state1.transformFullPerspective(2, 0, 0, 5, //
389 0, 2, 0, 6, //
390 0, 0, 1, 0, //
391 0, 0, 0, 1);
392 state2.transformFullPerspective(2, 0, 0, 5, //
393 0, 2, 0, 6, //
394 0, 0, 1, 0, //
395 0, 0, 0, 1);
396 state3.transformFullPerspective(2, 0, 0, 5, //
397 0, 2, 0, 6, //
398 0, 0, 1, 0, //
399 0, 0, 0, 1);
400
401 EXPECT_FALSE(state1.using_4x4_matrix());
402 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
403 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
404 EXPECT_EQ(state1.matrix_3x3(), transformed_matrix);
405 EXPECT_EQ(state1.matrix_4x4(), transformed_m44);
406 EXPECT_EQ(state1.matrix(), transformed_dl_matrix);
407
408 EXPECT_FALSE(state2.using_4x4_matrix());
409 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
410 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
411 EXPECT_EQ(state2.matrix_3x3(), transformed_matrix);
412 EXPECT_EQ(state2.matrix_4x4(), transformed_m44);
413 EXPECT_EQ(state2.matrix(), transformed_dl_matrix);
414
415 EXPECT_FALSE(state3.using_4x4_matrix());
416 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
417 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
418 EXPECT_EQ(state3.matrix_3x3(), transformed_matrix);
419 EXPECT_EQ(state3.matrix_4x4(), transformed_m44);
420 EXPECT_EQ(state3.matrix(), transformed_dl_matrix);
421}

◆ TEST() [250/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
TransformFullPerspectiveUsing4x4Matrix   
)

Definition at line 423 of file dl_matrix_clip_tracker_unittests.cc.

423 {
424 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
425 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
426 const SkMatrix matrix = SkMatrix::Scale(4, 4);
427 const SkM44 m44 = SkM44::Scale(4, 4);
428 const DlMatrix dl_matrix = DlMatrix::MakeScale({4, 4, 1});
429
430 const SkM44 transformed_m44 = SkM44(m44, SkM44(2, 0, 0, 5, //
431 0, 2, 0, 6, //
432 0, 0, 1, 7, //
433 0, 0, 0, 1));
434 const DlMatrix transformed_dl_matrix =
435 dl_matrix * DlMatrix::MakeRow(2, 0, 0, 5, //
436 0, 2, 0, 6, //
437 0, 0, 1, 7, //
438 0, 0, 0, 1);
439 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 2, 5, 7);
440
441 DisplayListMatrixClipState state1(cull_rect, matrix);
442 DisplayListMatrixClipState state2(cull_rect, m44);
443 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
444 state1.transformFullPerspective(2, 0, 0, 5, //
445 0, 2, 0, 6, //
446 0, 0, 1, 7, //
447 0, 0, 0, 1);
448 state2.transformFullPerspective(2, 0, 0, 5, //
449 0, 2, 0, 6, //
450 0, 0, 1, 7, //
451 0, 0, 0, 1);
452 state3.transformFullPerspective(2, 0, 0, 5, //
453 0, 2, 0, 6, //
454 0, 0, 1, 7, //
455 0, 0, 0, 1);
456
457 EXPECT_TRUE(state1.using_4x4_matrix());
458 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
459 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
460 EXPECT_EQ(state1.matrix_4x4(), transformed_m44);
461 EXPECT_EQ(state1.matrix(), transformed_dl_matrix);
462
463 EXPECT_TRUE(state2.using_4x4_matrix());
464 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
465 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
466 EXPECT_EQ(state2.matrix_4x4(), transformed_m44);
467 EXPECT_EQ(state2.matrix(), transformed_dl_matrix);
468
469 EXPECT_TRUE(state3.using_4x4_matrix());
470 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
471 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
472 EXPECT_EQ(state3.matrix_4x4(), transformed_m44);
473 EXPECT_EQ(state3.matrix(), transformed_dl_matrix);
474}

◆ TEST() [251/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
TransformTo4x4   
)

Definition at line 77 of file dl_matrix_clip_tracker_unittests.cc.

77 {
78 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
79 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
80 // clang-format off
81 const SkM44 m44 = SkM44(4, 0, 0.5, 0,
82 0, 4, 0.5, 0,
83 0, 0, 4.0, 0,
84 0, 0, 0.0, 1);
85 const DlMatrix dl_matrix = DlMatrix::MakeRow(4, 0, 0.5, 0,
86 0, 4, 0.5, 0,
87 0, 0, 4.0, 0,
88 0, 0, 0.0, 1);
89 // clang-format on
90 const SkRect local_cull_rect = SkRect::MakeLTRB(5, 10, 15, 20);
91
92 DisplayListMatrixClipState state1(cull_rect, SkMatrix::I());
93 DisplayListMatrixClipState state2(dl_cull_rect, DlMatrix());
94 EXPECT_FALSE(state1.using_4x4_matrix());
95 EXPECT_FALSE(state2.using_4x4_matrix());
96
97 state1.transform(m44);
98 EXPECT_TRUE(state1.using_4x4_matrix());
99 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
100 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
101 EXPECT_EQ(state1.matrix_4x4(), m44);
102 EXPECT_EQ(state1.matrix(), dl_matrix);
103
104 state2.transform(dl_matrix);
105 EXPECT_TRUE(state2.using_4x4_matrix());
106 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
107 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
108 EXPECT_EQ(state2.matrix_4x4(), m44);
109 EXPECT_EQ(state2.matrix(), dl_matrix);
110}

◆ TEST() [252/715]

flutter::testing::TEST ( DisplayListMatrixClipState  ,
Translate   
)

Definition at line 147 of file dl_matrix_clip_tracker_unittests.cc.

147 {
148 const SkRect cull_rect = SkRect::MakeLTRB(20, 40, 60, 80);
149 const DlRect dl_cull_rect = DlRect::MakeLTRB(20, 40, 60, 80);
150 const SkMatrix matrix = SkMatrix::Scale(4, 4);
151 const SkM44 m44 = SkM44::Scale(4, 4);
152 const DlMatrix dl_matrix = DlMatrix::MakeScale({4.0, 4.0, 1.0});
153 const SkMatrix translated_matrix =
155 const SkM44 translated_m44 = SkM44(translated_matrix);
156 const DlMatrix dl_translated_matrix =
157 dl_matrix * DlMatrix::MakeTranslation({5.0, 1.0});
158 const SkRect local_cull_rect = SkRect::MakeLTRB(0, 9, 10, 19);
159
160 DisplayListMatrixClipState state1(cull_rect, matrix);
161 DisplayListMatrixClipState state2(cull_rect, m44);
162 DisplayListMatrixClipState state3(dl_cull_rect, dl_matrix);
163 state1.translate(5, 1);
164 state2.translate(5, 1);
165 state3.translate(5, 1);
166
167 EXPECT_FALSE(state1.using_4x4_matrix());
168 EXPECT_EQ(state1.device_cull_rect(), cull_rect);
169 EXPECT_EQ(state1.local_cull_rect(), local_cull_rect);
170 EXPECT_EQ(state1.matrix_3x3(), translated_matrix);
171 EXPECT_EQ(state1.matrix_4x4(), translated_m44);
172 EXPECT_EQ(state1.matrix(), dl_translated_matrix);
173
174 EXPECT_FALSE(state2.using_4x4_matrix());
175 EXPECT_EQ(state2.device_cull_rect(), cull_rect);
176 EXPECT_EQ(state2.local_cull_rect(), local_cull_rect);
177 EXPECT_EQ(state2.matrix_3x3(), translated_matrix);
178 EXPECT_EQ(state2.matrix_4x4(), translated_m44);
179 EXPECT_EQ(state2.matrix(), dl_translated_matrix);
180
181 EXPECT_FALSE(state3.using_4x4_matrix());
182 EXPECT_EQ(state3.device_cull_rect(), cull_rect);
183 EXPECT_EQ(state3.local_cull_rect(), local_cull_rect);
184 EXPECT_EQ(state3.matrix_3x3(), translated_matrix);
185 EXPECT_EQ(state3.matrix_4x4(), translated_m44);
186 EXPECT_EQ(state3.matrix(), dl_translated_matrix);
187}

◆ TEST() [253/715]

flutter::testing::TEST ( DisplayListPaint  ,
ChainingConstructor   
)

Definition at line 95 of file dl_paint_unittests.cc.

95 {
97 DlPaint() //
98 .setAntiAlias(true) //
99 .setInvertColors(true) //
101 .setAlpha(0x7F) //
102 .setBlendMode(DlBlendMode::kLuminosity) //
103 .setDrawStyle(DlDrawStyle::kStrokeAndFill) //
104 .setStrokeCap(DlStrokeCap::kSquare) //
105 .setStrokeJoin(DlStrokeJoin::kBevel) //
106 .setStrokeWidth(42) //
107 .setStrokeMiter(1.5) //
110 DlBlendColorFilter(DlColor::kYellow(), DlBlendMode::kDstIn)
111 .shared())
113 DlBlurImageFilter(1.3, 4.7, DlTileMode::kClamp).shared())
114 .setMaskFilter(DlBlurMaskFilter(DlBlurStyle::kInner, 3.14).shared());
115 EXPECT_TRUE(paint.isAntiAlias());
116 EXPECT_TRUE(paint.isInvertColors());
117 EXPECT_EQ(paint.getColor(), DlColor::kGreen().withAlpha(0x7F));
118 EXPECT_EQ(paint.getAlpha(), 0x7F);
119 EXPECT_EQ(paint.getBlendMode(), DlBlendMode::kLuminosity);
120 EXPECT_EQ(paint.getDrawStyle(), DlDrawStyle::kStrokeAndFill);
121 EXPECT_EQ(paint.getStrokeCap(), DlStrokeCap::kSquare);
122 EXPECT_EQ(paint.getStrokeJoin(), DlStrokeJoin::kBevel);
123 EXPECT_EQ(paint.getStrokeWidth(), 42);
124 EXPECT_EQ(paint.getStrokeMiter(), 1.5);
125 EXPECT_EQ(*paint.getColorSource(), DlColorColorSource(DlColor::kMagenta()));
126 EXPECT_EQ(*paint.getColorFilter(),
127 DlBlendColorFilter(DlColor::kYellow(), DlBlendMode::kDstIn));
128 EXPECT_EQ(*paint.getImageFilter(),
129 DlBlurImageFilter(1.3, 4.7, DlTileMode::kClamp));
130 EXPECT_EQ(*paint.getMaskFilter(),
131 DlBlurMaskFilter(DlBlurStyle::kInner, 3.14));
132
133 EXPECT_NE(paint, DlPaint());
134}
DlPaint & setAntiAlias(bool isAntiAlias)
Definition: dl_paint.h:58
DlPaint & setInvertColors(bool isInvertColors)
Definition: dl_paint.h:64
DlPaint & setColorFilter(const std::shared_ptr< const DlColorFilter > &filter)
Definition: dl_paint.h:144
DlPaint & setMaskFilter(const std::shared_ptr< DlMaskFilter > &filter)
Definition: dl_paint.h:170
DlPaint & setStrokeCap(DlStrokeCap cap)
Definition: dl_paint.h:102
DlPaint & setStrokeWidth(float width)
Definition: dl_paint.h:116
DlPaint & setStrokeMiter(float miter)
Definition: dl_paint.h:122
DlPaint & setBlendMode(DlBlendMode mode)
Definition: dl_paint.h:86
DlPaint & setImageFilter(const std::shared_ptr< const DlImageFilter > &filter)
Definition: dl_paint.h:157
DlPaint & setStrokeJoin(DlStrokeJoin join)
Definition: dl_paint.h:110
DlPaint & setColorSource(std::shared_ptr< const DlColorSource > source)
Definition: dl_paint.h:131
constexpr SkColor4f kMagenta
Definition: SkColor.h:445
constexpr SkColor4f kYellow
Definition: SkColor.h:443

◆ TEST() [254/715]

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_TRUE(paint.isDefault());
30 EXPECT_EQ(paint, DlPaint::kDefault);
31
32 EXPECT_EQ(DlBlendMode::kDefaultMode, DlBlendMode::kSrcOver);
33 EXPECT_EQ(DlDrawStyle::kDefaultStyle, DlDrawStyle::kFill);
34 EXPECT_EQ(DlStrokeCap::kDefaultCap, DlStrokeCap::kButt);
35 EXPECT_EQ(DlStrokeJoin::kDefaultJoin, DlStrokeJoin::kMiter);
36
37 EXPECT_EQ(DlPaint::kDefaultColor, DlColor::kBlack());
38 EXPECT_EQ(DlPaint::kDefaultWidth, 0.0);
39 EXPECT_EQ(DlPaint::kDefaultMiter, 4.0);
40
41 EXPECT_EQ(paint, DlPaint());
42 EXPECT_EQ(paint, DlPaint(DlColor::kBlack()));
43 EXPECT_EQ(paint, DlPaint(DlColor(0xFF000000)));
44
45 EXPECT_NE(paint, DlPaint().setAntiAlias(true));
46 EXPECT_NE(paint, DlPaint().setInvertColors(true));
47 EXPECT_NE(paint, DlPaint().setColor(DlColor::kGreen()));
48 EXPECT_NE(paint, DlPaint(DlColor::kGreen()));
49 EXPECT_NE(paint, DlPaint(DlColor(0xFF00FF00)));
50 EXPECT_NE(paint, DlPaint().setAlpha(0x7f));
51 EXPECT_NE(paint, DlPaint().setBlendMode(DlBlendMode::kDstIn));
52 EXPECT_NE(paint, DlPaint().setDrawStyle(DlDrawStyle::kStrokeAndFill));
53 EXPECT_NE(paint, DlPaint().setStrokeCap(DlStrokeCap::kRound));
54 EXPECT_NE(paint, DlPaint().setStrokeJoin(DlStrokeJoin::kRound));
55 EXPECT_NE(paint, DlPaint().setStrokeWidth(6));
56 EXPECT_NE(paint, DlPaint().setStrokeMiter(7));
57
59 EXPECT_NE(paint, DlPaint().setColorSource(color_source.shared()));
60
61 DlBlendColorFilter color_filter(DlColor::kYellow(), DlBlendMode::kDstIn);
62 EXPECT_NE(paint, DlPaint().setColorFilter(color_filter.shared()));
63
64 DlBlurImageFilter image_filter(1.3, 4.7, DlTileMode::kClamp);
65 EXPECT_NE(paint, DlPaint().setImageFilter(image_filter.shared()));
66
67 DlBlurMaskFilter mask_filter(DlBlurStyle::kInner, 3.14);
68 EXPECT_NE(paint, DlPaint().setMaskFilter(mask_filter.shared()));
69}
static int kDefaultWidth
Definition: Request.cpp:23
std::shared_ptr< DlMaskFilter > mask_filter
@ kDefault

◆ TEST() [255/715]

flutter::testing::TEST ( DisplayListPaint  ,
NullPointerSetGet   
)

Definition at line 71 of file dl_paint_unittests.cc.

71 {
72 DlColorSource* null_color_source = nullptr;
73 DlColorFilter* null_color_filter = nullptr;
74 DlImageFilter* null_image_filter = nullptr;
75 DlMaskFilter* null_mask_filter = nullptr;
77 EXPECT_EQ(paint.setColorSource(null_color_source).getColorSource(), nullptr);
78 EXPECT_EQ(paint.setColorFilter(null_color_filter).getColorFilter(), nullptr);
79 EXPECT_EQ(paint.setImageFilter(null_image_filter).getImageFilter(), nullptr);
80 EXPECT_EQ(paint.setMaskFilter(null_mask_filter).getMaskFilter(), nullptr);
81}

◆ TEST() [256/715]

flutter::testing::TEST ( DisplayListPaint  ,
NullSharedPointerSetGet   
)

Definition at line 83 of file dl_paint_unittests.cc.

83 {
84 std::shared_ptr<DlColorSource> null_color_source;
85 std::shared_ptr<DlColorFilter> null_color_filter;
86 std::shared_ptr<DlImageFilter> null_image_filter;
87 std::shared_ptr<DlMaskFilter> null_mask_filter;
89 EXPECT_EQ(paint.setColorSource(null_color_source).getColorSource(), nullptr);
90 EXPECT_EQ(paint.setColorFilter(null_color_filter).getColorFilter(), nullptr);
91 EXPECT_EQ(paint.setImageFilter(null_image_filter).getImageFilter(), nullptr);
92 EXPECT_EQ(paint.setMaskFilter(null_mask_filter).getMaskFilter(), nullptr);
93}

◆ TEST() [257/715]

flutter::testing::TEST ( DisplayListRegion  ,
Deband   
)

Definition at line 128 of file dl_region_unittests.cc.

128 {
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}
ClipOpAndAA opAA SkRegion region
Definition: SkRecords.h:238

◆ TEST() [258/715]

flutter::testing::TEST ( DisplayListRegion  ,
EmptyRegion   
)

Definition at line 15 of file dl_region_unittests.cc.

15 {
18 EXPECT_TRUE(region.getRects().empty());
19}
bool isEmpty() const
Definition: SkRegion.h:146

◆ TEST() [259/715]

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

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

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

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

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

flutter::testing::TEST ( DisplayListRegion  ,
MergeTouchingRectangles   
)

Definition at line 89 of file dl_region_unittests.cc.

89 {
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() [265/715]

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

flutter::testing::TEST ( DisplayListRegion  ,
NonOverlappingRectangles2   
)

Definition at line 45 of file dl_region_unittests.cc.

45 {
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() [267/715]

flutter::testing::TEST ( DisplayListRegion  ,
NonOverlappingRectangles3   
)

Definition at line 62 of file dl_region_unittests.cc.

62 {
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() [268/715]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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();
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 kWhite
Definition: SkColor.h:439

◆ TEST() [285/715]

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

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;
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() [287/715]

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

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);
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() [289/715]

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

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.
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)
SkPaint ToNonShaderSk(const DlPaint &paint)

◆ TEST() [291/715]

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),
63 SkPaint::Style::kStrokeAndFill_Style);
64}

◆ TEST() [292/715]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkFilterMode   
)

Definition at line 87 of file dl_sk_conversions_unittests.cc.

87 {
89 ASSERT_EQ(ToSk(DlFilterMode::kNearest), SkFilterMode::kNearest);
90 ASSERT_EQ(ToSk(DlFilterMode::kLast), SkFilterMode::kLast);
91}

◆ TEST() [293/715]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkSamplingOptions   
)

Definition at line 100 of file dl_sk_conversions_unittests.cc.

100 {
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() [294/715]

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkSrcRectConstraint   
)

Definition at line 93 of file dl_sk_conversions_unittests.cc.

93 {
94 ASSERT_EQ(ToSk(DlCanvas::SrcRectConstraint::kFast),
95 SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint);
96 ASSERT_EQ(ToSk(DlCanvas::SrcRectConstraint::kStrict),
97 SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint);
98}

◆ TEST() [295/715]

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}

◆ TEST() [296/715]

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}

◆ TEST() [297/715]

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

flutter::testing::TEST ( DisplayListSkConversions  ,
ToSkVertexMode   
)

Definition at line 78 of file dl_sk_conversions_unittests.cc.

78 {
79 ASSERT_EQ(ToSk(DlVertexMode::kTriangles),
80 SkVertices::VertexMode::kTriangles_VertexMode);
81 ASSERT_EQ(ToSk(DlVertexMode::kTriangleStrip),
82 SkVertices::VertexMode::kTriangleStrip_VertexMode);
83 ASSERT_EQ(ToSk(DlVertexMode::kTriangleFan),
84 SkVertices::VertexMode::kTriangleFan_VertexMode);
85}

◆ TEST() [299/715]

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

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

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
73 EXPECT_FALSE(helper.paint(true).isDither());
74 EXPECT_FALSE(helper.paint(false).isDither());
75}

◆ TEST() [302/715]

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

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

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

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

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

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

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

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

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

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] = {
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() [312/715]

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] = {
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() [313/715]

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

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

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

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

flutter::testing::TEST ( DisplayListVertices  ,
ConvertWithZeroAndNegativeVerticesAndIndices   
)

Definition at line 208 of file dl_sk_conversions_unittests.cc.

208 {
209 DlVertices::Builder builder1(DlVertexMode::kTriangles, 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,
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() [318/715]

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] = {
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() [319/715]

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] = {
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() [320/715]

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

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

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

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

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

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] = {
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() [326/715]

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] = {
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() [327/715]

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

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

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] = {
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() [330/715]

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] = {
915 };
916 DlColor wrong_colors[4] = {
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() [331/715]

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

flutter::testing::TEST ( DlOpSpy  ,
DrawArc   
)

Definition at line 328 of file dl_op_spy_unittests.cc.

328 {
329 { // black
332 builder.DrawArc(SkRect::MakeWH(5, 5), 0, 1, true, paint);
333 sk_sp<DisplayList> dl = builder.Build();
334 DlOpSpy dl_op_spy;
335 dl->Dispatch(dl_op_spy);
336 ASSERT_DID_DRAW(dl_op_spy, dl);
337 }
338 { // transparent
341 builder.DrawArc(SkRect::MakeWH(5, 5), 0, 1, true, paint);
342 sk_sp<DisplayList> dl = builder.Build();
343 DlOpSpy dl_op_spy;
344 dl->Dispatch(dl_op_spy);
345 ASSERT_NO_DRAW(dl_op_spy, dl);
346 }
347}
#define ASSERT_DID_DRAW(spy, dl)
#define ASSERT_NO_DRAW(spy, dl)

◆ TEST() [333/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawCircle   
)

Definition at line 248 of file dl_op_spy_unittests.cc.

248 {
249 { // black
252 builder.DrawCircle(SkPoint::Make(5, 5), 1.0, 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
261 builder.DrawCircle(SkPoint::Make(5, 5), 1.0, 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() [334/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawColor   
)

Definition at line 113 of file dl_op_spy_unittests.cc.

113 {
114 { // Black color source.
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.
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;
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() [335/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawDashedLine   
)

Definition at line 185 of file dl_op_spy_unittests.cc.

185 {
186 { // black
189 builder.DrawDashedLine(DlPoint(0, 1), DlPoint(1, 2), 1.0f, 1.0f, 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
198 builder.DrawDashedLine(DlPoint(0, 1), DlPoint(1, 2), 1.0f, 1.0f, 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() [336/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawDisplayList   
)

Definition at line 497 of file dl_op_spy_unittests.cc.

497 {
498 { // Recursive Transparent DisplayList
501 builder.DrawPaint(paint);
502 sk_sp<DisplayList> dl = builder.Build();
503
504 DisplayListBuilder builder_parent;
505 DlPaint paint_parent(DlColor::kTransparent());
506 builder_parent.DrawPaint(paint_parent);
507 builder_parent.DrawDisplayList(dl, 1);
508 sk_sp<DisplayList> dl2 = builder_parent.Build();
509
510 DlOpSpy dl_op_spy;
511 dl2->Dispatch(dl_op_spy);
512 ASSERT_NO_DRAW(dl_op_spy, dl2);
513 }
514 { // Sub non-transparent DisplayList,
517 builder.DrawPaint(paint);
518 sk_sp<DisplayList> dl = builder.Build();
519
520 DisplayListBuilder builder_parent;
521 DlPaint paint_parent(DlColor::kTransparent());
522 builder_parent.DrawPaint(paint_parent);
523 builder_parent.DrawDisplayList(dl, 1);
524 sk_sp<DisplayList> dl2 = builder_parent.Build();
525
526 DlOpSpy dl_op_spy;
527 dl2->Dispatch(dl_op_spy);
528 ASSERT_DID_DRAW(dl_op_spy, dl2);
529 }
530
531 { // Sub non-transparent DisplayList, 0 opacity
532 DisplayListBuilder builder;
534 builder.DrawPaint(paint);
535 sk_sp<DisplayList> dl = builder.Build();
536
537 DisplayListBuilder builder_parent;
538 DlPaint paint_parent(DlColor::kTransparent());
539 builder_parent.DrawPaint(paint_parent);
540 builder_parent.DrawDisplayList(dl, 0);
541 sk_sp<DisplayList> dl2 = builder_parent.Build();
542
543 DlOpSpy dl_op_spy;
544 dl2->Dispatch(dl_op_spy);
545 ASSERT_NO_DRAW(dl_op_spy, dl2);
546 }
547
548 { // Parent non-transparent DisplayList
549 DisplayListBuilder builder;
551 builder.DrawPaint(paint);
552 sk_sp<DisplayList> dl = builder.Build();
553
554 DisplayListBuilder builder_parent;
555 DlPaint paint_parent(DlColor::kBlack());
556 builder_parent.DrawPaint(paint_parent);
557 builder_parent.DrawDisplayList(dl, 0);
558 sk_sp<DisplayList> dl2 = builder_parent.Build();
559
560 DlOpSpy dl_op_spy;
561 dl2->Dispatch(dl_op_spy);
562 ASSERT_DID_DRAW(dl_op_spy, dl2);
563 }
564}
void DrawPaint(const DlPaint &paint) override
Definition: dl_builder.cc:1053
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
Definition: dl_builder.cc:1535

◆ TEST() [337/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawLine   
)

Definition at line 164 of file dl_op_spy_unittests.cc.

164 {
165 { // black
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
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() [338/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawOval   
)

Definition at line 227 of file dl_op_spy_unittests.cc.

227 {
228 { // black
231 builder.DrawOval(SkRect::MakeWH(5, 5), 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
240 builder.DrawOval(SkRect::MakeWH(5, 5), 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() [339/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawPaint   
)

Definition at line 143 of file dl_op_spy_unittests.cc.

143 {
144 { // Transparent color in paint.
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.
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() [340/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawPath   
)

Definition at line 290 of file dl_op_spy_unittests.cc.

290 {
291 { // black line
294 paint.setDrawStyle(DlDrawStyle::kStroke);
295 builder.DrawPath(SkPath::Line(SkPoint::Make(0, 1), SkPoint::Make(1, 1)),
296 paint);
297 sk_sp<DisplayList> dl = builder.Build();
298 DlOpSpy dl_op_spy;
299 dl->Dispatch(dl_op_spy);
300 ASSERT_DID_DRAW(dl_op_spy, dl);
301 }
302 { // triangle
305 SkPath path;
306 path.moveTo({0, 0});
307 path.lineTo({1, 0});
308 path.lineTo({0, 1});
309 builder.DrawPath(path, paint);
310 sk_sp<DisplayList> dl = builder.Build();
311 DlOpSpy dl_op_spy;
312 dl->Dispatch(dl_op_spy);
313 ASSERT_DID_DRAW(dl_op_spy, dl);
314 }
315 { // transparent line
316 DisplayListBuilder builder;
318 paint.setDrawStyle(DlDrawStyle::kStroke);
319 builder.DrawPath(SkPath::Line(SkPoint::Make(0, 1), SkPoint::Make(1, 1)),
320 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}
static SkPath Line(const SkPoint a, const SkPoint b)
Definition: SkPath.h:106

◆ TEST() [341/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawPoints   
)

Definition at line 349 of file dl_op_spy_unittests.cc.

349 {
350 { // black
353 const SkPoint points[] = {SkPoint::Make(5, 4)};
355 sk_sp<DisplayList> dl = builder.Build();
356 DlOpSpy dl_op_spy;
357 dl->Dispatch(dl_op_spy);
358 ASSERT_DID_DRAW(dl_op_spy, dl);
359 }
360 { // transparent
361 DisplayListBuilder builder;
363 const SkPoint points[] = {SkPoint::Make(5, 4)};
365 sk_sp<DisplayList> dl = builder.Build();
366 DlOpSpy dl_op_spy;
367 dl->Dispatch(dl_op_spy);
368 ASSERT_NO_DRAW(dl_op_spy, dl);
369 }
370}

◆ TEST() [342/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawRect   
)

Definition at line 206 of file dl_op_spy_unittests.cc.

206 {
207 { // black
210 builder.DrawRect(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
219 builder.DrawRect(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() [343/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawRRect   
)

Definition at line 269 of file dl_op_spy_unittests.cc.

269 {
270 { // black
274 sk_sp<DisplayList> dl = builder.Build();
275 DlOpSpy dl_op_spy;
276 dl->Dispatch(dl_op_spy);
277 ASSERT_DID_DRAW(dl_op_spy, dl);
278 }
279 { // transparent
283 sk_sp<DisplayList> dl = builder.Build();
284 DlOpSpy dl_op_spy;
285 dl->Dispatch(dl_op_spy);
286 ASSERT_NO_DRAW(dl_op_spy, dl);
287 }
288}

◆ TEST() [344/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawShadow   
)

Definition at line 593 of file dl_op_spy_unittests.cc.

593 {
594 { // valid shadow
599 builder.DrawShadow(path, color, 1, false, 1);
600 sk_sp<DisplayList> dl = builder.Build();
601 DlOpSpy dl_op_spy;
602 dl->Dispatch(dl_op_spy);
603 ASSERT_DID_DRAW(dl_op_spy, dl);
604 }
605 { // transparent color
610 builder.DrawShadow(path, color, 1, false, 1);
611 sk_sp<DisplayList> dl = builder.Build();
612 DlOpSpy dl_op_spy;
613 dl->Dispatch(dl_op_spy);
614 ASSERT_NO_DRAW(dl_op_spy, dl);
615 }
616}

◆ TEST() [345/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawTextBlob   
)

Definition at line 566 of file dl_op_spy_unittests.cc.

566 {
567 { // Non-transparent color.
570 std::string string = "xx";
572 auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
573 builder.DrawTextBlob(text_blob, 1, 1, paint);
574 sk_sp<DisplayList> dl = builder.Build();
575 DlOpSpy dl_op_spy;
576 dl->Dispatch(dl_op_spy);
577 ASSERT_DID_DRAW(dl_op_spy, dl);
578 }
579 { // transparent color.
582 std::string string = "xx";
584 auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
585 builder.DrawTextBlob(text_blob, 1, 1, paint);
586 sk_sp<DisplayList> dl = builder.Build();
587 DlOpSpy dl_op_spy;
588 dl->Dispatch(dl_op_spy);
589 ASSERT_NO_DRAW(dl_op_spy, dl);
590 }
591}
font
Font Metadata and Metrics.

◆ TEST() [346/715]

flutter::testing::TEST ( DlOpSpy  ,
DrawVertices   
)

Definition at line 372 of file dl_op_spy_unittests.cc.

372 {
373 { // black
376 const SkPoint vertices[] = {
377 SkPoint::Make(5, 5),
378 SkPoint::Make(5, 15),
379 SkPoint::Make(15, 5),
380 };
381 const SkPoint texture_coordinates[] = {
382 SkPoint::Make(5, 5),
383 SkPoint::Make(15, 5),
384 SkPoint::Make(5, 15),
385 };
386 const DlColor colors[] = {
390 };
391 auto dl_vertices = DlVertices::Make(DlVertexMode::kTriangles, 3, vertices,
392 texture_coordinates, colors, 0);
393 builder.DrawVertices(dl_vertices.get(), DlBlendMode::kSrc, paint);
394 sk_sp<DisplayList> dl = builder.Build();
395 DlOpSpy dl_op_spy;
396 dl->Dispatch(dl_op_spy);
397 ASSERT_DID_DRAW(dl_op_spy, dl);
398 }
399 { // transparent
400 DisplayListBuilder builder;
402 const SkPoint vertices[] = {
403 SkPoint::Make(5, 5),
404 SkPoint::Make(5, 15),
405 SkPoint::Make(15, 5),
406 };
407 const SkPoint texture_coordinates[] = {
408 SkPoint::Make(5, 5),
409 SkPoint::Make(15, 5),
410 SkPoint::Make(5, 15),
411 };
412 const DlColor colors[] = {
416 };
417 auto dl_vertices = DlVertices::Make(DlVertexMode::kTriangles, 3, vertices,
418 texture_coordinates, colors, 0);
419 builder.DrawVertices(dl_vertices.get(), DlBlendMode::kSrc, paint);
420 sk_sp<DisplayList> dl = builder.Build();
421 DlOpSpy dl_op_spy;
422 dl->Dispatch(dl_op_spy);
423 ASSERT_NO_DRAW(dl_op_spy, dl);
424 }
425}

◆ TEST() [347/715]

flutter::testing::TEST ( DlOpSpy  ,
EmptyDisplayList   
)

Definition at line 38 of file dl_op_spy_unittests.cc.

38 {
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() [348/715]

flutter::testing::TEST ( DlOpSpy  ,
Images   
)

Definition at line 427 of file dl_op_spy_unittests.cc.

427 {
428 { // DrawImage
435 bitmap.allocPixels(info, 0);
436 auto sk_image = SkImages::RasterFromBitmap(bitmap);
437 builder.DrawImage(DlImage::Make(sk_image), SkPoint::Make(5, 5),
439 sk_sp<DisplayList> dl = builder.Build();
440 DlOpSpy dl_op_spy;
441 dl->Dispatch(dl_op_spy);
442 ASSERT_DID_DRAW(dl_op_spy, dl);
443 }
444 { // DrawImageRect
451 bitmap.allocPixels(info, 0);
452 auto sk_image = SkImages::RasterFromBitmap(bitmap);
453 builder.DrawImageRect(DlImage::Make(sk_image), SkRect::MakeWH(5, 5),
455 sk_sp<DisplayList> dl = builder.Build();
456 DlOpSpy dl_op_spy;
457 dl->Dispatch(dl_op_spy);
458 ASSERT_DID_DRAW(dl_op_spy, dl);
459 }
460 { // DrawImageNine
461 DisplayListBuilder builder;
467 bitmap.allocPixels(info, 0);
468 auto sk_image = SkImages::RasterFromBitmap(bitmap);
469 builder.DrawImageNine(DlImage::Make(sk_image), SkIRect::MakeWH(5, 5),
471 sk_sp<DisplayList> dl = builder.Build();
472 DlOpSpy dl_op_spy;
473 dl->Dispatch(dl_op_spy);
474 ASSERT_DID_DRAW(dl_op_spy, dl);
475 }
476 { // DrawAtlas
477 DisplayListBuilder builder;
483 bitmap.allocPixels(info, 0);
484 auto sk_image = SkImages::RasterFromBitmap(bitmap);
485 const SkRSXform xform[] = {SkRSXform::Make(1, 0, 0, 0)};
486 const SkRect tex[] = {SkRect::MakeXYWH(10, 10, 10, 10)};
487 SkRect cull_rect = SkRect::MakeWH(5, 5);
488 builder.DrawAtlas(DlImage::Make(sk_image), xform, tex, nullptr, 1,
489 DlBlendMode::kSrc, DlImageSampling::kLinear, &cull_rect);
490 sk_sp<DisplayList> dl = builder.Build();
491 DlOpSpy dl_op_spy;
492 dl->Dispatch(dl_op_spy);
493 ASSERT_DID_DRAW(dl_op_spy, dl);
494 }
495}

◆ TEST() [349/715]

flutter::testing::TEST ( DlOpSpy  ,
SetColor   
)

Definition at line 46 of file dl_op_spy_unittests.cc.

46 {
47 { // No Color set.
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.
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;
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() [350/715]

flutter::testing::TEST ( DlOpSpy  ,
SetColorSource   
)

Definition at line 76 of file dl_op_spy_unittests.cc.

76 {
77 { // Set null source
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.
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;
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() [351/715]

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}
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
Definition: SkSwizzler.cpp:31
Provides canvas-like painting methods that actually build vertices.
Definition: stopwatch_dl.h:39
static SkRect MakeRectFromVertices(SkPoint vertices[6])

◆ TEST() [352/715]

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

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

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithNoMutations   
)

Definition at line 12 of file embedded_view_params_unittests.cc.

12 {
13 MutatorsStack stack;
15
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() [355/715]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithRotation45   
)

Definition at line 65 of file embedded_view_params_unittests.cc.

65 {
66 MutatorsStack stack;
68 matrix.setRotate(45);
69 stack.PushTransform(matrix);
70
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)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition: SkVx.h:706

◆ TEST() [356/715]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithRotation90   
)

Definition at line 50 of file embedded_view_params_unittests.cc.

50 {
51 MutatorsStack stack;
53 matrix.setRotate(90);
54 stack.PushTransform(matrix);
55
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() [357/715]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithScale   
)

Definition at line 24 of file embedded_view_params_unittests.cc.

24 {
25 MutatorsStack stack;
27 stack.PushTransform(matrix);
28
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() [358/715]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithTranslate   
)

Definition at line 37 of file embedded_view_params_unittests.cc.

37 {
38 MutatorsStack stack;
40 stack.PushTransform(matrix);
41
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() [359/715]

flutter::testing::TEST ( EmbeddedViewParams  ,
GetBoundingRectAfterMutationsWithTranslateScaleAndRotation   
)

Definition at line 79 of file embedded_view_params_unittests.cc.

80 {
82 matrix.preScale(3, 3);
83 matrix.preRotate(90);
84
85 MutatorsStack stack;
86 stack.PushTransform(matrix);
87
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() [360/715]

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:460

◆ TEST() [361/715]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterPointIsFrozen   
)

◆ TEST() [362/715]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterRectIsFrozen   
)

◆ TEST() [363/715]

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterSemanticsCustomActionIsFrozen   
)

◆ TEST() [364/715]

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

flutter::testing::TEST ( EmbedderFrozen  ,
FlutterTransformationIsFrozen   
)

◆ TEST() [366/715]

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:3335
Function-pointer-based versions of the APIs above.
Definition: embedder.h:3319
FlutterEngineCreateAOTDataFnPtr CreateAOTData
Definition: embedder.h:3323
size_t struct_size
The size of this struct. Must be sizeof(FlutterEngineProcs).
Definition: embedder.h:3321

◆ TEST() [367/715]

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:3352

◆ TEST() [368/715]

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}
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 set
Definition: switches.h:76

◆ TEST() [369/715]

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:2955

◆ TEST() [370/715]

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

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

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

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

flutter::testing::TEST ( FlutterAppLifecycleDelegateTest  ,
ReleasesDelegateOnDealloc   
)

Definition at line 223 of file FlutterAppLifecycleDelegateTest.mm.

223 {
224 __weak FlutterAppLifecycleRegistrar* weakRegistrar;
225 __weak TestFlutterAppLifecycleDelegate* weakDelegate;
226 @autoreleasepool {
228 weakRegistrar = registrar;
230 weakDelegate = delegate;
231 [registrar addDelegate:delegate];
232 }
233 EXPECT_EQ(weakRegistrar, nil);
234 EXPECT_EQ(weakDelegate, nil);
235}
void addDelegate:(NSObject< FlutterAppLifecycleDelegate > *delegate)

◆ TEST() [375/715]

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 handleDidBecomeActive:(NSNotification *notification)

◆ TEST() [376/715]

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

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

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

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

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

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

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

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

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

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

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

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

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:1076
@ kFlutterKeyEventTypeUp
Definition: embedder.h:1075
@ kFlutterKeyEventTypeRepeat
Definition: embedder.h:1077
void handleEvent:callback:(NSEvent *event, [callback] FlutterAsyncKeyCallback callback)
return FALSE
constexpr uint64_t kPhysicalKeyA
Definition: key_codes.g.h:77
constexpr uint64_t kLogicalKeyA
Definition: key_codes.g.h:339
int BOOL
Definition: windows_types.h:37

◆ TEST() [389/715]

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

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}
constexpr uint64_t kPhysicalCapsLock
Definition: key_codes.g.h:129
constexpr uint64_t kLogicalCapsLock
Definition: key_codes.g.h:377

◆ TEST() [391/715]

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}
constexpr uint64_t kLogicalShiftRight
Definition: key_codes.g.h:684
constexpr uint64_t kPhysicalShiftLeft
Definition: key_codes.g.h:225
constexpr uint64_t kLogicalShiftLeft
Definition: key_codes.g.h:683
constexpr uint64_t kPhysicalShiftRight
Definition: key_codes.g.h:229

◆ TEST() [392/715]

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

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

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}
constexpr uint64_t kPhysicalAltRight
Definition: key_codes.g.h:230
constexpr uint64_t kPhysicalKeyW
Definition: key_codes.g.h:99
constexpr uint64_t kLogicalKeyW
Definition: key_codes.g.h:361
constexpr uint64_t kLogicalAltRight
Definition: key_codes.g.h:686

◆ TEST() [395/715]

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}
constexpr uint64_t kLogicalF1
Definition: key_codes.g.h:459
constexpr uint64_t kLogicalNumpad1
Definition: key_codes.g.h:703
constexpr uint64_t kPhysicalF1
Definition: key_codes.g.h:130
constexpr uint64_t kPhysicalNumpad1
Definition: key_codes.g.h:161

◆ TEST() [396/715]

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

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

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

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

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

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

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
CorrectLogicalKeyForLayouts   
)

Definition at line 462 of file FlutterKeyboardManagerTest.mm.

462 {
463 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] correctLogicalKeyForLayouts]);
464}

◆ TEST() [403/715]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
DoublePrimaryResponder   
)

Definition at line 438 of file FlutterKeyboardManagerTest.mm.

438 {
439 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] doublePrimaryResponder]);
440}

◆ TEST() [404/715]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
EmptyNextResponder   
)

Definition at line 446 of file FlutterKeyboardManagerTest.mm.

446 {
447 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] emptyNextResponder]);
448}

◆ TEST() [405/715]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
GetPressedState   
)

Definition at line 450 of file FlutterKeyboardManagerTest.mm.

450 {
451 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] getPressedState]);
452}

◆ TEST() [406/715]

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

Definition at line 454 of file FlutterKeyboardManagerTest.mm.

454 {
455 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] keyboardChannelGetPressedState]);
456}

◆ TEST() [407/715]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
RacingConditionBetweenKeyAndText   
)

Definition at line 458 of file FlutterKeyboardManagerTest.mm.

458 {
459 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] racingConditionBetweenKeyAndText]);
460}

◆ TEST() [408/715]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
ShouldNotHoldStrongReferenceToViewDelegate   
)

Definition at line 466 of file FlutterKeyboardManagerTest.mm.

466 {
467 ASSERT_TRUE(
468 [[FlutterKeyboardManagerUnittestsObjC alloc] shouldNotHoldStrongReferenceToViewDelegate]);
469}

◆ TEST() [409/715]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
SingleFinalResponder   
)

Definition at line 442 of file FlutterKeyboardManagerTest.mm.

442 {
444}
FlutterTextInputPlugin * textInputPlugin

◆ TEST() [410/715]

flutter::testing::TEST ( FlutterKeyboardManagerUnittests  ,
SinglePrimaryResponder   
)

Definition at line 434 of file FlutterKeyboardManagerTest.mm.

434 {
435 ASSERT_TRUE([[FlutterKeyboardManagerUnittestsObjC alloc] singlePrimaryResponder]);
436}

◆ TEST() [411/715]

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

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
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:3345
const char * increased_value
Definition: embedder.h:1370
const char * tooltip
A textual tooltip attached to the node.
Definition: embedder.h:1397
size_t custom_accessibility_actions_count
The number of custom accessibility action associated with this node.
Definition: embedder.h:1389
int32_t id
The unique identifier for this node.
Definition: embedder.h:1337
const char * decreased_value
Definition: embedder.h:1373
const char * label
A textual description of the node.
Definition: embedder.h:1363
const char * hint
A brief description of the result of performing an action on the node.
Definition: embedder.h:1365
const char * value
A textual description of the current value of the node.
Definition: embedder.h:1367
ax::mojom::Action action

◆ TEST() [413/715]

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

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

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:1345
FlutterSemanticsAction actions
The set of semantics actions applicable to this node.
Definition: embedder.h:1341
FlutterRect rect
The bounding box for this node in its coordinate system.
Definition: embedder.h:1378
FlutterTransformation transform
Definition: embedder.h:1381
int32_t text_selection_base
The position at which the text selection originates.
Definition: embedder.h:1343
FlutterSemanticsFlag flags
The set of semantics flags associated with this node.
Definition: embedder.h:1339

◆ TEST() [416/715]

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}
Definition: rect.h:36

◆ TEST() [417/715]

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

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

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

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

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

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

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

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestAcceptGesture   
)

Definition at line 164 of file FlutterPlatformViewControllerTest.mm.

164 {
165 FlutterPlatformViewController* platformViewController =
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() [425/715]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestAcceptGestureOnMissingViewId   
)

Definition at line 200 of file FlutterPlatformViewControllerTest.mm.

200 {
201 FlutterPlatformViewController* platformViewController =
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() [426/715]

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

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

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

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

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRejectGesture   
)

Definition at line 222 of file FlutterPlatformViewControllerTest.mm.

222 {
223 FlutterPlatformViewController* platformViewController =
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() [431/715]

flutter::testing::TEST ( FlutterPlatformViewController  ,
TestRejectGestureOnMissingViewId   
)

Definition at line 258 of file FlutterPlatformViewControllerTest.mm.

258 {
259 FlutterPlatformViewController* platformViewController =
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() [432/715]

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

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

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

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

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

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

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

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}
double frame
Definition: examples.cpp:31

◆ TEST() [440/715]

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

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

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)
int64_t texture_id
Definition: embedder.h:656

◆ TEST() [443/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
CanNotBecomeResponderIfNoViewController   
)

Definition at line 2026 of file FlutterTextInputPluginTest.mm.

2026 {
2027 FlutterEngine* engine = CreateTestEngine();
2028 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2029 nibName:nil
2030 bundle:nil];
2031 [viewController loadView];
2032 // Creates a NSWindow so that the native text field can become first responder.
2033 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2034 styleMask:NSBorderlessWindowMask
2035 backing:NSBackingStoreBuffered
2036 defer:NO];
2037 window.contentView = viewController.view;
2038
2039 engine.semanticsEnabled = YES;
2040
2041 auto bridge = viewController.accessibilityBridge.lock();
2043 ui::AXTree tree;
2044 ui::AXNode ax_node(&tree, nullptr, 0, 0);
2045 ui::AXNodeData node_data;
2046 node_data.SetValue("initial text");
2047 ax_node.SetData(node_data);
2048 delegate.Init(viewController.accessibilityBridge, &ax_node);
2049 FlutterTextPlatformNode text_platform_node(&delegate, viewController);
2050
2051 FlutterTextField* textField = text_platform_node.GetNativeViewAccessible();
2052 EXPECT_EQ([textField becomeFirstResponder], YES);
2053 // Removes view controller.
2054 [engine setViewController:nil];
2055 FlutterTextPlatformNode text_platform_node_no_controller(&delegate, nil);
2056 textField = text_platform_node_no_controller.GetNativeViewAccessible();
2057 EXPECT_EQ([textField becomeFirstResponder], NO);
2058}
The ax platform node for a text field.
void SetValue(const std::string &value)

◆ TEST() [444/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
CanWorkWithFlutterTextField   
)

Definition at line 1961 of file FlutterTextInputPluginTest.mm.

1961 {
1962 FlutterEngine* engine = CreateTestEngine();
1963 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
1964 nibName:nil
1965 bundle:nil];
1966 [viewController loadView];
1967 // Create a NSWindow so that the native text field can become first responder.
1968 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
1969 styleMask:NSBorderlessWindowMask
1970 backing:NSBackingStoreBuffered
1971 defer:NO];
1972 window.contentView = viewController.view;
1973
1974 engine.semanticsEnabled = YES;
1975
1976 auto bridge = viewController.accessibilityBridge.lock();
1978 ui::AXTree tree;
1979 ui::AXNode ax_node(&tree, nullptr, 0, 0);
1980 ui::AXNodeData node_data;
1981 node_data.SetValue("initial text");
1982 ax_node.SetData(node_data);
1983 delegate.Init(viewController.accessibilityBridge, &ax_node);
1984 {
1985 FlutterTextPlatformNode text_platform_node(&delegate, viewController);
1986
1987 FlutterTextFieldMock* mockTextField =
1988 [[FlutterTextFieldMock alloc] initWithPlatformNode:&text_platform_node
1989 fieldEditor:viewController.textInputPlugin];
1990 [viewController.view addSubview:mockTextField];
1991 [mockTextField startEditing];
1992
1993 NSDictionary* setClientConfig = @{
1994 @"inputAction" : @"action",
1995 @"inputType" : @{@"name" : @"inputName"},
1996 };
1997 FlutterMethodCall* methodCall =
1998 [FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
1999 arguments:@[ @(1), setClientConfig ]];
2000 FlutterResult result = ^(id result) {
2001 };
2002 [viewController.textInputPlugin handleMethodCall:methodCall result:result];
2003
2004 NSDictionary* arguments = @{
2005 @"text" : @"new text",
2006 @"selectionBase" : @(1),
2007 @"selectionExtent" : @(2),
2008 @"composingBase" : @(-1),
2009 @"composingExtent" : @(-1),
2010 };
2011 methodCall = [FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
2012 arguments:arguments];
2013 [viewController.textInputPlugin handleMethodCall:methodCall result:result];
2014 EXPECT_EQ([mockTextField.lastUpdatedString isEqualToString:@"new text"], YES);
2015 EXPECT_EQ(NSEqualRanges(mockTextField.lastUpdatedSelection, NSMakeRange(1, 1)), YES);
2016
2017 // This blocks the FlutterTextFieldMock, which is held onto by the main event
2018 // loop, from crashing.
2019 [mockTextField setPlatformNode:nil];
2020 }
2021
2022 // This verifies that clearing the platform node works.
2023 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
2024}
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
void setPlatformNode:(flutter::FlutterTextPlatformNode *node)

◆ TEST() [445/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
FirstResponderIsCorrect   
)

Definition at line 2093 of file FlutterTextInputPluginTest.mm.

2093 {
2094 FlutterEngine* engine = CreateTestEngine();
2095 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2096 nibName:nil
2097 bundle:nil];
2098 [viewController loadView];
2099
2100 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2101 styleMask:NSBorderlessWindowMask
2102 backing:NSBackingStoreBuffered
2103 defer:NO];
2104 window.contentView = viewController.view;
2105
2107
2108 [window makeFirstResponder:viewController.flutterView];
2109
2110 [viewController.textInputPlugin
2111 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.show" arguments:@[]]
2112 result:^(id){
2113 }];
2114
2115 ASSERT_TRUE(window.firstResponder == viewController.textInputPlugin);
2116
2118
2119 [viewController.textInputPlugin
2120 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.hide" arguments:@[]]
2121 result:^(id){
2122 }];
2123
2125 ASSERT_TRUE(window.firstResponder == viewController.flutterView);
2126}
BOOL acceptsFirstResponder()
Definition: FlutterView.mm:92

◆ TEST() [446/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
HandleArrowKeyWhenImePopoverIsActive   
)

Definition at line 1937 of file FlutterTextInputPluginTest.mm.

1937 {
1938 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] handleArrowKeyWhenImePopoverIsActive]);
1939}

◆ TEST() [447/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
HasZeroSizeAndClipsToBounds   
)

Definition at line 2128 of file FlutterTextInputPluginTest.mm.

2128 {
2129 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
2130 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
2131 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
2132 [engineMock binaryMessenger])
2133 .andReturn(binaryMessengerMock);
2134
2135 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
2136 nibName:@""
2137 bundle:nil];
2138
2139 FlutterTextInputPlugin* plugin =
2140 [[FlutterTextInputPlugin alloc] initWithViewController:viewController];
2141
2142 ASSERT_TRUE(NSIsEmptyRect(plugin.frame));
2143 ASSERT_TRUE(plugin.clipsToBounds);
2144}
id CreateMockFlutterEngine(NSString *pasteboardString)

◆ TEST() [448/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
IsAddedAndRemovedFromViewHierarchy   
)

Definition at line 2060 of file FlutterTextInputPluginTest.mm.

2060 {
2061 FlutterEngine* engine = CreateTestEngine();
2062 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine
2063 nibName:nil
2064 bundle:nil];
2065 [viewController loadView];
2066
2067 NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
2068 styleMask:NSBorderlessWindowMask
2069 backing:NSBackingStoreBuffered
2070 defer:NO];
2071 window.contentView = viewController.view;
2072
2073 ASSERT_EQ(viewController.textInputPlugin.superview, nil);
2074 ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
2075
2076 [viewController.textInputPlugin
2077 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.show" arguments:@[]]
2078 result:^(id){
2079 }];
2080
2081 ASSERT_EQ(viewController.textInputPlugin.superview, viewController.view);
2082 ASSERT_TRUE(window.firstResponder == viewController.textInputPlugin);
2083
2084 [viewController.textInputPlugin
2085 handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.hide" arguments:@[]]
2086 result:^(id){
2087 }];
2088
2089 ASSERT_EQ(viewController.textInputPlugin.superview, nil);
2090 ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
2091}

◆ TEST() [449/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenAutofillGroupIncludesPassword   
)

Definition at line 1895 of file FlutterTextInputPluginTest.mm.

1895 {
1896 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc]
1897 testAutocompleteDisabledWhenAutofillGroupIncludesPassword]);
1898}

◆ TEST() [450/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenAutofillNotSet   
)

Definition at line 1875 of file FlutterTextInputPluginTest.mm.

1875 {
1876 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenAutofillNotSet]);
1877}

◆ TEST() [451/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenObscureTextSet   
)

Definition at line 1887 of file FlutterTextInputPluginTest.mm.

1887 {
1888 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenObscureTextSet]);
1889}

◆ TEST() [452/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteDisabledWhenPasswordAutofillSet   
)

Definition at line 1891 of file FlutterTextInputPluginTest.mm.

1891 {
1892 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteDisabledWhenPasswordAutofillSet]);
1893}

◆ TEST() [453/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteEnabledWhenAutofillSet   
)

Definition at line 1879 of file FlutterTextInputPluginTest.mm.

1879 {
1880 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteEnabledWhenAutofillSet]);
1881}

◆ TEST() [454/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestAutocompleteEnabledWhenAutofillSetNoHint   
)

Definition at line 1883 of file FlutterTextInputPluginTest.mm.

1883 {
1884 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testAutocompleteEnabledWhenAutofillSetNoHint]);
1885}

◆ TEST() [455/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestClearClientDuringComposing   
)

Definition at line 1871 of file FlutterTextInputPluginTest.mm.

1871 {
1872 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testClearClientDuringComposing]);
1873}

◆ TEST() [456/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingRegionRemovedByFramework   
)

Definition at line 1867 of file FlutterTextInputPluginTest.mm.

1867 {
1868 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingRegionRemovedByFramework]);
1869}

◆ TEST() [457/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingWithDelta   
)

Definition at line 1921 of file FlutterTextInputPluginTest.mm.

1921 {
1922 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingWithDelta]);
1923}

◆ TEST() [458/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestComposingWithDeltasWhenSelectionIsActive   
)

Definition at line 1925 of file FlutterTextInputPluginTest.mm.

1925 {
1926 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testComposingWithDeltasWhenSelectionIsActive]);
1927}

◆ TEST() [459/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestEmptyCompositionRange   
)

Definition at line 1855 of file FlutterTextInputPluginTest.mm.

1855 {
1856 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testEmptyCompositionRange]);
1857}

◆ TEST() [460/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRange   
)

Definition at line 1900 of file FlutterTextInputPluginTest.mm.

1900 {
1901 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testFirstRectForCharacterRange]);
1902}

◆ TEST() [461/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRangeAtInfinity   
)

Definition at line 1904 of file FlutterTextInputPluginTest.mm.

1904 {
1905 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testFirstRectForCharacterRangeAtInfinity]);
1906}

◆ TEST() [462/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestFirstRectForCharacterRangeWithEsotericAffineTransform   
)

Definition at line 1908 of file FlutterTextInputPluginTest.mm.

1908 {
1909 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc]
1910 testFirstRectForCharacterRangeWithEsotericAffineTransform]);
1911}

◆ TEST() [463/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestInsertNewLine   
)

Definition at line 1953 of file FlutterTextInputPluginTest.mm.

1953 {
1954 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testInsertNewLine]);
1955}

◆ TEST() [464/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestLocalTextAndSelectionUpdateAfterDelta   
)

Definition at line 1929 of file FlutterTextInputPluginTest.mm.

1929 {
1930 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testLocalTextAndSelectionUpdateAfterDelta]);
1931}

◆ TEST() [465/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestOperationsThatTriggerDelta   
)

Definition at line 1917 of file FlutterTextInputPluginTest.mm.

1917 {
1918 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testOperationsThatTriggerDelta]);
1919}

◆ TEST() [466/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestPerformKeyEquivalent   
)

Definition at line 1933 of file FlutterTextInputPluginTest.mm.

1933 {
1934 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testPerformKeyEquivalent]);
1935}

◆ TEST() [467/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSelectorsAreForwardedToFramework   
)

Definition at line 1945 of file FlutterTextInputPluginTest.mm.

1945 {
1946 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSelectorsAreForwardedToFramework]);
1947}

◆ TEST() [468/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSelectorsNotForwardedToFrameworkIfNoClient   
)

Definition at line 1949 of file FlutterTextInputPluginTest.mm.

1949 {
1950 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSelectorsNotForwardedToFrameworkIfNoClient]);
1951}

◆ TEST() [469/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSendActionDoNotInsertNewLine   
)

Definition at line 1957 of file FlutterTextInputPluginTest.mm.

1957 {
1958 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSendActionDoNotInsertNewLine]);
1959}

◆ TEST() [470/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetEditingStateWithTextEditingDelta   
)

Definition at line 1913 of file FlutterTextInputPluginTest.mm.

1913 {
1914 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetEditingStateWithTextEditingDelta]);
1915}

◆ TEST() [471/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetMarkedTextWithReplacementRange   
)

Definition at line 1863 of file FlutterTextInputPluginTest.mm.

1863 {
1864 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetMarkedTextWithReplacementRange]);
1865}

◆ TEST() [472/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
TestSetMarkedTextWithSelectionChange   
)

Definition at line 1859 of file FlutterTextInputPluginTest.mm.

1859 {
1860 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] testSetMarkedTextWithSelectionChange]);
1861}

◆ TEST() [473/715]

flutter::testing::TEST ( FlutterTextInputPluginTest  ,
UnhandledKeyEquivalent   
)

Definition at line 1941 of file FlutterTextInputPluginTest.mm.

1941 {
1942 ASSERT_TRUE([[FlutterInputPluginTestObjc alloc] unhandledKeyEquivalent]);
1943}

◆ TEST() [474/715]

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

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}
static constexpr FlutterViewId kFlutterImplicitViewId
Definition: embedder.cc:108
int64_t FlutterViewIdentifier

◆ TEST() [476/715]

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>();
71
72 EXPECT_TRUE(true);
73}
gl
Definition: malisc.py:41

◆ TEST() [477/715]

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}
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
@ kFlutterDesktopGpuSurfaceTexture
void(* release_callback)(void *release_context)
FlutterDesktopGpuSurfaceTextureCallback callback
FlutterDesktopGpuSurfaceTextureConfig gpu_surface_config
FlutterDesktopTextureType type
size_t height
Height of the texture.
Definition: embedder.h:386
int64_t texture_id
unsigned int UINT
Definition: windows_types.h:32

◆ TEST() [478/715]

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
Definition: windows_types.h:36

◆ TEST() [479/715]

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

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

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

◆ TEST() [482/715]

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

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

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

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

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

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:240

◆ TEST() [488/715]

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.
Definition: mock_context.h:17
struct MyStruct s
FlutterDesktopBinaryReply callback
std::function< void()> closure
Definition: closure.h:14

◆ TEST() [489/715]

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

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

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

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

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

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

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

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:243
@ kFlutterSemanticsFlagIsExpanded
Whether a semantic node that hasExpandedState is currently expanded.
Definition: embedder.h:245

◆ TEST() [497/715]

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:212

◆ TEST() [498/715]

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

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

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

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}
static void ScheduleFrame(JNIEnv *env, jobject jcaller, jlong shell_holder)

◆ TEST() [502/715]

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)
Definition: view_modifier.h:24

◆ TEST() [503/715]

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

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

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

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

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

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

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

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

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 =
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() [512/715]

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 =
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() [513/715]

flutter::testing::TEST ( ImageDecoderTest  ,
ImagesWithTransparencyArePremulAlpha   
)

Definition at line 743 of file image_decoder_unittests.cc.

743 {
744 auto data = flutter::testing::OpenFixtureAsSkData("heart_end.png");
745 ASSERT_TRUE(data);
746 ImageGeneratorRegistry registry;
747 std::shared_ptr<ImageGenerator> generator =
749 ASSERT_TRUE(generator);
750
751 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(data),
752 std::move(generator));
753 auto compressed_image = ImageDecoderSkia::ImageFromCompressedData(
754 descriptor.get(), 250, 250, fml::tracing::TraceFlow(""));
755 ASSERT_TRUE(compressed_image);
756 ASSERT_EQ(compressed_image->width(), 250);
757 ASSERT_EQ(compressed_image->height(), 250);
758 ASSERT_EQ(compressed_image->alphaType(), kPremul_SkAlphaType);
759}

◆ TEST() [514/715]

flutter::testing::TEST ( ImageDecoderTest  ,
VerifyCodecRepeatCountsForGifAndWebPAreConsistentWithLoopCounts   
)

Definition at line 684 of file image_decoder_unittests.cc.

685 {
686 auto gif_mapping = flutter::testing::OpenFixtureAsSkData("hello_loop_2.gif");
687 auto webp_mapping =
688 flutter::testing::OpenFixtureAsSkData("hello_loop_2.webp");
689
690 ASSERT_TRUE(gif_mapping);
691 ASSERT_TRUE(webp_mapping);
692
693 ImageGeneratorRegistry registry;
694
695 auto gif_generator = registry.CreateCompatibleGenerator(gif_mapping);
696 auto webp_generator = registry.CreateCompatibleGenerator(webp_mapping);
697
698 ASSERT_TRUE(gif_generator);
699 ASSERT_TRUE(webp_generator);
700
701 // Both fixtures have a loop count of 2.
702 ASSERT_EQ(gif_generator->GetPlayCount(), static_cast<unsigned int>(2));
703 ASSERT_EQ(webp_generator->GetPlayCount(), static_cast<unsigned int>(2));
704}

◆ TEST() [515/715]

flutter::testing::TEST ( ImageDecoderTest  ,
VerifySimpleDecoding   
)

Definition at line 706 of file image_decoder_unittests.cc.

706 {
707 auto data = flutter::testing::OpenFixtureAsSkData("Horizontal.jpg");
709 ASSERT_TRUE(image != nullptr);
710 ASSERT_EQ(600, image->width());
711 ASSERT_EQ(200, image->height());
712
713 ImageGeneratorRegistry registry;
714 std::shared_ptr<ImageGenerator> generator =
716 ASSERT_TRUE(generator);
717
718 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(data),
719 std::move(generator));
720 auto compressed_image = ImageDecoderSkia::ImageFromCompressedData(
721 descriptor.get(), 6, 2, fml::tracing::TraceFlow(""));
722 ASSERT_EQ(compressed_image->width(), 6);
723 ASSERT_EQ(compressed_image->height(), 2);
724 ASSERT_EQ(compressed_image->alphaType(), kOpaque_SkAlphaType);
725
726#if IMPELLER_SUPPORTS_RENDERING
727 std::shared_ptr<impeller::Allocator> allocator =
728 std::make_shared<impeller::TestImpellerAllocator>();
729 auto result_1 = ImageDecoderImpeller::DecompressTexture(
730 descriptor.get(), SkISize::Make(6, 2), {100, 100},
731 /*supports_wide_gamut=*/false, allocator);
732 ASSERT_EQ(result_1.sk_bitmap->width(), 6);
733 ASSERT_EQ(result_1.sk_bitmap->height(), 2);
734
735 auto result_2 = ImageDecoderImpeller::DecompressTexture(
736 descriptor.get(), SkISize::Make(60, 20), {10, 10},
737 /*supports_wide_gamut=*/false, allocator);
738 ASSERT_EQ(result_2.sk_bitmap->width(), 10);
739 ASSERT_EQ(result_2.sk_bitmap->height(), 10);
740#endif // IMPELLER_SUPPORTS_RENDERING
741}

◆ TEST() [516/715]

flutter::testing::TEST ( ImageDecoderTest  ,
VerifySubpixelDecodingPreservesExifOrientation   
)

Definition at line 761 of file image_decoder_unittests.cc.

761 {
762 auto data = flutter::testing::OpenFixtureAsSkData("Horizontal.jpg");
763
764 ImageGeneratorRegistry registry;
765 std::shared_ptr<ImageGenerator> generator =
767 ASSERT_TRUE(generator);
768 auto descriptor =
769 fml::MakeRefCounted<ImageDescriptor>(data, std::move(generator));
770
771 // If Exif metadata is ignored, the height and width will be swapped because
772 // "Rotate 90 CW" is what is encoded there.
773 ASSERT_EQ(600, descriptor->width());
774 ASSERT_EQ(200, descriptor->height());
775
777 ASSERT_TRUE(image != nullptr);
778 ASSERT_EQ(600, image->width());
779 ASSERT_EQ(200, image->height());
780
781 auto decode = [descriptor](uint32_t target_width, uint32_t target_height) {
782 return ImageDecoderSkia::ImageFromCompressedData(
783 descriptor.get(), target_width, target_height,
785 };
786
787 auto expected_data = flutter::testing::OpenFixtureAsSkData("Horizontal.png");
788 ASSERT_TRUE(expected_data != nullptr);
789 ASSERT_FALSE(expected_data->isEmpty());
790
791 auto assert_image = [&](auto decoded_image, const std::string& decode_error) {
792 ASSERT_EQ(decoded_image->dimensions(), SkISize::Make(300, 100));
793 sk_sp<SkData> encoded =
794 SkPngEncoder::Encode(nullptr, decoded_image.get(), {});
795 ASSERT_TRUE(encoded->equals(expected_data.get()));
796 };
797
798 assert_image(decode(300, 100), {});
799}
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124

◆ TEST() [517/715]

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
static constexpr size_t kImageReaderSwapchainSize
Definition: image_lru.h:20

◆ TEST() [518/715]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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}
constexpr int kShift
constexpr int kScanCodeShiftRight
constexpr int kScanCodeShiftLeft
constexpr int kScanCodeControlRight
constexpr int kScanCodeControlLeft
constexpr int kControl

◆ TEST() [536/715]

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

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

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}
constexpr uint64_t kPhysicalControlLeft
Definition: key_codes.g.h:224
constexpr uint64_t kLogicalControlLeft
Definition: key_codes.g.h:681
constexpr uint64_t kLogicalControlRight
Definition: key_codes.g.h:682
constexpr uint64_t kPhysicalControlRight
Definition: key_codes.g.h:228

◆ TEST() [539/715]

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

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

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

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}
constexpr uint64_t kPhysicalNumLock
Definition: key_codes.g.h:155
constexpr uint64_t kLogicalNumLock
Definition: key_codes.g.h:381

◆ TEST() [543/715]

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

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

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

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

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

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}
constexpr uint64_t kPhysicalAltLeft
Definition: key_codes.g.h:226
constexpr uint64_t kLogicalAltLeft
Definition: key_codes.g.h:685

◆ TEST() [549/715]

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

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

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

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

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

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

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}
int find(T *array, int N, T item)
const std::vector< LayoutGoal > kLayoutGoals

◆ TEST() [556/715]

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)
SkMatrix transform_3x3() const
AutoRestore applyState(const SkRect &bounds, int can_apply_flags)
bool content_culled(const SkRect &content_bounds) const

◆ TEST() [557/715]

flutter::testing::TEST ( LayerStateStack  ,
ColorFilter   
)

Definition at line 208 of file layer_state_stack_unittests.cc.

208 {
209 SkRect rect = {10, 10, 20, 20};
210 std::shared_ptr<DlBlendColorFilter> outer_filter =
211 std::make_shared<DlBlendColorFilter>(DlColor::kYellow(),
212 DlBlendMode::kColorBurn);
213 std::shared_ptr<DlBlendColorFilter> inner_filter =
214 std::make_shared<DlBlendColorFilter>(DlColor::kRed(),
215 DlBlendMode::kColorBurn);
216
217 LayerStateStack state_stack;
218 state_stack.set_preroll_delegate(SkRect::MakeLTRB(0, 0, 50, 50));
219 {
220 auto mutator = state_stack.save();
221 mutator.applyColorFilter(rect, outer_filter);
222
223 ASSERT_EQ(state_stack.outstanding_color_filter(), outer_filter);
224
225 // Check nested color filters result in nested saveLayers
226 {
227 auto mutator2 = state_stack.save();
228 mutator.applyColorFilter(rect, inner_filter);
229
230 ASSERT_EQ(state_stack.outstanding_color_filter(), inner_filter);
231
232 // Verify output with applyState that does not accept color filters
233 {
235 state_stack.set_delegate(&builder);
236 {
237 auto restore = state_stack.applyState(rect, 0);
238 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
239
241 state_stack.fill(paint);
242 builder.DrawRect(rect, paint);
243 }
244 state_stack.clear_delegate();
245
246 DisplayListBuilder expected;
247 DlPaint outer_save_paint = DlPaint().setColorFilter(outer_filter);
248 DlPaint inner_save_paint = DlPaint().setColorFilter(inner_filter);
249 expected.SaveLayer(&rect, &outer_save_paint);
250 expected.SaveLayer(&rect, &inner_save_paint);
251 expected.DrawRect(rect, DlPaint());
252 expected.Restore();
253 expected.Restore();
254 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
255 }
256
257 // Verify output with applyState that accepts color filters
258 {
259 SkRect rect = {10, 10, 20, 20};
260 DisplayListBuilder builder;
261 state_stack.set_delegate(&builder);
262 {
263 auto restore = state_stack.applyState(
264 rect, LayerStateStack::kCallerCanApplyColorFilter);
265 ASSERT_EQ(state_stack.outstanding_color_filter(), inner_filter);
266
268 state_stack.fill(paint);
269 builder.DrawRect(rect, paint);
270 }
271 state_stack.clear_delegate();
272
273 DisplayListBuilder expected;
274 DlPaint save_paint = DlPaint().setColorFilter(outer_filter);
275 DlPaint draw_paint = DlPaint().setColorFilter(inner_filter);
276 expected.SaveLayer(&rect, &save_paint);
277 expected.DrawRect(rect, draw_paint);
278 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
279 }
280 }
281
282 ASSERT_EQ(state_stack.outstanding_color_filter(), outer_filter);
283 }
284
285 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
286}
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)
bool DisplayListsEQ_Verbose(const DisplayList *a, const DisplayList *b)

◆ TEST() [558/715]

flutter::testing::TEST ( LayerStateStack  ,
ColorFilterAndImageFilterInteraction   
)

Definition at line 489 of file layer_state_stack_unittests.cc.

489 {
490 SkRect rect = {10, 10, 20, 20};
491 std::shared_ptr<DlBlendColorFilter> color_filter =
492 std::make_shared<DlBlendColorFilter>(DlColor::kYellow(),
493 DlBlendMode::kColorBurn);
494 std::shared_ptr<DlBlurImageFilter> image_filter =
495 std::make_shared<DlBlurImageFilter>(2.0f, 2.0f, DlTileMode::kClamp);
496
498 LayerStateStack state_stack;
499 state_stack.set_delegate(&builder);
500 ASSERT_EQ(builder.GetSaveCount(), 1);
501
502 {
503 auto mutator1 = state_stack.save();
504 ASSERT_EQ(builder.GetSaveCount(), 1);
505 mutator1.applyColorFilter(rect, color_filter);
506 ASSERT_EQ(builder.GetSaveCount(), 1);
507
508 {
509 auto mutator2 = state_stack.save();
510 ASSERT_EQ(builder.GetSaveCount(), 1);
511 mutator2.applyImageFilter(rect, image_filter);
512
513 // color filter applied to image filter can be applied together
514 ASSERT_EQ(builder.GetSaveCount(), 1);
515 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
516 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
517 }
518 ASSERT_EQ(builder.GetSaveCount(), 1);
519 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
520 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
521 }
522 ASSERT_EQ(builder.GetSaveCount(), 1);
523 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
524 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
525
526 {
527 auto mutator1 = state_stack.save();
528 ASSERT_EQ(builder.GetSaveCount(), 1);
529 mutator1.applyImageFilter(rect, image_filter);
530 ASSERT_EQ(builder.GetSaveCount(), 1);
531
532 {
533 auto mutator2 = state_stack.save();
534 ASSERT_EQ(builder.GetSaveCount(), 1);
535 mutator2.applyColorFilter(rect, color_filter);
536
537 // The image filter will have been resolved by a saveLayer
538 ASSERT_EQ(builder.GetSaveCount(), 2);
539 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
540 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
541 }
542 ASSERT_EQ(builder.GetSaveCount(), 1);
543 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
544 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
545 }
546 ASSERT_EQ(builder.GetSaveCount(), 1);
547 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
548 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
549}
std::shared_ptr< const DlImageFilter > outstanding_image_filter() const

◆ TEST() [559/715]

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.outstanding_opacity(), SK_Scalar1);
45 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
46 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
47 ASSERT_EQ(state_stack.outstanding_bounds(), SkRect());
48
50 ASSERT_EQ(state_stack.device_cull_rect(), kGiantRect);
51 ASSERT_EQ(state_stack.local_cull_rect(), kGiantRect);
52 ASSERT_EQ(state_stack.transform_3x3(), SkMatrix::I());
53 ASSERT_EQ(state_stack.transform_4x4(), SkM44());
54
55 DlPaint dl_paint;
56 state_stack.fill(dl_paint);
57 ASSERT_EQ(dl_paint, DlPaint());
58}
#define SK_Scalar1
Definition: SkScalar.h:18
SkRect outstanding_bounds() const
SkScalar outstanding_opacity() const
static constexpr SkRect kGiantRect
Definition: layer.h:50

◆ TEST() [560/715]

flutter::testing::TEST ( LayerStateStack  ,
ImageFilter   
)

Definition at line 288 of file layer_state_stack_unittests.cc.

288 {
289 SkRect rect = {10, 10, 20, 20};
290 std::shared_ptr<DlBlurImageFilter> outer_filter =
291 std::make_shared<DlBlurImageFilter>(2.0f, 2.0f, DlTileMode::kClamp);
292 std::shared_ptr<DlBlurImageFilter> inner_filter =
293 std::make_shared<DlBlurImageFilter>(3.0f, 3.0f, DlTileMode::kClamp);
294 SkRect inner_src_rect = rect;
295 SkRect outer_src_rect;
296 ASSERT_EQ(inner_filter->map_local_bounds(rect, outer_src_rect),
297 &outer_src_rect);
298
299 LayerStateStack state_stack;
300 state_stack.set_preroll_delegate(SkRect::MakeLTRB(0, 0, 50, 50));
301 {
302 auto mutator = state_stack.save();
303 mutator.applyImageFilter(outer_src_rect, outer_filter);
304
305 ASSERT_EQ(state_stack.outstanding_image_filter(), outer_filter);
306
307 // Check nested color filters result in nested saveLayers
308 {
309 auto mutator2 = state_stack.save();
310 mutator.applyImageFilter(rect, inner_filter);
311
312 ASSERT_EQ(state_stack.outstanding_image_filter(), inner_filter);
313
314 // Verify output with applyState that does not accept color filters
315 {
317 state_stack.set_delegate(&builder);
318 {
319 auto restore = state_stack.applyState(rect, 0);
320 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
321
323 state_stack.fill(paint);
324 builder.DrawRect(rect, paint);
325 }
326 state_stack.clear_delegate();
327
328 DisplayListBuilder expected;
329 DlPaint outer_save_paint = DlPaint().setImageFilter(outer_filter);
330 DlPaint inner_save_paint = DlPaint().setImageFilter(inner_filter);
331 expected.SaveLayer(&outer_src_rect, &outer_save_paint);
332 expected.SaveLayer(&inner_src_rect, &inner_save_paint);
333 expected.DrawRect(rect, DlPaint());
334 expected.Restore();
335 expected.Restore();
336 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
337 }
338
339 // Verify output with applyState that accepts color filters
340 {
341 SkRect rect = {10, 10, 20, 20};
342 DisplayListBuilder builder;
343 state_stack.set_delegate(&builder);
344 {
345 auto restore = state_stack.applyState(
346 rect, LayerStateStack::kCallerCanApplyImageFilter);
347 ASSERT_EQ(state_stack.outstanding_image_filter(), inner_filter);
348
350 state_stack.fill(paint);
351 builder.DrawRect(rect, paint);
352 }
353 state_stack.clear_delegate();
354
355 DisplayListBuilder expected;
356 DlPaint save_paint = DlPaint().setImageFilter(outer_filter);
357 DlPaint draw_paint = DlPaint().setImageFilter(inner_filter);
358 expected.SaveLayer(&outer_src_rect, &save_paint);
359 expected.DrawRect(rect, draw_paint);
360 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
361 }
362 }
363
364 ASSERT_EQ(state_stack.outstanding_image_filter(), outer_filter);
365 }
366
367 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
368}
void applyImageFilter(const SkRect &bounds, const std::shared_ptr< const DlImageFilter > &filter)

◆ TEST() [561/715]

flutter::testing::TEST ( LayerStateStack  ,
OldDelegateIsRolledBack   
)

Definition at line 91 of file layer_state_stack_unittests.cc.

91 {
92 LayerStateStack state_stack;
94 DisplayListBuilder builder2;
95 DlCanvas& canvas = builder2;
96
97 ASSERT_TRUE(builder.GetTransform().isIdentity());
98 ASSERT_TRUE(canvas.GetTransform().isIdentity());
99
100 state_stack.set_delegate(&builder);
101
102 ASSERT_TRUE(builder.GetTransform().isIdentity());
103 ASSERT_TRUE(canvas.GetTransform().isIdentity());
104
105 auto mutator = state_stack.save();
106 mutator.translate({10, 10});
107
108 ASSERT_EQ(builder.GetTransform(), SkMatrix::Translate(10, 10));
109 ASSERT_TRUE(canvas.GetTransform().isIdentity());
110
111 state_stack.set_delegate(&canvas);
112
113 ASSERT_TRUE(builder.GetTransform().isIdentity());
114 ASSERT_EQ(canvas.GetTransform(), SkMatrix::Translate(10, 10));
115
116 state_stack.set_preroll_delegate(SkRect::MakeWH(100, 100));
117
118 ASSERT_TRUE(builder.GetTransform().isIdentity());
119 ASSERT_TRUE(canvas.GetTransform().isIdentity());
120
121 state_stack.set_delegate(&builder);
122 state_stack.clear_delegate();
123
124 ASSERT_TRUE(builder.GetTransform().isIdentity());
125 ASSERT_TRUE(canvas.GetTransform().isIdentity());
126
127 state_stack.set_delegate(&canvas);
128 state_stack.clear_delegate();
129
130 ASSERT_TRUE(builder.GetTransform().isIdentity());
131 ASSERT_TRUE(canvas.GetTransform().isIdentity());
132}
bool isIdentity() const
Definition: SkMatrix.h:223
virtual SkMatrix GetTransform() const =0
void translate(SkScalar tx, SkScalar ty)

◆ TEST() [562/715]

flutter::testing::TEST ( LayerStateStack  ,
Opacity   
)

Definition at line 134 of file layer_state_stack_unittests.cc.

134 {
135 SkRect rect = {10, 10, 20, 20};
136
137 LayerStateStack state_stack;
138 state_stack.set_preroll_delegate(SkRect::MakeLTRB(0, 0, 50, 50));
139 {
140 auto mutator = state_stack.save();
141 mutator.applyOpacity(rect, 0.5f);
142
143 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
144 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
145
146 // Check nested opacities multiply with each other
147 {
148 auto mutator2 = state_stack.save();
149 mutator.applyOpacity(rect, 0.5f);
150
151 ASSERT_EQ(state_stack.outstanding_opacity(), 0.25f);
152 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
153
154 // Verify output with applyState that does not accept opacity
155 {
157 state_stack.set_delegate(&builder);
158 {
159 auto restore = state_stack.applyState(rect, 0);
160 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
161 ASSERT_EQ(state_stack.outstanding_bounds(), SkRect());
162
164 state_stack.fill(paint);
165 builder.DrawRect(rect, paint);
166 }
167 state_stack.clear_delegate();
168
169 DisplayListBuilder expected;
170 DlPaint save_paint =
171 DlPaint().setOpacity(state_stack.outstanding_opacity());
172 expected.SaveLayer(&rect, &save_paint);
173 expected.DrawRect(rect, DlPaint());
174 expected.Restore();
175 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
176 }
177
178 // Verify output with applyState that accepts opacity
179 {
180 DisplayListBuilder builder;
181 state_stack.set_delegate(&builder);
182 {
183 auto restore = state_stack.applyState(
184 rect, LayerStateStack::kCallerCanApplyOpacity);
185 ASSERT_EQ(state_stack.outstanding_opacity(), 0.25f);
186 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
187
189 state_stack.fill(paint);
190 builder.DrawRect(rect, paint);
191 }
192 state_stack.clear_delegate();
193
194 DisplayListBuilder expected;
195 expected.DrawRect(rect, DlPaint().setOpacity(0.25f));
196 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), expected.Build()));
197 }
198 }
199
200 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
201 ASSERT_EQ(state_stack.outstanding_bounds(), rect);
202 }
203
204 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
205 ASSERT_EQ(state_stack.outstanding_bounds(), SkRect());
206}
DlPaint & setOpacity(SkScalar opacity)
Definition: dl_paint.h:78

◆ TEST() [563/715]

flutter::testing::TEST ( LayerStateStack  ,
OpacityAndColorFilterInteraction   
)

Definition at line 370 of file layer_state_stack_unittests.cc.

370 {
371 SkRect rect = {10, 10, 20, 20};
372 std::shared_ptr<DlBlendColorFilter> color_filter =
373 std::make_shared<DlBlendColorFilter>(DlColor::kYellow(),
374 DlBlendMode::kColorBurn);
375
377 LayerStateStack state_stack;
378 state_stack.set_delegate(&builder);
379 ASSERT_EQ(builder.GetSaveCount(), 1);
380
381 {
382 auto mutator1 = state_stack.save();
383 ASSERT_EQ(builder.GetSaveCount(), 1);
384 mutator1.applyOpacity(rect, 0.5f);
385 ASSERT_EQ(builder.GetSaveCount(), 1);
386
387 {
388 auto mutator2 = state_stack.save();
389 ASSERT_EQ(builder.GetSaveCount(), 1);
390 mutator2.applyColorFilter(rect, color_filter);
391
392 // The opacity will have been resolved by a saveLayer
393 ASSERT_EQ(builder.GetSaveCount(), 2);
394 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
395 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
396 }
397 ASSERT_EQ(builder.GetSaveCount(), 1);
398 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
399 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
400 }
401 ASSERT_EQ(builder.GetSaveCount(), 1);
402 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
403 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
404
405 {
406 auto mutator1 = state_stack.save();
407 ASSERT_EQ(builder.GetSaveCount(), 1);
408 mutator1.applyColorFilter(rect, color_filter);
409 ASSERT_EQ(builder.GetSaveCount(), 1);
410
411 {
412 auto mutator2 = state_stack.save();
413 ASSERT_EQ(builder.GetSaveCount(), 1);
414 mutator2.applyOpacity(rect, 0.5f);
415
416 // color filter applied to opacity can be applied together
417 ASSERT_EQ(builder.GetSaveCount(), 1);
418 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
419 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
420 }
421 ASSERT_EQ(builder.GetSaveCount(), 1);
422 ASSERT_EQ(state_stack.outstanding_color_filter(), color_filter);
423 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
424 }
425 ASSERT_EQ(builder.GetSaveCount(), 1);
426 ASSERT_EQ(state_stack.outstanding_color_filter(), nullptr);
427 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
428}

◆ TEST() [564/715]

flutter::testing::TEST ( LayerStateStack  ,
OpacityAndImageFilterInteraction   
)

Definition at line 430 of file layer_state_stack_unittests.cc.

430 {
431 SkRect rect = {10, 10, 20, 20};
432 std::shared_ptr<DlBlurImageFilter> image_filter =
433 std::make_shared<DlBlurImageFilter>(2.0f, 2.0f, DlTileMode::kClamp);
434
436 LayerStateStack state_stack;
437 state_stack.set_delegate(&builder);
438 ASSERT_EQ(builder.GetSaveCount(), 1);
439
440 {
441 auto mutator1 = state_stack.save();
442 ASSERT_EQ(builder.GetSaveCount(), 1);
443 mutator1.applyOpacity(rect, 0.5f);
444 ASSERT_EQ(builder.GetSaveCount(), 1);
445
446 {
447 auto mutator2 = state_stack.save();
448 ASSERT_EQ(builder.GetSaveCount(), 1);
449 mutator2.applyImageFilter(rect, image_filter);
450
451 // opacity applied to image filter can be applied together
452 ASSERT_EQ(builder.GetSaveCount(), 1);
453 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
454 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
455 }
456 ASSERT_EQ(builder.GetSaveCount(), 1);
457 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
458 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
459 }
460 ASSERT_EQ(builder.GetSaveCount(), 1);
461 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
462 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
463
464 {
465 auto mutator1 = state_stack.save();
466 ASSERT_EQ(builder.GetSaveCount(), 1);
467 mutator1.applyImageFilter(rect, image_filter);
468 ASSERT_EQ(builder.GetSaveCount(), 1);
469
470 {
471 auto mutator2 = state_stack.save();
472 ASSERT_EQ(builder.GetSaveCount(), 1);
473 mutator2.applyOpacity(rect, 0.5f);
474
475 // The image filter will have been resolved by a saveLayer
476 ASSERT_EQ(builder.GetSaveCount(), 2);
477 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
478 ASSERT_EQ(state_stack.outstanding_opacity(), 0.5f);
479 }
480 ASSERT_EQ(builder.GetSaveCount(), 1);
481 ASSERT_EQ(state_stack.outstanding_image_filter(), image_filter);
482 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
483 }
484 ASSERT_EQ(builder.GetSaveCount(), 1);
485 ASSERT_EQ(state_stack.outstanding_image_filter(), nullptr);
486 ASSERT_EQ(state_stack.outstanding_opacity(), SK_Scalar1);
487}

◆ TEST() [565/715]

flutter::testing::TEST ( LayerStateStack  ,
SingularDelegate   
)

Definition at line 60 of file layer_state_stack_unittests.cc.

60 {
61 LayerStateStack state_stack;
62 ASSERT_EQ(state_stack.canvas_delegate(), nullptr);
63
64 // Two different DlCanvas implementators
66 DisplayListBuilder builder2;
67 DlCanvas& canvas = builder2;
68
69 // no delegate -> builder delegate
70 state_stack.set_delegate(&builder);
71 ASSERT_EQ(state_stack.canvas_delegate(), &builder);
72
73 // builder delegate -> DlCanvas delegate
74 state_stack.set_delegate(&canvas);
75 ASSERT_EQ(state_stack.canvas_delegate(), &canvas);
76
77 // DlCanvas delegate -> builder delegate
78 state_stack.set_delegate(&builder);
79 ASSERT_EQ(state_stack.canvas_delegate(), &builder);
80
81 // builder delegate -> no delegate
82 state_stack.clear_delegate();
83 ASSERT_EQ(state_stack.canvas_delegate(), nullptr);
84
85 // DlCanvas delegate -> no delegate
86 state_stack.set_delegate(&canvas);
87 state_stack.clear_delegate();
88 ASSERT_EQ(state_stack.canvas_delegate(), nullptr);
89}

◆ TEST() [566/715]

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}
constexpr float kLog2E
Definition: math.h:15
constexpr float kSqrt2
Definition: math.h:45
constexpr float kPiOver4
Definition: math.h:33
constexpr float kPi
Definition: math.h:27
constexpr float k2OverPi
Definition: math.h:39
constexpr float kPiOver2
Definition: math.h:30
constexpr float kLogE2
Definition: math.h:21
constexpr float kE
Definition: math.h:12
constexpr float k1OverSqrt2
Definition: math.h:48
constexpr float kLog10E
Definition: math.h:18
constexpr float k1OverPi
Definition: math.h:36

◆ TEST() [567/715]

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

flutter::testing::TEST ( MockTextureTest  ,
PaintCalls   
)

Definition at line 30 of file mock_texture_unittests.cc.

30 {
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
Definition: dl_builder.cc:1396
SkSamplingOptions sampling
Definition: SkRecords.h:337

◆ TEST() [569/715]

flutter::testing::TEST ( MockTextureTest  ,
PaintCallsWithLinearSampling   
)

Definition at line 54 of file mock_texture_unittests.cc.

54 {
56 const SkRect paint_bounds1 = SkRect::MakeWH(1.0f, 1.0f);
57 const SkRect paint_bounds2 = SkRect::MakeWH(2.0f, 2.0f);
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() [570/715]

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

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}
LONG_PTR LRESULT
Definition: windows_types.h:61
UINT_PTR WPARAM
Definition: windows_types.h:59

◆ TEST() [572/715]

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

Definition at line 28 of file window_unittests.cc.

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

◆ TEST() [573/715]

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:1008

◆ TEST() [574/715]

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

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}
constexpr LRESULT kWmResultDontCheck
Definition: wm_builders.h:16

◆ TEST() [576/715]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

flutter::testing::TEST ( Mutator  ,
CopyConstructor   
)

Definition at line 224 of file mutators_stack_unittests.cc.

224 {
226 Mutator mutator = Mutator(rect);
227 Mutator copy = Mutator(mutator);
228 ASSERT_TRUE(mutator == copy);
229
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
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() [592/715]

flutter::testing::TEST ( Mutator  ,
Equality   
)

Definition at line 257 of file mutators_stack_unittests.cc.

257 {
259 matrix.setIdentity();
260 Mutator mutator = Mutator(matrix);
261 Mutator other_mutator = Mutator(matrix);
262 ASSERT_TRUE(mutator == other_mutator);
263
265 Mutator mutator2 = Mutator(rect);
266 Mutator other_mutator2 = Mutator(rect);
267 ASSERT_TRUE(mutator2 == other_mutator2);
268
270 Mutator mutator3 = Mutator(rrect);
271 Mutator other_mutator3 = Mutator(rrect);
272 ASSERT_TRUE(mutator3 == other_mutator3);
273
274 SkPath 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() [593/715]

flutter::testing::TEST ( Mutator  ,
Initialization   
)

Definition at line 192 of file mutators_stack_unittests.cc.

192 {
194 Mutator mutator = Mutator(rect);
195 ASSERT_TRUE(mutator.GetType() == MutatorType::kClipRect);
196 ASSERT_TRUE(mutator.GetRect() == rect);
197
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
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
@ kBackdropFilter

◆ TEST() [594/715]

flutter::testing::TEST ( Mutator  ,
UnEquality   
)

Definition at line 291 of file mutators_stack_unittests.cc.

291 {
293 Mutator mutator = Mutator(rect);
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() [595/715]

flutter::testing::TEST ( MutatorsStack  ,
CopyAndUpdateTheCopy   
)

Definition at line 26 of file mutators_stack_unittests.cc.

26 {
27 MutatorsStack stack;
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() [596/715]

flutter::testing::TEST ( MutatorsStack  ,
CopyConstructor   
)

Definition at line 16 of file mutators_stack_unittests.cc.

16 {
17 MutatorsStack stack;
19 auto rect = SkRect::MakeEmpty();
20 stack.PushClipRect(rect);
21 stack.PushClipRRect(rrect);
23 ASSERT_TRUE(copy == stack);
24}

◆ TEST() [597/715]

flutter::testing::TEST ( MutatorsStack  ,
Equality   
)

Definition at line 159 of file mutators_stack_unittests.cc.

159 {
160 MutatorsStack stack;
162 stack.PushTransform(matrix);
164 stack.PushClipRect(rect);
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() [598/715]

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

flutter::testing::TEST ( MutatorsStack  ,
Pop   
)

Definition at line 116 of file mutators_stack_unittests.cc.

116 {
117 MutatorsStack stack;
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() [600/715]

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

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

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

flutter::testing::TEST ( MutatorsStack  ,
PushClipRRect   
)

Definition at line 55 of file mutators_stack_unittests.cc.

55 {
56 MutatorsStack stack;
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() [604/715]

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

flutter::testing::TEST ( MutatorsStack  ,
PushTransform   
)

Definition at line 73 of file mutators_stack_unittests.cc.

73 {
74 MutatorsStack stack;
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() [606/715]

flutter::testing::TEST ( MutatorsStack  ,
Traversal   
)

Definition at line 126 of file mutators_stack_unittests.cc.

126 {
127 MutatorsStack stack;
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() [607/715]

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

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

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

flutter::testing::TEST ( PerformanceOverlayLayer120fps  ,
Gold   
)

Definition at line 230 of file performance_overlay_layer_unittests.cc.

230 {
231 TestPerformanceOverlayLayerGold(120);
232}

◆ TEST() [611/715]

flutter::testing::TEST ( PerformanceOverlayLayer90fps  ,
Gold   
)

Definition at line 226 of file performance_overlay_layer_unittests.cc.

226 {
227 TestPerformanceOverlayLayerGold(90);
228}

◆ TEST() [612/715]

flutter::testing::TEST ( PerformanceOverlayLayerDefault  ,
Gold   
)

Definition at line 222 of file performance_overlay_layer_unittests.cc.

222 {
223 TestPerformanceOverlayLayerGold(60);
224}

◆ TEST() [613/715]

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

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

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

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

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

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

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
Definition: task_runners.cc:30
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() [620/715]

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

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

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
Definition: update.py:1

◆ TEST() [623/715]

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

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

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
AlwaysForwardMoveEvent   
)

Definition at line 329 of file pointer_data_packet_converter_unittests.cc.

329 {
330 TestDelegate delegate;
331 delegate.AddView(kImplicitViewId);
333 auto packet = std::make_unique<PointerDataPacket>(4);
336 packet->SetPointerData(0, data);
338 packet->SetPointerData(1, data);
339 // Creates a move event without a location change.
341 packet->SetPointerData(2, data);
343 packet->SetPointerData(3, data);
344
345 auto converted_packet = converter.Convert(*packet);
346
347 std::vector<PointerData> result;
348 UnpackPointerPacket(result, std::move(converted_packet));
349
350 ASSERT_EQ(result.size(), (size_t)4);
351 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
352 ASSERT_EQ(result[0].synthesized, 0);
353
354 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
355 ASSERT_EQ(result[1].pointer_identifier, 1);
356 ASSERT_EQ(result[1].synthesized, 0);
357
358 // Does not filter out the move event.
359 ASSERT_EQ(result[2].change, PointerData::Change::kMove);
360 ASSERT_EQ(result[2].pointer_identifier, 1);
361 ASSERT_EQ(result[2].synthesized, 0);
362
363 ASSERT_EQ(result[3].change, PointerData::Change::kUp);
364 ASSERT_EQ(result[3].pointer_identifier, 1);
365 ASSERT_EQ(result[3].synthesized, 0);
366}
@ kUp
Definition: embedder.h:973
@ kDown
Definition: embedder.h:980
@ kAdd
Definition: embedder.h:990
@ kMove
Definition: embedder.h:985
string converter
Definition: cacheimages.py:19
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() [626/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertPointerDataPacket   
)

Definition at line 168 of file pointer_data_packet_converter_unittests.cc.

168 {
169 TestDelegate delegate;
170 delegate.AddView(kImplicitViewId);
172 auto packet = std::make_unique<PointerDataPacket>(6);
175 packet->SetPointerData(0, data);
177 packet->SetPointerData(1, data);
179 packet->SetPointerData(2, data);
181 packet->SetPointerData(3, data);
183 packet->SetPointerData(4, data);
185 0);
186 packet->SetPointerData(5, data);
187 auto converted_packet = converter.Convert(*packet);
188
189 std::vector<PointerData> result;
190 UnpackPointerPacket(result, std::move(converted_packet));
191
192 ASSERT_EQ(result.size(), (size_t)6);
193 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
194 ASSERT_EQ(result[0].synthesized, 0);
195
196 ASSERT_EQ(result[1].change, PointerData::Change::kHover);
197 ASSERT_EQ(result[1].synthesized, 0);
198 ASSERT_EQ(result[1].physical_delta_x, 3.0);
199 ASSERT_EQ(result[1].physical_delta_y, 0.0);
200
201 ASSERT_EQ(result[2].change, PointerData::Change::kDown);
202 ASSERT_EQ(result[2].pointer_identifier, 1);
203 ASSERT_EQ(result[2].synthesized, 0);
204
205 ASSERT_EQ(result[3].change, PointerData::Change::kMove);
206 ASSERT_EQ(result[3].pointer_identifier, 1);
207 ASSERT_EQ(result[3].synthesized, 0);
208 ASSERT_EQ(result[3].physical_delta_x, 0.0);
209 ASSERT_EQ(result[3].physical_delta_y, 4.0);
210
211 ASSERT_EQ(result[4].change, PointerData::Change::kUp);
212 ASSERT_EQ(result[4].pointer_identifier, 1);
213 ASSERT_EQ(result[4].synthesized, 0);
214
215 ASSERT_EQ(result[5].change, PointerData::Change::kRemove);
216 ASSERT_EQ(result[5].synthesized, 0);
217}
@ kHover
The pointer moved while up.
Definition: embedder.h:997
@ kRemove
Definition: embedder.h:995

◆ TEST() [627/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertPointerSignals   
)

Definition at line 590 of file pointer_data_packet_converter_unittests.cc.

590 {
591 PointerData::SignalKind signal_kinds[] = {
592 PointerData::SignalKind::kScroll,
593 PointerData::SignalKind::kScrollInertiaCancel,
594 PointerData::SignalKind::kScale,
595 };
596 for (const PointerData::SignalKind& kind : signal_kinds) {
597 TestDelegate delegate;
598 delegate.AddView(kImplicitViewId);
600 auto packet = std::make_unique<PointerDataPacket>(6);
604 0.0, 0.0, 0);
605 packet->SetPointerData(0, data);
608 0.0, 0.0, 0);
609 packet->SetPointerData(1, data);
612 0.0, 0.0, 1);
613 packet->SetPointerData(2, data);
615 34.0, 34.0, 30.0, 0.0, 0);
616 packet->SetPointerData(3, data);
618 49.0, 49.0, 50.0, 0.0, 0);
619 packet->SetPointerData(4, data);
621 10.0, 20.0, 30.0, 40.0, 0);
622 packet->SetPointerData(5, data);
623 auto converted_packet = converter.Convert(*packet);
624
625 std::vector<PointerData> result;
626 UnpackPointerPacket(result, std::move(converted_packet));
627
628 ASSERT_EQ(result.size(), (size_t)9);
629 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
630 ASSERT_EQ(result[0].signal_kind, PointerData::SignalKind::kNone);
631 ASSERT_EQ(result[0].device, 0);
632 ASSERT_EQ(result[0].physical_x, 0.0);
633 ASSERT_EQ(result[0].physical_y, 0.0);
634 ASSERT_EQ(result[0].synthesized, 0);
635
636 ASSERT_EQ(result[1].change, PointerData::Change::kAdd);
637 ASSERT_EQ(result[1].signal_kind, PointerData::SignalKind::kNone);
638 ASSERT_EQ(result[1].device, 1);
639 ASSERT_EQ(result[1].physical_x, 0.0);
640 ASSERT_EQ(result[1].physical_y, 0.0);
641 ASSERT_EQ(result[1].synthesized, 0);
642
643 ASSERT_EQ(result[2].change, PointerData::Change::kDown);
644 ASSERT_EQ(result[2].signal_kind, PointerData::SignalKind::kNone);
645 ASSERT_EQ(result[2].device, 1);
646 ASSERT_EQ(result[2].physical_x, 0.0);
647 ASSERT_EQ(result[2].physical_y, 0.0);
648 ASSERT_EQ(result[2].synthesized, 0);
649
650 // Converter will synthesize a hover to position for device 0.
651 ASSERT_EQ(result[3].change, PointerData::Change::kHover);
652 ASSERT_EQ(result[3].signal_kind, PointerData::SignalKind::kNone);
653 ASSERT_EQ(result[3].device, 0);
654 ASSERT_EQ(result[3].physical_x, 34.0);
655 ASSERT_EQ(result[3].physical_y, 34.0);
656 ASSERT_EQ(result[3].physical_delta_x, 34.0);
657 ASSERT_EQ(result[3].physical_delta_y, 34.0);
658 ASSERT_EQ(result[3].buttons, 0);
659 ASSERT_EQ(result[3].synthesized, 1);
660
661 ASSERT_EQ(result[4].change, PointerData::Change::kHover);
662 ASSERT_EQ(result[4].signal_kind, kind);
663 ASSERT_EQ(result[4].device, 0);
664 ASSERT_EQ(result[4].physical_x, 34.0);
665 ASSERT_EQ(result[4].physical_y, 34.0);
666 ASSERT_EQ(result[4].scroll_delta_x, 30.0);
667 ASSERT_EQ(result[4].scroll_delta_y, 0.0);
668
669 // Converter will synthesize a move to position for device 1.
670 ASSERT_EQ(result[5].change, PointerData::Change::kMove);
671 ASSERT_EQ(result[5].signal_kind, PointerData::SignalKind::kNone);
672 ASSERT_EQ(result[5].device, 1);
673 ASSERT_EQ(result[5].physical_x, 49.0);
674 ASSERT_EQ(result[5].physical_y, 49.0);
675 ASSERT_EQ(result[5].physical_delta_x, 49.0);
676 ASSERT_EQ(result[5].physical_delta_y, 49.0);
677 ASSERT_EQ(result[5].buttons, 1);
678 ASSERT_EQ(result[5].synthesized, 1);
679
680 ASSERT_EQ(result[6].change, PointerData::Change::kHover);
681 ASSERT_EQ(result[6].signal_kind, kind);
682 ASSERT_EQ(result[6].device, 1);
683 ASSERT_EQ(result[6].physical_x, 49.0);
684 ASSERT_EQ(result[6].physical_y, 49.0);
685 ASSERT_EQ(result[6].scroll_delta_x, 50.0);
686 ASSERT_EQ(result[6].scroll_delta_y, 0.0);
687
688 // Converter will synthesize an add for device 2.
689 ASSERT_EQ(result[7].change, PointerData::Change::kAdd);
690 ASSERT_EQ(result[7].signal_kind, PointerData::SignalKind::kNone);
691 ASSERT_EQ(result[7].device, 2);
692 ASSERT_EQ(result[7].physical_x, 10.0);
693 ASSERT_EQ(result[7].physical_y, 20.0);
694 ASSERT_EQ(result[7].synthesized, 1);
695
696 ASSERT_EQ(result[8].change, PointerData::Change::kHover);
697 ASSERT_EQ(result[8].signal_kind, kind);
698 ASSERT_EQ(result[8].device, 2);
699 ASSERT_EQ(result[8].physical_x, 10.0);
700 ASSERT_EQ(result[8].physical_y, 20.0);
701 ASSERT_EQ(result[8].scroll_delta_x, 30.0);
702 ASSERT_EQ(result[8].scroll_delta_y, 40.0);
703 }
704}
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)

◆ TEST() [628/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertTrackpadGesture   
)

Definition at line 706 of file pointer_data_packet_converter_unittests.cc.

706 {
707 TestDelegate delegate;
708 delegate.AddView(kImplicitViewId);
710 auto packet = std::make_unique<PointerDataPacket>(3);
713 0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
714 packet->SetPointerData(0, data);
716 0, 0.0, 0.0, 3.0, 4.0, 1.0, 0.0);
717 packet->SetPointerData(1, data);
719 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
720 packet->SetPointerData(2, data);
721 auto converted_packet = converter.Convert(*packet);
722
723 std::vector<PointerData> result;
724 UnpackPointerPacket(result, std::move(converted_packet));
725
726 ASSERT_EQ(result.size(), (size_t)4);
727 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
728 ASSERT_EQ(result[0].device, 0);
729 ASSERT_EQ(result[0].synthesized, 1);
730
731 ASSERT_EQ(result[1].change, PointerData::Change::kPanZoomStart);
732 ASSERT_EQ(result[1].signal_kind, PointerData::SignalKind::kNone);
733 ASSERT_EQ(result[1].device, 0);
734 ASSERT_EQ(result[1].physical_x, 0.0);
735 ASSERT_EQ(result[1].physical_y, 0.0);
736 ASSERT_EQ(result[1].synthesized, 0);
737
738 ASSERT_EQ(result[2].change, PointerData::Change::kPanZoomUpdate);
739 ASSERT_EQ(result[2].signal_kind, PointerData::SignalKind::kNone);
740 ASSERT_EQ(result[2].device, 0);
741 ASSERT_EQ(result[2].physical_x, 0.0);
742 ASSERT_EQ(result[2].physical_y, 0.0);
743 ASSERT_EQ(result[2].pan_x, 3.0);
744 ASSERT_EQ(result[2].pan_y, 4.0);
745 ASSERT_EQ(result[2].pan_delta_x, 3.0);
746 ASSERT_EQ(result[2].pan_delta_y, 4.0);
747 ASSERT_EQ(result[2].scale, 1.0);
748 ASSERT_EQ(result[2].rotation, 0.0);
749 ASSERT_EQ(result[2].synthesized, 0);
750
751 ASSERT_EQ(result[3].change, PointerData::Change::kPanZoomEnd);
752 ASSERT_EQ(result[3].signal_kind, PointerData::SignalKind::kNone);
753 ASSERT_EQ(result[3].device, 0);
754 ASSERT_EQ(result[3].physical_x, 0.0);
755 ASSERT_EQ(result[3].physical_y, 0.0);
756 ASSERT_EQ(result[3].synthesized, 0);
757}
@ kPanZoomUpdate
The pan/zoom updated.
Definition: embedder.h:1001
@ kPanZoomStart
A pan/zoom started on this pointer.
Definition: embedder.h:999
@ kPanZoomEnd
The pan/zoom ended.
Definition: embedder.h:1003
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() [629/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanConvertViewId   
)

Definition at line 759 of file pointer_data_packet_converter_unittests.cc.

759 {
760 TestDelegate delegate;
761 delegate.AddView(100);
762 delegate.AddView(200);
764 auto packet = std::make_unique<PointerDataPacket>(2);
767 data.view_id = 100;
768 packet->SetPointerData(0, data);
770 data.view_id = 200;
771 packet->SetPointerData(1, data);
772 auto converted_packet = converter.Convert(*packet);
773
774 std::vector<PointerData> result;
775 UnpackPointerPacket(result, std::move(converted_packet));
776
777 ASSERT_EQ(result.size(), (size_t)2);
778 ASSERT_EQ(result[0].view_id, 100);
779 ASSERT_EQ(result[1].view_id, 200);
780}

◆ TEST() [630/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanHandleThreeFingerGesture   
)

Definition at line 513 of file pointer_data_packet_converter_unittests.cc.

513 {
514 // Regression test https://github.com/flutter/flutter/issues/20517.
515 TestDelegate delegate;
516 delegate.AddView(kImplicitViewId);
519 std::vector<PointerData> result;
520 // First finger down.
521 auto packet = std::make_unique<PointerDataPacket>(1);
523 packet->SetPointerData(0, data);
524 auto converted_packet = converter.Convert(*packet);
525 UnpackPointerPacket(result, std::move(converted_packet));
526 // Second finger down.
527 packet = std::make_unique<PointerDataPacket>(1);
529 1);
530 packet->SetPointerData(0, data);
531 converted_packet = converter.Convert(*packet);
532 UnpackPointerPacket(result, std::move(converted_packet));
533 // Triggers three cancels.
534 packet = std::make_unique<PointerDataPacket>(3);
536 0);
537 packet->SetPointerData(0, data);
539 0);
540 packet->SetPointerData(1, data);
542 0);
543 packet->SetPointerData(2, data);
544 converted_packet = converter.Convert(*packet);
545 UnpackPointerPacket(result, std::move(converted_packet));
546
547 ASSERT_EQ(result.size(), (size_t)6);
548 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
549 ASSERT_EQ(result[0].device, 0);
550 ASSERT_EQ(result[0].physical_x, 0.0);
551 ASSERT_EQ(result[0].physical_y, 0.0);
552 ASSERT_EQ(result[0].synthesized, 1);
553 ASSERT_EQ(result[0].buttons, 0);
554
555 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
556 ASSERT_EQ(result[1].device, 0);
557 ASSERT_EQ(result[1].physical_x, 0.0);
558 ASSERT_EQ(result[1].physical_y, 0.0);
559 ASSERT_EQ(result[1].synthesized, 0);
560 ASSERT_EQ(result[1].buttons, 1);
561
562 ASSERT_EQ(result[2].change, PointerData::Change::kAdd);
563 ASSERT_EQ(result[2].device, 1);
564 ASSERT_EQ(result[2].physical_x, 33.0);
565 ASSERT_EQ(result[2].physical_y, 44.0);
566 ASSERT_EQ(result[2].synthesized, 1);
567 ASSERT_EQ(result[2].buttons, 0);
568
569 ASSERT_EQ(result[3].change, PointerData::Change::kDown);
570 ASSERT_EQ(result[3].device, 1);
571 ASSERT_EQ(result[3].physical_x, 33.0);
572 ASSERT_EQ(result[3].physical_y, 44.0);
573 ASSERT_EQ(result[3].synthesized, 0);
574 ASSERT_EQ(result[3].buttons, 1);
575
576 ASSERT_EQ(result[4].change, PointerData::Change::kCancel);
577 ASSERT_EQ(result[4].device, 1);
578 ASSERT_EQ(result[4].physical_x, 33.0);
579 ASSERT_EQ(result[4].physical_y, 44.0);
580 ASSERT_EQ(result[4].synthesized, 0);
581
582 ASSERT_EQ(result[5].change, PointerData::Change::kCancel);
583 ASSERT_EQ(result[5].device, 0);
584 ASSERT_EQ(result[5].physical_x, 0.0);
585 ASSERT_EQ(result[5].physical_y, 0.0);
586 ASSERT_EQ(result[5].synthesized, 0);
587 // Third cancel should be dropped
588}
@ kCancel
Definition: embedder.h:966

◆ TEST() [631/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanSynthesizeAdd   
)

Definition at line 467 of file pointer_data_packet_converter_unittests.cc.

467 {
468 TestDelegate delegate;
469 delegate.AddView(kImplicitViewId);
471 auto packet = std::make_unique<PointerDataPacket>(2);
474 1);
475 packet->SetPointerData(0, data);
477 packet->SetPointerData(1, data);
478 auto converted_packet = converter.Convert(*packet);
479
480 std::vector<PointerData> result;
481 UnpackPointerPacket(result, std::move(converted_packet));
482
483 ASSERT_EQ(result.size(), (size_t)4);
484 // A add should be synthesized.
485 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
486 ASSERT_EQ(result[0].physical_x, 330.0);
487 ASSERT_EQ(result[0].physical_y, 450.0);
488 ASSERT_EQ(result[0].synthesized, 1);
489 ASSERT_EQ(result[0].buttons, 0);
490
491 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
492 ASSERT_EQ(result[1].physical_x, 330.0);
493 ASSERT_EQ(result[1].physical_y, 450.0);
494 ASSERT_EQ(result[1].synthesized, 0);
495 ASSERT_EQ(result[1].buttons, 1);
496
497 // A move should be synthesized.
498 ASSERT_EQ(result[2].change, PointerData::Change::kMove);
499 ASSERT_EQ(result[2].physical_delta_x, -330.0);
500 ASSERT_EQ(result[2].physical_delta_y, -450.0);
501 ASSERT_EQ(result[2].physical_x, 0.0);
502 ASSERT_EQ(result[2].physical_y, 0.0);
503 ASSERT_EQ(result[2].synthesized, 1);
504 ASSERT_EQ(result[2].buttons, 1);
505
506 ASSERT_EQ(result[3].change, PointerData::Change::kUp);
507 ASSERT_EQ(result[3].physical_x, 0.0);
508 ASSERT_EQ(result[3].physical_y, 0.0);
509 ASSERT_EQ(result[3].synthesized, 0);
510 ASSERT_EQ(result[3].buttons, 0);
511}

◆ TEST() [632/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanSynthesizeDownAndUp   
)

Definition at line 219 of file pointer_data_packet_converter_unittests.cc.

219 {
220 TestDelegate delegate;
221 delegate.AddView(kImplicitViewId);
223 auto packet = std::make_unique<PointerDataPacket>(4);
226 packet->SetPointerData(0, data);
228 packet->SetPointerData(1, data);
230 packet->SetPointerData(2, data);
232 0);
233 packet->SetPointerData(3, data);
234 auto converted_packet = converter.Convert(*packet);
235
236 std::vector<PointerData> result;
237 UnpackPointerPacket(result, std::move(converted_packet));
238
239 ASSERT_EQ(result.size(), (size_t)6);
240 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
241 ASSERT_EQ(result[0].synthesized, 0);
242
243 // A hover should be synthesized.
244 ASSERT_EQ(result[1].change, PointerData::Change::kHover);
245 ASSERT_EQ(result[1].synthesized, 1);
246 ASSERT_EQ(result[1].physical_delta_x, 3.0);
247 ASSERT_EQ(result[1].physical_delta_y, 0.0);
248 ASSERT_EQ(result[1].buttons, 0);
249
250 ASSERT_EQ(result[2].change, PointerData::Change::kDown);
251 ASSERT_EQ(result[2].pointer_identifier, 1);
252 ASSERT_EQ(result[2].synthesized, 0);
253 ASSERT_EQ(result[2].buttons, 1);
254
255 // A move should be synthesized.
256 ASSERT_EQ(result[3].change, PointerData::Change::kMove);
257 ASSERT_EQ(result[3].pointer_identifier, 1);
258 ASSERT_EQ(result[3].synthesized, 1);
259 ASSERT_EQ(result[3].physical_delta_x, 0.0);
260 ASSERT_EQ(result[3].physical_delta_y, 4.0);
261 ASSERT_EQ(result[3].buttons, 1);
262
263 ASSERT_EQ(result[4].change, PointerData::Change::kUp);
264 ASSERT_EQ(result[4].pointer_identifier, 1);
265 ASSERT_EQ(result[4].synthesized, 0);
266 ASSERT_EQ(result[4].buttons, 0);
267
268 ASSERT_EQ(result[5].change, PointerData::Change::kRemove);
269 ASSERT_EQ(result[5].synthesized, 0);
270}

◆ TEST() [633/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanUpdatePointerIdentifier   
)

Definition at line 272 of file pointer_data_packet_converter_unittests.cc.

272 {
273 TestDelegate delegate;
274 delegate.AddView(kImplicitViewId);
276 auto packet = std::make_unique<PointerDataPacket>(7);
279 packet->SetPointerData(0, data);
281 packet->SetPointerData(1, data);
283 packet->SetPointerData(2, data);
285 packet->SetPointerData(3, data);
287 packet->SetPointerData(4, data);
289 packet->SetPointerData(5, data);
291 0);
292 packet->SetPointerData(6, data);
293 auto converted_packet = converter.Convert(*packet);
294
295 std::vector<PointerData> result;
296 UnpackPointerPacket(result, std::move(converted_packet));
297
298 ASSERT_EQ(result.size(), (size_t)7);
299 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
300 ASSERT_EQ(result[0].synthesized, 0);
301
302 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
303 ASSERT_EQ(result[1].pointer_identifier, 1);
304 ASSERT_EQ(result[1].synthesized, 0);
305
306 ASSERT_EQ(result[2].change, PointerData::Change::kUp);
307 ASSERT_EQ(result[2].pointer_identifier, 1);
308 ASSERT_EQ(result[2].synthesized, 0);
309
310 // Pointer count increase to 2.
311 ASSERT_EQ(result[3].change, PointerData::Change::kDown);
312 ASSERT_EQ(result[3].pointer_identifier, 2);
313 ASSERT_EQ(result[3].synthesized, 0);
314
315 ASSERT_EQ(result[4].change, PointerData::Change::kMove);
316 ASSERT_EQ(result[4].pointer_identifier, 2);
317 ASSERT_EQ(result[4].synthesized, 0);
318 ASSERT_EQ(result[4].physical_delta_x, 3.0);
319 ASSERT_EQ(result[4].physical_delta_y, 0.0);
320
321 ASSERT_EQ(result[5].change, PointerData::Change::kUp);
322 ASSERT_EQ(result[5].pointer_identifier, 2);
323 ASSERT_EQ(result[5].synthesized, 0);
324
325 ASSERT_EQ(result[6].change, PointerData::Change::kRemove);
326 ASSERT_EQ(result[6].synthesized, 0);
327}

◆ TEST() [634/715]

flutter::testing::TEST ( PointerDataPacketConverterTest  ,
CanWorkWithDifferentDevices   
)

Definition at line 368 of file pointer_data_packet_converter_unittests.cc.

368 {
369 TestDelegate delegate;
370 delegate.AddView(kImplicitViewId);
372 auto packet = std::make_unique<PointerDataPacket>(12);
375 packet->SetPointerData(0, data);
377 packet->SetPointerData(1, data);
379 packet->SetPointerData(2, data);
381 packet->SetPointerData(3, data);
383 packet->SetPointerData(4, data);
385 packet->SetPointerData(5, data);
387 packet->SetPointerData(6, data);
389 packet->SetPointerData(7, data);
391 packet->SetPointerData(8, data);
393 packet->SetPointerData(9, data);
395 0);
396 packet->SetPointerData(10, data);
398 0);
399 packet->SetPointerData(11, data);
400 auto converted_packet = converter.Convert(*packet);
401
402 std::vector<PointerData> result;
403 UnpackPointerPacket(result, std::move(converted_packet));
404
405 ASSERT_EQ(result.size(), (size_t)12);
406 ASSERT_EQ(result[0].change, PointerData::Change::kAdd);
407 ASSERT_EQ(result[0].device, 0);
408 ASSERT_EQ(result[0].synthesized, 0);
409
410 ASSERT_EQ(result[1].change, PointerData::Change::kDown);
411 ASSERT_EQ(result[1].device, 0);
412 ASSERT_EQ(result[1].pointer_identifier, 1);
413 ASSERT_EQ(result[1].synthesized, 0);
414
415 ASSERT_EQ(result[2].change, PointerData::Change::kAdd);
416 ASSERT_EQ(result[2].device, 1);
417 ASSERT_EQ(result[2].synthesized, 0);
418
419 ASSERT_EQ(result[3].change, PointerData::Change::kDown);
420 ASSERT_EQ(result[3].device, 1);
421 ASSERT_EQ(result[3].pointer_identifier, 2);
422 ASSERT_EQ(result[3].synthesized, 0);
423
424 ASSERT_EQ(result[4].change, PointerData::Change::kUp);
425 ASSERT_EQ(result[4].device, 0);
426 ASSERT_EQ(result[4].pointer_identifier, 1);
427 ASSERT_EQ(result[4].synthesized, 0);
428
429 ASSERT_EQ(result[5].change, PointerData::Change::kDown);
430 ASSERT_EQ(result[5].device, 0);
431 ASSERT_EQ(result[5].pointer_identifier, 3);
432 ASSERT_EQ(result[5].synthesized, 0);
433
434 ASSERT_EQ(result[6].change, PointerData::Change::kMove);
435 ASSERT_EQ(result[6].device, 1);
436 ASSERT_EQ(result[6].pointer_identifier, 2);
437 ASSERT_EQ(result[6].synthesized, 0);
438 ASSERT_EQ(result[6].physical_delta_x, 0.0);
439 ASSERT_EQ(result[6].physical_delta_y, 4.0);
440
441 ASSERT_EQ(result[7].change, PointerData::Change::kMove);
442 ASSERT_EQ(result[7].device, 0);
443 ASSERT_EQ(result[7].pointer_identifier, 3);
444 ASSERT_EQ(result[7].synthesized, 0);
445 ASSERT_EQ(result[7].physical_delta_x, 3.0);
446 ASSERT_EQ(result[7].physical_delta_y, 0.0);
447
448 ASSERT_EQ(result[8].change, PointerData::Change::kUp);
449 ASSERT_EQ(result[8].device, 1);
450 ASSERT_EQ(result[8].pointer_identifier, 2);
451 ASSERT_EQ(result[8].synthesized, 0);
452
453 ASSERT_EQ(result[9].change, PointerData::Change::kUp);
454 ASSERT_EQ(result[9].device, 0);
455 ASSERT_EQ(result[9].pointer_identifier, 3);
456 ASSERT_EQ(result[9].synthesized, 0);
457
458 ASSERT_EQ(result[10].change, PointerData::Change::kRemove);
459 ASSERT_EQ(result[10].device, 0);
460 ASSERT_EQ(result[10].synthesized, 0);
461
462 ASSERT_EQ(result[11].change, PointerData::Change::kRemove);
463 ASSERT_EQ(result[11].device, 1);
464 ASSERT_EQ(result[11].synthesized, 0);
465}

◆ TEST() [635/715]

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

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);
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() [637/715]

flutter::testing::TEST ( RasterCache  ,
AccessThresholdOfZeroDisablesCachingForDisplayList   
)

Definition at line 146 of file raster_cache_unittests.cc.

146 {
147 size_t threshold = 0;
148 flutter::RasterCache cache(threshold);
149
151
152 auto display_list = GetSampleDisplayList();
153
154 MockCanvas dummy_canvas(1000, 1000);
156
157 LayerStateStack preroll_state_stack;
158 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
159 LayerStateStack paint_state_stack;
160 preroll_state_stack.set_delegate(&dummy_canvas);
161
162 FixedRefreshRateStopwatch raster_time;
165 preroll_state_stack, &cache, &raster_time, &ui_time);
166 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
167 paint_state_stack, &cache, &raster_time, &ui_time);
168 auto& preroll_context = preroll_context_holder.preroll_context;
169 auto& paint_context = paint_context_holder.paint_context;
170
171 cache.BeginFrame();
172
173 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
174 false);
176 display_list_item, preroll_context, paint_context, matrix));
177 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
178}
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() [638/715]

flutter::testing::TEST ( RasterCache  ,
ComputeDeviceRectBasedOnFractionalTranslation   
)

Definition at line 323 of file raster_cache_unittests.cc.

323 {
324 SkRect logical_rect = SkRect::MakeLTRB(0, 0, 300.2, 300.3);
325 SkMatrix ctm = SkMatrix::MakeAll(2.0, 0, 0, 0, 2.0, 0, 0, 0, 1);
326 auto result = RasterCacheUtil::GetDeviceBounds(logical_rect, ctm);
327 ASSERT_EQ(result, SkRect::MakeLTRB(0.0, 0.0, 600.4, 600.6));
328}

◆ TEST() [639/715]

flutter::testing::TEST ( RasterCache  ,
DeviceRectRoundOutForDisplayList   
)

Definition at line 333 of file raster_cache_unittests.cc.

333 {
334 size_t threshold = 1;
335 flutter::RasterCache cache(threshold);
336
337 SkRect logical_rect = SkRect::MakeLTRB(28, 0, 354.56731, 310.288);
338 DisplayListBuilder builder(logical_rect);
339 builder.DrawRect(logical_rect, DlPaint(DlColor::kRed()));
340 sk_sp<DisplayList> display_list = builder.Build();
341
342 SkMatrix ctm = SkMatrix::MakeAll(1.3312, 0, 233, 0, 1.3312, 206, 0, 0, 1);
344
345 MockCanvas canvas(1000, 1000);
346 canvas.SetTransform(ctm);
347
348 LayerStateStack preroll_state_stack;
349 preroll_state_stack.set_preroll_delegate(kGiantRect, ctm);
350 LayerStateStack paint_state_stack;
351 preroll_state_stack.set_delegate(&canvas);
352
353 FixedRefreshRateStopwatch raster_time;
356 preroll_state_stack, &cache, &raster_time, &ui_time);
357 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
358 paint_state_stack, &cache, &raster_time, &ui_time);
359 auto& preroll_context = preroll_context_holder.preroll_context;
360 auto& paint_context = paint_context_holder.paint_context;
361
362 cache.BeginFrame();
363 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
364 false);
365
367 display_list_item, preroll_context, paint_context, ctm));
368 ASSERT_FALSE(display_list_item.Draw(paint_context, &canvas, &paint));
369
370 cache.EndFrame();
371 cache.BeginFrame();
372
374 display_list_item, preroll_context, paint_context, ctm));
375 ASSERT_TRUE(display_list_item.Draw(paint_context, &canvas, &paint));
376
377 canvas.Translate(248, 0);
378 ASSERT_TRUE(cache.Draw(display_list_item.GetId().value(), canvas, &paint));
379 ASSERT_TRUE(display_list_item.Draw(paint_context, &canvas, &paint));
380}

◆ TEST() [640/715]

flutter::testing::TEST ( RasterCache  ,
DisplayListWithSingularMatrixIsNotCached   
)

Definition at line 500 of file raster_cache_unittests.cc.

500 {
501 size_t threshold = 2;
502 flutter::RasterCache cache(threshold);
503
504 SkMatrix matrices[] = {
505 SkMatrix::Scale(0, 1),
506 SkMatrix::Scale(1, 0),
507 SkMatrix::Skew(1, 1),
508 };
509 int matrix_count = sizeof(matrices) / sizeof(matrices[0]);
510
511 auto display_list = GetSampleDisplayList();
512
513 MockCanvas dummy_canvas(1000, 1000);
515
516 LayerStateStack preroll_state_stack;
517 preroll_state_stack.set_preroll_delegate(kGiantRect, SkMatrix::I());
518 LayerStateStack paint_state_stack;
519 preroll_state_stack.set_delegate(&dummy_canvas);
520
521 FixedRefreshRateStopwatch raster_time;
523 PrerollContextHolder preroll_context_holder = GetSamplePrerollContextHolder(
524 preroll_state_stack, &cache, &raster_time, &ui_time);
525 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
526 paint_state_stack, &cache, &raster_time, &ui_time);
527 auto& preroll_context = preroll_context_holder.preroll_context;
528 auto& paint_context = paint_context_holder.paint_context;
529
530 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
531 false);
532
533 for (int i = 0; i < 10; i++) {
534 cache.BeginFrame();
535
536 for (int j = 0; j < matrix_count; j++) {
537 display_list_item.set_matrix(matrices[j]);
539 display_list_item, preroll_context, paint_context, matrices[j]));
540 }
541
542 for (int j = 0; j < matrix_count; j++) {
543 dummy_canvas.SetTransform(matrices[j]);
544 ASSERT_FALSE(
545 display_list_item.Draw(paint_context, &dummy_canvas, &paint));
546 }
547
548 cache.EndFrame();
549 }
550}

◆ TEST() [641/715]

flutter::testing::TEST ( RasterCache  ,
EvictUnusedCacheEntries   
)

Definition at line 223 of file raster_cache_unittests.cc.

223 {
224 size_t threshold = 1;
225 flutter::RasterCache cache(threshold);
226
228
229 auto display_list_1 = GetSampleDisplayList();
230 auto display_list_2 = GetSampleDisplayList();
231
232 MockCanvas dummy_canvas(1000, 1000);
234
235 LayerStateStack preroll_state_stack;
236 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
237 LayerStateStack paint_state_stack;
238 preroll_state_stack.set_delegate(&dummy_canvas);
239
240 FixedRefreshRateStopwatch raster_time;
243 preroll_state_stack, &cache, &raster_time, &ui_time);
244 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
245 paint_state_stack, &cache, &raster_time, &ui_time);
246 auto& preroll_context = preroll_context_holder.preroll_context;
247 auto& paint_context = paint_context_holder.paint_context;
248
249 DisplayListRasterCacheItem display_list_item_1(display_list_1, SkPoint(),
250 true, false);
251 DisplayListRasterCacheItem display_list_item_2(display_list_2, SkPoint(),
252 true, false);
253
254 cache.BeginFrame();
255 RasterCacheItemPreroll(display_list_item_1, preroll_context, matrix);
256 RasterCacheItemPreroll(display_list_item_2, preroll_context, matrix);
257 cache.EvictUnusedCacheEntries();
258 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
259 ASSERT_FALSE(
260 RasterCacheItemTryToRasterCache(display_list_item_1, paint_context));
261 ASSERT_FALSE(
262 RasterCacheItemTryToRasterCache(display_list_item_2, paint_context));
263 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
264 ASSERT_FALSE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
265 ASSERT_FALSE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
266 cache.EndFrame();
267
268 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
269 ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
270 ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
271
272 cache.BeginFrame();
273 RasterCacheItemPreroll(display_list_item_1, preroll_context, matrix);
274 RasterCacheItemPreroll(display_list_item_2, preroll_context, matrix);
275 cache.EvictUnusedCacheEntries();
276 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
277 ASSERT_TRUE(
278 RasterCacheItemTryToRasterCache(display_list_item_1, paint_context));
279 ASSERT_TRUE(
280 RasterCacheItemTryToRasterCache(display_list_item_2, paint_context));
281 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 51248u);
282 ASSERT_TRUE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
283 ASSERT_TRUE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
284 cache.EndFrame();
285
286 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 51248u);
287 ASSERT_EQ(cache.picture_metrics().total_count(), 2u);
288 ASSERT_EQ(cache.picture_metrics().total_bytes(), 51248u);
289
290 cache.BeginFrame();
291 RasterCacheItemPreroll(display_list_item_1, preroll_context, matrix);
292 cache.EvictUnusedCacheEntries();
293 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 25624u);
294 ASSERT_TRUE(
295 RasterCacheItemTryToRasterCache(display_list_item_1, paint_context));
296 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 25624u);
297 ASSERT_TRUE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
298 cache.EndFrame();
299
300 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 25624u);
301 ASSERT_EQ(cache.picture_metrics().total_count(), 1u);
302 ASSERT_EQ(cache.picture_metrics().total_bytes(), 25624u);
303
304 cache.BeginFrame();
305 cache.EvictUnusedCacheEntries();
306 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
307 cache.EndFrame();
308
309 ASSERT_EQ(cache.EstimatePictureCacheByteSize(), 0u);
310 ASSERT_EQ(cache.picture_metrics().total_count(), 0u);
311 ASSERT_EQ(cache.picture_metrics().total_bytes(), 0u);
312
313 cache.BeginFrame();
314 ASSERT_FALSE(
315 cache.Draw(display_list_item_1.GetId().value(), dummy_canvas, &paint));
316 ASSERT_FALSE(display_list_item_1.Draw(paint_context, &dummy_canvas, &paint));
317 ASSERT_FALSE(
318 cache.Draw(display_list_item_2.GetId().value(), dummy_canvas, &paint));
319 ASSERT_FALSE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
320 cache.EndFrame();
321}

◆ TEST() [642/715]

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

flutter::testing::TEST ( RasterCache  ,
NaiveComplexityScoringDisplayList   
)

Definition at line 426 of file raster_cache_unittests.cc.

426 {
428 DisplayListNaiveComplexityCalculator::GetInstance();
429
430 size_t threshold = 1;
431 flutter::RasterCache cache(threshold);
432
434
435 // Five raster ops will not be cached
436 auto display_list = GetSampleDisplayList(5);
437 unsigned int complexity_score = calculator->Compute(display_list.get());
438
439 ASSERT_EQ(complexity_score, 5u);
440 ASSERT_EQ(display_list->op_count(), 5u);
441 ASSERT_FALSE(calculator->ShouldBeCached(complexity_score));
442
443 MockCanvas dummy_canvas(1000, 1000);
445
446 LayerStateStack preroll_state_stack;
447 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
448 LayerStateStack paint_state_stack;
449 preroll_state_stack.set_delegate(&dummy_canvas);
450
451 FixedRefreshRateStopwatch raster_time;
454 preroll_state_stack, &cache, &raster_time, &ui_time);
455 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
456 paint_state_stack, &cache, &raster_time, &ui_time);
457 auto& preroll_context = preroll_context_holder.preroll_context;
458 auto& paint_context = paint_context_holder.paint_context;
459
460 cache.BeginFrame();
461
462 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), false,
463 false);
464
466 display_list_item, preroll_context, paint_context, matrix));
467 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
468
469 cache.EndFrame();
470 cache.BeginFrame();
471
473 display_list_item, preroll_context, paint_context, matrix));
474 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
475
476 // Six raster ops should be cached
477 display_list = GetSampleDisplayList(6);
478 complexity_score = calculator->Compute(display_list.get());
479
480 ASSERT_EQ(complexity_score, 6u);
481 ASSERT_EQ(display_list->op_count(), 6u);
482 ASSERT_TRUE(calculator->ShouldBeCached(complexity_score));
483
484 DisplayListRasterCacheItem display_list_item_2 =
485 DisplayListRasterCacheItem(display_list, SkPoint(), false, false);
486 cache.BeginFrame();
487
489 display_list_item_2, preroll_context, paint_context, matrix));
490 ASSERT_FALSE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
491
492 cache.EndFrame();
493 cache.BeginFrame();
494
496 display_list_item_2, preroll_context, paint_context, matrix));
497 ASSERT_TRUE(display_list_item_2.Draw(paint_context, &dummy_canvas, &paint));
498}
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() [644/715]

flutter::testing::TEST ( RasterCache  ,
NestedOpCountMetricUsedForDisplayList   
)

Definition at line 382 of file raster_cache_unittests.cc.

382 {
383 size_t threshold = 1;
384 flutter::RasterCache cache(threshold);
385
387
388 auto display_list = GetSampleNestedDisplayList();
389 ASSERT_EQ(display_list->op_count(), 1u);
390 ASSERT_EQ(display_list->op_count(true), 36u);
391
392 MockCanvas dummy_canvas(1000, 1000);
394
395 LayerStateStack preroll_state_stack;
396 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
397 LayerStateStack paint_state_stack;
398 preroll_state_stack.set_delegate(&dummy_canvas);
399
400 FixedRefreshRateStopwatch raster_time;
403 preroll_state_stack, &cache, &raster_time, &ui_time);
404 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
405 paint_state_stack, &cache, &raster_time, &ui_time);
406 auto& preroll_context = preroll_context_holder.preroll_context;
407 auto& paint_context = paint_context_holder.paint_context;
408
409 cache.BeginFrame();
410
411 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), false,
412 false);
413
415 display_list_item, preroll_context, paint_context, matrix));
416 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
417
418 cache.EndFrame();
419 cache.BeginFrame();
420
422 display_list_item, preroll_context, paint_context, matrix));
423 ASSERT_TRUE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
424}

◆ TEST() [645/715]

flutter::testing::TEST ( RasterCache  ,
PictureCacheLimitPerFrameIsRespectedWhenZeroForDisplayList   
)

Definition at line 180 of file raster_cache_unittests.cc.

180 {
181 size_t picture_cache_limit_per_frame = 0;
182 flutter::RasterCache cache(3, picture_cache_limit_per_frame);
183
185
186 auto display_list = GetSampleDisplayList();
187
188 MockCanvas dummy_canvas(1000, 1000);
190
191 LayerStateStack preroll_state_stack;
192 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
193 LayerStateStack paint_state_stack;
194 preroll_state_stack.set_delegate(&dummy_canvas);
195
196 FixedRefreshRateStopwatch raster_time;
199 preroll_state_stack, &cache, &raster_time, &ui_time);
200 PaintContextHolder paint_context_holder = GetSamplePaintContextHolder(
201 paint_state_stack, &cache, &raster_time, &ui_time);
202 auto& preroll_context = preroll_context_holder.preroll_context;
203 auto& paint_context = paint_context_holder.paint_context;
204
205 cache.BeginFrame();
206
207 DisplayListRasterCacheItem display_list_item(display_list, SkPoint(), true,
208 false);
209 // 1st access.
211 display_list_item, preroll_context, paint_context, matrix));
212 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
213 // 2nd access.
215 display_list_item, preroll_context, paint_context, matrix));
216 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
217 // the picture_cache_limit_per_frame = 0, so don't cache it
219 display_list_item, preroll_context, paint_context, matrix));
220 ASSERT_FALSE(display_list_item.Draw(paint_context, &dummy_canvas, &paint));
221}

◆ TEST() [646/715]

flutter::testing::TEST ( RasterCache  ,
PrepareLayerTransform   
)

Definition at line 552 of file raster_cache_unittests.cc.

552 {
553 SkRect child_bounds = SkRect::MakeLTRB(10, 10, 50, 50);
554 SkPath child_path = SkPath().addOval(child_bounds);
555 auto child_layer = MockLayer::Make(child_path);
556 auto blur_filter =
557 std::make_shared<DlBlurImageFilter>(5, 5, DlTileMode::kClamp);
558 auto blur_layer = std::make_shared<ImageFilterLayer>(blur_filter);
560 auto transform_layer = std::make_shared<TransformLayer>(matrix);
561 SkMatrix cache_matrix = SkMatrix::Translate(-20, -20);
562 cache_matrix.preConcat(matrix);
563 child_layer->set_expected_paint_matrix(cache_matrix);
564
565 blur_layer->Add(child_layer);
566 transform_layer->Add(blur_layer);
567
568 size_t threshold = 2;
569 MockRasterCache cache(threshold);
570 MockCanvas dummy_canvas(1000, 1000);
571
572 LayerStateStack preroll_state_stack;
573 preroll_state_stack.set_preroll_delegate(kGiantRect, matrix);
574 LayerStateStack paint_state_stack;
575 preroll_state_stack.set_delegate(&dummy_canvas);
576
577 FixedRefreshRateStopwatch raster_time;
579 std::vector<RasterCacheItem*> cache_items;
580
581 cache.BeginFrame();
582
583 auto preroll_holder = GetSamplePrerollContextHolder(
584 preroll_state_stack, &cache, &raster_time, &ui_time);
585 preroll_holder.preroll_context.raster_cached_entries = &cache_items;
586 transform_layer->Preroll(&preroll_holder.preroll_context);
587
588 auto paint_holder = GetSamplePaintContextHolder(paint_state_stack, &cache,
589 &raster_time, &ui_time);
590
591 cache.EvictUnusedCacheEntries();
592 LayerTree::TryToRasterCache(
593 *preroll_holder.preroll_context.raster_cached_entries,
594 &paint_holder.paint_context);
595
596 // Condition tested inside MockLayer::Paint against expected paint matrix.
597}
SkPath & addOval(const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1106
A RasterCache implementation that simulates the act of rendering a Layer or DisplayList without the o...

◆ TEST() [647/715]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeyHashFunction   
)

Definition at line 599 of file raster_cache_unittests.cc.

599 {
601 auto hash_function = map.hash_function();
603 uint64_t id = 5;
604 RasterCacheKey layer_key(id, RasterCacheKeyType::kLayer, matrix);
605 RasterCacheKey display_list_key(id, RasterCacheKeyType::kDisplayList, matrix);
606 RasterCacheKey layer_children_key(id, RasterCacheKeyType::kLayerChildren,
607 matrix);
608
609 auto layer_cache_key_id = RasterCacheKeyID(id, RasterCacheKeyType::kLayer);
610 auto layer_hash_code = hash_function(layer_key);
611 ASSERT_EQ(layer_hash_code, layer_cache_key_id.GetHash());
612
613 auto display_list_cache_key_id =
614 RasterCacheKeyID(id, RasterCacheKeyType::kDisplayList);
615 auto display_list_hash_code = hash_function(display_list_key);
616 ASSERT_EQ(display_list_hash_code, display_list_cache_key_id.GetHash());
617
618 auto layer_children_cache_key_id =
619 RasterCacheKeyID(id, RasterCacheKeyType::kLayerChildren);
620 auto layer_children_hash_code = hash_function(layer_children_key);
621 ASSERT_EQ(layer_children_hash_code, layer_children_cache_key_id.GetHash());
622}
std::unordered_map< RasterCacheKey, Value, Hash, Equal > Map

◆ TEST() [648/715]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeyIDEqual   
)

Definition at line 696 of file raster_cache_unittests.cc.

696 {
697 RasterCacheKeyID first = RasterCacheKeyID(1, RasterCacheKeyType::kLayer);
698 RasterCacheKeyID second = RasterCacheKeyID(2, RasterCacheKeyType::kLayer);
699 RasterCacheKeyID third =
700 RasterCacheKeyID(1, RasterCacheKeyType::kLayerChildren);
701
702 ASSERT_NE(first, second);
703 ASSERT_NE(first, third);
704 ASSERT_NE(second, third);
705
706 RasterCacheKeyID fourth =
707 RasterCacheKeyID({first, second}, RasterCacheKeyType::kLayer);
708 RasterCacheKeyID fifth =
709 RasterCacheKeyID({first, second}, RasterCacheKeyType::kLayerChildren);
710 RasterCacheKeyID sixth =
711 RasterCacheKeyID({second, first}, RasterCacheKeyType::kLayerChildren);
712 ASSERT_NE(fourth, fifth);
713 ASSERT_NE(fifth, sixth);
714}

◆ TEST() [649/715]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeyIDHashCode   
)

Definition at line 716 of file raster_cache_unittests.cc.

716 {
717 uint64_t foo = 1;
718 uint64_t bar = 2;
719 RasterCacheKeyID first = RasterCacheKeyID(foo, RasterCacheKeyType::kLayer);
720 RasterCacheKeyID second = RasterCacheKeyID(bar, RasterCacheKeyType::kLayer);
721 std::size_t first_hash = first.GetHash();
722 std::size_t second_hash = second.GetHash();
723
724 ASSERT_EQ(first_hash, fml::HashCombine(foo, RasterCacheKeyType::kLayer));
725 ASSERT_EQ(second_hash, fml::HashCombine(bar, RasterCacheKeyType::kLayer));
726
727 RasterCacheKeyID third =
728 RasterCacheKeyID({first, second}, RasterCacheKeyType::kLayerChildren);
729 RasterCacheKeyID fourth =
730 RasterCacheKeyID({second, first}, RasterCacheKeyType::kLayerChildren);
731 std::size_t third_hash = third.GetHash();
732 std::size_t fourth_hash = fourth.GetHash();
733
734 ASSERT_EQ(third_hash, fml::HashCombine(RasterCacheKeyID::kDefaultUniqueID,
735 RasterCacheKeyType::kLayerChildren,
736 first.GetHash(), second.GetHash()));
737 ASSERT_EQ(fourth_hash, fml::HashCombine(RasterCacheKeyID::kDefaultUniqueID,
738 RasterCacheKeyType::kLayerChildren,
739 second.GetHash(), first.GetHash()));
740
741 // Verify that the cached hash code is correct.
742 ASSERT_EQ(first_hash, first.GetHash());
743 ASSERT_EQ(second_hash, second.GetHash());
744 ASSERT_EQ(third_hash, third.GetHash());
745 ASSERT_EQ(fourth_hash, fourth.GetHash());
746}
std::size_t GetHash() const
constexpr std::size_t HashCombine()
Definition: hash_combine.h:25

◆ TEST() [650/715]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeySameID   
)

Definition at line 624 of file raster_cache_unittests.cc.

624 {
627 uint64_t id = 5;
628 RasterCacheKey layer_key(id, RasterCacheKeyType::kLayer, matrix);
629 RasterCacheKey display_list_key(id, RasterCacheKeyType::kDisplayList, matrix);
630 RasterCacheKey layer_children_key(id, RasterCacheKeyType::kLayerChildren,
631 matrix);
632 map[layer_key] = 100;
633 map[display_list_key] = 300;
634 map[layer_children_key] = 400;
635
636 ASSERT_EQ(map[layer_key], 100);
637 ASSERT_EQ(map[display_list_key], 300);
638 ASSERT_EQ(map[layer_children_key], 400);
639}

◆ TEST() [651/715]

flutter::testing::TEST ( RasterCache  ,
RasterCacheKeySameType   
)

Definition at line 641 of file raster_cache_unittests.cc.

641 {
644
645 RasterCacheKeyType type = RasterCacheKeyType::kLayer;
646 RasterCacheKey layer_first_key(5, type, matrix);
647 RasterCacheKey layer_second_key(10, type, matrix);
648 RasterCacheKey layer_third_key(15, type, matrix);
649 map[layer_first_key] = 50;
650 map[layer_second_key] = 100;
651 map[layer_third_key] = 150;
652 ASSERT_EQ(map[layer_first_key], 50);
653 ASSERT_EQ(map[layer_second_key], 100);
654 ASSERT_EQ(map[layer_third_key], 150);
655
656 type = RasterCacheKeyType::kDisplayList;
657 RasterCacheKey picture_first_key(20, type, matrix);
658 RasterCacheKey picture_second_key(25, type, matrix);
659 RasterCacheKey picture_third_key(30, type, matrix);
660 map[picture_first_key] = 200;
661 map[picture_second_key] = 250;
662 map[picture_third_key] = 300;
663 ASSERT_EQ(map[picture_first_key], 200);
664 ASSERT_EQ(map[picture_second_key], 250);
665 ASSERT_EQ(map[picture_third_key], 300);
666
667 type = RasterCacheKeyType::kDisplayList;
668 RasterCacheKey display_list_first_key(35, type, matrix);
669 RasterCacheKey display_list_second_key(40, type, matrix);
670 RasterCacheKey display_list_third_key(45, type, matrix);
671 map[display_list_first_key] = 350;
672 map[display_list_second_key] = 400;
673 map[display_list_third_key] = 450;
674 ASSERT_EQ(map[display_list_first_key], 350);
675 ASSERT_EQ(map[display_list_second_key], 400);
676 ASSERT_EQ(map[display_list_third_key], 450);
677
678 type = RasterCacheKeyType::kLayerChildren;
679 RasterCacheKeyID foo = RasterCacheKeyID(10, RasterCacheKeyType::kLayer);
680 RasterCacheKeyID bar = RasterCacheKeyID(20, RasterCacheKeyType::kLayer);
681 RasterCacheKeyID baz = RasterCacheKeyID(30, RasterCacheKeyType::kLayer);
682 RasterCacheKey layer_children_first_key(
683 RasterCacheKeyID({foo, bar, baz}, type), matrix);
684 RasterCacheKey layer_children_second_key(
685 RasterCacheKeyID({foo, baz, bar}, type), matrix);
686 RasterCacheKey layer_children_third_key(
687 RasterCacheKeyID({baz, bar, foo}, type), matrix);
688 map[layer_children_first_key] = 100;
689 map[layer_children_second_key] = 200;
690 map[layer_children_third_key] = 300;
691 ASSERT_EQ(map[layer_children_first_key], 100);
692 ASSERT_EQ(map[layer_children_second_key], 200);
693 ASSERT_EQ(map[layer_children_third_key], 300);
694}

◆ TEST() [652/715]

flutter::testing::TEST ( RasterCache  ,
SimpleInitialization   
)

Definition at line 29 of file raster_cache_unittests.cc.

29 {
31 ASSERT_TRUE(true);
32}

◆ TEST() [653/715]

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

flutter::testing::TEST ( RasterCacheUtilsTest  ,
SkM44IntegralTransCTM   
)

Definition at line 974 of file raster_cache_unittests.cc.

974 {
975#define EXPECT_EQ_WITH_TRANSLATE(test, expected, tx, ty, label) \
976 do { \
977 EXPECT_EQ(test.rc(0, 0), expected.rc(0, 0)) << label; \
978 EXPECT_EQ(test.rc(0, 1), expected.rc(0, 1)) << label; \
979 EXPECT_EQ(test.rc(0, 2), expected.rc(0, 2)) << label; \
980 EXPECT_EQ(test.rc(0, 3), tx) << label; \
981 EXPECT_EQ(test.rc(1, 0), expected.rc(1, 0)) << label; \
982 EXPECT_EQ(test.rc(1, 1), expected.rc(1, 1)) << label; \
983 EXPECT_EQ(test.rc(1, 2), expected.rc(1, 2)) << label; \
984 EXPECT_EQ(test.rc(1, 3), ty) << label; \
985 EXPECT_EQ(test.rc(2, 0), expected.rc(2, 0)) << label; \
986 EXPECT_EQ(test.rc(2, 1), expected.rc(2, 1)) << label; \
987 EXPECT_EQ(test.rc(2, 2), expected.rc(2, 2)) << label; \
988 EXPECT_EQ(test.rc(2, 3), expected.rc(2, 3)) << label; \
989 EXPECT_EQ(test.rc(3, 0), expected.rc(3, 0)) << label; \
990 EXPECT_EQ(test.rc(3, 1), expected.rc(3, 1)) << label; \
991 EXPECT_EQ(test.rc(3, 2), expected.rc(3, 2)) << label; \
992 EXPECT_EQ(test.rc(3, 3), expected.rc(3, 3)) << label; \
993 } while (0)
994
995#define EXPECT_NON_INTEGER_TRANSLATION(matrix) \
996 EXPECT_TRUE(SkScalarFraction(matrix.rc(0, 3)) != 0.0f || \
997 SkScalarFraction(matrix.rc(1, 3)) != 0.0f)
998
999 for (int r = 0; r < 4; r++) {
1000 for (int c = 0; c < 4; c++) {
1001 bool snaps;
1002 switch (r) {
1003 case 0: // X equation
1004 if (c == 3) {
1005 continue; // TranslateX, the value we are testing, skip
1006 }
1007 snaps = (c == 0); // X Scale value yes, Skew by Y or Z no
1008 break;
1009 case 1: // Y equation
1010 if (c == 3) {
1011 continue; // TranslateY, the value we are testing, skip
1012 }
1013 snaps = (c == 1); // Y Scale value yes, Skew by X or Z no
1014 break;
1015 case 2: // Z equation, ignored, will snap
1016 snaps = true;
1017 break;
1018 case 3: // W equation, modifications prevent snapping
1019 snaps = false;
1020 break;
1021 default:
1023 }
1024 auto label = std::to_string(r) + ", " + std::to_string(c);
1025 SkM44 matrix = SkM44::Translate(10.7f, 12.1f);
1027 matrix.setRC(r, c, 0.5f);
1028 if (snaps) {
1029 SkM44 compute;
1030 SkM44 get = RasterCacheUtil::GetIntegralTransCTM(matrix);
1031 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute))
1032 << label;
1033 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 11.0f, 12.0f, label);
1034 EXPECT_EQ(get, compute) << label;
1035 } else {
1036 SkM44 compute;
1037 SkM44 get = RasterCacheUtil::GetIntegralTransCTM(matrix);
1038 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute))
1039 << label;
1040 EXPECT_EQ(get, matrix) << label;
1041 }
1042 }
1043 }
1044#undef EXPECT_NON_INTEGER_TRANSLATION
1045#undef EXPECT_EQ_WITH_TRANSLATE
1046}
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() [655/715]

flutter::testing::TEST ( RasterCacheUtilsTest  ,
SkMatrixIntegralTransCTM   
)

Definition at line 773 of file raster_cache_unittests.cc.

773 {
774#define EXPECT_EQ_WITH_TRANSLATE(test, expected, expected_tx, expected_ty) \
775 do { \
776 EXPECT_EQ(test[SkMatrix::kMScaleX], expected[SkMatrix::kMScaleX]); \
777 EXPECT_EQ(test[SkMatrix::kMSkewX], expected[SkMatrix::kMSkewX]); \
778 EXPECT_EQ(test[SkMatrix::kMScaleY], expected[SkMatrix::kMScaleY]); \
779 EXPECT_EQ(test[SkMatrix::kMSkewY], expected[SkMatrix::kMSkewY]); \
780 EXPECT_EQ(test[SkMatrix::kMSkewX], expected[SkMatrix::kMSkewX]); \
781 EXPECT_EQ(test[SkMatrix::kMPersp0], expected[SkMatrix::kMPersp0]); \
782 EXPECT_EQ(test[SkMatrix::kMPersp1], expected[SkMatrix::kMPersp1]); \
783 EXPECT_EQ(test[SkMatrix::kMPersp2], expected[SkMatrix::kMPersp2]); \
784 EXPECT_EQ(test[SkMatrix::kMTransX], expected_tx); \
785 EXPECT_EQ(test[SkMatrix::kMTransY], expected_ty); \
786 } while (0)
787
788#define EXPECT_NON_INTEGER_TRANSLATION(matrix) \
789 EXPECT_TRUE(SkScalarFraction(matrix[SkMatrix::kMTransX]) != 0.0f || \
790 SkScalarFraction(matrix[SkMatrix::kMTransY]) != 0.0f)
791
792 {
793 // Identity
795 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
796 SkMatrix compute;
797 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
798 EXPECT_EQ(get, matrix);
799 }
800 {
801 // Integer translate
802 SkMatrix matrix = SkMatrix::Translate(10.0f, 12.0f);
803 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
804 SkMatrix compute;
805 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
806 EXPECT_EQ(get, matrix);
807 }
808 {
809 // Fractional x translate
810 SkMatrix matrix = SkMatrix::Translate(10.2f, 12.0f);
812 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
813 SkMatrix compute;
814 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
815 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 10.0f, 12.0f);
816 EXPECT_EQ(get, compute);
817 }
818 {
819 // Fractional y translate
820 SkMatrix matrix = SkMatrix::Translate(10.0f, 12.3f);
822 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
823 SkMatrix compute;
824 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
825 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 10.0f, 12.0f);
826 EXPECT_EQ(get, compute);
827 }
828 {
829 // Fractional x & y translate
830 SkMatrix matrix = SkMatrix::Translate(10.7f, 12.3f);
832 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
833 SkMatrix compute;
834 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
835 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 11.0f, 12.0f);
836 EXPECT_EQ(get, compute);
837 }
838 {
839 // Scale
840 SkMatrix matrix = SkMatrix::Scale(2.0f, 3.0f);
841 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
842 SkMatrix compute;
843 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
844 EXPECT_EQ(get, matrix);
845 }
846 {
847 // Scale, Integer translate
848 SkMatrix matrix = SkMatrix::Scale(2.0f, 3.0f);
849 matrix.preTranslate(10.0f, 12.0f);
850 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
851 SkMatrix compute;
852 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
853 EXPECT_EQ(get, matrix);
854 }
855 {
856 // Scale, Fractional translate
857 SkMatrix matrix = SkMatrix::Scale(2.0f, 3.0f);
858 matrix.preTranslate(10.7f, 12.1f);
860 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
861 SkMatrix compute;
862 EXPECT_TRUE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
863 EXPECT_EQ_WITH_TRANSLATE(get, matrix, 21.0f, 36.0f);
864 EXPECT_EQ(get, compute);
865 }
866 {
867 // Skew
868 SkMatrix matrix = SkMatrix::Skew(0.5f, 0.1f);
869 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
870 SkMatrix compute;
871 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
872 EXPECT_EQ(get, matrix);
873 }
874 {
875 // Skew, Fractional translate - should be NOP
876 SkMatrix matrix = SkMatrix::Skew(0.5f, 0.1f);
877 matrix.preTranslate(10.7f, 12.1f);
879 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
880 SkMatrix compute;
881 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
882 EXPECT_EQ(get, matrix);
883 }
884 {
885 // Rotate
887 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
888 SkMatrix compute;
889 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
890 EXPECT_EQ(get, matrix);
891 }
892 {
893 // Rotate, Fractional Translate - should be NOP
895 matrix.preTranslate(10.7f, 12.1f);
897 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
898 SkMatrix compute;
899 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
900 EXPECT_EQ(get, matrix);
901 }
902 {
903 // Perspective x
905 matrix.setPerspX(0.1);
906 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
907 SkMatrix compute;
908 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
909 EXPECT_EQ(get, matrix);
910 }
911 {
912 // Perspective x, Fractional Translate - should be NOP
914 matrix.setPerspX(0.1);
915 matrix.preTranslate(10.7f, 12.1f);
917 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
918 SkMatrix compute;
919 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
920 EXPECT_EQ(get, matrix);
921 }
922 {
923 // Perspective y
925 matrix.setPerspY(0.1);
926 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
927 SkMatrix compute;
928 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
929 EXPECT_EQ(get, matrix);
930 }
931 {
932 // Perspective y, Fractional Translate - should be NOP
934 matrix.setPerspY(0.1);
935 matrix.preTranslate(10.7f, 12.1f);
937 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
938 SkMatrix compute;
939 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
940 EXPECT_EQ(get, matrix);
941 }
942 {
943 // Perspective weight
944 // clang-format off
946 1.0f, 0.0f, 0.0f,
947 0.0f, 1.0f, 0.0f,
948 0.0f, 0.0f, 0.9f);
949 // clang-format on
950 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
951 SkMatrix compute;
952 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
953 EXPECT_EQ(get, matrix);
954 }
955 {
956 // Perspective weight, Fractional Translate - should be NOP
957 // clang-format off
959 1.0f, 0.0f, 0.0f,
960 0.0f, 1.0f, 0.0f,
961 0.0f, 0.0f, 0.9f);
962 // clang-format on
963 matrix.preTranslate(10.7f, 12.1f);
965 SkMatrix get = RasterCacheUtil::GetIntegralTransCTM(matrix);
966 SkMatrix compute;
967 EXPECT_FALSE(RasterCacheUtil::ComputeIntegralTransCTM(matrix, &compute));
968 EXPECT_EQ(get, matrix);
969 }
970#undef EXPECT_NON_INTEGER_TRANSLATION
971#undef EXPECT_EQ_WITH_TRANSLATE
972}

◆ TEST() [656/715]

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

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}
static SkRect MakeIWH(int w, int h)
Definition: SkRect.h:623

◆ TEST() [658/715]

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}
static float next(float f)

◆ TEST() [659/715]

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

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

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

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

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

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}
static const int32_t kMaxId

◆ TEST() [665/715]

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

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

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

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

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

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

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

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

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

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

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

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

flutter::testing::TEST ( SwitchesTest  ,
EnableAsserts   
)

Definition at line 109 of file switches_unittests.cc.

109 {
111 {"command", "--dart-flags=--enable-asserts"});
113 ASSERT_EQ(settings.dart_flags.size(), 1ul);
114 EXPECT_EQ(settings.dart_flags[0], "--enable-asserts");
115}
Settings SettingsFromCommandLine(const fml::CommandLine &command_line)
Definition: switches.cc:228
CommandLine CommandLineFromInitializerList(std::initializer_list< StringType > argv)
Definition: command_line.h:254

◆ TEST() [678/715]

flutter::testing::TEST ( SwitchesTest  ,
EnableEmbedderAPI   
)

Definition at line 72 of file switches_unittests.cc.

72 {
73 {
74 // enable
76 {"command", "--enable-embedder-api"});
78 EXPECT_EQ(settings.enable_embedder_api, true);
79 }
80 {
81 // default
82 fml::CommandLine command_line =
84 Settings settings = SettingsFromCommandLine(command_line);
85 EXPECT_EQ(settings.enable_embedder_api, false);
86 }
87}

◆ TEST() [679/715]

flutter::testing::TEST ( SwitchesTest  ,
NoEnableImpeller   
)

Definition at line 89 of file switches_unittests.cc.

89 {
90 {
91 // enable
92 fml::CommandLine command_line =
93 fml::CommandLineFromInitializerList({"command", "--enable-impeller"});
94 EXPECT_TRUE(command_line.HasOption("enable-impeller"));
96 EXPECT_EQ(settings.enable_impeller, true);
97 }
98 {
99 // disable
101 {"command", "--enable-impeller=false"});
102 EXPECT_TRUE(command_line.HasOption("enable-impeller"));
103 Settings settings = SettingsFromCommandLine(command_line);
104 EXPECT_EQ(settings.enable_impeller, false);
105 }
106}
bool HasOption(std::string_view name, size_t *index=nullptr) const
Definition: command_line.cc:40

◆ TEST() [680/715]

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"});
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() [681/715]

flutter::testing::TEST ( SwitchesTest  ,
SkiaTraceAllowlistFlag   
)

Definition at line 19 of file switches_unittests.cc.

19 {
20 fml::CommandLine 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() [682/715]

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"));
59 EXPECT_EQ(settings.trace_to_file, "trace.binpb");
60}

◆ TEST() [683/715]

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

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)
Definition: system_utils.cc:45

◆ TEST() [685/715]

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

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)
Definition: system_utils.cc:71

◆ TEST() [687/715]

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

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

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

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

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

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

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

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

Definition at line 101 of file system_utils_unittests.cc.

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

◆ TEST() [695/715]

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:1552

◆ TEST() [696/715]

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

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

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

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
Definition: create.py:1
int_closure destroy

◆ TEST() [700/715]

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

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

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

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

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

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

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

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

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
Definition: message_loop.cc:56

◆ TEST() [709/715]

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

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

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

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

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

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

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

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;
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/925]

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;
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/925]

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:1387

◆ TEST_F() [4/925]

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;
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/925]

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
Definition: dl_builder.cc:549
void ClipRect(const SkRect &rect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
Definition: dl_builder.cc:934
@ kHardEdge
Definition: layer.h:53

◆ TEST_F() [6/925]

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

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

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

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;
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/925]

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}
static constexpr SkRect kEmptyRect
Definition: mock_canvas.h:30

◆ TEST_F() [11/925]

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

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

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

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),
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/925]

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

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),
487
488 MockLayerTree l1(SkISize::Make(100, 100));
489
490 auto clip = std::make_shared<ClipRectLayer>(SkRect::MakeLTRB(60, 60, 80, 80),
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/925]

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
Definition: SkMatrix.cpp:1141
bool intersect(const SkRect &r)
Definition: SkRect.cpp:114

◆ TEST_F() [18/925]

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

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,
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
@ kAntiAliasWithSaveLayer
Definition: layer.h:53
Definition: SkSize.h:52

◆ TEST_F() [20/925]

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}
void ClipPath(const SkPath &path, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
Definition: dl_builder.cc:999

◆ TEST_F() [21/925]

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,
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
Definition: dl_builder.cc:919
static void Draw(SkCanvas *canvas, const SkRect &rect)

◆ TEST_F() [22/925]

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}
@ kAntiAlias
Definition: layer.h:53

◆ TEST_F() [23/925]

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

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

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

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)
Definition: SkCanvas.cpp:1349

◆ TEST_F() [27/925]

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

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

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

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

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

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:1824
const FlutterBackingStore * backing_store
Definition: embedder.h:1828

◆ TEST_F() [33/925]

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

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

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

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

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

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:1770
FlutterPoint offset
Definition: embedder.h:1835

◆ TEST_F() [39/925]

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

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

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

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

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

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

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

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

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

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

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

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

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(),
357 // render count < 2 don't cache it
358 EXPECT_EQ(cacheable_container_layer2->raster_cache_item()->cache_state(),
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(),
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
Definition: dl_builder.cc:893

◆ TEST_F() [52/925]

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

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

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

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

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

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

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

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

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

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(), //
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}
fml::RefPtr< fml::TaskRunner > GetCurrentTaskRunner()

◆ TEST_F() [62/925]

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"},
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:3019
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
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)
#define CREATE_NATIVE_ENTRY(native_entry)

◆ TEST_F() [63/925]

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", {},
269 ASSERT_TRUE(isolate);
270 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
271 Wait();
272}

◆ TEST_F() [64/925]

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(), //
167 );
168 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
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}

◆ TEST_F() [65/925]

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

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", {},
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() [67/925]

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

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

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

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

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(), //
227 );
228 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
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)
if(end==-1)
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
Definition: dart_error.cc:33

◆ TEST_F() [72/925]

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(), //
192 );
193 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
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() [73/925]

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(), //
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() [74/925]

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(), //
135 );
136 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
138 ASSERT_TRUE(isolate);
139 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
140}

◆ TEST_F() [75/925]

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(), //
151 );
152 auto isolate =
153 RunDartCodeInIsolate(vm_ref, settings, task_runners, "thisShouldNotExist",
155 ASSERT_FALSE(isolate);
156}

◆ TEST_F() [76/925]

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(), //
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() [77/925]

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(), //
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() [78/925]

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

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

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

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

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

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

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(), //
471 );
472 {
473 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
475 ASSERT_TRUE(isolate);
476 ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
477 }
478 ASSERT_EQ(create_callback_count, 1u);
479}

◆ TEST_F() [85/925]

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

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

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

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

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

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

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}

◆ TEST_F() [92/925]

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

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

flutter::testing::TEST_F ( DartVMTest  ,
DisableTimelineEventHandler   
)

Definition at line 49 of file dart_vm_unittests.cc.

49 {
50 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
52 auto settings = CreateSettingsForFixture();
53 settings.enable_timeline_event_handler = false;
54 auto vm = DartVMRef::Create(settings);
56}
bool TraceHasTimelineEventHandler()
Definition: trace_event.cc:375
void TraceSetTimelineEventHandler(TimelineEventHandler handler)
Definition: trace_event.cc:373

◆ TEST_F() [95/925]

flutter::testing::TEST_F ( DartVMTest  ,
OldGenHeapSize   
)

Definition at line 39 of file dart_vm_unittests.cc.

39 {
40 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
41 auto settings = CreateSettingsForFixture();
42 settings.old_gen_heap_size = 1024;
43 auto vm = DartVMRef::Create(settings);
44 // There is no way to introspect on the heap size so we just assert the vm was
45 // created.
46 ASSERT_TRUE(vm);
47}

◆ TEST_F() [96/925]

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

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").port_id, ILLEGAL_PORT);
29 ASSERT_FALSE(ns->RemoveIsolateNameMapping("foobar"));
30 Dart_PortEx correct_portex = {123, 456};
31 ASSERT_TRUE(ns->RegisterIsolatePortWithName(correct_portex, "foobar"));
32 ASSERT_FALSE(ns->RegisterIsolatePortWithName(correct_portex, "foobar"));
33 Dart_PortEx response = ns->LookupIsolatePortByName("foobar");
34 ASSERT_EQ(response.port_id, correct_portex.port_id);
35 ASSERT_EQ(response.origin_id, correct_portex.origin_id);
36 ASSERT_TRUE(ns->RemoveIsolateNameMapping("foobar"));
37}
#define ILLEGAL_PORT
Definition: dart_api.h:1535
int64_t port_id
Definition: dart_api.h:1527
int64_t origin_id
Definition: dart_api.h:1528

◆ TEST_F() [98/925]

flutter::testing::TEST_F ( DartVMTest  ,
TraceGetTimelineMicrosDoesNotGetClockWhenSystraceIsEnabled   
)

Definition at line 58 of file dart_vm_unittests.cc.

58 {
59 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
60 auto settings = CreateSettingsForFixture();
61 settings.trace_systrace = true;
62 auto vm = DartVMRef::Create(settings);
64}
int64_t TraceGetTimelineMicros()
Definition: trace_event.cc:379

◆ TEST_F() [99/925]

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

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

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

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

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

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

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

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

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

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

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

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

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);
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
Definition: dl_builder.cc:799

◆ TEST_F() [112/925]

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

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

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

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++) {
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}
std::vector< RasterCacheItem * > * raster_cached_entries
Definition: layer.h:85
int renderable_state_flags
Definition: layer.h:83

◆ TEST_F() [116/925]

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

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

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

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

flutter::testing::TEST_F ( DisplayListNopTest  ,
BlendModeAndColorAndFiltersByRendering   
)

Definition at line 4690 of file dl_rendering_unittests.cc.

4690 {
4691 auto test_mode_render = [this](DlBlendMode mode) {
4692 auto image_filter_nomtb = DlColorFilterImageFilter(color_filter_nomtb);
4693 auto image_filter_mtb = DlColorFilterImageFilter(color_filter_mtb);
4694 for (DlColor color : test_src_colors) {
4695 test_attributes_image(mode, color, nullptr, nullptr);
4696 test_attributes_image(mode, color, color_filter_nomtb.get(), nullptr);
4697 test_attributes_image(mode, color, color_filter_mtb.get(), nullptr);
4698 test_attributes_image(mode, color, nullptr, &image_filter_nomtb);
4699 test_attributes_image(mode, color, nullptr, &image_filter_mtb);
4700 }
4701 };
4702
4703#define TEST_MODE(V) test_mode_render(DlBlendMode::V);
4705#undef TEST_MODE
4706}
#define TEST_MODE(V)

◆ TEST_F() [121/925]

flutter::testing::TEST_F ( DisplayListNopTest  ,
BlendModeAndColorByRendering   
)

Definition at line 4677 of file dl_rendering_unittests.cc.

4677 {
4678 auto test_mode_render = [this](DlBlendMode mode) {
4679 // First check rendering a variety of colors onto image
4680 for (DlColor color : test_src_colors) {
4681 test_mode_color_via_rendering(mode, color);
4682 }
4683 };
4684
4685#define TEST_MODE(V) test_mode_render(DlBlendMode::V);
4687#undef TEST_MODE
4688}

◆ TEST_F() [122/925]

flutter::testing::TEST_F ( DisplayListNopTest  ,
BlendModeAndColorViaColorFilter   
)

Definition at line 4665 of file dl_rendering_unittests.cc.

4665 {
4666 auto test_mode_filter = [this](DlBlendMode mode) {
4667 for (DlColor color : test_src_colors) {
4668 test_mode_color_via_filter(mode, color);
4669 }
4670 };
4671
4672#define TEST_MODE(V) test_mode_filter(DlBlendMode::V);
4674#undef TEST_MODE
4675}

◆ TEST_F() [123/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
BlendColorFilterModifyTransparencyCheck   
)

Definition at line 4220 of file dl_rendering_unittests.cc.

4220 {
4221 auto test_mode_color = [](DlBlendMode mode, DlColor color) {
4222 std::stringstream desc_str;
4223 std::string mode_string = BlendModeToString(mode);
4224 desc_str << "blend[" << mode_string << ", " << color << "]";
4225 std::string desc = desc_str.str();
4226 DlBlendColorFilter filter(color, mode);
4227 if (filter.modifies_transparent_black()) {
4228 ASSERT_NE(DlBlendColorFilter::Make(color, mode), nullptr) << desc;
4229 }
4230
4231 DlPaint paint(DlColor(0x7f7f7f7f));
4232 DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);
4233
4234 DisplayListBuilder builder1;
4236 builder1.Rotate(45);
4237 builder1.Translate(-kTestCenter.fX, -kTestCenter.fY);
4238 builder1.DrawRect(kRenderBounds, paint);
4239 auto display_list1 = builder1.Build();
4240
4241 DisplayListBuilder builder2;
4243 builder2.Rotate(45);
4244 builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
4245 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4246 builder2.DrawRect(kRenderBounds, paint);
4247 builder2.Restore();
4248 auto display_list2 = builder2.Build();
4249
4250 for (auto& back_end : CanvasCompareTester::TestBackends) {
4251 auto provider = CanvasCompareTester::GetProvider(back_end);
4252 auto env = std::make_unique<RenderEnvironment>(
4253 provider.get(), PixelFormat::kN32PremulPixelFormat);
4254 auto results1 = env->getResult(display_list1);
4255 auto results2 = env->getResult(display_list2);
4256 int modified_transparent_pixels =
4257 CanvasCompareTester::countModifiedTransparentPixels(results1.get(),
4258 results2.get());
4259 EXPECT_EQ(filter.modifies_transparent_black(),
4260 modified_transparent_pixels != 0)
4261 << desc;
4262 }
4263 };
4264
4265 auto test_mode = [&test_mode_color](DlBlendMode mode) {
4266 test_mode_color(mode, DlColor::kTransparent());
4267 test_mode_color(mode, DlColor::kWhite());
4268 test_mode_color(mode, DlColor::kWhite().modulateOpacity(0.5));
4269 test_mode_color(mode, DlColor::kBlack());
4270 test_mode_color(mode, DlColor::kBlack().modulateOpacity(0.5));
4271 };
4272
4273#define TEST_MODE(V) test_mode(DlBlendMode::V);
4275#undef TEST_MODE
4276}
void Rotate(SkScalar degrees) override
Definition: dl_builder.cc:815
Definition: __init__.py:1
static std::string BlendModeToString(DlBlendMode mode)
constexpr SkRect kTestBounds2
constexpr SkRect kRenderBounds
constexpr SkPoint kTestCenter

◆ TEST_F() [124/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
BlendColorFilterOpacityCommuteCheck   
)

Definition at line 4278 of file dl_rendering_unittests.cc.

4278 {
4279 auto test_mode_color = [](DlBlendMode mode, DlColor color) {
4280 std::stringstream desc_str;
4281 std::string mode_string = BlendModeToString(mode);
4282 desc_str << "blend[" << mode_string << ", " << color << "]";
4283 std::string desc = desc_str.str();
4284 DlBlendColorFilter filter(color, mode);
4285 if (filter.can_commute_with_opacity()) {
4286 // If it can commute with opacity, then it might also be a NOP,
4287 // so we won't necessarily get a non-null return from |::Make()|
4288 } else {
4289 ASSERT_NE(DlBlendColorFilter::Make(color, mode), nullptr) << desc;
4290 }
4291
4292 DlPaint paint(DlColor(0x80808080));
4293 DlPaint opacity_save_paint = DlPaint().setOpacity(0.5);
4294 DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);
4295
4296 DisplayListBuilder builder1;
4297 builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
4298 builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
4299 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4300 builder1.DrawRect(kRenderBounds, paint);
4301 builder1.Restore();
4302 builder1.Restore();
4303 auto display_list1 = builder1.Build();
4304
4305 DisplayListBuilder builder2;
4306 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4307 builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
4308 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4309 builder2.DrawRect(kRenderBounds, paint);
4310 builder2.Restore();
4311 builder2.Restore();
4312 auto display_list2 = builder2.Build();
4313
4314 for (auto& back_end : CanvasCompareTester::TestBackends) {
4315 auto provider = CanvasCompareTester::GetProvider(back_end);
4316 auto env = std::make_unique<RenderEnvironment>(
4317 provider.get(), PixelFormat::kN32PremulPixelFormat);
4318 auto results1 = env->getResult(display_list1);
4319 auto results2 = env->getResult(display_list2);
4320 if (filter.can_commute_with_opacity()) {
4321 CanvasCompareTester::compareToReference(
4322 results2.get(), results1.get(), desc, nullptr, nullptr,
4324 } else {
4325 CanvasCompareTester::quickCompareToReference(
4326 results1.get(), results2.get(), false, desc);
4327 }
4328 }
4329 };
4330
4331 auto test_mode = [&test_mode_color](DlBlendMode mode) {
4332 test_mode_color(mode, DlColor::kTransparent());
4333 test_mode_color(mode, DlColor::kWhite());
4334 test_mode_color(mode, DlColor::kWhite().modulateOpacity(0.5));
4335 test_mode_color(mode, DlColor::kBlack());
4336 test_mode_color(mode, DlColor::kBlack().modulateOpacity(0.5));
4337 };
4338
4339#define TEST_MODE(V) test_mode(DlBlendMode::V);
4341#undef TEST_MODE
4342}

◆ TEST_F() [125/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAlphaColor   
)

Definition at line 2835 of file dl_rendering_unittests.cc.

2835 {
2836 // We use a non-opaque color to avoid obliterating any backdrop filter output
2837 CanvasCompareTester::RenderAll( //
2839 [=](const SkRenderContext& ctx) {
2840 ctx.canvas->drawColor(0x7FFF00FF);
2841 },
2842 [=](const DlRenderContext& ctx) {
2843 ctx.canvas->DrawColor(DlColor(0x7FFF00FF));
2844 },
2845 kDrawColorFlags));
2846}
RenderContext< DlCanvas *, const DlPaint &, sk_sp< DlImage > > DlRenderContext

◆ TEST_F() [126/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawArc   
)

Definition at line 3083 of file dl_rendering_unittests.cc.

3083 {
3084 CanvasCompareTester::RenderAll( //
3086 [=](const SkRenderContext& ctx) { //
3087 ctx.canvas->drawArc(kRenderBounds, 60, 330, false, ctx.paint);
3088 },
3089 [=](const DlRenderContext& ctx) { //
3090 ctx.canvas->DrawArc(kRenderBounds, 60, 330, false, ctx.paint);
3091 },
3092 kDrawArcNoCenterFlags));
3093}

◆ TEST_F() [127/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawArcCenter   
)

Definition at line 3095 of file dl_rendering_unittests.cc.

3095 {
3096 // Center arcs that inscribe nearly a whole circle except for a small
3097 // arc extent gap have 2 angles that may appear or disappear at the
3098 // various miter limits tested (0, 4, and 10).
3099 // The center angle here is 12 degrees which shows a miter
3100 // at limit=10, but not 0 or 4.
3101 // The arcs at the corners where it turns in towards the
3102 // center show miters at 4 and 10, but not 0.
3103 // Limit == 0, neither corner does a miter
3104 // Limit == 4, only the edge "turn-in" corners miter
3105 // Limit == 10, edge and center corners all miter
3106 CanvasCompareTester::RenderAll( //
3108 [=](const SkRenderContext& ctx) { //
3109 ctx.canvas->drawArc(kRenderBounds, 60, 360 - 12, true, ctx.paint);
3110 },
3111 [=](const DlRenderContext& ctx) { //
3112 ctx.canvas->DrawArc(kRenderBounds, 60, 360 - 12, true, ctx.paint);
3113 },
3114 kDrawArcWithCenterFlags)
3115 .set_draw_arc_center());
3116}

◆ TEST_F() [128/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAtlasLinear   
)

Definition at line 3596 of file dl_rendering_unittests.cc.

3596 {
3597 const SkRSXform xform[] = {
3598 // clang-format off
3599 { 1.2f, 0.0f, kRenderLeft, kRenderTop},
3600 { 0.0f, 1.2f, kRenderRight, kRenderTop},
3601 {-1.2f, 0.0f, kRenderRight, kRenderBottom},
3602 { 0.0f, -1.2f, kRenderLeft, kRenderBottom},
3603 // clang-format on
3604 };
3605 const SkRect tex[] = {
3606 // clang-format off
3611 // clang-format on
3612 };
3613 const SkColor sk_colors[] = {
3618 };
3619 const DlColor dl_colors[] = {
3624 };
3625 const DlImageSampling dl_sampling = DlImageSampling::kLinear;
3626 const SkSamplingOptions sk_sampling = SkImageSampling::kLinear;
3627 CanvasCompareTester::RenderAll( //
3628 TestParameters(
3629 [=](const SkRenderContext& ctx) {
3630 ctx.canvas->drawAtlas(ctx.image.get(), xform, tex, sk_colors, 2,
3631 SkBlendMode::kSrcOver, sk_sampling, //
3632 nullptr, &ctx.paint);
3633 },
3634 [=](const DlRenderContext& ctx) {
3635 ctx.canvas->DrawAtlas(ctx.image, xform, tex, dl_colors, 2,
3636 DlBlendMode::kSrcOver, dl_sampling, //
3637 nullptr, &ctx.paint);
3638 },
3639 kDrawAtlasWithPaintFlags));
3640}
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
constexpr int kRenderHalfHeight
constexpr int kRenderHalfWidth
RenderContext< SkCanvas *, const SkPaint &, sk_sp< SkImage > > SkRenderContext

◆ TEST_F() [129/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAtlasNearest   
)

Definition at line 3504 of file dl_rendering_unittests.cc.

3504 {
3505 const SkRSXform xform[] = {
3506 // clang-format off
3507 { 1.2f, 0.0f, kRenderLeft, kRenderTop},
3508 { 0.0f, 1.2f, kRenderRight, kRenderTop},
3509 {-1.2f, 0.0f, kRenderRight, kRenderBottom},
3510 { 0.0f, -1.2f, kRenderLeft, kRenderBottom},
3511 // clang-format on
3512 };
3513 const SkRect tex[] = {
3514 // clang-format off
3519 // clang-format on
3520 };
3521 const SkColor sk_colors[] = {
3526 };
3527 const DlColor dl_colors[] = {
3532 };
3533 const DlImageSampling dl_sampling = DlImageSampling::kNearestNeighbor;
3534 const SkSamplingOptions sk_sampling = SkImageSampling::kNearestNeighbor;
3535 CanvasCompareTester::RenderAll( //
3536 TestParameters(
3537 [=](const SkRenderContext& ctx) {
3538 ctx.canvas->drawAtlas(ctx.image.get(), xform, tex, sk_colors, 4,
3539 SkBlendMode::kSrcOver, sk_sampling, nullptr,
3540 &ctx.paint);
3541 },
3542 [=](const DlRenderContext& ctx) {
3543 ctx.canvas->DrawAtlas(ctx.image, xform, tex, dl_colors, 4,
3544 DlBlendMode::kSrcOver, dl_sampling, nullptr,
3545 &ctx.paint);
3546 },
3547 kDrawAtlasWithPaintFlags));
3548}

◆ TEST_F() [130/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawAtlasNearestNoPaint   
)

Definition at line 3550 of file dl_rendering_unittests.cc.

3550 {
3551 const SkRSXform xform[] = {
3552 // clang-format off
3553 { 1.2f, 0.0f, kRenderLeft, kRenderTop},
3554 { 0.0f, 1.2f, kRenderRight, kRenderTop},
3555 {-1.2f, 0.0f, kRenderRight, kRenderBottom},
3556 { 0.0f, -1.2f, kRenderLeft, kRenderBottom},
3557 // clang-format on
3558 };
3559 const SkRect tex[] = {
3560 // clang-format off
3565 // clang-format on
3566 };
3567 const SkColor sk_colors[] = {
3572 };
3573 const DlColor dl_colors[] = {
3578 };
3579 const DlImageSampling dl_sampling = DlImageSampling::kNearestNeighbor;
3580 const SkSamplingOptions sk_sampling = SkImageSampling::kNearestNeighbor;
3581 CanvasCompareTester::RenderAll( //
3582 TestParameters(
3583 [=](const SkRenderContext& ctx) {
3584 ctx.canvas->drawAtlas(ctx.image.get(), xform, tex, sk_colors, 4,
3585 SkBlendMode::kSrcOver, sk_sampling, //
3586 nullptr, nullptr);
3587 },
3588 [=](const DlRenderContext& ctx) {
3589 ctx.canvas->DrawAtlas(ctx.image, xform, tex, dl_colors, 4,
3590 DlBlendMode::kSrcOver, dl_sampling, //
3591 nullptr, nullptr);
3592 },
3593 kDrawAtlasFlags));
3594}

◆ TEST_F() [131/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawCircle   
)

Definition at line 3005 of file dl_rendering_unittests.cc.

3005 {
3006 CanvasCompareTester::RenderAll( //
3008 [=](const SkRenderContext& ctx) { //
3009 ctx.canvas->drawCircle(kTestCenter, kRenderRadius, ctx.paint);
3010 },
3011 [=](const DlRenderContext& ctx) { //
3012 ctx.canvas->DrawCircle(kTestCenter, kRenderRadius, ctx.paint);
3013 },
3014 kDrawCircleFlags));
3015}
constexpr SkScalar kRenderRadius

◆ TEST_F() [132/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawDiagonalDashedLines   
)

Definition at line 2927 of file dl_rendering_unittests.cc.

2927 {
2932 // Adding some edge center to edge center diagonals to better fill
2933 // out the RRect Clip so bounds checking sees less empty bounds space.
2938
2939 // Full diagonals are 100x100 which are 140 in length
2940 // Dashing them with 25 on, 5 off means that the last
2941 // dash goes from 120 to 145 which means both ends of the
2942 // diagonals will be in an "on" dash for maximum bounds
2943
2944 // Edge to edge diagonals are 50x50 which are 70 in length
2945 // Dashing them with 25 on, 5 off means that the last
2946 // dash goes from 60 to 85 which means both ends of the
2947 // edge diagonals will be in a dash segment
2948
2949 CanvasCompareTester::RenderAll( //
2951 [=](const SkRenderContext& ctx) { //
2952 // Skia requires kStroke style on horizontal and vertical
2953 // lines to get the bounds correct.
2954 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
2955 SkPaint p = ctx.paint;
2956 p.setStyle(SkPaint::kStroke_Style);
2957 SkScalar intervals[2] = {25.0f, 5.0f};
2958 p.setPathEffect(SkDashPathEffect::Make(intervals, 2.0f, 0.0f));
2959 ctx.canvas->drawLine(p1, p2, p);
2960 ctx.canvas->drawLine(p3, p4, p);
2961 ctx.canvas->drawLine(p5, p6, p);
2962 ctx.canvas->drawLine(p7, p8, p);
2963 },
2964 [=](const DlRenderContext& ctx) { //
2965 ctx.canvas->DrawDashedLine(ToDlPoint(p1), ToDlPoint(p2), //
2966 25.0f, 5.0f, ctx.paint);
2967 ctx.canvas->DrawDashedLine(ToDlPoint(p3), ToDlPoint(p4), //
2968 25.0f, 5.0f, ctx.paint);
2969 ctx.canvas->DrawDashedLine(ToDlPoint(p5), ToDlPoint(p6), //
2970 25.0f, 5.0f, ctx.paint);
2971 ctx.canvas->DrawDashedLine(ToDlPoint(p7), ToDlPoint(p8), //
2972 25.0f, 5.0f, ctx.paint);
2973 },
2974 kDrawLineFlags)
2975 .set_draw_line());
2976}
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194

◆ TEST_F() [133/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawDiagonalLines   
)

Definition at line 2848 of file dl_rendering_unittests.cc.

2848 {
2853 // Adding some edge center to edge center diagonals to better fill
2854 // out the RRect Clip so bounds checking sees less empty bounds space.
2859
2860 CanvasCompareTester::RenderAll( //
2862 [=](const SkRenderContext& ctx) { //
2863 // Skia requires kStroke style on horizontal and vertical
2864 // lines to get the bounds correct.
2865 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
2866 SkPaint p = ctx.paint;
2867 p.setStyle(SkPaint::kStroke_Style);
2868 ctx.canvas->drawLine(p1, p2, p);
2869 ctx.canvas->drawLine(p3, p4, p);
2870 ctx.canvas->drawLine(p5, p6, p);
2871 ctx.canvas->drawLine(p7, p8, p);
2872 },
2873 [=](const DlRenderContext& ctx) { //
2874 ctx.canvas->DrawLine(p1, p2, ctx.paint);
2875 ctx.canvas->DrawLine(p3, p4, ctx.paint);
2876 ctx.canvas->DrawLine(p5, p6, ctx.paint);
2877 ctx.canvas->DrawLine(p7, p8, ctx.paint);
2878 },
2879 kDrawLineFlags)
2880 .set_draw_line());
2881}

◆ TEST_F() [134/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawDisplayList   
)

Definition at line 3661 of file dl_rendering_unittests.cc.

3661 {
3662 sk_sp<DisplayList> display_list = makeTestDisplayList();
3663 CanvasCompareTester::RenderAll( //
3665 [=](const SkRenderContext& ctx) { //
3666 DlSkCanvasAdapter(ctx.canvas).DrawDisplayList(display_list);
3667 },
3668 [=](const DlRenderContext& ctx) { //
3669 ctx.canvas->DrawDisplayList(display_list);
3670 },
3671 kDrawDisplayListFlags)
3672 .set_draw_display_list());
3673}
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
sk_sp< DisplayList > makeTestDisplayList()

◆ TEST_F() [135/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawDRRect   
)

Definition at line 3031 of file dl_rendering_unittests.cc.

3031 {
3034 SkRect inner_bounds = kRenderBounds.makeInset(30.0, 30.0);
3035 SkRRect inner = SkRRect::MakeRectXY(inner_bounds, kRenderCornerRadius,
3037 CanvasCompareTester::RenderAll( //
3039 [=](const SkRenderContext& ctx) { //
3040 ctx.canvas->drawDRRect(outer, inner, ctx.paint);
3041 },
3042 [=](const DlRenderContext& ctx) { //
3043 ctx.canvas->DrawDRRect(outer, inner, ctx.paint);
3044 },
3045 kDrawDRRectFlags));
3046}
constexpr SkScalar kRenderCornerRadius

◆ TEST_F() [136/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawHorizontalLine   
)

Definition at line 2883 of file dl_rendering_unittests.cc.

2883 {
2886
2887 CanvasCompareTester::RenderAll( //
2889 [=](const SkRenderContext& ctx) { //
2890 // Skia requires kStroke style on horizontal and vertical
2891 // lines to get the bounds correct.
2892 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
2893 SkPaint p = ctx.paint;
2894 p.setStyle(SkPaint::kStroke_Style);
2895 ctx.canvas->drawLine(p1, p2, p);
2896 },
2897 [=](const DlRenderContext& ctx) { //
2898 ctx.canvas->DrawLine(p1, p2, ctx.paint);
2899 },
2900 kDrawHVLineFlags)
2901 .set_draw_line()
2903}

◆ TEST_F() [137/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageLinear   
)

Definition at line 3387 of file dl_rendering_unittests.cc.

3387 {
3388 CanvasCompareTester::RenderAll( //
3390 [=](const SkRenderContext& ctx) {
3391 ctx.canvas->drawImage(ctx.image, kRenderLeft, kRenderTop,
3393 },
3394 [=](const DlRenderContext& ctx) {
3395 ctx.canvas->DrawImage(ctx.image,
3398 },
3399 kDrawImageWithPaintFlags));
3400}

◆ TEST_F() [138/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNearest   
)

Definition at line 3355 of file dl_rendering_unittests.cc.

3355 {
3356 CanvasCompareTester::RenderAll( //
3358 [=](const SkRenderContext& ctx) {
3359 ctx.canvas->drawImage(ctx.image, kRenderLeft, kRenderTop,
3360 SkImageSampling::kNearestNeighbor,
3361 &ctx.paint);
3362 },
3363 [=](const DlRenderContext& ctx) {
3364 ctx.canvas->DrawImage(ctx.image, //
3366 DlImageSampling::kNearestNeighbor,
3367 &ctx.paint);
3368 },
3369 kDrawImageWithPaintFlags));
3370}

◆ TEST_F() [139/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNearestNoPaint   
)

Definition at line 3372 of file dl_rendering_unittests.cc.

3372 {
3373 CanvasCompareTester::RenderAll( //
3375 [=](const SkRenderContext& ctx) {
3376 ctx.canvas->drawImage(ctx.image, kRenderLeft, kRenderTop,
3377 SkImageSampling::kNearestNeighbor, nullptr);
3378 },
3379 [=](const DlRenderContext& ctx) {
3380 ctx.canvas->DrawImage(ctx.image,
3382 DlImageSampling::kNearestNeighbor, nullptr);
3383 },
3384 kDrawImageFlags));
3385}

◆ TEST_F() [140/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNineLinear   
)

Definition at line 3488 of file dl_rendering_unittests.cc.

3488 {
3490 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3491 CanvasCompareTester::RenderAll( //
3493 [=](const SkRenderContext& ctx) {
3494 ctx.canvas->drawImageNine(ctx.image.get(), src, dst,
3496 },
3497 [=](const DlRenderContext& ctx) {
3498 ctx.canvas->DrawImageNine(ctx.image, src, dst,
3500 },
3501 kDrawImageNineWithPaintFlags));
3502}
SkIRect makeInset(int32_t dx, int32_t dy) const
Definition: SkRect.h:332

◆ TEST_F() [141/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNineNearest   
)

Definition at line 3456 of file dl_rendering_unittests.cc.

3456 {
3458 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3459 CanvasCompareTester::RenderAll( //
3461 [=](const SkRenderContext& ctx) {
3462 ctx.canvas->drawImageNine(ctx.image.get(), src, dst,
3464 },
3465 [=](const DlRenderContext& ctx) {
3466 ctx.canvas->DrawImageNine(ctx.image, src, dst,
3467 DlFilterMode::kNearest, &ctx.paint);
3468 },
3469 kDrawImageNineWithPaintFlags));
3470}

◆ TEST_F() [142/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageNineNearestNoPaint   
)

Definition at line 3472 of file dl_rendering_unittests.cc.

3472 {
3474 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3475 CanvasCompareTester::RenderAll( //
3477 [=](const SkRenderContext& ctx) {
3478 ctx.canvas->drawImageNine(ctx.image.get(), src, dst,
3479 SkFilterMode::kNearest, nullptr);
3480 },
3481 [=](const DlRenderContext& ctx) {
3482 ctx.canvas->DrawImageNine(ctx.image, src, dst,
3483 DlFilterMode::kNearest, nullptr);
3484 },
3485 kDrawImageNineFlags));
3486}

◆ TEST_F() [143/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageRectLinear   
)

Definition at line 3438 of file dl_rendering_unittests.cc.

3438 {
3440 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3441 CanvasCompareTester::RenderAll( //
3443 [=](const SkRenderContext& ctx) {
3444 ctx.canvas->drawImageRect(
3447 },
3448 [=](const DlRenderContext& ctx) { //
3449 ctx.canvas->DrawImageRect(
3451 &ctx.paint, DlCanvas::SrcRectConstraint::kFast);
3452 },
3453 kDrawImageRectWithPaintFlags));
3454}
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543

◆ TEST_F() [144/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageRectNearest   
)

Definition at line 3402 of file dl_rendering_unittests.cc.

3402 {
3404 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3405 CanvasCompareTester::RenderAll( //
3407 [=](const SkRenderContext& ctx) {
3408 ctx.canvas->drawImageRect(
3409 ctx.image, src, dst, SkImageSampling::kNearestNeighbor,
3411 },
3412 [=](const DlRenderContext& ctx) {
3413 ctx.canvas->DrawImageRect(
3414 ctx.image, src, dst, DlImageSampling::kNearestNeighbor,
3415 &ctx.paint, DlCanvas::SrcRectConstraint::kFast);
3416 },
3417 kDrawImageRectWithPaintFlags));
3418}

◆ TEST_F() [145/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawImageRectNearestNoPaint   
)

Definition at line 3420 of file dl_rendering_unittests.cc.

3420 {
3422 SkRect dst = kRenderBounds.makeInset(10.5, 10.5);
3423 CanvasCompareTester::RenderAll( //
3425 [=](const SkRenderContext& ctx) {
3426 ctx.canvas->drawImageRect(
3427 ctx.image, src, dst, SkImageSampling::kNearestNeighbor, //
3429 },
3430 [=](const DlRenderContext& ctx) {
3431 ctx.canvas->DrawImageRect(
3432 ctx.image, src, dst, DlImageSampling::kNearestNeighbor, //
3433 nullptr, DlCanvas::SrcRectConstraint::kFast);
3434 },
3435 kDrawImageRectFlags));
3436}

◆ TEST_F() [146/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawOpaqueColor   
)

Definition at line 2810 of file dl_rendering_unittests.cc.

2810 {
2811 // We use a non-opaque color to avoid obliterating any backdrop filter output
2812 CanvasCompareTester::RenderAll( //
2814 [=](const SkRenderContext& ctx) {
2815 // DrawColor is not tested against attributes because it is supposed
2816 // to ignore them. So, if the paint has an alpha, it is because we
2817 // are doing a saveLayer+backdrop test and we need to not flood over
2818 // the backdrop output with a solid color. So, we perform an alpha
2819 // drawColor for that case only.
2820 SkColor color = SkColorSetA(SK_ColorMAGENTA, ctx.paint.getAlpha());
2821 ctx.canvas->drawColor(color);
2822 },
2823 [=](const DlRenderContext& ctx) {
2824 // DrawColor is not tested against attributes because it is supposed
2825 // to ignore them. So, if the paint has an alpha, it is because we
2826 // are doing a saveLayer+backdrop test and we need to not flood over
2827 // the backdrop output with a solid color. So, we transfer the alpha
2828 // from the paint for that case only.
2829 ctx.canvas->DrawColor(
2830 DlColor::kMagenta().withAlpha(ctx.paint.getAlpha()));
2831 },
2832 kDrawColorFlags));
2833}

◆ TEST_F() [147/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawOval   
)

Definition at line 2991 of file dl_rendering_unittests.cc.

2991 {
2993
2994 CanvasCompareTester::RenderAll( //
2996 [=](const SkRenderContext& ctx) { //
2997 ctx.canvas->drawOval(rect, ctx.paint);
2998 },
2999 [=](const DlRenderContext& ctx) { //
3000 ctx.canvas->DrawOval(rect, ctx.paint);
3001 },
3002 kDrawOvalFlags));
3003}

◆ TEST_F() [148/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPaint   
)

Definition at line 2798 of file dl_rendering_unittests.cc.

2798 {
2799 CanvasCompareTester::RenderAll( //
2801 [=](const SkRenderContext& ctx) { //
2802 ctx.canvas->drawPaint(ctx.paint);
2803 },
2804 [=](const DlRenderContext& ctx) { //
2805 ctx.canvas->DrawPaint(ctx.paint);
2806 },
2807 kDrawPaintFlags));
2808}

◆ TEST_F() [149/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPath   
)

Definition at line 3048 of file dl_rendering_unittests.cc.

3048 {
3049 SkPath path;
3050
3051 // unclosed lines to show some caps
3052 path.moveTo(kRenderLeft + 15, kRenderTop + 15);
3053 path.lineTo(kRenderRight - 15, kRenderBottom - 15);
3054 path.moveTo(kRenderLeft + 15, kRenderBottom - 15);
3055 path.lineTo(kRenderRight - 15, kRenderTop + 15);
3056
3057 path.addRect(kRenderBounds);
3058
3059 // miter diamonds horizontally and vertically to show miters
3061 for (int i = 1; i < kVerticalMiterDiamondPointCount; i++) {
3063 }
3064 path.close();
3066 for (int i = 1; i < kHorizontalMiterDiamondPointCount; i++) {
3068 }
3069 path.close();
3070
3071 CanvasCompareTester::RenderAll( //
3072 TestParameters(
3073 [=](const SkRenderContext& ctx) { //
3074 ctx.canvas->drawPath(path, ctx.paint);
3075 },
3076 [=](const DlRenderContext& ctx) { //
3077 ctx.canvas->DrawPath(path, ctx.paint);
3078 },
3079 kDrawPathFlags)
3080 .set_draw_path());
3081}
constexpr SkPoint kVerticalMiterDiamondPoints[]
const int kHorizontalMiterDiamondPointCount
const SkPoint kHorizontalMiterDiamondPoints[]
const int kVerticalMiterDiamondPointCount

◆ TEST_F() [150/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPointsAsLines   
)

Definition at line 3171 of file dl_rendering_unittests.cc.

3171 {
3172 const SkScalar x0 = kRenderLeft + 1;
3173 const SkScalar x1 = kRenderLeft + 16;
3174 const SkScalar x2 = kRenderRight - 16;
3175 const SkScalar x3 = kRenderRight - 1;
3176
3177 const SkScalar y0 = kRenderTop;
3178 const SkScalar y1 = kRenderTop + 16;
3179 const SkScalar y2 = kRenderBottom - 16;
3180 const SkScalar y3 = kRenderBottom;
3181
3182 // clang-format off
3183 const SkPoint points[] = {
3184 // Outer box
3185 {x0, y0}, {x3, y0},
3186 {x3, y0}, {x3, y3},
3187 {x3, y3}, {x0, y3},
3188 {x0, y3}, {x0, y0},
3189
3190 // Diagonals
3191 {x0, y0}, {x3, y3}, {x3, y0}, {x0, y3},
3192
3193 // Inner box
3194 {x1, y1}, {x2, y1},
3195 {x2, y1}, {x2, y2},
3196 {x2, y2}, {x1, y2},
3197 {x1, y2}, {x1, y1},
3198 };
3199 // clang-format on
3200
3201 const int count = sizeof(points) / sizeof(points[0]);
3202 ASSERT_TRUE((count & 1) == 0);
3203 CanvasCompareTester::RenderAll( //
3204 TestParameters(
3205 [=](const SkRenderContext& ctx) {
3206 // Skia requires kStroke style on horizontal and vertical
3207 // lines to get the bounds correct.
3208 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
3209 SkPaint p = ctx.paint;
3210 p.setStyle(SkPaint::kStroke_Style);
3212 ctx.canvas->drawPoints(mode, count, points, p);
3213 },
3214 [=](const DlRenderContext& ctx) {
3215 auto mode = PointMode::kLines;
3216 ctx.canvas->DrawPoints(mode, count, points, ctx.paint);
3217 },
3218 kDrawPointsAsLinesFlags));
3219}
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1242

◆ TEST_F() [151/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPointsAsPoints   
)

Definition at line 3118 of file dl_rendering_unittests.cc.

3118 {
3119 // The +/- 16 points are designed to fall just inside the clips
3120 // that are tested against so we avoid lots of undrawn pixels
3121 // in the accumulated bounds.
3122 const SkScalar x0 = kRenderLeft;
3123 const SkScalar x1 = kRenderLeft + 16;
3124 const SkScalar x2 = (kRenderLeft + kRenderCenterX) * 0.5;
3125 const SkScalar x3 = kRenderCenterX + 0.1;
3126 const SkScalar x4 = (kRenderRight + kRenderCenterX) * 0.5;
3127 const SkScalar x5 = kRenderRight - 16;
3128 const SkScalar x6 = kRenderRight;
3129
3130 const SkScalar y0 = kRenderTop;
3131 const SkScalar y1 = kRenderTop + 16;
3132 const SkScalar y2 = (kRenderTop + kRenderCenterY) * 0.5;
3133 const SkScalar y3 = kRenderCenterY + 0.1;
3134 const SkScalar y4 = (kRenderBottom + kRenderCenterY) * 0.5;
3135 const SkScalar y5 = kRenderBottom - 16;
3136 const SkScalar y6 = kRenderBottom;
3137
3138 // clang-format off
3139 const SkPoint points[] = {
3140 {x0, y0}, {x1, y0}, {x2, y0}, {x3, y0}, {x4, y0}, {x5, y0}, {x6, y0},
3141 {x0, y1}, {x1, y1}, {x2, y1}, {x3, y1}, {x4, y1}, {x5, y1}, {x6, y1},
3142 {x0, y2}, {x1, y2}, {x2, y2}, {x3, y2}, {x4, y2}, {x5, y2}, {x6, y2},
3143 {x0, y3}, {x1, y3}, {x2, y3}, {x3, y3}, {x4, y3}, {x5, y3}, {x6, y3},
3144 {x0, y4}, {x1, y4}, {x2, y4}, {x3, y4}, {x4, y4}, {x5, y4}, {x6, y4},
3145 {x0, y5}, {x1, y5}, {x2, y5}, {x3, y5}, {x4, y5}, {x5, y5}, {x6, y5},
3146 {x0, y6}, {x1, y6}, {x2, y6}, {x3, y6}, {x4, y6}, {x5, y6}, {x6, y6},
3147 };
3148 // clang-format on
3149 const int count = sizeof(points) / sizeof(points[0]);
3150
3151 CanvasCompareTester::RenderAll( //
3152 TestParameters(
3153 [=](const SkRenderContext& ctx) {
3154 // Skia requires kStroke style on horizontal and vertical
3155 // lines to get the bounds correct.
3156 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
3157 SkPaint p = ctx.paint;
3158 p.setStyle(SkPaint::kStroke_Style);
3160 ctx.canvas->drawPoints(mode, count, points, p);
3161 },
3162 [=](const DlRenderContext& ctx) {
3163 auto mode = PointMode::kPoints;
3164 ctx.canvas->DrawPoints(mode, count, points, ctx.paint);
3165 },
3166 kDrawPointsAsPointsFlags)
3167 .set_draw_line()
3168 .set_ignores_dashes());
3169}
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241

◆ TEST_F() [152/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawPointsAsPolygon   
)

Definition at line 3221 of file dl_rendering_unittests.cc.

3221 {
3222 const SkPoint points1[] = {
3223 // RenderBounds box with a diamond
3233 };
3234 const int count1 = sizeof(points1) / sizeof(points1[0]);
3235
3236 CanvasCompareTester::RenderAll( //
3237 TestParameters(
3238 [=](const SkRenderContext& ctx) {
3239 // Skia requires kStroke style on horizontal and vertical
3240 // lines to get the bounds correct.
3241 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
3242 SkPaint p = ctx.paint;
3243 p.setStyle(SkPaint::kStroke_Style);
3245 ctx.canvas->drawPoints(mode, count1, points1, p);
3246 },
3247 [=](const DlRenderContext& ctx) {
3248 auto mode = PointMode::kPolygon;
3249 ctx.canvas->DrawPoints(mode, count1, points1, ctx.paint);
3250 },
3251 kDrawPointsAsPolygonFlags));
3252}
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1243

◆ TEST_F() [153/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawRect   
)

Definition at line 2978 of file dl_rendering_unittests.cc.

2978 {
2979 // Bounds are offset by 0.5 pixels to induce AA
2980 CanvasCompareTester::RenderAll( //
2982 [=](const SkRenderContext& ctx) { //
2983 ctx.canvas->drawRect(kRenderBounds.makeOffset(0.5, 0.5), ctx.paint);
2984 },
2985 [=](const DlRenderContext& ctx) { //
2986 ctx.canvas->DrawRect(kRenderBounds.makeOffset(0.5, 0.5), ctx.paint);
2987 },
2988 kDrawRectFlags));
2989}

◆ TEST_F() [154/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawRRect   
)

Definition at line 3017 of file dl_rendering_unittests.cc.

3017 {
3020 CanvasCompareTester::RenderAll( //
3022 [=](const SkRenderContext& ctx) { //
3023 ctx.canvas->drawRRect(rrect, ctx.paint);
3024 },
3025 [=](const DlRenderContext& ctx) { //
3026 ctx.canvas->DrawRRect(rrect, ctx.paint);
3027 },
3028 kDrawRRectFlags));
3029}

◆ TEST_F() [155/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawShadow   
)

Definition at line 3722 of file dl_rendering_unittests.cc.

3722 {
3723 SkPath path;
3724 path.addRoundRect(
3725 {
3726 kRenderLeft + 10,
3727 kRenderTop,
3728 kRenderRight - 10,
3729 kRenderBottom - 20,
3730 },
3732 const DlColor color = DlColor::kDarkGrey();
3733 const SkScalar elevation = 5;
3734
3735 CanvasCompareTester::RenderAll( //
3736 TestParameters(
3737 [=](const SkRenderContext& ctx) { //
3738 DlSkCanvasDispatcher::DrawShadow(ctx.canvas, path, color, elevation,
3739 false, 1.0);
3740 },
3741 [=](const DlRenderContext& ctx) { //
3742 ctx.canvas->DrawShadow(path, color, elevation, false, 1.0);
3743 },
3744 kDrawShadowFlags),
3745 CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3));
3746}

◆ TEST_F() [156/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawShadowDpr   
)

Definition at line 3774 of file dl_rendering_unittests.cc.

3774 {
3775 SkPath path;
3776 path.addRoundRect(
3777 {
3778 kRenderLeft + 10,
3779 kRenderTop,
3780 kRenderRight - 10,
3781 kRenderBottom - 20,
3782 },
3784 const DlColor color = DlColor::kDarkGrey();
3785 const SkScalar elevation = 5;
3786
3787 CanvasCompareTester::RenderAll( //
3788 TestParameters(
3789 [=](const SkRenderContext& ctx) { //
3790 DlSkCanvasDispatcher::DrawShadow(ctx.canvas, path, color, elevation,
3791 false, 1.5);
3792 },
3793 [=](const DlRenderContext& ctx) { //
3794 ctx.canvas->DrawShadow(path, color, elevation, false, 1.5);
3795 },
3796 kDrawShadowFlags),
3797 CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3));
3798}

◆ TEST_F() [157/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawShadowTransparentOccluder   
)

Definition at line 3748 of file dl_rendering_unittests.cc.

3748 {
3749 SkPath path;
3750 path.addRoundRect(
3751 {
3752 kRenderLeft + 10,
3753 kRenderTop,
3754 kRenderRight - 10,
3755 kRenderBottom - 20,
3756 },
3758 const DlColor color = DlColor::kDarkGrey();
3759 const SkScalar elevation = 5;
3760
3761 CanvasCompareTester::RenderAll( //
3762 TestParameters(
3763 [=](const SkRenderContext& ctx) { //
3764 DlSkCanvasDispatcher::DrawShadow(ctx.canvas, path, color, elevation,
3765 true, 1.0);
3766 },
3767 [=](const DlRenderContext& ctx) { //
3768 ctx.canvas->DrawShadow(path, color, elevation, true, 1.0);
3769 },
3770 kDrawShadowFlags),
3771 CanvasCompareTester::DefaultTolerance.addBoundsPadding(3, 3));
3772}

◆ TEST_F() [158/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawTextBlob   
)

Definition at line 3675 of file dl_rendering_unittests.cc.

3675 {
3676 // TODO(https://github.com/flutter/flutter/issues/82202): Remove once the
3677 // performance overlay can use Fuchsia's font manager instead of the empty
3678 // default.
3679#if defined(OS_FUCHSIA)
3680 GTEST_SKIP() << "Rendering comparisons require a valid default font manager";
3681#else
3682 sk_sp<SkTextBlob> blob =
3683 CanvasCompareTester::MakeTextBlob("Testing", kRenderHeight * 0.33f);
3684#ifdef IMPELLER_SUPPORTS_RENDERING
3686#endif // IMPELLER_SUPPORTS_RENDERING
3687 SkScalar render_y_1_3 = kRenderTop + kRenderHeight * 0.3;
3688 SkScalar render_y_2_3 = kRenderTop + kRenderHeight * 0.6;
3689 CanvasCompareTester::RenderAll( //
3691 [=](const SkRenderContext& ctx) {
3692 auto paint = ctx.paint;
3693 ctx.canvas->drawTextBlob(blob, kRenderLeft, render_y_1_3, paint);
3694 ctx.canvas->drawTextBlob(blob, kRenderLeft, render_y_2_3, paint);
3695 ctx.canvas->drawTextBlob(blob, kRenderLeft, kRenderBottom, paint);
3696 },
3697 [=](const DlRenderContext& ctx) {
3698 auto paint = ctx.paint;
3699 ctx.canvas->DrawTextBlob(blob, kRenderLeft, render_y_1_3, paint);
3700 ctx.canvas->DrawTextBlob(blob, kRenderLeft, render_y_2_3, paint);
3701 ctx.canvas->DrawTextBlob(blob, kRenderLeft, kRenderBottom, paint);
3702 },
3703#ifdef IMPELLER_SUPPORTS_RENDERING
3704 [=](const DlRenderContext& ctx) {
3705 auto paint = ctx.paint;
3706 ctx.canvas->DrawTextFrame(frame, kRenderLeft, render_y_1_3, paint);
3707 ctx.canvas->DrawTextFrame(frame, kRenderLeft, render_y_2_3, paint);
3708 ctx.canvas->DrawTextFrame(frame, kRenderLeft, kRenderBottom, paint);
3709 },
3710#endif // IMPELLER_SUPPORTS_RENDERING
3711 kDrawTextBlobFlags)
3712 .set_draw_text_blob(),
3713 // From examining the bounds differential for the "Default" case, the
3714 // SkTextBlob adds a padding of ~32 on the left, ~30 on the right,
3715 // ~12 on top and ~8 on the bottom, so we add 33h & 13v allowed
3716 // padding to the tolerance
3717 CanvasCompareTester::DefaultTolerance.addBoundsPadding(33, 13));
3718 EXPECT_TRUE(blob->unique());
3719#endif // OS_FUCHSIA
3720}
bool unique() const
Definition: SkRefCnt.h:175
std::shared_ptr< TextFrame > MakeTextFrameFromTextBlobSkia(const sk_sp< SkTextBlob > &blob)

◆ TEST_F() [159/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawVerticalLine   
)

Definition at line 2905 of file dl_rendering_unittests.cc.

2905 {
2908
2909 CanvasCompareTester::RenderAll( //
2911 [=](const SkRenderContext& ctx) { //
2912 // Skia requires kStroke style on horizontal and vertical
2913 // lines to get the bounds correct.
2914 // See https://bugs.chromium.org/p/skia/issues/detail?id=12446
2915 SkPaint p = ctx.paint;
2916 p.setStyle(SkPaint::kStroke_Style);
2917 ctx.canvas->drawLine(p1, p2, p);
2918 },
2919 [=](const DlRenderContext& ctx) { //
2920 ctx.canvas->DrawLine(p1, p2, ctx.paint);
2921 },
2922 kDrawHVLineFlags)
2923 .set_draw_line()
2925}

◆ TEST_F() [160/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawVerticesWithColors   
)

Definition at line 3254 of file dl_rendering_unittests.cc.

3254 {
3255 // Cover as many sides of the box with only 6 vertices:
3256 // +----------+
3257 // |xxxxxxxxxx|
3258 // | xxxxxx|
3259 // | xxx|
3260 // |xxx |
3261 // |xxxxxx |
3262 // |xxxxxxxxxx|
3263 // +----------|
3264 const SkPoint pts[6] = {
3265 // Upper-Right corner, full top, half right coverage
3269 // Lower-Left corner, full bottom, half left coverage
3273 };
3274 const DlColor dl_colors[6] = {
3277 };
3278 const SkColor sk_colors[6] = {
3281 };
3282 const std::shared_ptr<DlVertices> dl_vertices =
3283 DlVertices::Make(DlVertexMode::kTriangles, 6, pts, nullptr, dl_colors);
3284 const auto sk_vertices =
3285 SkVertices::MakeCopy(SkVertices::VertexMode::kTriangles_VertexMode, 6,
3286 pts, nullptr, sk_colors);
3287
3288 CanvasCompareTester::RenderAll( //
3289 TestParameters(
3290 [=](const SkRenderContext& ctx) {
3291 ctx.canvas->drawVertices(sk_vertices, SkBlendMode::kSrcOver,
3292 ctx.paint);
3293 },
3294 [=](const DlRenderContext& ctx) {
3295 ctx.canvas->DrawVertices(dl_vertices, DlBlendMode::kSrcOver,
3296 ctx.paint);
3297 },
3298 kDrawVerticesFlags));
3299}
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
Definition: SkVertices.cpp:200

◆ TEST_F() [161/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
DrawVerticesWithImage   
)

Definition at line 3301 of file dl_rendering_unittests.cc.

3301 {
3302 // Cover as many sides of the box with only 6 vertices:
3303 // +----------+
3304 // |xxxxxxxxxx|
3305 // | xxxxxx|
3306 // | xxx|
3307 // |xxx |
3308 // |xxxxxx |
3309 // |xxxxxxxxxx|
3310 // +----------|
3311 const SkPoint pts[6] = {
3312 // Upper-Right corner, full top, half right coverage
3316 // Lower-Left corner, full bottom, half left coverage
3320 };
3321 const SkPoint tex[6] = {
3322 SkPoint::Make(kRenderWidth / 2.0, 0),
3326 SkPoint::Make(0, 0),
3328 };
3329 const std::shared_ptr<DlVertices> dl_vertices =
3330 DlVertices::Make(DlVertexMode::kTriangles, 6, pts, tex, nullptr);
3331 const auto sk_vertices = SkVertices::MakeCopy(
3332 SkVertices::VertexMode::kTriangles_VertexMode, 6, pts, tex, nullptr);
3333
3334 CanvasCompareTester::RenderAll( //
3335 TestParameters(
3336 [=](const SkRenderContext& ctx) { //
3337 SkPaint v_paint = ctx.paint;
3338 if (v_paint.getShader() == nullptr) {
3339 v_paint.setShader(MakeColorSource(ctx.image));
3340 }
3341 ctx.canvas->drawVertices(sk_vertices, SkBlendMode::kSrcOver,
3342 v_paint);
3343 },
3344 [=](const DlRenderContext& ctx) { //
3345 DlPaint v_paint = ctx.paint;
3346 if (v_paint.getColorSource() == nullptr) {
3347 v_paint.setColorSource(MakeColorSource(ctx.image));
3348 }
3349 ctx.canvas->DrawVertices(dl_vertices, DlBlendMode::kSrcOver,
3350 v_paint);
3351 },
3352 kDrawVerticesFlags));
3353}
SkShader * getShader() const
Definition: SkPaint.h:397

◆ TEST_F() [162/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
MatrixColorFilterModifyTransparencyCheck   
)

Definition at line 4037 of file dl_rendering_unittests.cc.

4037 {
4038 auto test_matrix = [](int element, SkScalar value) {
4039 // clang-format off
4040 float matrix[] = {
4041 1, 0, 0, 0, 0,
4042 0, 1, 0, 0, 0,
4043 0, 0, 1, 0, 0,
4044 0, 0, 0, 1, 0,
4045 };
4046 // clang-format on
4047 std::string desc =
4048 "matrix[" + std::to_string(element) + "] = " + std::to_string(value);
4049 float original_value = matrix[element];
4050 matrix[element] = value;
4052 auto dl_filter = DlMatrixColorFilter::Make(matrix);
4053 bool is_identity = (dl_filter == nullptr || original_value == value);
4054
4055 DlPaint paint(DlColor(0x7f7f7f7f));
4056 DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);
4057
4058 DisplayListBuilder builder1;
4060 builder1.Rotate(45);
4061 builder1.Translate(-kTestCenter.fX, -kTestCenter.fY);
4062 builder1.DrawRect(kRenderBounds, paint);
4063 auto display_list1 = builder1.Build();
4064
4065 DisplayListBuilder builder2;
4067 builder2.Rotate(45);
4068 builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
4069 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4070 builder2.DrawRect(kRenderBounds, paint);
4071 builder2.Restore();
4072 auto display_list2 = builder2.Build();
4073
4074 for (auto& back_end : CanvasCompareTester::TestBackends) {
4075 auto provider = CanvasCompareTester::GetProvider(back_end);
4076 auto env = std::make_unique<RenderEnvironment>(
4077 provider.get(), PixelFormat::kN32PremulPixelFormat);
4078 auto results1 = env->getResult(display_list1);
4079 auto results2 = env->getResult(display_list2);
4080 CanvasCompareTester::quickCompareToReference(
4081 results1.get(), results2.get(), is_identity,
4082 desc + " filter affects rendering");
4083 int modified_transparent_pixels =
4084 CanvasCompareTester::countModifiedTransparentPixels(results1.get(),
4085 results2.get());
4086 EXPECT_EQ(filter.modifies_transparent_black(),
4087 modified_transparent_pixels != 0)
4088 << desc;
4089 }
4090 };
4091
4092 // Tests identity (matrix[0] already == 1 in an identity filter)
4093 test_matrix(0, 1);
4094 // test_matrix(19, 1);
4095 for (int i = 0; i < 20; i++) {
4096 test_matrix(i, -0.25);
4097 test_matrix(i, 0);
4098 test_matrix(i, 0.25);
4099 test_matrix(i, 1);
4100 test_matrix(i, 1.25);
4104 }
4105}
static bool is_identity(const SkMatrix &m)
Definition: MatrixTest.cpp:89

◆ TEST_F() [163/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
MatrixColorFilterOpacityCommuteCheck   
)

Definition at line 4107 of file dl_rendering_unittests.cc.

4107 {
4108 auto test_matrix = [](int element, SkScalar value) {
4109 // clang-format off
4110 float matrix[] = {
4111 1, 0, 0, 0, 0,
4112 0, 1, 0, 0, 0,
4113 0, 0, 1, 0, 0,
4114 0, 0, 0, 1, 0,
4115 };
4116 // clang-format on
4117 std::string desc =
4118 "matrix[" + std::to_string(element) + "] = " + std::to_string(value);
4119 matrix[element] = value;
4120 auto filter = DlMatrixColorFilter::Make(matrix);
4121 EXPECT_EQ(std::isfinite(value), filter != nullptr);
4122
4123 DlPaint paint(DlColor(0x80808080));
4124 DlPaint opacity_save_paint = DlPaint().setOpacity(0.5);
4125 DlPaint filter_save_paint = DlPaint().setColorFilter(filter);
4126
4127 DisplayListBuilder builder1;
4128 builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
4129 builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
4130 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4131 builder1.DrawRect(kRenderBounds, paint);
4132 builder1.Restore();
4133 builder1.Restore();
4134 auto display_list1 = builder1.Build();
4135
4136 DisplayListBuilder builder2;
4137 builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4138 builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
4139 // builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
4140 builder2.DrawRect(kRenderBounds, paint);
4141 builder2.Restore();
4142 builder2.Restore();
4143 auto display_list2 = builder2.Build();
4144
4145 for (auto& back_end : CanvasCompareTester::TestBackends) {
4146 auto provider = CanvasCompareTester::GetProvider(back_end);
4147 auto env = std::make_unique<RenderEnvironment>(
4148 provider.get(), PixelFormat::kN32PremulPixelFormat);
4149 auto results1 = env->getResult(display_list1);
4150 auto results2 = env->getResult(display_list2);
4151 if (!filter || filter->can_commute_with_opacity()) {
4152 CanvasCompareTester::compareToReference(
4153 results2.get(), results1.get(), desc, nullptr, nullptr,
4155 } else {
4156 CanvasCompareTester::quickCompareToReference(
4157 results1.get(), results2.get(), false, desc);
4158 }
4159 }
4160 };
4161
4162 // Tests identity (matrix[0] already == 1 in an identity filter)
4163 test_matrix(0, 1);
4164 // test_matrix(19, 1);
4165 for (int i = 0; i < 20; i++) {
4166 test_matrix(i, -0.25);
4167 test_matrix(i, 0);
4168 test_matrix(i, 0.25);
4169 test_matrix(i, 1);
4170 test_matrix(i, 1.1);
4174 }
4175}
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003

◆ TEST_F() [164/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
SaveLayerClippedContentStillFilters   
)

Definition at line 3800 of file dl_rendering_unittests.cc.

3800 {
3801 // draw rect is just outside of render bounds on the right
3803 kRenderRight + 1, //
3804 kRenderTop, //
3806 kRenderBottom //
3807 );
3808 TestParameters test_params(
3809 [=](const SkRenderContext& ctx) {
3810 auto layer_filter =
3811 SkImageFilters::Blur(10.0f, 10.0f, SkTileMode::kDecal, nullptr);
3812 SkPaint layer_paint;
3813 layer_paint.setImageFilter(layer_filter);
3814 ctx.canvas->save();
3815 ctx.canvas->clipRect(kRenderBounds, SkClipOp::kIntersect, false);
3816 ctx.canvas->saveLayer(&kTestBounds2, &layer_paint);
3817 ctx.canvas->drawRect(draw_rect, ctx.paint);
3818 ctx.canvas->restore();
3819 ctx.canvas->restore();
3820 },
3821 [=](const DlRenderContext& ctx) {
3822 auto layer_filter =
3823 DlBlurImageFilter::Make(10.0f, 10.0f, DlTileMode::kDecal);
3824 DlPaint layer_paint;
3825 layer_paint.setImageFilter(layer_filter);
3826 ctx.canvas->Save();
3827 ctx.canvas->ClipRect(kRenderBounds, ClipOp::kIntersect, false);
3828 ctx.canvas->SaveLayer(&kTestBounds2, &layer_paint);
3829 ctx.canvas->DrawRect(draw_rect, ctx.paint);
3830 ctx.canvas->Restore();
3831 ctx.canvas->Restore();
3832 },
3833 kSaveLayerWithPaintFlags);
3834 CaseParameters case_params("Filtered SaveLayer with clipped content");
3835 BoundsTolerance tolerance = BoundsTolerance().addAbsolutePadding(6.0f, 6.0f);
3836
3837 for (auto& back_end : CanvasCompareTester::TestBackends) {
3838 auto provider = CanvasCompareTester::GetProvider(back_end);
3839 RenderEnvironment env = RenderEnvironment::MakeN32(provider.get());
3840 env.init_ref(kEmptySkSetup, test_params.sk_renderer(), //
3841 kEmptyDlSetup, test_params.dl_renderer(),
3842 test_params.imp_renderer());
3843 CanvasCompareTester::quickCompareToReference(env, "default");
3844 CanvasCompareTester::RenderWith(test_params, env, tolerance, case_params);
3845 }
3846}
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
static const DlSetup kEmptyDlSetup
static const SkSetup kEmptySkSetup
static void draw_rect(SkCanvas *canvas, const SkRect &r, const SkPaint &p)

◆ TEST_F() [165/925]

flutter::testing::TEST_F ( DisplayListRendering  ,
SaveLayerConsolidation   
)

Definition at line 3848 of file dl_rendering_unittests.cc.

3848 {
3849 float commutable_color_matrix[]{
3850 // clang-format off
3851 0, 1, 0, 0, 0,
3852 0, 0, 1, 0, 0,
3853 1, 0, 0, 0, 0,
3854 0, 0, 0, 1, 0,
3855 // clang-format on
3856 };
3857 float non_commutable_color_matrix[]{
3858 // clang-format off
3859 0, 1, 0, .1, 0,
3860 0, 0, 1, .1, 0,
3861 1, 0, 0, .1, 0,
3862 0, 0, 0, .7, 0,
3863 // clang-format on
3864 };
3865 SkMatrix contract_matrix;
3866 contract_matrix.setScale(0.9f, 0.9f, kRenderCenterX, kRenderCenterY);
3867
3868 std::vector<SkScalar> opacities = {
3869 0,
3870 0.5f,
3871 SK_Scalar1,
3872 };
3873 std::vector<std::shared_ptr<DlColorFilter>> color_filters = {
3874 std::make_shared<DlBlendColorFilter>(DlColor::kCyan(),
3875 DlBlendMode::kSrcATop),
3876 std::make_shared<DlMatrixColorFilter>(commutable_color_matrix),
3877 std::make_shared<DlMatrixColorFilter>(non_commutable_color_matrix),
3878 DlSrgbToLinearGammaColorFilter::kInstance,
3879 DlLinearToSrgbGammaColorFilter::kInstance,
3880 };
3881 std::vector<std::shared_ptr<DlImageFilter>> image_filters = {
3882 std::make_shared<DlBlurImageFilter>(5.0f, 5.0f, DlTileMode::kDecal),
3883 std::make_shared<DlDilateImageFilter>(5.0f, 5.0f),
3884 std::make_shared<DlErodeImageFilter>(5.0f, 5.0f),
3885 std::make_shared<DlMatrixImageFilter>(contract_matrix,
3887 };
3888
3889 auto render_content = [](DisplayListBuilder& builder) {
3890 builder.DrawRect(
3893 builder.DrawRect(
3896 builder.DrawRect(
3899 builder.DrawRect(
3901 DlPaint(DlColor::kRed().modulateOpacity(0.5f)));
3902 };
3903
3904 auto test_attributes_env =
3905 [render_content](DlPaint& paint1, DlPaint& paint2,
3906 const DlPaint& paint_both, bool same, bool rev_same,
3907 const std::string& desc1, const std::string& desc2,
3908 const RenderEnvironment* env) {
3909 DisplayListBuilder nested_builder;
3910 nested_builder.SaveLayer(&kTestBounds2, &paint1);
3911 nested_builder.SaveLayer(&kTestBounds2, &paint2);
3912 render_content(nested_builder);
3913 auto nested_results = env->getResult(nested_builder.Build());
3914
3915 DisplayListBuilder reverse_builder;
3916 reverse_builder.SaveLayer(&kTestBounds2, &paint2);
3917 reverse_builder.SaveLayer(&kTestBounds2, &paint1);
3918 render_content(reverse_builder);
3919 auto reverse_results = env->getResult(reverse_builder.Build());
3920
3921 DisplayListBuilder combined_builder;
3922 combined_builder.SaveLayer(&kTestBounds2, &paint_both);
3923 render_content(combined_builder);
3924 auto combined_results = env->getResult(combined_builder.Build());
3925
3926 // Set this boolean to true to test if combinations that are marked
3927 // as incompatible actually are compatible despite our predictions.
3928 // Some of the combinations that we treat as incompatible actually
3929 // are compatible with swapping the order of the operations, but
3930 // it would take a bit of new infrastructure to really identify
3931 // those combinations. The only hard constraint to test here is
3932 // when we claim that they are compatible and they aren't.
3933 const bool always = false;
3934
3935 // In some circumstances, Skia can combine image filter evaluations
3936 // and elide a renderpass. In this case rounding and precision of inputs
3937 // to color filters may cause the output to differ by 1.
3938 if (always || same) {
3939 CanvasCompareTester::compareToReference(
3940 nested_results.get(), combined_results.get(),
3941 "nested " + desc1 + " then " + desc2, /*bounds=*/nullptr,
3942 /*tolerance=*/nullptr, DlColor::kTransparent(),
3943 /*fuzzyCompares=*/true, combined_results->width(),
3944 combined_results->height(), /*printMismatches=*/true);
3945 }
3946 if (always || rev_same) {
3947 CanvasCompareTester::compareToReference(
3948 reverse_results.get(), combined_results.get(),
3949 "nested " + desc2 + " then " + desc1, /*bounds=*/nullptr,
3950 /*tolerance=*/nullptr, DlColor::kTransparent(),
3951 /*fuzzyCompares=*/true, combined_results->width(),
3952 combined_results->height(), /*printMismatches=*/true);
3953 }
3954 };
3955
3956 auto test_attributes = [test_attributes_env](DlPaint& paint1, DlPaint& paint2,
3957 const DlPaint& paint_both,
3958 bool same, bool rev_same,
3959 const std::string& desc1,
3960 const std::string& desc2) {
3961 for (auto& back_end : CanvasCompareTester::TestBackends) {
3962 auto provider = CanvasCompareTester::GetProvider(back_end);
3963 auto env = std::make_unique<RenderEnvironment>(
3964 provider.get(), PixelFormat::kN32PremulPixelFormat);
3965 test_attributes_env(paint1, paint2, paint_both, //
3966 same, rev_same, desc1, desc2, env.get());
3967 }
3968 };
3969
3970 // CF then Opacity should always work.
3971 // The reverse sometimes works.
3972 for (size_t cfi = 0; cfi < color_filters.size(); cfi++) {
3973 auto color_filter = color_filters[cfi];
3974 std::string cf_desc = "color filter #" + std::to_string(cfi + 1);
3975 DlPaint nested_paint1 = DlPaint().setColorFilter(color_filter);
3976
3977 for (size_t oi = 0; oi < opacities.size(); oi++) {
3978 SkScalar opacity = opacities[oi];
3979 std::string op_desc = "opacity " + std::to_string(opacity);
3980 DlPaint nested_paint2 = DlPaint().setOpacity(opacity);
3981
3982 DlPaint combined_paint = nested_paint1;
3983 combined_paint.setOpacity(opacity);
3984
3985 bool op_then_cf_works = opacity <= 0.0 || opacity >= 1.0 ||
3986 color_filter->can_commute_with_opacity();
3987
3988 test_attributes(nested_paint1, nested_paint2, combined_paint, true,
3989 op_then_cf_works, cf_desc, op_desc);
3990 }
3991 }
3992
3993 // Opacity then IF should always work.
3994 // The reverse can also work for some values of opacity.
3995 // The reverse should also theoretically work for some IFs, but we
3996 // get some rounding errors that are more than just trivial.
3997 for (size_t oi = 0; oi < opacities.size(); oi++) {
3998 SkScalar opacity = opacities[oi];
3999 std::string op_desc = "opacity " + std::to_string(opacity);
4000 DlPaint nested_paint1 = DlPaint().setOpacity(opacity);
4001
4002 for (size_t ifi = 0; ifi < image_filters.size(); ifi++) {
4003 auto image_filter = image_filters[ifi];
4004 std::string if_desc = "image filter #" + std::to_string(ifi + 1);
4005 DlPaint nested_paint2 = DlPaint().setImageFilter(image_filter);
4006
4007 DlPaint combined_paint = nested_paint1;
4008 combined_paint.setImageFilter(image_filter);
4009
4010 bool if_then_op_works = opacity <= 0.0 || opacity >= 1.0;
4011 test_attributes(nested_paint1, nested_paint2, combined_paint, true,
4012 if_then_op_works, op_desc, if_desc);
4013 }
4014 }
4015
4016 // CF then IF should always work.
4017 // The reverse might work, but we lack the infrastructure to check it.
4018 for (size_t cfi = 0; cfi < color_filters.size(); cfi++) {
4019 auto color_filter = color_filters[cfi];
4020 std::string cf_desc = "color filter #" + std::to_string(cfi + 1);
4021 DlPaint nested_paint1 = DlPaint().setColorFilter(color_filter);
4022
4023 for (size_t ifi = 0; ifi < image_filters.size(); ifi++) {
4024 auto image_filter = image_filters[ifi];
4025 std::string if_desc = "image filter #" + std::to_string(ifi + 1);
4026 DlPaint nested_paint2 = DlPaint().setImageFilter(image_filter);
4027
4028 DlPaint combined_paint = nested_paint1;
4029 combined_paint.setImageFilter(image_filter);
4030
4031 test_attributes(nested_paint1, nested_paint2, combined_paint, true, false,
4032 cf_desc, if_desc);
4033 }
4034 }
4035}
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:296

◆ TEST_F() [166/925]

flutter::testing::TEST_F ( DisplayListTest  ,
AllBlendModeNops   
)

Definition at line 770 of file display_list_unittests.cc.

770 {
772 DlOpReceiver& receiver = ToReceiver(builder);
773 receiver.setBlendMode(DlBlendMode::kSrcOver);
774 sk_sp<DisplayList> dl = builder.Build();
775 ASSERT_EQ(dl->bytes(false), sizeof(DisplayList));
776 ASSERT_EQ(dl->bytes(true), sizeof(DisplayList));
777 ASSERT_EQ(dl->op_count(false), 0u);
778 ASSERT_EQ(dl->op_count(true), 0u);
779 EXPECT_EQ(dl->total_depth(), 0u);
780}
virtual void setBlendMode(DlBlendMode mode)=0

◆ TEST_F() [167/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BackdropDetectionEmptyDisplayList   
)

Definition at line 4246 of file display_list_unittests.cc.

4246 {
4248 EXPECT_FALSE(builder.Build()->root_has_backdrop_filter());
4249}

◆ TEST_F() [168/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BackdropDetectionNestedSaveLayer   
)

Definition at line 4276 of file display_list_unittests.cc.

4276 {
4278 builder.SaveLayer(nullptr, nullptr);
4279 {
4280 // first inner content does have backdrop filter
4281 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10), DlPaint());
4282 builder.SaveLayer(nullptr, nullptr, &kTestBlurImageFilter1);
4283 {
4284 // second inner content has no backdrop filter
4285 builder.DrawRect(SkRect::MakeLTRB(10, 10, 20, 20), DlPaint());
4286 }
4287 builder.Restore();
4288 }
4289 builder.Restore();
4290 auto dl = builder.Build();
4291
4292 EXPECT_FALSE(dl->root_has_backdrop_filter());
4293 SaveLayerExpector expector({
4294 SaveLayerOptions::kNoAttributes.with_contains_backdrop_filter(),
4295 SaveLayerOptions::kNoAttributes.with_can_distribute_opacity(),
4296 });
4297 dl->Dispatch(expector);
4298 EXPECT_TRUE(expector.all_expectations_checked());
4299}

◆ TEST_F() [169/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BackdropDetectionSimpleRect   
)

Definition at line 4251 of file display_list_unittests.cc.

4251 {
4253 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10), DlPaint());
4254 EXPECT_FALSE(builder.Build()->root_has_backdrop_filter());
4255}

◆ TEST_F() [170/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BackdropDetectionSimpleSaveLayer   
)

Definition at line 4257 of file display_list_unittests.cc.

4257 {
4259 builder.SaveLayer(nullptr, nullptr, &kTestBlurImageFilter1);
4260 {
4261 // inner content has no backdrop filter
4262 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10), DlPaint());
4263 }
4264 builder.Restore();
4265 auto dl = builder.Build();
4266
4267 EXPECT_TRUE(dl->root_has_backdrop_filter());
4268 // The saveLayer itself, though, does not have the contains backdrop
4269 // flag set because its content does not contain a saveLayer with backdrop
4270 SaveLayerExpector expector(
4271 SaveLayerOptions::kNoAttributes.with_can_distribute_opacity());
4272 dl->Dispatch(expector);
4273 EXPECT_TRUE(expector.all_expectations_checked());
4274}

◆ TEST_F() [171/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderBoundsTransformComparedToSkia   
)

Definition at line 449 of file display_list_unittests.cc.

449 {
450 const SkRect frame_rect = SkRect::MakeLTRB(10, 10, 100, 100);
451 DisplayListBuilder builder(frame_rect);
452 SkPictureRecorder recorder;
453 SkCanvas* canvas = recorder.beginRecording(frame_rect);
454 ASSERT_EQ(builder.GetDestinationClipBounds(),
456 ASSERT_EQ(builder.GetLocalClipBounds().makeOutset(1, 1),
457 canvas->getLocalClipBounds());
458 ASSERT_EQ(builder.GetTransform(), canvas->getTotalMatrix());
459}
SkRect getLocalClipBounds() const
Definition: SkCanvas.cpp:1586
SkMatrix getTotalMatrix() const
Definition: SkCanvas.cpp:1629
SkIRect getDeviceClipBounds() const
Definition: SkCanvas.cpp:1607

◆ TEST_F() [172/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderCanBeReused   
)

Definition at line 255 of file display_list_unittests.cc.

255 {
257 builder.DrawRect(kTestBounds, DlPaint());
258 auto dl = builder.Build();
259 builder.DrawRect(kTestBounds, DlPaint());
260 auto dl2 = builder.Build();
261 ASSERT_TRUE(dl->Equals(dl2));
262}

◆ TEST_F() [173/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderClipBoundsAfterClipPath   
)

Definition at line 494 of file display_list_unittests.cc.

494 {
495 SkRect cull_rect = SkRect::MakeWH(100, 100);
496 SkPath clip_path = SkPath().addRect(10, 10, 15, 15).addRect(15, 15, 20, 20);
497 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 20, 20);
498 DisplayListBuilder builder(cull_rect);
499 builder.ClipPath(clip_path, ClipOp::kIntersect, false);
500 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
501}

◆ TEST_F() [174/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderClipBoundsAfterClipRect   
)

Definition at line 475 of file display_list_unittests.cc.

475 {
476 SkRect cull_rect = SkRect::MakeWH(100, 100);
477 SkRect clip_rect = SkRect::MakeLTRB(10, 10, 20, 20);
478 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 20, 20);
479 DisplayListBuilder builder(cull_rect);
480 builder.ClipRect(clip_rect, ClipOp::kIntersect, false);
481 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
482}

◆ TEST_F() [175/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderClipBoundsAfterClipRRect   
)

Definition at line 484 of file display_list_unittests.cc.

484 {
485 SkRect cull_rect = SkRect::MakeWH(100, 100);
486 SkRect clip_rect = SkRect::MakeLTRB(10, 10, 20, 20);
487 SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 2, 2);
488 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 20, 20);
489 DisplayListBuilder builder(cull_rect);
490 builder.ClipRRect(clip_rrect, ClipOp::kIntersect, false);
491 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
492}

◆ TEST_F() [176/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderInitialClipBounds   
)

Definition at line 461 of file display_list_unittests.cc.

461 {
462 SkRect cull_rect = SkRect::MakeWH(100, 100);
463 SkRect clip_bounds = SkRect::MakeWH(100, 100);
464 DisplayListBuilder builder(cull_rect);
465 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
466}

◆ TEST_F() [177/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderInitialClipBoundsNaN   
)

Definition at line 468 of file display_list_unittests.cc.

468 {
470 SkRect clip_bounds = SkRect::MakeEmpty();
471 DisplayListBuilder builder(cull_rect);
472 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
473}

◆ TEST_F() [178/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuilderInitialClipBoundsNonZero   
)

Definition at line 503 of file display_list_unittests.cc.

503 {
504 SkRect cull_rect = SkRect::MakeLTRB(10, 10, 100, 100);
505 SkRect clip_bounds = SkRect::MakeLTRB(10, 10, 100, 100);
506 DisplayListBuilder builder(cull_rect);
507 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
508}

◆ TEST_F() [179/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuildRestoresAttributes   
)

Definition at line 391 of file display_list_unittests.cc.

391 {
392 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
393 DisplayListBuilder builder(cull_rect);
394 DlOpReceiver& receiver = ToReceiver(builder);
395
396 receiver.setAntiAlias(true);
397 builder.Build();
398 check_defaults(builder, cull_rect);
399
400 receiver.setInvertColors(true);
401 builder.Build();
402 check_defaults(builder, cull_rect);
403
404 receiver.setColor(DlColor::kRed());
405 builder.Build();
406 check_defaults(builder, cull_rect);
407
408 receiver.setBlendMode(DlBlendMode::kColorBurn);
409 builder.Build();
410 check_defaults(builder, cull_rect);
411
412 receiver.setDrawStyle(DlDrawStyle::kStrokeAndFill);
413 builder.Build();
414 check_defaults(builder, cull_rect);
415
416 receiver.setStrokeWidth(300.0f);
417 builder.Build();
418 check_defaults(builder, cull_rect);
419
420 receiver.setStrokeMiter(300.0f);
421 builder.Build();
422 check_defaults(builder, cull_rect);
423
424 receiver.setStrokeCap(DlStrokeCap::kRound);
425 builder.Build();
426 check_defaults(builder, cull_rect);
427
428 receiver.setStrokeJoin(DlStrokeJoin::kRound);
429 builder.Build();
430 check_defaults(builder, cull_rect);
431
432 receiver.setColorSource(&kTestSource1);
433 builder.Build();
434 check_defaults(builder, cull_rect);
435
437 builder.Build();
438 check_defaults(builder, cull_rect);
439
441 builder.Build();
442 check_defaults(builder, cull_rect);
443
445 builder.Build();
446 check_defaults(builder, cull_rect);
447}
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 setColor(DlColor color)=0
virtual void setInvertColors(bool invert)=0
virtual void setStrokeCap(DlStrokeCap cap)=0

◆ TEST_F() [180/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuildRestoresClip   
)

Definition at line 374 of file display_list_unittests.cc.

374 {
375 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
376 DisplayListBuilder builder(cull_rect);
377
378 builder.ClipRect({0.0f, 0.0f, 10.0f, 10.0f});
379 builder.Build();
380 check_defaults(builder, cull_rect);
381
382 builder.ClipRRect(SkRRect::MakeRectXY({0.0f, 0.0f, 5.0f, 5.0f}, 2.0f, 2.0f));
383 builder.Build();
384 check_defaults(builder, cull_rect);
385
386 builder.ClipPath(SkPath().addOval({0.0f, 0.0f, 10.0f, 10.0f}));
387 builder.Build();
388 check_defaults(builder, cull_rect);
389}

◆ TEST_F() [181/925]

flutter::testing::TEST_F ( DisplayListTest  ,
BuildRestoresTransform   
)

Definition at line 313 of file display_list_unittests.cc.

313 {
314 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
315 DisplayListBuilder builder(cull_rect);
316
317 builder.Translate(10.0f, 10.0f);
318 builder.Build();
319 check_defaults(builder, cull_rect);
320
321 builder.Scale(10.0f, 10.0f);
322 builder.Build();
323 check_defaults(builder, cull_rect);
324
325 builder.Skew(0.1f, 0.1f);
326 builder.Build();
327 check_defaults(builder, cull_rect);
328
329 builder.Rotate(45.0f);
330 builder.Build();
331 check_defaults(builder, cull_rect);
332
333 builder.Transform(SkMatrix::Scale(10.0f, 10.0f));
334 builder.Build();
335 check_defaults(builder, cull_rect);
336
337 builder.Transform2DAffine(1.0f, 0.0f, 12.0f, //
338 0.0f, 1.0f, 35.0f);
339 builder.Build();
340 check_defaults(builder, cull_rect);
341
342 builder.Transform(SkM44(SkMatrix::Scale(10.0f, 10.0f)));
343 builder.Build();
344 check_defaults(builder, cull_rect);
345
346 builder.TransformFullPerspective(1.0f, 0.0f, 0.0f, 12.0f, //
347 0.0f, 1.0f, 0.0f, 35.0f, //
348 0.0f, 0.0f, 1.0f, 5.0f, //
349 0.0f, 0.0f, 0.0f, 1.0f);
350 builder.Build();
351 check_defaults(builder, cull_rect);
352}

◆ TEST_F() [182/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathAffectsClipBounds   
)

Definition at line 2013 of file display_list_unittests.cc.

2013 {
2015 DlOpReceiver& receiver = ToReceiver(builder);
2016 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2017 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
2018 receiver.clipPath(clip, ClipOp::kIntersect, false);
2019
2020 // Save initial return values for testing restored values
2021 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2022 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2023 ASSERT_EQ(initial_local_bounds, clip_bounds);
2024 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2025
2026 receiver.save();
2027 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, false);
2028 // Both clip bounds have changed
2029 ASSERT_NE(builder.GetLocalClipBounds(), clip_bounds);
2030 ASSERT_NE(builder.GetDestinationClipBounds(), clip_bounds);
2031 // Previous return values have not changed
2032 ASSERT_EQ(initial_local_bounds, clip_bounds);
2033 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2034 receiver.restore();
2035
2036 // save/restore returned the values to their original values
2037 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2038 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2039
2040 receiver.save();
2041 receiver.scale(2, 2);
2042 SkRect scaled_clip_bounds = SkRect::MakeLTRB(4.1, 4.65, 11.2, 13.85);
2043 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_clip_bounds);
2044 // Destination bounds are unaffected by transform
2045 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
2046 receiver.restore();
2047
2048 // save/restore returned the values to their original values
2049 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2050 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2051}
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() [183/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathAffectsClipBoundsWithMatrix   
)

Definition at line 2093 of file display_list_unittests.cc.

2093 {
2095 DlOpReceiver& receiver = ToReceiver(builder);
2096 SkRect clip_bounds = SkRect::MakeLTRB(0, 0, 10, 10);
2097 SkPath clip1 = SkPath().addCircle(2.5, 2.5, 2.5).addCircle(7.5, 7.5, 2.5);
2098 SkPath clip2 = SkPath().addCircle(12.5, 12.5, 2.5).addCircle(17.5, 17.5, 2.5);
2099
2100 receiver.save();
2101 receiver.clipPath(clip1, ClipOp::kIntersect, false);
2102 receiver.translate(10, 0);
2103 receiver.clipPath(clip1, ClipOp::kIntersect, false);
2104 ASSERT_TRUE(builder.GetDestinationClipBounds().isEmpty());
2105 receiver.restore();
2106
2107 receiver.save();
2108 receiver.clipPath(clip1, ClipOp::kIntersect, false);
2109 receiver.translate(-10, -10);
2110 receiver.clipPath(clip2, ClipOp::kIntersect, false);
2111 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
2112 receiver.restore();
2113}
virtual void translate(SkScalar tx, SkScalar ty)=0

◆ TEST_F() [184/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathDoAAAffectsClipBounds   
)

Definition at line 2053 of file display_list_unittests.cc.

2053 {
2055 DlOpReceiver& receiver = ToReceiver(builder);
2056 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2057 SkRect clip_expanded_bounds = SkRect::MakeLTRB(8, 9, 23, 28);
2058 receiver.clipPath(clip, ClipOp::kIntersect, true);
2059
2060 // Save initial return values for testing restored values
2061 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2062 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2063 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
2064 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
2065
2066 receiver.save();
2067 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, true);
2068 // Both clip bounds have changed
2069 ASSERT_NE(builder.GetLocalClipBounds(), clip_expanded_bounds);
2070 ASSERT_NE(builder.GetDestinationClipBounds(), clip_expanded_bounds);
2071 // Previous return values have not changed
2072 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
2073 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
2074 receiver.restore();
2075
2076 // save/restore returned the values to their original values
2077 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2078 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2079
2080 receiver.save();
2081 receiver.scale(2, 2);
2082 SkRect scaled_expanded_bounds = SkRect::MakeLTRB(4, 4.5, 11.5, 14);
2083 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_expanded_bounds);
2084 // Destination bounds are unaffected by transform
2085 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_expanded_bounds);
2086 receiver.restore();
2087
2088 // save/restore returned the values to their original values
2089 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2090 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2091}

◆ TEST_F() [185/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathNonCulling   
)

Definition at line 4603 of file display_list_unittests.cc.

4603 {
4604 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4605 SkPath path;
4606 path.moveTo(0.0f, 0.0f);
4607 path.lineTo(1000.0f, 0.0f);
4608 path.lineTo(0.0f, 1000.0f);
4609 path.close();
4610
4611 // Double checking that the path does indeed contain the clip. But,
4612 // sadly, the Builder will not check paths for coverage to this level
4613 // of detail. (In particular, path containment of the corners is not
4614 // authoritative of true containment, but we know in this case that
4615 // a triangle contains a rect if it contains all 4 corners...)
4616 ASSERT_TRUE(path.contains(clip.fLeft, clip.fTop));
4617 ASSERT_TRUE(path.contains(clip.fRight, clip.fTop));
4618 ASSERT_TRUE(path.contains(clip.fRight, clip.fBottom));
4619 ASSERT_TRUE(path.contains(clip.fLeft, clip.fBottom));
4620
4621 DisplayListBuilder cull_builder;
4622 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4623 cull_builder.ClipPath(path, ClipOp::kIntersect, false);
4624 auto cull_dl = cull_builder.Build();
4625
4626 CLIP_EXPECTOR(expector);
4627 expector.addExpectation(clip, ClipOp::kIntersect, false);
4628 expector.addExpectation(path, ClipOp::kIntersect, false);
4629 cull_dl->Dispatch(expector);
4630}
#define CLIP_EXPECTOR(name)

◆ TEST_F() [186/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathRectCulling   
)

Definition at line 4632 of file display_list_unittests.cc.

4632 {
4633 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4634 SkPath path;
4635 path.addRect(clip.makeOutset(1.0f, 1.0f));
4636
4637 DisplayListBuilder cull_builder;
4638 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4639 cull_builder.ClipPath(path, ClipOp::kIntersect, false);
4640 auto cull_dl = cull_builder.Build();
4641
4642 CLIP_EXPECTOR(expector);
4643 expector.addExpectation(clip, ClipOp::kIntersect, false);
4644 cull_dl->Dispatch(expector);
4645}

◆ TEST_F() [187/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathRectNonCulling   
)

Definition at line 4647 of file display_list_unittests.cc.

4647 {
4648 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4649 auto smaller_clip = clip.makeInset(1.0f, 1.0f);
4650 SkPath path;
4651 path.addRect(smaller_clip);
4652
4653 DisplayListBuilder cull_builder;
4654 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4655 cull_builder.ClipPath(path, ClipOp::kIntersect, false);
4656 auto cull_dl = cull_builder.Build();
4657
4658 CLIP_EXPECTOR(expector);
4659 expector.addExpectation(clip, ClipOp::kIntersect, false);
4660 // Builder will not cull this clip, but it will turn it into a ClipRect
4661 expector.addExpectation(smaller_clip, ClipOp::kIntersect, false);
4662 cull_dl->Dispatch(expector);
4663}

◆ TEST_F() [188/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathRRectCulling   
)

Definition at line 4665 of file display_list_unittests.cc.

4665 {
4666 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4667 auto rrect = SkRRect::MakeRectXY(clip.makeOutset(2.0f, 2.0f), 2.0f, 2.0f);
4668 SkPath path;
4669 path.addRRect(rrect);
4670
4671 DisplayListBuilder cull_builder;
4672 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4673 cull_builder.ClipPath(path, ClipOp::kIntersect, false);
4674 auto cull_dl = cull_builder.Build();
4675
4676 CLIP_EXPECTOR(expector);
4677 expector.addExpectation(clip, ClipOp::kIntersect, false);
4678 cull_dl->Dispatch(expector);
4679}

◆ TEST_F() [189/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathRRectNonCulling   
)

Definition at line 4681 of file display_list_unittests.cc.

4681 {
4682 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4683 auto rrect = SkRRect::MakeRectXY(clip.makeOutset(2.0f, 2.0f), 12.0f, 12.0f);
4684 SkPath path;
4685 path.addRRect(rrect);
4686
4687 DisplayListBuilder cull_builder;
4688 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4689 cull_builder.ClipPath(path, ClipOp::kIntersect, false);
4690 auto cull_dl = cull_builder.Build();
4691
4692 CLIP_EXPECTOR(expector);
4693 expector.addExpectation(clip, ClipOp::kIntersect, false);
4694 // Builder will not cull this clip, but it will turn it into a ClipRRect
4695 expector.addExpectation(rrect, ClipOp::kIntersect, false);
4696 cull_dl->Dispatch(expector);
4697}

◆ TEST_F() [190/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathTriggersDeferredSave   
)

Definition at line 2789 of file display_list_unittests.cc.

2789 {
2790 DisplayListBuilder builder1;
2791 DlOpReceiver& receiver1 = ToReceiver(builder1);
2792 receiver1.save();
2793 receiver1.save();
2794 receiver1.clipPath(kTestPath1, ClipOp::kIntersect, true);
2795 receiver1.drawRect({0, 0, 100, 100});
2796 receiver1.restore();
2797 receiver1.transformFullPerspective(1, 0, 0, 0, //
2798 0, 1, 0, 0, //
2799 0, 0, 1, 0, //
2800 0, 0, 0, 1);
2801 receiver1.drawRect({0, 0, 100, 100});
2802 receiver1.restore();
2803 auto display_list1 = builder1.Build();
2804
2805 DisplayListBuilder builder2;
2806 DlOpReceiver& receiver2 = ToReceiver(builder2);
2807 receiver2.save();
2808 receiver2.clipPath(kTestPath1, ClipOp::kIntersect, true);
2809 receiver2.drawRect({0, 0, 100, 100});
2810 receiver2.restore();
2811 receiver2.transformFullPerspective(1, 0, 0, 0, //
2812 0, 1, 0, 0, //
2813 0, 0, 1, 0, //
2814 0, 0, 0, 1);
2815 receiver2.drawRect({0, 0, 100, 100});
2816 auto display_list2 = builder2.Build();
2817
2818 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2819}
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() [191/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipPathWithInvertFillTypeDoesNotAffectClipBounds   
)

Definition at line 2171 of file display_list_unittests.cc.

2171 {
2172 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
2173 DisplayListBuilder builder(cull_rect);
2174 DlOpReceiver& receiver = ToReceiver(builder);
2175 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2177 receiver.clipPath(clip, ClipOp::kIntersect, false);
2178
2179 ASSERT_EQ(builder.GetLocalClipBounds(), cull_rect);
2180 ASSERT_EQ(builder.GetDestinationClipBounds(), cull_rect);
2181}

◆ TEST_F() [192/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClippedSaveLayerContentAccountsForFilter   
)

Definition at line 543 of file display_list_unittests.cc.

543 {
544 SkRect cull_rect = SkRect::MakeLTRB(0.0f, 0.0f, 300.0f, 300.0f);
545 SkRect clip_rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
546 SkRect draw_rect = SkRect::MakeLTRB(50.0f, 140.0f, 99.0f, 160.0f);
547 auto filter = DlBlurImageFilter::Make(10.0f, 10.0f, DlTileMode::kDecal);
548 DlPaint layer_paint = DlPaint().setImageFilter(filter);
549
550 ASSERT_FALSE(clip_rect.intersects(draw_rect));
551 ASSERT_TRUE(cull_rect.contains(clip_rect));
552 ASSERT_TRUE(cull_rect.contains(draw_rect));
553
555 builder.Save();
556 {
557 builder.ClipRect(clip_rect, ClipOp::kIntersect, false);
558 builder.SaveLayer(&cull_rect, &layer_paint);
559 { //
560 builder.DrawRect(draw_rect, DlPaint());
561 }
562 builder.Restore();
563 }
564 builder.Restore();
565 auto display_list = builder.Build();
566
567 EXPECT_EQ(display_list->op_count(), 6u);
568 EXPECT_EQ(display_list->total_depth(), 2u);
569
570 SkRect result_rect = draw_rect.makeOutset(30.0f, 30.0f);
571 ASSERT_TRUE(result_rect.intersect(clip_rect));
572 ASSERT_EQ(result_rect, SkRect::MakeLTRB(100.0f, 110.0f, 129.0f, 190.0f));
573 EXPECT_EQ(display_list->bounds(), result_rect);
574}
bool intersects(const SkRect &r) const
Definition: SkRect.h:1121

◆ TEST_F() [193/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectAffectsClipBounds   
)

Definition at line 1810 of file display_list_unittests.cc.

1810 {
1812 DlOpReceiver& receiver = ToReceiver(builder);
1813 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1814 receiver.clipRect(clip_bounds, ClipOp::kIntersect, false);
1815
1816 // Save initial return values for testing restored values
1817 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1818 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1819 ASSERT_EQ(initial_local_bounds, clip_bounds);
1820 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1821
1822 receiver.save();
1823 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, false);
1824 // Both clip bounds have changed
1825 ASSERT_NE(builder.GetLocalClipBounds(), clip_bounds);
1826 ASSERT_NE(builder.GetDestinationClipBounds(), clip_bounds);
1827 // Previous return values have not changed
1828 ASSERT_EQ(initial_local_bounds, clip_bounds);
1829 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1830 receiver.restore();
1831
1832 // save/restore returned the values to their original values
1833 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1834 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1835
1836 receiver.save();
1837 receiver.scale(2, 2);
1838 SkRect scaled_clip_bounds = SkRect::MakeLTRB(5.1, 5.65, 10.2, 12.85);
1839 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_clip_bounds);
1840 // Destination bounds are unaffected by transform
1841 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
1842 receiver.restore();
1843
1844 // save/restore returned the values to their original values
1845 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1846 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1847}

◆ TEST_F() [194/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectAffectsClipBoundsWithMatrix   
)

Definition at line 1889 of file display_list_unittests.cc.

1889 {
1891 DlOpReceiver& receiver = ToReceiver(builder);
1892 SkRect clip_bounds_1 = SkRect::MakeLTRB(0, 0, 10, 10);
1893 SkRect clip_bounds_2 = SkRect::MakeLTRB(10, 10, 20, 20);
1894 receiver.save();
1895 receiver.clipRect(clip_bounds_1, ClipOp::kIntersect, false);
1896 receiver.translate(10, 0);
1897 receiver.clipRect(clip_bounds_1, ClipOp::kIntersect, false);
1898 ASSERT_TRUE(builder.GetDestinationClipBounds().isEmpty());
1899 receiver.restore();
1900
1901 receiver.save();
1902 receiver.clipRect(clip_bounds_1, ClipOp::kIntersect, false);
1903 receiver.translate(-10, -10);
1904 receiver.clipRect(clip_bounds_2, ClipOp::kIntersect, false);
1905 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds_1);
1906 receiver.restore();
1907}

◆ TEST_F() [195/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectCulling   
)

Definition at line 4472 of file display_list_unittests.cc.

4472 {
4473 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4474
4475 DisplayListBuilder cull_builder;
4476 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4477 cull_builder.ClipRect(clip.makeOutset(1.0f, 1.0f), ClipOp::kIntersect, false);
4478 auto cull_dl = cull_builder.Build();
4479
4480 CLIP_EXPECTOR(expector);
4481 expector.addExpectation(clip, ClipOp::kIntersect, false);
4482 cull_dl->Dispatch(expector);
4483}

◆ TEST_F() [196/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectCullingPixel6a   
)

Definition at line 4448 of file display_list_unittests.cc.

4448 {
4449 // These particular values create bit errors if we use the path that
4450 // tests for inclusion in local space, but work OK if we use a forward
4451 // path that tests for inclusion in device space, due to the fact that
4452 // the extra matrix inversion is just enough math to cause the transform
4453 // to place the local space cull corners just outside the original rect.
4454 // The test in device space only works under a simple scale, such as we
4455 // use for DPR adjustments (and which are not always inversion friendly).
4456
4457 auto frame = SkRect::MakeLTRB(0.0f, 0.0f, 1080.0f, 2400.0f);
4458 DlScalar DPR = 2.625f;
4459 auto clip = SkRect::MakeLTRB(0.0f, 0.0f, 1080.0f / DPR, 2400.0f / DPR);
4460
4461 DisplayListBuilder cull_builder;
4462 cull_builder.ClipRect(frame, ClipOp::kIntersect, false);
4463 cull_builder.Scale(DPR, DPR);
4464 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4465 auto cull_dl = cull_builder.Build();
4466
4467 CLIP_EXPECTOR(expector);
4468 expector.addExpectation(frame, ClipOp::kIntersect, false);
4469 cull_dl->Dispatch(expector);
4470}
void Scale(SkScalar sx, SkScalar sy) override
Definition: dl_builder.cc:807

◆ TEST_F() [197/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectDoAAAffectsClipBounds   
)

Definition at line 1849 of file display_list_unittests.cc.

1849 {
1851 DlOpReceiver& receiver = ToReceiver(builder);
1852 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1853 SkRect clip_expanded_bounds = SkRect::MakeLTRB(10, 11, 21, 26);
1854 receiver.clipRect(clip_bounds, ClipOp::kIntersect, true);
1855
1856 // Save initial return values for testing restored values
1857 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1858 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1859 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1860 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1861
1862 receiver.save();
1863 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, true);
1864 // Both clip bounds have changed
1865 ASSERT_NE(builder.GetLocalClipBounds(), clip_expanded_bounds);
1866 ASSERT_NE(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1867 // Previous return values have not changed
1868 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1869 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1870 receiver.restore();
1871
1872 // save/restore returned the values to their original values
1873 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1874 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1875
1876 receiver.save();
1877 receiver.scale(2, 2);
1878 SkRect scaled_expanded_bounds = SkRect::MakeLTRB(5, 5.5, 10.5, 13);
1879 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_expanded_bounds);
1880 // Destination bounds are unaffected by transform
1881 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1882 receiver.restore();
1883
1884 // save/restore returned the values to their original values
1885 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1886 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1887}

◆ TEST_F() [198/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectNestedCulling   
)

Definition at line 4500 of file display_list_unittests.cc.

4500 {
4501 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4502 auto larger_clip = clip.makeOutset(1.0f, 1.0f);
4503
4504 DisplayListBuilder cull_builder;
4505 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4506 cull_builder.Save();
4507 cull_builder.ClipRect(larger_clip, ClipOp::kIntersect, false);
4508 cull_builder.Restore();
4509 auto cull_dl = cull_builder.Build();
4510
4511 CLIP_EXPECTOR(expector);
4512 expector.addExpectation(clip, ClipOp::kIntersect, false);
4513 cull_dl->Dispatch(expector);
4514}

◆ TEST_F() [199/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectNestedCullingComplex   
)

Definition at line 4534 of file display_list_unittests.cc.

4534 {
4535 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4536 auto smaller_clip = clip.makeInset(1.0f, 1.0f);
4537 auto smallest_clip = clip.makeInset(2.0f, 2.0f);
4538
4539 DisplayListBuilder cull_builder;
4540 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4541 cull_builder.Save();
4542 cull_builder.ClipRect(smallest_clip, ClipOp::kIntersect, false);
4543 cull_builder.ClipRect(smaller_clip, ClipOp::kIntersect, false);
4544 cull_builder.Restore();
4545 auto cull_dl = cull_builder.Build();
4546
4547 CLIP_EXPECTOR(expector);
4548 expector.addExpectation(clip, ClipOp::kIntersect, false);
4549 expector.addExpectation(smallest_clip, ClipOp::kIntersect, false);
4550 cull_dl->Dispatch(expector);
4551}

◆ TEST_F() [200/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectNestedNonCulling   
)

Definition at line 4516 of file display_list_unittests.cc.

4516 {
4517 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4518 auto larger_clip = clip.makeOutset(1.0f, 1.0f);
4519
4520 DisplayListBuilder cull_builder;
4521 cull_builder.Save();
4522 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4523 cull_builder.Restore();
4524 // Should not be culled because we have restored the prior clip
4525 cull_builder.ClipRect(larger_clip, ClipOp::kIntersect, false);
4526 auto cull_dl = cull_builder.Build();
4527
4528 CLIP_EXPECTOR(expector);
4529 expector.addExpectation(clip, ClipOp::kIntersect, false);
4530 expector.addExpectation(larger_clip, ClipOp::kIntersect, false);
4531 cull_dl->Dispatch(expector);
4532}

◆ TEST_F() [201/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectNestedNonCullingComplex   
)

Definition at line 4553 of file display_list_unittests.cc.

4553 {
4554 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4555 auto smaller_clip = clip.makeInset(1.0f, 1.0f);
4556 auto smallest_clip = clip.makeInset(2.0f, 2.0f);
4557
4558 DisplayListBuilder cull_builder;
4559 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4560 cull_builder.Save();
4561 cull_builder.ClipRect(smallest_clip, ClipOp::kIntersect, false);
4562 cull_builder.Restore();
4563 // Would not be culled if it was inside the clip
4564 cull_builder.ClipRect(smaller_clip, ClipOp::kIntersect, false);
4565 auto cull_dl = cull_builder.Build();
4566
4567 CLIP_EXPECTOR(expector);
4568 expector.addExpectation(clip, ClipOp::kIntersect, false);
4569 expector.addExpectation(smallest_clip, ClipOp::kIntersect, false);
4570 expector.addExpectation(smaller_clip, ClipOp::kIntersect, false);
4571 cull_dl->Dispatch(expector);
4572}

◆ TEST_F() [202/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectNonCulling   
)

Definition at line 4485 of file display_list_unittests.cc.

4485 {
4486 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4487 auto smaller_clip = clip.makeInset(1.0f, 1.0f);
4488
4489 DisplayListBuilder cull_builder;
4490 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4491 cull_builder.ClipRect(smaller_clip, ClipOp::kIntersect, false);
4492 auto cull_dl = cull_builder.Build();
4493
4494 CLIP_EXPECTOR(expector);
4495 expector.addExpectation(clip, ClipOp::kIntersect, false);
4496 expector.addExpectation(smaller_clip, ClipOp::kIntersect, false);
4497 cull_dl->Dispatch(expector);
4498}

◆ TEST_F() [203/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRectTriggersDeferredSave   
)

Definition at line 2721 of file display_list_unittests.cc.

2721 {
2722 DisplayListBuilder builder1;
2723 DlOpReceiver& receiver1 = ToReceiver(builder1);
2724 receiver1.save();
2725 receiver1.save();
2726 receiver1.clipRect(SkRect::MakeLTRB(0, 0, 100, 100), ClipOp::kIntersect,
2727 true);
2728 receiver1.drawRect({0, 0, 100, 100});
2729 receiver1.restore();
2730 receiver1.transformFullPerspective(1, 0, 0, 0, //
2731 0, 1, 0, 0, //
2732 0, 0, 1, 0, //
2733 0, 0, 0, 1);
2734 receiver1.drawRect({0, 0, 100, 100});
2735 receiver1.restore();
2736 auto display_list1 = builder1.Build();
2737
2738 DisplayListBuilder builder2;
2739 DlOpReceiver& receiver2 = ToReceiver(builder2);
2740 receiver2.save();
2741 receiver2.clipRect(SkRect::MakeLTRB(0, 0, 100, 100), ClipOp::kIntersect,
2742 true);
2743 receiver2.drawRect({0, 0, 100, 100});
2744 receiver2.restore();
2745 receiver2.transformFullPerspective(1, 0, 0, 0, //
2746 0, 1, 0, 0, //
2747 0, 0, 1, 0, //
2748 0, 0, 0, 1);
2749 receiver2.drawRect({0, 0, 100, 100});
2750 auto display_list2 = builder2.Build();
2751
2752 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2753}

◆ TEST_F() [204/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectAffectsClipBounds   
)

Definition at line 1909 of file display_list_unittests.cc.

1909 {
1911 DlOpReceiver& receiver = ToReceiver(builder);
1912 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1913 SkRRect clip = SkRRect::MakeRectXY(clip_bounds, 3, 2);
1914 receiver.clipRRect(clip, ClipOp::kIntersect, false);
1915
1916 // Save initial return values for testing restored values
1917 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1918 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1919 ASSERT_EQ(initial_local_bounds, clip_bounds);
1920 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1921
1922 receiver.save();
1923 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, false);
1924 // Both clip bounds have changed
1925 ASSERT_NE(builder.GetLocalClipBounds(), clip_bounds);
1926 ASSERT_NE(builder.GetDestinationClipBounds(), clip_bounds);
1927 // Previous return values have not changed
1928 ASSERT_EQ(initial_local_bounds, clip_bounds);
1929 ASSERT_EQ(initial_destination_bounds, clip_bounds);
1930 receiver.restore();
1931
1932 // save/restore returned the values to their original values
1933 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1934 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1935
1936 receiver.save();
1937 receiver.scale(2, 2);
1938 SkRect scaled_clip_bounds = SkRect::MakeLTRB(5.1, 5.65, 10.2, 12.85);
1939 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_clip_bounds);
1940 // Destination bounds are unaffected by transform
1941 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
1942 receiver.restore();
1943
1944 // save/restore returned the values to their original values
1945 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1946 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1947}
virtual void clipRRect(const SkRRect &rrect, ClipOp clip_op, bool is_aa)=0

◆ TEST_F() [205/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectAffectsClipBoundsWithMatrix   
)

Definition at line 1990 of file display_list_unittests.cc.

1990 {
1992 DlOpReceiver& receiver = ToReceiver(builder);
1993 SkRect clip_bounds_1 = SkRect::MakeLTRB(0, 0, 10, 10);
1994 SkRect clip_bounds_2 = SkRect::MakeLTRB(10, 10, 20, 20);
1995 SkRRect clip1 = SkRRect::MakeRectXY(clip_bounds_1, 3, 2);
1996 SkRRect clip2 = SkRRect::MakeRectXY(clip_bounds_2, 3, 2);
1997
1998 receiver.save();
1999 receiver.clipRRect(clip1, ClipOp::kIntersect, false);
2000 receiver.translate(10, 0);
2001 receiver.clipRRect(clip1, ClipOp::kIntersect, false);
2002 ASSERT_TRUE(builder.GetDestinationClipBounds().isEmpty());
2003 receiver.restore();
2004
2005 receiver.save();
2006 receiver.clipRRect(clip1, ClipOp::kIntersect, false);
2007 receiver.translate(-10, -10);
2008 receiver.clipRRect(clip2, ClipOp::kIntersect, false);
2009 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds_1);
2010 receiver.restore();
2011}

◆ TEST_F() [206/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectCulling   
)

Definition at line 4574 of file display_list_unittests.cc.

4574 {
4575 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4576 auto rrect = SkRRect::MakeRectXY(clip.makeOutset(2.0f, 2.0f), 2.0f, 2.0f);
4577
4578 DisplayListBuilder cull_builder;
4579 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4580 cull_builder.ClipRRect(rrect, ClipOp::kIntersect, false);
4581 auto cull_dl = cull_builder.Build();
4582
4583 CLIP_EXPECTOR(expector);
4584 expector.addExpectation(clip, ClipOp::kIntersect, false);
4585 cull_dl->Dispatch(expector);
4586}
void ClipRRect(const SkRRect &rrect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false) override
Definition: dl_builder.cc:966

◆ TEST_F() [207/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectDoAAAffectsClipBounds   
)

Definition at line 1949 of file display_list_unittests.cc.

1949 {
1951 DlOpReceiver& receiver = ToReceiver(builder);
1952 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
1953 SkRect clip_expanded_bounds = SkRect::MakeLTRB(10, 11, 21, 26);
1954 SkRRect clip = SkRRect::MakeRectXY(clip_bounds, 3, 2);
1955 receiver.clipRRect(clip, ClipOp::kIntersect, true);
1956
1957 // Save initial return values for testing restored values
1958 SkRect initial_local_bounds = builder.GetLocalClipBounds();
1959 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
1960 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1961 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1962
1963 receiver.save();
1964 receiver.clipRect({0, 0, 15, 15}, ClipOp::kIntersect, true);
1965 // Both clip bounds have changed
1966 ASSERT_NE(builder.GetLocalClipBounds(), clip_expanded_bounds);
1967 ASSERT_NE(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1968 // Previous return values have not changed
1969 ASSERT_EQ(initial_local_bounds, clip_expanded_bounds);
1970 ASSERT_EQ(initial_destination_bounds, clip_expanded_bounds);
1971 receiver.restore();
1972
1973 // save/restore returned the values to their original values
1974 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1975 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1976
1977 receiver.save();
1978 receiver.scale(2, 2);
1979 SkRect scaled_expanded_bounds = SkRect::MakeLTRB(5, 5.5, 10.5, 13);
1980 ASSERT_EQ(builder.GetLocalClipBounds(), scaled_expanded_bounds);
1981 // Destination bounds are unaffected by transform
1982 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_expanded_bounds);
1983 receiver.restore();
1984
1985 // save/restore returned the values to their original values
1986 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
1987 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
1988}

◆ TEST_F() [208/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectNonCulling   
)

Definition at line 4588 of file display_list_unittests.cc.

4588 {
4589 auto clip = SkRect::MakeLTRB(10.0f, 10.0f, 20.0f, 20.0f);
4590 auto rrect = SkRRect::MakeRectXY(clip.makeOutset(2.0f, 2.0f), 12.0f, 12.0f);
4591
4592 DisplayListBuilder cull_builder;
4593 cull_builder.ClipRect(clip, ClipOp::kIntersect, false);
4594 cull_builder.ClipRRect(rrect, ClipOp::kIntersect, false);
4595 auto cull_dl = cull_builder.Build();
4596
4597 CLIP_EXPECTOR(expector);
4598 expector.addExpectation(clip, ClipOp::kIntersect, false);
4599 expector.addExpectation(rrect, ClipOp::kIntersect, false);
4600 cull_dl->Dispatch(expector);
4601}

◆ TEST_F() [209/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ClipRRectTriggersDeferredSave   
)

Definition at line 2755 of file display_list_unittests.cc.

2755 {
2756 DisplayListBuilder builder1;
2757 DlOpReceiver& receiver1 = ToReceiver(builder1);
2758 receiver1.save();
2759 receiver1.save();
2760 receiver1.clipRRect(kTestRRect, ClipOp::kIntersect, true);
2761
2762 receiver1.drawRect({0, 0, 100, 100});
2763 receiver1.restore();
2764 receiver1.transformFullPerspective(1, 0, 0, 0, //
2765 0, 1, 0, 0, //
2766 0, 0, 1, 0, //
2767 0, 0, 0, 1);
2768 receiver1.drawRect({0, 0, 100, 100});
2769 receiver1.restore();
2770 auto display_list1 = builder1.Build();
2771
2772 DisplayListBuilder builder2;
2773 DlOpReceiver& receiver2 = ToReceiver(builder2);
2774 receiver2.save();
2775 receiver2.clipRRect(kTestRRect, ClipOp::kIntersect, true);
2776
2777 receiver2.drawRect({0, 0, 100, 100});
2778 receiver2.restore();
2779 receiver2.transformFullPerspective(1, 0, 0, 0, //
2780 0, 1, 0, 0, //
2781 0, 0, 1, 0, //
2782 0, 0, 0, 1);
2783 receiver2.drawRect({0, 0, 100, 100});
2784 auto display_list2 = builder2.Build();
2785
2786 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2787}

◆ TEST_F() [210/925]

flutter::testing::TEST_F ( DisplayListTest  ,
CollapseMultipleNestedSaveRestore   
)

Definition at line 2438 of file display_list_unittests.cc.

2438 {
2439 DisplayListBuilder builder1;
2440 DlOpReceiver& receiver1 = ToReceiver(builder1);
2441 receiver1.save();
2442 receiver1.save();
2443 receiver1.save();
2444 receiver1.translate(10, 10);
2445 receiver1.scale(2, 2);
2446 receiver1.clipRect({10, 10, 20, 20}, ClipOp::kIntersect, false);
2447 receiver1.drawRect({0, 0, 100, 100});
2448 receiver1.restore();
2449 receiver1.restore();
2450 receiver1.restore();
2451 auto display_list1 = builder1.Build();
2452
2453 DisplayListBuilder builder2;
2454 DlOpReceiver& receiver2 = ToReceiver(builder2);
2455 receiver2.save();
2456 receiver2.translate(10, 10);
2457 receiver2.scale(2, 2);
2458 receiver2.clipRect({10, 10, 20, 20}, ClipOp::kIntersect, false);
2459 receiver2.drawRect({0, 0, 100, 100});
2460 receiver2.restore();
2461 auto display_list2 = builder2.Build();
2462
2463 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2464}

◆ TEST_F() [211/925]

flutter::testing::TEST_F ( DisplayListTest  ,
CollapseNestedSaveAndSaveLayerRestore   
)

Definition at line 2466 of file display_list_unittests.cc.

2466 {
2467 DisplayListBuilder builder1;
2468 DlOpReceiver& receiver1 = ToReceiver(builder1);
2469 receiver1.save();
2470 receiver1.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
2471 receiver1.drawRect({0, 0, 100, 100});
2472 receiver1.scale(2, 2);
2473 receiver1.restore();
2474 receiver1.restore();
2475 auto display_list1 = builder1.Build();
2476
2477 DisplayListBuilder builder2;
2478 DlOpReceiver& receiver2 = ToReceiver(builder2);
2479 receiver2.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
2480 receiver2.drawRect({0, 0, 100, 100});
2481 receiver2.scale(2, 2);
2482 receiver2.restore();
2483 auto display_list2 = builder2.Build();
2484
2485 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2486}
virtual void saveLayer(const SkRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr)=0

◆ TEST_F() [212/925]

flutter::testing::TEST_F ( DisplayListTest  ,
CrossOfNonOverlappingOpsSupportGroupOpacity   
)

Definition at line 1222 of file display_list_unittests.cc.

1222 {
1224 builder.DrawRect(SkRect::MakeLTRB(200, 200, 300, 300), DlPaint()); // center
1225 builder.DrawRect(SkRect::MakeLTRB(100, 200, 200, 300), DlPaint()); // left
1226 builder.DrawRect(SkRect::MakeLTRB(200, 100, 300, 200), DlPaint()); // above
1227 builder.DrawRect(SkRect::MakeLTRB(300, 200, 400, 300), DlPaint()); // right
1228 builder.DrawRect(SkRect::MakeLTRB(200, 300, 300, 400), DlPaint()); // below
1229 auto display_list = builder.Build();
1230 EXPECT_TRUE(display_list->can_apply_group_opacity());
1231}

◆ TEST_F() [213/925]

flutter::testing::TEST_F ( DisplayListTest  ,
Defaults   
)

Definition at line 233 of file display_list_unittests.cc.

233 {
235 check_defaults(builder);
236}

◆ TEST_F() [214/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipPathDoesNotAffectClipBounds   
)

Definition at line 2152 of file display_list_unittests.cc.

2152 {
2154 DlOpReceiver& receiver = ToReceiver(builder);
2155 SkPath diff_clip = SkPath().addRect({0, 0, 15, 15});
2156 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2157 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
2158 receiver.clipPath(clip, ClipOp::kIntersect, false);
2159
2160 // Save initial return values for testing after kDifference clip
2161 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2162 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2163 ASSERT_EQ(initial_local_bounds, clip_bounds);
2164 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2165
2166 receiver.clipPath(diff_clip, ClipOp::kDifference, false);
2167 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2168 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2169}

◆ TEST_F() [215/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipPathWithInvertFillTypeAffectsClipBounds   
)

Definition at line 2183 of file display_list_unittests.cc.

2183 {
2184 SkRect cull_rect = SkRect::MakeLTRB(0, 0, 100.0, 100.0);
2185 DisplayListBuilder builder(cull_rect);
2186 DlOpReceiver& receiver = ToReceiver(builder);
2187 SkPath clip = SkPath().addCircle(10.2, 11.3, 2).addCircle(20.4, 25.7, 2);
2189 SkRect clip_bounds = SkRect::MakeLTRB(8.2, 9.3, 22.4, 27.7);
2190 receiver.clipPath(clip, ClipOp::kDifference, false);
2191
2192 ASSERT_EQ(builder.GetLocalClipBounds(), clip_bounds);
2193 ASSERT_EQ(builder.GetDestinationClipBounds(), clip_bounds);
2194}

◆ TEST_F() [216/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipRectDoesNotAffectClipBounds   
)

Definition at line 2115 of file display_list_unittests.cc.

2115 {
2117 DlOpReceiver& receiver = ToReceiver(builder);
2118 SkRect diff_clip = SkRect::MakeLTRB(0, 0, 15, 15);
2119 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
2120 receiver.clipRect(clip_bounds, ClipOp::kIntersect, false);
2121
2122 // Save initial return values for testing after kDifference clip
2123 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2124 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2125 ASSERT_EQ(initial_local_bounds, clip_bounds);
2126 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2127
2128 receiver.clipRect(diff_clip, ClipOp::kDifference, false);
2129 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2130 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2131}

◆ TEST_F() [217/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DiffClipRRectDoesNotAffectClipBounds   
)

Definition at line 2133 of file display_list_unittests.cc.

2133 {
2135 DlOpReceiver& receiver = ToReceiver(builder);
2136 SkRRect diff_clip = SkRRect::MakeRectXY({0, 0, 15, 15}, 1, 1);
2137 SkRect clip_bounds = SkRect::MakeLTRB(10.2, 11.3, 20.4, 25.7);
2138 SkRRect clip = SkRRect::MakeRectXY({10.2, 11.3, 20.4, 25.7}, 3, 2);
2139 receiver.clipRRect(clip, ClipOp::kIntersect, false);
2140
2141 // Save initial return values for testing after kDifference clip
2142 SkRect initial_local_bounds = builder.GetLocalClipBounds();
2143 SkRect initial_destination_bounds = builder.GetDestinationClipBounds();
2144 ASSERT_EQ(initial_local_bounds, clip_bounds);
2145 ASSERT_EQ(initial_destination_bounds, clip_bounds);
2146
2147 receiver.clipRRect(diff_clip, ClipOp::kDifference, false);
2148 ASSERT_EQ(builder.GetLocalClipBounds(), initial_local_bounds);
2149 ASSERT_EQ(builder.GetDestinationClipBounds(), initial_destination_bounds);
2150}

◆ TEST_F() [218/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListFullPerspectiveTransformHandling   
)

Definition at line 1027 of file display_list_unittests.cc.

1027 {
1028 // SkM44 constructor takes row-major order
1030 // clang-format off
1031 1, 2, 3, 4,
1032 5, 6, 7, 8,
1033 9, 10, 11, 12,
1034 13, 14, 15, 16
1035 // clang-format on
1036 );
1037
1038 { // First test ==
1040 DlOpReceiver& receiver = ToReceiver(builder);
1041 // receiver.transformFullPerspective takes row-major order
1042 receiver.transformFullPerspective(
1043 // clang-format off
1044 1, 2, 3, 4,
1045 5, 6, 7, 8,
1046 9, 10, 11, 12,
1047 13, 14, 15, 16
1048 // clang-format on
1049 );
1050 sk_sp<DisplayList> display_list = builder.Build();
1053 SkCanvas* canvas = surface->getCanvas();
1054 // We can't use DlSkCanvas.DrawDisplayList as that method protects
1055 // the canvas against mutations from the display list being drawn.
1056 auto dispatcher = DlSkCanvasDispatcher(surface->getCanvas());
1057 display_list->Dispatch(dispatcher);
1058 SkM44 dl_matrix = canvas->getLocalToDevice();
1059 ASSERT_EQ(sk_matrix, dl_matrix);
1060 }
1061 { // Next test !=
1063 DlOpReceiver& receiver = ToReceiver(builder);
1064 // receiver.transformFullPerspective takes row-major order
1065 receiver.transformFullPerspective(
1066 // clang-format off
1067 1, 5, 9, 13,
1068 2, 6, 7, 11,
1069 3, 7, 11, 15,
1070 4, 8, 12, 16
1071 // clang-format on
1072 );
1073 sk_sp<DisplayList> display_list = builder.Build();
1076 SkCanvas* canvas = surface->getCanvas();
1077 // We can't use DlSkCanvas.DrawDisplayList as that method protects
1078 // the canvas against mutations from the display list being drawn.
1079 auto dispatcher = DlSkCanvasDispatcher(surface->getCanvas());
1080 display_list->Dispatch(dispatcher);
1081 SkM44 dl_matrix = canvas->getLocalToDevice();
1082 ASSERT_NE(sk_matrix, dl_matrix);
1083 }
1084}
SkM44 getLocalToDevice() const
Definition: SkCanvas.cpp:1633
SkMatrix sk_matrix

◆ TEST_F() [219/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListSaveLayerBoundsWithAlphaFilter   
)

Definition at line 815 of file display_list_unittests.cc.

815 {
816 SkRect build_bounds = SkRect::MakeLTRB(-100, -100, 200, 200);
817 SkRect save_bounds = SkRect::MakeWH(100, 100);
818 SkRect rect = SkRect::MakeLTRB(30, 30, 70, 70);
819 // clang-format off
820 const float color_matrix[] = {
821 0, 0, 0, 0, 0,
822 0, 1, 0, 0, 0,
823 0, 0, 1, 0, 0,
824 0, 0, 0, 1, 0,
825 };
826 // clang-format on
827 DlMatrixColorFilter base_color_filter(color_matrix);
828 // clang-format off
829 const float alpha_matrix[] = {
830 0, 0, 0, 0, 0,
831 0, 1, 0, 0, 0,
832 0, 0, 1, 0, 0,
833 0, 0, 0, 0, 1,
834 };
835 // clang-format on
836 DlMatrixColorFilter alpha_color_filter(alpha_matrix);
837 sk_sp<SkColorFilter> sk_alpha_color_filter =
838 SkColorFilters::Matrix(alpha_matrix);
839
840 {
841 // No tricky stuff, just verifying drawing a rect produces rect bounds
842 DisplayListBuilder builder(build_bounds);
843 DlOpReceiver& receiver = ToReceiver(builder);
844 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
845 receiver.drawRect(rect);
846 receiver.restore();
847 sk_sp<DisplayList> display_list = builder.Build();
848 ASSERT_EQ(display_list->bounds(), rect);
849 }
850
851 {
852 // Now checking that a normal color filter still produces rect bounds
853 DisplayListBuilder builder(build_bounds);
854 DlOpReceiver& receiver = ToReceiver(builder);
855 receiver.setColorFilter(&base_color_filter);
856 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
857 receiver.setColorFilter(nullptr);
858 receiver.drawRect(rect);
859 receiver.restore();
860 sk_sp<DisplayList> display_list = builder.Build();
861 ASSERT_EQ(display_list->bounds(), rect);
862 }
863
864 {
865 // Now checking how SkPictureRecorder deals with a color filter
866 // that modifies alpha channels (save layer bounds are meaningless
867 // under those circumstances)
868 SkPictureRecorder recorder;
869 SkRTreeFactory rtree_factory;
870 SkCanvas* canvas = recorder.beginRecording(build_bounds, &rtree_factory);
871 SkPaint p1;
872 p1.setColorFilter(sk_alpha_color_filter);
873 canvas->saveLayer(save_bounds, &p1);
874 SkPaint p2;
875 canvas->drawRect(rect, p2);
876 canvas->restore();
878 ASSERT_EQ(picture->cullRect(), build_bounds);
879 }
880
881 {
882 // Now checking that DisplayList has the same behavior that we
883 // saw in the SkPictureRecorder example above - returning the
884 // cull rect of the DisplayListBuilder when it encounters a
885 // save layer that modifies an unbounded region
886 DisplayListBuilder builder(build_bounds);
887 DlOpReceiver& receiver = ToReceiver(builder);
888 receiver.setColorFilter(&alpha_color_filter);
889 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
890 receiver.setColorFilter(nullptr);
891 receiver.drawRect(rect);
892 receiver.restore();
893 sk_sp<DisplayList> display_list = builder.Build();
894 ASSERT_EQ(display_list->bounds(), build_bounds);
895 }
896
897 {
898 // Verifying that the save layer bounds are not relevant
899 // to the behavior in the previous example
900 DisplayListBuilder builder(build_bounds);
901 DlOpReceiver& receiver = ToReceiver(builder);
902 receiver.setColorFilter(&alpha_color_filter);
903 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
904 receiver.setColorFilter(nullptr);
905 receiver.drawRect(rect);
906 receiver.restore();
907 sk_sp<DisplayList> display_list = builder.Build();
908 ASSERT_EQ(display_list->bounds(), build_bounds);
909 }
910
911 {
912 // Making sure hiding a ColorFilter as an ImageFilter will
913 // generate the same behavior as setting it as a ColorFilter
914 DisplayListBuilder builder(build_bounds);
915 DlOpReceiver& receiver = ToReceiver(builder);
916 DlColorFilterImageFilter color_filter_image_filter(base_color_filter);
917 receiver.setImageFilter(&color_filter_image_filter);
918 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
919 receiver.setImageFilter(nullptr);
920 receiver.drawRect(rect);
921 receiver.restore();
922 sk_sp<DisplayList> display_list = builder.Build();
923 ASSERT_EQ(display_list->bounds(), rect);
924 }
925
926 {
927 // Making sure hiding a problematic ColorFilter as an ImageFilter
928 // will generate the same behavior as setting it as a ColorFilter
929 DisplayListBuilder builder(build_bounds);
930 DlOpReceiver& receiver = ToReceiver(builder);
931 DlColorFilterImageFilter color_filter_image_filter(alpha_color_filter);
932 receiver.setImageFilter(&color_filter_image_filter);
933 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
934 receiver.setImageFilter(nullptr);
935 receiver.drawRect(rect);
936 receiver.restore();
937 sk_sp<DisplayList> display_list = builder.Build();
938 ASSERT_EQ(display_list->bounds(), build_bounds);
939 }
940
941 {
942 // Same as above (ImageFilter hiding ColorFilter) with no save bounds
943 DisplayListBuilder builder(build_bounds);
944 DlOpReceiver& receiver = ToReceiver(builder);
945 DlColorFilterImageFilter color_filter_image_filter(alpha_color_filter);
946 receiver.setImageFilter(&color_filter_image_filter);
947 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
948 receiver.setImageFilter(nullptr);
949 receiver.drawRect(rect);
950 receiver.restore();
951 sk_sp<DisplayList> display_list = builder.Build();
952 ASSERT_EQ(display_list->bounds(), build_bounds);
953 }
954
955 {
956 // Testing behavior with an unboundable blend mode
957 DisplayListBuilder builder(build_bounds);
958 DlOpReceiver& receiver = ToReceiver(builder);
959 receiver.setBlendMode(DlBlendMode::kClear);
960 receiver.saveLayer(&save_bounds, SaveLayerOptions::kWithAttributes);
961 receiver.setBlendMode(DlBlendMode::kSrcOver);
962 receiver.drawRect(rect);
963 receiver.restore();
964 sk_sp<DisplayList> display_list = builder.Build();
965 ASSERT_EQ(display_list->bounds(), build_bounds);
966 }
967
968 {
969 // Same as previous with no save bounds
970 DisplayListBuilder builder(build_bounds);
971 DlOpReceiver& receiver = ToReceiver(builder);
972 receiver.setBlendMode(DlBlendMode::kClear);
973 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
974 receiver.setBlendMode(DlBlendMode::kSrcOver);
975 receiver.drawRect(rect);
976 receiver.restore();
977 sk_sp<DisplayList> display_list = builder.Build();
978 ASSERT_EQ(display_list->bounds(), build_bounds);
979 }
980}
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void restore()
Definition: SkCanvas.cpp:461
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() [220/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListsWithVaryingOpComparisons   
)

Definition at line 782 of file display_list_unittests.cc.

782 {
783 sk_sp<DisplayList> default_dl = Build(allGroups.size(), 0);
784 ASSERT_TRUE(default_dl->Equals(*default_dl)) << "Default == itself";
785 for (size_t gi = 0; gi < allGroups.size(); gi++) {
787 sk_sp<DisplayList> missing_dl = Build(gi, group.variants.size());
788 auto desc = "[Group " + group.op_name + " omitted]";
789 ASSERT_TRUE(missing_dl->Equals(*missing_dl)) << desc << " == itself";
790 ASSERT_FALSE(missing_dl->Equals(*default_dl)) << desc << " != Default";
791 ASSERT_FALSE(default_dl->Equals(*missing_dl)) << "Default != " << desc;
792 for (size_t vi = 0; vi < group.variants.size(); vi++) {
793 auto desc = "[Group " + group.op_name + " variant " +
794 std::to_string(vi + 1) + "]";
795 sk_sp<DisplayList> variant_dl = Build(gi, vi);
796 ASSERT_TRUE(variant_dl->Equals(*variant_dl)) << desc << " == itself";
797 if (vi == 0) {
798 ASSERT_TRUE(variant_dl->Equals(*default_dl)) << desc << " == Default";
799 ASSERT_TRUE(default_dl->Equals(*variant_dl)) << "Default == " << desc;
800 } else {
801 ASSERT_FALSE(variant_dl->Equals(*default_dl)) << desc << " != Default";
802 ASSERT_FALSE(default_dl->Equals(*variant_dl)) << "Default != " << desc;
803 }
804 if (group.variants[vi].is_empty()) {
805 ASSERT_TRUE(variant_dl->Equals(*missing_dl)) << desc << " != omitted";
806 ASSERT_TRUE(missing_dl->Equals(*variant_dl)) << "omitted != " << desc;
807 } else {
808 ASSERT_FALSE(variant_dl->Equals(*missing_dl)) << desc << " != omitted";
809 ASSERT_FALSE(missing_dl->Equals(*variant_dl)) << "omitted != " << desc;
810 }
811 }
812 }
813}
def Build(configs, env, options)
Definition: build.py:232
static std::vector< testing::DisplayListInvocationGroup > allGroups

◆ TEST_F() [221/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DisplayListTransformResetHandling   
)

Definition at line 1086 of file display_list_unittests.cc.

1086 {
1088 DlOpReceiver& receiver = ToReceiver(builder);
1089 receiver.scale(20.0, 20.0);
1090 receiver.transformReset();
1091 auto display_list = builder.Build();
1092 ASSERT_NE(display_list, nullptr);
1095 SkCanvas* canvas = surface->getCanvas();
1096 // We can't use DlSkCanvas.DrawDisplayList as that method protects
1097 // the canvas against mutations from the display list being drawn.
1098 auto dispatcher = DlSkCanvasDispatcher(surface->getCanvas());
1099 display_list->Dispatch(dispatcher);
1100 ASSERT_TRUE(canvas->getTotalMatrix().isIdentity());
1101}
virtual void transformReset()=0

◆ TEST_F() [222/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawDisplayListForwardsBackdropFlag   
)

Definition at line 4316 of file display_list_unittests.cc.

4316 {
4317 DisplayListBuilder child_builder;
4318 DlBlurImageFilter backdrop(2.0f, 2.0f, DlTileMode::kDecal);
4319 child_builder.SaveLayer(nullptr, nullptr, &backdrop);
4320 child_builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4321 DlPaint().setBlendMode(DlBlendMode::kMultiply));
4322 child_builder.Restore();
4323 auto child_dl = child_builder.Build();
4324 EXPECT_EQ(child_dl->max_root_blend_mode(), DlBlendMode::kSrcOver);
4325 EXPECT_TRUE(child_dl->root_has_backdrop_filter());
4326
4327 DisplayListBuilder parent_builder;
4328 parent_builder.DrawDisplayList(child_dl);
4329 auto parent_dl = parent_builder.Build();
4330 EXPECT_EQ(parent_dl->max_root_blend_mode(), DlBlendMode::kSrcOver);
4331 EXPECT_TRUE(parent_dl->root_has_backdrop_filter());
4332}
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191

◆ TEST_F() [223/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawDisplayListForwardsMaxBlend   
)

Definition at line 4301 of file display_list_unittests.cc.

4301 {
4302 DisplayListBuilder child_builder;
4303 child_builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4304 DlPaint().setBlendMode(DlBlendMode::kMultiply));
4305 auto child_dl = child_builder.Build();
4306 EXPECT_EQ(child_dl->max_root_blend_mode(), DlBlendMode::kMultiply);
4307 EXPECT_FALSE(child_dl->root_has_backdrop_filter());
4308
4309 DisplayListBuilder parent_builder;
4310 parent_builder.DrawDisplayList(child_dl);
4311 auto parent_dl = parent_builder.Build();
4312 EXPECT_EQ(parent_dl->max_root_blend_mode(), DlBlendMode::kMultiply);
4313 EXPECT_FALSE(parent_dl->root_has_backdrop_filter());
4314}

◆ TEST_F() [224/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawSaveDrawCannotInheritOpacity   
)

Definition at line 3154 of file display_list_unittests.cc.

3154 {
3156 builder.DrawCircle({10, 10}, 5, DlPaint());
3157 builder.Save();
3158 builder.ClipRect({0, 0, 20, 20}, DlCanvas::ClipOp::kIntersect, false);
3159 builder.DrawRect({5, 5, 15, 15}, DlPaint());
3160 builder.Restore();
3161 auto display_list = builder.Build();
3162
3163 ASSERT_FALSE(display_list->can_apply_group_opacity());
3164}

◆ TEST_F() [225/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedOval   
)

Definition at line 3180 of file display_list_unittests.cc.

3180 {
3181 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3182 canvas.DrawOval(rect, paint);
3183 };
3184 check_inverted_bounds(renderer, "DrawOval");
3185}
virtual void DrawOval(const SkRect &bounds, const DlPaint &paint)=0

◆ TEST_F() [226/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedOvalPath   
)

Definition at line 3194 of file display_list_unittests.cc.

3194 {
3195 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3196 canvas.DrawPath(SkPath().addOval(rect), paint);
3197 };
3198 check_inverted_bounds(renderer, "DrawOvalPath");
3199}
virtual void DrawPath(const SkPath &path, const DlPaint &paint)=0

◆ TEST_F() [227/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRect   
)

Definition at line 3166 of file display_list_unittests.cc.

3166 {
3167 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3168 canvas.DrawRect(rect, paint);
3169 };
3170 check_inverted_bounds(renderer, "DrawRect");
3171}

◆ TEST_F() [228/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRectangularPath   
)

Definition at line 3187 of file display_list_unittests.cc.

3187 {
3188 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3189 canvas.DrawPath(SkPath().addRect(rect), paint);
3190 };
3191 check_inverted_bounds(renderer, "DrawRectangularPath");
3192}

◆ TEST_F() [229/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRoundRect   
)

Definition at line 3173 of file display_list_unittests.cc.

3173 {
3174 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3175 canvas.DrawRRect(SkRRect::MakeRectXY(rect, 2.0f, 2.0f), paint);
3176 };
3177 check_inverted_bounds(renderer, "DrawRoundRect");
3178}
virtual void DrawRRect(const SkRRect &rrect, const DlPaint &paint)=0

◆ TEST_F() [230/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRoundRectPathCCW   
)

Definition at line 3210 of file display_list_unittests.cc.

3210 {
3211 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3212 SkPath path = SkPath() //
3214 canvas.DrawPath(path, paint);
3215 };
3216 check_inverted_bounds(renderer, "DrawRoundRectPath Counter-Clockwise");
3217}
SkPath & addRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1093

◆ TEST_F() [231/925]

flutter::testing::TEST_F ( DisplayListTest  ,
DrawUnorderedRoundRectPathCW   
)

Definition at line 3201 of file display_list_unittests.cc.

3201 {
3202 auto renderer = [](DlCanvas& canvas, DlPaint& paint, SkRect& rect) {
3203 SkPath path = SkPath() //
3204 .addRoundRect(rect, 2.0f, 2.0f, SkPathDirection::kCW);
3205 canvas.DrawPath(path, paint);
3206 };
3207 check_inverted_bounds(renderer, "DrawRoundRectPath Clockwise");
3208}

◆ TEST_F() [232/925]

flutter::testing::TEST_F ( DisplayListTest  ,
EmptyBuild   
)

Definition at line 238 of file display_list_unittests.cc.

238 {
240 auto dl = builder.Build();
241 EXPECT_EQ(dl->op_count(), 0u);
242 EXPECT_EQ(dl->bytes(), sizeof(DisplayList));
243 EXPECT_EQ(dl->total_depth(), 0u);
244}

◆ TEST_F() [233/925]

flutter::testing::TEST_F ( DisplayListTest  ,
EmptyRebuild   
)

Definition at line 246 of file display_list_unittests.cc.

246 {
248 auto dl1 = builder.Build();
249 auto dl2 = builder.Build();
250 auto dl3 = builder.Build();
251 ASSERT_TRUE(dl1->Equals(dl2));
252 ASSERT_TRUE(dl2->Equals(dl3));
253}

◆ TEST_F() [234/925]

flutter::testing::TEST_F ( DisplayListTest  ,
FlatDrawPointsProducesBounds   
)

Definition at line 2196 of file display_list_unittests.cc.

2196 {
2197 SkPoint horizontal_points[2] = {{10, 10}, {20, 10}};
2198 SkPoint vertical_points[2] = {{10, 10}, {10, 20}};
2199 {
2200 DisplayListBuilder builder;
2201 DlOpReceiver& receiver = ToReceiver(builder);
2202 receiver.drawPoints(PointMode::kPolygon, 2, horizontal_points);
2203 SkRect bounds = builder.Build()->bounds();
2204 EXPECT_TRUE(bounds.contains(10, 10));
2205 EXPECT_TRUE(bounds.contains(20, 10));
2206 EXPECT_GE(bounds.width(), 10);
2207 }
2208 {
2209 DisplayListBuilder builder;
2210 DlOpReceiver& receiver = ToReceiver(builder);
2211 receiver.drawPoints(PointMode::kPolygon, 2, vertical_points);
2212 SkRect bounds = builder.Build()->bounds();
2213 EXPECT_TRUE(bounds.contains(10, 10));
2214 EXPECT_TRUE(bounds.contains(10, 20));
2215 EXPECT_GE(bounds.height(), 10);
2216 }
2217 {
2218 DisplayListBuilder builder;
2219 DlOpReceiver& receiver = ToReceiver(builder);
2220 receiver.drawPoints(PointMode::kPoints, 1, horizontal_points);
2221 SkRect bounds = builder.Build()->bounds();
2222 EXPECT_TRUE(bounds.contains(10, 10));
2223 }
2224 {
2225 DisplayListBuilder builder;
2226 DlOpReceiver& receiver = ToReceiver(builder);
2227 receiver.setStrokeWidth(2);
2228 receiver.drawPoints(PointMode::kPolygon, 2, horizontal_points);
2229 SkRect bounds = builder.Build()->bounds();
2230 EXPECT_TRUE(bounds.contains(10, 10));
2231 EXPECT_TRUE(bounds.contains(20, 10));
2232 EXPECT_EQ(bounds, SkRect::MakeLTRB(9, 9, 21, 11));
2233 }
2234 {
2235 DisplayListBuilder builder;
2236 DlOpReceiver& receiver = ToReceiver(builder);
2237 receiver.setStrokeWidth(2);
2238 receiver.drawPoints(PointMode::kPolygon, 2, vertical_points);
2239 SkRect bounds = builder.Build()->bounds();
2240 EXPECT_TRUE(bounds.contains(10, 10));
2241 EXPECT_TRUE(bounds.contains(10, 20));
2242 EXPECT_EQ(bounds, SkRect::MakeLTRB(9, 9, 11, 21));
2243 }
2244 {
2245 DisplayListBuilder builder;
2246 DlOpReceiver& receiver = ToReceiver(builder);
2247 receiver.setStrokeWidth(2);
2248 receiver.drawPoints(PointMode::kPoints, 1, horizontal_points);
2249 SkRect bounds = builder.Build()->bounds();
2250 EXPECT_TRUE(bounds.contains(10, 10));
2251 EXPECT_EQ(bounds, SkRect::MakeLTRB(9, 9, 11, 11));
2252 }
2253}

◆ TEST_F() [235/925]

flutter::testing::TEST_F ( DisplayListTest  ,
FloodingFilteredLayerPushesRestoreOpIndex   
)

Definition at line 4007 of file display_list_unittests.cc.

4007 {
4009 builder.ClipRect(SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f));
4010 // ClipRect does not contribute to rtree rects, no id needed
4011
4012 DlPaint save_paint;
4013 // clang-format off
4014 const float matrix[] = {
4015 0.5f, 0.0f, 0.0f, 0.0f, 0.5f,
4016 0.5f, 0.0f, 0.0f, 0.0f, 0.5f,
4017 0.5f, 0.0f, 0.0f, 0.0f, 0.5f,
4018 0.5f, 0.0f, 0.0f, 0.0f, 0.5f
4019 };
4020 // clang-format on
4023 builder.SaveLayer(nullptr, &save_paint);
4024 int save_layer_id = DisplayListBuilderTestingLastOpIndex(builder);
4025
4026 builder.DrawRect(SkRect::MakeLTRB(120.0f, 120.0f, 125.0f, 125.0f), DlPaint());
4028
4029 builder.Restore();
4031
4032 auto dl = builder.Build();
4033 std::vector<int> indices;
4034 dl->rtree()->search(SkRect::MakeLTRB(0.0f, 0.0f, 500.0f, 500.0f), &indices);
4035 ASSERT_EQ(indices.size(), 3u);
4036 EXPECT_EQ(dl->rtree()->id(indices[0]), save_layer_id);
4037 EXPECT_EQ(dl->rtree()->id(indices[1]), draw_rect_id);
4038 EXPECT_EQ(dl->rtree()->id(indices[2]), restore_id);
4039}
int DisplayListBuilderTestingLastOpIndex(DisplayListBuilder &builder)

◆ TEST_F() [236/925]

flutter::testing::TEST_F ( DisplayListTest  ,
FloodingSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3769 of file display_list_unittests.cc.

3769 {
3770 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3771 DlPaint save_paint;
3772 auto color_filter =
3773 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3774 ASSERT_TRUE(color_filter->modifies_transparent_black());
3775 save_paint.setColorFilter(color_filter);
3776 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3777 ASSERT_NE(clip_rect, rect);
3778 ASSERT_TRUE(clip_rect.contains(rect));
3779
3781 builder.ClipRect(clip_rect);
3782 builder.SaveLayer(nullptr, &save_paint);
3783 { //
3784 builder.DrawRect(rect, DlPaint());
3785 }
3786 builder.Restore();
3787 auto display_list = builder.Build();
3788
3789 SaveLayerBoundsExpector expector;
3790 expector.addComputedExpectation(rect);
3791 display_list->Dispatch(expector);
3792 EXPECT_TRUE(expector.all_bounds_checked());
3793}

◆ TEST_F() [237/925]

flutter::testing::TEST_F ( DisplayListTest  ,
FlutterSvgIssue661BoundsWereEmpty   
)

Definition at line 1558 of file display_list_unittests.cc.

1558 {
1559 // See https://github.com/dnfield/flutter_svg/issues/661
1560
1561 SkPath path1;
1563 path1.moveTo(25.54f, 37.52f);
1564 path1.cubicTo(20.91f, 37.52f, 16.54f, 33.39f, 13.62f, 30.58f);
1565 path1.lineTo(13, 30);
1566 path1.lineTo(12.45f, 29.42f);
1567 path1.cubicTo(8.39f, 25.15f, 1.61f, 18, 8.37f, 11.27f);
1568 path1.cubicTo(10.18f, 9.46f, 12.37f, 9.58f, 14.49f, 11.58f);
1569 path1.cubicTo(15.67f, 12.71f, 17.05f, 14.69f, 17.07f, 16.58f);
1570 path1.cubicTo(17.0968f, 17.458f, 16.7603f, 18.3081f, 16.14f, 18.93f);
1571 path1.cubicTo(15.8168f, 19.239f, 15.4653f, 19.5169f, 15.09f, 19.76f);
1572 path1.cubicTo(14.27f, 20.33f, 14.21f, 20.44f, 14.27f, 20.62f);
1573 path1.cubicTo(15.1672f, 22.3493f, 16.3239f, 23.9309f, 17.7f, 25.31f);
1574 path1.cubicTo(19.0791f, 26.6861f, 20.6607f, 27.8428f, 22.39f, 28.74f);
1575 path1.cubicTo(22.57f, 28.8f, 22.69f, 28.74f, 23.25f, 27.92f);
1576 path1.cubicTo(23.5f, 27.566f, 23.778f, 27.231f, 24.08f, 26.92f);
1577 path1.cubicTo(24.7045f, 26.3048f, 25.5538f, 25.9723f, 26.43f, 26);
1578 path1.cubicTo(28.29f, 26, 30.27f, 27.4f, 31.43f, 28.58f);
1579 path1.cubicTo(33.43f, 30.67f, 33.55f, 32.9f, 31.74f, 34.7f);
1580 path1.cubicTo(30.1477f, 36.4508f, 27.906f, 37.4704f, 25.54f, 37.52f);
1581 path1.close();
1582 path1.moveTo(11.17f, 12.23f);
1583 path1.cubicTo(10.6946f, 12.2571f, 10.2522f, 12.4819f, 9.95f, 12.85f);
1584 path1.cubicTo(5.12f, 17.67f, 8.95f, 22.5f, 14.05f, 27.85f);
1585 path1.lineTo(14.62f, 28.45f);
1586 path1.lineTo(15.16f, 28.96f);
1587 path1.cubicTo(20.52f, 34.06f, 25.35f, 37.89f, 30.16f, 33.06f);
1588 path1.cubicTo(30.83f, 32.39f, 31.25f, 31.56f, 29.81f, 30.06f);
1589 path1.cubicTo(28.9247f, 29.07f, 27.7359f, 28.4018f, 26.43f, 28.16f);
1590 path1.cubicTo(26.1476f, 28.1284f, 25.8676f, 28.2367f, 25.68f, 28.45f);
1591 path1.cubicTo(25.4633f, 28.6774f, 25.269f, 28.9252f, 25.1f, 29.19f);
1592 path1.cubicTo(24.53f, 30.01f, 23.47f, 31.54f, 21.54f, 30.79f);
1593 path1.lineTo(21.41f, 30.72f);
1594 path1.cubicTo(19.4601f, 29.7156f, 17.6787f, 28.4133f, 16.13f, 26.86f);
1595 path1.cubicTo(14.5748f, 25.3106f, 13.2693f, 23.5295f, 12.26f, 21.58f);
1596 path1.lineTo(12.2f, 21.44f);
1597 path1.cubicTo(11.45f, 19.51f, 12.97f, 18.44f, 13.8f, 17.88f);
1598 path1.cubicTo(14.061f, 17.706f, 14.308f, 17.512f, 14.54f, 17.3f);
1599 path1.cubicTo(14.7379f, 17.1067f, 14.8404f, 16.8359f, 14.82f, 16.56f);
1600 path1.cubicTo(14.5978f, 15.268f, 13.9585f, 14.0843f, 13, 13.19f);
1601 path1.cubicTo(12.5398f, 12.642f, 11.8824f, 12.2971f, 11.17f, 12.23f);
1602 path1.lineTo(11.17f, 12.23f);
1603 path1.close();
1604 path1.moveTo(27, 19.34f);
1605 path1.lineTo(24.74f, 19.34f);
1606 path1.cubicTo(24.7319f, 18.758f, 24.262f, 18.2881f, 23.68f, 18.28f);
1607 path1.lineTo(23.68f, 16.05f);
1608 path1.lineTo(23.7f, 16.05f);
1609 path1.cubicTo(25.5153f, 16.0582f, 26.9863f, 17.5248f, 27, 19.34f);
1610 path1.lineTo(27, 19.34f);
1611 path1.close();
1612 path1.moveTo(32.3f, 19.34f);
1613 path1.lineTo(30.07f, 19.34f);
1614 path1.cubicTo(30.037f, 15.859f, 27.171f, 13.011f, 23.69f, 13);
1615 path1.lineTo(23.69f, 10.72f);
1616 path1.cubicTo(28.415f, 10.725f, 32.3f, 14.615f, 32.3f, 19.34f);
1617 path1.close();
1618
1619 SkPath path2;
1621 path2.moveTo(37.5f, 19.33f);
1622 path2.lineTo(35.27f, 19.33f);
1623 path2.cubicTo(35.265f, 12.979f, 30.041f, 7.755f, 23.69f, 7.75f);
1624 path2.lineTo(23.69f, 5.52f);
1625 path2.cubicTo(31.264f, 5.525f, 37.495f, 11.756f, 37.5f, 19.33f);
1626 path2.close();
1627
1630 {
1631 builder.Save();
1632 builder.ClipRect({0, 0, 100, 100}, ClipOp::kIntersect, true);
1633 {
1634 builder.Save();
1635 builder.Transform2DAffine(2.17391, 0, -2547.83, //
1636 0, 2.04082, -500);
1637 {
1638 builder.Save();
1639 builder.ClipRect({1172, 245, 1218, 294}, ClipOp::kIntersect, true);
1640 {
1641 builder.SaveLayer(nullptr, nullptr, nullptr);
1642 {
1643 builder.Save();
1644 builder.Transform2DAffine(1.4375, 0, 1164.09, //
1645 0, 1.53125, 236.548);
1646 builder.DrawPath(path1, paint);
1647 builder.Restore();
1648 }
1649 {
1650 builder.Save();
1651 builder.Transform2DAffine(1.4375, 0, 1164.09, //
1652 0, 1.53125, 236.548);
1653 builder.DrawPath(path2, paint);
1654 builder.Restore();
1655 }
1656 builder.Restore();
1657 }
1658 builder.Restore();
1659 }
1660 builder.Restore();
1661 }
1662 builder.Restore();
1663 }
1664 sk_sp<DisplayList> display_list = builder.Build();
1665 // Prior to the fix, the bounds were empty.
1666 EXPECT_FALSE(display_list->bounds().isEmpty());
1667 // These are just inside and outside of the expected bounds, but
1668 // testing float values can be flaky wrt minor changes in the bounds
1669 // calculations. If these lines have to be revised too often as the DL
1670 // implementation is improved and maintained, then we can eliminate
1671 // this test and just rely on the "rounded out" bounds test that follows.
1672 SkRect min_bounds = SkRect::MakeLTRB(0, 0.00191, 99.983, 100);
1673 SkRect max_bounds = SkRect::MakeLTRB(0, 0.00189, 99.985, 100);
1674 ASSERT_TRUE(max_bounds.contains(min_bounds));
1675 EXPECT_TRUE(max_bounds.contains(display_list->bounds()));
1676 EXPECT_TRUE(display_list->bounds().contains(min_bounds));
1677
1678 // This is the more practical result. The bounds are "almost" 0,0,100x100
1679 EXPECT_EQ(display_list->bounds().roundOut(), SkIRect::MakeWH(100, 100));
1680 EXPECT_EQ(display_list->op_count(), 19u);
1681 EXPECT_EQ(display_list->bytes(), sizeof(DisplayList) + 408u);
1682 EXPECT_EQ(display_list->total_depth(), 3u);
1683}
flutter::DisplayList DisplayList

◆ TEST_F() [238/925]

flutter::testing::TEST_F ( DisplayListTest  ,
FullRotationsAreNop   
)

Definition at line 754 of file display_list_unittests.cc.

754 {
756 DlOpReceiver& receiver = ToReceiver(builder);
757 receiver.rotate(0);
758 receiver.rotate(360);
759 receiver.rotate(720);
760 receiver.rotate(1080);
761 receiver.rotate(1440);
762 sk_sp<DisplayList> dl = builder.Build();
763 ASSERT_EQ(dl->bytes(false), sizeof(DisplayList));
764 ASSERT_EQ(dl->bytes(true), sizeof(DisplayList));
765 ASSERT_EQ(dl->op_count(false), 0u);
766 ASSERT_EQ(dl->op_count(true), 0u);
767 EXPECT_EQ(dl->total_depth(), 0u);
768}
virtual void rotate(SkScalar degrees)=0

◆ TEST_F() [239/925]

flutter::testing::TEST_F ( DisplayListTest  ,
FullTransformAffectsCurrentTransform   
)

Definition at line 1783 of file display_list_unittests.cc.

1783 {
1785 DlOpReceiver& receiver = ToReceiver(builder);
1786 receiver.transformFullPerspective(3, 0, 4, 12.3, //
1787 1, 5, 3, 14.5, //
1788 0, 0, 7, 16.2, //
1789 0, 0, 0, 1);
1790 SkMatrix matrix = SkMatrix::MakeAll(3, 0, 12.3, //
1791 1, 5, 14.5, //
1792 0, 0, 1);
1793 SkM44 m44 = SkM44(3, 0, 4, 12.3, //
1794 1, 5, 3, 14.5, //
1795 0, 0, 7, 16.2, //
1796 0, 0, 0, 1);
1797 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1798 SkMatrix cur_matrix = builder.GetTransform();
1799 ASSERT_EQ(cur_m44, m44);
1800 ASSERT_EQ(cur_matrix, matrix);
1801 receiver.translate(10, 10);
1802 // CurrentTransform has changed
1803 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1804 ASSERT_NE(builder.GetTransform(), cur_matrix);
1805 // Previous return values have not
1806 ASSERT_EQ(cur_m44, m44);
1807 ASSERT_EQ(cur_matrix, matrix);
1808}

◆ TEST_F() [240/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ImpellerPathPreferenceIsHonored   
)

Definition at line 3381 of file display_list_unittests.cc.

3381 {
3382 class Tester : public virtual DlOpReceiver,
3387 public:
3388 explicit Tester(bool prefer_impeller_paths)
3389 : prefer_impeller_paths_(prefer_impeller_paths) {}
3390
3391 bool PrefersImpellerPaths() const override {
3392 return prefer_impeller_paths_;
3393 }
3394
3395 void drawPath(const SkPath& path) override { skia_draw_path_calls_++; }
3396
3397 void drawPath(const CacheablePath& cache) override {
3398 impeller_draw_path_calls_++;
3399 }
3400
3401 void clipPath(const SkPath& path, ClipOp op, bool is_aa) override {
3402 skia_clip_path_calls_++;
3403 }
3404
3405 void clipPath(const CacheablePath& cache, ClipOp op, bool is_aa) override {
3406 impeller_clip_path_calls_++;
3407 }
3408
3409 virtual void drawShadow(const SkPath& sk_path,
3410 const DlColor color,
3411 const SkScalar elevation,
3412 bool transparent_occluder,
3413 SkScalar dpr) override {
3414 skia_draw_shadow_calls_++;
3415 }
3416
3417 virtual void drawShadow(const CacheablePath& cache,
3418 const DlColor color,
3419 const SkScalar elevation,
3420 bool transparent_occluder,
3421 SkScalar dpr) override {
3422 impeller_draw_shadow_calls_++;
3423 }
3424
3425 int skia_draw_path_calls() const { return skia_draw_path_calls_; }
3426 int skia_clip_path_calls() const { return skia_draw_path_calls_; }
3427 int skia_draw_shadow_calls() const { return skia_draw_path_calls_; }
3428 int impeller_draw_path_calls() const { return impeller_draw_path_calls_; }
3429 int impeller_clip_path_calls() const { return impeller_draw_path_calls_; }
3430 int impeller_draw_shadow_calls() const { return impeller_draw_path_calls_; }
3431
3432 private:
3433 const bool prefer_impeller_paths_;
3434 int skia_draw_path_calls_ = 0;
3435 int skia_clip_path_calls_ = 0;
3436 int skia_draw_shadow_calls_ = 0;
3437 int impeller_draw_path_calls_ = 0;
3438 int impeller_clip_path_calls_ = 0;
3439 int impeller_draw_shadow_calls_ = 0;
3440 };
3441
3442 DisplayListBuilder builder;
3443 builder.DrawPath(SkPath::Rect(SkRect::MakeLTRB(0, 0, 100, 100)), DlPaint());
3444 builder.ClipPath(SkPath::Rect(SkRect::MakeLTRB(0, 0, 100, 100)),
3445 ClipOp::kIntersect, true);
3446 builder.DrawShadow(SkPath::Rect(SkRect::MakeLTRB(20, 20, 80, 80)),
3447 DlColor::kBlue(), 1.0f, true, 1.0f);
3448 auto display_list = builder.Build();
3449
3450 {
3451 Tester skia_tester(false);
3452 display_list->Dispatch(skia_tester);
3453 EXPECT_EQ(skia_tester.skia_draw_path_calls(), 1);
3454 EXPECT_EQ(skia_tester.skia_clip_path_calls(), 1);
3455 EXPECT_EQ(skia_tester.skia_draw_shadow_calls(), 1);
3456 EXPECT_EQ(skia_tester.impeller_draw_path_calls(), 0);
3457 EXPECT_EQ(skia_tester.impeller_clip_path_calls(), 0);
3458 EXPECT_EQ(skia_tester.impeller_draw_shadow_calls(), 0);
3459 }
3460
3461 {
3462 Tester impeller_tester(true);
3463 display_list->Dispatch(impeller_tester);
3464 EXPECT_EQ(impeller_tester.skia_draw_path_calls(), 0);
3465 EXPECT_EQ(impeller_tester.skia_clip_path_calls(), 0);
3466 EXPECT_EQ(impeller_tester.skia_draw_shadow_calls(), 0);
3467 EXPECT_EQ(impeller_tester.impeller_draw_path_calls(), 1);
3468 EXPECT_EQ(impeller_tester.impeller_clip_path_calls(), 1);
3469 EXPECT_EQ(impeller_tester.impeller_draw_shadow_calls(), 1);
3470 }
3471}
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
Definition: SkPath.cpp:3586
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
DlCanvas::ClipOp ClipOp

◆ TEST_F() [241/925]

flutter::testing::TEST_F ( DisplayListTest  ,
LineOfNonOverlappingOpsSupportGroupOpacity   
)

Definition at line 1213 of file display_list_unittests.cc.

1213 {
1215 for (int i = 0; i < 10; i++) {
1216 builder.DrawRect(SkRect::MakeXYWH(i * 30, 0, 30, 30), DlPaint());
1217 }
1218 auto display_list = builder.Build();
1219 EXPECT_TRUE(display_list->can_apply_group_opacity());
1220}

◆ TEST_F() [242/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeEmptyDisplayList   
)

Definition at line 4102 of file display_list_unittests.cc.

4102 {
4104 EXPECT_EQ(builder.Build()->max_root_blend_mode(), DlBlendMode::kClear);
4105}

◆ TEST_F() [243/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeInsideComplexDeferredSaves   
)

Definition at line 4182 of file display_list_unittests.cc.

4182 {
4184 builder.Save();
4185 {
4186 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4187 DlPaint().setBlendMode(DlBlendMode::kModulate));
4188 builder.Save();
4189 {
4190 // We want to use a blend mode that is greater than modulate here
4191 ASSERT_GT(DlBlendMode::kScreen, DlBlendMode::kModulate);
4192 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4193 DlPaint().setBlendMode(DlBlendMode::kScreen));
4194 }
4195 builder.Restore();
4196
4197 // We want to use a blend mode that is smaller than modulate here
4198 ASSERT_LT(DlBlendMode::kSrc, DlBlendMode::kModulate);
4199 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4200 DlPaint().setBlendMode(DlBlendMode::kSrc));
4201 }
4202 builder.Restore();
4203
4204 // Double check that kScreen is the max blend mode
4205 auto expect = std::max(DlBlendMode::kModulate, DlBlendMode::kScreen);
4206 expect = std::max(expect, DlBlendMode::kSrc);
4207 ASSERT_EQ(expect, DlBlendMode::kScreen);
4208
4209 EXPECT_EQ(builder.Build()->max_root_blend_mode(), DlBlendMode::kScreen);
4210}

◆ TEST_F() [244/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeInsideComplexSaveLayers   
)

Definition at line 4212 of file display_list_unittests.cc.

4212 {
4214 builder.SaveLayer(nullptr, nullptr);
4215 {
4216 // outer save layer has Modulate now and Src later - Modulate is larger
4217 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4218 DlPaint().setBlendMode(DlBlendMode::kModulate));
4219 builder.SaveLayer(nullptr, nullptr);
4220 {
4221 // inner save layer only has a Screen blend
4222 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4223 DlPaint().setBlendMode(DlBlendMode::kScreen));
4224 }
4225 builder.Restore();
4226
4227 // We want to use a blend mode that is smaller than modulate here
4228 ASSERT_LT(DlBlendMode::kSrc, DlBlendMode::kModulate);
4229 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4230 DlPaint().setBlendMode(DlBlendMode::kSrc));
4231 }
4232 builder.Restore();
4233
4234 // Double check that kModulate is the max blend mode for the first
4235 // saveLayer operations
4236 auto expect = std::max(DlBlendMode::kModulate, DlBlendMode::kSrc);
4237 ASSERT_EQ(expect, DlBlendMode::kModulate);
4238
4239 auto dl = builder.Build();
4240 EXPECT_EQ(dl->max_root_blend_mode(), DlBlendMode::kSrcOver);
4241 SaveLayerExpector expector({DlBlendMode::kModulate, DlBlendMode::kScreen});
4242 dl->Dispatch(expector);
4243 EXPECT_TRUE(expector.all_expectations_checked());
4244}

◆ TEST_F() [245/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeInsideDeferredSave   
)

Definition at line 4137 of file display_list_unittests.cc.

4137 {
4139 builder.Save();
4140 {
4141 // Nothing to trigger the deferred save...
4142 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4143 DlPaint().setBlendMode(DlBlendMode::kModulate));
4144 }
4145 // Deferred save was not triggered, did it forward the max blend mode?
4146 builder.Restore();
4147 EXPECT_EQ(builder.Build()->max_root_blend_mode(), DlBlendMode::kModulate);
4148}

◆ TEST_F() [246/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeInsideNonDefaultBlendedSaveLayer   
)

Definition at line 4165 of file display_list_unittests.cc.

4165 {
4167 DlPaint save_paint;
4168 save_paint.setBlendMode(DlBlendMode::kScreen);
4169 builder.SaveLayer(nullptr, &save_paint);
4170 {
4171 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4172 DlPaint().setBlendMode(DlBlendMode::kModulate));
4173 }
4174 builder.Restore();
4175 auto dl = builder.Build();
4176 EXPECT_EQ(dl->max_root_blend_mode(), DlBlendMode::kScreen);
4177 SaveLayerExpector expector(DlBlendMode::kModulate);
4178 dl->Dispatch(expector);
4179 EXPECT_TRUE(expector.all_expectations_checked());
4180}

◆ TEST_F() [247/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeInsideNonDeferredSave   
)

Definition at line 4123 of file display_list_unittests.cc.

4123 {
4125 builder.Save();
4126 {
4127 // Trigger the deferred save
4128 builder.Scale(2.0f, 2.0f);
4129 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4130 DlPaint().setBlendMode(DlBlendMode::kModulate));
4131 }
4132 // Save was triggered, did it forward the max blend mode?
4133 builder.Restore();
4134 EXPECT_EQ(builder.Build()->max_root_blend_mode(), DlBlendMode::kModulate);
4135}

◆ TEST_F() [248/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeInsideSaveLayer   
)

Definition at line 4150 of file display_list_unittests.cc.

4150 {
4152 builder.SaveLayer(nullptr, nullptr);
4153 {
4154 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4155 DlPaint().setBlendMode(DlBlendMode::kModulate));
4156 }
4157 builder.Restore();
4158 auto dl = builder.Build();
4159 EXPECT_EQ(dl->max_root_blend_mode(), DlBlendMode::kSrcOver);
4160 SaveLayerExpector expector(DlBlendMode::kModulate);
4161 dl->Dispatch(expector);
4162 EXPECT_TRUE(expector.all_expectations_checked());
4163}

◆ TEST_F() [249/925]

flutter::testing::TEST_F ( DisplayListTest  ,
MaxBlendModeSimpleRect   
)

Definition at line 4107 of file display_list_unittests.cc.

4107 {
4108 auto test = [](DlBlendMode mode) {
4110 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4112 DlBlendMode expect =
4113 (mode == DlBlendMode::kDst) ? DlBlendMode::kClear : mode;
4114 EXPECT_EQ(builder.Build()->max_root_blend_mode(), expect) //
4115 << "testing " << mode;
4116 };
4117
4118 for (int i = 0; i < static_cast<int>(DlBlendMode::kLastMode); i++) {
4119 test(static_cast<DlBlendMode>(i));
4120 }
4121}

◆ TEST_F() [250/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedDisplayListRTreesAreSparse   
)

prepare_rtree=

prepare_rtree=

Definition at line 2374 of file display_list_unittests.cc.

2374 {
2375 DisplayListBuilder nested_dl_builder(/**prepare_rtree=*/true);
2376 DlOpReceiver& nested_dl_receiver = ToReceiver(nested_dl_builder);
2377 nested_dl_receiver.drawRect({10, 10, 20, 20});
2378 nested_dl_receiver.drawRect({50, 50, 60, 60});
2379 auto nested_display_list = nested_dl_builder.Build();
2380
2381 DisplayListBuilder builder(/**prepare_rtree=*/true);
2382 DlOpReceiver& receiver = ToReceiver(builder);
2383 receiver.drawDisplayList(nested_display_list);
2384 auto display_list = builder.Build();
2385
2386 auto rtree = display_list->rtree();
2387 std::vector<SkRect> rects = {
2388 {10, 10, 20, 20},
2389 {50, 50, 60, 60},
2390 };
2391
2392 // Hitting both sub-dl drawRect calls
2393 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 51, 51), rects,
2394 std::vector<int>({0, 1}));
2395}
#define TEST_RTREE(rtree, query, expected_rects, expected_indices)

◆ TEST_F() [251/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedFloodingSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3795 of file display_list_unittests.cc.

3795 {
3796 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3797 DlPaint save_paint;
3798 auto color_filter =
3799 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3800 ASSERT_TRUE(color_filter->modifies_transparent_black());
3801 save_paint.setColorFilter(color_filter);
3802 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3803 ASSERT_NE(clip_rect, rect);
3804 ASSERT_TRUE(clip_rect.contains(rect));
3805
3807 builder.ClipRect(clip_rect);
3808 builder.SaveLayer(nullptr, nullptr);
3809 {
3810 builder.SaveLayer(nullptr, &save_paint);
3811 { //
3812 builder.DrawRect(rect, DlPaint());
3813 }
3814 builder.Restore();
3815 }
3816 builder.Restore();
3817 auto display_list = builder.Build();
3818
3819 EXPECT_EQ(display_list->bounds(), clip_rect);
3820
3821 SaveLayerBoundsExpector expector;
3822 expector.addComputedExpectation(clip_rect);
3823 expector.addComputedExpectation(rect);
3824 display_list->Dispatch(expector);
3825 EXPECT_TRUE(expector.all_bounds_checked());
3826}

◆ TEST_F() [252/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedOpCountMetricsSameAsSkPicture   
)

Definition at line 982 of file display_list_unittests.cc.

982 {
983 SkPictureRecorder recorder;
984 recorder.beginRecording(SkRect::MakeWH(150, 100));
985 SkCanvas* canvas = recorder.getRecordingCanvas();
987 for (int y = 10; y <= 60; y += 10) {
988 for (int x = 10; x <= 60; x += 10) {
989 paint.setColor(((x + y) % 20) == 10 ? SK_ColorRED : SK_ColorBLUE);
990 canvas->drawRect(SkRect::MakeXYWH(x, y, 80, 80), paint);
991 }
992 }
993 SkPictureRecorder outer_recorder;
994 outer_recorder.beginRecording(SkRect::MakeWH(150, 100));
995 canvas = outer_recorder.getRecordingCanvas();
996 canvas->drawPicture(recorder.finishRecordingAsPicture());
997
998 auto picture = outer_recorder.finishRecordingAsPicture();
999 ASSERT_EQ(picture->approximateOpCount(), 1);
1000 ASSERT_EQ(picture->approximateOpCount(true), 36);
1001
1002 DisplayListBuilder builder(SkRect::MakeWH(150, 100));
1003 DlOpReceiver& receiver = ToReceiver(builder);
1004 for (int y = 10; y <= 60; y += 10) {
1005 for (int x = 10; x <= 60; x += 10) {
1006 receiver.setColor(((x + y) % 20) == 10 ? DlColor(SK_ColorRED)
1008 receiver.drawRect(SkRect::MakeXYWH(x, y, 80, 80));
1009 }
1010 }
1011
1012 DisplayListBuilder outer_builder(SkRect::MakeWH(150, 100));
1013 DlOpReceiver& outer_receiver = ToReceiver(outer_builder);
1014 outer_receiver.drawDisplayList(builder.Build());
1015 auto display_list = outer_builder.Build();
1016
1017 ASSERT_EQ(display_list->op_count(), 1u);
1018 ASSERT_EQ(display_list->op_count(true), 36u);
1019 EXPECT_EQ(display_list->total_depth(), 37u);
1020
1021 ASSERT_EQ(picture->approximateOpCount(),
1022 static_cast<int>(display_list->op_count()));
1023 ASSERT_EQ(picture->approximateOpCount(true),
1024 static_cast<int>(display_list->op_count(true)));
1025}
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
SkCanvas * getRecordingCanvas()
virtual int approximateOpCount(bool nested=false) const =0

◆ TEST_F() [253/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedSaveLayersCanBothSupportOpacityOptimization   
)

Definition at line 1438 of file display_list_unittests.cc.

1438 {
1439 SaveLayerOptions expected1 =
1440 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1441 SaveLayerOptions expected2 =
1442 SaveLayerOptions::kNoAttributes.with_can_distribute_opacity();
1443 SaveLayerExpector expector({expected1, expected2});
1444
1446 DlOpReceiver& receiver = ToReceiver(builder);
1447 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1448 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1449 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1450 receiver.drawRect({10, 10, 20, 20});
1451 receiver.restore();
1452 receiver.restore();
1453
1454 builder.Build()->Dispatch(expector);
1455 EXPECT_TRUE(expector.all_expectations_checked());
1456}
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
SaveLayerOptions with_can_distribute_opacity() const
Definition: display_list.h:177

◆ TEST_F() [254/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NestedSaveLayersMightInheritOpacity   
)

Definition at line 1414 of file display_list_unittests.cc.

1414 {
1415 SaveLayerOptions expected1 =
1416 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1417 SaveLayerOptions expected2 = SaveLayerOptions::kWithAttributes;
1418 SaveLayerOptions expected3 =
1419 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1420 SaveLayerExpector expector({expected1, expected2, expected3});
1421
1423 DlOpReceiver& receiver = ToReceiver(builder);
1424 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1425 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1426 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1427 receiver.drawRect({10, 10, 20, 20});
1428 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1429 receiver.drawRect({15, 15, 25, 25});
1430 receiver.restore();
1431 receiver.restore();
1432 receiver.restore();
1433
1434 builder.Build()->Dispatch(expector);
1435 EXPECT_TRUE(expector.all_expectations_checked());
1436}

◆ TEST_F() [255/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPClipDoesNotTriggerDeferredSave   
)

Definition at line 3009 of file display_list_unittests.cc.

3009 {
3010 DisplayListBuilder builder1;
3011 DlOpReceiver& receiver1 = ToReceiver(builder1);
3012 receiver1.save();
3013 receiver1.save();
3015 ClipOp::kIntersect, true);
3016 receiver1.drawRect({0, 0, 100, 100});
3017 receiver1.restore();
3018 receiver1.drawRect({0, 0, 100, 100});
3019 receiver1.restore();
3020 auto display_list1 = builder1.Build();
3021
3022 DisplayListBuilder builder2;
3023 DlOpReceiver& receiver2 = ToReceiver(builder2);
3024 receiver2.drawRect({0, 0, 100, 100});
3025 receiver2.drawRect({0, 0, 100, 100});
3026 auto display_list2 = builder2.Build();
3027
3028 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
3029}

◆ TEST_F() [256/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NopOperationsOmittedFromRecords   
)

Definition at line 3219 of file display_list_unittests.cc.

3219 {
3220 auto run_tests = [](const std::string& name,
3222 uint32_t expected_op_count = 0u,
3223 uint32_t expected_total_depth = 0u) {
3224 auto run_one_test =
3225 [init](const std::string& name,
3227 uint32_t expected_op_count = 0u,
3228 uint32_t expected_total_depth = 0u) {
3230 DlPaint paint;
3231 init(builder, paint);
3233 auto list = builder.Build();
3234 if (list->op_count() != expected_op_count) {
3235 FML_LOG(ERROR) << *list;
3236 }
3237 ASSERT_EQ(list->op_count(), expected_op_count) << name;
3238 EXPECT_EQ(list->total_depth(), expected_total_depth) << name;
3239 ASSERT_TRUE(list->bounds().isEmpty()) << name;
3240 };
3241 run_one_test(
3242 name + " DrawColor",
3243 [](DisplayListBuilder& builder, DlPaint& paint) {
3244 builder.DrawColor(paint.getColor(), paint.getBlendMode());
3245 },
3246 expected_op_count, expected_total_depth);
3247 run_one_test(
3248 name + " DrawPaint",
3249 [](DisplayListBuilder& builder, DlPaint& paint) {
3250 builder.DrawPaint(paint);
3251 },
3252 expected_op_count, expected_total_depth);
3253 run_one_test(
3254 name + " DrawRect",
3255 [](DisplayListBuilder& builder, DlPaint& paint) {
3256 builder.DrawRect({10, 10, 20, 20}, paint);
3257 },
3258 expected_op_count, expected_total_depth);
3259 run_one_test(
3260 name + " Other Draw Ops",
3261 [](DisplayListBuilder& builder, DlPaint& paint) {
3262 builder.DrawLine({10, 10}, {20, 20}, paint);
3263 builder.DrawOval({10, 10, 20, 20}, paint);
3264 builder.DrawCircle({50, 50}, 20, paint);
3265 builder.DrawRRect(SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5), paint);
3266 builder.DrawDRRect(SkRRect::MakeRectXY({5, 5, 100, 100}, 5, 5),
3267 SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5),
3268 paint);
3269 builder.DrawPath(kTestPath1, paint);
3270 builder.DrawArc({10, 10, 20, 20}, 45, 90, true, paint);
3271 SkPoint pts[] = {{10, 10}, {20, 20}};
3272 builder.DrawPoints(PointMode::kLines, 2, pts, paint);
3273 builder.DrawVertices(TestVertices1, DlBlendMode::kSrcOver, paint);
3274 builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear,
3275 &paint);
3276 builder.DrawImageRect(TestImage1, SkRect{0.0f, 0.0f, 10.0f, 10.0f},
3277 SkRect{10.0f, 10.0f, 25.0f, 25.0f},
3279 builder.DrawImageNine(TestImage1, {10, 10, 20, 20},
3280 {10, 10, 100, 100}, DlFilterMode::kLinear,
3281 &paint);
3282 SkRSXform xforms[] = {{1, 0, 10, 10}, {0, 1, 10, 10}};
3283 SkRect rects[] = {{10, 10, 20, 20}, {10, 20, 30, 20}};
3284 builder.DrawAtlas(TestImage1, xforms, rects, nullptr, 2,
3285 DlBlendMode::kSrcOver, DlImageSampling::kLinear,
3286 nullptr, &paint);
3287 builder.DrawTextBlob(GetTestTextBlob(1), 10, 10, paint);
3288
3289 // Dst mode eliminates most rendering ops except for
3290 // the following two, so we'll prune those manually...
3291 if (paint.getBlendMode() != DlBlendMode::kDst) {
3292 builder.DrawDisplayList(TestDisplayList1, paint.getOpacity());
3293 builder.DrawShadow(kTestPath1, paint.getColor(), 1, true, 1);
3294 }
3295 },
3296 expected_op_count, expected_total_depth);
3297 run_one_test(
3298 name + " SaveLayer",
3299 [](DisplayListBuilder& builder, DlPaint& paint) {
3300 builder.SaveLayer(nullptr, &paint, nullptr);
3301 builder.DrawRect({10, 10, 20, 20}, DlPaint());
3302 builder.Restore();
3303 },
3304 expected_op_count, expected_total_depth);
3305 run_one_test(
3306 name + " inside Save",
3307 [](DisplayListBuilder& builder, DlPaint& paint) {
3308 builder.Save();
3309 builder.DrawRect({10, 10, 20, 20}, paint);
3310 builder.Restore();
3311 },
3312 expected_op_count, expected_total_depth);
3313 };
3314 run_tests("transparent color", //
3315 [](DisplayListBuilder& builder, DlPaint& paint) {
3316 paint.setColor(DlColor::kTransparent());
3317 });
3318 run_tests("0 alpha", //
3319 [](DisplayListBuilder& builder, DlPaint& paint) {
3320 // The transparent test above already tested transparent
3321 // black (all 0s), we set White color here so we can test
3322 // the case of all 1s with a 0 alpha
3323 paint.setColor(DlColor::kWhite());
3324 paint.setAlpha(0);
3325 });
3326 run_tests("BlendMode::kDst", //
3327 [](DisplayListBuilder& builder, DlPaint& paint) {
3328 paint.setBlendMode(DlBlendMode::kDst);
3329 });
3330 run_tests("Empty rect clip", //
3331 [](DisplayListBuilder& builder, DlPaint& paint) {
3332 builder.ClipRect(SkRect::MakeEmpty(), ClipOp::kIntersect, false);
3333 });
3334 run_tests("Empty rrect clip", //
3335 [](DisplayListBuilder& builder, DlPaint& paint) {
3336 builder.ClipRRect(SkRRect::MakeEmpty(), ClipOp::kIntersect,
3337 false);
3338 });
3339 run_tests("Empty path clip", //
3340 [](DisplayListBuilder& builder, DlPaint& paint) {
3341 builder.ClipPath(SkPath(), ClipOp::kIntersect, false);
3342 });
3343 run_tests("Transparent SaveLayer", //
3344 [](DisplayListBuilder& builder, DlPaint& paint) {
3345 DlPaint save_paint;
3346 save_paint.setColor(DlColor::kTransparent());
3347 builder.SaveLayer(nullptr, &save_paint);
3348 });
3349 run_tests("0 alpha SaveLayer", //
3350 [](DisplayListBuilder& builder, DlPaint& paint) {
3351 DlPaint save_paint;
3352 // The transparent test above already tested transparent
3353 // black (all 0s), we set White color here so we can test
3354 // the case of all 1s with a 0 alpha
3355 save_paint.setColor(DlColor::kWhite());
3356 save_paint.setAlpha(0);
3357 builder.SaveLayer(nullptr, &save_paint);
3358 });
3359 run_tests("Dst blended SaveLayer", //
3360 [](DisplayListBuilder& builder, DlPaint& paint) {
3361 DlPaint save_paint;
3362 save_paint.setBlendMode(DlBlendMode::kDst);
3363 builder.SaveLayer(nullptr, &save_paint);
3364 });
3365 run_tests(
3366 "Nop inside SaveLayer",
3367 [](DisplayListBuilder& builder, DlPaint& paint) {
3368 builder.SaveLayer(nullptr, nullptr);
3369 paint.setBlendMode(DlBlendMode::kDst);
3370 },
3371 2u, 1u);
3372 run_tests("DrawImage inside Culled SaveLayer", //
3373 [](DisplayListBuilder& builder, DlPaint& paint) {
3374 DlPaint save_paint;
3375 save_paint.setColor(DlColor::kTransparent());
3376 builder.SaveLayer(nullptr, &save_paint);
3377 builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear);
3378 });
3379}
def build()
Definition: dom.py:52

◆ TEST_F() [257/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPRotationDoesNotTriggerDeferredSave   
)

Definition at line 2863 of file display_list_unittests.cc.

2863 {
2864 DisplayListBuilder builder1;
2865 DlOpReceiver& receiver1 = ToReceiver(builder1);
2866 receiver1.save();
2867 receiver1.save();
2868 receiver1.rotate(360);
2869 receiver1.drawRect({0, 0, 100, 100});
2870 receiver1.restore();
2871 receiver1.drawRect({0, 0, 100, 100});
2872 receiver1.restore();
2873 auto display_list1 = builder1.Build();
2874
2875 DisplayListBuilder builder2;
2876 DlOpReceiver& receiver2 = ToReceiver(builder2);
2877 receiver2.drawRect({0, 0, 100, 100});
2878 receiver2.drawRect({0, 0, 100, 100});
2879 auto display_list2 = builder2.Build();
2880
2881 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2882}

◆ TEST_F() [258/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPScaleDoesNotTriggerDeferredSave   
)

Definition at line 2842 of file display_list_unittests.cc.

2842 {
2843 DisplayListBuilder builder1;
2844 DlOpReceiver& receiver1 = ToReceiver(builder1);
2845 receiver1.save();
2846 receiver1.save();
2847 receiver1.scale(1.0, 1.0);
2848 receiver1.drawRect({0, 0, 100, 100});
2849 receiver1.restore();
2850 receiver1.drawRect({0, 0, 100, 100});
2851 receiver1.restore();
2852 auto display_list1 = builder1.Build();
2853
2854 DisplayListBuilder builder2;
2855 DlOpReceiver& receiver2 = ToReceiver(builder2);
2856 receiver2.drawRect({0, 0, 100, 100});
2857 receiver2.drawRect({0, 0, 100, 100});
2858 auto display_list2 = builder2.Build();
2859
2860 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2861}

◆ TEST_F() [259/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPSkewDoesNotTriggerDeferredSave   
)

Definition at line 2884 of file display_list_unittests.cc.

2884 {
2885 DisplayListBuilder builder1;
2886 DlOpReceiver& receiver1 = ToReceiver(builder1);
2887 receiver1.save();
2888 receiver1.save();
2889 receiver1.skew(0, 0);
2890 receiver1.drawRect({0, 0, 100, 100});
2891 receiver1.restore();
2892 receiver1.drawRect({0, 0, 100, 100});
2893 receiver1.restore();
2894 auto display_list1 = builder1.Build();
2895
2896 DisplayListBuilder builder2;
2897 DlOpReceiver& receiver2 = ToReceiver(builder2);
2898 receiver2.drawRect({0, 0, 100, 100});
2899 receiver2.drawRect({0, 0, 100, 100});
2900 auto display_list2 = builder2.Build();
2901
2902 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2903}
virtual void skew(SkScalar sx, SkScalar sy)=0

◆ TEST_F() [260/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTransform2DDoesNotTriggerDeferredSave   
)

Definition at line 2933 of file display_list_unittests.cc.

2933 {
2934 DisplayListBuilder builder1;
2935 DlOpReceiver& receiver1 = ToReceiver(builder1);
2936 receiver1.save();
2937 receiver1.save();
2938 receiver1.transform2DAffine(1, 0, 0, 0, 1, 0);
2939 receiver1.drawRect({0, 0, 100, 100});
2940 receiver1.restore();
2941 receiver1.drawRect({0, 0, 100, 100});
2942 receiver1.restore();
2943 auto display_list1 = builder1.Build();
2944
2945 DisplayListBuilder builder2;
2946 DlOpReceiver& receiver2 = ToReceiver(builder2);
2947 receiver2.drawRect({0, 0, 100, 100});
2948 receiver2.drawRect({0, 0, 100, 100});
2949 auto display_list2 = builder2.Build();
2950
2951 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2952}
virtual void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt)=0

◆ TEST_F() [261/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTransformDoesNotTriggerDeferredSave   
)

Definition at line 2905 of file display_list_unittests.cc.

2905 {
2906 DisplayListBuilder builder1;
2907 DlOpReceiver& receiver1 = ToReceiver(builder1);
2908 receiver1.save();
2909 receiver1.save();
2910 receiver1.transformFullPerspective(1, 0, 0, 0, //
2911 0, 1, 0, 0, //
2912 0, 0, 1, 0, //
2913 0, 0, 0, 1);
2914 receiver1.drawRect({0, 0, 100, 100});
2915 receiver1.restore();
2916 receiver1.transformFullPerspective(1, 0, 0, 0, //
2917 0, 1, 0, 0, //
2918 0, 0, 1, 0, //
2919 0, 0, 0, 1);
2920 receiver1.drawRect({0, 0, 100, 100});
2921 receiver1.restore();
2922 auto display_list1 = builder1.Build();
2923
2924 DisplayListBuilder builder2;
2925 DlOpReceiver& receiver2 = ToReceiver(builder2);
2926 receiver2.drawRect({0, 0, 100, 100});
2927 receiver2.drawRect({0, 0, 100, 100});
2928 auto display_list2 = builder2.Build();
2929
2930 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2931}

◆ TEST_F() [262/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTransformFullPerspectiveDoesNotTriggerDeferredSave   
)

Definition at line 2954 of file display_list_unittests.cc.

2954 {
2955 {
2956 DisplayListBuilder builder1;
2957 DlOpReceiver& receiver1 = ToReceiver(builder1);
2958 receiver1.save();
2959 receiver1.save();
2960 receiver1.transformFullPerspective(1, 0, 0, 0, //
2961 0, 1, 0, 0, //
2962 0, 0, 1, 0, //
2963 0, 0, 0, 1);
2964 receiver1.drawRect({0, 0, 100, 100});
2965 receiver1.restore();
2966 receiver1.drawRect({0, 0, 100, 100});
2967 receiver1.restore();
2968 auto display_list1 = builder1.Build();
2969
2970 DisplayListBuilder builder2;
2971 DlOpReceiver& receiver2 = ToReceiver(builder2);
2972 receiver2.drawRect({0, 0, 100, 100});
2973 receiver2.drawRect({0, 0, 100, 100});
2974 auto display_list2 = builder2.Build();
2975
2976 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2977 }
2978
2979 {
2980 DisplayListBuilder builder1;
2981 DlOpReceiver& receiver1 = ToReceiver(builder1);
2982 receiver1.save();
2983 receiver1.save();
2984 receiver1.transformFullPerspective(1, 0, 0, 0, //
2985 0, 1, 0, 0, //
2986 0, 0, 1, 0, //
2987 0, 0, 0, 1);
2988 receiver1.transformReset();
2989 receiver1.drawRect({0, 0, 100, 100});
2990 receiver1.restore();
2991 receiver1.drawRect({0, 0, 100, 100});
2992 receiver1.restore();
2993 auto display_list1 = builder1.Build();
2994
2995 DisplayListBuilder builder2;
2996 DlOpReceiver& receiver2 = ToReceiver(builder2);
2997 receiver2.save();
2998 receiver2.transformReset();
2999 receiver2.drawRect({0, 0, 100, 100});
3000 receiver2.restore();
3001 receiver2.drawRect({0, 0, 100, 100});
3002
3003 auto display_list2 = builder2.Build();
3004
3005 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
3006 }
3007}

◆ TEST_F() [263/925]

flutter::testing::TEST_F ( DisplayListTest  ,
NOPTranslateDoesNotTriggerDeferredSave   
)

Definition at line 2821 of file display_list_unittests.cc.

2821 {
2822 DisplayListBuilder builder1;
2823 DlOpReceiver& receiver1 = ToReceiver(builder1);
2824 receiver1.save();
2825 receiver1.save();
2826 receiver1.translate(0, 0);
2827 receiver1.drawRect({0, 0, 100, 100});
2828 receiver1.restore();
2829 receiver1.drawRect({0, 0, 100, 100});
2830 receiver1.restore();
2831 auto display_list1 = builder1.Build();
2832
2833 DisplayListBuilder builder2;
2834 DlOpReceiver& receiver2 = ToReceiver(builder2);
2835 receiver2.drawRect({0, 0, 100, 100});
2836 receiver2.drawRect({0, 0, 100, 100});
2837 auto display_list2 = builder2.Build();
2838
2839 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2840}

◆ TEST_F() [264/925]

flutter::testing::TEST_F ( DisplayListTest  ,
OOBSaveLayerContentCulledWithBlurFilter   
)

Definition at line 576 of file display_list_unittests.cc.

576 {
577 SkRect cull_rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
578 SkRect draw_rect = SkRect::MakeLTRB(25.0f, 25.0f, 99.0f, 75.0f);
579 auto filter = DlBlurImageFilter::Make(10.0f, 10.0f, DlTileMode::kDecal);
580 DlPaint layer_paint = DlPaint().setImageFilter(filter);
581
582 // We want a draw rect that is outside the layer bounds even though its
583 // filtered output might be inside. The drawn rect should be culled by
584 // the expectations of the layer bounds even though it is close enough
585 // to be visible due to filtering.
586 ASSERT_FALSE(cull_rect.intersects(draw_rect));
587 SkRect mapped_rect;
588 ASSERT_TRUE(filter->map_local_bounds(draw_rect, mapped_rect));
589 ASSERT_TRUE(mapped_rect.intersects(cull_rect));
590
592 builder.SaveLayer(&cull_rect, &layer_paint);
593 { //
594 builder.DrawRect(draw_rect, DlPaint());
595 }
596 builder.Restore();
597 auto display_list = builder.Build();
598
599 EXPECT_EQ(display_list->op_count(), 2u);
600 EXPECT_EQ(display_list->total_depth(), 1u);
601
602 EXPECT_TRUE(display_list->bounds().isEmpty()) << display_list->bounds();
603}

◆ TEST_F() [265/925]

flutter::testing::TEST_F ( DisplayListTest  ,
OOBSaveLayerContentCulledWithMatrixFilter   
)

Definition at line 605 of file display_list_unittests.cc.

605 {
606 SkRect cull_rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
607 SkRect draw_rect = SkRect::MakeLTRB(25.0f, 125.0f, 75.0f, 175.0f);
608 auto filter = DlMatrixImageFilter::Make(SkMatrix::Translate(100.0f, 0.0f),
610 DlPaint layer_paint = DlPaint().setImageFilter(filter);
611
612 // We want a draw rect that is outside the layer bounds even though its
613 // filtered output might be inside. The drawn rect should be culled by
614 // the expectations of the layer bounds even though it is close enough
615 // to be visible due to filtering.
616 ASSERT_FALSE(cull_rect.intersects(draw_rect));
617 SkRect mapped_rect;
618 ASSERT_TRUE(filter->map_local_bounds(draw_rect, mapped_rect));
619 ASSERT_TRUE(mapped_rect.intersects(cull_rect));
620
622 builder.SaveLayer(&cull_rect, &layer_paint);
623 { //
624 builder.DrawRect(draw_rect, DlPaint());
625 }
626 builder.Restore();
627 auto display_list = builder.Build();
628
629 EXPECT_EQ(display_list->op_count(), 2u);
630 EXPECT_EQ(display_list->total_depth(), 1u);
631
632 EXPECT_TRUE(display_list->bounds().isEmpty()) << display_list->bounds();
633}

◆ TEST_F() [266/925]

flutter::testing::TEST_F ( DisplayListTest  ,
OpacityIncompatibleRenderOpInsideDeferredSave   
)

Definition at line 4077 of file display_list_unittests.cc.

4077 {
4078 {
4079 // Without deferred save
4081 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4082 DlPaint().setBlendMode(DlBlendMode::kClear));
4083 EXPECT_FALSE(builder.Build()->can_apply_group_opacity());
4084 }
4085
4086 {
4087 // With deferred save
4089 builder.Save();
4090 {
4091 // Nothing to trigger the deferred save...
4092 builder.DrawRect(SkRect::MakeLTRB(0, 0, 10, 10),
4093 DlPaint().setBlendMode(DlBlendMode::kClear));
4094 }
4095 // Deferred save was not triggered, did it forward the incompatibility
4096 // flags?
4097 builder.Restore();
4098 EXPECT_FALSE(builder.Build()->can_apply_group_opacity());
4099 }
4100}

◆ TEST_F() [267/925]

flutter::testing::TEST_F ( DisplayListTest  ,
OverlappingOpsDoNotSupportGroupOpacity   
)

Definition at line 1204 of file display_list_unittests.cc.

1204 {
1206 for (int i = 0; i < 10; i++) {
1207 builder.DrawRect(SkRect::MakeXYWH(i * 10, 0, 30, 30), DlPaint());
1208 }
1209 auto display_list = builder.Build();
1210 EXPECT_FALSE(display_list->can_apply_group_opacity());
1211}

◆ TEST_F() [268/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RemoveUnnecessarySaveRestorePairs   
)

Definition at line 2397 of file display_list_unittests.cc.

2397 {
2398 {
2400 DlOpReceiver& receiver = ToReceiver(builder);
2401 receiver.drawRect({10, 10, 20, 20});
2402 receiver.save(); // This save op is unnecessary
2403 receiver.drawRect({50, 50, 60, 60});
2404 receiver.restore();
2405
2406 DisplayListBuilder builder2;
2407 DlOpReceiver& receiver2 = ToReceiver(builder2);
2408 receiver2.drawRect({10, 10, 20, 20});
2409 receiver2.drawRect({50, 50, 60, 60});
2410 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), builder2.Build()));
2411 }
2412
2413 {
2414 DisplayListBuilder builder;
2415 DlOpReceiver& receiver = ToReceiver(builder);
2416 receiver.drawRect({10, 10, 20, 20});
2417 receiver.save();
2418 receiver.translate(1.0, 1.0);
2419 {
2420 receiver.save(); // unnecessary
2421 receiver.drawRect({50, 50, 60, 60});
2422 receiver.restore();
2423 }
2424
2425 receiver.restore();
2426
2427 DisplayListBuilder builder2;
2428 DlOpReceiver& receiver2 = ToReceiver(builder2);
2429 receiver2.drawRect({10, 10, 20, 20});
2430 receiver2.save();
2431 receiver2.translate(1.0, 1.0);
2432 { receiver2.drawRect({50, 50, 60, 60}); }
2433 receiver2.restore();
2434 ASSERT_TRUE(DisplayListsEQ_Verbose(builder.Build(), builder2.Build()));
2435 }
2436}

◆ TEST_F() [269/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RemoveUnnecessarySaveRestorePairsInSetPaint   
)

Definition at line 2488 of file display_list_unittests.cc.

2488 {
2489 SkRect build_bounds = SkRect::MakeLTRB(-100, -100, 200, 200);
2490 SkRect rect = SkRect::MakeLTRB(30, 30, 70, 70);
2491 // clang-format off
2492 const float alpha_matrix[] = {
2493 0, 0, 0, 0, 0,
2494 0, 1, 0, 0, 0,
2495 0, 0, 1, 0, 0,
2496 0, 0, 0, 0, 1,
2497 };
2498 // clang-format on
2499 DlMatrixColorFilter alpha_color_filter(alpha_matrix);
2500 // Making sure hiding a problematic ColorFilter as an ImageFilter
2501 // will generate the same behavior as setting it as a ColorFilter
2502
2503 DlColorFilterImageFilter color_filter_image_filter(alpha_color_filter);
2504 {
2505 DisplayListBuilder builder(build_bounds);
2506 builder.Save();
2507 DlPaint paint;
2508 paint.setImageFilter(&color_filter_image_filter);
2509 builder.DrawRect(rect, paint);
2510 builder.Restore();
2511 sk_sp<DisplayList> display_list1 = builder.Build();
2512
2513 DisplayListBuilder builder2(build_bounds);
2514 DlPaint paint2;
2515 paint2.setImageFilter(&color_filter_image_filter);
2516 builder2.DrawRect(rect, paint2);
2517 sk_sp<DisplayList> display_list2 = builder2.Build();
2518 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2519 }
2520
2521 {
2522 DisplayListBuilder builder(build_bounds);
2523 builder.Save();
2524 builder.SaveLayer(&build_bounds);
2525 DlPaint paint;
2526 paint.setImageFilter(&color_filter_image_filter);
2527 builder.DrawRect(rect, paint);
2528 builder.Restore();
2529 builder.Restore();
2530 sk_sp<DisplayList> display_list1 = builder.Build();
2531
2532 DisplayListBuilder builder2(build_bounds);
2533 builder2.SaveLayer(&build_bounds);
2534 DlPaint paint2;
2535 paint2.setImageFilter(&color_filter_image_filter);
2536 builder2.DrawRect(rect, paint2);
2537 builder2.Restore();
2538 sk_sp<DisplayList> display_list2 = builder2.Build();
2539 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2540 }
2541}

◆ TEST_F() [270/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ResetTransformTriggersDeferredSave   
)

Definition at line 2633 of file display_list_unittests.cc.

2633 {
2634 DisplayListBuilder builder1;
2635 DlOpReceiver& receiver1 = ToReceiver(builder1);
2636 receiver1.save();
2637 receiver1.save();
2638 receiver1.transformReset();
2639 receiver1.drawRect({0, 0, 100, 100});
2640 receiver1.restore();
2641 receiver1.restore();
2642 auto display_list1 = builder1.Build();
2643
2644 DisplayListBuilder builder2;
2645 DlOpReceiver& receiver2 = ToReceiver(builder2);
2646 receiver2.save();
2647 receiver2.transformReset();
2648 receiver2.drawRect({0, 0, 100, 100});
2649 receiver2.restore();
2650 auto display_list2 = builder2.Build();
2651
2652 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2653}

◆ TEST_F() [271/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RotateAffectsCurrentTransform   
)

Definition at line 1723 of file display_list_unittests.cc.

1723 {
1725 DlOpReceiver& receiver = ToReceiver(builder);
1726 receiver.rotate(12.3);
1728 SkM44 m44 = SkM44(matrix);
1729 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1730 SkMatrix cur_matrix = builder.GetTransform();
1731 ASSERT_EQ(cur_m44, m44);
1732 ASSERT_EQ(cur_matrix, matrix);
1733 receiver.translate(10, 10);
1734 // CurrentTransform has changed
1735 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1736 ASSERT_NE(builder.GetTransform(), cur_matrix);
1737 // Previous return values have not
1738 ASSERT_EQ(cur_m44, m44);
1739 ASSERT_EQ(cur_matrix, matrix);
1740}

◆ TEST_F() [272/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RotatedSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3651 of file display_list_unittests.cc.

3651 {
3652 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3653
3655 builder.Rotate(45.0f);
3656 builder.SaveLayer(nullptr, nullptr);
3657 { //
3658 builder.DrawRect(rect, DlPaint());
3659 }
3660 builder.Restore();
3661 auto display_list = builder.Build();
3662
3663 SaveLayerBoundsExpector expector;
3664 expector.addComputedExpectation(rect);
3665 display_list->Dispatch(expector);
3666 EXPECT_TRUE(expector.all_bounds_checked());
3667}

◆ TEST_F() [273/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfClippedSaveLayerFilterScene   
)

Definition at line 3031 of file display_list_unittests.cc.

3031 {
3032 DisplayListBuilder builder(/*prepare_rtree=*/true);
3033 // blur filter with sigma=1 expands by 30 on all sides
3034 auto filter = DlBlurImageFilter(10.0, 10.0, DlTileMode::kClamp);
3035 DlPaint default_paint = DlPaint();
3036 DlPaint filter_paint = DlPaint().setImageFilter(&filter);
3037 builder.DrawRect({10, 10, 20, 20}, default_paint);
3038 builder.ClipRect({50, 50, 60, 60}, ClipOp::kIntersect, false);
3039 builder.SaveLayer(nullptr, &filter_paint);
3040 // the following rectangle will be expanded to 23,23,87,87
3041 // by the saveLayer filter during the restore operation
3042 // but it will then be clipped to 50,50,60,60
3043 builder.DrawRect({53, 53, 57, 57}, default_paint);
3044 builder.Restore();
3045 auto display_list = builder.Build();
3046 auto rtree = display_list->rtree();
3047 std::vector<SkRect> rects = {
3048 {10, 10, 20, 20},
3049 {50, 50, 60, 60},
3050 };
3051
3052 // Missing all drawRect calls
3053 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 10, 10), rects, {});
3054 TEST_RTREE(rtree, SkRect::MakeLTRB(20, 20, 25, 25), rects, {});
3055 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 50, 50), rects, {});
3056 TEST_RTREE(rtree, SkRect::MakeLTRB(60, 60, 65, 65), rects, {});
3057
3058 // Hitting just 1 of the drawRects
3059 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 11, 11), rects, {0});
3060 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 25, 25), rects, {0});
3061 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 51, 51), rects, {1});
3062 TEST_RTREE(rtree, SkRect::MakeLTRB(59, 59, 65, 65), rects, {1});
3063
3064 // Hitting both drawRect calls
3065 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 51, 51), rects,
3066 std::vector<int>({0, 1}));
3067}

◆ TEST_F() [274/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfSaveLayerFilterScene   
)

Definition at line 2338 of file display_list_unittests.cc.

2338 {
2339 DisplayListBuilder builder(/*prepare_rtree=*/true);
2340 // blur filter with sigma=1 expands by 3 on all sides
2341 auto filter = DlBlurImageFilter(1.0, 1.0, DlTileMode::kClamp);
2342 DlPaint default_paint = DlPaint();
2343 DlPaint filter_paint = DlPaint().setImageFilter(&filter);
2344 builder.DrawRect({10, 10, 20, 20}, default_paint);
2345 builder.SaveLayer(nullptr, &filter_paint);
2346 // the following rectangle will be expanded to 50,50,60,60
2347 // by the saveLayer filter during the restore operation
2348 builder.DrawRect({53, 53, 57, 57}, default_paint);
2349 builder.Restore();
2350 auto display_list = builder.Build();
2351 auto rtree = display_list->rtree();
2352 std::vector<SkRect> rects = {
2353 {10, 10, 20, 20},
2354 {50, 50, 60, 60},
2355 };
2356
2357 // Missing all drawRect calls
2358 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 10, 10), rects, {});
2359 TEST_RTREE(rtree, SkRect::MakeLTRB(20, 20, 25, 25), rects, {});
2360 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 50, 50), rects, {});
2361 TEST_RTREE(rtree, SkRect::MakeLTRB(60, 60, 65, 65), rects, {});
2362
2363 // Hitting just 1 of the drawRects
2364 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 11, 11), rects, {0});
2365 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 25, 25), rects, {0});
2366 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 51, 51), rects, {1});
2367 TEST_RTREE(rtree, SkRect::MakeLTRB(59, 59, 65, 65), rects, {1});
2368
2369 // Hitting both drawRect calls
2370 auto expected_indices = std::vector<int>{0, 1};
2371 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 51, 51), rects, expected_indices);
2372}

◆ TEST_F() [275/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfSaveRestoreScene   
)

Definition at line 2307 of file display_list_unittests.cc.

2307 {
2308 DisplayListBuilder builder(/*prepare_rtree=*/true);
2309 DlOpReceiver& receiver = ToReceiver(builder);
2310 receiver.drawRect({10, 10, 20, 20});
2311 receiver.save();
2312 receiver.drawRect({50, 50, 60, 60});
2313 receiver.restore();
2314 auto display_list = builder.Build();
2315 auto rtree = display_list->rtree();
2316 std::vector<SkRect> rects = {
2317 {10, 10, 20, 20},
2318 {50, 50, 60, 60},
2319 };
2320
2321 // Missing all drawRect calls
2322 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 10, 10), rects, {});
2323 TEST_RTREE(rtree, SkRect::MakeLTRB(20, 20, 25, 25), rects, {});
2324 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 50, 50), rects, {});
2325 TEST_RTREE(rtree, SkRect::MakeLTRB(60, 60, 65, 65), rects, {});
2326
2327 // Hitting just 1 of the drawRects
2328 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 11, 11), rects, {0});
2329 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 25, 25), rects, {0});
2330 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 51, 51), rects, {1});
2331 TEST_RTREE(rtree, SkRect::MakeLTRB(59, 59, 65, 65), rects, {1});
2332
2333 // Hitting both drawRect calls
2334 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 51, 51), rects,
2335 std::vector<int>({0, 1}));
2336}

◆ TEST_F() [276/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeOfSimpleScene   
)

Definition at line 2278 of file display_list_unittests.cc.

2278 {
2279 DisplayListBuilder builder(/*prepare_rtree=*/true);
2280 DlOpReceiver& receiver = ToReceiver(builder);
2281 std::vector<SkRect> rects = {
2282 {10, 10, 20, 20},
2283 {50, 50, 60, 60},
2284 };
2285 receiver.drawRect(rects[0]);
2286 receiver.drawRect(rects[1]);
2287 auto display_list = builder.Build();
2288 auto rtree = display_list->rtree();
2289
2290 // Missing all drawRect calls
2291 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 10, 10), rects, {});
2292 TEST_RTREE(rtree, SkRect::MakeLTRB(20, 20, 25, 25), rects, {});
2293 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 50, 50), rects, {});
2294 TEST_RTREE(rtree, SkRect::MakeLTRB(60, 60, 65, 65), rects, {});
2295
2296 // Hitting just 1 of the drawRects
2297 TEST_RTREE(rtree, SkRect::MakeLTRB(5, 5, 11, 11), rects, {0});
2298 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 25, 25), rects, {0});
2299 TEST_RTREE(rtree, SkRect::MakeLTRB(45, 45, 51, 51), rects, {1});
2300 TEST_RTREE(rtree, SkRect::MakeLTRB(59, 59, 65, 65), rects, {1});
2301
2302 // Hitting both drawRect calls
2303 TEST_RTREE(rtree, SkRect::MakeLTRB(19, 19, 51, 51), rects,
2304 std::vector<int>({0, 1}));
2305}

◆ TEST_F() [277/925]

flutter::testing::TEST_F ( DisplayListTest  ,
RTreeRenderCulling   
)

Definition at line 3069 of file display_list_unittests.cc.

3069 {
3070 DisplayListBuilder main_builder(true);
3071 DlOpReceiver& main_receiver = ToReceiver(main_builder);
3072 main_receiver.drawRect({0, 0, 10, 10});
3073 main_receiver.drawRect({20, 0, 30, 10});
3074 main_receiver.drawRect({0, 20, 10, 30});
3075 main_receiver.drawRect({20, 20, 30, 30});
3076 auto main = main_builder.Build();
3077
3078 auto test = [main](SkIRect cull_rect, const sk_sp<DisplayList>& expected) {
3079 { // Test SkIRect culling
3080 DisplayListBuilder culling_builder;
3081 main->Dispatch(ToReceiver(culling_builder), cull_rect);
3082
3083 EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected));
3084 }
3085
3086 { // Test SkRect culling
3087 DisplayListBuilder culling_builder;
3088 main->Dispatch(ToReceiver(culling_builder), SkRect::Make(cull_rect));
3089
3090 EXPECT_TRUE(DisplayListsEQ_Verbose(culling_builder.Build(), expected));
3091 }
3092 };
3093
3094 { // No rects
3095 SkIRect cull_rect = {11, 11, 19, 19};
3096
3097 DisplayListBuilder expected_builder;
3098 auto expected = expected_builder.Build();
3099
3100 test(cull_rect, expected);
3101 }
3102
3103 { // Rect 1
3104 SkIRect cull_rect = {9, 9, 19, 19};
3105
3106 DisplayListBuilder expected_builder;
3107 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
3108 expected_receiver.drawRect({0, 0, 10, 10});
3109 auto expected = expected_builder.Build();
3110
3111 test(cull_rect, expected);
3112 }
3113
3114 { // Rect 2
3115 SkIRect cull_rect = {11, 9, 21, 19};
3116
3117 DisplayListBuilder expected_builder;
3118 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
3119 expected_receiver.drawRect({20, 0, 30, 10});
3120 auto expected = expected_builder.Build();
3121
3122 test(cull_rect, expected);
3123 }
3124
3125 { // Rect 3
3126 SkIRect cull_rect = {9, 11, 19, 21};
3127
3128 DisplayListBuilder expected_builder;
3129 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
3130 expected_receiver.drawRect({0, 20, 10, 30});
3131 auto expected = expected_builder.Build();
3132
3133 test(cull_rect, expected);
3134 }
3135
3136 { // Rect 4
3137 SkIRect cull_rect = {11, 11, 21, 21};
3138
3139 DisplayListBuilder expected_builder;
3140 DlOpReceiver& expected_receiver = ToReceiver(expected_builder);
3141 expected_receiver.drawRect({20, 20, 30, 30});
3142 auto expected = expected_builder.Build();
3143
3144 test(cull_rect, expected);
3145 }
3146
3147 { // All 4 rects
3148 SkIRect cull_rect = {9, 9, 21, 21};
3149
3150 test(cull_rect, main);
3151 }
3152}
int main(int argc, char **argv)
Definition: benchmarking.cc:29
Definition: main.py:1

◆ TEST_F() [278/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveContentDepthTest   
)

Definition at line 3970 of file display_list_unittests.cc.

3970 {
3971 DisplayListBuilder child_builder;
3972 child_builder.DrawRect({10, 10, 20, 20}, DlPaint()); // depth 1
3973 auto child = child_builder.Build();
3974
3976 builder.DrawRect({10, 10, 20, 20}, DlPaint()); // depth 1
3977
3978 builder.Save(); // covers depth 1->9
3979 {
3980 builder.Translate(5, 5); // triggers deferred save at depth 1
3981 builder.DrawRect({10, 10, 20, 20}, DlPaint()); // depth 2
3982
3983 builder.DrawDisplayList(child, 1.0f); // depth 3 (content) + 4 (self)
3984
3985 builder.SaveLayer(nullptr, nullptr); // covers depth 5->6
3986 {
3987 builder.DrawRect({12, 12, 22, 22}, DlPaint()); // depth 5
3988 builder.DrawRect({14, 14, 24, 24}, DlPaint()); // depth 6
3989 }
3990 builder.Restore(); // layer is restored with depth 6
3991
3992 builder.DrawRect({16, 16, 26, 26}, DlPaint()); // depth 8
3993 builder.DrawRect({18, 18, 28, 28}, DlPaint()); // depth 9
3994 }
3995 builder.Restore(); // save is restored with depth 9
3996
3997 builder.DrawRect({16, 16, 26, 26}, DlPaint()); // depth 10
3998 builder.DrawRect({18, 18, 28, 28}, DlPaint()); // depth 11
3999 auto display_list = builder.Build();
4000
4001 EXPECT_EQ(display_list->total_depth(), 11u);
4002
4003 DepthExpector expector({8, 2});
4004 display_list->Dispatch(expector);
4005}

◆ TEST_F() [279/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsClipDetectionSimpleClippedRect   
)

Definition at line 3901 of file display_list_unittests.cc.

3901 {
3902 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3903 SkRect save_rect = SkRect::MakeLTRB(50.0f, 50.0f, 110.0f, 110.0f);
3904 SkRect content_rect = SkRect::MakeLTRB(100.0f, 100.0f, 110.0f, 110.0f);
3905
3907 builder.SaveLayer(&save_rect, nullptr);
3908 { //
3909 builder.DrawRect(rect, DlPaint());
3910 }
3911 builder.Restore();
3912 auto display_list = builder.Build();
3913
3914 SaveLayerBoundsExpector expector;
3915 expector.addSuppliedExpectation(content_rect, true);
3916 display_list->Dispatch(expector);
3917 EXPECT_TRUE(expector.all_bounds_checked());
3918}

◆ TEST_F() [280/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsClipDetectionSimpleUnclippedRect   
)

Definition at line 3883 of file display_list_unittests.cc.

3883 {
3884 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3885 SkRect save_rect = SkRect::MakeLTRB(50.0f, 50.0f, 250.0f, 250.0f);
3886
3888 builder.SaveLayer(&save_rect, nullptr);
3889 { //
3890 builder.DrawRect(rect, DlPaint());
3891 }
3892 builder.Restore();
3893 auto display_list = builder.Build();
3894
3895 SaveLayerBoundsExpector expector;
3896 expector.addSuppliedExpectation(rect);
3897 display_list->Dispatch(expector);
3898 EXPECT_TRUE(expector.all_bounds_checked());
3899}

◆ TEST_F() [281/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfFloodingColorFilter   
)

Definition at line 3855 of file display_list_unittests.cc.

3855 {
3856 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3858 auto color_filter =
3859 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3860 ASSERT_TRUE(color_filter->modifies_transparent_black());
3861 draw_paint.setColorFilter(color_filter);
3862 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3863 ASSERT_NE(clip_rect, rect);
3864 ASSERT_TRUE(clip_rect.contains(rect));
3865
3867 builder.ClipRect(clip_rect);
3868 builder.SaveLayer(nullptr, nullptr);
3869 { //
3870 builder.DrawRect(rect, draw_paint);
3871 }
3872 builder.Restore();
3873 auto display_list = builder.Build();
3874
3875 // A color filter is implicitly clipped to the draw bounds so the layer
3876 // bounds will be the same as the draw bounds.
3877 SaveLayerBoundsExpector expector;
3878 expector.addComputedExpectation(rect);
3879 display_list->Dispatch(expector);
3880 EXPECT_TRUE(expector.all_bounds_checked());
3881}

◆ TEST_F() [282/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfFloodingImageFilter   
)

Definition at line 3828 of file display_list_unittests.cc.

3828 {
3829 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3831 auto color_filter =
3832 DlBlendColorFilter::Make(DlColor::kRed(), DlBlendMode::kSrc);
3833 ASSERT_TRUE(color_filter->modifies_transparent_black());
3834 auto image_filter = DlColorFilterImageFilter::Make(color_filter);
3835 draw_paint.setImageFilter(image_filter);
3836 SkRect clip_rect = rect.makeOutset(100.0f, 100.0f);
3837 ASSERT_NE(clip_rect, rect);
3838 ASSERT_TRUE(clip_rect.contains(rect));
3839
3841 builder.ClipRect(clip_rect);
3842 builder.SaveLayer(nullptr, nullptr);
3843 { //
3844 builder.DrawRect(rect, draw_paint);
3845 }
3846 builder.Restore();
3847 auto display_list = builder.Build();
3848
3849 SaveLayerBoundsExpector expector;
3850 expector.addComputedExpectation(clip_rect);
3851 display_list->Dispatch(expector);
3852 EXPECT_TRUE(expector.all_bounds_checked());
3853}

◆ TEST_F() [283/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfImageBlurredRect   
)

Definition at line 3575 of file display_list_unittests.cc.

3575 {
3576 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3578 auto image_filter = DlBlurImageFilter::Make(2.0f, 3.0f, DlTileMode::kDecal);
3579 draw_paint.setImageFilter(image_filter);
3580
3582 builder.SaveLayer(nullptr, nullptr);
3583 { //
3584 builder.DrawRect(rect, draw_paint);
3585 }
3586 builder.Restore();
3587 auto display_list = builder.Build();
3588
3589 SaveLayerBoundsExpector expector;
3590 expector.addComputedExpectation(rect.makeOutset(6.0f, 9.0f));
3591 display_list->Dispatch(expector);
3592 EXPECT_TRUE(expector.all_bounds_checked());
3593}

◆ TEST_F() [284/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfMaskBlurredRect   
)

Definition at line 3555 of file display_list_unittests.cc.

3555 {
3556 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3559 draw_paint.setMaskFilter(mask_filter);
3560
3562 builder.SaveLayer(nullptr, nullptr);
3563 { //
3564 builder.DrawRect(rect, draw_paint);
3565 }
3566 builder.Restore();
3567 auto display_list = builder.Build();
3568
3569 SaveLayerBoundsExpector expector;
3570 expector.addComputedExpectation(rect.makeOutset(6.0f, 6.0f));
3571 display_list->Dispatch(expector);
3572 EXPECT_TRUE(expector.all_bounds_checked());
3573}

◆ TEST_F() [285/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfNestedSimpleRect   
)

Definition at line 3747 of file display_list_unittests.cc.

3747 {
3748 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3749
3751 builder.SaveLayer(nullptr, nullptr);
3752 { //
3753 builder.SaveLayer(nullptr, nullptr);
3754 { //
3755 builder.DrawRect(rect, DlPaint());
3756 }
3757 builder.Restore();
3758 }
3759 builder.Restore();
3760 auto display_list = builder.Build();
3761
3762 SaveLayerBoundsExpector expector;
3763 expector.addComputedExpectation(rect);
3764 expector.addComputedExpectation(rect);
3765 display_list->Dispatch(expector);
3766 EXPECT_TRUE(expector.all_bounds_checked());
3767}

◆ TEST_F() [286/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfRotatedSimpleRect   
)

Definition at line 3728 of file display_list_unittests.cc.

3728 {
3729 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3730
3732 builder.SaveLayer(nullptr, nullptr);
3733 { //
3734 builder.Rotate(45.0f);
3735 builder.DrawRect(rect, DlPaint());
3736 }
3737 builder.Restore();
3738 auto display_list = builder.Build();
3739
3741 SaveLayerBoundsExpector expector;
3742 expector.addComputedExpectation(matrix.mapRect(rect));
3743 display_list->Dispatch(expector);
3744 EXPECT_TRUE(expector.all_bounds_checked());
3745}

◆ TEST_F() [287/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfScaledSimpleRect   
)

Definition at line 3709 of file display_list_unittests.cc.

3709 {
3710 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3711
3713 builder.SaveLayer(nullptr, nullptr);
3714 { //
3715 builder.Scale(10.0f, 10.0f);
3716 builder.DrawRect(rect, DlPaint());
3717 }
3718 builder.Restore();
3719 auto display_list = builder.Build();
3720
3721 SaveLayerBoundsExpector expector;
3722 expector.addComputedExpectation(
3723 SkRect::MakeLTRB(1000.0f, 1000.0f, 2000.0f, 2000.0f));
3724 display_list->Dispatch(expector);
3725 EXPECT_TRUE(expector.all_bounds_checked());
3726}

◆ TEST_F() [288/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3538 of file display_list_unittests.cc.

3538 {
3539 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3540
3542 builder.SaveLayer(nullptr, nullptr);
3543 { //
3544 builder.DrawRect(rect, DlPaint());
3545 }
3546 builder.Restore();
3547 auto display_list = builder.Build();
3548
3549 SaveLayerBoundsExpector expector;
3550 expector.addComputedExpectation(rect);
3551 display_list->Dispatch(expector);
3552 EXPECT_TRUE(expector.all_bounds_checked());
3553}

◆ TEST_F() [289/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfStrokedRect   
)

Definition at line 3595 of file display_list_unittests.cc.

3595 {
3596 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3598 draw_paint.setStrokeWidth(5.0f);
3599 draw_paint.setDrawStyle(DlDrawStyle::kStroke);
3600
3602 builder.SaveLayer(nullptr, nullptr);
3603 { //
3604 builder.DrawRect(rect, draw_paint);
3605 }
3606 builder.Restore();
3607 auto display_list = builder.Build();
3608
3609 SaveLayerBoundsExpector expector;
3610 expector.addComputedExpectation(rect.makeOutset(2.5f, 2.5f));
3611 display_list->Dispatch(expector);
3612 EXPECT_TRUE(expector.all_bounds_checked());
3613}

◆ TEST_F() [290/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsComputationOfTranslatedSimpleRect   
)

Definition at line 3691 of file display_list_unittests.cc.

3691 {
3692 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3693
3695 builder.SaveLayer(nullptr, nullptr);
3696 { //
3697 builder.Translate(10.0f, 10.0f);
3698 builder.DrawRect(rect, DlPaint());
3699 }
3700 builder.Restore();
3701 auto display_list = builder.Build();
3702
3703 SaveLayerBoundsExpector expector;
3704 expector.addComputedExpectation(rect.makeOffset(10.0f, 10.0f));
3705 display_list->Dispatch(expector);
3706 EXPECT_TRUE(expector.all_bounds_checked());
3707}

◆ TEST_F() [291/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerBoundsSnapshotsImageFilter   
)

Definition at line 1301 of file display_list_unittests.cc.

1301 {
1303 DlOpReceiver& receiver = ToReceiver(builder);
1304 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1305 receiver.drawRect({50, 50, 100, 100});
1306 // This image filter should be ignored since it was not set before saveLayer
1308 receiver.restore();
1309 SkRect bounds = builder.Build()->bounds();
1310 EXPECT_EQ(bounds, SkRect::MakeLTRB(50, 50, 100, 100));
1311}

◆ TEST_F() [292/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerColorFilterDoesNotInheritOpacity   
)

Definition at line 1475 of file display_list_unittests.cc.

1475 {
1476 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1477 SaveLayerExpector expector(expected);
1478
1480 DlOpReceiver& receiver = ToReceiver(builder);
1481 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1483 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1484 receiver.setColorFilter(nullptr);
1485 receiver.drawRect({10, 10, 20, 20});
1486 receiver.restore();
1487
1488 builder.Build()->Dispatch(expector);
1489 EXPECT_TRUE(expector.all_expectations_checked());
1490}

◆ TEST_F() [293/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerColorFilterOnChildDoesNotInheritOpacity   
)

Definition at line 1526 of file display_list_unittests.cc.

1526 {
1527 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1528 SaveLayerExpector expector(expected);
1529
1531 DlOpReceiver& receiver = ToReceiver(builder);
1532 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1533 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1535 receiver.drawRect({10, 10, 20, 20});
1536 receiver.restore();
1537
1538 builder.Build()->Dispatch(expector);
1539 EXPECT_TRUE(expector.all_expectations_checked());
1540}

◆ TEST_F() [294/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerFalseSupportsGroupOpacityOverlappingChidren   
)

Definition at line 1233 of file display_list_unittests.cc.

1233 {
1235 DlOpReceiver& receiver = ToReceiver(builder);
1236 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1237 for (int i = 0; i < 10; i++) {
1238 receiver.drawRect(SkRect::MakeXYWH(i * 10, 0, 30, 30));
1239 }
1240 receiver.restore();
1241 auto display_list = builder.Build();
1242 EXPECT_TRUE(display_list->can_apply_group_opacity());
1243}

◆ TEST_F() [295/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerFalseSupportsGroupOpacityWithChildSrcBlend   
)

Definition at line 1279 of file display_list_unittests.cc.

1279 {
1281 DlOpReceiver& receiver = ToReceiver(builder);
1282 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1283 receiver.setBlendMode(DlBlendMode::kSrc);
1284 receiver.drawRect({0, 0, 10, 10});
1285 receiver.restore();
1286 auto display_list = builder.Build();
1287 EXPECT_TRUE(display_list->can_apply_group_opacity());
1288}

◆ TEST_F() [296/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerFalseWithSrcBlendSupportsGroupOpacity   
)

Definition at line 1257 of file display_list_unittests.cc.

1257 {
1259 DlOpReceiver& receiver = ToReceiver(builder);
1260 receiver.setBlendMode(DlBlendMode::kSrc);
1261 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1262 receiver.drawRect({0, 0, 10, 10});
1263 receiver.restore();
1264 auto display_list = builder.Build();
1265 EXPECT_TRUE(display_list->can_apply_group_opacity());
1266}

◆ TEST_F() [297/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerImageFilterDoesNotInheritOpacity   
)

Definition at line 1458 of file display_list_unittests.cc.

1458 {
1459 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1460 SaveLayerExpector expector(expected);
1461
1463 DlOpReceiver& receiver = ToReceiver(builder);
1464 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1466 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1467 receiver.setImageFilter(nullptr);
1468 receiver.drawRect({10, 10, 20, 20});
1469 receiver.restore();
1470
1471 builder.Build()->Dispatch(expector);
1472 EXPECT_TRUE(expector.all_expectations_checked());
1473}

◆ TEST_F() [298/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerImageFilterOnChildInheritsOpacity   
)

Definition at line 1509 of file display_list_unittests.cc.

1509 {
1510 SaveLayerOptions expected =
1511 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1512 SaveLayerExpector expector(expected);
1513
1515 DlOpReceiver& receiver = ToReceiver(builder);
1516 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1517 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1519 receiver.drawRect({10, 10, 20, 20});
1520 receiver.restore();
1521
1522 builder.Build()->Dispatch(expector);
1523 EXPECT_TRUE(expector.all_expectations_checked());
1524}

◆ TEST_F() [299/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerNoAttributesInheritsOpacity   
)

Definition at line 1383 of file display_list_unittests.cc.

1383 {
1384 SaveLayerOptions expected =
1385 SaveLayerOptions::kNoAttributes.with_can_distribute_opacity();
1386 SaveLayerExpector expector(expected);
1387
1389 DlOpReceiver& receiver = ToReceiver(builder);
1390 receiver.saveLayer(nullptr, SaveLayerOptions::kNoAttributes);
1391 receiver.drawRect({10, 10, 20, 20});
1392 receiver.restore();
1393
1394 builder.Build()->Dispatch(expector);
1395 EXPECT_TRUE(expector.all_expectations_checked());
1396}

◆ TEST_F() [300/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerOneSimpleOpInheritsOpacity   
)

Definition at line 1367 of file display_list_unittests.cc.

1367 {
1368 SaveLayerOptions expected =
1369 SaveLayerOptions::kWithAttributes.with_can_distribute_opacity();
1370 SaveLayerExpector expector(expected);
1371
1373 DlOpReceiver& receiver = ToReceiver(builder);
1374 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1375 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1376 receiver.drawRect({10, 10, 20, 20});
1377 receiver.restore();
1378
1379 builder.Build()->Dispatch(expector);
1380 EXPECT_TRUE(expector.all_expectations_checked());
1381}

◆ TEST_F() [301/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerSrcBlendDoesNotInheritOpacity   
)

Definition at line 1492 of file display_list_unittests.cc.

1492 {
1493 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1494 SaveLayerExpector expector(expected);
1495
1497 DlOpReceiver& receiver = ToReceiver(builder);
1498 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1499 receiver.setBlendMode(DlBlendMode::kSrc);
1500 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1501 receiver.setBlendMode(DlBlendMode::kSrcOver);
1502 receiver.drawRect({10, 10, 20, 20});
1503 receiver.restore();
1504
1505 builder.Build()->Dispatch(expector);
1506 EXPECT_TRUE(expector.all_expectations_checked());
1507}

◆ TEST_F() [302/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerSrcBlendOnChildDoesNotInheritOpacity   
)

Definition at line 1542 of file display_list_unittests.cc.

1542 {
1543 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1544 SaveLayerExpector expector(expected);
1545
1547 DlOpReceiver& receiver = ToReceiver(builder);
1548 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1549 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1550 receiver.setBlendMode(DlBlendMode::kSrc);
1551 receiver.drawRect({10, 10, 20, 20});
1552 receiver.restore();
1553
1554 builder.Build()->Dispatch(expector);
1555 EXPECT_TRUE(expector.all_expectations_checked());
1556}

◆ TEST_F() [303/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTrueSupportsGroupOpacityOverlappingChidren   
)

Definition at line 1245 of file display_list_unittests.cc.

1245 {
1247 DlOpReceiver& receiver = ToReceiver(builder);
1248 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1249 for (int i = 0; i < 10; i++) {
1250 receiver.drawRect(SkRect::MakeXYWH(i * 10, 0, 30, 30));
1251 }
1252 receiver.restore();
1253 auto display_list = builder.Build();
1254 EXPECT_TRUE(display_list->can_apply_group_opacity());
1255}

◆ TEST_F() [304/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTrueSupportsGroupOpacityWithChildSrcBlend   
)

Definition at line 1290 of file display_list_unittests.cc.

1290 {
1292 DlOpReceiver& receiver = ToReceiver(builder);
1293 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1294 receiver.setBlendMode(DlBlendMode::kSrc);
1295 receiver.drawRect({0, 0, 10, 10});
1296 receiver.restore();
1297 auto display_list = builder.Build();
1298 EXPECT_TRUE(display_list->can_apply_group_opacity());
1299}

◆ TEST_F() [305/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTrueWithSrcBlendDoesNotSupportGroupOpacity   
)

Definition at line 1268 of file display_list_unittests.cc.

1268 {
1270 DlOpReceiver& receiver = ToReceiver(builder);
1271 receiver.setBlendMode(DlBlendMode::kSrc);
1272 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1273 receiver.drawRect({0, 0, 10, 10});
1274 receiver.restore();
1275 auto display_list = builder.Build();
1276 EXPECT_FALSE(display_list->can_apply_group_opacity());
1277}

◆ TEST_F() [306/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveLayerTwoOverlappingOpsDoesNotInheritOpacity   
)

Definition at line 1398 of file display_list_unittests.cc.

1398 {
1399 SaveLayerOptions expected = SaveLayerOptions::kWithAttributes;
1400 SaveLayerExpector expector(expected);
1401
1403 DlOpReceiver& receiver = ToReceiver(builder);
1404 receiver.setColor(DlColor(SkColorSetARGB(127, 255, 255, 255)));
1405 receiver.saveLayer(nullptr, SaveLayerOptions::kWithAttributes);
1406 receiver.drawRect({10, 10, 20, 20});
1407 receiver.drawRect({15, 15, 25, 25});
1408 receiver.restore();
1409
1410 builder.Build()->Dispatch(expector);
1411 EXPECT_TRUE(expector.all_expectations_checked());
1412}

◆ TEST_F() [307/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveRestoreRestoresClip   
)

Definition at line 354 of file display_list_unittests.cc.

354 {
355 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
356 DisplayListBuilder builder(cull_rect);
357
358 builder.Save();
359 builder.ClipRect({0.0f, 0.0f, 10.0f, 10.0f});
360 builder.Restore();
361 check_defaults(builder, cull_rect);
362
363 builder.Save();
364 builder.ClipRRect(SkRRect::MakeRectXY({0.0f, 0.0f, 5.0f, 5.0f}, 2.0f, 2.0f));
365 builder.Restore();
366 check_defaults(builder, cull_rect);
367
368 builder.Save();
369 builder.ClipPath(SkPath().addOval({0.0f, 0.0f, 10.0f, 10.0f}));
370 builder.Restore();
371 check_defaults(builder, cull_rect);
372}

◆ TEST_F() [308/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SaveRestoreRestoresTransform   
)

Definition at line 264 of file display_list_unittests.cc.

264 {
265 SkRect cull_rect = SkRect::MakeLTRB(-10.0f, -10.0f, 500.0f, 500.0f);
266 DisplayListBuilder builder(cull_rect);
267
268 builder.Save();
269 builder.Translate(10.0f, 10.0f);
270 builder.Restore();
271 check_defaults(builder, cull_rect);
272
273 builder.Save();
274 builder.Scale(10.0f, 10.0f);
275 builder.Restore();
276 check_defaults(builder, cull_rect);
277
278 builder.Save();
279 builder.Skew(0.1f, 0.1f);
280 builder.Restore();
281 check_defaults(builder, cull_rect);
282
283 builder.Save();
284 builder.Rotate(45.0f);
285 builder.Restore();
286 check_defaults(builder, cull_rect);
287
288 builder.Save();
289 builder.Transform(SkMatrix::Scale(10.0f, 10.0f));
290 builder.Restore();
291 check_defaults(builder, cull_rect);
292
293 builder.Save();
294 builder.Transform2DAffine(1.0f, 0.0f, 12.0f, //
295 0.0f, 1.0f, 35.0f);
296 builder.Restore();
297 check_defaults(builder, cull_rect);
298
299 builder.Save();
300 builder.Transform(SkM44(SkMatrix::Scale(10.0f, 10.0f)));
301 builder.Restore();
302 check_defaults(builder, cull_rect);
303
304 builder.Save();
305 builder.TransformFullPerspective(1.0f, 0.0f, 0.0f, 12.0f, //
306 0.0f, 1.0f, 0.0f, 35.0f, //
307 0.0f, 0.0f, 1.0f, 5.0f, //
308 0.0f, 0.0f, 0.0f, 1.0f);
309 builder.Restore();
310 check_defaults(builder, cull_rect);
311}

◆ TEST_F() [309/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ScaleAffectsCurrentTransform   
)

Definition at line 1704 of file display_list_unittests.cc.

1704 {
1706 DlOpReceiver& receiver = ToReceiver(builder);
1707 receiver.scale(12.3, 14.5);
1708 SkMatrix matrix = SkMatrix::Scale(12.3, 14.5);
1709 SkM44 m44 = SkM44(matrix);
1710 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1711 SkMatrix cur_matrix = builder.GetTransform();
1712 ASSERT_EQ(cur_m44, m44);
1713 ASSERT_EQ(cur_matrix, matrix);
1714 receiver.translate(10, 10);
1715 // CurrentTransform has changed
1716 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1717 ASSERT_NE(builder.GetTransform(), cur_matrix);
1718 // Previous return values have not
1719 ASSERT_EQ(cur_m44, m44);
1720 ASSERT_EQ(cur_matrix, matrix);
1721}

◆ TEST_F() [310/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ScaledSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3633 of file display_list_unittests.cc.

3633 {
3634 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3635
3637 builder.Scale(10.0f, 10.0f);
3638 builder.SaveLayer(nullptr, nullptr);
3639 { //
3640 builder.DrawRect(rect, DlPaint());
3641 }
3642 builder.Restore();
3643 auto display_list = builder.Build();
3644
3645 SaveLayerBoundsExpector expector;
3646 expector.addComputedExpectation(rect);
3647 display_list->Dispatch(expector);
3648 EXPECT_TRUE(expector.all_bounds_checked());
3649}

◆ TEST_F() [311/925]

flutter::testing::TEST_F ( DisplayListTest  ,
ScaleTriggersDeferredSave   
)

Definition at line 2699 of file display_list_unittests.cc.

2699 {
2700 DisplayListBuilder builder1;
2701 DlOpReceiver& receiver1 = ToReceiver(builder1);
2702 receiver1.save();
2703 receiver1.save();
2704 receiver1.scale(0.5, 0.5);
2705 receiver1.drawRect({0, 0, 100, 100});
2706 receiver1.restore();
2707 receiver1.restore();
2708 auto display_list1 = builder1.Build();
2709
2710 DisplayListBuilder builder2;
2711 DlOpReceiver& receiver2 = ToReceiver(builder2);
2712 receiver2.save();
2713 receiver2.scale(0.5, 0.5);
2714 receiver2.drawRect({0, 0, 100, 100});
2715 receiver2.restore();
2716 auto display_list2 = builder2.Build();
2717
2718 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2719}

◆ TEST_F() [312/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsAreEqualWithOrWithoutRtree   
)

Definition at line 728 of file display_list_unittests.cc.

728 {
729 for (auto& group : allGroups) {
730 for (size_t i = 0; i < group.variants.size(); i++) {
731 DisplayListBuilder builder1(/*prepare_rtree=*/false);
732 DisplayListBuilder builder2(/*prepare_rtree=*/true);
733 group.variants[i].Invoke(ToReceiver(builder1));
734 group.variants[i].Invoke(ToReceiver(builder2));
735 sk_sp<DisplayList> dl1 = builder1.Build();
736 sk_sp<DisplayList> dl2 = builder2.Build();
737
738 auto desc = group.op_name + "(variant " + std::to_string(i + 1) + " )";
739 ASSERT_EQ(dl1->op_count(false), dl2->op_count(false)) << desc;
740 ASSERT_EQ(dl1->bytes(false), dl2->bytes(false)) << desc;
741 ASSERT_EQ(dl1->op_count(true), dl2->op_count(true)) << desc;
742 ASSERT_EQ(dl1->bytes(true), dl2->bytes(true)) << desc;
743 EXPECT_EQ(dl1->total_depth(), dl2->total_depth()) << desc;
744 ASSERT_EQ(dl1->bounds(), dl2->bounds()) << desc;
745 ASSERT_EQ(dl1->total_depth(), dl2->total_depth()) << desc;
746 ASSERT_TRUE(DisplayListsEQ_Verbose(dl1, dl2)) << desc;
747 ASSERT_TRUE(DisplayListsEQ_Verbose(dl2, dl2)) << desc;
748 ASSERT_EQ(dl1->rtree().get(), nullptr) << desc;
749 ASSERT_NE(dl2->rtree().get(), nullptr) << desc;
750 }
751 }
752}

◆ TEST_F() [313/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsCompareToEachOther   
)

Definition at line 691 of file display_list_unittests.cc.

691 {
692 for (auto& group : allGroups) {
693 std::vector<sk_sp<DisplayList>> lists_a;
694 std::vector<sk_sp<DisplayList>> lists_b;
695 for (size_t i = 0; i < group.variants.size(); i++) {
696 lists_a.push_back(Build(group.variants[i]));
697 lists_b.push_back(Build(group.variants[i]));
698 }
699
700 for (size_t i = 0; i < lists_a.size(); i++) {
701 sk_sp<DisplayList> listA = lists_a[i];
702 for (size_t j = 0; j < lists_b.size(); j++) {
703 sk_sp<DisplayList> listB = lists_b[j];
704 auto desc = group.op_name + "(variant " + std::to_string(i + 1) +
705 " ==? variant " + std::to_string(j + 1) + ")";
706 if (i == j ||
707 (group.variants[i].is_empty() && group.variants[j].is_empty())) {
708 // They are the same variant, or both variants are NOPs
709 ASSERT_EQ(listA->op_count(false), listB->op_count(false)) << desc;
710 ASSERT_EQ(listA->bytes(false), listB->bytes(false)) << desc;
711 ASSERT_EQ(listA->op_count(true), listB->op_count(true)) << desc;
712 ASSERT_EQ(listA->bytes(true), listB->bytes(true)) << desc;
713 EXPECT_EQ(listA->total_depth(), listB->total_depth()) << desc;
714 ASSERT_EQ(listA->bounds(), listB->bounds()) << desc;
715 ASSERT_TRUE(listA->Equals(*listB)) << desc;
716 ASSERT_TRUE(listB->Equals(*listA)) << desc;
717 } else {
718 // No assertion on op/byte counts or bounds
719 // they may or may not be equal between variants
720 ASSERT_FALSE(listA->Equals(*listB)) << desc;
721 ASSERT_FALSE(listB->Equals(*listA)) << desc;
722 }
723 }
724 }
725 }
726}

◆ TEST_F() [314/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsNotEqualEmpty   
)

Definition at line 648 of file display_list_unittests.cc.

648 {
650 for (auto& group : allGroups) {
651 for (size_t i = 0; i < group.variants.size(); i++) {
652 sk_sp<DisplayList> dl = Build(group.variants[i]);
653 auto desc =
654 group.op_name + "(variant " + std::to_string(i + 1) + " != empty)";
655 if (group.variants[i].is_empty()) {
656 ASSERT_TRUE(DisplayListsEQ_Verbose(dl, empty));
657 ASSERT_TRUE(empty->Equals(*dl)) << desc;
658 } else {
659 ASSERT_TRUE(DisplayListsNE_Verbose(dl, empty));
660 ASSERT_FALSE(empty->Equals(*dl)) << desc;
661 }
662 }
663 }
664}
bool DisplayListsNE_Verbose(const DisplayList *a, const DisplayList *b)

◆ TEST_F() [315/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpDisplayListsRecapturedAreEqual   
)

Definition at line 666 of file display_list_unittests.cc.

666 {
667 for (auto& group : allGroups) {
668 for (size_t i = 0; i < group.variants.size(); i++) {
669 sk_sp<DisplayList> dl = Build(group.variants[i]);
670 // Verify recapturing the replay of the display list is Equals()
671 // when dispatching directly from the DL to another builder
672 DisplayListBuilder copy_builder;
673 DlOpReceiver& r = ToReceiver(copy_builder);
674 dl->Dispatch(r);
675 sk_sp<DisplayList> copy = copy_builder.Build();
676 auto desc =
677 group.op_name + "(variant " + std::to_string(i + 1) + " == copy)";
679 ASSERT_EQ(copy->op_count(false), dl->op_count(false)) << desc;
680 ASSERT_EQ(copy->bytes(false), dl->bytes(false)) << desc;
681 ASSERT_EQ(copy->op_count(true), dl->op_count(true)) << desc;
682 ASSERT_EQ(copy->bytes(true), dl->bytes(true)) << desc;
683 EXPECT_EQ(copy->total_depth(), dl->total_depth()) << desc;
684 ASSERT_EQ(copy->bounds(), dl->bounds()) << desc;
685 ASSERT_TRUE(copy->Equals(*dl)) << desc;
686 ASSERT_TRUE(dl->Equals(*copy)) << desc;
687 }
688 }
689}

◆ TEST_F() [316/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpSizes   
)

Definition at line 635 of file display_list_unittests.cc.

635 {
636 for (auto& group : allGroups) {
637 for (size_t i = 0; i < group.variants.size(); i++) {
638 auto& invocation = group.variants[i];
639 sk_sp<DisplayList> dl = Build(invocation);
640 auto desc = group.op_name + "(variant " + std::to_string(i + 1) + ")";
641 EXPECT_EQ(dl->op_count(false), invocation.op_count()) << desc;
642 EXPECT_EQ(dl->bytes(false), invocation.byte_count()) << desc;
643 EXPECT_EQ(dl->total_depth(), invocation.depth_accumulated()) << desc;
644 }
645 }
646}

◆ TEST_F() [317/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SingleOpsMightSupportGroupOpacityBlendMode   
)

Definition at line 1103 of file display_list_unittests.cc.

1103 {
1104 auto run_tests = [](const std::string& name,
1105 void build(DlOpReceiver & receiver), bool expect_for_op,
1106 bool expect_with_kSrc) {
1107 {
1108 // First test is the draw op, by itself
1109 // (usually supports group opacity)
1111 DlOpReceiver& receiver = ToReceiver(builder);
1112 build(receiver);
1113 auto display_list = builder.Build();
1114 EXPECT_EQ(display_list->can_apply_group_opacity(), expect_for_op)
1115 << "{" << std::endl
1116 << " " << name << std::endl
1117 << "}";
1118 }
1119 {
1120 // Second test i the draw op with kSrc,
1121 // (usually fails group opacity)
1123 DlOpReceiver& receiver = ToReceiver(builder);
1124 receiver.setBlendMode(DlBlendMode::kSrc);
1125 build(receiver);
1126 auto display_list = builder.Build();
1127 EXPECT_EQ(display_list->can_apply_group_opacity(), expect_with_kSrc)
1128 << "{" << std::endl
1129 << " receiver.setBlendMode(kSrc);" << std::endl
1130 << " " << name << std::endl
1131 << "}";
1132 }
1133 };
1134
1135#define RUN_TESTS(body) \
1136 run_tests(#body, [](DlOpReceiver& receiver) { body }, true, false)
1137#define RUN_TESTS2(body, expect) \
1138 run_tests(#body, [](DlOpReceiver& receiver) { body }, expect, expect)
1139
1140 RUN_TESTS(receiver.drawPaint(););
1141 RUN_TESTS2(receiver.drawColor(DlColor(SK_ColorRED), DlBlendMode::kSrcOver);
1142 , true);
1143 RUN_TESTS2(receiver.drawColor(DlColor(SK_ColorRED), DlBlendMode::kSrc);
1144 , false);
1145 RUN_TESTS(receiver.drawLine({0, 0}, {10, 10}););
1146 RUN_TESTS(receiver.drawRect({0, 0, 10, 10}););
1147 RUN_TESTS(receiver.drawOval({0, 0, 10, 10}););
1148 RUN_TESTS(receiver.drawCircle({10, 10}, 5););
1149 RUN_TESTS(receiver.drawRRect(SkRRect::MakeRectXY({0, 0, 10, 10}, 2, 2)););
1150 RUN_TESTS(receiver.drawDRRect(SkRRect::MakeRectXY({0, 0, 10, 10}, 2, 2),
1151 SkRRect::MakeRectXY({2, 2, 8, 8}, 2, 2)););
1152 RUN_TESTS(receiver.drawPath(
1153 SkPath().addOval({0, 0, 10, 10}).addOval({5, 5, 15, 15})););
1154 RUN_TESTS(receiver.drawArc({0, 0, 10, 10}, 0, math::kPi, true););
1155 RUN_TESTS2(
1157 , false);
1158 RUN_TESTS2(receiver.drawVertices(TestVertices1.get(), DlBlendMode::kSrc);
1159 , false);
1160 RUN_TESTS(receiver.drawImage(TestImage1, {0, 0}, kLinearSampling, true););
1161 RUN_TESTS2(receiver.drawImage(TestImage1, {0, 0}, kLinearSampling, false);
1162 , true);
1163 RUN_TESTS(receiver.drawImageRect(TestImage1, {10, 10, 20, 20}, {0, 0, 10, 10},
1164 kNearestSampling, true,
1165 DlCanvas::SrcRectConstraint::kFast););
1166 RUN_TESTS2(receiver.drawImageRect(TestImage1, {10, 10, 20, 20},
1167 {0, 0, 10, 10}, kNearestSampling, false,
1168 DlCanvas::SrcRectConstraint::kFast);
1169 , true);
1170 RUN_TESTS(receiver.drawImageNine(TestImage2, {20, 20, 30, 30}, {0, 0, 20, 20},
1171 DlFilterMode::kLinear, true););
1172 RUN_TESTS2(
1173 receiver.drawImageNine(TestImage2, {20, 20, 30, 30}, {0, 0, 20, 20},
1174 DlFilterMode::kLinear, false);
1175 , true);
1176 static SkRSXform xforms[] = {{1, 0, 0, 0}, {0, 1, 0, 0}};
1177 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
1178 RUN_TESTS2(
1179 receiver.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
1180 DlBlendMode::kSrcIn, kNearestSampling, nullptr, true);
1181 , false);
1182 RUN_TESTS2(
1183 receiver.drawAtlas(TestImage1, xforms, texs, nullptr, 2,
1184 DlBlendMode::kSrcIn, kNearestSampling, nullptr, false);
1185 , false);
1186 EXPECT_TRUE(TestDisplayList1->can_apply_group_opacity());
1188 {
1189 static DisplayListBuilder builder;
1190 builder.DrawRect({0, 0, 10, 10}, DlPaint());
1191 builder.DrawRect({5, 5, 15, 15}, DlPaint());
1192 static auto display_list = builder.Build();
1193 RUN_TESTS2(receiver.drawDisplayList(display_list);, false);
1194 }
1195 RUN_TESTS2(receiver.drawTextBlob(GetTestTextBlob(1), 0, 0);, false);
1196 RUN_TESTS2(
1197 receiver.drawShadow(kTestPath1, DlColor(SK_ColorBLACK), 1.0, false, 1.0);
1198 , false);
1199
1200#undef RUN_TESTS2
1201#undef RUN_TESTS
1202}
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() [318/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SkewAffectsCurrentTransform   
)

Definition at line 1742 of file display_list_unittests.cc.

1742 {
1744 DlOpReceiver& receiver = ToReceiver(builder);
1745 receiver.skew(12.3, 14.5);
1746 SkMatrix matrix = SkMatrix::Skew(12.3, 14.5);
1747 SkM44 m44 = SkM44(matrix);
1748 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1749 SkMatrix cur_matrix = builder.GetTransform();
1750 ASSERT_EQ(cur_m44, m44);
1751 ASSERT_EQ(cur_matrix, matrix);
1752 receiver.translate(10, 10);
1753 // CurrentTransform has changed
1754 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1755 ASSERT_NE(builder.GetTransform(), cur_matrix);
1756 // Previous return values have not
1757 ASSERT_EQ(cur_m44, m44);
1758 ASSERT_EQ(cur_matrix, matrix);
1759}

◆ TEST_F() [319/925]

flutter::testing::TEST_F ( DisplayListTest  ,
SkewTriggersDeferredSave   
)

Definition at line 2655 of file display_list_unittests.cc.

2655 {
2656 DisplayListBuilder builder1;
2657 DlOpReceiver& receiver1 = ToReceiver(builder1);
2658 receiver1.save();
2659 receiver1.save();
2660 receiver1.skew(10, 10);
2661 receiver1.drawRect({0, 0, 100, 100});
2662 receiver1.restore();
2663 receiver1.restore();
2664 auto display_list1 = builder1.Build();
2665
2666 DisplayListBuilder builder2;
2667 DlOpReceiver& receiver2 = ToReceiver(builder2);
2668 receiver2.save();
2669 receiver2.skew(10, 10);
2670 receiver2.drawRect({0, 0, 100, 100});
2671 receiver2.restore();
2672 auto display_list2 = builder2.Build();
2673
2674 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2675}

◆ TEST_F() [320/925]

flutter::testing::TEST_F ( DisplayListTest  ,
Transform2DTriggersDeferredSave   
)

Definition at line 2583 of file display_list_unittests.cc.

2583 {
2584 DisplayListBuilder builder1;
2585 DlOpReceiver& receiver1 = ToReceiver(builder1);
2586 receiver1.save();
2587 receiver1.save();
2588 receiver1.transform2DAffine(0, 1, 12, 1, 0, 33);
2589 receiver1.drawRect({0, 0, 100, 100});
2590 receiver1.restore();
2591 receiver1.restore();
2592 auto display_list1 = builder1.Build();
2593
2594 DisplayListBuilder builder2;
2595 DlOpReceiver& receiver2 = ToReceiver(builder2);
2596 receiver2.save();
2597 receiver2.transform2DAffine(0, 1, 12, 1, 0, 33);
2598 receiver2.drawRect({0, 0, 100, 100});
2599 receiver2.restore();
2600 auto display_list2 = builder2.Build();
2601
2602 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2603}

◆ TEST_F() [321/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformAffectsCurrentTransform   
)

Definition at line 1761 of file display_list_unittests.cc.

1761 {
1763 DlOpReceiver& receiver = ToReceiver(builder);
1764 receiver.transform2DAffine(3, 0, 12.3, //
1765 1, 5, 14.5);
1766 SkMatrix matrix = SkMatrix::MakeAll(3, 0, 12.3, //
1767 1, 5, 14.5, //
1768 0, 0, 1);
1769 SkM44 m44 = SkM44(matrix);
1770 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1771 SkMatrix cur_matrix = builder.GetTransform();
1772 ASSERT_EQ(cur_m44, m44);
1773 ASSERT_EQ(cur_matrix, matrix);
1774 receiver.translate(10, 10);
1775 // CurrentTransform has changed
1776 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1777 ASSERT_NE(builder.GetTransform(), cur_matrix);
1778 // Previous return values have not
1779 ASSERT_EQ(cur_m44, m44);
1780 ASSERT_EQ(cur_matrix, matrix);
1781}

◆ TEST_F() [322/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformingFilterSaveLayerFloodedContentBounds   
)

Definition at line 4059 of file display_list_unittests.cc.

4059 {
4061 builder.ClipRect(SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f));
4062
4063 DlPaint save_paint;
4064 auto image_filter = DlMatrixImageFilter::Make(
4065 SkMatrix::Translate(100.0f, 100.0f), DlImageSampling::kNearestNeighbor);
4066 save_paint.setImageFilter(image_filter);
4067 builder.SaveLayer(nullptr, &save_paint);
4068
4069 builder.DrawColor(DlColor::kBlue(), DlBlendMode::kSrcOver);
4070
4071 builder.Restore();
4072
4073 auto dl = builder.Build();
4074 EXPECT_EQ(dl->bounds(), SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f));
4075}

◆ TEST_F() [323/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformingFilterSaveLayerSimpleContentBounds   
)

Definition at line 4041 of file display_list_unittests.cc.

4041 {
4043 builder.ClipRect(SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f));
4044
4045 DlPaint save_paint;
4046 auto image_filter = DlMatrixImageFilter::Make(
4047 SkMatrix::Translate(100.0f, 100.0f), DlImageSampling::kNearestNeighbor);
4048 save_paint.setImageFilter(image_filter);
4049 builder.SaveLayer(nullptr, &save_paint);
4050
4051 builder.DrawRect(SkRect::MakeLTRB(20.0f, 20.0f, 25.0f, 25.0f), DlPaint());
4052
4053 builder.Restore();
4054
4055 auto dl = builder.Build();
4056 EXPECT_EQ(dl->bounds(), SkRect::MakeLTRB(120.0f, 120.0f, 125.0f, 125.0f));
4057}

◆ TEST_F() [324/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformPerspectiveTriggersDeferredSave   
)

Definition at line 2605 of file display_list_unittests.cc.

2605 {
2606 DisplayListBuilder builder1;
2607 DlOpReceiver& receiver1 = ToReceiver(builder1);
2608 receiver1.save();
2609 receiver1.save();
2610 receiver1.transformFullPerspective(0, 1, 0, 12, //
2611 1, 0, 0, 33, //
2612 3, 2, 5, 29, //
2613 0, 0, 0, 12);
2614 receiver1.drawRect({0, 0, 100, 100});
2615 receiver1.restore();
2616 receiver1.restore();
2617 auto display_list1 = builder1.Build();
2618
2619 DisplayListBuilder builder2;
2620 DlOpReceiver& receiver2 = ToReceiver(builder2);
2621 receiver2.save();
2622 receiver2.transformFullPerspective(0, 1, 0, 12, //
2623 1, 0, 0, 33, //
2624 3, 2, 5, 29, //
2625 0, 0, 0, 12);
2626 receiver2.drawRect({0, 0, 100, 100});
2627 receiver2.restore();
2628 auto display_list2 = builder2.Build();
2629
2630 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2631}

◆ TEST_F() [325/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformResetSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3669 of file display_list_unittests.cc.

3669 {
3670 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3671 SkRect rect_doubled = SkMatrix::Scale(2.0f, 2.0f).mapRect(rect);
3672
3674 builder.Scale(10.0f, 10.0f);
3675 builder.SaveLayer(nullptr, nullptr);
3676 builder.TransformReset();
3677 builder.Scale(20.0f, 20.0f);
3678 // Net local transform for saveLayer is Scale(2, 2)
3679 { //
3680 builder.DrawRect(rect, DlPaint());
3681 }
3682 builder.Restore();
3683 auto display_list = builder.Build();
3684
3685 SaveLayerBoundsExpector expector;
3686 expector.addComputedExpectation(rect_doubled);
3687 display_list->Dispatch(expector);
3688 EXPECT_TRUE(expector.all_bounds_checked());
3689}

◆ TEST_F() [326/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TransformTriggersDeferredSave   
)

Definition at line 2543 of file display_list_unittests.cc.

2543 {
2544 DisplayListBuilder builder1;
2545 DlOpReceiver& receiver1 = ToReceiver(builder1);
2546 receiver1.save();
2547 receiver1.save();
2548 receiver1.transformFullPerspective(1, 0, 0, 10, //
2549 0, 1, 0, 100, //
2550 0, 0, 1, 0, //
2551 0, 0, 0, 1);
2552 receiver1.drawRect({0, 0, 100, 100});
2553 receiver1.restore();
2554 receiver1.transformFullPerspective(1, 0, 0, 10, //
2555 0, 1, 0, 100, //
2556 0, 0, 1, 0, //
2557 0, 0, 0, 1);
2558 receiver1.drawRect({0, 0, 100, 100});
2559 receiver1.restore();
2560 auto display_list1 = builder1.Build();
2561
2562 DisplayListBuilder builder2;
2563 DlOpReceiver& receiver2 = ToReceiver(builder2);
2564 receiver2.save();
2565 receiver2.transformFullPerspective(1, 0, 0, 10, //
2566 0, 1, 0, 100, //
2567 0, 0, 1, 0, //
2568 0, 0, 0, 1);
2569 receiver2.drawRect({0, 0, 100, 100});
2570 receiver2.restore();
2571 receiver2.save();
2572 receiver2.transformFullPerspective(1, 0, 0, 10, //
2573 0, 1, 0, 100, //
2574 0, 0, 1, 0, //
2575 0, 0, 0, 1);
2576 receiver2.drawRect({0, 0, 100, 100});
2577 receiver2.restore();
2578 auto display_list2 = builder2.Build();
2579
2580 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2581}

◆ TEST_F() [327/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TranslateAffectsCurrentTransform   
)

Definition at line 1685 of file display_list_unittests.cc.

1685 {
1687 DlOpReceiver& receiver = ToReceiver(builder);
1688 receiver.translate(12.3, 14.5);
1689 SkMatrix matrix = SkMatrix::Translate(12.3, 14.5);
1690 SkM44 m44 = SkM44(matrix);
1691 SkM44 cur_m44 = builder.GetTransformFullPerspective();
1692 SkMatrix cur_matrix = builder.GetTransform();
1693 ASSERT_EQ(cur_m44, m44);
1694 ASSERT_EQ(cur_matrix, matrix);
1695 receiver.translate(10, 10);
1696 // CurrentTransform has changed
1697 ASSERT_NE(builder.GetTransformFullPerspective(), m44);
1698 ASSERT_NE(builder.GetTransform(), cur_matrix);
1699 // Previous return values have not
1700 ASSERT_EQ(cur_m44, m44);
1701 ASSERT_EQ(cur_matrix, matrix);
1702}

◆ TEST_F() [328/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TranslatedSaveLayerBoundsComputationOfSimpleRect   
)

Definition at line 3615 of file display_list_unittests.cc.

3615 {
3616 SkRect rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
3617
3619 builder.Translate(10.0f, 10.0f);
3620 builder.SaveLayer(nullptr, nullptr);
3621 { //
3622 builder.DrawRect(rect, DlPaint());
3623 }
3624 builder.Restore();
3625 auto display_list = builder.Build();
3626
3627 SaveLayerBoundsExpector expector;
3628 expector.addComputedExpectation(rect);
3629 display_list->Dispatch(expector);
3630 EXPECT_TRUE(expector.all_bounds_checked());
3631}

◆ TEST_F() [329/925]

flutter::testing::TEST_F ( DisplayListTest  ,
TranslateTriggersDeferredSave   
)

Definition at line 2677 of file display_list_unittests.cc.

2677 {
2678 DisplayListBuilder builder1;
2679 DlOpReceiver& receiver1 = ToReceiver(builder1);
2680 receiver1.save();
2681 receiver1.save();
2682 receiver1.translate(10, 10);
2683 receiver1.drawRect({0, 0, 100, 100});
2684 receiver1.restore();
2685 receiver1.restore();
2686 auto display_list1 = builder1.Build();
2687
2688 DisplayListBuilder builder2;
2689 DlOpReceiver& receiver2 = ToReceiver(builder2);
2690 receiver2.save();
2691 receiver2.translate(10, 10);
2692 receiver2.drawRect({0, 0, 100, 100});
2693 receiver2.restore();
2694 auto display_list2 = builder2.Build();
2695
2696 ASSERT_TRUE(DisplayListsEQ_Verbose(display_list1, display_list2));
2697}

◆ TEST_F() [330/925]

flutter::testing::TEST_F ( DisplayListTest  ,
UnclippedSaveLayerContentAccountsForFilter   
)

Definition at line 510 of file display_list_unittests.cc.

510 {
511 SkRect cull_rect = SkRect::MakeLTRB(0.0f, 0.0f, 300.0f, 300.0f);
512 SkRect clip_rect = SkRect::MakeLTRB(100.0f, 100.0f, 200.0f, 200.0f);
513 SkRect draw_rect = SkRect::MakeLTRB(50.0f, 140.0f, 101.0f, 160.0f);
514 auto filter = DlBlurImageFilter::Make(10.0f, 10.0f, DlTileMode::kDecal);
515 DlPaint layer_paint = DlPaint().setImageFilter(filter);
516
517 ASSERT_TRUE(clip_rect.intersects(draw_rect));
518 ASSERT_TRUE(cull_rect.contains(clip_rect));
519 ASSERT_TRUE(cull_rect.contains(draw_rect));
520
522 builder.Save();
523 {
524 builder.ClipRect(clip_rect, ClipOp::kIntersect, false);
525 builder.SaveLayer(&cull_rect, &layer_paint);
526 { //
527 builder.DrawRect(draw_rect, DlPaint());
528 }
529 builder.Restore();
530 }
531 builder.Restore();
532 auto display_list = builder.Build();
533
534 EXPECT_EQ(display_list->op_count(), 6u);
535 EXPECT_EQ(display_list->total_depth(), 2u);
536
537 SkRect result_rect = draw_rect.makeOutset(30.0f, 30.0f);
538 ASSERT_TRUE(result_rect.intersect(clip_rect));
539 ASSERT_EQ(result_rect, SkRect::MakeLTRB(100.0f, 110.0f, 131.0f, 190.0f));
540 EXPECT_EQ(display_list->bounds(), result_rect);
541}

◆ TEST_F() [331/925]

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()
Definition: message_loop.cc:72
FlutterEngineResult FlutterEngineUpdateSemanticsEnabled(FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled)
Enable or disable accessibility semantics.
Definition: embedder.cc:2827
@ kSpellOut
Definition: embedder.h:1202
@ kLocale
Definition: embedder.h:1204
A batch of updates to semantics nodes and custom actions.
Definition: embedder.h:1504

◆ TEST_F() [332/925]

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:105
const int32_t kFlutterSemanticsCustomActionIdBatchEnd
Definition: embedder.cc:106
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:2855
FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature flags)
Sets additional accessibility features.
Definition: embedder.cc:2841
@ kFlutterAccessibilityFeatureReduceMotion
Definition: embedder.h:103
static constexpr char kTooltip[]
std::function< void(Dart_NativeArguments)> NativeEntry
FlutterTransformation transform
Definition: embedder.h:1306
const char * tooltip
A textual tooltip attached to the node.
Definition: embedder.h:1322
FlutterPlatformViewIdentifier platform_view_id
Definition: embedder.h:1320
int32_t id
The unique identifier for this node.
Definition: embedder.h:1262
double transY
vertical translation
Definition: embedder.h:289
double pers2
perspective scale factor
Definition: embedder.h:295
double skewX
horizontal skew factor
Definition: embedder.h:281
double pers0
input x-axis perspective factor
Definition: embedder.h:291
double scaleX
horizontal scale factor
Definition: embedder.h:279
double skewY
vertical skew factor
Definition: embedder.h:285
double scaleY
vertical scale factor
Definition: embedder.h:287
double pers1
input y-axis perspective factor
Definition: embedder.h:293
double transX
horizontal translation
Definition: embedder.h:283

◆ TEST_F() [333/925]

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

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:1395

◆ TEST_F() [335/925]

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);
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
1350 info.struct_size = sizeof(FlutterAddViewInfo);
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:2193
size_t height
Physical height of the window.
Definition: embedder.h:847
int64_t view_id
The view that this event is describing.
Definition: embedder.h:865
double pixel_ratio
Scale factor for the physical screen.
Definition: embedder.h:849
size_t width
Physical width of the window.
Definition: embedder.h:845

◆ TEST_F() [336/925]

flutter::testing::TEST_F ( EmbedderTest  ,
ArcEndCapsAreDrawnCorrectly   
)

Definition at line 2912 of file embedder_gl_unittests.cc.

2912 {
2913 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2914
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
bool ImageMatchesFixture(const std::string &fixture_file_name, const sk_sp< SkImage > &scene_image)

◆ TEST_F() [337/925]

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
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:2254
FlutterAddViewCallback add_view_callback
Definition: embedder.h:913
size_t struct_size
Definition: embedder.h:890
FlutterViewId view_id
The identifier for the view to add. This must be unique.
Definition: embedder.h:893
const FlutterWindowMetricsEvent * view_metrics
Definition: embedder.h:898
FlutterViewId view_id
Definition: embedder.h:1787
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
Definition: embedder.h:1887
FlutterRemoveViewCallback remove_view_callback
Definition: embedder.h:961
FlutterViewId view_id
Definition: embedder.h:944

◆ TEST_F() [338/925]

flutter::testing::TEST_F ( EmbedderTest  ,
BackToBackKeyEventResponsesCorrectlyInvoked   
)

Definition at line 3222 of file embedder_unittests.cc.

3222 {
3224 fml::AutoResetWaitableEvent sync_latch;
3226
3227 // One of the threads that the callback will be posted to is the platform
3228 // thread. So we cannot wait for assertions to complete on the platform
3229 // thread. Create a new thread to manage the engine instance and wait for
3230 // assertions on the test thread.
3231 auto platform_task_runner = CreateNewThread("platform_thread");
3232
3233 platform_task_runner->PostTask([&]() {
3234 auto& context =
3235 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3236
3238 builder.SetSoftwareRendererConfig();
3239 builder.SetDartEntrypoint("key_data_echo");
3240 context.AddNativeCallback(
3241 "SignalNativeTest",
3243 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
3244
3245 context.AddNativeCallback(
3246 "EchoKeyEvent", CREATE_NATIVE_ENTRY([](Dart_NativeArguments args) {}));
3247
3248 engine = builder.LaunchEngine();
3249 ASSERT_TRUE(engine.is_valid());
3250
3251 sync_latch.Signal();
3252 });
3253 sync_latch.Wait();
3254 ready.Wait();
3255
3256 // Dispatch a single event
3257 FlutterKeyEvent event{
3258 .struct_size = sizeof(FlutterKeyEvent),
3259 .timestamp = 1000,
3261 .physical = 0x00070005,
3262 .logical = 0x00000000062,
3263 .character = nullptr,
3264 .synthesized = false,
3266 };
3267
3268 // Dispatch two events back to back, using the same callback on different
3269 // user_data
3270 KeyEventUserData user_data2{
3271 .latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3272 .returned = false,
3273 };
3274 KeyEventUserData user_data3{
3275 .latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3276 .returned = false,
3277 };
3278 auto callback23 = [](bool handled, void* untyped_user_data) {
3279 KeyEventUserData* user_data =
3280 reinterpret_cast<KeyEventUserData*>(untyped_user_data);
3281 EXPECT_EQ(handled, false);
3282 user_data->returned = true;
3283 user_data->latch->Signal();
3284 };
3285 platform_task_runner->PostTask([&]() {
3286 FlutterEngineSendKeyEvent(engine.get(), &event, callback23, &user_data2);
3287 FlutterEngineSendKeyEvent(engine.get(), &event, callback23, &user_data3);
3288 });
3289 user_data2.latch->Wait();
3290 user_data3.latch->Wait();
3291
3292 EXPECT_TRUE(user_data2.returned);
3293 EXPECT_TRUE(user_data3.returned);
3294
3295 fml::AutoResetWaitableEvent shutdown_latch;
3296 platform_task_runner->PostTask([&]() {
3297 engine.reset();
3298 shutdown_latch.Signal();
3299 });
3300 shutdown_latch.Wait();
3301}
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:2581
@ kFlutterKeyEventDeviceTypeKeyboard
Definition: embedder.h:1081
size_t struct_size
The size of this struct. Must be sizeof(FlutterKeyEvent).
Definition: embedder.h:1112

◆ TEST_F() [339/925]

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);
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
1305 info.struct_size = sizeof(FlutterAddViewInfo);
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() [340/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanCreateAndCollectAValidElfSource   
)

Definition at line 2387 of file embedder_unittests.cc.

2387 {
2388 if (!DartVM::IsRunningPrecompiledCode()) {
2389 GTEST_SKIP();
2390 return;
2391 }
2392 FlutterEngineAOTDataSource data_in = {};
2393 FlutterEngineAOTData data_out = nullptr;
2394
2395 // Collecting a null object should be allowed
2396 ASSERT_EQ(FlutterEngineCollectAOTData(data_out), kSuccess);
2397
2398 const auto elf_path =
2400
2402 data_in.elf_path = elf_path.c_str();
2403
2404 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kSuccess);
2405 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2406 ASSERT_EQ(data_in.elf_path, elf_path.c_str());
2407 ASSERT_NE(data_out, nullptr);
2408
2409 ASSERT_EQ(FlutterEngineCollectAOTData(data_out), kSuccess);
2410}
FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data)
Collects the AOT data.
Definition: embedder.cc:1480
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:1426
@ kFlutterEngineAOTDataSourceTypeElfPath
Definition: embedder.h:2110
constexpr const char * kDefaultAOTAppELFFileName
Definition: elf_loader.h:17
FlutterEngineAOTDataSourceType type
Definition: embedder.h:2116
const char * elf_path
Absolute path to an ELF library file.
Definition: embedder.h:2119

◆ TEST_F() [341/925]

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);
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:2687
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
Collects the handle created using FlutterPlatformMessageCreateResponseHandle.
Definition: embedder.cc:2722

◆ TEST_F() [342/925]

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:2959
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:2297
FlutterEngineResult FlutterEngineRunInitialized(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Runs an initialized engine instance. An engine can be initialized via FlutterEngineInitialize....
Definition: embedder.cc:2154

◆ TEST_F() [343/925]

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 {
1215 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext));
1216 builder.SetSoftwareRendererConfig();
1217 auto engine = builder.InitializeEngine();
1218 ASSERT_TRUE(engine.is_valid());
1219 engine.reset();
1220}

◆ TEST_F() [344/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
CanDeinitializeAnEngine   
)

Test that an engine can be deinitialized.

Definition at line 1240 of file embedder_unittests.cc.

1240 {
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() [346/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanGetVulkanEmbedderContext   
)

Definition at line 49 of file embedder_gl_unittests.cc.

49 {
50 auto& context = GetEmbedderContext(EmbedderTestContextType::kVulkanContext);
52}

◆ TEST_F() [347/925]

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:3207

◆ TEST_F() [348/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
CanLaunchAndShutdownWithAValidElfSource   
)

Definition at line 2412 of file embedder_unittests.cc.

2412 {
2413 if (!DartVM::IsRunningPrecompiledCode()) {
2414 GTEST_SKIP();
2415 return;
2416 }
2417 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2418
2420 context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
2421
2422 EmbedderConfigBuilder builder(
2423 context,
2424 EmbedderConfigBuilder::InitializationPreference::kAOTDataInitialize);
2425
2426 builder.SetSoftwareRendererConfig();
2427
2428 auto engine = builder.LaunchEngine();
2429 ASSERT_TRUE(engine.is_valid());
2430
2431 // Wait for the root isolate to launch.
2432 latch.Wait();
2433 engine.reset();
2434}

◆ TEST_F() [350/925]

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

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 2619 of file embedder_unittests.cc.

2619 {
2620 // This test is only relevant in JIT mode.
2621 if (DartVM::IsRunningPrecompiledCode()) {
2622 GTEST_SKIP();
2623 return;
2624 }
2625
2626 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2627 EmbedderConfigBuilder builder(context);
2628 builder.SetSoftwareRendererConfig();
2629
2630 // Explicitly define the locations of the JIT snapshots
2631 builder.GetProjectArgs().isolate_snapshot_data =
2632 reinterpret_cast<const uint8_t*>("invalid_snapshot_data");
2633 builder.GetProjectArgs().isolate_snapshot_instructions =
2634 reinterpret_cast<const uint8_t*>("invalid_snapshot_instructions");
2635
2636 auto engine = builder.LaunchEngine();
2637 ASSERT_TRUE(engine.is_valid());
2639}

◆ TEST_F() [352/925]

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 2586 of file embedder_unittests.cc.

2586 {
2587 // This test is only relevant in JIT mode.
2588 if (DartVM::IsRunningPrecompiledCode()) {
2589 GTEST_SKIP();
2590 return;
2591 }
2592
2593 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2594 EmbedderConfigBuilder builder(context);
2595 builder.SetSoftwareRendererConfig();
2596
2597 // Construct the location of valid JIT snapshots.
2598 const std::string src_path = GetSourcePath();
2599 const std::string vm_snapshot_data =
2600 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_DATA});
2601 const std::string vm_snapshot_instructions =
2602 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_INSTRUCTIONS});
2603
2604 // Explicitly define the locations of the JIT snapshots
2605 builder.GetProjectArgs().vm_snapshot_data =
2606 reinterpret_cast<const uint8_t*>(vm_snapshot_data.c_str());
2607 builder.GetProjectArgs().vm_snapshot_instructions =
2608 reinterpret_cast<const uint8_t*>(vm_snapshot_instructions.c_str());
2609
2610 auto engine = builder.LaunchEngine();
2611 ASSERT_TRUE(engine.is_valid());
2612}
const uint8_t * vm_snapshot_data
Definition: main_impl.cc:52
const uint8_t * vm_snapshot_instructions
Definition: main_impl.cc:53
const char * GetSourcePath()

◆ TEST_F() [353/925]

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 2546 of file embedder_unittests.cc.

2546 {
2547 // This test is only relevant in JIT mode.
2548 if (DartVM::IsRunningPrecompiledCode()) {
2549 GTEST_SKIP();
2550 return;
2551 }
2552
2553 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2554 EmbedderConfigBuilder builder(context);
2555 builder.SetSoftwareRendererConfig();
2556
2557 // Construct the location of valid JIT snapshots.
2558 const std::string src_path = GetSourcePath();
2559 const std::string vm_snapshot_data =
2560 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_DATA});
2561 const std::string vm_snapshot_instructions =
2562 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_INSTRUCTIONS});
2563 const std::string isolate_snapshot_data =
2564 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_DATA});
2565 const std::string isolate_snapshot_instructions =
2566 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_INSTRUCTIONS});
2567
2568 // Explicitly define the locations of the JIT snapshots
2569 builder.GetProjectArgs().vm_snapshot_data =
2570 reinterpret_cast<const uint8_t*>(vm_snapshot_data.c_str());
2571 builder.GetProjectArgs().vm_snapshot_instructions =
2572 reinterpret_cast<const uint8_t*>(vm_snapshot_instructions.c_str());
2573 builder.GetProjectArgs().isolate_snapshot_data =
2574 reinterpret_cast<const uint8_t*>(isolate_snapshot_data.c_str());
2575 builder.GetProjectArgs().isolate_snapshot_instructions =
2576 reinterpret_cast<const uint8_t*>(isolate_snapshot_instructions.c_str());
2577
2578 auto engine = builder.LaunchEngine();
2579 ASSERT_TRUE(engine.is_valid());
2580}
const uint8_t * isolate_snapshot_data
Definition: gen_snapshot.cc:69
const uint8_t * isolate_snapshot_instructions
Definition: gen_snapshot.cc:70

◆ TEST_F() [354/925]

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 2645 of file embedder_unittests.cc.

2645 {
2646 // This test is only relevant in JIT mode.
2647 if (DartVM::IsRunningPrecompiledCode()) {
2648 GTEST_SKIP();
2649 return;
2650 }
2651
2652 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2653 EmbedderConfigBuilder builder(context);
2654 builder.SetSoftwareRendererConfig();
2655
2656 ASSERT_EQ(builder.GetProjectArgs().vm_snapshot_data, nullptr);
2657 ASSERT_EQ(builder.GetProjectArgs().vm_snapshot_instructions, nullptr);
2658 ASSERT_EQ(builder.GetProjectArgs().isolate_snapshot_data, nullptr);
2659 ASSERT_EQ(builder.GetProjectArgs().isolate_snapshot_instructions, nullptr);
2660
2661 auto engine = builder.LaunchEngine();
2662 ASSERT_TRUE(engine.is_valid());
2663}

◆ TEST_F() [355/925]

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);
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() [356/925]

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

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);
1428 builder.SetSoftwareRendererConfig();
1429
1430 auto engine = builder.LaunchEngine();
1431 ASSERT_TRUE(engine.is_valid());
1432
1434 info.struct_size = sizeof(FlutterRemoveViewInfo);
1435 info.view_id = kFlutterImplicitViewId;
1436 info.remove_view_callback = [](const FlutterRemoveViewResult* result) {
1437 FAIL();
1438 };
1440}

◆ TEST_F() [358/925]

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);
1585 builder.SetSoftwareRendererConfig();
1586
1587 auto engine = builder.LaunchEngine();
1588 ASSERT_TRUE(engine.is_valid());
1589
1592 info.struct_size = sizeof(FlutterRemoveViewInfo);
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() [359/925]

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
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 EXPECT_GE(captures.worker_threads_count - 1, 2u);
2314 EXPECT_LE(captures.worker_threads_count - 1, 4u);
2315
2316 platform_task_runner->PostTask([&]() {
2317 engine.reset();
2318 sync_latch.Signal();
2319 });
2320 sync_latch.Wait();
2321
2322 // The engine should have already been destroyed on the platform task runner.
2323 ASSERT_FALSE(engine.is_valid());
2324}
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:557
DartVM * GetDartVM()
Get a pointer to the Dart VM used by this running shell instance.
Definition: shell.cc:834
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:3213
FlutterNativeThreadType
Definition: embedder.h:2086
flutter::EmbedderEngine * ToEmbedderEngine(const FlutterEngine &engine)

◆ TEST_F() [360/925]

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:3063

◆ TEST_F() [361/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanReloadSystemFonts   
)

Definition at line 276 of file embedder_unittests.cc.

276 {
277 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
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:2902

◆ TEST_F() [362/925]

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);
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() [363/925]

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
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 {
1872 platform_view.struct_size = sizeof(platform_view);
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:1795
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:1841
const FlutterPlatformView * platform_view
Definition: embedder.h:1831
size_t struct_size
This size of this struct. Must be sizeof(FlutterLayer).
Definition: embedder.h:1821
FlutterPlatformViewIdentifier identifier
Definition: embedder.h:1720
A region represented by a collection of non-overlapping rectangles.
Definition: embedder.h:1799
size_t struct_size
The size of this struct. Must be sizeof(FlutterRegion).
Definition: embedder.h:1801

◆ TEST_F() [364/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderGradientWithMetal   
)

Definition at line 38 of file embedder_metal_unittests.mm.

38 {
39 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
40
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() [366/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderImplicitView   
)

Definition at line 644 of file embedder_unittests.cc.

644 {
645 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
646
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() [368/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderImplicitViewUsingPresentLayersCallback   
)

Definition at line 676 of file embedder_unittests.cc.

676 {
677 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
678
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() [369/925]

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);
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() [370/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderSceneWithoutCustomCompositor   
)

Definition at line 1495 of file embedder_gl_unittests.cc.

1495 {
1496 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1497
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() [371/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanRenderSceneWithoutCustomCompositorMetal   
)

Definition at line 242 of file embedder_metal_unittests.mm.

242 {
243 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
244
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() [372/925]

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

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));
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"));
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() [374/925]

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);
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() [375/925]

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 {
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() [376/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanScheduleFrame   
)

Definition at line 3365 of file embedder_unittests.cc.

3365 {
3366 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3368 builder.SetSoftwareRendererConfig();
3369 builder.SetDartEntrypoint("can_schedule_frame");
3371 context.AddNativeCallback(
3372 "SignalNativeTest",
3374 [&latch](Dart_NativeArguments args) { latch.Signal(); }));
3375
3376 fml::AutoResetWaitableEvent check_latch;
3377 context.AddNativeCallback(
3378 "SignalNativeCount",
3380 [&check_latch](Dart_NativeArguments args) { check_latch.Signal(); }));
3381
3382 auto engine = builder.LaunchEngine();
3383 ASSERT_TRUE(engine.is_valid());
3384
3385 // Wait for the application to attach the listener.
3386 latch.Wait();
3387
3388 ASSERT_EQ(FlutterEngineScheduleFrame(engine.get()), kSuccess);
3389
3390 check_latch.Wait();
3391}
FlutterEngineResult FlutterEngineScheduleFrame(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Schedule a new frame to redraw the content.
Definition: embedder.cc:3293

◆ TEST_F() [377/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSendLowMemoryNotification   
)

Definition at line 2203 of file embedder_unittests.cc.

2203 {
2204 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2205
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:3191

◆ TEST_F() [378/925]

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 3480 of file embedder_unittests.cc.

3480 {
3481 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3483 builder.SetSoftwareRendererConfig();
3484 builder.SetDartEntrypoint("pointer_data_packet");
3485
3486 fml::AutoResetWaitableEvent ready_latch, count_latch, message_latch;
3487 context.AddNativeCallback(
3488 "SignalNativeTest",
3490 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3491 context.AddNativeCallback(
3492 "SignalNativeCount",
3496 ASSERT_EQ(count, 1);
3497 count_latch.Signal();
3498 }));
3499 context.AddNativeCallback(
3500 "SignalNativeMessage",
3504 ASSERT_EQ("PointerData(viewId: 0, x: 123.0, y: 456.0)", message);
3505 message_latch.Signal();
3506 }));
3507
3508 auto engine = builder.LaunchEngine();
3509 ASSERT_TRUE(engine.is_valid());
3510
3511 ready_latch.Wait();
3512
3513 FlutterPointerEvent pointer_event = {};
3514 pointer_event.struct_size = sizeof(FlutterPointerEvent);
3515 pointer_event.phase = FlutterPointerPhase::kAdd;
3516 pointer_event.x = 123;
3517 pointer_event.y = 456;
3518 pointer_event.timestamp = static_cast<size_t>(1234567890);
3519 pointer_event.view_id = 0;
3520
3522 FlutterEngineSendPointerEvent(engine.get(), &pointer_event, 1);
3523 ASSERT_EQ(result, kSuccess);
3524
3525 count_latch.Wait();
3526 message_latch.Wait();
3527}
FlutterEngineResult FlutterEngineSendPointerEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count)
Definition: embedder.cc:2429
FlutterEngineResult
Definition: embedder.h:72
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
Definition: embedder.h:1036
FlutterViewId view_id
The identifier of the view that received the pointer event.
Definition: embedder.h:1071
double y
The y coordinate of the pointer event in physical pixels.
Definition: embedder.h:1045
double x
The x coordinate of the pointer event in physical pixels.
Definition: embedder.h:1043
FlutterPointerPhase phase
Definition: embedder.h:1037

◆ TEST_F() [379/925]

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 3531 of file embedder_unittests.cc.

3531 {
3532 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3534 builder.SetSoftwareRendererConfig();
3535 builder.SetDartEntrypoint("pointer_data_packet_view_id");
3536
3537 fml::AutoResetWaitableEvent ready_latch, add_view_latch, message_latch;
3538 context.AddNativeCallback(
3539 "SignalNativeTest",
3541 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3542 context.AddNativeCallback(
3543 "SignalNativeMessage",
3547 ASSERT_EQ("ViewID: 2", message);
3548 message_latch.Signal();
3549 }));
3550
3551 auto engine = builder.LaunchEngine();
3552 ASSERT_TRUE(engine.is_valid());
3553 ready_latch.Wait();
3554
3555 // Add view 2
3556 FlutterWindowMetricsEvent metrics = {};
3557 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
3558 metrics.width = 800;
3559 metrics.height = 600;
3560 metrics.pixel_ratio = 1.0;
3561 metrics.view_id = 2;
3562
3564 info.struct_size = sizeof(FlutterAddViewInfo);
3565 info.view_id = 2;
3566 info.view_metrics = &metrics;
3567 info.add_view_callback = [](const FlutterAddViewResult* result) {
3568 EXPECT_TRUE(result->added);
3569 fml::AutoResetWaitableEvent* add_view_latch =
3570 reinterpret_cast<fml::AutoResetWaitableEvent*>(result->user_data);
3571 add_view_latch->Signal();
3572 };
3573 info.user_data = &add_view_latch;
3574 ASSERT_EQ(FlutterEngineAddView(engine.get(), &info), kSuccess);
3575 add_view_latch.Wait();
3576
3577 // Send a pointer event for view 2
3578 FlutterPointerEvent pointer_event = {};
3579 pointer_event.struct_size = sizeof(FlutterPointerEvent);
3580 pointer_event.phase = FlutterPointerPhase::kAdd;
3581 pointer_event.x = 123;
3582 pointer_event.y = 456;
3583 pointer_event.timestamp = static_cast<size_t>(1234567890);
3584 pointer_event.view_id = 2;
3585
3587 FlutterEngineSendPointerEvent(engine.get(), &pointer_event, 1);
3588 ASSERT_EQ(result, kSuccess);
3589
3590 message_latch.Wait();
3591}

◆ TEST_F() [380/925]

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);
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() [381/925]

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);
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() [382/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanSetNextFrameCallback   
)

Definition at line 3393 of file embedder_unittests.cc.

3393 {
3394 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3396 builder.SetSoftwareRendererConfig();
3397 builder.SetDartEntrypoint("draw_solid_red");
3398
3399 auto engine = builder.LaunchEngine();
3400 ASSERT_TRUE(engine.is_valid());
3401
3402 // Register the callback that is executed once the next frame is drawn.
3403 fml::AutoResetWaitableEvent callback_latch;
3404 VoidCallback callback = [](void* user_data) {
3405 fml::AutoResetWaitableEvent* callback_latch =
3407
3408 callback_latch->Signal();
3409 };
3410
3412 &callback_latch);
3413 ASSERT_EQ(result, kSuccess);
3414
3415 // Send a window metrics events so frames may be scheduled.
3416 FlutterWindowMetricsEvent event = {};
3417 event.struct_size = sizeof(event);
3418 event.width = 800;
3419 event.height = 600;
3420 event.pixel_ratio = 1.0;
3421 event.physical_view_inset_top = 0.0;
3422 event.physical_view_inset_right = 0.0;
3423 event.physical_view_inset_bottom = 0.0;
3424 event.physical_view_inset_left = 0.0;
3426 kSuccess);
3427
3428 callback_latch.Wait();
3429}
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:3305

◆ TEST_F() [383/925]

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

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 2448 of file embedder_unittests.cc.

2448 {
2449// TODO(#107263): Inconsistent snapshot paths in the Linux Fuchsia FEMU test.
2450#if defined(OS_FUCHSIA)
2451 GTEST_SKIP() << "Inconsistent paths in Fuchsia.";
2452#else
2453
2454 // This test is only relevant in JIT mode.
2455 if (DartVM::IsRunningPrecompiledCode()) {
2456 GTEST_SKIP();
2457 return;
2458 }
2459
2460 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2461 EmbedderConfigBuilder builder(context);
2462 builder.SetSoftwareRendererConfig();
2463
2464 // Construct the location of valid JIT snapshots.
2465 const std::string src_path = GetSourcePath();
2466 const std::string vm_snapshot_data =
2467 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_DATA});
2468 const std::string vm_snapshot_instructions =
2469 fml::paths::JoinPaths({src_path, TEST_VM_SNAPSHOT_INSTRUCTIONS});
2470 const std::string isolate_snapshot_data =
2471 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_DATA});
2472 const std::string isolate_snapshot_instructions =
2473 fml::paths::JoinPaths({src_path, TEST_ISOLATE_SNAPSHOT_INSTRUCTIONS});
2474
2475 // Explicitly define the locations of the JIT snapshots
2476 builder.GetProjectArgs().vm_snapshot_data =
2477 reinterpret_cast<const uint8_t*>(vm_snapshot_data.c_str());
2478 builder.GetProjectArgs().vm_snapshot_instructions =
2479 reinterpret_cast<const uint8_t*>(vm_snapshot_instructions.c_str());
2480 builder.GetProjectArgs().isolate_snapshot_data =
2481 reinterpret_cast<const uint8_t*>(isolate_snapshot_data.c_str());
2482 builder.GetProjectArgs().isolate_snapshot_instructions =
2483 reinterpret_cast<const uint8_t*>(isolate_snapshot_instructions.c_str());
2484
2485 auto engine = builder.LaunchEngine();
2486
2488 const Settings settings = shell.GetSettings();
2489
2490 ASSERT_NE(settings.vm_snapshot_data(), nullptr);
2491 ASSERT_NE(settings.vm_snapshot_instr(), nullptr);
2492 ASSERT_NE(settings.isolate_snapshot_data(), nullptr);
2493 ASSERT_NE(settings.isolate_snapshot_instr(), nullptr);
2494 ASSERT_NE(settings.dart_library_sources_kernel(), nullptr);
2495#endif // OS_FUCHSIA
2496}

◆ TEST_F() [385/925]

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:708
VkInstance instance
Definition: main.cc:48
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)

◆ TEST_F() [386/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanTerminateCleanly   
)

Definition at line 147 of file embedder_unittests.cc.

147 {
148 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
150 builder.SetSoftwareRendererConfig();
151 builder.SetDartEntrypoint("terminateExitCodeHandler");
152 auto engine = builder.LaunchEngine();
153 ASSERT_TRUE(engine.is_valid());
154}

◆ TEST_F() [387/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CanUpdateLocales   
)

Definition at line 1988 of file embedder_unittests.cc.

1988 {
1989 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
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:3004
const char * language_code
Definition: embedder.h:1941
size_t struct_size
This size of this struct. Must be sizeof(FlutterLocale).
Definition: embedder.h:1937
const char * script_code
Definition: embedder.h:1951
const char * country_code
Definition: embedder.h:1946
const char * variant_code
Definition: embedder.h:1956

◆ TEST_F() [388/925]

flutter::testing::TEST_F ( EmbedderTest  ,
ClipsAreCorrectlyCalculated   
)

Definition at line 2946 of file embedder_gl_unittests.cc.

2946 {
2947 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2948
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 {
2969 platform_view.struct_size = sizeof(platform_view);
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 =
2986
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:1694
FlutterRect FlutterRectMake(const SkRect &rect)
void FilterMutationsByType(const FlutterPlatformViewMutation **mutations, size_t count, FlutterPlatformViewMutationType type, const std::function< void(const FlutterPlatformViewMutation &mutation)> &handler)
SkMatrix GetTotalMutationTransformationMatrix(const FlutterPlatformViewMutation **mutations, size_t count)

◆ TEST_F() [389/925]

flutter::testing::TEST_F ( EmbedderTest  ,
ComplexClipsAreCorrectlyCalculated   
)

Definition at line 3026 of file embedder_gl_unittests.cc.

3026 {
3027 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3028
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 {
3049 platform_view.struct_size = sizeof(platform_view);
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() [390/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorCanPostOnlyPlatformViews   
)

Definition at line 3344 of file embedder_gl_unittests.cc.

3344 {
3345 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3346
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 {
3364 platform_view.struct_size = sizeof(platform_view);
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 {
3379 platform_view.struct_size = sizeof(platform_view);
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() [391/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorCanPostZeroLayersForPresentation   
)

Definition at line 3310 of file embedder_gl_unittests.cc.

3310 {
3311 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3312
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() [392/925]

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
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 {
740 platform_view.struct_size = sizeof(platform_view);
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 {
787 platform_view.struct_size = sizeof(platform_view);
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() [393/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderKnownSceneMetal   
)

Definition at line 316 of file embedder_metal_unittests.mm.

316 {
317 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
318
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 {
367 platform_view.struct_size = sizeof(platform_view);
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 {
413 platform_view.struct_size = sizeof(platform_view);
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() [394/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurfaceWithRootSurfaceXformation   
)

Definition at line 2309 of file embedder_gl_unittests.cc.

2311 {
2312 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2313
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 {
2369 platform_view.struct_size = sizeof(platform_view);
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() [395/925]

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
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 {
1340 platform_view.struct_size = sizeof(platform_view);
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 {
1387 platform_view.struct_size = sizeof(platform_view);
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() [396/925]

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
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 {
775 platform_view.struct_size = sizeof(platform_view);
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 {
822 platform_view.struct_size = sizeof(platform_view);
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:1627

◆ TEST_F() [397/925]

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
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 {
155 platform_view.struct_size = sizeof(platform_view);
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:1756

◆ TEST_F() [398/925]

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
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 {
494 platform_view.struct_size = sizeof(platform_view);
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() [399/925]

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
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 {
617 platform_view.struct_size = sizeof(platform_view);
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:1625

◆ TEST_F() [400/925]

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
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 {
1205 platform_view.struct_size = sizeof(platform_view);
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() [401/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorRenderTargetsAreInStableOrder   
)

Definition at line 3454 of file embedder_gl_unittests.cc.

3454 {
3455 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3456
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) {
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) {
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() [403/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorRenderTargetsAreRecycled   
)

Definition at line 3408 of file embedder_gl_unittests.cc.

3408 {
3409 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3410
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() [404/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CompositorRenderTargetsNotRecycledWhenAvoidsCacheSet   
)

Definition at line 4263 of file embedder_gl_unittests.cc.

4263 {
4264 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4265
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() [405/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CreateInvalidBackingstoreMetalTexture   
)

Definition at line 513 of file embedder_metal_unittests.mm.

513 {
514 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
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() [406/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CreateInvalidBackingstoreOpenGLFramebuffer   
)

Definition at line 4467 of file embedder_gl_unittests.cc.

4467 {
4468 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
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() [407/925]

flutter::testing::TEST_F ( EmbedderTest  ,
CreateInvalidBackingstoreOpenGLTexture   
)

Definition at line 4404 of file embedder_gl_unittests.cc.

4404 {
4405 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
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() [408/925]

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
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 {
965 platform_view.struct_size = sizeof(platform_view);
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:275

◆ TEST_F() [409/925]

flutter::testing::TEST_F ( EmbedderTest  ,
DartEntrypointArgs   
)

Definition at line 595 of file embedder_unittests.cc.

595 {
596 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
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() [410/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
EmptySceneIsAcceptable   
)

Definition at line 2856 of file embedder_gl_unittests.cc.

2856 {
2857 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2858
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() [412/925]

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

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,
4573
4574 EXPECT_TRUE(resolve_called);
4575 resolve_called = false;
4576
4577 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false,
4579
4580 EXPECT_FALSE(resolve_called);
4581
4582 texture_->MarkNewFrameAvailable();
4583 texture_->Paint(ctx, SkRect::MakeXYWH(0, 0, 100, 100), false,
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() [414/925]

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:2769
@ kRGBA
Definition: embedder.h:607
static sk_sp< SkSurface > GetSurfaceFromTexture(const sk_sp< GrDirectContext > &skia_context, SkISize texture_size, void *texture)

◆ TEST_F() [415/925]

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;
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() [416/925]

flutter::testing::TEST_F ( EmbedderTest  ,
FrameInfoContainsValidWidthAndHeight   
)

Definition at line 3524 of file embedder_gl_unittests.cc.

3524 {
3525 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3526
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:479
uint32_t height
Definition: embedder.h:433
uint32_t width
Definition: embedder.h:432

◆ TEST_F() [417/925]

flutter::testing::TEST_F ( EmbedderTest  ,
IgnoresWindowMetricsEventForUnknownView   
)

Definition at line 3634 of file embedder_unittests.cc.

3634 {
3635 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3637 builder.SetSoftwareRendererConfig();
3638 builder.SetDartEntrypoint("window_metrics_event_view_id");
3639
3640 fml::AutoResetWaitableEvent ready_latch, message_latch;
3641 context.AddNativeCallback(
3642 "SignalNativeTest",
3644 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3645
3646 context.AddNativeCallback(
3647 "SignalNativeMessage",
3651 // Message latch should only be signaled once as the bad
3652 // view metric should be dropped by the engine.
3653 ASSERT_FALSE(message_latch.IsSignaledForTest());
3654 ASSERT_EQ("Changed: [0]", message);
3655 message_latch.Signal();
3656 }));
3657
3658 auto engine = builder.LaunchEngine();
3659 ASSERT_TRUE(engine.is_valid());
3660
3661 ready_latch.Wait();
3662
3663 // Send a window metric for a nonexistent view, which should be dropped by the
3664 // engine.
3665 FlutterWindowMetricsEvent bad_event = {};
3666 bad_event.struct_size = sizeof(FlutterWindowMetricsEvent);
3667 bad_event.width = 200;
3668 bad_event.height = 300;
3669 bad_event.pixel_ratio = 1.5;
3670 bad_event.view_id = 100;
3671
3674 ASSERT_EQ(result, kSuccess);
3675
3676 // Send a window metric for a valid view. The engine notifies the Dart app.
3677 FlutterWindowMetricsEvent event = {};
3678 event.struct_size = sizeof(FlutterWindowMetricsEvent);
3679 event.width = 200;
3680 event.height = 300;
3681 event.pixel_ratio = 1.5;
3682 event.view_id = 0;
3683
3685 ASSERT_EQ(result, kSuccess);
3686
3687 message_latch.Wait();
3688}

◆ TEST_F() [418/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
InvalidAOTDataSourcesMustReturnError   
)

Definition at line 2326 of file embedder_unittests.cc.

2326 {
2327 if (!DartVM::IsRunningPrecompiledCode()) {
2328 GTEST_SKIP();
2329 return;
2330 }
2331 FlutterEngineAOTDataSource data_in = {};
2332 FlutterEngineAOTData data_out = nullptr;
2333
2334 // Null source specified.
2335 ASSERT_EQ(FlutterEngineCreateAOTData(nullptr, &data_out), kInvalidArguments);
2336 ASSERT_EQ(data_out, nullptr);
2337
2338 // Null data_out specified.
2339 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, nullptr), kInvalidArguments);
2340
2341 // Invalid FlutterEngineAOTDataSourceType type specified.
2342 // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
2343 data_in.type = static_cast<FlutterEngineAOTDataSourceType>(-1);
2344 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2345 ASSERT_EQ(data_out, nullptr);
2346
2347 // Invalid ELF path specified.
2349 data_in.elf_path = nullptr;
2350 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2351 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2352 ASSERT_EQ(data_in.elf_path, nullptr);
2353 ASSERT_EQ(data_out, nullptr);
2354
2355 // Invalid ELF path specified.
2356 data_in.elf_path = "";
2357 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2358 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2359 ASSERT_EQ(data_in.elf_path, "");
2360 ASSERT_EQ(data_out, nullptr);
2361
2362 // Could not find VM snapshot data.
2363 data_in.elf_path = "/bin/true";
2364 ASSERT_EQ(FlutterEngineCreateAOTData(&data_in, &data_out), kInvalidArguments);
2365 ASSERT_EQ(data_in.type, kFlutterEngineAOTDataSourceTypeElfPath);
2366 ASSERT_EQ(data_in.elf_path, "/bin/true");
2367 ASSERT_EQ(data_out, nullptr);
2368}
FlutterEngineAOTDataSourceType
AOT data source type.
Definition: embedder.h:2109

◆ TEST_F() [420/925]

flutter::testing::TEST_F ( EmbedderTest  ,
InvalidFlutterWindowMetricsEvent   
)

Definition at line 2665 of file embedder_unittests.cc.

2665 {
2666 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2668 builder.SetSoftwareRendererConfig();
2669 auto engine = builder.LaunchEngine();
2670
2671 ASSERT_TRUE(engine.is_valid());
2672
2673 FlutterWindowMetricsEvent event = {};
2674 event.struct_size = sizeof(event);
2675 event.width = 800;
2676 event.height = 600;
2677 event.pixel_ratio = 0.0;
2678 event.physical_view_inset_top = 0.0;
2679 event.physical_view_inset_right = 0.0;
2680 event.physical_view_inset_bottom = 0.0;
2681 event.physical_view_inset_left = 0.0;
2682
2683 // Pixel ratio must be positive.
2686
2687 event.pixel_ratio = 1.0;
2688 event.physical_view_inset_top = -1.0;
2689 event.physical_view_inset_right = -1.0;
2690 event.physical_view_inset_bottom = -1.0;
2691 event.physical_view_inset_left = -1.0;
2692
2693 // Physical view insets must be non-negative.
2696
2697 event.physical_view_inset_top = 700;
2698 event.physical_view_inset_right = 900;
2699 event.physical_view_inset_bottom = 700;
2700 event.physical_view_inset_left = 900;
2701
2702 // Top/bottom insets cannot be greater than height.
2703 // Left/right insets cannot be greater than width.
2706}

◆ TEST_F() [421/925]

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);
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:2636
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformMessage).
Definition: embedder.h:1164
const FlutterPlatformMessageResponseHandle * response_handle
Definition: embedder.h:1174
const char * channel
Definition: embedder.h:1165
const uint8_t * message
Definition: embedder.h:1166

◆ TEST_F() [422/925]

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([&]() {
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() [423/925]

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 2504 of file embedder_unittests.cc.

2504 {
2505// TODO(#107263): Inconsistent snapshot paths in the Linux Fuchsia FEMU test.
2506#if defined(OS_FUCHSIA)
2507 GTEST_SKIP() << "Inconsistent paths in Fuchsia.";
2508#else
2509
2510 // This test is only relevant in JIT mode.
2511 if (DartVM::IsRunningPrecompiledCode()) {
2512 GTEST_SKIP();
2513 return;
2514 }
2515
2516 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2517 EmbedderConfigBuilder builder(context);
2518 builder.SetSoftwareRendererConfig();
2519
2520 // Explicitly define the locations of the invalid JIT snapshots
2521 builder.GetProjectArgs().vm_snapshot_data =
2522 reinterpret_cast<const uint8_t*>("invalid_vm_data");
2523 builder.GetProjectArgs().vm_snapshot_instructions =
2524 reinterpret_cast<const uint8_t*>("invalid_vm_instructions");
2525 builder.GetProjectArgs().isolate_snapshot_data =
2526 reinterpret_cast<const uint8_t*>("invalid_snapshot_data");
2527 builder.GetProjectArgs().isolate_snapshot_instructions =
2528 reinterpret_cast<const uint8_t*>("invalid_snapshot_instructions");
2529
2530 auto engine = builder.LaunchEngine();
2531
2533 const Settings settings = shell.GetSettings();
2534
2535 ASSERT_EQ(settings.vm_snapshot_data(), nullptr);
2536 ASSERT_EQ(settings.vm_snapshot_instr(), nullptr);
2537 ASSERT_EQ(settings.isolate_snapshot_data(), nullptr);
2538 ASSERT_EQ(settings.isolate_snapshot_instr(), nullptr);
2539#endif // OS_FUCHSIA
2540}

◆ TEST_F() [424/925]

flutter::testing::TEST_F ( EmbedderTest  ,
KeyDataAreBuffered   
)

Definition at line 3028 of file embedder_unittests.cc.

3028 {
3029 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
3030 std::vector<FlutterKeyEvent> echoed_events;
3031
3032 auto native_echo_event = [&](Dart_NativeArguments args) {
3033 echoed_events.push_back(FlutterKeyEvent{
3034 .timestamp =
3035 static_cast<double>(tonic::DartConverter<uint64_t>::FromDart(
3037 .type =
3046 .device_type = UnserializeKeyEventDeviceType(
3049 });
3050
3051 message_latch->Signal();
3052 };
3053
3054 auto platform_task_runner = CreateNewThread("platform_thread");
3055
3058 platform_task_runner->PostTask([&]() {
3059 auto& context =
3060 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3061 EmbedderConfigBuilder builder(context);
3062 builder.SetSoftwareRendererConfig();
3063 builder.SetDartEntrypoint("key_data_late_echo");
3064 builder.SetPlatformMessageCallback(
3065 [&](const FlutterPlatformMessage* message) {
3067 engine.get(), message->response_handle, nullptr, 0);
3068 });
3069 context.AddNativeCallback(
3070 "SignalNativeTest",
3072 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
3073
3074 context.AddNativeCallback("EchoKeyEvent",
3075 CREATE_NATIVE_ENTRY(native_echo_event));
3076
3077 engine = builder.LaunchEngine();
3078 ASSERT_TRUE(engine.is_valid());
3079 });
3080 ready.Wait();
3081
3082 FlutterKeyEvent sample_event{
3083 .struct_size = sizeof(FlutterKeyEvent),
3085 .physical = 0x00070004,
3086 .logical = 0x00000000061,
3087 .character = "A",
3088 .synthesized = false,
3090 };
3091
3092 // Send an event.
3093 sample_event.timestamp = 1.0l;
3094 platform_task_runner->PostTask([&]() {
3095 FlutterEngineSendKeyEvent(engine.get(), &sample_event, nullptr, nullptr);
3096 message_latch->Signal();
3097 });
3098 message_latch->Wait();
3099
3100 // Should not receive echos because the callback is not set yet.
3101 EXPECT_EQ(echoed_events.size(), 0u);
3102
3103 // Send an empty message to 'test/starts_echo' to start echoing.
3104 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
3106 engine.get(), [](const uint8_t* data, size_t size, void* user_data) {},
3107 nullptr, &response_handle);
3108
3110 .struct_size = sizeof(FlutterPlatformMessage),
3111 .channel = "test/starts_echo",
3112 .message = nullptr,
3113 .message_size = 0,
3114 .response_handle = response_handle,
3115 };
3116
3117 platform_task_runner->PostTask([&]() {
3120 ASSERT_EQ(result, kSuccess);
3121
3123 });
3124
3125 // message_latch->Wait();
3126 message_latch->Wait();
3127 // All previous events should be received now.
3128 EXPECT_EQ(echoed_events.size(), 1u);
3129
3130 // Send a second event.
3131 sample_event.timestamp = 10.0l;
3132 platform_task_runner->PostTask([&]() {
3133 FlutterEngineSendKeyEvent(engine.get(), &sample_event, nullptr, nullptr);
3134 });
3135 message_latch->Wait();
3136
3137 // The event should be echoed, too.
3138 EXPECT_EQ(echoed_events.size(), 2u);
3139
3140 fml::AutoResetWaitableEvent shutdown_latch;
3141 platform_task_runner->PostTask([&]() {
3142 engine.reset();
3143 shutdown_latch.Signal();
3144 });
3145 shutdown_latch.Wait();
3146}
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:2737
FlutterKeyEventType UnserializeKeyEventType(uint64_t kind)
fml::UniqueObject< FlutterEngine, UniqueEngineTraits > UniqueEngine
FlutterKeyEventDeviceType UnserializeKeyEventDeviceType(uint64_t source)

◆ TEST_F() [425/925]

flutter::testing::TEST_F ( EmbedderTest  ,
KeyDataIsCorrectlySerialized   
)

Definition at line 2904 of file embedder_unittests.cc.

2904 {
2905 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
2906 uint64_t echoed_char;
2907 FlutterKeyEvent echoed_event;
2908 echoed_event.struct_size = sizeof(FlutterKeyEvent);
2909
2910 auto native_echo_event = [&](Dart_NativeArguments args) {
2911 echoed_event.type =
2914 echoed_event.timestamp =
2915 static_cast<double>(tonic::DartConverter<uint64_t>::FromDart(
2923 echoed_event.synthesized =
2925 echoed_event.device_type =
2928
2929 message_latch->Signal();
2930 };
2931
2932 auto platform_task_runner = CreateNewThread("platform_thread");
2933
2936 platform_task_runner->PostTask([&]() {
2937 auto& context =
2938 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2939 EmbedderConfigBuilder builder(context);
2940 builder.SetSoftwareRendererConfig();
2941 builder.SetDartEntrypoint("key_data_echo");
2942 builder.SetPlatformMessageCallback(
2943 [&](const FlutterPlatformMessage* message) {
2945 engine.get(), message->response_handle, nullptr, 0);
2946 });
2947 context.AddNativeCallback(
2948 "SignalNativeTest",
2950 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
2951
2952 context.AddNativeCallback("EchoKeyEvent",
2953 CREATE_NATIVE_ENTRY(native_echo_event));
2954
2955 engine = builder.LaunchEngine();
2956 ASSERT_TRUE(engine.is_valid());
2957 });
2958
2959 ready.Wait();
2960
2961 // A normal down event
2962 const FlutterKeyEvent down_event_upper_a{
2963 .struct_size = sizeof(FlutterKeyEvent),
2964 .timestamp = 1,
2966 .physical = 0x00070004,
2967 .logical = 0x00000000061,
2968 .character = "A",
2969 .synthesized = false,
2971 };
2972 platform_task_runner->PostTask([&]() {
2973 FlutterEngineSendKeyEvent(engine.get(), &down_event_upper_a, nullptr,
2974 nullptr);
2975 });
2976 message_latch->Wait();
2977
2978 ExpectKeyEventEq(echoed_event, down_event_upper_a);
2979 EXPECT_EQ(echoed_char, 0x41llu);
2980
2981 // A repeat event with multi-byte character
2982 const FlutterKeyEvent repeat_event_wide_char{
2983 .struct_size = sizeof(FlutterKeyEvent),
2984 .timestamp = 1000,
2986 .physical = 0x00070005,
2987 .logical = 0x00000000062,
2988 .character = "∆",
2989 .synthesized = false,
2991 };
2992 platform_task_runner->PostTask([&]() {
2993 FlutterEngineSendKeyEvent(engine.get(), &repeat_event_wide_char, nullptr,
2994 nullptr);
2995 });
2996 message_latch->Wait();
2997
2998 ExpectKeyEventEq(echoed_event, repeat_event_wide_char);
2999 EXPECT_EQ(echoed_char, 0x2206llu);
3000
3001 // An up event with no character, synthesized
3002 const FlutterKeyEvent up_event{
3003 .struct_size = sizeof(FlutterKeyEvent),
3004 .timestamp = 1000000,
3006 .physical = 0x00070006,
3007 .logical = 0x00000000063,
3008 .character = nullptr,
3009 .synthesized = true,
3011 };
3012 platform_task_runner->PostTask([&]() {
3013 FlutterEngineSendKeyEvent(engine.get(), &up_event, nullptr, nullptr);
3014 });
3015 message_latch->Wait();
3016
3017 ExpectKeyEventEq(echoed_event, up_event);
3018 EXPECT_EQ(echoed_char, 0llu);
3019
3020 fml::AutoResetWaitableEvent shutdown_latch;
3021 platform_task_runner->PostTask([&]() {
3022 engine.reset();
3023 shutdown_latch.Signal();
3024 });
3025 shutdown_latch.Wait();
3026}
void ExpectKeyEventEq(const FlutterKeyEvent &subject, const FlutterKeyEvent &baseline)

◆ TEST_F() [426/925]

flutter::testing::TEST_F ( EmbedderTest  ,
KeyDataResponseIsCorrectlyInvoked   
)

Definition at line 3148 of file embedder_unittests.cc.

3148 {
3150 fml::AutoResetWaitableEvent sync_latch;
3152
3153 // One of the threads that the key data callback will be posted to is the
3154 // platform thread. So we cannot wait for assertions to complete on the
3155 // platform thread. Create a new thread to manage the engine instance and wait
3156 // for assertions on the test thread.
3157 auto platform_task_runner = CreateNewThread("platform_thread");
3158
3159 platform_task_runner->PostTask([&]() {
3160 auto& context =
3161 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3163 builder.SetSoftwareRendererConfig();
3164 builder.SetDartEntrypoint("key_data_echo");
3165 context.AddNativeCallback(
3166 "SignalNativeTest",
3168 [&ready](Dart_NativeArguments args) { ready.Signal(); }));
3169 context.AddNativeCallback(
3170 "EchoKeyEvent", CREATE_NATIVE_ENTRY([](Dart_NativeArguments args) {}));
3171
3172 engine = builder.LaunchEngine();
3173 ASSERT_TRUE(engine.is_valid());
3174
3175 sync_latch.Signal();
3176 });
3177 sync_latch.Wait();
3178 ready.Wait();
3179
3180 // Dispatch a single event
3181 FlutterKeyEvent event{
3182 .struct_size = sizeof(FlutterKeyEvent),
3183 .timestamp = 1000,
3185 .physical = 0x00070005,
3186 .logical = 0x00000000062,
3187 .character = nullptr,
3189 };
3190
3191 KeyEventUserData user_data1{
3192 .latch = std::make_shared<fml::AutoResetWaitableEvent>(),
3193 };
3194 // Entrypoint `key_data_echo` returns `event.synthesized` as `handled`.
3195 event.synthesized = true;
3196 platform_task_runner->PostTask([&]() {
3197 // Test when the response callback is empty.
3198 // It should not cause a crash.
3199 FlutterEngineSendKeyEvent(engine.get(), &event, nullptr, nullptr);
3200
3201 // Test when the response callback is non-empty.
3202 // It should be invoked (so that the latch can be unlocked.)
3204 engine.get(), &event,
3205 [](bool handled, void* untyped_user_data) {
3206 KeyEventUserData* user_data =
3207 reinterpret_cast<KeyEventUserData*>(untyped_user_data);
3208 EXPECT_EQ(handled, true);
3209 user_data->latch->Signal();
3210 },
3211 &user_data1);
3212 });
3213 user_data1.latch->Wait();
3214 fml::AutoResetWaitableEvent shutdown_latch;
3215 platform_task_runner->PostTask([&]() {
3216 engine.reset();
3217 shutdown_latch.Signal();
3218 });
3219 shutdown_latch.Wait();
3220}

◆ TEST_F() [427/925]

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);
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() [428/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
MetalCompositorMustBeAbleToRenderPlatformViews   
)

Definition at line 131 of file embedder_metal_unittests.mm.

131 {
132 auto& context = GetEmbedderContext(EmbedderTestContextType::kMetalContext);
133
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 {
178 platform_view.struct_size = sizeof(platform_view);
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() [430/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MultipleDisplaysWithSameDisplayIdIsInvalid   
)

Definition at line 4217 of file embedder_gl_unittests.cc.

4217 {
4218 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4219
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:3252
@ kFlutterEngineDisplaysUpdateTypeStartup
Definition: embedder.h:2006
size_t struct_size
This size of this struct. Must be sizeof(FlutterDisplay).
Definition: embedder.h:1973
FlutterEngineDisplayId display_id
Definition: embedder.h:1975

◆ TEST_F() [431/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MultipleDisplaysWithSingleDisplayTrueIsInvalid   
)

Definition at line 4171 of file embedder_gl_unittests.cc.

4171 {
4172 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4173
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() [432/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWhenPopulateExistingDamageButNoOtherFBOCallback   
)

Definition at line 3636 of file embedder_gl_unittests.cc.

3637 {
3638 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3639
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() [433/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWithBothFBOCallbacksSet   
)

Definition at line 3567 of file embedder_gl_unittests.cc.

3567 {
3568 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3569
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() [434/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWithBothPresentCallbacksSet   
)

Definition at line 3578 of file embedder_gl_unittests.cc.

3578 {
3579 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3580
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() [435/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MustNotRunWithMultipleAOTSources   
)

Definition at line 2370 of file embedder_unittests.cc.

2370 {
2371 if (!DartVM::IsRunningPrecompiledCode()) {
2372 GTEST_SKIP();
2373 return;
2374 }
2375 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2376
2377 EmbedderConfigBuilder builder(
2378 context,
2379 EmbedderConfigBuilder::InitializationPreference::kMultiAOTInitialize);
2380
2381 builder.SetSoftwareRendererConfig();
2382
2383 auto engine = builder.LaunchEngine();
2384 ASSERT_FALSE(engine.is_valid());
2385}

◆ TEST_F() [436/925]

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);
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() [437/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MustRunWhenPopulateExistingDamageIsProvided   
)

Definition at line 3600 of file embedder_gl_unittests.cc.

3600 {
3601 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3602
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() [438/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MustRunWithPopulateExistingDamageAndFBOCallback   
)

Definition at line 3617 of file embedder_gl_unittests.cc.

3617 {
3618 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3619
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() [439/925]

flutter::testing::TEST_F ( EmbedderTest  ,
MustStillRunWhenPopulateExistingDamageIsNotProvided   
)

Definition at line 3589 of file embedder_gl_unittests.cc.

3589 {
3590 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3591
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() [440/925]

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
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 {
1131 platform_view.struct_size = sizeof(platform_view);
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() [441/925]

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
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 {
994 platform_view.struct_size = sizeof(platform_view);
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() [442/925]

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);
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() [443/925]

flutter::testing::TEST_F ( EmbedderTest  ,
ObjectsCanBePostedViaPorts   
)

Definition at line 3111 of file embedder_gl_unittests.cc.

3111 {
3112 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
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:3067
@ kFlutterEngineDartObjectTypeString
Definition: embedder.h:2018
@ kFlutterEngineDartObjectTypeBool
Definition: embedder.h:2014
@ kFlutterEngineDartObjectTypeDouble
Definition: embedder.h:2017
@ kFlutterEngineDartObjectTypeInt32
Definition: embedder.h:2015
@ kFlutterEngineDartObjectTypeBuffer
Definition: embedder.h:2021
@ kFlutterEngineDartObjectTypeInt64
Definition: embedder.h:2016
@ kFlutterEngineDartObjectTypeNull
Definition: embedder.h:2013
int64_t FlutterEngineDartPort
Definition: embedder.h:2010
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
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
FlutterEngineDartObjectType type
Definition: embedder.h:2069

◆ TEST_F() [444/925]

flutter::testing::TEST_F ( EmbedderTest  ,
ObjectsPostedViaPortsServicedOnSecondaryTaskHeap   
)

Definition at line 4354 of file embedder_gl_unittests.cc.

4354 {
4355 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
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() [445/925]

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);
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() [446/925]

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
402 message.struct_size = sizeof(FlutterPlatformMessage);
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() [447/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformThreadIsolatesWithCustomPlatformTaskRunner   
)

Definition at line 3721 of file embedder_unittests.cc.

3721 {
3722 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3723 static fml::AutoResetWaitableEvent latch;
3724
3725 static std::thread::id ffi_call_thread_id;
3726 static void (*ffi_signal_native_test)() = []() -> void {
3727 ffi_call_thread_id = std::this_thread::get_id();
3728 latch.Signal();
3729 };
3730
3731 Dart_FfiNativeResolver ffi_resolver = [](const char* name,
3732 uintptr_t args_n) -> void* {
3733 if (std::string_view(name) == "FFISignalNativeTest") {
3734 return reinterpret_cast<void*>(ffi_signal_native_test);
3735 }
3736 return nullptr;
3737 };
3738
3739 // The test's Dart code will call this native function which overrides the
3740 // FFI resolver. After that, the Dart code will invoke the FFI function
3741 // using runOnPlatformThread.
3742 context.AddNativeCallback(
3743 "SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
3745 }));
3746
3747 auto platform_task_runner = CreateNewThread("test_platform_thread");
3748
3750
3751 EmbedderTestTaskRunner test_task_runner(
3752 platform_task_runner, [&](FlutterTask task) {
3753 if (!engine.is_valid()) {
3754 return;
3755 }
3756 FlutterEngineRunTask(engine.get(), &task);
3757 });
3758
3759 std::thread::id platform_thread_id;
3760 platform_task_runner->PostTask([&]() {
3761 platform_thread_id = std::this_thread::get_id();
3762
3763 EmbedderConfigBuilder builder(context);
3764 const auto task_runner_description =
3765 test_task_runner.GetFlutterTaskRunnerDescription();
3766 builder.SetSoftwareRendererConfig();
3767 builder.SetPlatformTaskRunner(&task_runner_description);
3768 builder.SetDartEntrypoint("invokePlatformThreadIsolate");
3769 builder.AddCommandLineArgument("--enable-platform-isolates");
3770 engine = builder.LaunchEngine();
3771 ASSERT_TRUE(engine.is_valid());
3772 });
3773
3774 latch.Wait();
3775
3776 fml::AutoResetWaitableEvent kill_latch;
3777 platform_task_runner->PostTask(fml::MakeCopyable([&]() mutable {
3778 engine.reset();
3779
3780 platform_task_runner->PostTask([&kill_latch] { kill_latch.Signal(); });
3781 }));
3782 kill_latch.Wait();
3783
3784 // Check that the FFI call was executed on the platform thread.
3785 ASSERT_EQ(platform_thread_id, ffi_call_thread_id);
3786}
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:3262
DART_EXPORT Dart_Handle Dart_RootLibrary(void)

◆ TEST_F() [448/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformViewMutatorsAreValidWithPixelRatio   
)

Definition at line 2627 of file embedder_gl_unittests.cc.

2627 {
2628 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2629
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 {
2678 platform_view.struct_size = sizeof(platform_view);
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:1697
@ kFlutterPlatformViewMutationTypeOpacity
Definition: embedder.h:1691
FlutterTransformation FlutterTransformationMake(const SkMatrix &matrix)
FlutterRoundedRect FlutterRoundedRectMake(const SkRRect &rect)
FlutterTransformation transformation
Definition: embedder.h:1710
FlutterRoundedRect clip_rounded_rect
Definition: embedder.h:1709

◆ TEST_F() [449/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PlatformViewMutatorsAreValidWithPixelRatioAndRootSurfaceTransformation   
)

Definition at line 2738 of file embedder_gl_unittests.cc.

2739 {
2740 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2741
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 {
2795 platform_view.struct_size = sizeof(platform_view);
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() [450/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PopulateExistingDamageReceivesInvalidID   
)

Definition at line 3990 of file embedder_gl_unittests.cc.

3990 {
3991 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3992
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:464
FlutterRect * damage
The actual damage region(s) in question.
Definition: embedder.h:466

◆ TEST_F() [451/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PopulateExistingDamageReceivesValidID   
)

Definition at line 3953 of file embedder_gl_unittests.cc.

3953 {
3954 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3955
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() [452/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoContainsValidFBOId   
)

Definition at line 3655 of file embedder_gl_unittests.cc.

3655 {
3656 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3657
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:501

◆ TEST_F() [453/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesEmptyDamage   
)

Definition at line 3784 of file embedder_gl_unittests.cc.

3784 {
3785 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3786
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:503
FlutterDamage buffer_damage
Damage used to set the buffer's damage region.
Definition: embedder.h:505
double bottom
Definition: embedder.h:441
double top
Definition: embedder.h:439
double left
Definition: embedder.h:438
double right
Definition: embedder.h:440

◆ TEST_F() [454/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesFullDamageWhenExistingDamageIsWholeScreen   
)

Definition at line 3698 of file embedder_gl_unittests.cc.

3699 {
3700 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3701
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() [455/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesFullScreenDamageWhenPopulateExistingDamageIsNotProvided   
)

Definition at line 4591 of file embedder_gl_unittests.cc.

4593 {
4594 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4595
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() [456/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesJoinedDamageWhenExistingDamageContainsMultipleRects   
)

Definition at line 4661 of file embedder_gl_unittests.cc.

4662 {
4663 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4664
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() [457/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PresentInfoReceivesPartialDamage   
)

Definition at line 3868 of file embedder_gl_unittests.cc.

3868 {
3869 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
3870
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() [458/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PushingMutlipleFramesSetsUpNewRecordingCanvasWithCustomCompositor   
)

Definition at line 2433 of file embedder_gl_unittests.cc.

2434 {
2435 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2436
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:2309

◆ TEST_F() [459/925]

flutter::testing::TEST_F ( EmbedderTest  ,
PushingMutlipleFramesSetsUpNewRecordingCanvasWithoutCustomCompositor   
)

Definition at line 2477 of file embedder_gl_unittests.cc.

2478 {
2479 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2480
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() [460/925]

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
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 {
277 platform_view.struct_size = sizeof(platform_view);
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
static void setup(SkCanvas *canvas, SkPaint *paint, const SkBitmap &bm, SkFilterMode fm, SkTileMode tmx, SkTileMode tmy)
Definition: tilemodes.cpp:52

◆ TEST_F() [461/925]

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

flutter::testing::TEST_F ( EmbedderTest  ,
RegisterChannelListener   
)

Definition at line 3690 of file embedder_unittests.cc.

3690 {
3691 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3692
3695 bool listening = false;
3696 context.AddNativeCallback(
3697 "SignalNativeTest",
3699 context.SetChannelUpdateCallback([&](const FlutterChannelUpdate* update) {
3700 EXPECT_STREQ(update->channel, "test/listen");
3701 EXPECT_TRUE(update->listening);
3702 listening = true;
3703 latch2.Signal();
3704 });
3705
3706 EmbedderConfigBuilder builder(context);
3707 builder.SetSoftwareRendererConfig();
3708 builder.SetDartEntrypoint("channel_listener_response");
3709
3710 auto engine = builder.LaunchEngine();
3711 ASSERT_TRUE(engine.is_valid());
3712
3713 latch.Wait();
3714 // Drain tasks posted to platform thread task runner.
3716 latch2.Wait();
3717
3718 ASSERT_TRUE(listening);
3719}
An update to whether a message channel has a listener set or not.
Definition: embedder.h:1535

◆ TEST_F() [463/925]

flutter::testing::TEST_F ( EmbedderTest  ,
SceneWithNoRootContainerIsAcceptable   
)

Definition at line 2882 of file embedder_gl_unittests.cc.

2882 {
2883 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
2884
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() [464/925]

flutter::testing::TEST_F ( EmbedderTest  ,
SetSingleDisplayConfigurationWithDisplayId   
)

Definition at line 4038 of file embedder_gl_unittests.cc.

4038 {
4039 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4040
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() [465/925]

flutter::testing::TEST_F ( EmbedderTest  ,
SetSingleDisplayConfigurationWithoutDisplayId   
)

Definition at line 4080 of file embedder_gl_unittests.cc.

4080 {
4081 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4082
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() [466/925]

flutter::testing::TEST_F ( EmbedderTest  ,
SetValidMultiDisplayConfiguration   
)

Definition at line 4122 of file embedder_gl_unittests.cc.

4122 {
4123 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4124
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() [467/925]

flutter::testing::TEST_F ( EmbedderTest  ,
SnapshotRenderTargetScalesDownToDriverMax   
)

Definition at line 4311 of file embedder_gl_unittests.cc.

4311 {
4312 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
4313
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)
Definition: dart_invoke.cc:20

◆ TEST_F() [468/925]

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));
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
284 texture.struct_size = sizeof(FlutterMetalTexture);
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:602

◆ TEST_F() [469/925]

flutter::testing::TEST_F ( EmbedderTest  ,
VerifyB141980393   
)

Definition at line 1957 of file embedder_gl_unittests.cc.

1957 {
1958 auto& context = GetEmbedderContext(EmbedderTestContextType::kOpenGLContext);
1959
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 {
1997 platform_view.struct_size = sizeof(platform_view);
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() [470/925]

flutter::testing::TEST_F ( EmbedderTest  ,
VerifyB143464703WithSoftwareBackend   
)

Definition at line 2079 of file embedder_unittests.cc.

2079 {
2080 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
2081
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 {
2132 platform_view.struct_size = sizeof(platform_view);
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() [471/925]

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);
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() [472/925]

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

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);
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() [474/925]

flutter::testing::TEST_F ( EmbedderTest  ,
VsyncCallbackPostedIntoFuture   
)

Definition at line 3309 of file embedder_unittests.cc.

3309 {
3311 fml::AutoResetWaitableEvent present_latch;
3312 fml::AutoResetWaitableEvent vsync_latch;
3313
3314 // One of the threads that the callback (FlutterEngineOnVsync) will be posted
3315 // to is the platform thread. So we cannot wait for assertions to complete on
3316 // the platform thread. Create a new thread to manage the engine instance and
3317 // wait for assertions on the test thread.
3318 auto platform_task_runner = CreateNewThread("platform_thread");
3319
3320 platform_task_runner->PostTask([&]() {
3321 auto& context =
3322 GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3323
3324 context.SetVsyncCallback([&](intptr_t baton) {
3325 platform_task_runner->PostTask([baton = baton, &engine, &vsync_latch]() {
3326 FlutterEngineOnVsync(engine.get(), baton, NanosFromEpoch(16),
3327 NanosFromEpoch(32));
3328 vsync_latch.Signal();
3329 });
3330 });
3331 context.AddNativeCallback(
3332 "SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
3333 present_latch.Signal();
3334 }));
3335
3336 EmbedderConfigBuilder builder(context);
3337 builder.SetSoftwareRendererConfig();
3338 builder.SetupVsyncCallback();
3339 builder.SetDartEntrypoint("empty_scene");
3340 engine = builder.LaunchEngine();
3341 ASSERT_TRUE(engine.is_valid());
3342
3343 // Send a window metrics events so frames may be scheduled.
3344 FlutterWindowMetricsEvent event = {};
3345 event.struct_size = sizeof(event);
3346 event.width = 800;
3347 event.height = 600;
3348 event.pixel_ratio = 1.0;
3349
3351 kSuccess);
3352 });
3353
3354 vsync_latch.Wait();
3355 present_latch.Wait();
3356
3357 fml::AutoResetWaitableEvent shutdown_latch;
3358 platform_task_runner->PostTask([&]() {
3359 engine.reset();
3360 shutdown_latch.Signal();
3361 });
3362 shutdown_latch.Wait();
3363}
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:2875

◆ TEST_F() [475/925]

flutter::testing::TEST_F ( EmbedderTest  ,
WindowMetricsEventDefaultsToImplicitView   
)

Definition at line 3593 of file embedder_unittests.cc.

3593 {
3594 auto& context = GetEmbedderContext(EmbedderTestContextType::kSoftwareContext);
3596 builder.SetSoftwareRendererConfig();
3597 builder.SetDartEntrypoint("window_metrics_event_view_id");
3598
3599 fml::AutoResetWaitableEvent ready_latch, message_latch;
3600 context.AddNativeCallback(
3601 "SignalNativeTest",
3603 [&ready_latch](Dart_NativeArguments args) { ready_latch.Signal(); }));
3604 context.AddNativeCallback(
3605 "SignalNativeMessage",
3609 ASSERT_EQ("Changed: [0]", message);
3610 message_latch.Signal();
3611 }));
3612
3613 auto engine = builder.LaunchEngine();
3614 ASSERT_TRUE(engine.is_valid());
3615
3616 ready_latch.Wait();
3617
3618 FlutterWindowMetricsEvent event = {};
3619 // Simulate an event that comes from an old version of embedder.h that doesn't
3620 // have the view_id field.
3621 event.struct_size = offsetof(FlutterWindowMetricsEvent, view_id);
3622 event.width = 200;
3623 event.height = 300;
3624 event.pixel_ratio = 1.5;
3625 // Skip assigning event.view_id here to test the default behavior.
3626
3629 ASSERT_EQ(result, kSuccess);
3630
3631 message_latch.Wait();
3632}

◆ TEST_F() [476/925]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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(), //
29 );
30 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
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() [501/925]

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}
NSMutableArray< id > * messages
void handleEvent:callback:(NSEvent *event, [callback] FlutterAsyncKeyCallback callback)

◆ TEST_F() [502/925]

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

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}
constexpr uint64_t kLogicalKeyQ
Definition: key_codes.g.h:355
NSMutableDictionary< NSNumber *, NSNumber * > * layoutMap

◆ TEST_F() [504/925]

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

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:613
@ kYUVA
Definition: embedder.h:606

◆ TEST_F() [506/925]

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:612

◆ TEST_F() [507/925]

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

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

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

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

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
void Initialize(zx::channel directory_request, std::optional< zx::eventpair > view_ref)
Initializes Dart bindings for the Fuchsia application model.
Definition: fuchsia.cc:103
FlutterEngineInitializeFnPtr Initialize
Definition: embedder.h:3327
FlutterEngineUpdateSemanticsEnabledFnPtr UpdateSemanticsEnabled
Definition: embedder.h:3343

◆ TEST_F() [512/925]

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

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

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
577 .struct_size = sizeof(FlutterPresentViewInfo),
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:1782
FlutterBackingStoreCreateCallback create_backing_store_callback
Definition: embedder.h:1903
FlutterPresentViewCallback present_view_callback
Definition: embedder.h:1932
FlutterBackingStoreCollectCallback collect_backing_store_callback
Definition: embedder.h:1908
A structure to represent the width and height.
Definition: embedder.h:423

◆ TEST_F() [515/925]

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

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

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

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

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

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

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

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}
SIT bool any(const Vec< 1, T > &x)
Definition: SkVx.h:530

◆ TEST_F() [523/925]

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

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

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

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

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

◆ TEST_F() [528/925]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testLookupKeyAssets   
)

Definition at line 319 of file FlutterViewControllerTest.mm.

319 {
320 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssets]);
321}

◆ TEST_F() [564/925]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testLookupKeyAssetsWithPackage   
)

Definition at line 323 of file FlutterViewControllerTest.mm.

323 {
324 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssetsWithPackage]);
325}

◆ TEST_F() [565/925]

flutter::testing::TEST_F ( FlutterViewControllerTest  ,
testViewControllerIsReleased   
)

Definition at line 327 of file FlutterViewControllerTest.mm.

327 {
328 ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testViewControllerIsReleased]);
329}

◆ TEST_F() [566/925]

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

Definition at line 657 of file flutter_windows_engine_unittests.cc.

657 {
658 auto& context = GetContext();
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
SK_API GrDirectContext * GetContext(const SkImage *src)
std::unique_ptr< FlutterDesktopEngine, EngineDeleter > EnginePtr

◆ TEST_F() [567/925]

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

Definition at line 695 of file flutter_windows_engine_unittests.cc.

695 {
696 auto& context = GetContext();
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() [568/925]

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();
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::unique_ptr< FlutterDesktopViewController, ViewControllerDeleter > ViewControllerPtr
std::string str() const
Definition: logging.cc:122
FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(FlutterDesktopViewControllerRef controller)

◆ TEST_F() [569/925]

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

Definition at line 510 of file flutter_windows_engine_unittests.cc.

510 {
512 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
513 EngineModifier modifier(engine.get());
514
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}
void MockEmbedderApiForKeyboard(EngineModifier &modifier, std::shared_ptr< MockKeyResponseController > response_controller)

◆ TEST_F() [570/925]

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

Definition at line 1268 of file flutter_windows_engine_unittests.cc.

1268 {
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() [571/925]

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

Definition at line 992 of file flutter_windows_engine_unittests.cc.

992 {
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() [572/925]

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

Definition at line 1011 of file flutter_windows_engine_unittests.cc.

1011 {
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() [573/925]

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

Definition at line 1217 of file flutter_windows_engine_unittests.cc.

1217 {
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() [574/925]

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

Definition at line 167 of file flutter_windows_engine_unittests.cc.

167 {
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() [575/925]

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

Definition at line 464 of file flutter_windows_engine_unittests.cc.

464 {
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(
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() [576/925]

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

Definition at line 972 of file flutter_windows_engine_unittests.cc.

972 {
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() [577/925]

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

Definition at line 1116 of file flutter_windows_engine_unittests.cc.

1116 {
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() [578/925]

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

Definition at line 1058 of file flutter_windows_engine_unittests.cc.

1058 {
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() [579/925]

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

Definition at line 573 of file flutter_windows_engine_unittests.cc.

573 {
575 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
576 EXPECT_EQ(engine->GetExecutableName(), "flutter_windows_unittests.exe");
577}

◆ TEST_F() [580/925]

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

Definition at line 1082 of file flutter_windows_engine_unittests.cc.

1082 {
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() [581/925]

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

Definition at line 953 of file flutter_windows_engine_unittests.cc.

953 {
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() [582/925]

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

Definition at line 1168 of file flutter_windows_engine_unittests.cc.

1168 {
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() [583/925]

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

Definition at line 1029 of file flutter_windows_engine_unittests.cc.

1029 {
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() [584/925]

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

Definition at line 354 of file flutter_windows_engine_unittests.cc.

354 {
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() [585/925]

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

Definition at line 309 of file flutter_windows_engine_unittests.cc.

309 {
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() [586/925]

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

Definition at line 622 of file flutter_windows_engine_unittests.cc.

622 {
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() [587/925]

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

Definition at line 1243 of file flutter_windows_engine_unittests.cc.

1243 {
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() [588/925]

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

Definition at line 1298 of file flutter_windows_engine_unittests.cc.

1298 {
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() [589/925]

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

Definition at line 51 of file flutter_windows_engine_unittests.cc.

51 {
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
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:266
#define FLUTTER_ENGINE_VERSION
Definition: embedder.h:70
SIN Vec< N, float > floor(const Vec< N, float > &x)
Definition: SkVx.h:703
FlutterRendererType type
Definition: embedder.h:827

◆ TEST_F() [590/925]

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

Definition at line 39 of file flutter_windows_engine_unittests.cc.

39 {
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() [591/925]

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

Definition at line 247 of file flutter_windows_engine_unittests.cc.

247 {
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() [592/925]

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

Definition at line 194 of file flutter_windows_engine_unittests.cc.

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

◆ TEST_F() [593/925]

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

Definition at line 541 of file flutter_windows_engine_unittests.cc.

541 {
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() [594/925]

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

Definition at line 282 of file flutter_windows_engine_unittests.cc.

282 {
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() [595/925]

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

Definition at line 405 of file flutter_windows_engine_unittests.cc.

405 {
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() [596/925]

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

Definition at line 557 of file flutter_windows_engine_unittests.cc.

557 {
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() [597/925]

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

Definition at line 489 of file flutter_windows_engine_unittests.cc.

489 {
491 EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
492 THREAD_PRIORITY_BELOW_NORMAL);
493
495 EXPECT_EQ(GetThreadPriority(GetCurrentThread()),
496 THREAD_PRIORITY_ABOVE_NORMAL);
497
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
507 EXPECT_EQ(GetThreadPriority(GetCurrentThread()), THREAD_PRIORITY_NORMAL);
508}
@ kBackground
Suitable for threads that shouldn't disrupt high priority work.
Definition: embedder.h:260
@ kDisplay
Suitable for threads which generate data for the display.
Definition: embedder.h:264
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)

◆ TEST_F() [598/925]

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

Definition at line 774 of file flutter_windows_engine_unittests.cc.

774 {
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() [599/925]

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

Definition at line 811 of file flutter_windows_engine_unittests.cc.

811 {
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() [600/925]

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

Definition at line 919 of file flutter_windows_engine_unittests.cc.

919 {
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() [601/925]

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

Definition at line 859 of file flutter_windows_engine_unittests.cc.

859 {
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() [602/925]

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

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

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

Definition at line 318 of file flutter_window_unittests.cc.

318 {
319 std::unique_ptr<FlutterWindowsEngine> engine =
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() [605/925]

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

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

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

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

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}
TPoint< Scalar > Point
Definition: point.h:322
TSize< Scalar > Size
Definition: size.h:137

◆ TEST_F() [610/925]

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

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:1017
@ kFlutterPointerDeviceKindTouch
Definition: embedder.h:1009
@ kFlutterPointerDeviceKindStylus
Definition: embedder.h:1010

◆ TEST_F() [612/925]

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

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

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

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

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}
static bool ValidateShell(Shell *shell)

◆ TEST_F() [617/925]

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

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
CanCreateImageDecoder   
)

Definition at line 177 of file image_decoder_unittests.cc.

177 {
179 auto thread_task_runner = CreateNewThread();
180 TaskRunners runners(GetCurrentTestName(), // label
181 thread_task_runner, // platform
182 thread_task_runner, // raster
183 thread_task_runner, // ui
184 thread_task_runner // io
185
186 );
187
188 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
189 TestIOManager manager(runners.GetIOTaskRunner());
190 Settings settings;
191 auto decoder = ImageDecoder::Make(settings, runners, loop->GetTaskRunner(),
192 manager.GetWeakIOManager(),
193 std::make_shared<fml::SyncSwitch>());
194 ASSERT_NE(decoder, nullptr);
195 });
196}
static std::shared_ptr< ConcurrentMessageLoop > Create(size_t worker_count=std::thread::hardware_concurrency())
void PostTaskSync(const fml::RefPtr< fml::TaskRunner > &task_runner, const std::function< void()> &function)

◆ TEST_F() [619/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
CanDecodeWithoutAGPUContext   
)

Definition at line 547 of file image_decoder_unittests.cc.

547 {
549 TaskRunners runners(GetCurrentTestName(), // label
550 CreateNewThread("platform"), // platform
551 CreateNewThread("raster"), // raster
552 CreateNewThread("ui"), // ui
553 CreateNewThread("io") // io
554 );
555
557
558 std::unique_ptr<IOManager> io_manager;
559
560 auto release_io_manager = [&]() {
561 io_manager.reset();
562 latch.Signal();
563 };
564
565 auto decode_image = [&]() {
567 std::unique_ptr<ImageDecoder> image_decoder = ImageDecoder::Make(
568 settings, runners, loop->GetTaskRunner(),
569 io_manager->GetWeakIOManager(), std::make_shared<fml::SyncSwitch>());
570
571 auto data = flutter::testing::OpenFixtureAsSkData("DashInNooglerHat.jpg");
572
573 ASSERT_TRUE(data);
574 ASSERT_GE(data->size(), 0u);
575
576 ImageGeneratorRegistry registry;
577 std::shared_ptr<ImageGenerator> generator =
579 ASSERT_TRUE(generator);
580
581 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
582 std::move(data), std::move(generator));
583
585 const std::string& decode_error) {
586 ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
587 ASSERT_TRUE(image && image->skia_image());
588 runners.GetIOTaskRunner()->PostTask(release_io_manager);
589 };
590 image_decoder->Decode(descriptor, descriptor->width(), descriptor->height(),
591 callback);
592 };
593
594 auto set_up_io_manager_and_decode = [&]() {
595 io_manager =
596 std::make_unique<TestIOManager>(runners.GetIOTaskRunner(), false);
597 runners.GetUITaskRunner()->PostTask(decode_image);
598 };
599
600 runners.GetIOTaskRunner()->PostTask(set_up_io_manager_and_decode);
601
602 latch.Wait();
603}
std::function< void(sk_sp< DlImage >, std::string)> ImageResult
Definition: image_decoder.h:35

◆ TEST_F() [620/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
CanDecodeWithResizes   
)

Definition at line 605 of file image_decoder_unittests.cc.

605 {
606 const auto image_dimensions =
608 flutter::testing::OpenFixtureAsSkData("DashInNooglerHat.jpg"))
609 ->dimensions();
610
611 ASSERT_FALSE(image_dimensions.isEmpty());
612
613 ASSERT_NE(image_dimensions.width(), image_dimensions.height());
614
616 TaskRunners runners(GetCurrentTestName(), // label
617 CreateNewThread("platform"), // platform
618 CreateNewThread("raster"), // raster
619 CreateNewThread("ui"), // ui
620 CreateNewThread("io") // io
621 );
622
624 std::unique_ptr<IOManager> io_manager;
625 std::unique_ptr<ImageDecoder> image_decoder;
626
627 // Setup the IO manager.
628 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
629 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
630 });
631
632 // Setup the image decoder.
633 PostTaskSync(runners.GetUITaskRunner(), [&]() {
634 Settings settings;
635 image_decoder = ImageDecoder::Make(settings, runners, loop->GetTaskRunner(),
636 io_manager->GetWeakIOManager(),
637 std::make_shared<fml::SyncSwitch>());
638 });
639
640 // Setup a generic decoding utility that gives us the final decoded size.
641 auto decoded_size = [&](uint32_t target_width,
642 uint32_t target_height) -> SkISize {
643 SkISize final_size = SkISize::MakeEmpty();
644 runners.GetUITaskRunner()->PostTask([&]() {
645 auto data = flutter::testing::OpenFixtureAsSkData("DashInNooglerHat.jpg");
646
647 ASSERT_TRUE(data);
648 ASSERT_GE(data->size(), 0u);
649
650 ImageGeneratorRegistry registry;
651 std::shared_ptr<ImageGenerator> generator =
653 ASSERT_TRUE(generator);
654
655 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
656 std::move(data), std::move(generator));
657
659 [&](const sk_sp<DlImage>& image, const std::string& decode_error) {
660 ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
661 ASSERT_TRUE(image && image->skia_image());
662 final_size = image->skia_image()->dimensions();
663 latch.Signal();
664 };
665 image_decoder->Decode(descriptor, target_width, target_height, callback);
666 });
667 latch.Wait();
668 return final_size;
669 };
670
671 ASSERT_EQ(SkISize::Make(3024, 4032), image_dimensions);
672 ASSERT_EQ(decoded_size(3024, 4032), image_dimensions);
673 ASSERT_EQ(decoded_size(100, 100), SkISize::Make(100, 100));
674
675 // Destroy the IO manager
676 PostTaskSync(runners.GetIOTaskRunner(), [&]() { io_manager.reset(); });
677
678 // Destroy the image decoder
679 PostTaskSync(runners.GetUITaskRunner(), [&]() { image_decoder.reset(); });
680}

◆ TEST_F() [621/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
ExifDataIsRespectedOnDecode   
)

Definition at line 485 of file image_decoder_unittests.cc.

485 {
487 TaskRunners runners(GetCurrentTestName(), // label
488 CreateNewThread("platform"), // platform
489 CreateNewThread("raster"), // raster
490 CreateNewThread("ui"), // ui
491 CreateNewThread("io") // io
492 );
493
495
496 std::unique_ptr<IOManager> io_manager;
497
498 auto release_io_manager = [&]() {
499 io_manager.reset();
500 latch.Signal();
501 };
502
503 SkISize decoded_size = SkISize::MakeEmpty();
504 auto decode_image = [&]() {
506 std::unique_ptr<ImageDecoder> image_decoder = ImageDecoder::Make(
507 settings, runners, loop->GetTaskRunner(),
508 io_manager->GetWeakIOManager(), std::make_shared<fml::SyncSwitch>());
509
510 auto data = flutter::testing::OpenFixtureAsSkData("Horizontal.jpg");
511
512 ASSERT_TRUE(data);
513 ASSERT_GE(data->size(), 0u);
514
515 ImageGeneratorRegistry registry;
516 std::shared_ptr<ImageGenerator> generator =
518 ASSERT_TRUE(generator);
519
520 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
521 std::move(data), std::move(generator));
522
524 const std::string& decode_error) {
525 ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
526 ASSERT_TRUE(image && image->skia_image());
527 decoded_size = image->skia_image()->dimensions();
528 runners.GetIOTaskRunner()->PostTask(release_io_manager);
529 };
530 image_decoder->Decode(descriptor, descriptor->width(), descriptor->height(),
531 callback);
532 };
533
534 auto set_up_io_manager_and_decode = [&]() {
535 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
536 runners.GetUITaskRunner()->PostTask(decode_image);
537 };
538
539 runners.GetIOTaskRunner()->PostTask(set_up_io_manager_and_decode);
540
541 latch.Wait();
542
543 ASSERT_EQ(decoded_size.width(), 600);
544 ASSERT_EQ(decoded_size.height(), 200);
545}

◆ TEST_F() [622/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
ImpellerNonWideGamut   
)

Definition at line 458 of file image_decoder_unittests.cc.

458 {
459 auto data = flutter::testing::OpenFixtureAsSkData("Horizontal.jpg");
461 ASSERT_TRUE(image != nullptr);
462 ASSERT_EQ(SkISize::Make(600, 200), image->dimensions());
463
464 ImageGeneratorRegistry registry;
465 std::shared_ptr<ImageGenerator> generator =
467 ASSERT_TRUE(generator);
468
469 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(data),
470 std::move(generator));
471
472#if IMPELLER_SUPPORTS_RENDERING
473 std::shared_ptr<impeller::Allocator> allocator =
474 std::make_shared<impeller::TestImpellerAllocator>();
475 std::optional<DecompressResult> result =
476 ImageDecoderImpeller::DecompressTexture(
477 descriptor.get(), SkISize::Make(600, 200), {600, 200},
478 /*supports_wide_gamut=*/true, allocator);
479
480 ASSERT_TRUE(result.has_value());
481 ASSERT_EQ(result->image_info.colorType(), kRGBA_8888_SkColorType);
482#endif // IMPELLER_SUPPORTS_RENDERING
483}

◆ TEST_F() [623/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
ImpellerNullColorspace   
)

Definition at line 351 of file image_decoder_unittests.cc.

351 {
355 bitmap.allocPixels(info, 10 * 4);
356 auto data = SkData::MakeWithoutCopy(bitmap.getPixels(), 10 * 10 * 4);
358 ASSERT_TRUE(image != nullptr);
359 ASSERT_EQ(SkISize::Make(10, 10), image->dimensions());
360 ASSERT_EQ(nullptr, image->colorSpace());
361
362 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
363 std::move(data), image->imageInfo(), 10 * 4);
364
365#if IMPELLER_SUPPORTS_RENDERING
366 std::shared_ptr<impeller::Allocator> allocator =
367 std::make_shared<impeller::TestImpellerAllocator>();
368 std::optional<DecompressResult> decompressed =
369 ImageDecoderImpeller::DecompressTexture(
370 descriptor.get(), SkISize::Make(100, 100), {100, 100},
371 /*supports_wide_gamut=*/true, allocator);
372 ASSERT_TRUE(decompressed.has_value());
373 ASSERT_EQ(decompressed->image_info.colorType(), kRGBA_8888_SkColorType);
374 ASSERT_EQ(decompressed->image_info.colorSpace(), nullptr);
375#endif // IMPELLER_SUPPORTS_RENDERING
376}
const SkImageInfo & imageInfo() const
Definition: SkImage.h:279
SkColorSpace * colorSpace() const
Definition: SkImage.cpp:156

◆ TEST_F() [624/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
ImpellerPixelConversion32F   
)

Definition at line 378 of file image_decoder_unittests.cc.

378 {
382 bitmap.allocPixels(info, 10 * 16);
383 auto data = SkData::MakeWithoutCopy(bitmap.getPixels(), 10 * 10 * 16);
385 ASSERT_TRUE(image != nullptr);
386 ASSERT_EQ(SkISize::Make(10, 10), image->dimensions());
387 ASSERT_EQ(nullptr, image->colorSpace());
388
389 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
390 std::move(data), image->imageInfo(), 10 * 16);
391
392#if IMPELLER_SUPPORTS_RENDERING
393 std::shared_ptr<impeller::Allocator> allocator =
394 std::make_shared<impeller::TestImpellerAllocator>();
395 std::optional<DecompressResult> decompressed =
396 ImageDecoderImpeller::DecompressTexture(
397 descriptor.get(), SkISize::Make(100, 100), {100, 100},
398 /*supports_wide_gamut=*/true, allocator);
399
400 ASSERT_TRUE(decompressed.has_value());
401 ASSERT_EQ(decompressed->image_info.colorType(), kRGBA_F16_SkColorType);
402 ASSERT_EQ(decompressed->image_info.colorSpace(), nullptr);
403#endif // IMPELLER_SUPPORTS_RENDERING
404}
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition: SkColorType.h:40

◆ TEST_F() [625/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
ImpellerUploadToSharedNoGpu   
)

Definition at line 322 of file image_decoder_unittests.cc.

322 {
323#if !IMPELLER_SUPPORTS_RENDERING
324 GTEST_SKIP() << "Impeller only test.";
325#endif // IMPELLER_SUPPORTS_RENDERING
326
327 auto no_gpu_access_context =
328 std::make_shared<impeller::TestImpellerContext>();
329 auto gpu_disabled_switch = std::make_shared<fml::SyncSwitch>(true);
330
333 auto bitmap = std::make_shared<SkBitmap>();
334 bitmap->allocPixels(info, 10 * 4);
336 desc.size = bitmap->computeByteSize();
337 auto buffer = std::make_shared<impeller::TestImpellerDeviceBuffer>(desc);
338
339 auto result = ImageDecoderImpeller::UploadTextureToPrivate(
340 no_gpu_access_context, buffer, info, bitmap, gpu_disabled_switch);
341 ASSERT_EQ(no_gpu_access_context->command_buffer_count_, 0ul);
342 ASSERT_EQ(result.second, "");
343
344 result = ImageDecoderImpeller::UploadTextureToStorage(
345 no_gpu_access_context, bitmap, gpu_disabled_switch,
347 ASSERT_EQ(no_gpu_access_context->command_buffer_count_, 0ul);
348 ASSERT_EQ(result.second, "");
349}

◆ TEST_F() [626/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
ImpellerWideGamutDisplayP3Opaque   
)

Definition at line 406 of file image_decoder_unittests.cc.

406 {
407 auto data = flutter::testing::OpenFixtureAsSkData("DisplayP3Logo.jpg");
409 ASSERT_TRUE(image != nullptr);
410 ASSERT_EQ(SkISize::Make(100, 100), image->dimensions());
411
412 ImageGeneratorRegistry registry;
413 std::shared_ptr<ImageGenerator> generator =
415 ASSERT_TRUE(generator);
416
417 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(std::move(data),
418 std::move(generator));
419
420#if IMPELLER_SUPPORTS_RENDERING
421 std::shared_ptr<impeller::Allocator> allocator =
422 std::make_shared<impeller::TestImpellerAllocator>();
423 std::optional<DecompressResult> wide_result =
424 ImageDecoderImpeller::DecompressTexture(
425 descriptor.get(), SkISize::Make(100, 100), {100, 100},
426 /*supports_wide_gamut=*/true, allocator);
427
428 ASSERT_TRUE(wide_result.has_value());
429 ASSERT_EQ(wide_result->image_info.colorType(), kBGR_101010x_XR_SkColorType);
430 ASSERT_TRUE(wide_result->image_info.colorSpace()->isSRGB());
431
432 const SkPixmap& wide_pixmap = wide_result->sk_bitmap->pixmap();
433 const uint32_t* pixel_ptr = static_cast<const uint32_t*>(wide_pixmap.addr());
434 bool found_deep_red = false;
435 for (int i = 0; i < wide_pixmap.width() * wide_pixmap.height(); ++i) {
436 uint32_t pixel = *pixel_ptr++;
437 float blue = DecodeBGR10((pixel >> 0) & 0x3ff);
438 float green = DecodeBGR10((pixel >> 10) & 0x3ff);
439 float red = DecodeBGR10((pixel >> 20) & 0x3ff);
440 if (fabsf(red - 1.0931f) < 0.01f && fabsf(green - -0.2268f) < 0.01f &&
441 fabsf(blue - -0.1501f) < 0.01f) {
442 found_deep_red = true;
443 break;
444 }
445 }
446 ASSERT_TRUE(found_deep_red);
447
448 std::optional<DecompressResult> narrow_result =
449 ImageDecoderImpeller::DecompressTexture(
450 descriptor.get(), SkISize::Make(100, 100), {100, 100},
451 /*supports_wide_gamut=*/false, allocator);
452
453 ASSERT_TRUE(narrow_result.has_value());
454 ASSERT_EQ(narrow_result->image_info.colorType(), kRGBA_8888_SkColorType);
455#endif // IMPELLER_SUPPORTS_RENDERING
456}

◆ TEST_F() [627/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
InvalidImageResultsError   
)

Definition at line 229 of file image_decoder_unittests.cc.

229 {
231 auto thread_task_runner = CreateNewThread();
232 TaskRunners runners(GetCurrentTestName(), // label
233 thread_task_runner, // platform
234 thread_task_runner, // raster
235 thread_task_runner, // ui
236 thread_task_runner // io
237 );
238
240 thread_task_runner->PostTask([&]() {
241 TestIOManager manager(runners.GetIOTaskRunner());
243 auto decoder = ImageDecoder::Make(settings, runners, loop->GetTaskRunner(),
244 manager.GetWeakIOManager(),
245 std::make_shared<fml::SyncSwitch>());
246
247 auto data = flutter::testing::OpenFixtureAsSkData("ThisDoesNotExist.jpg");
248 ASSERT_FALSE(data);
249
250 fml::RefPtr<ImageDescriptor> image_descriptor =
251 fml::MakeRefCounted<ImageDescriptor>(
252 std::move(data), std::make_unique<UnknownImageGenerator>());
253
255 const std::string& decode_error) {
256 ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
257 ASSERT_FALSE(image);
258 latch.Signal();
259 };
260 decoder->Decode(image_descriptor, 0, 0, callback);
261 });
262 latch.Wait();
263}

◆ TEST_F() [628/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
MultiFrameCodecCanBeCollectedBeforeIOTasksFinish   
)

Definition at line 801 of file image_decoder_unittests.cc.

802 {
803 // This test verifies that the MultiFrameCodec safely shares state between
804 // tasks on the IO and UI runners, and does not allow unsafe memory access if
805 // the UI object is collected while the IO thread still has pending decode
806 // work. This could happen in a real application if the engine is collected
807 // while a multi-frame image is decoding. To exercise this, the test:
808 // - Starts a Dart VM
809 // - Latches the IO task runner
810 // - Create a MultiFrameCodec for an animated gif pointed to a callback
811 // in the Dart fixture
812 // - Calls getNextFrame on the UI task runner
813 // - Collects the MultiFrameCodec object before unlatching the IO task
814 // runner.
815 // - Unlatches the IO task runner
816 auto settings = CreateSettingsForFixture();
817 auto vm_ref = DartVMRef::Create(settings);
818 auto vm_data = vm_ref.GetVMData();
819
820 auto gif_mapping = flutter::testing::OpenFixtureAsSkData("hello_loop_2.gif");
821
822 ASSERT_TRUE(gif_mapping);
823
824 ImageGeneratorRegistry registry;
825 std::shared_ptr<ImageGenerator> gif_generator =
826 registry.CreateCompatibleGenerator(gif_mapping);
827 ASSERT_TRUE(gif_generator);
828
829 TaskRunners runners(GetCurrentTestName(), // label
830 CreateNewThread("platform"), // platform
831 CreateNewThread("raster"), // raster
832 CreateNewThread("ui"), // ui
833 CreateNewThread("io") // io
834 );
835
837 std::unique_ptr<TestIOManager> io_manager;
838
839 // Setup the IO manager.
840 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
841 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
842 });
843
844 auto isolate = RunDartCodeInIsolate(vm_ref, settings, runners, "main", {},
846 io_manager->GetWeakIOManager());
847
848 // Latch the IO task runner.
849 runners.GetIOTaskRunner()->PostTask([&]() { io_latch.Wait(); });
850
851 PostTaskSync(runners.GetUITaskRunner(), [&]() {
852 fml::AutoResetWaitableEvent isolate_latch;
853 fml::RefPtr<MultiFrameCodec> codec;
854 EXPECT_TRUE(isolate->RunInIsolateScope([&]() -> bool {
855 Dart_Handle library = Dart_RootLibrary();
856 if (Dart_IsError(library)) {
857 isolate_latch.Signal();
858 return false;
859 }
860 Dart_Handle closure =
861 Dart_GetField(library, Dart_NewStringFromCString("frameCallback"));
862 if (Dart_IsError(closure) || !Dart_IsClosure(closure)) {
863 isolate_latch.Signal();
864 return false;
865 }
866
867 codec = fml::MakeRefCounted<MultiFrameCodec>(std::move(gif_generator));
868 codec->getNextFrame(closure);
869 codec = nullptr;
870 isolate_latch.Signal();
871 return true;
872 }));
873 isolate_latch.Wait();
874
875 EXPECT_FALSE(codec);
876
877 io_latch.Signal();
878 });
879
880 // Destroy the IO manager
881 PostTaskSync(runners.GetIOTaskRunner(), [&]() { io_manager.reset(); });
882}

◆ TEST_F() [629/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
MultiFrameCodecDidAccessGpuDisabledSyncSwitch   
)

Definition at line 884 of file image_decoder_unittests.cc.

884 {
885 auto settings = CreateSettingsForFixture();
886 auto vm_ref = DartVMRef::Create(settings);
887 auto vm_data = vm_ref.GetVMData();
888
889 auto gif_mapping = flutter::testing::OpenFixtureAsSkData("hello_loop_2.gif");
890
891 ASSERT_TRUE(gif_mapping);
892
893 ImageGeneratorRegistry registry;
894 std::shared_ptr<ImageGenerator> gif_generator =
895 registry.CreateCompatibleGenerator(gif_mapping);
896 ASSERT_TRUE(gif_generator);
897
898 TaskRunners runners(GetCurrentTestName(), // label
899 CreateNewThread("platform"), // platform
900 CreateNewThread("raster"), // raster
901 CreateNewThread("ui"), // ui
902 CreateNewThread("io") // io
903 );
904
905 std::unique_ptr<TestIOManager> io_manager;
908
909 auto validate_frame_callback = [&latch](Dart_NativeArguments args) {
910 EXPECT_FALSE(Dart_IsNull(Dart_GetNativeArgument(args, 0)));
911 latch.Signal();
912 };
913
914 AddNativeCallback("ValidateFrameCallback",
915 CREATE_NATIVE_ENTRY(validate_frame_callback));
916 // Setup the IO manager.
917 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
918 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
919 });
920
921 auto isolate = RunDartCodeInIsolate(vm_ref, settings, runners, "main", {},
923 io_manager->GetWeakIOManager());
924
925 PostTaskSync(runners.GetUITaskRunner(), [&]() {
926 fml::AutoResetWaitableEvent isolate_latch;
927
928 EXPECT_TRUE(isolate->RunInIsolateScope([&]() -> bool {
929 Dart_Handle library = Dart_RootLibrary();
930 if (Dart_IsError(library)) {
931 isolate_latch.Signal();
932 return false;
933 }
934 Dart_Handle closure =
935 Dart_GetField(library, Dart_NewStringFromCString("frameCallback"));
936 if (Dart_IsError(closure) || !Dart_IsClosure(closure)) {
937 isolate_latch.Signal();
938 return false;
939 }
940
941 EXPECT_FALSE(io_manager->did_access_is_gpu_disabled_sync_switch_);
942 codec = fml::MakeRefCounted<MultiFrameCodec>(std::move(gif_generator));
943 codec->getNextFrame(closure);
944 isolate_latch.Signal();
945 return true;
946 }));
947 isolate_latch.Wait();
948 });
949
950 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
951 EXPECT_TRUE(io_manager->did_access_is_gpu_disabled_sync_switch_);
952 });
953
954 latch.Wait();
955
956 // Destroy the Isolate
957 isolate = nullptr;
958
959 // Destroy the MultiFrameCodec
960 PostTaskSync(runners.GetUITaskRunner(), [&]() { codec = nullptr; });
961
962 // Destroy the IO manager
963 PostTaskSync(runners.GetIOTaskRunner(), [&]() { io_manager.reset(); });
964}

◆ TEST_F() [630/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
MultiFrameCodecProducesATextureEvenIfGPUIsDisabledOnImpeller   
)

Definition at line 966 of file image_decoder_unittests.cc.

967 {
968 auto settings = CreateSettingsForFixture();
969 settings.enable_impeller = true;
970 auto vm_ref = DartVMRef::Create(settings);
971 auto vm_data = vm_ref.GetVMData();
972
973 auto gif_mapping = flutter::testing::OpenFixtureAsSkData("hello_loop_2.gif");
974
975 ASSERT_TRUE(gif_mapping);
976
977 ImageGeneratorRegistry registry;
978 std::shared_ptr<ImageGenerator> gif_generator =
979 registry.CreateCompatibleGenerator(gif_mapping);
980 ASSERT_TRUE(gif_generator);
981
982 TaskRunners runners(GetCurrentTestName(), // label
983 CreateNewThread("platform"), // platform
984 CreateNewThread("raster"), // raster
985 CreateNewThread("ui"), // ui
986 CreateNewThread("io") // io
987 );
988
989 std::unique_ptr<TestIOManager> io_manager;
992
993 auto validate_frame_callback = [&latch](Dart_NativeArguments args) {
994 EXPECT_FALSE(Dart_IsNull(Dart_GetNativeArgument(args, 0)));
995 latch.Signal();
996 };
997
998 AddNativeCallback("ValidateFrameCallback",
999 CREATE_NATIVE_ENTRY(validate_frame_callback));
1000
1001 // Setup the IO manager.
1002 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
1003 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
1004 // Mark GPU disabled.
1005 io_manager->SetGpuDisabled(true);
1006 });
1007
1008 auto isolate = RunDartCodeInIsolate(vm_ref, settings, runners, "main", {},
1010 io_manager->GetWeakIOManager());
1011
1012 PostTaskSync(runners.GetUITaskRunner(), [&]() {
1013 fml::AutoResetWaitableEvent isolate_latch;
1014
1015 EXPECT_TRUE(isolate->RunInIsolateScope([&]() -> bool {
1016 Dart_Handle library = Dart_RootLibrary();
1017 if (Dart_IsError(library)) {
1018 isolate_latch.Signal();
1019 return false;
1020 }
1021 Dart_Handle closure =
1022 Dart_GetField(library, Dart_NewStringFromCString("frameCallback"));
1023 if (Dart_IsError(closure) || !Dart_IsClosure(closure)) {
1024 isolate_latch.Signal();
1025 return false;
1026 }
1027
1028 EXPECT_FALSE(io_manager->did_access_is_gpu_disabled_sync_switch_);
1029 codec = fml::MakeRefCounted<MultiFrameCodec>(std::move(gif_generator));
1030 codec->getNextFrame(closure);
1031 isolate_latch.Signal();
1032 return true;
1033 }));
1034 isolate_latch.Wait();
1035 });
1036
1037 PostTaskSync(runners.GetIOTaskRunner(), [&]() {
1038 EXPECT_TRUE(io_manager->did_access_is_gpu_disabled_sync_switch_);
1039 });
1040
1041 latch.Wait();
1042
1043 // Destroy the Isolate
1044 isolate = nullptr;
1045
1046 // Destroy the MultiFrameCodec
1047 PostTaskSync(runners.GetUITaskRunner(), [&]() { codec = nullptr; });
1048
1049 // Destroy the IO manager
1050 PostTaskSync(runners.GetIOTaskRunner(), [&]() { io_manager.reset(); });
1051}

◆ TEST_F() [631/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
NullCheckBuffer   
)

Definition at line 1053 of file image_decoder_unittests.cc.

1053 {
1054 auto context = std::make_shared<impeller::TestImpellerContext>();
1055 auto allocator = ImpellerAllocator(context->GetResourceAllocator());
1056
1057 EXPECT_FALSE(allocator.allocPixelRef(nullptr));
1058}

◆ TEST_F() [632/925]

flutter::testing::TEST_F ( ImageDecoderFixtureTest  ,
ValidImageResultsInSuccess   
)

Definition at line 265 of file image_decoder_unittests.cc.

265 {
267 TaskRunners runners(GetCurrentTestName(), // label
268 CreateNewThread("platform"), // platform
269 CreateNewThread("raster"), // raster
270 CreateNewThread("ui"), // ui
271 CreateNewThread("io") // io
272 );
273
275
276 std::unique_ptr<TestIOManager> io_manager;
277
278 auto release_io_manager = [&]() {
279 io_manager.reset();
280 latch.Signal();
281 };
282 auto decode_image = [&]() {
284 std::unique_ptr<ImageDecoder> image_decoder = ImageDecoder::Make(
285 settings, runners, loop->GetTaskRunner(),
286 io_manager->GetWeakIOManager(), std::make_shared<fml::SyncSwitch>());
287
288 auto data = flutter::testing::OpenFixtureAsSkData("DashInNooglerHat.jpg");
289
290 ASSERT_TRUE(data);
291 ASSERT_GE(data->size(), 0u);
292
293 ImageGeneratorRegistry registry;
294 std::shared_ptr<ImageGenerator> generator =
296 ASSERT_TRUE(generator);
297
298 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
299 std::move(data), std::move(generator));
300
302 const std::string& decode_error) {
303 ASSERT_TRUE(runners.GetUITaskRunner()->RunsTasksOnCurrentThread());
304 ASSERT_TRUE(image && image->skia_image());
305 EXPECT_TRUE(io_manager->did_access_is_gpu_disabled_sync_switch_);
306 runners.GetIOTaskRunner()->PostTask(release_io_manager);
307 };
308 EXPECT_FALSE(io_manager->did_access_is_gpu_disabled_sync_switch_);
309 image_decoder->Decode(descriptor, descriptor->width(), descriptor->height(),
310 callback);
311 };
312
313 auto set_up_io_manager_and_decode = [&]() {
314 io_manager = std::make_unique<TestIOManager>(runners.GetIOTaskRunner());
315 runners.GetUITaskRunner()->PostTask(decode_image);
316 };
317
318 runners.GetIOTaskRunner()->PostTask(set_up_io_manager_and_decode);
319 latch.Wait();
320}

◆ TEST_F() [633/925]

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)
static void SetViewportMetrics(JNIEnv *env, jobject jcaller, jlong shell_holder, jfloat devicePixelRatio, jint physicalWidth, jint physicalHeight, jint physicalPaddingTop, jint physicalPaddingRight, jint physicalPaddingBottom, jint physicalPaddingLeft, jint physicalViewInsetTop, jint physicalViewInsetRight, jint physicalViewInsetBottom, jint physicalViewInsetLeft, jint systemGestureInsetTop, jint systemGestureInsetRight, jint systemGestureInsetBottom, jint systemGestureInsetLeft, jint physicalTouchSlop, jintArray javaDisplayFeaturesBounds, jintArray javaDisplayFeaturesType, jintArray javaDisplayFeaturesState)

◆ TEST_F() [634/925]

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

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

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

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

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

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

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

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(
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);
1258 kNotSynthesized);
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(
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(
1301
1302 EXPECT_EQ(tester.key_calls.size(), 2);
1305 kNotSynthesized);
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)
constexpr uint64_t kPhysicalKeyQ
Definition: key_codes.g.h:93
constexpr LRESULT kWmResultZero
Definition: wm_builders.h:14
struct flutter::testing::WmKeyDownInfo WmKeyDownInfo
struct flutter::testing::WmSysKeyUpInfo WmSysKeyUpInfo
struct flutter::testing::WmKeyUpInfo WmKeyUpInfo
constexpr LRESULT kWmResultDefault
Definition: wm_builders.h:15
struct flutter::testing::WmCharInfo WmCharInfo
Definition: tester.py:1

◆ TEST_F() [642/925]

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(
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);
1346 kNotSynthesized);
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(
1364 EXPECT_EQ(tester.key_calls.size(), 2);
1367 kNotSynthesized);
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(
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);
1388 kNotSynthesized);
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(
1406 EXPECT_EQ(tester.key_calls.size(), 2);
1409 kNotSynthesized);
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() [643/925]

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}
struct flutter::testing::WmSysKeyDownInfo WmSysKeyDownInfo

◆ TEST_F() [644/925]

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);
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);
899 kNotSynthesized);
900 tester.clear_key_calls();
901 // Don't redispatch sys messages.
902 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
903}

◆ TEST_F() [645/925]

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);
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);
657 kNotSynthesized);
658 tester.clear_key_calls();
659 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 0);
660}
constexpr uint64_t kPhysicalArrowLeft
Definition: key_codes.g.h:152
constexpr uint64_t kLogicalArrowLeft
Definition: key_codes.g.h:388

◆ TEST_F() [646/925]

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);
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);
688 kNotSynthesized);
689 tester.clear_key_calls();
690 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
691}

◆ TEST_F() [647/925]

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);
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);
1200 kNotSynthesized);
1201 tester.clear_key_calls();
1202 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1203}
constexpr uint64_t kLogicalDigit1
Definition: key_codes.g.h:317
constexpr uint64_t kPhysicalDigit1
Definition: key_codes.g.h:103

◆ TEST_F() [648/925]

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);
1107 kNotSynthesized);
1108 tester.clear_key_calls();
1109 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1110
1111 // Press A
1112 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
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);
1144 kNotSynthesized);
1145 tester.clear_key_calls();
1146 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1147}

◆ TEST_F() [649/925]

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);
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);
799 kNotSynthesized);
800 tester.clear_key_calls();
801 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
802}

◆ TEST_F() [650/925]

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);
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);
832 kNotSynthesized);
833 tester.clear_key_calls();
834 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
835}

◆ TEST_F() [651/925]

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(
1440 WmDeadCharInfo{'^', kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1441 kWmResultZero)});
1442
1443 EXPECT_EQ(tester.key_calls.size(), 1);
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);
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(
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}
constexpr uint64_t kLogicalKeyE
Definition: key_codes.g.h:343
constexpr uint64_t kLogicalBracketRight
Definition: key_codes.g.h:335
constexpr uint64_t kPhysicalKeyE
Definition: key_codes.g.h:81
constexpr uint64_t kPhysicalBracketLeft
Definition: key_codes.g.h:120
struct flutter::testing::WmDeadCharInfo WmDeadCharInfo

◆ TEST_F() [652/925]

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(
1584 WmDeadCharInfo{'^', kScanCodeBracketLeft, kNotExtended, kWasUp}.Build(
1585 kWmResultZero)});
1586
1587 EXPECT_EQ(tester.key_calls.size(), 1);
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);
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(
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() [653/925]

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(
1653 WmDeadCharInfo{'`', kScanCodeBackquote, kNotExtended, kWasUp}.Build(
1654 kWmResultZero)});
1655
1656 EXPECT_EQ(tester.key_calls.size(), 1);
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);
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(
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);
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);
1721 kNotSynthesized);
1722 tester.clear_key_calls();
1723 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1724}
constexpr uint64_t kPhysicalBackquote
Definition: key_codes.g.h:125
constexpr uint64_t kLogicalBackquote
Definition: key_codes.g.h:338

◆ TEST_F() [654/925]

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},
1501 kWmResultZero)});
1502
1503 EXPECT_EQ(tester.key_calls.size(), 1);
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(
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);
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(
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 uint64_t kLogicalDigit6
Definition: key_codes.g.h:322
constexpr uint64_t kPhysicalDigit6
Definition: key_codes.g.h:108

◆ TEST_F() [655/925]

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

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

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

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>{
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() [659/925]

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>{
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() [660/925]

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);
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);
932 kNotSynthesized);
933 tester.clear_key_calls();
934 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
935}
constexpr uint64_t kLogicalMetaLeft
Definition: key_codes.g.h:687
constexpr uint64_t kPhysicalMetaLeft
Definition: key_codes.g.h:227

◆ TEST_F() [661/925]

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);
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);
965 kNotSynthesized);
966 tester.clear_key_calls();
967 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
968}
constexpr uint64_t kLogicalMetaRight
Definition: key_codes.g.h:688
constexpr uint64_t kPhysicalMetaRight
Definition: key_codes.g.h:231

◆ TEST_F() [662/925]

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(
1738 WmCharInfo{0xd800, kScanCodeKeyW, kNotExtended, kWasUp}.Build(
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() [663/925]

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>{
980 kWmResultZero)});
981
982 // Hold A
983 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
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() [664/925]

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>{
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>{
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() [665/925]

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},
1042 kWmResultZero)});
1043
1044 EXPECT_EQ(tester.key_calls.size(), 1);
1047 kNotSynthesized);
1048 tester.clear_key_calls();
1049 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
1050
1051 // Press A
1052 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
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);
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() [666/925]

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},
703 kWmResultZero)});
704
705 EXPECT_EQ(tester.key_calls.size(), 1);
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);
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);
733 kNotSynthesized);
734 tester.clear_key_calls();
735 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
736}

◆ TEST_F() [667/925]

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},
748 kWmResultZero)});
749
750 EXPECT_EQ(tester.key_calls.size(), 1);
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);
766 kNotSynthesized);
767 tester.clear_key_calls();
768 EXPECT_EQ(tester.RedispatchedMessageCountAndClear(), 1);
769}

◆ TEST_F() [668/925]

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>{
2077 kWmResultZero)});
2078
2079 // Hold A
2080 tester.InjectKeyboardChanges(std::vector<KeyboardChange>{
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() [669/925]

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>{
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>{
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() [670/925]

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(
1772 Win32Message event2 =
1773 WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
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);
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);
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);
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);
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);
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);
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);
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);
1955 kSynthesized);
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}
constexpr uint64_t kLogicalScrollLock
Definition: key_codes.g.h:382
constexpr uint64_t kPhysicalScrollLock
Definition: key_codes.g.h:143

◆ TEST_F() [671/925]

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(
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>{
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)
constexpr uint64_t kPhysicalEnter
Definition: key_codes.g.h:113
constexpr uint64_t kLogicalEnter
Definition: key_codes.g.h:372

◆ TEST_F() [672/925]

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},
2031 WmKeyDownInfo{VK_PROCESSKEY, kScanCodeDigit2, kNotExtended, kWasUp}.Build(
2033 KeyStateChange{VK_LSHIFT, false, true},
2034 WmKeyUpInfo{VK_PROCESSKEY, kScanCodeShiftLeft, kNotExtended}.Build(
2036 WmKeyUpInfo{'2', kScanCodeDigit2, kNotExtended, kWasUp}.Build(
2037 kWmResultZero)});
2038
2039 EXPECT_EQ(tester.key_calls.size(), 4);
2042 kNotSynthesized);
2044 kNotSynthesized);
2047 kNotSynthesized);
2049 kNotSynthesized);
2050 tester.clear_key_calls();
2051}

◆ TEST_F() [673/925]

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>{
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(
2312 WmCharInfo{0x8, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2314 WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
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);
2323 kNotSynthesized);
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}
constexpr uint64_t kLogicalBackspace
Definition: key_codes.g.h:370
constexpr uint64_t kPhysicalBackspace
Definition: key_codes.g.h:115

◆ TEST_F() [674/925]

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

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

Definition at line 2460 of file keyboard_unittests.cc.

◆ TEST_F() [676/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
Multiple   
)

Definition at line 96 of file layer_tree_unittests.cc.

96 {
97 const SkPath child_path1 = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
98 const SkPath child_path2 = SkPath().addRect(8.0f, 2.0f, 16.5f, 14.5f);
99 const DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
100 const DlPaint child_paint2 = DlPaint(DlColor::kGreen());
101 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
102 mock_layer1->set_fake_has_platform_view(true);
103 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
104 auto layer = std::make_shared<ContainerLayer>();
105 layer->Add(mock_layer1);
106 layer->Add(mock_layer2);
107
108 SkRect expected_total_bounds = child_path1.getBounds();
109 expected_total_bounds.join(child_path2.getBounds());
110 auto layer_tree = BuildLayerTree(layer);
111 layer_tree->Preroll(frame());
112 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
113 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
114 EXPECT_EQ(layer->paint_bounds(), expected_total_bounds);
115 EXPECT_FALSE(mock_layer1->is_empty());
116 EXPECT_FALSE(mock_layer2->is_empty());
117 EXPECT_FALSE(layer->is_empty());
118 EXPECT_EQ(mock_layer1->parent_matrix(), root_transform());
119 EXPECT_EQ(mock_layer2->parent_matrix(), root_transform());
120 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
121 EXPECT_EQ(mock_layer2->parent_cull_rect(),
122 kGiantRect); // Siblings are independent
123
124 layer_tree->Paint(frame());
125 EXPECT_EQ(
126 mock_canvas().draw_calls(),
127 std::vector({MockCanvas::DrawCall{
128 0, MockCanvas::DrawPathData{child_path1, child_paint1}},
129 MockCanvas::DrawCall{0, MockCanvas::DrawPathData{
130 child_path2, child_paint2}}}));
131}

◆ TEST_F() [677/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
MultipleWithEmpty   
)

Definition at line 133 of file layer_tree_unittests.cc.

133 {
134 const SkPath child_path1 = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
135 const DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
136 const DlPaint child_paint2 = DlPaint(DlColor::kGreen());
137 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
138 auto mock_layer2 = std::make_shared<MockLayer>(SkPath(), child_paint2);
139 auto layer = std::make_shared<ContainerLayer>();
140 layer->Add(mock_layer1);
141 layer->Add(mock_layer2);
142
143 auto layer_tree = BuildLayerTree(layer);
144 layer_tree->Preroll(frame());
145 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
146 EXPECT_EQ(mock_layer2->paint_bounds(), SkPath().getBounds());
147 EXPECT_EQ(layer->paint_bounds(), child_path1.getBounds());
148 EXPECT_FALSE(mock_layer1->is_empty());
149 EXPECT_TRUE(mock_layer2->is_empty());
150 EXPECT_FALSE(layer->is_empty());
151 EXPECT_EQ(mock_layer1->parent_matrix(), root_transform());
152 EXPECT_EQ(mock_layer2->parent_matrix(), root_transform());
153 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
154 EXPECT_EQ(mock_layer2->parent_cull_rect(), kGiantRect);
155
156 layer_tree->Paint(frame());
157 EXPECT_EQ(mock_canvas().draw_calls(),
158 std::vector({MockCanvas::DrawCall{
159 0, MockCanvas::DrawPathData{child_path1, child_paint1}}}));
160}

◆ TEST_F() [678/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
NeedsSystemComposite   
)

Definition at line 162 of file layer_tree_unittests.cc.

162 {
163 const SkPath child_path1 = SkPath().addRect(5.0f, 6.0f, 20.5f, 21.5f);
164 const SkPath child_path2 = SkPath().addRect(8.0f, 2.0f, 16.5f, 14.5f);
165 const DlPaint child_paint1 = DlPaint(DlColor::kMidGrey());
166 const DlPaint child_paint2 = DlPaint(DlColor::kGreen());
167 auto mock_layer1 = std::make_shared<MockLayer>(child_path1, child_paint1);
168 auto mock_layer2 = std::make_shared<MockLayer>(child_path2, child_paint2);
169 auto layer = std::make_shared<ContainerLayer>();
170 layer->Add(mock_layer1);
171 layer->Add(mock_layer2);
172
173 SkRect expected_total_bounds = child_path1.getBounds();
174 expected_total_bounds.join(child_path2.getBounds());
175 auto layer_tree = BuildLayerTree(layer);
176 layer_tree->Preroll(frame());
177 EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
178 EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
179 EXPECT_EQ(layer->paint_bounds(), expected_total_bounds);
180 EXPECT_FALSE(mock_layer1->is_empty());
181 EXPECT_FALSE(mock_layer2->is_empty());
182 EXPECT_FALSE(layer->is_empty());
183 EXPECT_EQ(mock_layer1->parent_matrix(), root_transform());
184 EXPECT_EQ(mock_layer2->parent_matrix(), root_transform());
185 EXPECT_EQ(mock_layer1->parent_cull_rect(), kGiantRect);
186 EXPECT_EQ(mock_layer2->parent_cull_rect(), kGiantRect);
187
188 layer_tree->Paint(frame());
189 EXPECT_EQ(
190 mock_canvas().draw_calls(),
191 std::vector({MockCanvas::DrawCall{
192 0, MockCanvas::DrawPathData{child_path1, child_paint1}},
193 MockCanvas::DrawCall{0, MockCanvas::DrawPathData{
194 child_path2, child_paint2}}}));
195}

◆ TEST_F() [679/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
PaintBeforePrerollDies   
)

Definition at line 56 of file layer_tree_unittests.cc.

56 {
57 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
58 SkPath child_path;
59 child_path.addRect(child_bounds);
60 auto mock_layer = std::make_shared<MockLayer>(child_path);
61 auto layer = std::make_shared<ContainerLayer>();
62 layer->Add(mock_layer);
63
64 auto layer_tree = BuildLayerTree(layer);
65 EXPECT_EQ(mock_layer->paint_bounds(), kEmptyRect);
66 EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
67 EXPECT_TRUE(mock_layer->is_empty());
68 EXPECT_TRUE(layer->is_empty());
69
70 layer_tree->Paint(frame());
71 EXPECT_EQ(mock_canvas().draw_calls(), std::vector<MockCanvas::DrawCall>());
72}

◆ TEST_F() [680/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
PaintContextInitialization   
)

Definition at line 237 of file layer_tree_unittests.cc.

237 {
238 LayerStateStack state_stack;
239 FixedRefreshRateStopwatch mock_raster_time;
240 FixedRefreshRateStopwatch mock_ui_time;
241 std::shared_ptr<TextureRegistry> mock_registry;
242
243 auto expect_defaults = [&state_stack, &mock_raster_time, &mock_ui_time,
244 &mock_registry](const PaintContext& context) {
245 EXPECT_EQ(&context.state_stack, &state_stack);
246 EXPECT_EQ(context.canvas, nullptr);
247 EXPECT_EQ(context.gr_context, nullptr);
248 EXPECT_EQ(context.view_embedder, nullptr);
249 EXPECT_EQ(&context.raster_time, &mock_raster_time);
250 EXPECT_EQ(&context.ui_time, &mock_ui_time);
251 EXPECT_EQ(context.texture_registry.get(), mock_registry.get());
252 EXPECT_EQ(context.raster_cache, nullptr);
253
254 EXPECT_EQ(context.enable_leaf_layer_tracing, false);
255 EXPECT_EQ(context.layer_snapshot_store, nullptr);
256 };
257
258 // These 4 initializers are required because they are handled by reference
259 PaintContext context{
260 .state_stack = state_stack,
261 .raster_time = mock_raster_time,
262 .ui_time = mock_ui_time,
263 .texture_registry = mock_registry,
264 };
265 expect_defaults(context);
266}
LayerStateStack & state_stack
Definition: layer.h:101

◆ TEST_F() [681/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
PaintingEmptyLayerDies   
)

Definition at line 46 of file layer_tree_unittests.cc.

46 {
47 auto layer = std::make_shared<ContainerLayer>();
48 auto layer_tree = BuildLayerTree(layer);
49 layer_tree->Preroll(frame());
50 EXPECT_EQ(layer->paint_bounds(), SkRect::MakeEmpty());
51 EXPECT_TRUE(layer->is_empty());
52
53 layer_tree->Paint(frame());
54}

◆ TEST_F() [682/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
PrerollContextInitialization   
)

Definition at line 197 of file layer_tree_unittests.cc.

197 {
198 LayerStateStack state_stack;
200 FixedRefreshRateStopwatch mock_raster_time;
201 FixedRefreshRateStopwatch mock_ui_time;
202 std::shared_ptr<TextureRegistry> mock_registry;
203
204 auto expect_defaults = [&state_stack, &mock_raster_time, &mock_ui_time,
205 &mock_registry](const PrerollContext& context) {
206 EXPECT_EQ(context.raster_cache, nullptr);
207 EXPECT_EQ(context.gr_context, nullptr);
208 EXPECT_EQ(context.view_embedder, nullptr);
209 EXPECT_EQ(&context.state_stack, &state_stack);
210 EXPECT_EQ(context.dst_color_space, nullptr);
211 EXPECT_EQ(context.state_stack.device_cull_rect(), kGiantRect);
212 EXPECT_EQ(context.state_stack.transform_3x3(), SkMatrix::I());
213 EXPECT_EQ(context.state_stack.transform_4x4(), SkM44());
214 EXPECT_EQ(context.surface_needs_readback, false);
215
216 EXPECT_EQ(&context.raster_time, &mock_raster_time);
217 EXPECT_EQ(&context.ui_time, &mock_ui_time);
218 EXPECT_EQ(context.texture_registry.get(), mock_registry.get());
219
220 EXPECT_EQ(context.has_platform_view, false);
221 EXPECT_EQ(context.has_texture_layer, false);
222
223 EXPECT_EQ(context.renderable_state_flags, 0);
224 EXPECT_EQ(context.raster_cached_entries, nullptr);
225 };
226
227 // These 4 initializers are required because they are handled by reference
228 PrerollContext context{
229 .state_stack = state_stack,
230 .raster_time = mock_raster_time,
231 .ui_time = mock_ui_time,
232 .texture_registry = mock_registry,
233 };
234 expect_defaults(context);
235}
LayerStateStack & state_stack
Definition: layer.h:59

◆ TEST_F() [683/925]

flutter::testing::TEST_F ( LayerTreeTest  ,
Simple   
)

Definition at line 74 of file layer_tree_unittests.cc.

74 {
75 const SkRect child_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f);
76 const SkPath child_path = SkPath().addRect(child_bounds);
77 const DlPaint child_paint = DlPaint(DlColor::kCyan());
78 auto mock_layer = std::make_shared<MockLayer>(child_path, child_paint);
79 auto layer = std::make_shared<ContainerLayer>();
80 layer->Add(mock_layer);
81
82 auto layer_tree = BuildLayerTree(layer);
83 layer_tree->Preroll(frame());
84 EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
85 EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
86 EXPECT_FALSE(mock_layer->is_empty());
87 EXPECT_FALSE(layer->is_empty());
88 EXPECT_EQ(mock_layer->parent_matrix(), root_transform());
89
90 layer_tree->Paint(frame());
91 EXPECT_EQ(mock_canvas().draw_calls(),
92 std::vector({MockCanvas::DrawCall{
93 0, MockCanvas::DrawPathData{child_path, child_paint}}}));
94}

◆ TEST_F() [684/925]

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);
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() [685/925]

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

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

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

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

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);
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() [690/925]

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

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

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

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

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

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

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

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

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

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

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

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

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

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(),
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(),
202 EXPECT_FALSE(cacheable_opacity_item->Draw(paint_context(), &paint));
203}

◆ TEST_F() [704/925]

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

flutter::testing::TEST_F ( PainterTest  ,
DrawDashedLineSkia   
)

Definition at line 198 of file paragraph_unittests.cc.

198 {
199 PretendImpellerIsEnabled(false);
200
201 auto recorder = DlOpRecorder();
202 draw(makeDecoratedStyle(txt::TextDecorationStyle::kDashed))
203 ->Dispatch(recorder);
204
205 // Skia draws a dashed underline as a filled rectangle with a path effect.
206 EXPECT_EQ(recorder.lineCount(), 0);
207 EXPECT_EQ(recorder.dashedLineCount(), 1);
208}
A custom |DlOpReceiver| that records some |DlOps| it receives.

◆ TEST_F() [706/925]

flutter::testing::TEST_F ( PainterTest  ,
DrawsSolidLineSkia   
)

Definition at line 186 of file paragraph_unittests.cc.

186 {
187 PretendImpellerIsEnabled(false);
188
189 auto recorder = DlOpRecorder();
190 draw(makeDecoratedStyle(txt::TextDecorationStyle::kSolid))
191 ->Dispatch(recorder);
192
193 // Skia may draw a solid underline as a filled rectangle:
194 // https://skia.googlesource.com/skia/+/refs/heads/main/modules/skparagraph/src/Decorations.cpp#91
195 EXPECT_EQ(recorder.rectCount(), 1);
196}

◆ TEST_F() [707/925]

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

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

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

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.
70 auto settings = CreateSettingsForFixture();
71 settings.assets_path = asset_dir.path();
72 RunConfiguration::InferFromSettings(settings);
74
75 // 2nd, test that the RunConfiguration constructor sets the asset manager.
76 // (Android is directly calling that constructor without InferFromSettings.)
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));
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}
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
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)
static void CheckTwoSkSLsAreLoaded()
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
Definition: file_posix.cc:191
constexpr LogSeverity kLogWarning
Definition: log_level.h:14
bool UnlinkFile(const char *path)
Definition: file_posix.cc:171

◆ TEST_F() [711/925]

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
Definition: unique_object.h:89
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() [712/925]

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

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

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

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

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

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

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

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:1369
@ Dart_PerformanceMode_Default
Definition: dart_api.h:1373
@ Dart_PerformanceMode_Latency
Definition: dart_api.h:1380
DART_EXPORT Dart_PerformanceMode Dart_SetPerformanceMode(Dart_PerformanceMode mode)

◆ TEST_F() [720/925]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

flutter::testing::TEST_F ( RasterCacheTest  ,
RasterCacheKeyIDLayerChildrenIds   
)

Definition at line 750 of file raster_cache_unittests.cc.

750 {
751 auto layer = std::make_shared<ContainerLayer>();
752
753 const SkPath child_path = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f));
754 auto mock_layer = std::make_shared<MockLayer>(child_path);
755 layer->Add(mock_layer);
756
757 auto display_list = GetSampleDisplayList();
758 auto display_list_layer = std::make_shared<DisplayListLayer>(
759 SkPoint::Make(0.0f, 0.0f), display_list, false, false);
760 layer->Add(display_list_layer);
761
762 auto ids = RasterCacheKeyID::LayerChildrenIds(layer.get()).value();
763 std::vector<RasterCacheKeyID> expected_ids;
764 expected_ids.emplace_back(
765 RasterCacheKeyID(mock_layer->unique_id(), RasterCacheKeyType::kLayer));
766 expected_ids.emplace_back(RasterCacheKeyID(display_list->unique_id(),
767 RasterCacheKeyType::kDisplayList));
768 ASSERT_EQ(expected_ids[0], mock_layer->caching_key_id());
769 ASSERT_EQ(expected_ids[1], display_list_layer->caching_key_id());
770 ASSERT_EQ(ids, expected_ids);
771}

◆ TEST_F() [750/925]

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,
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,
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() [751/925]

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

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

◆ TEST_F() [753/925]

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
676}
static void TestDartVmFlags(std::vector< const char * > &flags)

◆ TEST_F() [754/925]

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 =
251 std::make_unique<LayerTree>(nullptr, 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)
constexpr int64_t kImplicitViewId

◆ TEST_F() [755/925]

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 =
170 std::make_unique<LayerTree>(nullptr, 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)
Definition: task_runner.cc:33

◆ TEST_F() [756/925]

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

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

flutter::testing::TEST_F ( ShellTest  ,
CanCorrectlyPipePointerPacket   
)

Definition at line 315 of file input_events_unittests.cc.

315 {
316 // Sets up shell with test fixture.
317 auto settings = CreateSettingsForFixture();
318 std::unique_ptr<Shell> shell = CreateShell({
319 .settings = settings,
320 .platform_view_create_callback = ShellTestPlatformViewBuilder({
321 .simulate_vsync = true,
322 }),
323 });
324
325 auto configuration = RunConfiguration::InferFromSettings(settings);
326 configuration.SetEntrypoint("onPointerDataPacketMain");
327 // Sets up native handler.
328 fml::AutoResetWaitableEvent reportLatch;
329 std::vector<int64_t> result_sequence;
330 auto nativeOnPointerDataPacket = [&reportLatch, &result_sequence](
332 Dart_Handle exception = nullptr;
333 result_sequence = tonic::DartConverter<std::vector<int64_t>>::FromArguments(
334 args, 0, exception);
335 reportLatch.Signal();
336 };
337 // Starts engine.
338 AddNativeCallback("NativeOnPointerDataPacket",
339 CREATE_NATIVE_ENTRY(nativeOnPointerDataPacket));
340 ASSERT_TRUE(configuration.IsValid());
341 RunEngine(shell.get(), std::move(configuration));
342 // Starts test.
343 auto packet = std::make_unique<PointerDataPacket>(6);
344 PointerData data;
346 packet->SetPointerData(0, data);
348 packet->SetPointerData(1, data);
350 packet->SetPointerData(2, data);
352 packet->SetPointerData(3, data);
354 packet->SetPointerData(4, data);
356 packet->SetPointerData(5, data);
357 ShellTest::DispatchPointerData(shell.get(), std::move(packet));
358 ShellTest::VSyncFlush(shell.get());
359
360 reportLatch.Wait();
361 size_t expect_length = 6;
362 ASSERT_EQ(result_sequence.size(), expect_length);
363 ASSERT_EQ(PointerData::Change(result_sequence[0]), PointerData::Change::kAdd);
364 ASSERT_EQ(PointerData::Change(result_sequence[1]),
366 ASSERT_EQ(PointerData::Change(result_sequence[2]),
368 ASSERT_EQ(PointerData::Change(result_sequence[3]),
370 ASSERT_EQ(PointerData::Change(result_sequence[4]), PointerData::Change::kUp);
371 ASSERT_EQ(PointerData::Change(result_sequence[5]),
373
374 // Cleans up shell.
375 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
376 DestroyShell(std::move(shell));
377 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
378}
void CreateSimulatedPointerData(PointerData &data, PointerData::Change change, double dx, double dy)

◆ TEST_F() [759/925]

flutter::testing::TEST_F ( ShellTest  ,
CanCorrectlySynthesizePointerPacket   
)

Definition at line 380 of file input_events_unittests.cc.

380 {
381 // Sets up shell with test fixture.
382 auto settings = CreateSettingsForFixture();
383 std::unique_ptr<Shell> shell = CreateShell({
384 .settings = settings,
385 .platform_view_create_callback = ShellTestPlatformViewBuilder({
386 .simulate_vsync = true,
387 }),
388 });
389
390 auto configuration = RunConfiguration::InferFromSettings(settings);
391 configuration.SetEntrypoint("onPointerDataPacketMain");
392 // Sets up native handler.
393 fml::AutoResetWaitableEvent reportLatch;
394 std::vector<int64_t> result_sequence;
395 auto nativeOnPointerDataPacket = [&reportLatch, &result_sequence](
397 Dart_Handle exception = nullptr;
398 result_sequence = tonic::DartConverter<std::vector<int64_t>>::FromArguments(
399 args, 0, exception);
400 reportLatch.Signal();
401 };
402 // Starts engine.
403 AddNativeCallback("NativeOnPointerDataPacket",
404 CREATE_NATIVE_ENTRY(nativeOnPointerDataPacket));
405 ASSERT_TRUE(configuration.IsValid());
406 RunEngine(shell.get(), std::move(configuration));
407 // Starts test.
408 auto packet = std::make_unique<PointerDataPacket>(4);
409 PointerData data;
411 packet->SetPointerData(0, data);
413 packet->SetPointerData(1, data);
415 packet->SetPointerData(2, data);
417 packet->SetPointerData(3, data);
418 ShellTest::DispatchPointerData(shell.get(), std::move(packet));
419 ShellTest::VSyncFlush(shell.get());
420
421 reportLatch.Wait();
422 size_t expect_length = 6;
423 ASSERT_EQ(result_sequence.size(), expect_length);
424 ASSERT_EQ(PointerData::Change(result_sequence[0]), PointerData::Change::kAdd);
425 // The pointer data packet converter should synthesize a hover event.
426 ASSERT_EQ(PointerData::Change(result_sequence[1]),
428 ASSERT_EQ(PointerData::Change(result_sequence[2]),
430 // The pointer data packet converter should synthesize a move event.
431 ASSERT_EQ(PointerData::Change(result_sequence[3]),
433 ASSERT_EQ(PointerData::Change(result_sequence[4]), PointerData::Change::kUp);
434 ASSERT_EQ(PointerData::Change(result_sequence[5]),
436
437 // Cleans up shell.
438 ASSERT_TRUE(DartVMRef::IsInstanceRunning());
439 DestroyShell(std::move(shell));
440 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
441}

◆ TEST_F() [760/925]

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

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

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

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

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

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)
static void ParseViewWidthsCallback(const Dart_NativeArguments &args, std::map< int64_t, int64_t > *viewWidths)

◆ TEST_F() [766/925]

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

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:69
DlBlendMode getBlendMode() const
Definition: dl_paint.h:83
DlDrawStyle getDrawStyle() const
Definition: dl_paint.h:91
std::shared_ptr< const DlMaskFilter > getMaskFilter() const
Definition: dl_paint.h:166
std::shared_ptr< const DlColorFilter > getColorFilter() const
Definition: dl_paint.h:140
constexpr uint32_t argb() const
Definition: dl_color.h:82

◆ TEST_F() [768/925]

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

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

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.
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() [771/925]

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.
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() [772/925]

flutter::testing::TEST_F ( ShellTest  ,
DelayAtMostOneEventForFasterThanVSyncInputEvents   
)

Definition at line 220 of file input_events_unittests.cc.

220 {
221 // We don't use `constexpr int frame_time` here because MSVC doesn't handle
222 // it well with lambda capture.
223 UnitlessTime frame_time = 10;
224 UnitlessTime base_latency = 0.2 * frame_time;
225 Generator double_sampling = [frame_time, base_latency](int i) {
226 return static_cast<UnitlessTime>(i * 0.5 * frame_time + base_latency);
227 };
228 constexpr int n = 40;
229 std::vector<int> events_consumed_at_frame;
230 TestSimulatedInputEvents(this, n, base_latency, double_sampling, frame_time,
231 events_consumed_at_frame);
232
233 // Draw one extra frame due to delaying a pending packet for the next frame.
234 int frame_drawn = events_consumed_at_frame.size();
235 ASSERT_EQ(frame_drawn, n / 2 + 1);
236
237 for (int i = 0; i < n / 2; i += 1) {
238 ASSERT_GE(events_consumed_at_frame[i], 2 * i - 1);
239 }
240}
std::function< UnitlessTime(int)> Generator
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)

◆ TEST_F() [773/925]

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);
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() [774/925]

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

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

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(
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}
void MergeWithLease(size_t lease_term)

◆ TEST_F() [777/925]

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

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

flutter::testing::TEST_F ( ShellTest  ,
EncodeImageAccessesSyncSwitch   
)

Definition at line 130 of file image_encoding_unittests.cc.

130 {
131 Settings settings = CreateSettingsForFixture();
132 TaskRunners task_runners("test", // label
133 GetCurrentTaskRunner(), // platform
134 CreateNewThread(), // raster
135 CreateNewThread(), // ui
136 CreateNewThread() // io
137 );
138
139 auto native_encode_image = [&](Dart_NativeArguments args) {
140 auto image_handle = Dart_GetNativeArgument(args, 0);
141 image_handle =
142 Dart_GetField(image_handle, Dart_NewStringFromCString("_image"));
143 ASSERT_FALSE(Dart_IsError(image_handle)) << Dart_GetError(image_handle);
144 ASSERT_FALSE(Dart_IsNull(image_handle));
145 auto format_handle = Dart_GetNativeArgument(args, 1);
146
147 intptr_t peer = 0;
149 image_handle, tonic::DartWrappable::kPeerIndex, &peer);
150 ASSERT_FALSE(Dart_IsError(result));
151 CanvasImage* canvas_image = reinterpret_cast<CanvasImage*>(peer);
152
153 int64_t format = -1;
154 result = Dart_IntegerToInt64(format_handle, &format);
155 ASSERT_FALSE(Dart_IsError(result));
156
157 auto io_manager = UIDartState::Current()->GetIOManager();
159
160 task_runners.GetIOTaskRunner()->PostTask([&]() {
161 auto is_gpu_disabled_sync_switch =
162 std::make_shared<const MockSyncSwitch>();
163 EXPECT_CALL(*is_gpu_disabled_sync_switch, Execute)
164 .WillOnce([](const MockSyncSwitch::Handlers& handlers) {
165 handlers.true_handler();
166 });
167 ConvertToRasterUsingResourceContext(canvas_image->image()->skia_image(),
168 io_manager->GetResourceContext(),
169 is_gpu_disabled_sync_switch);
170 latch.Signal();
171 });
172
173 latch.Wait();
174
175 message_latch.Signal();
176 };
177
178 AddNativeCallback("EncodeImage", CREATE_NATIVE_ENTRY(native_encode_image));
179
180 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
181
182 ASSERT_TRUE(shell->IsSetup());
183 auto configuration = RunConfiguration::InferFromSettings(settings);
184 configuration.SetEntrypoint("encodeImageProducesExternalUint8List");
185
186 shell->RunEngine(std::move(configuration), [&](auto result) {
187 ASSERT_EQ(result, Engine::RunStatus::Success);
188 });
189
190 message_latch.Wait();
191 DestroyShell(std::move(shell), task_runners);
192}
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() [780/925]

flutter::testing::TEST_F ( ShellTest  ,
EncodeImageGivesExternalTypedData   
)

Definition at line 71 of file image_encoding_unittests.cc.

71 {
72 auto native_encode_image = [&](Dart_NativeArguments args) {
73 auto image_handle = Dart_GetNativeArgument(args, 0);
74 image_handle =
75 Dart_GetField(image_handle, Dart_NewStringFromCString("_image"));
76 ASSERT_FALSE(Dart_IsError(image_handle)) << Dart_GetError(image_handle);
77 ASSERT_FALSE(Dart_IsNull(image_handle));
78 auto format_handle = Dart_GetNativeArgument(args, 1);
79 auto callback_handle = Dart_GetNativeArgument(args, 2);
80
81 intptr_t peer = 0;
83 image_handle, tonic::DartWrappable::kPeerIndex, &peer);
84 ASSERT_FALSE(Dart_IsError(result));
85 CanvasImage* canvas_image = reinterpret_cast<CanvasImage*>(peer);
86
87 int64_t format = -1;
88 result = Dart_IntegerToInt64(format_handle, &format);
89 ASSERT_FALSE(Dart_IsError(result));
90
91 result = EncodeImage(canvas_image, format, callback_handle);
92 ASSERT_TRUE(Dart_IsNull(result));
93 };
94
95 auto nativeValidateExternal = [&](Dart_NativeArguments args) {
96 auto handle = Dart_GetNativeArgument(args, 0);
97
98 auto typed_data_type = Dart_GetTypeOfExternalTypedData(handle);
99 EXPECT_EQ(typed_data_type, Dart_TypedData_kUint8);
100
101 message_latch.Signal();
102 };
103
104 Settings settings = CreateSettingsForFixture();
105 TaskRunners task_runners("test", // label
106 GetCurrentTaskRunner(), // platform
107 CreateNewThread(), // raster
108 CreateNewThread(), // ui
109 CreateNewThread() // io
110 );
111
112 AddNativeCallback("EncodeImage", CREATE_NATIVE_ENTRY(native_encode_image));
113 AddNativeCallback("ValidateExternal",
114 CREATE_NATIVE_ENTRY(nativeValidateExternal));
115
116 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
117
118 ASSERT_TRUE(shell->IsSetup());
119 auto configuration = RunConfiguration::InferFromSettings(settings);
120 configuration.SetEntrypoint("encodeImageProducesExternalUint8List");
121
122 shell->RunEngine(std::move(configuration), [&](auto result) {
123 ASSERT_EQ(result, Engine::RunStatus::Success);
124 });
125
126 message_latch.Wait();
127 DestroyShell(std::move(shell), task_runners);
128}
DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData(Dart_Handle object)
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615
Dart_Handle EncodeImage(CanvasImage *canvas_image, int format, Dart_Handle callback_handle)

◆ TEST_F() [781/925]

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

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

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

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

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}

◆ TEST_F() [786/925]

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

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

flutter::testing::TEST_F ( ShellTest  ,
HandlesActualIphoneXsInputEvents   
)

Definition at line 242 of file input_events_unittests.cc.

242 {
243 // Actual delivery times measured on iPhone Xs, in the unit of frame_time
244 // (16.67ms for 60Hz).
245 static constexpr double iphone_xs_times[] = {0.15,
246 1.0773046874999999,
247 2.1738720703124996,
248 3.0579052734374996,
249 4.0890087890624995,
250 5.0952685546875,
251 6.1251708984375,
252 7.1253076171875,
253 8.125927734374999,
254 9.37248046875,
255 10.133950195312499,
256 11.161201171875,
257 12.226992187499999,
258 13.1443798828125,
259 14.440327148437499,
260 15.091684570312498,
261 16.138681640625,
262 17.126469726562497,
263 18.1592431640625,
264 19.371372070312496,
265 20.033774414062496,
266 21.021782226562497,
267 22.070053710937497,
268 23.325541992187496,
269 24.119648437499997,
270 25.084262695312496,
271 26.077866210937497,
272 27.036547851562496,
273 28.035073242187497,
274 29.081411132812498,
275 30.066064453124998,
276 31.089360351562497,
277 32.086142578125,
278 33.4618798828125,
279 34.14697265624999,
280 35.0513525390625,
281 36.136025390624994,
282 37.1618408203125,
283 38.144472656249995,
284 39.201123046875,
285 40.4339501953125,
286 41.1552099609375,
287 42.102128906249995,
288 43.0426318359375,
289 44.070131835937495,
290 45.08862304687499,
291 46.091469726562494};
292 constexpr int n = sizeof(iphone_xs_times) / sizeof(iphone_xs_times[0]);
293 // We don't use `constexpr int frame_time` here because MSVC doesn't handle
294 // it well with lambda capture.
295 UnitlessTime frame_time = 10000;
296 double base_latency_f = 0.0;
297 for (int i = 0; i < 10; i++) {
298 base_latency_f += 0.1;
299 // Everything is converted to int to avoid floating point error in
300 // TestSimulatedInputEvents.
301 UnitlessTime base_latency =
302 static_cast<UnitlessTime>(base_latency_f * frame_time);
303 Generator iphone_xs_generator = [frame_time, base_latency](int i) {
304 return base_latency +
305 static_cast<UnitlessTime>(iphone_xs_times[i] * frame_time);
306 };
307 std::vector<int> events_consumed_at_frame;
308 TestSimulatedInputEvents(this, n, base_latency, iphone_xs_generator,
309 frame_time, events_consumed_at_frame);
310 int frame_drawn = events_consumed_at_frame.size();
311 ASSERT_GE(frame_drawn, n - 1);
312 }
313}

◆ TEST_F() [789/925]

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}

◆ TEST_F() [790/925]

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

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

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

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

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

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

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 |SyncSwitch::Execute|.
Definition: sync_switch.h:35

◆ TEST_F() [797/925]

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

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

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>();
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() [800/925]

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

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

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

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

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

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

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

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}
static double time(int loops, Benchmark *bench, Target *target)
Definition: nanobench.cpp:394

◆ TEST_F() [808/925]

flutter::testing::TEST_F ( ShellTest  ,
MissAtMostOneFrameForIrregularInputEvents   
)

Definition at line 196 of file input_events_unittests.cc.

196 {
197 // We don't use `constexpr int frame_time` here because MSVC doesn't handle
198 // it well with lambda capture.
199 UnitlessTime frame_time = 10;
200 UnitlessTime base_latency = 0.5 * frame_time;
201 Generator extreme = [frame_time, base_latency](int i) {
202 return static_cast<UnitlessTime>(
203 i * frame_time + base_latency +
204 (i % 2 == 0 ? 0.1 * frame_time : 0.9 * frame_time));
205 };
206 constexpr int n = 40;
207 std::vector<int> events_consumed_at_frame;
208 TestSimulatedInputEvents(this, n, base_latency, extreme, frame_time,
209 events_consumed_at_frame);
210 int frame_drawn = events_consumed_at_frame.size();
211 ASSERT_GE(frame_drawn, n - 1);
212
213 // Make sure that it also works after an engine restart.
214 TestSimulatedInputEvents(this, n, base_latency, extreme, frame_time,
215 events_consumed_at_frame, true /* restart_engine */);
216 int frame_drawn_after_restart = events_consumed_at_frame.size();
217 ASSERT_GE(frame_drawn_after_restart, n - 1);
218}

◆ TEST_F() [809/925]

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
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
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
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
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
1782 static_cast<size_t>(4000000U));
1783 DestroyShell(std::move(third_shell), task_runners);
1784 // max bytes threshold
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
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:120
static size_t GetRasterizerResourceCacheBytesSync(const Shell &shell)

◆ TEST_F() [810/925]

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

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

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

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

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

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

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

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

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

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()));
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() [820/925]

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

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

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) {
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}
GrDirectContext * gr_context
Definition: layer.h:57

◆ TEST_F() [823/925]

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

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

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 =
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() [826/925]

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);
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() [827/925]

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);
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() [828/925]

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

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

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

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

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

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.
97 ASSERT_EQ(result->GetInfo().width(), fake_width);
98}

◆ TEST_F() [834/925]

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

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

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

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->MakeRasterSnapshotSync(
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() [838/925]

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

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

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

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

◆ TEST_F() [842/925]

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:122

◆ TEST_F() [843/925]

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 =
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}
const void * data() const
Definition: SkData.h:37
static void LogSkData(const sk_sp< SkData > &data, const char *title)

◆ TEST_F() [844/925]

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() [845/925]

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() [846/925]

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)
1825#elif defined(SHELL_ENABLE_METAL)
1827 static_cast<size_t>(256 * (1 << 20)));
1828#else
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() [847/925]

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
1889 static_cast<size_t>(3840000U));
1890 DestroyShell(std::move(shell), task_runners);
1891}

◆ TEST_F() [848/925]

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
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
1927 static_cast<size_t>(10000U));
1928 DestroyShell(std::move(shell), task_runners);
1929}

◆ TEST_F() [849/925]

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() [850/925]

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() [851/925]

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() [852/925]

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() [853/925]

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() [854/925]

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() [855/925]

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() [856/925]

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() [857/925]

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() [858/925]

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() [859/925]

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() [860/925]

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() [861/925]

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() [862/925]

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() [863/925]

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() [864/925]

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....
Definition: dart_isolate.h:63
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() [865/925]

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,
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}
static void InvokePlatformMessageEmptyResponseCallback(JNIEnv *env, jobject jcaller, jlong shell_holder, jint responseId)

◆ TEST_F() [866/925]

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
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
88 flutter::PlatformData(), task_runners, settings,
89 [vsync_clock, &create_vsync_waiter](Shell& shell) {
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}
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter

◆ TEST_F() [867/925]

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() [868/925]

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() [869/925]

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() [870/925]

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() [871/925]

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() [872/925]

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() [873/925]

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() [874/925]

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() [875/925]

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() [876/925]

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() [877/925]

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() [878/925]

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() [879/925]

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() [880/925]

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() [881/925]

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() [882/925]

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() [883/925]

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() [884/925]

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}
TRect< Scalar > Rect
Definition: rect.h:769

◆ TEST_F() [885/925]

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() [886/925]

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}
static bool equal(const SkBitmap &a, const SkBitmap &b)
Definition: ImageTest.cpp:1395
SkRange< size_t > TextRange
Definition: TextStyle.h:337

◆ TEST_F() [887/925]

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() [888/925]

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,
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() [889/925]

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() [890/925]

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,
95 }
96 EXPECT_TRUE(DisplayListsEQ_Verbose(display_list(), expected_builder.Build()));
97}

◆ TEST_F() [891/925]

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() [892/925]

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() [893/925]

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() [894/925]

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() [895/925]

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() [896/925]

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() [897/925]

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)
Definition: dart_invoke.cc:12

◆ TEST_F() [898/925]

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() [899/925]

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() [900/925]

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() [901/925]

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() [902/925]

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() [903/925]

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();
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)

◆ TEST_F() [904/925]

flutter::testing::TEST_F ( WindowsTest  ,
EngineCanTransitionToHeadless   
)

Definition at line 152 of file flutter_windows_unittests.cc.

152 {
153 auto& context = GetContext();
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}

◆ TEST_F() [905/925]

flutter::testing::TEST_F ( WindowsTest  ,
GetGraphicsAdapter   
)

Definition at line 411 of file flutter_windows_unittests.cc.

411 {
412 auto& context = GetContext();
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() [906/925]

flutter::testing::TEST_F ( WindowsTest  ,
GetKeyboardStateHeadless   
)

Definition at line 548 of file flutter_windows_unittests.cc.

548 {
549 auto& context = GetContext();
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() [907/925]

flutter::testing::TEST_F ( WindowsTest  ,
GetViewId   
)

Definition at line 400 of file flutter_windows_unittests.cc.

400 {
401 auto& context = GetContext();
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() [908/925]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchConflictingCustomEntrypoints   
)

Definition at line 201 of file flutter_windows_unittests.cc.

201 {
202 auto& context = GetContext();
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() [909/925]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchCustomEntrypoint   
)

Definition at line 103 of file flutter_windows_unittests.cc.

103 {
104 auto& context = GetContext();
106 builder.SetDartEntrypoint("customEntrypoint");
107 ViewControllerPtr controller{builder.Run()};
108 ASSERT_NE(controller, nullptr);
109}

◆ TEST_F() [910/925]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchCustomEntrypointInEngineRunInvocation   
)

Definition at line 116 of file flutter_windows_unittests.cc.

116 {
117 auto& context = GetContext();
119 EnginePtr engine{builder.InitializeEngine()};
120 ASSERT_NE(engine, nullptr);
121
122 ASSERT_TRUE(FlutterDesktopEngineRun(engine.get(), "customEntrypoint"));
123}

◆ TEST_F() [911/925]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchHeadlessEngine   
)

Definition at line 126 of file flutter_windows_unittests.cc.

126 {
127 auto& context = GetContext();
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() [912/925]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchMain   
)

Definition at line 76 of file flutter_windows_unittests.cc.

76 {
77 auto& context = GetContext();
79 ViewControllerPtr controller{builder.Run()};
80 ASSERT_NE(controller, nullptr);
81}

◆ TEST_F() [913/925]

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();
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() [914/925]

flutter::testing::TEST_F ( WindowsTest  ,
LaunchRefreshesAccessibility   
)

Definition at line 176 of file flutter_windows_unittests.cc.

176 {
177 auto& context = GetContext();
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() [915/925]

flutter::testing::TEST_F ( WindowsTest  ,
Lifecycle   
)

Definition at line 503 of file flutter_windows_unittests.cc.

503 {
504 auto& context = GetContext();
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() [916/925]

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() [917/925]

flutter::testing::TEST_F ( WindowsTest  ,
PlatformExecutable   
)

Definition at line 254 of file flutter_windows_unittests.cc.

254 {
255 auto& context = GetContext();
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() [918/925]

flutter::testing::TEST_F ( WindowsTest  ,
PluginRegistrarGetImplicitView   
)

Definition at line 426 of file flutter_windows_unittests.cc.

426 {
427 auto& context = GetContext();
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() [919/925]

flutter::testing::TEST_F ( WindowsTest  ,
PluginRegistrarGetView   
)

Definition at line 442 of file flutter_windows_unittests.cc.

442 {
443 auto& context = GetContext();
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() [920/925]

flutter::testing::TEST_F ( WindowsTest  ,
PluginRegistrarGetViewHeadless   
)

Definition at line 465 of file flutter_windows_unittests.cc.

465 {
466 auto& context = GetContext();
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() [921/925]

flutter::testing::TEST_F ( WindowsTest  ,
PresentHeadless   
)

Definition at line 363 of file flutter_windows_unittests.cc.

363 {
364 auto& context = GetContext();
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() [922/925]

flutter::testing::TEST_F ( WindowsTest  ,
SurfaceOptional   
)

Definition at line 485 of file flutter_windows_unittests.cc.

485 {
486 auto& context = GetContext();
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() [923/925]

flutter::testing::TEST_F ( WindowsTest  ,
VerifyNativeFunction   
)

Definition at line 212 of file flutter_windows_unittests.cc.

212 {
213 auto& context = GetContext();
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() [924/925]

flutter::testing::TEST_F ( WindowsTest  ,
VerifyNativeFunctionWithParameters   
)

Definition at line 231 of file flutter_windows_unittests.cc.

231 {
232 auto& context = GetContext();
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() [925/925]

flutter::testing::TEST_F ( WindowsTest  ,
VerifyNativeFunctionWithReturn   
)

Definition at line 279 of file flutter_windows_unittests.cc.

279 {
280 auto& context = GetContext();
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/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
Bug147807   
)

Definition at line 57 of file dl_golden_unittests.cc.

57 {
58 Point content_scale = GetContentScale();
59 auto draw = [content_scale](DlCanvas* canvas,
60 const std::vector<sk_sp<DlImage>>& images) {
61 canvas->Scale(content_scale.x, content_scale.y);
63 paint.setColor(DlColor(0xfffef7ff));
64 canvas->DrawRect(SkRect::MakeLTRB(0, 0, 375, 667), paint);
65 paint.setColor(DlColor(0xffff9800));
66 canvas->DrawRect(SkRect::MakeLTRB(0, 0, 187.5, 333.5), paint);
67 paint.setColor(DlColor(0xff9c27b0));
68 canvas->DrawRect(SkRect::MakeLTRB(187.5, 0, 375, 333.5), paint);
69 paint.setColor(DlColor(0xff4caf50));
70 canvas->DrawRect(SkRect::MakeLTRB(0, 333.5, 187.5, 667), paint);
71 paint.setColor(DlColor(0xfff44336));
72 canvas->DrawRect(SkRect::MakeLTRB(187.5, 333.5, 375, 667), paint);
73
74 canvas->Save();
75 {
76 canvas->ClipRRect(
77 SkRRect::MakeOval(SkRect::MakeLTRB(201.25, 10, 361.25, 170)),
78 DlCanvas::ClipOp::kIntersect, true);
79 SkRect save_layer_bounds = SkRect::MakeLTRB(201.25, 10, 361.25, 170);
81 0, 3, -920, //
82 0, 0, 1),
84 canvas->SaveLayer(&save_layer_bounds, /*paint=*/nullptr, &backdrop);
85 {
86 canvas->Translate(201.25, 10);
87 auto paint = DlPaint()
88 .setAntiAlias(true)
89 .setColor(DlColor(0xff2196f3))
91 .setDrawStyle(DlDrawStyle::kStroke);
92 canvas->DrawCircle(SkPoint::Make(80, 80), 80, paint);
93 }
94 canvas->Restore();
95 }
96 canvas->Restore();
97 };
98
99 DisplayListBuilder builder;
100 std::vector<sk_sp<DlImage>> images;
102
103 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
104}
static SkRRect MakeOval(const SkRect &oval)
Definition: SkRRect.h:162
virtual void Scale(SkScalar sx, SkScalar sy)=0
virtual void SaveLayer(const SkRect *bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr)=0
virtual void Restore()=0
virtual void ClipRRect(const SkRRect &rrect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false)=0
virtual void Save()=0
std::array< MockImage, 3 > images
Definition: mock_vulkan.cc:41

◆ TEST_P() [2/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
CanDrawPaint   
)

Definition at line 23 of file dl_golden_unittests.cc.

23 {
24 auto draw = [](DlCanvas* canvas,
25 const std::vector<std::unique_ptr<DlImage>>& images) {
26 canvas->Scale(0.2, 0.2);
28 paint.setColor(DlColor::kCyan());
29 canvas->DrawPaint(paint);
30 };
31
33 draw(&builder, /*images=*/{});
34
35 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
36}
virtual void DrawPaint(const DlPaint &paint)=0

◆ TEST_P() [3/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
CanRenderImage   
)

Definition at line 38 of file dl_golden_unittests.cc.

38 {
39 auto draw = [](DlCanvas* canvas, const std::vector<sk_sp<DlImage>>& images) {
40 FML_CHECK(images.size() >= 1);
42 paint.setColor(DlColor::kRed());
43 canvas->DrawImage(images[0], SkPoint::Make(100.0, 100.0),
45 };
46
48 std::vector<sk_sp<DlImage>> images;
49 images.emplace_back(CreateDlImageForFixture("kalimba.jpg"));
51
52 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
53}
virtual void DrawImage(const sk_sp< DlImage > &image, const SkPoint point, DlImageSampling sampling, const DlPaint *paint=nullptr)=0

◆ TEST_P() [4/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
DashedLinesTest   
)

Definition at line 185 of file dl_golden_unittests.cc.

185 {
186 Point content_scale = GetContentScale();
187 auto draw = [content_scale](DlCanvas* canvas,
188 const std::vector<sk_sp<DlImage>>& images) {
189 canvas->Scale(content_scale.x, content_scale.y);
191
192 auto draw_one = [canvas](DlStrokeCap cap, Scalar x, Scalar y,
193 Scalar dash_on, Scalar dash_off) {
194 Point center = Point(x, y);
195 Scalar inner = 20.0f;
196 Scalar outer = 100.0f;
197 DlPaint thick_paint = DlPaint()
199 .setStrokeCap(cap)
200 .setStrokeWidth(8.0f);
201 DlPaint middle_paint = DlPaint()
203 .setStrokeCap(cap)
204 .setStrokeWidth(5.0f);
205 DlPaint thin_paint = DlPaint()
207 .setStrokeCap(cap)
208 .setStrokeWidth(2.0f);
209 for (int degrees = 0; degrees < 360; degrees += 30) {
210 Point delta = Point(1.0f, 0.0f).Rotate(Degrees(degrees));
211 canvas->DrawDashedLine(center + inner * delta, center + outer * delta,
212 dash_on, dash_off, thick_paint);
213 canvas->DrawDashedLine(center + inner * delta, center + outer * delta,
214 dash_on, dash_off, middle_paint);
215 canvas->DrawDashedLine(center + inner * delta, center + outer * delta,
216 dash_on, dash_off, thin_paint);
217 }
218 };
219
220 draw_one(DlStrokeCap::kButt, 150.0f, 150.0f, 15.0f, 10.0f);
221 draw_one(DlStrokeCap::kSquare, 400.0f, 150.0f, 15.0f, 10.0f);
222 draw_one(DlStrokeCap::kRound, 150.0f, 400.0f, 15.0f, 10.0f);
223 draw_one(DlStrokeCap::kRound, 400.0f, 400.0f, 0.0f, 11.0f);
224
225 // Make sure the rendering op responds appropriately to clipping
226 canvas->Save();
227 SkPath clip_path = SkPath();
228 clip_path.moveTo(275.0f, 225.0f);
229 clip_path.lineTo(325.0f, 275.0f);
230 clip_path.lineTo(275.0f, 325.0f);
231 clip_path.lineTo(225.0f, 275.0f);
232 canvas->ClipPath(clip_path);
233 canvas->DrawColor(DlColor::kYellow());
234 draw_one(DlStrokeCap::kRound, 275.0f, 275.0f, 15.0f, 10.0f);
235 canvas->Restore();
236 };
237
238 DisplayListBuilder builder;
239 std::vector<sk_sp<DlImage>> images;
241
242 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
243}
virtual void DrawColor(DlColor color, DlBlendMode mode=DlBlendMode::kSrcOver)=0
virtual void DrawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length, const DlPaint &paint)=0
virtual void ClipPath(const SkPath &path, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false)=0
DlStrokeCap
Definition: dl_paint.h:28
float Scalar
Definition: scalar.h:18
constexpr TPoint Rotate(const Radians &angle) const
Definition: point.h:226

◆ TEST_P() [5/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
GaussianVsRRectBlur   
)

Definition at line 131 of file dl_golden_unittests.cc.

131 {
132 Point content_scale = GetContentScale();
133 auto draw = [content_scale](DlCanvas* canvas,
134 const std::vector<sk_sp<DlImage>>& images) {
135 canvas->Scale(content_scale.x, content_scale.y);
136 canvas->DrawPaint(DlPaint().setColor(DlColor(0xff112233)));
137 DrawBlurGrid(canvas);
138 };
139
141 std::vector<sk_sp<DlImage>> images;
143
144 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
145}

◆ TEST_P() [6/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
GaussianVsRRectBlurScaled   
)

Definition at line 147 of file dl_golden_unittests.cc.

147 {
148 Point content_scale = GetContentScale();
149 auto draw = [content_scale](DlCanvas* canvas,
150 const std::vector<sk_sp<DlImage>>& images) {
151 canvas->Scale(content_scale.x, content_scale.y);
152 canvas->DrawPaint(DlPaint().setColor(DlColor(0xff112233)));
153 canvas->Scale(0.33, 0.33);
154 DrawBlurGrid(canvas);
155 };
156
158 std::vector<sk_sp<DlImage>> images;
160
161 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
162}

◆ TEST_P() [7/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
GaussianVsRRectBlurScaledRotated   
)

Definition at line 164 of file dl_golden_unittests.cc.

164 {
165 Point content_scale = GetContentScale();
166 auto draw = [content_scale](DlCanvas* canvas,
167 const std::vector<sk_sp<DlImage>>& images) {
168 canvas->Scale(content_scale.x, content_scale.y);
169 canvas->Translate(200, 200);
170 canvas->DrawPaint(DlPaint().setColor(DlColor(0xff112233)));
171 canvas->Scale(0.33, 0.33);
172 canvas->Translate(300, 300);
173 canvas->Rotate(45);
174 canvas->Translate(-300, -300);
175 DrawBlurGrid(canvas);
176 };
177
179 std::vector<sk_sp<DlImage>> images;
181
182 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
183}
virtual void Rotate(SkScalar degrees)=0

◆ TEST_P() [8/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
TextBlurMaskFilterDisrespectCTM   
)

Definition at line 86 of file dl_golden_blur_unittests.cc.

86 {
87 impeller::Point content_scale = GetContentScale();
88 auto draw = [&](DlCanvas* canvas,
89 const std::vector<std::unique_ptr<DlImage>>& images) {
90 canvas->DrawColor(DlColor(0xff111111));
91 canvas->Scale(content_scale.x, content_scale.y);
92 canvas->Scale(2, 2);
93 TextRenderOptions options;
94 options.mask_filter =
96 /*respect_ctm=*/false);
97 ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
98 "Roboto-Regular.ttf",
99 SkPoint::Make(101, 101), options));
100 options.mask_filter = nullptr;
101 options.color = DlColor::kRed();
102 ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
103 "Roboto-Regular.ttf",
104 SkPoint::Make(100, 100), options));
105 };
106
108 draw(&builder, /*images=*/{});
109
110 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
111}
bool RenderTextInCanvasSkia(const std::shared_ptr< Context > &context, Canvas &canvas, const std::string &text, const std::string_view &font_fixture, TextRenderOptions options={})

◆ TEST_P() [9/15]

flutter::testing::TEST_P ( DlGoldenTest  ,
TextBlurMaskFilterRespectCTM   
)

Definition at line 59 of file dl_golden_blur_unittests.cc.

59 {
60 impeller::Point content_scale = GetContentScale();
61 auto draw = [&](DlCanvas* canvas,
62 const std::vector<std::unique_ptr<DlImage>>& images) {
63 canvas->DrawColor(DlColor(0xff111111));
64 canvas->Scale(content_scale.x, content_scale.y);
65 canvas->Scale(2, 2);
66 TextRenderOptions options;
67 options.mask_filter =
69 /*respect_ctm=*/true);
70 ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
71 "Roboto-Regular.ttf",
72 SkPoint::Make(101, 101), options));
73 options.mask_filter = nullptr;
74 options.color = DlColor::kRed();
75 ASSERT_TRUE(RenderTextInCanvasSkia(canvas, "hello world",
76 "Roboto-Regular.ttf",
77 SkPoint::Make(100, 100), options));
78 };
79
81 draw(&builder, /*images=*/{});
82
83 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
84}

◆ TEST_P() [10/15]

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() [11/15]

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
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() [12/15]

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
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 {
1730 platform_view.struct_size = sizeof(platform_view);
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() [13/15]

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
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() [14/15]

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
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 {
2245 platform_view.struct_size = sizeof(platform_view);
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() [15/15]

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
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 {
2567 platform_view.struct_size = sizeof(platform_view);
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,
const std::string &  file,
int  line 
)
static

Definition at line 2258 of file display_list_unittests.cc.

2263 {
2264 std::vector<int> indices;
2265 auto label = "from " + file + ":" + std::to_string(line);
2266 rtree->search(query, &indices);
2267 EXPECT_EQ(indices, expected_indices) << label;
2268 EXPECT_EQ(indices.size(), expected_indices.size()) << label;
2269 std::list<SkRect> rects = rtree->searchAndConsolidateRects(query, false);
2270 // ASSERT_EQ(rects.size(), expected_indices.size());
2271 auto iterator = rects.cbegin();
2272 for (int i : expected_indices) {
2273 ASSERT_TRUE(iterator != rects.cend()) << label;
2274 EXPECT_EQ(*iterator++, expected_rects[i]) << label;
2275 }
2276}

◆ 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) {
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)
Definition: dl_comparable.h:70

◆ 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 53 of file input_events_unittests.cc.

60 {
61 ///// Begin constructing shell ///////////////////////////////////////////////
62 auto settings = fixture->CreateSettingsForFixture();
63 std::unique_ptr<Shell> shell = fixture->CreateShell({
64 .settings = settings,
65 .platform_view_create_callback = ShellTestPlatformViewBuilder({
66 .simulate_vsync = true,
67 }),
68 });
69
70 auto configuration = RunConfiguration::InferFromSettings(settings);
71 configuration.SetEntrypoint("onPointerDataPacketMain");
72
73 // The following 4 variables are only accessed in the UI thread by
74 // nativeOnPointerDataPacket and nativeOnBeginFrame between their
75 // initializations and `shell.reset()`.
76 events_consumed_at_frame.clear();
77 bool will_draw_new_frame = true;
78 int events_consumed = 0;
79 int frame_drawn = 0;
80 auto nativeOnPointerDataPacket = [&events_consumed_at_frame,
81 &will_draw_new_frame, &events_consumed,
82 &frame_drawn](Dart_NativeArguments args) {
83 events_consumed += 1;
84 if (will_draw_new_frame) {
85 frame_drawn += 1;
86 will_draw_new_frame = false;
87 events_consumed_at_frame.push_back(events_consumed);
88 } else {
89 events_consumed_at_frame.back() = events_consumed;
90 }
91 };
92 fixture->AddNativeCallback("NativeOnPointerDataPacket",
93 CREATE_NATIVE_ENTRY(nativeOnPointerDataPacket));
94
95 ASSERT_TRUE(configuration.IsValid());
96 fixture->RunEngine(shell.get(), std::move(configuration));
97
98 if (restart_engine) {
99 auto new_configuration = RunConfiguration::InferFromSettings(settings);
100 new_configuration.SetEntrypoint("onPointerDataPacketMain");
101 ASSERT_TRUE(new_configuration.IsValid());
102 fixture->RestartEngine(shell.get(), std::move(new_configuration));
103 }
104 ///// End constructing shell /////////////////////////////////////////////////
105
106 ASSERT_GE(base_latency, 0);
107
108 // Check that delivery_time satisfies our assumptions.
109 int continuous_frame_count = 0;
110 for (int i = 0; i < num_events; i += 1) {
111 // j is the frame index of event i if there were no latency.
112 int j = static_cast<int>((delivery_time(i) - base_latency) / frame_time);
113 if (j == continuous_frame_count) {
114 continuous_frame_count += 1;
115 }
116 double random_latency = delivery_time(i) - j * frame_time - base_latency;
117 ASSERT_GE(random_latency, 0);
118 ASSERT_LT(random_latency, frame_time);
119
120 // If there were no latency, there should be at least one event per frame.
121 // Hence j should never skip any integer less than continuous_frame_count.
122 ASSERT_LT(j, continuous_frame_count);
123 }
124
125 // This has to be running on a different thread than Platform thread to avoid
126 // dead locks.
127 auto simulation = std::async(std::launch::async, [&]() {
128 // i is the input event's index.
129 // j is the frame's index.
130 for (int i = 0, j = 0; i < num_events; j += 1) {
131 double t = j * frame_time;
132 while (i < num_events && delivery_time(i) <= t) {
133 // Use a different x every time for the pointer data converter to
134 // generate non-empty events.
135 ShellTest::DispatchFakePointerData(shell.get(), /*x=*/i);
136 i += 1;
137 }
138 ShellTest::VSyncFlush(shell.get(), &will_draw_new_frame);
139 }
140 // Finally, issue a vsync for the pending event that may be generated duing
141 // the last vsync.
142 ShellTest::VSyncFlush(shell.get(), &will_draw_new_frame);
143 });
144
145 simulation.wait();
146
147 TaskRunners task_runners = fixture->GetTaskRunnersForFixture();
149 task_runners.GetPlatformTaskRunner()->PostTask([&shell, &latch]() mutable {
150 shell.reset();
151 latch.Signal();
152 });
153 latch.Wait();
154
155 // Make sure that all events have been consumed so
156 // https://github.com/flutter/flutter/issues/40863 won't happen again.
157 ASSERT_GT(events_consumed_at_frame.size(), 0u);
158 ASSERT_EQ(events_consumed_at_frame.back(), num_events);
159}
void AddNativeCallback(const std::string &name, Dart_NativeFunction callback)
Definition: dart_fixture.cc:75
static void RunEngine(Shell *shell, RunConfiguration configuration)
Definition: shell_test.cc:104
Settings CreateSettingsForFixture() override
Definition: shell_test.cc:336
TaskRunners GetTaskRunnersForFixture()
Definition: shell_test.cc:355
std::unique_ptr< Shell > CreateShell(const Settings &settings, std::optional< TaskRunners > task_runners={})
Definition: shell_test.cc:369
static void RestartEngine(Shell *shell, RunConfiguration configuration)
Definition: shell_test.cc:118

◆ 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 {
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 159 of file pointer_data_packet_converter_unittests.cc.

160 {
161 for (size_t i = 0; i < packet->GetLength(); i++) {
162 PointerData pointer_data = packet->GetPointerData(i);
163 output.push_back(pointer_data);
164 }
165 packet.reset();
166}

◆ UnserializeKeyEventDeviceType()

FlutterKeyEventDeviceType flutter::testing::UnserializeKeyEventDeviceType ( uint64_t  source)

Definition at line 2874 of file embedder_unittests.cc.

2874 {
2875 switch (source) {
2876 case 1:
2878 case 2:
2880 case 3:
2882 case 4:
2884 case 5:
2886 default:
2889 }
2890}
@ kFlutterKeyEventDeviceTypeDirectionalPad
Definition: embedder.h:1082
@ kFlutterKeyEventDeviceTypeHdmi
Definition: embedder.h:1085
@ kFlutterKeyEventDeviceTypeJoystick
Definition: embedder.h:1084
@ kFlutterKeyEventDeviceTypeGamepad
Definition: embedder.h:1083

◆ UnserializeKeyEventType()

FlutterKeyEventType flutter::testing::UnserializeKeyEventType ( uint64_t  kind)

Definition at line 2856 of file embedder_unittests.cc.

2856 {
2857 switch (kind) {
2858 case 1:
2860 case 2:
2862 case 3:
2864 default:
2867 }
2868}

◆ 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) {
621 case SkPath::Verb::kLine_Verb:
622 return "Lines";
623 case SkPath::Verb::kQuad_Verb:
624 return "Quads";
625 case SkPath::Verb::kConic_Verb:
626 return "Conics";
627 case SkPath::Verb::kCubic_Verb:
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>{
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(
2404 WmCharInfo{0x8, kScanCodeBackspace, kNotExtended, kWasUp}.Build(
2406 WmKeyUpInfo{VK_BACK, kScanCodeBackspace, kNotExtended}.Build(
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);
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);
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}

Variable Documentation

◆ allGroups

std::vector<testing::DisplayListInvocationGroup> flutter::testing::allGroups
static
Initial value:
=
std::vector< DisplayListInvocationGroup > CreateAllGroups()

Definition at line 47 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:

Definition at line 30 of file dl_test_snippets.h.

◆ 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.

◆ kEmojiFontFile

const std::string flutter::testing::kEmojiFontFile
static
Initial value:
=
"NotoColorEmoji.ttf"

Definition at line 22 of file paragraph_unittests.cc.

◆ kEmojiFontName

const std::string flutter::testing::kEmojiFontName
static
Initial value:
=
"Noto Color Emoji"

Definition at line 29 of file paragraph_unittests.cc.

◆ kEmptyDlRenderer

const DlRenderer flutter::testing::kEmptyDlRenderer = [](const DlRenderContext&) {}
static

Definition at line 363 of file dl_rendering_unittests.cc.

◆ kEmptyDlSetup

const DlSetup flutter::testing::kEmptyDlSetup = [](const DlSetupContext&) {}
static

Definition at line 362 of file dl_rendering_unittests.cc.

◆ 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 361 of file dl_rendering_unittests.cc.

◆ kEmptySkSetup

const SkSetup flutter::testing::kEmptySkSetup = [](const SkSetupContext&) {}
static

Definition at line 360 of file dl_rendering_unittests.cc.

◆ kEndPoints

constexpr SkPoint flutter::testing::kEndPoints[]
constexpr
Initial value:
= {
{0, 0},
{100, 100},
}

Definition at line 26 of file dl_test_snippets.h.

◆ 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:

Definition at line 155 of file dl_rendering_unittests.cc.

◆ kHorizontalMiterDiamondPoints

const SkPoint flutter::testing::kHorizontalMiterDiamondPoints[]

◆ 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 48 of file dl_test_snippets.h.

◆ 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 65 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.

◆ kMiter10DiamondOffsetX

constexpr SkScalar flutter::testing::kMiter10DiamondOffsetX = kRenderHeight * 0.051
constexpr

Definition at line 79 of file dl_rendering_unittests.cc.

◆ kMiter10DiamondOffsetY

constexpr SkScalar flutter::testing::kMiter10DiamondOffsetY = kRenderWidth * 0.051
constexpr

Definition at line 85 of file dl_rendering_unittests.cc.

◆ kMiter4DiamondOffsetX

constexpr SkScalar flutter::testing::kMiter4DiamondOffsetX = kRenderHeight * 0.14
constexpr

Definition at line 80 of file dl_rendering_unittests.cc.

◆ kMiter4DiamondOffsetY

constexpr SkScalar flutter::testing::kMiter4DiamondOffsetY = kRenderWidth * 0.14
constexpr

Definition at line 86 of file dl_rendering_unittests.cc.

◆ kMiterExtremeDiamondOffsetX

constexpr SkScalar flutter::testing::kMiterExtremeDiamondOffsetX = kRenderHeight * 0.04
constexpr

Definition at line 78 of file dl_rendering_unittests.cc.

◆ kMiterExtremeDiamondOffsetY

constexpr SkScalar flutter::testing::kMiterExtremeDiamondOffsetY = kRenderWidth * 0.04
constexpr

Definition at line 84 of file dl_rendering_unittests.cc.

◆ kNearestSampling

DlImageSampling flutter::testing::kNearestSampling = DlImageSampling::kNearestNeighbor
static

Definition at line 64 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 57 of file dl_rendering_unittests.cc.

◆ kRenderBounds

constexpr SkRect flutter::testing::kRenderBounds
constexpr

◆ kRenderCenterX

constexpr int flutter::testing::kRenderCenterX = (kRenderLeft + kRenderRight) / 2
constexpr

Definition at line 58 of file dl_rendering_unittests.cc.

◆ kRenderCenterY

constexpr int flutter::testing::kRenderCenterY = (kRenderTop + kRenderBottom) / 2
constexpr

Definition at line 59 of file dl_rendering_unittests.cc.

◆ kRenderCornerRadius

constexpr SkScalar flutter::testing::kRenderCornerRadius = kRenderRadius / 5.0
constexpr

Definition at line 61 of file dl_rendering_unittests.cc.

◆ kRenderHalfHeight

constexpr int flutter::testing::kRenderHalfHeight = 50
constexpr

Definition at line 53 of file dl_rendering_unittests.cc.

◆ kRenderHalfWidth

constexpr int flutter::testing::kRenderHalfWidth = 50
constexpr

Definition at line 52 of file dl_rendering_unittests.cc.

◆ kRenderHeight

constexpr int flutter::testing::kRenderHeight = 100
constexpr

Definition at line 51 of file dl_rendering_unittests.cc.

◆ kRenderLeft

constexpr int flutter::testing::kRenderLeft = (kTestWidth - kRenderWidth) / 2
constexpr

Definition at line 54 of file dl_rendering_unittests.cc.

◆ kRenderRadius

constexpr SkScalar flutter::testing::kRenderRadius = std::min(kRenderWidth, kRenderHeight) / 2.0
constexpr

Definition at line 60 of file dl_rendering_unittests.cc.

◆ kRenderRight

constexpr int flutter::testing::kRenderRight = kRenderLeft + kRenderWidth
constexpr

Definition at line 56 of file dl_rendering_unittests.cc.

◆ kRenderTop

constexpr int flutter::testing::kRenderTop = (kTestHeight - kRenderHeight) / 2
constexpr

Definition at line 55 of file dl_rendering_unittests.cc.

◆ kRenderWidth

constexpr int flutter::testing::kRenderWidth = 100
constexpr

Definition at line 50 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 42 of file dl_test_snippets.h.

◆ 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 35 of file dl_test_snippets.h.

◆ 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.

◆ 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 179 of file dl_test_snippets.h.

◆ kTestBounds2

constexpr SkRect flutter::testing::kTestBounds2 = SkRect::MakeWH(kTestWidth, kTestHeight)
constexpr

Definition at line 64 of file dl_rendering_unittests.cc.

◆ kTestCenter

constexpr SkPoint flutter::testing::kTestCenter = SkPoint::Make(kTestWidth / 2, kTestHeight / 2)
constexpr

Definition at line 63 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.

◆ kTestColors [2/2]

constexpr DlColor flutter::testing::kTestColors[kTestStopCount]
staticconstexpr
Initial value:

Definition at line 60 of file dl_color_source_unittests.cc.

◆ kTestHeight

constexpr int flutter::testing::kTestHeight = 200
constexpr

Definition at line 49 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 182 of file dl_test_snippets.h.

◆ kTestLinearGradient

const auto flutter::testing::kTestLinearGradient
static
Initial value:
=
SkPoint::Make(100.0f, 100.0f),
2,
DlTileMode::kClamp,
nullptr)
static const float kTestStops[2]
static const DlColor kTestColors[2]

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 192 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 193 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:3614

Definition at line 186 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 188 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 190 of file dl_test_snippets.h.

◆ kTestPathOval

const SkPath flutter::testing::kTestPathOval = SkPath::Oval(kTestBounds)
static

Definition at line 185 of file dl_test_snippets.h.

◆ kTestPathRect

const SkPath flutter::testing::kTestPathRect = SkPath::Rect(kTestBounds)
static

Definition at line 184 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.

◆ 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.

◆ kTestRRect

const SkRRect flutter::testing::kTestRRect = SkRRect::MakeRectXY(kTestBounds, 5, 5)
static

Definition at line 180 of file dl_test_snippets.h.

◆ kTestRRectRect

const SkRRect flutter::testing::kTestRRectRect = SkRRect::MakeRect(kTestBounds)
static

Definition at line 181 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:
=
3,
DlTileMode::kMirror)
constexpr float kStops[]
constexpr SkPoint kEndPoints[]
const DlColor kColors[]

Definition at line 95 of file dl_test_snippets.h.

◆ kTestSource3

const std::shared_ptr<DlColorSource> flutter::testing::kTestSource3
static
Initial value:
=
10.0,
3,
DlTileMode::kMirror)

Definition at line 102 of file dl_test_snippets.h.

◆ kTestSource4

const std::shared_ptr<DlColorSource> flutter::testing::kTestSource4
static
Initial value:
=
10.0,
200.0,
3,
DlTileMode::kDecal)

Definition at line 109 of file dl_test_snippets.h.

◆ kTestSource5

const std::shared_ptr<DlColorSource> flutter::testing::kTestSource5
static
Initial value:
=
0.0,
360.0,
3,
DlTileMode::kDecal)

Definition at line 118 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.

◆ 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.

◆ 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.

◆ kTestWidth

constexpr int flutter::testing::kTestWidth = 200
constexpr

Definition at line 48 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:

Definition at line 124 of file dl_rendering_unittests.cc.

◆ kVerticalMiterDiamondPoints

constexpr SkPoint flutter::testing::kVerticalMiterDiamondPoints[]
constexpr

◆ 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 93 of file dl_rendering_unittests.cc.

◆ kXOffsetL1

constexpr SkScalar flutter::testing::kXOffsetL1 = kXOffset0 - kMiter4DiamondOffsetX
constexpr

Definition at line 94 of file dl_rendering_unittests.cc.

◆ kXOffsetL2

constexpr SkScalar flutter::testing::kXOffsetL2 = kXOffsetL1 - kMiter10DiamondOffsetX
constexpr

Definition at line 95 of file dl_rendering_unittests.cc.

◆ kXOffsetL3

constexpr SkScalar flutter::testing::kXOffsetL3 = kXOffsetL2 - kMiter10DiamondOffsetX
constexpr

Definition at line 96 of file dl_rendering_unittests.cc.

◆ kXOffsetR1

constexpr SkScalar flutter::testing::kXOffsetR1 = kXOffset0 + kMiter4DiamondOffsetX
constexpr

Definition at line 97 of file dl_rendering_unittests.cc.

◆ kXOffsetR2

constexpr SkScalar flutter::testing::kXOffsetR2 = kXOffsetR1 + kMiterExtremeDiamondOffsetX
constexpr

Definition at line 98 of file dl_rendering_unittests.cc.

◆ kXOffsetR3

constexpr SkScalar flutter::testing::kXOffsetR3 = kXOffsetR2 + kMiterExtremeDiamondOffsetX
constexpr

Definition at line 99 of file dl_rendering_unittests.cc.

◆ kYOffset0

constexpr SkScalar flutter::testing::kYOffset0 = kRenderCenterY + 0.5
constexpr

Definition at line 128 of file dl_rendering_unittests.cc.

◆ kYOffsetD1

constexpr SkScalar flutter::testing::kYOffsetD1 = kXOffset0 + kMiter4DiamondOffsetY
constexpr

Definition at line 132 of file dl_rendering_unittests.cc.

◆ kYOffsetD2

constexpr SkScalar flutter::testing::kYOffsetD2 = kYOffsetD1 + kMiterExtremeDiamondOffsetY
constexpr

Definition at line 133 of file dl_rendering_unittests.cc.

◆ kYOffsetD3

constexpr SkScalar flutter::testing::kYOffsetD3 = kYOffsetD2 + kMiterExtremeDiamondOffsetY
constexpr

Definition at line 134 of file dl_rendering_unittests.cc.

◆ kYOffsetU1

constexpr SkScalar flutter::testing::kYOffsetU1 = kXOffset0 - kMiter4DiamondOffsetY
constexpr

Definition at line 129 of file dl_rendering_unittests.cc.

◆ kYOffsetU2

constexpr SkScalar flutter::testing::kYOffsetU2 = kYOffsetU1 - kMiter10DiamondOffsetY
constexpr

Definition at line 130 of file dl_rendering_unittests.cc.

◆ kYOffsetU3

constexpr SkScalar flutter::testing::kYOffsetU3 = kYOffsetU2 - kMiter10DiamondOffsetY
constexpr

Definition at line 131 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:

Definition at line 213 of file dl_test_snippets.h.

◆ TestDisplayList2

sk_sp<DisplayList> flutter::testing::TestDisplayList2
static
Initial value:

Definition at line 215 of file dl_test_snippets.h.

◆ TestImage1

auto flutter::testing::TestImage1 = MakeTestImage(40, 40, 5)
static

Definition at line 87 of file dl_test_snippets.h.

◆ TestImage2

auto flutter::testing::TestImage2 = MakeTestImage(50, 50, 5)
static

Definition at line 88 of file dl_test_snippets.h.

◆ TestSkImage

auto flutter::testing::TestSkImage = MakeTestImage(30, 30, 5)->skia_image()
static

Definition at line 89 of file dl_test_snippets.h.

◆ TestVertices1

std::shared_ptr<const DlVertices> flutter::testing::TestVertices1
static
Initial value:
=
DlVertices::Make(DlVertexMode::kTriangles,
3,
nullptr,

Definition at line 195 of file dl_test_snippets.h.

◆ TestVertices2

std::shared_ptr<const DlVertices> flutter::testing::TestVertices2
static
Initial value:
=
DlVertices::Make(DlVertexMode::kTriangleFan,
3,
nullptr,

Definition at line 201 of file dl_test_snippets.h.