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

Unified Diff: chrome/browser/extensions/crx_installer_browsertest.cc

Issue 9999041: Regression test for packing and installing an extension from an URL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: VLOG -> LOG(ERROR) Created 8 years, 8 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
« no previous file with comments | « chrome/browser/download/download_crx_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/crx_installer_browsertest.cc
diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc
index 0773a3f42f0a6ad3d2e8da4ea33a18bbf0ccbc72..0fd70900a4405d3cdf8b8ddf5662f27fadf1873d 100644
--- a/chrome/browser/extensions/crx_installer_browsertest.cc
+++ b/chrome/browser/extensions/crx_installer_browsertest.cc
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/download/download_crx_util.h"
+#include "chrome/browser/download/download_service.h"
+#include "chrome/browser/download/download_service_factory.h"
+#include "chrome/browser/download/download_test_observer.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_install_ui.h"
@@ -16,6 +20,8 @@ class SkBitmap;
namespace {
+// Observer waits for exactly one download to finish.
+
class MockInstallUI : public ExtensionInstallUI {
public:
explicit MockInstallUI(Profile* profile) :
@@ -116,3 +122,37 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) {
EXPECT_TRUE(InstallExtension(
test_data_dir_.AppendASCII("generic_platform_app.crx"), 1));
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) {
+ const int kNumDownloadsExpected = 1;
+ const bool kExpectFileSelectDialog = false;
+
+ LOG(ERROR) << "PackAndInstallExtension: Packing extension";
+ FilePath crx_path = PackExtension(
+ test_data_dir_.AppendASCII("common/background_page"));
+ ASSERT_FALSE(crx_path.empty());
+ std::string crx_path_string(crx_path.value().begin(), crx_path.value().end());
+ GURL url = GURL(std::string("file:///").append(crx_path_string));
+
+ MockInstallUI* mock_ui = new MockInstallUI(browser()->profile());
+ download_crx_util::SetMockInstallUIForTesting(mock_ui);
+
+ LOG(ERROR) << "PackAndInstallExtension: Getting download manager";
+ content::DownloadManager* download_manager =
+ DownloadServiceFactory::GetForProfile(
+ browser()->profile())->GetDownloadManager();
+
+ LOG(ERROR) << "PackAndInstallExtension: Setting observer";
+ scoped_ptr<DownloadTestObserver> observer(
+ new DownloadTestObserverTerminal(
+ download_manager, kNumDownloadsExpected, kExpectFileSelectDialog,
+ DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
+ LOG(ERROR) << "PackAndInstallExtension: Navigating to URL";
+ ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_NONE);
+
+ EXPECT_TRUE(WaitForExtensionInstall());
+ LOG(ERROR) << "PackAndInstallExtension: Extension install";
+ EXPECT_TRUE(mock_ui->confirmation_requested());
+ LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed";
+}
« no previous file with comments | « chrome/browser/download/download_crx_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698