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

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

Issue 7249003: Move GetVersionStringModifier() and GetChannel() from platform_util_* to chrome_version_info_* (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: correct nits Created 9 years, 6 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
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.cc ('k') | chrome/chrome_common.gypi » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/apps_promo.h" 9 #include "chrome/browser/extensions/apps_promo.h"
10 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 int64 actual_start = 1264899600 + // unix epoch for Jan 31 2010 0100 GMT. 160 int64 actual_start = 1264899600 + // unix epoch for Jan 31 2010 0100 GMT.
161 promo_group * 2 * 60 * 60; 161 promo_group * 2 * 60 * 60;
162 EXPECT_EQ(promo_start, actual_start); 162 EXPECT_EQ(promo_start, actual_start);
163 163
164 double promo_end = 164 double promo_end =
165 prefs->GetDouble(prefs::kNTPPromoEnd); 165 prefs->GetDouble(prefs::kNTPPromoEnd);
166 EXPECT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT. 166 EXPECT_EQ(promo_end, 1327971600); // unix epoch for Jan 31 2012 0100 GMT.
167 } 167 }
168 168
169 TEST_F(PromoResourceServiceTest, UnpackWebStoreSignal) { 169 TEST_F(PromoResourceServiceTest, UnpackWebStoreSignal) {
170 web_resource_service_->set_channel(platform_util::CHANNEL_DEV); 170 web_resource_service_->set_channel(chrome::VersionInfo::CHANNEL_DEV);
171 171
172 std::string json = "{ " 172 std::string json = "{ "
173 " \"topic\": {" 173 " \"topic\": {"
174 " \"answers\": [" 174 " \"answers\": ["
175 " {" 175 " {"
176 " \"answer_id\": \"341252\"," 176 " \"answer_id\": \"341252\","
177 " \"name\": \"webstore_promo:15:1:\"," 177 " \"name\": \"webstore_promo:15:1:\","
178 " \"question\": \"The header!\"," 178 " \"question\": \"The header!\","
179 " \"inproduct_target\": \"The button label!\"," 179 " \"inproduct_target\": \"The button label!\","
180 " \"inproduct\": \"http://link.com\"," 180 " \"inproduct\": \"http://link.com\","
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 MessageLoop loop; 224 MessageLoop loop;
225 225
226 // Check that prefs are set correctly. 226 // Check that prefs are set correctly.
227 web_resource_service_->UnpackWebStoreSignal(*(test_json.get())); 227 web_resource_service_->UnpackWebStoreSignal(*(test_json.get()));
228 EXPECT_FALSE(AppsPromo::IsPromoSupportedForLocale()); 228 EXPECT_FALSE(AppsPromo::IsPromoSupportedForLocale());
229 EXPECT_TRUE(AppsPromo::IsWebStoreSupportedForLocale()); 229 EXPECT_TRUE(AppsPromo::IsWebStoreSupportedForLocale());
230 } 230 }
231 231
232 TEST_F(PromoResourceServiceTest, IsBuildTargeted) { 232 TEST_F(PromoResourceServiceTest, IsBuildTargeted) {
233 // canary 233 // canary
234 const platform_util::Channel canary = platform_util::CHANNEL_CANARY; 234 const chrome::VersionInfo::Channel canary =
235 chrome::VersionInfo::CHANNEL_CANARY;
235 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 1)); 236 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 1));
236 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 3)); 237 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 3));
237 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 7)); 238 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(canary, 7));
238 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 15)); 239 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 15));
239 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 8)); 240 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 8));
240 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 11)); 241 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(canary, 11));
241 242
242 // dev 243 // dev
243 const platform_util::Channel dev = platform_util::CHANNEL_DEV; 244 const chrome::VersionInfo::Channel dev =
245 chrome::VersionInfo::CHANNEL_DEV;
244 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 1)); 246 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 1));
245 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 3)); 247 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 3));
246 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 7)); 248 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 7));
247 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 15)); 249 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 15));
248 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(dev, 8)); 250 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(dev, 8));
249 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 11)); 251 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(dev, 11));
250 252
251 // beta 253 // beta
252 const platform_util::Channel beta = platform_util::CHANNEL_BETA; 254 const chrome::VersionInfo::Channel beta =
255 chrome::VersionInfo::CHANNEL_BETA;
253 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(beta, 1)); 256 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(beta, 1));
254 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 3)); 257 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 3));
255 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 7)); 258 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 7));
256 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 15)); 259 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 15));
257 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(beta, 8)); 260 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(beta, 8));
258 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 11)); 261 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(beta, 11));
259 262
260 // stable 263 // stable
261 const platform_util::Channel stable = platform_util::CHANNEL_STABLE; 264 const chrome::VersionInfo::Channel stable =
265 chrome::VersionInfo::CHANNEL_STABLE;
262 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 1)); 266 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 1));
263 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 3)); 267 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 3));
264 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 7)); 268 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 7));
265 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 15)); 269 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 15));
266 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 8)); 270 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 8));
267 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 11)); 271 EXPECT_FALSE(PromoResourceService::IsBuildTargeted(stable, 11));
268 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 12)); 272 EXPECT_TRUE(PromoResourceService::IsBuildTargeted(stable, 12));
269 } 273 }
OLDNEW
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698