SyncPromoUITest() {}
// testing::Test:
- virtual void SetUp() OVERRIDE {
+ void SetUp() override {
testing::Test::SetUp();
- profile_.reset(new TestingProfile());
+ TestingProfile::Builder builder;
+ builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
+ FakeSigninManagerBase::Build);
+ profile_ = builder.Build();
}
protected:
- void CreateSigninManager(const std::string& username) {
- SigninManagerBase* signin_manager =
-#if defined(OS_CHROMEOS)
- static_cast<FakeSigninManagerBase*>(
- SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(),
- &FakeSigninManagerBase::Build));
-#else
- static_cast<FakeSigninManager*>(
- SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(),
- &FakeSigninManager::Build));
-#endif
- signin_manager->Initialize(profile_.get(), NULL);
-
- if (!username.empty()) {
- ASSERT_TRUE(signin_manager);
- signin_manager->SetAuthenticatedUsername(username);
- }
- }
-
void DisableSync() {
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync);
}
// Verifies that ShouldShowSyncPromo returns false if sync is disabled by
// policy.
TEST_F(SyncPromoUITest, ShouldShowSyncPromoSyncDisabled) {
- CreateSigninManager("");
DisableSync();
EXPECT_FALSE(SyncPromoUI::ShouldShowSyncPromo(profile_.get()));
}
// Verifies that ShouldShowSyncPromo returns true if all conditions to
// show the promo are met.
TEST_F(SyncPromoUITest, ShouldShowSyncPromoSyncEnabled) {
- CreateSigninManager("");
#if defined(OS_CHROMEOS)
// No sync promo on CrOS.
EXPECT_FALSE(SyncPromoUI::ShouldShowSyncPromo(profile_.get()));