Cleanup: Pass std::string as const reference from pdf/
[chromium-blink-merge.git] / components / html_viewer / run_all_unittests.cc
blob5ce14d6fef5ea3ed6f424dc44caedba5d2ef3d20
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"
6 #include "base/bind.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"
19 #endif
21 namespace {
23 class NoAtExitBaseTestSuite : public base::TestSuite {
24 public:
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);
32 CHECK_NE(fd, -1);
33 ui::ResourceBundle::InitSharedInstanceWithPakPath(base::FilePath());
34 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
35 base::File(fd), resource_file_region, ui::SCALE_FACTOR_100P);
36 #else
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);
41 #endif
44 private:
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();
54 } // namespace
56 int main(int argc, char** argv) {
57 #if defined(OS_ANDROID)
58 JNIEnv* env = base::android::AttachCurrentThread();
59 base::RegisterContentUriTestUtils(env);
60 #else
61 base::AtExitManager at_exit;
62 #endif
63 mojo::embedder::test::InitWithSimplePlatformSupport();
65 return base::LaunchUnitTests(argc,
66 argv,
67 base::Bind(&RunTestSuite, argc, argv));