| 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_aura_mus_test_suite.h" | 5 #include "ui/views/mus/views_aura_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/views/mus/desktop_window_tree_host_mus.h" |
| 22 #include "ui/views/mus/mus_client.h" | 23 #include "ui/views/mus/mus_client.h" |
| 23 #include "ui/views/mus/test_utils.h" | 24 #include "ui/views/mus/test_utils.h" |
| 24 #include "ui/views/test/platform_test_helper.h" | 25 #include "ui/views/test/platform_test_helper.h" |
| 25 #include "ui/views/test/views_test_helper_aura.h" | 26 #include "ui/views/test/views_test_helper_aura.h" |
| 26 #include "ui/views/views_delegate.h" | 27 #include "ui/views/views_delegate.h" |
| 28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 27 | 29 |
| 28 namespace views { | 30 namespace views { |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 void EnsureCommandLineSwitch(const std::string& name) { | 33 void EnsureCommandLineSwitch(const std::string& name) { |
| 32 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 34 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 33 if (!cmd_line->HasSwitch(name)) | 35 if (!cmd_line->HasSwitch(name)) |
| 34 cmd_line->AppendSwitch(name); | 36 cmd_line->AppendSwitch(name); |
| 35 } | 37 } |
| 36 | 38 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 // since a new MessageLoop is created for each test. | 59 // since a new MessageLoop is created for each test. |
| 58 mus_client_ = test::MusClientTestApi::Create(connector, identity); | 60 mus_client_ = test::MusClientTestApi::Create(connector, identity); |
| 59 } | 61 } |
| 60 ~PlatformTestHelperMus() override {} | 62 ~PlatformTestHelperMus() override {} |
| 61 | 63 |
| 62 // PlatformTestHelper: | 64 // PlatformTestHelper: |
| 63 void OnTestHelperCreated(ViewsTestHelper* helper) override { | 65 void OnTestHelperCreated(ViewsTestHelper* helper) override { |
| 64 static_cast<ViewsTestHelperAura*>(helper)->EnableMusWithWindowTreeClient( | 66 static_cast<ViewsTestHelperAura*>(helper)->EnableMusWithWindowTreeClient( |
| 65 mus_client_->window_tree_client()); | 67 mus_client_->window_tree_client()); |
| 66 } | 68 } |
| 69 void SimulateNativeDestroy(Widget* widget) override { |
| 70 // TODO: this should call through to a WindowTreeClientDelegate |
| 71 // function that destroys the WindowTreeHost. http://crbug.com/663868. |
| 72 widget->CloseNow(); |
| 73 } |
| 67 | 74 |
| 68 private: | 75 private: |
| 69 std::unique_ptr<MusClient> mus_client_; | 76 std::unique_ptr<MusClient> mus_client_; |
| 70 | 77 |
| 71 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); | 78 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); |
| 72 }; | 79 }; |
| 73 | 80 |
| 74 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( | 81 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( |
| 75 const service_manager::Identity& identity, | 82 const service_manager::Identity& identity, |
| 76 const base::Callback<service_manager::Connector*(void)>& callback) { | 83 const base::Callback<service_manager::Connector*(void)>& callback) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 service_manager_connector_ = connector->Clone(); | 152 service_manager_connector_ = connector->Clone(); |
| 146 service_manager_identity_ = context_->identity(); | 153 service_manager_identity_ = context_->identity(); |
| 147 wait->Signal(); | 154 wait->Signal(); |
| 148 } | 155 } |
| 149 | 156 |
| 150 void TearDownConnections(base::WaitableEvent* wait) { | 157 void TearDownConnections(base::WaitableEvent* wait) { |
| 151 context_.reset(); | 158 context_.reset(); |
| 152 wait->Signal(); | 159 wait->Signal(); |
| 153 } | 160 } |
| 154 | 161 |
| 155 // Returns the name of the test executable, e.g. "exe:views_mus_unittests". | 162 // Returns the name of the test executable, e.g. |
| 163 // "exe:views_aura_mus_unittests". |
| 156 std::string GetTestName() { | 164 std::string GetTestName() { |
| 157 base::FilePath executable = base::CommandLine::ForCurrentProcess() | 165 base::FilePath executable = base::CommandLine::ForCurrentProcess() |
| 158 ->GetProgram() | 166 ->GetProgram() |
| 159 .BaseName() | 167 .BaseName() |
| 160 .RemoveExtension(); | 168 .RemoveExtension(); |
| 161 return std::string("exe:") + executable.MaybeAsASCII(); | 169 return std::string("exe:") + executable.MaybeAsASCII(); |
| 162 } | 170 } |
| 163 | 171 |
| 164 base::Thread thread_; | 172 base::Thread thread_; |
| 165 std::unique_ptr<service_manager::BackgroundServiceManager> | 173 std::unique_ptr<service_manager::BackgroundServiceManager> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 186 ViewsTestSuite::Initialize(); | 194 ViewsTestSuite::Initialize(); |
| 187 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); | 195 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); |
| 188 } | 196 } |
| 189 | 197 |
| 190 void ViewsAuraMusTestSuite::Shutdown() { | 198 void ViewsAuraMusTestSuite::Shutdown() { |
| 191 service_manager_connections_.reset(); | 199 service_manager_connections_.reset(); |
| 192 ViewsTestSuite::Shutdown(); | 200 ViewsTestSuite::Shutdown(); |
| 193 } | 201 } |
| 194 | 202 |
| 195 } // namespace views | 203 } // namespace views |
| OLD | NEW |