| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/screen_capture_notification_ui_cocoa.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 10 | 10 |
| 11 @interface ScreenCaptureNotificationController (ExposedForTesting) | 11 @interface ScreenCaptureNotificationController (ExposedForTesting) |
| 12 - (NSButton*)stopButton; | 12 - (NSButton*)stopButton; |
| 13 - (NSButton*)minimizeButton; |
| 13 @end | 14 @end |
| 14 | 15 |
| 15 @implementation ScreenCaptureNotificationController (ExposedForTesting) | 16 @implementation ScreenCaptureNotificationController (ExposedForTesting) |
| 16 - (NSButton*)stopButton { | 17 - (NSButton*)stopButton { |
| 17 return stopButton_; | 18 return stopButton_; |
| 18 } | 19 } |
| 20 |
| 21 - (NSButton*)minimizeButton { |
| 22 return minimizeButton_; |
| 23 } |
| 19 @end | 24 @end |
| 20 | 25 |
| 21 class ScreenCaptureNotificationUICocoaTest : public CocoaTest { | 26 class ScreenCaptureNotificationUICocoaTest : public CocoaTest { |
| 22 public: | 27 public: |
| 23 ScreenCaptureNotificationUICocoaTest() | 28 ScreenCaptureNotificationUICocoaTest() |
| 24 : callback_called_(0) { | 29 : callback_called_(0) { |
| 25 } | 30 } |
| 26 | 31 |
| 27 virtual void TearDown() OVERRIDE { | 32 virtual void TearDown() OVERRIDE { |
| 28 callback_called_ = 0; | 33 callback_called_ = 0; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 66 } |
| 62 | 67 |
| 63 TEST_F(ScreenCaptureNotificationUICocoaTest, LongTitle) { | 68 TEST_F(ScreenCaptureNotificationUICocoaTest, LongTitle) { |
| 64 target_.reset(new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16( | 69 target_.reset(new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16( |
| 65 "Very long title, with very very very very very very very very " | 70 "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 " | 71 "very very very very very very very very very very very very many " |
| 67 "words"))); | 72 "words"))); |
| 68 target_->OnStarted( | 73 target_->OnStarted( |
| 69 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback, | 74 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback, |
| 70 base::Unretained(this))); | 75 base::Unretained(this))); |
| 71 EXPECT_LE(NSWidth([[controller() window] frame]), 1000); | 76 // The elided label sometimes is a few pixels longer than the max width. So |
| 77 // allow a 5px off from the 1000px maximium. |
| 78 EXPECT_LE(NSWidth([[controller() window] frame]), 1005); |
| 72 } | 79 } |
| 73 | 80 |
| 74 TEST_F(ScreenCaptureNotificationUICocoaTest, ShortTitle) { | 81 TEST_F(ScreenCaptureNotificationUICocoaTest, ShortTitle) { |
| 75 target_.reset( | 82 target_.reset( |
| 76 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title"))); | 83 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title"))); |
| 77 target_->OnStarted( | 84 target_->OnStarted( |
| 78 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback, | 85 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback, |
| 79 base::Unretained(this))); | 86 base::Unretained(this))); |
| 80 EXPECT_EQ(460, NSWidth([[controller() window] frame])); | 87 EXPECT_EQ(460, NSWidth([[controller() window] frame])); |
| 81 } | 88 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 target_.reset( | 102 target_.reset( |
| 96 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title"))); | 103 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title"))); |
| 97 target_->OnStarted( | 104 target_->OnStarted( |
| 98 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback, | 105 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback, |
| 99 base::Unretained(this))); | 106 base::Unretained(this))); |
| 100 | 107 |
| 101 [[controller() window] close]; | 108 [[controller() window] close]; |
| 102 | 109 |
| 103 EXPECT_EQ(1, callback_called_); | 110 EXPECT_EQ(1, callback_called_); |
| 104 } | 111 } |
| 112 |
| 113 TEST_F(ScreenCaptureNotificationUICocoaTest, MinimizeWindow) { |
| 114 target_.reset( |
| 115 new ScreenCaptureNotificationUICocoa(base::UTF8ToUTF16("Title"))); |
| 116 target_->OnStarted( |
| 117 base::Bind(&ScreenCaptureNotificationUICocoaTest::StopCallback, |
| 118 base::Unretained(this))); |
| 119 |
| 120 [[controller() minimizeButton] performClick:nil]; |
| 121 |
| 122 EXPECT_EQ(0, callback_called_); |
| 123 EXPECT_TRUE([[controller() window] isMiniaturized]); |
| 124 } |
| OLD | NEW |