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

Unified Diff: chrome/browser/metrics/variations/variations_seed_store_unittest.cc

Issue 238443008: Make VariationsService simulate received seeds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 7 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/metrics/variations/variations_seed_store_unittest.cc
===================================================================
--- chrome/browser/metrics/variations/variations_seed_store_unittest.cc (revision 269404)
+++ chrome/browser/metrics/variations/variations_seed_store_unittest.cc (working copy)
@@ -24,6 +24,10 @@
: VariationsSeedStore(local_state) {}
virtual ~TestVariationsSeedStore() {}
+ bool StoreSeedForTesting(const std::string& seed_data) {
+ return StoreSeedData(seed_data, std::string(), base::Time::Now(), NULL);
+ }
+
virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature(
const std::string& seed_bytes,
const std::string& base64_seed_signature) OVERRIDE {
@@ -122,7 +126,6 @@
}
TEST(VariationsSeedStoreTest, StoreSeedData) {
- const base::Time now = base::Time::Now();
const VariationsSeed seed = CreateTestSeed();
const std::string serialized_seed = SerializeSeed(seed);
@@ -131,7 +134,7 @@
TestVariationsSeedStore seed_store(&prefs);
- EXPECT_TRUE(seed_store.StoreSeedData(serialized_seed, std::string(), now));
+ EXPECT_TRUE(seed_store.StoreSeedForTesting(serialized_seed));
// Make sure the pref was actually set.
EXPECT_FALSE(PrefHasDefaultValue(prefs, prefs::kVariationsSeed));
@@ -144,10 +147,24 @@
// Check if trying to store a bad seed leaves the pref unchanged.
prefs.ClearPref(prefs::kVariationsSeed);
- EXPECT_FALSE(seed_store.StoreSeedData("should fail", std::string(), now));
+ EXPECT_FALSE(seed_store.StoreSeedForTesting("should fail"));
EXPECT_TRUE(PrefHasDefaultValue(prefs, prefs::kVariationsSeed));
}
+TEST(VariationsSeedStoreTest, StoreSeedData_ParsedSeed) {
+ const VariationsSeed seed = CreateTestSeed();
+ const std::string serialized_seed = SerializeSeed(seed);
+
+ TestingPrefServiceSimple prefs;
+ VariationsSeedStore::RegisterPrefs(prefs.registry());
+ TestVariationsSeedStore seed_store(&prefs);
+
+ VariationsSeed parsed_seed;
+ EXPECT_TRUE(seed_store.StoreSeedData(serialized_seed, std::string(),
+ base::Time::Now(), &parsed_seed));
+ EXPECT_EQ(serialized_seed, SerializeSeed(parsed_seed));
+}
+
TEST(VariationsSeedStoreTest, VerifySeedSignature) {
// The below seed and signature pair were generated using the server's
// private key.
« no previous file with comments | « chrome/browser/metrics/variations/variations_seed_store.cc ('k') | chrome/browser/metrics/variations/variations_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698