summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorshouqun.liu@intel.com <shouqun.liu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-25 13:17:28 +0000
committershouqun.liu@intel.com <shouqun.liu@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-25 13:17:28 +0000
commitb09c0a167416c2763461e5d6a8cb540700bf12fc (patch)
tree8ce55b8c290d3e565c72b04e272bf0f7b9855f24 /net
parent32ee872fc57bfab7d14792c1bd120d5b14e39f49 (diff)
downloadchromium_src-b09c0a167416c2763461e5d6a8cb540700bf12fc.zip
chromium_src-b09c0a167416c2763461e5d6a8cb540700bf12fc.tar.gz
chromium_src-b09c0a167416c2763461e5d6a8cb540700bf12fc.tar.bz2
Fix the failed cases in URLFetcherFileTest on Android.
* Push the needed data files to target device. * Set the correct document root. BUG= TEST=net_unittests --gtest_filter=URLFetcherFileTest.* Review URL: https://chromiumcodereview.appspot.com/10986042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/test/local_test_server.h4
-rw-r--r--net/test/remote_test_server.cc10
-rw-r--r--net/test/remote_test_server.h6
-rw-r--r--net/url_request/url_fetcher_impl_unittest.cc16
4 files changed, 28 insertions, 8 deletions
diff --git a/net/test/local_test_server.h b/net/test/local_test_server.h
index 2663668..d8d070e 100644
--- a/net/test/local_test_server.h
+++ b/net/test/local_test_server.h
@@ -53,6 +53,10 @@ class LocalTestServer : public BaseTestServer {
// |command_line|. Returns true on success.
virtual bool AddCommandLineArguments(CommandLine* command_line) const;
+ // Returns the actual path of document root for test cases. This function
+ // should be called by test cases to retrieve the actual document root path.
+ FilePath GetDocumentRoot() const { return document_root(); };
+
private:
bool Init(const FilePath& document_root);
diff --git a/net/test/remote_test_server.cc b/net/test/remote_test_server.cc
index 5020ca7..45da5a5 100644
--- a/net/test/remote_test_server.cc
+++ b/net/test/remote_test_server.cc
@@ -143,6 +143,16 @@ bool RemoteTestServer::Stop() {
return stopped;
}
+// On Android, the document root in the device is not the same as the document
+// root in the host machine where the test server is launched. So prepend
+// DIR_SOURCE_ROOT here to get the actual path of document root on the Android
+// device.
+FilePath RemoteTestServer::GetDocumentRoot() const {
+ FilePath src_dir;
+ PathService::Get(base::DIR_SOURCE_ROOT, &src_dir);
+ return src_dir.Append(document_root());
+}
+
bool RemoteTestServer::Init(const FilePath& document_root) {
if (document_root.IsAbsolute())
return false;
diff --git a/net/test/remote_test_server.h b/net/test/remote_test_server.h
index 417eda8b..82ac471 100644
--- a/net/test/remote_test_server.h
+++ b/net/test/remote_test_server.h
@@ -37,6 +37,12 @@ class RemoteTestServer : public BaseTestServer {
// Stops the Python test server that is running on the host machine.
bool Stop();
+ // Returns the actual path of document root for the test cases. This function
+ // should be called by test cases to retrieve the actual document root path
+ // on the Android device, otherwise document_root() function is used to get
+ // the document root.
+ FilePath GetDocumentRoot() const;
+
private:
bool Init(const FilePath& document_root);
diff --git a/net/url_request/url_fetcher_impl_unittest.cc b/net/url_request/url_fetcher_impl_unittest.cc
index a94e887..6435baf 100644
--- a/net/url_request/url_fetcher_impl_unittest.cc
+++ b/net/url_request/url_fetcher_impl_unittest.cc
@@ -1087,7 +1087,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
CreateFetcherForFile(
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch),
temp_dir.path().AppendASCII(kFileToFetch));
@@ -1110,7 +1110,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
CreateFetcherForFile(
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch),
temp_dir.path().AppendASCII(kFileToFetch));
@@ -1129,7 +1129,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
CreateFetcherForFile(
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch),
temp_dir.path().AppendASCII(kFileToFetch));
@@ -1158,7 +1158,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
ASSERT_FALSE(file_util::ContentsEqual(file_path_, expected_file_));
// Get a small file.
@@ -1186,7 +1186,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
CreateFetcherForFile(
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch),
file_path_);
@@ -1204,7 +1204,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
CreateFetcherForTempFile(
test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch));
@@ -1223,7 +1223,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
CreateFetcherForTempFile(test_server.GetURL(
std::string(kTestServerFilePrefix) + kFileToFetch));
@@ -1238,7 +1238,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_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
CreateFetcherForTempFile(test_server.GetURL(
std::string(kTestServerFilePrefix) + kFileToFetch));