| 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/profiles/profile_loader.h" | 5 #include "chrome/browser/profiles/profile_loader.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/lifetime/application_lifetime.h" | 12 #include "chrome/browser/lifetime/application_lifetime.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_loader.h" | 14 #include "chrome/browser/profiles/profile_loader.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 using ::testing::_; | 22 using ::testing::_; |
| 22 using ::testing::Invoke; | 23 using ::testing::Invoke; |
| 23 using ::testing::Return; | 24 using ::testing::Return; |
| 24 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
| 25 using ::testing::WithArgs; | 26 using ::testing::WithArgs; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 virtual ~MockCallback(); | 64 virtual ~MockCallback(); |
| 64 | 65 |
| 65 private: | 66 private: |
| 66 DISALLOW_COPY_AND_ASSIGN(MockCallback); | 67 DISALLOW_COPY_AND_ASSIGN(MockCallback); |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 MockCallback::MockCallback() {} | 70 MockCallback::MockCallback() {} |
| 70 MockCallback::~MockCallback() {} | 71 MockCallback::~MockCallback() {} |
| 71 | 72 |
| 72 TEST(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) { | 73 TEST(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) { |
| 74 content::TestBrowserThreadBundle thread_bundle_; |
| 73 TestingProfile profile; | 75 TestingProfile profile; |
| 74 base::FilePath fake_profile_path_1 = | 76 base::FilePath fake_profile_path_1 = |
| 75 base::FilePath::FromUTF8Unsafe("fake/profile 1"); | 77 base::FilePath::FromUTF8Unsafe("fake/profile 1"); |
| 76 base::FilePath fake_profile_path_2 = | 78 base::FilePath fake_profile_path_2 = |
| 77 base::FilePath::FromUTF8Unsafe("fake/profile 2"); | 79 base::FilePath::FromUTF8Unsafe("fake/profile 2"); |
| 78 | 80 |
| 79 TestProfileLoader loader; | 81 TestProfileLoader loader; |
| 80 EXPECT_FALSE(loader.IsAnyProfileLoading()); | 82 EXPECT_FALSE(loader.IsAnyProfileLoading()); |
| 81 | 83 |
| 82 // path_1 never loads. | 84 // path_1 never loads. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 loader.LoadProfileInvalidatingOtherLoads( | 127 loader.LoadProfileInvalidatingOtherLoads( |
| 126 fake_profile_path_2, base::Bind(&MockCallback::Run, path_2_load)); | 128 fake_profile_path_2, base::Bind(&MockCallback::Run, path_2_load)); |
| 127 | 129 |
| 128 // Make a second request for path_1, and invalidate it. | 130 // Make a second request for path_1, and invalidate it. |
| 129 loader.LoadProfileInvalidatingOtherLoads( | 131 loader.LoadProfileInvalidatingOtherLoads( |
| 130 fake_profile_path_1, base::Bind(&MockCallback::Run, path_1_load)); | 132 fake_profile_path_1, base::Bind(&MockCallback::Run, path_1_load)); |
| 131 loader.InvalidatePendingProfileLoads(); | 133 loader.InvalidatePendingProfileLoads(); |
| 132 } | 134 } |
| 133 | 135 |
| 134 } // namespace | 136 } // namespace |
| OLD | NEW |