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

Side by Side Diff: chrome/browser/chromeos/printing/printers_manager_unittest.cc

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 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 2016 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/chromeos/printing/printers_manager.h" 5 #include "chrome/browser/chromeos/printing/printers_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 std::string second_printer = kLexJson; 190 std::string second_printer = kLexJson;
191 191
192 auto value = base::MakeUnique<base::ListValue>(); 192 auto value = base::MakeUnique<base::ListValue>();
193 value->AppendString(first_printer); 193 value->AppendString(first_printer);
194 value->AppendString(second_printer); 194 value->AppendString(second_printer);
195 195
196 sync_preferences::TestingPrefServiceSyncable* prefs = 196 sync_preferences::TestingPrefServiceSyncable* prefs =
197 profile_->GetTestingPrefService(); 197 profile_->GetTestingPrefService();
198 // TestingPrefSyncableService assumes ownership of |value|. 198 // TestingPrefSyncableService assumes ownership of |value|.
199 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, value.release()); 199 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, std::move(value));
200 200
201 auto printers = manager_->GetRecommendedPrinters(); 201 auto printers = manager_->GetRecommendedPrinters();
202 ASSERT_EQ(2U, printers.size()); 202 ASSERT_EQ(2U, printers.size());
203 EXPECT_EQ("Color Laser", printers[0]->display_name()); 203 EXPECT_EQ("Color Laser", printers[0]->display_name());
204 EXPECT_EQ("ipp://192.168.1.5", printers[1]->uri()); 204 EXPECT_EQ("ipp://192.168.1.5", printers[1]->uri());
205 EXPECT_EQ(Printer::Source::SRC_POLICY, printers[1]->source()); 205 EXPECT_EQ(Printer::Source::SRC_POLICY, printers[1]->source());
206 } 206 }
207 207
208 TEST_F(PrintersManagerTest, GetRecommendedPrinter) { 208 TEST_F(PrintersManagerTest, GetRecommendedPrinter) {
209 std::string printer = kLexJson; 209 std::string printer = kLexJson;
210 auto value = base::MakeUnique<base::ListValue>(); 210 auto value = base::MakeUnique<base::ListValue>();
211 value->AppendString(printer); 211 value->AppendString(printer);
212 212
213 sync_preferences::TestingPrefServiceSyncable* prefs = 213 sync_preferences::TestingPrefServiceSyncable* prefs =
214 profile_->GetTestingPrefService(); 214 profile_->GetTestingPrefService();
215 // TestingPrefSyncableService assumes ownership of |value|. 215 // TestingPrefSyncableService assumes ownership of |value|.
216 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, value.release()); 216 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, std::move(value));
217 217
218 auto printers = manager_->GetRecommendedPrinters(); 218 auto printers = manager_->GetRecommendedPrinters();
219 219
220 const Printer& from_list = *(printers.front()); 220 const Printer& from_list = *(printers.front());
221 std::unique_ptr<Printer> retrieved = manager_->GetPrinter(from_list.id()); 221 std::unique_ptr<Printer> retrieved = manager_->GetPrinter(from_list.id());
222 222
223 EXPECT_EQ(from_list.id(), retrieved->id()); 223 EXPECT_EQ(from_list.id(), retrieved->id());
224 EXPECT_EQ("LexaPrint", from_list.display_name()); 224 EXPECT_EQ("LexaPrint", from_list.display_name());
225 EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source()); 225 EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source());
226 } 226 }
227 227
228 } // namespace chromeos 228 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698