| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #import "chrome/browser/cocoa/task_manager_mac.h" | 9 #import "chrome/browser/cocoa/task_manager_mac.h" |
| 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 cell = [controller tableView:table dataCellForTableColumn:title_column row:2]; | 69 cell = [controller tableView:table dataCellForTableColumn:title_column row:2]; |
| 70 EXPECT_TRUE([@"zzz" isEqualToString:[cell title]]); | 70 EXPECT_TRUE([@"zzz" isEqualToString:[cell title]]); |
| 71 | 71 |
| 72 // Releases the controller, which in turn deletes |bridge|. | 72 // Releases the controller, which in turn deletes |bridge|. |
| 73 [controller close]; | 73 [controller close]; |
| 74 | 74 |
| 75 task_manager.RemoveResource(&resource1); | 75 task_manager.RemoveResource(&resource1); |
| 76 task_manager.RemoveResource(&resource2); | 76 task_manager.RemoveResource(&resource2); |
| 77 task_manager.RemoveResource(&resource3); | 77 task_manager.RemoveResource(&resource3); |
| 78 } | 78 } |
| 79 |
| 80 TEST_F(TaskManagerWindowControllerTest, SelectionAdaptsToSorting) { |
| 81 TaskManager task_manager; |
| 82 |
| 83 TestResource resource1(UTF8ToUTF16("yyy"), 1); |
| 84 TestResource resource2(UTF8ToUTF16("aaa"), 2); |
| 85 |
| 86 task_manager.AddResource(&resource1); |
| 87 task_manager.AddResource(&resource2); |
| 88 |
| 89 TaskManagerMac* bridge(new TaskManagerMac(&task_manager)); |
| 90 TaskManagerWindowController* controller = bridge->cocoa_controller(); |
| 91 NSTableView* table = [controller tableView]; |
| 92 ASSERT_EQ(2, [controller numberOfRowsInTableView:table]); |
| 93 |
| 94 // Select row 0 in the table (corresponds to row 1 in the model). |
| 95 [table selectRowIndexes:[NSIndexSet indexSetWithIndex:0] |
| 96 byExtendingSelection:NO]; |
| 97 |
| 98 // Change the name of resource2 so that it becomes row 1 in the table. |
| 99 resource2.title_ = UTF8ToUTF16("zzz"); |
| 100 bridge->OnItemsChanged(1, 1); |
| 101 |
| 102 // Check that the selection has moved to row 1. |
| 103 NSIndexSet* selection = [table selectedRowIndexes]; |
| 104 ASSERT_EQ(1u, [selection count]); |
| 105 EXPECT_EQ(1u, [selection firstIndex]); |
| 106 |
| 107 // Releases the controller, which in turn deletes |bridge|. |
| 108 [controller close]; |
| 109 |
| 110 task_manager.RemoveResource(&resource1); |
| 111 task_manager.RemoveResource(&resource2); |
| 112 } |
| OLD | NEW |