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]; | |
125 shelf_.reset(); | 124 shelf_.reset(); |
126 } | 125 } |
127 CocoaProfileTest::TearDown(); | 126 CocoaProfileTest::TearDown(); |
128 } | 127 } |
129 | 128 |
130 protected: | 129 protected: |
131 id CreateItemController(); | 130 id CreateItemController(); |
132 | 131 |
133 base::scoped_nsobject<CountingDownloadShelfController> shelf_; | 132 base::scoped_nsobject<CountingDownloadShelfController> shelf_; |
134 base::scoped_nsobject<ViewResizerPong> resize_delegate_; | 133 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. | 366 // Test that pending autoClose calls are cancelled when exiting. |
368 TEST_F(DownloadShelfControllerTest, CancelAutoCloseOnExit) { | 367 TEST_F(DownloadShelfControllerTest, CancelAutoCloseOnExit) { |
369 base::scoped_nsobject<DownloadItemController> item(CreateItemController()); | 368 base::scoped_nsobject<DownloadItemController> item(CreateItemController()); |
370 [shelf_ showDownloadShelf:YES | 369 [shelf_ showDownloadShelf:YES |
371 isUserAction:NO]; | 370 isUserAction:NO]; |
372 EXPECT_TRUE([shelf_ isVisible]); | 371 EXPECT_TRUE([shelf_ isVisible]); |
373 [shelf_ add:item.get()]; | 372 [shelf_ add:item.get()]; |
374 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); | 373 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); |
375 EXPECT_EQ(2, shelf_.get()->cancelAutoCloseCount_); | 374 EXPECT_EQ(2, shelf_.get()->cancelAutoCloseCount_); |
376 | 375 |
377 [shelf_ exiting]; | 376 [shelf_ browserWillBeDestroyed]; |
378 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); | 377 EXPECT_EQ(0, shelf_.get()->scheduleAutoCloseCount_); |
379 EXPECT_EQ(3, shelf_.get()->cancelAutoCloseCount_); | 378 EXPECT_EQ(3, shelf_.get()->cancelAutoCloseCount_); |
380 shelf_.reset(); | 379 shelf_.reset(); |
381 } | 380 } |
382 | 381 |
383 // The view should not be hidden when the shelf is shown. | 382 // The view should not be hidden when the shelf is shown. |
384 // The view should be hidden after the closing animation. | 383 // The view should be hidden after the closing animation. |
385 TEST_F(DownloadShelfControllerTest, ViewVisibility) { | 384 TEST_F(DownloadShelfControllerTest, ViewVisibility) { |
386 [shelf_ showDownloadShelf:YES isUserAction:NO]; | 385 [shelf_ showDownloadShelf:YES isUserAction:NO]; |
387 EXPECT_FALSE([[shelf_ view] isHidden]); | 386 EXPECT_FALSE([[shelf_ view] isHidden]); |
388 | 387 |
389 [shelf_ setCloseAnimationHandler:^{ | 388 [shelf_ setCloseAnimationHandler:^{ |
390 base::MessageLoop::current()->QuitNow(); | 389 base::MessageLoop::current()->QuitNow(); |
391 }]; | 390 }]; |
392 [shelf_ showDownloadShelf:NO isUserAction:NO]; | 391 [shelf_ showDownloadShelf:NO isUserAction:NO]; |
393 base::MessageLoop::current()->Run(); | 392 base::MessageLoop::current()->Run(); |
394 EXPECT_TRUE([[shelf_ view] isHidden]); | 393 EXPECT_TRUE([[shelf_ view] isHidden]); |
395 | 394 |
396 [shelf_ showDownloadShelf:YES isUserAction:NO]; | 395 [shelf_ showDownloadShelf:YES isUserAction:NO]; |
397 EXPECT_FALSE([[shelf_ view] isHidden]); | 396 EXPECT_FALSE([[shelf_ view] isHidden]); |
398 } | 397 } |
399 | 398 |
400 } // namespace | 399 } // namespace |
OLD | NEW |