1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 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 16 #ifndef ROSEN_MODULES_TEXGINE_SRC_MOCK_H 17 #define ROSEN_MODULES_TEXGINE_SRC_MOCK_H 18 19 #include <fstream> 20 #include <system_error> 21 22 namespace OHOS { 23 namespace Rosen { 24 namespace TextEngine { 25 class MockIFStream : public std::ifstream { 26 public: 27 explicit MockIFStream(const std::string &filename, 28 std::ios_base::openmode mode = ios_base::in); 29 30 bool StdFilesystemIsOpen() const; 31 32 std::istream &StdFilesystemSeekg(pos_type pos); 33 34 std::istream &StdFilesystemSeekg(off_type off, std::ios_base::seekdir dir); 35 36 pos_type StdFilesystemTellg(); 37 38 std::istream &StdFilesystemRead(char_type *s, std::streamsize count); 39 40 void StdFilestystemClose(); 41 }; 42 43 bool StdFilesystemExists(const std::string &p, std::error_code &ec); 44 } // namespace TextEngine 45 } // namespace Rosen 46 } // namespace OHOS 47 48 #endif // ROSEN_MODULES_TEXGINE_SRC_MOCK_H 49