Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1005)

Side by Side Diff: components/html_viewer/run_all_unittests.cc

Issue 1485573002: Remove SimpleBroker and instead use the production broker implementation in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ipc/mojo/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 5 #include <vector>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/test/launcher/unit_test_launcher.h" 10 #include "base/test/launcher/unit_test_launcher.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace { 24 namespace {
25 25
26 std::vector<gfx::Display> GetTestDisplays() { 26 std::vector<gfx::Display> GetTestDisplays() {
27 std::vector<gfx::Display> displays(1); 27 std::vector<gfx::Display> displays(1);
28 displays[0].set_id(2000); 28 displays[0].set_id(2000);
29 displays[0].SetScaleAndBounds(1., gfx::Rect(0, 0, 800, 600)); 29 displays[0].SetScaleAndBounds(1., gfx::Rect(0, 0, 800, 600));
30 return displays; 30 return displays;
31 } 31 }
32 32
33 class NoAtExitBaseTestSuite : public base::TestSuite {
34 public:
35 NoAtExitBaseTestSuite(int argc, char** argv)
36 : base::TestSuite(argc, argv, false), ui_init_(GetTestDisplays()) {
37 #if defined(OS_ANDROID)
38 base::MemoryMappedFile::Region resource_file_region;
39 int fd = base::android::OpenApkAsset("assets/html_viewer.pak",
40 &resource_file_region);
41 CHECK_NE(fd, -1);
42 ui::ResourceBundle::InitSharedInstanceWithPakPath(base::FilePath());
43 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
44 base::File(fd), resource_file_region, ui::SCALE_FACTOR_100P);
45 #else
46 base::FilePath pak_path;
47 CHECK(PathService::Get(base::DIR_MODULE, &pak_path));
48 pak_path = pak_path.AppendASCII("html_viewer.pak");
49 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_path);
50 #endif
51 }
52
53 private:
54 ui::mojo::UIInit ui_init_;
55
56 DISALLOW_COPY_AND_ASSIGN(NoAtExitBaseTestSuite);
57 };
58
59 int RunTestSuite(int argc, char** argv) {
60 return NoAtExitBaseTestSuite(argc, argv).Run();
61 }
62
63 } // namespace 33 } // namespace
64 34
65 int main(int argc, char** argv) { 35 int main(int argc, char** argv) {
36 base::TestSuite test_suite(argc, argv);
66 #if defined(OS_ANDROID) 37 #if defined(OS_ANDROID)
67 JNIEnv* env = base::android::AttachCurrentThread(); 38 JNIEnv* env = base::android::AttachCurrentThread();
68 base::RegisterContentUriTestUtils(env); 39 base::RegisterContentUriTestUtils(env);
40 base::MemoryMappedFile::Region resource_file_region;
41 int fd = base::android::OpenApkAsset("assets/html_viewer.pak",
42 &resource_file_region);
43 CHECK_NE(fd, -1);
44 ui::ResourceBundle::InitSharedInstanceWithPakPath(base::FilePath());
45 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
46 base::File(fd), resource_file_region, ui::SCALE_FACTOR_100P);
69 #else 47 #else
70 base::AtExitManager at_exit; 48 base::FilePath pak_path;
49 CHECK(PathService::Get(base::DIR_MODULE, &pak_path));
50 pak_path = pak_path.AppendASCII("html_viewer.pak");
51 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_path);
71 #endif 52 #endif
53 ui::mojo::UIInit ui_init(GetTestDisplays());
72 mojo::embedder::Init(); 54 mojo::embedder::Init();
73 55
74 return base::LaunchUnitTests(argc, 56 return base::LaunchUnitTests(
75 argv, 57 argc, argv,
76 base::Bind(&RunTestSuite, argc, argv)); 58 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
77 } 59 }
OLDNEW
« no previous file with comments | « no previous file | ipc/mojo/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698