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

Unified Diff: chrome/browser/app_controller_mac_unittest.mm

Issue 14923004: [Mac] AppController needs to update its "last profile" pointer when the active profile is deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/app_controller_mac_unittest.mm
diff --git a/chrome/browser/app_controller_mac_unittest.mm b/chrome/browser/app_controller_mac_unittest.mm
index b391fd76b12af0adec2ac091ccfaa44cfec9f5e5..3287f350b25f19e8ccd14492dd634a4d25a6fbd6 100644
--- a/chrome/browser/app_controller_mac_unittest.mm
+++ b/chrome/browser/app_controller_mac_unittest.mm
@@ -4,12 +4,40 @@
#import <Cocoa/Cocoa.h>
+#import "chrome/browser/app_controller_mac.h"
+
+#include "base/files/file_path.h"
#include "base/memory/scoped_nsobject.h"
+#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/app/chrome_command_ids.h"
-#import "chrome/browser/app_controller_mac.h"
+#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/base/testing_profile_manager.h"
+#include "chrome/test/base/ui_test_utils.h"
#include "testing/platform_test.h"
class AppControllerTest : public PlatformTest {
+ protected:
+ AppControllerTest()
+ : extension_event_router_forwarder_(new extensions::EventRouterForwarder),
+ ui_thread_(content::BrowserThread::UI, &message_loop_),
+ db_thread_(content::BrowserThread::DB, &message_loop_),
+ file_thread_(content::BrowserThread::FILE, &message_loop_) {
+ }
+
+ virtual void TearDown() {
+ TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL);
+ message_loop_.RunUntilIdle();
+ }
+
+ scoped_refptr<extensions::EventRouterForwarder>
+ extension_event_router_forwarder_;
+ base::MessageLoopForUI message_loop_;
+ content::TestBrowserThread ui_thread_;
+ content::TestBrowserThread db_thread_;
+ content::TestBrowserThread file_thread_;
};
TEST_F(AppControllerTest, DockMenu) {
@@ -25,3 +53,30 @@ TEST_F(AppControllerTest, DockMenu) {
EXPECT_EQ(@selector(commandFromDock:), [item action]);
}
}
+
+TEST_F(AppControllerTest, LastProfile) {
+ TestingProfileManager manager(TestingBrowserProcess::GetGlobal());
+ ASSERT_TRUE(manager.SetUp());
+
+ // Create two profiles.
+ base::FilePath dest_path1 =
+ manager.CreateTestingProfile("New Profile 1")->GetPath();
+ base::FilePath dest_path2 =
+ manager.CreateTestingProfile("New Profile 2")->GetPath();
+ ASSERT_EQ(2U, manager.profile_manager()->GetNumberOfProfiles());
+ ASSERT_EQ(2U, manager.profile_manager()->GetLoadedProfiles().size());
+
+ PrefService* local_state = g_browser_process->local_state();
+ local_state->SetString(prefs::kProfileLastUsed,
+ dest_path1.BaseName().MaybeAsASCII());
+
+ scoped_nsobject<AppController> ac([[AppController alloc] init]);
+
+ // Delete the active profile.
+ manager.profile_manager()->ScheduleProfileForDeletion(
+ dest_path1, ProfileManager::CreateCallback());
+
+ message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(dest_path2, [ac lastProfile]->GetPath());
+}

Powered by Google App Engine
This is Rietveld 408576698