OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/download/download_item_controller.h" |
| 6 |
5 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
6 | 8 |
| 9 #include <memory> |
| 10 |
7 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
11 #import "chrome/browser/ui/cocoa/download/download_item_button.h" | 14 #import "chrome/browser/ui/cocoa/download/download_item_button.h" |
12 #import "chrome/browser/ui/cocoa/download/download_item_controller.h" | |
13 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 15 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
14 #include "content/public/test/mock_download_item.h" | 16 #include "content/public/test/mock_download_item.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/platform_test.h" | 18 #include "testing/platform_test.h" |
17 #import "third_party/ocmock/OCMock/OCMock.h" | 19 #import "third_party/ocmock/OCMock/OCMock.h" |
18 #import "third_party/ocmock/gtest_support.h" | 20 #import "third_party/ocmock/gtest_support.h" |
19 | 21 |
20 using ::testing::Return; | 22 using ::testing::Return; |
21 using ::testing::ReturnRefOfCopy; | 23 using ::testing::ReturnRefOfCopy; |
22 | 24 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 shelf:shelf_.get() | 91 shelf:shelf_.get() |
90 navigator:NULL]); | 92 navigator:NULL]); |
91 | 93 |
92 [[test_window() contentView] addSubview:[item view]]; | 94 [[test_window() contentView] addSubview:[item view]]; |
93 run_loop.RunUntilIdle(); | 95 run_loop.RunUntilIdle(); |
94 return item.release(); | 96 return item.release(); |
95 } | 97 } |
96 } | 98 } |
97 | 99 |
98 protected: | 100 protected: |
99 scoped_ptr<content::MockDownloadItem> download_item_; | 101 std::unique_ptr<content::MockDownloadItem> download_item_; |
100 base::scoped_nsobject<DownloadShelfController> shelf_; | 102 base::scoped_nsobject<DownloadShelfController> shelf_; |
101 }; | 103 }; |
102 | 104 |
103 TEST_F(DownloadItemControllerTest, ShelfNotifiedOfOpenedDownload) { | 105 TEST_F(DownloadItemControllerTest, ShelfNotifiedOfOpenedDownload) { |
104 base::scoped_nsobject<DownloadItemController> item(CreateItemController()); | 106 base::scoped_nsobject<DownloadItemController> item(CreateItemController()); |
105 [[(id)shelf_ expect] downloadWasOpened:[OCMArg any]]; | 107 [[(id)shelf_ expect] downloadWasOpened:[OCMArg any]]; |
106 download_item_->NotifyObserversDownloadOpened(); | 108 download_item_->NotifyObserversDownloadOpened(); |
107 } | 109 } |
108 | 110 |
109 TEST_F(DownloadItemControllerTest, RemovesSelfWhenDownloadIsDestroyed) { | 111 TEST_F(DownloadItemControllerTest, RemovesSelfWhenDownloadIsDestroyed) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // download item are mock objects. | 182 // download item are mock objects. |
181 [downloadItemButton removeFromSuperview]; | 183 [downloadItemButton removeFromSuperview]; |
182 }]; | 184 }]; |
183 // The unit test will stop here until the block causes the DownloadItemButton | 185 // The unit test will stop here until the block causes the DownloadItemButton |
184 // to dismiss the menu. | 186 // to dismiss the menu. |
185 [item showContextMenu:nil]; | 187 [item showContextMenu:nil]; |
186 } | 188 } |
187 | 189 |
188 | 190 |
189 } // namespace | 191 } // namespace |
OLD | NEW |