OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_proxy.h" | 5 #include "base/files/file_proxy.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <utility> | 10 #include <utility> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/files/file.h" | 13 #include "base/files/file.h" |
11 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
15 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 20 #include "build/build_config.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
17 | 22 |
18 namespace base { | 23 namespace base { |
19 | 24 |
20 class FileProxyTest : public testing::Test { | 25 class FileProxyTest : public testing::Test { |
21 public: | 26 public: |
22 FileProxyTest() | 27 FileProxyTest() |
23 : file_thread_("FileProxyTestFileThread"), | 28 : file_thread_("FileProxyTestFileThread"), |
24 error_(File::FILE_OK), | 29 error_(File::FILE_OK), |
25 bytes_written_(-1), | 30 bytes_written_(-1), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 69 } |
65 | 70 |
66 void DidWrite(File::Error error, | 71 void DidWrite(File::Error error, |
67 int bytes_written) { | 72 int bytes_written) { |
68 error_ = error; | 73 error_ = error; |
69 bytes_written_ = bytes_written; | 74 bytes_written_ = bytes_written; |
70 MessageLoop::current()->QuitWhenIdle(); | 75 MessageLoop::current()->QuitWhenIdle(); |
71 } | 76 } |
72 | 77 |
73 protected: | 78 protected: |
74 void CreateProxy(uint32 flags, FileProxy* proxy) { | 79 void CreateProxy(uint32_t flags, FileProxy* proxy) { |
75 proxy->CreateOrOpen( | 80 proxy->CreateOrOpen( |
76 test_path(), flags, | 81 test_path(), flags, |
77 Bind(&FileProxyTest::DidCreateOrOpen, weak_factory_.GetWeakPtr())); | 82 Bind(&FileProxyTest::DidCreateOrOpen, weak_factory_.GetWeakPtr())); |
78 MessageLoop::current()->Run(); | 83 MessageLoop::current()->Run(); |
79 EXPECT_TRUE(proxy->IsValid()); | 84 EXPECT_TRUE(proxy->IsValid()); |
80 } | 85 } |
81 | 86 |
82 TaskRunner* file_task_runner() const { | 87 TaskRunner* file_task_runner() const { |
83 return file_thread_.task_runner().get(); | 88 return file_thread_.task_runner().get(); |
84 } | 89 } |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 char buffer[53]; | 373 char buffer[53]; |
369 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); | 374 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); |
370 int i = 0; | 375 int i = 0; |
371 for (; i < 10; ++i) | 376 for (; i < 10; ++i) |
372 EXPECT_EQ(kTestData[i], buffer[i]); | 377 EXPECT_EQ(kTestData[i], buffer[i]); |
373 for (; i < 53; ++i) | 378 for (; i < 53; ++i) |
374 EXPECT_EQ(0, buffer[i]); | 379 EXPECT_EQ(0, buffer[i]); |
375 } | 380 } |
376 | 381 |
377 } // namespace base | 382 } // namespace base |
OLD | NEW |