OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include <vector> |
| 6 |
5 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
6 #include "base/bind.h" | 8 #include "base/bind.h" |
7 #include "base/path_service.h" | 9 #include "base/path_service.h" |
8 #include "base/test/launcher/unit_test_launcher.h" | 10 #include "base/test/launcher/unit_test_launcher.h" |
9 #include "base/test/test_suite.h" | 11 #include "base/test/test_suite.h" |
10 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
11 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/display.h" |
12 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
13 #include "ui/mojo/init/ui_init.h" | 16 #include "ui/mojo/init/ui_init.h" |
14 | 17 |
15 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
16 #include "base/android/apk_assets.h" | 19 #include "base/android/apk_assets.h" |
17 #include "base/android/jni_android.h" | 20 #include "base/android/jni_android.h" |
18 #include "base/test/test_file_util.h" | 21 #include "base/test/test_file_util.h" |
19 #endif | 22 #endif |
20 | 23 |
21 namespace { | 24 namespace { |
22 | 25 |
| 26 std::vector<gfx::Display> GetTestDisplays() { |
| 27 std::vector<gfx::Display> displays(1); |
| 28 displays[0].set_id(2000); |
| 29 displays[0].SetScaleAndBounds(1., gfx::Rect(0, 0, 800, 600)); |
| 30 return displays; |
| 31 } |
| 32 |
23 class NoAtExitBaseTestSuite : public base::TestSuite { | 33 class NoAtExitBaseTestSuite : public base::TestSuite { |
24 public: | 34 public: |
25 NoAtExitBaseTestSuite(int argc, char** argv) | 35 NoAtExitBaseTestSuite(int argc, char** argv) |
26 : base::TestSuite(argc, argv, false), | 36 : base::TestSuite(argc, argv, false), ui_init_(GetTestDisplays()) { |
27 ui_init_(gfx::Size(800, 600), 1.f) { | |
28 #if defined(OS_ANDROID) | 37 #if defined(OS_ANDROID) |
29 base::MemoryMappedFile::Region resource_file_region; | 38 base::MemoryMappedFile::Region resource_file_region; |
30 int fd = base::android::OpenApkAsset("assets/html_viewer.pak", | 39 int fd = base::android::OpenApkAsset("assets/html_viewer.pak", |
31 &resource_file_region); | 40 &resource_file_region); |
32 CHECK_NE(fd, -1); | 41 CHECK_NE(fd, -1); |
33 ui::ResourceBundle::InitSharedInstanceWithPakPath(base::FilePath()); | 42 ui::ResourceBundle::InitSharedInstanceWithPakPath(base::FilePath()); |
34 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( | 43 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
35 base::File(fd), resource_file_region, ui::SCALE_FACTOR_100P); | 44 base::File(fd), resource_file_region, ui::SCALE_FACTOR_100P); |
36 #else | 45 #else |
37 base::FilePath pak_path; | 46 base::FilePath pak_path; |
(...skipping 21 matching lines...) Expand all Loading... |
59 base::RegisterContentUriTestUtils(env); | 68 base::RegisterContentUriTestUtils(env); |
60 #else | 69 #else |
61 base::AtExitManager at_exit; | 70 base::AtExitManager at_exit; |
62 #endif | 71 #endif |
63 mojo::embedder::Init(); | 72 mojo::embedder::Init(); |
64 | 73 |
65 return base::LaunchUnitTests(argc, | 74 return base::LaunchUnitTests(argc, |
66 argv, | 75 argv, |
67 base::Bind(&RunTestSuite, argc, argv)); | 76 base::Bind(&RunTestSuite, argc, argv)); |
68 } | 77 } |
OLD | NEW |