1f6603c60Sopenharmony_ci/*
2f6603c60Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3f6603c60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f6603c60Sopenharmony_ci * you may not use this file except in compliance with the License.
5f6603c60Sopenharmony_ci * You may obtain a copy of the License at
6f6603c60Sopenharmony_ci *
7f6603c60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f6603c60Sopenharmony_ci *
9f6603c60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, Hardware
10f6603c60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f6603c60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f6603c60Sopenharmony_ci * See the License for the specific language governing permissions and
13f6603c60Sopenharmony_ci * limitations under the License.
14f6603c60Sopenharmony_ci */
15f6603c60Sopenharmony_ci
16f6603c60Sopenharmony_ci#include "drawing_point.h"
17f6603c60Sopenharmony_ci#include "gtest/gtest.h"
18f6603c60Sopenharmony_ci#include "utils/scalar.h"
19f6603c60Sopenharmony_ci
20f6603c60Sopenharmony_ciusing namespace testing;
21f6603c60Sopenharmony_ciusing namespace testing::ext;
22f6603c60Sopenharmony_ci
23f6603c60Sopenharmony_cinamespace OHOS {
24f6603c60Sopenharmony_cinamespace Rosen {
25f6603c60Sopenharmony_cinamespace Drawing {
26f6603c60Sopenharmony_ciclass NativeDrawingPointTest : public testing::Test {
27f6603c60Sopenharmony_cipublic:
28f6603c60Sopenharmony_ci    static void SetUpTestCase();
29f6603c60Sopenharmony_ci    static void TearDownTestCase();
30f6603c60Sopenharmony_ci    void SetUp() override;
31f6603c60Sopenharmony_ci    void TearDown() override;
32f6603c60Sopenharmony_ci};
33f6603c60Sopenharmony_ci
34f6603c60Sopenharmony_civoid NativeDrawingPointTest::SetUpTestCase() {}
35f6603c60Sopenharmony_civoid NativeDrawingPointTest::TearDownTestCase() {}
36f6603c60Sopenharmony_civoid NativeDrawingPointTest::SetUp() {}
37f6603c60Sopenharmony_civoid NativeDrawingPointTest::TearDown() {}
38f6603c60Sopenharmony_ci
39f6603c60Sopenharmony_ci/*
40f6603c60Sopenharmony_ci * @tc.name: NativeDrawingPointTest_PointGetAndSet001
41f6603c60Sopenharmony_ci * @tc.desc: test for set and get the x-axis and y-axis coordinates of the point.
42f6603c60Sopenharmony_ci * @tc.type: FUNC
43f6603c60Sopenharmony_ci * @tc.require: AR000GTO5R
44f6603c60Sopenharmony_ci */
45f6603c60Sopenharmony_ciHWTEST_F(NativeDrawingPointTest, NativeDrawingPointTest_PointGetAndSet001, TestSize.Level1)
46f6603c60Sopenharmony_ci{
47f6603c60Sopenharmony_ci    OH_Drawing_Point* centerPt = OH_Drawing_PointCreate(0, 0);
48f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_PointSet(nullptr, 150, 250), OH_DRAWING_ERROR_INVALID_PARAMETER);
49f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_PointSet(centerPt, 150, 250), OH_DRAWING_SUCCESS); // 150: point's x, 250: point's y
50f6603c60Sopenharmony_ci    float x, y;
51f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_PointGetX(centerPt, &x), OH_DRAWING_SUCCESS);
52f6603c60Sopenharmony_ci    EXPECT_EQ(OH_Drawing_PointGetY(centerPt, &y), OH_DRAWING_SUCCESS);
53f6603c60Sopenharmony_ci
54f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(x, 150));
55f6603c60Sopenharmony_ci    EXPECT_TRUE(IsScalarAlmostEqual(y, 250));
56f6603c60Sopenharmony_ci    OH_Drawing_PointDestroy(centerPt);
57f6603c60Sopenharmony_ci}
58f6603c60Sopenharmony_ci} // namespace Drawing
59f6603c60Sopenharmony_ci} // namespace Rosen
60f6603c60Sopenharmony_ci} // namespace OHOS