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

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

Issue 10872034: Changing PluginPrefs to use PluginFinder's async interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@test_async
Patch Set: Fixed bauerb's review comments Created 8 years, 3 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/plugin_prefs.h" 5 #include "chrome/browser/plugin_prefs.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/test/base/testing_browser_process.h" 12 #include "chrome/test/base/testing_browser_process.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "chrome/test/base/testing_profile_manager.h" 14 #include "chrome/test/base/testing_profile_manager.h"
15 #include "content/public/browser/plugin_service.h" 15 #include "content/public/browser/plugin_service.h"
16 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webkit/plugins/npapi/mock_plugin_list.cc" 18 #include "webkit/plugins/npapi/mock_plugin_list.cc"
19 #include "webkit/plugins/webplugininfo.h" 19 #include "webkit/plugins/webplugininfo.h"
20 20
21 using content::BrowserThread; 21 using content::BrowserThread;
22 using content::PluginService; 22 using content::PluginService;
23 23
24 namespace {
25
26 void CanEnablePluginCallback(bool dummy) {
27 MessageLoop::current()->QuitWhenIdle();
ibraaaa 2012/08/29 15:35:50 This is to maintain the exact same behavior, howev
Bernhard Bauer 2012/08/29 16:53:21 Yeah, something like base::IgnoreResult for parame
ibraaaa 2012/08/29 17:37:53 Sorry, I don't get what you mean? On 2012/08/29 1
Bernhard Bauer 2012/08/29 18:10:17 You ignore the result at the moment, but maybe you
ibraaaa 2012/08/29 18:28:19 ok, I thought you were answering my first question
Bernhard Bauer 2012/08/31 12:54:11 We are running a message loop in line 179, so we n
28 }
29
30 } // namespace
31
24 class PluginPrefsTest : public ::testing::Test { 32 class PluginPrefsTest : public ::testing::Test {
25 public: 33 public:
26 virtual void SetUp() OVERRIDE { 34 virtual void SetUp() OVERRIDE {
27 plugin_prefs_ = new PluginPrefs(); 35 plugin_prefs_ = new PluginPrefs();
28 } 36 }
29 37
30 void SetPolicyEnforcedPluginPatterns( 38 void SetPolicyEnforcedPluginPatterns(
31 const std::set<string16>& disabled, 39 const std::set<string16>& disabled,
32 const std::set<string16>& disabled_exceptions, 40 const std::set<string16>& disabled_exceptions,
33 const std::set<string16>& enabled) { 41 const std::set<string16>& enabled) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 profile_manager.CreateTestingProfile("Profile 1"); 165 profile_manager.CreateTestingProfile("Profile 1");
158 PluginPrefs* plugin_prefs = PluginPrefs::GetForTestingProfile(profile_1); 166 PluginPrefs* plugin_prefs = PluginPrefs::GetForTestingProfile(profile_1);
159 ASSERT_TRUE(plugin_prefs); 167 ASSERT_TRUE(plugin_prefs);
160 plugin_prefs->SetPluginListForTesting(&plugin_list); 168 plugin_prefs->SetPluginListForTesting(&plugin_list);
161 169
162 webkit::WebPluginInfo plugin(ASCIIToUTF16("Foo"), 170 webkit::WebPluginInfo plugin(ASCIIToUTF16("Foo"),
163 FilePath(FILE_PATH_LITERAL("/path/too/foo")), 171 FilePath(FILE_PATH_LITERAL("/path/too/foo")),
164 ASCIIToUTF16("1.0.0"), 172 ASCIIToUTF16("1.0.0"),
165 ASCIIToUTF16("Foo plug-in")); 173 ASCIIToUTF16("Foo plug-in"));
166 plugin_list.AddPluginToLoad(plugin); 174 plugin_list.AddPluginToLoad(plugin);
167 PluginPrefs::EnablePluginGlobally(false, plugin.path, 175 PluginPrefs::EnablePluginGlobally(
168 MessageLoop::QuitClosure()); 176 false, plugin.path,
177 base::Bind(&CanEnablePluginCallback));
169 178
170 message_loop.Run(); 179 message_loop.Run();
171 180
172 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(plugin)); 181 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(plugin));
173 182
174 TestingProfile* profile_2 = 183 TestingProfile* profile_2 =
175 profile_manager.CreateTestingProfile("Profile 2"); 184 profile_manager.CreateTestingProfile("Profile 2");
176 PluginPrefs* plugin_prefs_2 = PluginPrefs::GetForTestingProfile(profile_2); 185 PluginPrefs* plugin_prefs_2 = PluginPrefs::GetForTestingProfile(profile_2);
177 ASSERT_TRUE(plugin_prefs); 186 ASSERT_TRUE(plugin_prefs);
178 plugin_prefs_2->SetPluginListForTesting(&plugin_list); 187 plugin_prefs_2->SetPluginListForTesting(&plugin_list);
179 EXPECT_FALSE(plugin_prefs_2->IsPluginEnabled(plugin)); 188 EXPECT_FALSE(plugin_prefs_2->IsPluginEnabled(plugin));
180 189
181 profile_manager.DeleteTestingProfile("Profile 1"); 190 profile_manager.DeleteTestingProfile("Profile 1");
182 profile_manager.DeleteTestingProfile("Profile 2"); 191 profile_manager.DeleteTestingProfile("Profile 2");
183 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698