From: Yangster-mac Date: Wed, 22 Nov 2017 05:58:44 +0000 (-0800) Subject: Set the metric name for alerts in fake config and add a test to make sure the fake... X-Git-Tag: android-x86-9.0-r1~317^2~5^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=756cd48749eb63592b4cf8f6e16f7366debec054;p=android-x86%2Fframeworks-base.git Set the metric name for alerts in fake config and add a test to make sure the fake config is valid.. Test: unit test passed. Change-Id: I1879fc523cca9fc6c672332ab4ac383f21dc16fc --- diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp index 0c9252e2095f..408eeda67b95 100644 --- a/cmds/statsd/src/config/ConfigManager.cpp +++ b/cmds/statsd/src/config/ConfigManager.cpp @@ -30,8 +30,6 @@ namespace statsd { #define STATS_SERVICE_DIR "/data/system/stats-service" -static StatsdConfig build_fake_config(); - using android::base::StringPrintf; using std::unique_ptr; @@ -229,7 +227,7 @@ void ConfigManager::update_saved_configs(const ConfigKey& key, const StatsdConfi } } -static StatsdConfig build_fake_config() { +StatsdConfig build_fake_config() { // HACK: Hard code a test metric for counting screen on events... StatsdConfig config; config.set_name("CONFIG_12345"); diff --git a/cmds/statsd/src/config/ConfigManager.h b/cmds/statsd/src/config/ConfigManager.h index 01d7fb969230..74a15741a542 100644 --- a/cmds/statsd/src/config/ConfigManager.h +++ b/cmds/statsd/src/config/ConfigManager.h @@ -34,6 +34,9 @@ using std::unordered_map; using std::vector; using std::pair; +// Util function to Hard code a test metric for counting screen on events. +StatsdConfig build_fake_config(); + /** * Keeps track of which configurations have been set from various sources. * diff --git a/cmds/statsd/src/metrics/MetricsManager.h b/cmds/statsd/src/metrics/MetricsManager.h index 59ade7cdf48b..a6054e353aa2 100644 --- a/cmds/statsd/src/metrics/MetricsManager.h +++ b/cmds/statsd/src/metrics/MetricsManager.h @@ -101,7 +101,7 @@ private: // maps from ConditionTracker to MetricProducer std::unordered_map> mConditionToMetricMap; - bool mConfigValid; + bool mConfigValid = false; }; } // namespace statsd diff --git a/cmds/statsd/tests/ConfigManager_test.cpp b/cmds/statsd/tests/ConfigManager_test.cpp index f570522dcd0a..3b52991791de 100644 --- a/cmds/statsd/tests/ConfigManager_test.cpp +++ b/cmds/statsd/tests/ConfigManager_test.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include "src/config/ConfigManager.h" +#include "src/metrics/MetricsManager.h" #include #include @@ -60,6 +61,11 @@ MATCHER_P(StatsdConfigEq, name, "") { return arg.name() == name; } +TEST(ConfigManagerTest, TestFakeConfig) { + auto metricsManager = std::make_unique(build_fake_config()); + EXPECT_TRUE(metricsManager->isConfigValid()); +} + /** * Test the addOrUpdate and remove methods */