Chromium Code Reviews| Index: chrome/browser/ui/browser_command_controller_browsertest.cc |
| diff --git a/chrome/browser/ui/browser_command_controller_browsertest.cc b/chrome/browser/ui/browser_command_controller_browsertest.cc |
| index 1f71986976be3a6086a13d3573c2ebd3bcc4eb4a..c12d88b02a2d065b103ee7fc738e2de12523fce6 100644 |
| --- a/chrome/browser/ui/browser_command_controller_browsertest.cc |
| +++ b/chrome/browser/ui/browser_command_controller_browsertest.cc |
| @@ -4,12 +4,26 @@ |
| #include "chrome/browser/ui/browser_command_controller.h" |
| +#include "base/command_line.h" |
| #include "chrome/app/chrome_command_ids.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/browser/profiles/profile_window.h" |
| +#include "chrome/browser/search_engines/template_url_service_factory.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_commands.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/startup/startup_browser_creator.h" |
| #include "chrome/browser/ui/tab_modal_confirm_dialog_browsertest.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| +#include "components/search_engines/template_url_service.h" |
| +#include "components/signin/core/common/profile_management_switches.h" |
| +#include "components/signin/core/common/profile_management_switches.h" |
| +#include "content/public/browser/notification_service.h" |
| #include "content/public/test/test_utils.h" |
| typedef InProcessBrowserTest BrowserCommandControllerBrowserTest; |
| @@ -39,3 +53,50 @@ IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest, DisableFind) { |
| content::RunAllPendingInMessageLoop(); |
| EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FIND)); |
| } |
| + |
| +// This test also tests the BrowsingDataRemover that fires when all of a guest's |
|
Peter Kasting
2015/02/12 22:18:40
What about that BrowsingDataRemover does this test
Mike Lerman
2015/02/13 14:07:29
I tried rephrasing my comment here. I'm referencin
|
| +// browsers are closed, in ~Browser(). |
| +IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest, |
| + NewAvatarMenuEnabledInGuestMode) { |
| + switches::EnableNewAvatarMenuForTesting( |
| + base::CommandLine::ForCurrentProcess()); |
| + |
| + EXPECT_EQ(1U, BrowserList::GetInstance(chrome::GetActiveDesktop())->size()); |
| + |
| + // Create a guest browser nicely. Using CreateProfile() and CreateBrowser() |
| + // does incomplete initialization that would lead to |
| + // SystemUrlRequestContextGetter being leaked. |
| + scoped_ptr<content::WindowedNotificationObserver> browser_creation_observer; |
|
battre
2015/02/13 08:49:43
opt/nit: you could also create this on the stack.
Mike Lerman
2015/02/13 14:07:29
Done.
|
| + browser_creation_observer.reset(new content::WindowedNotificationObserver( |
| + chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
|
Peter Kasting
2015/02/12 22:18:40
Nit: Indent 4, not 6
Mike Lerman
2015/02/13 14:07:29
Done.
|
| + content::NotificationService::AllSources())); |
| + profiles::SwitchToGuestProfile(chrome::GetActiveDesktop(), |
| + ProfileManager::CreateCallback()); |
| + |
| + // RunUntilIdle() (racily) isn't sufficient to ensure browser creation, so |
| + // listen for the notification. |
| + base::MessageLoop::current()->RunUntilIdle(); |
| + browser_creation_observer->Wait(); |
| + EXPECT_EQ(2U, BrowserList::GetInstance(chrome::GetActiveDesktop())->size()); |
| + |
| + // Access the browser that was created for the new Guest Profile. |
| + Profile* guest = g_browser_process->profile_manager()->GetProfileByPath( |
| + ProfileManager::GetGuestProfilePath()); |
| + Browser* browser = chrome::FindAnyBrowser( |
| + guest, true, chrome::GetActiveDesktop()); |
| + EXPECT_TRUE(browser); |
| + |
| + // The BrowsingDataRemover needs a loaded TemplateUrlService or else it hangs |
| + // on to a CallbackList::Subscription forever. |
| + TemplateURLServiceFactory::GetForProfile(guest)->set_loaded(true); |
| + |
| + chrome::BrowserCommandController* command_controller = |
| + browser->command_controller(); |
|
Peter Kasting
2015/02/12 22:18:40
Nit: Just inline this into the next line, pulling
Mike Lerman
2015/02/13 14:07:29
Done.
|
| + const CommandUpdater* command_updater = command_controller->command_updater(); |
| + #if defined(OS_CHROMEOS) |
| + // Chrome OS uses system tray menu to handle multi-profiles. |
| + EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| + #else |
| + EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| + #endif |
| +} |