| 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/mus/views_mus_test_suite.h" | 5 #include "ui/views/mus/views_mus_test_suite.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/json/json_reader.h" |
| 12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
| 16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 17 #include "mojo/edk/embedder/embedder.h" | 18 #include "mojo/edk/embedder/embedder.h" |
| 18 #include "mojo/edk/embedder/scoped_ipc_support.h" | 19 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 19 #include "services/catalog/catalog.h" | 20 #include "services/catalog/catalog.h" |
| 20 #include "services/service_manager/background/background_service_manager.h" | 21 #include "services/service_manager/background/background_service_manager.h" |
| 21 #include "services/service_manager/public/cpp/connector.h" | 22 #include "services/service_manager/public/cpp/connector.h" |
| 22 #include "services/service_manager/public/cpp/service.h" | 23 #include "services/service_manager/public/cpp/service.h" |
| 23 #include "services/service_manager/public/cpp/service_context.h" | 24 #include "services/service_manager/public/cpp/service_context.h" |
| 24 #include "services/ui/common/switches.h" | 25 #include "services/ui/common/switches.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "ui/aura/mus/window_tree_host_mus.h" | 27 #include "ui/aura/mus/window_tree_host_mus.h" |
| 27 #include "ui/aura/test/env_test_helper.h" | 28 #include "ui/aura/test/env_test_helper.h" |
| 28 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
| 29 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
| 30 #include "ui/views/mus/desktop_window_tree_host_mus.h" | 31 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
| 31 #include "ui/views/mus/mus_client.h" | 32 #include "ui/views/mus/mus_client.h" |
| 32 #include "ui/views/mus/test_utils.h" | 33 #include "ui/views/mus/test_utils.h" |
| 33 #include "ui/views/test/platform_test_helper.h" | 34 #include "ui/views/test/platform_test_helper.h" |
| 34 #include "ui/views/test/views_test_helper_aura.h" | 35 #include "ui/views/test/views_test_helper_aura.h" |
| 35 #include "ui/views/views_delegate.h" | 36 #include "ui/views/views_delegate.h" |
| 36 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 37 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 37 | 38 |
| 39 // Generated within the ":views_mus_tests_catalog_source" target. |
| 40 extern const char kViewsMusTestCatalog[]; |
| 41 |
| 38 namespace views { | 42 namespace views { |
| 39 namespace { | 43 namespace { |
| 40 | 44 |
| 41 const base::FilePath::CharType kCatalogFilename[] = | |
| 42 FILE_PATH_LITERAL("views_mus_tests_catalog.json"); | |
| 43 | |
| 44 void EnsureCommandLineSwitch(const std::string& name) { | 45 void EnsureCommandLineSwitch(const std::string& name) { |
| 45 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 46 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 46 if (!cmd_line->HasSwitch(name)) | 47 if (!cmd_line->HasSwitch(name)) |
| 47 cmd_line->AppendSwitch(name); | 48 cmd_line->AppendSwitch(name); |
| 48 } | 49 } |
| 49 | 50 |
| 50 class DefaultService : public service_manager::Service { | 51 class DefaultService : public service_manager::Service { |
| 51 public: | 52 public: |
| 52 DefaultService() {} | 53 DefaultService() {} |
| 53 ~DefaultService() override {} | 54 ~DefaultService() override {} |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return base::MakeUnique<PlatformTestHelperMus>(callback.Run(), identity); | 101 return base::MakeUnique<PlatformTestHelperMus>(callback.Run(), identity); |
| 101 } | 102 } |
| 102 | 103 |
| 103 } // namespace | 104 } // namespace |
| 104 | 105 |
| 105 class ServiceManagerConnection { | 106 class ServiceManagerConnection { |
| 106 public: | 107 public: |
| 107 ServiceManagerConnection() | 108 ServiceManagerConnection() |
| 108 : thread_("Persistent service_manager connections"), | 109 : thread_("Persistent service_manager connections"), |
| 109 ipc_thread_("IPC thread") { | 110 ipc_thread_("IPC thread") { |
| 110 catalog::Catalog::LoadDefaultCatalogManifest( | 111 catalog::Catalog::SetDefaultCatalogManifest( |
| 111 base::FilePath(kCatalogFilename)); | 112 base::JSONReader::Read(kViewsMusTestCatalog)); |
| 112 mojo::edk::Init(); | 113 mojo::edk::Init(); |
| 113 ipc_thread_.StartWithOptions( | 114 ipc_thread_.StartWithOptions( |
| 114 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 115 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 115 ipc_support_ = base::MakeUnique<mojo::edk::ScopedIPCSupport>( | 116 ipc_support_ = base::MakeUnique<mojo::edk::ScopedIPCSupport>( |
| 116 ipc_thread_.task_runner(), | 117 ipc_thread_.task_runner(), |
| 117 mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN); | 118 mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN); |
| 118 | 119 |
| 119 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 120 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 120 base::WaitableEvent::InitialState::NOT_SIGNALED); | 121 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 121 base::Thread::Options options; | 122 base::Thread::Options options; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ViewsTestSuite::Initialize(); | 229 ViewsTestSuite::Initialize(); |
| 229 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); | 230 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); |
| 230 } | 231 } |
| 231 | 232 |
| 232 void ViewsMusTestSuite::Shutdown() { | 233 void ViewsMusTestSuite::Shutdown() { |
| 233 service_manager_connections_.reset(); | 234 service_manager_connections_.reset(); |
| 234 ViewsTestSuite::Shutdown(); | 235 ViewsTestSuite::Shutdown(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 } // namespace views | 238 } // namespace views |
| OLD | NEW |