Bug 1473520 - Add test coverage for applying recorded scalar actions. r?janerik draft
authorPetru Gurita <petru.gurita1@gmail.com>
Tue, 17 Jul 2018 23:01:25 +0300
changeset 819385 c14471b7c4d8
parent 818950 71fce5b6b828
child 819395 f9f04a3466c1
child 819396 38e7e6a3377a
push id116545
push userbmo:petru.gurita1@gmail.com
push dateTue, 17 Jul 2018 20:03:05 +0000
reviewersjanerik
bugs1473520
milestone63.0a1
Bug 1473520 - Add test coverage for applying recorded scalar actions. r?janerik Created two new test coverages, `WrongscalarOperator' and 'WrongKeyedScalarOperator', that test scalar operations on wrong type of scalars. MozReview-Commit-ID: 8iI8NaZlmfg
toolkit/components/telemetry/tests/gtest/TestScalars.cpp
--- a/toolkit/components/telemetry/tests/gtest/TestScalars.cpp
+++ b/toolkit/components/telemetry/tests/gtest/TestScalars.cpp
@@ -318,39 +318,42 @@ TEST_F(TelemetryTestFixture, ScalarEvent
 }
 
 TEST_F(TelemetryTestFixture, WrongScalarOperator) {
   AutoJSContextWithGlobal cx(mCleanGlobal);
 
   // Make sure we don't get scalars from other tests.
   Unused << mTelemetry->ClearScalars();
 
+  const uint32_t expectedValue = 1172015;
+
+  Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_UNSIGNED_INT_KIND, expectedValue);
   Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_STRING_KIND, NS_LITERAL_STRING(EXPECTED_STRING));
   Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_BOOLEAN_KIND, true);
 
   TelemetryScalar::DeserializationStarted();
 
   Telemetry::ScalarAdd(Telemetry::ScalarID::TELEMETRY_TEST_STRING_KIND, 1447);
   Telemetry::ScalarAdd(Telemetry::ScalarID::TELEMETRY_TEST_BOOLEAN_KIND, 1447);
+  Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_UNSIGNED_INT_KIND, true);
   TelemetryScalar::ApplyPendingOperations();
 
   JS::RootedValue scalarsSnapshot(cx.GetJSContext());
   GetScalarsSnapshot(false, cx.GetJSContext(), &scalarsSnapshot);
   CheckStringScalar("telemetry.test.string_kind", cx.GetJSContext(), scalarsSnapshot, EXPECTED_STRING);
   CheckBoolScalar("telemetry.test.boolean_kind", cx.GetJSContext(), scalarsSnapshot, true);
+  CheckUintScalar("telemetry.test.unsigned_int_kind", cx.GetJSContext(), scalarsSnapshot, expectedValue);
 }
 
 TEST_F(TelemetryTestFixture, WrongKeyedScalarOperator) {
-
   AutoJSContextWithGlobal cx(mCleanGlobal);
 
   // Make sure we don't get scalars from other tests.
   Unused << mTelemetry->ClearScalars();
 
-
   const uint32_t kExpectedUint = 1172017;
 
   Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_KEYED_UNSIGNED_INT,
                        NS_LITERAL_STRING("key1"), kExpectedUint);
   Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_KEYED_BOOLEAN_KIND,
                        NS_LITERAL_STRING("key2"), true);
 
   TelemetryScalar::DeserializationStarted();
@@ -363,10 +366,9 @@ TEST_F(TelemetryTestFixture, WrongKeyedS
   TelemetryScalar::ApplyPendingOperations();
 
   JS::RootedValue scalarsSnapshot(cx.GetJSContext());
   GetScalarsSnapshot(true, cx.GetJSContext(), &scalarsSnapshot);
   CheckKeyedUintScalar("telemetry.test.keyed_unsigned_int", "key1",
                        cx.GetJSContext(), scalarsSnapshot, kExpectedUint);
   CheckKeyedBoolScalar("telemetry.test.keyed_boolean_kind", "key2",
                        cx.GetJSContext(), scalarsSnapshot, true);
-
 }