• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <gmock/gmock.h>
17 #include <gtest/gtest.h>
18 #include <sys/stat.h>
19 #include <unistd.h>
20 
21 #include "async_work.h"
22 #include "utils_log.h"
23 
24 namespace OHOS::FileManagement::CloudSync::Test {
25 using namespace testing;
26 using namespace testing::ext;
27 using namespace std;
28 
29 class AsyncWorkTest : public testing::Test {
30 public:
31     static void SetUpTestCase(void);
32     static void TearDownTestCase(void);
33     void SetUp();
34     void TearDown();
35 };
36 
SetUpTestCase(void)37 void AsyncWorkTest::SetUpTestCase(void)
38 {
39     GTEST_LOG_(INFO) << "SetUpTestCase";
40 }
41 
TearDownTestCase(void)42 void AsyncWorkTest::TearDownTestCase(void)
43 {
44     GTEST_LOG_(INFO) << "TearDownTestCase";
45 }
46 
SetUp(void)47 void AsyncWorkTest::SetUp(void)
48 {
49     GTEST_LOG_(INFO) << "SetUp";
50 }
51 
TearDown(void)52 void AsyncWorkTest::TearDown(void)
53 {
54     GTEST_LOG_(INFO) << "TearDown";
55 }
56 
57 /**
58  * @tc.name: GetPromiseOrCallBackWorkTest001
59  * @tc.desc: Verify the ForceCreateDirectory function
60  * @tc.type: FUNC
61  * @tc.require: I6H5MH
62  */
63 HWTEST_F(AsyncWorkTest, GetPromiseOrCallBackWorkTest001, TestSize.Level1)
64 {
65     napi_env env = nullptr;
66     napi_callback_info info = nullptr;
67     LibN::NFuncArg funcArg(env, info);
68 
69     std::unique_ptr<LibN::NAsyncWork> asyncWork = LibN::GetPromiseOrCallBackWork(env, funcArg, 1);
70     EXPECT_NE(asyncWork, nullptr);
71 }
72 
73 HWTEST_F(AsyncWorkTest, GetPromiseOrCallBackWorkTest002, TestSize.Level1)
74 {
75     napi_env env = nullptr;
76     napi_callback_info info = nullptr;
77     LibN::NFuncArg funcArg(env, info);
78 
79     std::unique_ptr<LibN::NAsyncWork> asyncWork = LibN::GetPromiseOrCallBackWork(env, funcArg, 0);
80     EXPECT_EQ(asyncWork, nullptr);
81 }
82 
83 }