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

Side by Side Diff: chrome/browser/web_resource/web_resource_service_unittest.cc

Issue 6248026: Rename Real* to Double* in values.* and dependent files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More renames Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/time.h" 6 #include "base/time.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/web_resource/web_resource_service.h" 10 #include "chrome/browser/web_resource/web_resource_service.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 "}"; 50 "}";
51 scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( 51 scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>(
52 base::JSONReader::Read(json, false))); 52 base::JSONReader::Read(json, false)));
53 53
54 // Check that prefs are set correctly. 54 // Check that prefs are set correctly.
55 web_resource_service->UnpackLogoSignal(*(test_json.get())); 55 web_resource_service->UnpackLogoSignal(*(test_json.get()));
56 PrefService* prefs = profile.GetPrefs(); 56 PrefService* prefs = profile.GetPrefs();
57 ASSERT_TRUE(prefs != NULL); 57 ASSERT_TRUE(prefs != NULL);
58 58
59 double logo_start = 59 double logo_start =
60 prefs->GetReal(prefs::kNTPCustomLogoStart); 60 prefs->GetDouble(prefs::kNTPCustomLogoStart);
61 EXPECT_EQ(logo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT. 61 EXPECT_EQ(logo_start, 1264899600); // unix epoch for Jan 31 2010 0100 GMT.
62 double logo_end = 62 double logo_end =
63 prefs->GetReal(prefs::kNTPCustomLogoEnd); 63 prefs->GetDouble(prefs::kNTPCustomLogoEnd);
64 EXPECT_EQ(logo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT. 64 EXPECT_EQ(logo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
65 65
66 // Change the start only and recheck. 66 // Change the start only and recheck.
67 json = "{ " 67 json = "{ "
68 " \"topic\": {" 68 " \"topic\": {"
69 " \"answers\": [" 69 " \"answers\": ["
70 " {" 70 " {"
71 " \"name\": \"custom_logo_start\"," 71 " \"name\": \"custom_logo_start\","
72 " \"inproduct\": \"28/02/10 14:00 GMT\"" 72 " \"inproduct\": \"28/02/10 14:00 GMT\""
73 " }," 73 " },"
74 " {" 74 " {"
75 " \"name\": \"custom_logo_end\"," 75 " \"name\": \"custom_logo_end\","
76 " \"inproduct\": \"31/01/12 01:00 GMT\"" 76 " \"inproduct\": \"31/01/12 01:00 GMT\""
77 " }" 77 " }"
78 " ]" 78 " ]"
79 " }" 79 " }"
80 "}"; 80 "}";
81 test_json->Clear(); 81 test_json->Clear();
82 test_json.reset(static_cast<DictionaryValue*>( 82 test_json.reset(static_cast<DictionaryValue*>(
83 base::JSONReader::Read(json, false))); 83 base::JSONReader::Read(json, false)));
84 84
85 // Check that prefs are set correctly. 85 // Check that prefs are set correctly.
86 web_resource_service->UnpackLogoSignal(*(test_json.get())); 86 web_resource_service->UnpackLogoSignal(*(test_json.get()));
87 87
88 logo_start = prefs->GetReal(prefs::kNTPCustomLogoStart); 88 logo_start = prefs->GetDouble(prefs::kNTPCustomLogoStart);
89 EXPECT_EQ(logo_start, 1267365600); // date changes to Feb 28 2010 1400 GMT. 89 EXPECT_EQ(logo_start, 1267365600); // date changes to Feb 28 2010 1400 GMT.
90 90
91 // If no date is included in the prefs, reset custom logo dates to 0. 91 // If no date is included in the prefs, reset custom logo dates to 0.
92 json = "{ " 92 json = "{ "
93 " \"topic\": {" 93 " \"topic\": {"
94 " \"answers\": [" 94 " \"answers\": ["
95 " {" 95 " {"
96 " }" 96 " }"
97 " ]" 97 " ]"
98 " }" 98 " }"
99 "}"; 99 "}";
100 test_json->Clear(); 100 test_json->Clear();
101 test_json.reset(static_cast<DictionaryValue*>( 101 test_json.reset(static_cast<DictionaryValue*>(
102 base::JSONReader::Read(json, false))); 102 base::JSONReader::Read(json, false)));
103 103
104 // Check that prefs are set correctly. 104 // Check that prefs are set correctly.
105 web_resource_service->UnpackLogoSignal(*(test_json.get())); 105 web_resource_service->UnpackLogoSignal(*(test_json.get()));
106 logo_start = prefs->GetReal(prefs::kNTPCustomLogoStart); 106 logo_start = prefs->GetDouble(prefs::kNTPCustomLogoStart);
107 EXPECT_EQ(logo_start, 0); // date value reset to 0; 107 EXPECT_EQ(logo_start, 0); // date value reset to 0;
108 logo_end = prefs->GetReal(prefs::kNTPCustomLogoEnd); 108 logo_end = prefs->GetDouble(prefs::kNTPCustomLogoEnd);
109 EXPECT_EQ(logo_end, 0); // date value reset to 0; 109 EXPECT_EQ(logo_end, 0); // date value reset to 0;
110 } 110 }
111 111
112 TEST_F(WebResourceServiceTest, UnpackPromoSignal) { 112 TEST_F(WebResourceServiceTest, UnpackPromoSignal) {
113 // Set up a testing profile and create a web resource service. 113 // Set up a testing profile and create a web resource service.
114 TestingProfile profile; 114 TestingProfile profile;
115 scoped_refptr<WebResourceService> web_resource_service( 115 scoped_refptr<WebResourceService> web_resource_service(
116 new WebResourceService(&profile)); 116 new WebResourceService(&profile));
117 117
118 // Set up start and end dates and promo line in a Dictionary as if parsed 118 // Set up start and end dates and promo line in a Dictionary as if parsed
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 int promo_build_type = prefs->GetInteger(prefs::kNTPPromoBuild); 154 int promo_build_type = prefs->GetInteger(prefs::kNTPPromoBuild);
155 EXPECT_EQ(promo_build_type & DEV_BUILD, DEV_BUILD); 155 EXPECT_EQ(promo_build_type & DEV_BUILD, DEV_BUILD);
156 EXPECT_EQ(promo_build_type & BETA_BUILD, BETA_BUILD); 156 EXPECT_EQ(promo_build_type & BETA_BUILD, BETA_BUILD);
157 EXPECT_EQ(promo_build_type & STABLE_BUILD, 0); 157 EXPECT_EQ(promo_build_type & STABLE_BUILD, 0);
158 158
159 int promo_time_slice = prefs->GetInteger(prefs::kNTPPromoGroupTimeSlice); 159 int promo_time_slice = prefs->GetInteger(prefs::kNTPPromoGroupTimeSlice);
160 EXPECT_EQ(promo_time_slice, 2); 160 EXPECT_EQ(promo_time_slice, 2);
161 161
162 double promo_start = 162 double promo_start =
163 prefs->GetReal(prefs::kNTPPromoStart); 163 prefs->GetDouble(prefs::kNTPPromoStart);
164 int64 actual_start = 1264899600 + // unix epoch for Jan 31 2010 0100 GMT. 164 int64 actual_start = 1264899600 + // unix epoch for Jan 31 2010 0100 GMT.
165 promo_group * 2 * 60 * 60; 165 promo_group * 2 * 60 * 60;
166 EXPECT_EQ(promo_start, actual_start); 166 EXPECT_EQ(promo_start, actual_start);
167 167
168 double promo_end = 168 double promo_end =
169 prefs->GetReal(prefs::kNTPPromoEnd); 169 prefs->GetDouble(prefs::kNTPPromoEnd);
170 EXPECT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT. 170 EXPECT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
171 } 171 }
172 172
173 173
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698