| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/clean/chrome/browser/ui/tab_collection/tab_collection_view_controll
er.h" | 5 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_view_controll
er.h" |
| 6 | 6 |
| 7 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h" | 7 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h" |
| 8 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h" | 8 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #import "testing/gtest_mac.h" | 10 #import "testing/gtest_mac.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 item1.title = @"Item1"; | 33 item1.title = @"Item1"; |
| 34 view_controller_.items = [@[ item0, item1 ] mutableCopy]; | 34 view_controller_.items = [@[ item0, item1 ] mutableCopy]; |
| 35 } | 35 } |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 TestTabCollectionViewController* view_controller_; | 38 TestTabCollectionViewController* view_controller_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Tests that an item is inserted. | 41 // Tests that an item is inserted. |
| 42 TEST_F(TabCollectionViewControllerTest, TestInsertItem) { | 42 TEST_F(TabCollectionViewControllerTest, TestInsertItem) { |
| 43 [view_controller_ insertItem:[[TabCollectionItem alloc] init] atIndex:0]; | 43 [view_controller_ insertItem:[[TabCollectionItem alloc] init] |
| 44 atIndex:0 |
| 45 selectedIndex:0]; |
| 44 EXPECT_EQ(3, static_cast<int>(view_controller_.items.count)); | 46 EXPECT_EQ(3, static_cast<int>(view_controller_.items.count)); |
| 45 } | 47 } |
| 46 | 48 |
| 47 // Tests that an item is deleted. | 49 // Tests that an item is deleted. |
| 48 TEST_F(TabCollectionViewControllerTest, TestDeleteItem) { | 50 TEST_F(TabCollectionViewControllerTest, TestDeleteItem) { |
| 49 [view_controller_ deleteItemAtIndex:0]; | 51 [view_controller_ deleteItemAtIndex:0 selectedIndex:0]; |
| 50 EXPECT_EQ(1, static_cast<int>(view_controller_.items.count)); | 52 EXPECT_EQ(1, static_cast<int>(view_controller_.items.count)); |
| 51 } | 53 } |
| 52 | 54 |
| 53 // Tests that an item is moved. | 55 // Tests that an item is moved. |
| 54 TEST_F(TabCollectionViewControllerTest, TestMoveItem) { | 56 TEST_F(TabCollectionViewControllerTest, TestMoveItem) { |
| 55 [view_controller_ moveItemFromIndex:0 toIndex:1]; | 57 [view_controller_ moveItemFromIndex:0 toIndex:1 selectedIndex:0]; |
| 56 EXPECT_NSEQ(@"Item1", view_controller_.items[0].title); | 58 EXPECT_NSEQ(@"Item1", view_controller_.items[0].title); |
| 57 } | 59 } |
| 58 | 60 |
| 59 // Tests that an item is replaced. | 61 // Tests that an item is replaced. |
| 60 TEST_F(TabCollectionViewControllerTest, TestReplaceItem) { | 62 TEST_F(TabCollectionViewControllerTest, TestReplaceItem) { |
| 61 TabCollectionItem* item = [[TabCollectionItem alloc] init]; | 63 TabCollectionItem* item = [[TabCollectionItem alloc] init]; |
| 62 item.title = @"NewItem"; | 64 item.title = @"NewItem"; |
| 63 [view_controller_ replaceItemAtIndex:0 withItem:item]; | 65 [view_controller_ replaceItemAtIndex:0 withItem:item]; |
| 64 EXPECT_NSEQ(@"NewItem", view_controller_.items[0].title); | 66 EXPECT_NSEQ(@"NewItem", view_controller_.items[0].title); |
| 65 } | 67 } |
| 66 | 68 |
| 67 // Tests that items are initialized. | 69 // Tests that items are initialized. |
| 68 TEST_F(TabCollectionViewControllerTest, TestInitializeItems) { | 70 TEST_F(TabCollectionViewControllerTest, TestInitializeItems) { |
| 69 TabCollectionItem* item = [[TabCollectionItem alloc] init]; | 71 TabCollectionItem* item = [[TabCollectionItem alloc] init]; |
| 70 item.title = @"NewItem"; | 72 item.title = @"NewItem"; |
| 71 [view_controller_ populateItems:@[ item ]]; | 73 [view_controller_ populateItems:@[ item ] selectedIndex:0]; |
| 72 EXPECT_NSEQ(@"NewItem", view_controller_.items[0].title); | 74 EXPECT_NSEQ(@"NewItem", view_controller_.items[0].title); |
| 73 } | 75 } |
| OLD | NEW |