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

Side by Side Diff: webkit/browser/fileapi/native_file_util_unittest.cc

Issue 206783004: Remove PlatforFile from fileapi/native_file_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file.h"
8 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
10 #include "base/platform_file.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webkit/browser/fileapi/native_file_util.h" 12 #include "webkit/browser/fileapi/native_file_util.h"
13 13
14 namespace fileapi { 14 namespace fileapi {
15 15
16 class NativeFileUtilTest : public testing::Test { 16 class NativeFileUtilTest : public testing::Test {
17 public: 17 public:
18 NativeFileUtilTest() {} 18 NativeFileUtilTest() {}
19 19
20 virtual void SetUp() { 20 virtual void SetUp() {
(...skipping 21 matching lines...) Expand all
42 } 42 }
43 43
44 private: 44 private:
45 base::ScopedTempDir data_dir_; 45 base::ScopedTempDir data_dir_;
46 46
47 DISALLOW_COPY_AND_ASSIGN(NativeFileUtilTest); 47 DISALLOW_COPY_AND_ASSIGN(NativeFileUtilTest);
48 }; 48 };
49 49
50 TEST_F(NativeFileUtilTest, CreateCloseAndDeleteFile) { 50 TEST_F(NativeFileUtilTest, CreateCloseAndDeleteFile) {
51 base::FilePath file_name = Path("test_file"); 51 base::FilePath file_name = Path("test_file");
52 base::PlatformFile file_handle; 52 base::File file;
53 bool created = false; 53 int flags = base::File::FLAG_WRITE | base::File::FLAG_ASYNC;
54 int flags = base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC;
55 ASSERT_EQ(base::File::FILE_OK, 54 ASSERT_EQ(base::File::FILE_OK,
56 NativeFileUtil::CreateOrOpen(file_name, 55 NativeFileUtil::CreateOrOpen(file_name,
57 base::PLATFORM_FILE_CREATE | flags, 56 base::File::FLAG_CREATE | flags,
58 &file_handle, &created)); 57 &file));
59 ASSERT_TRUE(created); 58 ASSERT_TRUE(file.created());
60 59
61 EXPECT_TRUE(base::PathExists(file_name)); 60 EXPECT_TRUE(base::PathExists(file_name));
62 EXPECT_TRUE(NativeFileUtil::PathExists(file_name)); 61 EXPECT_TRUE(NativeFileUtil::PathExists(file_name));
63 EXPECT_EQ(0, GetSize(file_name)); 62 EXPECT_EQ(0, GetSize(file_name));
64 EXPECT_NE(base::kInvalidPlatformFileValue, file_handle); 63 EXPECT_TRUE(file.IsValid());
65 64 file.Close();
66 ASSERT_EQ(base::File::FILE_OK, NativeFileUtil::Close(file_handle));
67 65
68 ASSERT_EQ(base::File::FILE_OK, 66 ASSERT_EQ(base::File::FILE_OK,
69 NativeFileUtil::CreateOrOpen(file_name, 67 NativeFileUtil::CreateOrOpen(file_name,
70 base::PLATFORM_FILE_OPEN | flags, 68 base::File::FLAG_OPEN | flags,
71 &file_handle, &created)); 69 &file));
72 ASSERT_FALSE(created); 70 ASSERT_FALSE(file.created());
73 ASSERT_EQ(base::File::FILE_OK, NativeFileUtil::Close(file_handle)); 71 file.Close();
74 72
75 ASSERT_EQ(base::File::FILE_OK, 73 ASSERT_EQ(base::File::FILE_OK,
76 NativeFileUtil::DeleteFile(file_name)); 74 NativeFileUtil::DeleteFile(file_name));
77 EXPECT_FALSE(base::PathExists(file_name)); 75 EXPECT_FALSE(base::PathExists(file_name));
78 EXPECT_FALSE(NativeFileUtil::PathExists(file_name)); 76 EXPECT_FALSE(NativeFileUtil::PathExists(file_name));
79 } 77 }
80 78
81 TEST_F(NativeFileUtilTest, EnsureFileExists) { 79 TEST_F(NativeFileUtilTest, EnsureFileExists) {
82 base::FilePath file_name = Path("foobar"); 80 base::FilePath file_name = Path("foobar");
83 bool created = false; 81 bool created = false;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, 401 FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
404 NativeFileUtil::MOVE)); 402 NativeFileUtil::MOVE));
405 403
406 ASSERT_TRUE(FileExists(to_file3)); 404 ASSERT_TRUE(FileExists(to_file3));
407 ASSERT_EQ(base::File::FILE_OK, 405 ASSERT_EQ(base::File::FILE_OK,
408 NativeFileUtil::GetFileInfo(to_file2, &file_info2)); 406 NativeFileUtil::GetFileInfo(to_file2, &file_info2));
409 EXPECT_EQ(file_info1.last_modified, file_info2.last_modified); 407 EXPECT_EQ(file_info1.last_modified, file_info2.last_modified);
410 } 408 }
411 409
412 } // namespace fileapi 410 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698