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

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

Issue 2487033002: Use EXPECT_DOUBLE_EQ for doubles in NotificationPromoTest. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | 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 <vector> 8 #include <vector>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 notification_promo_.InitFromJson(*test_json_, promo_type_); 140 notification_promo_.InitFromJson(*test_json_, promo_type_);
141 141
142 // Test the fields. 142 // Test the fields.
143 TestServerProvidedParameters(); 143 TestServerProvidedParameters();
144 } 144 }
145 145
146 void TestServerProvidedParameters() { 146 void TestServerProvidedParameters() {
147 // Check values. 147 // Check values.
148 EXPECT_EQ(notification_promo_.promo_text_, promo_text_); 148 EXPECT_EQ(notification_promo_.promo_text_, promo_text_);
149 149
150 EXPECT_EQ(notification_promo_.start_, start_); 150 EXPECT_DOUBLE_EQ(notification_promo_.start_, start_);
151 EXPECT_EQ(notification_promo_.end_, end_); 151 EXPECT_DOUBLE_EQ(notification_promo_.end_, end_);
152 152
153 EXPECT_EQ(notification_promo_.promo_id_, promo_id_); 153 EXPECT_EQ(notification_promo_.promo_id_, promo_id_);
154 EXPECT_EQ(notification_promo_.max_views_, max_views_); 154 EXPECT_EQ(notification_promo_.max_views_, max_views_);
155 EXPECT_EQ(notification_promo_.max_seconds_, max_seconds_); 155 EXPECT_EQ(notification_promo_.max_seconds_, max_seconds_);
156 } 156 }
157 157
158 void TestViews() { 158 void TestViews() {
159 notification_promo_.views_ = notification_promo_.max_views_ - 2; 159 notification_promo_.views_ = notification_promo_.max_views_ - 2;
160 notification_promo_.WritePrefs(); 160 notification_promo_.WritePrefs();
161 161
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 EXPECT_FALSE(notification_promo_.CanShow()); 268 EXPECT_FALSE(notification_promo_.CanShow());
269 269
270 notification_promo_.first_view_time_ = 0; 270 notification_promo_.first_view_time_ = 0;
271 notification_promo_.max_seconds_ = max_seconds_; 271 notification_promo_.max_seconds_ = max_seconds_;
272 EXPECT_TRUE(notification_promo_.CanShow()); 272 EXPECT_TRUE(notification_promo_.CanShow());
273 } 273 }
274 274
275 // Tests that the first view time is recorded properly in prefs when the 275 // Tests that the first view time is recorded properly in prefs when the
276 // first view occurs. 276 // first view occurs.
277 void TestFirstViewTimeRecorded() { 277 void TestFirstViewTimeRecorded() {
278 EXPECT_EQ(0, notification_promo_.first_view_time_); 278 EXPECT_DOUBLE_EQ(0, notification_promo_.first_view_time_);
279 notification_promo_.HandleViewed(); 279 notification_promo_.HandleViewed();
280 280
281 NotificationPromo temp_promo(&local_state_); 281 NotificationPromo temp_promo(&local_state_);
282 temp_promo.InitFromVariations(); 282 temp_promo.InitFromVariations();
283 temp_promo.InitFromPrefs(promo_type_); 283 temp_promo.InitFromPrefs(promo_type_);
284 EXPECT_NE(0, temp_promo.first_view_time_); 284 EXPECT_NE(0, temp_promo.first_view_time_);
285 285
286 notification_promo_.views_ = 0; 286 notification_promo_.views_ = 0;
287 notification_promo_.first_view_time_ = 0; 287 notification_promo_.first_view_time_ = 0;
288 notification_promo_.WritePrefs(); 288 notification_promo_.WritePrefs();
(...skipping 25 matching lines...) Expand all
314 std::string promo_list_key = "mobile_ntp_whats_new_promo"; 314 std::string promo_list_key = "mobile_ntp_whats_new_promo";
315 std::string promo_dict_key = "ios.ntppromo"; 315 std::string promo_dict_key = "ios.ntppromo";
316 316
317 base::DictionaryValue promo_dict; 317 base::DictionaryValue promo_dict;
318 promo_dict.Set(promo_list_key, promo_list); 318 promo_dict.Set(promo_list_key, promo_list);
319 local_state_.Set(promo_dict_key, promo_dict); 319 local_state_.Set(promo_dict_key, promo_dict);
320 320
321 // Initialize promo and verify that its instance variables match the data 321 // Initialize promo and verify that its instance variables match the data
322 // saved in the old structure. 322 // saved in the old structure.
323 promo.InitFromPrefs(promo_type_); 323 promo.InitFromPrefs(promo_type_);
324 EXPECT_EQ(first_view_time, promo.first_view_time_); 324 EXPECT_DOUBLE_EQ(first_view_time, promo.first_view_time_);
325 EXPECT_EQ(views, promo.views_); 325 EXPECT_EQ(views, promo.views_);
326 EXPECT_EQ(closed, promo.closed_); 326 EXPECT_EQ(closed, promo.closed_);
327 EXPECT_FALSE(promo.CanShow()); 327 EXPECT_FALSE(promo.CanShow());
328 328
329 // Verify that old pref structure was cleared. 329 // Verify that old pref structure was cleared.
330 const base::DictionaryValue* current_promo_dict = 330 const base::DictionaryValue* current_promo_dict =
331 local_state_.GetDictionary(promo_dict_key); 331 local_state_.GetDictionary(promo_dict_key);
332 // Do not continue further if no dictionary was found at the key in prefs. 332 // Do not continue further if no dictionary was found at the key in prefs.
333 ASSERT_TRUE(current_promo_dict); 333 ASSERT_TRUE(current_promo_dict);
334 const base::ListValue* current_promo_list = NULL; 334 const base::ListValue* current_promo_list = NULL;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 " \"promo_id\":0" 441 " \"promo_id\":0"
442 "}", 442 "}",
443 "What do you think of Chrome?", 443 "What do you think of Chrome?",
444 933672366, // unix epoch for 3 Aug 1999 9:26:06 GMT. 444 933672366, // unix epoch for 3 Aug 1999 9:26:06 GMT.
445 0, 30, 30); 445 0, 30, 30);
446 InitPromoFromVariations(); 446 InitPromoFromVariations();
447 TestMigrationOfOldPrefs(); 447 TestMigrationOfOldPrefs();
448 } 448 }
449 449
450 } // namespace ios 450 } // namespace ios
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698