1 /*
2 * Copyright (c) 2022 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 #include <cstdint>
17 #include <iosfwd>
18 #include <string>
19
20 #include <gtest/gtest.h>
21 #include "gtest/gtest-message.h"
22 #include "gtest/gtest-test-part.h"
23 #include "gtest/hwext/gtest-ext.h"
24 #include "gtest/hwext/gtest-tag.h"
25 #include "account_file_operator.h"
26
27 using namespace testing::ext;
28 using namespace OHOS::AccountSA;
29 using namespace OHOS;
30
31 class AccountFileOperatorTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp();
36 void TearDown();
37 };
38
SetUpTestCase()39 void AccountFileOperatorTest::SetUpTestCase() {}
40
TearDownTestCase()41 void AccountFileOperatorTest::TearDownTestCase() {}
42
SetUp()43 void AccountFileOperatorTest::SetUp()
44 {
45 }
46
TearDown()47 void AccountFileOperatorTest::TearDown() {}
48
49 /**
50 * @tc.name: AccountFileOperator001
51 * @tc.desc: Test invalid path
52 * @tc.type: FUNC
53 * @tc.require: issueI5RWXN
54 */
55 HWTEST_F(AccountFileOperatorTest, AccountFileOperator001, TestSize.Level0)
56 {
57 auto accountFileOperator_ = std::make_shared<AccountFileOperator>();
58 EXPECT_EQ(accountFileOperator_->DeleteDirOrFile("../../xx"), OHOS::ERR_OSACCOUNT_SERVICE_FILE_DELE_ERROR);
59 EXPECT_EQ(accountFileOperator_->IsExistFile(""), false);
60 EXPECT_EQ(accountFileOperator_->IsJsonFormat("../&*&"), false);
61 EXPECT_EQ(accountFileOperator_->IsExistDir(""), false);
62 EXPECT_EQ(
63 accountFileOperator_->InputFileByPathAndContent("/test1", "test"), ERR_OSACCOUNT_SERVICE_FILE_FIND_DIR_ERROR);
64 }
65