Regression test for packing and installing an extension from an URL.

BUG=120936
TEST=Regression test.


Review URL: http://codereview.chromium.org/9999041

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132482 0039d316-1c4b-4281-b951-d872f2087c98
parent 3197b92d
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#pragma once #pragma once
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/ref_counted.h"
class CrxInstaller; class CrxInstaller;
class ExtensionInstallUI; class ExtensionInstallUI;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/crx_installer.h"
#include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_install_ui.h" #include "chrome/browser/extensions/extension_install_ui.h"
...@@ -16,6 +20,8 @@ class SkBitmap; ...@@ -16,6 +20,8 @@ class SkBitmap;
namespace { namespace {
// Observer waits for exactly one download to finish.
class MockInstallUI : public ExtensionInstallUI { class MockInstallUI : public ExtensionInstallUI {
public: public:
explicit MockInstallUI(Profile* profile) : explicit MockInstallUI(Profile* profile) :
...@@ -116,3 +122,37 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) { ...@@ -116,3 +122,37 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) {
EXPECT_TRUE(InstallExtension( EXPECT_TRUE(InstallExtension(
test_data_dir_.AppendASCII("generic_platform_app.crx"), 1)); 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";
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment