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

Side by Side Diff: components/policy/core/common/schema_registry_unittest.cc

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/policy/core/common/schema_registry.h" 5 #include "components/policy/core/common/schema_registry.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include <memory>
8
8 #include "components/policy/core/common/policy_namespace.h" 9 #include "components/policy/core/common/policy_namespace.h"
9 #include "components/policy/core/common/schema.h" 10 #include "components/policy/core/common/schema.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using ::testing::Mock; 14 using ::testing::Mock;
14 using ::testing::_; 15 using ::testing::_;
15 16
16 namespace policy { 17 namespace policy {
17 18
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 134
134 registry.RemoveObserver(&observer); 135 registry.RemoveObserver(&observer);
135 } 136 }
136 137
137 TEST(SchemaRegistryTest, Combined) { 138 TEST(SchemaRegistryTest, Combined) {
138 std::string error; 139 std::string error;
139 Schema schema = Schema::Parse(kTestSchema, &error); 140 Schema schema = Schema::Parse(kTestSchema, &error);
140 ASSERT_TRUE(schema.valid()) << error; 141 ASSERT_TRUE(schema.valid()) << error;
141 142
142 MockSchemaRegistryObserver observer; 143 MockSchemaRegistryObserver observer;
143 scoped_ptr<SchemaRegistry> registry1(new SchemaRegistry); 144 std::unique_ptr<SchemaRegistry> registry1(new SchemaRegistry);
144 scoped_ptr<SchemaRegistry> registry2(new SchemaRegistry); 145 std::unique_ptr<SchemaRegistry> registry2(new SchemaRegistry);
145 CombinedSchemaRegistry combined; 146 CombinedSchemaRegistry combined;
146 combined.AddObserver(&observer); 147 combined.AddObserver(&observer);
147 148
148 EXPECT_CALL(observer, OnSchemaRegistryUpdated(_)).Times(0); 149 EXPECT_CALL(observer, OnSchemaRegistryUpdated(_)).Times(0);
149 registry1->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"), 150 registry1->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"),
150 schema); 151 schema);
151 Mock::VerifyAndClearExpectations(&observer); 152 Mock::VerifyAndClearExpectations(&observer);
152 153
153 // Starting to track a registry issues notifications when it comes with new 154 // Starting to track a registry issues notifications when it comes with new
154 // schemas. 155 // schemas.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 Mock::VerifyAndClearExpectations(&observer); 240 Mock::VerifyAndClearExpectations(&observer);
240 241
241 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false)); 242 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
242 registry2.reset(); 243 registry2.reset();
243 Mock::VerifyAndClearExpectations(&observer); 244 Mock::VerifyAndClearExpectations(&observer);
244 245
245 combined.RemoveObserver(&observer); 246 combined.RemoveObserver(&observer);
246 } 247 }
247 248
248 TEST(SchemaRegistryTest, ForwardingSchemaRegistry) { 249 TEST(SchemaRegistryTest, ForwardingSchemaRegistry) {
249 scoped_ptr<SchemaRegistry> registry(new SchemaRegistry); 250 std::unique_ptr<SchemaRegistry> registry(new SchemaRegistry);
250 ForwardingSchemaRegistry forwarding(registry.get()); 251 ForwardingSchemaRegistry forwarding(registry.get());
251 MockSchemaRegistryObserver observer; 252 MockSchemaRegistryObserver observer;
252 forwarding.AddObserver(&observer); 253 forwarding.AddObserver(&observer);
253 254
254 EXPECT_FALSE(registry->IsReady()); 255 EXPECT_FALSE(registry->IsReady());
255 EXPECT_FALSE(forwarding.IsReady()); 256 EXPECT_FALSE(forwarding.IsReady());
256 // They always have the same SchemaMap. 257 // They always have the same SchemaMap.
257 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); 258 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map()));
258 259
259 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true)); 260 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // No notifications are expected in this case either. 299 // No notifications are expected in this case either.
299 scoped_refptr<SchemaMap> schema_map = registry->schema_map(); 300 scoped_refptr<SchemaMap> schema_map = registry->schema_map();
300 registry.reset(); 301 registry.reset();
301 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map())); 302 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map()));
302 Mock::VerifyAndClearExpectations(&observer); 303 Mock::VerifyAndClearExpectations(&observer);
303 304
304 forwarding.RemoveObserver(&observer); 305 forwarding.RemoveObserver(&observer);
305 } 306 }
306 307
307 } // namespace policy 308 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698