OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 base::PlatformFileError expectation = | 168 base::PlatformFileError expectation = |
169 kFilteringTestCases[i].visible ? | 169 kFilteringTestCases[i].visible ? |
170 base::PLATFORM_FILE_OK : | 170 base::PLATFORM_FILE_OK : |
171 base::PLATFORM_FILE_ERROR_NOT_FOUND; | 171 base::PLATFORM_FILE_ERROR_NOT_FOUND; |
172 | 172 |
173 if (kFilteringTestCases[i].is_directory) | 173 if (kFilteringTestCases[i].is_directory) |
174 operation->DirectoryExists(url, base::Bind(&ExpectEqHelper, expectation)); | 174 operation->DirectoryExists(url, base::Bind(&ExpectEqHelper, expectation)); |
175 else | 175 else |
176 operation->FileExists(url, base::Bind(&ExpectEqHelper, expectation)); | 176 operation->FileExists(url, base::Bind(&ExpectEqHelper, expectation)); |
177 MessageLoop::current()->RunAllPending(); | 177 MessageLoop::current()->RunUntilIdle(); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 TEST_F(NativeMediaFileUtilTest, ReadDirectoryFiltering) { | 181 TEST_F(NativeMediaFileUtilTest, ReadDirectoryFiltering) { |
182 PopulateDirectoryWithTestCases(root_path(), | 182 PopulateDirectoryWithTestCases(root_path(), |
183 kFilteringTestCases, | 183 kFilteringTestCases, |
184 arraysize(kFilteringTestCases)); | 184 arraysize(kFilteringTestCases)); |
185 | 185 |
186 std::set<FilePath::StringType> content; | 186 std::set<FilePath::StringType> content; |
187 FileSystemURL url(origin(), type(), root_path()); | 187 FileSystemURL url(origin(), type(), root_path()); |
188 bool completed = false; | 188 bool completed = false; |
189 NewOperation(url)->ReadDirectory( | 189 NewOperation(url)->ReadDirectory( |
190 url, base::Bind(&DidReadDirectory, &content, &completed)); | 190 url, base::Bind(&DidReadDirectory, &content, &completed)); |
191 MessageLoop::current()->RunAllPending(); | 191 MessageLoop::current()->RunUntilIdle(); |
192 EXPECT_TRUE(completed); | 192 EXPECT_TRUE(completed); |
193 EXPECT_EQ(5u, content.size()); | 193 EXPECT_EQ(5u, content.size()); |
194 | 194 |
195 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { | 195 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
196 FilePath::StringType name = | 196 FilePath::StringType name = |
197 FilePath(kFilteringTestCases[i].path).BaseName().value(); | 197 FilePath(kFilteringTestCases[i].path).BaseName().value(); |
198 std::set<FilePath::StringType>::const_iterator found = content.find(name); | 198 std::set<FilePath::StringType>::const_iterator found = content.find(name); |
199 EXPECT_EQ(kFilteringTestCases[i].visible, found != content.end()); | 199 EXPECT_EQ(kFilteringTestCases[i].visible, found != content.end()); |
200 } | 200 } |
201 } | 201 } |
OLD | NEW |