| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "mojo/file_utils/file_util.h" | 11 #include "mojo/file_utils/file_util.h" |
| 12 #include "mojo/public/cpp/application/application_impl.h" | |
| 13 #include "mojo/public/cpp/application/application_test_base.h" | 12 #include "mojo/public/cpp/application/application_test_base.h" |
| 14 #include "mojo/public/cpp/application/connect.h" | 13 #include "mojo/public/cpp/application/connect.h" |
| 15 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h" | 14 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h" |
| 16 #include "mojo/public/cpp/utility/run_loop.h" | 15 #include "mojo/public/cpp/utility/run_loop.h" |
| 17 #include "mojo/services/files/interfaces/directory.mojom-sync.h" | 16 #include "mojo/services/files/interfaces/directory.mojom-sync.h" |
| 18 #include "mojo/services/files/interfaces/file.mojom-sync.h" | 17 #include "mojo/services/files/interfaces/file.mojom-sync.h" |
| 19 #include "mojo/services/files/interfaces/files.mojom-sync.h" | 18 #include "mojo/services/files/interfaces/files.mojom-sync.h" |
| 20 | 19 |
| 21 namespace file_utils { | 20 namespace file_utils { |
| 22 namespace test { | 21 namespace test { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 (*directory) | 85 (*directory) |
| 87 ->OpenFile(path_name, GetSynchronousProxy(&temp_file), | 86 ->OpenFile(path_name, GetSynchronousProxy(&temp_file), |
| 88 mojo::files::kOpenFlagWrite | mojo::files::kOpenFlagRead, | 87 mojo::files::kOpenFlagWrite | mojo::files::kOpenFlagRead, |
| 89 &error)); | 88 &error)); |
| 90 EXPECT_EQ(mojo::files::Error::OK, error); | 89 EXPECT_EQ(mojo::files::Error::OK, error); |
| 91 return temp_file; | 90 return temp_file; |
| 92 } | 91 } |
| 93 | 92 |
| 94 TEST_F(FileUtilTest, BasicCreateTemporaryFile) { | 93 TEST_F(FileUtilTest, BasicCreateTemporaryFile) { |
| 95 mojo::SynchronousInterfacePtr<mojo::files::Files> files; | 94 mojo::SynchronousInterfacePtr<mojo::files::Files> files; |
| 96 mojo::ConnectToService(application_impl()->shell(), "mojo:files", | 95 mojo::ConnectToService(shell(), "mojo:files", GetSynchronousProxy(&files)); |
| 97 GetSynchronousProxy(&files)); | |
| 98 | 96 |
| 99 mojo::files::Error error = mojo::files::Error::INTERNAL; | 97 mojo::files::Error error = mojo::files::Error::INTERNAL; |
| 100 mojo::SynchronousInterfacePtr<mojo::files::Directory> directory; | 98 mojo::SynchronousInterfacePtr<mojo::files::Directory> directory; |
| 101 ASSERT_TRUE(files->OpenFileSystem( | 99 ASSERT_TRUE(files->OpenFileSystem( |
| 102 nullptr, mojo::GetSynchronousProxy(&directory), &error)); | 100 nullptr, mojo::GetSynchronousProxy(&directory), &error)); |
| 103 EXPECT_EQ(mojo::files::Error::OK, error); | 101 EXPECT_EQ(mojo::files::Error::OK, error); |
| 104 | 102 |
| 105 std::string filename1; | 103 std::string filename1; |
| 106 auto file1 = mojo::SynchronousInterfacePtr<mojo::files::File>::Create( | 104 auto file1 = mojo::SynchronousInterfacePtr<mojo::files::File>::Create( |
| 107 CreateTemporaryFileInDir(&directory, &filename1)); | 105 CreateTemporaryFileInDir(&directory, &filename1)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 150 |
| 153 // Test that the files can be closed once more. | 151 // Test that the files can be closed once more. |
| 154 CloseFileHelper(&file1); | 152 CloseFileHelper(&file1); |
| 155 CloseFileHelper(&file2); | 153 CloseFileHelper(&file2); |
| 156 CloseFileHelper(&file3); | 154 CloseFileHelper(&file3); |
| 157 } | 155 } |
| 158 | 156 |
| 159 } // namespace | 157 } // namespace |
| 160 } // namespace test | 158 } // namespace test |
| 161 } // namespace file_utils | 159 } // namespace file_utils |
| OLD | NEW |