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

Side by Side Diff: webkit/fileapi/file_system_url_request_job_unittest.cc

Issue 11595003: webkit: Update the calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_url_request_job.h" 5 #include "webkit/fileapi/file_system_url_request_job.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 new FileSystemContext( 66 new FileSystemContext(
67 FileSystemTaskRunners::CreateMockTaskRunners(), 67 FileSystemTaskRunners::CreateMockTaskRunners(),
68 special_storage_policy_, NULL, 68 special_storage_policy_, NULL,
69 temp_dir_.path(), 69 temp_dir_.path(),
70 CreateDisallowFileAccessOptions()); 70 CreateDisallowFileAccessOptions());
71 71
72 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( 72 file_system_context_->sandbox_provider()->ValidateFileSystemRoot(
73 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create 73 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
74 base::Bind(&FileSystemURLRequestJobTest::OnValidateFileSystem, 74 base::Bind(&FileSystemURLRequestJobTest::OnValidateFileSystem,
75 weak_factory_.GetWeakPtr())); 75 weak_factory_.GetWeakPtr()));
76 MessageLoop::current()->RunAllPending(); 76 MessageLoop::current()->RunUntilIdle();
77 77
78 net::URLRequest::Deprecated::RegisterProtocolFactory( 78 net::URLRequest::Deprecated::RegisterProtocolFactory(
79 "filesystem", &FileSystemURLRequestJobFactory); 79 "filesystem", &FileSystemURLRequestJobFactory);
80 } 80 }
81 81
82 virtual void TearDown() OVERRIDE { 82 virtual void TearDown() OVERRIDE {
83 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); 83 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL);
84 ClearUnusedJob(); 84 ClearUnusedJob();
85 if (pending_job_) { 85 if (pending_job_) {
86 pending_job_->Kill(); 86 pending_job_->Kill();
87 pending_job_ = NULL; 87 pending_job_ = NULL;
88 } 88 }
89 // FileReader posts a task to close the file in destructor. 89 // FileReader posts a task to close the file in destructor.
90 MessageLoop::current()->RunAllPending(); 90 MessageLoop::current()->RunUntilIdle();
91 } 91 }
92 92
93 void OnValidateFileSystem(base::PlatformFileError result) { 93 void OnValidateFileSystem(base::PlatformFileError result) {
94 ASSERT_EQ(base::PLATFORM_FILE_OK, result); 94 ASSERT_EQ(base::PLATFORM_FILE_OK, result);
95 } 95 }
96 96
97 void TestRequestHelper(const GURL& url, 97 void TestRequestHelper(const GURL& url,
98 const net::HttpRequestHeaders* headers, 98 const net::HttpRequestHeaders* headers,
99 bool run_to_completion) { 99 bool run_to_completion) {
100 delegate_.reset(new net::TestDelegate()); 100 delegate_.reset(new net::TestDelegate());
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 EXPECT_TRUE(delegate_->request_failed()); 334 EXPECT_TRUE(delegate_->request_failed());
335 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); 335 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error());
336 } 336 }
337 337
338 TEST_F(FileSystemURLRequestJobTest, Cancel) { 338 TEST_F(FileSystemURLRequestJobTest, Cancel) {
339 WriteFile("file1.dat", kTestFileData, arraysize(kTestFileData) - 1); 339 WriteFile("file1.dat", kTestFileData, arraysize(kTestFileData) - 1);
340 TestRequestNoRun(CreateFileSystemURL("file1.dat")); 340 TestRequestNoRun(CreateFileSystemURL("file1.dat"));
341 341
342 // Run StartAsync() and only StartAsync(). 342 // Run StartAsync() and only StartAsync().
343 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); 343 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release());
344 MessageLoop::current()->RunAllPending(); 344 MessageLoop::current()->RunUntilIdle();
345 // If we get here, success! we didn't crash! 345 // If we get here, success! we didn't crash!
346 } 346 }
347 347
348 TEST_F(FileSystemURLRequestJobTest, GetMimeType) { 348 TEST_F(FileSystemURLRequestJobTest, GetMimeType) {
349 const char kFilename[] = "hoge.html"; 349 const char kFilename[] = "hoge.html";
350 350
351 std::string mime_type_direct; 351 std::string mime_type_direct;
352 FilePath::StringType extension = 352 FilePath::StringType extension =
353 FilePath().AppendASCII(kFilename).Extension(); 353 FilePath().AppendASCII(kFilename).Extension();
354 if (!extension.empty()) 354 if (!extension.empty())
355 extension = extension.substr(1); 355 extension = extension.substr(1);
356 EXPECT_TRUE(net::GetWellKnownMimeTypeFromExtension( 356 EXPECT_TRUE(net::GetWellKnownMimeTypeFromExtension(
357 extension, &mime_type_direct)); 357 extension, &mime_type_direct));
358 358
359 TestRequest(CreateFileSystemURL(kFilename)); 359 TestRequest(CreateFileSystemURL(kFilename));
360 360
361 std::string mime_type_from_job; 361 std::string mime_type_from_job;
362 request_->GetMimeType(&mime_type_from_job); 362 request_->GetMimeType(&mime_type_from_job);
363 EXPECT_EQ(mime_type_direct, mime_type_from_job); 363 EXPECT_EQ(mime_type_direct, mime_type_from_job);
364 } 364 }
365 365
366 } // namespace 366 } // namespace
367 } // namespace fileapi 367 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_quota_client_unittest.cc ('k') | webkit/fileapi/local_file_stream_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698