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