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

Unified Diff: components/metrics/call_stack_profile_metrics_provider_unittest.cc

Issue 1029653002: Enable startup profiling by Win x64 stack sampling profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@statprof-metrics-provider
Patch Set: address comments Created 5 years, 9 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
Index: components/metrics/call_stack_profile_metrics_provider_unittest.cc
diff --git a/components/metrics/call_stack_profile_metrics_provider_unittest.cc b/components/metrics/call_stack_profile_metrics_provider_unittest.cc
index c542c495c2ec2d7af1aaecdaf361d37d488eb6b8..65c8dd9f5b582e6cf4e733d639ef9dbb505b3d7f 100644
--- a/components/metrics/call_stack_profile_metrics_provider_unittest.cc
+++ b/components/metrics/call_stack_profile_metrics_provider_unittest.cc
@@ -4,9 +4,11 @@
#include "components/metrics/call_stack_profile_metrics_provider.h"
+#include "base/metrics/field_trial.h"
#include "base/profiler/stack_sampling_profiler.h"
#include "base/strings/string_number_conversions.h"
#include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
+#include "components/variations/entropy_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::StackSamplingProfiler;
@@ -17,8 +19,42 @@ using Sample = StackSamplingProfiler::Sample;
namespace metrics {
+namespace {
+
+// This test fixture enables the field trial that
+// CallStackProfileMetricsProvider depends on to report profiles.
+class CallStackProfileMetricsProviderTest : public testing::Test {
Ilya Sherman 2015/03/24 21:07:55 nit: I believe that test fixtures are supposed to
Mike Wittman 2015/03/24 22:40:59 Yes, that sounds familiar.
+ public:
+ CallStackProfileMetricsProviderTest() {}
+ ~CallStackProfileMetricsProviderTest() {}
+
+ void SetUp() override {
+ field_trial_list_.reset(new base::FieldTrialList(
+ new metrics::SHA1EntropyProvider("foo")));
+ base::FieldTrialList::CreateFieldTrial(
+ FieldTrialState::kFieldTrialName,
+ FieldTrialState::kReportProfilesGroupName);
+ }
+
+ void TearDown() override {
+ field_trial_list_.reset();
Ilya Sherman 2015/03/24 21:07:55 nit: No need to call this explicitly, unless it ne
Mike Wittman 2015/03/24 22:40:59 Removed. Also moved the SetUp contents into the co
+ }
+
+ private:
+ // Exposes field trial/group names from the CallStackProfileMetricsProvider.
+ class FieldTrialState : public CallStackProfileMetricsProvider {
+ public:
+ using CallStackProfileMetricsProvider::kFieldTrialName;
+ using CallStackProfileMetricsProvider::kReportProfilesGroupName;
+ };
+
+ scoped_ptr<base::FieldTrialList> field_trial_list_;
+};
+
+} // namespace
+
// Checks that all properties from multiple profiles are filled as expected.
-TEST(CallStackProfileMetricsProviderTest, MultipleProfiles) {
+TEST_F(CallStackProfileMetricsProviderTest, MultipleProfiles) {
const uintptr_t module1_base_address = 0x1000;
const uintptr_t module2_base_address = 0x2000;
const uintptr_t module3_base_address = 0x3000;
@@ -229,7 +265,7 @@ TEST(CallStackProfileMetricsProviderTest, MultipleProfiles) {
// Checks that all duplicate samples are collapsed with
// preserve_sample_ordering = false.
-TEST(CallStackProfileMetricsProviderTest, RepeatedStacksUnordered) {
+TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksUnordered) {
const uintptr_t module_base_address = 0x1000;
const Module modules[] = {
@@ -305,7 +341,7 @@ TEST(CallStackProfileMetricsProviderTest, RepeatedStacksUnordered) {
// Checks that only contiguous duplicate samples are collapsed with
// preserve_sample_ordering = true.
-TEST(CallStackProfileMetricsProviderTest, RepeatedStacksOrdered) {
+TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksOrdered) {
const uintptr_t module_base_address = 0x1000;
const Module modules[] = {
@@ -381,7 +417,7 @@ TEST(CallStackProfileMetricsProviderTest, RepeatedStacksOrdered) {
// Checks that unknown modules produce an empty Entry.
-TEST(CallStackProfileMetricsProviderTest, UnknownModule) {
+TEST_F(CallStackProfileMetricsProviderTest, UnknownModule) {
// -1 indicates an unknown module.
const Frame frame(reinterpret_cast<const void*>(0x1000), -1);

Powered by Google App Engine
This is Rietveld 408576698