Skip to content

Commit

Permalink
Bug 1551410 - Part 2: test case; r=chutten
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D31109

--HG--
extra : moz-landing-system : lando
  • Loading branch information
xeonchen committed May 17, 2019
1 parent 756316c commit 80a397c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ void GetEncodedOriginStrings(
nsAutoJSString jsStr;
ASSERT_TRUE(jsStr.init(aCx, encodingVal));

nsPrintfCString encoding(aEncoding.get(), i);
nsPrintfCString encoding(aEncoding.get(), i % TelemetryOrigin::SizeOfPrioDatasPerMetric());
ASSERT_TRUE(NS_ConvertUTF16toUTF8(jsStr) == encoding)
<< "Actual 'encoding' (" << NS_ConvertUTF16toUTF8(jsStr).get()
<< ") must match expected (" << encoding;
<< ") must match expected (" << encoding << ")";

JS::RootedValue prioVal(aCx);
ASSERT_TRUE(JS_GetProperty(aCx, arrayItemObj, "prio", &prioVal));
Expand Down
15 changes: 15 additions & 0 deletions toolkit/components/telemetry/tests/gtest/TestOrigins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ TEST_F(TelemetryTestFixture, RecordOriginTwiceMixed) {
Telemetry::RecordOrigin(OriginMetricID::TelemetryTest_Test1, doubleclick);
Telemetry::RecordOrigin(OriginMetricID::TelemetryTest_Test1, doubleclickHash);

// Properly prepare the prio prefs
// (Sourced from PrioEncoder.cpp from when it was being prototyped)
const nsLiteralCString prioKeyA(
"35AC1C7576C7C6EDD7FED6BCFC337B34D48CB4EE45C86BEEFB40BD8875707733");
const nsLiteralCString prioKeyB(
"26E6674E65425B823F1F1D5F96E3BB3EF9E406EC7FBA7DEF8B08A35DD135AF50");
Preferences::SetCString("prio.publicKeyA", prioKeyA);
Preferences::SetCString("prio.publicKeyB", prioKeyB);

nsTArray<Tuple<nsCString, nsCString>> encodedStrings;
GetEncodedOriginStrings(aCx, telemetryTest1 + NS_LITERAL_CSTRING("-%u"),
encodedStrings);
ASSERT_EQ(2 * TelemetryOrigin::SizeOfPrioDatasPerMetric(),
encodedStrings.Length());

JS::RootedValue originSnapshot(aCx);
GetOriginSnapshot(aCx, &originSnapshot, true /* aClear */);

Expand Down

0 comments on commit 80a397c

Please sign in to comment.