Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
af0b1ef8
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
af0b1ef8
编写于
7月 28, 2022
作者:
H
hk_js
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add graphic test case about ndk interface
Signed-off-by:
N
hk_js
<
hekun18@huawei.com
>
上级
667b91b7
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
1120 addition
and
0 deletion
+1120
-0
graphic/BUILD.gn
graphic/BUILD.gn
+1
-0
graphic/graphicnapidrawingtest/BUILD.gn
graphic/graphicnapidrawingtest/BUILD.gn
+52
-0
graphic/graphicnapidrawingtest/NativeDrawingBitmapTest.cpp
graphic/graphicnapidrawingtest/NativeDrawingBitmapTest.cpp
+127
-0
graphic/graphicnapidrawingtest/NativeDrawingBrushTest.cpp
graphic/graphicnapidrawingtest/NativeDrawingBrushTest.cpp
+69
-0
graphic/graphicnapidrawingtest/NativeDrawingCanvasTest.cpp
graphic/graphicnapidrawingtest/NativeDrawingCanvasTest.cpp
+152
-0
graphic/graphicnapidrawingtest/NativeDrawingColorTest.cpp
graphic/graphicnapidrawingtest/NativeDrawingColorTest.cpp
+56
-0
graphic/graphicnapidrawingtest/NativeDrawingPathTest.cpp
graphic/graphicnapidrawingtest/NativeDrawingPathTest.cpp
+151
-0
graphic/graphicnapidrawingtest/NativeDrawingPenTest.cpp
graphic/graphicnapidrawingtest/NativeDrawingPenTest.cpp
+148
-0
graphic/graphicnapidrawingtest/OH_Drawing_FontCollectionTest.cpp
.../graphicnapidrawingtest/OH_Drawing_FontCollectionTest.cpp
+39
-0
graphic/graphicnapidrawingtest/OH_Drawing_TypographyTest.cpp
graphic/graphicnapidrawingtest/OH_Drawing_TypographyTest.cpp
+304
-0
graphic/graphicnapidrawingtest/Test.json
graphic/graphicnapidrawingtest/Test.json
+21
-0
未找到文件。
graphic/BUILD.gn
浏览文件 @
af0b1ef8
...
...
@@ -17,6 +17,7 @@ group("graphic") {
if (is_standard_system) {
deps = [
"effectKit:EffectKitTest",
"graphicnapidrawingtest:GraphicNapiDrawingTest",
"webGL:webGL_hap_test",
"windowStage:ActsWindowStageTest",
"windowstandard:window_hap_test",
...
...
graphic/graphicnapidrawingtest/BUILD.gn
0 → 100644
浏览文件 @
af0b1ef8
# 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("//test/xts/tools/build/suite.gni")
module_output_path = "hit/GraphicNapiDrawingTest"
###############################################################################
ohos_moduletest_suite("GraphicNapiDrawingTest") {
module_out_path = module_output_path
sources = [
"NativeDrawingBitmapTest.cpp",
"NativeDrawingBrushTest.cpp",
"NativeDrawingCanvasTest.cpp",
"NativeDrawingColorTest.cpp",
"NativeDrawingPathTest.cpp",
"NativeDrawingPenTest.cpp",
"OH_Drawing_FontCollectionTest.cpp",
"OH_Drawing_TypographyTest.cpp",
]
cflags = [
"-Wall",
"-Werror",
]
include_dirs = [
"//foundation/graphic/graphic_2d/rosen/modules/2d_engine",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/src",
"//third_party/googletest/googletest/include",
]
deps = [
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
]
}
graphic/graphicnapidrawingtest/NativeDrawingBitmapTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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 "c/drawing_bitmap.h"
#include "c/drawing_types.h"
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
namespace
Rosen
{
namespace
Drawing
{
class
NativeDrawingBitmapTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
static
void
TearDownTestCase
();
void
SetUp
()
override
;
void
TearDown
()
override
;
};
void
NativeDrawingBitmapTest
::
SetUpTestCase
()
{}
void
NativeDrawingBitmapTest
::
TearDownTestCase
()
{}
void
NativeDrawingBitmapTest
::
SetUp
()
{}
void
NativeDrawingBitmapTest
::
TearDown
()
{}
/*
* @tc.name: NativeDrawingBitmapTest_bitmap001
* @tc.desc: test for create drawing_bitmap and destroy drawing_bitmap.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingBitmapTest
,
NativeDrawingBitmapTest_bitmap001
,
TestSize
.
Level1
)
{
OH_Drawing_Bitmap
*
bitmap
=
OH_Drawing_BitmapCreate
();
EXPECT_EQ
(
bitmap
==
nullptr
,
false
);
OH_Drawing_BitmapDestroy
(
bitmap
);
}
/*
* @tc.name: NativeDrawingBitmapTest_bitmap002
* @tc.desc: test for drawing_bitmap build.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingBitmapTest
,
NativeDrawingBitmapTest_bitmap002
,
TestSize
.
Level1
)
{
OH_Drawing_Bitmap
*
bitmap1
=
OH_Drawing_BitmapCreate
();
const
unsigned
int
width
=
500
;
const
unsigned
int
height
=
500
;
OH_Drawing_BitmapFormat
bitmapFormat
{
COLOR_FORMAT_ALPHA_8
,
ALPHA_FORMAT_PREMUL
};
OH_Drawing_BitmapBuild
(
bitmap1
,
width
,
height
,
&
bitmapFormat
);
EXPECT_EQ
(
width
,
OH_Drawing_BitmapGetWidth
(
bitmap1
));
EXPECT_EQ
(
height
,
OH_Drawing_BitmapGetHeight
(
bitmap1
));
OH_Drawing_BitmapDestroy
(
bitmap1
);
}
/*
* @tc.name: NativeDrawingBitmapTest_bitmap003
* @tc.desc: test for drawing_bitmap build.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingBitmapTest
,
NativeDrawingBitmapTest_bitmap003
,
TestSize
.
Level1
)
{
OH_Drawing_Bitmap
*
bitmap2
=
OH_Drawing_BitmapCreate
();
const
unsigned
int
width
=
0
;
const
unsigned
int
height
=
0
;
OH_Drawing_BitmapFormat
bitmapFormat
{
COLOR_FORMAT_RGB_565
,
ALPHA_FORMAT_OPAQUE
};
OH_Drawing_BitmapBuild
(
bitmap2
,
width
,
height
,
&
bitmapFormat
);
EXPECT_EQ
(
width
,
OH_Drawing_BitmapGetWidth
(
bitmap2
));
EXPECT_EQ
(
height
,
OH_Drawing_BitmapGetHeight
(
bitmap2
));
OH_Drawing_BitmapDestroy
(
bitmap2
);
}
/*
* @tc.name: NativeDrawingBitmapTest_bitmap004
* @tc.desc: test for drawing_bitmap build.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingBitmapTest
,
NativeDrawingBitmapTest_bitmap004
,
TestSize
.
Level1
)
{
OH_Drawing_Bitmap
*
bitmap4
=
OH_Drawing_BitmapCreate
();
const
unsigned
int
width
=
500
;
const
unsigned
int
height
=
500
;
OH_Drawing_BitmapFormat
bitmapFormat
{
COLOR_FORMAT_ARGB_4444
,
ALPHA_FORMAT_UNPREMUL
};
OH_Drawing_BitmapBuild
(
bitmap4
,
width
,
height
,
&
bitmapFormat
);
EXPECT_EQ
(
width
,
OH_Drawing_BitmapGetWidth
(
bitmap4
));
EXPECT_EQ
(
height
,
OH_Drawing_BitmapGetHeight
(
bitmap4
));
EXPECT_EQ
(
OH_Drawing_BitmapGetPixels
(
bitmap4
)
==
nullptr
,
false
);
OH_Drawing_BitmapDestroy
(
bitmap4
);
}
/*
* @tc.name: NativeDrawingBitmapTest_bitmap005
* @tc.desc: test for drawing_bitmap build.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingBitmapTest
,
NativeDrawingBitmapTest_bitmap005
,
TestSize
.
Level1
)
{
OH_Drawing_Bitmap
*
bitmap5
=
OH_Drawing_BitmapCreate
();
const
unsigned
int
width
=
500
;
const
unsigned
int
height
=
500
;
OH_Drawing_BitmapFormat
bitmapFormat
{
COLOR_FORMAT_RGBA_8888
,
ALPHA_FORMAT_UNPREMUL
};
OH_Drawing_BitmapBuild
(
bitmap5
,
width
,
height
,
&
bitmapFormat
);
EXPECT_EQ
(
width
,
OH_Drawing_BitmapGetWidth
(
bitmap5
));
EXPECT_EQ
(
height
,
OH_Drawing_BitmapGetHeight
(
bitmap5
));
OH_Drawing_BitmapDestroy
(
bitmap5
);
}
}
// namespace Drawing
}
// namespace Rosen
}
// namespace OHOS
\ No newline at end of file
graphic/graphicnapidrawingtest/NativeDrawingBrushTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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 "c/drawing_brush.h"
#include "c/drawing_color.h"
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
namespace
Rosen
{
namespace
Drawing
{
class
NativeDrawingBrushTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
static
void
TearDownTestCase
();
void
SetUp
()
override
;
void
TearDown
()
override
;
};
void
NativeDrawingBrushTest
::
SetUpTestCase
()
{}
void
NativeDrawingBrushTest
::
TearDownTestCase
()
{}
void
NativeDrawingBrushTest
::
SetUp
()
{}
void
NativeDrawingBrushTest
::
TearDown
()
{}
/*
* @tc.name: NativeDrawingBrushTest_brush001
* @tc.desc: test for create brush and destroy brush.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingBrushTest
,
NativeDrawingBrushTest_brush001
,
TestSize
.
Level1
)
{
OH_Drawing_Brush
*
brush
=
OH_Drawing_BrushCreate
();
EXPECT_EQ
(
brush
==
nullptr
,
false
);
OH_Drawing_BrushDestroy
(
brush
);
}
/*
* @tc.name: NativeDrawingBrushTest_brush002
* @tc.desc: test for the set methods of brush.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingBrushTest
,
NativeDrawingBrushTest_brush002
,
TestSize
.
Level1
)
{
OH_Drawing_Brush
*
brush1
=
OH_Drawing_BrushCreate
();
OH_Drawing_BrushSetAntiAlias
(
brush1
,
false
);
EXPECT_EQ
(
OH_Drawing_BrushIsAntiAlias
(
brush1
),
false
);
OH_Drawing_BrushSetColor
(
brush1
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0xFF
,
0x00
,
0x00
));
EXPECT_EQ
(
OH_Drawing_BrushGetColor
(
brush1
),
0xFFFF0000
);
}
}
// namespace Drawing
}
// namespace Rosen
}
// namespace OHOS
\ No newline at end of file
graphic/graphicnapidrawingtest/NativeDrawingCanvasTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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 "c/drawing_bitmap.h"
#include "c/drawing_brush.h"
#include "c/drawing_canvas.h"
#include "c/drawing_color.h"
#include "c/drawing_path.h"
#include "c/drawing_pen.h"
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
namespace
Rosen
{
namespace
Drawing
{
class
NativeDrawingCanvasTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
static
void
TearDownTestCase
();
void
SetUp
()
override
;
void
TearDown
()
override
;
};
void
NativeDrawingCanvasTest
::
SetUpTestCase
()
{}
void
NativeDrawingCanvasTest
::
TearDownTestCase
()
{}
void
NativeDrawingCanvasTest
::
SetUp
()
{}
void
NativeDrawingCanvasTest
::
TearDown
()
{}
/*
* @tc.name: NativeDrawingCanvasTest_canvas001
* @tc.desc: test for create canvas and destroy canvas.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas001
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas
=
OH_Drawing_CanvasCreate
();
EXPECT_EQ
(
canvas
==
nullptr
,
false
);
OH_Drawing_CanvasDestroy
(
canvas
);
}
/*
* @tc.name: NativeDrawingCanvasTest_canvas002
* @tc.desc: test for OH_Drawing_CanvasBind.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas002
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas1
=
OH_Drawing_CanvasCreate
();
OH_Drawing_Bitmap
*
bitmap
=
OH_Drawing_BitmapCreate
();
OH_Drawing_CanvasBind
(
canvas1
,
bitmap
);
}
/*
* @tc.name: NativeDrawingCanvasTest_canvas003
* @tc.desc: test for OH_Drawing_CanvasAttachPen & OH_Drawing_CanvasDetachPen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas003
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas2
=
OH_Drawing_CanvasCreate
();
OH_Drawing_Pen
*
pen
=
OH_Drawing_PenCreate
();
OH_Drawing_CanvasAttachPen
(
canvas2
,
pen
);
OH_Drawing_CanvasDetachPen
(
canvas2
);
}
/*
* @tc.name: NativeDrawingCanvasTest_canvas004
* @tc.desc: test for OH_Drawing_CanvasAttachBrush & OH_Drawing_CanvasDetachBrush.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas004
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas3
=
OH_Drawing_CanvasCreate
();
OH_Drawing_Brush
*
brush
=
OH_Drawing_BrushCreate
();
OH_Drawing_CanvasAttachBrush
(
canvas3
,
brush
);
OH_Drawing_CanvasDetachBrush
(
canvas3
);
}
/*
* @tc.name: NativeDrawingCanvasTest_canvas005
* @tc.desc: test for OH_Drawing_CanvasDrawLine.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas005
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas4
=
OH_Drawing_CanvasCreate
();
OH_Drawing_CanvasDrawLine
(
canvas4
,
0
,
0
,
20
,
20
);
OH_Drawing_CanvasDrawLine
(
canvas4
,
-
15.2
f
,
-
1
,
0
,
20
);
}
/*
* @tc.name: NativeDrawingCanvasTest_canvas006
* @tc.desc: test for OH_Drawing_CanvasDrawPath.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas006
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas5
=
OH_Drawing_CanvasCreate
();
OH_Drawing_Path
*
path
=
OH_Drawing_PathCreate
();
OH_Drawing_CanvasDrawPath
(
canvas5
,
path
);
}
/*
* @tc.name: NativeDrawingCanvasTest_canvas007
* @tc.desc: test for OH_Drawing_CanvasSave & OH_Drawing_CanvasRestore.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas007
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas6
=
OH_Drawing_CanvasCreate
();
OH_Drawing_Path
*
path
=
OH_Drawing_PathCreate
();
OH_Drawing_CanvasDrawPath
(
canvas6
,
path
);
OH_Drawing_CanvasSave
(
canvas6
);
OH_Drawing_CanvasRestore
(
canvas6
);
}
/*
* @tc.name: NativeDrawingCanvasTest_canvas008
* @tc.desc: test for OH_Drawing_CanvasClear.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingCanvasTest
,
NativeDrawingCanvasTest_canvas008
,
TestSize
.
Level1
)
{
OH_Drawing_Canvas
*
canvas7
=
OH_Drawing_CanvasCreate
();
OH_Drawing_CanvasClear
(
canvas7
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0xFF
,
0x00
,
0x00
));
}
}
// namespace Drawing
}
// namespace Rosen
}
// namespace OHOS
\ No newline at end of file
graphic/graphicnapidrawingtest/NativeDrawingColorTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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 "c/drawing_brush.h"
#include "c/drawing_color.h"
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
namespace
Rosen
{
namespace
Drawing
{
class
NativeDrawingColorTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
static
void
TearDownTestCase
();
void
SetUp
()
override
;
void
TearDown
()
override
;
};
void
NativeDrawingColorTest
::
SetUpTestCase
()
{}
void
NativeDrawingColorTest
::
TearDownTestCase
()
{}
void
NativeDrawingColorTest
::
SetUp
()
{}
void
NativeDrawingColorTest
::
TearDown
()
{}
/*
* @tc.name: NativeDrawingColorTest_color001
* @tc.desc: test for ColorSetArgb.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingColorTest
,
NativeDrawingColorTest_color001
,
TestSize
.
Level1
)
{
OH_Drawing_Brush
*
brush1
=
OH_Drawing_BrushCreate
();
OH_Drawing_BrushSetAntiAlias
(
brush1
,
false
);
EXPECT_EQ
(
OH_Drawing_BrushIsAntiAlias
(
brush1
),
false
);
OH_Drawing_BrushSetColor
(
brush1
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0xFF
,
0x00
,
0x00
));
EXPECT_EQ
(
OH_Drawing_BrushGetColor
(
brush1
),
0xFFFF0000
);
}
}
// namespace Drawing
}
// namespace Rosen
}
// namespace OHOS
\ No newline at end of file
graphic/graphicnapidrawingtest/NativeDrawingPathTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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 "c/drawing_path.h"
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
namespace
Rosen
{
namespace
Drawing
{
class
NativeDrawingPathTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
static
void
TearDownTestCase
();
void
SetUp
()
override
;
void
TearDown
()
override
;
};
void
NativeDrawingPathTest
::
SetUpTestCase
()
{}
void
NativeDrawingPathTest
::
TearDownTestCase
()
{}
void
NativeDrawingPathTest
::
SetUp
()
{}
void
NativeDrawingPathTest
::
TearDown
()
{}
/*
* @tc.name: NativeDrawingPathTest_path001
* @tc.desc: test for create drawing_path.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path001
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path
=
OH_Drawing_PathCreate
();
EXPECT_EQ
(
path
==
nullptr
,
false
);
OH_Drawing_PathDestroy
(
path
);
}
/*
* @tc.name: NativeDrawingPathTest_path002
* @tc.desc: test for PathMoveTo func.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path002
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path1
=
OH_Drawing_PathCreate
();
OH_Drawing_PathMoveTo
(
path1
,
20
,
20
);
OH_Drawing_PathMoveTo
(
path1
,
-
1
,
20.6
f
);
OH_Drawing_PathDestroy
(
path1
);
}
/*
* @tc.name: NativeDrawingPathTest_path004
* @tc.desc: test for PathLineTo func.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path003
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path2
=
OH_Drawing_PathCreate
();
OH_Drawing_PathLineTo
(
path2
,
50
,
40
);
OH_Drawing_PathLineTo
(
path2
,
-
50
,
10.2
f
);
OH_Drawing_PathDestroy
(
path2
);
}
/*
* @tc.name: NativeDrawingPathTest_path005
* @tc.desc: test for PathReset func.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path004
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path3
=
OH_Drawing_PathCreate
();
OH_Drawing_PathMoveTo
(
path3
,
20
,
20
);
OH_Drawing_PathReset
(
path3
);
OH_Drawing_PathDestroy
(
path3
);
}
/*
* @tc.name: NativeDrawingPathTest_path006
* @tc.desc: test for PathArcTo func.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path005
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path4
=
OH_Drawing_PathCreate
();
OH_Drawing_PathArcTo
(
path4
,
10
,
10
,
20
,
0
,
0
,
90
);
OH_Drawing_PathArcTo
(
path4
,
-
10
,
10
,
10
,
-
10
,
0
,
90
);
OH_Drawing_PathDestroy
(
path4
);
}
/*
* @tc.name: NativeDrawingPathTest_path007
* @tc.desc: test for PathQuadTo func.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path006
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path5
=
OH_Drawing_PathCreate
();
OH_Drawing_PathQuadTo
(
path5
,
0
,
0
,
30
,
30
);
OH_Drawing_PathQuadTo
(
path5
,
-
20.5
f
,
-
20.5
f
,
30
,
0
);
OH_Drawing_PathDestroy
(
path5
);
}
/*
* @tc.name: NativeDrawingPathTest_path008
* @tc.desc: test for PathCubicTo func.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path007
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path6
=
OH_Drawing_PathCreate
();
OH_Drawing_PathCubicTo
(
path6
,
30
,
40
,
60
,
0
,
50
,
20
);
OH_Drawing_PathCubicTo
(
path6
,
-
30
,
40
,
60
,
-
30.6
f
,
50
,
-
20
);
OH_Drawing_PathDestroy
(
path6
);
}
/*
* @tc.name: NativeDrawingPathTest_path009
* @tc.desc: test for PathClose func.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPathTest
,
NativeDrawingPathTest_path009
,
TestSize
.
Level1
)
{
OH_Drawing_Path
*
path7
=
OH_Drawing_PathCreate
();
OH_Drawing_PathLineTo
(
path7
,
50
,
40
);
OH_Drawing_PathClose
(
path7
);
OH_Drawing_PathDestroy
(
path7
);
}
}
// namespace Drawing
}
// namespace Rosen
}
// namespace OHOS
\ No newline at end of file
graphic/graphicnapidrawingtest/NativeDrawingPenTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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 "c/drawing_color.h"
#include "c/drawing_pen.h"
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
namespace
Rosen
{
namespace
Drawing
{
class
NativeDrawingPenTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
static
void
TearDownTestCase
();
void
SetUp
()
override
;
void
TearDown
()
override
;
};
void
NativeDrawingPenTest
::
SetUpTestCase
()
{}
void
NativeDrawingPenTest
::
TearDownTestCase
()
{}
void
NativeDrawingPenTest
::
SetUp
()
{}
void
NativeDrawingPenTest
::
TearDown
()
{}
/*
* @tc.name: NativeDrawingPenTest_pen001
* @tc.desc: test for create drawing_pen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPenTest
,
NativeDrawingPenTest_pen001
,
TestSize
.
Level1
)
{
OH_Drawing_Pen
*
pen
=
OH_Drawing_PenCreate
();
EXPECT_EQ
(
pen
==
nullptr
,
false
);
OH_Drawing_PenDestroy
(
pen
);
}
/*
* @tc.name: NativeDrawingPenTest_pen002
* @tc.desc: test for the get and set methods about AntiAlias for a pen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPenTest
,
NativeDrawingPenTest_pen002
,
TestSize
.
Level1
)
{
OH_Drawing_Pen
*
pen1
=
OH_Drawing_PenCreate
();
OH_Drawing_PenSetAntiAlias
(
pen1
,
true
);
EXPECT_EQ
(
OH_Drawing_PenIsAntiAlias
(
pen1
),
true
);
OH_Drawing_PenSetAntiAlias
(
pen1
,
false
);
EXPECT_EQ
(
OH_Drawing_PenIsAntiAlias
(
pen1
),
false
);
OH_Drawing_PenDestroy
(
pen1
);
}
/*
* @tc.name: NativeDrawingPenTest_pen003
* @tc.desc: test for the get and set methods about the color for a pen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPenTest
,
NativeDrawingPenTest_pen003
,
TestSize
.
Level1
)
{
OH_Drawing_Pen
*
pen2
=
OH_Drawing_PenCreate
();
OH_Drawing_PenSetColor
(
pen2
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0xFF
,
0x00
,
0x00
));
EXPECT_EQ
(
OH_Drawing_PenGetColor
(
pen2
),
0xFFFF0000
);
OH_Drawing_PenDestroy
(
pen2
);
}
/*
* @tc.name: NativeDrawingPenTest_pen004
* @tc.desc: test for the get and set methods about the width for a pen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPenTest
,
NativeDrawingPenTest_pen004
,
TestSize
.
Level1
)
{
OH_Drawing_Pen
*
pen3
=
OH_Drawing_PenCreate
();
OH_Drawing_PenSetWidth
(
pen3
,
10
);
EXPECT_EQ
(
OH_Drawing_PenGetWidth
(
pen3
),
10
);
OH_Drawing_PenDestroy
(
pen3
);
}
/*
* @tc.name: NativeDrawingPenTest_pen005
* @tc.desc: test for the get and set methods about the miterLimit for a pen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPenTest
,
NativeDrawingPenTest_pen005
,
TestSize
.
Level1
)
{
OH_Drawing_Pen
*
pen4
=
OH_Drawing_PenCreate
();
OH_Drawing_PenSetMiterLimit
(
pen4
,
5
);
EXPECT_EQ
(
OH_Drawing_PenGetMiterLimit
(
pen4
),
5
);
OH_Drawing_PenDestroy
(
pen4
);
}
/*
* @tc.name: NativeDrawingPenTest_pen006
* @tc.desc: test for the get and set methods about the line cap style for a pen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPenTest
,
NativeDrawingPenTest_pen006
,
TestSize
.
Level1
)
{
OH_Drawing_Pen
*
pen5
=
OH_Drawing_PenCreate
();
OH_Drawing_PenSetCap
(
pen5
,
OH_Drawing_PenLineCapStyle
::
LINE_SQUARE_CAP
);
EXPECT_EQ
(
OH_Drawing_PenGetCap
(
pen5
),
OH_Drawing_PenLineCapStyle
::
LINE_SQUARE_CAP
);
OH_Drawing_PenSetCap
(
pen5
,
OH_Drawing_PenLineCapStyle
::
LINE_FLAT_CAP
);
EXPECT_EQ
(
OH_Drawing_PenGetCap
(
pen5
),
OH_Drawing_PenLineCapStyle
::
LINE_FLAT_CAP
);
OH_Drawing_PenSetCap
(
pen5
,
OH_Drawing_PenLineCapStyle
::
LINE_ROUND_CAP
);
EXPECT_EQ
(
OH_Drawing_PenGetCap
(
pen5
),
OH_Drawing_PenLineCapStyle
::
LINE_ROUND_CAP
);
OH_Drawing_PenDestroy
(
pen5
);
}
/*
* @tc.name: NativeDrawingPenTest_pen007
* @tc.desc: test for the get and set methods about the line join style for a pen.
* @tc.type: FUNC
* @tc.require: AR000GTO5R
*/
HWTEST_F
(
NativeDrawingPenTest
,
NativeDrawingPenTest_pen007
,
TestSize
.
Level1
)
{
OH_Drawing_Pen
*
pen6
=
OH_Drawing_PenCreate
();
OH_Drawing_PenSetJoin
(
pen6
,
OH_Drawing_PenLineJoinStyle
::
LINE_ROUND_JOIN
);
EXPECT_EQ
(
OH_Drawing_PenGetJoin
(
pen6
),
OH_Drawing_PenLineJoinStyle
::
LINE_ROUND_JOIN
);
OH_Drawing_PenSetJoin
(
pen6
,
OH_Drawing_PenLineJoinStyle
::
LINE_MITER_JOIN
);
EXPECT_EQ
(
OH_Drawing_PenGetJoin
(
pen6
),
OH_Drawing_PenLineJoinStyle
::
LINE_MITER_JOIN
);
OH_Drawing_PenSetJoin
(
pen6
,
OH_Drawing_PenLineJoinStyle
::
LINE_BEVEL_JOIN
);
EXPECT_EQ
(
OH_Drawing_PenGetJoin
(
pen6
),
OH_Drawing_PenLineJoinStyle
::
LINE_BEVEL_JOIN
);
OH_Drawing_PenDestroy
(
pen6
);
}
}
// namespace Drawing
}
// namespace Rosen
}
// namespace OHOS
\ No newline at end of file
graphic/graphicnapidrawingtest/OH_Drawing_FontCollectionTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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.
*/
#include "c/drawing_font_collection.h"
#include "gtest/gtest.h"
#include "c/drawing_text_declaration.h"
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
class
OH_Drawing_FontCollectionTest
:
public
testing
::
Test
{
};
/*
* @tc.name: NativeDrawingTest001
* @tc.desc: test for creating fontCollection
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_FontCollectionTest
,
OH_Drawing_FontCollectionTest001
,
TestSize
.
Level1
)
{
OH_Drawing_FontCollection
*
fontCollection
=
OH_Drawing_CreateFontCollection
();
EXPECT_EQ
(
fontCollection
==
nullptr
,
false
);
OH_Drawing_DestroyFontCollection
(
fontCollection
);
}
}
\ No newline at end of file
graphic/graphicnapidrawingtest/OH_Drawing_TypographyTest.cpp
0 → 100644
浏览文件 @
af0b1ef8
/*
* 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.
*/
#include "gtest/gtest.h"
#include "c/drawing_bitmap.h"
#include "c/drawing_canvas.h"
#include "c/drawing_color.h"
#include "c/drawing_font_collection.h"
#include "c/drawing_text_declaration.h"
#include "c/drawing_text_typography.h"
#include "rosen_text/ui/typography.h"
#include "rosen_text/ui/typography_create.h"
using
namespace
rosen
;
using
namespace
testing
;
using
namespace
testing
::
ext
;
namespace
OHOS
{
class
OH_Drawing_TypographyTest
:
public
testing
::
Test
{
};
static
TypographyStyle
*
ConvertToOriginalText
(
OH_Drawing_TypographyStyle
*
style
)
{
return
reinterpret_cast
<
TypographyStyle
*>
(
style
);
}
static
TextStyle
*
ConvertToOriginalText
(
OH_Drawing_TextStyle
*
style
)
{
return
reinterpret_cast
<
TextStyle
*>
(
style
);
}
/*
* @tc.name: OH_Drawing_TypographyTest001
* @tc.desc: test for creating TypographyStyle
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest001
,
TestSize
.
Level1
)
{
OH_Drawing_TypographyStyle
*
typoStyle
=
OH_Drawing_CreateTypographyStyle
();
EXPECT_EQ
(
typoStyle
==
nullptr
,
false
);
OH_Drawing_DestroyTypographyStyle
(
typoStyle
);
}
/*
* @tc.name: OH_Drawing_TypographyTest002
* @tc.desc: test for text direction
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest002
,
TestSize
.
Level1
)
{
OH_Drawing_TypographyStyle
*
typoStyle
=
OH_Drawing_CreateTypographyStyle
();
OH_Drawing_SetTypographyTextDirection
(
typoStyle
,
TEXT_DIRECTION_LTR
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textDirection_
,
TextDirection
::
LTR
);
OH_Drawing_SetTypographyTextDirection
(
typoStyle
,
TEXT_DIRECTION_RTL
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textDirection_
,
TextDirection
::
RTL
);
}
/*
* @tc.name: OH_Drawing_TypographyTest003
* @tc.desc: test for text alignment
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest003
,
TestSize
.
Level1
)
{
OH_Drawing_TypographyStyle
*
typoStyle
=
OH_Drawing_CreateTypographyStyle
();
OH_Drawing_SetTypographyTextAlign
(
typoStyle
,
TEXT_ALIGN_LEFT
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textAlign_
,
TextAlign
::
LEFT
);
OH_Drawing_SetTypographyTextAlign
(
typoStyle
,
TEXT_ALIGN_RIGHT
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textAlign_
,
TextAlign
::
RIGHT
);
OH_Drawing_SetTypographyTextAlign
(
typoStyle
,
TEXT_ALIGN_CENTER
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textAlign_
,
TextAlign
::
CENTER
);
OH_Drawing_SetTypographyTextAlign
(
typoStyle
,
TEXT_ALIGN_JUSTIFY
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textAlign_
,
TextAlign
::
JUSTIFY
);
OH_Drawing_SetTypographyTextAlign
(
typoStyle
,
TEXT_ALIGN_START
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textAlign_
,
TextAlign
::
START
);
OH_Drawing_SetTypographyTextAlign
(
typoStyle
,
TEXT_ALIGN_END
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
textAlign_
,
TextAlign
::
END
);
}
/*
* @tc.name: OH_Drawing_TypographyTest004
* @tc.desc: test for max lines
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest004
,
TestSize
.
Level1
)
{
OH_Drawing_TypographyStyle
*
typoStyle
=
OH_Drawing_CreateTypographyStyle
();
OH_Drawing_SetTypographyTextMaxLines
(
typoStyle
,
100
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
maxLines_
,
100
);
OH_Drawing_SetTypographyTextMaxLines
(
typoStyle
,
200
);
EXPECT_EQ
(
ConvertToOriginalText
(
typoStyle
)
->
maxLines_
,
200
);
}
/*
* @tc.name: OH_Drawing_TypographyTest005
* @tc.desc: test for creating text style
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest005
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
EXPECT_EQ
(
txtStyle
==
nullptr
,
false
);
OH_Drawing_DestroyTextStyle
(
txtStyle
);
}
/*
* @tc.name: OH_Drawing_TypographyTest006
* @tc.desc: test for text color
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest006
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
// black
OH_Drawing_SetTextStyleColor
(
txtStyle
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0x00
,
0x00
,
0x00
));
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
color_
,
0xFF000000
);
// red
OH_Drawing_SetTextStyleColor
(
txtStyle
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0xFF
,
0x00
,
0x00
));
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
color_
,
0xFFFF0000
);
// blue
OH_Drawing_SetTextStyleColor
(
txtStyle
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0x00
,
0x00
,
0xFF
));
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
color_
,
0xFF0000FF
);
}
/*
* @tc.name: OH_Drawing_TypographyTest007
* @tc.desc: test for font size
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest007
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleFontSize
(
txtStyle
,
80
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
fontSize_
,
80
);
OH_Drawing_SetTextStyleFontSize
(
txtStyle
,
40
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
fontSize_
,
40
);
}
/*
* @tc.name: OH_Drawing_TypographyTest008
* @tc.desc: test for font weight
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest008
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleFontWeight
(
txtStyle
,
FONT_WEIGHT_400
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
fontWeight_
,
FontWeight
::
W400
);
OH_Drawing_SetTextStyleFontWeight
(
txtStyle
,
FONT_WEIGHT_900
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
fontWeight_
,
FontWeight
::
W900
);
}
/*
* @tc.name: OH_Drawing_TypographyTest009
* @tc.desc: test for baseline location
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest009
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleBaseLine
(
txtStyle
,
TEXT_BASELINE_ALPHABETIC
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
textBaseline_
,
TextBaseline
::
ALPHABETIC
);
OH_Drawing_SetTextStyleBaseLine
(
txtStyle
,
TEXT_BASELINE_IDEOGRAPHIC
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
textBaseline_
,
TextBaseline
::
IDEOGRAPHIC
);
}
/*
* @tc.name: OH_Drawing_TypographyTest010
* @tc.desc: test for text decoration
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest010
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleDecoration
(
txtStyle
,
TEXT_DECORATION_NONE
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
decoration_
,
TextDecoration
::
NONE
);
OH_Drawing_SetTextStyleDecoration
(
txtStyle
,
TEXT_DECORATION_UNDERLINE
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
decoration_
,
TextDecoration
::
UNDERLINE
);
OH_Drawing_SetTextStyleDecoration
(
txtStyle
,
TEXT_DECORATION_OVERLINE
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
decoration_
,
TextDecoration
::
OVERLINE
);
OH_Drawing_SetTextStyleDecoration
(
txtStyle
,
TEXT_DECORATION_LINE_THROUGH
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
decoration_
,
TextDecoration
::
LINETHROUGH
);
}
/*
* @tc.name: OH_Drawing_TypographyTest011
* @tc.desc: test for text decoration color
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest011
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleDecorationColor
(
txtStyle
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0x00
,
0x00
,
0x00
));
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
decorationColor_
,
0xFF000000
);
OH_Drawing_SetTextStyleDecorationColor
(
txtStyle
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0xFF
,
0x00
,
0x00
));
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
decorationColor_
,
0xFFFF0000
);
}
/*
* @tc.name: OH_Drawing_TypographyTest012
* @tc.desc: test for font height
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest012
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleFontHeight
(
txtStyle
,
0.0
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
height_
,
0.0
);
}
/*
* @tc.name: OH_Drawing_TypographyTest013
* @tc.desc: test for font families
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest013
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
const
char
*
fontFamilies
[]
=
{
"Roboto"
};
OH_Drawing_SetTextStyleFontFamilies
(
txtStyle
,
1
,
fontFamilies
);
std
::
vector
<
std
::
string
>
fontFamiliesResult
=
{
"Roboto"
};
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
fontFamilies_
,
fontFamiliesResult
);
}
/*
* @tc.name: OH_Drawing_TypographyTest014
* @tc.desc: test for font italic
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest014
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleFontStyle
(
txtStyle
,
FONT_STYLE_NORMAL
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
fontStyle_
,
FontStyle
::
NORMAL
);
OH_Drawing_SetTextStyleFontStyle
(
txtStyle
,
FONT_STYLE_ITALIC
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
fontStyle_
,
FontStyle
::
ITALIC
);
}
/*
* @tc.name: OH_Drawing_TypographyTest015
* @tc.desc: test for font locale
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest015
,
TestSize
.
Level1
)
{
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_SetTextStyleLocale
(
txtStyle
,
"en"
);
EXPECT_EQ
(
ConvertToOriginalText
(
txtStyle
)
->
locale_
,
"en"
);
}
/*
* @tc.name: OH_Drawing_TypographyTest016
* @tc.desc: test for typography
* @tc.type: FUNC
*/
HWTEST_F
(
OH_Drawing_TypographyTest
,
OH_Drawing_TypographyTest016
,
TestSize
.
Level1
)
{
OH_Drawing_TypographyStyle
*
typoStyle
=
OH_Drawing_CreateTypographyStyle
();
OH_Drawing_TextStyle
*
txtStyle
=
OH_Drawing_CreateTextStyle
();
OH_Drawing_TypographyCreate
*
handler
=
OH_Drawing_CreateTypographyHandler
(
typoStyle
,
OH_Drawing_CreateFontCollection
());
EXPECT_TRUE
(
handler
!=
nullptr
);
OH_Drawing_SetTextStyleColor
(
txtStyle
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0x00
,
0x00
,
0x00
));
double
fontSize
=
30
;
OH_Drawing_SetTextStyleFontSize
(
txtStyle
,
fontSize
);
OH_Drawing_SetTextStyleFontWeight
(
txtStyle
,
FONT_WEIGHT_400
);
OH_Drawing_SetTextStyleBaseLine
(
txtStyle
,
TEXT_BASELINE_ALPHABETIC
);
const
char
*
fontFamilies
[]
=
{
"Roboto"
};
OH_Drawing_SetTextStyleFontFamilies
(
txtStyle
,
1
,
fontFamilies
);
OH_Drawing_TypographyHandlerPushTextStyle
(
handler
,
txtStyle
);
const
char
*
text
=
"OpenHarmony
\n
"
;
OH_Drawing_TypographyHandlerAddText
(
handler
,
text
);
OH_Drawing_TypographyHandlerPopTextStyle
(
handler
);
OH_Drawing_Typography
*
typography
=
OH_Drawing_CreateTypography
(
handler
);
double
maxWidth
=
800.0
;
OH_Drawing_TypographyLayout
(
typography
,
maxWidth
);
double
position
[
2
]
=
{
10.0
,
15.0
};
OH_Drawing_Bitmap
*
cBitmap
=
OH_Drawing_BitmapCreate
();
OH_Drawing_BitmapFormat
cFormat
{
COLOR_FORMAT_RGBA_8888
,
ALPHA_FORMAT_OPAQUE
};
uint32_t
width
=
20
;
uint32_t
height
=
40
;
OH_Drawing_BitmapBuild
(
cBitmap
,
width
,
height
,
&
cFormat
);
OH_Drawing_Canvas
*
cCanvas
=
OH_Drawing_CanvasCreate
();
OH_Drawing_CanvasBind
(
cCanvas
,
cBitmap
);
OH_Drawing_CanvasClear
(
cCanvas
,
OH_Drawing_ColorSetArgb
(
0xFF
,
0xFF
,
0xFF
,
0xFF
));
OH_Drawing_TypographyPaint
(
typography
,
cCanvas
,
position
[
0
],
position
[
1
]);
}
}
\ No newline at end of file
graphic/graphicnapidrawingtest/Test.json
0 → 100644
浏览文件 @
af0b1ef8
{
"kits"
:
[
{
"push"
:
[
"GraphicNapiDrawingTest->/data/local/tmp/GraphicNapiDrawingTest"
],
"type"
:
"PushKit"
,
"post-push"
:
[
"chmod -R 777 /data/local/tmp/*"
]
}
],
"driver"
:
{
"native-test-timeout"
:
"120000"
,
"type"
:
"CppTest"
,
"module-name"
:
"GraphicNapiDrawingTest"
,
"runtime-hint"
:
"1s"
,
"native-test-device-path"
:
"/data/local/tmp"
},
"description"
:
"Configuration for GraphicNapiDrawingTest Tests"
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录