| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/mac/scoped_block.h" | 7 #import "base/mac/scoped_block.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/download/download_shelf.h" | 10 #include "chrome/browser/download/download_shelf.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 resize_delegate_.reset([[ViewResizerPong alloc] init]); | 114 resize_delegate_.reset([[ViewResizerPong alloc] init]); |
| 115 shelf_.reset([[CountingDownloadShelfController alloc] | 115 shelf_.reset([[CountingDownloadShelfController alloc] |
| 116 initWithBrowser:browser() | 116 initWithBrowser:browser() |
| 117 resizeDelegate:resize_delegate_.get()]); | 117 resizeDelegate:resize_delegate_.get()]); |
| 118 EXPECT_TRUE([shelf_ view]); | 118 EXPECT_TRUE([shelf_ view]); |
| 119 [[test_window() contentView] addSubview:[shelf_ view]]; | 119 [[test_window() contentView] addSubview:[shelf_ view]]; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void TearDown() override { | 122 void TearDown() override { |
| 123 if (shelf_.get()) { | 123 if (shelf_.get()) { |
| 124 [shelf_ exiting]; | 124 [shelf_ browserWillBeDestroyed]; |
| 125 shelf_.reset(); | 125 shelf_.reset(); |
| 126 } | 126 } |
| 127 CocoaProfileTest::TearDown(); | 127 CocoaProfileTest::TearDown(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 protected: | 130 protected: |
| 131 id CreateItemController(); | 131 id CreateItemController(); |
| 132 | 132 |
| 133 base::scoped_nsobject<CountingDownloadShelfController> shelf_; | 133 base::scoped_nsobject<CountingDownloadShelfController> shelf_; |
| 134 base::scoped_nsobject<ViewResizerPong> resize_delegate_; | 134 base::scoped_nsobject<ViewResizerPong> resize_delegate_; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // Test that pending autoClose calls are cancelled when exiting. | 367 // Test that pending autoClose calls are cancelled when exiting. |
| 368 TEST_F(DownloadShelfControllerTest, CancelAutoCloseOnExit) { | 368 TEST_F(DownloadShelfControllerTest, CancelAutoCloseOnExit) { |
| 369 base::scoped_nsobject<DownloadItemController> item(CreateItemController()); | 369 base::scoped_nsobject<DownloadItemController> item(CreateItemController()); |
| 370 [shelf_ showDownloadShelf:YES | 370 [shelf_ showDownloadShelf:YES |
| 371 isUserAction:NO]; | 371 isUserAction:NO]; |
| 372 EXPECT_TRUE([shelf_ isVisible]); | 372 EXPECT_TRUE([shelf_ isVisible]); |
| 373 [shelf_ add:item.get()]; | 373 [shelf_ add:item.get()]; |
| 374 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); | 374 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); |
| 375 EXPECT_EQ(2, shelf_.get()->cancelAutoCloseCount_); | 375 EXPECT_EQ(2, shelf_.get()->cancelAutoCloseCount_); |
| 376 | 376 |
| 377 [shelf_ exiting]; | 377 [shelf_ browserWillBeDestroyed]; |
| 378 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); | 378 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); |
| 379 EXPECT_EQ(3, shelf_.get()->cancelAutoCloseCount_); | 379 EXPECT_EQ(3, shelf_.get()->cancelAutoCloseCount_); |
| 380 shelf_.reset(); | 380 shelf_.reset(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 // The view should not be hidden when the shelf is shown. | 383 // The view should not be hidden when the shelf is shown. |
| 384 // The view should be hidden after the closing animation. | 384 // The view should be hidden after the closing animation. |
| 385 TEST_F(DownloadShelfControllerTest, ViewVisibility) { | 385 TEST_F(DownloadShelfControllerTest, ViewVisibility) { |
| 386 [shelf_ showDownloadShelf:YES isUserAction:NO]; | 386 [shelf_ showDownloadShelf:YES isUserAction:NO]; |
| 387 EXPECT_FALSE([[shelf_ view] isHidden]); | 387 EXPECT_FALSE([[shelf_ view] isHidden]); |
| 388 | 388 |
| 389 [shelf_ setCloseAnimationHandler:^{ | 389 [shelf_ setCloseAnimationHandler:^{ |
| 390 base::MessageLoop::current()->QuitNow(); | 390 base::MessageLoop::current()->QuitNow(); |
| 391 }]; | 391 }]; |
| 392 [shelf_ showDownloadShelf:NO isUserAction:NO]; | 392 [shelf_ showDownloadShelf:NO isUserAction:NO]; |
| 393 base::MessageLoop::current()->Run(); | 393 base::MessageLoop::current()->Run(); |
| 394 EXPECT_TRUE([[shelf_ view] isHidden]); | 394 EXPECT_TRUE([[shelf_ view] isHidden]); |
| 395 | 395 |
| 396 [shelf_ showDownloadShelf:YES isUserAction:NO]; | 396 [shelf_ showDownloadShelf:YES isUserAction:NO]; |
| 397 EXPECT_FALSE([[shelf_ view] isHidden]); | 397 EXPECT_FALSE([[shelf_ view] isHidden]); |
| 398 } | 398 } |
| 399 | 399 |
| 400 } // namespace | 400 } // namespace |
| OLD | NEW |