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

Side by Side Diff: chromecast/base/device_capabilities_impl_unittest.cc

Issue 2258493003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 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"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 DISALLOW_COPY_AND_ASSIGN(MockCapabilitiesObserver); 146 DISALLOW_COPY_AND_ASSIGN(MockCapabilitiesObserver);
147 }; 147 };
148 148
149 // Test fixtures needs an example default capability to test DeviceCapabilities 149 // Test fixtures needs an example default capability to test DeviceCapabilities
150 // methods. Gets a sample key and initial value. 150 // methods. Gets a sample key and initial value.
151 void GetSampleDefaultCapability(std::string* key, 151 void GetSampleDefaultCapability(std::string* key,
152 std::unique_ptr<base::Value>* init_value) { 152 std::unique_ptr<base::Value>* init_value) {
153 DCHECK(key); 153 DCHECK(key);
154 DCHECK(init_value); 154 DCHECK(init_value);
155 *key = DeviceCapabilities::kKeyBluetoothSupported; 155 *key = DeviceCapabilities::kKeyBluetoothSupported;
156 *init_value = base::WrapUnique(new base::FundamentalValue(true)); 156 *init_value = base::MakeUnique<base::FundamentalValue>(true);
157 } 157 }
158 158
159 // For test fixtures that test dynamic capabilities, gets a sample key 159 // For test fixtures that test dynamic capabilities, gets a sample key
160 // and initial value. 160 // and initial value.
161 void GetSampleDynamicCapability(std::string* key, 161 void GetSampleDynamicCapability(std::string* key,
162 std::unique_ptr<base::Value>* init_value) { 162 std::unique_ptr<base::Value>* init_value) {
163 DCHECK(key); 163 DCHECK(key);
164 DCHECK(init_value); 164 DCHECK(init_value);
165 *key = "dummy_dynamic_key"; 165 *key = "dummy_dynamic_key";
166 *init_value = base::WrapUnique(new base::FundamentalValue(99)); 166 *init_value = base::MakeUnique<base::FundamentalValue>(99);
167 } 167 }
168 168
169 // Gets a value for sample default capability different from |init_value| 169 // Gets a value for sample default capability different from |init_value|
170 // returned in GetSampleDefaultCapability(). Must be of same type as 170 // returned in GetSampleDefaultCapability(). Must be of same type as
171 // |init_value| of course. 171 // |init_value| of course.
172 std::unique_ptr<base::Value> GetSampleDefaultCapabilityNewValue() { 172 std::unique_ptr<base::Value> GetSampleDefaultCapabilityNewValue() {
173 return base::WrapUnique(new base::FundamentalValue(false)); 173 return base::MakeUnique<base::FundamentalValue>(false);
174 } 174 }
175 175
176 // Gets a value for sample dynamic capability different from |init_value| 176 // Gets a value for sample dynamic capability different from |init_value|
177 // returned in GetSampleDynamicCapability(). Must be of same type as 177 // returned in GetSampleDynamicCapability(). Must be of same type as
178 // |init_value| of course. 178 // |init_value| of course.
179 std::unique_ptr<base::Value> GetSampleDynamicCapabilityNewValue() { 179 std::unique_ptr<base::Value> GetSampleDynamicCapabilityNewValue() {
180 return base::WrapUnique(new base::FundamentalValue(100)); 180 return base::MakeUnique<base::FundamentalValue>(100);
181 } 181 }
182 182
183 // Tests that |json| string matches contents of a DictionaryValue with one entry 183 // Tests that |json| string matches contents of a DictionaryValue with one entry
184 // specified by |key| and |value|. 184 // specified by |key| and |value|.
185 bool JsonStringEquals(const std::string& json, 185 bool JsonStringEquals(const std::string& json,
186 const std::string& key, 186 const std::string& key,
187 const base::Value& value) { 187 const base::Value& value) {
188 base::DictionaryValue dict_value; 188 base::DictionaryValue dict_value;
189 dict_value.Set(key, value.CreateDeepCopy()); 189 dict_value.Set(key, value.CreateDeepCopy());
190 std::unique_ptr<const std::string> dict_json(SerializeToJson(dict_value)); 190 std::unique_ptr<const std::string> dict_json(SerializeToJson(dict_value));
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 capabilities()->SetCapability( 683 capabilities()->SetCapability(
684 "dummy_validate_key", base::WrapUnique(new base::FundamentalValue(true))); 684 "dummy_validate_key", base::WrapUnique(new base::FundamentalValue(true)));
685 base::RunLoop().RunUntilIdle(); 685 base::RunLoop().RunUntilIdle();
686 686
687 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior 687 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior
688 // was successful 688 // was successful
689 AssertBasicOperationsSuccessful(capabilities()); 689 AssertBasicOperationsSuccessful(capabilities());
690 } 690 }
691 691
692 } // namespace chromecast 692 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/base/device_capabilities_impl.cc ('k') | chromecast/browser/cast_browser_main_parts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698