Chromium Code Reviews| Index: ios/chrome/browser/ui/history/history_entry_inserter_unittest.mm |
| diff --git a/ios/chrome/browser/ui/history/history_entry_inserter_unittest.mm b/ios/chrome/browser/ui/history/history_entry_inserter_unittest.mm |
| index 2ae31774eda7a6c92c4c3e7adda5e1f2d5e86f70..1c2df6a3c4dba32a1beff30d2e1ea81b2192451c 100644 |
| --- a/ios/chrome/browser/ui/history/history_entry_inserter_unittest.mm |
| +++ b/ios/chrome/browser/ui/history/history_entry_inserter_unittest.mm |
| @@ -5,7 +5,6 @@ |
| #import "ios/chrome/browser/ui/history/history_entry_inserter.h" |
| #import "base/mac/foundation_util.h" |
| -#include "base/mac/scoped_nsobject.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/time/time.h" |
| #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| @@ -17,34 +16,38 @@ |
| #import "third_party/ocmock/OCMock/OCMock.h" |
| #import "third_party/ocmock/gtest_support.h" |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| HistoryEntryItem* TestHistoryEntryItem(base::Time timestamp, |
| const std::string& name) { |
| history::HistoryEntry entry = history::HistoryEntry( |
| history::HistoryEntry::LOCAL_ENTRY, GURL(("http://" + name).c_str()), |
| base::UTF8ToUTF16(name.c_str()), timestamp, std::string(), false, |
| base::string16(), false); |
| - return [[[HistoryEntryItem alloc] initWithType:kItemTypeEnumZero |
| - historyEntry:entry |
| - browserState:nil |
| - delegate:nil] autorelease]; |
| + return [[HistoryEntryItem alloc] initWithType:kItemTypeEnumZero |
| + historyEntry:entry |
| + browserState:nil |
| + delegate:nil]; |
| } |
| // Test fixture for HistoryEntryInserter. |
| class HistoryEntryInserterTest : public PlatformTest { |
| public: |
| HistoryEntryInserterTest() { |
| - model_.reset([[CollectionViewModel alloc] init]); |
| + model_ = [[CollectionViewModel alloc] init]; |
| [model_ addSectionWithIdentifier:kSectionIdentifierEnumZero]; |
| - inserter_.reset([[HistoryEntryInserter alloc] initWithModel:model_]); |
| - mock_delegate_.reset([[OCMockObject |
| - mockForProtocol:@protocol(HistoryEntryInserterDelegate)] retain]); |
| + inserter_ = [[HistoryEntryInserter alloc] initWithModel:model_]; |
| + mock_delegate_ = |
| + [OCMockObject mockForProtocol:@protocol(HistoryEntryInserterDelegate)]; |
| [inserter_ setDelegate:mock_delegate_]; |
| } |
| protected: |
| - base::scoped_nsobject<CollectionViewModel> model_; |
| - base::scoped_nsobject<HistoryEntryInserter> inserter_; |
| - base::scoped_nsprotocol<id<HistoryEntryInserterDelegate>> mock_delegate_; |
| + CollectionViewModel* model_; |
|
noyau (Ping after 24h)
2017/01/27 16:04:38
Should C++ object continue to use scoped_nsobject?
stkhapugin
2017/02/02 15:29:23
Since this is a private unit test-only C++ class,
noyau (Ping after 24h)
2017/02/03 12:16:46
I'm torn here. To be honest, I'd rather see that w
stkhapugin
2017/02/03 13:11:37
I think scoped_nsobject is bad, and should be remo
stkhapugin
2017/05/30 18:19:00
Done.
|
| + HistoryEntryInserter* inserter_; |
| + id<HistoryEntryInserterDelegate> mock_delegate_; |
| }; |
| // Tests that history entry items added to CollectionViewModel are sorted by |
| @@ -58,7 +61,7 @@ TEST_F(HistoryEntryInserterTest, AddItems) { |
| HistoryEntryItem* entry3 = |
| TestHistoryEntryItem(today - 2 * (minute), "entry3"); |
| - OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_.get(); |
| + OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_; |
| [[mock_delegate expect] historyEntryInserter:inserter_ |
| didInsertSectionAtIndex:1]; |
| [[mock_delegate expect] |
| @@ -106,7 +109,7 @@ TEST_F(HistoryEntryInserterTest, AddSections) { |
| TestHistoryEntryItem(today - day - minute, "day2_entry2"); |
| HistoryEntryItem* day3 = TestHistoryEntryItem(today - 2 * day, "day3"); |
| - OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_.get(); |
| + OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_; |
| [[mock_delegate expect] historyEntryInserter:inserter_ |
| didInsertSectionAtIndex:1]; |
| @@ -196,7 +199,7 @@ TEST_F(HistoryEntryInserterTest, AddDuplicateItems) { |
| HistoryEntryItem* entry1 = TestHistoryEntryItem(today, "entry"); |
| HistoryEntryItem* entry2 = TestHistoryEntryItem(today, "entry"); |
| - OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_.get(); |
| + OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_; |
| [[mock_delegate expect] historyEntryInserter:inserter_ |
| didInsertSectionAtIndex:1]; |
| [[mock_delegate expect] |
| @@ -224,7 +227,7 @@ TEST_F(HistoryEntryInserterTest, RemoveSection) { |
| HistoryEntryItem* day1 = TestHistoryEntryItem(today, "day1"); |
| HistoryEntryItem* day2 = TestHistoryEntryItem(today - day, "day2"); |
| - OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_.get(); |
| + OCMockObject* mock_delegate = (OCMockObject*)mock_delegate_; |
| [[mock_delegate expect] historyEntryInserter:inserter_ |
| didInsertSectionAtIndex:1]; |