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(1u, 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(2u, profile_manager->GetNumberOfProfiles()); |
| 31 } |
| 32 |
| 33 typedef InProcessBrowserTest AvatarMenuButtonTest; |
| 34 |
| 35 IN_PROC_BROWSER_TEST_F(AvatarMenuButtonTest, HideOnSecondClick) { |
| 36 if (!ProfileManager::IsMultipleProfilesEnabled()) |
| 37 return; |
| 38 |
| 39 CreateTestingProfile(); |
| 40 |
| 41 BrowserView* browser_view = reinterpret_cast<BrowserView*>( |
| 42 browser()->window()); |
| 43 AvatarMenuButton* button = browser_view->frame()->GetAvatarMenuButton(); |
| 44 ASSERT_TRUE(button); |
| 45 |
| 46 // Verify that clicking once shows the avatar bubble. |
| 47 static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked( |
| 48 NULL, gfx::Point()); |
| 49 MessageLoop::current()->RunUntilIdle(); |
| 50 EXPECT_TRUE(AvatarMenuBubbleView::IsShowing()); |
| 51 |
| 52 // Verify that clicking again doesn't reshow it. |
| 53 static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked( |
| 54 NULL, gfx::Point()); |
| 55 // Hide the bubble manually. In the browser this would normally happen during |
| 56 // the event processing. |
| 57 AvatarMenuBubbleView::Hide(); |
| 58 MessageLoop::current()->RunUntilIdle(); |
| 59 EXPECT_FALSE(AvatarMenuBubbleView::IsShowing()); |
| 60 } |
| 61 |
| 62 } // namespace |
OLD | NEW |