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

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

Issue 409743003: Use content::RunBlockingPoolTask() in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 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
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"
6
5 #include "base/at_exit.h" 7 #include "base/at_exit.h"
6 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
7 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/download/download_crx_util.h" 10 #include "chrome/browser/download/download_crx_util.h"
9 #include "chrome/browser/extensions/browser_action_test_util.h" 11 #include "chrome/browser/extensions/browser_action_test_util.h"
10 #include "chrome/browser/extensions/crx_installer.h"
11 #include "chrome/browser/extensions/extension_browsertest.h" 12 #include "chrome/browser/extensions/extension_browsertest.h"
12 #include "chrome/browser/extensions/extension_install_prompt.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
13 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_util.h" 15 #include "chrome/browser/extensions/extension_util.h"
15 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" 16 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
21 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/download_manager.h" 24 #include "content/public/browser/download_manager.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/test/browser_test_utils.h" 26 #include "content/public/test/browser_test_utils.h"
26 #include "content/public/test/download_test_observer.h" 27 #include "content/public/test/download_test_observer.h"
28 #include "content/public/test/test_utils.h"
27 #include "extensions/browser/extension_prefs.h" 29 #include "extensions/browser/extension_prefs.h"
28 #include "extensions/browser/extension_system.h" 30 #include "extensions/browser/extension_system.h"
29 #include "extensions/browser/management_policy.h" 31 #include "extensions/browser/management_policy.h"
30 #include "extensions/browser/notification_types.h" 32 #include "extensions/browser/notification_types.h"
31 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
32 #include "extensions/common/feature_switch.h" 34 #include "extensions/common/feature_switch.h"
33 #include "extensions/common/file_util.h" 35 #include "extensions/common/file_util.h"
34 #include "extensions/common/permissions/permission_set.h" 36 #include "extensions/common/permissions/permission_set.h"
35 #include "extensions/common/switches.h" 37 #include "extensions/common/switches.h"
36 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 base::FilePath extension_path = extension->path(); 519 base::FilePath extension_path = extension->path();
518 EXPECT_TRUE(cache_dir.path().IsParent(extension_path)); 520 EXPECT_TRUE(cache_dir.path().IsParent(extension_path));
519 EXPECT_TRUE(base::PathExists(extension_path)); 521 EXPECT_TRUE(base::PathExists(extension_path));
520 522
521 std::string extension_id = extension->id(); 523 std::string extension_id = extension->id();
522 UninstallExtension(extension_id); 524 UninstallExtension(extension_id);
523 ExtensionService* service = extensions::ExtensionSystem::Get( 525 ExtensionService* service = extensions::ExtensionSystem::Get(
524 browser()->profile())->extension_service(); 526 browser()->profile())->extension_service();
525 EXPECT_FALSE(service->GetExtensionById(extension_id, false)); 527 EXPECT_FALSE(service->GetExtensionById(extension_id, false));
526 528
527 // In the worst case you need to repeat this up to 3 times to make sure that 529 content::RunAllBlockingPoolTasksUntilIdle();
528 // all pending tasks we sent from UI thread to task runner and back to UI.
529 for (int i = 0; i < 3; i++) {
530 // Wait for background task completion that sends replay to UI thread.
531 content::BrowserThread::GetBlockingPool()->FlushForTesting();
532 // Wait for UI thread task completion.
533 base::RunLoop().RunUntilIdle();
534 }
535 530
536 EXPECT_FALSE(base::PathExists(extension_path)); 531 EXPECT_FALSE(base::PathExists(extension_path));
537 } 532 }
538 #endif 533 #endif
539 534
540 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, DoNotSync) { 535 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, DoNotSync) {
541 ExtensionService* service = extensions::ExtensionSystem::Get( 536 ExtensionService* service = extensions::ExtensionSystem::Get(
542 browser()->profile())->extension_service(); 537 browser()->profile())->extension_service();
543 scoped_refptr<CrxInstaller> crx_installer( 538 scoped_refptr<CrxInstaller> crx_installer(
544 CrxInstaller::CreateSilent(service)); 539 CrxInstaller::CreateSilent(service));
(...skipping 13 matching lines...) Expand all
558 ManagementPolicyMock policy; 553 ManagementPolicyMock policy;
559 extensions::ExtensionSystem::Get(profile()) 554 extensions::ExtensionSystem::Get(profile())
560 ->management_policy() 555 ->management_policy()
561 ->RegisterProvider(&policy); 556 ->RegisterProvider(&policy);
562 557
563 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx"); 558 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx");
564 EXPECT_FALSE(InstallExtension(crx_path, 0)); 559 EXPECT_FALSE(InstallExtension(crx_path, 0));
565 } 560 }
566 561
567 } // namespace extensions 562 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698