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

Unified 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: address review comments Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/avatar_menu_button_browsertest.cc
diff --git a/chrome/browser/ui/views/avatar_menu_button_browsertest.cc b/chrome/browser/ui/views/avatar_menu_button_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ed28223922fc9e57d616c9ceca63a50574bc4e41
--- /dev/null
+++ b/chrome/browser/ui/views/avatar_menu_button_browsertest.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/avatar_menu_button.h"
+
+#include "base/path_service.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/views/avatar_menu_bubble_view.h"
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/testing_browser_process.h"
+
+namespace {
+
+void CreateTestingProfile() {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ EXPECT_EQ(1, profile_manager->GetNumberOfProfiles());
+
+ FilePath path;
+ PathService::Get(chrome::DIR_USER_DATA, &path);
+ path = path.AppendASCII("test_profile");
+ if (!file_util::PathExists(path))
+ CHECK(file_util::CreateDirectory(path));
+ Profile* profile =
+ Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
+ profile_manager->RegisterTestingProfile(profile, true);
+
+ EXPECT_EQ(2, profile_manager->GetNumberOfProfiles());
+}
+
+typedef InProcessBrowserTest AvatarMenuButtonTest;
+
+// 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.
+IN_PROC_BROWSER_TEST_F(AvatarMenuButtonTest, HideOnSecondClick) {
+ if (!ProfileManager::IsMultipleProfilesEnabled())
+ return;
+
+ CreateTestingProfile();
+
+ BrowserView* browser_view = reinterpret_cast<BrowserView*>(
+ browser()->window());
+ AvatarMenuButton* button = browser_view->frame()->GetAvatarMenuButton();
+ ASSERT_TRUE(button);
+
+ // Verify that clicking once shows the avatar bubble.
+ static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked(
+ NULL, gfx::Point());
+ MessageLoop::current()->RunUntilIdle();
+ EXPECT_TRUE(AvatarMenuBubbleView::IsShowing());
+
+ // Verify that clicking again doesn't reshow it.
+ static_cast<views::MenuButtonListener*>(button)->OnMenuButtonClicked(
+ NULL, gfx::Point());
+ // Hide the bubble manually. In the browser this would normally happen during
+ // the event processing.
+ AvatarMenuBubbleView::Hide();
+ MessageLoop::current()->RunUntilIdle();
+ EXPECT_FALSE(AvatarMenuBubbleView::IsShowing());
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698