Flutter Engine
flutter_runner::testing Namespace Reference

Classes

struct  BufferCollectionTokenPair
 
struct  FakeEntityNodeT
 
class  FakeFlatland
 
class  FakeFlatlandTest
 
class  FakeFocuser
 
struct  FakeGraph
 
struct  FakeImage
 
struct  FakeImageT
 
struct  FakeMaterialT
 
struct  FakeMemoryT
 
class  FakeMouseSource
 
struct  FakeNodeT
 
struct  FakeOpacityNodeT
 
class  FakePlatformMessageResponse
 
struct  FakeResourceT
 
struct  FakeSceneGraphT
 
class  FakeSession
 
class  FakeSessionTest
 
struct  FakeShapeNodeT
 
struct  FakeShapeT
 
class  FakeTouchSource
 
struct  FakeTransform
 
struct  FakeView
 
struct  FakeViewHolderT
 
struct  FakeViewport
 
class  FakeViewRefFocused
 
struct  FakeViewT
 
class  FlatlandConnectionTest
 
class  FlatlandExternalViewEmbedderTest
 
class  FlatlandPlatformViewTests
 
class  FocusDelegateTest
 
class  GfxExternalViewEmbedderTest
 
class  GfxSessionConnectionTest
 
class  PlatformViewTests
 
class  PointerDelegateTest
 
struct  SnapshotT
 
struct  StateT
 
class  TouchEventBuilder
 
struct  ViewTokenPair
 

Typedefs

using fup_EventPhase = fuchsia::ui::pointer::EventPhase
 
using fup_TouchEvent = fuchsia::ui::pointer::TouchEvent
 
using fup_TouchIxnId = fuchsia::ui::pointer::TouchInteractionId
 
using fup_TouchIxnResult = fuchsia::ui::pointer::TouchInteractionResult
 
using fup_TouchIxnStatus = fuchsia::ui::pointer::TouchInteractionStatus
 
using fup_TouchPointerSample = fuchsia::ui::pointer::TouchPointerSample
 
using fup_TouchResponse = fuchsia::ui::pointer::TouchResponse
 
using fup_TouchResponseType = fuchsia::ui::pointer::TouchResponseType
 
using fup_ViewParameters = fuchsia::ui::pointer::ViewParameters
 
using FakeContent = std::variant< FakeViewport, FakeImage >
 
using FakeResourceId = decltype(fuchsia::ui::gfx::CreateResourceCmd::id)
 
using FakeNodeState = FakeNodeT< StateT >
 
using FakeNode = FakeNodeT< SnapshotT >
 
using FakeEntityNodeState = FakeEntityNodeT< StateT >
 
using FakeEntityNode = FakeEntityNodeT< SnapshotT >
 
using FakeOpacityNodeState = FakeOpacityNodeT< StateT >
 
using FakeOpacityNode = FakeOpacityNodeT< SnapshotT >
 
using FakeShapeNodeState = FakeShapeNodeT< StateT >
 
using FakeShapeNode = FakeShapeNodeT< SnapshotT >
 
using FakeViewState = FakeViewT< StateT >
 
using FakeView = FakeViewT< SnapshotT >
 
using FakeViewHolderState = FakeViewHolderT< StateT >
 
using FakeViewHolder = FakeViewHolderT< SnapshotT >
 
using FakeShapeState = FakeShapeT< StateT >
 
using FakeShape = FakeShapeT< SnapshotT >
 
using FakeMaterialState = FakeMaterialT< StateT >
 
using FakeMaterial = FakeMaterialT< SnapshotT >
 
using FakeImageState = FakeImageT< StateT >
 
using FakeImage = FakeImageT< SnapshotT >
 
using FakeMemoryState = FakeMemoryT< StateT >
 
using FakeMemory = FakeMemoryT< SnapshotT >
 
using FakeResourceState = FakeResourceT< StateT >
 
using FakeResource = FakeResourceT< SnapshotT >
 
using FakeSceneGraphState = FakeSceneGraphT< StateT >
 
using FakeSceneGraph = FakeSceneGraphT< SnapshotT >
 

Functions

 TEST_F (FocusDelegateTest, WatchCallbackSeries)
 
 TEST_F (FocusDelegateTest, RequestFocusTest)
 
 TEST_F (FocusDelegateTest, RequestFocusFailTest)
 
 TEST_F (PlatformViewTests, InvalidPlatformMessageRequest)
 
 TEST_F (PlatformViewTests, CreateSurfaceTest)
 
 TEST_F (PlatformViewTests, SetViewportMetrics)
 
 TEST_F (PlatformViewTests, ChangesAccessibilitySettings)
 
 TEST_F (PlatformViewTests, EnableWireframeTest)
 
 TEST_F (PlatformViewTests, CreateViewTest)
 
 TEST_F (PlatformViewTests, UpdateViewTest)
 
 TEST_F (PlatformViewTests, DestroyViewTest)
 
 TEST_F (PlatformViewTests, ViewEventsTest)
 
 TEST_F (PlatformViewTests, GetFocusStatesTest)
 
 TEST_F (PlatformViewTests, RequestFocusTest)
 
 TEST_F (PlatformViewTests, RequestFocusFailTest)
 
 TEST_F (PlatformViewTests, OnKeyEvent)
 
 TEST_F (PlatformViewTests, OnShaderWarmup)
 
 TEST_F (PlatformViewTests, DISABLED_TouchSourceLogicalToPhysicalConversion)
 
 TEST_F (PlatformViewTests, DownPointerNumericNudge)
 
 TEST_F (PointerDelegateTest, Data_FuchsiaTimeVersusFlutterTime)
 
 TEST_F (PointerDelegateTest, Phase_FlutterPhasesAreSynthesized)
 
 TEST_F (PointerDelegateTest, Phase_FuchsiaCancelBecomesFlutterCancel)
 
 TEST_F (PointerDelegateTest, Coordinates_CorrectMapping)
 
 TEST_F (PointerDelegateTest, Coordinates_DownEventClampedToView)
 
 TEST_F (PointerDelegateTest, Protocol_FirstResponseIsEmpty)
 
 TEST_F (PointerDelegateTest, Protocol_ResponseMatchesEarlierEvents)
 
 TEST_F (PointerDelegateTest, Protocol_LateGrant)
 
 TEST_F (PointerDelegateTest, Protocol_LateGrantCombo)
 
 TEST_F (PointerDelegateTest, Protocol_EarlyGrant)
 
 TEST_F (PointerDelegateTest, Protocol_LateDeny)
 
 TEST_F (PointerDelegateTest, Protocol_LateDenyCombo)
 
 TEST_F (PointerDelegateTest, Protocol_PointersAreIndependent)
 
 TEST (EngineTest, ThreadNames)
 
 TEST_F (FakeFlatlandTest, Initialization)
 
 TEST_F (FakeFlatlandTest, DebugLabel)
 
 TEST_F (FakeFlatlandTest, Present)
 
 TEST_F (FakeSessionTest, Initialization)
 
 TEST_F (FakeSessionTest, DebugLabel)
 
 TEST_F (FakeSessionTest, CommandQueueInvariants)
 
 TEST_F (FakeSessionTest, SimpleResourceLifecycle)
 
 TEST_F (FakeSessionTest, ResourceReferenceCounting)
 
 TEST_F (FakeSessionTest, BasicSceneGraph)
 
template<typename ZX >
std::pair< zx_koid_t, zx_koid_t > GetKoids (const ZX &kobj)
 
template<typename F >
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fidl::InterfaceHandle< F > &interface_handle)
 
template<typename F >
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fidl::InterfaceRequest< F > &interface_request)
 
template<typename F >
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fidl::InterfacePtr< F > &interface_ptr)
 
template<typename F >
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fidl::Binding< F > &interface_binding)
 
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fuchsia::ui::views::ViewCreationToken &view_token)
 
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fuchsia::ui::views::ViewportCreationToken &viewport_token)
 
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fuchsia::ui::views::ViewRef &view_ref)
 
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fuchsia::ui::views::ViewRefControl &view_ref_control)
 
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fuchsia::ui::composition::BufferCollectionExportToken &buffer_collection_token)
 
std::pair< zx_koid_t, zx_koid_t > GetKoids (const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)
 
FakeSceneGraph SceneGraphFromState (const FakeSceneGraphState &state)
 
 TEST_F (FlatlandConnectionTest, Initialization)
 
 TEST_F (FlatlandConnectionTest, FlatlandDisconnect)
 
 TEST_F (FlatlandConnectionTest, BasicPresent)
 
 TEST_F (FlatlandConnectionTest, AwaitVsyncBeforePresent)
 
 TEST_F (FlatlandConnectionTest, OutOfOrderAwait)
 
 TEST_F (FlatlandConnectionTest, PresentCreditExhaustion)
 
 TEST_F (FlatlandExternalViewEmbedderTest, RootScene)
 
 TEST_F (FlatlandExternalViewEmbedderTest, SimpleScene)
 
 TEST_F (FlatlandExternalViewEmbedderTest, SceneWithOneView)
 
 TEST_F (FlatlandExternalViewEmbedderTest, SceneWithOneView_NoOverlay)
 
 TEST_F (FlatlandExternalViewEmbedderTest, SceneWithOneView_DestroyBeforeDrawing)
 
 TEST_F (FlatlandPlatformViewTests, InvalidPlatformMessageRequest)
 
 TEST_F (FlatlandPlatformViewTests, CreateSurfaceTest)
 
 TEST_F (FlatlandPlatformViewTests, SetViewportMetrics)
 
 TEST_F (FlatlandPlatformViewTests, ChangesAccessibilitySettings)
 
 TEST_F (FlatlandPlatformViewTests, EnableWireframeTest)
 
 TEST_F (FlatlandPlatformViewTests, CreateViewTest)
 
 TEST_F (FlatlandPlatformViewTests, UpdateViewTest)
 
 TEST_F (FlatlandPlatformViewTests, DestroyViewTest)
 
 TEST_F (FlatlandPlatformViewTests, GetFocusStatesTest)
 
 TEST_F (FlatlandPlatformViewTests, RequestFocusTest)
 
 TEST_F (FlatlandPlatformViewTests, RequestFocusNeverCreatedTest)
 
 TEST_F (FlatlandPlatformViewTests, RequestFocusDisposedTest)
 
 TEST_F (FlatlandPlatformViewTests, OnKeyEvent)
 
 TEST_F (FlatlandPlatformViewTests, OnShaderWarmup)
 
 TEST_F (FlatlandPlatformViewTests, TouchSourceLogicalToPhysicalConversion)
 
 TEST_F (GfxExternalViewEmbedderTest, RootScene)
 
 TEST_F (GfxExternalViewEmbedderTest, SimpleScene)
 
 TEST_F (GfxExternalViewEmbedderTest, SceneWithOneView)
 
 TEST_F (GfxExternalViewEmbedderTest, SimpleSceneDisjointHitRegions)
 
 TEST_F (GfxExternalViewEmbedderTest, SimpleSceneOverlappingHitRegions)
 
 TEST_F (GfxSessionConnectionTest, Initialization)
 
 TEST_F (GfxSessionConnectionTest, SessionDisconnect)
 
 TEST_F (GfxSessionConnectionTest, BasicPresent)
 
 TEST_F (GfxSessionConnectionTest, AwaitVsyncBackpressure)
 
 TEST_F (GfxSessionConnectionTest, PresentBackpressure)
 
 TEST (CalculateNextLatchPointTest, PresentAsSoonAsPossible)
 
 TEST (CalculateNextLatchPointTest, LongFrameBuildTime)
 
 TEST (CalculateNextLatchPointTest, DelayedPresentRequestWithLongFrameBuildTime)
 
 TEST (CalculateNextLatchPointTest, LastLastPointTargetedLate)
 
 TEST (CalculateNextLatchPointTest, SteadyState_OnTimeFrames)
 
 TEST (CalculateNextLatchPointTest, SteadyState_LongFrameBuildTimes)
 
 TEST (CalculateNextLatchPointTest, SteadyState_LateLastLatchPointTargeted)
 
 TEST (CalculateNextLatchPointTest, SteadyState_DelayedPresentRequestWithLongFrameBuildTime)
 
 TEST (CalculateNextLatchPointTest, SteadyState_FuzzyLatchPointsBeforeTarget)
 
 TEST (CalculateNextLatchPointTest, SteadyState_FuzzyLatchPointsAfterTarget)
 
 TEST (SnapToNextPhaseTest, SnapOverlapsWithNow)
 
 TEST (SnapToNextPhaseTest, SnapAfterNow)
 
 TEST (SnapToNextPhaseTest, SnapAfterNowMultiJump)
 
 TEST (SnapToNextPhaseTest, SnapAfterNowMultiJumpAccountForCeils)
 
 TEST (GetTargetTimesTest, ScheduleForNextVsync)
 
 TEST (GetTargetTimesTest, ScheduleForCurrentVsync_DueToOffset)
 
 TEST (GetTargetTimesTest, ScheduleForFollowingVsync_BecauseOfNow)
 
 TEST (GetTargetTimesTest, ScheduleForFollowingVsync_BecauseOfTargettedTime)
 
 TEST (GetTargetTimesTest, ScheduleForDistantVsync_BecauseOfTargettedTime)
 
 TEST (GetTargetTimesTest, ScheduleForFollowingVsync_WithSlightVsyncDrift)
 
 TEST (GetTargetTimesTest, ScheduleForAnOffsetFromVsync)
 
 TEST (GetTargetTimesTest, ScheduleMultipleTimes)
 
 TEST (GetTargetTimesTest, ScheduleMultipleTimes_WithDelayedWakeups)
 
 TEST (UpdatePresentationInfoTest, SingleUpdate)
 
 TEST (UpdatePresentationInfoTest, MultipleUpdates)
 

Variables

constexpr std::array< std::array< float, 2 >, 2 > kRect = {{{0, 0}, {20, 20}}}
 
constexpr std::array< float, 9 > kIdentity = {1, 0, 0, 0, 1, 0, 0, 0, 1}
 
constexpr fup_TouchIxnId kIxnOne
 
static constexpr fuchsia::ui::composition::TransformId kInvalidTransformId {0}
 
static constexpr fuchsia::ui::composition::ContentId kInvalidContentId {0}
 
constexpr FakeResourceId kInvalidFakeResourceId = 0u
 

Typedef Documentation

◆ FakeContent

Definition at line 162 of file fake_flatland_types.h.

◆ FakeEntityNode

◆ FakeEntityNodeState

◆ FakeImage

Definition at line 315 of file fake_resources.h.

◆ FakeImageState

Definition at line 314 of file fake_resources.h.

◆ FakeMaterial

◆ FakeMaterialState

◆ FakeMemory

Definition at line 330 of file fake_resources.h.

◆ FakeMemoryState

Definition at line 329 of file fake_resources.h.

◆ FakeNode

Definition at line 135 of file fake_resources.h.

◆ FakeNodeState

Definition at line 134 of file fake_resources.h.

◆ FakeOpacityNode

◆ FakeOpacityNodeState

◆ FakeResource

◆ FakeResourceId

◆ FakeResourceState

◆ FakeSceneGraph

◆ FakeSceneGraphState

◆ FakeShape

Definition at line 256 of file fake_resources.h.

◆ FakeShapeNode

◆ FakeShapeNodeState

◆ FakeShapeState

Definition at line 255 of file fake_resources.h.

◆ FakeView

Definition at line 204 of file fake_resources.h.

◆ FakeViewHolder

◆ FakeViewHolderState

◆ FakeViewState

Definition at line 203 of file fake_resources.h.

◆ fup_EventPhase

typedef fuchsia::ui::pointer::EventPhase flutter_runner::testing::fup_EventPhase

Definition at line 24 of file pointer_delegate_unittests.cc.

◆ fup_TouchEvent

typedef fuchsia::ui::pointer::TouchEvent flutter_runner::testing::fup_TouchEvent

Definition at line 25 of file pointer_delegate_unittests.cc.

◆ fup_TouchIxnId

typedef fuchsia::ui::pointer::TouchInteractionId flutter_runner::testing::fup_TouchIxnId

Definition at line 26 of file pointer_delegate_unittests.cc.

◆ fup_TouchIxnResult

typedef fuchsia::ui::pointer::TouchInteractionResult flutter_runner::testing::fup_TouchIxnResult

Definition at line 27 of file pointer_delegate_unittests.cc.

◆ fup_TouchIxnStatus

using flutter_runner::testing::fup_TouchIxnStatus = typedef fuchsia::ui::pointer::TouchInteractionStatus

Definition at line 28 of file pointer_delegate_unittests.cc.

◆ fup_TouchPointerSample

typedef fuchsia::ui::pointer::TouchPointerSample flutter_runner::testing::fup_TouchPointerSample

Definition at line 29 of file pointer_delegate_unittests.cc.

◆ fup_TouchResponse

using flutter_runner::testing::fup_TouchResponse = typedef fuchsia::ui::pointer::TouchResponse

Definition at line 30 of file pointer_delegate_unittests.cc.

◆ fup_TouchResponseType

using flutter_runner::testing::fup_TouchResponseType = typedef fuchsia::ui::pointer::TouchResponseType

Definition at line 31 of file pointer_delegate_unittests.cc.

◆ fup_ViewParameters

typedef fuchsia::ui::pointer::ViewParameters flutter_runner::testing::fup_ViewParameters

Definition at line 32 of file pointer_delegate_unittests.cc.

Function Documentation

◆ GetKoids() [1/11]

template<typename ZX >
std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const ZX &  kobj)

Definition at line 199 of file fake_flatland_types.h.

Referenced by flutter_runner::testing::FakeFlatland::FireOnFramePresentedEvent(), and GetKoids().

199  {
200  zx_info_handle_basic_t info;
201  zx_status_t status =
202  kobj.get_info(ZX_INFO_HANDLE_BASIC, &info, sizeof(info),
203  /*actual_records*/ nullptr, /*avail_records*/ nullptr);
204  return status == ZX_OK ? std::make_pair(info.koid, info.related_koid)
205  : std::make_pair(zx_koid_t{}, zx_koid_t{});
206 }
Definition: ref_ptr.h:255

◆ GetKoids() [2/11]

template<typename F >
std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fidl::InterfaceHandle< F > &  interface_handle)

Definition at line 209 of file fake_flatland_types.h.

References GetKoids().

210  {
211  return GetKoids(interface_handle.channel());
212 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [3/11]

template<typename F >
std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fidl::InterfaceRequest< F > &  interface_request)

Definition at line 215 of file fake_flatland_types.h.

References GetKoids().

216  {
217  return GetKoids(interface_request.channel());
218 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [4/11]

template<typename F >
std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fidl::InterfacePtr< F > &  interface_ptr)

Definition at line 221 of file fake_flatland_types.h.

References GetKoids().

222  {
223  return GetKoids(interface_ptr.channel());
224 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [5/11]

template<typename F >
std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fidl::Binding< F > &  interface_binding)

Definition at line 227 of file fake_flatland_types.h.

References GetKoids().

228  {
229  return GetKoids(interface_binding.channel());
230 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [6/11]

std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fuchsia::ui::views::ViewCreationToken &  view_token)
inline

Definition at line 232 of file fake_flatland_types.h.

References GetKoids().

233  {
234  return GetKoids(view_token.value);
235 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [7/11]

std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fuchsia::ui::views::ViewportCreationToken &  viewport_token)
inline

Definition at line 237 of file fake_flatland_types.h.

References GetKoids().

238  {
239  return GetKoids(viewport_token.value);
240 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [8/11]

std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fuchsia::ui::views::ViewRef &  view_ref)
inline

Definition at line 242 of file fake_flatland_types.h.

References GetKoids().

243  {
244  return GetKoids(view_ref.reference);
245 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [9/11]

std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fuchsia::ui::views::ViewRefControl &  view_ref_control)
inline

Definition at line 247 of file fake_flatland_types.h.

References GetKoids().

248  {
249  return GetKoids(view_ref_control.reference);
250 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [10/11]

std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fuchsia::ui::composition::BufferCollectionExportToken &  buffer_collection_token)
inline

Definition at line 252 of file fake_flatland_types.h.

References GetKoids().

254  {
255  return GetKoids(buffer_collection_token.value);
256 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ GetKoids() [11/11]

std::pair<zx_koid_t, zx_koid_t> flutter_runner::testing::GetKoids ( const fuchsia::ui::composition::BufferCollectionImportToken &  buffer_collection_token)
inline

Definition at line 258 of file fake_flatland_types.h.

References GetKoids().

260  {
261  return GetKoids(buffer_collection_token.value);
262 }
std::pair< zx_koid_t, zx_koid_t > GetKoids(const fuchsia::ui::composition::BufferCollectionImportToken &buffer_collection_token)

◆ SceneGraphFromState()

FakeSceneGraph flutter_runner::testing::SceneGraphFromState ( const FakeSceneGraphState state)

Definition at line 272 of file fake_resources.cc.

References flutter_runner::testing::FakeSceneGraphT< S >::buffer_collection_map, FML_CHECK, flutter_runner::testing::FakeSceneGraphT< S >::label_map, flutter_runner::testing::FakeSceneGraphT< S >::resource_map, and flutter_runner::testing::FakeSceneGraphT< S >::root_view_id.

Referenced by flutter_runner::testing::FakeSession::SceneGraph().

272  {
273  FakeResourceCache resource_cache;
274  FakeSceneGraph scene_graph;
275 
276  // Snapshot all buffer collections.
277  for (auto& buffer_collection : state.buffer_collection_map) {
278  scene_graph.buffer_collection_map.emplace(
279  std::make_pair(buffer_collection.first, buffer_collection.second.koid));
280  }
281 
282  // Snapshot resources in the map recursively.
283  for (auto& resource : state.resource_map) {
284  scene_graph.resource_map.emplace(std::make_pair(
285  resource.first, ResourceFromState(resource.second, resource_cache)));
286  }
287 
288  // Snapshot labels in the map.
289  for (auto& label_resources : state.label_map) {
290  auto [label_iter, label_success] =
291  scene_graph.label_map.emplace(std::make_pair(
292  label_resources.first, std::vector<std::weak_ptr<FakeResource>>()));
293  FML_CHECK(label_success);
294  auto& snapshot_label_resources = label_iter->second;
295 
296  for (auto& resource : label_resources.second) {
297  auto resource_ptr = resource.lock();
298  FML_CHECK(resource_ptr);
299 
300  snapshot_label_resources.emplace_back(
301  ResourceFromState(resource_ptr, resource_cache));
302  }
303  }
304 
305  // Snapshot the view id.
306  scene_graph.root_view_id = state.root_view_id;
307 
308  return scene_graph;
309 }
FakeSceneGraphT< SnapshotT > FakeSceneGraph
#define FML_CHECK(condition)
Definition: logging.h:68
AtkStateType state

◆ TEST() [1/26]

flutter_runner::testing::TEST ( EngineTest  ,
ThreadNames   
)

Definition at line 23 of file engine_unittests.cc.

References flutter::testing::GetCurrentTestName(), flutter::ThreadHost::io_thread, flutter::ThreadHost::platform_thread, flutter::ThreadHost::raster_thread, and flutter::ThreadHost::ui_thread.

23  {
24  std::string prefix = GetCurrentTestName();
25  flutter::ThreadHost engine_thread_host = Engine::CreateThreadHost(prefix);
26 
27  char thread_name[ZX_MAX_NAME_LEN];
28  zx::thread::self()->get_property(ZX_PROP_NAME, thread_name,
29  sizeof(thread_name));
30  EXPECT_EQ(std::string(thread_name), prefix + std::string(".platform"));
31  EXPECT_EQ(engine_thread_host.platform_thread, nullptr);
32 
33  engine_thread_host.raster_thread->GetTaskRunner()->PostTask([&prefix]() {
34  char thread_name[ZX_MAX_NAME_LEN];
35  zx::thread::self()->get_property(ZX_PROP_NAME, thread_name,
36  sizeof(thread_name));
37  EXPECT_EQ(std::string(thread_name), prefix + std::string(".raster"));
38  });
39  engine_thread_host.raster_thread->Join();
40 
41  engine_thread_host.ui_thread->GetTaskRunner()->PostTask([&prefix]() {
42  char thread_name[ZX_MAX_NAME_LEN];
43  zx::thread::self()->get_property(ZX_PROP_NAME, thread_name,
44  sizeof(thread_name));
45  EXPECT_EQ(std::string(thread_name), prefix + std::string(".ui"));
46  });
47  engine_thread_host.ui_thread->Join();
48 
49  engine_thread_host.io_thread->GetTaskRunner()->PostTask([&prefix]() {
50  char thread_name[ZX_MAX_NAME_LEN];
51  zx::thread::self()->get_property(ZX_PROP_NAME, thread_name,
52  sizeof(thread_name));
53  EXPECT_EQ(std::string(thread_name), prefix + std::string(".io"));
54  });
55  engine_thread_host.io_thread->Join();
56 }
std::unique_ptr< fml::Thread > ui_thread
Definition: thread_host.h:84
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:13
The collection of all the threads used by the engine.
Definition: thread_host.h:21
std::unique_ptr< fml::Thread > io_thread
Definition: thread_host.h:86
std::unique_ptr< fml::Thread > raster_thread
Definition: thread_host.h:85
std::unique_ptr< fml::Thread > platform_thread
Definition: thread_host.h:83

◆ TEST() [2/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
PresentAsSoonAsPossible   
)

Definition at line 448 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

448  {
449  fml::TimePoint present_requested_time = TimePointFromInt(0);
450  fml::TimePoint now = TimePointFromInt(0);
451  fml::TimePoint last_latch_point_targeted = TimePointFromInt(0);
452  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(0);
453  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
454  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
455  future_presentation_infos = {};
456 
457  // Assertions about given values.
458  EXPECT_GE(now, present_requested_time);
459  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
460  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
461 
462  fml::TimePoint calculated_latch_point =
463  GfxSessionConnection::CalculateNextLatchPoint(
464  present_requested_time, now, last_latch_point_targeted,
465  flutter_frame_build_time, vsync_interval, future_presentation_infos);
466 
467  EXPECT_GE(TimePointToInt(calculated_latch_point), TimePointToInt(now));
468  EXPECT_LE(TimePointToInt(calculated_latch_point),
469  TimePointToInt(now + vsync_interval));
470 
471  EXPECT_GE(TimePointToInt(calculated_latch_point),
472  TimePointToInt(present_requested_time + flutter_frame_build_time));
473  EXPECT_GE(TimePointToInt(calculated_latch_point),
474  TimePointToInt(last_latch_point_targeted));
475 }

◆ TEST() [3/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
LongFrameBuildTime   
)

Definition at line 477 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

477  {
478  fml::TimePoint present_requested_time = TimePointFromInt(500);
479  fml::TimePoint now = TimePointFromInt(600);
480  fml::TimePoint last_latch_point_targeted = TimePointFromInt(0);
481  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2500);
482  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
483  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
484  future_presentation_infos = {};
485 
486  // Assertions about given values.
487  EXPECT_GE(now, present_requested_time);
488  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
489  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
490 
491  EXPECT_GT(flutter_frame_build_time, vsync_interval);
492 
493  fml::TimePoint calculated_latch_point =
494  GfxSessionConnection::CalculateNextLatchPoint(
495  present_requested_time, now, last_latch_point_targeted,
496  flutter_frame_build_time, vsync_interval, future_presentation_infos);
497 
498  EXPECT_GE(TimePointToInt(calculated_latch_point),
499  TimePointToInt(now + (vsync_interval * 2)));
500  EXPECT_LE(TimePointToInt(calculated_latch_point),
501  TimePointToInt(now + (vsync_interval * 3)));
502 
503  EXPECT_GE(TimePointToInt(calculated_latch_point),
504  TimePointToInt(present_requested_time + flutter_frame_build_time));
505  EXPECT_GE(TimePointToInt(calculated_latch_point),
506  TimePointToInt(last_latch_point_targeted));
507 }

◆ TEST() [4/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
DelayedPresentRequestWithLongFrameBuildTime   
)

Definition at line 509 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

509  {
510  fml::TimePoint present_requested_time = TimePointFromInt(0);
511  fml::TimePoint now = TimePointFromInt(1500);
512  fml::TimePoint last_latch_point_targeted = TimePointFromInt(0);
513  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2000);
514  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
515  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
516  future_presentation_infos = {};
517 
518  // Assertions about given values.
519  EXPECT_GE(now, present_requested_time);
520  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
521  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
522 
523  EXPECT_GT(flutter_frame_build_time, vsync_interval);
524  EXPECT_GT(now, present_requested_time + vsync_interval);
525 
526  fml::TimePoint calculated_latch_point =
527  GfxSessionConnection::CalculateNextLatchPoint(
528  present_requested_time, now, last_latch_point_targeted,
529  flutter_frame_build_time, vsync_interval, future_presentation_infos);
530 
531  EXPECT_GE(TimePointToInt(calculated_latch_point), TimePointToInt(now));
532  EXPECT_LE(TimePointToInt(calculated_latch_point),
533  TimePointToInt(now + vsync_interval));
534 
535  EXPECT_GE(TimePointToInt(calculated_latch_point),
536  TimePointToInt(present_requested_time + flutter_frame_build_time));
537  EXPECT_GE(TimePointToInt(calculated_latch_point),
538  TimePointToInt(last_latch_point_targeted));
539 }

◆ TEST() [5/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
LastLastPointTargetedLate   
)

Definition at line 541 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

541  {
542  fml::TimePoint present_requested_time = TimePointFromInt(2000);
543  fml::TimePoint now = TimePointFromInt(2000);
544  fml::TimePoint last_latch_point_targeted = TimePointFromInt(2600);
545  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
546  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
547  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
548  future_presentation_infos = {};
549 
550  // Assertions about given values.
551  EXPECT_GE(now, present_requested_time);
552  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
553  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
554 
555  EXPECT_GT(last_latch_point_targeted, present_requested_time);
556 
557  fml::TimePoint calculated_latch_point =
558  GfxSessionConnection::CalculateNextLatchPoint(
559  present_requested_time, now, last_latch_point_targeted,
560  flutter_frame_build_time, vsync_interval, future_presentation_infos);
561 
562  EXPECT_GE(TimePointToInt(calculated_latch_point),
563  TimePointToInt(now + vsync_interval));
564  EXPECT_LE(TimePointToInt(calculated_latch_point),
565  TimePointToInt(now + (vsync_interval * 2)));
566 
567  EXPECT_GE(TimePointToInt(calculated_latch_point),
568  TimePointToInt(present_requested_time + flutter_frame_build_time));
569  EXPECT_GE(TimePointToInt(calculated_latch_point),
570  TimePointToInt(last_latch_point_targeted));
571 }

◆ TEST() [6/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
SteadyState_OnTimeFrames   
)

Definition at line 577 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

577  {
578  fml::TimePoint present_requested_time = TimePointFromInt(5000);
579  fml::TimePoint now = TimePointFromInt(5000);
580  fml::TimePoint last_latch_point_targeted = TimePointFromInt(4500);
581  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
582  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
583  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
584  future_presentation_infos = {
585  {TimePointFromInt(3500), TimePointFromInt(4000)},
586  {TimePointFromInt(4500), TimePointFromInt(5000)},
587  {TimePointFromInt(5500), TimePointFromInt(6000)},
588  {TimePointFromInt(6500), TimePointFromInt(7000)},
589  {TimePointFromInt(7500), TimePointFromInt(8000)},
590  };
591 
592  // Assertions about given values.
593  EXPECT_GE(now, present_requested_time);
594  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
595  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
596 
597  fml::TimePoint calculated_latch_point =
598  GfxSessionConnection::CalculateNextLatchPoint(
599  present_requested_time, now, last_latch_point_targeted,
600  flutter_frame_build_time, vsync_interval, future_presentation_infos);
601 
602  EXPECT_GE(TimePointToInt(calculated_latch_point),
603  TimePointToInt(now + vsync_interval));
604  EXPECT_LE(TimePointToInt(calculated_latch_point),
605  TimePointToInt(now + (vsync_interval * 2)));
606  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6500);
607 
608  EXPECT_GE(TimePointToInt(calculated_latch_point),
609  TimePointToInt(present_requested_time + flutter_frame_build_time));
610  EXPECT_GE(TimePointToInt(calculated_latch_point),
611  TimePointToInt(last_latch_point_targeted));
612 }

◆ TEST() [7/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
SteadyState_LongFrameBuildTimes   
)

Definition at line 614 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

614  {
615  fml::TimePoint present_requested_time = TimePointFromInt(5000);
616  fml::TimePoint now = TimePointFromInt(5000);
617  fml::TimePoint last_latch_point_targeted = TimePointFromInt(4500);
618  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2000);
619  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
620  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
621  future_presentation_infos = {
622  {TimePointFromInt(3500), TimePointFromInt(4000)},
623  {TimePointFromInt(4500), TimePointFromInt(5000)},
624  {TimePointFromInt(5500), TimePointFromInt(6000)},
625  {TimePointFromInt(6500), TimePointFromInt(7000)},
626  {TimePointFromInt(7500), TimePointFromInt(8000)},
627  };
628 
629  // Assertions about given values.
630  EXPECT_GE(now, present_requested_time);
631  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
632  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
633 
634  EXPECT_GT(flutter_frame_build_time, vsync_interval);
635 
636  fml::TimePoint calculated_latch_point =
637  GfxSessionConnection::CalculateNextLatchPoint(
638  present_requested_time, now, last_latch_point_targeted,
639  flutter_frame_build_time, vsync_interval, future_presentation_infos);
640 
641  EXPECT_GE(TimePointToInt(calculated_latch_point),
642  TimePointToInt(now + (vsync_interval * 2)));
643  EXPECT_LE(TimePointToInt(calculated_latch_point),
644  TimePointToInt(now + (vsync_interval * 3)));
645  EXPECT_EQ(TimePointToInt(calculated_latch_point), 7500);
646 
647  EXPECT_GE(TimePointToInt(calculated_latch_point),
648  TimePointToInt(present_requested_time + flutter_frame_build_time));
649  EXPECT_GE(TimePointToInt(calculated_latch_point),
650  TimePointToInt(last_latch_point_targeted));
651 }

◆ TEST() [8/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
SteadyState_LateLastLatchPointTargeted   
)

Definition at line 653 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

653  {
654  fml::TimePoint present_requested_time = TimePointFromInt(5000);
655  fml::TimePoint now = TimePointFromInt(5000);
656  fml::TimePoint last_latch_point_targeted = TimePointFromInt(6500);
657  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
658  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
659  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
660  future_presentation_infos = {
661  {TimePointFromInt(4500), TimePointFromInt(5000)},
662  {TimePointFromInt(5500), TimePointFromInt(6000)},
663  {TimePointFromInt(6500), TimePointFromInt(7000)},
664  {TimePointFromInt(7500), TimePointFromInt(8000)},
665  {TimePointFromInt(8500), TimePointFromInt(9000)},
666  };
667 
668  // Assertions about given values.
669  EXPECT_GE(now, present_requested_time);
670  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
671  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
672 
673  EXPECT_GT(last_latch_point_targeted, now + vsync_interval);
674 
675  fml::TimePoint calculated_latch_point =
676  GfxSessionConnection::CalculateNextLatchPoint(
677  present_requested_time, now, last_latch_point_targeted,
678  flutter_frame_build_time, vsync_interval, future_presentation_infos);
679 
680  EXPECT_GE(TimePointToInt(calculated_latch_point),
681  TimePointToInt(now + vsync_interval));
682  EXPECT_LE(TimePointToInt(calculated_latch_point),
683  TimePointToInt(now + (vsync_interval * 2)));
684  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6500);
685 
686  EXPECT_GE(TimePointToInt(calculated_latch_point),
687  TimePointToInt(present_requested_time + flutter_frame_build_time));
688  EXPECT_GE(TimePointToInt(calculated_latch_point),
689  TimePointToInt(last_latch_point_targeted));
690 }

◆ TEST() [9/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
SteadyState_DelayedPresentRequestWithLongFrameBuildTime   
)

Definition at line 692 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

693  {
694  fml::TimePoint present_requested_time = TimePointFromInt(4000);
695  fml::TimePoint now = TimePointFromInt(5500);
696  fml::TimePoint last_latch_point_targeted = TimePointFromInt(3500);
697  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2000);
698  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
699  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
700  future_presentation_infos = {
701  {TimePointFromInt(4500), TimePointFromInt(5000)},
702  {TimePointFromInt(5500), TimePointFromInt(6000)},
703  {TimePointFromInt(6500), TimePointFromInt(7000)},
704  };
705 
706  // Assertions about given values.
707  EXPECT_GE(now, present_requested_time);
708  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
709  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
710 
711  EXPECT_GT(flutter_frame_build_time, vsync_interval);
712  EXPECT_GT(now, present_requested_time + vsync_interval);
713 
714  fml::TimePoint calculated_latch_point =
715  GfxSessionConnection::CalculateNextLatchPoint(
716  present_requested_time, now, last_latch_point_targeted,
717  flutter_frame_build_time, vsync_interval, future_presentation_infos);
718 
719  EXPECT_GE(TimePointToInt(calculated_latch_point),
720  TimePointToInt(now + vsync_interval));
721  EXPECT_LE(TimePointToInt(calculated_latch_point),
722  TimePointToInt(now + (vsync_interval * 2)));
723  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6500);
724 
725  EXPECT_GE(TimePointToInt(calculated_latch_point),
726  TimePointToInt(present_requested_time + flutter_frame_build_time));
727  EXPECT_GE(TimePointToInt(calculated_latch_point),
728  TimePointToInt(last_latch_point_targeted));
729 }

◆ TEST() [10/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
SteadyState_FuzzyLatchPointsBeforeTarget   
)

Definition at line 731 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

731  {
732  fml::TimePoint present_requested_time = TimePointFromInt(4000);
733  fml::TimePoint now = TimePointFromInt(4000);
734  fml::TimePoint last_latch_point_targeted = TimePointFromInt(5490);
735  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
736  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
737  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
738  future_presentation_infos = {
739  {TimePointFromInt(4510), TimePointFromInt(5000)},
740  {TimePointFromInt(5557), TimePointFromInt(6000)},
741  {TimePointFromInt(6482), TimePointFromInt(7000)},
742  {TimePointFromInt(7356), TimePointFromInt(8000)},
743  };
744 
745  // Assertions about given values.
746  EXPECT_GE(now, present_requested_time);
747  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
748  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
749 
750  fml::TimePoint calculated_latch_point =
751  GfxSessionConnection::CalculateNextLatchPoint(
752  present_requested_time, now, last_latch_point_targeted,
753  flutter_frame_build_time, vsync_interval, future_presentation_infos);
754 
755  EXPECT_GE(TimePointToInt(calculated_latch_point),
756  TimePointToInt(now + vsync_interval));
757  EXPECT_LE(TimePointToInt(calculated_latch_point),
758  TimePointToInt(now + (vsync_interval * 2)));
759  EXPECT_EQ(TimePointToInt(calculated_latch_point), 5557);
760 
761  EXPECT_GE(TimePointToInt(calculated_latch_point),
762  TimePointToInt(present_requested_time + flutter_frame_build_time));
763  EXPECT_GE(TimePointToInt(calculated_latch_point),
764  TimePointToInt(last_latch_point_targeted));
765 }

◆ TEST() [11/26]

flutter_runner::testing::TEST ( CalculateNextLatchPointTest  ,
SteadyState_FuzzyLatchPointsAfterTarget   
)

Definition at line 767 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::CalculateNextLatchPoint().

767  {
768  fml::TimePoint present_requested_time = TimePointFromInt(4000);
769  fml::TimePoint now = TimePointFromInt(4000);
770  fml::TimePoint last_latch_point_targeted = TimePointFromInt(5557);
771  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
772  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
773  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
774  future_presentation_infos = {
775  {TimePointFromInt(4510), TimePointFromInt(5000)},
776  {TimePointFromInt(5490), TimePointFromInt(6000)},
777  {TimePointFromInt(6482), TimePointFromInt(7000)},
778  {TimePointFromInt(7356), TimePointFromInt(8000)},
779  };
780 
781  // Assertions about given values.
782  EXPECT_GE(now, present_requested_time);
783  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
784  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
785 
786  fml::TimePoint calculated_latch_point =
787  GfxSessionConnection::CalculateNextLatchPoint(
788  present_requested_time, now, last_latch_point_targeted,
789  flutter_frame_build_time, vsync_interval, future_presentation_infos);
790 
791  EXPECT_GE(TimePointToInt(calculated_latch_point),
792  TimePointToInt(now + (vsync_interval * 2)));
793  EXPECT_LE(TimePointToInt(calculated_latch_point),
794  TimePointToInt(now + (vsync_interval * 3)));
795  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6482);
796 
797  EXPECT_GE(TimePointToInt(calculated_latch_point),
798  TimePointToInt(present_requested_time + flutter_frame_build_time));
799  EXPECT_GE(TimePointToInt(calculated_latch_point),
800  TimePointToInt(last_latch_point_targeted));
801 }

◆ TEST() [12/26]

flutter_runner::testing::TEST ( SnapToNextPhaseTest  ,
SnapOverlapsWithNow   
)

Definition at line 803 of file gfx_session_connection_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::GfxSessionConnection::SnapToNextPhase().

803  {
804  const auto now = fml::TimePoint::Now();
805  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(10);
806  const auto delta = fml::TimeDelta::FromNanoseconds(10);
808  now, last_presentation_time, delta);
809 
810  EXPECT_EQ(now + delta, next_vsync);
811 }
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static TimePoint Now()
Definition: time_point.cc:49

◆ TEST() [13/26]

flutter_runner::testing::TEST ( SnapToNextPhaseTest  ,
SnapAfterNow   
)

Definition at line 813 of file gfx_session_connection_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::GfxSessionConnection::SnapToNextPhase().

813  {
814  const auto now = fml::TimePoint::Now();
815  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(9);
816  const auto delta = fml::TimeDelta::FromNanoseconds(10);
818  now, last_presentation_time, delta);
819 
820  // math here: 10 - 9 = 1
821  EXPECT_EQ(now + fml::TimeDelta::FromNanoseconds(1), next_vsync);
822 }
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static TimePoint Now()
Definition: time_point.cc:49

◆ TEST() [14/26]

flutter_runner::testing::TEST ( SnapToNextPhaseTest  ,
SnapAfterNowMultiJump   
)

Definition at line 824 of file gfx_session_connection_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::GfxSessionConnection::SnapToNextPhase().

824  {
825  const auto now = fml::TimePoint::Now();
826  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(34);
827  const auto delta = fml::TimeDelta::FromNanoseconds(10);
829  now, last_presentation_time, delta);
830 
831  // zeroes: -34, -24, -14, -4, 6, ...
832  EXPECT_EQ(now + fml::TimeDelta::FromNanoseconds(6), next_vsync);
833 }
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static TimePoint Now()
Definition: time_point.cc:49

◆ TEST() [15/26]

flutter_runner::testing::TEST ( SnapToNextPhaseTest  ,
SnapAfterNowMultiJumpAccountForCeils   
)

Definition at line 835 of file gfx_session_connection_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::GfxSessionConnection::SnapToNextPhase().

835  {
836  const auto now = fml::TimePoint::Now();
837  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(20);
838  const auto delta = fml::TimeDelta::FromNanoseconds(16);
840  now, last_presentation_time, delta);
841 
842  // zeroes: -20, -4, 12, 28, ...
843  EXPECT_EQ(now + fml::TimeDelta::FromNanoseconds(12), next_vsync);
844 }
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static TimePoint Now()
Definition: time_point.cc:49

◆ TEST() [16/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleForNextVsync   
)

Definition at line 846 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

846  {
847  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(0);
848  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
849  const fml::TimePoint last_targeted_vsync = TimePointFromInt(10);
850  const fml::TimePoint now = TimePointFromInt(9);
851  const fml::TimePoint next_vsync = TimePointFromInt(10);
852 
853  const auto target_times =
855  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
856 
857  EXPECT_EQ(TimePointToInt(target_times.frame_start), 10);
858  EXPECT_EQ(TimePointToInt(target_times.frame_target), 20);
859 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [17/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleForCurrentVsync_DueToOffset   
)

Definition at line 861 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

861  {
862  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(3);
863  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
864  const fml::TimePoint last_targeted_vsync = TimePointFromInt(0);
865  const fml::TimePoint now = TimePointFromInt(6);
866  const fml::TimePoint next_vsync = TimePointFromInt(10);
867 
868  const auto target_times =
870  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
871 
872  EXPECT_EQ(TimePointToInt(target_times.frame_start), 7);
873  EXPECT_EQ(TimePointToInt(target_times.frame_target), 10);
874 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [18/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleForFollowingVsync_BecauseOfNow   
)

Definition at line 876 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

876  {
877  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(0);
878  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
879  const fml::TimePoint last_targeted_vsync = TimePointFromInt(10);
880  const fml::TimePoint now = TimePointFromInt(15);
881  const fml::TimePoint next_vsync = TimePointFromInt(10);
882 
883  const auto target_times =
885  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
886 
887  EXPECT_EQ(TimePointToInt(target_times.frame_start), 20);
888  EXPECT_EQ(TimePointToInt(target_times.frame_target), 30);
889 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [19/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleForFollowingVsync_BecauseOfTargettedTime   
)

Definition at line 891 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

891  {
892  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(0);
893  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
894  const fml::TimePoint last_targeted_vsync = TimePointFromInt(20);
895  const fml::TimePoint now = TimePointFromInt(9);
896  const fml::TimePoint next_vsync = TimePointFromInt(10);
897 
898  const auto target_times =
900  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
901 
902  EXPECT_EQ(TimePointToInt(target_times.frame_start), 20);
903  EXPECT_EQ(TimePointToInt(target_times.frame_target), 30);
904 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [20/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleForDistantVsync_BecauseOfTargettedTime   
)

Definition at line 906 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

906  {
907  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(0);
908  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
909  const fml::TimePoint last_targeted_vsync = TimePointFromInt(60);
910  const fml::TimePoint now = TimePointFromInt(9);
911  const fml::TimePoint next_vsync = TimePointFromInt(10);
912 
913  const auto target_times =
915  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
916 
917  EXPECT_EQ(TimePointToInt(target_times.frame_start), 60);
918  EXPECT_EQ(TimePointToInt(target_times.frame_target), 70);
919 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [21/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleForFollowingVsync_WithSlightVsyncDrift   
)

Definition at line 921 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

921  {
922  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(0);
923  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
924 
925  // Even though it appears as if the next vsync is at time 40, we should still
926  // present at time 50.
927  const fml::TimePoint last_targeted_vsync = TimePointFromInt(37);
928  const fml::TimePoint now = TimePointFromInt(9);
929  const fml::TimePoint next_vsync = TimePointFromInt(10);
930 
931  const auto target_times =
933  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
934 
935  EXPECT_EQ(TimePointToInt(target_times.frame_start), 40);
936  EXPECT_EQ(TimePointToInt(target_times.frame_target), 50);
937 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [22/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleForAnOffsetFromVsync   
)

Definition at line 939 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

939  {
940  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(4);
941  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
942  const fml::TimePoint last_targeted_vsync = TimePointFromInt(10);
943  const fml::TimePoint now = TimePointFromInt(9);
944  const fml::TimePoint next_vsync = TimePointFromInt(10);
945 
946  const auto target_times =
948  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
949 
950  EXPECT_EQ(TimePointToInt(target_times.frame_start), 16);
951  EXPECT_EQ(TimePointToInt(target_times.frame_target), 20);
952 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [23/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleMultipleTimes   
)

Definition at line 954 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

954  {
955  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(0);
956  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
957 
958  fml::TimePoint last_targeted_vsync = TimePointFromInt(0);
959  fml::TimePoint now = TimePointFromInt(5);
960  fml::TimePoint next_vsync = TimePointFromInt(10);
961 
962  for (int i = 0; i < 100; ++i) {
963  const auto target_times =
965  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
966 
967  EXPECT_EQ(TimePointToInt(target_times.frame_start), 10 * (i + 1));
968  EXPECT_EQ(TimePointToInt(target_times.frame_target), 10 * (i + 2));
969 
970  // Simulate the passage of time.
971  now = now + vsync_interval;
972  next_vsync = next_vsync + vsync_interval;
973  last_targeted_vsync = target_times.frame_target;
974  }
975 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [24/26]

flutter_runner::testing::TEST ( GetTargetTimesTest  ,
ScheduleMultipleTimes_WithDelayedWakeups   
)

Definition at line 977 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::GetTargetTimes().

977  {
978  // It is often the case that Flutter does not wake up when it intends to due
979  // to CPU contention. This test has GfxSessionConnection wake up to
980  // schedule 0-4ns after when |now| should be - and we verify that the results
981  // should be the same as if there were no delay.
982  const fml::TimeDelta vsync_offset = TimeDeltaFromInt(0);
983  const fml::TimeDelta vsync_interval = TimeDeltaFromInt(10);
984 
985  fml::TimePoint last_targeted_vsync = TimePointFromInt(0);
986  fml::TimePoint now = TimePointFromInt(5);
987  fml::TimePoint next_vsync = TimePointFromInt(10);
988 
989  for (int i = 0; i < 100; ++i) {
990  const auto target_times =
992  vsync_offset, vsync_interval, last_targeted_vsync, now, next_vsync);
993 
994  const auto target_times_delay =
996  vsync_offset, vsync_interval, last_targeted_vsync,
997  now + TimeDeltaFromInt(i % 5), next_vsync);
998 
999  EXPECT_EQ(TimePointToInt(target_times.frame_start),
1000  TimePointToInt(target_times_delay.frame_start));
1001  EXPECT_EQ(TimePointToInt(target_times.frame_target),
1002  TimePointToInt(target_times_delay.frame_target));
1003 
1004  // Simulate the passage of time.
1005  now = now + vsync_interval;
1006  next_vsync = next_vsync + vsync_interval;
1007  last_targeted_vsync = target_times.frame_target;
1008  }
1009 }
static FlutterFrameTimes GetTargetTimes(fml::TimeDelta vsync_offset, fml::TimeDelta vsync_interval, fml::TimePoint last_targeted_vsync, fml::TimePoint now, fml::TimePoint next_vsync)

◆ TEST() [25/26]

flutter_runner::testing::TEST ( UpdatePresentationInfoTest  ,
SingleUpdate   
)

Definition at line 1011 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::UpdatePresentationInfo().

1011  {
1012  std::vector<fuchsia::scenic::scheduling::PresentationInfo>
1013  future_presentations = {};
1014 
1015  // Update the |vsync_info|.
1016  future_presentations.push_back(
1017  CreatePresentationInfo(/*latch_point=*/5, /*presentation_time=*/10));
1018 
1019  fuchsia::scenic::scheduling::FuturePresentationTimes future_info;
1020  future_info.future_presentations = std::move(future_presentations);
1021  future_info.remaining_presents_in_flight_allowed = 1;
1022 
1023  fuchsia::scenic::scheduling::PresentationInfo presentation_info;
1024  presentation_info.set_presentation_time(0);
1025 
1026  fuchsia::scenic::scheduling::PresentationInfo new_presentation_info =
1028  std::move(future_info), presentation_info);
1029 
1030  EXPECT_EQ(new_presentation_info.presentation_time(), 10);
1031 }
static fuchsia::scenic::scheduling::PresentationInfo UpdatePresentationInfo(fuchsia::scenic::scheduling::FuturePresentationTimes future_info, fuchsia::scenic::scheduling::PresentationInfo &presentation_info)

◆ TEST() [26/26]

flutter_runner::testing::TEST ( UpdatePresentationInfoTest  ,
MultipleUpdates   
)

Definition at line 1033 of file gfx_session_connection_unittests.cc.

References flutter_runner::GfxSessionConnection::UpdatePresentationInfo().

1033  {
1034  std::vector<fuchsia::scenic::scheduling::PresentationInfo>
1035  future_presentations = {};
1036 
1037  // Update the |vsync_info|.
1038  future_presentations.push_back(
1039  CreatePresentationInfo(/*latch_point=*/15, /*presentation_time=*/20));
1040  future_presentations.push_back(
1041  CreatePresentationInfo(/*latch_point=*/25, /*presentation_time=*/30));
1042  fuchsia::scenic::scheduling::FuturePresentationTimes future_info;
1043  future_info.future_presentations = std::move(future_presentations);
1044  future_info.remaining_presents_in_flight_allowed = 1;
1045 
1046  fuchsia::scenic::scheduling::PresentationInfo presentation_info;
1047  presentation_info.set_presentation_time(0);
1048 
1049  fuchsia::scenic::scheduling::PresentationInfo new_presentation_info =
1051  std::move(future_info), presentation_info);
1052 
1053  EXPECT_EQ(new_presentation_info.presentation_time(), 20);
1054 
1055  // Clear and re-try with more future times!
1056  future_presentations.clear();
1057  future_presentations.push_back(
1058  CreatePresentationInfo(/*latch_point=*/15, /*presentation_time=*/20));
1059  future_presentations.push_back(
1060  CreatePresentationInfo(/*latch_point=*/25, /*presentation_time=*/30));
1061  future_presentations.push_back(
1062  CreatePresentationInfo(/*latch_point=*/35, /*presentation_time=*/40));
1063  future_presentations.push_back(
1064  CreatePresentationInfo(/*latch_point=*/45, /*presentation_time=*/50));
1065  future_info.future_presentations = std::move(future_presentations);
1066  future_info.remaining_presents_in_flight_allowed = 1;
1067 
1068  new_presentation_info =
1070  std::move(future_info), new_presentation_info);
1071 
1072  EXPECT_EQ(new_presentation_info.presentation_time(), 30);
1073 }
static fuchsia::scenic::scheduling::PresentationInfo UpdatePresentationInfo(fuchsia::scenic::scheduling::FuturePresentationTimes future_info, fuchsia::scenic::scheduling::PresentationInfo &presentation_info)

◆ TEST_F() [1/77]

flutter_runner::testing::TEST_F ( FakeFlatlandTest  ,
Initialization   
)

Definition at line 54 of file fake_flatland_unittests.cc.

References flutter_runner::testing::FakeFlatlandTest::fake_flatland(), and flutter_runner::testing::FakeFlatlandTest::loop().

54  {
55  EXPECT_EQ(fake_flatland().debug_name(), "");
56 
57  // Pump the loop one time; the flatland should retain its initial state.
58  loop().RunUntilIdle();
59  EXPECT_EQ(fake_flatland().debug_name(), "");
60 }

◆ TEST_F() [2/77]

flutter_runner::testing::TEST_F ( FakeFlatlandTest  ,
DebugLabel   
)

Definition at line 62 of file fake_flatland_unittests.cc.

References flutter_runner::testing::FakeFlatlandTest::ConnectFlatland(), flutter_runner::testing::FakeFlatlandTest::fake_flatland(), flutter::testing::GetCurrentTestName(), and flutter_runner::testing::FakeFlatlandTest::loop().

62  {
63  const std::string debug_label = GetCurrentTestName();
64  fuchsia::ui::composition::FlatlandPtr flatland = ConnectFlatland();
65 
66  // Set the flatland's debug name. The `SetDebugName` hasn't been processed
67  // yet, so the flatland's view of the debug name is still empty.
68  flatland->SetDebugName(debug_label);
69  EXPECT_EQ(fake_flatland().debug_name(), "");
70 
71  // Pump the loop; the contents of the initial `SetDebugName` should be
72  // processed.
73  loop().RunUntilIdle();
74  EXPECT_EQ(fake_flatland().debug_name(), debug_label);
75 }
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:13

◆ TEST_F() [3/77]

flutter_runner::testing::TEST_F ( FocusDelegateTest  ,
WatchCallbackSeries   
)

Definition at line 65 of file focus_delegate_unittests.cc.

References flutter_runner::testing::FakePlatformMessageResponse::Create(), flutter_runner::testing::FocusDelegateTest::focus_delegate_, ParsePlatformMessage(), flutter_runner::testing::FocusDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::FocusDelegateTest::vrf_.

65  {
66  std::vector<bool> vrf_states{false, true, true, false,
67  true, false, true, true};
68  std::size_t vrf_index = 0;
69  std::size_t callback_index = 0;
70  focus_delegate_->WatchLoop([&](bool focus_state) {
71  // Make sure the focus state that FocusDelegate gives us is consistent with
72  // what was fired from the vrf.
73  EXPECT_EQ(vrf_states[callback_index], focus_state);
74 
75  // View.focus.getCurrent should complete with the current (up to date) focus
76  // state.
77  auto response = FakePlatformMessageResponse::Create();
78  EXPECT_TRUE(focus_delegate_->HandlePlatformMessage(
79  ParsePlatformMessage("{\"method\":\"View.focus.getCurrent\"}"),
80  response));
81  response->ExpectCompleted(focus_state ? "[true]" : "[false]");
82 
83  // Ensure this callback always happens in lockstep with
84  // vrf_->ScheduleCallback.
85  EXPECT_EQ(vrf_index, callback_index++);
86  });
87 
88  // Subsequent WatchLoop calls should not be respected.
89  focus_delegate_->WatchLoop([](bool _) {
90  ADD_FAILURE() << "Subsequent WatchLoops should not be respected!";
91  });
92 
93  do {
94  // Ensure the next focus state is handled correctly.
95  auto response1 = FakePlatformMessageResponse::Create();
96  EXPECT_TRUE(focus_delegate_->HandlePlatformMessage(
97  ParsePlatformMessage("{\"method\":\"View.focus.getNext\"}"),
98  response1));
99 
100  // Since there's already an outstanding PlatformMessageResponse, this one
101  // should be completed null.
102  auto response2 = FakePlatformMessageResponse::Create();
103  EXPECT_TRUE(focus_delegate_->HandlePlatformMessage(
104  ParsePlatformMessage("{\"method\":\"View.focus.getNext\"}"),
105  response2));
106  response2->ExpectCompleted("[null]");
107 
108  // Post watch events and trigger the next vrf event.
109  RunLoopUntilIdle();
110  vrf_->ScheduleCallback(vrf_states[vrf_index]);
111  RunLoopUntilIdle();
112 
113  // Next focus state should be completed by now.
114  response1->ExpectCompleted(vrf_states[vrf_index] ? "[true]" : "[false]");
115 
116  // Check View.focus.getCurrent again, and increment vrf_index since we move
117  // on to the next focus state.
118  auto response3 = FakePlatformMessageResponse::Create();
119  EXPECT_TRUE(focus_delegate_->HandlePlatformMessage(
120  ParsePlatformMessage("{\"method\":\"View.focus.getCurrent\"}"),
121  response3));
122  response3->ExpectCompleted(vrf_states[vrf_index++] ? "[true]" : "[false]");
123 
124  // vrf_->times_watched should always be 1 more than the amount of vrf events
125  // emitted.
126  EXPECT_EQ(vrf_index + 1, vrf_->times_watched);
127  } while (vrf_index < vrf_states.size());
128 }
rapidjson::Value ParsePlatformMessage(std::string json)

◆ TEST_F() [4/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Data_FuchsiaTimeVersusFlutterTime   
)

Definition at line 66 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), kIxnOne, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

66  {
67  std::optional<std::vector<flutter::PointerData>> pointers;
68  pointer_delegate_->WatchLoop(
69  [&pointers](std::vector<flutter::PointerData> events) {
70  pointers = std::move(events);
71  });
72  RunLoopUntilIdle(); // Server gets watch call.
73 
74  // Fuchsia ADD -> Flutter ADD+DOWN
75  std::vector<fup_TouchEvent> events =
76  TouchEventBuilder::New()
77  .AddTime(/* in nanoseconds */ 1111789u)
78  .AddViewParameters(kRect, kRect, kIdentity)
79  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
80  .AddResult(
81  {.interaction = kIxnOne, .status = fup_TouchIxnStatus::GRANTED})
82  .BuildAsVector();
83  touch_source_->ScheduleCallback(std::move(events));
84  RunLoopUntilIdle();
85 
86  ASSERT_TRUE(pointers.has_value());
87  ASSERT_EQ(pointers->size(), 2u);
88  EXPECT_EQ((*pointers)[0].time_stamp, /* in microseconds */ 1111u);
89  EXPECT_EQ((*pointers)[1].time_stamp, /* in microseconds */ 1111u);
90 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [5/77]

flutter_runner::testing::TEST_F ( FakeFlatlandTest  ,
Present   
)

Definition at line 77 of file fake_flatland_unittests.cc.

References flutter_runner::testing::FakeFlatlandTest::ConnectFlatland(), flutter_runner::testing::FakeFlatlandTest::fake_flatland(), flutter_runner::testing::FakeFlatland::FireOnFramePresentedEvent(), flutter_runner::testing::FakeFlatland::FireOnNextFrameBeginEvent(), flutter_runner::testing::FakeFlatlandTest::loop(), and flutter_runner::testing::FakeFlatland::SetPresentHandler().

77  {
78  fuchsia::ui::composition::FlatlandPtr flatland = ConnectFlatland();
79 
80  // Fire an OnNextFrameBegin event and verify the test receives it.
81  constexpr uint64_t kOnNextFrameAdditionalPresentCredits = 10u;
82  uint64_t on_next_frame_additional_present_credits = 0u;
83  fuchsia::ui::composition::OnNextFrameBeginValues on_next_frame_begin_values;
84  on_next_frame_begin_values.set_additional_present_credits(
85  kOnNextFrameAdditionalPresentCredits);
86  flatland.events().OnNextFrameBegin =
87  [&on_next_frame_additional_present_credits](
88  auto on_next_frame_begin_values) {
89  static bool called_once = false;
90  EXPECT_FALSE(called_once);
91 
92  on_next_frame_additional_present_credits =
93  on_next_frame_begin_values.additional_present_credits();
94  called_once = true;
95  };
96  fake_flatland().FireOnNextFrameBeginEvent(
97  std::move(on_next_frame_begin_values));
98  EXPECT_EQ(on_next_frame_additional_present_credits, 0u);
99  loop().RunUntilIdle();
100  EXPECT_EQ(on_next_frame_additional_present_credits,
101  kOnNextFrameAdditionalPresentCredits);
102 
103  // Fire an OnFramePresented event and verify the test receives it.
104  constexpr uint64_t kOnFramePresentedNumPresentsAllowed = 20u;
105  uint64_t frame_presented_num_presents_allowed = 0u;
106  flatland.events().OnFramePresented =
107  [&frame_presented_num_presents_allowed](auto frame_presented_info) {
108  static bool called_once = false;
109  EXPECT_FALSE(called_once);
110 
111  frame_presented_num_presents_allowed =
112  frame_presented_info.num_presents_allowed;
113  called_once = true;
114  };
115  fake_flatland().FireOnFramePresentedEvent(
116  fuchsia::scenic::scheduling::FramePresentedInfo{
117  .actual_presentation_time = 0,
118  .num_presents_allowed = kOnFramePresentedNumPresentsAllowed,
119  });
120  EXPECT_EQ(frame_presented_num_presents_allowed, 0u);
121  loop().RunUntilIdle();
122  EXPECT_EQ(frame_presented_num_presents_allowed,
123  kOnFramePresentedNumPresentsAllowed);
124 
125  // Call Present and verify the fake handled it.
126  constexpr int64_t kPresentRequestedTime = 42;
127  int64_t present_requested_time = 0;
128  fuchsia::ui::composition::PresentArgs present_args;
129  present_args.set_requested_presentation_time(kPresentRequestedTime);
130  fake_flatland().SetPresentHandler(
131  [&present_requested_time](auto present_args) {
132  static bool called_once = false;
133  EXPECT_FALSE(called_once);
134 
135  present_requested_time = present_args.requested_presentation_time();
136  called_once = true;
137  });
138  flatland->Present(std::move(present_args));
139  EXPECT_EQ(present_requested_time, 0);
140  loop().RunUntilIdle();
141  EXPECT_EQ(present_requested_time, kPresentRequestedTime);
142 }

◆ TEST_F() [6/77]

flutter_runner::testing::TEST_F ( FlatlandConnectionTest  ,
Initialization   
)

Definition at line 81 of file flatland_connection_unittests.cc.

References flutter_runner::testing::FlatlandConnectionTest::fake_flatland(), flutter::testing::GetCurrentTestName(), flutter_runner::kDefaultFlatlandPresentationInterval, flutter_runner::testing::FlatlandConnectionTest::loop(), flutter_runner::testing::FlatlandConnectionTest::TakeFlatlandHandle(), and fml::TimeDelta::Zero().

81  {
82  // Create the FlatlandConnection but don't pump the loop. No FIDL calls are
83  // completed yet.
84  const std::string debug_name = GetCurrentTestName();
85  flutter_runner::FlatlandConnection flatland_connection(
86  debug_name, TakeFlatlandHandle(), []() { FAIL(); },
87  [](auto...) { FAIL(); }, 1, fml::TimeDelta::Zero());
88  EXPECT_EQ(fake_flatland().debug_name(), "");
89 
90  // Simulate an AwaitVsync that comes immediately.
91  bool await_vsync_fired = false;
92  AwaitVsyncChecked(flatland_connection, await_vsync_fired,
94  EXPECT_TRUE(await_vsync_fired);
95 
96  // Ensure the debug name is set.
97  loop().RunUntilIdle();
98  EXPECT_EQ(fake_flatland().debug_name(), debug_name);
99 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
static constexpr fml::TimeDelta kDefaultFlatlandPresentationInterval

◆ TEST_F() [7/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Phase_FlutterPhasesAreSynthesized   
)

Definition at line 92 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), flutter::PointerData::kAdd, flutter::PointerData::kDown, kIxnOne, flutter::PointerData::kMove, flutter::PointerData::kRemove, flutter::PointerData::kUp, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

92  {
93  std::optional<std::vector<flutter::PointerData>> pointers;
94  pointer_delegate_->WatchLoop(
95  [&pointers](std::vector<flutter::PointerData> events) {
96  pointers = std::move(events);
97  });
98  RunLoopUntilIdle(); // Server gets watch call.
99 
100  // Fuchsia ADD -> Flutter ADD+DOWN
101  std::vector<fup_TouchEvent> events =
102  TouchEventBuilder::New()
103  .AddTime(1111000u)
104  .AddViewParameters(kRect, kRect, kIdentity)
105  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
106  .AddResult(
107  {.interaction = kIxnOne, .status = fup_TouchIxnStatus::GRANTED})
108  .BuildAsVector();
109  touch_source_->ScheduleCallback(std::move(events));
110  RunLoopUntilIdle();
111 
112  ASSERT_TRUE(pointers.has_value());
113  ASSERT_EQ(pointers->size(), 2u);
114  EXPECT_EQ((*pointers)[0].change, flutter::PointerData::Change::kAdd);
115  EXPECT_EQ((*pointers)[1].change, flutter::PointerData::Change::kDown);
116 
117  // Fuchsia CHANGE -> Flutter MOVE
118  events = TouchEventBuilder::New()
119  .AddTime(2222000u)
120  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
121  .BuildAsVector();
122  touch_source_->ScheduleCallback(std::move(events));
123  RunLoopUntilIdle();
124 
125  ASSERT_TRUE(pointers.has_value());
126  ASSERT_EQ(pointers->size(), 1u);
127  EXPECT_EQ((*pointers)[0].change, flutter::PointerData::Change::kMove);
128 
129  // Fuchsia REMOVE -> Flutter UP+REMOVE
130  events = TouchEventBuilder::New()
131  .AddTime(3333000u)
132  .AddSample(kIxnOne, fup_EventPhase::REMOVE, {10.f, 10.f})
133  .BuildAsVector();
134  touch_source_->ScheduleCallback(std::move(events));
135  RunLoopUntilIdle();
136 
137  ASSERT_TRUE(pointers.has_value());
138  ASSERT_EQ(pointers->size(), 2u);
139  EXPECT_EQ((*pointers)[0].change, flutter::PointerData::Change::kUp);
140  EXPECT_EQ((*pointers)[1].change, flutter::PointerData::Change::kRemove);
141 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [8/77]

flutter_runner::testing::TEST_F ( FlatlandConnectionTest  ,
FlatlandDisconnect   
)

Definition at line 101 of file flatland_connection_unittests.cc.

References flutter_runner::testing::FakeFlatland::Disconnect(), flutter_runner::testing::FlatlandConnectionTest::fake_flatland(), flutter::testing::GetCurrentTestName(), flutter_runner::testing::FlatlandConnectionTest::loop(), flutter_runner::testing::FlatlandConnectionTest::TakeFlatlandHandle(), and fml::TimeDelta::Zero().

101  {
102  // Set up a callback which allows sensing of the error state.
103  bool error_fired = false;
104  fml::closure on_session_error = [&error_fired]() { error_fired = true; };
105 
106  // Create the FlatlandConnection but don't pump the loop. No FIDL calls are
107  // completed yet.
108  flutter_runner::FlatlandConnection flatland_connection(
109  GetCurrentTestName(), TakeFlatlandHandle(), std::move(on_session_error),
110  [](auto...) { FAIL(); }, 1, fml::TimeDelta::Zero());
111  EXPECT_FALSE(error_fired);
112 
113  // Simulate a flatland disconnection, then Pump the loop. The error callback
114  // will fire.
115  fake_flatland().Disconnect(
116  fuchsia::ui::composition::FlatlandError::BAD_OPERATION);
117  loop().RunUntilIdle();
118  EXPECT_TRUE(error_fired);
119 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
std::function< void()> closure
Definition: closure.h:14

◆ TEST_F() [9/77]

flutter_runner::testing::TEST_F ( FlatlandConnectionTest  ,
BasicPresent   
)

Definition at line 121 of file flatland_connection_unittests.cc.

References event, flutter_runner::testing::FlatlandConnectionTest::fake_flatland(), flutter_runner::testing::FakeFlatland::FireOnFramePresentedEvent(), flutter_runner::testing::FakeFlatland::FireOnNextFrameBeginEvent(), flutter::testing::GetCurrentTestName(), flutter_runner::kDefaultFlatlandPresentationInterval, flutter_runner::testing::FlatlandConnectionTest::loop(), flutter_runner::testing::FakeFlatland::SetPresentHandler(), flutter_runner::testing::FlatlandConnectionTest::TakeFlatlandHandle(), and fml::TimeDelta::Zero().

121  {
122  // Set up callbacks which allow sensing of how many presents were handled.
123  size_t presents_called = 0u;
124  zx_handle_t release_fence_handle;
125  fake_flatland().SetPresentHandler([&presents_called,
126  &release_fence_handle](auto present_args) {
127  presents_called++;
128  release_fence_handle = present_args.release_fences().empty()
129  ? ZX_HANDLE_INVALID
130  : present_args.release_fences().front().get();
131  });
132 
133  // Set up a callback which allows sensing of how many vsync's
134  // (`OnFramePresented` events) were handled.
135  size_t vsyncs_handled = 0u;
136  on_frame_presented_event on_frame_presented = [&vsyncs_handled](auto...) {
137  vsyncs_handled++;
138  };
139 
140  // Create the FlatlandConnection but don't pump the loop. No FIDL calls are
141  // completed yet.
142  flutter_runner::FlatlandConnection flatland_connection(
143  GetCurrentTestName(), TakeFlatlandHandle(), []() { FAIL(); },
144  std::move(on_frame_presented), 1, fml::TimeDelta::Zero());
145  EXPECT_EQ(presents_called, 0u);
146  EXPECT_EQ(vsyncs_handled, 0u);
147 
148  // Pump the loop. Nothing is called.
149  loop().RunUntilIdle();
150  EXPECT_EQ(presents_called, 0u);
151  EXPECT_EQ(vsyncs_handled, 0u);
152 
153  // Simulate an AwaitVsync that comes after the first call.
154  bool await_vsync_fired = false;
155  AwaitVsyncChecked(flatland_connection, await_vsync_fired,
157  EXPECT_TRUE(await_vsync_fired);
158 
159  // Call Present and Pump the loop; `Present` and its callback is called. No
160  // release fence should be queued.
161  await_vsync_fired = false;
162  zx::event first_release_fence;
163  zx::event::create(0, &first_release_fence);
164  const zx_handle_t first_release_fence_handle = first_release_fence.get();
165  flatland_connection.EnqueueReleaseFence(std::move(first_release_fence));
166  flatland_connection.Present();
167  loop().RunUntilIdle();
168  EXPECT_EQ(presents_called, 1u);
169  EXPECT_EQ(release_fence_handle, ZX_HANDLE_INVALID);
170  EXPECT_EQ(vsyncs_handled, 0u);
171  EXPECT_FALSE(await_vsync_fired);
172 
173  // Fire the `OnNextFrameBegin` event. AwaitVsync should be fired.
174  AwaitVsyncChecked(flatland_connection, await_vsync_fired,
176  fuchsia::ui::composition::OnNextFrameBeginValues on_next_frame_begin_values;
177  on_next_frame_begin_values.set_additional_present_credits(3);
178  fake_flatland().FireOnNextFrameBeginEvent(
179  std::move(on_next_frame_begin_values));
180  loop().RunUntilIdle();
181  EXPECT_TRUE(await_vsync_fired);
182 
183  // Fire the `OnFramePresented` event associated with the first `Present`,
184  fake_flatland().FireOnFramePresentedEvent(
185  fuchsia::scenic::scheduling::FramePresentedInfo());
186  loop().RunUntilIdle();
187  EXPECT_EQ(vsyncs_handled, 1u);
188 
189  // Call Present for a second time and Pump the loop; `Present` and its
190  // callback is called. Release fences for the earlier present is used.
191  await_vsync_fired = false;
192  flatland_connection.Present();
193  loop().RunUntilIdle();
194  EXPECT_EQ(presents_called, 2u);
195  EXPECT_EQ(release_fence_handle, first_release_fence_handle);
196 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
FlKeyEvent * event
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event
static constexpr fml::TimeDelta kDefaultFlatlandPresentationInterval

◆ TEST_F() [10/77]

flutter_runner::testing::TEST_F ( FocusDelegateTest  ,
RequestFocusTest   
)

Definition at line 132 of file focus_delegate_unittests.cc.

References flutter_runner::testing::FakePlatformMessageResponse::Create(), flutter_runner::testing::FocusDelegateTest::focus_delegate_, flutter_runner::testing::FocusDelegateTest::focuser_, message, ParsePlatformMessage(), and flutter_runner::testing::FocusDelegateTest::RunLoopUntilIdle().

132  {
133  // This "Mock" ViewRef serves as the target for the RequestFocus operation.
134  auto mock_view_ref_pair = scenic::ViewRefPair::New();
135  // Create the platform message request.
136  std::ostringstream message;
137  message << "{"
138  << " \"method\":\"View.focus.request\","
139  << " \"args\": {"
140  << " \"viewRef\":"
141  << mock_view_ref_pair.view_ref.reference.get() << " }"
142  << "}";
143 
144  // Dispatch the plaform message request with an expected completion response.
145  auto response = FakePlatformMessageResponse::Create();
146  EXPECT_TRUE(focus_delegate_->HandlePlatformMessage(
147  ParsePlatformMessage(message.str()), response));
148  RunLoopUntilIdle();
149 
150  response->ExpectCompleted("[0]");
151  EXPECT_TRUE(focuser_->request_focus_called());
152 }
Win32Message message
rapidjson::Value ParsePlatformMessage(std::string json)

◆ TEST_F() [11/77]

flutter_runner::testing::TEST_F ( GfxSessionConnectionTest  ,
Initialization   
)

Definition at line 133 of file gfx_session_connection_unittests.cc.

References flutter_runner::testing::GfxSessionConnectionTest::fake_session(), flutter::testing::GetCurrentTestName(), flutter_runner::testing::GfxSessionConnectionTest::GetInspectNode(), flutter_runner::kDefaultPresentationInterval, flutter_runner::testing::GfxSessionConnectionTest::loop(), flutter_runner::testing::GfxSessionConnectionTest::TakeSessionHandle(), and fml::TimeDelta::Zero().

133  {
134  // Create the GfxSessionConnection but don't pump the loop. No FIDL calls are
135  // completed yet.
136  const std::string debug_name = GetCurrentTestName();
137  flutter_runner::GfxSessionConnection session_connection(
138  debug_name, GetInspectNode(), TakeSessionHandle(), []() { FAIL(); },
139  [](auto...) { FAIL(); }, 1, fml::TimeDelta::Zero());
140  EXPECT_EQ(fake_session().debug_name(), "");
141  EXPECT_TRUE(fake_session().command_queue().empty());
142 
143  // Simulate an AwaitVsync that comes immediately, before
144  // `RequestPresentationTimes` returns.
145  bool await_vsync_fired = false;
146  AwaitVsyncChecked(session_connection, await_vsync_fired,
148  EXPECT_TRUE(await_vsync_fired);
149 
150  // Ensure the debug name is set.
151  loop().RunUntilIdle();
152  EXPECT_EQ(fake_session().debug_name(), debug_name);
153  EXPECT_TRUE(fake_session().command_queue().empty());
154 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
static constexpr fml::TimeDelta kDefaultPresentationInterval

◆ TEST_F() [12/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Phase_FuchsiaCancelBecomesFlutterCancel   
)

Definition at line 143 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), flutter::PointerData::kAdd, flutter::PointerData::kCancel, flutter::PointerData::kDown, kIxnOne, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

143  {
144  std::optional<std::vector<flutter::PointerData>> pointers;
145  pointer_delegate_->WatchLoop(
146  [&pointers](std::vector<flutter::PointerData> events) {
147  pointers = std::move(events);
148  });
149  RunLoopUntilIdle(); // Server gets watch call.
150 
151  // Fuchsia ADD -> Flutter ADD+DOWN
152  std::vector<fup_TouchEvent> events =
153  TouchEventBuilder::New()
154  .AddTime(1111000u)
155  .AddViewParameters(kRect, kRect, kIdentity)
156  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
157  .AddResult(
158  {.interaction = kIxnOne, .status = fup_TouchIxnStatus::GRANTED})
159  .BuildAsVector();
160  touch_source_->ScheduleCallback(std::move(events));
161  RunLoopUntilIdle();
162 
163  ASSERT_TRUE(pointers.has_value());
164  ASSERT_EQ(pointers->size(), 2u);
165  EXPECT_EQ((*pointers)[0].change, flutter::PointerData::Change::kAdd);
166  EXPECT_EQ((*pointers)[1].change, flutter::PointerData::Change::kDown);
167 
168  // Fuchsia CANCEL -> Flutter CANCEL
169  events = TouchEventBuilder::New()
170  .AddTime(2222000u)
171  .AddSample(kIxnOne, fup_EventPhase::CANCEL, {10.f, 10.f})
172  .BuildAsVector();
173  touch_source_->ScheduleCallback(std::move(events));
174  RunLoopUntilIdle();
175 
176  ASSERT_TRUE(pointers.has_value());
177  ASSERT_EQ(pointers->size(), 1u);
178  EXPECT_EQ((*pointers)[0].change, flutter::PointerData::Change::kCancel);
179 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [13/77]

flutter_runner::testing::TEST_F ( FocusDelegateTest  ,
RequestFocusFailTest   
)

Definition at line 156 of file focus_delegate_unittests.cc.

References flutter_runner::testing::FakePlatformMessageResponse::Create(), flutter_runner::testing::FocusDelegateTest::focus_delegate_, flutter_runner::testing::FocusDelegateTest::focuser_, message, ParsePlatformMessage(), and flutter_runner::testing::FocusDelegateTest::RunLoopUntilIdle().

156  {
157  // This "Mock" ViewRef serves as the target for the RequestFocus operation.
158  auto mock_view_ref_pair = scenic::ViewRefPair::New();
159  // We're testing the focus failure case.
160  focuser_->fail_request_focus();
161  // Create the platform message request.
162  std::ostringstream message;
163  message << "{"
164  << " \"method\":\"View.focus.request\","
165  << " \"args\": {"
166  << " \"viewRef\":"
167  << mock_view_ref_pair.view_ref.reference.get() << " }"
168  << "}";
169 
170  // Dispatch the plaform message request with an expected completion response.
171  auto response = FakePlatformMessageResponse::Create();
172  EXPECT_TRUE(focus_delegate_->HandlePlatformMessage(
173  ParsePlatformMessage(message.str()), response));
174  RunLoopUntilIdle();
175 
176  response->ExpectCompleted(
177  "[" +
178  std::to_string(
179  static_cast<std::underlying_type_t<fuchsia::ui::views::Error>>(
180  fuchsia::ui::views::Error::DENIED)) +
181  "]");
182  EXPECT_TRUE(focuser_->request_focus_called());
183 }
Win32Message message
rapidjson::Value ParsePlatformMessage(std::string json)

◆ TEST_F() [14/77]

flutter_runner::testing::TEST_F ( GfxSessionConnectionTest  ,
SessionDisconnect   
)

Definition at line 156 of file gfx_session_connection_unittests.cc.

References flutter_runner::testing::FakeSession::DisconnectSession(), flutter_runner::testing::GfxSessionConnectionTest::fake_session(), flutter::testing::GetCurrentTestName(), flutter_runner::testing::GfxSessionConnectionTest::GetInspectNode(), flutter_runner::testing::GfxSessionConnectionTest::loop(), flutter_runner::testing::GfxSessionConnectionTest::TakeSessionHandle(), and fml::TimeDelta::Zero().

156  {
157  // Set up a callback which allows sensing of the session error state.
158  bool session_error_fired = false;
159  fml::closure on_session_error = [&session_error_fired]() {
160  session_error_fired = true;
161  };
162 
163  // Create the GfxSessionConnection but don't pump the loop. No FIDL calls are
164  // completed yet.
165  flutter_runner::GfxSessionConnection session_connection(
166  GetCurrentTestName(), GetInspectNode(), TakeSessionHandle(),
167  std::move(on_session_error), [](auto...) { FAIL(); }, 1,
169  EXPECT_FALSE(session_error_fired);
170 
171  // Simulate a session disconnection, then Pump the loop. The session error
172  // callback will fire.
173  fake_session().DisconnectSession();
174  loop().RunUntilIdle();
175  EXPECT_TRUE(session_error_fired);
176 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
std::function< void()> closure
Definition: closure.h:14

◆ TEST_F() [15/77]

flutter_runner::testing::TEST_F ( GfxSessionConnectionTest  ,
BasicPresent   
)

Definition at line 178 of file gfx_session_connection_unittests.cc.

References flutter_runner::testing::GfxSessionConnectionTest::fake_session(), flutter_runner::testing::FakeSession::FireOnFramePresentedEvent(), flutter::testing::GetCurrentTestName(), flutter_runner::testing::GfxSessionConnectionTest::GetInspectNode(), flutter_runner::kDefaultPresentationInterval, flutter_runner::testing::GfxSessionConnectionTest::loop(), flutter_runner::testing::FakeSession::SetPresent2Handler(), flutter_runner::testing::FakeSession::SetRequestPresentationTimesHandler(), flutter_runner::testing::GfxSessionConnectionTest::TakeSessionHandle(), and fml::TimeDelta::Zero().

178  {
179  // Set up callbacks which allow sensing of how many presents
180  // (`RequestPresentationTimes` or `Present` calls) were handled.
181  size_t request_times_called = 0u;
182  size_t presents_called = 0u;
183  fake_session().SetRequestPresentationTimesHandler([&request_times_called](
184  auto...) -> auto {
185  request_times_called++;
186  return FuturePresentationTimes{
187  .future_presentations = {},
188  .remaining_presents_in_flight_allowed = 1,
189  };
190  });
191  fake_session().SetPresent2Handler([&presents_called](auto...) -> auto {
192  presents_called++;
193  return FuturePresentationTimes{
194  .future_presentations = {},
195  .remaining_presents_in_flight_allowed = 1,
196  };
197  });
198 
199  // Set up a callback which allows sensing of how many vsync's
200  // (`OnFramePresented` events) were handled.
201  size_t vsyncs_handled = 0u;
202  on_frame_presented_event on_frame_presented = [&vsyncs_handled](auto...) {
203  vsyncs_handled++;
204  };
205 
206  // Create the GfxSessionConnection but don't pump the loop. No FIDL calls are
207  // completed yet.
208  flutter_runner::GfxSessionConnection session_connection(
209  GetCurrentTestName(), GetInspectNode(), TakeSessionHandle(),
210  []() { FAIL(); }, std::move(on_frame_presented), 1,
212  EXPECT_TRUE(fake_session().command_queue().empty());
213  EXPECT_EQ(request_times_called, 0u);
214  EXPECT_EQ(presents_called, 0u);
215  EXPECT_EQ(vsyncs_handled, 0u);
216 
217  // Pump the loop; `RequestPresentationTimes`, `Present`, and both of their
218  // callbacks are called.
219  loop().RunUntilIdle();
220  EXPECT_TRUE(fake_session().command_queue().empty());
221  EXPECT_EQ(request_times_called, 1u);
222  EXPECT_EQ(presents_called, 1u);
223  EXPECT_EQ(vsyncs_handled, 0u);
224 
225  // Fire the `OnFramePresented` event associated with the first `Present`, then
226  // pump the loop. The `OnFramePresented` event is resolved.
227  fake_session().FireOnFramePresentedEvent(
228  MakeFramePresentedInfoForOnePresent(0, 0));
229  loop().RunUntilIdle();
230  EXPECT_TRUE(fake_session().command_queue().empty());
231  EXPECT_EQ(request_times_called, 1u);
232  EXPECT_EQ(presents_called, 1u);
233  EXPECT_EQ(vsyncs_handled, 1u);
234 
235  // Simulate an AwaitVsync that comes after the first `OnFramePresented`
236  // event.
237  bool await_vsync_fired = false;
238  AwaitVsyncChecked(session_connection, await_vsync_fired,
240  EXPECT_TRUE(await_vsync_fired);
241 
242  // Call Present and Pump the loop; `Present` and its callback is called.
243  await_vsync_fired = false;
244  session_connection.Present();
245  loop().RunUntilIdle();
246  EXPECT_TRUE(fake_session().command_queue().empty());
247  EXPECT_FALSE(await_vsync_fired);
248  EXPECT_EQ(request_times_called, 1u);
249  EXPECT_EQ(presents_called, 2u);
250  EXPECT_EQ(vsyncs_handled, 1u);
251 
252  // Fire the `OnFramePresented` event associated with the second `Present`,
253  // then pump the loop. The `OnFramePresented` event is resolved.
254  fake_session().FireOnFramePresentedEvent(
255  MakeFramePresentedInfoForOnePresent(0, 0));
256  loop().RunUntilIdle();
257  EXPECT_TRUE(fake_session().command_queue().empty());
258  EXPECT_FALSE(await_vsync_fired);
259  EXPECT_EQ(request_times_called, 1u);
260  EXPECT_EQ(presents_called, 2u);
261  EXPECT_EQ(vsyncs_handled, 2u);
262 
263  // Simulate an AwaitVsync that comes after the second `OnFramePresented`
264  // event.
265  await_vsync_fired = false;
266  AwaitVsyncChecked(session_connection, await_vsync_fired,
269  EXPECT_TRUE(await_vsync_fired);
270 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event
static constexpr fml::TimeDelta kDefaultPresentationInterval

◆ TEST_F() [16/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Coordinates_CorrectMapping   
)

Definition at line 181 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), kIxnOne, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

181  {
182  std::optional<std::vector<flutter::PointerData>> pointers;
183  pointer_delegate_->WatchLoop(
184  [&pointers](std::vector<flutter::PointerData> events) {
185  pointers = std::move(events);
186  });
187  RunLoopUntilIdle(); // Server gets watch call.
188 
189  // Fuchsia ADD event, with a view parameter that maps the viewport identically
190  // to the view. Then the center point of the viewport should map to the center
191  // of the view, (10.f, 10.f).
192  std::vector<fup_TouchEvent> events =
193  TouchEventBuilder::New()
194  .AddTime(2222000u)
195  .AddViewParameters(/*view*/ {{{0, 0}, {20, 20}}},
196  /*viewport*/ {{{0, 0}, {20, 20}}},
197  /*matrix*/ {1, 0, 0, 0, 1, 0, 0, 0, 1})
198  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
199  .AddResult(
200  {.interaction = kIxnOne, .status = fup_TouchIxnStatus::GRANTED})
201  .BuildAsVector();
202  touch_source_->ScheduleCallback(std::move(events));
203  RunLoopUntilIdle();
204 
205  ASSERT_TRUE(pointers.has_value());
206  ASSERT_EQ(pointers->size(), 2u); // ADD - DOWN
207  EXPECT_FLOAT_EQ((*pointers)[0].physical_x, 10.f);
208  EXPECT_FLOAT_EQ((*pointers)[0].physical_y, 10.f);
209  pointers = {};
210 
211  // Fuchsia CHANGE event, with a view parameter that translates the viewport by
212  // (10, 10) within the view. Then the minimal point in the viewport (its
213  // origin) should map to the center of the view, (10.f, 10.f).
214  events = TouchEventBuilder::New()
215  .AddTime(2222000u)
216  .AddViewParameters(/*view*/ {{{0, 0}, {20, 20}}},
217  /*viewport*/ {{{0, 0}, {20, 20}}},
218  /*matrix*/ {1, 0, 0, 0, 1, 0, 10, 10, 1})
219  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {0.f, 0.f})
220  .BuildAsVector();
221  touch_source_->ScheduleCallback(std::move(events));
222  RunLoopUntilIdle();
223 
224  ASSERT_TRUE(pointers.has_value());
225  ASSERT_EQ(pointers->size(), 1u); // MOVE
226  EXPECT_FLOAT_EQ((*pointers)[0].physical_x, 10.f);
227  EXPECT_FLOAT_EQ((*pointers)[0].physical_y, 10.f);
228 
229  // Fuchsia CHANGE event, with a view parameter that scales the viewport by
230  // (0.5, 0.5) within the view. Then the maximal point in the viewport should
231  // map to the center of the view, (10.f, 10.f).
232  events = TouchEventBuilder::New()
233  .AddTime(2222000u)
234  .AddViewParameters(/*view*/ {{{0, 0}, {20, 20}}},
235  /*viewport*/ {{{0, 0}, {20, 20}}},
236  /*matrix*/ {0.5f, 0, 0, 0, 0.5f, 0, 0, 0, 1})
237  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {20.f, 20.f})
238  .BuildAsVector();
239  touch_source_->ScheduleCallback(std::move(events));
240  RunLoopUntilIdle();
241 
242  ASSERT_TRUE(pointers.has_value());
243  ASSERT_EQ(pointers->size(), 1u); // MOVE
244  EXPECT_FLOAT_EQ((*pointers)[0].physical_x, 10.f);
245  EXPECT_FLOAT_EQ((*pointers)[0].physical_y, 10.f);
246 }
constexpr fup_TouchIxnId kIxnOne

◆ TEST_F() [17/77]

flutter_runner::testing::TEST_F ( FakeSessionTest  ,
Initialization   
)

Definition at line 184 of file fake_session_unittests.cc.

References flutter_runner::testing::FakeSessionTest::fake_session(), flutter_runner::testing::FakeSessionTest::loop(), and flutter::size.

184  {
185  EXPECT_EQ(fake_session().debug_name(), "");
186  EXPECT_EQ(fake_session().command_queue().size(), 0u);
187  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
188 
189  // Pump the loop one time; the session should retain its initial state.
190  loop().RunUntilIdle();
191  EXPECT_EQ(fake_session().debug_name(), "");
192  EXPECT_EQ(fake_session().command_queue().size(), 0u);
193  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
194 }
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 observatory The hostname IP address on which the Dart Observatory should be served If not defaults to or::depending on whether ipv6 is specified disable Disable the Dart Observatory The observatory is never available in release mode Bind to the IPv6 localhost address for the Dart Observatory Ignored if observatory 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 Remove all existing persistent cache This is mainly for debugging purposes such as reproducing the shader compilation jank use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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:226

◆ TEST_F() [18/77]

flutter_runner::testing::TEST_F ( FakeSessionTest  ,
DebugLabel   
)

Definition at line 196 of file fake_session_unittests.cc.

References flutter_runner::testing::FakeSessionTest::CreateSession(), flutter_runner::testing::FakeSessionTest::fake_session(), flutter::testing::GetCurrentTestName(), and flutter_runner::testing::FakeSessionTest::loop().

196  {
197  scenic::Session session = CreateSession();
198 
199  // Set the session's debug name. The `SetDebugName` hasn't been processed
200  // yet, so the session's view of the debug name is still empty.
201  const std::string kDebugLabel = GetCurrentTestName();
202  session.SetDebugName(kDebugLabel);
203  session.Flush(); // Bypass local command caching.
204  EXPECT_EQ(fake_session().debug_name(), "");
205 
206  // Pump the loop; the contents of the initial `SetDebugName` should be
207  // processed.
208  loop().RunUntilIdle();
209  EXPECT_EQ(fake_session().debug_name(), kDebugLabel);
210 }
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:13

◆ TEST_F() [19/77]

flutter_runner::testing::TEST_F ( FlatlandConnectionTest  ,
AwaitVsyncBeforePresent   
)

Definition at line 198 of file flatland_connection_unittests.cc.

References flutter_runner::testing::FlatlandConnectionTest::fake_flatland(), flutter::testing::GetCurrentTestName(), flutter_runner::kDefaultFlatlandPresentationInterval, flutter_runner::testing::FlatlandConnectionTest::loop(), flutter_runner::testing::FakeFlatland::SetPresentHandler(), flutter_runner::testing::FlatlandConnectionTest::TakeFlatlandHandle(), and fml::TimeDelta::Zero().

198  {
199  // Set up callbacks which allow sensing of how many presents were handled.
200  size_t presents_called = 0u;
201  fake_flatland().SetPresentHandler(
202  [&presents_called](auto present_args) { presents_called++; });
203 
204  // Create the FlatlandConnection but don't pump the loop. No FIDL calls are
205  // completed yet.
206  flutter_runner::FlatlandConnection flatland_connection(
207  GetCurrentTestName(), TakeFlatlandHandle(), []() { FAIL(); },
208  [](auto...) {}, 1, fml::TimeDelta::Zero());
209  EXPECT_EQ(presents_called, 0u);
210 
211  // Pump the loop. Nothing is called.
212  loop().RunUntilIdle();
213  EXPECT_EQ(presents_called, 0u);
214 
215  // Simulate an AwaitVsync that comes before the first Present.
216  bool await_vsync_callback_fired = false;
217  AwaitVsyncChecked(flatland_connection, await_vsync_callback_fired,
219  EXPECT_TRUE(await_vsync_callback_fired);
220 
221  // Another AwaitVsync that comes before the first Present.
222  await_vsync_callback_fired = false;
223  AwaitVsyncChecked(flatland_connection, await_vsync_callback_fired,
225  EXPECT_TRUE(await_vsync_callback_fired);
226 
227  // Queue Present.
228  flatland_connection.Present();
229  loop().RunUntilIdle();
230  EXPECT_EQ(presents_called, 1u);
231 
232  // Set the callback with AwaitVsync, callback should not be fired
233  await_vsync_callback_fired = false;
234  AwaitVsyncChecked(flatland_connection, await_vsync_callback_fired,
236  EXPECT_FALSE(await_vsync_callback_fired);
237 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
static constexpr fml::TimeDelta kDefaultFlatlandPresentationInterval

◆ TEST_F() [20/77]

flutter_runner::testing::TEST_F ( FakeSessionTest  ,
CommandQueueInvariants   
)

Definition at line 212 of file fake_session_unittests.cc.

References flutter_runner::testing::FakeSessionTest::CreateSession(), flutter_runner::testing::FakeSessionTest::fake_session(), flutter_runner::testing::FakeSessionTest::loop(), node, and flutter::size.

212  {
213  scenic::Session session = CreateSession();
214 
215  // The scene graph is initially empty.
216  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
217 
218  // Create entity node for testing; no creation commands have been processed
219  // yet, so the session's view of the scene graph is empty.
220  std::optional<scenic::EntityNode> node(&session);
221  session.Flush(); // Bypass local command caching.
222  EXPECT_EQ(fake_session().command_queue().size(), 0u);
223  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
224 
225  // Pump the loop; the initial creation command should be enqueued but still
226  // not processed yet, so the session's view of the scene graph is empty.
227  loop().RunUntilIdle();
228  EXPECT_GT(fake_session().command_queue().size(), 0u);
229  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
230 
231  // Present initial scene graph. The `Present` hasn't been processed yet, so
232  // the session's view of the scene graph is still empty.
233  session.Present2(0u, 0u, [](auto...) {});
234  EXPECT_GT(fake_session().command_queue().size(), 0u);
235  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
236 
237  // Pump the loop; the contents of the initial `Present` should be processed.
238  loop().RunUntilIdle();
239  EXPECT_EQ(fake_session().command_queue().size(), 0u);
240  EXPECT_THAT(fake_session().SceneGraph(),
241  IsEntityNodeSceneGraph("", node->id()));
242 }
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 observatory The hostname IP address on which the Dart Observatory should be served If not defaults to or::depending on whether ipv6 is specified disable Disable the Dart Observatory The observatory is never available in release mode Bind to the IPv6 localhost address for the Dart Observatory Ignored if observatory 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 Remove all existing persistent cache This is mainly for debugging purposes such as reproducing the shader compilation jank use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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:226
int32_t id
The unique identifier for this node.
Definition: embedder.h:937
G_BEGIN_DECLS const FlutterSemanticsNode * node

◆ TEST_F() [21/77]

flutter_runner::testing::TEST_F ( FlatlandConnectionTest  ,
OutOfOrderAwait   
)

Definition at line 239 of file flatland_connection_unittests.cc.

References flutter_runner::testing::FlatlandConnectionTest::fake_flatland(), flutter::testing::GetCurrentTestName(), flutter_runner::kDefaultFlatlandPresentationInterval, flutter_runner::testing::FlatlandConnectionTest::loop(), flutter_runner::testing::FlatlandConnectionTest::OnNextFrameBegin(), flutter_runner::testing::FakeFlatland::SetPresentHandler(), flutter_runner::testing::FlatlandConnectionTest::TakeFlatlandHandle(), and fml::TimeDelta::Zero().

239  {
240  // Set up callbacks which allow sensing of how many presents were handled.
241  size_t presents_called = 0u;
242  fake_flatland().SetPresentHandler(
243  [&presents_called](auto present_args) { presents_called++; });
244 
245  // Set up a callback which allows sensing of how many vsync's
246  // (`OnFramePresented` events) were handled.
247  size_t vsyncs_handled = 0u;
248  on_frame_presented_event on_frame_presented = [&vsyncs_handled](auto...) {
249  vsyncs_handled++;
250  };
251 
252  // Create the FlatlandConnection but don't pump the loop. No FIDL calls are
253  // completed yet.
254  flutter_runner::FlatlandConnection flatland_connection(
255  GetCurrentTestName(), TakeFlatlandHandle(), []() { FAIL(); },
256  std::move(on_frame_presented), 1, fml::TimeDelta::Zero());
257  EXPECT_EQ(presents_called, 0u);
258  EXPECT_EQ(vsyncs_handled, 0u);
259 
260  // Pump the loop. Nothing is called.
261  loop().RunUntilIdle();
262  EXPECT_EQ(presents_called, 0u);
263  EXPECT_EQ(vsyncs_handled, 0u);
264 
265  // Simulate an AwaitVsync that comes before the first Present.
266  bool await_vsync_callback_fired = false;
267  AwaitVsyncChecked(flatland_connection, await_vsync_callback_fired,
269  EXPECT_TRUE(await_vsync_callback_fired);
270 
271  // Queue Present.
272  flatland_connection.Present();
273  loop().RunUntilIdle();
274  EXPECT_EQ(presents_called, 1u);
275 
276  // Set the callback with AwaitVsync, callback should not be fired
277  await_vsync_callback_fired = false;
278  AwaitVsyncChecked(flatland_connection, await_vsync_callback_fired,
280  EXPECT_FALSE(await_vsync_callback_fired);
281 
282  // Fire the `OnNextFrameBegin` event. AwaitVsync callback should be fired.
283  await_vsync_callback_fired = false;
284  OnNextFrameBegin(1);
285  loop().RunUntilIdle();
286  EXPECT_TRUE(await_vsync_callback_fired);
287 
288  // Second consecutive ONFB should not call the fire callback and should
289  // instead set it to be pending to fire on next AwaitVsync
290  await_vsync_callback_fired = false;
291  OnNextFrameBegin(1);
292  loop().RunUntilIdle();
293  EXPECT_FALSE(await_vsync_callback_fired);
294 
295  // Now an AwaitVsync should immediately fire the pending callback
296  await_vsync_callback_fired = false;
297  AwaitVsyncChecked(flatland_connection, await_vsync_callback_fired,
299  EXPECT_TRUE(await_vsync_callback_fired);
300 
301  // With the pending callback fired, The new callback should be set for the
302  // next OnNextFrameBegin to call
303  await_vsync_callback_fired = false;
304  AwaitVsyncChecked(flatland_connection, await_vsync_callback_fired,
306  EXPECT_FALSE(await_vsync_callback_fired);
307 
308  // Now OnNextFrameBegin should fire the callback
309  await_vsync_callback_fired = false;
310  OnNextFrameBegin(1);
311  loop().RunUntilIdle();
312  EXPECT_TRUE(await_vsync_callback_fired);
313 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event
static constexpr fml::TimeDelta kDefaultFlatlandPresentationInterval

◆ TEST_F() [22/77]

flutter_runner::testing::TEST_F ( FakeSessionTest  ,
SimpleResourceLifecycle   
)

Definition at line 244 of file fake_session_unittests.cc.

References flutter_runner::testing::FakeSessionTest::CreateSession(), flutter_runner::testing::FakeSessionTest::fake_session(), flutter_runner::testing::FakeSessionTest::loop(), and node.

244  {
245  scenic::Session session = CreateSession();
246 
247  // The scene graph is initially empty.
248  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
249 
250  // Present an initial entity node, pumping the loop to process commands.
251  std::optional<scenic::EntityNode> node(&session);
252  session.Present2(0u, 0u, [](auto...) {});
253  loop().RunUntilIdle();
254  EXPECT_THAT(fake_session().SceneGraph(),
255  IsEntityNodeSceneGraph("", node->id()));
256 
257  // Present a simple property update on the test entity node.
258  const std::string kNodeLabel = "EntityNode";
259  node->SetLabel(kNodeLabel);
260  session.Present2(0u, 0u, [](auto...) {});
261  loop().RunUntilIdle();
262  EXPECT_THAT(fake_session().SceneGraph(),
263  IsEntityNodeSceneGraph(kNodeLabel, node->id()));
264 
265  // Present the destruction of the entity node.
266  node.reset();
267  session.Present2(0u, 0u, [](auto...) {});
268  loop().RunUntilIdle();
269  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
270 }
int32_t id
The unique identifier for this node.
Definition: embedder.h:937
G_BEGIN_DECLS const FlutterSemanticsNode * node

◆ TEST_F() [23/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Coordinates_DownEventClampedToView   
)

Definition at line 248 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), kIxnOne, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

248  {
249  const float kSmallDiscrepancy = -0.00003f;
250 
251  std::optional<std::vector<flutter::PointerData>> pointers;
252  pointer_delegate_->WatchLoop(
253  [&pointers](std::vector<flutter::PointerData> events) {
254  pointers = std::move(events);
255  });
256  RunLoopUntilIdle(); // Server gets watch call.
257 
258  std::vector<fup_TouchEvent> events =
259  TouchEventBuilder::New()
260  .AddTime(1111000u)
261  .AddViewParameters(kRect, kRect, kIdentity)
262  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, kSmallDiscrepancy})
263  .AddResult(
264  {.interaction = kIxnOne, .status = fup_TouchIxnStatus::GRANTED})
265  .BuildAsVector();
266  touch_source_->ScheduleCallback(std::move(events));
267  RunLoopUntilIdle();
268 
269  ASSERT_TRUE(pointers.has_value());
270  ASSERT_EQ(pointers->size(), 2u);
271 
272  const auto& add_event = (*pointers)[0];
273  EXPECT_FLOAT_EQ(add_event.physical_x, 10.f);
274  EXPECT_FLOAT_EQ(add_event.physical_y, kSmallDiscrepancy);
275 
276  const auto& down_event = (*pointers)[1];
277  EXPECT_FLOAT_EQ(down_event.physical_x, 10.f);
278  EXPECT_EQ(down_event.physical_y, 0.f);
279 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [24/77]

flutter_runner::testing::TEST_F ( FakeSessionTest  ,
ResourceReferenceCounting   
)

Definition at line 272 of file fake_session_unittests.cc.

References flutter_runner::testing::FakeSessionTest::CreateSession(), flutter_runner::testing::FakeSessionTest::fake_session(), kInvalidFakeResourceId, flutter_runner::testing::FakeSessionTest::loop(), and flutter_runner::testing::FakeSession::SceneGraph().

272  {
273  scenic::Session session = CreateSession();
274 
275  // Present a chain of 4 entity nodes for testing.
276  std::array<std::optional<scenic::EntityNode>, 4> nodes{
277  std::optional<scenic::EntityNode>(&session),
278  std::optional<scenic::EntityNode>(&session),
279  std::optional<scenic::EntityNode>(&session),
280  std::optional<scenic::EntityNode>(&session)};
281  const std::string kNodeLabel = "EntityNode";
282  for (size_t i = 0; i < 4; i++) {
283  nodes[i]->SetLabel(kNodeLabel + std::string(1, '0' + i));
284  if (i < 3) {
285  nodes[i]->AddChild(*nodes[i + 1]);
286  }
287  }
288  session.Present2(0u, 0u, [](auto...) {});
289  loop().RunUntilIdle();
290  {
291  auto scene_graph = fake_session().SceneGraph();
292  EXPECT_EQ(scene_graph.root_view_id, kInvalidFakeResourceId);
293  EXPECT_EQ(scene_graph.buffer_collection_map.size(), 0u);
294  EXPECT_EQ(scene_graph.resource_map.size(), 4u);
295  EXPECT_EQ(scene_graph.label_map.size(), 4u);
296  for (size_t i = 0; i < 4; i++) {
297  const std::string node_i_label = kNodeLabel + std::string(1, '0' + i);
298  ASSERT_EQ(scene_graph.resource_map.count(nodes[i]->id()), 1u);
299  ASSERT_EQ(scene_graph.label_map.count(node_i_label), 1u);
300 
301  const auto node_i = scene_graph.resource_map[nodes[i]->id()];
302  const auto node_i_label_resources = scene_graph.label_map[node_i_label];
303  EXPECT_EQ(node_i_label_resources.size(), 1u);
304  EXPECT_FALSE(node_i_label_resources[0].expired());
305  EXPECT_EQ(node_i_label_resources[0].lock(), node_i);
306  }
307 
308  EXPECT_THAT(
309  scene_graph.resource_map[nodes[0]->id()],
310  Pointee(IsEntityNode(
311  nodes[0]->id(), kNodeLabel + std::string(1, '0'),
312  ElementsAre(Pointee(IsEntityNode(
313  nodes[1]->id(), kNodeLabel + std::string(1, '1'),
314  ElementsAre(Pointee(IsEntityNode(
315  nodes[2]->id(), kNodeLabel + std::string(1, '2'),
316  ElementsAre(Pointee(IsEntityNode(
317  nodes[3]->id(), kNodeLabel + std::string(1, '3'),
318  IsEmpty()))))))))))));
319  }
320 
321  // Destroy node #0. It should be dropped immediately since it has no parent.
322  nodes[0].reset();
323  session.Present2(0u, 0u, [](auto...) {});
324  loop().RunUntilIdle();
325  {
326  auto scene_graph = fake_session().SceneGraph();
327  EXPECT_EQ(scene_graph.root_view_id, kInvalidFakeResourceId);
328  EXPECT_EQ(scene_graph.buffer_collection_map.size(), 0u);
329  EXPECT_EQ(scene_graph.resource_map.size(), 3u);
330  EXPECT_EQ(scene_graph.label_map.size(), 3u);
331  for (size_t i = 1; i < 4; i++) {
332  const std::string node_i_label = kNodeLabel + std::string(1, '0' + i);
333  ASSERT_EQ(scene_graph.resource_map.count(nodes[i]->id()), 1u);
334  ASSERT_EQ(scene_graph.label_map.count(node_i_label), 1u);
335 
336  const auto node_i = scene_graph.resource_map[nodes[i]->id()];
337  const auto node_i_label_resources = scene_graph.label_map[node_i_label];
338  EXPECT_EQ(node_i_label_resources.size(), 1u);
339  EXPECT_FALSE(node_i_label_resources[0].expired());
340  EXPECT_EQ(node_i_label_resources[0].lock(), node_i);
341  }
342 
343  EXPECT_EQ(scene_graph.resource_map.count(nodes[0]->id()), 0u);
344  EXPECT_THAT(scene_graph.resource_map[nodes[1]->id()],
345  Pointee(IsEntityNode(
346  nodes[1]->id(), kNodeLabel + std::string(1, '1'),
347  ElementsAre(Pointee(IsEntityNode(
348  nodes[2]->id(), kNodeLabel + std::string(1, '2'),
349  ElementsAre(Pointee(IsEntityNode(
350  nodes[3]->id(), kNodeLabel + std::string(1, '3'),
351  IsEmpty())))))))));
352  }
353 
354  // Destroy node #2. It should still exist in the tree and the labels map
355  // because it has a parent, but it is removed from the resource map.
356  nodes[2].reset();
357  session.Present2(0u, 0u, [](auto...) {});
358  loop().RunUntilIdle();
359  {
360  auto scene_graph = fake_session().SceneGraph();
361  EXPECT_EQ(scene_graph.root_view_id, kInvalidFakeResourceId);
362  EXPECT_EQ(scene_graph.buffer_collection_map.size(), 0u);
363  EXPECT_EQ(scene_graph.resource_map.size(), 2u);
364  EXPECT_EQ(scene_graph.label_map.size(), 3u);
365  for (size_t i = 1; i < 4; i++) {
366  const std::string node_i_label = kNodeLabel + std::string(1, '0' + i);
367  ASSERT_EQ(scene_graph.label_map.count(node_i_label), 1u);
368  ASSERT_EQ(scene_graph.resource_map.count(nodes[i]->id()),
369  i != 2 ? 1u : 0u);
370 
371  const auto node_i_label_resources = scene_graph.label_map[node_i_label];
372  EXPECT_EQ(node_i_label_resources.size(), 1u);
373  EXPECT_FALSE(node_i_label_resources[0].expired());
374 
375  if (i != 2) {
376  const auto node_i = scene_graph.resource_map[nodes[i]->id()];
377  EXPECT_EQ(node_i_label_resources[0].lock(), node_i);
378  } else {
379  EXPECT_EQ(scene_graph.resource_map.count(nodes[i]->id()), 0u);
380  }
381  }
382 
383  EXPECT_THAT(scene_graph.resource_map[nodes[1]->id()],
384  Pointee(IsEntityNode(
385  nodes[1]->id(), kNodeLabel + std::string(1, '1'),
386  ElementsAre(Pointee(IsEntityNode(
387  nodes[2]->id(), kNodeLabel + std::string(1, '2'),
388  ElementsAre(Pointee(IsEntityNode(
389  nodes[3]->id(), kNodeLabel + std::string(1, '3'),
390  IsEmpty())))))))));
391  }
392 
393  // Destroy node #3. It should still exist in the tree and the labels map
394  // because it has a grand-parent, but it is removed from the resource map.
395  nodes[3].reset();
396  session.Present2(0u, 0u, [](auto...) {});
397  loop().RunUntilIdle();
398  {
399  auto scene_graph = fake_session().SceneGraph();
400  EXPECT_EQ(scene_graph.root_view_id, kInvalidFakeResourceId);
401  EXPECT_EQ(scene_graph.buffer_collection_map.size(), 0u);
402  EXPECT_EQ(scene_graph.resource_map.size(), 1u);
403  EXPECT_EQ(scene_graph.label_map.size(), 3u);
404  for (size_t i = 1; i < 4; i++) {
405  const std::string node_i_label = kNodeLabel + std::string(1, '0' + i);
406  ASSERT_EQ(scene_graph.label_map.count(node_i_label), 1u);
407  ASSERT_EQ(scene_graph.resource_map.count(nodes[i]->id()),
408  i < 2 ? 1u : 0u);
409 
410  const auto node_i_label_resources = scene_graph.label_map[node_i_label];
411  EXPECT_EQ(node_i_label_resources.size(), 1u);
412  EXPECT_FALSE(node_i_label_resources[0].expired());
413 
414  if (i < 2) {
415  const auto node_i = scene_graph.resource_map[nodes[i]->id()];
416  EXPECT_EQ(node_i_label_resources[0].lock(), node_i);
417  } else {
418  EXPECT_EQ(scene_graph.resource_map.count(nodes[i]->id()), 0u);
419  }
420  }
421 
422  EXPECT_THAT(scene_graph.resource_map[nodes[1]->id()],
423  Pointee(IsEntityNode(
424  nodes[1]->id(), kNodeLabel + std::string(1, '1'),
425  ElementsAre(Pointee(IsEntityNode(
426  nodes[2]->id(), kNodeLabel + std::string(1, '2'),
427  ElementsAre(Pointee(IsEntityNode(
428  nodes[3]->id(), kNodeLabel + std::string(1, '3'),
429  IsEmpty())))))))));
430  }
431 }
constexpr FakeResourceId kInvalidFakeResourceId

◆ TEST_F() [25/77]

flutter_runner::testing::TEST_F ( GfxSessionConnectionTest  ,
AwaitVsyncBackpressure   
)

Definition at line 272 of file gfx_session_connection_unittests.cc.

References flutter_runner::testing::GfxSessionConnectionTest::fake_session(), flutter_runner::testing::FakeSession::FireOnFramePresentedEvent(), flutter::testing::GetCurrentTestName(), flutter_runner::testing::GfxSessionConnectionTest::GetInspectNode(), flutter_runner::kDefaultPresentationInterval, flutter_runner::testing::GfxSessionConnectionTest::loop(), flutter_runner::testing::FakeSession::SetPresent2Handler(), flutter_runner::testing::GfxSessionConnectionTest::TakeSessionHandle(), and fml::TimeDelta::Zero().

272  {
273  // Set up a callback which allows sensing of how many presents
274  // (`Present` calls) were handled.
275  size_t presents_called = 0u;
276  fake_session().SetPresent2Handler([&presents_called](auto...) -> auto {
277  presents_called++;
278  return FuturePresentationTimes{
279  .future_presentations = {},
280  .remaining_presents_in_flight_allowed = 1,
281  };
282  });
283 
284  // Set up a callback which allows sensing of how many vsync's
285  // (`OnFramePresented` events) were handled.
286  size_t vsyncs_handled = 0u;
287  on_frame_presented_event on_frame_presented = [&vsyncs_handled](auto...) {
288  vsyncs_handled++;
289  };
290 
291  // Create the GfxSessionConnection but don't pump the loop. No FIDL calls are
292  // completed yet.
293  flutter_runner::GfxSessionConnection session_connection(
294  GetCurrentTestName(), GetInspectNode(), TakeSessionHandle(),
295  []() { FAIL(); }, std::move(on_frame_presented), 1,
297  EXPECT_EQ(presents_called, 0u);
298  EXPECT_EQ(vsyncs_handled, 0u);
299 
300  // Pump the loop; `RequestPresentationTimes`, `Present`, and both of their
301  // callbacks are called.
302  loop().RunUntilIdle();
303  EXPECT_EQ(presents_called, 1u);
304  EXPECT_EQ(vsyncs_handled, 0u);
305 
306  // Simulate an AwaitVsync that comes before the first `OnFramePresented`
307  // event.
308  bool await_vsync_fired = false;
309  AwaitVsyncChecked(session_connection, await_vsync_fired,
311  EXPECT_FALSE(await_vsync_fired);
312 
313  // Fire the `OnFramePresented` event associated with the first `Present`, then
314  // pump the loop. The `OnFramePresented` event is resolved. The AwaitVsync
315  // callback is resolved.
316  fake_session().FireOnFramePresentedEvent(
317  MakeFramePresentedInfoForOnePresent(0, 0));
318  loop().RunUntilIdle();
319  EXPECT_TRUE(await_vsync_fired);
320  EXPECT_EQ(presents_called, 1u);
321  EXPECT_EQ(vsyncs_handled, 1u);
322 
323  // Simulate an AwaitVsync that comes before the second `Present`.
324  await_vsync_fired = false;
325  AwaitVsyncChecked(session_connection, await_vsync_fired,
328  EXPECT_TRUE(await_vsync_fired);
329 
330  // Call Present and Pump the loop; `Present` and its callback is called.
331  await_vsync_fired = false;
332  session_connection.Present();
333  loop().RunUntilIdle();
334  EXPECT_FALSE(await_vsync_fired);
335  EXPECT_EQ(presents_called, 2u);
336  EXPECT_EQ(vsyncs_handled, 1u);
337 
338  // Simulate an AwaitVsync that comes before the second `OnFramePresented`
339  // event.
340  await_vsync_fired = false;
341  AwaitVsyncChecked(session_connection, await_vsync_fired,
344  EXPECT_FALSE(await_vsync_fired);
345 
346  // Fire the `OnFramePresented` event associated with the second `Present`,
347  // then pump the loop. The `OnFramePresented` event is resolved.
348  fake_session().FireOnFramePresentedEvent(
349  MakeFramePresentedInfoForOnePresent(0, 0));
350  loop().RunUntilIdle();
351  EXPECT_TRUE(await_vsync_fired);
352  EXPECT_EQ(presents_called, 2u);
353  EXPECT_EQ(vsyncs_handled, 2u);
354 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event
static constexpr fml::TimeDelta kDefaultPresentationInterval

◆ TEST_F() [26/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_FirstResponseIsEmpty   
)

Definition at line 281 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

281  {
282  bool called = false;
283  pointer_delegate_->WatchLoop(
284  [&called](std::vector<flutter::PointerData> events) { called = true; });
285  RunLoopUntilIdle(); // Server gets Watch call.
286 
287  EXPECT_FALSE(called); // No events yet received to forward to client.
288  // Server sees an initial "response" from client, which is empty, by contract.
289  const auto responses = touch_source_->UploadedResponses();
290  ASSERT_TRUE(responses.has_value());
291  ASSERT_EQ(responses->size(), 0u);
292 }

◆ TEST_F() [27/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_ResponseMatchesEarlierEvents   
)

Definition at line 294 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), flutter::testing::Build(), flutter_runner::testing::TouchEventBuilder::BuildAsVector(), flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

294  {
295  std::optional<std::vector<flutter::PointerData>> pointers;
296  pointer_delegate_->WatchLoop(
297  [&pointers](std::vector<flutter::PointerData> events) {
298  pointers = std::move(events);
299  });
300  RunLoopUntilIdle(); // Server gets watch call.
301 
302  // Fuchsia view parameter only. Empty response.
303  std::vector<fup_TouchEvent> events =
304  TouchEventBuilder::New()
305  .AddTime(1111000u)
306  .AddViewParameters(kRect, kRect, kIdentity)
307  .BuildAsVector();
308 
309  // Fuchsia ptr 1 ADD sample. Yes response.
310  fup_TouchEvent e1 =
311  TouchEventBuilder::New()
312  .AddTime(1111000u)
313  .AddViewParameters(kRect, kRect, kIdentity)
314  .AddSample({.device_id = 0u, .pointer_id = 1u, .interaction_id = 3u},
315  fup_EventPhase::ADD, {10.f, 10.f})
316  .Build();
317  events.emplace_back(std::move(e1));
318 
319  // Fuchsia ptr 2 ADD sample. Yes response.
320  fup_TouchEvent e2 =
321  TouchEventBuilder::New()
322  .AddTime(1111000u)
323  .AddSample({.device_id = 0u, .pointer_id = 2u, .interaction_id = 3u},
324  fup_EventPhase::ADD, {5.f, 5.f})
325  .Build();
326  events.emplace_back(std::move(e2));
327 
328  // Fuchsia ptr 3 ADD sample. Yes response.
329  fup_TouchEvent e3 =
330  TouchEventBuilder::New()
331  .AddTime(1111000u)
332  .AddSample({.device_id = 0u, .pointer_id = 3u, .interaction_id = 3u},
333  fup_EventPhase::ADD, {1.f, 1.f})
334  .Build();
335  events.emplace_back(std::move(e3));
336  touch_source_->ScheduleCallback(std::move(events));
337  RunLoopUntilIdle();
338 
339  const auto responses = touch_source_->UploadedResponses();
340  ASSERT_TRUE(responses.has_value());
341  ASSERT_EQ(responses.value().size(), 4u);
342  // Event 0 did not carry a sample, so no response.
343  EXPECT_FALSE(responses.value()[0].has_response_type());
344  // Events 1-3 had a sample, must have a response.
345  EXPECT_TRUE(responses.value()[1].has_response_type());
346  EXPECT_EQ(responses.value()[1].response_type(), fup_TouchResponseType::YES);
347  EXPECT_TRUE(responses.value()[2].has_response_type());
348  EXPECT_EQ(responses.value()[2].response_type(), fup_TouchResponseType::YES);
349  EXPECT_TRUE(responses.value()[3].has_response_type());
350  EXPECT_EQ(responses.value()[3].response_type(), fup_TouchResponseType::YES);
351 }
constexpr std::array< std::array< float, 2 >, 2 > kRect
static sk_sp< DisplayList > Build(size_t g_index, size_t v_index)
constexpr std::array< float, 9 > kIdentity
fuchsia::ui::pointer::TouchEvent fup_TouchEvent

◆ TEST_F() [28/77]

flutter_runner::testing::TEST_F ( FlatlandConnectionTest  ,
PresentCreditExhaustion   
)

Definition at line 315 of file flatland_connection_unittests.cc.

References event, flutter_runner::testing::FlatlandConnectionTest::fake_flatland(), flutter::testing::GetCurrentTestName(), flutter_runner::testing::FlatlandConnectionTest::loop(), fml::TimePoint::Now(), flutter_runner::testing::FlatlandConnectionTest::OnNextFrameBegin(), flutter_runner::testing::FakeFlatland::SetPresentHandler(), flutter_runner::testing::FlatlandConnectionTest::TakeFlatlandHandle(), and fml::TimeDelta::Zero().

315  {
316  // Set up callbacks which allow sensing of how many presents were handled.
317  size_t num_presents_called = 0u;
318  size_t num_release_fences = 0u;
319  size_t num_acquire_fences = 0u;
320 
321  auto reset_test_counters = [&num_presents_called, &num_acquire_fences,
322  &num_release_fences]() {
323  num_presents_called = 0u;
324  num_release_fences = 0u;
325  num_acquire_fences = 0u;
326  };
327 
328  fake_flatland().SetPresentHandler(
329  [&num_presents_called, &num_acquire_fences, &num_release_fences](
330  fuchsia::ui::composition::PresentArgs present_args) {
331  num_presents_called++;
332  num_acquire_fences = present_args.acquire_fences().size();
333  num_release_fences = present_args.release_fences().size();
334  });
335 
336  // Create the FlatlandConnection but don't pump the loop. No FIDL calls are
337  // completed yet.
338  on_frame_presented_event on_frame_presented = [](auto...) {};
339  flutter_runner::FlatlandConnection flatland_connection(
340  GetCurrentTestName(), TakeFlatlandHandle(), []() { FAIL(); },
341  std::move(on_frame_presented), 1, fml::TimeDelta::Zero());
342  EXPECT_EQ(num_presents_called, 0u);
343 
344  // Pump the loop. Nothing is called.
345  loop().RunUntilIdle();
346  EXPECT_EQ(num_presents_called, 0u);
347 
348  // Simulate an AwaitVsync that comes before the first Present.
349  flatland_connection.AwaitVsync([](fml::TimePoint, fml::TimePoint) {});
350  loop().RunUntilIdle();
351  EXPECT_EQ(num_presents_called, 0u);
352 
353  // This test uses a fire callback that triggers Present() with a single
354  // acquire and release fence in order to approximate the behavior of the real
355  // flutter fire callback and let us drive presents with ONFBs
356  auto fire_callback = [dispatcher = loop().dispatcher(), &flatland_connection](
357  fml::TimePoint frame_start,
358  fml::TimePoint frame_end) {
359  async::PostTask(dispatcher, [&flatland_connection]() {
360  zx::event acquire_fence;
361  zx::event::create(0, &acquire_fence);
362  zx::event release_fence;
363  zx::event::create(0, &release_fence);
364  flatland_connection.EnqueueAcquireFence(std::move(acquire_fence));
365  flatland_connection.EnqueueReleaseFence(std::move(release_fence));
366  flatland_connection.Present();
367  });
368  };
369 
370  // Call Await Vsync with a callback that triggers Present and consumes the one
371  // and only present credit we start with.
372  reset_test_counters();
373  flatland_connection.AwaitVsync(fire_callback);
374  loop().RunUntilIdle();
375  EXPECT_EQ(num_presents_called, 1u);
376  EXPECT_EQ(num_acquire_fences, 1u);
377  EXPECT_EQ(num_release_fences, 0u);
378 
379  // Do it again, but this time we should not get a present because the client
380  // has exhausted its present credits.
381  reset_test_counters();
382  flatland_connection.AwaitVsync(fire_callback);
383  OnNextFrameBegin(0);
384  loop().RunUntilIdle();
385  EXPECT_EQ(num_presents_called, 0u);
386 
387  // Supply a present credit but dont set a new fire callback. Fire callback
388  // from previous ONFB should fire and trigger a Present()
389  reset_test_counters();
390  OnNextFrameBegin(1);
391  loop().RunUntilIdle();
392  EXPECT_EQ(num_presents_called, 1u);
393  EXPECT_EQ(num_acquire_fences, 1u);
394  EXPECT_EQ(num_release_fences, 1u);
395 
396  // From here on we are testing handling of a race condition where a fire
397  // callback is fired but another ONFB arrives before the present from the
398  // first fire callback comes in, causing present_credits to be negative
399  // within Present().
400 
401  uint num_onfb = 5;
402  uint num_deferred_callbacks = 0;
403  // This callback will accumulate num_onfb+1 calls before firing all
404  // of their presents at once.
405  auto accumulating_fire_callback = [&](fml::TimePoint frame_start,
406  fml::TimePoint frame_end) {
407  num_deferred_callbacks++;
408  if (num_deferred_callbacks > num_onfb) {
410  for (uint i = 0; i < num_onfb + 1; i++) {
411  fire_callback(now, now);
412  num_deferred_callbacks--;
413  }
414  }
415  };
416 
417  reset_test_counters();
418  for (uint i = 0; i < num_onfb; i++) {
419  flatland_connection.AwaitVsync(accumulating_fire_callback);
420  // only supply a present credit on the first call. Since Presents are being
421  // deferred this credit will not be used up, but we need a credit to call
422  // the accumulating_fire_callback
423  OnNextFrameBegin(i == 0 ? 1 : 0);
424  loop().RunUntilIdle();
425  EXPECT_EQ(num_presents_called, 0u);
426  }
427 
428  // This is the num_onfb+1 call to accumulating_fire_callback which triggers
429  // all of the "racing" presents to fire. the first one should be fired,
430  // but the other num_onfb Presents should be deferred.
431  flatland_connection.AwaitVsync(accumulating_fire_callback);
432  OnNextFrameBegin(0);
433  loop().RunUntilIdle();
434  EXPECT_EQ(num_presents_called, 1u);
435  EXPECT_EQ(num_acquire_fences, 1u);
436  EXPECT_EQ(num_release_fences, 1u);
437 
438  // Supply a present credit, but pass an empty lambda to AwaitVsync so
439  // that it doesnt call Present(). Should get a deferred present with
440  // all the accumulate acuire fences
441  reset_test_counters();
442  flatland_connection.AwaitVsync([](fml::TimePoint, fml::TimePoint) {});
443  OnNextFrameBegin(1);
444  loop().RunUntilIdle();
445  EXPECT_EQ(num_presents_called, 1u);
446  EXPECT_EQ(num_acquire_fences, num_onfb);
447  EXPECT_EQ(num_release_fences, 1u);
448 
449  // Pump another frame to check that release fences accumulate as expected
450  reset_test_counters();
451  flatland_connection.AwaitVsync(fire_callback);
452  OnNextFrameBegin(1);
453  loop().RunUntilIdle();
454  EXPECT_EQ(num_presents_called, 1u);
455  EXPECT_EQ(num_acquire_fences, 1u);
456  EXPECT_EQ(num_release_fences, num_onfb);
457 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
FlKeyEvent * event
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event
static TimePoint Now()
Definition: time_point.cc:49

◆ TEST_F() [29/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_LateGrant   
)

Definition at line 353 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddResult(), flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), flutter::PointerData::kAdd, flutter::PointerData::kDown, kIxnOne, flutter::PointerData::kMove, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

353  {
354  std::optional<std::vector<flutter::PointerData>> pointers;
355  pointer_delegate_->WatchLoop(
356  [&pointers](std::vector<flutter::PointerData> events) {
357  pointers = std::move(events);
358  });
359  RunLoopUntilIdle(); // Server gets watch call.
360 
361  // Fuchsia ADD, no grant result - buffer it.
362  std::vector<fup_TouchEvent> events =
363  TouchEventBuilder::New()
364  .AddTime(1111000u)
365  .AddViewParameters(kRect, kRect, kIdentity)
366  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
367  .BuildAsVector();
368  touch_source_->ScheduleCallback(std::move(events));
369  RunLoopUntilIdle();
370 
371  ASSERT_TRUE(pointers.has_value());
372  EXPECT_EQ(pointers.value().size(), 0u);
373  pointers = {};
374 
375  // Fuchsia CHANGE, no grant result - buffer it.
376  events = TouchEventBuilder::New()
377  .AddTime(2222000u)
378  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
379  .BuildAsVector();
380  touch_source_->ScheduleCallback(std::move(events));
381  RunLoopUntilIdle();
382 
383  ASSERT_TRUE(pointers.has_value());
384  EXPECT_EQ(pointers.value().size(), 0u);
385  pointers = {};
386 
387  // Fuchsia result: ownership granted. Buffered pointers released.
388  events = TouchEventBuilder::New()
389  .AddTime(3333000u)
390  .AddResult({kIxnOne, fup_TouchIxnStatus::GRANTED})
391  .BuildAsVector();
392  touch_source_->ScheduleCallback(std::move(events));
393  RunLoopUntilIdle();
394 
395  ASSERT_TRUE(pointers.has_value());
396  ASSERT_EQ(pointers.value().size(), 3u); // ADD - DOWN - MOVE
397  EXPECT_EQ(pointers.value()[0].change, flutter::PointerData::Change::kAdd);
398  EXPECT_EQ(pointers.value()[1].change, flutter::PointerData::Change::kDown);
399  EXPECT_EQ(pointers.value()[2].change, flutter::PointerData::Change::kMove);
400  pointers = {};
401 
402  // Fuchsia CHANGE, grant result - release immediately.
403  events = TouchEventBuilder::New()
404  .AddTime(/* in nanoseconds */ 4444000u)
405  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
406  .BuildAsVector();
407  touch_source_->ScheduleCallback(std::move(events));
408  RunLoopUntilIdle();
409 
410  ASSERT_TRUE(pointers.has_value());
411  ASSERT_EQ(pointers.value().size(), 1u);
412  EXPECT_EQ(pointers.value()[0].change, flutter::PointerData::Change::kMove);
413  EXPECT_EQ(pointers.value()[0].time_stamp, /* in microseconds */ 4444u);
414  pointers = {};
415 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [30/77]

flutter_runner::testing::TEST_F ( GfxSessionConnectionTest  ,
PresentBackpressure   
)

Definition at line 356 of file gfx_session_connection_unittests.cc.

References flutter_runner::testing::GfxSessionConnectionTest::fake_session(), flutter_runner::testing::FakeSession::FireOnFramePresentedEvent(), flutter::testing::GetCurrentTestName(), flutter_runner::testing::GfxSessionConnectionTest::GetInspectNode(), flutter_runner::testing::GfxSessionConnectionTest::loop(), flutter_runner::testing::FakeSession::SetPresent2Handler(), flutter_runner::testing::GfxSessionConnectionTest::TakeSessionHandle(), and fml::TimeDelta::Zero().

356  {
357  // Set up a callback which allows sensing of how many presents
358  // (`Present` calls) were handled.
359  size_t presents_called = 0u;
360  fake_session().SetPresent2Handler([&presents_called](auto...) -> auto {
361  presents_called++;
362  return FuturePresentationTimes{
363  .future_presentations = {},
364  .remaining_presents_in_flight_allowed = 1,
365  };
366  });
367 
368  // Set up a callback which allows sensing of how many vsync's
369  // (`OnFramePresented` events) were handled.
370  size_t vsyncs_handled = 0u;
371  on_frame_presented_event on_frame_presented = [&vsyncs_handled](auto...) {
372  vsyncs_handled++;
373  };
374 
375  // Create the GfxSessionConnection but don't pump the loop. No FIDL calls are
376  // completed yet.
377  flutter_runner::GfxSessionConnection session_connection(
378  GetCurrentTestName(), GetInspectNode(), TakeSessionHandle(),
379  []() { FAIL(); }, std::move(on_frame_presented), 1,
381  EXPECT_EQ(presents_called, 0u);
382  EXPECT_EQ(vsyncs_handled, 0u);
383 
384  // Pump the loop; `RequestPresentationTimes`, `Present`, and both of their
385  // callbacks are called.
386  loop().RunUntilIdle();
387  EXPECT_EQ(presents_called, 1u);
388  EXPECT_EQ(vsyncs_handled, 0u);
389 
390  // Call Present and Pump the loop; `Present` is not called due to backpressue.
391  session_connection.Present();
392  loop().RunUntilIdle();
393  EXPECT_EQ(presents_called, 1u);
394  EXPECT_EQ(vsyncs_handled, 0u);
395 
396  // Call Present again and Pump the loop; `Present` is not called due to
397  // backpressue.
398  session_connection.Present();
399  loop().RunUntilIdle();
400  EXPECT_EQ(presents_called, 1u);
401  EXPECT_EQ(vsyncs_handled, 0u);
402 
403  // Fire the `OnFramePresented` event associated with the first `Present`, then
404  // pump the loop. The `OnFramePresented` event is resolved. The pending
405  // `Present` calls are resolved.
406  fake_session().FireOnFramePresentedEvent(
407  MakeFramePresentedInfoForOnePresent(0, 0));
408  loop().RunUntilIdle();
409  EXPECT_EQ(presents_called, 2u);
410  EXPECT_EQ(vsyncs_handled, 1u);
411 
412  // Call Present and Pump the loop; `Present` is not called due to
413  // backpressue.
414  session_connection.Present();
415  loop().RunUntilIdle();
416  EXPECT_EQ(presents_called, 2u);
417  EXPECT_EQ(vsyncs_handled, 1u);
418 
419  // Call Present again and Pump the loop; `Present` is not called due to
420  // backpressue.
421  session_connection.Present();
422  loop().RunUntilIdle();
423  EXPECT_EQ(presents_called, 2u);
424  EXPECT_EQ(vsyncs_handled, 1u);
425 
426  // Fire the `OnFramePresented` event associated with the second `Present`,
427  // then pump the loop. The `OnFramePresented` event is resolved. The pending
428  // `Present` calls are resolved.
429  fake_session().FireOnFramePresentedEvent(
430  MakeFramePresentedInfoForOnePresent(0, 0));
431  loop().RunUntilIdle();
432  EXPECT_EQ(presents_called, 3u);
433  EXPECT_EQ(vsyncs_handled, 2u);
434 
435  // Fire the `OnFramePresented` event associated with the third `Present`,
436  // then pump the loop. The `OnFramePresented` event is resolved. No pending
437  // `Present` calls exist, so none are resolved.
438  fake_session().FireOnFramePresentedEvent(
439  MakeFramePresentedInfoForOnePresent(0, 0));
440  loop().RunUntilIdle();
441  EXPECT_EQ(presents_called, 3u);
442  EXPECT_EQ(vsyncs_handled, 3u);
443 }
static constexpr TimeDelta Zero()
Definition: time_delta.h:33
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:13
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event

◆ TEST_F() [31/77]

flutter_runner::testing::TEST_F ( FlatlandExternalViewEmbedderTest  ,
RootScene   
)

Definition at line 380 of file flatland_external_view_embedder_unittests.cc.

380  {
381  fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher;
382  fuchsia::ui::views::ViewportCreationToken viewport_creation_token;
383  fuchsia::ui::views::ViewCreationToken view_creation_token;
384  fuchsia::ui::views::ViewRef view_ref;
385  auto view_creation_token_status = zx::channel::create(
386  0u, &viewport_creation_token.value, &view_creation_token.value);
387  ASSERT_EQ(view_creation_token_status, ZX_OK);
388  auto view_ref_pair = scenic::ViewRefPair::New();
389  view_ref_pair.view_ref.Clone(&view_ref);
390 
391  FlatlandExternalViewEmbedder external_view_embedder(
392  std::move(view_creation_token),
393  fuchsia::ui::views::ViewIdentityOnCreation{
394  .view_ref = std::move(view_ref_pair.view_ref),
395  .view_ref_control = std::move(view_ref_pair.control_ref),
396  },
397  fuchsia::ui::composition::ViewBoundProtocols{},
398  parent_viewport_watcher.NewRequest(), flatland_connection(),
399  fake_surface_producer());
400  EXPECT_THAT(fake_flatland().graph(), IsEmptyGraph());
401 
402  // Pump the loop; the graph should still be empty because nothing called
403  // `Present` yet.
404  loop().RunUntilIdle();
405  EXPECT_THAT(fake_flatland().graph(), IsEmptyGraph());
406 
407  // Pump the loop; the contents of the initial `Present` should be processed.
408  flatland_connection()->Present();
409  loop().RunUntilIdle();
410  EXPECT_THAT(fake_flatland().graph(),
411  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
412  view_ref));
413 }

◆ TEST_F() [32/77]

flutter_runner::testing::TEST_F ( FlatlandExternalViewEmbedderTest  ,
SimpleScene   
)

Definition at line 415 of file flatland_external_view_embedder_unittests.cc.

415  {
416  fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher;
417  fuchsia::ui::views::ViewportCreationToken viewport_creation_token;
418  fuchsia::ui::views::ViewCreationToken view_creation_token;
419  fuchsia::ui::views::ViewRef view_ref;
420  auto view_creation_token_status = zx::channel::create(
421  0u, &viewport_creation_token.value, &view_creation_token.value);
422  ASSERT_EQ(view_creation_token_status, ZX_OK);
423  auto view_ref_pair = scenic::ViewRefPair::New();
424  view_ref_pair.view_ref.Clone(&view_ref);
425 
426  // Create the `FlatlandExternalViewEmbedder` and pump the message loop until
427  // the initial scene graph is setup.
428  FlatlandExternalViewEmbedder external_view_embedder(
429  std::move(view_creation_token),
430  fuchsia::ui::views::ViewIdentityOnCreation{
431  .view_ref = std::move(view_ref_pair.view_ref),
432  .view_ref_control = std::move(view_ref_pair.control_ref),
433  },
434  fuchsia::ui::composition::ViewBoundProtocols{},
435  parent_viewport_watcher.NewRequest(), flatland_connection(),
436  fake_surface_producer());
437  flatland_connection()->Present();
438  loop().RunUntilIdle();
439  fake_flatland().FireOnNextFrameBeginEvent(WithPresentCredits(1u));
440  loop().RunUntilIdle();
441  EXPECT_THAT(fake_flatland().graph(),
442  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
443  view_ref));
444 
445  // Draw the scene. The scene graph shouldn't change yet.
446  const SkISize frame_size_signed = SkISize::Make(512, 512);
447  const fuchsia::math::SizeU frame_size{
448  static_cast<uint32_t>(frame_size_signed.width()),
449  static_cast<uint32_t>(frame_size_signed.height())};
450  DrawSimpleFrame(
451  external_view_embedder, frame_size_signed, 1.f, [](SkCanvas* canvas) {
452  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
453  canvas->imageInfo().height());
454  SkPaint rect_paint;
455  rect_paint.setColor(SK_ColorGREEN);
456  canvas->translate(canvas_size.width() / 4.f,
457  canvas_size.height() / 2.f);
458  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
459  canvas_size.height() / 32.f),
460  rect_paint);
461  });
462  EXPECT_THAT(fake_flatland().graph(),
463  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
464  view_ref));
465 
466  // Pump the message loop. The scene updates should propagate to flatland.
467  loop().RunUntilIdle();
468  EXPECT_THAT(
469  fake_flatland().graph(),
470  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token, view_ref,
471  /*layers*/
472  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1)}));
473 }

◆ TEST_F() [33/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_LateGrantCombo   
)

Definition at line 417 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), flutter::PointerData::kAdd, flutter::PointerData::kDown, kIxnOne, flutter::PointerData::kMove, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

417  {
418  std::optional<std::vector<flutter::PointerData>> pointers;
419  pointer_delegate_->WatchLoop(
420  [&pointers](std::vector<flutter::PointerData> events) {
421  pointers = std::move(events);
422  });
423  RunLoopUntilIdle(); // Server gets watch call.
424 
425  // Fuchsia ADD, no grant result - buffer it.
426  std::vector<fup_TouchEvent> events =
427  TouchEventBuilder::New()
428  .AddTime(1111000u)
429  .AddViewParameters(kRect, kRect, kIdentity)
430  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
431  .BuildAsVector();
432  touch_source_->ScheduleCallback(std::move(events));
433  RunLoopUntilIdle();
434 
435  ASSERT_TRUE(pointers.has_value());
436  EXPECT_EQ(pointers.value().size(), 0u);
437  pointers = {};
438 
439  // Fuchsia CHANGE, no grant result - buffer it.
440  events = TouchEventBuilder::New()
441  .AddTime(2222000u)
442  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
443  .BuildAsVector();
444  touch_source_->ScheduleCallback(std::move(events));
445  RunLoopUntilIdle();
446 
447  ASSERT_TRUE(pointers.has_value());
448  EXPECT_EQ(pointers.value().size(), 0u);
449  pointers = {};
450 
451  // Fuchsia CHANGE, with grant result - release buffered events.
452  events = TouchEventBuilder::New()
453  .AddTime(3333000u)
454  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
455  .AddResult({kIxnOne, fup_TouchIxnStatus::GRANTED})
456  .BuildAsVector();
457  touch_source_->ScheduleCallback(std::move(events));
458  RunLoopUntilIdle();
459 
460  ASSERT_TRUE(pointers.has_value());
461  ASSERT_EQ(pointers.value().size(), 4u); // ADD - DOWN - MOVE - MOVE
462  EXPECT_EQ(pointers.value()[0].change, flutter::PointerData::Change::kAdd);
463  EXPECT_EQ(pointers.value()[0].time_stamp, 1111u);
464  EXPECT_EQ(pointers.value()[1].change, flutter::PointerData::Change::kDown);
465  EXPECT_EQ(pointers.value()[1].time_stamp, 1111u);
466  EXPECT_EQ(pointers.value()[2].change, flutter::PointerData::Change::kMove);
467  EXPECT_EQ(pointers.value()[2].time_stamp, 2222u);
468  EXPECT_EQ(pointers.value()[3].change, flutter::PointerData::Change::kMove);
469  EXPECT_EQ(pointers.value()[3].time_stamp, 3333u);
470  pointers = {};
471 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [34/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
InvalidPlatformMessageRequest   
)

Definition at line 420 of file platform_view_unittest.cc.

References flutter_runner::testing::FakePlatformMessageResponse::Create(), and platform_view.

420  {
421  MockPlatformViewDelegate delegate;
422  flutter::TaskRunners task_runners =
423  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
424 
425  FakeViewRefFocused vrf;
426  fidl::BindingSet<fuchsia::ui::views::ViewRefFocused> vrf_bindings;
427  auto vrf_handle = vrf_bindings.AddBinding(&vrf);
428 
430  PlatformViewBuilder(delegate, std::move(task_runners))
431  .SetViewRefFocused(std::move(vrf_handle))
432  .Build();
433 
434  // Cast platform_view to its base view so we can have access to the public
435  // "HandlePlatformMessage" function.
436  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
437  EXPECT_TRUE(base_view);
438 
439  // Invalid platform channel.
440  auto response1 = FakePlatformMessageResponse::Create();
441  base_view->HandlePlatformMessage(response1->WithMessage(
442  "flutter/invalid", "{\"method\":\"Invalid.invalidMethod\"}"));
443 
444  // Invalid json.
445  auto response2 = FakePlatformMessageResponse::Create();
446  base_view->HandlePlatformMessage(
447  response2->WithMessage("flutter/platform_views", "{Invalid JSON"));
448 
449  // Invalid method.
450  auto response3 = FakePlatformMessageResponse::Create();
451  base_view->HandlePlatformMessage(response3->WithMessage(
452  "flutter/platform_views", "{\"method\":\"View.focus.invalidMethod\"}"));
453 
454  // Missing arguments.
455  auto response4 = FakePlatformMessageResponse::Create();
456  base_view->HandlePlatformMessage(response4->WithMessage(
457  "flutter/platform_views", "{\"method\":\"View.update\"}"));
458  auto response5 = FakePlatformMessageResponse::Create();
459  base_view->HandlePlatformMessage(
460  response5->WithMessage("flutter/platform_views",
461  "{\"method\":\"View.update\",\"args\":{"
462  "\"irrelevantField\":\"irrelevantValue\"}}"));
463 
464  // Wrong argument types.
465  auto response6 = FakePlatformMessageResponse::Create();
466  base_view->HandlePlatformMessage(response6->WithMessage(
467  "flutter/platform_views",
468  "{\"method\":\"View.update\",\"args\":{\"viewId\":false,\"hitTestable\":"
469  "123,\"focusable\":\"yes\"}}"));
470 
471  // Run the event loop and check our responses.
472  RunLoopUntilIdle();
473  response1->ExpectCompleted("");
474  response2->ExpectCompleted("");
475  response3->ExpectCompleted("");
476  response4->ExpectCompleted("");
477  response5->ExpectCompleted("");
478  response6->ExpectCompleted("");
479 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52

◆ TEST_F() [35/77]

flutter_runner::testing::TEST_F ( FakeSessionTest  ,
BasicSceneGraph   
)

Definition at line 433 of file fake_session_unittests.cc.

References flutter_runner::testing::FakeSessionTest::CreateSession(), flutter_runner::testing::FakeSessionTest::fake_session(), flutter::testing::GetCurrentTestName(), and flutter_runner::testing::FakeSessionTest::loop().

433  {
434  scenic::Session session = CreateSession();
435 
436  // The scene graph is initially empty.
437  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
438 
439  // Create and present initial scene graph.
440  const std::string kViewDebugString = GetCurrentTestName();
441  const std::string kNodeLabel = "ChildNode";
442  fuchsia::ui::views::ViewRef view_ref;
443  auto [view_token, view_holder_token] = scenic::ViewTokenPair::New();
444  auto view_ref_pair = scenic::ViewRefPair::New();
445  view_ref_pair.view_ref.Clone(&view_ref);
446  scenic::View root_view(&session, std::move(view_token),
447  std::move(view_ref_pair.control_ref),
448  std::move(view_ref_pair.view_ref), kViewDebugString);
449  scenic::EntityNode child_node(&session);
450  child_node.SetLabel(kNodeLabel);
451  root_view.AddChild(child_node);
452  session.Present2(0u, 0u, [](auto...) {});
453  loop().RunUntilIdle();
454  EXPECT_THAT(fake_session().SceneGraph(),
455  IsBasicSceneGraph(kViewDebugString, kNodeLabel,
456  GetPeerKoid(view_holder_token.value.get()),
457  GetPeerKoid(view_ref.reference.get()),
458  GetKoid(view_ref.reference.get())));
459 }
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:13

◆ TEST_F() [36/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_EarlyGrant   
)

Definition at line 473 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), flutter::PointerData::kAdd, flutter::PointerData::kDown, kIxnOne, flutter::PointerData::kMove, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

473  {
474  std::optional<std::vector<flutter::PointerData>> pointers;
475  pointer_delegate_->WatchLoop(
476  [&pointers](std::vector<flutter::PointerData> events) {
477  pointers = std::move(events);
478  });
479  RunLoopUntilIdle(); // Server gets watch call.
480 
481  // Fuchsia ADD, with grant result - release immediately.
482  std::vector<fup_TouchEvent> events =
483  TouchEventBuilder::New()
484  .AddTime(1111000u)
485  .AddViewParameters(kRect, kRect, kIdentity)
486  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
487  .AddResult({kIxnOne, fup_TouchIxnStatus::GRANTED})
488  .BuildAsVector();
489  touch_source_->ScheduleCallback(std::move(events));
490  RunLoopUntilIdle();
491 
492  ASSERT_TRUE(pointers.has_value());
493  ASSERT_EQ(pointers.value().size(), 2u);
494  EXPECT_EQ(pointers.value()[0].change, flutter::PointerData::Change::kAdd);
495  EXPECT_EQ(pointers.value()[1].change, flutter::PointerData::Change::kDown);
496  pointers = {};
497 
498  // Fuchsia CHANGE, after grant result - release immediately.
499  events = TouchEventBuilder::New()
500  .AddTime(2222000u)
501  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
502  .BuildAsVector();
503  touch_source_->ScheduleCallback(std::move(events));
504  RunLoopUntilIdle();
505 
506  ASSERT_TRUE(pointers.has_value());
507  ASSERT_EQ(pointers.value().size(), 1u);
508  EXPECT_EQ(pointers.value()[0].change, flutter::PointerData::Change::kMove);
509  pointers = {};
510 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [37/77]

flutter_runner::testing::TEST_F ( FlatlandExternalViewEmbedderTest  ,
SceneWithOneView   
)

Definition at line 475 of file flatland_external_view_embedder_unittests.cc.

References flutter_runner::testing::ViewTokenPair::New().

475  {
476  fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher;
477  fuchsia::ui::views::ViewportCreationToken viewport_creation_token;
478  fuchsia::ui::views::ViewCreationToken view_creation_token;
479  fuchsia::ui::views::ViewRef view_ref;
480  auto view_creation_token_status = zx::channel::create(
481  0u, &viewport_creation_token.value, &view_creation_token.value);
482  ASSERT_EQ(view_creation_token_status, ZX_OK);
483  auto view_ref_pair = scenic::ViewRefPair::New();
484  view_ref_pair.view_ref.Clone(&view_ref);
485 
486  // Create the `FlatlandExternalViewEmbedder` and pump the message loop until
487  // the initial scene graph is setup.
488  FlatlandExternalViewEmbedder external_view_embedder(
489  std::move(view_creation_token),
490  fuchsia::ui::views::ViewIdentityOnCreation{
491  .view_ref = std::move(view_ref_pair.view_ref),
492  .view_ref_control = std::move(view_ref_pair.control_ref),
493  },
494  fuchsia::ui::composition::ViewBoundProtocols{},
495  parent_viewport_watcher.NewRequest(), flatland_connection(),
496  fake_surface_producer());
497  flatland_connection()->Present();
498  loop().RunUntilIdle();
499  fake_flatland().FireOnNextFrameBeginEvent(WithPresentCredits(1u));
500  loop().RunUntilIdle();
501  EXPECT_THAT(fake_flatland().graph(),
502  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
503  view_ref));
504 
505  // Create the view before drawing the scene.
506  const SkSize child_view_size_signed = SkSize::Make(256.f, 512.f);
507  const fuchsia::math::SizeU child_view_size{
508  static_cast<uint32_t>(child_view_size_signed.width()),
509  static_cast<uint32_t>(child_view_size_signed.height())};
510  auto [child_view_token, child_viewport_token] = ViewTokenPair::New();
511  const uint32_t child_view_id = child_viewport_token.value.get();
512  flutter::EmbeddedViewParams child_view_params(
513  SkMatrix::I(), child_view_size_signed, flutter::MutatorsStack());
514  external_view_embedder.CreateView(
515  child_view_id, []() {},
516  [](fuchsia::ui::composition::ContentId,
517  fuchsia::ui::composition::ChildViewWatcherPtr) {});
518 
519  // Draw the scene. The scene graph shouldn't change yet.
520  const SkISize frame_size_signed = SkISize::Make(512, 512);
521  const fuchsia::math::SizeU frame_size{
522  static_cast<uint32_t>(frame_size_signed.width()),
523  static_cast<uint32_t>(frame_size_signed.height())};
524  DrawFrameWithView(
525  external_view_embedder, frame_size_signed, 1.f, child_view_id,
526  child_view_params,
527  [](SkCanvas* canvas) {
528  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
529  canvas->imageInfo().height());
530  SkPaint rect_paint;
531  rect_paint.setColor(SK_ColorGREEN);
532  canvas->translate(canvas_size.width() / 4.f,
533  canvas_size.height() / 2.f);
534  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
535  canvas_size.height() / 32.f),
536  rect_paint);
537  },
538  [](SkCanvas* canvas) {
539  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
540  canvas->imageInfo().height());
541  SkPaint rect_paint;
542  rect_paint.setColor(SK_ColorRED);
543  canvas->translate(canvas_size.width() * 3.f / 4.f,
544  canvas_size.height() / 2.f);
545  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
546  canvas_size.height() / 32.f),
547  rect_paint);
548  });
549  EXPECT_THAT(fake_flatland().graph(),
550  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
551  view_ref));
552 
553  // Pump the message loop. The scene updates should propagate to flatland.
554  loop().RunUntilIdle();
555  fake_flatland().FireOnNextFrameBeginEvent(WithPresentCredits(1u));
556  loop().RunUntilIdle();
557  EXPECT_THAT(
558  fake_flatland().graph(),
559  IsFlutterGraph(
560  parent_viewport_watcher, viewport_creation_token, view_ref, /*layers*/
561  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1),
562  IsViewportLayer(child_view_token, child_view_size, {0, 0}),
563  IsImageLayer(frame_size, kUpperLayerBlendMode, 1)}));
564 
565  // Destroy the view. The scene graph shouldn't change yet.
566  external_view_embedder.DestroyView(
567  child_view_id, [](fuchsia::ui::composition::ContentId) {});
568  EXPECT_THAT(
569  fake_flatland().graph(),
570  IsFlutterGraph(
571  parent_viewport_watcher, viewport_creation_token, view_ref, /*layers*/
572  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1),
573  IsViewportLayer(child_view_token, child_view_size, {0, 0}),
574  IsImageLayer(frame_size, kUpperLayerBlendMode, 1)}));
575 
576  // Draw another frame without the view. The scene graph shouldn't change yet.
577  DrawSimpleFrame(
578  external_view_embedder, frame_size_signed, 1.f, [](SkCanvas* canvas) {
579  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
580  canvas->imageInfo().height());
581  SkPaint rect_paint;
582  rect_paint.setColor(SK_ColorGREEN);
583  canvas->translate(canvas_size.width() / 4.f,
584  canvas_size.height() / 2.f);
585  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
586  canvas_size.height() / 32.f),
587  rect_paint);
588  });
589  EXPECT_THAT(
590  fake_flatland().graph(),
591  IsFlutterGraph(
592  parent_viewport_watcher, viewport_creation_token, view_ref, /*layers*/
593  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1),
594  IsViewportLayer(child_view_token, child_view_size, {0, 0}),
595  IsImageLayer(frame_size, kUpperLayerBlendMode, 1)}));
596 
597  // Pump the message loop. The scene updates should propagate to flatland.
598  loop().RunUntilIdle();
599  EXPECT_THAT(
600  fake_flatland().graph(),
601  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
602  view_ref, /*layers*/
603  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1)}));
604 }

◆ TEST_F() [38/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
CreateSurfaceTest   
)

Definition at line 483 of file platform_view_unittest.cc.

References flutter_runner::PlatformView::CreateExternalViewEmbedder(), flutter_runner::CreateFMLTaskRunner(), flutter::kRender, flutter::MakeDefaultContextOptions(), flutter::PlatformView::NotifyCreated(), and platform_view.

483  {
484  MockPlatformViewDelegate delegate;
485 
486  flutter::TaskRunners task_runners =
487  flutter::TaskRunners("test_runners", // label
488  nullptr, // platform
490  async_get_default_dispatcher()), // raster
491  nullptr, // ui
492  nullptr // io
493  );
494 
495  // Test create surface callback function.
496  sk_sp<GrDirectContext> gr_context = GrDirectContext::MakeMock(
497  nullptr,
499  std::shared_ptr<MockExternalViewEmbedder> external_view_embedder =
500  std::make_shared<MockExternalViewEmbedder>();
501  auto CreateSurfaceCallback = [&external_view_embedder, gr_context]() {
502  return std::make_unique<flutter_runner::Surface>(
503  "PlatformViewTest", external_view_embedder, gr_context.get());
504  };
505 
507  PlatformViewBuilder(delegate, std::move(task_runners))
508  .SetCreateSurfaceCallback(CreateSurfaceCallback)
509  .SetExternalViewEmbedder(external_view_embedder)
510  .Build();
511  platform_view.NotifyCreated();
512 
513  RunLoopUntilIdle();
514 
515  EXPECT_EQ(gr_context.get(), delegate.surface()->GetContext());
516  EXPECT_EQ(external_view_embedder.get(),
517  platform_view.CreateExternalViewEmbedder().get());
518 }
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
std::unique_ptr< flutter::PlatformViewIOS > platform_view
void NotifyCreated()
Used by embedders to notify the shell that a platform view has been created. This notification is use...
std::shared_ptr< flutter::ExternalViewEmbedder > CreateExternalViewEmbedder() override
The context is used to render to a texture or renderbuffer.
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...

◆ TEST_F() [39/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_LateDeny   
)

Definition at line 512 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddResult(), flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), kIxnOne, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

512  {
513  std::optional<std::vector<flutter::PointerData>> pointers;
514  pointer_delegate_->WatchLoop(
515  [&pointers](std::vector<flutter::PointerData> events) {
516  pointers = std::move(events);
517  });
518  RunLoopUntilIdle(); // Server gets watch call.
519 
520  // Fuchsia ADD, no grant result - buffer it.
521  std::vector<fup_TouchEvent> events =
522  TouchEventBuilder::New()
523  .AddTime(1111000u)
524  .AddViewParameters(kRect, kRect, kIdentity)
525  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
526  .BuildAsVector();
527  touch_source_->ScheduleCallback(std::move(events));
528  RunLoopUntilIdle();
529 
530  ASSERT_TRUE(pointers.has_value());
531  EXPECT_EQ(pointers.value().size(), 0u);
532  pointers = {};
533 
534  // Fuchsia CHANGE, no grant result - buffer it.
535  events = TouchEventBuilder::New()
536  .AddTime(2222000u)
537  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
538  .BuildAsVector();
539  touch_source_->ScheduleCallback(std::move(events));
540  RunLoopUntilIdle();
541 
542  ASSERT_TRUE(pointers.has_value());
543  EXPECT_EQ(pointers.value().size(), 0u);
544  pointers = {};
545 
546  // Fuchsia result: ownership denied. Buffered pointers deleted.
547  events = TouchEventBuilder::New()
548  .AddTime(3333000u)
549  .AddResult({kIxnOne, fup_TouchIxnStatus::DENIED})
550  .BuildAsVector();
551  touch_source_->ScheduleCallback(std::move(events));
552  RunLoopUntilIdle();
553 
554  ASSERT_TRUE(pointers.has_value());
555  ASSERT_EQ(pointers.value().size(), 0u); // Do not release to client!
556  pointers = {};
557 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [40/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
SetViewportMetrics   
)

Definition at line 523 of file platform_view_unittest.cc.

References flutter::testing::Build(), and platform_view.

523  {
524  constexpr float invalid_pixel_ratio = -0.75f;
525  constexpr float valid_pixel_ratio = 0.75f;
526  constexpr float invalid_max_bound = -0.75f;
527  constexpr float valid_max_bound = 0.75f;
528 
529  MockPlatformViewDelegate delegate;
530  EXPECT_EQ(delegate.metrics(), flutter::ViewportMetrics());
531 
532  fuchsia::ui::scenic::SessionListenerPtr session_listener;
533  std::vector<fuchsia::ui::scenic::Event> events;
534  flutter::TaskRunners task_runners("test_runners", nullptr, nullptr, nullptr,
535  nullptr);
537  PlatformViewBuilder(delegate, std::move(task_runners))
538  .SetSessionListenerRequest(session_listener.NewRequest())
539  .Build();
540  RunLoopUntilIdle();
541  EXPECT_EQ(delegate.metrics(), flutter::ViewportMetrics());
542 
543  // Test updating with an invalid pixel ratio. The final metrics should be
544  // unchanged.
545  events.clear();
546  events.emplace_back(fuchsia::ui::scenic::Event::WithGfx(
547  fuchsia::ui::gfx::Event::WithMetrics(fuchsia::ui::gfx::MetricsEvent{
548  .node_id = 0,
549  .metrics =
550  fuchsia::ui::gfx::Metrics{
551  .scale_x = invalid_pixel_ratio,
552  .scale_y = 1.f,
553  .scale_z = 1.f,
554  },
555  })));
556  session_listener->OnScenicEvent(std::move(events));
557  RunLoopUntilIdle();
558  EXPECT_EQ(delegate.metrics(), flutter::ViewportMetrics());
559 
560  // Test updating with an invalid size. The final metrics should be unchanged.
561  events.clear();
562  events.emplace_back(
563  fuchsia::ui::scenic::Event::WithGfx(
564  fuchsia::ui::gfx::Event::WithViewPropertiesChanged(
565  fuchsia::ui::gfx::ViewPropertiesChangedEvent{
566  .view_id = 0,
567  .properties =
568  fuchsia::ui::gfx::ViewProperties{
569  .bounding_box =
570  fuchsia::ui::gfx::BoundingBox{
571  .min =
572  fuchsia::ui::gfx::vec3{
573  .x = 0.f,
574  .y = 0.f,
575  .z = 0.f,
576  },
577  .max =
578  fuchsia::ui::gfx::vec3{
579  .x = invalid_max_bound,
580  .y = invalid_max_bound,
581  .z = invalid_max_bound,
582  },
583  },
584  },
585  })));
586  session_listener->OnScenicEvent(std::move(events));
587  RunLoopUntilIdle();
588  EXPECT_EQ(delegate.metrics(), flutter::ViewportMetrics());
589 
590  // Test updating the size only. The final metrics should be unchanged until
591  // both pixel ratio and size are updated.
592  events.clear();
593  events.emplace_back(
594  fuchsia::ui::scenic::Event::WithGfx(
595  fuchsia::ui::gfx::Event::WithViewPropertiesChanged(
596  fuchsia::ui::gfx::ViewPropertiesChangedEvent{
597  .view_id = 0,
598  .properties =
599  fuchsia::ui::gfx::ViewProperties{
600  .bounding_box =
601  fuchsia::ui::gfx::BoundingBox{
602  .min =
603  fuchsia::ui::gfx::vec3{
604  .x = 0.f,
605  .y = 0.f,
606  .z = 0.f,
607  },
608  .max =
609  fuchsia::ui::gfx::vec3{
610  .x = valid_max_bound,
611  .y = valid_max_bound,
612  .z = valid_max_bound,
613  },
614  },
615  },
616  })));
617  session_listener->OnScenicEvent(std::move(events));
618  RunLoopUntilIdle();
619  EXPECT_EQ(delegate.metrics(), flutter::ViewportMetrics());
620 
621  // Test updating the pixel ratio only. The final metrics should change now.
622  events.clear();
623  events.emplace_back(fuchsia::ui::scenic::Event::WithGfx(
624  fuchsia::ui::gfx::Event::WithMetrics(fuchsia::ui::gfx::MetricsEvent{
625  .node_id = 0,
626  .metrics =
627  fuchsia::ui::gfx::Metrics{
628  .scale_x = valid_pixel_ratio,
629  .scale_y = 1.f,
630  .scale_z = 1.f,
631  },
632  })));
633  session_listener->OnScenicEvent(std::move(events));
634  RunLoopUntilIdle();
635  EXPECT_EQ(
636  delegate.metrics(),
638  valid_pixel_ratio, std::round(valid_pixel_ratio * valid_max_bound),
639  std::round(valid_pixel_ratio * valid_max_bound), -1.0));
640 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
static sk_sp< DisplayList > Build(size_t g_index, size_t v_index)

◆ TEST_F() [41/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
InvalidPlatformMessageRequest   
)

Definition at line 539 of file flatland_platform_view_unittest.cc.

References flutter_runner::testing::FakePlatformMessageResponse::Create(), and platform_view.

539  {
540  MockPlatformViewDelegate delegate;
541  flutter::TaskRunners task_runners =
542  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
543 
544  FakeViewRefFocused vrf;
545  fidl::BindingSet<fuchsia::ui::views::ViewRefFocused> vrf_bindings;
546  auto vrf_handle = vrf_bindings.AddBinding(&vrf);
547 
548  auto platform_view = PlatformViewBuilder(delegate, std::move(task_runners))
549  .SetViewRefFocused(std::move(vrf_handle))
550  .Build();
551 
552  // Cast platform_view to its base view so we can have access to the public
553  // "HandlePlatformMessage" function.
554  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
555  EXPECT_TRUE(base_view);
556 
557  // Invalid platform channel.
558  auto response1 = FakePlatformMessageResponse::Create();
559  base_view->HandlePlatformMessage(response1->WithMessage(
560  "flutter/invalid", "{\"method\":\"Invalid.invalidMethod\"}"));
561 
562  // Invalid json.
563  auto response2 = FakePlatformMessageResponse::Create();
564  base_view->HandlePlatformMessage(
565  response2->WithMessage("flutter/platform_views", "{Invalid JSON"));
566 
567  // Invalid method.
568  auto response3 = FakePlatformMessageResponse::Create();
569  base_view->HandlePlatformMessage(response3->WithMessage(
570  "flutter/platform_views", "{\"method\":\"View.focus.invalidMethod\"}"));
571 
572  // Missing arguments.
573  auto response4 = FakePlatformMessageResponse::Create();
574  base_view->HandlePlatformMessage(response4->WithMessage(
575  "flutter/platform_views", "{\"method\":\"View.update\"}"));
576  auto response5 = FakePlatformMessageResponse::Create();
577  base_view->HandlePlatformMessage(
578  response5->WithMessage("flutter/platform_views",
579  "{\"method\":\"View.update\",\"args\":{"
580  "\"irrelevantField\":\"irrelevantValue\"}}"));
581 
582  // Wrong argument types.
583  auto response6 = FakePlatformMessageResponse::Create();
584  base_view->HandlePlatformMessage(response6->WithMessage(
585  "flutter/platform_views",
586  "{\"method\":\"View.update\",\"args\":{\"viewId\":false,\"hitTestable\":"
587  "123,\"focusable\":\"yes\"}}"));
588 
589  // Run the event loop and check our responses.
590  RunLoopUntilIdle();
591  response1->ExpectCompleted("");
592  response2->ExpectCompleted("");
593  response3->ExpectCompleted("");
594  response4->ExpectCompleted("");
595  response5->ExpectCompleted("");
596  response6->ExpectCompleted("");
597 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52

◆ TEST_F() [42/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_LateDenyCombo   
)

Definition at line 559 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), kIxnOne, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

559  {
560  std::optional<std::vector<flutter::PointerData>> pointers;
561  pointer_delegate_->WatchLoop(
562  [&pointers](std::vector<flutter::PointerData> events) {
563  pointers = std::move(events);
564  });
565  RunLoopUntilIdle(); // Server gets watch call.
566 
567  // Fuchsia ADD, no grant result - buffer it.
568  std::vector<fup_TouchEvent> events =
569  TouchEventBuilder::New()
570  .AddTime(1111000u)
571  .AddViewParameters(kRect, kRect, kIdentity)
572  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
573  .BuildAsVector();
574  touch_source_->ScheduleCallback(std::move(events));
575  RunLoopUntilIdle();
576 
577  ASSERT_TRUE(pointers.has_value());
578  EXPECT_EQ(pointers.value().size(), 0u);
579  pointers = {};
580 
581  // Fuchsia CHANGE, no grant result - buffer it.
582  events = TouchEventBuilder::New()
583  .AddTime(2222000u)
584  .AddSample(kIxnOne, fup_EventPhase::CHANGE, {10.f, 10.f})
585  .BuildAsVector();
586  touch_source_->ScheduleCallback(std::move(events));
587  RunLoopUntilIdle();
588 
589  ASSERT_TRUE(pointers.has_value());
590  EXPECT_EQ(pointers.value().size(), 0u);
591  pointers = {};
592 
593  // Fuchsia result: ownership denied. Buffered pointers deleted.
594  events = TouchEventBuilder::New()
595  .AddTime(3333000u)
596  .AddSample(kIxnOne, fup_EventPhase::CANCEL, {10.f, 10.f})
597  .AddResult({kIxnOne, fup_TouchIxnStatus::DENIED})
598  .BuildAsVector();
599  touch_source_->ScheduleCallback(std::move(events));
600  RunLoopUntilIdle();
601 
602  ASSERT_TRUE(pointers.has_value());
603  ASSERT_EQ(pointers.value().size(), 0u); // Do not release to client!
604  pointers = {};
605 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
constexpr std::array< float, 9 > kIdentity

◆ TEST_F() [43/77]

flutter_runner::testing::TEST_F ( GfxExternalViewEmbedderTest  ,
RootScene   
)

Definition at line 575 of file gfx_external_view_embedder_unittests.cc.

References flutter::testing::GetCurrentTestName().

575  {
576  const std::string debug_name = GetCurrentTestName();
577  auto [view_token, view_holder_token] = scenic::ViewTokenPair::New();
578  auto view_ref_pair = scenic::ViewRefPair::New();
579  fuchsia::ui::views::ViewRef view_ref;
580  view_ref_pair.view_ref.Clone(&view_ref);
581 
582  GfxExternalViewEmbedder external_view_embedder(
583  debug_name, std::move(view_token), std::move(view_ref_pair),
584  session_connection(), fake_surface_producer());
585  EXPECT_EQ(fake_session().debug_name(), "");
586  EXPECT_THAT(fake_session().SceneGraph(), IsEmptySceneGraph());
587 
588  // Pump the loop; the contents of the initial `Present` should be processed.
589  loop().RunUntilIdle();
590  EXPECT_EQ(fake_session().debug_name(), debug_name);
591  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
592  view_holder_token, view_ref);
593 
594  // Fire the `OnFramePresented` event associated with the first `Present`, then
595  // pump the loop. The `OnFramePresented` event is resolved.
596  //
597  // The scene graph shouldn't change.
598  fake_session().FireOnFramePresentedEvent(
599  MakeFramePresentedInfoForOnePresent(0, 0));
600  loop().RunUntilIdle();
601  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
602  view_holder_token, view_ref);
603 }
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:13

◆ TEST_F() [44/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
CreateSurfaceTest   
)

Definition at line 601 of file flatland_platform_view_unittest.cc.

References flutter_runner::CreateFMLTaskRunner(), flutter::kRender, flutter::MakeDefaultContextOptions(), and platform_view.

601  {
602  MockPlatformViewDelegate delegate;
603 
604  flutter::TaskRunners task_runners =
605  flutter::TaskRunners("test_runners", // label
606  nullptr, // platform
608  async_get_default_dispatcher()), // raster
609  nullptr, // ui
610  nullptr // io
611  );
612 
613  // Test create surface callback function.
614  sk_sp<GrDirectContext> gr_context = GrDirectContext::MakeMock(
615  nullptr,
617  std::shared_ptr<MockExternalViewEmbedder> external_view_embedder =
618  std::make_shared<MockExternalViewEmbedder>();
619  auto CreateSurfaceCallback = [&external_view_embedder, gr_context]() {
620  return std::make_unique<flutter_runner::Surface>(
621  "PlatformViewTest", external_view_embedder, gr_context.get());
622  };
623 
624  auto platform_view = PlatformViewBuilder(delegate, std::move(task_runners))
625  .SetCreateSurfaceCallback(CreateSurfaceCallback)
626  .SetExternalViewEmbedder(external_view_embedder)
627  .Build();
628  platform_view.NotifyCreated();
629 
630  RunLoopUntilIdle();
631 
632  EXPECT_EQ(gr_context.get(), delegate.surface()->GetContext());
633  EXPECT_EQ(external_view_embedder.get(),
634  platform_view.CreateExternalViewEmbedder().get());
635 }
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
std::unique_ptr< flutter::PlatformViewIOS > platform_view
The context is used to render to a texture or renderbuffer.
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...

◆ TEST_F() [45/77]

flutter_runner::testing::TEST_F ( FlatlandExternalViewEmbedderTest  ,
SceneWithOneView_NoOverlay   
)

Definition at line 606 of file flatland_external_view_embedder_unittests.cc.

References flutter_runner::testing::ViewTokenPair::New().

606  {
607  fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher;
608  fuchsia::ui::views::ViewportCreationToken viewport_creation_token;
609  fuchsia::ui::views::ViewCreationToken view_creation_token;
610  fuchsia::ui::views::ViewRef view_ref;
611  auto view_creation_token_status = zx::channel::create(
612  0u, &viewport_creation_token.value, &view_creation_token.value);
613  ASSERT_EQ(view_creation_token_status, ZX_OK);
614  auto view_ref_pair = scenic::ViewRefPair::New();
615  view_ref_pair.view_ref.Clone(&view_ref);
616 
617  // Create the `FlatlandExternalViewEmbedder` and pump the message loop until
618  // the initial scene graph is setup.
619  FlatlandExternalViewEmbedder external_view_embedder(
620  std::move(view_creation_token),
621  fuchsia::ui::views::ViewIdentityOnCreation{
622  .view_ref = std::move(view_ref_pair.view_ref),
623  .view_ref_control = std::move(view_ref_pair.control_ref),
624  },
625  fuchsia::ui::composition::ViewBoundProtocols{},
626  parent_viewport_watcher.NewRequest(), flatland_connection(),
627  fake_surface_producer());
628  flatland_connection()->Present();
629  loop().RunUntilIdle();
630  fake_flatland().FireOnNextFrameBeginEvent(WithPresentCredits(1u));
631  loop().RunUntilIdle();
632  EXPECT_THAT(fake_flatland().graph(),
633  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
634  view_ref));
635 
636  // Create the view before drawing the scene.
637  const SkSize child_view_size_signed = SkSize::Make(256.f, 512.f);
638  const fuchsia::math::SizeU child_view_size{
639  static_cast<uint32_t>(child_view_size_signed.width()),
640  static_cast<uint32_t>(child_view_size_signed.height())};
641  auto [child_view_token, child_viewport_token] = ViewTokenPair::New();
642  const uint32_t child_view_id = child_viewport_token.value.get();
643  flutter::EmbeddedViewParams child_view_params(
644  SkMatrix::I(), child_view_size_signed, flutter::MutatorsStack());
645  external_view_embedder.CreateView(
646  child_view_id, []() {},
647  [](fuchsia::ui::composition::ContentId,
648  fuchsia::ui::composition::ChildViewWatcherPtr) {});
649 
650  // Draw the scene. The scene graph shouldn't change yet.
651  const SkISize frame_size_signed = SkISize::Make(512, 512);
652  const fuchsia::math::SizeU frame_size{
653  static_cast<uint32_t>(frame_size_signed.width()),
654  static_cast<uint32_t>(frame_size_signed.height())};
655  DrawFrameWithView(
656  external_view_embedder, frame_size_signed, 1.f, child_view_id,
657  child_view_params,
658  [](SkCanvas* canvas) {
659  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
660  canvas->imageInfo().height());
661  SkPaint rect_paint;
662  rect_paint.setColor(SK_ColorGREEN);
663  canvas->translate(canvas_size.width() / 4.f,
664  canvas_size.height() / 2.f);
665  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
666  canvas_size.height() / 32.f),
667  rect_paint);
668  },
669  [](SkCanvas* canvas) {});
670  EXPECT_THAT(fake_flatland().graph(),
671  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
672  view_ref));
673 
674  // Pump the message loop. The scene updates should propagate to flatland.
675  loop().RunUntilIdle();
676  fake_flatland().FireOnNextFrameBeginEvent(WithPresentCredits(1u));
677  loop().RunUntilIdle();
678  EXPECT_THAT(
679  fake_flatland().graph(),
680  IsFlutterGraph(
681  parent_viewport_watcher, viewport_creation_token, view_ref, /*layers*/
682  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1),
683  IsViewportLayer(child_view_token, child_view_size, {0, 0})}));
684 
685  // Destroy the view. The scene graph shouldn't change yet.
686  external_view_embedder.DestroyView(
687  child_view_id, [](fuchsia::ui::composition::ContentId) {});
688  EXPECT_THAT(
689  fake_flatland().graph(),
690  IsFlutterGraph(
691  parent_viewport_watcher, viewport_creation_token, view_ref, /*layers*/
692  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1),
693  IsViewportLayer(child_view_token, child_view_size, {0, 0})}));
694 
695  // Draw another frame without the view. The scene graph shouldn't change yet.
696  DrawSimpleFrame(
697  external_view_embedder, frame_size_signed, 1.f, [](SkCanvas* canvas) {
698  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
699  canvas->imageInfo().height());
700  SkPaint rect_paint;
701  rect_paint.setColor(SK_ColorGREEN);
702  canvas->translate(canvas_size.width() / 4.f,
703  canvas_size.height() / 2.f);
704  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
705  canvas_size.height() / 32.f),
706  rect_paint);
707  });
708  EXPECT_THAT(
709  fake_flatland().graph(),
710  IsFlutterGraph(
711  parent_viewport_watcher, viewport_creation_token, view_ref, /*layers*/
712  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1),
713  IsViewportLayer(child_view_token, child_view_size, {0, 0})}));
714 
715  // Pump the message loop. The scene updates should propagate to flatland.
716  loop().RunUntilIdle();
717  EXPECT_THAT(
718  fake_flatland().graph(),
719  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
720  view_ref, /*layers*/
721  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1)}));
722 }

◆ TEST_F() [46/77]

flutter_runner::testing::TEST_F ( GfxExternalViewEmbedderTest  ,
SimpleScene   
)

Definition at line 606 of file gfx_external_view_embedder_unittests.cc.

References flutter::testing::GetCurrentTestName().

606  {
607  const std::string debug_name = GetCurrentTestName();
608  auto [view_token, view_holder_token] = scenic::ViewTokenPair::New();
609  auto view_ref_pair = scenic::ViewRefPair::New();
610  fuchsia::ui::views::ViewRef view_ref;
611  view_ref_pair.view_ref.Clone(&view_ref);
612 
613  // Create the `GfxExternalViewEmbedder` and pump the message loop until
614  // the initial scene graph is setup.
615  GfxExternalViewEmbedder external_view_embedder(
616  debug_name, std::move(view_token), std::move(view_ref_pair),
617  session_connection(), fake_surface_producer());
618  loop().RunUntilIdle();
619  fake_session().FireOnFramePresentedEvent(
620  MakeFramePresentedInfoForOnePresent(0, 0));
621  loop().RunUntilIdle();
622  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
623  view_holder_token, view_ref);
624 
625  // Draw the scene. The scene graph shouldn't change yet.
626  const SkISize frame_size = SkISize::Make(512, 512);
627  SkRect paint_region;
628  DrawSimpleFrame(
629  external_view_embedder, frame_size, 1.f,
630  [&paint_region](SkCanvas* canvas) {
631  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
632  canvas->imageInfo().height());
633  SkPaint rect_paint;
634  rect_paint.setColor(SK_ColorGREEN);
635 
636  paint_region = SkRect::MakeXYWH(
637  canvas_size.width() / 4.f, canvas_size.height() / 2.f,
638  canvas_size.width() / 32.f, canvas_size.height() / 32.f);
639 
640  canvas->drawRect(paint_region, rect_paint);
641  });
642  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
643  view_holder_token, view_ref);
644 
645  // Pump the message loop. The scene updates should propogate to Scenic.
646  loop().RunUntilIdle();
647  std::vector<FakeResource> scenic_layers =
648  ExtractLayersFromSceneGraph(fake_session().SceneGraph());
649  EXPECT_EQ(scenic_layers.size(), 1u);
650  ExpectImageCompositorLayer(scenic_layers[0], frame_size,
651  /* flutter layer index = */ 0, {paint_region});
652 }
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:13

◆ TEST_F() [47/77]

flutter_runner::testing::TEST_F ( PointerDelegateTest  ,
Protocol_PointersAreIndependent   
)

Definition at line 607 of file pointer_delegate_unittests.cc.

References flutter_runner::testing::TouchEventBuilder::AddResult(), flutter_runner::testing::TouchEventBuilder::AddSample(), flutter_runner::testing::TouchEventBuilder::AddTime(), flutter_runner::testing::TouchEventBuilder::AddViewParameters(), flutter::testing::Build(), flutter::PointerData::kAdd, flutter::PointerData::kDown, kIxnOne, flutter_runner::testing::TouchEventBuilder::New(), flutter_runner::testing::PointerDelegateTest::pointer_delegate_, flutter_runner::testing::PointerDelegateTest::RunLoopUntilIdle(), and flutter_runner::testing::PointerDelegateTest::touch_source_.

607  {
608  std::optional<std::vector<flutter::PointerData>> pointers;
609  pointer_delegate_->WatchLoop(
610  [&pointers](std::vector<flutter::PointerData> events) {
611  pointers = std::move(events);
612  });
613  RunLoopUntilIdle(); // Server gets watch call.
614 
615  constexpr fup_TouchIxnId kIxnTwo = {
616  .device_id = 1u, .pointer_id = 2u, .interaction_id = 2u};
617 
618  // Fuchsia ptr1 ADD and ptr2 ADD, no grant result for either - buffer them.
619  std::vector<fup_TouchEvent> events =
620  TouchEventBuilder::New()
621  .AddTime(1111000u)
622  .AddViewParameters(kRect, kRect, kIdentity)
623  .AddSample(kIxnOne, fup_EventPhase::ADD, {10.f, 10.f})
624  .BuildAsVector();
625  fup_TouchEvent ptr2 =
626  TouchEventBuilder::New()
627  .AddTime(1111000u)
628  .AddSample(kIxnTwo, fup_EventPhase::ADD, {15.f, 15.f})
629  .Build();
630  events.emplace_back(std::move(ptr2));
631  touch_source_->ScheduleCallback(std::move(events));
632  RunLoopUntilIdle();
633 
634  ASSERT_TRUE(pointers.has_value());
635  EXPECT_EQ(pointers.value().size(), 0u);
636  pointers = {};
637 
638  // Server grants win to pointer 2.
639  events = TouchEventBuilder::New()
640  .AddTime(2222000u)
641  .AddResult({kIxnTwo, fup_TouchIxnStatus::GRANTED})
642  .BuildAsVector();
643  touch_source_->ScheduleCallback(std::move(events));
644  RunLoopUntilIdle();
645 
646  // Note: Fuchsia's device and pointer IDs (both 32 bit) are coerced together
647  // to fit in Flutter's 64-bit device ID. However, Flutter's pointer_identifier
648  // is not set by platform runner code - PointerDataCaptureConverter (PDPC)
649  // sets it.
650  ASSERT_TRUE(pointers.has_value());
651  ASSERT_EQ(pointers.value().size(), 2u);
652  EXPECT_EQ(pointers.value()[0].pointer_identifier, 0); // reserved for PDPC
653  EXPECT_EQ(pointers.value()[0].device, (int64_t)((1ul << 32) | 2u));
654  EXPECT_EQ(pointers.value()[0].change, flutter::PointerData::Change::kAdd);
655  EXPECT_EQ(pointers.value()[1].pointer_identifier, 0); // reserved for PDPC
656  EXPECT_EQ(pointers.value()[1].device, (int64_t)((1ul << 32) | 2u));
657  EXPECT_EQ(pointers.value()[1].change, flutter::PointerData::Change::kDown);
658  pointers = {};
659 
660  // Server grants win to pointer 1.
661  events = TouchEventBuilder::New()
662  .AddTime(3333000u)
663  .AddResult({kIxnOne, fup_TouchIxnStatus::GRANTED})
664  .BuildAsVector();
665  touch_source_->ScheduleCallback(std::move(events));
666  RunLoopUntilIdle();
667 
668  ASSERT_TRUE(pointers.has_value());
669  ASSERT_EQ(pointers.value().size(), 2u);
670  EXPECT_EQ(pointers.value()[0].pointer_identifier, 0); // reserved for PDPC
671  EXPECT_EQ(pointers.value()[0].device, (int64_t)((1ul << 32) | 1u));
672  EXPECT_EQ(pointers.value()[0].change, flutter::PointerData::Change::kAdd);
673  EXPECT_EQ(pointers.value()[1].pointer_identifier, 0); // reserved for PDPC
674  EXPECT_EQ(pointers.value()[1].device, (int64_t)((1ul << 32) | 1u));
675  EXPECT_EQ(pointers.value()[1].change, flutter::PointerData::Change::kDown);
676  pointers = {};
677 }
constexpr fup_TouchIxnId kIxnOne
constexpr std::array< std::array< float, 2 >, 2 > kRect
static sk_sp< DisplayList > Build(size_t g_index, size_t v_index)
constexpr std::array< float, 9 > kIdentity
fuchsia::ui::pointer::TouchEvent fup_TouchEvent
fuchsia::ui::pointer::TouchInteractionId fup_TouchIxnId

◆ TEST_F() [48/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
SetViewportMetrics   
)

Definition at line 640 of file flatland_platform_view_unittest.cc.

References flutter::testing::Build(), height, platform_view, and width.

640  {
641  constexpr uint32_t width = 640;
642  constexpr uint32_t height = 480;
643 
644  MockPlatformViewDelegate delegate;
645  EXPECT_EQ(delegate.metrics(), flutter::ViewportMetrics());
646 
647  MockParentViewportWatcher watcher;
648  std::vector<fuchsia::ui::scenic::Event> events;
649  flutter::TaskRunners task_runners("test_runners", nullptr, nullptr, nullptr,
650  nullptr);
651  auto platform_view = PlatformViewBuilder(delegate, std::move(task_runners))
652  .SetParentViewportWatcher(watcher.GetHandle())
653  .Build();
654  RunLoopUntilIdle();
655  EXPECT_EQ(delegate.metrics(), flutter::ViewportMetrics());
656 
657  watcher.SetLayout(width, height);
658  RunLoopUntilIdle();
659  EXPECT_EQ(delegate.metrics(),
660  flutter::ViewportMetrics(1.0, width, height, -1.0));
661 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
static sk_sp< DisplayList > Build(size_t g_index, size_t v_index)
int32_t width
int32_t height

◆ TEST_F() [49/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
ChangesAccessibilitySettings   
)

Definition at line 645 of file platform_view_unittest.cc.

References flutter::kAccessibleNavigation, and platform_view.

645  {
646  MockPlatformViewDelegate delegate;
647  flutter::TaskRunners task_runners =
648  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
649 
650  EXPECT_FALSE(delegate.semantics_enabled());
651  EXPECT_EQ(delegate.semantics_features(), 0);
652 
654  PlatformViewBuilder(delegate, std::move(task_runners)).Build();
655 
656  RunLoopUntilIdle();
657 
658  platform_view.SetSemanticsEnabled(true);
659 
660  EXPECT_TRUE(delegate.semantics_enabled());
661  EXPECT_EQ(delegate.semantics_features(),
662  static_cast<int32_t>(
664 
665  platform_view.SetSemanticsEnabled(false);
666 
667  EXPECT_FALSE(delegate.semantics_enabled());
668  EXPECT_EQ(delegate.semantics_features(), 0);
669 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view

◆ TEST_F() [50/77]

flutter_runner::testing::TEST_F ( GfxExternalViewEmbedderTest  ,
SceneWithOneView   
)

Definition at line 655 of file gfx_external_view_embedder_unittests.cc.

References flutter_runner::GfxExternalViewEmbedder::CreateView(), flutter_runner::GfxExternalViewEmbedder::DestroyView(), and flutter::testing::GetCurrentTestName().

655  {
656  const std::string debug_name = GetCurrentTestName();
657  auto [view_token, view_holder_token] = scenic::ViewTokenPair::New();
658  auto view_ref_pair = scenic::ViewRefPair::New();
659  fuchsia::ui::views::ViewRef view_ref;
660  view_ref_pair.view_ref.Clone(&view_ref);
661 
662  // Create the `GfxExternalViewEmbedder` and pump the message loop until
663  // the initial scene graph is setup.
664  GfxExternalViewEmbedder external_view_embedder(
665  debug_name, std::move(view_token), std::move(view_ref_pair),
666  session_connection(), fake_surface_producer());
667  loop().RunUntilIdle();
668  fake_session().FireOnFramePresentedEvent(
669  MakeFramePresentedInfoForOnePresent(0, 0));
670  loop().RunUntilIdle();
671  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
672  view_holder_token, view_ref);
673 
674  // Create the view before drawing the scene.
675  const SkSize child_view_size = SkSize::Make(256.f, 512.f);
676  auto [child_view_token, child_view_holder_token] =
677  scenic::ViewTokenPair::New();
678  const uint32_t child_view_id = child_view_holder_token.value.get();
679  flutter::EmbeddedViewParams child_view_params(SkMatrix::I(), child_view_size,
681  external_view_embedder.CreateView(
682  child_view_id, []() {}, [](scenic::ResourceId) {});
683 
684  // Draw the scene. The scene graph shouldn't change yet.
685  const SkISize frame_size = SkISize::Make(512, 512);
686 
687  SkRect main_surface_paint_region, overlay_paint_region;
688 
689  DrawFrameWithView(
690  external_view_embedder, frame_size, 1.f, child_view_id, child_view_params,
691  [&main_surface_paint_region](SkCanvas* canvas) {
692  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
693  canvas->imageInfo().height());
694 
695  main_surface_paint_region = SkRect::MakeXYWH(
696  canvas_size.width() / 4.f, canvas_size.width() / 2.f,
697  canvas_size.width() / 32.f, canvas_size.height() / 32.f);
698 
699  SkPaint rect_paint;
700  rect_paint.setColor(SK_ColorGREEN);
701  canvas->drawRect(main_surface_paint_region, rect_paint);
702  },
703  [&overlay_paint_region](SkCanvas* canvas) {
704  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
705  canvas->imageInfo().height());
706  overlay_paint_region = SkRect::MakeXYWH(
707  canvas_size.width() * 3.f / 4.f, canvas_size.height() / 2.f,
708  canvas_size.width() / 32.f, canvas_size.height() / 32.f);
709 
710  SkPaint rect_paint;
711  rect_paint.setColor(SK_ColorRED);
712  canvas->drawRect(overlay_paint_region, rect_paint);
713  });
714  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
715  view_holder_token, view_ref);
716 
717  // Pump the message loop. The scene updates should propagate to Scenic.
718  loop().RunUntilIdle();
719  std::vector<FakeResource> scenic_layers =
720  ExtractLayersFromSceneGraph(fake_session().SceneGraph());
721  EXPECT_EQ(scenic_layers.size(), 3u);
722  ExpectImageCompositorLayer(scenic_layers[0], frame_size,
723  /* flutter layer index = */ 0,
724  {main_surface_paint_region});
725  ExpectViewCompositorLayer(scenic_layers[1], child_view_token,
726  child_view_params,
727  /* flutter layer index = */ 1);
728  ExpectImageCompositorLayer(scenic_layers[2], frame_size,
729  /* flutter layer index = */ 1,
730  {overlay_paint_region});
731 
732  // Destroy the view.
733  external_view_embedder.DestroyView(child_view_id, [](scenic::ResourceId) {});
734 
735  // Pump the message loop.
736  loop().RunUntilIdle();
737 }
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:13

◆ TEST_F() [51/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
ChangesAccessibilitySettings   
)

Definition at line 666 of file flatland_platform_view_unittest.cc.

References flutter::kAccessibleNavigation, and platform_view.

666  {
667  MockPlatformViewDelegate delegate;
668  flutter::TaskRunners task_runners =
669  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
670 
671  EXPECT_FALSE(delegate.semantics_enabled());
672  EXPECT_EQ(delegate.semantics_features(), 0);
673 
674  auto platform_view =
675  PlatformViewBuilder(delegate, std::move(task_runners)).Build();
676 
677  RunLoopUntilIdle();
678 
679  platform_view.SetSemanticsEnabled(true);
680 
681  EXPECT_TRUE(delegate.semantics_enabled());
682  EXPECT_EQ(delegate.semantics_features(),
683  static_cast<int32_t>(
685 
686  platform_view.SetSemanticsEnabled(false);
687 
688  EXPECT_FALSE(delegate.semantics_enabled());
689  EXPECT_EQ(delegate.semantics_features(), 0);
690 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view

◆ TEST_F() [52/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
EnableWireframeTest   
)

Definition at line 673 of file platform_view_unittest.cc.

References fml::MallocMapping::Copy(), message, and platform_view.

673  {
674  MockPlatformViewDelegate delegate;
675  flutter::TaskRunners task_runners =
676  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
677 
678  // Test wireframe callback function. If the message sent to the platform
679  // view was properly handled and parsed, this function should be called,
680  // setting |wireframe_enabled| to true.
681  bool wireframe_enabled = false;
682  auto EnableWireframeCallback = [&wireframe_enabled](bool should_enable) {
683  wireframe_enabled = should_enable;
684  };
685 
687  PlatformViewBuilder(delegate, std::move(task_runners))
688  .SetEnableWireframeCallback(EnableWireframeCallback)
689  .Build();
690 
691  // Cast platform_view to its base view so we can have access to the public
692  // "HandlePlatformMessage" function.
693  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
694  EXPECT_TRUE(base_view);
695 
696  // JSON for the message to be passed into the PlatformView.
697  const uint8_t txt[] =
698  "{"
699  " \"method\":\"View.enableWireframe\","
700  " \"args\": {"
701  " \"enable\":true"
702  " }"
703  "}";
704 
705  std::unique_ptr<flutter::PlatformMessage> message =
706  std::make_unique<flutter::PlatformMessage>(
707  "flutter/platform_views", fml::MallocMapping::Copy(txt, sizeof(txt)),
709  base_view->HandlePlatformMessage(std::move(message));
710 
711  RunLoopUntilIdle();
712 
713  EXPECT_TRUE(wireframe_enabled);
714 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162

◆ TEST_F() [53/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
EnableWireframeTest   
)

Definition at line 694 of file flatland_platform_view_unittest.cc.

References fml::MallocMapping::Copy(), message, and platform_view.

694  {
695  MockPlatformViewDelegate delegate;
696  flutter::TaskRunners task_runners =
697  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
698 
699  // Test wireframe callback function. If the message sent to the platform
700  // view was properly handled and parsed, this function should be called,
701  // setting |wireframe_enabled| to true.
702  bool wireframe_enabled = false;
703  auto EnableWireframeCallback = [&wireframe_enabled](bool should_enable) {
704  wireframe_enabled = should_enable;
705  };
706 
707  auto platform_view = PlatformViewBuilder(delegate, std::move(task_runners))
708  .SetEnableWireframeCallback(EnableWireframeCallback)
709  .Build();
710 
711  // Cast platform_view to its base view so we can have access to the public
712  // "HandlePlatformMessage" function.
713  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
714  EXPECT_TRUE(base_view);
715 
716  // JSON for the message to be passed into the PlatformView.
717  const uint8_t txt[] =
718  "{"
719  " \"method\":\"View.enableWireframe\","
720  " \"args\": {"
721  " \"enable\":true"
722  " }"
723  "}";
724 
725  std::unique_ptr<flutter::PlatformMessage> message =
726  std::make_unique<flutter::PlatformMessage>(
727  "flutter/platform_views", fml::MallocMapping::Copy(txt, sizeof(txt)),
729  base_view->HandlePlatformMessage(std::move(message));
730 
731  RunLoopUntilIdle();
732 
733  EXPECT_TRUE(wireframe_enabled);
734 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162

◆ TEST_F() [54/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
CreateViewTest   
)

Definition at line 718 of file platform_view_unittest.cc.

References fml::MallocMapping::Copy(), flutter_runner::CreateFMLTaskRunner(), message, and platform_view.

718  {
719  MockPlatformViewDelegate delegate;
720  flutter::TaskRunners task_runners =
721  flutter::TaskRunners("test_runners", // label
723  async_get_default_dispatcher()), // platform
724  nullptr, // raster
725  nullptr, // ui
726  nullptr // io
727  );
728 
729  // Test wireframe callback function. If the message sent to the platform
730  // view was properly handled and parsed, this function should be called,
731  // setting |wireframe_enabled| to true.
732  bool create_view_called = false;
733  auto CreateViewCallback = [&create_view_called](
734  int64_t view_id,
735  flutter_runner::ViewCallback on_view_created,
736  flutter_runner::GfxViewIdCallback on_view_bound,
737  bool hit_testable, bool focusable) {
738  create_view_called = true;
739  on_view_created();
740  on_view_bound(0);
741  };
742 
744  PlatformViewBuilder(delegate, std::move(task_runners))
745  .SetCreateViewCallback(CreateViewCallback)
746  .Build();
747 
748  // Cast platform_view to its base view so we can have access to the public
749  // "HandlePlatformMessage" function.
750  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
751  EXPECT_TRUE(base_view);
752 
753  // JSON for the message to be passed into the PlatformView.
754  const uint8_t txt[] =
755  "{"
756  " \"method\":\"View.create\","
757  " \"args\": {"
758  " \"viewId\":42,"
759  " \"hitTestable\":true,"
760  " \"focusable\":true"
761  " }"
762  "}";
763 
764  std::unique_ptr<flutter::PlatformMessage> message =
765  std::make_unique<flutter::PlatformMessage>(
766  "flutter/platform_views", fml::MallocMapping::Copy(txt, sizeof(txt)),
768  base_view->HandlePlatformMessage(std::move(message));
769 
770  RunLoopUntilIdle();
771 
772  EXPECT_TRUE(create_view_called);
773 }
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
std::function< void()> ViewCallback
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162
std::function< void(scenic::ResourceId)> GfxViewIdCallback

◆ TEST_F() [55/77]

flutter_runner::testing::TEST_F ( FlatlandExternalViewEmbedderTest  ,
SceneWithOneView_DestroyBeforeDrawing   
)

Definition at line 724 of file flatland_external_view_embedder_unittests.cc.

References flutter_runner::testing::ViewTokenPair::New().

725  {
726  fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher;
727  fuchsia::ui::views::ViewportCreationToken viewport_creation_token;
728  fuchsia::ui::views::ViewCreationToken view_creation_token;
729  fuchsia::ui::views::ViewRef view_ref;
730  auto view_creation_token_status = zx::channel::create(
731  0u, &viewport_creation_token.value, &view_creation_token.value);
732  ASSERT_EQ(view_creation_token_status, ZX_OK);
733  auto view_ref_pair = scenic::ViewRefPair::New();
734  view_ref_pair.view_ref.Clone(&view_ref);
735 
736  // Create the `FlatlandExternalViewEmbedder` and pump the message loop until
737  // the initial scene graph is setup.
738  FlatlandExternalViewEmbedder external_view_embedder(
739  std::move(view_creation_token),
740  fuchsia::ui::views::ViewIdentityOnCreation{
741  .view_ref = std::move(view_ref_pair.view_ref),
742  .view_ref_control = std::move(view_ref_pair.control_ref),
743  },
744  fuchsia::ui::composition::ViewBoundProtocols{},
745  parent_viewport_watcher.NewRequest(), flatland_connection(),
746  fake_surface_producer());
747  flatland_connection()->Present();
748  loop().RunUntilIdle();
749  fake_flatland().FireOnNextFrameBeginEvent(WithPresentCredits(1u));
750  loop().RunUntilIdle();
751  EXPECT_THAT(fake_flatland().graph(),
752  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
753  view_ref));
754 
755  // Create the view before drawing the scene.
756  auto [child_view_token, child_viewport_token] = ViewTokenPair::New();
757  const uint32_t child_view_id = child_viewport_token.value.get();
758  external_view_embedder.CreateView(
759  child_view_id, []() {},
760  [](fuchsia::ui::composition::ContentId,
761  fuchsia::ui::composition::ChildViewWatcherPtr) {});
762 
763  // Draw the scene without the view. The scene graph shouldn't change yet.
764  const SkISize frame_size_signed = SkISize::Make(512, 512);
765  const fuchsia::math::SizeU frame_size{
766  static_cast<uint32_t>(frame_size_signed.width()),
767  static_cast<uint32_t>(frame_size_signed.height())};
768  DrawSimpleFrame(
769  external_view_embedder, frame_size_signed, 1.f, [](SkCanvas* canvas) {
770  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
771  canvas->imageInfo().height());
772  SkPaint rect_paint;
773  rect_paint.setColor(SK_ColorGREEN);
774  canvas->translate(canvas_size.width() / 4.f,
775  canvas_size.height() / 2.f);
776  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
777  canvas_size.height() / 32.f),
778  rect_paint);
779  });
780 
781  // Pump the message loop. The scene updates should propagate to flatland.
782  loop().RunUntilIdle();
783  fake_flatland().FireOnNextFrameBeginEvent(WithPresentCredits(1u));
784  loop().RunUntilIdle();
785  EXPECT_THAT(
786  fake_flatland().graph(),
787  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token, view_ref,
788  /*layers*/
789  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1)}));
790 
791  // Destroy the view. The scene graph shouldn't change yet.
792  external_view_embedder.DestroyView(
793  child_view_id, [](fuchsia::ui::composition::ContentId) {});
794  EXPECT_THAT(
795  fake_flatland().graph(),
796  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token, view_ref,
797  /*layers*/
798  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1)}));
799 
800  // Draw another frame without the view and change the size. The scene graph
801  // shouldn't change yet.
802  const SkISize new_frame_size_signed = SkISize::Make(256, 256);
803  const fuchsia::math::SizeU new_frame_size{
804  static_cast<uint32_t>(new_frame_size_signed.width()),
805  static_cast<uint32_t>(new_frame_size_signed.height())};
806  DrawSimpleFrame(
807  external_view_embedder, new_frame_size_signed, 1.f, [](SkCanvas* canvas) {
808  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
809  canvas->imageInfo().height());
810  SkPaint rect_paint;
811  rect_paint.setColor(SK_ColorGREEN);
812  canvas->translate(canvas_size.width() / 4.f,
813  canvas_size.height() / 2.f);
814  canvas->drawRect(SkRect::MakeWH(canvas_size.width() / 32.f,
815  canvas_size.height() / 32.f),
816  rect_paint);
817  });
818  EXPECT_THAT(
819  fake_flatland().graph(),
820  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token, view_ref,
821  /*layers*/
822  {IsImageLayer(frame_size, kFirstLayerBlendMode, 1)}));
823 
824  // Pump the message loop. The scene updates should propagate to flatland.
825  loop().RunUntilIdle();
826  EXPECT_THAT(
827  fake_flatland().graph(),
828  IsFlutterGraph(parent_viewport_watcher, viewport_creation_token,
829  view_ref, /*layers*/
830  {IsImageLayer(new_frame_size, kFirstLayerBlendMode, 1)}));
831 }

◆ TEST_F() [56/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
CreateViewTest   
)

Definition at line 738 of file flatland_platform_view_unittest.cc.

References fml::MallocMapping::Copy(), flutter_runner::CreateFMLTaskRunner(), message, and platform_view.

738  {
739  MockPlatformViewDelegate delegate;
740  flutter::TaskRunners task_runners =
741  flutter::TaskRunners("test_runners", // label
743  async_get_default_dispatcher()), // platform
744  nullptr, // raster
745  nullptr, // ui
746  nullptr // io
747  );
748 
749  // Test wireframe callback function. If the message sent to the platform
750  // view was properly handled and parsed, this function should be called,
751  // setting |wireframe_enabled| to true.
752  bool create_view_called = false;
753  auto CreateViewCallback =
754  [&create_view_called, this](
755  int64_t view_id, flutter_runner::ViewCallback on_view_created,
757  bool hit_testable, bool focusable) {
758  create_view_called = true;
759  on_view_created();
760  fuchsia::ui::composition::ContentId content_id;
761  on_view_bound(std::move(content_id), MakeChildViewWatcher());
762  };
763 
764  auto platform_view = PlatformViewBuilder(delegate, std::move(task_runners))
765  .SetCreateViewCallback(CreateViewCallback)
766  .Build();
767 
768  // Cast platform_view to its base view so we can have access to the public
769  // "HandlePlatformMessage" function.
770  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
771  EXPECT_TRUE(base_view);
772 
773  // JSON for the message to be passed into the PlatformView.
774  const uint8_t txt[] =
775  "{"
776  " \"method\":\"View.create\","
777  " \"args\": {"
778  " \"viewId\":42,"
779  " \"hitTestable\":true,"
780  " \"focusable\":true"
781  " }"
782  "}";
783 
784  std::unique_ptr<flutter::PlatformMessage> message =
785  std::make_unique<flutter::PlatformMessage>(
786  "flutter/platform_views", fml::MallocMapping::Copy(txt, sizeof(txt)),
788  base_view->HandlePlatformMessage(std::move(message));
789 
790  RunLoopUntilIdle();
791 
792  EXPECT_TRUE(create_view_called);
793 }
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
std::function< void(fuchsia::ui::composition::ContentId, fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher)> FlatlandViewCreatedCallback
std::function< void()> ViewCallback
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162

◆ TEST_F() [57/77]

flutter_runner::testing::TEST_F ( GfxExternalViewEmbedderTest  ,
SimpleSceneDisjointHitRegions   
)

Definition at line 742 of file gfx_external_view_embedder_unittests.cc.

References flutter::testing::GetCurrentTestName().

742  {
743  const std::string debug_name = GetCurrentTestName();
744  auto [view_token, view_holder_token] = scenic::ViewTokenPair::New();
745  auto view_ref_pair = scenic::ViewRefPair::New();
746  fuchsia::ui::views::ViewRef view_ref;
747  view_ref_pair.view_ref.Clone(&view_ref);
748 
749  // Create the `GfxExternalViewEmbedder` and pump the message loop until
750  // the initial scene graph is setup.
751  GfxExternalViewEmbedder external_view_embedder(
752  debug_name, std::move(view_token), std::move(view_ref_pair),
753  session_connection(), fake_surface_producer());
754  loop().RunUntilIdle();
755  fake_session().FireOnFramePresentedEvent(
756  MakeFramePresentedInfoForOnePresent(0, 0));
757  loop().RunUntilIdle();
758  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
759  view_holder_token, view_ref);
760 
761  // Draw the scene. The scene graph shouldn't change yet.
762  SkRect paint_region_1, paint_region_2;
763  const SkISize frame_size = SkISize::Make(512, 512);
764  DrawSimpleFrame(
765  external_view_embedder, frame_size, 1.f,
766  [&paint_region_1, &paint_region_2](SkCanvas* canvas) {
767  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
768  canvas->imageInfo().height());
769 
770  paint_region_1 = SkRect::MakeXYWH(
771  canvas_size.width() / 4.f, canvas_size.height() / 2.f,
772  canvas_size.width() / 32.f, canvas_size.height() / 32.f);
773 
774  SkPaint rect_paint;
775  rect_paint.setColor(SK_ColorGREEN);
776  canvas->drawRect(paint_region_1, rect_paint);
777 
778  paint_region_2 = SkRect::MakeXYWH(
779  canvas_size.width() * 3.f / 4.f, canvas_size.height() / 2.f,
780  canvas_size.width() / 32.f, canvas_size.height() / 32.f);
781 
782  rect_paint.setColor(SK_ColorRED);
783  canvas->drawRect(paint_region_2, rect_paint);
784  });
785  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
786  view_holder_token, view_ref);
787 
788  // Pump the message loop. The scene updates should propogate to Scenic.
789  loop().RunUntilIdle();
790  std::vector<FakeResource> scenic_layers =
791  ExtractLayersFromSceneGraph(fake_session().SceneGraph());
792  EXPECT_EQ(scenic_layers.size(), 1u);
793  ExpectImageCompositorLayer(scenic_layers[0], frame_size,
794  /* flutter layer index = */ 0,
795  {paint_region_1, paint_region_2});
796 }
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:13

◆ TEST_F() [58/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
UpdateViewTest   
)

Definition at line 777 of file platform_view_unittest.cc.

References fml::MallocMapping::Copy(), message, and platform_view.

777  {
778  MockPlatformViewDelegate delegate;
779  flutter::TaskRunners task_runners =
780  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
781 
782  std::optional<SkRect> occlusion_hint_for_test;
783  std::optional<bool> hit_testable_for_test;
784  std::optional<bool> focusable_for_test;
785  auto UpdateViewCallback = [&occlusion_hint_for_test, &hit_testable_for_test,
786  &focusable_for_test](
787  int64_t view_id, SkRect occlusion_hint,
788  bool hit_testable, bool focusable) {
789  occlusion_hint_for_test = occlusion_hint;
790  hit_testable_for_test = hit_testable;
791  focusable_for_test = focusable;
792  };
793 
795  PlatformViewBuilder(delegate, std::move(task_runners))
796  .SetUpdateViewCallback(UpdateViewCallback)
797  .Build();
798 
799  // Cast platform_view to its base view so we can have access to the public
800  // "HandlePlatformMessage" function.
801  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
802  EXPECT_TRUE(base_view);
803 
804  // Send a basic message.
805  const uint8_t json[] =
806  "{"
807  " \"method\":\"View.update\","
808  " \"args\": {"
809  " \"viewId\":42,"
810  " \"hitTestable\":true,"
811  " \"focusable\":true"
812  " }"
813  "}";
814  std::unique_ptr<flutter::PlatformMessage> message =
815  std::make_unique<flutter::PlatformMessage>(
816  "flutter/platform_views",
817  fml::MallocMapping::Copy(json, sizeof(json)),
819  base_view->HandlePlatformMessage(std::move(message));
820 
821  RunLoopUntilIdle();
822  ASSERT_TRUE(occlusion_hint_for_test.has_value());
823  ASSERT_TRUE(hit_testable_for_test.has_value());
824  ASSERT_TRUE(focusable_for_test.has_value());
825  EXPECT_EQ(occlusion_hint_for_test.value(), SkRect::MakeEmpty());
826  EXPECT_EQ(hit_testable_for_test.value(), true);
827  EXPECT_EQ(focusable_for_test.value(), true);
828 
829  // Reset for the next message.
830  occlusion_hint_for_test.reset();
831  hit_testable_for_test.reset();
832  focusable_for_test.reset();
833 
834  // Send another basic message.
835  const uint8_t json_false[] =
836  "{"
837  " \"method\":\"View.update\","
838  " \"args\": {"
839  " \"viewId\":42,"
840  " \"hitTestable\":false,"
841  " \"focusable\":false"
842  " }"
843  "}";
844  std::unique_ptr<flutter::PlatformMessage> message_false =
845  std::make_unique<flutter::PlatformMessage>(
846  "flutter/platform_views",
847  fml::MallocMapping::Copy(json_false, sizeof(json_false)),
849  base_view->HandlePlatformMessage(std::move(message_false));
850  RunLoopUntilIdle();
851  ASSERT_TRUE(occlusion_hint_for_test.has_value());
852  ASSERT_TRUE(hit_testable_for_test.has_value());
853  ASSERT_TRUE(focusable_for_test.has_value());
854  EXPECT_EQ(occlusion_hint_for_test.value(), SkRect::MakeEmpty());
855  EXPECT_EQ(hit_testable_for_test.value(), false);
856  EXPECT_EQ(focusable_for_test.value(), false);
857 
858  // Reset for the next message.
859  occlusion_hint_for_test.reset();
860  hit_testable_for_test.reset();
861  focusable_for_test.reset();
862 
863  // Send a message including an occlusion hint.
864  const uint8_t json_occlusion_hint[] =
865  "{"
866  " \"method\":\"View.update\","
867  " \"args\": {"
868  " \"viewId\":42,"
869  " \"hitTestable\":true,"
870  " \"focusable\":true,"
871  " \"viewOcclusionHintLTRB\":[0.1,0.2,0.3,0.4]"
872  " }"
873  "}";
874  std::unique_ptr<flutter::PlatformMessage> message_occlusion_hint =
875  std::make_unique<flutter::PlatformMessage>(
876  "flutter/platform_views",
877  fml::MallocMapping::Copy(json_occlusion_hint,
878  sizeof(json_occlusion_hint)),
880  base_view->HandlePlatformMessage(std::move(message_occlusion_hint));
881  RunLoopUntilIdle();
882  ASSERT_TRUE(occlusion_hint_for_test.has_value());
883  ASSERT_TRUE(hit_testable_for_test.has_value());
884  ASSERT_TRUE(focusable_for_test.has_value());
885  EXPECT_EQ(occlusion_hint_for_test.value(),
886  SkRect::MakeLTRB(0.1, 0.2, 0.3, 0.4));
887  EXPECT_EQ(hit_testable_for_test.value(), true);
888  EXPECT_EQ(focusable_for_test.value(), true);
889 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162

◆ TEST_F() [59/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
UpdateViewTest   
)

Definition at line 797 of file flatland_platform_view_unittest.cc.

References fml::MallocMapping::Copy(), message, and platform_view.

797  {
798  MockPlatformViewDelegate delegate;
799  flutter::TaskRunners task_runners =
800  flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr);
801 
802  std::optional<SkRect> occlusion_hint_for_test;
803  std::optional<bool> hit_testable_for_test;
804  std::optional<bool> focusable_for_test;
805  auto UpdateViewCallback = [&occlusion_hint_for_test, &hit_testable_for_test,
806  &focusable_for_test](
807  int64_t view_id, SkRect occlusion_hint,
808  bool hit_testable, bool focusable) {
809  occlusion_hint_for_test = occlusion_hint;
810  hit_testable_for_test = hit_testable;
811  focusable_for_test = focusable;
812  };
813 
814  auto platform_view = PlatformViewBuilder(delegate, std::move(task_runners))
815  .SetUpdateViewCallback(UpdateViewCallback)
816  .Build();
817 
818  // Cast platform_view to its base view so we can have access to the public
819  // "HandlePlatformMessage" function.
820  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
821  EXPECT_TRUE(base_view);
822 
823  // Send a basic message.
824  const uint8_t json[] =
825  "{"
826  " \"method\":\"View.update\","
827  " \"args\": {"
828  " \"viewId\":42,"
829  " \"hitTestable\":true,"
830  " \"focusable\":true"
831  " }"
832  "}";
833  std::unique_ptr<flutter::PlatformMessage> message =
834  std::make_unique<flutter::PlatformMessage>(
835  "flutter/platform_views",
836  fml::MallocMapping::Copy(json, sizeof(json)),
838  base_view->HandlePlatformMessage(std::move(message));
839 
840  RunLoopUntilIdle();
841  ASSERT_TRUE(occlusion_hint_for_test.has_value());
842  ASSERT_TRUE(hit_testable_for_test.has_value());
843  ASSERT_TRUE(focusable_for_test.has_value());
844  EXPECT_EQ(occlusion_hint_for_test.value(), SkRect::MakeEmpty());
845  EXPECT_EQ(hit_testable_for_test.value(), true);
846  EXPECT_EQ(focusable_for_test.value(), true);
847 
848  // Reset for the next message.
849  occlusion_hint_for_test.reset();
850  hit_testable_for_test.reset();
851  focusable_for_test.reset();
852 
853  // Send another basic message.
854  const uint8_t json_false[] =
855  "{"
856  " \"method\":\"View.update\","
857  " \"args\": {"
858  " \"viewId\":42,"
859  " \"hitTestable\":false,"
860  " \"focusable\":false"
861  " }"
862  "}";
863  std::unique_ptr<flutter::PlatformMessage> message_false =
864  std::make_unique<flutter::PlatformMessage>(
865  "flutter/platform_views",
866  fml::MallocMapping::Copy(json_false, sizeof(json_false)),
868  base_view->HandlePlatformMessage(std::move(message_false));
869  RunLoopUntilIdle();
870  ASSERT_TRUE(occlusion_hint_for_test.has_value());
871  ASSERT_TRUE(hit_testable_for_test.has_value());
872  ASSERT_TRUE(focusable_for_test.has_value());
873  EXPECT_EQ(occlusion_hint_for_test.value(), SkRect::MakeEmpty());
874  EXPECT_EQ(hit_testable_for_test.value(), false);
875  EXPECT_EQ(focusable_for_test.value(), false);
876 
877  // Reset for the next message.
878  occlusion_hint_for_test.reset();
879  hit_testable_for_test.reset();
880  focusable_for_test.reset();
881 
882  // Send a message including an occlusion hint.
883  const uint8_t json_occlusion_hint[] =
884  "{"
885  " \"method\":\"View.update\","
886  " \"args\": {"
887  " \"viewId\":42,"
888  " \"hitTestable\":true,"
889  " \"focusable\":true,"
890  " \"viewOcclusionHintLTRB\":[0.1,0.2,0.3,0.4]"
891  " }"
892  "}";
893  std::unique_ptr<flutter::PlatformMessage> message_occlusion_hint =
894  std::make_unique<flutter::PlatformMessage>(
895  "flutter/platform_views",
896  fml::MallocMapping::Copy(json_occlusion_hint,
897  sizeof(json_occlusion_hint)),
899  base_view->HandlePlatformMessage(std::move(message_occlusion_hint));
900  RunLoopUntilIdle();
901  ASSERT_TRUE(occlusion_hint_for_test.has_value());
902  ASSERT_TRUE(hit_testable_for_test.has_value());
903  ASSERT_TRUE(focusable_for_test.has_value());
904  EXPECT_EQ(occlusion_hint_for_test.value(),
905  SkRect::MakeLTRB(0.1, 0.2, 0.3, 0.4));
906  EXPECT_EQ(hit_testable_for_test.value(), true);
907  EXPECT_EQ(focusable_for_test.value(), true);
908 }
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162

◆ TEST_F() [60/77]

flutter_runner::testing::TEST_F ( GfxExternalViewEmbedderTest  ,
SimpleSceneOverlappingHitRegions   
)

Definition at line 801 of file gfx_external_view_embedder_unittests.cc.

References flutter::testing::GetCurrentTestName().

801  {
802  const std::string debug_name = GetCurrentTestName();
803  auto [view_token, view_holder_token] = scenic::ViewTokenPair::New();
804  auto view_ref_pair = scenic::ViewRefPair::New();
805  fuchsia::ui::views::ViewRef view_ref;
806  view_ref_pair.view_ref.Clone(&view_ref);
807 
808  // Create the `GfxExternalViewEmbedder` and pump the message loop until
809  // the initial scene graph is setup.
810  GfxExternalViewEmbedder external_view_embedder(
811  debug_name, std::move(view_token), std::move(view_ref_pair),
812  session_connection(), fake_surface_producer());
813  loop().RunUntilIdle();
814  fake_session().FireOnFramePresentedEvent(
815  MakeFramePresentedInfoForOnePresent(0, 0));
816  loop().RunUntilIdle();
817  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
818  view_holder_token, view_ref);
819 
820  // Draw the scene. The scene graph shouldn't change yet.
821  SkRect joined_paint_region = SkRect::MakeEmpty();
822  const SkISize frame_size = SkISize::Make(512, 512);
823  DrawSimpleFrame(
824  external_view_embedder, frame_size, 1.f,
825  [&joined_paint_region](SkCanvas* canvas) {
826  const SkSize canvas_size = SkSize::Make(canvas->imageInfo().width(),
827  canvas->imageInfo().height());
828 
829  auto paint_region_1 = SkRect::MakeXYWH(
830  canvas_size.width() / 4.f, canvas_size.height() / 4.f,
831  canvas_size.width() / 2.f, canvas_size.height() / 2.f);
832  SkPaint rect_paint;
833  rect_paint.setColor(SK_ColorGREEN);
834  canvas->drawRect(paint_region_1, rect_paint);
835 
836  auto paint_region_2 = SkRect::MakeXYWH(
837  canvas_size.width() * 3.f / 8.f, canvas_size.height() / 4.f,
838  canvas_size.width() / 2.f, canvas_size.height() / 2.f);
839  rect_paint.setColor(SK_ColorRED);
840  canvas->drawRect(paint_region_2, rect_paint);
841 
842  joined_paint_region.join(paint_region_1);
843  joined_paint_region.join(paint_region_2);
844  });
845  ExpectRootSceneGraph(fake_session().SceneGraph(), debug_name,
846  view_holder_token, view_ref);
847 
848  EXPECT_EQ(joined_paint_region.x(), 128.f);
849  EXPECT_EQ(joined_paint_region.y(), 128.f);
850  EXPECT_EQ(joined_paint_region.width(), 320.f);
851  EXPECT_EQ(joined_paint_region.height(), 256.f);
852  // Pump the message loop. The scene updates should propogate to Scenic.
853  loop().RunUntilIdle();
854  std::vector<FakeResource> scenic_layers =
855  ExtractLayersFromSceneGraph(fake_session().SceneGraph());
856  EXPECT_EQ(scenic_layers.size(), 1u);
857  ExpectImageCompositorLayer(scenic_layers[0], frame_size,
858  /* flutter layer index = */ 0,
859  {joined_paint_region});
860 }
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:13

◆ TEST_F() [61/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
DestroyViewTest   
)

Definition at line 893 of file platform_view_unittest.cc.

References fml::MallocMapping::Copy(), flutter_runner::CreateFMLTaskRunner(), message, and platform_view.

893  {
894  MockPlatformViewDelegate delegate;
895  flutter::TaskRunners task_runners =
896  flutter::TaskRunners("test_runners", // label
898  async_get_default_dispatcher()), // platform
899  nullptr, // raster
900  nullptr, // ui
901  nullptr // io
902  );
903 
904  // Test wireframe callback function. If the message sent to the platform
905  // view was properly handled and parsed, this function should be called,
906  // setting |wireframe_enabled| to true.
907  bool destroy_view_called = false;
908  auto DestroyViewCallback =
909  [&destroy_view_called](
910  int64_t view_id, flutter_runner::GfxViewIdCallback on_view_unbound) {
911  destroy_view_called = true;
912  on_view_unbound(0);
913  };
914 
916  PlatformViewBuilder(delegate, std::move(task_runners))
917  .SetDestroyViewCallback(DestroyViewCallback)
918  .Build();
919 
920  // Cast platform_view to its base view so we can have access to the public
921  // "HandlePlatformMessage" function.
922  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
923  EXPECT_TRUE(base_view);
924 
925  // JSON for the message to be passed into the PlatformView.
926  const uint8_t txt[] =
927  "{"
928  " \"method\":\"View.dispose\","
929  " \"args\": {"
930  " \"viewId\":42"
931  " }"
932  "}";
933 
934  std::unique_ptr<flutter::PlatformMessage> message =
935  std::make_unique<flutter::PlatformMessage>(
936  "flutter/platform_views", fml::MallocMapping::Copy(txt, sizeof(txt)),
938  base_view->HandlePlatformMessage(std::move(message));
939 
940  RunLoopUntilIdle();
941 
942  EXPECT_TRUE(destroy_view_called);
943 }
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162
std::function< void(scenic::ResourceId)> GfxViewIdCallback

◆ TEST_F() [62/77]

flutter_runner::testing::TEST_F ( FlatlandPlatformViewTests  ,
DestroyViewTest   
)

Definition at line 912 of file flatland_platform_view_unittest.cc.

References fml::MallocMapping::Copy(), flutter_runner::testing::FakePlatformMessageResponse::Create(), flutter_runner::CreateFMLTaskRunner(), message, and platform_view.

912  {
913  MockPlatformViewDelegate delegate;
914  flutter::TaskRunners task_runners =
915  flutter::TaskRunners("test_runners", // label
917  async_get_default_dispatcher()), // platform
918  nullptr, // raster
919  nullptr, // ui
920  nullptr // io
921  );
922 
923  bool destroy_view_called = false;
924 
925  auto on_destroy_view =
926  [&destroy_view_called](
927  int64_t view_id,
928  flutter_runner::FlatlandViewIdCallback on_view_unbound) {
929  destroy_view_called = true;
930  fuchsia::ui::composition::ContentId content_id;
931  on_view_unbound(std::move(content_id));
932  };
933 
934  bool create_view_called = false;
935  auto on_create_view =
936  [&create_view_called, this](
937  int64_t view_id, flutter_runner::ViewCallback on_view_created,
939  bool hit_testable, bool focusable) {
940  create_view_called = true;
941  on_view_created();
942  fuchsia::ui::composition::ContentId content_id;
943  on_view_bound(std::move(content_id), MakeChildViewWatcher());
944  };
945 
946  auto platform_view = PlatformViewBuilder(delegate, std::move(task_runners))
947  .SetCreateViewCallback(on_create_view)
948  .SetDestroyViewCallback(on_destroy_view)
949  .Build();
950 
951  // Cast platform_view to its base view so we can have access to the public
952  // "HandlePlatformMessage" function.
953  auto base_view = static_cast<flutter::PlatformView*>(&platform_view);
954  EXPECT_TRUE(base_view);
955 
956  std::ostringstream create_message;
957  create_message << "{"
958  << " \"method\":\"View.create\","
959  << " \"args\": {"
960  << " \"viewId\":42,"
961  << " \"hitTestable\":true,"
962  << " \"focusable\":true"
963  << " }"
964  << "}";
965 
966  auto create_response = FakePlatformMessageResponse::Create();
967  base_view->HandlePlatformMessage(create_response->WithMessage(
968  "flutter/platform_views", create_message.str()));
969  RunLoopUntilIdle();
970 
971  // JSON for the message to be passed into the PlatformView.
972  const uint8_t txt[] =
973  "{"
974  " \"method\":\"View.dispose\","
975  " \"args\": {"
976  " \"viewId\":42"
977  " }"
978  "}";
979 
980  std::unique_ptr<flutter::PlatformMessage> message =
981  std::make_unique<flutter::PlatformMessage>(
982  "flutter/platform_views", fml::MallocMapping::Copy(txt, sizeof(txt)),
984  base_view->HandlePlatformMessage(std::move(message));
985 
986  RunLoopUntilIdle();
987 
988  EXPECT_TRUE(destroy_view_called);
989 }
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
std::unique_ptr< flutter::PlatformViewIOS > platform_view
Win32Message message
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:52
std::function< void(fuchsia::ui::composition::ContentId, fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher)> FlatlandViewCreatedCallback
std::function< void(fuchsia::ui::composition::ContentId)> FlatlandViewIdCallback
std::function< void()> ViewCallback
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162

◆ TEST_F() [63/77]

flutter_runner::testing::TEST_F ( PlatformViewTests  ,
ViewEventsTest   
)

Definition at line 948 of file platform_view_unittest.cc.

References fml::MallocMapping::Copy(), flutter_runner::CreateFMLTaskRunner(), flutter::PlatformMessage::data(), platform_view, and impeller::compiler::ToString().

948  {
949  constexpr int64_t kViewId = 33;
950  constexpr scenic::ResourceId kViewHolderId = 42;
951  MockPlatformViewDelegate delegate;
952 
953  fuchsia::ui::scenic::SessionListenerPtr session_listener;
954  std::vector<fuchsia::ui::scenic::Event> events;
955  flutter::TaskRunners task_runners =
956  flutter::TaskRunners("test_runners", // label
958  async_get_default_dispatcher()), // platform
960  async_get_default_dispatcher()), // raster
962  async_get_default_dispatcher()), // ui
963  nullptr // io
964  );
965 
966  auto on_create_view =
967  [kViewId](int64_t view_id, flutter_runner::ViewCallback on_view_created,
968  flutter_runner::GfxViewIdCallback on_view_bound,
969  bool hit_testable, bool focusable) {
970  ASSERT_EQ(view_id, kViewId);
971  on_view_created();
972  on_view_bound(kViewHolderId);
973  };
974 
976  PlatformViewBuilder(delegate, std::move(task_runners))
977  .SetSessionListenerRequest(session_listener.NewRequest())
978  .SetCreateViewCallback(on_create_view)
979  .Build();
980  RunLoopUntilIdle();
981  ASSERT_EQ(delegate.message(), nullptr);
982 
983  // Create initial view for testing.
984  std::ostringstream create_view_message;
985  create_view_message << "{"
986  << " \"method\":\"View.create\","
987  << " \"args\":{"
988  << " \"viewId\":" << kViewId << ","
989  << " \"hitTestable\":true,"
990  << " \"focusable\":true"
991  << " }"
992