Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: chrome/browser/profiles/profile_loader_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix silly compile error Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
20 #if defined(OS_CHROMEOS)
21 #include "base/command_line.h"
22 #include "chrome/common/chrome_switches.h"
23 #endif // defined(OS_CHROMEOS)
24
19 namespace { 25 namespace {
20 26
21 using ::testing::_; 27 using ::testing::_;
22 using ::testing::Invoke; 28 using ::testing::Invoke;
23 using ::testing::Return; 29 using ::testing::Return;
24 using ::testing::StrictMock; 30 using ::testing::StrictMock;
25 using ::testing::WithArgs; 31 using ::testing::WithArgs;
26 32
27 class TestProfileLoader : public ProfileLoader { 33 class TestProfileLoader : public ProfileLoader {
28 public: 34 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 friend class base::RefCountedThreadSafe<MockCallback>; 68 friend class base::RefCountedThreadSafe<MockCallback>;
63 virtual ~MockCallback(); 69 virtual ~MockCallback();
64 70
65 private: 71 private:
66 DISALLOW_COPY_AND_ASSIGN(MockCallback); 72 DISALLOW_COPY_AND_ASSIGN(MockCallback);
67 }; 73 };
68 74
69 MockCallback::MockCallback() {} 75 MockCallback::MockCallback() {}
70 MockCallback::~MockCallback() {} 76 MockCallback::~MockCallback() {}
71 77
72 TEST(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) { 78 class ProfileLoaderTest : public testing::Test {
79 protected:
80 static void SetUpTestCase() {
81 #if defined(OS_CHROMEOS)
82 // Needed to handle http://crbug.com/119175.
83 CommandLine::ForCurrentProcess()->AppendSwitch(
84 switches::kDisableZeroBrowsersOpenForTests);
85 #endif // defined(OS_CHROMEOS)
86 }
87
88 private:
89 content::TestBrowserThreadBundle thread_bundle_;
90 };
91
92 TEST_F(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
73 TestingProfile profile; 93 TestingProfile profile;
74 base::FilePath fake_profile_path_1 = 94 base::FilePath fake_profile_path_1 =
75 base::FilePath::FromUTF8Unsafe("fake/profile 1"); 95 base::FilePath::FromUTF8Unsafe("fake/profile 1");
76 base::FilePath fake_profile_path_2 = 96 base::FilePath fake_profile_path_2 =
77 base::FilePath::FromUTF8Unsafe("fake/profile 2"); 97 base::FilePath::FromUTF8Unsafe("fake/profile 2");
78 98
79 TestProfileLoader loader; 99 TestProfileLoader loader;
80 EXPECT_FALSE(loader.IsAnyProfileLoading()); 100 EXPECT_FALSE(loader.IsAnyProfileLoading());
81 101
82 // path_1 never loads. 102 // path_1 never loads.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 loader.LoadProfileInvalidatingOtherLoads( 145 loader.LoadProfileInvalidatingOtherLoads(
126 fake_profile_path_2, base::Bind(&MockCallback::Run, path_2_load)); 146 fake_profile_path_2, base::Bind(&MockCallback::Run, path_2_load));
127 147
128 // Make a second request for path_1, and invalidate it. 148 // Make a second request for path_1, and invalidate it.
129 loader.LoadProfileInvalidatingOtherLoads( 149 loader.LoadProfileInvalidatingOtherLoads(
130 fake_profile_path_1, base::Bind(&MockCallback::Run, path_1_load)); 150 fake_profile_path_1, base::Bind(&MockCallback::Run, path_1_load));
131 loader.InvalidatePendingProfileLoads(); 151 loader.InvalidatePendingProfileLoads();
132 } 152 }
133 153
134 } // namespace 154 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698