blob: f1db0f6a84c49293d8467353d26fd46fa3c0756c [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "test_component.h"
#include <lib/fidl/cpp/interface_request.h>
#include <lib/sys/cpp/component_context.h>
#include "suite.h"
TestComponent::TestComponent(TestComponentArgs args, DoneCallback done_callback)
: dispatcher_(args.dispatcher),
binding_(this, std::move(args.request), args.dispatcher),
ns_(std::move(args.ns)),
done_callback_(std::move(done_callback)) {
suite_ = std::make_unique<Suite>(
std::move(args.parent_env_svc), std::move(args.parent_env), std::move(args.test_metadata),
std::move(args.test_component_svc), std::move(args.legacy_url), dispatcher_);
suite_context_ = sys::ComponentContext::Create();
suite_context_->outgoing()->AddPublicService(suite_->GetHandler());
suite_context_->outgoing()->Serve(std::move(args.outgoing_dir), dispatcher_);
}
TestComponent::~TestComponent() = default;
void TestComponent::Stop() { Kill(); }
void TestComponent::Kill() {
binding_.Close(ZX_OK);
// this object would be killed after this call
done_callback_(this);
}