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

Side by Side Diff: chrome/browser/ui/views/avatar_menu_button_browsertest.cc

Issue 11646008: Close avatar bubble when avatar button is clicked a second time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_button.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698