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

Side by Side Diff: ios/chrome/browser/notification_promo_unittest.cc

Issue 2911033002: Remove raw base::DictionaryValue::Set (Closed)
Patch Set: Proper Windows Fix Created 3 years, 6 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
« no previous file with comments | « ios/chrome/browser/notification_promo.cc ('k') | ios/chrome/browser/ui/webui/flags_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/test/mock_entropy_provider.h" 17 #include "base/test/mock_entropy_provider.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 int views = max_views_ + 1; 297 int views = max_views_ + 1;
297 bool closed = true; 298 bool closed = true;
298 299
299 // Save data into old prefs structure. 300 // Save data into old prefs structure.
300 auto ntp_promo = base::MakeUnique<base::DictionaryValue>(); 301 auto ntp_promo = base::MakeUnique<base::DictionaryValue>();
301 ntp_promo->SetInteger("id", promo.promo_id_); 302 ntp_promo->SetInteger("id", promo.promo_id_);
302 ntp_promo->SetDouble("first_view_time", first_view_time); 303 ntp_promo->SetDouble("first_view_time", first_view_time);
303 ntp_promo->SetInteger("views", views); 304 ntp_promo->SetInteger("views", views);
304 ntp_promo->SetBoolean("closed", true); 305 ntp_promo->SetBoolean("closed", true);
305 306
306 base::ListValue* promo_list = new base::ListValue; 307 auto promo_list = base::MakeUnique<base::ListValue>();
307 promo_list->Append(std::move(ntp_promo)); 308 promo_list->Append(std::move(ntp_promo));
308 309
309 std::string promo_list_key = "mobile_ntp_whats_new_promo"; 310 std::string promo_list_key = "mobile_ntp_whats_new_promo";
310 std::string promo_dict_key = "ios.ntppromo"; 311 std::string promo_dict_key = "ios.ntppromo";
311 312
312 base::DictionaryValue promo_dict; 313 base::DictionaryValue promo_dict;
313 promo_dict.Set(promo_list_key, promo_list); 314 promo_dict.Set(promo_list_key, std::move(promo_list));
314 local_state_.Set(promo_dict_key, promo_dict); 315 local_state_.Set(promo_dict_key, promo_dict);
315 316
316 // Initialize promo and verify that its instance variables match the data 317 // Initialize promo and verify that its instance variables match the data
317 // saved in the old structure. 318 // saved in the old structure.
318 promo.InitFromPrefs(); 319 promo.InitFromPrefs();
319 EXPECT_DOUBLE_EQ(first_view_time, promo.first_view_time_); 320 EXPECT_DOUBLE_EQ(first_view_time, promo.first_view_time_);
320 EXPECT_EQ(views, promo.views_); 321 EXPECT_EQ(views, promo.views_);
321 EXPECT_EQ(closed, promo.closed_); 322 EXPECT_EQ(closed, promo.closed_);
322 EXPECT_FALSE(promo.CanShow()); 323 EXPECT_FALSE(promo.CanShow());
323 324
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 " \"promo_id\":0" 436 " \"promo_id\":0"
436 "}", 437 "}",
437 "What do you think of Chrome?", 438 "What do you think of Chrome?",
438 933672366, // unix epoch for 3 Aug 1999 9:26:06 GMT. 439 933672366, // unix epoch for 3 Aug 1999 9:26:06 GMT.
439 0, 30, 30); 440 0, 30, 30);
440 InitPromoFromVariations(); 441 InitPromoFromVariations();
441 TestMigrationOfOldPrefs(); 442 TestMigrationOfOldPrefs();
442 } 443 }
443 444
444 } // namespace ios 445 } // namespace ios
OLDNEW
« no previous file with comments | « ios/chrome/browser/notification_promo.cc ('k') | ios/chrome/browser/ui/webui/flags_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698