Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 5 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" | 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 EXPECT_NSEQ(cheddar, cheeseItems[0]); | 295 EXPECT_NSEQ(cheddar, cheeseItems[0]); |
| 296 EXPECT_NSEQ(pepperJack, cheeseItems[1]); | 296 EXPECT_NSEQ(pepperJack, cheeseItems[1]); |
| 297 EXPECT_NSEQ(gouda, cheeseItems[2]); | 297 EXPECT_NSEQ(gouda, cheeseItems[2]); |
| 298 } | 298 } |
| 299 | 299 |
| 300 TEST(CollectionViewModelTest, InvalidIndexPath) { | 300 TEST(CollectionViewModelTest, InvalidIndexPath) { |
| 301 base::scoped_nsobject<CollectionViewModel> model( | 301 base::scoped_nsobject<CollectionViewModel> model( |
| 302 [[CollectionViewModel alloc] init]); | 302 [[CollectionViewModel alloc] init]); |
| 303 [model addSectionWithIdentifier:SectionIdentifierCheese]; | 303 [model addSectionWithIdentifier:SectionIdentifierCheese]; |
| 304 | 304 |
| 305 logging::SetLogAssertHandler(&LogSink); | |
|
noyau (Ping after 24h)
2016/12/22 13:17:22
Suggestions: This would probably be better is hand
sdefresne
2016/12/22 13:28:12
I agree (there is a similar scoped object in net/t
| |
| 305 bool out_of_bounds_exception_thrown = false; | 306 bool out_of_bounds_exception_thrown = false; |
| 306 @try { | 307 @try { |
| 307 logging::SetLogAssertHandler(&LogSink); | |
| 308 [model indexInItemTypeForIndexPath:[NSIndexPath indexPathForItem:0 | 308 [model indexInItemTypeForIndexPath:[NSIndexPath indexPathForItem:0 |
| 309 inSection:0]]; | 309 inSection:0]]; |
| 310 } @catch (NSException* exception) { | 310 } @catch (NSException* exception) { |
| 311 if ([[exception name] isEqualToString:NSRangeException]) { | 311 if ([[exception name] isEqualToString:NSRangeException]) { |
| 312 out_of_bounds_exception_thrown = true; | 312 out_of_bounds_exception_thrown = true; |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 EXPECT_TRUE(out_of_bounds_exception_thrown); | 315 EXPECT_TRUE(out_of_bounds_exception_thrown); |
| 316 logging::SetLogAssertHandler(nullptr); | |
| 316 } | 317 } |
| 317 | 318 |
| 318 TEST(CollectionViewModelTest, RemoveItems) { | 319 TEST(CollectionViewModelTest, RemoveItems) { |
| 319 base::scoped_nsobject<CollectionViewModel> model( | 320 base::scoped_nsobject<CollectionViewModel> model( |
| 320 [[CollectionViewModel alloc] init]); | 321 [[CollectionViewModel alloc] init]); |
| 321 | 322 |
| 322 [model addSectionWithIdentifier:SectionIdentifierCheese]; | 323 [model addSectionWithIdentifier:SectionIdentifierCheese]; |
| 323 [model addItemWithType:ItemTypeCheesePepperJack | 324 [model addItemWithType:ItemTypeCheesePepperJack |
| 324 toSectionWithIdentifier:SectionIdentifierCheese]; | 325 toSectionWithIdentifier:SectionIdentifierCheese]; |
| 325 [model addItemWithType:ItemTypeCheeseGouda | 326 [model addItemWithType:ItemTypeCheeseGouda |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 | 583 |
| 583 EXPECT_FALSE([model footerForSectionWithIdentifier:SectionIdentifierCheese]); | 584 EXPECT_FALSE([model footerForSectionWithIdentifier:SectionIdentifierCheese]); |
| 584 EXPECT_FALSE([model footerForSection:cheeseSection]); | 585 EXPECT_FALSE([model footerForSection:cheeseSection]); |
| 585 | 586 |
| 586 EXPECT_EQ(weasleyFooter.get(), | 587 EXPECT_EQ(weasleyFooter.get(), |
| 587 [model footerForSectionWithIdentifier:SectionIdentifierWeasley]); | 588 [model footerForSectionWithIdentifier:SectionIdentifierWeasley]); |
| 588 EXPECT_EQ(weasleyFooter.get(), [model footerForSection:weasleySection]); | 589 EXPECT_EQ(weasleyFooter.get(), [model footerForSection:weasleySection]); |
| 589 } | 590 } |
| 590 | 591 |
| 591 } // namespace | 592 } // namespace |
| OLD | NEW |