1 // Copyright 2013 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.
5 #import "chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
11 @interface ScreenCaptureNotificationController (ExposedForTesting)
12 - (NSButton*)stopButton;
15 @implementation ScreenCaptureNotificationController (ExposedForTesting)
16 - (NSButton*)stopButton {
21 class ScreenCaptureNotificationUICocoaTest : public CocoaTest {
23 ScreenCaptureNotificationUICocoaTest()
24 : callback_called_(0) {
27 virtual void TearDown() OVERRIDE {
30 EXPECT_EQ(0, callback_called_);
32 CocoaTest::TearDown();
40 ScreenCaptureNotificationController* controller() {
41 return target_->windowController_.get();
44 scoped_ptr<ScreenCaptureNotificationUICocoa> target_;
47 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureNotificationUICocoaTest);
50 TEST_F(ScreenCaptureNotificationUICocoaTest, CreateAndDestroy) {
52 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
55 TEST_F(ScreenCaptureNotificationUICocoaTest, CreateAndStart) {
57 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
59 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
60 base::Unretained(this)));
63 TEST_F(ScreenCaptureNotificationUICocoaTest, LongTitle) {
64 target_.reset(new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16(
65 "Very long title, with very very very very very very very very "
66 "very very very very very very very very very very very very many "
69 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
70 base::Unretained(this)));
71 EXPECT_LE(NSWidth([[controller() window] frame]), 1000);
74 TEST_F(ScreenCaptureNotificationUICocoaTest, ShortTitle) {
76 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
78 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
79 base::Unretained(this)));
80 EXPECT_EQ(460, NSWidth([[controller() window] frame]));
83 TEST_F(ScreenCaptureNotificationUICocoaTest, ClickStop) {
85 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
87 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
88 base::Unretained(this)));
90 [[controller() stopButton] performClick:nil];
91 EXPECT_EQ(1, callback_called_);
94 TEST_F(ScreenCaptureNotificationUICocoaTest, CloseWindow) {
96 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title")));
98 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback,
99 base::Unretained(this)));
101 [[controller() window] close];
103 EXPECT_EQ(1, callback_called_);