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 "services/ui/public/cpp/tests/window_server_shelltest_base.h" | 5 #include "services/ui/public/cpp/tests/window_server_shelltest_base.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "services/shell/public/cpp/shell_client.h" | 12 #include "services/shell/public/cpp/service.h" |
13 #include "services/shell/public/cpp/shell_test.h" | 13 #include "services/shell/public/cpp/shell_test.h" |
14 #include "services/ui/common/switches.h" | 14 #include "services/ui/common/switches.h" |
15 #include "ui/gl/gl_switches.h" | 15 #include "ui/gl/gl_switches.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char kTestAppName[] = "mojo:mus_ws_unittests_app"; | 21 const char kTestAppName[] = "mojo:mus_ws_unittests_app"; |
22 | 22 |
23 class WindowServerShellTestClient : public shell::test::ShellTestClient { | 23 class WindowServerShellTestClient : public shell::test::ShellTestClient { |
24 public: | 24 public: |
25 explicit WindowServerShellTestClient(WindowServerShellTestBase* test) | 25 explicit WindowServerShellTestClient(WindowServerShellTestBase* test) |
26 : ShellTestClient(test), test_(test) {} | 26 : ShellTestClient(test), test_(test) {} |
27 ~WindowServerShellTestClient() override {} | 27 ~WindowServerShellTestClient() override {} |
28 | 28 |
29 private: | 29 private: |
30 // shell::test::ShellTestClient: | 30 // shell::test::ShellTestClient: |
31 bool AcceptConnection(shell::Connection* connection) override { | 31 bool OnConnect(shell::Connection* connection) override { |
32 return test_->AcceptConnection(connection); | 32 return test_->OnConnect(connection); |
33 } | 33 } |
34 | 34 |
35 WindowServerShellTestBase* test_; | 35 WindowServerShellTestBase* test_; |
36 | 36 |
37 DISALLOW_COPY_AND_ASSIGN(WindowServerShellTestClient); | 37 DISALLOW_COPY_AND_ASSIGN(WindowServerShellTestClient); |
38 }; | 38 }; |
39 | 39 |
40 void EnsureCommandLineSwitch(const std::string& name) { | 40 void EnsureCommandLineSwitch(const std::string& name) { |
41 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 41 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
42 if (!cmd_line->HasSwitch(name)) | 42 if (!cmd_line->HasSwitch(name)) |
43 cmd_line->AppendSwitch(name); | 43 cmd_line->AppendSwitch(name); |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 WindowServerShellTestBase::WindowServerShellTestBase() | 48 WindowServerShellTestBase::WindowServerShellTestBase() |
49 : ShellTest(kTestAppName) { | 49 : ShellTest(kTestAppName) { |
50 EnsureCommandLineSwitch(switches::kUseTestConfig); | 50 EnsureCommandLineSwitch(switches::kUseTestConfig); |
51 EnsureCommandLineSwitch(::switches::kOverrideUseGLWithOSMesaForTests); | 51 EnsureCommandLineSwitch(::switches::kOverrideUseGLWithOSMesaForTests); |
52 } | 52 } |
53 | 53 |
54 WindowServerShellTestBase::~WindowServerShellTestBase() {} | 54 WindowServerShellTestBase::~WindowServerShellTestBase() {} |
55 | 55 |
56 std::unique_ptr<shell::ShellClient> | 56 std::unique_ptr<shell::Service> |
57 WindowServerShellTestBase::CreateShellClient() { | 57 WindowServerShellTestBase::CreateService() { |
58 return base::WrapUnique(new WindowServerShellTestClient(this)); | 58 return base::WrapUnique(new WindowServerShellTestClient(this)); |
59 } | 59 } |
60 | 60 |
61 } // namespace ui | 61 } // namespace ui |
OLD | NEW |