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

Unified Diff: chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm

Issue 615663002: Mac: Remove download shelf from AX hierarchy when not visible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test Created 6 years, 3 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 | « chrome/browser/ui/cocoa/download/download_shelf_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm b/chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm
index 8ce96cad72aa9bec077c9012862965e706ca1517..02847730d74b303d85a3e9ffc014783c215ea71c 100644
--- a/chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm
@@ -4,6 +4,7 @@
#import <Cocoa/Cocoa.h>
+#import "base/mac/scoped_block.h"
#import "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/download/download_shelf.h"
@@ -60,6 +61,10 @@ using ::testing::AnyNumber;
}
@end
+@interface DownloadShelfController (Testing)
+- (void)animationDidEnd:(NSAnimation*)animation;
+@end
+
// Subclass of the DownloadShelfController to override scheduleAutoClose and
// cancelAutoClose. During regular operation, a scheduled autoClose waits for 5
// seconds before closing the shelf (unless it is cancelled during this
@@ -69,7 +74,11 @@ using ::testing::AnyNumber;
@public
int scheduleAutoCloseCount_;
int cancelAutoCloseCount_;
+ base::mac::ScopedBlock<dispatch_block_t> closeAnimationHandler_;
}
+
+// Handler will be called at the end of a close animation.
+- (void)setCloseAnimationHandler:(dispatch_block_t)handler;
@end
@implementation CountingDownloadShelfController
@@ -81,6 +90,17 @@ using ::testing::AnyNumber;
-(void)cancelAutoClose {
++cancelAutoCloseCount_;
}
+
+- (void)setCloseAnimationHandler:(dispatch_block_t)handler {
+ closeAnimationHandler_.reset(handler);
+}
+
+- (void)animationDidEnd:(NSAnimation*)animation {
+ [super animationDidEnd:animation];
+ if (closeAnimationHandler_)
+ closeAnimationHandler_.get()();
+}
+
@end
namespace {
@@ -360,4 +380,21 @@ TEST_F(DownloadShelfControllerTest, CancelAutoCloseOnExit) {
shelf_.reset();
}
+// The view should not be hidden when the shelf is shown.
+// The view should be hidden after the closing animation.
+TEST_F(DownloadShelfControllerTest, ViewVisibility) {
+ [shelf_ showDownloadShelf:YES isUserAction:NO];
+ EXPECT_FALSE([[shelf_ view] isHidden]);
+
+ [shelf_ setCloseAnimationHandler:^{
+ base::MessageLoop::current()->QuitNow();
+ }];
+ [shelf_ showDownloadShelf:NO isUserAction:NO];
+ base::MessageLoop::current()->Run();
+ EXPECT_TRUE([[shelf_ view] isHidden]);
+
+ [shelf_ showDownloadShelf:YES isUserAction:NO];
+ EXPECT_FALSE([[shelf_ view] isHidden]);
+}
+
} // namespace
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_shelf_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698