#include "chrome/browser/performance_manager/metrics/page_resource_monitor.h"
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/system/sys_info.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/performance_manager/embedder/graph_features.h"
#include "components/performance_manager/public/features.h"
#include "components/performance_manager/public/graph/frame_node.h"
#include "components/performance_manager/public/graph/graph.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "components/performance_manager/public/graph/process_node.h"
#include "components/performance_manager/public/resource_attribution/cpu_measurement_delegate.h"
#include "components/performance_manager/public/resource_attribution/memory_measurement_delegate.h"
#include "components/performance_manager/test_support/graph_test_harness.h"
#include "components/performance_manager/test_support/mock_graphs.h"
#include "components/performance_manager/test_support/resource_attribution/measurement_delegates.h"
#include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/metrics/public/mojom/ukm_interface.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace performance_manager::metrics {
namespace {
PageMeasurementAlgorithm;
PageMeasurementBackgroundState;
CPUMeasurementDelegate;
FakeMemoryMeasurementDelegateFactory;
MemoryMeasurementDelegate;
SimulatedCPUMeasurementDelegate;
SimulatedCPUMeasurementDelegateFactory;
class PageResourceMonitorUnitTest : public GraphTestHarness { … };
void PageResourceMonitorUnitTest::TriggerCollectPageResourceUsage() { … }
void PageResourceMonitorUnitTest::WaitForMetrics(bool include_system_cpu) { … }
void PageResourceMonitorUnitTest::WaitForMetricsAndTestBackgroundStates(
std::map<ukm::SourceId, PageMeasurementBackgroundState> expected_states) { … }
TEST_F(PageResourceMonitorUnitTest, TestPageResourceUsage) { … }
TEST_F(PageResourceMonitorUnitTest, TestPageResourceUsageNavigation) { … }
TEST_F(PageResourceMonitorUnitTest, TestOnlyRecordTabs) { … }
TEST_F(PageResourceMonitorUnitTest, TestResourceUsage) { … }
TEST_F(PageResourceMonitorUnitTest, TestResourceUsageBackgroundState) { … }
}
}