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

Side by Side Diff: mojo/public/cpp/application/tests/service_registry_unittest.cc

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
« no previous file with comments | « mojo/public/cpp/application/tests/BUILD.gn ('k') | mojo/public/cpp/bindings/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 "mojo/public/cpp/application/lib/service_registry.h"
6
7 #include "mojo/public/cpp/application/lib/service_connector.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace mojo {
11 namespace internal {
12 namespace {
13
14 class TestConnector : public ServiceConnectorBase {
15 public:
16 TestConnector(const std::string& name, int* delete_count)
17 : ServiceConnectorBase(name), delete_count_(delete_count) {}
18 ~TestConnector() override { (*delete_count_)++; }
19 void ConnectToService(const std::string& name,
20 ScopedMessagePipeHandle client_handle) override {}
21
22 private:
23 int* delete_count_;
24 };
25
26 TEST(ServiceRegistryTest, Ownership) {
27 int delete_count = 0;
28
29 // Destruction.
30 {
31 ServiceRegistry registry;
32 registry.AddServiceConnector(new TestConnector("TC1", &delete_count));
33 }
34 EXPECT_EQ(1, delete_count);
35
36 // Removal.
37 {
38 ServiceRegistry registry;
39 ServiceConnectorBase* c = new TestConnector("TC1", &delete_count);
40 registry.AddServiceConnector(c);
41 registry.RemoveServiceConnector(c);
42 EXPECT_EQ(2, delete_count);
43 }
44
45 // Multiple.
46 {
47 ServiceRegistry registry;
48 registry.AddServiceConnector(new TestConnector("TC1", &delete_count));
49 registry.AddServiceConnector(new TestConnector("TC2", &delete_count));
50 }
51 EXPECT_EQ(4, delete_count);
52
53 // Re-addition.
54 {
55 ServiceRegistry registry;
56 registry.AddServiceConnector(new TestConnector("TC1", &delete_count));
57 registry.AddServiceConnector(new TestConnector("TC1", &delete_count));
58 EXPECT_EQ(5, delete_count);
59 }
60 EXPECT_EQ(6, delete_count);
61 }
62
63 } // namespace
64 } // namespace internal
65 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/tests/BUILD.gn ('k') | mojo/public/cpp/bindings/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698