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

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

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More test fixes. Created 7 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/prefs/browser_prefs.h" 22 #include "chrome/browser/prefs/browser_prefs.h"
23 #include "chrome/browser/prefs/incognito_mode_prefs.h" 23 #include "chrome/browser/prefs/incognito_mode_prefs.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_info_cache.h" 25 #include "chrome/browser/profiles/profile_info_cache.h"
26 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #include "chrome/common/chrome_constants.h" 28 #include "chrome/common/chrome_constants.h"
29 #include "chrome/common/chrome_paths.h" 29 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "chrome/test/base/browser_with_test_window_test.h"
32 #include "chrome/test/base/scoped_testing_local_state.h" 33 #include "chrome/test/base/scoped_testing_local_state.h"
33 #include "chrome/test/base/test_browser_window.h" 34 #include "chrome/test/base/test_browser_window.h"
34 #include "chrome/test/base/testing_browser_process.h" 35 #include "chrome/test/base/testing_browser_process.h"
35 #include "chrome/test/base/testing_profile.h" 36 #include "chrome/test/base/testing_profile.h"
36 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
37 #include "content/public/test/test_browser_thread_bundle.h" 38 #include "content/public/test/test_browser_thread_bundle.h"
38 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
40 41
41 #if defined(OS_CHROMEOS) 42 #if defined(OS_CHROMEOS)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 BrowserThread::PostTask( 76 BrowserThread::PostTask(
76 BrowserThread::FILE, FROM_HERE, 77 BrowserThread::FILE, FROM_HERE,
77 base::Bind(base::IgnoreResult(&file_util::CreateDirectory), path)); 78 base::Bind(base::IgnoreResult(&file_util::CreateDirectory), path));
78 79
79 return new TestingProfile(path, this); 80 return new TestingProfile(path, this);
80 } 81 }
81 }; 82 };
82 83
83 } // namespace 84 } // namespace
84 85
85 class ProfileManagerTest : public testing::Test { 86 class ProfileManagerTest : public BrowserWithTestWindowTest {
Jered 2013/10/01 20:57:34 This seems nice, but how is this change related to
samarth 2013/10/02 00:18:00 It just need to define content::RenderViewHostTest
86 protected: 87 protected:
87 class MockObserver { 88 class MockObserver {
88 public: 89 public:
89 MOCK_METHOD2(OnProfileCreated, 90 MOCK_METHOD2(OnProfileCreated,
90 void(Profile* profile, Profile::CreateStatus status)); 91 void(Profile* profile, Profile::CreateStatus status));
91 }; 92 };
92 93
93 ProfileManagerTest() 94 ProfileManagerTest()
94 : local_state_(TestingBrowserProcess::GetGlobal()) { 95 : local_state_(TestingBrowserProcess::GetGlobal()) {
95 } 96 }
96 97
97 virtual void SetUp() { 98 virtual void SetUp() {
99 BrowserWithTestWindowTest::SetUp();
98 // Create a new temporary directory, and store the path 100 // Create a new temporary directory, and store the path
99 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 101 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
100 TestingBrowserProcess::GetGlobal()->SetProfileManager( 102 TestingBrowserProcess::GetGlobal()->SetProfileManager(
101 new UnittestProfileManager(temp_dir_.path())); 103 new UnittestProfileManager(temp_dir_.path()));
102 104
103 #if defined(OS_CHROMEOS) 105 #if defined(OS_CHROMEOS)
104 CommandLine* cl = CommandLine::ForCurrentProcess(); 106 CommandLine* cl = CommandLine::ForCurrentProcess();
105 cl->AppendSwitch(switches::kTestType); 107 cl->AppendSwitch(switches::kTestType);
106 #endif 108 #endif
107 } 109 }
108 110
109 virtual void TearDown() { 111 virtual void TearDown() {
112 BrowserWithTestWindowTest::TearDown();
110 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); 113 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL);
111 base::RunLoop().RunUntilIdle(); 114 base::RunLoop().RunUntilIdle();
112 } 115 }
113 116
114 // Helper function to create a profile with |name| for a profile |manager|. 117 // Helper function to create a profile with |name| for a profile |manager|.
115 void CreateProfileAsync(ProfileManager* manager, 118 void CreateProfileAsync(ProfileManager* manager,
116 const std::string& name, 119 const std::string& name,
117 MockObserver* mock_observer) { 120 MockObserver* mock_observer) {
118 manager->CreateProfileAsync( 121 manager->CreateProfileAsync(
119 temp_dir_.path().AppendASCII(name), 122 temp_dir_.path().AppendASCII(name),
120 base::Bind(&MockObserver::OnProfileCreated, 123 base::Bind(&MockObserver::OnProfileCreated,
121 base::Unretained(mock_observer)), 124 base::Unretained(mock_observer)),
122 UTF8ToUTF16(name), 125 UTF8ToUTF16(name),
123 string16(), 126 string16(),
124 std::string()); 127 std::string());
125 } 128 }
126 129
127 #if defined(OS_CHROMEOS)
128 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
129 chromeos::ScopedTestCrosSettings test_cros_settings_;
130 #endif
131
132 // The path to temporary directory used to contain the test operations. 130 // The path to temporary directory used to contain the test operations.
133 base::ScopedTempDir temp_dir_; 131 base::ScopedTempDir temp_dir_;
134 ScopedTestingLocalState local_state_; 132 ScopedTestingLocalState local_state_;
135
136 content::TestBrowserThreadBundle thread_bundle_;
137
138 #if defined(OS_CHROMEOS)
139 chromeos::ScopedTestUserManager test_user_manager_;
140 #endif
141 }; 133 };
142 134
143 TEST_F(ProfileManagerTest, GetProfile) { 135 TEST_F(ProfileManagerTest, GetProfile) {
144 base::FilePath dest_path = temp_dir_.path(); 136 base::FilePath dest_path = temp_dir_.path();
145 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); 137 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile"));
146 138
147 ProfileManager* profile_manager = g_browser_process->profile_manager(); 139 ProfileManager* profile_manager = g_browser_process->profile_manager();
148 140
149 // Successfully create a profile. 141 // Successfully create a profile.
150 Profile* profile = profile_manager->GetProfile(dest_path); 142 Profile* profile = profile_manager->GetProfile(dest_path);
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 dest_path2.BaseName().MaybeAsASCII()); 754 dest_path2.BaseName().MaybeAsASCII());
763 profile_manager->ScheduleProfileForDeletion(dest_path2, 755 profile_manager->ScheduleProfileForDeletion(dest_path2,
764 ProfileManager::CreateCallback()); 756 ProfileManager::CreateCallback());
765 // Spin the message loop so that all the callbacks can finish running. 757 // Spin the message loop so that all the callbacks can finish running.
766 base::RunLoop().RunUntilIdle(); 758 base::RunLoop().RunUntilIdle();
767 759
768 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 760 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
769 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 761 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
770 } 762 }
771 #endif // !defined(OS_MACOSX) 763 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698