diff options
author | kaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 12:02:06 +0000 |
---|---|---|
committer | kaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 12:02:06 +0000 |
commit | da5ba6982c90521b37c966a775c88d444079938e (patch) | |
tree | 5cd1189d35b9520b1a2012b11aa8195b596d63c4 /chrome/browser/extensions/extension_metrics_apitest.cc | |
parent | ce178df9466d2cd0a0c9a15a94c94c5b466f83f7 (diff) | |
download | chromium_src-da5ba6982c90521b37c966a775c88d444079938e.zip chromium_src-da5ba6982c90521b37c966a775c88d444079938e.tar.gz chromium_src-da5ba6982c90521b37c966a775c88d444079938e.tar.bz2 |
Moving experimental.metrics API to metricsPrivate
1. experimental.metrics is now metricsPrivate
2. metricsPrivate is available to component extensions only
3. removed getEnabled/setEnabled functions as useless/harmful.
BUG=
TEST=
Review URL: http://codereview.chromium.org/8548013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_metrics_apitest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_metrics_apitest.cc | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/chrome/browser/extensions/extension_metrics_apitest.cc b/chrome/browser/extensions/extension_metrics_apitest.cc index f96d4ac..3d8b506 100644 --- a/chrome/browser/extensions/extension_metrics_apitest.cc +++ b/chrome/browser/extensions/extension_metrics_apitest.cc @@ -6,8 +6,6 @@ #include "base/metrics/histogram.h" #include "chrome/browser/extensions/extension_apitest.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/extensions/extension.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" @@ -17,7 +15,7 @@ namespace { // user actions, with the specified counts. If the tests in test.js are // modified, this array may need to be updated. struct RecordedUserAction { - const char* name; // base name of metric without extension id. + const char* name; int count; // number of times the metric was recorded. } g_user_actions[] = { {"test.ua.1", 1}, @@ -28,7 +26,7 @@ struct RecordedUserAction { // histograms. If the tests in test.js are modified, this array may need to be // updated. struct RecordedHistogram { - const char* name; // base name of metric without extension id. + const char* name; base::Histogram::ClassType type; int min; int max; @@ -45,24 +43,13 @@ struct RecordedHistogram { {"test.small.count", base::Histogram::HISTOGRAM, 1, 100, 50}, }; -// Build the full name of a metrics for the given extension. Each metric -// is made up of the unique name within the extension followed by the -// extension's id. -std::string BuildFullName(const std::string& name, const Extension* extension) { - std::string full_name(name); - full_name += extension->id(); - return full_name; -} - // This class observes and collects user action notifications that are sent // by the tests, so that they can be examined afterwards for correctness. class UserActionObserver : public content::NotificationObserver { public: UserActionObserver(); - void ValidateUserActions(const Extension* extension, - const RecordedUserAction* recorded, - int count); + void ValidateUserActions(const RecordedUserAction* recorded, int count); virtual void Observe(int type, const content::NotificationSource& source, @@ -96,19 +83,17 @@ void UserActionObserver::Observe(int type, ++(count_map_[name]); } -void UserActionObserver::ValidateUserActions(const Extension* extension, - const RecordedUserAction* recorded, +void UserActionObserver::ValidateUserActions(const RecordedUserAction* recorded, int count) { EXPECT_EQ(count, num_metrics()); for (int i = 0; i < count; ++i) { const RecordedUserAction& ua = recorded[i]; - EXPECT_EQ(ua.count, GetMetricCount(BuildFullName(ua.name, extension))); + EXPECT_EQ(ua.count, GetMetricCount(ua.name)); } } -void ValidateHistograms(const Extension* extension, - const RecordedHistogram* recorded, +void ValidateHistograms(const RecordedHistogram* recorded, int count) { base::StatisticsRecorder::Histograms histograms; base::StatisticsRecorder::GetHistograms(&histograms); @@ -119,13 +104,11 @@ void ValidateHistograms(const Extension* extension, // correct. for (int i = 0; i < count; ++i) { const RecordedHistogram& r = recorded[i]; - std::string name(BuildFullName(r.name, extension)); - size_t j = 0; for (j = 0; j < histograms.size(); ++j) { base::Histogram* histogram(histograms[j]); - if (name == histogram->histogram_name()) { + if (r.name == histogram->histogram_name()) { EXPECT_EQ(r.type, histogram->histogram_type()); EXPECT_EQ(r.min, histogram->declared_min()); EXPECT_EQ(r.max, histogram->declared_max()); @@ -140,17 +123,10 @@ void ValidateHistograms(const Extension* extension, } // anonymous namespace IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) { - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kEnableExperimentalExtensionApis); - UserActionObserver observer; - ASSERT_TRUE(RunExtensionTest("metrics")) << message_; - const Extension* extension = GetSingleLoadedExtension(); - ASSERT_TRUE(extension); + ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_; - observer.ValidateUserActions(extension, - g_user_actions, - arraysize(g_user_actions)); - ValidateHistograms(extension, g_histograms, arraysize(g_histograms)); + observer.ValidateUserActions(g_user_actions, arraysize(g_user_actions)); + ValidateHistograms(g_histograms, arraysize(g_histograms)); } |