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

Unified Diff: components/rappor/rappor_service_unittest.cc

Issue 1090683003: Alternative Multi-dimensional Rappor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 64-bit shift Created 5 years, 8 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/rappor/rappor_service.cc ('k') | components/rappor/reports.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/rappor/rappor_service_unittest.cc
diff --git a/components/rappor/rappor_service_unittest.cc b/components/rappor/rappor_service_unittest.cc
index eefdb52ecb6446d498f250d3e09492d4acc72439..de612cc3298b70d7cd2f18de5dc7351d637e7f5e 100644
--- a/components/rappor/rappor_service_unittest.cc
+++ b/components/rappor/rappor_service_unittest.cc
@@ -6,6 +6,7 @@
#include "base/base64.h"
#include "base/prefs/testing_pref_service.h"
+#include "components/metrics/metrics_hashes.h"
#include "components/rappor/byte_vector_utils.h"
#include "components/rappor/proto/rappor_metric.pb.h"
#include "components/rappor/rappor_parameters.h"
@@ -95,4 +96,24 @@ TEST(RapporServiceTest, Incognito) {
EXPECT_EQ(0, reports.report_size());
}
+// Check that Sample objects record correctly.
+TEST(RapporServiceTest, RecordSample) {
+ TestRapporService rappor_service;
+ scoped_ptr<Sample> sample = rappor_service.CreateSample(COARSE_RAPPOR_TYPE);
+ sample->SetStringField("Url", "example.com");
+ sample->SetFlagsField("Flags1", 0xbcd, 12);
+ rappor_service.RecordSampleObj("ObjMetric", sample.Pass());
+ uint64_t url_hash = metrics::HashMetricName("ObjMetric.Url");
+ uint64_t flags_hash = metrics::HashMetricName("ObjMetric.Flags1");
+ RapporReports reports;
+ rappor_service.GetReports(&reports);
+ EXPECT_EQ(2, reports.report_size());
+ size_t url_index = reports.report(0).name_hash() == url_hash ? 0 : 1;
+ size_t flags_index = url_index == 0 ? 1 : 0;
+ EXPECT_EQ(url_hash, reports.report(url_index).name_hash());
+ EXPECT_EQ(1u, reports.report(url_index).bits().size());
+ EXPECT_EQ(flags_hash, reports.report(flags_index).name_hash());
+ EXPECT_EQ(2u, reports.report(flags_index).bits().size());
+}
+
} // namespace rappor
« no previous file with comments | « components/rappor/rappor_service.cc ('k') | components/rappor/reports.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698