Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/download/download_shelf_controller.h" 5 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <memory>
9 #include <utility> 10 #include <utility>
10 11
11 #import "base/mac/scoped_block.h" 12 #import "base/mac/scoped_block.h"
12 #import "base/mac/scoped_nsobject.h" 13 #import "base/mac/scoped_nsobject.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/download/download_shelf.h" 14 #include "chrome/browser/download/download_shelf.h"
15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
16 #import "chrome/browser/ui/cocoa/download/download_item_controller.h" 16 #import "chrome/browser/ui/cocoa/download/download_item_controller.h"
17 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" 17 #import "chrome/browser/ui/cocoa/view_resizer_pong.h"
18 #include "content/public/test/mock_download_item.h" 18 #include "content/public/test/mock_download_item.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
21 #import "third_party/ocmock/OCMock/OCMock.h" 21 #import "third_party/ocmock/OCMock/OCMock.h"
22 #import "third_party/ocmock/gtest_support.h" 22 #import "third_party/ocmock/gtest_support.h"
23 #import "ui/events/test/cocoa_test_event_utils.h" 23 #import "ui/events/test/cocoa_test_event_utils.h"
24 24
25 using ::testing::Return; 25 using ::testing::Return;
26 using ::testing::AnyNumber; 26 using ::testing::AnyNumber;
27 27
28 // Wraps a content::MockDownloadItem so it can be retained by the mock 28 // Wraps a content::MockDownloadItem so it can be retained by the mock
29 // DownloadItemController. 29 // DownloadItemController.
30 @interface WrappedMockDownloadItem : NSObject { 30 @interface WrappedMockDownloadItem : NSObject {
31 @private 31 @private
32 scoped_ptr<content::MockDownloadItem> download_; 32 std::unique_ptr<content::MockDownloadItem> download_;
33 } 33 }
34 - (id)initWithMockDownload:(scoped_ptr<content::MockDownloadItem>)download; 34 - (id)initWithMockDownload:(std::unique_ptr<content::MockDownloadItem>)download;
35 - (content::DownloadItem*)download; 35 - (content::DownloadItem*)download;
36 - (content::MockDownloadItem*)mockDownload; 36 - (content::MockDownloadItem*)mockDownload;
37 @end 37 @end
38 38
39 @implementation WrappedMockDownloadItem 39 @implementation WrappedMockDownloadItem
40 - (id)initWithMockDownload:(scoped_ptr<content::MockDownloadItem>)download { 40 - (id)initWithMockDownload:
41 (std::unique_ptr<content::MockDownloadItem>)download {
41 if ((self = [super init])) { 42 if ((self = [super init])) {
42 download_ = std::move(download); 43 download_ = std::move(download);
43 } 44 }
44 return self; 45 return self;
45 } 46 }
46 47
47 - (content::DownloadItem*)download { 48 - (content::DownloadItem*)download {
48 return download_.get(); 49 return download_.get();
49 } 50 }
50 51
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 132 }
132 133
133 protected: 134 protected:
134 id CreateItemController(); 135 id CreateItemController();
135 136
136 base::scoped_nsobject<CountingDownloadShelfController> shelf_; 137 base::scoped_nsobject<CountingDownloadShelfController> shelf_;
137 base::scoped_nsobject<ViewResizerPong> resize_delegate_; 138 base::scoped_nsobject<ViewResizerPong> resize_delegate_;
138 }; 139 };
139 140
140 id DownloadShelfControllerTest::CreateItemController() { 141 id DownloadShelfControllerTest::CreateItemController() {
141 scoped_ptr<content::MockDownloadItem> download( 142 std::unique_ptr<content::MockDownloadItem> download(
142 new ::testing::NiceMock<content::MockDownloadItem>); 143 new ::testing::NiceMock<content::MockDownloadItem>);
143 ON_CALL(*download.get(), GetOpened()) 144 ON_CALL(*download.get(), GetOpened())
144 .WillByDefault(Return(false)); 145 .WillByDefault(Return(false));
145 ON_CALL(*download.get(), GetState()) 146 ON_CALL(*download.get(), GetState())
146 .WillByDefault(Return(content::DownloadItem::IN_PROGRESS)); 147 .WillByDefault(Return(content::DownloadItem::IN_PROGRESS));
147 148
148 base::scoped_nsobject<WrappedMockDownloadItem> wrappedMockDownload( 149 base::scoped_nsobject<WrappedMockDownloadItem> wrappedMockDownload(
149 [[WrappedMockDownloadItem alloc] 150 [[WrappedMockDownloadItem alloc]
150 initWithMockDownload:std::move(download)]); 151 initWithMockDownload:std::move(download)]);
151 152
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 }]; 396 }];
396 [shelf_ showDownloadShelf:NO isUserAction:NO]; 397 [shelf_ showDownloadShelf:NO isUserAction:NO];
397 base::MessageLoop::current()->Run(); 398 base::MessageLoop::current()->Run();
398 EXPECT_TRUE([[shelf_ view] isHidden]); 399 EXPECT_TRUE([[shelf_ view] isHidden]);
399 400
400 [shelf_ showDownloadShelf:YES isUserAction:NO]; 401 [shelf_ showDownloadShelf:YES isUserAction:NO];
401 EXPECT_FALSE([[shelf_ view] isHidden]); 402 EXPECT_FALSE([[shelf_ view] isHidden]);
402 } 403 }
403 404
404 } // namespace 405 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698