diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-21 12:20:39 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-21 12:20:39 +0000 |
commit | df231a1c868cc197900115655b20960c547842f6 (patch) | |
tree | 5af25a0edd507c81eaa689b3c11746be3396d003 /chrome/browser/plugin_exceptions_table_model_unittest.cc | |
parent | 9efbdb3ecd991ce527bee0ea9c5b900aea882d90 (diff) | |
download | chromium_src-df231a1c868cc197900115655b20960c547842f6.zip chromium_src-df231a1c868cc197900115655b20960c547842f6.tar.gz chromium_src-df231a1c868cc197900115655b20960c547842f6.tar.bz2 |
[Gtk] Add per-plugin content exceptions to preferences.
Modify gtk_tree::TableAdapter to add groups in the TableModel as special rows in the list_store.
Also, fix a bug in PluginExceptionsTableModel sending OnItemsRemoved callbacks at the wrong time.
Run with --enable-resource-content-settings to test.
BUG=39252
TEST=manual
Review URL: http://codereview.chromium.org/3435009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60046 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 | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc index 69db0a1..2e7528f 100644 --- a/chrome/browser/plugin_exceptions_table_model_unittest.cc +++ b/chrome/browser/plugin_exceptions_table_model_unittest.cc @@ -19,12 +19,34 @@ // as a friend. namespace plugin_test_internal { +using ::testing::_; +using ::testing::InSequence; +using ::testing::Invoke; + class MockTableModelObserver : public TableModelObserver { public: + explicit MockTableModelObserver(TableModel* model) + : model_(model) { + ON_CALL(*this, OnItemsRemoved(_, _)) + .WillByDefault( + Invoke(this, &MockTableModelObserver::CheckOnItemsRemoved)); + } + MOCK_METHOD0(OnModelChanged, void()); MOCK_METHOD2(OnItemsChanged, void(int start, int length)); MOCK_METHOD2(OnItemsAdded, void(int start, int length)); MOCK_METHOD2(OnItemsRemoved, void(int start, int length)); + + private: + void CheckOnItemsRemoved(int start, int length) { + if (!model_) + return; + // This method is called *after* the items have been removed, so we check if + // the first removed item was still inside the correct range. + EXPECT_LT(start, model_->RowCount() + 1); + } + + TableModel* model_; }; class PluginExceptionsTableModelTest : public testing::Test { @@ -126,7 +148,7 @@ TEST_F(PluginExceptionsTableModelTest, Basic) { } TEST_F(PluginExceptionsTableModelTest, RemoveOneRow) { - MockTableModelObserver observer; + MockTableModelObserver observer(table_model_.get()); table_model_->SetObserver(&observer); EXPECT_CALL(observer, OnItemsRemoved(1, 1)); @@ -140,7 +162,7 @@ TEST_F(PluginExceptionsTableModelTest, RemoveOneRow) { } TEST_F(PluginExceptionsTableModelTest, RemoveLastRowInGroup) { - MockTableModelObserver observer; + MockTableModelObserver observer(table_model_.get()); table_model_->SetObserver(&observer); EXPECT_CALL(observer, OnModelChanged()); @@ -150,11 +172,31 @@ TEST_F(PluginExceptionsTableModelTest, RemoveLastRowInGroup) { EXPECT_EQ(2, table_model_->RowCount()); EXPECT_EQ(1, static_cast<int>(table_model_->GetGroups().size())); CheckInvariants(); + + HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); + EXPECT_CALL(observer, OnModelChanged()); + map->SetContentSetting(HostContentSettingsMap::Pattern("[*.]blurp.net"), + CONTENT_SETTINGS_TYPE_PLUGINS, + "bar", + CONTENT_SETTING_BLOCK); + EXPECT_EQ(3, table_model_->RowCount()); + + InSequence s; + EXPECT_CALL(observer, OnItemsRemoved(2, 1)); + EXPECT_CALL(observer, OnItemsRemoved(0, 1)); + rows.clear(); + rows.insert(0); + rows.insert(2); + table_model_->RemoveRows(rows); + EXPECT_EQ(1, table_model_->RowCount()); + EXPECT_EQ(1, static_cast<int>(table_model_->GetGroups().size())); + CheckInvariants(); + table_model_->SetObserver(NULL); } TEST_F(PluginExceptionsTableModelTest, RemoveAllRows) { - MockTableModelObserver observer; + MockTableModelObserver observer(table_model_.get()); table_model_->SetObserver(&observer); EXPECT_CALL(observer, OnModelChanged()); |