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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 435863002: Fix some infobar problems. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using static_cast Created 6 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
index 99300210a2b397b05fca0597c93d2d8b3cc3b7f1..65b1df2b23019a923a9d7cfe2284cb064b0e7f88 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
@@ -8,6 +8,7 @@
#include "base/mac/sdk_forward_declarations.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window_testing.h"
#include "chrome/browser/infobars/infobar_service.h"
@@ -25,6 +26,8 @@
#import "chrome/browser/ui/cocoa/history_overlay_controller.h"
#import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
#import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
+#import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
+#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/nsview_additions.h"
#import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
#import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
@@ -35,7 +38,9 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/test_utils.h"
#import "testing/gtest_mac.h"
+#include "ui/gfx/animation/slide_animation.h"
namespace {
@@ -64,6 +69,23 @@ enum ViewID {
} // namespace
+@interface InfoBarContainerController(TestingAPI)
+- (BOOL)isTopInfoBarAnimationRunning;
+@end
+
+@implementation InfoBarContainerController(TestingAPI)
+- (BOOL)isTopInfoBarAnimationRunning {
+ InfoBarController* infoBarController = [infobarControllers_ objectAtIndex:0];
+ if (infoBarController) {
+ const gfx::SlideAnimation& infobarAnimation =
+ static_cast<const InfoBarCocoa*>(
+ infoBarController.infobar)->animation();
Robert Sesek 2014/08/27 14:59:45 nit: indent +4 more spaces
Malcolm 2014/08/28 01:42:39 Done. thanks!
+ return infobarAnimation.is_animating();
+ }
+ return NO;
+}
+@end
+
class BrowserWindowControllerTest : public InProcessBrowserTest {
public:
BrowserWindowControllerTest() : InProcessBrowserTest() {
@@ -134,6 +156,64 @@ class BrowserWindowControllerTest : public InProcessBrowserTest {
return height;
}
+ static void CheckTopInfoBarAnimation(
+ InfoBarContainerController* info_bar_container_controller,
+ const base::Closure& quit_task) {
+ if (![info_bar_container_controller isTopInfoBarAnimationRunning])
+ quit_task.Run();
+ }
+
+ static void CheckBookmarkBarAnimation(
+ BookmarkBarController* bookmark_bar_controller,
+ const base::Closure& quit_task) {
+ if (![bookmark_bar_controller isAnimationRunning])
+ quit_task.Run();
+ }
+
+ void WaitForTopInfoBarAnimationToFinish() {
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+
+ base::Timer timer(false, true);
+ timer.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(15),
+ base::Bind(&CheckTopInfoBarAnimation,
+ [controller() infoBarContainerController],
+ runner->QuitClosure()));
+ runner->Run();
+ }
+
+ void WaitForBookmarkBarAnimationToFinish() {
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+
+ base::Timer timer(false, true);
+ timer.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(15),
+ base::Bind(&CheckBookmarkBarAnimation,
+ [controller() bookmarkBarController],
+ runner->QuitClosure()));
+ runner->Run();
+ }
+
+ NSInteger GetExpectedTopInfoBarTipHeight() {
+ InfoBarContainerController* info_bar_container_controller =
+ [controller() infoBarContainerController];
+ CGFloat overlapping_tip_height =
+ [info_bar_container_controller overlappingTipHeight];
+ LocationBarViewMac* location_bar_view = [controller() locationBarBridge];
+ NSPoint icon_bottom = location_bar_view->GetPageInfoBubblePoint();
+
+ NSPoint info_bar_top = NSMakePoint(0,
+ NSHeight([info_bar_container_controller view].frame) -
+ overlapping_tip_height);
+ info_bar_top = [[info_bar_container_controller view]
+ convertPoint:info_bar_top toView:nil];
+ return icon_bottom.y - info_bar_top.y;
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(BrowserWindowControllerTest);
};
@@ -354,3 +434,31 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window);
}
+
+// Tests that top infobar tip is streched when bookmark bar becomes SHOWN/HIDDEN
+IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
+ InfoBarTipStrechedWhenBookmarkBarStatusChanged) {
+ EXPECT_FALSE([controller() isBookmarkBarVisible]);
+ ShowInfoBar(browser());
+ // The infobar tip is animated during the infobar is being added, wait until
+ // it completes.
+ WaitForTopInfoBarAnimationToFinish();
+
+ EXPECT_FALSE([[controller() infoBarContainerController]
+ shouldSuppressTopInfoBarTip]);
+
+ NSInteger max_tip_height = infobars::InfoBar::kMaximumArrowTargetHeight +
+ infobars::InfoBar::kSeparatorLineHeight;
+
+ chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
+ WaitForBookmarkBarAnimationToFinish();
+ EXPECT_TRUE([controller() isBookmarkBarVisible]);
+ EXPECT_EQ(std::min(GetExpectedTopInfoBarTipHeight(), max_tip_height),
+ [[controller() infoBarContainerController] overlappingTipHeight]);
+
+ chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
+ WaitForBookmarkBarAnimationToFinish();
+ EXPECT_FALSE([controller() isBookmarkBarVisible]);
+ EXPECT_EQ(std::min(GetExpectedTopInfoBarTipHeight(), max_tip_height),
+ [[controller() infoBarContainerController] overlappingTipHeight]);
+}
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698