summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/save_package_unittest.cc
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-06-28 21:49:31 +0100
committerKristian Monsen <kristianm@google.com>2011-07-08 17:55:00 +0100
commitddb351dbec246cf1fab5ec20d2d5520909041de1 (patch)
tree158e3fb57bdcac07c7f1e767fde3c70687c9fbb1 /chrome/browser/download/save_package_unittest.cc
parent6b92e04f5f151c896e3088e86f70db7081009308 (diff)
downloadexternal_chromium-ddb351dbec246cf1fab5ec20d2d5520909041de1.zip
external_chromium-ddb351dbec246cf1fab5ec20d2d5520909041de1.tar.gz
external_chromium-ddb351dbec246cf1fab5ec20d2d5520909041de1.tar.bz2
Merge Chromium at r12.0.742.93: Initial merge by git
Change-Id: Ic5ee2fec31358bbee305f7e915442377bfa6cda6
Diffstat (limited to 'chrome/browser/download/save_package_unittest.cc')
-rw-r--r--chrome/browser/download/save_package_unittest.cc59
1 files changed, 46 insertions, 13 deletions
diff --git a/chrome/browser/download/save_package_unittest.cc b/chrome/browser/download/save_package_unittest.cc
index 45ccf61..827d9ec 100644
--- a/chrome/browser/download/save_package_unittest.cc
+++ b/chrome/browser/download/save_package_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,6 +6,7 @@
#include "base/file_path.h"
#include "base/path_service.h"
+#include "base/memory/scoped_temp_dir.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/download/save_package.h"
@@ -98,22 +99,22 @@ class SavePackageTest : public RenderViewHostTestHarness {
// Do the initialization in SetUp so contents() is initialized by
// RenderViewHostTestHarness::SetUp.
- FilePath test_dir;
- PathService::Get(base::DIR_TEMP, &test_dir);
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
save_package_success_ = new SavePackage(contents(),
- test_dir.AppendASCII("testfile" HTML_EXTENSION),
- test_dir.AppendASCII("testfile_files"));
+ temp_dir_.path().AppendASCII("testfile" HTML_EXTENSION),
+ temp_dir_.path().AppendASCII("testfile_files"));
// We need to construct a path that is *almost* kMaxFilePathLength long
long_file_name.resize(kMaxFilePathLength + long_file_name.length());
while (long_file_name.length() < kMaxFilePathLength)
long_file_name += long_file_name;
- long_file_name.resize(kMaxFilePathLength - 9 - test_dir.value().length());
+ long_file_name.resize(
+ kMaxFilePathLength - 9 - temp_dir_.path().value().length());
save_package_fail_ = new SavePackage(contents(),
- test_dir.AppendASCII(long_file_name + HTML_EXTENSION),
- test_dir.AppendASCII(long_file_name + "_files"));
+ temp_dir_.path().AppendASCII(long_file_name + HTML_EXTENSION),
+ temp_dir_.path().AppendASCII(long_file_name + "_files"));
}
private:
@@ -122,6 +123,8 @@ class SavePackageTest : public RenderViewHostTestHarness {
// SavePackage for failed generating file name.
scoped_refptr<SavePackage> save_package_fail_;
+ ScopedTempDir temp_dir_;
+
DISALLOW_COPY_AND_ASSIGN(SavePackageTest);
};
@@ -185,7 +188,13 @@ TEST_F(SavePackageTest, TestUnSuccessfullyGenerateSavePackageFilename) {
}
}
-TEST_F(SavePackageTest, TestLongSavePackageFilename) {
+// Crashing on Windows, see http://crbug.com/79365
+#if defined(OS_WIN)
+#define MAYBE_TestLongSavePackageFilename DISABLED_TestLongSavePackageFilename
+#else
+#define MAYBE_TestLongSavePackageFilename TestLongSavePackageFilename
+#endif
+TEST_F(SavePackageTest, MAYBE_TestLongSavePackageFilename) {
const std::string base_url("http://www.google.com/");
const std::string long_file = long_file_name + ".css";
const std::string url = base_url + long_file;
@@ -211,7 +220,13 @@ TEST_F(SavePackageTest, TestLongSavePackageFilename) {
EXPECT_NE(filename, filename2);
}
-TEST_F(SavePackageTest, TestLongSafePureFilename) {
+// Crashing on Windows, see http://crbug.com/79365
+#if defined(OS_WIN)
+#define MAYBE_TestLongSafePureFilename DISABLED_TestLongSafePureFilename
+#else
+#define MAYBE_TestLongSafePureFilename TestLongSafePureFilename
+#endif
+TEST_F(SavePackageTest, MAYBE_TestLongSafePureFilename) {
const FilePath save_dir(FPL("test_dir"));
const FilePath::StringType ext(FPL_HTML_EXTENSION);
FilePath::StringType filename =
@@ -247,7 +262,13 @@ static const struct {
{FPL("helloworld."), FPL("helloworld.") FPL_HTML_EXTENSION},
};
-TEST_F(SavePackageTest, TestEnsureHtmlExtension) {
+// Crashing on Windows, see http://crbug.com/79365
+#if defined(OS_WIN)
+#define MAYBE_TestEnsureHtmlExtension DISABLED_TestEnsureHtmlExtension
+#else
+#define MAYBE_TestEnsureHtmlExtension TestEnsureHtmlExtension
+#endif
+TEST_F(SavePackageTest, MAYBE_TestEnsureHtmlExtension) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kExtensionTestCases); ++i) {
FilePath original = FilePath(kExtensionTestCases[i].page_title);
FilePath expected = FilePath(kExtensionTestCases[i].expected_name);
@@ -257,7 +278,13 @@ TEST_F(SavePackageTest, TestEnsureHtmlExtension) {
}
}
-TEST_F(SavePackageTest, TestEnsureMimeExtension) {
+// Crashing on Windows, see http://crbug.com/79365
+#if defined(OS_WIN)
+#define MAYBE_TestEnsureMimeExtension DISABLED_TestEnsureMimeExtension
+#else
+#define MAYBE_TestEnsureMimeExtension TestEnsureMimeExtension
+#endif
+TEST_F(SavePackageTest, MAYBE_TestEnsureMimeExtension) {
static const struct {
const FilePath::CharType* page_title;
const FilePath::CharType* expected_name;
@@ -348,7 +375,13 @@ static const struct SuggestedSaveNameTestCase {
},
};
-TEST_F(SavePackageTest, TestSuggestedSaveNames) {
+// Crashing on Windows, see http://crbug.com/79365
+#if defined(OS_WIN)
+#define MAYBE_TestSuggestedSaveNames DISABLED_TestSuggestedSaveNames
+#else
+#define MAYBE_TestSuggestedSaveNames TestSuggestedSaveNames
+#endif
+TEST_F(SavePackageTest, MAYBE_TestSuggestedSaveNames) {
for (size_t i = 0; i < arraysize(kSuggestedSaveNames); ++i) {
scoped_refptr<SavePackage> save_package(
new SavePackage(contents(), FilePath(), FilePath()));