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 "gtest/gtest.h"
17 #include "iconsumer_surface.h"
18 #include "ohos_adapter_helper.h"
19 #include "window.h"
20 
21 using testing::ext::TestSize;
22 
23 namespace OHOS::NWeb {
24 /**
25  * @tc.name: NormalTest.
26  * @tc.desc: test WindowAdapterImpl class function.
27  * @tc.type: FUNC.
28  * @tc.require:
29  */
30 HWTEST(WindowAdapterImplTest, NormalTest, TestSize.Level1)
31 {
32     auto cSurface = IConsumerSurface::Create("test");
33     auto producer = cSurface->GetProducer();
34     auto pSurface = Surface::CreateSurfaceAsProducer(producer);
35     auto window = OhosAdapterHelper::GetInstance().GetWindowAdapterInstance().CreateNativeWindowFromSurface(&pSurface);
36     EXPECT_NE(window, nullptr);
37     EXPECT_EQ(OhosAdapterHelper::GetInstance().GetWindowAdapterInstance().NativeWindowSetBufferGeometry(
38         window, 0, 0), OHOS::GSERROR_OK);
39     OhosAdapterHelper::GetInstance().GetWindowAdapterInstance().NativeWindowSurfaceCleanCache(window);
40     OhosAdapterHelper::GetInstance().GetWindowAdapterInstance().NativeWindowSurfaceCleanCacheWithPara(window, false);
41     OhosAdapterHelper::GetInstance().GetWindowAdapterInstance().DestroyNativeWindow(window);
42 }
43 
44 /**
45  * @tc.name: NormalTest.
46  * @tc.desc: test AshmemAdapterImplTest class function.
47  * @tc.type: FUNC.
48  * @tc.require:
49  */
50 HWTEST(AshmemAdapterImplTest, NormalTest, TestSize.Level1)
51 {
52     size_t size = 1024;
53     EXPECT_GE(AshmemAdapter::AshmemCreate("test", size), 0);
54 }
55 } // namespace OHOS::NWeb
56