Chromium Code Reviews| 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..df6d50331fbb6e88b3086e2e598f2a1bbb8248a0 100644 |
| --- a/net/url_request/url_fetcher_impl_unittest.cc |
| +++ b/net/url_request/url_fetcher_impl_unittest.cc |
| @@ -381,15 +381,31 @@ 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) { |
| +#if defined(OS_ANDROID) |
| + PathService::Get(base::DIR_SOURCE_ROOT, &document_root_); |
| + 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) { |
|
wtc
2012/10/18 22:25:01
My proposal is to remove the document_root member
|
| +#if defined(OS_ANDROID) |
| + return document_root_; |
| +#else |
| + return test_server.document_root(); |
| +#endif |
| + } |
| + |
| // URLFetcherDelegate |
| virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; |
| protected: |
| +#if defined(OS_ANDROID) |
| + FilePath document_root_; |
| +#endif |
| FilePath expected_file_; |
| FilePath file_path_; |
| @@ -1087,7 +1103,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 +1126,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 +1145,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 +1174,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 +1202,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 +1220,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 +1239,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 +1254,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)); |