Chromium Code Reviews| Index: chrome/browser/ui/app_list/profile_loader_unittest.cc |
| diff --git a/chrome/browser/ui/app_list/profile_loader_unittest.cc b/chrome/browser/ui/app_list/profile_loader_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9ccd79934fb4da8279300e5548e0633fc1e6296d |
| --- /dev/null |
| +++ b/chrome/browser/ui/app_list/profile_loader_unittest.cc |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/bind.h" |
| +#include "base/files/file_path.h" |
| +#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 { |
| + last_callback_result_ = NULL; |
| + profile1_.reset( |
| + new FakeProfile("p1", base::FilePath(FILE_PATH_LITERAL("profile1")))); |
| + profile2_.reset( |
| + new FakeProfile("p2", base::FilePath(FILE_PATH_LITERAL("profile2")))); |
| + |
| + profile_store_.reset(new FakeProfileStore( |
| + base::FilePath(FILE_PATH_LITERAL("udd")))); |
| + keep_alive_service_ = new FakeKeepAliveService; |
| + loader_.reset(new ProfileLoader(profile_store_.get(), |
| + make_scoped_ptr(keep_alive_service_))); |
| + } |
| + |
| + virtual void TearDown() OVERRIDE { |
| + } |
| + |
| + void OnProfileLoaded(Profile* profile) { |
| + last_callback_result_ = profile; |
| + } |
| + |
| + FakeKeepAliveService* keep_alive_service_; |
| + scoped_ptr<ProfileLoader> loader_; |
| + scoped_ptr<FakeProfileStore> profile_store_; |
| + scoped_ptr<FakeProfile> profile1_; |
| + scoped_ptr<FakeProfile> profile2_; |
| + Profile* last_callback_result_; |
| +}; |
| + |
| +TEST_F(ProfileLoaderUnittest, LoadASecondProfileBeforeTheFirstFinishes) { |
|
benwells
2013/09/26 06:55:29
Would be good to test InvalidatePendingProfileLoad
benwells
2013/09/26 06:55:29
Also would be good to test this classes interactio
koz (OOO until 15th September)
2013/09/26 22:12:47
Done.
koz (OOO until 15th September)
2013/09/26 22:12:47
Done.
|
| + EXPECT_FALSE(loader_->IsAnyProfileLoading()); |
| + |
| + loader_->LoadProfileInvalidatingOtherLoads( |
| + profile1_->GetPath(), |
| + base::Bind(&ProfileLoaderUnittest::OnProfileLoaded, |
| + base::Unretained(this))); |
| + EXPECT_TRUE(loader_->IsAnyProfileLoading()); |
| + loader_->LoadProfileInvalidatingOtherLoads( |
| + profile2_->GetPath(), |
| + base::Bind(&ProfileLoaderUnittest::OnProfileLoaded, |
| + base::Unretained(this))); |
| + |
| + profile_store_->RunCallbackByPath(profile1_->GetPath(), profile1_.get()); |
| + EXPECT_EQ(NULL, last_callback_result_); |
| + |
| + profile_store_->RunCallbackByPath(profile2_->GetPath(), profile2_.get()); |
| + EXPECT_EQ(profile2_.get(), last_callback_result_); |
| + |
| + EXPECT_FALSE(loader_->IsAnyProfileLoading()); |
| +} |