Index: net/url_request/url_fetcher_impl_unittest.cc |
diff --git a/net/url_request/url_fetcher_impl_unittest.cc b/net/url_request/url_fetcher_impl_unittest.cc |
index a94e8870489f8d40f3b8d64c322adb53d3ece7d1..e191e4a198a3d82b8f05f02fda80645322684ec3 100644 |
--- a/net/url_request/url_fetcher_impl_unittest.cc |
+++ b/net/url_request/url_fetcher_impl_unittest.cc |
@@ -381,15 +381,29 @@ class URLFetcherMultipleAttemptTest : public URLFetcherTest { |
class URLFetcherFileTest : public URLFetcherTest { |
public: |
URLFetcherFileTest() : take_ownership_of_file_(false), |
- expected_file_error_(base::PLATFORM_FILE_OK) {} |
+ expected_file_error_(base::PLATFORM_FILE_OK) { |
+ PathService::Get(base::DIR_SOURCE_ROOT, &document_root_); |
+#if defined(OS_ANDROID) |
+ document_root_= document_root_.AppendASCII(kDocRoot); |
+#endif |
+ } |
void CreateFetcherForFile(const GURL& url, const FilePath& file_path); |
void CreateFetcherForTempFile(const GURL& url); |
+ FilePath GetDocumentRoot(const TestServer& test_server) { |
+#if defined(OS_ANDROID) |
+ return document_root_; |
+#else |
+ return test_server.document_root(); |
wtc
2012/10/16 21:43:03
What does test_server.document_root() return for O
Shouqun Liu
2012/10/17 08:44:30
Hi wtc, thanks for your advice!
For Android, test
|
+#endif |
+ } |
+ |
// URLFetcherDelegate |
virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; |
protected: |
+ FilePath document_root_; |
wtc
2012/10/16 21:43:03
The document_root_ member should be inside #if def
|
FilePath expected_file_; |
FilePath file_path_; |
@@ -1087,7 +1101,7 @@ TEST_F(URLFetcherFileTest, SmallGet) { |
// Get a small file. |
static const char kFileToFetch[] = "simple.html"; |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
CreateFetcherForFile( |
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
temp_dir.path().AppendASCII(kFileToFetch)); |
@@ -1110,7 +1124,7 @@ TEST_F(URLFetcherFileTest, LargeGet) { |
// Get a file large enough to require more than one read into |
// URLFetcher::Core's IOBuffer. |
static const char kFileToFetch[] = "animate1.gif"; |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
CreateFetcherForFile( |
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
temp_dir.path().AppendASCII(kFileToFetch)); |
@@ -1129,7 +1143,7 @@ TEST_F(URLFetcherFileTest, CanTakeOwnershipOfFile) { |
// Get a small file. |
static const char kFileToFetch[] = "simple.html"; |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
CreateFetcherForFile( |
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
temp_dir.path().AppendASCII(kFileToFetch)); |
@@ -1158,7 +1172,7 @@ TEST_F(URLFetcherFileTest, OverwriteExistingFile) { |
const int data_size = arraysize(kData); |
ASSERT_EQ(file_util::WriteFile(file_path_, kData, data_size), data_size); |
ASSERT_TRUE(file_util::PathExists(file_path_)); |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
ASSERT_FALSE(file_util::ContentsEqual(file_path_, expected_file_)); |
// Get a small file. |
@@ -1186,7 +1200,7 @@ TEST_F(URLFetcherFileTest, TryToOverwriteDirectory) { |
// Get a small file. |
expected_file_error_ = base::PLATFORM_FILE_ERROR_ACCESS_DENIED; |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
CreateFetcherForFile( |
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
file_path_); |
@@ -1204,7 +1218,7 @@ TEST_F(URLFetcherFileTest, SmallGetToTempFile) { |
// Get a small file. |
static const char kFileToFetch[] = "simple.html"; |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
CreateFetcherForTempFile( |
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch)); |
@@ -1223,7 +1237,7 @@ TEST_F(URLFetcherFileTest, LargeGetToTempFile) { |
// Get a file large enough to require more than one read into |
// URLFetcher::Core's IOBuffer. |
static const char kFileToFetch[] = "animate1.gif"; |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
CreateFetcherForTempFile(test_server.GetURL( |
std::string(kTestServerFilePrefix) + kFileToFetch)); |
@@ -1238,7 +1252,7 @@ TEST_F(URLFetcherFileTest, CanTakeOwnershipOfTempFile) { |
// Get a small file. |
static const char kFileToFetch[] = "simple.html"; |
- expected_file_ = test_server.document_root().AppendASCII(kFileToFetch); |
+ expected_file_ = GetDocumentRoot(test_server).AppendASCII(kFileToFetch); |
CreateFetcherForTempFile(test_server.GetURL( |
std::string(kTestServerFilePrefix) + kFileToFetch)); |