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