| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/app_list/profile_loader.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "base/bind.h" | 9 #include "base/bind.h" |
| 6 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/app_list/profile_loader.h" | |
| 10 #include "chrome/browser/ui/app_list/test/fake_profile.h" | 12 #include "chrome/browser/ui/app_list/test/fake_profile.h" |
| 11 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" | 13 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 class ProfileLoaderUnittest : public testing::Test { | 16 class ProfileLoaderUnittest : public testing::Test { |
| 15 public: | 17 public: |
| 16 void SetUp() override { | 18 void SetUp() override { |
| 17 last_callback_result_ = NULL; | 19 last_callback_result_ = NULL; |
| 18 profile1_.reset( | 20 profile1_.reset( |
| 19 new FakeProfile("p1", base::FilePath(FILE_PATH_LITERAL("profile1")))); | 21 new FakeProfile("p1", base::FilePath(FILE_PATH_LITERAL("profile1")))); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 | 40 |
| 39 void OnProfileLoaded(Profile* profile) { | 41 void OnProfileLoaded(Profile* profile) { |
| 40 last_callback_result_ = profile; | 42 last_callback_result_ = profile; |
| 41 } | 43 } |
| 42 | 44 |
| 43 bool HasKeepAlive() const { | 45 bool HasKeepAlive() const { |
| 44 return loader_->keep_alive_.get() != NULL; | 46 return loader_->keep_alive_.get() != NULL; |
| 45 } | 47 } |
| 46 | 48 |
| 47 protected: | 49 protected: |
| 48 scoped_ptr<ProfileLoader> loader_; | 50 std::unique_ptr<ProfileLoader> loader_; |
| 49 scoped_ptr<FakeProfileStore> profile_store_; | 51 std::unique_ptr<FakeProfileStore> profile_store_; |
| 50 scoped_ptr<FakeProfile> profile1_; | 52 std::unique_ptr<FakeProfile> profile1_; |
| 51 scoped_ptr<FakeProfile> profile2_; | 53 std::unique_ptr<FakeProfile> profile2_; |
| 52 Profile* last_callback_result_; | 54 Profile* last_callback_result_; |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 TEST_F(ProfileLoaderUnittest, LoadASecondProfileBeforeTheFirstFinishes) { | 57 TEST_F(ProfileLoaderUnittest, LoadASecondProfileBeforeTheFirstFinishes) { |
| 56 EXPECT_FALSE(loader_->IsAnyProfileLoading()); | 58 EXPECT_FALSE(loader_->IsAnyProfileLoading()); |
| 57 | 59 |
| 58 StartLoadingProfile(profile1_.get()); | 60 StartLoadingProfile(profile1_.get()); |
| 59 EXPECT_TRUE(loader_->IsAnyProfileLoading()); | 61 EXPECT_TRUE(loader_->IsAnyProfileLoading()); |
| 60 | 62 |
| 61 StartLoadingProfile(profile2_.get()); | 63 StartLoadingProfile(profile2_.get()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 StartLoadingProfile(profile1_.get()); | 110 StartLoadingProfile(profile1_.get()); |
| 109 loader_->InvalidatePendingProfileLoads(); | 111 loader_->InvalidatePendingProfileLoads(); |
| 110 // The profile is still considered loading even though we will do nothing when | 112 // The profile is still considered loading even though we will do nothing when |
| 111 // it gets here. | 113 // it gets here. |
| 112 EXPECT_TRUE(loader_->IsAnyProfileLoading()); | 114 EXPECT_TRUE(loader_->IsAnyProfileLoading()); |
| 113 EXPECT_TRUE(HasKeepAlive()); | 115 EXPECT_TRUE(HasKeepAlive()); |
| 114 | 116 |
| 115 FinishLoadingProfile(profile1_.get()); | 117 FinishLoadingProfile(profile1_.get()); |
| 116 EXPECT_EQ(NULL, last_callback_result_); | 118 EXPECT_EQ(NULL, last_callback_result_); |
| 117 } | 119 } |
| OLD | NEW |