mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 04:39:03 +02:00
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55444
--HG--
extra : moz-landing-system : lando
173 lines
6.1 KiB
C++
173 lines
6.1 KiB
C++
/* vim:set ts=2 sw=2 sts=0 et: */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
*/
|
|
|
|
#include "gtest/gtest.h"
|
|
#include "js/Conversions.h"
|
|
#include "mozilla/Telemetry.h"
|
|
#include "TelemetryFixture.h"
|
|
#include "TelemetryTestHelpers.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace TelemetryTestHelpers;
|
|
|
|
TEST_F(TelemetryTestFixture, AutoCounter) {
|
|
const uint32_t kExpectedValue = 100;
|
|
AutoJSContextWithGlobal cx(mCleanGlobal);
|
|
|
|
const char* telemetryTestCountName =
|
|
Telemetry::GetHistogramName(Telemetry::TELEMETRY_TEST_COUNT);
|
|
|
|
GetAndClearHistogram(cx.GetJSContext(), mTelemetry,
|
|
NS_LITERAL_CSTRING("TELEMETRY_TEST_COUNT"), false);
|
|
|
|
// Accumulate in the histogram
|
|
{
|
|
Telemetry::AutoCounter<Telemetry::TELEMETRY_TEST_COUNT> autoCounter;
|
|
autoCounter += kExpectedValue / 2;
|
|
}
|
|
// This counter should not accumulate since it does not go out of scope
|
|
Telemetry::AutoCounter<Telemetry::TELEMETRY_TEST_COUNT> autoCounter;
|
|
autoCounter += kExpectedValue;
|
|
// Accumulate a second time in the histogram
|
|
{
|
|
Telemetry::AutoCounter<Telemetry::TELEMETRY_TEST_COUNT> autoCounter;
|
|
autoCounter += kExpectedValue / 2;
|
|
}
|
|
|
|
// Get a snapshot for all the histograms
|
|
JS::RootedValue snapshot(cx.GetJSContext());
|
|
GetSnapshots(cx.GetJSContext(), mTelemetry, telemetryTestCountName, &snapshot,
|
|
false);
|
|
|
|
// Get the histogram from the snapshot
|
|
JS::RootedValue histogram(cx.GetJSContext());
|
|
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);
|
|
ASSERT_EQ(uSum, kExpectedValue)
|
|
<< "The histogram is not returning expected value";
|
|
}
|
|
|
|
TEST_F(TelemetryTestFixture, AutoCounterUnderflow) {
|
|
const uint32_t kExpectedValue = 0;
|
|
AutoJSContextWithGlobal cx(mCleanGlobal);
|
|
|
|
const char* telemetryTestCountName =
|
|
Telemetry::GetHistogramName(Telemetry::TELEMETRY_TEST_COUNT);
|
|
|
|
GetAndClearHistogram(cx.GetJSContext(), mTelemetry,
|
|
NS_LITERAL_CSTRING("TELEMETRY_TEST_COUNT"), false);
|
|
|
|
// Accumulate in the histogram
|
|
{
|
|
Telemetry::AutoCounter<Telemetry::TELEMETRY_TEST_COUNT> autoCounter;
|
|
autoCounter += -1;
|
|
}
|
|
|
|
// Get a snapshot for all the histograms
|
|
JS::RootedValue snapshot(cx.GetJSContext());
|
|
GetSnapshots(cx.GetJSContext(), mTelemetry, telemetryTestCountName, &snapshot,
|
|
false);
|
|
|
|
// Get the histogram from the snapshot
|
|
JS::RootedValue histogram(cx.GetJSContext());
|
|
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 = 42;
|
|
JS::ToUint32(cx.GetJSContext(), sum, &uSum);
|
|
ASSERT_EQ(uSum, kExpectedValue)
|
|
<< "The histogram is supposed to return 0 when an underflow occurs.";
|
|
}
|
|
|
|
TEST_F(TelemetryTestFixture, RuntimeAutoCounter) {
|
|
const uint32_t kExpectedValue = 100;
|
|
AutoJSContextWithGlobal cx(mCleanGlobal);
|
|
|
|
const char* telemetryTestCountName =
|
|
Telemetry::GetHistogramName(Telemetry::TELEMETRY_TEST_COUNT);
|
|
|
|
GetAndClearHistogram(cx.GetJSContext(), mTelemetry,
|
|
NS_LITERAL_CSTRING("TELEMETRY_TEST_COUNT"), false);
|
|
|
|
// Accumulate in the histogram
|
|
{
|
|
Telemetry::RuntimeAutoCounter autoCounter(Telemetry::TELEMETRY_TEST_COUNT);
|
|
autoCounter += kExpectedValue / 2;
|
|
}
|
|
// This counter should not accumulate since it does not go out of scope
|
|
Telemetry::RuntimeAutoCounter autoCounter(Telemetry::TELEMETRY_TEST_COUNT);
|
|
autoCounter += kExpectedValue;
|
|
// Accumulate a second time in the histogram
|
|
{
|
|
Telemetry::RuntimeAutoCounter autoCounter(Telemetry::TELEMETRY_TEST_COUNT);
|
|
autoCounter += kExpectedValue / 2;
|
|
}
|
|
// Get a snapshot for all the histograms
|
|
JS::RootedValue snapshot(cx.GetJSContext());
|
|
GetSnapshots(cx.GetJSContext(), mTelemetry, telemetryTestCountName, &snapshot,
|
|
false);
|
|
|
|
// Get the histogram from the snapshot
|
|
JS::RootedValue histogram(cx.GetJSContext());
|
|
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);
|
|
ASSERT_EQ(uSum, kExpectedValue)
|
|
<< "The histogram is not returning expected value";
|
|
}
|
|
|
|
TEST_F(TelemetryTestFixture, RuntimeAutoCounterUnderflow) {
|
|
const uint32_t kExpectedValue = 0;
|
|
AutoJSContextWithGlobal cx(mCleanGlobal);
|
|
|
|
const char* telemetryTestCountName =
|
|
Telemetry::GetHistogramName(Telemetry::TELEMETRY_TEST_COUNT);
|
|
|
|
GetAndClearHistogram(cx.GetJSContext(), mTelemetry,
|
|
NS_LITERAL_CSTRING("TELEMETRY_TEST_COUNT"), false);
|
|
|
|
// Accumulate in the histogram
|
|
{
|
|
Telemetry::RuntimeAutoCounter autoCounter(Telemetry::TELEMETRY_TEST_COUNT,
|
|
kExpectedValue);
|
|
autoCounter += -1;
|
|
}
|
|
|
|
// Get a snapshot for all the histograms
|
|
JS::RootedValue snapshot(cx.GetJSContext());
|
|
GetSnapshots(cx.GetJSContext(), mTelemetry, telemetryTestCountName, &snapshot,
|
|
false);
|
|
|
|
// Get the histogram from the snapshot
|
|
JS::RootedValue histogram(cx.GetJSContext());
|
|
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 = 42;
|
|
JS::ToUint32(cx.GetJSContext(), sum, &uSum);
|
|
ASSERT_EQ(uSum, kExpectedValue)
|
|
<< "The histogram is supposed to return 0 when an underflow occurs.";
|
|
}
|