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

Unified Diff: ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controller_unittest.mm

Issue 2971093002: [ios] Take snapshot for tab grid. (Closed)
Patch Set: Update unit test. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controller_unittest.mm
diff --git a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controller_unittest.mm b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controller_unittest.mm
index f6b5cf8557983ca8e50575468d597e86b61a5208..b3dc7f7d8a48a38fc021ff1c67c6189e865a0d79 100644
--- a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controller_unittest.mm
+++ b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controller_unittest.mm
@@ -6,9 +6,11 @@
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h"
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h"
+#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
+#import "third_party/ocmock/OCMock/OCMock.h"
#include "third_party/ocmock/gtest_support.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -17,10 +19,12 @@
@interface TestTabCollectionViewController : TabCollectionViewController
@property(nonatomic, readwrite) NSMutableArray<TabCollectionItem*>* items;
+@property(nonatomic, readwrite) UICollectionView* tabs;
@end
@implementation TestTabCollectionViewController
@dynamic items;
+@dynamic tabs;
@end
class TabCollectionViewControllerTest : public PlatformTest {
@@ -32,10 +36,14 @@ class TabCollectionViewControllerTest : public PlatformTest {
TabCollectionItem* item1 = [[TabCollectionItem alloc] init];
item1.title = @"Item1";
view_controller_.items = [@[ item0, item1 ] mutableCopy];
+
+ tabs_ = OCMClassMock([UICollectionView class]);
+ view_controller_.tabs = tabs_;
}
protected:
TestTabCollectionViewController* view_controller_;
+ id tabs_;
};
// Tests that an item is inserted.
@@ -73,3 +81,13 @@ TEST_F(TabCollectionViewControllerTest, TestInitializeItems) {
[view_controller_ populateItems:@[ item ] selectedIndex:0];
EXPECT_NSEQ(@"NewItem", view_controller_.items[0].title);
}
+
+// Tests that a snapshot is updated.
+TEST_F(TabCollectionViewControllerTest, TestUpdateSnapshot) {
+ id cell = OCMClassMock([TabCollectionTabCell class]);
+ NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:0];
+ OCMStub([tabs_ cellForItemAtIndexPath:indexPath]).andReturn(cell);
+ [view_controller_ updateSnapshotAtIndex:0];
+ [[cell verify] configureCell:view_controller_.items[0]
+ snapshotCache:[OCMArg any]];
+}

Powered by Google App Engine
This is Rietveld 408576698