OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include <vector> | |
6 | |
7 #include "base/at_exit.h" | |
8 #include "base/bind.h" | |
9 #include "base/path_service.h" | |
10 #include "base/test/launcher/unit_test_launcher.h" | |
11 #include "base/test/test_suite.h" | |
12 #include "build/build_config.h" | |
13 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | |
14 #include "ui/base/resource/resource_bundle.h" | |
15 #include "ui/gfx/display.h" | |
16 #include "ui/gfx/geometry/size.h" | |
17 #include "ui/mojo/init/ui_init.h" | |
18 | |
19 #if defined(OS_ANDROID) | |
20 #include "base/android/apk_assets.h" | |
21 #include "base/android/jni_android.h" | |
22 #include "base/test/test_file_util.h" | |
23 #endif | |
24 | |
25 namespace { | |
26 | |
27 std::vector<gfx::Display> GetTestDisplays() { | |
28 std::vector<gfx::Display> displays(1); | |
29 displays[0].set_id(2000); | |
30 displays[0].SetScaleAndBounds(1., gfx::Rect(0, 0, 800, 600)); | |
31 return displays; | |
32 } | |
33 | |
34 } // namespace | |
35 | |
36 int main(int argc, char** argv) { | |
37 base::TestSuite test_suite(argc, argv); | |
38 #if defined(OS_ANDROID) | |
39 JNIEnv* env = base::android::AttachCurrentThread(); | |
40 base::RegisterContentUriTestUtils(env); | |
41 base::MemoryMappedFile::Region resource_file_region; | |
42 int fd = base::android::OpenApkAsset("assets/html_viewer.pak", | |
43 &resource_file_region); | |
44 CHECK_NE(fd, -1); | |
45 ui::ResourceBundle::InitSharedInstanceWithPakPath(base::FilePath()); | |
46 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( | |
47 base::File(fd), resource_file_region, ui::SCALE_FACTOR_100P); | |
48 #else | |
49 base::FilePath pak_path; | |
50 CHECK(PathService::Get(base::DIR_MODULE, &pak_path)); | |
51 pak_path = pak_path.AppendASCII("html_viewer.pak"); | |
52 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_path); | |
53 #endif | |
54 ui::mojo::UIInit ui_init(GetTestDisplays()); | |
55 mojo::embedder::Init(); | |
56 | |
57 return base::LaunchUnitTests( | |
58 argc, argv, | |
59 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); | |
60 } | |
OLD | NEW |