Flutter Engine
flutter::testing::MockSession Class Reference
Inheritance diagram for flutter::testing::MockSession:

Public Member Functions

 MockSession ()
 
void NotImplemented_ (const std::string &name) final
 
void Bind (fidl::InterfaceRequest<::fuchsia::ui::scenic::Session > request, ::fuchsia::ui::scenic::SessionListenerPtr listener)
 
void Enqueue (std::vector< fuchsia::ui::scenic::Command > cmds) override
 
void SetExpectedCommands (std::vector< fuchsia::ui::gfx::Command > gfx_cmds)
 
size_t num_enqueued_commands ()
 

Static Public Member Functions

static std::string Vec3ValueToString (fuchsia::ui::gfx::Vector3Value value)
 
static std::string QuaternionValueToString (fuchsia::ui::gfx::QuaternionValue value)
 
static std::string GfxCreateResourceCmdToString (const fuchsia::ui::gfx::CreateResourceCmd &cmd)
 
static std::string GfxCmdToString (const fuchsia::ui::gfx::Command &cmd)
 
static std::string ScenicCmdToString (const fuchsia::ui::scenic::Command &cmd)
 

Detailed Description

Definition at line 32 of file fuchsia_layer_unittests.cc.

Constructor & Destructor Documentation

◆ MockSession()

flutter::testing::MockSession::MockSession ( )
inline

Definition at line 34 of file fuchsia_layer_unittests.cc.

34 : binding_(this) {}

Member Function Documentation

◆ Bind()

void flutter::testing::MockSession::Bind ( fidl::InterfaceRequest<::fuchsia::ui::scenic::Session >  request,
::fuchsia::ui::scenic::SessionListenerPtr  listener 
)
inline

Definition at line 38 of file fuchsia_layer_unittests.cc.

39  {
40  binding_.Bind(std::move(request));
41  listener_ = std::move(listener);
42  }

◆ Enqueue()

void flutter::testing::MockSession::Enqueue ( std::vector< fuchsia::ui::scenic::Command >  cmds)
inlineoverride

Definition at line 152 of file fuchsia_layer_unittests.cc.

References ScenicCmdToString().

152  {
153  for (const auto& cmd : cmds) {
154  num_enqueued_commands_++;
155  EXPECT_FALSE(expected_.empty())
156  << "Received more commands than expected; command: <"
157  << ScenicCmdToString(cmd)
158  << ">, num_enqueued_commands: " << num_enqueued_commands_;
159  if (!expected_.empty()) {
160  EXPECT_TRUE(AreCommandsEqual(expected_.front(), cmd))
161  << "actual command: <" << ScenicCmdToString(cmd)
162  << ">, expected command: <" << ScenicCmdToString(expected_.front())
163  << ">, num_enqueued_commands: " << num_enqueued_commands_;
164  expected_.pop_front();
165  }
166  }
167  }
static std::string ScenicCmdToString(const fuchsia::ui::scenic::Command &cmd)

◆ GfxCmdToString()

static std::string flutter::testing::MockSession::GfxCmdToString ( const fuchsia::ui::gfx::Command &  cmd)
inlinestatic

Definition at line 87 of file fuchsia_layer_unittests.cc.

References GfxCreateResourceCmdToString(), QuaternionValueToString(), and Vec3ValueToString().

Referenced by ScenicCmdToString().

87  {
88  switch (cmd.Which()) {
89  case fuchsia::ui::gfx::Command::Tag::kCreateResource:
90  return "CreateResource: " +
91  GfxCreateResourceCmdToString(cmd.create_resource());
92  case fuchsia::ui::gfx::Command::Tag::kReleaseResource:
93  return "ReleaseResource id: " +
94  std::to_string(cmd.release_resource().id);
95  case fuchsia::ui::gfx::Command::Tag::kAddChild:
96  return "AddChild id: " + std::to_string(cmd.add_child().node_id) +
97  " child_id: " + std::to_string(cmd.add_child().child_id);
98  case fuchsia::ui::gfx::Command::Tag::kSetTranslation:
99  return "SetTranslation id: " +
100  std::to_string(cmd.set_translation().id) +
101  " value: " + Vec3ValueToString(cmd.set_translation().value);
102  case fuchsia::ui::gfx::Command::Tag::kSetScale:
103  return "SetScale id: " + std::to_string(cmd.set_scale().id) +
104  " value: " + Vec3ValueToString(cmd.set_scale().value);
105  case fuchsia::ui::gfx::Command::Tag::kSetRotation:
106  return "SetRotation id: " + std::to_string(cmd.set_rotation().id) +
107  " value: " + QuaternionValueToString(cmd.set_rotation().value);
108  case fuchsia::ui::gfx::Command::Tag::kSetOpacity:
109  return "SetOpacity id: " + std::to_string(cmd.set_opacity().node_id) +
110  ", opacity: " + std::to_string(cmd.set_opacity().opacity);
111  case fuchsia::ui::gfx::Command::Tag::kSetColor:
112  return "SetColor id: " + std::to_string(cmd.set_color().material_id) +
113  ", rgba: (" + std::to_string(cmd.set_color().color.value.red) +
114  ", " + std::to_string(cmd.set_color().color.value.green) + ", " +
115  std::to_string(cmd.set_color().color.value.blue) + ", " +
116  std::to_string(cmd.set_color().color.value.alpha) + ")";
117  case fuchsia::ui::gfx::Command::Tag::kSetLabel:
118  return "SetLabel id: " + std::to_string(cmd.set_label().id) + " " +
119  cmd.set_label().label;
120  case fuchsia::ui::gfx::Command::Tag::kSetHitTestBehavior:
121  return "SetHitTestBehavior node_id: " +
122  std::to_string(cmd.set_hit_test_behavior().node_id);
123  case fuchsia::ui::gfx::Command::Tag::kSetClipPlanes:
124  return "SetClipPlanes node_id: " +
125  std::to_string(cmd.set_clip_planes().node_id);
126  case fuchsia::ui::gfx::Command::Tag::kSetShape:
127  return "SetShape node_id: " + std::to_string(cmd.set_shape().node_id) +
128  ", shape_id: " + std::to_string(cmd.set_shape().shape_id);
129  case fuchsia::ui::gfx::Command::Tag::kSetMaterial:
130  return "SetMaterial node_id: " +
131  std::to_string(cmd.set_material().node_id) + ", material_id: " +
132  std::to_string(cmd.set_material().material_id);
133  case fuchsia::ui::gfx::Command::Tag::kSetTexture:
134  return "SetTexture material_id: " +
135  std::to_string(cmd.set_texture().material_id) +
136  ", texture_id: " + std::to_string(cmd.set_texture().texture_id);
137 
138  default:
139  return "Unhandled gfx command" + std::to_string(cmd.Which());
140  }
141  }
static std::string QuaternionValueToString(fuchsia::ui::gfx::QuaternionValue value)
static std::string GfxCreateResourceCmdToString(const fuchsia::ui::gfx::CreateResourceCmd &cmd)
static std::string Vec3ValueToString(fuchsia::ui::gfx::Vector3Value value)

◆ GfxCreateResourceCmdToString()

static std::string flutter::testing::MockSession::GfxCreateResourceCmdToString ( const fuchsia::ui::gfx::CreateResourceCmd &  cmd)
inlinestatic

Definition at line 58 of file fuchsia_layer_unittests.cc.

References id.

Referenced by GfxCmdToString().

59  {
60  std::string id = " id: " + std::to_string(cmd.id);
61  switch (cmd.resource.Which()) {
62  case fuchsia::ui::gfx::ResourceArgs::Tag::kRectangle:
63  return "Rectangle" + id;
64  case fuchsia::ui::gfx::ResourceArgs::Tag::kRoundedRectangle:
65  return "RoundedRectangle" + id;
66  case fuchsia::ui::gfx::ResourceArgs::Tag::kViewHolder:
67  return "ViewHolder" + id;
68  case fuchsia::ui::gfx::ResourceArgs::Tag::kOpacityNode:
69  return "OpacityNode" + id;
70  case fuchsia::ui::gfx::ResourceArgs::Tag::kEntityNode:
71  return "EntityNode" + id;
72  case fuchsia::ui::gfx::ResourceArgs::Tag::kShapeNode:
73  return "ShapeNode" + id;
74  case fuchsia::ui::gfx::ResourceArgs::Tag::kMaterial:
75  return "Material" + id;
76  case fuchsia::ui::gfx::ResourceArgs::Tag::kImage:
77  return "Image" + id + ", memory_id: " +
78  std::to_string(cmd.resource.image().memory_id) +
79  ", memory_offset: " +
80  std::to_string(cmd.resource.image().memory_offset);
81  default:
82  return "Unhandled CreateResource command" +
83  std::to_string(cmd.resource.Which());
84  }
85  }
int32_t id

◆ NotImplemented_()

void flutter::testing::MockSession::NotImplemented_ ( const std::string &  name)
inlinefinal

Definition at line 36 of file fuchsia_layer_unittests.cc.

36 {}

◆ num_enqueued_commands()

size_t flutter::testing::MockSession::num_enqueued_commands ( )
inline

Definition at line 178 of file fuchsia_layer_unittests.cc.

178 { return num_enqueued_commands_; }

◆ QuaternionValueToString()

static std::string flutter::testing::MockSession::QuaternionValueToString ( fuchsia::ui::gfx::QuaternionValue  value)
inlinestatic

Definition at line 50 of file fuchsia_layer_unittests.cc.

Referenced by GfxCmdToString().

51  {
52  return "{" + std::to_string(value.value.x) + ", " +
53  std::to_string(value.value.y) + ", " +
54  std::to_string(value.value.z) + ", " +
55  std::to_string(value.value.w) + "}";
56  }
uint8_t value

◆ ScenicCmdToString()

static std::string flutter::testing::MockSession::ScenicCmdToString ( const fuchsia::ui::scenic::Command &  cmd)
inlinestatic

Definition at line 143 of file fuchsia_layer_unittests.cc.

References GfxCmdToString().

Referenced by Enqueue().

144  {
145  if (cmd.Which() != fuchsia::ui::scenic::Command::Tag::kGfx) {
146  return "Unhandled non-gfx command: " + std::to_string(cmd.Which());
147  }
148  return GfxCmdToString(cmd.gfx());
149  }
static std::string GfxCmdToString(const fuchsia::ui::gfx::Command &cmd)

◆ SetExpectedCommands()

void flutter::testing::MockSession::SetExpectedCommands ( std::vector< fuchsia::ui::gfx::Command >  gfx_cmds)
inline

Definition at line 169 of file fuchsia_layer_unittests.cc.

169  {
170  std::deque<fuchsia::ui::scenic::Command> scenic_commands;
171  for (auto it = gfx_cmds.begin(); it != gfx_cmds.end(); it++) {
172  scenic_commands.push_back(scenic::NewCommand(std::move((*it))));
173  }
174  expected_ = std::move(scenic_commands);
175  num_enqueued_commands_ = 0;
176  }

◆ Vec3ValueToString()

static std::string flutter::testing::MockSession::Vec3ValueToString ( fuchsia::ui::gfx::Vector3Value  value)
inlinestatic

Definition at line 44 of file fuchsia_layer_unittests.cc.

Referenced by GfxCmdToString().

44  {
45  return "{" + std::to_string(value.value.x) + ", " +
46  std::to_string(value.value.y) + ", " +
47  std::to_string(value.value.z) + "}";
48  }
uint8_t value

The documentation for this class was generated from the following file: