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

Unified 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 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/profile_menu_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm
===================================================================
--- chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm (revision 174685)
+++ chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm (working copy)
@@ -5,10 +5,13 @@
#import "chrome/browser/ui/cocoa/profile_menu_controller.h"
#include "base/memory/scoped_nsobject.h"
+#include "base/threading/thread_restrictions.h"
#include "chrome/browser/profiles/avatar_menu_model.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "chrome/browser/ui/cocoa/run_loop_testing.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/test_browser_window.h"
#include "grit/generated_resources.h"
#include "testing/gtest_mac.h"
@@ -212,3 +215,27 @@
p3_browser.reset();
VerifyProfileNamedIsActive(@"Profile 3", __LINE__);
}
+
+TEST_F(ProfileMenuControllerTest, DeleteActiveProfile) {
+ TestingProfileManager* manager = testing_profile_manager();
+
+ manager->CreateTestingProfile("Profile 2");
+ TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3");
+ ASSERT_EQ(3U, manager->profile_manager()->GetNumberOfProfiles());
+
+ const FilePath profile3_path = profile3->GetPath();
+ manager->DeleteTestingProfile("Profile 3");
+
+ // Simulate an unloaded profile by setting the "last used" local state pref
+ // the profile that was just deleted.
+ PrefService* local_state = g_browser_process->local_state();
+ local_state->SetString(prefs::kProfileLastUsed,
+ profile3_path.BaseName().MaybeAsASCII());
+
+ // Simulate the active browser changing to NULL and ensure a profile doesn't
+ // get created by disallowing IO operations temporarily.
+ const bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(false);
+ [controller() activeBrowserChangedTo:NULL];
+ base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
+}
+
« 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