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

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

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 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 (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/extensions/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_restrictions.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "chrome/browser/download/download_crx_util.h" 19 #include "chrome/browser/download/download_crx_util.h"
19 #include "chrome/browser/extensions/browser_action_test_util.h" 20 #include "chrome/browser/extensions/browser_action_test_util.h"
20 #include "chrome/browser/extensions/extension_browsertest.h" 21 #include "chrome/browser/extensions/extension_browsertest.h"
21 #include "chrome/browser/extensions/extension_install_prompt.h" 22 #include "chrome/browser/extensions/extension_install_prompt.h"
22 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" 23 #include "chrome/browser/extensions/extension_install_prompt_show_params.h"
23 #include "chrome/browser/extensions/extension_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
24 #include "chrome/browser/extensions/extension_tab_util.h" 25 #include "chrome/browser/extensions/extension_tab_util.h"
25 #include "chrome/browser/extensions/extension_util.h" 26 #include "chrome/browser/extensions/extension_util.h"
26 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" 27 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } // namespace 208 } // namespace
208 209
209 class ExtensionCrxInstallerTest : public ExtensionBrowserTest { 210 class ExtensionCrxInstallerTest : public ExtensionBrowserTest {
210 protected: 211 protected:
211 std::unique_ptr<WebstoreInstaller::Approval> GetApproval( 212 std::unique_ptr<WebstoreInstaller::Approval> GetApproval(
212 const char* manifest_dir, 213 const char* manifest_dir,
213 const std::string& id, 214 const std::string& id,
214 bool strict_manifest_checks) { 215 bool strict_manifest_checks) {
215 std::unique_ptr<WebstoreInstaller::Approval> result; 216 std::unique_ptr<WebstoreInstaller::Approval> result;
216 217
218 base::ThreadRestrictions::ScopedAllowIO allow_io;
217 base::FilePath ext_path = test_data_dir_.AppendASCII(manifest_dir); 219 base::FilePath ext_path = test_data_dir_.AppendASCII(manifest_dir);
218 std::string error; 220 std::string error;
219 std::unique_ptr<base::DictionaryValue> parsed_manifest( 221 std::unique_ptr<base::DictionaryValue> parsed_manifest(
220 file_util::LoadManifest(ext_path, &error)); 222 file_util::LoadManifest(ext_path, &error));
221 if (!parsed_manifest.get() || !error.empty()) 223 if (!parsed_manifest.get() || !error.empty())
222 return result; 224 return result;
223 225
224 return WebstoreInstaller::Approval::CreateWithNoInstallPrompt( 226 return WebstoreInstaller::Approval::CreateWithNoInstallPrompt(
225 browser()->profile(), id, std::move(parsed_manifest), 227 browser()->profile(), id, std::move(parsed_manifest),
226 strict_manifest_checks); 228 strict_manifest_checks);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 333
332 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis, 334 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis,
333 PlatformAppCrx) { 335 PlatformAppCrx) {
334 EXPECT_TRUE(InstallExtension( 336 EXPECT_TRUE(InstallExtension(
335 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1)); 337 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1));
336 } 338 }
337 339
338 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, BlockedFileTypes) { 340 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, BlockedFileTypes) {
339 const Extension* extension = 341 const Extension* extension =
340 InstallExtension(test_data_dir_.AppendASCII("blocked_file_types.crx"), 1); 342 InstallExtension(test_data_dir_.AppendASCII("blocked_file_types.crx"), 1);
343 base::ThreadRestrictions::ScopedAllowIO allow_io;
341 EXPECT_TRUE(base::PathExists(extension->path().AppendASCII("test.html"))); 344 EXPECT_TRUE(base::PathExists(extension->path().AppendASCII("test.html")));
342 EXPECT_TRUE(base::PathExists(extension->path().AppendASCII("test.nexe"))); 345 EXPECT_TRUE(base::PathExists(extension->path().AppendASCII("test.nexe")));
343 EXPECT_FALSE(base::PathExists(extension->path().AppendASCII("test1.EXE"))); 346 EXPECT_FALSE(base::PathExists(extension->path().AppendASCII("test1.EXE")));
344 EXPECT_FALSE(base::PathExists(extension->path().AppendASCII("test2.exe"))); 347 EXPECT_FALSE(base::PathExists(extension->path().AppendASCII("test2.exe")));
345 } 348 }
346 349
347 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, AllowedThemeFileTypes) { 350 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, AllowedThemeFileTypes) {
348 const Extension* extension = InstallExtension( 351 const Extension* extension = InstallExtension(
349 test_data_dir_.AppendASCII("theme_with_extension.crx"), 1); 352 test_data_dir_.AppendASCII("theme_with_extension.crx"), 1);
350 ASSERT_TRUE(extension); 353 ASSERT_TRUE(extension);
351 const base::FilePath& path = extension->path(); 354 const base::FilePath& path = extension->path();
355 base::ThreadRestrictions::ScopedAllowIO allow_io;
352 EXPECT_TRUE( 356 EXPECT_TRUE(
353 base::PathExists(path.AppendASCII("images/theme_frame_camo.PNG"))); 357 base::PathExists(path.AppendASCII("images/theme_frame_camo.PNG")));
354 EXPECT_TRUE( 358 EXPECT_TRUE(
355 base::PathExists(path.AppendASCII("images/theme_ntp_background.png"))); 359 base::PathExists(path.AppendASCII("images/theme_ntp_background.png")));
356 EXPECT_TRUE(base::PathExists( 360 EXPECT_TRUE(base::PathExists(
357 path.AppendASCII("images/theme_ntp_background_norepeat.png"))); 361 path.AppendASCII("images/theme_ntp_background_norepeat.png")));
358 EXPECT_TRUE( 362 EXPECT_TRUE(
359 base::PathExists(path.AppendASCII("images/theme_toolbar_camo.png"))); 363 base::PathExists(path.AppendASCII("images/theme_toolbar_camo.png")));
360 EXPECT_TRUE(base::PathExists(path.AppendASCII("images/redirect_target.GIF"))); 364 EXPECT_TRUE(base::PathExists(path.AppendASCII("images/redirect_target.GIF")));
361 EXPECT_TRUE(base::PathExists(path.AppendASCII("test.image.bmp"))); 365 EXPECT_TRUE(base::PathExists(path.AppendASCII("test.image.bmp")));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 base::ScopedTempDir cache_dir; 596 base::ScopedTempDir cache_dir;
593 ASSERT_TRUE(cache_dir.CreateUniqueTempDir()); 597 ASSERT_TRUE(cache_dir.CreateUniqueTempDir());
594 ExtensionAssetsManagerChromeOS::SetSharedInstallDirForTesting( 598 ExtensionAssetsManagerChromeOS::SetSharedInstallDirForTesting(
595 cache_dir.GetPath()); 599 cache_dir.GetPath());
596 600
597 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx"); 601 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx");
598 const extensions::Extension* extension = InstallExtension( 602 const extensions::Extension* extension = InstallExtension(
599 crx_path, 1, extensions::Manifest::EXTERNAL_PREF); 603 crx_path, 1, extensions::Manifest::EXTERNAL_PREF);
600 base::FilePath extension_path = extension->path(); 604 base::FilePath extension_path = extension->path();
601 EXPECT_TRUE(cache_dir.GetPath().IsParent(extension_path)); 605 EXPECT_TRUE(cache_dir.GetPath().IsParent(extension_path));
606 base::ThreadRestrictions::ScopedAllowIO allow_io;
602 EXPECT_TRUE(base::PathExists(extension_path)); 607 EXPECT_TRUE(base::PathExists(extension_path));
603 608
604 std::string extension_id = extension->id(); 609 std::string extension_id = extension->id();
605 UninstallExtension(extension_id); 610 UninstallExtension(extension_id);
606 ExtensionRegistry* registry = ExtensionRegistry::Get( 611 ExtensionRegistry* registry = ExtensionRegistry::Get(
607 browser()->profile()); 612 browser()->profile());
608 EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id)); 613 EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id));
609 614
610 content::RunAllBlockingPoolTasksUntilIdle(); 615 content::RunAllBlockingPoolTasksUntilIdle();
611 616
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 EXPECT_TRUE(WaitForCrxInstallerDone()); 716 EXPECT_TRUE(WaitForCrxInstallerDone());
712 const Extension* extension = installer->extension(); 717 const Extension* extension = installer->extension();
713 ASSERT_TRUE(extension); 718 ASSERT_TRUE(extension);
714 ASSERT_EQ(extension_id, extension->id()); 719 ASSERT_EQ(extension_id, extension->id());
715 EXPECT_TRUE(ExtensionPrefs::Get(profile())->AllowFileAccess(extension_id)); 720 EXPECT_TRUE(ExtensionPrefs::Get(profile())->AllowFileAccess(extension_id));
716 EXPECT_TRUE(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS); 721 EXPECT_TRUE(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS);
717 } 722 }
718 } 723 }
719 724
720 } // namespace extensions 725 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/content_verifier_browsertest.cc ('k') | chrome/browser/extensions/extension_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698