| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 void TestMigrationOfOldPrefs() { | 290 void TestMigrationOfOldPrefs() { |
| 291 NotificationPromo promo(&local_state_); | 291 NotificationPromo promo(&local_state_); |
| 292 promo.InitFromVariations(); | 292 promo.InitFromVariations(); |
| 293 | 293 |
| 294 // Pick values for each variable that is saved into old prefs structure. | 294 // Pick values for each variable that is saved into old prefs structure. |
| 295 double first_view_time = 2.0; | 295 double first_view_time = 2.0; |
| 296 int views = max_views_ + 1; | 296 int views = max_views_ + 1; |
| 297 bool closed = true; | 297 bool closed = true; |
| 298 | 298 |
| 299 // Save data into old prefs structure. | 299 // Save data into old prefs structure. |
| 300 base::DictionaryValue* ntp_promo = new base::DictionaryValue; | 300 auto ntp_promo = base::MakeUnique<base::DictionaryValue>(); |
| 301 ntp_promo->SetInteger("id", promo.promo_id_); | 301 ntp_promo->SetInteger("id", promo.promo_id_); |
| 302 ntp_promo->SetDouble("first_view_time", first_view_time); | 302 ntp_promo->SetDouble("first_view_time", first_view_time); |
| 303 ntp_promo->SetInteger("views", views); | 303 ntp_promo->SetInteger("views", views); |
| 304 ntp_promo->SetBoolean("closed", true); | 304 ntp_promo->SetBoolean("closed", true); |
| 305 | 305 |
| 306 base::ListValue* promo_list = new base::ListValue; | 306 base::ListValue* promo_list = new base::ListValue; |
| 307 promo_list->Set(0, ntp_promo); | 307 promo_list->Append(std::move(ntp_promo)); |
| 308 | 308 |
| 309 std::string promo_list_key = "mobile_ntp_whats_new_promo"; | 309 std::string promo_list_key = "mobile_ntp_whats_new_promo"; |
| 310 std::string promo_dict_key = "ios.ntppromo"; | 310 std::string promo_dict_key = "ios.ntppromo"; |
| 311 | 311 |
| 312 base::DictionaryValue promo_dict; | 312 base::DictionaryValue promo_dict; |
| 313 promo_dict.Set(promo_list_key, promo_list); | 313 promo_dict.Set(promo_list_key, promo_list); |
| 314 local_state_.Set(promo_dict_key, promo_dict); | 314 local_state_.Set(promo_dict_key, promo_dict); |
| 315 | 315 |
| 316 // Initialize promo and verify that its instance variables match the data | 316 // Initialize promo and verify that its instance variables match the data |
| 317 // saved in the old structure. | 317 // saved in the old structure. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 " \"promo_id\":0" | 435 " \"promo_id\":0" |
| 436 "}", | 436 "}", |
| 437 "What do you think of Chrome?", | 437 "What do you think of Chrome?", |
| 438 933672366, // unix epoch for 3 Aug 1999 9:26:06 GMT. | 438 933672366, // unix epoch for 3 Aug 1999 9:26:06 GMT. |
| 439 0, 30, 30); | 439 0, 30, 30); |
| 440 InitPromoFromVariations(); | 440 InitPromoFromVariations(); |
| 441 TestMigrationOfOldPrefs(); | 441 TestMigrationOfOldPrefs(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 } // namespace ios | 444 } // namespace ios |
| OLD | NEW |