Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: base/files/file_unittest.cc

Issue 206783004: Remove PlatforFile from fileapi/native_file_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change API to return File Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/file.h" 6 #include "base/files/file.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using base::File; 11 using base::File;
12 using base::FilePath; 12 using base::FilePath;
13 13
14 TEST(File, Create) { 14 TEST(File, Create) {
15 base::ScopedTempDir temp_dir; 15 base::ScopedTempDir temp_dir;
16 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 16 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
17 FilePath file_path = temp_dir.path().AppendASCII("create_file_1"); 17 FilePath file_path = temp_dir.path().AppendASCII("create_file_1");
18 18
19 { 19 {
20 // Don't create a File at all.
21 File file;
22 EXPECT_FALSE(file.IsValid());
23 EXPECT_EQ(base::File::FILE_ERROR_FAILED, file.error_details());
24
25 File file2(base::File::FILE_ERROR_TOO_MANY_OPENED);
26 EXPECT_FALSE(file2.IsValid());
27 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, file2.error_details());
28 }
29
30 {
20 // Open a file that doesn't exist. 31 // Open a file that doesn't exist.
21 File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ); 32 File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
22 EXPECT_FALSE(file.IsValid()); 33 EXPECT_FALSE(file.IsValid());
23 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file.error_details()); 34 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file.error_details());
24 } 35 }
25 36
26 { 37 {
27 // Open or create a file. 38 // Open or create a file.
28 File file(file_path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ); 39 File file(file_path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ);
29 EXPECT_TRUE(file.IsValid()); 40 EXPECT_TRUE(file.IsValid());
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 NULL)); 424 NULL));
414 ASSERT_TRUE(dir.IsValid()); 425 ASSERT_TRUE(dir.IsValid());
415 426
416 base::File::Info info; 427 base::File::Info info;
417 EXPECT_TRUE(dir.GetInfo(&info)); 428 EXPECT_TRUE(dir.GetInfo(&info));
418 EXPECT_TRUE(info.is_directory); 429 EXPECT_TRUE(info.is_directory);
419 EXPECT_FALSE(info.is_symbolic_link); 430 EXPECT_FALSE(info.is_symbolic_link);
420 EXPECT_EQ(0, info.size); 431 EXPECT_EQ(0, info.size);
421 } 432 }
422 #endif // defined(OS_WIN) 433 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698