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

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: 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/frame/browser_view.h"
10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/testing_browser_process.h"
13
14 namespace {
15
16 void CreateTestingProfile() {
17 ProfileManager* profile_manager = g_browser_process->profile_manager();
18 EXPECT_EQ(1, profile_manager->GetNumberOfProfiles());
19
20 FilePath path;
21 PathService::Get(chrome::DIR_USER_DATA, &path);
22 path = path.AppendASCII("test_profile");
23 if (!file_util::PathExists(path))
24 CHECK(file_util::CreateDirectory(path));
25 Profile* profile =
26 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
27 profile_manager->RegisterTestingProfile(profile, true);
28
29 EXPECT_EQ(2, profile_manager->GetNumberOfProfiles());
30 }
31
32 typedef InProcessBrowserTest AvatarMenuButtonTest;
33
34 // Verify that clicking the avatar button a second time hides the avatar bubble.
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(button->bubble_widget());
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 button->bubble_widget()->Close();
58 MessageLoop::current()->RunUntilIdle();
59 EXPECT_FALSE(button->bubble_widget());
60 }
61
62 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698