1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/at_exit.h"
7 #include "base/path_service.h"
8 #include "base/test/launcher/unit_test_launcher.h"
9 #include "base/test/test_suite.h"
10 #include "third_party/mojo/src/mojo/edk/embedder/test_embedder.h"
11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/geometry/size.h"
13 #include "ui/mojo/init/ui_init.h"
15 #if defined(OS_ANDROID)
16 #include "base/android/apk_assets.h"
17 #include "base/android/jni_android.h"
18 #include "base/test/test_file_util.h"
23 class NoAtExitBaseTestSuite
: public base::TestSuite
{
25 NoAtExitBaseTestSuite(int argc
, char** argv
)
26 : base::TestSuite(argc
, argv
, false),
27 ui_init_(gfx::Size(800, 600), 1.f
) {
28 #if defined(OS_ANDROID)
29 base::MemoryMappedFile::Region resource_file_region
;
30 int fd
= base::android::OpenApkAsset("assets/html_viewer.pak",
31 &resource_file_region
);
33 ui::ResourceBundle::InitSharedInstanceWithPakPath(base::FilePath());
34 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
35 base::File(fd
), resource_file_region
, ui::SCALE_FACTOR_100P
);
37 base::FilePath pak_path
;
38 CHECK(PathService::Get(base::DIR_MODULE
, &pak_path
));
39 pak_path
= pak_path
.AppendASCII("html_viewer.pak");
40 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_path
);
45 ui::mojo::UIInit ui_init_
;
47 DISALLOW_COPY_AND_ASSIGN(NoAtExitBaseTestSuite
);
50 int RunTestSuite(int argc
, char** argv
) {
51 return NoAtExitBaseTestSuite(argc
, argv
).Run();
56 int main(int argc
, char** argv
) {
57 #if defined(OS_ANDROID)
58 JNIEnv
* env
= base::android::AttachCurrentThread();
59 base::RegisterContentUriTestUtils(env
);
61 base::AtExitManager at_exit
;
63 mojo::embedder::test::InitWithSimplePlatformSupport();
65 return base::LaunchUnitTests(argc
,
67 base::Bind(&RunTestSuite
, argc
, argv
));