diff --git a/chrome/app/nibs/ScreenCaptureNotification.xib b/chrome/app/nibs/ScreenCaptureNotification.xib
deleted file mode 100644
index f9c05d6ddef174..00000000000000
--- a/chrome/app/nibs/ScreenCaptureNotification.xib
+++ /dev/null
@@ -1,382 +0,0 @@
-
-
-
- 1070
- 12C60
- 2549
- 1187.34
- 625.00
-
-
-
-
-
-
-
- YES
-
-
- window
-
-
-
- 17
-
-
-
- stopSharing:
-
-
-
- 18
-
-
-
- statusField_
-
-
-
- 25
-
-
-
- stopButton_
-
-
-
- 26
-
-
-
- delegate
-
-
-
- 22
-
-
-
-
- YES
-
- 0
-
- YES
-
-
-
-
-
- -2
-
-
- File's Owner
-
-
- -1
-
-
- First Responder
-
-
- -3
-
-
- Application
-
-
- 3
-
-
- YES
-
-
-
-
-
- 4
-
-
- YES
-
-
-
-
-
-
- 13
-
-
- YES
-
-
-
-
-
- 14
-
-
-
-
- 23
-
-
- YES
-
-
-
-
-
- 24
-
-
-
-
-
-
- YES
-
- YES
- -1.IBPluginDependency
- -2.IBPluginDependency
- -3.IBPluginDependency
- 13.IBPluginDependency
- 14.IBPluginDependency
- 23.IBPluginDependency
- 24.IBPluginDependency
- 3.IBPluginDependency
- 3.IBWindowTemplateEditedContentRect
- 3.NSWindowTemplate.visibleAtLaunch
- 4.CustomClassName
- 4.IBPluginDependency
-
-
- YES
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- {{200, 1287}, {466, 40}}
-
- ScreenCaptureNotificationView
- com.apple.InterfaceBuilder.CocoaPlugin
-
-
-
- YES
-
-
-
-
-
- YES
-
-
-
-
- 27
-
-
-
- YES
-
- ScreenCaptureNotificationView
- NSView
-
- IBProjectSource
- ./Classes/ScreenCaptureNotificationView.h
-
-
-
- ScreenCaptureNotificationWindow
- NSWindow
-
- IBProjectSource
- ./Classes/ScreenCaptureNotificationWindow.h
-
-
-
- ScreenCaptureNotificationController
- NSWindowController
-
- stopSharing:
- id
-
-
- stopSharing:
-
- stopSharing:
- id
-
-
-
- YES
-
- YES
- statusField_
- stopButton_
-
-
- YES
- NSTextField
- NSButton
-
-
-
- YES
-
- YES
- statusField_
- stopButton_
-
-
- YES
-
- statusField_
- NSTextField
-
-
- stopButton_
- NSButton
-
-
-
-
- IBProjectSource
- ./Classes/ScreenCaptureNotificationController.h
-
-
-
-
- 0
- IBCocoaFramework
-
- com.apple.InterfaceBuilder.CocoaPlugin.macosx
-
-
-
- com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3
-
-
- YES
- 3
-
-
diff --git a/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h b/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h
index f1bc31a1bf4bf5..ca803a70034892 100644
--- a/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h
+++ b/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h
@@ -7,31 +7,39 @@
#include
#include "base/callback.h"
+#include "base/gtest_prod_util.h"
+#include "base/mac/scoped_nsobject.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/screen_capture_notification_ui.h"
// Controller for the screen capture notification window which allows the user
// to quickly stop screen capturing.
-@interface ScreenCaptureNotificationController : NSWindowController {
+@interface ScreenCaptureNotificationController
+ : NSWindowController {
@private
base::Closure stop_callback_;
- string16 text_;
- IBOutlet NSTextField* statusField_;
- IBOutlet NSButton* stopButton_;
+ base::scoped_nsobject stopButton_;
}
- (id)initWithCallback:(const base::Closure&)stop_callback
text:(const string16&)text;
-- (IBAction)stopSharing:(id)sender;
-@end
+- (void)stopSharing:(id)sender;
-// A floating window with a custom border. The custom border and background
-// content is defined by DisconnectView. Declared here so that it can be
-// instantiated via a xib.
-@interface ScreenCaptureNotificationWindow : NSWindow
@end
-// The custom background/border for the ScreenCaptureNotificationWindow.
-// Declared here so that it can be instantiated via a xib.
-@interface ScreenCaptureNotificationView : NSView
-@end
+class ScreenCaptureNotificationUICocoa : public ScreenCaptureNotificationUI {
+ public:
+ explicit ScreenCaptureNotificationUICocoa(const string16& text);
+ virtual ~ScreenCaptureNotificationUICocoa();
+
+ // ScreenCaptureNotificationUI interface.
+ virtual void OnStarted(const base::Closure& stop_callback) OVERRIDE;
+
+ private:
+ friend class ScreenCaptureNotificationUICocoaTest;
+
+ const string16 text_;
+ base::scoped_nsobject windowController_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenCaptureNotificationUICocoa);
+};
diff --git a/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.mm b/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.mm
index 631a15001f6df5..6f5cc4ecec2347 100644
--- a/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.mm
+++ b/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.mm
@@ -2,60 +2,65 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import
-
#include "chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h"
+#import
+
#include "base/compiler_specific.h"
#include "base/i18n/rtl.h"
-#include "base/mac/bundle_locations.h"
+#include "base/mac/mac_util.h"
+#include "base/mac/scoped_nsobject.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+#include "skia/ext/skia_utils_mac.h"
+#import "ui/base/cocoa/controls/blue_label_button.h"
+#include "ui/base/cocoa/window_size_constants.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/font.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_util_mac.h"
+#include "ui/gfx/text_elider.h"
+#include "ui/native_theme/native_theme.h"
+
+const CGFloat kMinimumWidth = 460;
+const CGFloat kMaximumWidth = 1000;
+const CGFloat kHorizontalMargin = 10;
+const CGFloat kPadding = 5;
+const CGFloat kPaddingLeft = 10;
+const CGFloat kWindowCornerRadius = 2;
@interface ScreenCaptureNotificationController()
-- (void)Hide;
+- (void)hide;
+- (void)populateWithText:(const string16&)text;
@end
-class ScreenCaptureNotificationUICocoa : public ScreenCaptureNotificationUI {
- public:
- explicit ScreenCaptureNotificationUICocoa(const string16& text);
- virtual ~ScreenCaptureNotificationUICocoa();
-
- // ScreenCaptureNotificationUI interface.
- virtual void OnStarted(const base::Closure& stop_callback) OVERRIDE;
+@interface ScreenCaptureNotificationView : NSView
+@end
- private:
- const string16 text_;
- ScreenCaptureNotificationController* window_controller_;
+@interface WindowGripView : NSImageView
+- (WindowGripView*)init;
+@end
- DISALLOW_COPY_AND_ASSIGN(ScreenCaptureNotificationUICocoa);
-};
ScreenCaptureNotificationUICocoa::ScreenCaptureNotificationUICocoa(
const string16& text)
- : text_(text),
- window_controller_(nil) {
+ : text_(text) {
}
-ScreenCaptureNotificationUICocoa::~ScreenCaptureNotificationUICocoa() {
- // ScreenCaptureNotificationController is responsible for releasing itself in
- // its windowWillClose: method.
- [window_controller_ Hide];
- window_controller_ = nil;
-}
+ScreenCaptureNotificationUICocoa::~ScreenCaptureNotificationUICocoa() {}
void ScreenCaptureNotificationUICocoa::OnStarted(
const base::Closure& stop_callback) {
DCHECK(!stop_callback.is_null());
- DCHECK(window_controller_ == nil);
+ DCHECK(!windowController_);
- window_controller_ =
- [[ScreenCaptureNotificationController alloc]
- initWithCallback:stop_callback
- text:text_];
- [window_controller_ showWindow:nil];
+ windowController_.reset([[ScreenCaptureNotificationController alloc]
+ initWithCallback:stop_callback
+ text:text_]);
+ [windowController_ showWindow:nil];
}
scoped_ptr ScreenCaptureNotificationUI::Create(
@@ -67,191 +72,159 @@ - (void)Hide;
@implementation ScreenCaptureNotificationController
- (id)initWithCallback:(const base::Closure&)stop_callback
text:(const string16&)text {
- NSString* nibpath =
- [base::mac::FrameworkBundle() pathForResource:@"ScreenCaptureNotification"
- ofType:@"nib"];
- self = [super initWithWindowNibPath:nibpath owner:self];
+ base::scoped_nsobject window(
+ [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO]);
+ [window setReleasedWhenClosed:NO];
+ [window setBackgroundColor:[NSColor clearColor]];
+ [window setOpaque:NO];
+ [window setHasShadow:YES];
+ [window setLevel:NSStatusWindowLevel];
+ [window setMovableByWindowBackground:YES];
+ [window setDelegate:self];
+
+ self = [super initWithWindow:window];
if (self) {
stop_callback_ = stop_callback;
- text_ = text;
+ [self populateWithText:text];
+
+ // Center the window at the bottom of the screen, above the dock (if
+ // present).
+ NSRect desktopRect = [[NSScreen mainScreen] visibleFrame];
+ NSRect contentRect = [[window contentView] frame];
+ NSRect windowRect =
+ NSMakeRect((NSWidth(desktopRect) - NSWidth(contentRect)) / 2,
+ NSMinY(desktopRect),
+ NSWidth(contentRect),
+ NSHeight(contentRect));
+ [window setFrame:windowRect display:YES];
}
return self;
}
-- (void)dealloc {
- [super dealloc];
-}
-
-- (IBAction)stopSharing:(id)sender {
+- (void)stopSharing:(id)sender {
if (!stop_callback_.is_null()) {
- stop_callback_.Run();
+ base::Closure callback = stop_callback_;
+ stop_callback_.Reset();
+ callback.Run(); // Deletes |self|.
}
}
-- (void)Hide {
+- (void)hide {
stop_callback_.Reset();
[self close];
}
-- (void)windowDidLoad {
- [statusField_ setStringValue:base::SysUTF16ToNSString(text_)];
-
- string16 button_label =
- l10n_util::GetStringUTF16(IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_STOP);
- [stopButton_ setTitle:base::SysUTF16ToNSString(button_label)];
-
- // Resize the window dynamically based on the content.
- CGFloat oldConnectedWidth = NSWidth([statusField_ bounds]);
- [statusField_ sizeToFit];
- NSRect statusFrame = [statusField_ frame];
- CGFloat newConnectedWidth = NSWidth(statusFrame);
-
- // Set a max width for the connected to text field.
- const int kMaximumStatusWidth = 400;
- if (newConnectedWidth > kMaximumStatusWidth) {
- newConnectedWidth = kMaximumStatusWidth;
- statusFrame.size.width = newConnectedWidth;
- [statusField_ setFrame:statusFrame];
- }
-
- CGFloat oldstopWidth = NSWidth([stopButton_ bounds]);
+- (void)populateWithText:(const string16&)text {
+ base::scoped_nsobject content(
+ [[ScreenCaptureNotificationView alloc]
+ initWithFrame:ui::kWindowSizeDeterminedLater]);
+ [[self window] setContentView:content];
+
+ // Create button.
+ stopButton_.reset([[BlueLabelButton alloc] initWithFrame:NSZeroRect]);
+ [stopButton_ setTitle:l10n_util::GetNSString(
+ IDS_MEDIA_SCREEN_CAPTURE_NOTIFICATION_STOP)];
+ [stopButton_ setTarget:self];
+ [stopButton_ setAction:@selector(stopSharing:)];
[stopButton_ sizeToFit];
- NSRect stopFrame = [stopButton_ frame];
- CGFloat newStopWidth = NSWidth(stopFrame);
-
- // Move the stop button appropriately.
- stopFrame.origin.x += newConnectedWidth - oldConnectedWidth;
- [stopButton_ setFrame:stopFrame];
-
- // Then resize the window appropriately.
- NSWindow *window = [self window];
- NSRect windowFrame = [window frame];
- windowFrame.size.width += (newConnectedWidth - oldConnectedWidth +
- newStopWidth - oldstopWidth);
- [window setFrame:windowFrame display:NO];
+ [content addSubview:stopButton_];
+
+ CGFloat buttonWidth = NSWidth([stopButton_ frame]);
+ CGFloat totalHeight = kPadding + NSHeight([stopButton_ frame]) + kPadding;
+
+ // Create grip icon.
+ base::scoped_nsobject gripView([[WindowGripView alloc] init]);
+ [content addSubview:gripView];
+ CGFloat gripWidth = NSWidth([gripView frame]);
+ CGFloat gripHeight = NSHeight([gripView frame]);
+ [gripView
+ setFrameOrigin:NSMakePoint(kPaddingLeft, (totalHeight - gripHeight) / 2)];
+
+ // Create text label.
+ int maximumWidth =
+ std::min(kMaximumWidth, NSWidth([[NSScreen mainScreen] visibleFrame]));
+ int maxLabelWidth = maximumWidth - kPaddingLeft - kPadding -
+ kHorizontalMargin * 2 - gripWidth - buttonWidth;
+ gfx::Font font(ui::ResourceBundle::GetSharedInstance()
+ .GetFont(ui::ResourceBundle::BaseFont)
+ .GetNativeFont());
+ string16 elidedText =
+ ElideText(text, font, maxLabelWidth, gfx::ELIDE_IN_MIDDLE);
+ NSString* statusText = base::SysUTF16ToNSString(elidedText);
+ base::scoped_nsobject statusTextField(
+ [[NSTextField alloc] initWithFrame:ui::kWindowSizeDeterminedLater]);
+ [statusTextField setEditable:NO];
+ [statusTextField setSelectable:NO];
+ [statusTextField setDrawsBackground:NO];
+ [statusTextField setBezeled:NO];
+ [statusTextField setStringValue:statusText];
+ [statusTextField setFont:font.GetNativeFont()];
+ [statusTextField sizeToFit];
+ [statusTextField setFrameOrigin:NSMakePoint(
+ kPaddingLeft + kHorizontalMargin + gripWidth,
+ (totalHeight - NSHeight([statusTextField frame])) / 2)];
+ [content addSubview:statusTextField];
+
+ // Resize content view to fit controls.
+ CGFloat minimumLableWidth = kMinimumWidth - kPaddingLeft - kPadding -
+ kHorizontalMargin * 2 - gripWidth - buttonWidth;
+ CGFloat lableWidth =
+ std::max(NSWidth([statusTextField frame]), minimumLableWidth);
+ CGFloat totalWidth = kPaddingLeft + kPadding + kHorizontalMargin * 2 +
+ gripWidth + lableWidth + buttonWidth;
+ [content setFrame:NSMakeRect(0, 0, totalWidth, totalHeight)];
+
+ // Move the button to the right place.
+ NSPoint buttonOrigin =
+ NSMakePoint(totalWidth - kPadding - buttonWidth, kPadding);
+ [stopButton_ setFrameOrigin:buttonOrigin];
if (base::i18n::IsRTL()) {
- // Handle right to left case
- CGFloat buttonInset = NSWidth(windowFrame) - NSMaxX(stopFrame);
- CGFloat buttonTextSpacing
- = NSMinX(stopFrame) - NSMaxX(statusFrame);
- stopFrame.origin.x = buttonInset;
- statusFrame.origin.x = NSMaxX(stopFrame) + buttonTextSpacing;
- [statusField_ setFrame:statusFrame];
- [stopButton_ setFrame:stopFrame];
+ [stopButton_
+ setFrameOrigin:NSMakePoint(totalWidth - NSMaxX([stopButton_ frame]),
+ NSMinY([stopButton_ frame]))];
+ [statusTextField
+ setFrameOrigin:NSMakePoint(totalWidth - NSMaxX([statusTextField frame]),
+ NSMinY([statusTextField frame]))];
+ [gripView setFrameOrigin:NSMakePoint(totalWidth - NSMaxX([gripView frame]),
+ NSMinY([gripView frame]))];
}
-
- // Center the window at the bottom of the screen, above the dock (if present).
- NSRect desktopRect = [[NSScreen mainScreen] visibleFrame];
- NSRect windowRect = [[self window] frame];
- CGFloat x = (NSWidth(desktopRect) - NSWidth(windowRect)) / 2;
- CGFloat y = NSMinY(desktopRect);
- [[self window] setFrameOrigin:NSMakePoint(x, y)];
}
- (void)windowWillClose:(NSNotification*)notification {
- [self stopSharing:self];
- [self autorelease];
+ [self stopSharing:nil];
}
@end
+@implementation ScreenCaptureNotificationView
-@implementation ScreenCaptureNotificationWindow
-- (id)initWithContentRect:(NSRect)contentRect
- styleMask:(NSUInteger)aStyle
- backing:(NSBackingStoreType)bufferingType
- defer:(BOOL)flag {
- // Pass NSBorderlessWindowMask for the styleMask to remove the title bar.
- self = [super initWithContentRect:contentRect
- styleMask:NSBorderlessWindowMask
- backing:bufferingType
- defer:flag];
+- (void)drawRect:(NSRect)dirtyRect {
+ [gfx::SkColorToSRGBNSColor(ui::NativeTheme::instance()->GetSystemColor(
+ ui::NativeTheme::kColorId_DialogBackground)) set];
+ [[NSBezierPath bezierPathWithRoundedRect:[self bounds]
+ xRadius:kWindowCornerRadius
+ yRadius:kWindowCornerRadius] fill];
+}
- if (self) {
- // Set window to be clear and non-opaque so we can see through it.
- [self setBackgroundColor:[NSColor clearColor]];
- [self setOpaque:NO];
- [self setMovableByWindowBackground:YES];
+@end
- // Pull the window up to Status Level so that it always displays.
- [self setLevel:NSStatusWindowLevel];
- }
+@implementation WindowGripView
+- (WindowGripView*)init {
+ gfx::Image gripImage =
+ ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ IDR_SCREEN_CAPTURE_NOTIFICATION_GRIP,
+ ui::ResourceBundle::RTL_DISABLED);
+ self = [super
+ initWithFrame:NSMakeRect(0, 0, gripImage.Width(), gripImage.Height())];
+ [self setImage:gripImage.ToNSImage()];
return self;
}
-@end
-@implementation ScreenCaptureNotificationView
-- (void)drawRect:(NSRect)rect {
- // All magic numbers taken from screen shots provided by UX.
- NSRect bounds = NSInsetRect([self bounds], 1, 1);
-
- NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:bounds
- xRadius:5
- yRadius:5];
- NSColor *gray = [NSColor colorWithCalibratedWhite:0.91 alpha:1.0];
- [gray setFill];
- [path fill];
- [path setLineWidth:4];
- NSColor *green = [NSColor colorWithCalibratedRed:0.13
- green:0.69
- blue:0.11
- alpha:1.0];
- [green setStroke];
- [path stroke];
-
-
- // Draw drag handle on proper side
- const CGFloat kHeight = 21.0;
- const CGFloat kBaseInset = 12.0;
- const CGFloat kDragHandleWidth = 5.0;
-
- NSColor *dark = [NSColor colorWithCalibratedWhite:0.70 alpha:1.0];
- NSColor *light = [NSColor colorWithCalibratedWhite:0.97 alpha:1.0];
-
- // Turn off aliasing so it's nice and crisp.
- NSGraphicsContext *context = [NSGraphicsContext currentContext];
- BOOL alias = [context shouldAntialias];
- [context setShouldAntialias:NO];
-
- // Handle bidirectional locales properly.
- CGFloat inset = base::i18n::IsRTL() ?
- NSMaxX(bounds) - kBaseInset - kDragHandleWidth : kBaseInset;
-
- NSPoint top = NSMakePoint(inset, NSMidY(bounds) - kHeight / 2.0);
- NSPoint bottom = NSMakePoint(inset, top.y + kHeight);
-
- path = [NSBezierPath bezierPath];
- [path moveToPoint:top];
- [path lineToPoint:bottom];
- [dark setStroke];
- [path stroke];
-
- top.x += 1;
- bottom.x += 1;
- path = [NSBezierPath bezierPath];
- [path moveToPoint:top];
- [path lineToPoint:bottom];
- [light setStroke];
- [path stroke];
-
- top.x += 2;
- bottom.x += 2;
- path = [NSBezierPath bezierPath];
- [path moveToPoint:top];
- [path lineToPoint:bottom];
- [dark setStroke];
- [path stroke];
-
- top.x += 1;
- bottom.x += 1;
- path = [NSBezierPath bezierPath];
- [path moveToPoint:top];
- [path lineToPoint:bottom];
- [light setStroke];
- [path stroke];
-
- [context setShouldAntialias:alias];
+- (BOOL)mouseDownCanMoveWindow {
+ return YES;
}
-
@end
diff --git a/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa_unittest.mm b/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa_unittest.mm
new file mode 100644
index 00000000000000..284ca3e6328883
--- /dev/null
+++ b/chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa_unittest.mm
@@ -0,0 +1,104 @@
+// Copyright 2013 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.
+
+#import "chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h"
+
+#include "base/bind.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+
+@interface ScreenCaptureNotificationController (ExposedForTesting)
+- (NSButton*)stopButton;
+@end
+
+@implementation ScreenCaptureNotificationController (ExposedForTesting)
+- (NSButton*)stopButton {
+ return stopButton_;
+}
+@end
+
+class ScreenCaptureNotificationUICocoaTest : public CocoaTest {
+ public:
+ ScreenCaptureNotificationUICocoaTest()
+ : callback_called_(0) {
+ }
+
+ virtual void TearDown() OVERRIDE {
+ callback_called_ = 0;
+ target_.reset();
+ EXPECT_EQ(0, callback_called_);
+
+ CocoaTest::TearDown();
+ }
+
+ void StopCallback() {
+ ++callback_called_;
+ }
+
+ protected:
+ ScreenCaptureNotificationController* controller() {
+ return target_->windowController_.get();
+ }
+
+ scoped_ptr target_;
+ int callback_called_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenCaptureNotificationUICocoaTest);
+};
+
+TEST_F(ScreenCaptureNotificationUICocoaTest, CreateAndDestroy) {
+ target_.reset(
+ new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
+}
+
+TEST_F(ScreenCaptureNotificationUICocoaTest, CreateAndStart) {
+ target_.reset(
+ new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
+ target_->OnStarted(
+ base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
+ base::Unretained(this)));
+}
+
+TEST_F(ScreenCaptureNotificationUICocoaTest, LongTitle) {
+ target_.reset(new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16(
+ "Very long title, with very very very very very very very very "
+ "very very very very very very very very very very very very many "
+ "words")));
+ target_->OnStarted(
+ base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
+ base::Unretained(this)));
+ EXPECT_LE(NSWidth([[controller() window] frame]), 1000);
+}
+
+TEST_F(ScreenCaptureNotificationUICocoaTest, ShortTitle) {
+ target_.reset(
+ new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
+ target_->OnStarted(
+ base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
+ base::Unretained(this)));
+ EXPECT_EQ(460, NSWidth([[controller() window] frame]));
+}
+
+TEST_F(ScreenCaptureNotificationUICocoaTest, ClickStop) {
+ target_.reset(
+ new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
+ target_->OnStarted(
+ base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
+ base::Unretained(this)));
+
+ [[controller() stopButton] performClick:nil];
+ EXPECT_EQ(1, callback_called_);
+}
+
+TEST_F(ScreenCaptureNotificationUICocoaTest, CloseWindow) {
+ target_.reset(
+ new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
+ target_->OnStarted(
+ base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
+ base::Unretained(this)));
+
+ [[controller() window] close];
+
+ EXPECT_EQ(1, callback_called_);
+}
diff --git a/chrome/chrome_nibs.gypi b/chrome/chrome_nibs.gypi
index 57fa683a9803a7..5f706da0a3a639 100644
--- a/chrome/chrome_nibs.gypi
+++ b/chrome/chrome_nibs.gypi
@@ -24,7 +24,7 @@
'app/nibs/ContentBlockedPlugins.xib',
'app/nibs/ContentBlockedPopups.xib',
'app/nibs/ContentBlockedGeolocation.xib',
- 'app/nibs/ContentBlockedSavePassword.xib',
+ 'app/nibs/ContentBlockedSavePassword.xib',
'app/nibs/ContentBlockedSimple.xib',
'app/nibs/ContentProtocolHandlers.xib',
'app/nibs/CookieDetailsView.xib',
@@ -63,7 +63,6 @@
'app/nibs/InfoBar.xib',
'app/nibs/Notification.xib',
'app/nibs/Panel.xib',
- 'app/nibs/ScreenCaptureNotification.xib',
], # mac_untranslated_xibs
'mac_all_xibs': [
'<@(mac_translated_xibs)',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 3921ec74c0eaf6..68fe179bc4dca7 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1555,6 +1555,7 @@
'browser/ui/cocoa/panels/panel_cocoa_unittest.mm',
'browser/ui/cocoa/profile_menu_controller_unittest.mm',
'browser/ui/cocoa/run_loop_testing_unittest.mm',
+ 'browser/ui/cocoa/screen_capture_notification_ui_cocoa_unittest.mm',
'browser/ui/cocoa/status_bubble_mac_unittest.mm',
'browser/ui/cocoa/status_icons/status_icon_mac_unittest.mm',
'browser/ui/cocoa/styled_text_field_cell_unittest.mm',