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

Commit 74b1513f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

Merge "Set the metric name for alerts in fake config and add a test to make sure the fake config is valid.."
parents 9f36f6b3 756cd487
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
 */