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 "ash/test/ash_interactive_ui_test_base.h" | 5 #include "ash/test/ash_interactive_ui_test_base.h" |
6 | 6 |
| 7 #include "base/lazy_instance.h" |
7 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "mojo/edk/embedder/embedder.h" |
8 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
9 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/base/ui_base_paths.h" | 12 #include "ui/base/ui_base_paths.h" |
11 #include "ui/gl/test/gl_surface_test_support.h" | 13 #include "ui/gl/test/gl_surface_test_support.h" |
12 | 14 |
13 namespace ash { | 15 namespace ash { |
14 namespace test { | 16 namespace test { |
15 | 17 |
| 18 namespace { |
| 19 |
| 20 class MojoInitializer { |
| 21 public: |
| 22 MojoInitializer() { mojo::edk::Init(); } |
| 23 }; |
| 24 |
| 25 base::LazyInstance<MojoInitializer>::Leaky mojo_initializer; |
| 26 |
| 27 // Initialize mojo once per process. |
| 28 void InitializeMojo() { |
| 29 mojo_initializer.Get(); |
| 30 } |
| 31 |
| 32 } // namespace |
| 33 |
16 AshInteractiveUITestBase::AshInteractiveUITestBase() {} | 34 AshInteractiveUITestBase::AshInteractiveUITestBase() {} |
17 | 35 |
18 AshInteractiveUITestBase::~AshInteractiveUITestBase() {} | 36 AshInteractiveUITestBase::~AshInteractiveUITestBase() {} |
19 | 37 |
20 void AshInteractiveUITestBase::SetUp() { | 38 void AshInteractiveUITestBase::SetUp() { |
| 39 InitializeMojo(); |
| 40 |
21 gl::GLSurfaceTestSupport::InitializeOneOff(); | 41 gl::GLSurfaceTestSupport::InitializeOneOff(); |
22 | 42 |
23 ui::RegisterPathProvider(); | 43 ui::RegisterPathProvider(); |
24 ui::ResourceBundle::InitSharedInstanceWithLocale( | 44 ui::ResourceBundle::InitSharedInstanceWithLocale( |
25 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 45 "en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
26 base::FilePath resources_pack_path; | 46 base::FilePath resources_pack_path; |
27 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 47 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
28 resources_pack_path = | 48 resources_pack_path = |
29 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 49 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
30 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 50 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
31 resources_pack_path, ui::SCALE_FACTOR_NONE); | 51 resources_pack_path, ui::SCALE_FACTOR_NONE); |
32 env_ = aura::Env::CreateInstance(); | 52 env_ = aura::Env::CreateInstance(); |
33 | 53 |
34 test::AshTestBase::SetUp(); | 54 test::AshTestBase::SetUp(); |
35 } | 55 } |
36 | 56 |
37 void AshInteractiveUITestBase::TearDown() { | 57 void AshInteractiveUITestBase::TearDown() { |
38 test::AshTestBase::TearDown(); | 58 test::AshTestBase::TearDown(); |
39 env_.reset(); | 59 env_.reset(); |
40 } | 60 } |
41 | 61 |
42 } // namespace test | 62 } // namespace test |
43 } // namespace ash | 63 } // namespace ash |
OLD | NEW |