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

Side by Side Diff: chrome/browser/ui/cocoa/task_manager_mac_unittest.mm

Issue 6312178: Highlight background pages in task manager if user clicks View Background Pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome
Patch Set: Review feedback Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/task_manager_mac.mm ('k') | chrome/browser/ui/gtk/browser_window_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/cocoa/task_manager_mac.h" 9 #import "chrome/browser/ui/cocoa/task_manager_mac.h"
10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
(...skipping 20 matching lines...) Expand all
31 }; 31 };
32 32
33 } // namespace 33 } // namespace
34 34
35 class TaskManagerWindowControllerTest : public CocoaTest { 35 class TaskManagerWindowControllerTest : public CocoaTest {
36 }; 36 };
37 37
38 // Test creation, to ensure nothing leaks or crashes. 38 // Test creation, to ensure nothing leaks or crashes.
39 TEST_F(TaskManagerWindowControllerTest, Init) { 39 TEST_F(TaskManagerWindowControllerTest, Init) {
40 TaskManager task_manager; 40 TaskManager task_manager;
41 TaskManagerMac* bridge(new TaskManagerMac(&task_manager)); 41 TaskManagerMac* bridge(new TaskManagerMac(&task_manager, false));
42 TaskManagerWindowController* controller = bridge->cocoa_controller(); 42 TaskManagerWindowController* controller = bridge->cocoa_controller();
43 43
44 // Releases the controller, which in turn deletes |bridge|. 44 // Releases the controller, which in turn deletes |bridge|.
45 [controller close]; 45 [controller close];
46 } 46 }
47 47
48 TEST_F(TaskManagerWindowControllerTest, Sort) { 48 TEST_F(TaskManagerWindowControllerTest, Sort) {
49 TaskManager task_manager; 49 TaskManager task_manager;
50 50
51 TestResource resource1(UTF8ToUTF16("zzz"), 1); 51 TestResource resource1(UTF8ToUTF16("zzz"), 1);
52 TestResource resource2(UTF8ToUTF16("zzb"), 2); 52 TestResource resource2(UTF8ToUTF16("zzb"), 2);
53 TestResource resource3(UTF8ToUTF16("zza"), 2); 53 TestResource resource3(UTF8ToUTF16("zza"), 2);
54 54
55 task_manager.AddResource(&resource1); 55 task_manager.AddResource(&resource1);
56 task_manager.AddResource(&resource2); 56 task_manager.AddResource(&resource2);
57 task_manager.AddResource(&resource3); // Will be in the same group as 2. 57 task_manager.AddResource(&resource3); // Will be in the same group as 2.
58 58
59 TaskManagerMac* bridge(new TaskManagerMac(&task_manager)); 59 TaskManagerMac* bridge(new TaskManagerMac(&task_manager, false));
60 TaskManagerWindowController* controller = bridge->cocoa_controller(); 60 TaskManagerWindowController* controller = bridge->cocoa_controller();
61 NSTableView* table = [controller tableView]; 61 NSTableView* table = [controller tableView];
62 ASSERT_EQ(3, [controller numberOfRowsInTableView:table]); 62 ASSERT_EQ(3, [controller numberOfRowsInTableView:table]);
63 63
64 // Test that table is sorted on title. 64 // Test that table is sorted on title.
65 NSTableColumn* title_column = [table tableColumnWithIdentifier: 65 NSTableColumn* title_column = [table tableColumnWithIdentifier:
66 [NSNumber numberWithInt:IDS_TASK_MANAGER_PAGE_COLUMN]]; 66 [NSNumber numberWithInt:IDS_TASK_MANAGER_PAGE_COLUMN]];
67 NSCell* cell; 67 NSCell* cell;
68 cell = [controller tableView:table dataCellForTableColumn:title_column row:0]; 68 cell = [controller tableView:table dataCellForTableColumn:title_column row:0];
69 EXPECT_NSEQ(@"zzb", [cell title]); 69 EXPECT_NSEQ(@"zzb", [cell title]);
(...skipping 12 matching lines...) Expand all
82 82
83 TEST_F(TaskManagerWindowControllerTest, SelectionAdaptsToSorting) { 83 TEST_F(TaskManagerWindowControllerTest, SelectionAdaptsToSorting) {
84 TaskManager task_manager; 84 TaskManager task_manager;
85 85
86 TestResource resource1(UTF8ToUTF16("yyy"), 1); 86 TestResource resource1(UTF8ToUTF16("yyy"), 1);
87 TestResource resource2(UTF8ToUTF16("aaa"), 2); 87 TestResource resource2(UTF8ToUTF16("aaa"), 2);
88 88
89 task_manager.AddResource(&resource1); 89 task_manager.AddResource(&resource1);
90 task_manager.AddResource(&resource2); 90 task_manager.AddResource(&resource2);
91 91
92 TaskManagerMac* bridge(new TaskManagerMac(&task_manager)); 92 TaskManagerMac* bridge(new TaskManagerMac(&task_manager, false));
93 TaskManagerWindowController* controller = bridge->cocoa_controller(); 93 TaskManagerWindowController* controller = bridge->cocoa_controller();
94 NSTableView* table = [controller tableView]; 94 NSTableView* table = [controller tableView];
95 ASSERT_EQ(2, [controller numberOfRowsInTableView:table]); 95 ASSERT_EQ(2, [controller numberOfRowsInTableView:table]);
96 96
97 // Select row 0 in the table (corresponds to row 1 in the model). 97 // Select row 0 in the table (corresponds to row 1 in the model).
98 [table selectRowIndexes:[NSIndexSet indexSetWithIndex:0] 98 [table selectRowIndexes:[NSIndexSet indexSetWithIndex:0]
99 byExtendingSelection:NO]; 99 byExtendingSelection:NO];
100 100
101 // Change the name of resource2 so that it becomes row 1 in the table. 101 // Change the name of resource2 so that it becomes row 1 in the table.
102 resource2.title_ = UTF8ToUTF16("zzz"); 102 resource2.title_ = UTF8ToUTF16("zzz");
103 bridge->OnItemsChanged(1, 1); 103 bridge->OnItemsChanged(1, 1);
104 104
105 // Check that the selection has moved to row 1. 105 // Check that the selection has moved to row 1.
106 NSIndexSet* selection = [table selectedRowIndexes]; 106 NSIndexSet* selection = [table selectedRowIndexes];
107 ASSERT_EQ(1u, [selection count]); 107 ASSERT_EQ(1u, [selection count]);
108 EXPECT_EQ(1u, [selection firstIndex]); 108 EXPECT_EQ(1u, [selection firstIndex]);
109 109
110 // Releases the controller, which in turn deletes |bridge|. 110 // Releases the controller, which in turn deletes |bridge|.
111 [controller close]; 111 [controller close];
112 112
113 task_manager.RemoveResource(&resource1); 113 task_manager.RemoveResource(&resource1);
114 task_manager.RemoveResource(&resource2); 114 task_manager.RemoveResource(&resource2);
115 } 115 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/task_manager_mac.mm ('k') | chrome/browser/ui/gtk/browser_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698