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

Unified Diff: components/metrics/persistent_system_profile_unittest.cc

Issue 2950173003: Support add-on 'field trial' records. (Closed)
Patch Set: addressed review comments by asvitkine Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/persistent_system_profile.cc ('k') | components/variations/active_field_trials.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/persistent_system_profile_unittest.cc
diff --git a/components/metrics/persistent_system_profile_unittest.cc b/components/metrics/persistent_system_profile_unittest.cc
index a2e038a47d2ebc5791e69dc9eeff42d2e9cf8ec6..4adaed3fb735bccd8331224cb0899f98934e55ab 100644
--- a/components/metrics/persistent_system_profile_unittest.cc
+++ b/components/metrics/persistent_system_profile_unittest.cc
@@ -8,6 +8,7 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/rand_util.h"
+#include "components/variations/metrics_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace metrics {
@@ -134,4 +135,37 @@ TEST_F(PersistentSystemProfileTest, ProfileStorage) {
EXPECT_EQ(90U, proto2.field_trial(1).group_id());
}
+TEST_F(PersistentSystemProfileTest, ProfileExtensions) {
+ persistent_profile()->AddFieldTrial("sna", "foo");
+
+ SystemProfileProto fetched;
+ ASSERT_FALSE(
+ PersistentSystemProfile::GetSystemProfile(*memory_allocator(), &fetched));
+
+ SystemProfileProto proto;
+ SystemProfileProto::FieldTrial* trial = proto.add_field_trial();
+ trial->set_name_id(123);
+ trial->set_group_id(456);
+
+ persistent_profile()->SetSystemProfile(proto, false);
+ ASSERT_TRUE(
+ PersistentSystemProfile::GetSystemProfile(*memory_allocator(), &fetched));
+ ASSERT_EQ(2, fetched.field_trial_size());
+ EXPECT_EQ(123U, fetched.field_trial(0).name_id());
+ EXPECT_EQ(456U, fetched.field_trial(0).group_id());
+ EXPECT_EQ(metrics::HashName("sna"), fetched.field_trial(1).name_id());
+ EXPECT_EQ(metrics::HashName("foo"), fetched.field_trial(1).group_id());
+
+ persistent_profile()->AddFieldTrial("foo", "bar");
+ ASSERT_TRUE(
+ PersistentSystemProfile::GetSystemProfile(*memory_allocator(), &fetched));
+ ASSERT_EQ(3, fetched.field_trial_size());
+ EXPECT_EQ(123U, fetched.field_trial(0).name_id());
+ EXPECT_EQ(456U, fetched.field_trial(0).group_id());
+ EXPECT_EQ(metrics::HashName("sna"), fetched.field_trial(1).name_id());
+ EXPECT_EQ(metrics::HashName("foo"), fetched.field_trial(1).group_id());
+ EXPECT_EQ(metrics::HashName("foo"), fetched.field_trial(2).name_id());
+ EXPECT_EQ(metrics::HashName("bar"), fetched.field_trial(2).group_id());
+}
+
} // namespace metrics
« no previous file with comments | « components/metrics/persistent_system_profile.cc ('k') | components/variations/active_field_trials.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698