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

Side by Side Diff: components/signin/core/browser/account_tracker_service_unittest.cc

Issue 2287733002: Switch //components away from base::ListValue::Append(Value*) overload. (Closed)
Patch Set: rebase Created 4 years, 3 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 <algorithm> 5 #include <algorithm>
6 #include <memory>
7 #include <utility>
6 #include <vector> 8 #include <vector>
7 9
8 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
9 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
10 #include "components/prefs/pref_registry_simple.h" 12 #include "components/prefs/pref_registry_simple.h"
11 #include "components/prefs/scoped_user_pref_update.h" 13 #include "components/prefs/scoped_user_pref_update.h"
12 #include "components/prefs/testing_pref_service.h" 14 #include "components/prefs/testing_pref_service.h"
13 #include "components/signin/core/browser/account_fetcher_service.h" 15 #include "components/signin/core/browser/account_fetcher_service.h"
14 #include "components/signin/core/browser/account_info.h" 16 #include "components/signin/core/browser/account_info.h"
15 #include "components/signin/core/browser/account_tracker_service.h" 17 #include "components/signin/core/browser/account_tracker_service.h"
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 std::string email_beta = AccountIdToEmail("beta"); 900 std::string email_beta = AccountIdToEmail("beta");
899 std::string gaia_beta = AccountIdToGaiaId("beta"); 901 std::string gaia_beta = AccountIdToGaiaId("beta");
900 902
901 pref.registry()->RegisterListPref(AccountTrackerService::kAccountInfoPref); 903 pref.registry()->RegisterListPref(AccountTrackerService::kAccountInfoPref);
902 pref.registry()->RegisterIntegerPref( 904 pref.registry()->RegisterIntegerPref(
903 prefs::kAccountIdMigrationState, 905 prefs::kAccountIdMigrationState,
904 AccountTrackerService::MIGRATION_NOT_STARTED); 906 AccountTrackerService::MIGRATION_NOT_STARTED);
905 907
906 ListPrefUpdate update(&pref, AccountTrackerService::kAccountInfoPref); 908 ListPrefUpdate update(&pref, AccountTrackerService::kAccountInfoPref);
907 909
908 base::DictionaryValue* dict = new base::DictionaryValue(); 910 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
909 update->Append(dict);
910 dict->SetString("account_id", base::UTF8ToUTF16(email_alpha)); 911 dict->SetString("account_id", base::UTF8ToUTF16(email_alpha));
911 dict->SetString("email", base::UTF8ToUTF16(email_alpha)); 912 dict->SetString("email", base::UTF8ToUTF16(email_alpha));
912 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha)); 913 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha));
914 update->Append(std::move(dict));
913 915
914 dict = new base::DictionaryValue(); 916 dict.reset(new base::DictionaryValue());
915 update->Append(dict);
916 dict->SetString("account_id", base::UTF8ToUTF16(email_beta)); 917 dict->SetString("account_id", base::UTF8ToUTF16(email_beta));
917 dict->SetString("email", base::UTF8ToUTF16(email_beta)); 918 dict->SetString("email", base::UTF8ToUTF16(email_beta));
918 dict->SetString("gaia", base::UTF8ToUTF16(gaia_beta)); 919 dict->SetString("gaia", base::UTF8ToUTF16(gaia_beta));
920 update->Append(std::move(dict));
919 921
920 std::unique_ptr<TestSigninClient> client; 922 std::unique_ptr<TestSigninClient> client;
921 client.reset(new TestSigninClient(&pref)); 923 client.reset(new TestSigninClient(&pref));
922 tracker.Initialize(client.get()); 924 tracker.Initialize(client.get());
923 925
924 ASSERT_EQ(tracker.GetMigrationState(), 926 ASSERT_EQ(tracker.GetMigrationState(),
925 AccountTrackerService::MIGRATION_IN_PROGRESS); 927 AccountTrackerService::MIGRATION_IN_PROGRESS);
926 928
927 account_info = tracker.GetAccountInfo(gaia_alpha); 929 account_info = tracker.GetAccountInfo(gaia_alpha);
928 ASSERT_EQ(account_info.account_id, gaia_alpha); 930 ASSERT_EQ(account_info.account_id, gaia_alpha);
(...skipping 21 matching lines...) Expand all
950 std::string gaia_alpha = AccountIdToGaiaId("alpha"); 952 std::string gaia_alpha = AccountIdToGaiaId("alpha");
951 std::string email_beta = AccountIdToEmail("beta"); 953 std::string email_beta = AccountIdToEmail("beta");
952 954
953 pref.registry()->RegisterListPref(AccountTrackerService::kAccountInfoPref); 955 pref.registry()->RegisterListPref(AccountTrackerService::kAccountInfoPref);
954 pref.registry()->RegisterIntegerPref( 956 pref.registry()->RegisterIntegerPref(
955 prefs::kAccountIdMigrationState, 957 prefs::kAccountIdMigrationState,
956 AccountTrackerService::MIGRATION_NOT_STARTED); 958 AccountTrackerService::MIGRATION_NOT_STARTED);
957 959
958 ListPrefUpdate update(&pref, AccountTrackerService::kAccountInfoPref); 960 ListPrefUpdate update(&pref, AccountTrackerService::kAccountInfoPref);
959 961
960 base::DictionaryValue* dict = new base::DictionaryValue(); 962 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
961 update->Append(dict);
danakj 2016/08/26 22:59:24 this append got lost
dcheng 2016/08/26 23:03:38 Fixed this already in PS3 =)
962 dict->SetString("account_id", base::UTF8ToUTF16(email_alpha)); 963 dict->SetString("account_id", base::UTF8ToUTF16(email_alpha));
963 dict->SetString("email", base::UTF8ToUTF16(email_alpha)); 964 dict->SetString("email", base::UTF8ToUTF16(email_alpha));
964 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha)); 965 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha));
965 966
966 dict = new base::DictionaryValue(); 967 dict.reset(new base::DictionaryValue());
967 update->Append(dict);
968 dict->SetString("account_id", base::UTF8ToUTF16(email_beta)); 968 dict->SetString("account_id", base::UTF8ToUTF16(email_beta));
969 dict->SetString("email", base::UTF8ToUTF16(email_beta)); 969 dict->SetString("email", base::UTF8ToUTF16(email_beta));
970 dict->SetString("gaia", base::UTF8ToUTF16(std::string())); 970 dict->SetString("gaia", base::UTF8ToUTF16(std::string()));
971 update->Append(std::move(dict));
971 972
972 std::unique_ptr<TestSigninClient> client; 973 std::unique_ptr<TestSigninClient> client;
973 client.reset(new TestSigninClient(&pref)); 974 client.reset(new TestSigninClient(&pref));
974 tracker.Initialize(client.get()); 975 tracker.Initialize(client.get());
975 976
976 ASSERT_EQ(tracker.GetMigrationState(), 977 ASSERT_EQ(tracker.GetMigrationState(),
977 AccountTrackerService::MIGRATION_NOT_STARTED); 978 AccountTrackerService::MIGRATION_NOT_STARTED);
978 979
979 account_info = tracker.GetAccountInfo(email_alpha); 980 account_info = tracker.GetAccountInfo(email_alpha);
980 ASSERT_EQ(account_info.account_id, email_alpha); 981 ASSERT_EQ(account_info.account_id, email_alpha);
(...skipping 21 matching lines...) Expand all
1002 std::string email_beta = AccountIdToEmail("beta"); 1003 std::string email_beta = AccountIdToEmail("beta");
1003 std::string gaia_beta = AccountIdToGaiaId("beta"); 1004 std::string gaia_beta = AccountIdToGaiaId("beta");
1004 1005
1005 pref.registry()->RegisterListPref(AccountTrackerService::kAccountInfoPref); 1006 pref.registry()->RegisterListPref(AccountTrackerService::kAccountInfoPref);
1006 pref.registry()->RegisterIntegerPref( 1007 pref.registry()->RegisterIntegerPref(
1007 prefs::kAccountIdMigrationState, 1008 prefs::kAccountIdMigrationState,
1008 AccountTrackerService::MIGRATION_IN_PROGRESS); 1009 AccountTrackerService::MIGRATION_IN_PROGRESS);
1009 1010
1010 ListPrefUpdate update(&pref, AccountTrackerService::kAccountInfoPref); 1011 ListPrefUpdate update(&pref, AccountTrackerService::kAccountInfoPref);
1011 1012
1012 base::DictionaryValue* dict = new base::DictionaryValue(); 1013 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
1013 update->Append(dict);
1014 dict->SetString("account_id", base::UTF8ToUTF16(email_alpha)); 1014 dict->SetString("account_id", base::UTF8ToUTF16(email_alpha));
1015 dict->SetString("email", base::UTF8ToUTF16(email_alpha)); 1015 dict->SetString("email", base::UTF8ToUTF16(email_alpha));
1016 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha)); 1016 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha));
1017 update->Append(std::move(dict));
1017 1018
1018 dict = new base::DictionaryValue(); 1019 dict.reset(new base::DictionaryValue());
1019 update->Append(dict);
1020 dict->SetString("account_id", base::UTF8ToUTF16(email_beta)); 1020 dict->SetString("account_id", base::UTF8ToUTF16(email_beta));
1021 dict->SetString("email", base::UTF8ToUTF16(email_beta)); 1021 dict->SetString("email", base::UTF8ToUTF16(email_beta));
1022 dict->SetString("gaia", base::UTF8ToUTF16(gaia_beta)); 1022 dict->SetString("gaia", base::UTF8ToUTF16(gaia_beta));
1023 update->Append(std::move(dict));
1023 1024
1024 // Succeed miggrated account. 1025 // Succeed miggrated account.
1025 dict = new base::DictionaryValue(); 1026 dict.reset(new base::DictionaryValue());
1026 update->Append(dict);
1027 dict->SetString("account_id", base::UTF8ToUTF16(gaia_alpha)); 1027 dict->SetString("account_id", base::UTF8ToUTF16(gaia_alpha));
1028 dict->SetString("email", base::UTF8ToUTF16(email_alpha)); 1028 dict->SetString("email", base::UTF8ToUTF16(email_alpha));
1029 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha)); 1029 dict->SetString("gaia", base::UTF8ToUTF16(gaia_alpha));
1030 update->Append(std::move(dict));
1030 1031
1031 std::unique_ptr<TestSigninClient> client; 1032 std::unique_ptr<TestSigninClient> client;
1032 client.reset(new TestSigninClient(&pref)); 1033 client.reset(new TestSigninClient(&pref));
1033 tracker.Initialize(client.get()); 1034 tracker.Initialize(client.get());
1034 1035
1035 ASSERT_EQ(tracker.GetMigrationState(), 1036 ASSERT_EQ(tracker.GetMigrationState(),
1036 AccountTrackerService::MIGRATION_IN_PROGRESS); 1037 AccountTrackerService::MIGRATION_IN_PROGRESS);
1037 1038
1038 account_info = tracker.GetAccountInfo(gaia_alpha); 1039 account_info = tracker.GetAccountInfo(gaia_alpha);
1039 ASSERT_EQ(account_info.account_id, gaia_alpha); 1040 ASSERT_EQ(account_info.account_id, gaia_alpha);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 ASSERT_FALSE(info.is_child_account); 1208 ASSERT_FALSE(info.is_child_account);
1208 ASSERT_TRUE(observer.CheckEvents(TrackingEvent(UPDATED, child_id))); 1209 ASSERT_TRUE(observer.CheckEvents(TrackingEvent(UPDATED, child_id)));
1209 1210
1210 SimulateTokenRevoked(child_id); 1211 SimulateTokenRevoked(child_id);
1211 ASSERT_TRUE(observer.CheckEvents(TrackingEvent(REMOVED, child_id))); 1212 ASSERT_TRUE(observer.CheckEvents(TrackingEvent(REMOVED, child_id)));
1212 1213
1213 tracker.RemoveObserver(&observer); 1214 tracker.RemoveObserver(&observer);
1214 fetcher.Shutdown(); 1215 fetcher.Shutdown();
1215 tracker.Shutdown(); 1216 tracker.Shutdown();
1216 } 1217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698