[fuchsia][flatland] Tests for FlatlandPlatformView (flutter/engine#29999)
This commit is contained in:
@@ -477,6 +477,7 @@ if (enable_unittests) {
|
||||
"tests/fake_session_unittests.cc",
|
||||
"tests/flatland_connection_unittests.cc",
|
||||
"tests/flatland_external_view_embedder_unittests.cc",
|
||||
"tests/flatland_platform_view_unittest.cc",
|
||||
"tests/flutter_runner_product_configuration_unittests.cc",
|
||||
"tests/gfx_external_view_embedder_unittests.cc",
|
||||
"tests/gfx_session_connection_unittests.cc",
|
||||
|
||||
@@ -73,6 +73,10 @@ void FlatlandPlatformView::OnGetLayout(
|
||||
static_cast<float>(info.logical_size().height)};
|
||||
|
||||
// TODO(fxbug.dev/64201): Set device pixel ratio.
|
||||
if (info.pixel_scale().width != 1 || info.pixel_scale().height != 1) {
|
||||
FML_LOG(ERROR)
|
||||
<< "Flutter does not currently support pixel_scale's other than 1";
|
||||
}
|
||||
|
||||
SetViewportMetrics({
|
||||
1, // device_pixel_ratio
|
||||
@@ -204,6 +208,7 @@ void FlatlandPlatformView::OnCreateView(ViewCallback on_view_created,
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
on_create_view_callback_(view_id_raw, std::move(on_view_created),
|
||||
std::move(on_view_bound), hit_testable, focusable);
|
||||
}
|
||||
@@ -211,9 +216,9 @@ void FlatlandPlatformView::OnCreateView(ViewCallback on_view_created,
|
||||
void FlatlandPlatformView::OnDisposeView(int64_t view_id_raw) {
|
||||
auto on_view_unbound =
|
||||
[weak = weak_factory_.GetWeakPtr(),
|
||||
platform_task_runner = task_runners_.GetPlatformTaskRunner()](
|
||||
fuchsia::ui::composition::ContentId content_id) {
|
||||
platform_task_runner->PostTask([weak, content_id]() {
|
||||
platform_task_runner = task_runners_.GetPlatformTaskRunner(),
|
||||
view_id_raw](fuchsia::ui::composition::ContentId content_id) {
|
||||
platform_task_runner->PostTask([weak, content_id, view_id_raw]() {
|
||||
if (!weak) {
|
||||
FML_LOG(WARNING)
|
||||
<< "Flatland View unbound from PlatformView after PlatformView"
|
||||
@@ -223,6 +228,7 @@ void FlatlandPlatformView::OnDisposeView(int64_t view_id_raw) {
|
||||
|
||||
FML_DCHECK(weak->child_view_info_.count(content_id.value) == 1);
|
||||
weak->child_view_info_.erase(content_id.value);
|
||||
weak->focus_delegate_->OnDisposeChildView(view_id_raw);
|
||||
});
|
||||
};
|
||||
on_destroy_view_callback_(view_id_raw, std::move(on_view_unbound));
|
||||
|
||||
@@ -87,7 +87,8 @@ bool FocusDelegate::HandlePlatformMessage(
|
||||
if (child_view_view_refs_.count(id) != 1) {
|
||||
FML_LOG(ERROR) << "Argument 'viewId' (" << id
|
||||
<< ") does not refer to a valid ChildView";
|
||||
return false;
|
||||
Complete(std::move(response), "[1]");
|
||||
return true;
|
||||
}
|
||||
|
||||
return RequestFocusById(id, std::move(response));
|
||||
@@ -104,6 +105,11 @@ void FocusDelegate::OnChildViewViewRef(uint64_t view_id,
|
||||
child_view_view_refs_[view_id] = std::move(view_ref);
|
||||
}
|
||||
|
||||
void FocusDelegate::OnDisposeChildView(uint64_t view_id) {
|
||||
FML_CHECK(child_view_view_refs_.count(view_id) == 1);
|
||||
child_view_view_refs_.erase(view_id);
|
||||
}
|
||||
|
||||
void FocusDelegate::Complete(
|
||||
fml::RefPtr<flutter::PlatformMessageResponse> response,
|
||||
std::string value) {
|
||||
|
||||
@@ -53,6 +53,8 @@ class FocusDelegate {
|
||||
void OnChildViewViewRef(uint64_t view_id,
|
||||
fuchsia::ui::views::ViewRef view_ref);
|
||||
|
||||
void OnDisposeChildView(uint64_t view_id);
|
||||
|
||||
private:
|
||||
fuchsia::ui::views::ViewRefFocusedPtr view_ref_focused_;
|
||||
fuchsia::ui::views::FocuserPtr focuser_;
|
||||
|
||||
@@ -29,6 +29,8 @@ class FakePlatformMessageResponse : public PlatformMessageResponse {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsCompleted() { return is_complete_; }
|
||||
|
||||
std::unique_ptr<PlatformMessage> WithMessage(std::string channel,
|
||||
std::string message) {
|
||||
return std::make_unique<PlatformMessage>(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user