blob: 943cb554811e4b75d85fe149880ccde2d957f03f [file] [log] [blame]
// Copyright 2017 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 <fuchsia/modular/cpp/fidl.h>
#include <lib/app_driver/cpp/module_driver.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/fsl/vmo/strings.h>
#include "peridot/public/lib/integration_testing/cpp/reporting.h"
#include "peridot/public/lib/integration_testing/cpp/testing.h"
#include "peridot/tests/common/defs.h"
#include "peridot/tests/parent_child/defs.h"
using modular::testing::Get;
using modular::testing::Put;
using modular::testing::Signal;
using modular::testing::TestPoint;
namespace {
// Cf. README.md for what this test does and how.
class TestModule {
public:
TestModule(modular::ModuleHost* module_host,
fidl::InterfaceRequest<
fuchsia::ui::app::ViewProvider> /*view_provider_request*/) {
modular::testing::Init(module_host->startup_context(), __FILE__);
FXL_LOG(INFO) << "Child module 2 initialized";
Signal(std::string("child_module_2_init"));
}
// Called from ModuleDriver.
TestPoint stopped_{"Child module 2 stopped"};
void Terminate(fit::function<void()> done) {
FXL_LOG(INFO) << "Child module 2 exiting.";
stopped_.Pass();
Signal("child_module_2_stop");
modular::testing::Done(std::move(done));
}
private:
FXL_DISALLOW_COPY_AND_ASSIGN(TestModule);
};
} // namespace
int main(int /*argc*/, const char** /*argv*/) {
async::Loop loop(&kAsyncLoopConfigAttachToThread);
auto context = component::StartupContext::CreateFromStartupInfo();
modular::ModuleDriver<TestModule> driver(context.get(),
[&loop] { loop.Quit(); });
loop.Run();
return 0;
}