| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "mojo/shell/background/background_shell.h" | 8 #include "mojo/shell/background/background_shell.h" |
| 9 #include "mojo/shell/background/tests/test_application_catalog_store.h" | 9 #include "mojo/shell/background/tests/test_catalog_store.h" |
| 10 #include "mojo/shell/public/cpp/connector.h" | 10 #include "mojo/shell/public/cpp/connector.h" |
| 11 #include "mojo/shell/public/cpp/shell_client.h" | 11 #include "mojo/shell/public/cpp/shell_client.h" |
| 12 #include "mojo/shell/public/cpp/shell_connection.h" | 12 #include "mojo/shell/public/cpp/shell_connection.h" |
| 13 #include "ui/views/mus/window_manager_connection.h" | 13 #include "ui/views/mus/window_manager_connection.h" |
| 14 | 14 |
| 15 using mojo::shell::BackgroundShell; | 15 using mojo::shell::BackgroundShell; |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const char kTestName[] = "mojo:test-app"; | 20 const char kTestName[] = "mojo:test-app"; |
| 21 | 21 |
| 22 class DefaultShellClient : public mojo::ShellClient { | 22 class DefaultShellClient : public mojo::ShellClient { |
| 23 public: | 23 public: |
| 24 DefaultShellClient() {} | 24 DefaultShellClient() {} |
| 25 ~DefaultShellClient() override {} | 25 ~DefaultShellClient() override {} |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); | 28 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 scoped_ptr<mojo::shell::TestApplicationCatalogStore> | 31 scoped_ptr<mojo::shell::TestCatalogStore> BuildTestCatalogStore() { |
| 32 BuildTestApplicationCatalogStore() { | |
| 33 scoped_ptr<base::ListValue> apps(new base::ListValue); | 32 scoped_ptr<base::ListValue> apps(new base::ListValue); |
| 34 apps->Append( | 33 apps->Append( |
| 35 mojo::shell::BuildPermissiveSerializedAppInfo(kTestName, "test")); | 34 mojo::shell::BuildPermissiveSerializedAppInfo(kTestName, "test")); |
| 36 return make_scoped_ptr( | 35 return make_scoped_ptr(new mojo::shell::TestCatalogStore(std::move(apps))); |
| 37 new mojo::shell::TestApplicationCatalogStore(std::move(apps))); | |
| 38 } | 36 } |
| 39 | 37 |
| 40 class PlatformTestHelperMus : public PlatformTestHelper { | 38 class PlatformTestHelperMus : public PlatformTestHelper { |
| 41 public: | 39 public: |
| 42 PlatformTestHelperMus() { | 40 PlatformTestHelperMus() { |
| 43 background_shell_.reset(new BackgroundShell); | 41 background_shell_.reset(new BackgroundShell); |
| 44 scoped_ptr<BackgroundShell::InitParams> init_params( | 42 scoped_ptr<BackgroundShell::InitParams> init_params( |
| 45 new BackgroundShell::InitParams); | 43 new BackgroundShell::InitParams); |
| 46 init_params->app_catalog = BuildTestApplicationCatalogStore(); | 44 init_params->catalog_store = BuildTestCatalogStore(); |
| 47 background_shell_->Init(std::move(init_params)); | 45 background_shell_->Init(std::move(init_params)); |
| 48 shell_client_.reset(new DefaultShellClient); | 46 shell_client_.reset(new DefaultShellClient); |
| 49 shell_connection_.reset(new mojo::ShellConnection( | 47 shell_connection_.reset(new mojo::ShellConnection( |
| 50 shell_client_.get(), | 48 shell_client_.get(), |
| 51 background_shell_->CreateShellClientRequest(kTestName))); | 49 background_shell_->CreateShellClientRequest(kTestName))); |
| 52 shell_connection_->WaitForInitialize(); | 50 shell_connection_->WaitForInitialize(); |
| 53 // ui/views/mus requires a WindowManager running, for now use the desktop | 51 // ui/views/mus requires a WindowManager running, for now use the desktop |
| 54 // one. | 52 // one. |
| 55 mojo::Connector* connector = shell_connection_->connector(); | 53 mojo::Connector* connector = shell_connection_->connector(); |
| 56 connector->Connect("mojo:desktop_wm"); | 54 connector->Connect("mojo:desktop_wm"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 } // namespace | 72 } // namespace |
| 75 | 73 |
| 76 // static | 74 // static |
| 77 scoped_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | 75 scoped_ptr<PlatformTestHelper> PlatformTestHelper::Create() { |
| 78 return make_scoped_ptr(new PlatformTestHelperMus); | 76 return make_scoped_ptr(new PlatformTestHelperMus); |
| 79 } | 77 } |
| 80 | 78 |
| 81 } // namespace views | 79 } // namespace views |
| OLD | NEW |