#include "chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.h"
#include <memory>
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/enterprise/connectors/core/connectors_prefs.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/common/chrome_constants.h"
#endif
_;
namespace enterprise_connectors {
class DeviceTrustConnectorServiceFactoryBaseTest { … };
class DeviceTrustConnectorServiceFactoryTest
: public DeviceTrustConnectorServiceFactoryBaseTest,
public ::testing::Test { … };
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(DeviceTrustConnectorServiceFactoryTest, CreateForRegularProfile) {
EXPECT_FALSE(profile()->IsOffTheRecord());
EXPECT_TRUE(DeviceTrustConnectorServiceFactory::GetForProfile(profile()));
}
#endif
TEST_F(DeviceTrustConnectorServiceFactoryTest, NullForIncognitoProfile) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(DeviceTrustConnectorServiceFactoryTest,
CreatedForSigninProfileChromeOS) {
TestingProfile::Builder builder;
builder.SetPath(base::FilePath(FILE_PATH_LITERAL(chrome::kInitialProfile)));
std::unique_ptr<TestingProfile> testing_profile = builder.Build();
Profile* signin_profile =
testing_profile->GetPrimaryOTRProfile(true);
RedirectTestingFactoryToRealFactory(signin_profile);
ASSERT_TRUE(signin_profile);
EXPECT_TRUE(signin_profile->IsOffTheRecord());
EXPECT_TRUE(ash::ProfileHelper::IsSigninProfile(signin_profile));
DeviceTrustConnectorService* device_trust_connector_service =
DeviceTrustConnectorServiceFactory::GetForProfile(signin_profile);
EXPECT_TRUE(device_trust_connector_service);
}
#endif
}