OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/test/platform_test_helper.h" | 5 #include "ui/views/test/platform_test_helper.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "mojo/shell/public/cpp/application_impl.h" | |
9 #include "mojo/shell/public/cpp/application_test_base.h" | 8 #include "mojo/shell/public/cpp/application_test_base.h" |
| 9 #include "mojo/shell/public/cpp/shell.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
12 #include "ui/base/ui_base_paths.h" | 12 #include "ui/base/ui_base_paths.h" |
13 #include "ui/gl/test/gl_surface_test_support.h" | 13 #include "ui/gl/test/gl_surface_test_support.h" |
14 #include "ui/views/mus/window_manager_connection.h" | 14 #include "ui/views/mus/window_manager_connection.h" |
15 | 15 |
16 namespace views { | 16 namespace views { |
17 namespace { | 17 namespace { |
18 | 18 |
19 class PlatformTestHelperMus : public PlatformTestHelper { | 19 class PlatformTestHelperMus : public PlatformTestHelper { |
20 public: | 20 public: |
21 PlatformTestHelperMus() { | 21 PlatformTestHelperMus() { |
22 gfx::GLSurfaceTestSupport::InitializeOneOff(); | 22 gfx::GLSurfaceTestSupport::InitializeOneOff(); |
23 | 23 |
24 // TODO(sky): We really shouldn't need to configure ResourceBundle. | 24 // TODO(sky): We really shouldn't need to configure ResourceBundle. |
25 ui::RegisterPathProvider(); | 25 ui::RegisterPathProvider(); |
26 base::FilePath ui_test_pak_path; | 26 base::FilePath ui_test_pak_path; |
27 CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); | 27 CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); |
28 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); | 28 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); |
29 aura::Env::CreateInstance(true); | 29 aura::Env::CreateInstance(true); |
30 | 30 |
31 mojo_test_helper_.reset(new mojo::test::TestHelper(nullptr)); | 31 mojo_test_helper_.reset(new mojo::test::TestHelper(nullptr)); |
32 // ui/views/mus requires a WindowManager running, for now use the desktop | 32 // ui/views/mus requires a WindowManager running, for now use the desktop |
33 // one. | 33 // one. |
34 mojo_test_helper_->application_impl()->ConnectToApplication( | 34 mojo_test_helper_->shell()->ConnectToApplication("mojo:desktop_wm"); |
35 "mojo:desktop_wm"); | 35 WindowManagerConnection::Create(mojo_test_helper_->shell()); |
36 WindowManagerConnection::Create(mojo_test_helper_->application_impl()); | |
37 } | 36 } |
38 | 37 |
39 ~PlatformTestHelperMus() override { | 38 ~PlatformTestHelperMus() override { |
40 mojo_test_helper_.reset(nullptr); | 39 mojo_test_helper_.reset(nullptr); |
41 aura::Env::DeleteInstance(); | 40 aura::Env::DeleteInstance(); |
42 ui::ResourceBundle::CleanupSharedInstance(); | 41 ui::ResourceBundle::CleanupSharedInstance(); |
43 } | 42 } |
44 | 43 |
45 private: | 44 private: |
46 scoped_ptr<mojo::test::TestHelper> mojo_test_helper_; | 45 scoped_ptr<mojo::test::TestHelper> mojo_test_helper_; |
47 | 46 |
48 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); | 47 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); |
49 }; | 48 }; |
50 | 49 |
51 } // namespace | 50 } // namespace |
52 | 51 |
53 // static | 52 // static |
54 scoped_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | 53 scoped_ptr<PlatformTestHelper> PlatformTestHelper::Create() { |
55 return make_scoped_ptr(new PlatformTestHelperMus); | 54 return make_scoped_ptr(new PlatformTestHelperMus); |
56 } | 55 } |
57 | 56 |
58 } // namespace views | 57 } // namespace views |
OLD | NEW |