1 /*
2 * Copyright (c) 2024 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, Hardware
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 "drawing_bitmap.h"
18 #include "drawing_error_code.h"
19
20 #ifdef RS_ENABLE_VK
21 #include "platform/ohos/backend/rs_vulkan_context.h"
22 #endif
23
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS {
28 namespace Rosen {
29 namespace Drawing {
30 class NativeErrorCodeTest : public testing::Test {
31 public:
32 static void SetUpTestCase();
33 static void TearDownTestCase();
34 void SetUp() override;
35 void TearDown() override;
36 };
37
SetUpTestCase()38 void NativeErrorCodeTest::SetUpTestCase()
39 {
40 #ifdef RS_ENABLE_VK
41 RsVulkanContext::SetRecyclable(false);
42 #endif
43 }
TearDownTestCase()44 void NativeErrorCodeTest::TearDownTestCase() {}
SetUp()45 void NativeErrorCodeTest::SetUp() {}
TearDown()46 void NativeErrorCodeTest::TearDown() {}
47
48 /*
49 * @tc.name: NativeErrorCodeTest_GetAndReset
50 * @tc.desc: test GetAndReset
51 * @tc.type: FUNC
52 * @tc.require: AR000GTO5R
53 */
54 HWTEST_F(NativeErrorCodeTest, NativeErrorCodeTest_GetAndReset, TestSize.Level1)
55 {
56 OH_Drawing_ErrorCodeReset();
57 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
58 OH_Drawing_BitmapCreateFromPixels(nullptr, nullptr, 0);
59 EXPECT_NE(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
60 OH_Drawing_ErrorCodeReset();
61 EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_DRAWING_SUCCESS);
62 }
63 } // namespace Drawing
64 } // namespace Rosen
65 } // namespace OHOS