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 "ppapi/tests/test_flash_file.h" | 5 #include "ppapi/tests/test_flash_file.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ppapi/c/pp_file_info.h" | 10 #include "ppapi/c/pp_file_info.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 std::string contents = "This is file."; | 278 std::string contents = "This is file."; |
279 PP_FileHandle file_handle = FileModuleLocal::OpenFile(instance_, | 279 PP_FileHandle file_handle = FileModuleLocal::OpenFile(instance_, |
280 filename, | 280 filename, |
281 PP_FILEOPENFLAG_WRITE | | 281 PP_FILEOPENFLAG_WRITE | |
282 PP_FILEOPENFLAG_CREATE); | 282 PP_FILEOPENFLAG_CREATE); |
283 ASSERT_NE(PP_kInvalidFileHandle, file_handle); | 283 ASSERT_NE(PP_kInvalidFileHandle, file_handle); |
284 ASSERT_TRUE(WriteFile(file_handle, contents)); | 284 ASSERT_TRUE(WriteFile(file_handle, contents)); |
285 CloseFileHandle(file_handle); | 285 CloseFileHandle(file_handle); |
286 ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname)); | 286 ASSERT_TRUE(FileModuleLocal::CreateDir(instance_, dirname)); |
287 | 287 |
288 ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, "", &result)); | 288 ASSERT_TRUE( |
289 FileModuleLocal::DirEntry expected[] = | 289 FileModuleLocal::GetDirContents(instance_, std::string(), &result)); |
290 { {"..", true}, | 290 FileModuleLocal::DirEntry expected[] = { { "..", true }, { filename, false }, |
291 {filename, false}, | 291 { dirname, true } }; |
292 {dirname, true} | |
293 }; | |
294 size_t expected_size = sizeof(expected) / sizeof(expected[0]); | 292 size_t expected_size = sizeof(expected) / sizeof(expected[0]); |
295 | 293 |
296 std::sort(expected, expected + expected_size, DirEntryLessThan); | 294 std::sort(expected, expected + expected_size, DirEntryLessThan); |
297 std::sort(result.begin(), result.end(), DirEntryLessThan); | 295 std::sort(result.begin(), result.end(), DirEntryLessThan); |
298 | 296 |
299 ASSERT_EQ(expected_size, result.size()); | 297 ASSERT_EQ(expected_size, result.size()); |
300 ASSERT_TRUE(std::equal(expected, expected + expected_size, result.begin(), | 298 ASSERT_TRUE(std::equal(expected, expected + expected_size, result.begin(), |
301 DirEntryEqual)); | 299 DirEntryEqual)); |
302 | 300 |
303 PASS(); | 301 PASS(); |
(...skipping 18 matching lines...) Expand all Loading... |
322 size_t after_close = 0; | 320 size_t after_close = 0; |
323 ASSERT_SUBTEST_SUCCESS(GetItemCountUnderModuleLocalRoot(&after_close)); | 321 ASSERT_SUBTEST_SUCCESS(GetItemCountUnderModuleLocalRoot(&after_close)); |
324 ASSERT_EQ(before_create, after_close); | 322 ASSERT_EQ(before_create, after_close); |
325 | 323 |
326 PASS(); | 324 PASS(); |
327 } | 325 } |
328 | 326 |
329 std::string TestFlashFile::GetItemCountUnderModuleLocalRoot( | 327 std::string TestFlashFile::GetItemCountUnderModuleLocalRoot( |
330 size_t* item_count) { | 328 size_t* item_count) { |
331 std::vector<FileModuleLocal::DirEntry> contents; | 329 std::vector<FileModuleLocal::DirEntry> contents; |
332 ASSERT_TRUE(FileModuleLocal::GetDirContents(instance_, "", &contents)); | 330 ASSERT_TRUE( |
| 331 FileModuleLocal::GetDirContents(instance_, std::string(), &contents)); |
333 *item_count = contents.size(); | 332 *item_count = contents.size(); |
334 PASS(); | 333 PASS(); |
335 } | 334 } |
OLD | NEW |