chromium/base/power_monitor/battery_state_sampler_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/power_monitor/battery_state_sampler.h"

#include <queue>
#include <utility>

#include "base/power_monitor/power_monitor_buildflags.h"
#include "base/power_monitor/sampling_event_source.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/power_monitor_test_utils.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

class TestBatteryLevelProvider : public BatteryLevelProvider {};

class TestBatteryLevelProviderAsync : public TestBatteryLevelProvider {};

// A test observer that exposes the last battery state received.
class TestObserver : public BatteryStateSampler::Observer {};

// Those test battery states just need to be different. The actual values don't
// matter.
const std::optional<BatteryLevelProvider::BatteryState> kTestBatteryState1 =;
const std::optional<BatteryLevelProvider::BatteryState> kTestBatteryState2 =;
const std::optional<BatteryLevelProvider::BatteryState> kTestBatteryState3 =;

bool operator==(const BatteryLevelProvider::BatteryState& lhs,
                const BatteryLevelProvider::BatteryState& rhs) {}

bool operator!=(const BatteryLevelProvider::BatteryState& lhs,
                const BatteryLevelProvider::BatteryState& rhs) {}

TEST(BatteryStateSamplerTest, GlobalInstance) {}

TEST(BatteryStateSamplerTest, InitialSample) {}

TEST(BatteryStateSamplerTest, MultipleSamples) {}

TEST(BatteryStateSamplerTest, MultipleObservers) {}

// Tests that if sampling the battery state is asynchronous (like it is on
// Windows), the sampler will correctly notify new observers when the first
// sample arrives.
TEST(BatteryStateSamplerTest, InitialSample_Async) {}

}  // namespace base