OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #ifndef CRASHPAD_UTIL_TEST_SCOPED_TEMP_DIR_ | |
16 #define CRASHPAD_UTIL_TEST_SCOPED_TEMP_DIR_ | |
17 | |
18 #include "base/basictypes.h" | |
19 #include "base/files/file_path.h" | |
20 | |
21 namespace crashpad { | |
22 namespace test { | |
23 | |
24 //! \brief A RAII object that creates a temporary directory for testing. | |
25 //! | |
26 //! Upon construction, a temporary directory will be created. Failure to create | |
27 //! the directory is fatal. On destruction, the directory and all its contents | |
28 //! will be removed. | |
29 class ScopedTempDir { | |
30 public: | |
31 ScopedTempDir(); | |
32 ~ScopedTempDir(); | |
33 | |
34 //! \brief Returns the path of the temporary directory. | |
35 //! | |
36 //! \return The temporary directory path. | |
37 base::FilePath path() { return path_; } | |
Mark Mentovai
2014/12/31 05:51:09
This should be const and can return a const&.
Robert Sesek
2015/01/02 17:34:08
Done.
| |
38 | |
39 private: | |
40 //! \brief Creates the temporary directory and asserts success of the | |
41 //! operation. | |
42 base::FilePath CreateTemporaryDirectory(); | |
Mark Mentovai
2014/12/31 05:51:09
This should be static. Remember to add “// static”
Robert Sesek
2015/01/02 17:34:08
Done.
| |
43 | |
44 //! \brief Removes all files and subdirectories at the given \a path, | |
45 //! including the \a path itself. | |
46 //! | |
47 //! Failures should be recorded as gtest expectations. | |
Mark Mentovai
2014/12/31 05:51:09
These are comments for the caller, not the impleme
Robert Sesek
2015/01/02 17:34:08
Done.
| |
48 //! | |
49 //! \param[in] path The path and its contents to delete. This must reference | |
Mark Mentovai
2014/12/31 05:51:09
“The path and its contents to delete” doesn’t make
Robert Sesek
2015/01/02 17:34:08
Done.
| |
50 //! a directory. | |
51 void RecursivelyDeleteTemporaryDirectory(const base::FilePath& path); | |
Mark Mentovai
2014/12/31 05:51:09
So can this.
Robert Sesek
2015/01/02 17:34:08
Done.
| |
52 | |
53 base::FilePath path_; | |
Mark Mentovai
2014/12/31 05:51:09
Even this can be const.
Robert Sesek
2015/01/02 17:34:08
Done.
| |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir); | |
56 }; | |
57 | |
58 } // namespace test | |
59 } // namespace crashpad | |
60 | |
61 #endif // CRASHPAD_UTIL_TEST_SCOPED_TEMP_DIR_ | |
OLD | NEW |