Chromium Code Reviews| Index: chrome/browser/app_controller_mac_browsertest.mm |
| diff --git a/chrome/browser/app_controller_mac_browsertest.mm b/chrome/browser/app_controller_mac_browsertest.mm |
| index 52fa358be367f07ac4379687bdb787fef7de07ba..43679133779435ae25efe4a239b51717dc849321 100644 |
| --- a/chrome/browser/app_controller_mac_browsertest.mm |
| +++ b/chrome/browser/app_controller_mac_browsertest.mm |
| @@ -22,11 +22,13 @@ |
| #include "chrome/browser/apps/app_browsertest_util.h" |
| #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/history/history_service_factory.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_list.h" |
| #include "chrome/browser/ui/browser_window.h" |
| #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
| +#include "chrome/browser/ui/cocoa/history_menu_bridge.h" |
| #include "chrome/browser/ui/host_desktop.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/browser/ui/user_manager.h" |
| @@ -79,6 +81,13 @@ void SendAppleEventToOpenUrlToAppController(const GURL& url) { |
| method_invoke(controller, get_url, shortcut_event, NULL); |
| } |
| +void RunClosureWhenProfileInitialized(const base::Closure& closure, |
| + Profile* profile, |
| + Profile::CreateStatus status) { |
| + if (status == Profile::CREATE_STATUS_INITIALIZED) |
| + closure.Run(); |
| +} |
| + |
| } // namespace |
| @interface TestOpenShortcutOnStartup : NSObject |
| @@ -427,6 +436,63 @@ class AppControllerMainMenuBrowserTest : public InProcessBrowserTest { |
| }; |
| IN_PROC_BROWSER_TEST_F(AppControllerMainMenuBrowserTest, |
| + HistoryMenuResetAfterProfileDeletion) { |
| + ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| + AppController* ac = [NSApp delegate]; |
| + |
| + // Use the existing profile as profile 1. |
| + Profile* profile1 = browser()->profile(); |
| + |
| + // Create profile 2. |
| + base::FilePath profile2_path = |
| + profile_manager->GenerateNextProfileDirectoryPath(); |
| + base::RunLoop run_loop; |
| + profile_manager->CreateProfileAsync( |
| + profile2_path, |
| + base::Bind(&RunClosureWhenProfileInitialized, |
| + run_loop.QuitClosure()), |
| + base::string16(), |
| + base::string16(), |
| + std::string()); |
| + run_loop.Run(); |
| + Profile* profile2 = profile_manager->GetProfileByPath(profile2_path); |
| + DCHECK(profile2); |
|
Robert Sesek
2015/04/21 20:12:30
ASSERT_TRUE
Mike Lerman
2015/04/21 20:18:48
Done.
|
| + |
| + // Switch the controller to profile1. |
| + [ac windowChangedToProfile:profile1]; |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + // Verify the controller's History Menu corresponds to profile1. |
| + DCHECK_EQ([ac historyMenuBridge]->service(), |
|
Robert Sesek
2015/04/21 20:12:30
EXPECT_EQ
Mike Lerman
2015/04/21 20:18:48
Done.
|
| + HistoryServiceFactory::GetForProfile(profile1, |
| + ServiceAccessType::EXPLICIT_ACCESS)); |
| + |
| + // Switch the controller to profile2. |
| + [ac windowChangedToProfile:profile2]; |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + // Verify the controller's History Menu has changed. |
| + DCHECK_EQ([ac historyMenuBridge]->service(), |
|
Robert Sesek
2015/04/21 20:12:30
EXPECT_EQ
Mike Lerman
2015/04/21 20:18:48
Done.
|
| + HistoryServiceFactory::GetForProfile(profile2, |
| + ServiceAccessType::EXPLICIT_ACCESS)); |
| + DCHECK_NE( |
|
Robert Sesek
2015/04/21 20:12:30
EXPECT_NE
Mike Lerman
2015/04/21 20:18:48
Done.
|
| + HistoryServiceFactory::GetForProfile(profile1, |
| + ServiceAccessType::EXPLICIT_ACCESS), |
| + HistoryServiceFactory::GetForProfile(profile2, |
| + ServiceAccessType::EXPLICIT_ACCESS)); |
| + |
| + // Delete profile2. |
| + profile_manager->ScheduleProfileForDeletion( |
| + profile2->GetPath(), ProfileManager::CreateCallback()); |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + // Verify the controller's history is back to profile1. |
| + DCHECK_EQ([ac historyMenuBridge]->service(), |
|
Robert Sesek
2015/04/21 20:12:30
EXPECT_EQ
Mike Lerman
2015/04/21 20:18:48
Done.
|
| + HistoryServiceFactory::GetForProfile(profile1, |
| + ServiceAccessType::EXPLICIT_ACCESS)); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(AppControllerMainMenuBrowserTest, |
| BookmarksMenuIsRestoredAfterProfileSwitch) { |
| ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| base::scoped_nsobject<AppController> ac([[AppController alloc] init]); |