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

Unified Diff: chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc

Issue 1148323007: [Extensions] Introduce a ScopedExtensionDialogAutoConfirm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
index 245d053adff476c38228e62a4f25fa689e3f77ce..3f02e4dd1f9e87f1013451b07f2b301dbd71aad6 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
@@ -26,6 +26,7 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/api/management/management_api.h"
+#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/install/extension_install_ui.h"
#include "gpu/config/gpu_feature_type.h"
@@ -117,8 +118,8 @@ class ExtensionWebstorePrivateApiTest : public ExtensionApiTest {
void SetUpOnMainThread() override {
ExtensionApiTest::SetUpOnMainThread();
- ExtensionInstallPrompt::g_auto_confirm_for_tests =
- ExtensionInstallPrompt::ACCEPT;
+ auto_confirm_install_.reset(new ScopedExtensionDialogAutoConfirm(
+ &g_auto_confirm_install_for_testing, AUTO_CONFIRM_ACCEPT));
ASSERT_TRUE(webstore_install_dir_.CreateUniqueTempDir());
webstore_install_dir_copy_ = webstore_install_dir_.path();
@@ -149,7 +150,8 @@ class ExtensionWebstorePrivateApiTest : public ExtensionApiTest {
// of extensions will return the contents of |crx_file|.
bool RunInstallTest(const std::string& page, const std::string& crx_file) {
// Auto-confirm the uninstallation dialog.
- ManagementUninstallFunction::SetAutoConfirmForTest(true);
+ ScopedExtensionDialogAutoConfirm auto_confirm(
+ &g_auto_confirm_uninstall_for_testing, AUTO_CONFIRM_ACCEPT);
#if defined(OS_WIN) && !defined(NDEBUG)
// See http://crbug.com/177163 for details.
return true;
@@ -176,6 +178,8 @@ class ExtensionWebstorePrivateApiTest : public ExtensionApiTest {
// WebstoreInstaller needs a reference to a FilePath when setting the download
// directory for testing.
base::FilePath webstore_install_dir_copy_;
+
+ scoped_ptr<ScopedExtensionDialogAutoConfirm> auto_confirm_install_;
};
// Test cases for webstore origin frame blocking.
@@ -238,8 +242,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) {
// Now test the case where the user cancels the confirmation dialog.
IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallCancelled) {
- ExtensionInstallPrompt::g_auto_confirm_for_tests =
- ExtensionInstallPrompt::CANCEL;
+ ScopedExtensionDialogAutoConfirm auto_cancel(
+ &g_auto_confirm_install_for_testing, AUTO_CONFIRM_CANCEL);
ASSERT_TRUE(RunInstallTest("cancelled.html", "extension.crx"));
}

Powered by Google App Engine
This is Rietveld 408576698