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

Unified Diff: chrome/browser/web_resource/promo_resource_service_unittest.cc

Issue 7655008: promo_resource_service fixes/cleanup for promos. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: round of fixing nits Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/web_resource/promo_resource_service_unittest.cc
===================================================================
--- chrome/browser/web_resource/promo_resource_service_unittest.cc (revision 101174)
+++ chrome/browser/web_resource/promo_resource_service_unittest.cc (working copy)
@@ -111,7 +111,7 @@
EXPECT_EQ(logo_end, 0); // date value reset to 0;
}
-TEST_F(PromoResourceServiceTest, UnpackPromoSignal) {
+TEST_F(PromoResourceServiceTest, UnpackNotificationSignal) {
// Set up start and end dates and promo line in a Dictionary as if parsed
// from the service.
std::string json = "{ "
@@ -119,7 +119,7 @@
" \"answers\": ["
" {"
" \"name\": \"promo_start\","
- " \"question\": \"3:2\","
+ " \"question\": \"3:2:5\","
" \"tooltip\": \"Eat more pie!\","
" \"inproduct\": \"31/01/10 01:00 GMT\""
" },"
@@ -134,7 +134,7 @@
base::JSONReader::Read(json, false)));
// Check that prefs are set correctly.
- web_resource_service_->UnpackPromoSignal(*(test_json.get()));
+ web_resource_service_->UnpackNotificationSignal(*(test_json.get()));
PrefService* prefs = profile_.GetPrefs();
ASSERT_TRUE(prefs != NULL);
@@ -143,7 +143,7 @@
int promo_group = prefs->GetInteger(prefs::kNTPPromoGroup);
EXPECT_GE(promo_group, 0);
- EXPECT_LT(promo_group, 16);
+ EXPECT_LT(promo_group, 100);
int promo_build_type = prefs->GetInteger(prefs::kNTPPromoBuild);
EXPECT_EQ(promo_build_type & PromoResourceService::DEV_BUILD,
@@ -155,15 +155,34 @@
int promo_time_slice = prefs->GetInteger(prefs::kNTPPromoGroupTimeSlice);
EXPECT_EQ(promo_time_slice, 2);
- double promo_start =
- prefs->GetDouble(prefs::kNTPPromoStart);
- int64 actual_start = 1264899600 + // unix epoch for Jan 31 2010 0100 GMT.
- promo_group * 2 * 60 * 60;
+ int promo_group_max = prefs->GetInteger(prefs::kNTPPromoGroupMax);
+ EXPECT_EQ(promo_group_max, 5);
+
+ double promo_start = prefs->GetDouble(prefs::kNTPPromoStart);
+ double actual_start = 1264899600; // unix epoch for Jan 31 2010 0100 GMT.
EXPECT_EQ(promo_start, actual_start);
- double promo_end =
- prefs->GetDouble(prefs::kNTPPromoEnd);
+ double modified_start = actual_start + promo_group * 2 * 60 * 60;
+ EXPECT_EQ(PromoResourceService::GetNotificationStartTime(prefs),
+ modified_start);
+
+ double promo_end = prefs->GetDouble(prefs::kNTPPromoEnd);
EXPECT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
+
+ // Unpack the same json a second time.
+ web_resource_service_->UnpackNotificationSignal(*(test_json.get()));
+
+ // All the data should be unchanged.
+ EXPECT_EQ(promo_line, prefs->GetString(prefs::kNTPPromoLine));
+ EXPECT_EQ(promo_group, prefs->GetInteger(prefs::kNTPPromoGroup));
+ EXPECT_EQ(promo_build_type, prefs->GetInteger(prefs::kNTPPromoBuild));
+ EXPECT_EQ(promo_time_slice,
+ prefs->GetInteger(prefs::kNTPPromoGroupTimeSlice));
+ EXPECT_EQ(promo_group_max, prefs->GetInteger(prefs::kNTPPromoGroupMax));
+ EXPECT_EQ(promo_start, prefs->GetDouble(prefs::kNTPPromoStart));
+ EXPECT_EQ(modified_start,
+ PromoResourceService::GetNotificationStartTime(prefs));
+ EXPECT_EQ(promo_end, prefs->GetDouble(prefs::kNTPPromoEnd));
jstritar 2011/09/19 22:20:54 Maybe test CanShowNotificationPromo? You could try
achuithb 2011/09/19 22:57:56 I can't because of the build check in CanShowNotif
}
TEST_F(PromoResourceServiceTest, UnpackWebStoreSignal) {

Powered by Google App Engine
This is Rietveld 408576698