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

Side by Side Diff: chrome/browser/supervised_user/legacy/supervised_user_sync_service_unittest.cc

Issue 2888073002: Remove raw DictionaryValue::Set in //chrome (Closed)
Patch Set: Fix Tests Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/ptr_util.h"
10 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
15 #include "base/values.h"
13 #include "build/build_config.h" 16 #include "build/build_config.h"
14 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" 17 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
15 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_fac tory.h" 18 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_fac tory.h"
16 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
17 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
18 #include "components/prefs/scoped_user_pref_update.h" 21 #include "components/prefs/scoped_user_pref_update.h"
19 #include "components/sync/model/attachments/attachment_id.h" 22 #include "components/sync/model/attachments/attachment_id.h"
20 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" 23 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h"
21 #include "components/sync/model/sync_change.h" 24 #include "components/sync/model/sync_change.h"
22 #include "components/sync/model/sync_error_factory_mock.h" 25 #include "components/sync/model/sync_error_factory_mock.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 const char kAvatar2[] = "chromeos-avatar-index:0"; 191 const char kAvatar2[] = "chromeos-avatar-index:0";
189 const char kAvatar3[] = "chromeos-avatar-index:20"; 192 const char kAvatar3[] = "chromeos-avatar-index:20";
190 #else 193 #else
191 const char kAvatar2[] = "chrome-avatar-index:0"; 194 const char kAvatar2[] = "chrome-avatar-index:0";
192 const char kAvatar3[] = "chrome-avatar-index:20"; 195 const char kAvatar3[] = "chrome-avatar-index:20";
193 #endif 196 #endif
194 const char kAvatar4[] = ""; 197 const char kAvatar4[] = "";
195 { 198 {
196 DictionaryPrefUpdate update(prefs(), prefs::kSupervisedUsers); 199 DictionaryPrefUpdate update(prefs(), prefs::kSupervisedUsers);
197 base::DictionaryValue* supervised_users = update.Get(); 200 base::DictionaryValue* supervised_users = update.Get();
198 base::DictionaryValue* dict = new base::DictionaryValue; 201 auto dict = base::MakeUnique<base::DictionaryValue>();
199 dict->SetString(kNameKey, kName1); 202 dict->SetString(kNameKey, kName1);
200 supervised_users->Set(kUserId1, dict); 203 supervised_users->Set(kUserId1, std::move(dict));
201 dict = new base::DictionaryValue; 204 dict = base::MakeUnique<base::DictionaryValue>();
202 dict->SetString(kNameKey, kName2); 205 dict->SetString(kNameKey, kName2);
203 dict->SetBoolean(kAcknowledgedKey, true); 206 dict->SetBoolean(kAcknowledgedKey, true);
204 supervised_users->Set(kUserId2, dict); 207 supervised_users->Set(kUserId2, std::move(dict));
205 } 208 }
206 209
207 const base::DictionaryValue* async_supervised_users = NULL; 210 const base::DictionaryValue* async_supervised_users = NULL;
208 service()->GetSupervisedUsersAsync( 211 service()->GetSupervisedUsersAsync(
209 base::Bind(&GetSupervisedUsersCallback, &async_supervised_users)); 212 base::Bind(&GetSupervisedUsersCallback, &async_supervised_users));
210 213
211 SyncDataList initial_sync_data; 214 SyncDataList initial_sync_data;
212 initial_sync_data.push_back(CreateRemoteData(kUserId2, kName2, kAvatar2)); 215 initial_sync_data.push_back(CreateRemoteData(kUserId2, kName2, kAvatar2));
213 initial_sync_data.push_back(CreateRemoteData(kUserId3, kName3, kAvatar3)); 216 initial_sync_data.push_back(CreateRemoteData(kUserId3, kName3, kAvatar3));
214 initial_sync_data.push_back(CreateRemoteData(kUserId4, kName4, kAvatar4)); 217 initial_sync_data.push_back(CreateRemoteData(kUserId4, kName4, kAvatar4));
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 364
362 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex( 365 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
363 "chrome-avatar-index:x", 366 "chrome-avatar-index:x",
364 &avatar)); 367 &avatar));
365 368
366 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex( 369 EXPECT_FALSE(SupervisedUserSyncService::GetAvatarIndex(
367 "chromeos-avatar-index:5", 370 "chromeos-avatar-index:5",
368 &avatar)); 371 &avatar));
369 #endif 372 #endif
370 } 373 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698