Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/table_model_array_controller.h" | 5 #import "chrome/browser/ui/cocoa/table_model_array_controller.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/mock_plugin_exceptions_table_model.h" | 10 #include "chrome/browser/mock_plugin_exceptions_table_model.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 private: | 101 private: |
| 102 AutoReset<CommandLine> command_line_; | 102 AutoReset<CommandLine> command_line_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 TEST_F(TableModelArrayControllerTest, CheckTitles) { | 105 TEST_F(TableModelArrayControllerTest, CheckTitles) { |
| 106 NSArray* titles = [[controller_.get() arrangedObjects] valueForKey:@"title"]; | 106 NSArray* titles = [[controller_.get() arrangedObjects] valueForKey:@"title"]; |
| 107 EXPECT_NSEQ(@"(\n" | 107 EXPECT_NSEQ(@"(\n" |
| 108 @" FooPlugin,\n" | 108 @" FooPlugin,\n" |
| 109 @" \"[*.]example.com\",\n" | 109 @" \"[*.]example.com\",\n" |
| 110 @" BarPlugin,\n" | 110 @" BarPlugin,\n" |
| 111 @" \"[*.]example.com\",\n" | 111 @" \"[*.]moose.org\",\n" |
| 112 @" \"[*.]moose.org\"\n" | 112 @" \"[*.]example.com\"\n" |
|
Bernhard Bauer
2011/05/31 14:55:12
So we now return the content settings rules in the
markusheintz_
2011/06/01 20:08:22
You caught me being lazy in this CL. But I agree.
| |
| 113 @")", | 113 @")", |
| 114 [titles description]); | 114 [titles description]); |
| 115 } | 115 } |
| 116 | 116 |
| 117 TEST_F(TableModelArrayControllerTest, RemoveRows) { | 117 TEST_F(TableModelArrayControllerTest, RemoveRows) { |
| 118 NSArrayController* controller = controller_.get(); | 118 NSArrayController* controller = controller_.get(); |
| 119 [controller setSelectionIndex:1]; | 119 [controller setSelectionIndex:1]; |
| 120 [controller remove:nil]; | 120 [controller remove:nil]; |
| 121 NSArray* titles = [[controller arrangedObjects] valueForKey:@"title"]; | 121 NSArray* titles = [[controller arrangedObjects] valueForKey:@"title"]; |
| 122 EXPECT_NSEQ(@"(\n" | 122 EXPECT_NSEQ(@"(\n" |
| 123 @" BarPlugin,\n" | 123 @" BarPlugin,\n" |
| 124 @" \"[*.]example.com\",\n" | 124 @" \"[*.]moose.org\",\n" |
| 125 @" \"[*.]moose.org\"\n" | 125 @" \"[*.]example.com\"\n" |
| 126 @")", | 126 @")", |
| 127 [titles description]); | 127 [titles description]); |
| 128 | 128 |
| 129 [controller setSelectionIndex:2]; | 129 [controller setSelectionIndex:2]; |
| 130 [controller remove:nil]; | 130 [controller remove:nil]; |
| 131 titles = [[controller arrangedObjects] valueForKey:@"title"]; | 131 titles = [[controller arrangedObjects] valueForKey:@"title"]; |
| 132 EXPECT_NSEQ(@"(\n" | 132 EXPECT_NSEQ(@"(\n" |
| 133 @" BarPlugin,\n" | 133 @" BarPlugin,\n" |
| 134 @" \"[*.]example.com\"\n" | 134 @" \"[*.]moose.org\"\n" |
| 135 @")", | 135 @")", |
| 136 [titles description]); | 136 [titles description]); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST_F(TableModelArrayControllerTest, RemoveAll) { | 139 TEST_F(TableModelArrayControllerTest, RemoveAll) { |
| 140 [controller_.get() removeAll:nil]; | 140 [controller_.get() removeAll:nil]; |
| 141 EXPECT_EQ(0u, [[controller_.get() arrangedObjects] count]); | 141 EXPECT_EQ(0u, [[controller_.get() arrangedObjects] count]); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST_F(TableModelArrayControllerTest, AddException) { | 144 TEST_F(TableModelArrayControllerTest, AddException) { |
| 145 TestingProfile* profile = browser_helper_.profile(); | 145 TestingProfile* profile = browser_helper_.profile(); |
| 146 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 146 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
| 147 ContentSettingsPattern example_com = | 147 ContentSettingsPattern example_com = |
| 148 ContentSettingsPattern::FromString("[*.]example.com"); | 148 ContentSettingsPattern::FromString("[*.]example.com"); |
| 149 map->SetContentSetting(example_com, | 149 map->SetContentSetting(example_com, |
| 150 CONTENT_SETTINGS_TYPE_PLUGINS, | 150 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 151 "c-blurp", | 151 "c-blurp", |
| 152 CONTENT_SETTING_BLOCK); | 152 CONTENT_SETTING_BLOCK); |
| 153 | 153 |
| 154 NSArrayController* controller = controller_.get(); | 154 NSArrayController* controller = controller_.get(); |
| 155 NSArray* titles = [[controller arrangedObjects] valueForKey:@"title"]; | 155 NSArray* titles = [[controller arrangedObjects] valueForKey:@"title"]; |
| 156 EXPECT_NSEQ(@"(\n" | 156 EXPECT_NSEQ(@"(\n" |
| 157 @" FooPlugin,\n" | 157 @" FooPlugin,\n" |
| 158 @" \"[*.]example.com\",\n" | 158 @" \"[*.]example.com\",\n" |
| 159 @" BarPlugin,\n" | 159 @" BarPlugin,\n" |
| 160 @" \"[*.]moose.org\",\n" | |
| 160 @" \"[*.]example.com\",\n" | 161 @" \"[*.]example.com\",\n" |
| 161 @" \"[*.]moose.org\",\n" | |
| 162 @" BlurpPlugin,\n" | 162 @" BlurpPlugin,\n" |
| 163 @" \"[*.]example.com\"\n" | 163 @" \"[*.]example.com\"\n" |
| 164 @")", | 164 @")", |
| 165 [titles description]); | 165 [titles description]); |
| 166 NSMutableIndexSet* indexes = [NSMutableIndexSet indexSetWithIndex:1]; | 166 NSMutableIndexSet* indexes = [NSMutableIndexSet indexSetWithIndex:1]; |
| 167 [indexes addIndex:6]; | 167 [indexes addIndex:6]; |
| 168 [controller setSelectionIndexes:indexes]; | 168 [controller setSelectionIndexes:indexes]; |
| 169 [controller remove:nil]; | 169 [controller remove:nil]; |
| 170 titles = [[controller arrangedObjects] valueForKey:@"title"]; | 170 titles = [[controller arrangedObjects] valueForKey:@"title"]; |
| 171 EXPECT_NSEQ(@"(\n" | 171 EXPECT_NSEQ(@"(\n" |
| 172 @" BarPlugin,\n" | 172 @" BarPlugin,\n" |
| 173 @" \"[*.]example.com\",\n" | 173 @" \"[*.]moose.org\",\n" |
| 174 @" \"[*.]moose.org\"\n" | 174 @" \"[*.]example.com\"\n" |
| 175 @")", | 175 @")", |
| 176 [titles description]); | 176 [titles description]); |
| 177 } | 177 } |
| 178 | 178 |
| OLD | NEW |