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

Commit 469cd808 authored by yro's avatar yro
Browse files

Use the configs from disk after reboot and separate out ConfigManager

startup for unit test to avoid reading configs for tests

Bug: 70667694
Test: manual testing conducted, statsd, statsd_test
Change-Id: I49cb82d2b1d7c178b7a4c30c089d8d93e7902faa
parent cbc43ed9
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -49,15 +49,13 @@ ConfigManager::~ConfigManager() {
void ConfigManager::Startup() {
    map<ConfigKey, StatsdConfig> configsFromDisk;
    StorageManager::readConfigFromDisk(configsFromDisk);
    // TODO(b/70667694): Make the configs from disk be used. And remove the fake config,
    // and tests shouldn't call this Startup(), maybe call StartupForTest() so we don't read
    // configs from disk for tests.
    // for (const auto& pair : configsFromDisk) {
    //    UpdateConfig(pair.first, pair.second);
    //}

    // Uncomment the following line and use the hard coded config for development.
    // UpdateConfig(ConfigKey(1000, "fake"), build_fake_config());
    for (const auto& pair : configsFromDisk) {
        UpdateConfig(pair.first, pair.second);
    }
}

void ConfigManager::StartupForTest() {
    // Dummy function to avoid reading configs from disks for tests.
}

void ConfigManager::AddListener(const sp<ConfigListener>& listener) {
+5 −0
Original line number Diff line number Diff line
@@ -48,6 +48,11 @@ public:
     */
    void Startup();

    /*
     * Dummy initializer for tests.
     */
    void StartupForTest();

    /**
     * Someone else wants to know about the configs.
     */
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ TEST(ConfigManagerTest, TestRemoveUid) {
    EXPECT_CALL(*(listener.get()), OnConfigRemoved(ConfigKeyEq(2, StringToId("yyy"))));
    EXPECT_CALL(*(listener.get()), OnConfigRemoved(ConfigKeyEq(2, StringToId("zzz"))));

    manager->Startup();
    manager->StartupForTest();
    manager->UpdateConfig(ConfigKey(1, StringToId("aaa")), config);
    manager->UpdateConfig(ConfigKey(2, StringToId("xxx")), config);
    manager->UpdateConfig(ConfigKey(2, StringToId("yyy")), config);