| 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 #include "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/mock_plugin_exceptions_table_model.h" | 8 #include "chrome/browser/mock_plugin_exceptions_table_model.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/test/base/testing_browser_process_test.h" | 10 #include "chrome/test/base/testing_browser_process_test.h" |
| 11 #include "chrome/test/base/testing_pref_service.h" | 11 #include "chrome/test/base/testing_pref_service.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/base/models/table_model_observer.h" | 15 #include "ui/base/models/table_model_observer.h" |
| 16 #include "webkit/plugins/npapi/plugin_group.h" | 16 #include "webkit/plugins/npapi/plugin_group.h" |
| 17 #include "webkit/plugins/npapi/webplugininfo.h" | 17 #include "webkit/plugins/webplugininfo.h" |
| 18 | 18 |
| 19 // Can't be an internal namespace because PluginExceptionsTableModel declares | 19 // Can't be an internal namespace because PluginExceptionsTableModel declares |
| 20 // as a friend. | 20 // as a friend. |
| 21 namespace plugin_test_internal { | 21 namespace plugin_test_internal { |
| 22 | 22 |
| 23 using ::testing::_; | 23 using ::testing::_; |
| 24 using ::testing::Invoke; | 24 using ::testing::Invoke; |
| 25 | 25 |
| 26 class MockTableModelObserver : public ui::TableModelObserver { | 26 class MockTableModelObserver : public ui::TableModelObserver { |
| 27 public: | 27 public: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 CONTENT_SETTING_BLOCK); | 84 CONTENT_SETTING_BLOCK); |
| 85 map->SetContentSetting(example_com, | 85 map->SetContentSetting(example_com, |
| 86 ContentSettingsPattern::Wildcard(), | 86 ContentSettingsPattern::Wildcard(), |
| 87 CONTENT_SETTINGS_TYPE_PLUGINS, | 87 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 88 "b-bar", | 88 "b-bar", |
| 89 CONTENT_SETTING_ALLOW); | 89 CONTENT_SETTING_ALLOW); |
| 90 | 90 |
| 91 table_model_.reset(new MockPluginExceptionsTableModel(map, NULL)); | 91 table_model_.reset(new MockPluginExceptionsTableModel(map, NULL)); |
| 92 | 92 |
| 93 std::vector<webkit::npapi::PluginGroup> plugins; | 93 std::vector<webkit::npapi::PluginGroup> plugins; |
| 94 webkit::npapi::WebPluginInfo foo_plugin; | 94 webkit::WebPluginInfo foo_plugin; |
| 95 foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo")); | 95 foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo")); |
| 96 foo_plugin.name = ASCIIToUTF16("FooPlugin"); | 96 foo_plugin.name = ASCIIToUTF16("FooPlugin"); |
| 97 foo_plugin.enabled = | 97 foo_plugin.enabled = |
| 98 webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; | 98 webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; |
| 99 scoped_ptr<webkit::npapi::PluginGroup> foo_group( | 99 scoped_ptr<webkit::npapi::PluginGroup> foo_group( |
| 100 webkit::npapi::PluginGroup::FromWebPluginInfo(foo_plugin)); | 100 webkit::npapi::PluginGroup::FromWebPluginInfo(foo_plugin)); |
| 101 plugins.push_back(*foo_group); | 101 plugins.push_back(*foo_group); |
| 102 | 102 |
| 103 webkit::npapi::WebPluginInfo bar_plugin; | 103 webkit::WebPluginInfo bar_plugin; |
| 104 bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar")); | 104 bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar")); |
| 105 bar_plugin.name = ASCIIToUTF16("BarPlugin"); | 105 bar_plugin.name = ASCIIToUTF16("BarPlugin"); |
| 106 bar_plugin.enabled = | 106 bar_plugin.enabled = |
| 107 webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; | 107 webkit::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; |
| 108 scoped_ptr<webkit::npapi::PluginGroup> bar_group( | 108 scoped_ptr<webkit::npapi::PluginGroup> bar_group( |
| 109 webkit::npapi::PluginGroup::FromWebPluginInfo(bar_plugin)); | 109 webkit::npapi::PluginGroup::FromWebPluginInfo(bar_plugin)); |
| 110 plugins.push_back(*bar_group); | 110 plugins.push_back(*bar_group); |
| 111 | 111 |
| 112 table_model_->set_plugins(plugins); | 112 table_model_->set_plugins(plugins); |
| 113 table_model_->ReloadSettings(); | 113 table_model_->ReloadSettings(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 protected: | 116 protected: |
| 117 void CheckInvariants() const { | 117 void CheckInvariants() const { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 plugin_test_internal::MockTableModelObserver observer(table_model_.get()); | 216 plugin_test_internal::MockTableModelObserver observer(table_model_.get()); |
| 217 table_model_->SetObserver(&observer); | 217 table_model_->SetObserver(&observer); |
| 218 | 218 |
| 219 EXPECT_CALL(observer, OnModelChanged()); | 219 EXPECT_CALL(observer, OnModelChanged()); |
| 220 table_model_->RemoveAll(); | 220 table_model_->RemoveAll(); |
| 221 EXPECT_EQ(0, table_model_->RowCount()); | 221 EXPECT_EQ(0, table_model_->RowCount()); |
| 222 EXPECT_EQ(0, static_cast<int>(table_model_->GetGroups().size())); | 222 EXPECT_EQ(0, static_cast<int>(table_model_->GetGroups().size())); |
| 223 CheckInvariants(); | 223 CheckInvariants(); |
| 224 table_model_->SetObserver(NULL); | 224 table_model_->SetObserver(NULL); |
| 225 } | 225 } |
| OLD | NEW |