Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 756cd487 authored by Yangster-mac's avatar Yangster-mac
Browse files

Set the metric name for alerts in fake config and add a test to make sure the...

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
parent 916c83d2
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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");
+3 −0
Original line number Diff line number Diff line
@@ -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.
 *
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ private:
    // maps from ConditionTracker to MetricProducer
    std::unordered_map<int, std::vector<int>> mConditionToMetricMap;

    bool mConfigValid;
    bool mConfigValid = false;
};

}  // namespace statsd
+6 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
// limitations under the License.

#include "src/config/ConfigManager.h"
#include "src/metrics/MetricsManager.h"

#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -60,6 +61,11 @@ MATCHER_P(StatsdConfigEq, name, "") {
    return arg.name() == name;
}

TEST(ConfigManagerTest, TestFakeConfig) {
    auto metricsManager = std::make_unique<MetricsManager>(build_fake_config());
    EXPECT_TRUE(metricsManager->isConfigValid());
}

/**
 * Test the addOrUpdate and remove methods
 */