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

Side by Side Diff: services/shell/tests/connect/connect_test_driver.cc

Issue 2419723002: Move services/shell to services/service_manager (Closed)
Patch Set: rebase 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <memory>
6
7 #include "base/at_exit.h"
8 #include "base/command_line.h"
9 #include "base/macros.h"
10 #include "base/process/process.h"
11 #include "mojo/public/cpp/bindings/binding_set.h"
12 #include "services/shell/public/cpp/connection.h"
13 #include "services/shell/public/cpp/connector.h"
14 #include "services/shell/public/cpp/service.h"
15 #include "services/shell/runner/child/test_native_main.h"
16 #include "services/shell/runner/init.h"
17 #include "services/shell/tests/connect/connect_test.mojom.h"
18 #include "services/shell/tests/util.h"
19
20 using shell::test::mojom::ClientProcessTest;
21 using shell::test::mojom::ClientProcessTestRequest;
22
23 namespace {
24
25 class Driver : public shell::Service,
26 public shell::InterfaceFactory<ClientProcessTest>,
27 public ClientProcessTest {
28 public:
29 Driver() {}
30 ~Driver() override {}
31
32 private:
33 // shell::Service:
34 bool OnConnect(const shell::Identity& remote_identity,
35 shell::InterfaceRegistry* registry) override {
36 registry->AddInterface<ClientProcessTest>(this);
37 return true;
38 }
39 bool OnStop() override {
40 // TODO(rockot): http://crbug.com/596621. Should be able to remove this
41 // override entirely.
42 _exit(1);
43 }
44
45 // shell::InterfaceFactory<ConnectTestService>:
46 void Create(const shell::Identity& remote_identity,
47 ClientProcessTestRequest request) override {
48 bindings_.AddBinding(this, std::move(request));
49 }
50
51 // test::mojom::ClientProcessTest:
52 void LaunchAndConnectToProcess(
53 const LaunchAndConnectToProcessCallback& callback) override {
54 base::Process process;
55 std::unique_ptr<shell::Connection> connection =
56 shell::test::LaunchAndConnectToProcess(
57 #if defined(OS_WIN)
58 "connect_test_exe.exe",
59 #else
60 "connect_test_exe",
61 #endif
62 shell::Identity("exe:connect_test_exe",
63 shell::mojom::kInheritUserID),
64 connector(), &process);
65 callback.Run(static_cast<int32_t>(connection->GetResult()),
66 connection->GetRemoteIdentity());
67 }
68
69 mojo::BindingSet<ClientProcessTest> bindings_;
70
71 DISALLOW_COPY_AND_ASSIGN(Driver);
72 };
73
74 } // namespace
75
76 int main(int argc, char** argv) {
77 base::AtExitManager at_exit;
78 base::CommandLine::Init(argc, argv);
79
80 shell::InitializeLogging();
81
82 Driver driver;
83 return shell::TestNativeMain(&driver);
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698