diff options
author | cmumford@chromium.org <cmumford@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 21:40:55 +0000 |
---|---|---|
committer | cmumford@chromium.org <cmumford@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-04 21:40:55 +0000 |
commit | 21d8ff1e1b8eaaa253bc7e8a79aa7d2c96b1d907 (patch) | |
tree | 4bf19d564abc3642ce3057776ea4e154ca4b8bd9 /third_party | |
parent | 6d66889e60c2ed2f6da8affb7399bba857c6dc30 (diff) | |
download | chromium_src-21d8ff1e1b8eaaa253bc7e8a79aa7d2c96b1d907.zip chromium_src-21d8ff1e1b8eaaa253bc7e8a79aa7d2c96b1d907.tar.gz chromium_src-21d8ff1e1b8eaaa253bc7e8a79aa7d2c96b1d907.tar.bz2 |
ChromiumEnv::GetChildren() now clearing prior results.
Required as per API documentation in leveldb/env.h
BUG=324924
Review URL: https://codereview.chromium.org/99913005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238780 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/leveldatabase/env_chromium.cc | 1 | ||||
-rw-r--r-- | third_party/leveldatabase/env_chromium_unittest.cc | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index ee36b14..b5a866c 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -811,6 +811,7 @@ Status ChromiumEnv::GetChildren(const std::string& dir_string, return MakeIOError( dir_string, "Could not open/read directory", kGetChildren, error); } + result->clear(); for (std::vector<base::FilePath>::iterator it = entries.begin(); it != entries.end(); ++it) { diff --git a/third_party/leveldatabase/env_chromium_unittest.cc b/third_party/leveldatabase/env_chromium_unittest.cc index a995acd..ca87238 100644 --- a/third_party/leveldatabase/env_chromium_unittest.cc +++ b/third_party/leveldatabase/env_chromium_unittest.cc @@ -199,4 +199,28 @@ TEST(ChromiumEnv, GetChildrenEmptyDir) { EXPECT_EQ(0, result.size()); } +TEST(ChromiumEnv, GetChildrenPriorResults) { + base::ScopedTempDir scoped_temp_dir; + scoped_temp_dir.CreateUniqueTempDir(); + base::FilePath dir = scoped_temp_dir.path(); + + base::FilePath new_file_dir = dir.Append(FPL("tmp_file")); + FILE* f = fopen(new_file_dir.value().c_str(), "w"); + if (f) { + fputs("Temp file contents", f); + fclose(f); + } + + Env* env = IDBEnv(); + std::vector<std::string> result; + leveldb::Status status = env->GetChildren(dir.AsUTF8Unsafe(), &result); + EXPECT_TRUE(status.ok()); + EXPECT_EQ(1, result.size()); + + // And a second time should also return one result + status = env->GetChildren(dir.AsUTF8Unsafe(), &result); + EXPECT_TRUE(status.ok()); + EXPECT_EQ(1, result.size()); +} + int main(int argc, char** argv) { return base::TestSuite(argc, argv).Run(); } |