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

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

Issue 10897020: Convert plugins_check.py to a browser test. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/chromeos_plugins_list.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/plugin_prefs.h" 10 #include "chrome/browser/plugin_prefs.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 scoped_refptr<content::MessageLoopRunner> runner = 51 scoped_refptr<content::MessageLoopRunner> runner =
52 new content::MessageLoopRunner; 52 new content::MessageLoopRunner;
53 BrowserThread::PostTask( 53 BrowserThread::PostTask(
54 BrowserThread::IO, 54 BrowserThread::IO,
55 FROM_HERE, 55 FROM_HERE,
56 base::Bind(&CrashFlashInternal, runner->QuitClosure())); 56 base::Bind(&CrashFlashInternal, runner->QuitClosure()));
57 runner->Run(); 57 runner->Run();
58 } 58 }
59 59
60 static FilePath GetFlashPath() { 60 static FilePath GetFlashPath() {
61 FilePath path; 61 std::vector<webkit::WebPluginInfo> plugins = GetPlugins();
62 for (std::vector<webkit::WebPluginInfo>::const_iterator it =
63 plugins.begin(); it != plugins.end(); ++it) {
64 if (it->name == ASCIIToUTF16("Shockwave Flash"))
65 return it->path;
66 }
67 return FilePath();
68 }
69
70 static std::vector<webkit::WebPluginInfo> GetPlugins() {
71 std::vector<webkit::WebPluginInfo> plugins;
62 scoped_refptr<content::MessageLoopRunner> runner = 72 scoped_refptr<content::MessageLoopRunner> runner =
63 new content::MessageLoopRunner; 73 new content::MessageLoopRunner;
64 content::PluginService::GetInstance()->GetPlugins( 74 content::PluginService::GetInstance()->GetPlugins(
65 base::Bind(&GetPluginsInfoCallback, &path, runner->QuitClosure())); 75 base::Bind(&GetPluginsInfoCallback, &plugins, runner->QuitClosure()));
66 runner->Run(); 76 runner->Run();
67 return path; 77 return plugins;
68 } 78 }
69 79
70 static void EnableFlash(bool enable, Profile* profile) { 80 static void EnableFlash(bool enable, Profile* profile) {
71 FilePath flash_path = GetFlashPath(); 81 FilePath flash_path = GetFlashPath();
72 ASSERT_FALSE(flash_path.empty()); 82 ASSERT_FALSE(flash_path.empty());
73 83
74 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); 84 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile);
75 scoped_refptr<content::MessageLoopRunner> runner = 85 scoped_refptr<content::MessageLoopRunner> runner =
76 new content::MessageLoopRunner; 86 new content::MessageLoopRunner;
77 plugin_prefs->EnablePlugin(enable, flash_path, runner->QuitClosure()); 87 plugin_prefs->EnablePlugin(enable, flash_path, runner->QuitClosure());
(...skipping 21 matching lines...) Expand all
99 continue; 109 continue;
100 } 110 }
101 base::KillProcess(iter.GetData().handle, 0, true); 111 base::KillProcess(iter.GetData().handle, 0, true);
102 found = true; 112 found = true;
103 } 113 }
104 ASSERT_TRUE(found) << "Didn't find Flash process!"; 114 ASSERT_TRUE(found) << "Didn't find Flash process!";
105 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); 115 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task);
106 } 116 }
107 117
108 static void GetPluginsInfoCallback( 118 static void GetPluginsInfoCallback(
109 FilePath* flash_path, 119 std::vector<webkit::WebPluginInfo>* rv,
110 const base::Closure& quit_task, 120 const base::Closure& quit_task,
111 const std::vector<webkit::WebPluginInfo>& plugins) { 121 const std::vector<webkit::WebPluginInfo>& plugins) {
112 for (std::vector<webkit::WebPluginInfo>::const_iterator it = 122 *rv = plugins;
113 plugins.begin(); it != plugins.end(); ++it) {
114 if (it->name == ASCIIToUTF16("Shockwave Flash")) {
115 *flash_path = it->path;
116 break;
117 }
118 }
119 quit_task.Run(); 123 quit_task.Run();
120 } 124 }
121 125
122 static void CountPluginProcesses(int* count, const base::Closure& quit_task) { 126 static void CountPluginProcesses(int* count, const base::Closure& quit_task) {
123 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { 127 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
124 if (iter.GetData().type == content::PROCESS_TYPE_PLUGIN || 128 if (iter.GetData().type == content::PROCESS_TYPE_PLUGIN ||
125 iter.GetData().type == content::PROCESS_TYPE_PPAPI_PLUGIN) { 129 iter.GetData().type == content::PROCESS_TYPE_PPAPI_PLUGIN) {
126 (*count)++; 130 (*count)++;
127 } 131 }
128 } 132 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 CrashFlash(); 169 CrashFlash();
166 170
167 ASSERT_NO_FATAL_FAILURE(LoadAndWait(browser(), url, false)); 171 ASSERT_NO_FATAL_FAILURE(LoadAndWait(browser(), url, false));
168 EnsureFlashProcessCount(0); 172 EnsureFlashProcessCount(0);
169 173
170 // Now enable it again. 174 // Now enable it again.
171 EnableFlash(true, profile); 175 EnableFlash(true, profile);
172 ASSERT_NO_FATAL_FAILURE(LoadAndWait(browser(), url, true)); 176 ASSERT_NO_FATAL_FAILURE(LoadAndWait(browser(), url, true));
173 EnsureFlashProcessCount(1); 177 EnsureFlashProcessCount(1);
174 } 178 }
179
180 // Verify that the official builds have the known set of plugins.
181 IN_PROC_BROWSER_TEST_F(ChromePluginTest, InstalledPlugins) {
182 #if !defined(OFFICIAL_BUILD)
183 return;
184 #endif
185 const char* expected[] = {
186 "Chrome PDF Viewer",
187 "Shockwave Flash",
188 "Native Client",
189 #if defined(OS_CHROMEOS)
190 "Chrome Remote Desktop Viewer",
191 "Google Talk Plugin",
192 "Google Talk Plugin Video Accelerator",
193 "Netflix",
194 #endif
195 };
196
197 std::vector<webkit::WebPluginInfo> plugins = GetPlugins();
198 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) {
199 size_t j = 0;
200 for (; j < plugins.size(); ++j) {
201 if (plugins[j].name == ASCIIToUTF16(expected[i]))
202 break;
203 }
204 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i];
205 }
206 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/chromeos_plugins_list.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698