| 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/public/cpp/application_impl.h" | |
| 10 #include "mojo/shell/public/cpp/shell_client.h" | 9 #include "mojo/shell/public/cpp/shell_client.h" |
| 10 #include "mojo/shell/public/cpp/shell_connection.h" |
| 11 #include "ui/views/mus/window_manager_connection.h" | 11 #include "ui/views/mus/window_manager_connection.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class DefaultShellClient : public mojo::ShellClient { | 17 class DefaultShellClient : public mojo::ShellClient { |
| 18 public: | 18 public: |
| 19 DefaultShellClient() {} | 19 DefaultShellClient() {} |
| 20 ~DefaultShellClient() override {} | 20 ~DefaultShellClient() override {} |
| 21 | 21 |
| 22 private: | 22 private: |
| 23 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); | 23 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 class PlatformTestHelperMus : public PlatformTestHelper { | 26 class PlatformTestHelperMus : public PlatformTestHelper { |
| 27 public: | 27 public: |
| 28 PlatformTestHelperMus() { | 28 PlatformTestHelperMus() { |
| 29 // Force the new edk. | 29 // Force the new edk. |
| 30 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-new-edk"); | 30 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-new-edk"); |
| 31 | 31 |
| 32 background_shell_.reset(new mojo::shell::BackgroundShell); | 32 background_shell_.reset(new mojo::shell::BackgroundShell); |
| 33 background_shell_->Init(); | 33 background_shell_->Init(); |
| 34 shell_client_.reset(new DefaultShellClient); | 34 shell_client_.reset(new DefaultShellClient); |
| 35 app_.reset(new mojo::ApplicationImpl( | 35 shell_connection_.reset(new mojo::ShellConnection( |
| 36 shell_client_.get(), | 36 shell_client_.get(), |
| 37 background_shell_->CreateApplication(GURL("mojo://test-app")))); | 37 background_shell_->CreateShellClientRequest(GURL("mojo://test-app")))); |
| 38 app_->WaitForInitialize(); | 38 shell_connection_->WaitForInitialize(); |
| 39 // ui/views/mus requires a WindowManager running, for now use the desktop | 39 // ui/views/mus requires a WindowManager running, for now use the desktop |
| 40 // one. | 40 // one. |
| 41 app_->Connect("mojo:desktop_wm"); | 41 shell_connection_->Connect("mojo:desktop_wm"); |
| 42 WindowManagerConnection::Create(app_.get()); | 42 WindowManagerConnection::Create(shell_connection_.get()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 ~PlatformTestHelperMus() override { | 45 ~PlatformTestHelperMus() override { |
| 46 WindowManagerConnection::Reset(); | 46 WindowManagerConnection::Reset(); |
| 47 // |app_| has a reference to us, destroy it while we are still valid. | 47 // |app_| has a reference to us, destroy it while we are still valid. |
| 48 app_.reset(); | 48 shell_connection_.reset(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 scoped_ptr<mojo::shell::BackgroundShell> background_shell_; | 52 scoped_ptr<mojo::shell::BackgroundShell> background_shell_; |
| 53 scoped_ptr<mojo::ApplicationImpl> app_; | 53 scoped_ptr<mojo::ShellConnection> shell_connection_; |
| 54 scoped_ptr<DefaultShellClient> shell_client_; | 54 scoped_ptr<DefaultShellClient> shell_client_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); | 56 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 // static | 61 // static |
| 62 scoped_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | 62 scoped_ptr<PlatformTestHelper> PlatformTestHelper::Create() { |
| 63 return make_scoped_ptr(new PlatformTestHelperMus); | 63 return make_scoped_ptr(new PlatformTestHelperMus); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace views | 66 } // namespace views |
| OLD | NEW |