Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: ui/views/mus/views_mus_test_suite.cc

Issue 2374883002: views/mus: Change 'reset(new' to base::MakeUnqiue. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/run_loop.h" 12 #include "base/run_loop.h"
12 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/simple_thread.h" 14 #include "base/threading/simple_thread.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "services/shell/background/background_shell.h" 16 #include "services/shell/background/background_shell.h"
16 #include "services/shell/public/cpp/connector.h" 17 #include "services/shell/public/cpp/connector.h"
17 #include "services/shell/public/cpp/service.h" 18 #include "services/shell/public/cpp/service.h"
18 #include "services/shell/public/cpp/service_context.h" 19 #include "services/shell/public/cpp/service_context.h"
19 #include "services/ui/common/switches.h" 20 #include "services/ui/common/switches.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/views/mus/window_manager_connection.h" 22 #include "ui/views/mus/window_manager_connection.h"
22 #include "ui/views/test/platform_test_helper.h" 23 #include "ui/views/test/platform_test_helper.h"
23 #include "ui/views/views_delegate.h" 24 #include "ui/views/views_delegate.h"
24 25
25 namespace views { 26 namespace views {
26 namespace { 27 namespace {
27 28
28 void EnsureCommandLineSwitch(const std::string& name) { 29 void EnsureCommandLineSwitch(const std::string& name) {
29 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 30 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
30 if (!cmd_line->HasSwitch(name)) 31 if (!cmd_line->HasSwitch(name))
31 cmd_line->AppendSwitch(name); 32 cmd_line->AppendSwitch(name);
32 } 33 }
33 34
34 class DefaultService : public shell::Service { 35 class DefaultService : public shell::Service {
35 public: 36 public:
36 DefaultService() {} 37 DefaultService() {}
37 ~DefaultService() override {} 38 ~DefaultService() override {}
38 39
39 private: 40 private:
40 DISALLOW_COPY_AND_ASSIGN(DefaultService); 41 DISALLOW_COPY_AND_ASSIGN(DefaultService);
41 }; 42 };
42 43
43 class PlatformTestHelperMus : public PlatformTestHelper { 44 class PlatformTestHelperMus : public PlatformTestHelper {
44 public: 45 public:
45 PlatformTestHelperMus(shell::Connector* connector, 46 PlatformTestHelperMus(shell::Connector* connector,
46 const shell::Identity& identity) { 47 const shell::Identity& identity) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 DCHECK(shell_connector_); 108 DCHECK(shell_connector_);
108 return shell_connector_.get(); 109 return shell_connector_.get();
109 } 110 }
110 111
111 void CloneConnector(base::WaitableEvent* wait) { 112 void CloneConnector(base::WaitableEvent* wait) {
112 shell_connector_ = shell_connection_->connector()->Clone(); 113 shell_connector_ = shell_connection_->connector()->Clone();
113 wait->Signal(); 114 wait->Signal();
114 } 115 }
115 116
116 void SetUpConnections(base::WaitableEvent* wait) { 117 void SetUpConnections(base::WaitableEvent* wait) {
117 background_shell_.reset(new shell::BackgroundShell); 118 background_shell_ = base::MakeUnique<shell::BackgroundShell>();
118 background_shell_->Init(nullptr); 119 background_shell_->Init(nullptr);
119 service_.reset(new DefaultService); 120 service_ = base::MakeUnique<DefaultService>();
120 shell_connection_.reset(new shell::ServiceContext( 121 shell_connection_ = base::MakeUnique<shell::ServiceContext>(
121 service_.get(), 122 service_.get(), background_shell_->CreateServiceRequest(GetTestName()));
122 background_shell_->CreateServiceRequest(GetTestName())));
123 123
124 // ui/views/mus requires a WindowManager running, so launch test_wm. 124 // ui/views/mus requires a WindowManager running, so launch test_wm.
125 shell::Connector* connector = shell_connection_->connector(); 125 shell::Connector* connector = shell_connection_->connector();
126 connector->Connect("mojo:test_wm"); 126 connector->Connect("mojo:test_wm");
127 shell_connector_ = connector->Clone(); 127 shell_connector_ = connector->Clone();
128 shell_identity_ = shell_connection_->identity(); 128 shell_identity_ = shell_connection_->identity();
129 wait->Signal(); 129 wait->Signal();
130 } 130 }
131 131
132 void TearDownConnections(base::WaitableEvent* wait) { 132 void TearDownConnections(base::WaitableEvent* wait) {
(...skipping 26 matching lines...) Expand all
159 ViewsMusTestSuite::~ViewsMusTestSuite() {} 159 ViewsMusTestSuite::~ViewsMusTestSuite() {}
160 160
161 void ViewsMusTestSuite::Initialize() { 161 void ViewsMusTestSuite::Initialize() {
162 PlatformTestHelper::SetIsMus(); 162 PlatformTestHelper::SetIsMus();
163 // Let other mojo apps know that we're running in tests. Do this with a 163 // Let other mojo apps know that we're running in tests. Do this with a
164 // command line flag to avoid making blocking calls to other processes for 164 // command line flag to avoid making blocking calls to other processes for
165 // setup for tests (e.g. to unlock the screen in the window manager). 165 // setup for tests (e.g. to unlock the screen in the window manager).
166 EnsureCommandLineSwitch(ui::switches::kUseTestConfig); 166 EnsureCommandLineSwitch(ui::switches::kUseTestConfig);
167 167
168 ViewsTestSuite::Initialize(); 168 ViewsTestSuite::Initialize();
169 shell_connections_.reset(new ShellConnection); 169 shell_connections_ = base::MakeUnique<ShellConnection>();
170 } 170 }
171 171
172 void ViewsMusTestSuite::Shutdown() { 172 void ViewsMusTestSuite::Shutdown() {
173 shell_connections_.reset(); 173 shell_connections_.reset();
174 ViewsTestSuite::Shutdown(); 174 ViewsTestSuite::Shutdown();
175 } 175 }
176 176
177 } // namespace views 177 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/pointer_watcher_event_router_unittest.cc ('k') | ui/views/mus/window_manager_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698