diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-15 15:38:44 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-15 15:38:44 +0000 |
commit | 0cd07f946c353e33d0b9474d383ab06612e40bd8 (patch) | |
tree | c3b05021da46c9f489d5b359f53a3e3f36f02ae7 /chrome/browser/plugin_exceptions_table_model_unittest.cc | |
parent | e19f6b1bb2e8d09ae7471f10d56c834a250182c5 (diff) | |
download | chromium_src-0cd07f946c353e33d0b9474d383ab06612e40bd8.zip chromium_src-0cd07f946c353e33d0b9474d383ab06612e40bd8.tar.gz chromium_src-0cd07f946c353e33d0b9474d383ab06612e40bd8.tar.bz2 |
[Mac] Add per-plugin exceptions to content settings.
Screenshot: http://www.dropmocks.com/mXMd
I'm adding a subclass of NSArrayController, TableModelArrayController, that binds to a RemoveRowsTableModel that can use groups and displays them using group rows in an NSTableView. This cleans up SimpleContentExceptionsWindowController a lot, and the class could also be used for other table models that use groups (keyword editor and autofill).
XIB changes: In SimpleContentExceptionsWindow.xib, bind table view to TableModelArrayController instead of using the dataSource outlet. Buttons call actions on TableModelArrayController, and table view delegate also points to it.
BUG=39252
TEST=SimpleContentExceptionsWindowControllerTest.*:TableModelArrayControllerTest.*:PluginExceptionsTableModelTest.*
Review URL: http://codereview.chromium.org/3327016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/plugin_exceptions_table_model_unittest.cc')
-rw-r--r-- | chrome/browser/plugin_exceptions_table_model_unittest.cc | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc index 7720287..69db0a1 100644 --- a/chrome/browser/plugin_exceptions_table_model_unittest.cc +++ b/chrome/browser/plugin_exceptions_table_model_unittest.cc @@ -3,9 +3,10 @@ // found in the LICENSE file. #include "app/table_model_observer.h" +#include "base/auto_reset.h" #include "base/command_line.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/plugin_exceptions_table_model.h" +#include "chrome/browser/mock_plugin_exceptions_table_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/testing_pref_service.h" @@ -26,31 +27,12 @@ class MockTableModelObserver : public TableModelObserver { MOCK_METHOD2(OnItemsRemoved, void(int start, int length)); }; -class TestingPluginExceptionsTableModel : public PluginExceptionsTableModel { - public: - TestingPluginExceptionsTableModel(HostContentSettingsMap* map, - HostContentSettingsMap* otr_map) - : PluginExceptionsTableModel(map, otr_map) {} - virtual ~TestingPluginExceptionsTableModel() {} - - void set_plugins(const std::vector<WebPluginInfo>& plugins) { - plugins_ = plugins; - } - - protected: - virtual void GetPlugins(std::vector<WebPluginInfo>* plugins) { - *plugins = plugins_; - } - - private: - std::vector<WebPluginInfo> plugins_; -}; - class PluginExceptionsTableModelTest : public testing::Test { public: PluginExceptionsTableModelTest() : ui_thread_(ChromeThread::UI, &message_loop_), - command_line_(*CommandLine::ForCurrentProcess()) {} + command_line_(CommandLine::ForCurrentProcess(), + *CommandLine::ForCurrentProcess()) {} virtual void SetUp() { CommandLine::ForCurrentProcess()->AppendSwitch( @@ -75,7 +57,7 @@ class PluginExceptionsTableModelTest : public testing::Test { "bar", CONTENT_SETTING_ALLOW); - table_model_.reset(new TestingPluginExceptionsTableModel(map, NULL)); + table_model_.reset(new MockPluginExceptionsTableModel(map, NULL)); std::vector<WebPluginInfo> plugins; WebPluginInfo foo_plugin; @@ -93,10 +75,6 @@ class PluginExceptionsTableModelTest : public testing::Test { table_model_->ReloadSettings(); } - virtual void TearDown() { - *CommandLine::ForCurrentProcess() = command_line_; - } - protected: void CheckInvariants() { typedef std::deque<PluginExceptionsTableModel::SettingsEntry> Entries; @@ -136,10 +114,10 @@ class PluginExceptionsTableModelTest : public testing::Test { ChromeThread ui_thread_; scoped_ptr<TestingProfile> profile_; - scoped_ptr<TestingPluginExceptionsTableModel> table_model_; + scoped_ptr<MockPluginExceptionsTableModel> table_model_; private: - CommandLine command_line_; + AutoReset<CommandLine> command_line_; }; TEST_F(PluginExceptionsTableModelTest, Basic) { @@ -179,7 +157,7 @@ TEST_F(PluginExceptionsTableModelTest, RemoveAllRows) { MockTableModelObserver observer; table_model_->SetObserver(&observer); - EXPECT_CALL(observer, OnItemsRemoved(0, 3)); + EXPECT_CALL(observer, OnModelChanged()); table_model_->RemoveAll(); EXPECT_EQ(0, table_model_->RowCount()); EXPECT_EQ(0, static_cast<int>(table_model_->GetGroups().size())); |