OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/base/device_capabilities_impl.h" | 5 #include "chromecast/base/device_capabilities_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chromecast/base/serializers.h" | 15 #include "chromecast/base/serializers.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 namespace chromecast { | 19 namespace chromecast { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 const char kSampleDictionaryCapability[] = | 23 const char kSampleDictionaryCapability[] = |
23 "{" | 24 "{" |
24 " \"dummy_field_bool\": true," | 25 " \"dummy_field_bool\": true," |
25 " \"dummy_field_int\": 99" | 26 " \"dummy_field_int\": 99" |
26 "}"; | 27 "}"; |
27 | 28 |
28 void GetSampleDefaultCapability(std::string* key, | 29 void GetSampleDefaultCapability(std::string* key, |
29 scoped_ptr<base::Value>* init_value); | 30 std::unique_ptr<base::Value>* init_value); |
30 void TestBasicOperations(DeviceCapabilities* capabilities); | 31 void TestBasicOperations(DeviceCapabilities* capabilities); |
31 | 32 |
32 // Simple capability manager that implements the Validator interface. Either | 33 // Simple capability manager that implements the Validator interface. Either |
33 // accepts or rejects all proposed changes based on |accept_changes| constructor | 34 // accepts or rejects all proposed changes based on |accept_changes| constructor |
34 // argument. | 35 // argument. |
35 class FakeCapabilityManagerSimple : public DeviceCapabilities::Validator { | 36 class FakeCapabilityManagerSimple : public DeviceCapabilities::Validator { |
36 public: | 37 public: |
37 // Registers itself as Validator in constructor. If init_value is not null, | 38 // Registers itself as Validator in constructor. If init_value is not null, |
38 // the capability gets initialized to that value. Else capability remains | 39 // the capability gets initialized to that value. Else capability remains |
39 // untouched. | 40 // untouched. |
40 FakeCapabilityManagerSimple(DeviceCapabilities* capabilities, | 41 FakeCapabilityManagerSimple(DeviceCapabilities* capabilities, |
41 const std::string& key, | 42 const std::string& key, |
42 scoped_ptr<base::Value> init_value, | 43 std::unique_ptr<base::Value> init_value, |
43 bool accept_changes) | 44 bool accept_changes) |
44 : DeviceCapabilities::Validator(capabilities), | 45 : DeviceCapabilities::Validator(capabilities), |
45 key_(key), | 46 key_(key), |
46 accept_changes_(accept_changes) { | 47 accept_changes_(accept_changes) { |
47 capabilities->Register(key, this); | 48 capabilities->Register(key, this); |
48 if (init_value) | 49 if (init_value) |
49 SetValidatedValue(key, std::move(init_value)); | 50 SetValidatedValue(key, std::move(init_value)); |
50 } | 51 } |
51 | 52 |
52 // Unregisters itself as Validator. | 53 // Unregisters itself as Validator. |
53 ~FakeCapabilityManagerSimple() override { | 54 ~FakeCapabilityManagerSimple() override { |
54 capabilities()->Unregister(key_, this); | 55 capabilities()->Unregister(key_, this); |
55 } | 56 } |
56 | 57 |
57 void Validate(const std::string& path, | 58 void Validate(const std::string& path, |
58 scoped_ptr<base::Value> proposed_value) override { | 59 std::unique_ptr<base::Value> proposed_value) override { |
59 ASSERT_EQ(path.find(key_), 0ul); | 60 ASSERT_EQ(path.find(key_), 0ul); |
60 if (accept_changes_) | 61 if (accept_changes_) |
61 SetValidatedValue(path, std::move(proposed_value)); | 62 SetValidatedValue(path, std::move(proposed_value)); |
62 } | 63 } |
63 | 64 |
64 private: | 65 private: |
65 const std::string key_; | 66 const std::string key_; |
66 const bool accept_changes_; | 67 const bool accept_changes_; |
67 }; | 68 }; |
68 | 69 |
69 // Used to test that capabilities/validator can be read and written in | 70 // Used to test that capabilities/validator can be read and written in |
70 // Validate() without encountering deadlocks/unexpected behavior. | 71 // Validate() without encountering deadlocks/unexpected behavior. |
71 class FakeCapabilityManagerComplex : public DeviceCapabilities::Validator { | 72 class FakeCapabilityManagerComplex : public DeviceCapabilities::Validator { |
72 public: | 73 public: |
73 FakeCapabilityManagerComplex(DeviceCapabilities* capabilities, | 74 FakeCapabilityManagerComplex(DeviceCapabilities* capabilities, |
74 const std::string& key) | 75 const std::string& key) |
75 : DeviceCapabilities::Validator(capabilities), key_(key) { | 76 : DeviceCapabilities::Validator(capabilities), key_(key) { |
76 capabilities->Register(key, this); | 77 capabilities->Register(key, this); |
77 } | 78 } |
78 | 79 |
79 // Unregisters itself as Validator. | 80 // Unregisters itself as Validator. |
80 ~FakeCapabilityManagerComplex() override { | 81 ~FakeCapabilityManagerComplex() override { |
81 capabilities()->Unregister(key_, this); | 82 capabilities()->Unregister(key_, this); |
82 } | 83 } |
83 | 84 |
84 // Runs TestBasicOperations(). | 85 // Runs TestBasicOperations(). |
85 void Validate(const std::string& path, | 86 void Validate(const std::string& path, |
86 scoped_ptr<base::Value> proposed_value) override { | 87 std::unique_ptr<base::Value> proposed_value) override { |
87 TestBasicOperations(capabilities()); | 88 TestBasicOperations(capabilities()); |
88 } | 89 } |
89 | 90 |
90 private: | 91 private: |
91 const std::string key_; | 92 const std::string key_; |
92 }; | 93 }; |
93 | 94 |
94 // Used to test that capabilities/validators can be read and written in | 95 // Used to test that capabilities/validators can be read and written in |
95 // OnCapabilitiesChanged() without encountering deadlocks/unexpected behavior. | 96 // OnCapabilitiesChanged() without encountering deadlocks/unexpected behavior. |
96 class FakeCapabilitiesObserver : public DeviceCapabilities::Observer { | 97 class FakeCapabilitiesObserver : public DeviceCapabilities::Observer { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 MOCK_METHOD1(OnCapabilitiesChanged, void(const std::string& path)); | 130 MOCK_METHOD1(OnCapabilitiesChanged, void(const std::string& path)); |
130 | 131 |
131 private: | 132 private: |
132 DISALLOW_COPY_AND_ASSIGN(MockCapabilitiesObserver); | 133 DISALLOW_COPY_AND_ASSIGN(MockCapabilitiesObserver); |
133 }; | 134 }; |
134 | 135 |
135 // Test fixtures needs an example default capability to test DeviceCapabilities | 136 // Test fixtures needs an example default capability to test DeviceCapabilities |
136 // methods. Gets a sample key and initial value. | 137 // methods. Gets a sample key and initial value. |
137 void GetSampleDefaultCapability(std::string* key, | 138 void GetSampleDefaultCapability(std::string* key, |
138 scoped_ptr<base::Value>* init_value) { | 139 std::unique_ptr<base::Value>* init_value) { |
139 DCHECK(key); | 140 DCHECK(key); |
140 DCHECK(init_value); | 141 DCHECK(init_value); |
141 *key = DeviceCapabilities::kKeyBluetoothSupported; | 142 *key = DeviceCapabilities::kKeyBluetoothSupported; |
142 *init_value = make_scoped_ptr(new base::FundamentalValue(true)); | 143 *init_value = base::WrapUnique(new base::FundamentalValue(true)); |
143 } | 144 } |
144 | 145 |
145 // For test fixtures that test dynamic capabilities, gets a sample key | 146 // For test fixtures that test dynamic capabilities, gets a sample key |
146 // and initial value. | 147 // and initial value. |
147 void GetSampleDynamicCapability(std::string* key, | 148 void GetSampleDynamicCapability(std::string* key, |
148 scoped_ptr<base::Value>* init_value) { | 149 std::unique_ptr<base::Value>* init_value) { |
149 DCHECK(key); | 150 DCHECK(key); |
150 DCHECK(init_value); | 151 DCHECK(init_value); |
151 *key = "dummy_dynamic_key"; | 152 *key = "dummy_dynamic_key"; |
152 *init_value = make_scoped_ptr(new base::FundamentalValue(99)); | 153 *init_value = base::WrapUnique(new base::FundamentalValue(99)); |
153 } | 154 } |
154 | 155 |
155 // Gets a value for sample default capability different from |init_value| | 156 // Gets a value for sample default capability different from |init_value| |
156 // returned in GetSampleDefaultCapability(). Must be of same type as | 157 // returned in GetSampleDefaultCapability(). Must be of same type as |
157 // |init_value| of course. | 158 // |init_value| of course. |
158 scoped_ptr<base::Value> GetSampleDefaultCapabilityNewValue() { | 159 std::unique_ptr<base::Value> GetSampleDefaultCapabilityNewValue() { |
159 return make_scoped_ptr(new base::FundamentalValue(false)); | 160 return base::WrapUnique(new base::FundamentalValue(false)); |
160 } | 161 } |
161 | 162 |
162 // Gets a value for sample dynamic capability different from |init_value| | 163 // Gets a value for sample dynamic capability different from |init_value| |
163 // returned in GetSampleDynamicCapability(). Must be of same type as | 164 // returned in GetSampleDynamicCapability(). Must be of same type as |
164 // |init_value| of course. | 165 // |init_value| of course. |
165 scoped_ptr<base::Value> GetSampleDynamicCapabilityNewValue() { | 166 std::unique_ptr<base::Value> GetSampleDynamicCapabilityNewValue() { |
166 return make_scoped_ptr(new base::FundamentalValue(100)); | 167 return base::WrapUnique(new base::FundamentalValue(100)); |
167 } | 168 } |
168 | 169 |
169 // Tests that |json| string matches contents of a DictionaryValue with one entry | 170 // Tests that |json| string matches contents of a DictionaryValue with one entry |
170 // specified by |key| and |value|. | 171 // specified by |key| and |value|. |
171 bool JsonStringEquals(const std::string& json, | 172 bool JsonStringEquals(const std::string& json, |
172 const std::string& key, | 173 const std::string& key, |
173 const base::Value& value) { | 174 const base::Value& value) { |
174 base::DictionaryValue dict_value; | 175 base::DictionaryValue dict_value; |
175 dict_value.Set(key, value.CreateDeepCopy()); | 176 dict_value.Set(key, value.CreateDeepCopy()); |
176 scoped_ptr<const std::string> dict_json(SerializeToJson(dict_value)); | 177 std::unique_ptr<const std::string> dict_json(SerializeToJson(dict_value)); |
177 return dict_json.get() && *dict_json == json; | 178 return dict_json.get() && *dict_json == json; |
178 } | 179 } |
179 | 180 |
180 // The function runs through the set of basic operations of DeviceCapabilities. | 181 // The function runs through the set of basic operations of DeviceCapabilities. |
181 // Register validator for sample default capability, reads capability, writes | 182 // Register validator for sample default capability, reads capability, writes |
182 // capability, and unregister validator. After it has completed, use | 183 // capability, and unregister validator. After it has completed, use |
183 // AssertBasicOperationsSuccessful() to ensure that all operations completed | 184 // AssertBasicOperationsSuccessful() to ensure that all operations completed |
184 // successfully. Sample default capability should not be added or registered in | 185 // successfully. Sample default capability should not be added or registered in |
185 // class before this function is called. | 186 // class before this function is called. |
186 void TestBasicOperations(DeviceCapabilities* capabilities) { | 187 void TestBasicOperations(DeviceCapabilities* capabilities) { |
187 std::string key; | 188 std::string key; |
188 scoped_ptr<base::Value> init_value; | 189 std::unique_ptr<base::Value> init_value; |
189 GetSampleDefaultCapability(&key, &init_value); | 190 GetSampleDefaultCapability(&key, &init_value); |
190 | 191 |
191 ASSERT_FALSE(capabilities->GetCapability(key)); | 192 ASSERT_FALSE(capabilities->GetCapability(key)); |
192 ASSERT_FALSE(capabilities->GetValidator(key)); | 193 ASSERT_FALSE(capabilities->GetValidator(key)); |
193 | 194 |
194 // Register and write capability | 195 // Register and write capability |
195 FakeCapabilityManagerSimple* manager(new FakeCapabilityManagerSimple( | 196 FakeCapabilityManagerSimple* manager(new FakeCapabilityManagerSimple( |
196 capabilities, key, init_value->CreateDeepCopy(), true)); | 197 capabilities, key, init_value->CreateDeepCopy(), true)); |
197 // Read Validator | 198 // Read Validator |
198 EXPECT_EQ(capabilities->GetValidator(key), manager); | 199 EXPECT_EQ(capabilities->GetValidator(key), manager); |
199 // Read Capability | 200 // Read Capability |
200 EXPECT_TRUE(base::Value::Equals(capabilities->GetCapability(key).get(), | 201 EXPECT_TRUE(base::Value::Equals(capabilities->GetCapability(key).get(), |
201 init_value.get())); | 202 init_value.get())); |
202 // Unregister | 203 // Unregister |
203 delete manager; | 204 delete manager; |
204 | 205 |
205 // Write capability again. Provides way of checking that this function | 206 // Write capability again. Provides way of checking that this function |
206 // ran and was successful. | 207 // ran and was successful. |
207 scoped_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); | 208 std::unique_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); |
208 capabilities->SetCapability(key, std::move(new_value)); | 209 capabilities->SetCapability(key, std::move(new_value)); |
209 } | 210 } |
210 | 211 |
211 // See TestBasicOperations() comment. | 212 // See TestBasicOperations() comment. |
212 void AssertBasicOperationsSuccessful(const DeviceCapabilities* capabilities) { | 213 void AssertBasicOperationsSuccessful(const DeviceCapabilities* capabilities) { |
213 base::RunLoop().RunUntilIdle(); | 214 base::RunLoop().RunUntilIdle(); |
214 std::string key; | 215 std::string key; |
215 scoped_ptr<base::Value> init_value; | 216 std::unique_ptr<base::Value> init_value; |
216 GetSampleDefaultCapability(&key, &init_value); | 217 GetSampleDefaultCapability(&key, &init_value); |
217 scoped_ptr<base::Value> value = capabilities->GetCapability(key); | 218 std::unique_ptr<base::Value> value = capabilities->GetCapability(key); |
218 ASSERT_TRUE(value); | 219 ASSERT_TRUE(value); |
219 scoped_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); | 220 std::unique_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); |
220 EXPECT_TRUE(base::Value::Equals(value.get(), new_value.get())); | 221 EXPECT_TRUE(base::Value::Equals(value.get(), new_value.get())); |
221 } | 222 } |
222 | 223 |
223 } // namespace | 224 } // namespace |
224 | 225 |
225 class DeviceCapabilitiesImplTest : public ::testing::Test { | 226 class DeviceCapabilitiesImplTest : public ::testing::Test { |
226 protected: | 227 protected: |
227 void SetUp() override { | 228 void SetUp() override { |
228 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 229 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); |
229 capabilities_ = DeviceCapabilities::Create(); | 230 capabilities_ = DeviceCapabilities::Create(); |
(...skipping 16 matching lines...) Expand all Loading... |
246 message_loop_.reset(); | 247 message_loop_.reset(); |
247 } | 248 } |
248 | 249 |
249 DeviceCapabilities* capabilities() const { return capabilities_.get(); } | 250 DeviceCapabilities* capabilities() const { return capabilities_.get(); } |
250 | 251 |
251 MockCapabilitiesObserver* capabilities_observer() const { | 252 MockCapabilitiesObserver* capabilities_observer() const { |
252 return mock_capabilities_observer_.get(); | 253 return mock_capabilities_observer_.get(); |
253 } | 254 } |
254 | 255 |
255 private: | 256 private: |
256 scoped_ptr<base::MessageLoop> message_loop_; | 257 std::unique_ptr<base::MessageLoop> message_loop_; |
257 scoped_ptr<DeviceCapabilities> capabilities_; | 258 std::unique_ptr<DeviceCapabilities> capabilities_; |
258 scoped_ptr<MockCapabilitiesObserver> mock_capabilities_observer_; | 259 std::unique_ptr<MockCapabilitiesObserver> mock_capabilities_observer_; |
259 }; | 260 }; |
260 | 261 |
261 // Tests that class is in correct state after Create(). | 262 // Tests that class is in correct state after Create(). |
262 TEST_F(DeviceCapabilitiesImplTest, Create) { | 263 TEST_F(DeviceCapabilitiesImplTest, Create) { |
263 scoped_ptr<const std::string> empty_dict_string( | 264 std::unique_ptr<const std::string> empty_dict_string( |
264 SerializeToJson(base::DictionaryValue())); | 265 SerializeToJson(base::DictionaryValue())); |
265 EXPECT_EQ(capabilities()->GetData()->json_string(), *empty_dict_string); | 266 EXPECT_EQ(capabilities()->GetData()->json_string(), *empty_dict_string); |
266 EXPECT_TRUE(capabilities()->GetData()->dictionary().empty()); | 267 EXPECT_TRUE(capabilities()->GetData()->dictionary().empty()); |
267 } | 268 } |
268 | 269 |
269 // Tests Register() of a default capability. | 270 // Tests Register() of a default capability. |
270 TEST_F(DeviceCapabilitiesImplTest, Register) { | 271 TEST_F(DeviceCapabilitiesImplTest, Register) { |
271 std::string key; | 272 std::string key; |
272 scoped_ptr<base::Value> init_value; | 273 std::unique_ptr<base::Value> init_value; |
273 GetSampleDefaultCapability(&key, &init_value); | 274 GetSampleDefaultCapability(&key, &init_value); |
274 | 275 |
275 EXPECT_CALL(*capabilities_observer(), OnCapabilitiesChanged(key)).Times(0); | 276 EXPECT_CALL(*capabilities_observer(), OnCapabilitiesChanged(key)).Times(0); |
276 FakeCapabilityManagerSimple manager(capabilities(), key, nullptr, true); | 277 FakeCapabilityManagerSimple manager(capabilities(), key, nullptr, true); |
277 | 278 |
278 EXPECT_EQ(capabilities()->GetValidator(key), &manager); | 279 EXPECT_EQ(capabilities()->GetValidator(key), &manager); |
279 scoped_ptr<const std::string> empty_dict_string( | 280 std::unique_ptr<const std::string> empty_dict_string( |
280 SerializeToJson(base::DictionaryValue())); | 281 SerializeToJson(base::DictionaryValue())); |
281 EXPECT_EQ(capabilities()->GetData()->json_string(), *empty_dict_string); | 282 EXPECT_EQ(capabilities()->GetData()->json_string(), *empty_dict_string); |
282 EXPECT_FALSE(capabilities()->GetCapability(key)); | 283 EXPECT_FALSE(capabilities()->GetCapability(key)); |
283 } | 284 } |
284 | 285 |
285 // Tests Unregister() of a default capability. | 286 // Tests Unregister() of a default capability. |
286 TEST_F(DeviceCapabilitiesImplTest, Unregister) { | 287 TEST_F(DeviceCapabilitiesImplTest, Unregister) { |
287 std::string key; | 288 std::string key; |
288 scoped_ptr<base::Value> init_value; | 289 std::unique_ptr<base::Value> init_value; |
289 GetSampleDefaultCapability(&key, &init_value); | 290 GetSampleDefaultCapability(&key, &init_value); |
290 | 291 |
291 EXPECT_CALL(*capabilities_observer(), OnCapabilitiesChanged(key)).Times(0); | 292 EXPECT_CALL(*capabilities_observer(), OnCapabilitiesChanged(key)).Times(0); |
292 FakeCapabilityManagerSimple* manager = | 293 FakeCapabilityManagerSimple* manager = |
293 new FakeCapabilityManagerSimple(capabilities(), key, nullptr, true); | 294 new FakeCapabilityManagerSimple(capabilities(), key, nullptr, true); |
294 | 295 |
295 delete manager; | 296 delete manager; |
296 | 297 |
297 EXPECT_FALSE(capabilities()->GetValidator(key)); | 298 EXPECT_FALSE(capabilities()->GetValidator(key)); |
298 scoped_ptr<const std::string> empty_dict_string( | 299 std::unique_ptr<const std::string> empty_dict_string( |
299 SerializeToJson(base::DictionaryValue())); | 300 SerializeToJson(base::DictionaryValue())); |
300 EXPECT_EQ(capabilities()->GetData()->json_string(), *empty_dict_string); | 301 EXPECT_EQ(capabilities()->GetData()->json_string(), *empty_dict_string); |
301 EXPECT_FALSE(capabilities()->GetCapability(key)); | 302 EXPECT_FALSE(capabilities()->GetCapability(key)); |
302 } | 303 } |
303 | 304 |
304 // Tests GetCapability() and updating the value through SetCapability(). | 305 // Tests GetCapability() and updating the value through SetCapability(). |
305 TEST_F(DeviceCapabilitiesImplTest, GetCapabilityAndSetCapability) { | 306 TEST_F(DeviceCapabilitiesImplTest, GetCapabilityAndSetCapability) { |
306 std::string key; | 307 std::string key; |
307 scoped_ptr<base::Value> init_value; | 308 std::unique_ptr<base::Value> init_value; |
308 GetSampleDefaultCapability(&key, &init_value); | 309 GetSampleDefaultCapability(&key, &init_value); |
309 FakeCapabilityManagerSimple manager(capabilities(), key, | 310 FakeCapabilityManagerSimple manager(capabilities(), key, |
310 init_value->CreateDeepCopy(), true); | 311 init_value->CreateDeepCopy(), true); |
311 | 312 |
312 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), | 313 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), |
313 init_value.get())); | 314 init_value.get())); |
314 | 315 |
315 scoped_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); | 316 std::unique_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); |
316 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); | 317 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); |
317 base::RunLoop().RunUntilIdle(); | 318 base::RunLoop().RunUntilIdle(); |
318 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), | 319 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), |
319 new_value.get())); | 320 new_value.get())); |
320 } | 321 } |
321 | 322 |
322 // Tests BluetoothSupported() and updating this value through SetCapability(). | 323 // Tests BluetoothSupported() and updating this value through SetCapability(). |
323 TEST_F(DeviceCapabilitiesImplTest, BluetoothSupportedAndSetCapability) { | 324 TEST_F(DeviceCapabilitiesImplTest, BluetoothSupportedAndSetCapability) { |
324 FakeCapabilityManagerSimple manager( | 325 FakeCapabilityManagerSimple manager( |
325 capabilities(), DeviceCapabilities::kKeyBluetoothSupported, | 326 capabilities(), DeviceCapabilities::kKeyBluetoothSupported, |
326 make_scoped_ptr(new base::FundamentalValue(true)), true); | 327 base::WrapUnique(new base::FundamentalValue(true)), true); |
327 | 328 |
328 EXPECT_TRUE(capabilities()->BluetoothSupported()); | 329 EXPECT_TRUE(capabilities()->BluetoothSupported()); |
329 capabilities()->SetCapability( | 330 capabilities()->SetCapability( |
330 DeviceCapabilities::kKeyBluetoothSupported, | 331 DeviceCapabilities::kKeyBluetoothSupported, |
331 make_scoped_ptr(new base::FundamentalValue(false))); | 332 base::WrapUnique(new base::FundamentalValue(false))); |
332 base::RunLoop().RunUntilIdle(); | 333 base::RunLoop().RunUntilIdle(); |
333 EXPECT_FALSE(capabilities()->BluetoothSupported()); | 334 EXPECT_FALSE(capabilities()->BluetoothSupported()); |
334 } | 335 } |
335 | 336 |
336 // Tests DisplaySupported() and updating this value through SetCapability(). | 337 // Tests DisplaySupported() and updating this value through SetCapability(). |
337 TEST_F(DeviceCapabilitiesImplTest, DisplaySupportedAndSetCapability) { | 338 TEST_F(DeviceCapabilitiesImplTest, DisplaySupportedAndSetCapability) { |
338 FakeCapabilityManagerSimple manager( | 339 FakeCapabilityManagerSimple manager( |
339 capabilities(), DeviceCapabilities::kKeyDisplaySupported, | 340 capabilities(), DeviceCapabilities::kKeyDisplaySupported, |
340 make_scoped_ptr(new base::FundamentalValue(true)), true); | 341 base::WrapUnique(new base::FundamentalValue(true)), true); |
341 | 342 |
342 EXPECT_TRUE(capabilities()->DisplaySupported()); | 343 EXPECT_TRUE(capabilities()->DisplaySupported()); |
343 capabilities()->SetCapability( | 344 capabilities()->SetCapability( |
344 DeviceCapabilities::kKeyDisplaySupported, | 345 DeviceCapabilities::kKeyDisplaySupported, |
345 make_scoped_ptr(new base::FundamentalValue(false))); | 346 base::WrapUnique(new base::FundamentalValue(false))); |
346 base::RunLoop().RunUntilIdle(); | 347 base::RunLoop().RunUntilIdle(); |
347 EXPECT_FALSE(capabilities()->DisplaySupported()); | 348 EXPECT_FALSE(capabilities()->DisplaySupported()); |
348 } | 349 } |
349 | 350 |
350 // Tests HiResAudioSupported() and updating this value through SetCapability() | 351 // Tests HiResAudioSupported() and updating this value through SetCapability() |
351 TEST_F(DeviceCapabilitiesImplTest, HiResAudioSupportedAndSetCapability) { | 352 TEST_F(DeviceCapabilitiesImplTest, HiResAudioSupportedAndSetCapability) { |
352 FakeCapabilityManagerSimple manager( | 353 FakeCapabilityManagerSimple manager( |
353 capabilities(), DeviceCapabilities::kKeyHiResAudioSupported, | 354 capabilities(), DeviceCapabilities::kKeyHiResAudioSupported, |
354 make_scoped_ptr(new base::FundamentalValue(true)), true); | 355 base::WrapUnique(new base::FundamentalValue(true)), true); |
355 | 356 |
356 EXPECT_TRUE(capabilities()->HiResAudioSupported()); | 357 EXPECT_TRUE(capabilities()->HiResAudioSupported()); |
357 capabilities()->SetCapability( | 358 capabilities()->SetCapability( |
358 DeviceCapabilities::kKeyHiResAudioSupported, | 359 DeviceCapabilities::kKeyHiResAudioSupported, |
359 make_scoped_ptr(new base::FundamentalValue(false))); | 360 base::WrapUnique(new base::FundamentalValue(false))); |
360 base::RunLoop().RunUntilIdle(); | 361 base::RunLoop().RunUntilIdle(); |
361 EXPECT_FALSE(capabilities()->HiResAudioSupported()); | 362 EXPECT_FALSE(capabilities()->HiResAudioSupported()); |
362 } | 363 } |
363 | 364 |
364 // Tests SetCapability() for a default capability when the capability's manager | 365 // Tests SetCapability() for a default capability when the capability's manager |
365 // rejects the proposed change. | 366 // rejects the proposed change. |
366 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityInvalid) { | 367 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityInvalid) { |
367 std::string key; | 368 std::string key; |
368 scoped_ptr<base::Value> init_value; | 369 std::unique_ptr<base::Value> init_value; |
369 GetSampleDefaultCapability(&key, &init_value); | 370 GetSampleDefaultCapability(&key, &init_value); |
370 FakeCapabilityManagerSimple manager(capabilities(), key, | 371 FakeCapabilityManagerSimple manager(capabilities(), key, |
371 init_value->CreateDeepCopy(), false); | 372 init_value->CreateDeepCopy(), false); |
372 | 373 |
373 capabilities()->SetCapability(key, GetSampleDefaultCapabilityNewValue()); | 374 capabilities()->SetCapability(key, GetSampleDefaultCapabilityNewValue()); |
374 base::RunLoop().RunUntilIdle(); | 375 base::RunLoop().RunUntilIdle(); |
375 | 376 |
376 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), | 377 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), |
377 init_value.get())); | 378 init_value.get())); |
378 } | 379 } |
379 | 380 |
380 // Test that SetCapability() updates the capabilities string correctly | 381 // Test that SetCapability() updates the capabilities string correctly |
381 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityUpdatesString) { | 382 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityUpdatesString) { |
382 std::string key; | 383 std::string key; |
383 scoped_ptr<base::Value> init_value; | 384 std::unique_ptr<base::Value> init_value; |
384 GetSampleDefaultCapability(&key, &init_value); | 385 GetSampleDefaultCapability(&key, &init_value); |
385 FakeCapabilityManagerSimple manager(capabilities(), key, | 386 FakeCapabilityManagerSimple manager(capabilities(), key, |
386 init_value->CreateDeepCopy(), true); | 387 init_value->CreateDeepCopy(), true); |
387 | 388 |
388 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, | 389 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, |
389 *init_value)); | 390 *init_value)); |
390 | 391 |
391 scoped_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); | 392 std::unique_ptr<base::Value> new_value = GetSampleDefaultCapabilityNewValue(); |
392 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); | 393 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); |
393 base::RunLoop().RunUntilIdle(); | 394 base::RunLoop().RunUntilIdle(); |
394 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, | 395 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, |
395 *new_value)); | 396 *new_value)); |
396 } | 397 } |
397 | 398 |
398 // Test that SetCapability() notifies Observers when the capability's value | 399 // Test that SetCapability() notifies Observers when the capability's value |
399 // changes | 400 // changes |
400 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityNotifiesObservers) { | 401 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityNotifiesObservers) { |
401 std::string key; | 402 std::string key; |
402 scoped_ptr<base::Value> init_value; | 403 std::unique_ptr<base::Value> init_value; |
403 GetSampleDefaultCapability(&key, &init_value); | 404 GetSampleDefaultCapability(&key, &init_value); |
404 | 405 |
405 EXPECT_CALL(*capabilities_observer(), OnCapabilitiesChanged(key)).Times(3); | 406 EXPECT_CALL(*capabilities_observer(), OnCapabilitiesChanged(key)).Times(3); |
406 | 407 |
407 // 1st call (register) | 408 // 1st call (register) |
408 FakeCapabilityManagerSimple manager(capabilities(), key, | 409 FakeCapabilityManagerSimple manager(capabilities(), key, |
409 init_value->CreateDeepCopy(), true); | 410 init_value->CreateDeepCopy(), true); |
410 | 411 |
411 // 2nd call | 412 // 2nd call |
412 capabilities()->SetCapability(key, GetSampleDefaultCapabilityNewValue()); | 413 capabilities()->SetCapability(key, GetSampleDefaultCapabilityNewValue()); |
413 | 414 |
414 // Observer should not get called when value does not change | 415 // Observer should not get called when value does not change |
415 capabilities()->SetCapability(key, GetSampleDefaultCapabilityNewValue()); | 416 capabilities()->SetCapability(key, GetSampleDefaultCapabilityNewValue()); |
416 | 417 |
417 // 3rd call | 418 // 3rd call |
418 capabilities()->SetCapability(key, std::move(init_value)); | 419 capabilities()->SetCapability(key, std::move(init_value)); |
419 base::RunLoop().RunUntilIdle(); | 420 base::RunLoop().RunUntilIdle(); |
420 } | 421 } |
421 | 422 |
422 // Test adding dynamic capabilities | 423 // Test adding dynamic capabilities |
423 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDynamic) { | 424 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDynamic) { |
424 std::string key; | 425 std::string key; |
425 scoped_ptr<base::Value> init_value; | 426 std::unique_ptr<base::Value> init_value; |
426 GetSampleDynamicCapability(&key, &init_value); | 427 GetSampleDynamicCapability(&key, &init_value); |
427 | 428 |
428 ASSERT_FALSE(capabilities()->GetCapability(key)); | 429 ASSERT_FALSE(capabilities()->GetCapability(key)); |
429 capabilities()->SetCapability(key, init_value->CreateDeepCopy()); | 430 capabilities()->SetCapability(key, init_value->CreateDeepCopy()); |
430 base::RunLoop().RunUntilIdle(); | 431 base::RunLoop().RunUntilIdle(); |
431 | 432 |
432 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), | 433 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), |
433 init_value.get())); | 434 init_value.get())); |
434 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, | 435 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, |
435 *init_value)); | 436 *init_value)); |
436 | 437 |
437 scoped_ptr<base::Value> new_value = GetSampleDynamicCapabilityNewValue(); | 438 std::unique_ptr<base::Value> new_value = GetSampleDynamicCapabilityNewValue(); |
438 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); | 439 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); |
439 base::RunLoop().RunUntilIdle(); | 440 base::RunLoop().RunUntilIdle(); |
440 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), | 441 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), |
441 new_value.get())); | 442 new_value.get())); |
442 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, | 443 EXPECT_TRUE(JsonStringEquals(capabilities()->GetData()->json_string(), key, |
443 *new_value)); | 444 *new_value)); |
444 } | 445 } |
445 | 446 |
446 // Tests that SetCapability() works with expanded paths when there is a | 447 // Tests that SetCapability() works with expanded paths when there is a |
447 // capability of type DictionaryValue. | 448 // capability of type DictionaryValue. |
448 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionary) { | 449 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionary) { |
449 std::string key("dummy_dictionary_key"); | 450 std::string key("dummy_dictionary_key"); |
450 scoped_ptr<base::Value> init_value = | 451 std::unique_ptr<base::Value> init_value = |
451 DeserializeFromJson(kSampleDictionaryCapability); | 452 DeserializeFromJson(kSampleDictionaryCapability); |
452 ASSERT_TRUE(init_value); | 453 ASSERT_TRUE(init_value); |
453 FakeCapabilityManagerSimple manager(capabilities(), key, | 454 FakeCapabilityManagerSimple manager(capabilities(), key, |
454 std::move(init_value), true); | 455 std::move(init_value), true); |
455 | 456 |
456 capabilities()->SetCapability( | 457 capabilities()->SetCapability( |
457 "dummy_dictionary_key.dummy_field_bool", | 458 "dummy_dictionary_key.dummy_field_bool", |
458 make_scoped_ptr(new base::FundamentalValue(false))); | 459 base::WrapUnique(new base::FundamentalValue(false))); |
459 base::RunLoop().RunUntilIdle(); | 460 base::RunLoop().RunUntilIdle(); |
460 bool value_bool = true; | 461 bool value_bool = true; |
461 scoped_ptr<base::Value> value = | 462 std::unique_ptr<base::Value> value = |
462 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); | 463 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); |
463 ASSERT_TRUE(value); | 464 ASSERT_TRUE(value); |
464 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); | 465 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); |
465 EXPECT_FALSE(value_bool); | 466 EXPECT_FALSE(value_bool); |
466 | 467 |
467 capabilities()->SetCapability( | 468 capabilities()->SetCapability( |
468 "dummy_dictionary_key.dummy_field_int", | 469 "dummy_dictionary_key.dummy_field_int", |
469 make_scoped_ptr(new base::FundamentalValue(100))); | 470 base::WrapUnique(new base::FundamentalValue(100))); |
470 base::RunLoop().RunUntilIdle(); | 471 base::RunLoop().RunUntilIdle(); |
471 int value_int = 0; | 472 int value_int = 0; |
472 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); | 473 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); |
473 ASSERT_TRUE(value); | 474 ASSERT_TRUE(value); |
474 EXPECT_TRUE(value->GetAsInteger(&value_int)); | 475 EXPECT_TRUE(value->GetAsInteger(&value_int)); |
475 EXPECT_EQ(value_int, 100); | 476 EXPECT_EQ(value_int, 100); |
476 } | 477 } |
477 | 478 |
478 // Tests that SetCapability() works with expanded paths when there is a | 479 // Tests that SetCapability() works with expanded paths when there is a |
479 // capability of type DictionaryValue and invalid changes are proposed. | 480 // capability of type DictionaryValue and invalid changes are proposed. |
480 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionaryInvalid) { | 481 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionaryInvalid) { |
481 std::string key("dummy_dictionary_key"); | 482 std::string key("dummy_dictionary_key"); |
482 scoped_ptr<base::Value> init_value = | 483 std::unique_ptr<base::Value> init_value = |
483 DeserializeFromJson(kSampleDictionaryCapability); | 484 DeserializeFromJson(kSampleDictionaryCapability); |
484 ASSERT_TRUE(init_value); | 485 ASSERT_TRUE(init_value); |
485 FakeCapabilityManagerSimple manager(capabilities(), key, | 486 FakeCapabilityManagerSimple manager(capabilities(), key, |
486 std::move(init_value), false); | 487 std::move(init_value), false); |
487 | 488 |
488 capabilities()->SetCapability( | 489 capabilities()->SetCapability( |
489 "dummy_dictionary_key.dummy_field_bool", | 490 "dummy_dictionary_key.dummy_field_bool", |
490 make_scoped_ptr(new base::FundamentalValue(false))); | 491 base::WrapUnique(new base::FundamentalValue(false))); |
491 base::RunLoop().RunUntilIdle(); | 492 base::RunLoop().RunUntilIdle(); |
492 bool value_bool = false; | 493 bool value_bool = false; |
493 scoped_ptr<base::Value> value = | 494 std::unique_ptr<base::Value> value = |
494 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); | 495 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); |
495 ASSERT_TRUE(value); | 496 ASSERT_TRUE(value); |
496 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); | 497 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); |
497 EXPECT_TRUE(value_bool); | 498 EXPECT_TRUE(value_bool); |
498 | 499 |
499 capabilities()->SetCapability( | 500 capabilities()->SetCapability( |
500 "dummy_dictionary_key.dummy_field_int", | 501 "dummy_dictionary_key.dummy_field_int", |
501 make_scoped_ptr(new base::FundamentalValue(100))); | 502 base::WrapUnique(new base::FundamentalValue(100))); |
502 base::RunLoop().RunUntilIdle(); | 503 base::RunLoop().RunUntilIdle(); |
503 int value_int = 0; | 504 int value_int = 0; |
504 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); | 505 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); |
505 ASSERT_TRUE(value); | 506 ASSERT_TRUE(value); |
506 EXPECT_TRUE(value->GetAsInteger(&value_int)); | 507 EXPECT_TRUE(value->GetAsInteger(&value_int)); |
507 EXPECT_EQ(value_int, 99); | 508 EXPECT_EQ(value_int, 99); |
508 } | 509 } |
509 | 510 |
510 // Test MergeDictionary. | 511 // Test MergeDictionary. |
511 TEST_F(DeviceCapabilitiesImplTest, MergeDictionary) { | 512 TEST_F(DeviceCapabilitiesImplTest, MergeDictionary) { |
512 scoped_ptr<base::Value> deserialized_value = | 513 std::unique_ptr<base::Value> deserialized_value = |
513 DeserializeFromJson(kSampleDictionaryCapability); | 514 DeserializeFromJson(kSampleDictionaryCapability); |
514 ASSERT_TRUE(deserialized_value); | 515 ASSERT_TRUE(deserialized_value); |
515 base::DictionaryValue* dict_value = nullptr; | 516 base::DictionaryValue* dict_value = nullptr; |
516 ASSERT_TRUE(deserialized_value->GetAsDictionary(&dict_value)); | 517 ASSERT_TRUE(deserialized_value->GetAsDictionary(&dict_value)); |
517 ASSERT_TRUE(dict_value); | 518 ASSERT_TRUE(dict_value); |
518 | 519 |
519 capabilities()->MergeDictionary(*dict_value); | 520 capabilities()->MergeDictionary(*dict_value); |
520 base::RunLoop().RunUntilIdle(); | 521 base::RunLoop().RunUntilIdle(); |
521 | 522 |
522 // First make sure that capabilities get created if they do not exist | 523 // First make sure that capabilities get created if they do not exist |
523 bool value_bool = false; | 524 bool value_bool = false; |
524 scoped_ptr<base::Value> value = | 525 std::unique_ptr<base::Value> value = |
525 capabilities()->GetCapability("dummy_field_bool"); | 526 capabilities()->GetCapability("dummy_field_bool"); |
526 ASSERT_TRUE(value); | 527 ASSERT_TRUE(value); |
527 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); | 528 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); |
528 EXPECT_TRUE(value_bool); | 529 EXPECT_TRUE(value_bool); |
529 | 530 |
530 int value_int = 0; | 531 int value_int = 0; |
531 value = capabilities()->GetCapability("dummy_field_int"); | 532 value = capabilities()->GetCapability("dummy_field_int"); |
532 ASSERT_TRUE(value); | 533 ASSERT_TRUE(value); |
533 EXPECT_TRUE(value->GetAsInteger(&value_int)); | 534 EXPECT_TRUE(value->GetAsInteger(&value_int)); |
534 EXPECT_EQ(value_int, 99); | 535 EXPECT_EQ(value_int, 99); |
(...skipping 19 matching lines...) Expand all Loading... |
554 } | 555 } |
555 | 556 |
556 // Tests that it is safe to call DeviceCapabilities methods in | 557 // Tests that it is safe to call DeviceCapabilities methods in |
557 // an Observer's OnCapabilitiesChanged() implementation safely with correct | 558 // an Observer's OnCapabilitiesChanged() implementation safely with correct |
558 // behavior and without deadlocking. | 559 // behavior and without deadlocking. |
559 TEST_F(DeviceCapabilitiesImplTest, OnCapabilitiesChangedSafe) { | 560 TEST_F(DeviceCapabilitiesImplTest, OnCapabilitiesChangedSafe) { |
560 FakeCapabilitiesObserver observer(capabilities()); | 561 FakeCapabilitiesObserver observer(capabilities()); |
561 | 562 |
562 // Trigger FakeCapabilitiesObserver::OnCapabilitiesChanged() | 563 // Trigger FakeCapabilitiesObserver::OnCapabilitiesChanged() |
563 capabilities()->SetCapability( | 564 capabilities()->SetCapability( |
564 "dummy_trigger_key", make_scoped_ptr(new base::FundamentalValue(true))); | 565 "dummy_trigger_key", base::WrapUnique(new base::FundamentalValue(true))); |
565 base::RunLoop().RunUntilIdle(); | 566 base::RunLoop().RunUntilIdle(); |
566 | 567 |
567 // Check that FakeCapabilitiesObserver::OnCapabilitiesChanged() ran and that | 568 // Check that FakeCapabilitiesObserver::OnCapabilitiesChanged() ran and that |
568 // behavior was successful | 569 // behavior was successful |
569 AssertBasicOperationsSuccessful(capabilities()); | 570 AssertBasicOperationsSuccessful(capabilities()); |
570 } | 571 } |
571 | 572 |
572 // Tests that it is safe to call DeviceCapabilities methods in a Validator's | 573 // Tests that it is safe to call DeviceCapabilities methods in a Validator's |
573 // Validate() implementation safely with correct behavior and without | 574 // Validate() implementation safely with correct behavior and without |
574 // deadlocking. | 575 // deadlocking. |
575 TEST_F(DeviceCapabilitiesImplTest, ValidateSafe) { | 576 TEST_F(DeviceCapabilitiesImplTest, ValidateSafe) { |
576 FakeCapabilityManagerComplex manager(capabilities(), "dummy_validate_key"); | 577 FakeCapabilityManagerComplex manager(capabilities(), "dummy_validate_key"); |
577 | 578 |
578 // Trigger FakeCapabilityManagerComplex::Validate() | 579 // Trigger FakeCapabilityManagerComplex::Validate() |
579 capabilities()->SetCapability( | 580 capabilities()->SetCapability( |
580 "dummy_validate_key", make_scoped_ptr(new base::FundamentalValue(true))); | 581 "dummy_validate_key", base::WrapUnique(new base::FundamentalValue(true))); |
581 base::RunLoop().RunUntilIdle(); | 582 base::RunLoop().RunUntilIdle(); |
582 | 583 |
583 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior | 584 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior |
584 // was successful | 585 // was successful |
585 AssertBasicOperationsSuccessful(capabilities()); | 586 AssertBasicOperationsSuccessful(capabilities()); |
586 } | 587 } |
587 | 588 |
588 } // namespace chromecast | 589 } // namespace chromecast |
OLD | NEW |