#include "chrome/browser/enterprise/connectors/reporting/realtime_reporting_client.h"
#include <memory>
#include <set>
#include <string>
#include <utility>
#include "base/test/gmock_move_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/enterprise/connectors/reporting/metrics_utils.h"
#include "chrome/browser/enterprise/connectors/reporting/realtime_reporting_client.h"
#include "chrome/browser/enterprise/connectors/reporting/realtime_reporting_client_factory.h"
#include "chrome/browser/policy/dm_token_utils.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/enterprise/common/proto/connectors.pb.h"
#include "components/enterprise/connectors/core/reporting_service_settings.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "content/public/test/browser_task_environment.h"
#include "extensions/browser/test_event_router.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/enterprise/browser/enterprise_switches.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/ash/settings/scoped_cros_settings_test_helper.h"
#include "chromeos/ash/components/install_attributes/stub_install_attributes.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user.h"
#else
#include "components/enterprise/browser/controller/fake_browser_dm_token_storage.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
#include "chromeos/components/mgs/managed_guest_session_utils.h"
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
#include "chrome/browser/enterprise/profile_management/profile_management_features.h"
#include "chrome/browser/enterprise/signin/enterprise_signin_prefs.h"
#include "components/device_signals/core/browser/signals_types.h"
#endif
_;
namespace enterprise_connectors {
namespace {
std::unique_ptr<KeyedService> BuildRealtimeReportingClient(
content::BrowserContext* context) { … }
class RealtimeReportingClientTestBase : public testing::Test { … };
class RealtimeReportingClientIsRealtimeReportingEnabledTest
: public RealtimeReportingClientTestBase,
public testing::WithParamInterface<testing::tuple<bool, bool>> { … };
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
class RealtimeReportingClientOidcTest : public RealtimeReportingClientTestBase { … };
#endif
}
TEST_P(RealtimeReportingClientIsRealtimeReportingEnabledTest,
ShouldInitRealtimeReportingClient) { … }
INSTANTIATE_TEST_SUITE_P(…);
class RealtimeReportingClientUmaTest : public RealtimeReportingClientTestBase { … };
TEST_F(RealtimeReportingClientUmaTest, TestUmaEventUploadSucceeds) { … }
TEST_F(RealtimeReportingClientUmaTest, TestUmaEventUploadFails) { … }
TEST_F(RealtimeReportingClientTestBase,
TestEventNameToUmaEnumMapIncludesAllEvents) { … }
TEST_F(RealtimeReportingClientTestBase,
TestUnknownEventNameMapsTokUnknownEvent) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
TEST_F(RealtimeReportingClientTestBase, TestCrowdstrikeSignalsPopulated) { … }
TEST_F(RealtimeReportingClientTestBase,
TestCrowdstrikeSignalsNotPopulatedForEmptyResponse) { … }
TEST_F(RealtimeReportingClientOidcTest, Username) { … }
#endif
}