Skip to content

Commit

Permalink
[ui][testing] Allow multiple calls to AttachClientView()
Browse files Browse the repository at this point in the history
Bug: 113684
Test: touch-input-test
Change-Id: If41973c7ffa68ffbf567355f6f56f7364ac709b2
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/750486
Reviewed-by: Caroline Liu <[email protected]>
Commit-Queue: Alexander Brusher <[email protected]>
  • Loading branch information
abrush21 authored and CQ Bot committed Oct 31, 2022
1 parent c356c26 commit 8cd0c1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/ui/testing/scene_provider/scene_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ namespace ui_testing {

void FakeViewController::Dismiss() { dismiss_(); }

SceneProvider::SceneProvider(sys::ComponentContext* context) : context_(context) {
auto scene_provider_config = scene_provider_config_lib::Config::TakeFromStartupHandle();
use_flatland_ = scene_provider_config.use_flatland();
use_scene_manager_ = scene_provider_config.use_scene_manager();
}

void SceneProvider::AttachClientView(
fuchsia::ui::test::scene::ControllerAttachClientViewRequest request,
AttachClientViewCallback callback) {
FX_LOGS(INFO) << "Attach client view";

auto scene_provider_config = scene_provider_config_lib::Config::TakeFromStartupHandle();

fuchsia::ui::views::ViewRef client_view_ref;

if (scene_provider_config.use_scene_manager()) {
if (use_scene_manager_) {
fuchsia::session::scene::ManagerSyncPtr scene_manager;
context_->svc()->Connect(scene_manager.NewRequest());

Expand Down Expand Up @@ -85,16 +89,14 @@ void SceneProvider::PresentView(
fake_view_controller_.emplace(std::move(view_controller), [this] { this->DismissView(); });
}

auto scene_provider_config = scene_provider_config_lib::Config::TakeFromStartupHandle();

// TODO(fxbug.dev/106094): Register client's scoped view tree watcher, if
// requested.

// On GFX, |view_spec| will have the `view_ref` and `view_holder_token` fields
// set. On flatland, it will have the `viewport_creation_token` field set.
// Any other combination thereof is invalid.
if (view_spec.has_view_ref() && view_spec.has_view_holder_token()) {
if (scene_provider_config.use_scene_manager()) {
if (use_scene_manager_) {
fuchsia::session::scene::ManagerSyncPtr scene_manager;
context_->svc()->Connect(scene_manager.NewRequest());

Expand All @@ -110,8 +112,7 @@ void SceneProvider::PresentView(
/* presentation */ nullptr);
}
} else if (view_spec.has_viewport_creation_token()) {
FX_CHECK(scene_provider_config.use_scene_manager())
<< "Flatland not supported on root presenter";
FX_CHECK(use_scene_manager_) << "Flatland not supported on root presenter";

fuchsia::session::scene::ManagerSyncPtr scene_manager;
context_->svc()->Connect(scene_manager.NewRequest());
Expand Down
4 changes: 3 additions & 1 deletion src/ui/testing/scene_provider/scene_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FakeViewController : public fuchsia::element::ViewController {
class SceneProvider : public fuchsia::ui::test::scene::Controller,
public fuchsia::element::GraphicalPresenter {
public:
explicit SceneProvider(sys::ComponentContext* context) : context_(context) {}
explicit SceneProvider(sys::ComponentContext* context);
~SceneProvider() override = default;

// |fuchsia::ui::test::scene::Controller|
Expand Down Expand Up @@ -72,6 +72,8 @@ class SceneProvider : public fuchsia::ui::test::scene::Controller,
std::optional<FakeViewController> fake_view_controller_;
fuchsia::element::AnnotationControllerPtr annotation_controller_;
sys::ComponentContext* context_ = nullptr;
bool use_flatland_ = false;
bool use_scene_manager_ = false;
};

} // namespace ui_testing
Expand Down

0 comments on commit 8cd0c1e

Please sign in to comment.