#include "base/memory/scoped_ptr.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/profile_loader.h"
-#include "chrome/browser/ui/app_list/test/fake_keep_alive_service.h"
#include "chrome/browser/ui/app_list/test/fake_profile.h"
#include "chrome/browser/ui/app_list/test/fake_profile_store.h"
#include "testing/gtest/include/gtest/gtest.h"
class ProfileLoaderUnittest : public testing::Test {
public:
- virtual void SetUp() OVERRIDE {
+ void SetUp() override {
last_callback_result_ = NULL;
profile1_.reset(
new FakeProfile("p1", base::FilePath(FILE_PATH_LITERAL("profile1"))));
profile_store_.reset(new FakeProfileStore(
base::FilePath(FILE_PATH_LITERAL("udd"))));
- keep_alive_service_ = new FakeKeepAliveService;
- loader_.reset(new ProfileLoader(
- profile_store_.get(),
- scoped_ptr<KeepAliveService>(keep_alive_service_)));
+ loader_.reset(new ProfileLoader(profile_store_.get()));
}
void StartLoadingProfile(Profile* profile) {
last_callback_result_ = profile;
}
- FakeKeepAliveService* keep_alive_service_;
+ bool HasKeepAlive() const {
+ return loader_->keep_alive_.get() != NULL;
+ }
+
+ protected:
scoped_ptr<ProfileLoader> loader_;
scoped_ptr<FakeProfileStore> profile_store_;
scoped_ptr<FakeProfile> profile1_;
TEST_F(ProfileLoaderUnittest, TestKeepsAliveWhileLoadingProfiles) {
EXPECT_FALSE(loader_->IsAnyProfileLoading());
- EXPECT_FALSE(keep_alive_service_->is_keeping_alive());
+ EXPECT_FALSE(HasKeepAlive());
StartLoadingProfile(profile1_.get());
EXPECT_TRUE(loader_->IsAnyProfileLoading());
- EXPECT_TRUE(keep_alive_service_->is_keeping_alive());
+ EXPECT_TRUE(HasKeepAlive());
FinishLoadingProfile(profile1_.get());
EXPECT_FALSE(loader_->IsAnyProfileLoading());
- EXPECT_FALSE(keep_alive_service_->is_keeping_alive());
+ EXPECT_FALSE(HasKeepAlive());
}
TEST_F(ProfileLoaderUnittest, TestKeepsAliveWhileLoadingMultipleProfiles) {
EXPECT_FALSE(loader_->IsAnyProfileLoading());
- EXPECT_FALSE(keep_alive_service_->is_keeping_alive());
+ EXPECT_FALSE(HasKeepAlive());
StartLoadingProfile(profile1_.get());
EXPECT_TRUE(loader_->IsAnyProfileLoading());
- EXPECT_TRUE(keep_alive_service_->is_keeping_alive());
+ EXPECT_TRUE(HasKeepAlive());
StartLoadingProfile(profile2_.get());
EXPECT_TRUE(loader_->IsAnyProfileLoading());
- EXPECT_TRUE(keep_alive_service_->is_keeping_alive());
+ EXPECT_TRUE(HasKeepAlive());
FinishLoadingProfile(profile1_.get());
EXPECT_TRUE(loader_->IsAnyProfileLoading());
- EXPECT_TRUE(keep_alive_service_->is_keeping_alive());
+ EXPECT_TRUE(HasKeepAlive());
FinishLoadingProfile(profile2_.get());
EXPECT_FALSE(loader_->IsAnyProfileLoading());
- EXPECT_FALSE(keep_alive_service_->is_keeping_alive());
+ EXPECT_FALSE(HasKeepAlive());
}
TEST_F(ProfileLoaderUnittest, TestInvalidatingCurrentLoad) {
EXPECT_FALSE(loader_->IsAnyProfileLoading());
- EXPECT_FALSE(keep_alive_service_->is_keeping_alive());
+ EXPECT_FALSE(HasKeepAlive());
StartLoadingProfile(profile1_.get());
loader_->InvalidatePendingProfileLoads();
// The profile is still considered loading even though we will do nothing when
// it gets here.
EXPECT_TRUE(loader_->IsAnyProfileLoading());
- EXPECT_TRUE(keep_alive_service_->is_keeping_alive());
+ EXPECT_TRUE(HasKeepAlive());
FinishLoadingProfile(profile1_.get());
EXPECT_EQ(NULL, last_callback_result_);