forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_all_unittests.cc
91 lines (73 loc) · 2.77 KB
/
run_all_unittests.cc
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2018 The Chromium 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 "base/bind.h"
#include "base/files/file.h"
#include "base/i18n/icu_util.h"
#include "base/message_loop/message_pump_type.h"
#include "base/path_service.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "mojo/core/embedder/configuration.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/embedder/scoped_ipc_support.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/base/ui_base_paths.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/jni_android.h"
#endif
namespace {
class ServiceTestSuite : public base::TestSuite {
public:
ServiceTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}
ServiceTestSuite(const ServiceTestSuite&) = delete;
ServiceTestSuite& operator=(const ServiceTestSuite&) = delete;
~ServiceTestSuite() override = default;
protected:
void Initialize() override {
base::TestSuite::Initialize();
#if !BUILDFLAG(IS_IOS)
ui::RegisterPathProvider();
base::FilePath ui_test_pak_path;
ASSERT_TRUE(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
base::FilePath path;
#if BUILDFLAG(IS_ANDROID)
ASSERT_TRUE(base::PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &path));
#else
ASSERT_TRUE(base::PathService::Get(base::DIR_ASSETS, &path));
#endif
base::FilePath bluetooth_test_strings =
path.Append(FILE_PATH_LITERAL("bluetooth_test_strings.pak"));
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
bluetooth_test_strings, ui::kScaleFactorNone);
#endif // !BUILDFLAG(IS_IOS)
// base::TestSuite and ViewsInit both try to load icu. That's ok for tests.
base::i18n::AllowMultipleInitializeCallsForTesting();
}
void Shutdown() override {
#if !BUILDFLAG(IS_IOS)
ui::ResourceBundle::CleanupSharedInstance();
#endif
base::TestSuite::Shutdown();
}
};
} // namespace
int main(int argc, char** argv) {
ServiceTestSuite test_suite(argc, argv);
mojo::core::Configuration mojo_config;
mojo_config.is_broker_process = true;
mojo::core::Init(mojo_config);
base::Thread ipc_thread("IPC thread");
ipc_thread.StartWithOptions(
base::Thread::Options(base::MessagePumpType::IO, 0));
mojo::core::ScopedIPCSupport ipc_support(
ipc_thread.task_runner(),
mojo::core::ScopedIPCSupport::ShutdownPolicy::CLEAN);
return base::LaunchUnitTests(
argc, argv,
base::BindOnce(&ServiceTestSuite::Run, base::Unretained(&test_suite)));
}