| 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/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/threading/simple_thread.h" | 14 #include "base/threading/simple_thread.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "services/service_manager/background/background_service_manager.h" | 16 #include "services/service_manager/background/background_service_manager.h" |
| 17 #include "services/service_manager/public/cpp/connector.h" | 17 #include "services/service_manager/public/cpp/connector.h" |
| 18 #include "services/service_manager/public/cpp/service.h" | 18 #include "services/service_manager/public/cpp/service.h" |
| 19 #include "services/service_manager/public/cpp/service_context.h" | 19 #include "services/service_manager/public/cpp/service_context.h" |
| 20 #include "services/ui/common/switches.h" | 20 #include "services/ui/common/switches.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/aura/window.h" |
| 22 #include "ui/views/mus/window_manager_connection.h" | 23 #include "ui/views/mus/window_manager_connection.h" |
| 23 #include "ui/views/test/platform_test_helper.h" | 24 #include "ui/views/test/platform_test_helper.h" |
| 24 #include "ui/views/views_delegate.h" | 25 #include "ui/views/views_delegate.h" |
| 25 | 26 |
| 26 namespace views { | 27 namespace views { |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 void EnsureCommandLineSwitch(const std::string& name) { | 30 void EnsureCommandLineSwitch(const std::string& name) { |
| 30 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 31 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 31 if (!cmd_line->HasSwitch(name)) | 32 if (!cmd_line->HasSwitch(name)) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 50 class PlatformTestHelperMus : public PlatformTestHelper { | 51 class PlatformTestHelperMus : public PlatformTestHelper { |
| 51 public: | 52 public: |
| 52 PlatformTestHelperMus(service_manager::Connector* connector, | 53 PlatformTestHelperMus(service_manager::Connector* connector, |
| 53 const service_manager::Identity& identity) { | 54 const service_manager::Identity& identity) { |
| 54 // It is necessary to recreate the WindowManagerConnection for each test, | 55 // It is necessary to recreate the WindowManagerConnection for each test, |
| 55 // since a new MessageLoop is created for each test. | 56 // since a new MessageLoop is created for each test. |
| 56 connection_ = WindowManagerConnection::Create(connector, identity); | 57 connection_ = WindowManagerConnection::Create(connector, identity); |
| 57 } | 58 } |
| 58 ~PlatformTestHelperMus() override {} | 59 ~PlatformTestHelperMus() override {} |
| 59 | 60 |
| 61 // PlatformTestHelper: |
| 62 void SimulateNativeDestroy(Widget* widget) override { |
| 63 delete widget->GetNativeView(); |
| 64 } |
| 65 |
| 60 private: | 66 private: |
| 61 std::unique_ptr<WindowManagerConnection> connection_; | 67 std::unique_ptr<WindowManagerConnection> connection_; |
| 62 | 68 |
| 63 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); | 69 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); |
| 64 }; | 70 }; |
| 65 | 71 |
| 66 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( | 72 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( |
| 67 const service_manager::Identity& identity, | 73 const service_manager::Identity& identity, |
| 68 const base::Callback<service_manager::Connector*(void)>& callback) { | 74 const base::Callback<service_manager::Connector*(void)>& callback) { |
| 69 return base::MakeUnique<PlatformTestHelperMus>(callback.Run(), identity); | 75 return base::MakeUnique<PlatformTestHelperMus>(callback.Run(), identity); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 ViewsTestSuite::Initialize(); | 184 ViewsTestSuite::Initialize(); |
| 179 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); | 185 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); |
| 180 } | 186 } |
| 181 | 187 |
| 182 void ViewsMusTestSuite::Shutdown() { | 188 void ViewsMusTestSuite::Shutdown() { |
| 183 service_manager_connections_.reset(); | 189 service_manager_connections_.reset(); |
| 184 ViewsTestSuite::Shutdown(); | 190 ViewsTestSuite::Shutdown(); |
| 185 } | 191 } |
| 186 | 192 |
| 187 } // namespace views | 193 } // namespace views |
| OLD | NEW |