1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
media / capture / run_all_unittests.cc [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdio.h>
#include <memory>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_pump_type.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "base/threading/thread.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/embedder/scoped_ipc_support.h"
#include "testing/gtest/include/gtest/gtest.h"
class MojoEnabledTestEnvironment final : public testing::Environment {
public:
MojoEnabledTestEnvironment() : mojo_ipc_thread_("MojoIpcThread") {}
~MojoEnabledTestEnvironment() final = default;
void SetUp() final {
mojo::core::Init();
mojo_ipc_thread_.StartWithOptions(
base::Thread::Options(base::MessagePumpType::IO, 0));
mojo_ipc_support_ = std::make_unique<mojo::core::ScopedIPCSupport>(
mojo_ipc_thread_.task_runner(),
mojo::core::ScopedIPCSupport::ShutdownPolicy::FAST);
VLOG(1) << "Mojo initialized";
}
void TearDown() final {
mojo_ipc_support_.reset();
VLOG(1) << "Mojo IPC tear down";
}
private:
base::Thread mojo_ipc_thread_;
std::unique_ptr<mojo::core::ScopedIPCSupport> mojo_ipc_support_;
};
int main(int argc, char* argv[]) {
base::TestSuite test_suite(argc, argv);
testing::AddGlobalTestEnvironment(new MojoEnabledTestEnvironment());
return base::LaunchUnitTests(
argc, argv,
base::BindOnce(&base::TestSuite::Run, base::Unretained(&test_suite)));
}