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

Side by Side Diff: chrome/browser/plugin_exceptions_table_model_unittest.cc

Issue 5516004: Clean up PluginGroup and related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "app/table_model_observer.h" 5 #include "app/table_model_observer.h"
6 #include "base/auto_reset.h" 6 #include "base/auto_reset.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/mock_plugin_exceptions_table_model.h" 9 #include "chrome/browser/mock_plugin_exceptions_table_model.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 CONTENT_SETTINGS_TYPE_PLUGINS, 75 CONTENT_SETTINGS_TYPE_PLUGINS,
76 "b-bar", 76 "b-bar",
77 CONTENT_SETTING_BLOCK); 77 CONTENT_SETTING_BLOCK);
78 map->SetContentSetting(example_com, 78 map->SetContentSetting(example_com,
79 CONTENT_SETTINGS_TYPE_PLUGINS, 79 CONTENT_SETTINGS_TYPE_PLUGINS,
80 "b-bar", 80 "b-bar",
81 CONTENT_SETTING_ALLOW); 81 CONTENT_SETTING_ALLOW);
82 82
83 table_model_.reset(new MockPluginExceptionsTableModel(map, NULL)); 83 table_model_.reset(new MockPluginExceptionsTableModel(map, NULL));
84 84
85 NPAPI::PluginList::PluginMap plugins; 85 std::vector<PluginGroup> plugins;
86 WebPluginInfo foo_plugin; 86 WebPluginInfo foo_plugin;
87 foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo")); 87 foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo"));
88 foo_plugin.name = ASCIIToUTF16("FooPlugin"); 88 foo_plugin.name = ASCIIToUTF16("FooPlugin");
89 foo_plugin.enabled = true; 89 foo_plugin.enabled = true;
90 PluginGroup* foo_group = PluginGroup::FromWebPluginInfo(foo_plugin); 90 scoped_ptr<PluginGroup> foo_group(
91 plugins[foo_group->identifier()] = linked_ptr<PluginGroup>(foo_group); 91 PluginGroup::FromWebPluginInfo(foo_plugin));
92 plugins.push_back(*foo_group);
92 93
93 WebPluginInfo bar_plugin; 94 WebPluginInfo bar_plugin;
94 bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar")); 95 bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar"));
95 bar_plugin.name = ASCIIToUTF16("BarPlugin"); 96 bar_plugin.name = ASCIIToUTF16("BarPlugin");
96 bar_plugin.enabled = true; 97 bar_plugin.enabled = true;
97 PluginGroup* bar_group = PluginGroup::FromWebPluginInfo(bar_plugin); 98 scoped_ptr<PluginGroup> bar_group(
98 plugins[bar_group->identifier()] = linked_ptr<PluginGroup>(bar_group); 99 PluginGroup::FromWebPluginInfo(bar_plugin));
100 plugins.push_back(*bar_group);
99 101
100 table_model_->set_plugins(plugins); 102 table_model_->set_plugins(plugins);
101 table_model_->ReloadSettings(); 103 table_model_->ReloadSettings();
102 } 104 }
103 105
104 protected: 106 protected:
105 void CheckInvariants() { 107 void CheckInvariants() {
106 typedef std::deque<PluginExceptionsTableModel::SettingsEntry> Entries; 108 typedef std::deque<PluginExceptionsTableModel::SettingsEntry> Entries;
107 Entries& settings = table_model_->settings_; 109 Entries& settings = table_model_->settings_;
108 std::deque<int>& row_counts = table_model_->row_counts_; 110 std::deque<int>& row_counts = table_model_->row_counts_;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 207
206 EXPECT_CALL(observer, OnModelChanged()); 208 EXPECT_CALL(observer, OnModelChanged());
207 table_model_->RemoveAll(); 209 table_model_->RemoveAll();
208 EXPECT_EQ(0, table_model_->RowCount()); 210 EXPECT_EQ(0, table_model_->RowCount());
209 EXPECT_EQ(0, static_cast<int>(table_model_->GetGroups().size())); 211 EXPECT_EQ(0, static_cast<int>(table_model_->GetGroups().size()));
210 CheckInvariants(); 212 CheckInvariants();
211 table_model_->SetObserver(NULL); 213 table_model_->SetObserver(NULL);
212 } 214 }
213 215
214 } // namespace plugin_test_internal 216 } // namespace plugin_test_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698