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

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

Issue 6313009: Add possibility to divide chrome users into groups of equal size, and change ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/browser/web_resource/web_resource_service.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_resource/web_resource_service_unittest.cc
===================================================================
--- chrome/browser/web_resource/web_resource_service_unittest.cc (revision 72341)
+++ chrome/browser/web_resource/web_resource_service_unittest.cc (working copy)
@@ -14,6 +14,17 @@
typedef testing::Test WebResourceServiceTest;
+namespace {
+
+// From web_resource_service.cc
+enum BuildType {
+ DEV_BUILD = 1,
+ BETA_BUILD = 1 << 1,
+ STABLE_BUILD = 1 << 2,
+};
+
+} // namespace
+
// Verifies that custom dates read from a web resource server are written to
// the preferences file.
TEST_F(WebResourceServiceTest, UnpackLogoSignal) {
@@ -42,12 +53,15 @@
// Check that prefs are set correctly.
web_resource_service->UnpackLogoSignal(*(test_json.get()));
+ PrefService* prefs = profile.GetPrefs();
+ ASSERT_TRUE(prefs != NULL);
+
double logo_start =
- profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoStart);
- ASSERT_EQ(logo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT.
+ prefs->GetReal(prefs::kNTPCustomLogoStart);
+ EXPECT_EQ(logo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT.
double logo_end =
- profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoEnd);
- ASSERT_EQ(logo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
+ prefs->GetReal(prefs::kNTPCustomLogoEnd);
+ EXPECT_EQ(logo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
// Change the start only and recheck.
json = "{ "
@@ -70,9 +84,10 @@
// Check that prefs are set correctly.
web_resource_service->UnpackLogoSignal(*(test_json.get()));
- logo_start = profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoStart);
- ASSERT_EQ(logo_start, 1267365600); // date changes to Feb 28 2010 1400 GMT.
+ logo_start = prefs->GetReal(prefs::kNTPCustomLogoStart);
+ EXPECT_EQ(logo_start, 1267365600); // date changes to Feb 28 2010 1400 GMT.
+
// If no date is included in the prefs, reset custom logo dates to 0.
json = "{ "
" \"topic\": {"
@@ -88,10 +103,10 @@
// Check that prefs are set correctly.
web_resource_service->UnpackLogoSignal(*(test_json.get()));
- logo_start = profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoStart);
- ASSERT_EQ(logo_start, 0); // date value reset to 0;
- logo_end = profile.GetPrefs()->GetReal(prefs::kNTPCustomLogoEnd);
- ASSERT_EQ(logo_end, 0); // date value reset to 0;
+ logo_start = prefs->GetReal(prefs::kNTPCustomLogoStart);
+ EXPECT_EQ(logo_start, 0); // date value reset to 0;
+ logo_end = prefs->GetReal(prefs::kNTPCustomLogoEnd);
+ EXPECT_EQ(logo_end, 0); // date value reset to 0;
}
TEST_F(WebResourceServiceTest, UnpackPromoSignal) {
@@ -107,6 +122,7 @@
" \"answers\": ["
" {"
" \"name\": \"promo_start\","
+ " \"question\": \"3:2\","
" \"tooltip\": \"Eat more pie!\","
" \"inproduct\": \"31/01/10 01:00 GMT\""
" },"
@@ -125,13 +141,33 @@
// Check that prefs are set correctly.
web_resource_service->UnpackPromoSignal(*(test_json.get()));
+ PrefService* prefs = profile.GetPrefs();
+ ASSERT_TRUE(prefs != NULL);
+
+ std::string promo_line = prefs->GetString(prefs::kNTPPromoLine);
+ EXPECT_EQ(promo_line, "Eat more pie!");
+
+ int promo_group = prefs->GetInteger(prefs::kNTPPromoGroup);
+ EXPECT_GE(promo_group, 0);
+ EXPECT_LT(promo_group, 16);
+
+ int promo_build_type = prefs->GetInteger(prefs::kNTPPromoBuild);
+ EXPECT_EQ(promo_build_type & DEV_BUILD, DEV_BUILD);
+ EXPECT_EQ(promo_build_type & BETA_BUILD, BETA_BUILD);
+ EXPECT_EQ(promo_build_type & STABLE_BUILD, 0);
+
+ int promo_time_slice = prefs->GetInteger(prefs::kNTPPromoGroupTimeSlice);
+ EXPECT_EQ(promo_time_slice, 2);
+
double promo_start =
- profile.GetPrefs()->GetReal(prefs::kNTPPromoStart);
- ASSERT_EQ(promo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT.
+ prefs->GetReal(prefs::kNTPPromoStart);
+ int64 actual_start = 1264899600 + // unix epoch for Jan 31 2010 0100 GMT.
+ promo_group * 2 * 60 * 60;
+ EXPECT_EQ(promo_start, actual_start);
+
double promo_end =
- profile.GetPrefs()->GetReal(prefs::kNTPPromoEnd);
- ASSERT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
- std::string promo_line = profile.GetPrefs()->GetString(prefs::kNTPPromoLine);
- ASSERT_EQ(promo_line, "Eat more pie!");
+ prefs->GetReal(prefs::kNTPPromoEnd);
+ EXPECT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
}
+
« no previous file with comments | « chrome/browser/web_resource/web_resource_service.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698