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

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

Issue 4804001: Add new promotional line for NTP.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 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/notification_type.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 67122)
+++ chrome/browser/web_resource/web_resource_service_unittest.cc (working copy)
@@ -94,3 +94,41 @@
ASSERT_EQ(logo_end, 0); // date value reset to 0;
}
+TEST_F(WebResourceServiceTest, UnpackPromoSignal) {
+ // Set up a testing profile and create a web resource service.
+ TestingProfile profile;
+ scoped_refptr<WebResourceService> web_resource_service(
+ new WebResourceService(&profile));
+
+ // Set up start and end dates and promo line in a Dictionary as if parsed
+ // from the service.
+ std::string json = "{ "
+ " \"topic\": {"
+ " \"answers\": ["
+ " {"
+ " \"name\": \"promo_start\","
+ " \"tooltip\": \"Eat more pie!\","
+ " \"inproduct\": \"31/01/10 01:00 GMT\""
+ " },"
+ " {"
+ " \"name\": \"promo_end\","
+ " \"inproduct\": \"31/01/12 01:00 GMT\""
+ " }"
+ " ]"
+ " }"
+ "}";
+ scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>(
+ base::JSONReader::Read(json, false)));
+
+ // Check that prefs are set correctly.
+ web_resource_service->UnpackPromoSignal(*(test_json.get()));
+ double promo_start =
+ profile.GetPrefs()->GetReal(prefs::kNTPPromoStart);
+ ASSERT_EQ(promo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT.
+ 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!");
+}
+
« no previous file with comments | « chrome/browser/web_resource/web_resource_service.cc ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698