summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-26 21:41:46 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-26 21:41:46 +0000
commit0c75380cad9a21aae2ad396fcdf10c7af78615d0 (patch)
treeba3d2e918efe43693841319ef88046298d620c80
parent6b232038d064a4cda79f37d084c25b15c7a22ec0 (diff)
downloadchromium_src-0c75380cad9a21aae2ad396fcdf10c7af78615d0.zip
chromium_src-0c75380cad9a21aae2ad396fcdf10c7af78615d0.tar.gz
chromium_src-0c75380cad9a21aae2ad396fcdf10c7af78615d0.tar.bz2
Run all extension webstore private api tests in temp directory.
This makes it possible for the tests to succeed when locally sharded, otherwise there's a race condition as they try to create and delete the same files. Only possible concern: if there's a crash, the "scoped_*" tmp directory inside the chrome/test/data/ subdir won't be cleaned up. We can't stick the temp dir in /tmp because then those files can't be served by the web server. Is this a concern? BUG=124657 TEST=ExtensionWebstorePrivateBundleTest.InstallBundle Review URL: http://codereview.chromium.org/10174015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134154 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_webstore_private_apitest.cc23
-rw-r--r--chrome/test/data/extensions/api_test/webstore_private/theme.html2
2 files changed, 19 insertions, 6 deletions
diff --git a/chrome/browser/extensions/extension_webstore_private_apitest.cc b/chrome/browser/extensions/extension_webstore_private_apitest.cc
index a3ba3f2..b037687 100644
--- a/chrome/browser/extensions/extension_webstore_private_apitest.cc
+++ b/chrome/browser/extensions/extension_webstore_private_apitest.cc
@@ -99,14 +99,25 @@ class ExtensionNoConfirmWebstorePrivateApiTest : public ExtensionApiTest {
host_resolver()->AddRule("www.example.com", "127.0.0.1");
ASSERT_TRUE(test_server()->Start());
ExtensionInstallUI::DisableFailureUIForTests();
+
+ ASSERT_TRUE(tmp_.CreateUniqueTempDirUnderPath(test_data_dir_));
+ ASSERT_TRUE(file_util::CreateDirectory(tmp_.path()));
+ ASSERT_TRUE(file_util::CopyDirectory(
+ test_data_dir_.AppendASCII("webstore_private"),
+ tmp_.path(),
+ true));
}
protected:
// Returns a test server URL, but with host 'www.example.com' so it matches
// the web store app's extent that we set up via command line flags.
- GURL GetTestServerURL(const std::string& path) {
+ virtual GURL GetTestServerURL(const std::string& path) {
+ std::string basename = tmp_.path().BaseName().MaybeAsASCII();
GURL url = test_server()->GetURL(
- std::string("files/extensions/api_test/webstore_private/") + path);
+ std::string("files/extensions/api_test/") +
+ basename +
+ "/webstore_private/" +
+ path);
// Replace the host with 'www.example.com' so it matches the web store
// app's extent.
@@ -131,6 +142,8 @@ class ExtensionNoConfirmWebstorePrivateApiTest : public ExtensionApiTest {
ExtensionService* service() {
return browser()->profile()->GetExtensionService();
}
+
+ ScopedTempDir tmp_;
};
class ExtensionWebstorePrivateApiTest :
@@ -164,7 +177,7 @@ class ExtensionWebstorePrivateBundleTest
protected:
void PackCRX(const std::string& id) {
- FilePath dir_path = test_data_dir_
+ FilePath dir_path = tmp_.path()
.AppendASCII("webstore_private/bundle")
.AppendASCII(id);
@@ -190,7 +203,7 @@ class ExtensionWebstorePrivateBundleTest
// Packs the extension at |ext_path| using |id|'s PEM key.
void PackCRX(const std::string& id, const FilePath& ext_path) {
- FilePath data_path = test_data_dir_.AppendASCII("webstore_private/bundle");
+ FilePath data_path = tmp_.path().AppendASCII("webstore_private/bundle");
FilePath pem_path = data_path.AppendASCII(id + ".pem");
FilePath crx_path = data_path.AppendASCII(id + ".crx");
FilePath destination = PackExtensionWithOptions(
@@ -342,7 +355,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionNoConfirmWebstorePrivateApiTest,
InstallTheme) {
WebstoreInstallListener listener;
WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener);
- ASSERT_TRUE(RunInstallTest("theme.html", "../../theme.crx"));
+ ASSERT_TRUE(RunInstallTest("theme.html", "../../../theme.crx"));
listener.Wait();
ASSERT_TRUE(listener.received_success());
ASSERT_EQ("iamefpfkojoapidjnbafmgkgncegbkad", listener.id());
diff --git a/chrome/test/data/extensions/api_test/webstore_private/theme.html b/chrome/test/data/extensions/api_test/webstore_private/theme.html
index c0d59e0..c386012 100644
--- a/chrome/test/data/extensions/api_test/webstore_private/theme.html
+++ b/chrome/test/data/extensions/api_test/webstore_private/theme.html
@@ -14,7 +14,7 @@ runTests([
assertEq(info.id, themeId);
});
- var manifest = getManifest("../../theme/manifest.json");
+ var manifest = getManifest("../../../theme/manifest.json");
chrome.webstorePrivate.beginInstallWithManifest3(
{id: themeId, manifest: manifest},
callbackPass(function(result) {