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

Side by Side Diff: chrome/browser/extensions/extension_install_prompt_unittest.cc

Issue 1947683005: Add test renderer host support to ExtensionServiceTestBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests that end up creating two RenderViewHostFactories. Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extensions/extension_install_prompt.h" 5 #include "chrome/browser/extensions/extension_install_prompt.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" 16 #include "chrome/browser/extensions/extension_install_prompt_show_params.h"
17 #include "chrome/browser/extensions/extension_service_test_with_install.h" 17 #include "chrome/browser/extensions/extension_service_test_with_install.h"
18 #include "chrome/browser/extensions/extension_util.h" 18 #include "chrome/browser/extensions/extension_util.h"
19 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
20 #include "content/public/browser/web_contents.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 21 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "content/public/test/test_web_contents_factory.h" 22 #include "content/public/test/test_web_contents_factory.h"
23 #include "content/public/test/web_contents_tester.h"
22 #include "extensions/browser/image_loader.h" 24 #include "extensions/browser/image_loader.h"
23 #include "extensions/common/constants.h" 25 #include "extensions/common/constants.h"
24 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
25 #include "extensions/common/extension_builder.h" 27 #include "extensions/common/extension_builder.h"
26 #include "extensions/common/feature_switch.h" 28 #include "extensions/common/feature_switch.h"
27 #include "extensions/common/manifest_handlers/icons_handler.h" 29 #include "extensions/common/manifest_handlers/icons_handler.h"
28 #include "extensions/common/permissions/api_permission.h" 30 #include "extensions/common/permissions/api_permission.h"
29 #include "extensions/common/permissions/api_permission_set.h" 31 #include "extensions/common/permissions/api_permission_set.h"
30 #include "extensions/common/permissions/manifest_permission_set.h" 32 #include "extensions/common/permissions/manifest_permission_set.h"
31 #include "extensions/common/permissions/permission_set.h" 33 #include "extensions/common/permissions/permission_set.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ImageLoader::ImageRepresentation::NEVER_RESIZE, gfx::Size(), 214 ImageLoader::ImageRepresentation::NEVER_RESIZE, gfx::Size(),
213 ui::SCALE_FACTOR_100P)); 215 ui::SCALE_FACTOR_100P));
214 base::RunLoop image_loop; 216 base::RunLoop image_loop;
215 gfx::Image image; 217 gfx::Image image;
216 ImageLoader::Get(browser_context()) 218 ImageLoader::Get(browser_context())
217 ->LoadImagesAsync( 219 ->LoadImagesAsync(
218 extension, image_rep, 220 extension, image_rep,
219 base::Bind(&SetImage, &image, image_loop.QuitClosure())); 221 base::Bind(&SetImage, &image, image_loop.QuitClosure()));
220 image_loop.Run(); 222 image_loop.Run();
221 ASSERT_FALSE(image.IsEmpty()); 223 ASSERT_FALSE(image.IsEmpty());
222 content::TestWebContentsFactory factory; 224 std::unique_ptr<content::WebContents> web_contents(
223 content::WebContents* web_contents = 225 content::WebContentsTester::CreateTestWebContents(browser_context(),
224 factory.CreateWebContents(browser_context()); 226 nullptr));
225 { 227 {
226 ExtensionInstallPrompt prompt(web_contents); 228 ExtensionInstallPrompt prompt(web_contents.get());
227 base::RunLoop run_loop; 229 base::RunLoop run_loop;
228 prompt.ShowDialog(ExtensionInstallPrompt::DoneCallback(), 230 prompt.ShowDialog(ExtensionInstallPrompt::DoneCallback(), extension,
229 extension,
230 nullptr, // Force an icon fetch. 231 nullptr, // Force an icon fetch.
231 base::Bind(&VerifyPromptIconCallback, 232 base::Bind(&VerifyPromptIconCallback,
232 run_loop.QuitClosure(), image.AsBitmap())); 233 run_loop.QuitClosure(), image.AsBitmap()));
233 run_loop.Run(); 234 run_loop.Run();
234 } 235 }
235 236
236 { 237 {
237 ExtensionInstallPrompt prompt(web_contents); 238 ExtensionInstallPrompt prompt(web_contents.get());
238 base::RunLoop run_loop; 239 base::RunLoop run_loop;
239 gfx::ImageSkia app_icon = util::GetDefaultAppIcon(); 240 gfx::ImageSkia app_icon = util::GetDefaultAppIcon();
240 prompt.ShowDialog(ExtensionInstallPrompt::DoneCallback(), 241 prompt.ShowDialog(ExtensionInstallPrompt::DoneCallback(),
241 extension, 242 extension,
242 app_icon.bitmap(), // Use a different icon. 243 app_icon.bitmap(), // Use a different icon.
243 base::Bind(&VerifyPromptIconCallback, 244 base::Bind(&VerifyPromptIconCallback,
244 run_loop.QuitClosure(), *app_icon.bitmap())); 245 run_loop.QuitClosure(), *app_icon.bitmap()));
245 run_loop.Run(); 246 run_loop.Run();
246 } 247 }
247 } 248 }
248 249
249 } // namespace extensions 250 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698