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

Side by Side Diff: chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm

Issue 11661017: [Mac] Fix profile getting re-created / IO allowed dcheck with profile menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: [Mac] Fix profile getting re-created / IO allowed dcheck with profile menu. Created 7 years, 12 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
« no previous file with comments | « chrome/browser/ui/cocoa/profile_menu_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" 5 #import "chrome/browser/ui/cocoa/profile_menu_controller.h"
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/memory/scoped_nsobject.h"
8 #include "base/threading/thread_restrictions.h"
8 #include "chrome/browser/profiles/avatar_menu_model.h" 9 #include "chrome/browser/profiles/avatar_menu_model.h"
10 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/browser_list.h" 11 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
11 #include "chrome/browser/ui/cocoa/run_loop_testing.h" 13 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
14 #include "chrome/common/pref_names.h"
12 #include "chrome/test/base/test_browser_window.h" 15 #include "chrome/test/base/test_browser_window.h"
13 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
14 #include "testing/gtest_mac.h" 17 #include "testing/gtest_mac.h"
15 #include "ui/base/l10n/l10n_util_mac.h" 18 #include "ui/base/l10n/l10n_util_mac.h"
16 19
17 class ProfileMenuControllerTest : public CocoaProfileTest { 20 class ProfileMenuControllerTest : public CocoaProfileTest {
18 public: 21 public:
19 ProfileMenuControllerTest() { 22 ProfileMenuControllerTest() {
20 item_.reset([[NSMenuItem alloc] initWithTitle:@"Users" 23 item_.reset([[NSMenuItem alloc] initWithTitle:@"Users"
21 action:nil 24 action:nil
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 208
206 // Open a new browser and make sure it takes effect. 209 // Open a new browser and make sure it takes effect.
207 scoped_ptr<Browser> p3_browser( 210 scoped_ptr<Browser> p3_browser(
208 chrome::CreateBrowserWithTestWindowForProfile(profile3)); 211 chrome::CreateBrowserWithTestWindowForProfile(profile3));
209 BrowserList::SetLastActive(p3_browser.get()); 212 BrowserList::SetLastActive(p3_browser.get());
210 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); 213 VerifyProfileNamedIsActive(@"Profile 3", __LINE__);
211 214
212 p3_browser.reset(); 215 p3_browser.reset();
213 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); 216 VerifyProfileNamedIsActive(@"Profile 3", __LINE__);
214 } 217 }
218
219 TEST_F(ProfileMenuControllerTest, DeleteActiveProfile) {
220 TestingProfileManager* manager = testing_profile_manager();
221
222 manager->CreateTestingProfile("Profile 2");
223 TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3");
224 ASSERT_EQ(3U, manager->profile_manager()->GetNumberOfProfiles());
225
226 const FilePath profile3_path = profile3->GetPath();
227 manager->DeleteTestingProfile("Profile 3");
228
229 // Simulate an unloaded profile by setting the "last used" local state pref
230 // the profile that was just deleted.
231 PrefService* local_state = g_browser_process->local_state();
232 local_state->SetString(prefs::kProfileLastUsed,
233 profile3_path.BaseName().MaybeAsASCII());
234
235 // Simulate the active browser changing to NULL and ensure a profile doesn't
236 // get created by disallowing IO operations temporarily.
237 const bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(false);
238 [controller() activeBrowserChangedTo:NULL];
239 base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
240 }
241
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/profile_menu_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698