Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/avatar_menu_button.h" | |
| 6 | |
| 7 #include "base/path_service.h" | |
| 8 #include "chrome/browser/profiles/profile_manager.h" | |
| 9 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" | |
| 10 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 11 #include "chrome/common/chrome_paths.h" | |
| 12 #include "chrome/test/base/in_process_browser_test.h" | |
| 13 #include "chrome/test/base/testing_browser_process.h" | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 void CreateTestingProfile() { | |
| 18 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 19 EXPECT_EQ(1, profile_manager->GetNumberOfProfiles()); | |
| 20 | |
| 21 FilePath path; | |
| 22 PathService::Get(chrome::DIR_USER_DATA, &path); | |
| 23 path = path.AppendASCII("test_profile"); | |
| 24 if (!file_util::PathExists(path)) | |
| 25 CHECK(file_util::CreateDirectory(path)); | |
| 26 Profile* profile = | |
| 27 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); | |
| 28 profile_manager->RegisterTestingProfile(profile, true); | |
| 29 | |
| 30 EXPECT_EQ(2, profile_manager->GetNumberOfProfiles()); | |
| 31 } | |
| 32 | |
| 33 typedef InProcessBrowserTest AvatarMenuButtonTest; | |
| 34 | |
| 35 // Verify that clicking the avatar button a second time hides the avatar bubble. | |
|
Peter Kasting
2013/01/04 00:58:43
Nit: Technically, this doesn't actually verify tha
sail
2013/01/04 19:23:08
Done.
| |
| 36 IN_PROC_BROWSER_TEST_F(AvatarMenuButtonTest, HideOnSecondClick) { | |
| 37 if (!ProfileManager::IsMultipleProfilesEnabled()) | |
| 38 return; | |
| 39 | |
| 40 CreateTestingProfile(); | |
| 41 | |
| 42 BrowserView* browser_view = reinterpret_cast<BrowserView*>( | |
| 43 browser()->window()); | |
| 44 AvatarMenuButton* button = browser_view->frame()->GetAvatarMenuButton(); | |
| 45 ASSERT_TRUE(button); | |
| 46 | |
| 47 // Verify that clicking once shows the avatar bubble. | |
| 48 static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked( | |
| 49 NULL, gfx::Point()); | |
| 50 MessageLoop::current()->RunUntilIdle(); | |
| 51 EXPECT_TRUE(AvatarMenuBubbleView::IsShowing()); | |
| 52 | |
| 53 // Verify that clicking again doesn't reshow it. | |
| 54 static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked( | |
| 55 NULL, gfx::Point()); | |
| 56 // Hide the bubble manually. In the browser this would normally happen during | |
| 57 // the event processing. | |
| 58 AvatarMenuBubbleView::Hide(); | |
| 59 MessageLoop::current()->RunUntilIdle(); | |
| 60 EXPECT_FALSE(AvatarMenuBubbleView::IsShowing()); | |
| 61 } | |
| 62 | |
| 63 } // namespace | |
| OLD | NEW |