Bug 1427766 - Add a c++ test for GetHistogramName r=chutten
authorDhi Aurrahman <diorahman@rockybars.com>
Tue, 27 Feb 2018 05:29:26 +0700
changeset 405655 54ad50a2582638cba1fd6c8236df539a252c01ec
parent 405654 6188bb22f81e855084b4d266525d23fb8e1030bd
child 405656 e283310058ba4a0358fd3ea844d88cd66d72fd20
push id33526
push userarchaeopteryx@coole-files.de
push dateWed, 28 Feb 2018 10:55:04 +0000
treeherdermozilla-central@ee326c976eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1427766
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427766 - Add a c++ test for GetHistogramName r=chutten
toolkit/components/telemetry/tests/gtest/TestHistograms.cpp
--- a/toolkit/components/telemetry/tests/gtest/TestHistograms.cpp
+++ b/toolkit/components/telemetry/tests/gtest/TestHistograms.cpp
@@ -13,29 +13,32 @@
 using namespace mozilla;
 using namespace TelemetryTestHelpers;
 
 TEST_F(TelemetryTestFixture, AccumulateCountHistogram)
 {
   const uint32_t kExpectedValue = 100;
   AutoJSContextWithGlobal cx(mCleanGlobal);
 
+  const char* telemetryTestCountName = Telemetry::GetHistogramName(Telemetry::TELEMETRY_TEST_COUNT);
+  ASSERT_STREQ(telemetryTestCountName, "TELEMETRY_TEST_COUNT") << "The histogram name is wrong";
+
   GetAndClearHistogram(cx.GetJSContext(), mTelemetry, NS_LITERAL_CSTRING("TELEMETRY_TEST_COUNT"),
                        false);
 
   // Accumulate in the histogram
   Telemetry::Accumulate(Telemetry::TELEMETRY_TEST_COUNT, kExpectedValue);
 
   // Get a snapshot for all the histograms
   JS::RootedValue snapshot(cx.GetJSContext());
-  GetSnapshots(cx.GetJSContext(), mTelemetry, "TELEMETRY_TEST_COUNT", &snapshot, false);
+  GetSnapshots(cx.GetJSContext(), mTelemetry, telemetryTestCountName, &snapshot, false);
 
   // Get the histogram from the snapshot
   JS::RootedValue histogram(cx.GetJSContext());
-  GetProperty(cx.GetJSContext(), "TELEMETRY_TEST_COUNT", snapshot, &histogram);
+  GetProperty(cx.GetJSContext(), telemetryTestCountName, snapshot, &histogram);
 
   // Get "sum" property from histogram
   JS::RootedValue sum(cx.GetJSContext());
   GetProperty(cx.GetJSContext(), "sum", histogram,  &sum);
 
   // Check that the "sum" stored in the histogram matches with |kExpectedValue|
   uint32_t uSum = 0;
   JS::ToUint32(cx.GetJSContext(), sum, &uSum);