Commit 284aae98 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Disable URLRequestFileDirTest tests that fail on Android.

Various RootDirectory test cases exist to make sure browsing file:///
works. However, this action is not allowed on Android, so it is a slight
mystery how the tests manage to pass on earlier version of Android. The
tests fail under newer version of Android.

Given this situation, just disable the tests on Android altogether, as
it is pointless to test a disallowed action. Also combine the test cases
which are very similar into a single test case with a for-loop.

BUG=787149

Change-Id: Icec5ed676b245519ae98e8914b397122d5c7bbd5
Reviewed-on: https://chromium-review.googlesource.com/780921
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518421}
parent bbcd68d9
...@@ -302,83 +302,38 @@ TEST_F(URLRequestFileDirTest, EmptyDirectory) { ...@@ -302,83 +302,38 @@ TEST_F(URLRequestFileDirTest, EmptyDirectory) {
EXPECT_FALSE(HasParentDirEntry(delegate.data_received())); EXPECT_FALSE(HasParentDirEntry(delegate.data_received()));
} }
// Android security policies prevent access to the root directory, so skip this
// test there.
#if !defined(OS_ANDROID)
TEST_F(URLRequestFileDirTest, RootDirectory) { TEST_F(URLRequestFileDirTest, RootDirectory) {
for (int slashes_to_test = 1; slashes_to_test < 4; ++slashes_to_test) {
base::FilePath::StringType root_dir_string;
#if defined(OS_WIN) #if defined(OS_WIN)
base::FilePath root_dir(L"C:\\"); root_dir_string = L"C:";
#else
base::FilePath root_dir("/");
#endif #endif
TestJobFactory factory(root_dir); root_dir_string.append(slashes_to_test, base::FilePath::kSeparators[0]);
context_.set_job_factory(&factory); base::FilePath root_dir(root_dir_string);
TestJobFactory factory(root_dir);
TestDelegate delegate; context_.set_job_factory(&factory);
std::unique_ptr<URLRequest> request(
context_.CreateRequest(FilePathToFileURL(root_dir), DEFAULT_PRIORITY, TestDelegate delegate;
&delegate, TRAFFIC_ANNOTATION_FOR_TESTS)); std::unique_ptr<URLRequest> request(
request->Start(); context_.CreateRequest(FilePathToFileURL(root_dir), DEFAULT_PRIORITY,
EXPECT_TRUE(request->is_pending()); &delegate, TRAFFIC_ANNOTATION_FOR_TESTS));
request->Start();
base::RunLoop().Run(); EXPECT_TRUE(request->is_pending());
ASSERT_GT(delegate.bytes_received(), 0); base::RunLoop().Run();
ASSERT_LE(delegate.bytes_received(), kBufferSize);
EXPECT_TRUE(HasHeader(delegate.data_received(), root_dir)); ASSERT_GT(delegate.bytes_received(), 0);
EXPECT_FALSE(HasParentDirLink(delegate.data_received())); ASSERT_LE(delegate.bytes_received(), kBufferSize);
EXPECT_GT(GetEntryCount(delegate.data_received()), 0); EXPECT_TRUE(HasHeader(delegate.data_received(), root_dir));
EXPECT_FALSE(HasParentDirEntry(delegate.data_received())); EXPECT_FALSE(HasParentDirLink(delegate.data_received()));
} EXPECT_GT(GetEntryCount(delegate.data_received()), 0);
EXPECT_FALSE(HasParentDirEntry(delegate.data_received()));
TEST_F(URLRequestFileDirTest, RootDirectoryWithTrailer) { }
#if defined(OS_WIN)
base::FilePath root_dir(L"C:\\\\");
#else
base::FilePath root_dir("//");
#endif
TestJobFactory factory(root_dir);
context_.set_job_factory(&factory);
TestDelegate delegate;
std::unique_ptr<URLRequest> request(
context_.CreateRequest(FilePathToFileURL(root_dir), DEFAULT_PRIORITY,
&delegate, TRAFFIC_ANNOTATION_FOR_TESTS));
request->Start();
EXPECT_TRUE(request->is_pending());
base::RunLoop().Run();
ASSERT_GT(delegate.bytes_received(), 0);
ASSERT_LE(delegate.bytes_received(), kBufferSize);
EXPECT_TRUE(HasHeader(delegate.data_received(), root_dir));
EXPECT_FALSE(HasParentDirLink(delegate.data_received()));
EXPECT_GT(GetEntryCount(delegate.data_received()), 0);
EXPECT_FALSE(HasParentDirEntry(delegate.data_received()));
}
TEST_F(URLRequestFileDirTest, RootDirectoryWithLongerTrailer) {
#if defined(OS_WIN)
base::FilePath root_dir(L"C:\\\\\\");
#else
base::FilePath root_dir("///");
#endif
TestJobFactory factory(root_dir);
context_.set_job_factory(&factory);
TestDelegate delegate;
std::unique_ptr<URLRequest> request(
context_.CreateRequest(FilePathToFileURL(root_dir), DEFAULT_PRIORITY,
&delegate, TRAFFIC_ANNOTATION_FOR_TESTS));
request->Start();
EXPECT_TRUE(request->is_pending());
base::RunLoop().Run();
ASSERT_GT(delegate.bytes_received(), 0);
ASSERT_LE(delegate.bytes_received(), kBufferSize);
EXPECT_TRUE(HasHeader(delegate.data_received(), root_dir));
EXPECT_FALSE(HasParentDirLink(delegate.data_received()));
EXPECT_GT(GetEntryCount(delegate.data_received()), 0);
EXPECT_FALSE(HasParentDirEntry(delegate.data_received()));
} }
#endif // !defined(OS_ANDROID)
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment