Commit fe79558b authored by edchin's avatar edchin Committed by Commit Bot

[ios] GridCommands implementation in TabGridMediator

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I32c9bf8ba1a131268a71d2a2bcb04ef7b49b7665
Reviewed-on: https://chromium-review.googlesource.com/943934
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540381}
parent 60930b78
...@@ -163,15 +163,15 @@ NSArray* CreateItems(WebStateList* webStateList) { ...@@ -163,15 +163,15 @@ NSArray* CreateItems(WebStateList* webStateList) {
} }
- (void)selectItemAtIndex:(NSUInteger)index { - (void)selectItemAtIndex:(NSUInteger)index {
// TODO(crbug.com/804503) : Add alerts for unimplemented controls. self.webStateList->ActivateWebStateAt(index);
} }
- (void)closeItemAtIndex:(NSUInteger)index { - (void)closeItemAtIndex:(NSUInteger)index {
// TODO(crbug.com/804503) : Add alerts for unimplemented controls. self.webStateList->CloseWebStateAt(index, WebStateList::CLOSE_USER_ACTION);
} }
- (void)closeAllItems { - (void)closeAllItems {
// TODO(crbug.com/804503) : Add alerts for unimplemented controls. self.webStateList->CloseAllWebStates(WebStateList::CLOSE_USER_ACTION);
} }
#pragma mark - GridImageDataSource #pragma mark - GridImageDataSource
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/tab_grid/grid_commands.h"
#import "ios/chrome/browser/ui/tab_grid/grid_consumer.h" #import "ios/chrome/browser/ui/tab_grid/grid_consumer.h"
#import "ios/chrome/browser/ui/tab_grid/grid_item.h" #import "ios/chrome/browser/ui/tab_grid/grid_item.h"
#import "ios/chrome/browser/web/tab_id_tab_helper.h" #import "ios/chrome/browser/web/tab_id_tab_helper.h"
...@@ -122,3 +123,25 @@ TEST_F(TabGridMediatorTest, ConsumerMoveItem) { ...@@ -122,3 +123,25 @@ TEST_F(TabGridMediatorTest, ConsumerMoveItem) {
web_state_list_->MoveWebStateAt(1, 2); web_state_list_->MoveWebStateAt(1, 2);
[[consumer_ verify] moveItemFromIndex:1 toIndex:2 selectedIndex:2]; [[consumer_ verify] moveItemFromIndex:1 toIndex:2 selectedIndex:2];
} }
// Tests that the active index is updated when |-selectItemAtIndex:| is called.
TEST_F(TabGridMediatorTest, SelectItemCommand) {
// Previous selected index is 1.
[mediator_ selectItemAtIndex:2];
EXPECT_EQ(2, web_state_list_->active_index());
}
// Tests that the webStateList count is decremented when |-closeItemAtIndex:| is
// called.
TEST_F(TabGridMediatorTest, CloseItemCommand) {
// Previously there were 3 items.
[mediator_ closeItemAtIndex:1];
EXPECT_EQ(2, web_state_list_->count());
}
// Tests that the webStateList is empty when |-closeAllItems| is called.
TEST_F(TabGridMediatorTest, CloseAllItemsCommand) {
// Previously there were 3 items.
[mediator_ closeAllItems];
EXPECT_EQ(0, web_state_list_->count());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment