summaryrefslogtreecommitdiffstats
path: root/webkit/blob
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 22:52:27 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 22:52:27 +0000
commit01428900d992d47476438f7343c504f528528ed5 (patch)
tree69cf4c1cb52c1a82b806f769c7dfd91fc3719bc2 /webkit/blob
parentb1ccd3bdacc818a5160a029383ff7bfe7d10b3e4 (diff)
downloadchromium_src-01428900d992d47476438f7343c504f528528ed5.zip
chromium_src-01428900d992d47476438f7343c504f528528ed5.tar.gz
chromium_src-01428900d992d47476438f7343c504f528528ed5.tar.bz2
GTTF: Remove possible interference between BlobURLRequestJob tests.
Quite a lot of state was shared between tests, like a temporary directory, some paths, and a Thread (which could possibly have some tasks still running). This is risky, and we had problems with those in the past. ui_tests used to reuse the same temporary directory, which caused problems with file collisions and failure to delete files. We had problems with net_unittests having posted tasks after the test that started them has finished. It is very hard to debug and reproduce when it happens. This change increases the test run time by 3 ms (5 ms before vs 8 ms after). Arguably, the time savings are not worth a possible reliability problem. BUG=none TEST=test_shell_tests Review URL: http://codereview.chromium.org/3281007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/blob')
-rw-r--r--webkit/blob/blob_url_request_job_unittest.cc40
1 files changed, 17 insertions, 23 deletions
diff --git a/webkit/blob/blob_url_request_job_unittest.cc b/webkit/blob/blob_url_request_job_unittest.cc
index 338c885..7afe699 100644
--- a/webkit/blob/blob_url_request_job_unittest.cc
+++ b/webkit/blob/blob_url_request_job_unittest.cc
@@ -122,20 +122,21 @@ class BlobURLRequestJobTest : public testing::Test {
Method method_;
};
- static void SetUpTestCase() {
- temp_dir_.reset(new ScopedTempDir());
- ASSERT_TRUE(temp_dir_->CreateUniqueTempDir());
+ void SetUp() {
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- temp_file1_ = temp_dir_->path().AppendASCII("BlobFile1.dat");
- file_util::WriteFile(temp_file1_, kTestFileData1,
- arraysize(kTestFileData1) - 1);
+ temp_file1_ = temp_dir_.path().AppendASCII("BlobFile1.dat");
+ ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1),
+ file_util::WriteFile(temp_file1_, kTestFileData1,
+ arraysize(kTestFileData1) - 1));
file_util::FileInfo file_info1;
file_util::GetFileInfo(temp_file1_, &file_info1);
temp_file_modification_time1_ = file_info1.last_modified;
- temp_file2_ = temp_dir_->path().AppendASCII("BlobFile2.dat");
- file_util::WriteFile(temp_file2_, kTestFileData2,
- arraysize(kTestFileData2) - 1);
+ temp_file2_ = temp_dir_.path().AppendASCII("BlobFile2.dat");
+ ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1),
+ file_util::WriteFile(temp_file2_, kTestFileData2,
+ arraysize(kTestFileData2) - 1));
file_util::FileInfo file_info2;
file_util::GetFileInfo(temp_file2_, &file_info2);
temp_file_modification_time2_ = file_info2.last_modified;
@@ -145,9 +146,8 @@ class BlobURLRequestJobTest : public testing::Test {
io_thread_->StartWithOptions(options);
}
- static void TearDownTestCase() {
+ void TearDown() {
io_thread_.reset(NULL);
- temp_dir_.reset(NULL);
}
static URLRequestJob* BlobURLRequestJobFactory(URLRequest* request,
@@ -381,12 +381,12 @@ class BlobURLRequestJobTest : public testing::Test {
}
private:
- static scoped_ptr<ScopedTempDir> temp_dir_;
- static FilePath temp_file1_;
- static FilePath temp_file2_;
- static base::Time temp_file_modification_time1_;
- static base::Time temp_file_modification_time2_;
- static scoped_ptr<base::Thread> io_thread_;
+ ScopedTempDir temp_dir_;
+ FilePath temp_file1_;
+ FilePath temp_file2_;
+ base::Time temp_file_modification_time1_;
+ base::Time temp_file_modification_time2_;
+ scoped_ptr<base::Thread> io_thread_;
static BlobURLRequestJob* blob_url_request_job_;
scoped_ptr<base::WaitableEvent> test_finished_event_;
@@ -398,12 +398,6 @@ class BlobURLRequestJobTest : public testing::Test {
};
// static
-scoped_ptr<ScopedTempDir> BlobURLRequestJobTest::temp_dir_;
-FilePath BlobURLRequestJobTest::temp_file1_;
-FilePath BlobURLRequestJobTest::temp_file2_;
-base::Time BlobURLRequestJobTest::temp_file_modification_time1_;
-base::Time BlobURLRequestJobTest::temp_file_modification_time2_;
-scoped_ptr<base::Thread> BlobURLRequestJobTest::io_thread_;
BlobURLRequestJob* BlobURLRequestJobTest::blob_url_request_job_ = NULL;
TEST_F(BlobURLRequestJobTest, TestGetSimpleDataRequest) {