| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "components/mus/common/switches.h" |
| 9 #include "services/shell/background/background_shell.h" | 10 #include "services/shell/background/background_shell.h" |
| 10 #include "services/shell/background/tests/test_catalog_store.h" | 11 #include "services/shell/background/tests/test_catalog_store.h" |
| 11 #include "services/shell/public/cpp/connector.h" | 12 #include "services/shell/public/cpp/connector.h" |
| 12 #include "services/shell/public/cpp/shell_client.h" | 13 #include "services/shell/public/cpp/shell_client.h" |
| 13 #include "services/shell/public/cpp/shell_connection.h" | 14 #include "services/shell/public/cpp/shell_connection.h" |
| 14 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 15 #include "ui/views/mus/window_manager_connection.h" | 16 #include "ui/views/mus/window_manager_connection.h" |
| 16 #include "ui/views/test/platform_test_helper.h" | 17 #include "ui/views/test/platform_test_helper.h" |
| 17 #include "ui/views/views_delegate.h" | 18 #include "ui/views/views_delegate.h" |
| 18 | 19 |
| 19 using shell::BackgroundShell; | 20 using shell::BackgroundShell; |
| 20 | 21 |
| 21 namespace views { | 22 namespace views { |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 25 void EnsureCommandLineSwitch(const std::string& name) { |
| 26 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 27 if (!cmd_line->HasSwitch(name)) |
| 28 cmd_line->AppendSwitch(name); |
| 29 } |
| 30 |
| 24 class DefaultShellClient : public shell::ShellClient { | 31 class DefaultShellClient : public shell::ShellClient { |
| 25 public: | 32 public: |
| 26 DefaultShellClient() {} | 33 DefaultShellClient() {} |
| 27 ~DefaultShellClient() override {} | 34 ~DefaultShellClient() override {} |
| 28 | 35 |
| 29 private: | 36 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); | 37 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); |
| 31 }; | 38 }; |
| 32 | 39 |
| 33 class PlatformTestHelperMus : public PlatformTestHelper { | 40 class PlatformTestHelperMus : public PlatformTestHelper { |
| 34 public: | 41 public: |
| 35 PlatformTestHelperMus() { | 42 PlatformTestHelperMus() { |
| 43 // Let other mojo apps know that we're running in tests. Do this with a |
| 44 // command line flag to avoid making blocking calls to other processes for |
| 45 // setup for tests (e.g. to unlock the screen in the window manager). |
| 46 EnsureCommandLineSwitch(mus::switches::kUseTestConfig); |
| 47 |
| 36 background_shell_.reset(new BackgroundShell); | 48 background_shell_.reset(new BackgroundShell); |
| 37 background_shell_->Init(nullptr); | 49 background_shell_->Init(nullptr); |
| 38 shell_client_.reset(new DefaultShellClient); | 50 shell_client_.reset(new DefaultShellClient); |
| 39 shell_connection_.reset(new shell::ShellConnection( | 51 shell_connection_.reset(new shell::ShellConnection( |
| 40 shell_client_.get(), | 52 shell_client_.get(), |
| 41 background_shell_->CreateShellClientRequest(GetTestName()))); | 53 background_shell_->CreateShellClientRequest(GetTestName()))); |
| 42 | 54 |
| 43 // TODO(rockot): Remove this RunLoop. http://crbug.com/594852. | 55 // TODO(rockot): Remove this RunLoop. http://crbug.com/594852. |
| 44 base::RunLoop wait_loop; | 56 base::RunLoop wait_loop; |
| 45 shell_connection_->set_initialize_handler(wait_loop.QuitClosure()); | 57 shell_connection_->set_initialize_handler(wait_loop.QuitClosure()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | 113 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { |
| 102 return base::WrapUnique(new PlatformTestHelperMus); | 114 return base::WrapUnique(new PlatformTestHelperMus); |
| 103 } | 115 } |
| 104 | 116 |
| 105 // static | 117 // static |
| 106 bool PlatformTestHelper::IsMus() { | 118 bool PlatformTestHelper::IsMus() { |
| 107 return true; | 119 return true; |
| 108 } | 120 } |
| 109 | 121 |
| 110 } // namespace views | 122 } // namespace views |
| OLD | NEW |