2Dgraphics Test

Signed-off-by: mlw296395 <wangmiaolin050@chinasoftinc.com>
Change-Id: I86a6eb75ca32ff1f132f1c04e2ac4f44eed35f8e
This commit is contained in:
mlw296395 2022-03-24 14:30:36 +08:00
parent 3d1b4229d7
commit 9ea2e2a635
15 changed files with 4289 additions and 1 deletions

View File

@ -164,7 +164,8 @@
],
"test": [
"//foundation/graphic/standard:graphic_standard_test",
"//foundation/graphic/standard/rosen/test/render_service:unittest"
"//foundation/graphic/standard/rosen/test/render_service:unittest",
"//foundation/graphic/standard/rosen/test/2d_graphics:unittest"
]
}
}

View File

@ -0,0 +1,21 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
group("unittest") {
testonly = true
deps = [
"unittest/image:unittest",
"unittest/utils:unittest",
]
}

View File

@ -0,0 +1,47 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
module_output_path = "graphic_standard/rosen/modules/2d_graphics/image"
ohos_unittest("2d_graphics_image_test") {
module_out_path = module_output_path
sources = [
"bitmap_test.cpp",
"image_test.cpp",
"picture_test.cpp",
]
include_dirs = [
"//foundation/graphic/standard/rosen/modules/2d_graphics/include",
"//foundation/graphic/standard/rosen/modules/2d_graphics/src",
"//third_party/googletest/googletest/include",
]
deps = [
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
"//foundation/graphic/standard/rosen/modules/2d_graphics:2d_graphics",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
]
subsystem_name = "graphic"
}
group("unittest") {
testonly = true
deps = [ ":2d_graphics_image_test" ]
}

View File

@ -0,0 +1,352 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "image/bitmap.h"
#include "draw/color.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class BitmapTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void BitmapTest::SetUpTestCase() {}
void BitmapTest::TearDownTestCase() {}
void BitmapTest::SetUp() {}
void BitmapTest::TearDown() {}
/**
* @tc.name: BitmapCreateAndDestory001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapCreateAndDestory001, TestSize.Level1)
{
// The best way to create Bitmap.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
}
/**
* @tc.name: BitmapBuildTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapBuildTest001, TestSize.Level1)
{
// The best way to Build Bitmap.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(100, 200, bitmapFormat);
}
/**
* @tc.name: BitmapBuildTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapBuildTest002, TestSize.Level1)
{
// The best way to Build Bitmap.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(150, 99, bitmapFormat);
}
/**
* @tc.name: BitmapBuildTest003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapBuildTest003, TestSize.Level1)
{
// The best way to Build Bitmap.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(111, 450, bitmapFormat);
}
/**
* @tc.name: BitmapGetWidthTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapGetWidthTest001, TestSize.Level1)
{
// The best way to get width.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(111, 450, bitmapFormat);
ASSERT_EQ(111, bitmap->GetWidth());
}
/**
* @tc.name: BitmapGetWidthTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapGetWidthTest002, TestSize.Level1)
{
// The best way to get width.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(151, 150, bitmapFormat);
ASSERT_EQ(151, bitmap->GetWidth());
}
/**
* @tc.name: BitmapGetHeightTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapGetHeightTest001, TestSize.Level1)
{
// The best way to get height.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(111, 450, bitmapFormat);
ASSERT_EQ(450, bitmap->GetHeight());
}
/**
* @tc.name: BitmapGetHeightTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapGetHeightTest002, TestSize.Level1)
{
// The best way to get height.
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(151, 150, bitmapFormat);
ASSERT_EQ(150, bitmap->GetHeight());
}
/**
* @tc.name: BitmapSetAndPixelsTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapSetAndPixelsTest001, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat *bitmapFormat1= nullptr;
bitmap->SetPixels(bitmapFormat1);
EXPECT_EQ(bitmapFormat1, bitmap->GetPixels());
}
/**
* @tc.name: BitmapSetAndPixelsTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapSetAndPixelsTest002, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat * bitmapFormat2= nullptr;
bitmap->SetPixels(bitmapFormat2);
EXPECT_EQ(bitmapFormat2, bitmap->GetPixels());
}
/**
* @tc.name: BitmapCopyPixelsTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapCopyPixelsTest001, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
Bitmap bitmap1;
bitmap->CopyPixels(bitmap1, 100, 105, 201, 845);
}
/**
* @tc.name: BitmapCopyPixelsTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapCopyPixelsTest002, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
Bitmap bitmap1;
bitmap->CopyPixels(bitmap1, 66, 5, 99, 320);
}
/**
* @tc.name: BitmapClearWithColor001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapClearWithColor001, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
bitmap->ClearWithColor(COLORTYPE_UNKNOWN);
}
/**
* @tc.name: BitmapClearWithColor002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapClearWithColor002, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
bitmap->ClearWithColor(COLORTYPE_ALPHA_8);
}
/**
* @tc.name: BitmapIsValid001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapIsValid001, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
ASSERT_TRUE(bitmap->IsValid());
}
/**
* @tc.name: BitmapIsValid002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapIsValid002, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
ASSERT_FALSE(! bitmap->IsValid());
}
/**
* @tc.name: BitmapBitmapGetColorTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapBitmapGetColorTest001, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
ASSERT_EQ(Color::COLOR_TRANSPARENT, bitmap->GetColor(0, 0));
}
/**
* @tc.name: BitmapGetColorTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapGetColorTest002, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
ASSERT_EQ(Color::COLOR_TRANSPARENT, bitmap->GetColor(1, 2));
}
/**
* @tc.name: BitmapGetFormatTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapGetFormatTest001, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(111, 450, bitmapFormat);
ASSERT_EQ(ColorType::COLORTYPE_UNKNOWN, bitmap->GetFormat().colorType);
ASSERT_EQ(AlphaType::ALPHATYPE_UNKNOWN, bitmap->GetFormat().alphaType);
bitmap->Free();
}
/**
* @tc.name: BitmapGetFormatTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(BitmapTest, BitmapGetFormatTest002, TestSize.Level1)
{
std::unique_ptr<Bitmap> bitmap = std::make_unique<Bitmap>();
ASSERT_TRUE(bitmap != nullptr);
BitmapFormat bitmapFormat = {ColorType::COLORTYPE_ALPHA_8, AlphaType::ALPHATYPE_OPAQUYE};
bitmap->Build(151, 150, bitmapFormat);
ASSERT_EQ(ColorType::COLORTYPE_UNKNOWN, bitmap->GetFormat().colorType);
ASSERT_EQ(AlphaType::ALPHATYPE_UNKNOWN, bitmap->GetFormat().alphaType);
bitmap->Free();
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,143 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "image/image.h"
#include "image/bitmap.h"
#include "image/picture.h"
#include "utils/matrix.h"
#include "utils/size.h"
#include "draw/brush.h"
#include "effect/color_space.h"
#include "engine_adapter/impl_factory.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class ImageTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void ImageTest::SetUpTestCase() {}
void ImageTest::TearDownTestCase() {}
void ImageTest::SetUp() {}
void ImageTest::TearDown() {}
/**
* @tc.name: CreateAndDestory001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(ImageTest, CreateAndDestory001, TestSize.Level1)
{
// The best way to create Image.
std::unique_ptr<Image> image = std::make_unique<Image>();
ASSERT_TRUE(image != nullptr);
}
/**
* @tc.name: BuildFromBitmap001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(ImageTest, BuildFromBitmap001, TestSize.Level1)
{
std::unique_ptr<Image> image = std::make_unique<Image>();
ASSERT_TRUE(image != nullptr);
Bitmap bitmap;
image->BuildFromBitmap(bitmap);
}
/**
* @tc.name: ImageGetWidthTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(ImageTest, ImageGetWidthTest001, TestSize.Level1)
{
Bitmap bitmap;
BitmapFormat bitmapFormat {COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUYE};
bitmap.Build(10, 10, bitmapFormat);
Image image;
image.BuildFromBitmap(bitmap);
ASSERT_EQ(10, image.GetWidth());
}
/**
* @tc.name: ImageGetWidthTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(ImageTest, ImageGetWidthTest002, TestSize.Level1)
{
Bitmap bitmap;
BitmapFormat bitmapFormat {COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUYE};
bitmap.Build(15, 15, bitmapFormat);
Image image;
image.BuildFromBitmap(bitmap);
ASSERT_EQ(15, image.GetWidth());
}
/**
* @tc.name: ImageGetHeightTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(ImageTest, ImageGetHeightTest001, TestSize.Level1)
{
Bitmap bitmap;
BitmapFormat bitmapFormat {COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUYE};
bitmap.Build(10, 10, bitmapFormat);
Image image;
image.BuildFromBitmap(bitmap);
ASSERT_EQ(10, image.GetHeight());
}
/**
* @tc.name: ImageGetHeightTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(ImageTest, ImageGetHeightTest002, TestSize.Level1)
{
Bitmap bitmap;
BitmapFormat bitmapFormat {COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUYE};
bitmap.Build(15, 15, bitmapFormat);
Image image;
image.BuildFromBitmap(bitmap);
ASSERT_EQ(15, image.GetHeight());
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "image/picture.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class PictureTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void PictureTest::SetUpTestCase() {}
void PictureTest::TearDownTestCase() {}
void PictureTest::SetUp() {}
void PictureTest::TearDown() {}
/**
* @tc.name: PictureCreateAndDestory001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(PictureTest, PictureCreateAndDestory001, TestSize.Level1)
{
// The best way to create Picture.
std::unique_ptr<Picture> picture = std::make_unique<Picture>();
ASSERT_TRUE(picture != nullptr);
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,52 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
module_output_path = "graphic_standard/rosen/modules/2d_graphics/utils"
ohos_unittest("2d_graphics_utils_test") {
module_out_path = module_output_path
sources = [
"camera3d_test.cpp",
"matrix_test.cpp",
"point3_test.cpp",
"point_test.cpp",
"rect_test.cpp",
"round_rect_test.cpp",
"sampling_options_test.cpp",
"size_test.cpp",
]
include_dirs = [
"//foundation/graphic/standard/rosen/modules/2d_graphics/include",
"//foundation/graphic/standard/rosen/modules/2d_graphics/src",
"//third_party/googletest/googletest/include",
]
deps = [
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
"//foundation/graphic/standard/rosen/modules/2d_graphics:2d_graphics",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
]
subsystem_name = "graphic"
}
group("unittest") {
testonly = true
deps = [ ":2d_graphics_utils_test" ]
}

View File

@ -0,0 +1,290 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "utils/camera3d.h"
#include "utils/scalar.h"
#include "utils/matrix.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class Camera3DTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void Camera3DTest::SetUpTestCase() {}
void Camera3DTest::TearDownTestCase() {}
void Camera3DTest::SetUp() {}
void Camera3DTest::TearDown() {}
/**
* @tc.name: Camera3DCreateAndDestory001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DCreateAndDestory001, TestSize.Level1)
{
// The best way to create Camera3D.
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
}
/**
* @tc.name: Camera3DCreateAndDestory002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DCreateAndDestory002, TestSize.Level1)
{
// The best way to create Camera3D.
Camera3D camera3d;
}
/**
* @tc.name: Camera3DTranslateTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DTranslateTest001, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->Translate(131.5f, 121.0f, 60.0f);
}
/**
* @tc.name: Camera3DTranslateTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DTranslateTest002, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->Translate(23.6f, 7.9f, 800.9f);
}
/**
* @tc.name: Camera3DRotateXDegreesTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateXDegreesTest001, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateXDegrees(800.6f);
}
/**
* @tc.name: Camera3DRotateXDegreesTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateXDegreesTest002, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateXDegrees(300.0f);
}
/**
* @tc.name: Camera3DRotateXDegreesTest003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateXDegreesTest003, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateXDegrees(300.29f);
}
/**
* @tc.name: Camera3DRotateYDegreesTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateYDegreesTest001, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateYDegrees(300.29f);
}
/**
* @tc.name: Camera3DRotateYDegreesTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateYDegreesTest002, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateYDegrees(300);
}
/**
* @tc.name: Camera3DRotateYDegreesTest003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateYDegreesTest003, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateYDegrees(300.29f);
}
/**
* @tc.name: Camera3DRotateZDegreesTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateZDegreesTest001, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateZDegrees(300.29f);
}
/**
* @tc.name: Camera3DRotateZDegreesTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateZDegreesTest002, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateZDegrees(300.0f);
}
/**
* @tc.name: Camera3DRotateZDegreesTest003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DRotateZDegreesTest003, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->RotateZDegrees(300.29f);
}
/**
* @tc.name: Camera3DSetAndGetCameraPosTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DSetAndGetCameraPosTest001, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->SetCameraPos(8.2f, 9.1f, 8.2f);
EXPECT_EQ(8.2f, camera3d->GetCameraPosX());
EXPECT_EQ(9.1f, camera3d->GetCameraPosY());
EXPECT_EQ(8.2f, camera3d->GetCameraPosZ());
camera3d->Save();
camera3d->Restore();
}
/**
* @tc.name: Camera3DSetAndGetCameraPosTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DSetAndGetCameraPosTest002, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
camera3d->SetCameraPos(8.0f, 8.1f, 8.2f);
EXPECT_EQ(8.0f, camera3d->GetCameraPosX());
EXPECT_EQ(8.1f, camera3d->GetCameraPosY());
EXPECT_EQ(8.2f, camera3d->GetCameraPosZ());
camera3d->Save();
camera3d->Restore();
}
/**
* @tc.name: Camera3DApplyToMatrixTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DApplyToMatrixTest001, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
Matrix matrix;
camera3d->ApplyToMatrix(matrix);
}
/**
* @tc.name: Camera3DApplyToMatrixTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Camera3DTest, Camera3DApplyToMatrixTest002, TestSize.Level1)
{
std::unique_ptr<Camera3D> camera3d = std::make_unique<Camera3D>();
ASSERT_TRUE(camera3d != nullptr);
Matrix matrix2;
camera3d->ApplyToMatrix(matrix2);
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,305 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "utils/matrix.h"
#include "utils/scalar.h"
#include "utils/point.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class MatrixTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void MatrixTest::SetUpTestCase() {}
void MatrixTest::TearDownTestCase() {}
void MatrixTest::SetUp() {}
void MatrixTest::TearDown() {}
/**
* @tc.name: CreateAndDestory001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, CreateAndDestory001, TestSize.Level1)
{
// The best way to create Matrix.
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
}
/**
* @tc.name: CreateAndDestory002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, CreateAndDestory002, TestSize.Level1)
{
// The best way to create Matrix.
Matrix matrix;
}
/**
* @tc.name: MatrixRotateTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixRotateTest001, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->Rotate(0.1f, 150.1f, 650.9f);
}
/**
* @tc.name: MatrixRotateTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixRotateTest002, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->Rotate(20.8f, 133.0f, 100);
}
/**
* @tc.name: MatrixTranslateTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixTranslateTest001, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->Translate(20.8f, 100);
}
/**
* @tc.name: MatrixTranslateTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixTranslateTest002, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->Translate(77.7f, 190.2f);
}
/**
* @tc.name: MatrixScaleTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixScaleTest001, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->Scale(32.1f, 10.6f, 800, 90.1f);
}
/**
* @tc.name: MatrixScaleTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixScaleTest002, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->Scale(16.5f, 50.6f, 150.8f, 560.9f);
}
/**
* @tc.name: MatrixMultiplyTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixMultiplyTest001, TestSize.Level1)
{
Matrix matrix1;
Matrix matrix2;
matrix1.Rotate(3.0f, 2.0f, 1.0f);
matrix2.Rotate(1.5f, 2.5f, 3.5f);
Matrix matrix3 = matrix1 * matrix2;
EXPECT_TRUE(matrix3 == matrix1);
EXPECT_FALSE(matrix3 == matrix2);
}
/**
* @tc.name: MatrixMultiplyTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixMultiplyTest002, TestSize.Level1)
{
Matrix matrix1;
Matrix matrix2;
matrix1.Rotate(3.7f, 6.0f, 1.9f);
matrix2.Rotate(5.5f, 12.5f, 30.5f);
Matrix matrix3 = matrix1 * matrix2;
EXPECT_TRUE(matrix3 == matrix1);
EXPECT_FALSE(matrix3 == matrix2);
}
/**
* @tc.name: MatrixEqualTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixEqualTest001, TestSize.Level1)
{
Matrix matrix1;
Matrix matrix2 = matrix1;
EXPECT_TRUE(matrix1 == matrix2);
}
/**
* @tc.name: MatrixEqualTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixEqualTest002, TestSize.Level1)
{
Matrix matrix1;
matrix1.Rotate(1.0f, 2.0f, 3.0f);
Matrix matrix2;
EXPECT_FALSE(matrix1 == matrix2);
}
/**
* @tc.name: MatrixSetMatrixTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixSetMatrixTest001, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->SetMatrix(200, 150, 800, 60, 200, 150, 800, 60, 90);
}
/**
* @tc.name: MatrixSetMatrixTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixSetMatrixTest002, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->SetMatrix(20.9f, 15.8f, 80.8f, 60, 2.4f, 99.9f, 60, 60, 900);
}
/**
* @tc.name: MatrixSetMatrixTest003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixSetMatrixTest003, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
matrix->SetMatrix(20.9f, 15.8f, 80.8f, 60.6f, 2.4f, 99.9f, 60.5f, 60.1f, 90.5f);
}
/**
* @tc.name: MatrixMapPointsTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixMapPointsTest001, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
std::vector<Point> dst = {{1, 2}};
std::vector<Point> src = {{2, 3}};
matrix->MapPoints(dst, src, 100);
}
/**
* @tc.name: MatrixMapPointsTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixMapPointsTest002, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
std::vector<Point> dst = {{3, 2}};
std::vector<Point> src = {{1, 3}};
matrix->MapPoints(dst, src, 191);
}
/**
* @tc.name: MatrixGetTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(MatrixTest, MatrixGetTest001, TestSize.Level1)
{
std::unique_ptr<Matrix> matrix = std::make_unique<Matrix>();
ASSERT_TRUE(matrix != nullptr);
ASSERT_EQ(1, matrix->Get(0));
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,615 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "utils/point3.h"
#include "utils/scalar.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class Point3Test : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void Point3Test::SetUpTestCase() {}
void Point3Test::TearDownTestCase() {}
void Point3Test::SetUp() {}
void Point3Test::TearDown() {}
/**
* @tc.name: Point3CreateAndDestroy001
* @tc.desc: Point3 Point3 Function SetandGet XYZ Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3CreateAndDestroy001, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
EXPECT_EQ(0.0f, point3->GetX());
EXPECT_EQ(0.0f, point3->GetY());
EXPECT_EQ(0.0f, point3->GetZ());
}
/**
* @tc.name: Point3CreateAndDestroy002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3CreateAndDestroy002, TestSize.Level1)
{
Point3 point1;
point1.SetX(2.0f);
Point3 point2(point1);
EXPECT_TRUE(point1 == point2);
}
/**
* @tc.name: Point3CreateAndDestroy003
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3CreateAndDestroy003, TestSize.Level1)
{
Point3 point1;
point1.SetX(3.0f);
Point3 point2(point1);
EXPECT_TRUE(point1 == point2);
}
/**
* @tc.name: Point3CreateAndDestroy004
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3CreateAndDestroy004, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>(1.0f, 2.0f, 3.0f);
EXPECT_EQ(1.0f, point3->GetX());
EXPECT_EQ(2.0f, point3->GetY());
EXPECT_EQ(3.0f, point3->GetZ());
}
/**
* @tc.name: Point3CreateAndDestroy005
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3CreateAndDestroy005, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>(4.0f, 5.0f, 6.0f);
EXPECT_EQ(4.0f, point3->GetX());
EXPECT_EQ(5.0f, point3->GetY());
EXPECT_EQ(6.0f, point3->GetZ());
}
/**
* @tc.name: Point3SetAndGetXTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3SetAndGetXTest001, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
point3->SetX(1.0f);
EXPECT_EQ(1.0f, point3->GetX());
}
/**
* @tc.name: Point3SetAndGetXTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3SetAndGetXTest002, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
point3->SetX(2.0f);
EXPECT_EQ(2.0f, point3->GetX());
}
/**
* @tc.name: Point3SetAndGetYTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3SetAndGetYTest001, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
point3->SetY(1.0f);
EXPECT_EQ(1.0f, point3->GetY());
}
/**
* @tc.name: Point3SetAndGetYTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3SetAndGetYTest002, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
point3->SetY(2.0f);
EXPECT_EQ(2.0f, point3->GetY());
}
/**
* @tc.name: Point3SetAndGetZTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3SetAndGetZTest001, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
point3->SetZ(1.0f);
EXPECT_EQ(1.0f, point3->GetZ());
}
/**
* @tc.name: Point3SetAndGetZTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3SetAndGetZTest002, TestSize.Level1)
{
std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
point3->SetZ(2.0f);
EXPECT_EQ(2.0f, point3->GetZ());
}
/**
* @tc.name: Point3AddEqualTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3AddEqualTest001, TestSize.Level1)
{
Point3 point1;
Point3 point2(1.0f, 2.0f, 3.0f);
point1 += point2;
EXPECT_EQ(1.0f, point1.GetX());
EXPECT_EQ(2.0f, point1.GetY());
EXPECT_EQ(3.0f, point1.GetZ());
}
/**
* @tc.name: Point3AddEqualTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3AddEqualTest002, TestSize.Level1)
{
Point3 point1;
Point3 point2(3.0f, 2.0f, 1.0f);
point1 += point2;
EXPECT_EQ(3.0f, point1.GetX());
EXPECT_EQ(2.0f, point1.GetY());
EXPECT_EQ(1.0f, point1.GetZ());
}
/**
* @tc.name: Point3MinusEqualTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MinusEqualTest001, TestSize.Level1)
{
Point3 point1;
Point3 point2(1.0f, 2.0f, 3.0f);
point1 -= point2;
EXPECT_EQ(-1.0f, point1.GetX());
EXPECT_EQ(-2.0f, point1.GetY());
EXPECT_EQ(-3.0f, point1.GetZ());
}
/**
* @tc.name: Point3MinusEqualTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MinusEqualTest002, TestSize.Level1)
{
Point3 point1;
Point3 point2(3.0f, 2.0f, 1.0f);
point1 -= point2;
EXPECT_EQ(-3.0f, point1.GetX());
EXPECT_EQ(-2.0f, point1.GetY());
EXPECT_EQ(-1.0f, point1.GetZ());
}
/**
* @tc.name: Point3MultiplyEqualTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MultiplyEqualTest001, TestSize.Level1)
{
Point3 point3(1.0f, 2.0f, 3.0f);
point3 *= 2;
EXPECT_EQ(2.0f, point3.GetX());
EXPECT_EQ(4.0f, point3.GetY());
EXPECT_EQ(6.0f, point3.GetZ());
}
/**
* @tc.name: Point3MultiplyEqualTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MultiplyEqualTest002, TestSize.Level1)
{
Point3 point3(3.0f, 2.0f, 1.0f);
point3 *= 2;
EXPECT_EQ(6.0f, point3.GetX());
EXPECT_EQ(4.0f, point3.GetY());
EXPECT_EQ(2.0f, point3.GetZ());
}
/**
* @tc.name: Point3DivideEqualTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3DivideEqualTest001, TestSize.Level1)
{
Point3 point3(2.0f, 4.0f, 6.0f);
point3 /= 2.0f;
EXPECT_EQ(1.0f, point3.GetX());
EXPECT_EQ(2.0f, point3.GetY());
EXPECT_EQ(3.0f, point3.GetZ());
}
/**
* @tc.name: Point3DivideEqualTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3DivideEqualTest002, TestSize.Level1)
{
Point3 point3(4.0f, 8.0f, 10.0f);
point3 /= 2.0f;
EXPECT_EQ(2.0f, point3.GetX());
EXPECT_EQ(4.0f, point3.GetY());
EXPECT_EQ(5.0f, point3.GetZ());
}
/**
* @tc.name: Point3AddTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3AddTest001, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2(0.0f, 0.0f, 0.0f);
Point3 point3 = point1 + point2;
EXPECT_EQ(3.0f, point3.GetX());
EXPECT_EQ(0.0f, point3.GetY());
EXPECT_EQ(3.0f, point3.GetZ());
}
/**
* @tc.name: Point3AddTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3AddTest002, TestSize.Level1)
{
Point3 point1(3.0f, 2.0f, 1.0f);
Point3 point2(0.0f, 0.0f, 0.0f);
Point3 point3 = point1 + point2;
EXPECT_EQ(5.0f, point3.GetX());
EXPECT_EQ(0.0f, point3.GetY());
EXPECT_EQ(1.0f, point3.GetZ());
}
/**
* @tc.name: Point3MinusTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MinusTest001, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2;
Point3 point3 = point1 - point2;
EXPECT_EQ(1.0f, point3.GetX());
EXPECT_EQ(2.0f, point3.GetY());
EXPECT_EQ(3.0f, point3.GetZ());
}
/**
* @tc.name: Point3MinusTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MinusTest002, TestSize.Level1)
{
Point3 point1(3.0f, 2.0f, 1.0f);
Point3 point2;
Point3 point3 = point1 - point2;
EXPECT_EQ(3.0f, point3.GetX());
EXPECT_EQ(2.0f, point3.GetY());
EXPECT_EQ(1.0f, point3.GetZ());
}
/**
* @tc.name: Point3MultiplyTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MultiplyTest001, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2 = 2.0f * point1;
EXPECT_EQ(2.0f, point2.GetX());
EXPECT_EQ(4.0f, point2.GetY());
EXPECT_EQ(6.0f, point2.GetZ());
}
/**
* @tc.name: Point3MultiplyTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MultiplyTest002, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2 = 3.0f * point1;
EXPECT_EQ(3.0f, point2.GetX());
EXPECT_EQ(6.0f, point2.GetY());
EXPECT_EQ(9.0f, point2.GetZ());
}
/**
* @tc.name: Point3MultiplyTest003
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MultiplyTest003, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2 = point1 * 2.0f;
EXPECT_EQ(2.0f, point2.GetX());
EXPECT_EQ(4.0f, point2.GetY());
EXPECT_EQ(6.0f, point2.GetZ());
}
/**
* @tc.name: Point3MultiplyTest004
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MultiplyTest004, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2 = point1 * 3.0f;
EXPECT_EQ(3.0f, point2.GetX());
EXPECT_EQ(6.0f, point2.GetY());
EXPECT_EQ(9.0f, point2.GetZ());
}
/**
* @tc.name: Point3DivideTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3DivideTest001, TestSize.Level1)
{
Point3 point1(2.0f, 4.0f, 6.0f);
Point3 point2 = point1 / 2.0f;
EXPECT_EQ(1.0f, point2.GetX());
EXPECT_EQ(2.0f, point2.GetY());
EXPECT_EQ(3.0f, point2.GetZ());
}
/**
* @tc.name: Point3DivideTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3DivideTest002, TestSize.Level1)
{
Point3 point1(3.0f, 6.0f, 9.0f);
Point3 point2 = point1 / 3.0f;
EXPECT_EQ(1.0f, point2.GetX());
EXPECT_EQ(2.0f, point2.GetY());
EXPECT_EQ(3.0f, point2.GetZ());
}
/**
* @tc.name: Point3AddTest003
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3AddTest003, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2 = +point1;
EXPECT_EQ(1.0f, point2.GetX());
EXPECT_EQ(2.0f, point2.GetY());
EXPECT_EQ(3.0f, point2.GetZ());
}
/**
* @tc.name: Point3AddTest004
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3AddTest005, TestSize.Level1)
{
Point3 point1(3.0f, 2.0f, 1.0f);
Point3 point2 = +point1;
EXPECT_EQ(3.0f, point2.GetX());
EXPECT_EQ(2.0f, point2.GetY());
EXPECT_EQ(1.0f, point2.GetZ());
}
/**
* @tc.name: Point3MinusTest003
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MinusTest003, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2 = -point1;
EXPECT_EQ(-1.0f, point2.GetX());
EXPECT_EQ(-2.0f, point2.GetY());
EXPECT_EQ(-3.0f, point2.GetZ());
}
/**
* @tc.name: Point3MinusTest004
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3MinusTest004, TestSize.Level1)
{
Point3 point1(3.0f, 2.0f, 1.0f);
Point3 point2 = -point1;
EXPECT_EQ(-3.0f, point2.GetX());
EXPECT_EQ(-2.0f, point2.GetY());
EXPECT_EQ(-1.0f, point2.GetZ());
}
/**
* @tc.name: Point3EqualTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3EqualTest001, TestSize.Level1)
{
Point3 point1;
Point3 point2;
EXPECT_TRUE(point1 == point2);
}
/**
* @tc.name: Point3EqualTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3EqualTest002, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2;
EXPECT_FALSE(point1 == point2);
}
/**
* @tc.name: Point3NotEqualTest001
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3NotEqualTest001, TestSize.Level1)
{
Point3 point1(1.0f, 2.0f, 3.0f);
Point3 point2;
EXPECT_TRUE(point1 != point2);
}
/**
* @tc.name: Point3NotEqualTest002
* @tc.desc: Point3 Point3 Function Test
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(Point3Test, Point3NotEqualTest002, TestSize.Level1)
{
Point3 point1;
Point3 point2;
EXPECT_FALSE(point1 != point2);
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,656 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "utils/rect.h"
#include "utils/scalar.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class RectTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void RectTest::SetUpTestCase() {}
void RectTest::TearDownTestCase() {}
void RectTest::SetUp() {}
void RectTest::TearDown() {}
/**
* @tc.name: RectFCreateAndDestroy001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFCreateAndDestroy001, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
EXPECT_EQ(0.0f, rectF->GetLeft());
EXPECT_EQ(0.0f, rectF->GetTop());
EXPECT_EQ(0.0f, rectF->GetRight());
EXPECT_EQ(0.0f, rectF->GetBottom());
}
/**
* @tc.name: RectFCreateAndDestroy002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFCreateAndDestroy002, TestSize.Level1)
{
RectF rectf1;
rectf1.SetLeft(1.0f);
RectF rectf2(rectf1);
EXPECT_EQ(rectf1.GetLeft(), rectf2.GetLeft());
}
/**
* @tc.name: RectFCreateAndDestroy003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFCreateAndDestroy003, TestSize.Level1)
{
RectF rectf1;
rectf1.SetLeft(2.0f);
RectF rectf2(rectf1);
EXPECT_EQ(rectf1.GetLeft(), rectf2.GetLeft());
}
/**
* @tc.name: RectFCreateAndDestroy004
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFCreateAndDestroy004, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
EXPECT_EQ(1.0f, rectF->GetLeft());
EXPECT_EQ(2.0f, rectF->GetTop());
EXPECT_EQ(3.0f, rectF->GetRight());
EXPECT_EQ(4.0f, rectF->GetBottom());
}
/**
* @tc.name: RectFCreateAndDestroy005
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFCreateAndDestroy005, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>(4.0f, 3.0f, 2.0f, 1.0f);
EXPECT_EQ(4.0f, rectF->GetLeft());
EXPECT_EQ(3.0f, rectF->GetTop());
EXPECT_EQ(2.0f, rectF->GetRight());
EXPECT_EQ(1.0f, rectF->GetBottom());
}
/**
* @tc.name: RectFIsValid001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFIsValid001, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>(4.0f, 3.0f, 2.0f, 1.0f);
EXPECT_FALSE(rectF->IsValid());
}
/**
* @tc.name: RectFIsValid002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFIsValid002, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
EXPECT_TRUE(rectF->IsValid());
}
/**
* @tc.name: RectFSetAndGetLeft001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetLeft001, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetLeft(1.0f);
EXPECT_EQ(1.0f, rectF->GetLeft());
}
/**
* @tc.name: RectFSetAndGetLeft002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetLeft002, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetLeft(2.0f);
EXPECT_EQ(2.0f, rectF->GetLeft());
}
/**
* @tc.name: RectFSetAndGetRight001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetRight001, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetRight(1.0f);
EXPECT_EQ(1.0f, rectF->GetRight());
}
/**
* @tc.name: RectFSetAndGetRight002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetRight002, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetRight(2.0f);
EXPECT_EQ(2.0f, rectF->GetRight());
}
/**
* @tc.name: RectFSetAndGetTop001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetTop001, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetTop(1.0f);
EXPECT_EQ(1.0f, rectF->GetTop());
}
/**
* @tc.name: RectFSetAndGetTop002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetTop002, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetTop(2.0f);
EXPECT_EQ(2.0f, rectF->GetTop());
}
/**
* @tc.name: RectFSetAndGetBottom001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetBottom001, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetBottom(1.0f);
EXPECT_EQ(1.0f, rectF->GetBottom());
}
/**
* @tc.name: RectFSetAndGetBottom002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFSetAndGetBottom002, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>();
rectF->SetBottom(2.0f);
EXPECT_EQ(2.0f, rectF->GetBottom());
}
/**
* @tc.name: RectFOffset001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFOffset001, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
rectF->Offset(1.0f, 2.0f);
EXPECT_EQ(2.0f, rectF->GetLeft());
EXPECT_EQ(4.0f, rectF->GetRight());
EXPECT_EQ(4.0f, rectF->GetTop());
EXPECT_EQ(6.0f, rectF->GetBottom());
}
/**
* @tc.name: RectFOffset002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFOffset002, TestSize.Level1)
{
std::unique_ptr<RectF> rectF = std::make_unique<RectF>(1.0f, 2.0f, 3.0f, 4.0f);
rectF->Offset(2.0f, 1.0f);
EXPECT_EQ(3.0f, rectF->GetLeft());
EXPECT_EQ(5.0f, rectF->GetRight());
EXPECT_EQ(3.0f, rectF->GetTop());
EXPECT_EQ(5.0f, rectF->GetBottom());
}
/**
* @tc.name: RectFEqual001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFEqual001, TestSize.Level1)
{
RectF rectf1;
RectF rectf2;
rectf1.SetLeft(1.0f);
EXPECT_FALSE(rectf1 == rectf2);
}
/**
* @tc.name: RectFEqual002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFEqual002, TestSize.Level1)
{
RectF rectf1;
RectF rectf2;
EXPECT_TRUE(rectf1 == rectf2);
}
/**
* @tc.name: RectFNotEqual001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFNotEqual001, TestSize.Level1)
{
RectF rectf1;
RectF rectf2;
EXPECT_FALSE(rectf1 != rectf2);
}
/**
* @tc.name: RectFNotEqual002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectFNotEqual002, TestSize.Level1)
{
RectF rectf1;
RectF rectf2;
rectf2.SetLeft(2.0f);
EXPECT_TRUE(rectf1 != rectf2);
}
/**
* @tc.name: RectICreateAndDestroy001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectICreateAndDestroy001, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
EXPECT_EQ(0.0f, rectI->GetLeft());
EXPECT_EQ(0.0f, rectI->GetTop());
EXPECT_EQ(0.0f, rectI->GetRight());
EXPECT_EQ(0.0f, rectI->GetBottom());
}
/**
* @tc.name: RectICreateAndDestroy002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectICreateAndDestroy002, TestSize.Level1)
{
RectI recti1;
recti1.SetLeft(1.0f);
RectI recti2(recti1);
EXPECT_EQ(recti1.GetLeft(), recti2.GetLeft());
}
/**
* @tc.name: RectICreateAndDestroy003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectICreateAndDestroy003, TestSize.Level1)
{
RectI recti1;
recti1.SetLeft(2.0f);
RectI recti2(recti1);
EXPECT_EQ(recti1.GetLeft(), recti2.GetLeft());
}
/**
* @tc.name: RectICreateAndDestroy004
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectICreateAndDestroy004, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
EXPECT_EQ(1.0f, rectI->GetLeft());
EXPECT_EQ(2.0f, rectI->GetTop());
EXPECT_EQ(3.0f, rectI->GetRight());
EXPECT_EQ(4.0f, rectI->GetBottom());
}
/**
* @tc.name: RectICreateAndDestroy005
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectICreateAndDestroy005, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>(4.0f, 3.0f, 2.0f, 1.0f);
EXPECT_EQ(4.0f, rectI->GetLeft());
EXPECT_EQ(3.0f, rectI->GetTop());
EXPECT_EQ(2.0f, rectI->GetRight());
EXPECT_EQ(1.0f, rectI->GetBottom());
}
/**
* @tc.name: RectIIsValid001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectIIsValid001, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>(4.0f, 3.0f, 2.0f, 1.0f);
EXPECT_FALSE(rectI->IsValid());
}
/**
* @tc.name: RectIIsValid002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectIIsValid002, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
EXPECT_TRUE(rectI->IsValid());
}
/**
* @tc.name: RectISetAndGetLeft001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetLeft001, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetLeft(1.0f);
EXPECT_EQ(1.0f, rectI->GetLeft());
}
/**
* @tc.name: RectISetAndGetLeft002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetLeft002, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetLeft(2.0f);
EXPECT_EQ(2.0f, rectI->GetLeft());
}
/**
* @tc.name: RectISetAndGetRight001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetRight001, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetRight(1.0f);
EXPECT_EQ(1.0f, rectI->GetRight());
}
/**
* @tc.name: RectISetAndGetRight002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetRight002, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetRight(2.0f);
EXPECT_EQ(2.0f, rectI->GetRight());
}
/**
* @tc.name: RectISetAndGetTop001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetTop001, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetTop(1.0f);
EXPECT_EQ(1.0f, rectI->GetTop());
}
/**
* @tc.name: RectISetAndGetTop002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetTop002, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetTop(2.0f);
EXPECT_EQ(2.0f, rectI->GetTop());
}
/**
* @tc.name: RectISetAndGetBottom001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetBottom001, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetBottom(1.0f);
EXPECT_EQ(1.0f, rectI->GetBottom());
}
/**
* @tc.name: RectISetAndGetBottom002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectISetAndGetBottom002, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>();
rectI->SetBottom(2.0f);
EXPECT_EQ(2.0f, rectI->GetBottom());
}
/**
* @tc.name: RectIOffset001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectIOffset001, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
rectI->Offset(1.0f, 2.0f);
EXPECT_EQ(2.0f, rectI->GetLeft());
EXPECT_EQ(4.0f, rectI->GetRight());
EXPECT_EQ(4.0f, rectI->GetTop());
EXPECT_EQ(6.0f, rectI->GetBottom());
}
/**
* @tc.name: RectIOffset002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectIOffset002, TestSize.Level1)
{
std::unique_ptr<RectI> rectI = std::make_unique<RectI>(1.0f, 2.0f, 3.0f, 4.0f);
rectI->Offset(2.0f, 1.0f);
EXPECT_EQ(3.0f, rectI->GetLeft());
EXPECT_EQ(5.0f, rectI->GetRight());
EXPECT_EQ(3.0f, rectI->GetTop());
EXPECT_EQ(5.0f, rectI->GetBottom());
}
/**
* @tc.name: RectIEqual001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectIEqual001, TestSize.Level1)
{
RectI recti1;
RectI recti2;
recti1.SetLeft(1.0f);
EXPECT_FALSE(recti1 == recti2);
}
/**
* @tc.name: RectIEqual002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectIEqual002, TestSize.Level1)
{
RectI recti1;
RectI recti2;
EXPECT_TRUE(recti1 == recti2);
}
/**
* @tc.name: RectINotEqual001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectINotEqual001, TestSize.Level1)
{
RectI recti1;
RectI recti2;
EXPECT_FALSE(recti1 != recti2);
}
/**
* @tc.name: RectINotEqual002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RectTest, RectINotEqual002, TestSize.Level1)
{
RectI recti1;
RectI recti2;
recti2.SetLeft(2.0f);
EXPECT_TRUE(recti1 != recti2);
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,194 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "utils/rect.h"
#include "utils/scalar.h"
#include "utils/round_rect.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class RoundRectTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void RoundRectTest::SetUpTestCase() {}
void RoundRectTest::TearDownTestCase() {}
void RoundRectTest::SetUp() {}
void RoundRectTest::TearDown() {}
/**
* @tc.name: RoundRectCreateAndDestory001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectCreateAndDestory001, TestSize.Level1)
{
// The best way to create RoundRect.
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>();
ASSERT_TRUE(roundRect != nullptr);
}
/**
* @tc.name: RoundRectCreateAndDestory002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectCreateAndDestory002, TestSize.Level1)
{
// The best way to create RoundRect.
const RoundRect roundRect1;
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>(roundRect1);
ASSERT_TRUE(roundRect != nullptr);
}
/**
* @tc.name: RoundRectCreateAndDestory003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectRectCreateAndDestory003, TestSize.Level1)
{
// The best way to create RoundRect.
Rect rect;
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>(rect, 12.6f, 77.4f);
ASSERT_TRUE(roundRect != nullptr);
}
/**
* @tc.name: RoundRectCreateAndDestory004
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectRectCreateAndDestory004, TestSize.Level1)
{
// The best way to create RoundRect.
Rect rect;
std::vector<Point> radiusXY = {{1, 3}};
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>(rect, radiusXY);
ASSERT_TRUE(roundRect != nullptr);
}
/**
* @tc.name: RoundRectSetAndGetCornerRadius001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectRectSetAndGetCornerRadius001, TestSize.Level1)
{
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>();
ASSERT_TRUE(roundRect != nullptr);
roundRect->SetCornerRadius(Drawing::RoundRect::TOP_RIGHT_POS, 111.3f, 84.5f);
ASSERT_EQ(roundRect->GetCornerRadius(Drawing::RoundRect::TOP_RIGHT_POS).GetX(), 111.3f);
ASSERT_EQ(roundRect->GetCornerRadius(Drawing::RoundRect::TOP_RIGHT_POS).GetY(), 84.5f);
}
/**
* @tc.name: RoundRectSetAndGetCornerRadius002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectSetAndGetCornerRadius002, TestSize.Level1)
{
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>();
ASSERT_TRUE(roundRect != nullptr);
roundRect->SetCornerRadius(Drawing::RoundRect::BOTTOM_RIGHT_POS, 120.0f, 90.5f);
ASSERT_EQ(roundRect->GetCornerRadius(Drawing::RoundRect::BOTTOM_RIGHT_POS).GetX(), 120.0f);
ASSERT_EQ(roundRect->GetCornerRadius(Drawing::RoundRect::BOTTOM_RIGHT_POS).GetY(), 90.5f);
}
/**
* @tc.name: RoundRectSetAndGetRect001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectSetAndGetRect001, TestSize.Level1)
{
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>();
ASSERT_TRUE(roundRect != nullptr);
Rect rect1;
roundRect->SetRect(rect1);
Rect rect2 = roundRect->GetRect();
EXPECT_EQ(rect2, rect1);
}
/**
* @tc.name: RoundRectSetAndGetRect002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectSetAndGetRect002, TestSize.Level1)
{
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>();
ASSERT_TRUE(roundRect != nullptr);
const Rect rect2;
roundRect->SetRect(rect2);
EXPECT_EQ(rect2, roundRect->GetRect());
}
/**
* @tc.name: RoundRectRoundRectOffsetTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectRoundRectOffsetTest001, TestSize.Level1)
{
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>();
ASSERT_TRUE(roundRect != nullptr);
roundRect->Offset(54.6f, 432.8f);
}
/**
* @tc.name: RoundRectRoundRectOffsetTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(RoundRectTest, RoundRectRoundRectOffsetTest002, TestSize.Level1)
{
std::unique_ptr<RoundRect> roundRect = std::make_unique<RoundRect>();
ASSERT_TRUE(roundRect != nullptr);
roundRect->Offset(200.0f, 40.8f);
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,210 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "utils/sampling_options.h"
#include "utils/scalar.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class SamplingOptionsTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void SamplingOptionsTest::SetUpTestCase() {}
void SamplingOptionsTest::TearDownTestCase() {}
void SamplingOptionsTest::SetUp() {}
void SamplingOptionsTest::TearDown() {}
/**
* @tc.name: SamplingOptionsCreateAndDestroy001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsCreateAndDestroy001, TestSize.Level1)
{
// The best way to create SamplingOptions.
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
ASSERT_TRUE(sampling != nullptr);
}
/**
* @tc.name: SamplingOptionsCreateAndDestroy002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsCreateAndDestroy002, TestSize.Level1)
{
// The best way to create SamplingOptions.
CubicResampler cubicResampler;
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>(cubicResampler);
ASSERT_TRUE(sampling != nullptr);
}
/**
* @tc.name: SamplingOptionsGetUseCubic001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsGetUseCubic001, TestSize.Level1)
{
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
ASSERT_TRUE(sampling != nullptr);
ASSERT_EQ(false, sampling->GetUseCubic());
}
/**
* @tc.name: SamplingOptionsGetFilterMode001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsGetFilterMode001, TestSize.Level1)
{
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
ASSERT_TRUE(sampling != nullptr);
ASSERT_EQ(FilterMode::NEAREST, sampling->GetFilterMode());
}
/**
* @tc.name: SamplingOptionsGetMipmapMode001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsGetMipmapMode001, TestSize.Level1)
{
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
ASSERT_TRUE(sampling != nullptr);
ASSERT_EQ(MipmapMode::NONE, sampling->GetMipmapMode());
}
/**
* @tc.name: SamplingOptionsGetCubicCoffB001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffB001, TestSize.Level1)
{
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
ASSERT_TRUE(sampling != nullptr);
ASSERT_EQ(0, sampling->GetCubicCoffB());
}
/**
* @tc.name: SamplingOptionsGetCubicCoffB002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffB002, TestSize.Level1)
{
CubicResampler cubicResampler;
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>(cubicResampler);
ASSERT_TRUE(sampling != nullptr);
ASSERT_EQ(0, sampling->GetCubicCoffB());
}
/**
* @tc.name: SamplingOptionsGetCubicCoffC001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffC001, TestSize.Level1)
{
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>();
ASSERT_TRUE(sampling != nullptr);
ASSERT_EQ(0, sampling->GetCubicCoffC());
}
/**
* @tc.name: SamplingOptionsGetCubicCoffC002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsGetCubicCoffC002, TestSize.Level1)
{
CubicResampler cubicResampler;
std::unique_ptr<SamplingOptions> sampling = std::make_unique<SamplingOptions>(cubicResampler);
ASSERT_TRUE(sampling != nullptr);
ASSERT_EQ(0, sampling->GetCubicCoffC());
}
/**
* @tc.name: SamplingOptionsEqual001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsEqual001, TestSize.Level1)
{
SamplingOptions sampling1;
ASSERT_TRUE(sampling1 == sampling1);
}
/**
* @tc.name: SamplingOptionsEqual002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsEqual002, TestSize.Level1)
{
SamplingOptions sampling1;
SamplingOptions sampling2 = sampling1;
EXPECT_FALSE(sampling2 != sampling1);
}
/**
* @tc.name: SamplingOptionsEqual003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(SamplingOptionsTest, SamplingOptionsEqual003, TestSize.Level1)
{
SamplingOptions sampling1;
SamplingOptions sampling2;
EXPECT_FALSE(sampling1 != sampling2);
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,265 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, Hardware
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"
#include "utils/size.h"
#include "utils/scalar.h"
#include "utils/rect.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
namespace Drawing {
class SizeTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void SizeTest::SetUpTestCase() {}
void SizeTest::TearDownTestCase() {}
void SizeTest::SetUp() {}
void SizeTest::TearDown() {}
/**
* @tc.name: SizeCreateAndDestory001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeCreateAndDestory001, TestSize.Level1)
{
// The best way to create SizeF.
std::unique_ptr<SizeF> sizeF = std::make_unique<SizeF>();
ASSERT_TRUE(sizeF != nullptr);
std::unique_ptr<SizeI> sizeI = std::make_unique<SizeI>();
ASSERT_TRUE(sizeI != nullptr);
}
/**
* @tc.name: SizeCreateAndDestory002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeCreateAndDestory002, TestSize.Level1)
{
// The best way to create SizeF.
const SizeF sizef1;
std::unique_ptr<SizeF> sizeF = std::make_unique<SizeF>(sizef1);
ASSERT_TRUE(sizeF != nullptr);
const SizeI sizei1;
std::unique_ptr<SizeI> sizeI = std::make_unique<SizeI>(sizei1);
ASSERT_TRUE(sizeI != nullptr);
}
/**
* @tc.name: SizeFIsZeroTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFIsZeroTest001, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
ASSERT_TRUE(size->IsZero());
}
/**
* @tc.name: SizeFIsZeroTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFIsZeroTest002, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
ASSERT_FALSE(! size->IsZero());
}
/**
* @tc.name: SizeFIsEmptyTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFIsEmptyTest001, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
ASSERT_TRUE(size->IsEmpty());
}
/**
* @tc.name: SizeFIsEmptyTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFIsEmptyTest002, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
ASSERT_FALSE(! size->IsEmpty());
}
/**
* @tc.name: SizeFGetAndSetWidth001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFGetAndSetWidth001, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
size->SetWidth(92.5f);
float width = size->Width();
EXPECT_EQ(width, 92.5f);
}
/**
* @tc.name: SizeFGetAndSetWidth002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFGetAndSetWidth002, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
size->SetWidth(162.5f);
float width = size->Width();
EXPECT_EQ(width, 162.5f);
}
/**
* @tc.name: SizeFGetAndSetWidth003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFGetAndSetWidth003, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
size->SetWidth(102.5f);
float width = size->Width();
EXPECT_EQ(width, 102.5f);
}
/**
* @tc.name: SizeFGetAndSetHeight001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFGetAndSetHeight001, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
size->SetHeight(102.5f);
float height = size->Height();
EXPECT_EQ(height, 102.5f);
}
/**
* @tc.name: SizeFGetAndSetHeight002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFGetAndSetHeight002, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
size->SetHeight(131.5f);
float height = size->Height();
EXPECT_EQ(height, 131.5f);
}
/**
* @tc.name: SizeFGetAndSetHeight003
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeFGetAndSetHeight003, TestSize.Level1)
{
std::unique_ptr<SizeF> size = std::make_unique<SizeF>();
ASSERT_TRUE(size != nullptr);
size->SetHeight(50.0f);
int height = size->Height();
EXPECT_EQ(height, 50.0f);
}
/**
* @tc.name: SizeOperatorEqualTest001
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeOperatorEqualTest001, TestSize.Level1)
{
std::unique_ptr<SizeF> sizeF = std::make_unique<SizeF>();
ASSERT_TRUE(sizeF != nullptr);
std::unique_ptr<SizeI> sizeI = std::make_unique<SizeI>();
ASSERT_TRUE(sizeI != nullptr);
EXPECT_TRUE(sizeF == sizeF);
EXPECT_TRUE(sizeI == sizeI);
}
/**
* @tc.name: SizeOperatorEqualTest002
* @tc.desc:
* @tc.type: FUNC
* @tc.require:AR000GGNV3
* @tc.author:
*/
HWTEST_F(SizeTest, SizeOperatorEqualTest002, TestSize.Level1)
{
std::unique_ptr<SizeF> sizeF = std::make_unique<SizeF>();
std::unique_ptr<SizeF> sizeF2 = std::make_unique<SizeF>(1.0f, 1.1f);
ASSERT_TRUE(sizeF != nullptr);
ASSERT_TRUE(sizeF2 != nullptr);
std::unique_ptr<SizeI> sizeI = std::make_unique<SizeI>();
std::unique_ptr<SizeI> sizeI2 = std::make_unique<SizeI>(2.0f, 3.0f);
ASSERT_TRUE(sizeI != nullptr);
ASSERT_TRUE(sizeI2 != nullptr);
EXPECT_TRUE(sizeF != sizeF2);
EXPECT_TRUE(sizeI != sizeI2);
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS