Blender
V5.0
source
blender
windowmanager
intern
wm_dragdrop_test.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#include "testing/testing.h"
6
7
/* #eFileSel_File_Types. */
8
#include "
DNA_space_types.h
"
9
10
#include "
WM_api.hh
"
11
#include "
WM_types.hh
"
12
13
namespace
blender::tests
{
14
15
TEST
(wm_drag,
wmDragPath
)
16
{
17
{
23
blender::Vector<const char *>
paths{
"text_file.txt"
};
24
wmDragPath
*path_data =
WM_drag_create_path_data
(paths);
25
blender::Vector<std::string>
expected_file_paths{
"text_file.txt"
};
26
27
EXPECT_EQ
(path_data->
paths
.
size
(), 1);
28
EXPECT_EQ
(path_data->
tooltip
,
"text_file.txt"
);
29
EXPECT_EQ
(path_data->
paths
, expected_file_paths);
30
32
wmDrag
drag;
33
drag.
type
=
WM_DRAG_PATH
;
34
drag.
poin
= path_data;
35
EXPECT_STREQ(
WM_drag_get_single_path
(&drag),
"text_file.txt"
);
36
EXPECT_EQ
(
WM_drag_get_path_file_type
(&drag),
FILE_TYPE_TEXT
);
37
EXPECT_EQ
(
WM_drag_get_paths
(&drag), expected_file_paths.
as_span
());
38
EXPECT_STREQ(
WM_drag_get_single_path
(&drag,
FILE_TYPE_TEXT
),
"text_file.txt"
);
39
EXPECT_EQ
(
WM_drag_get_single_path
(&drag,
FILE_TYPE_BLENDER
),
nullptr
);
40
EXPECT_TRUE(
41
WM_drag_has_path_file_type
(&drag,
FILE_TYPE_BLENDER
|
FILE_TYPE_TEXT
|
FILE_TYPE_IMAGE
));
42
EXPECT_FALSE(
WM_drag_has_path_file_type
(&drag,
FILE_TYPE_BLENDER
|
FILE_TYPE_IMAGE
));
43
MEM_delete(path_data);
44
}
45
{
46
blender::Vector<const char *>
paths = {
"blender.blend"
,
"text_file.txt"
,
"image.png"
};
47
wmDragPath
*path_data =
WM_drag_create_path_data
(paths);
48
blender::Vector<std::string>
expected_file_paths = {
49
"blender.blend"
,
"text_file.txt"
,
"image.png"
};
50
51
EXPECT_EQ
(path_data->
paths
.
size
(), 3);
52
EXPECT_EQ
(path_data->
tooltip
,
"Dragging 3 files"
);
53
EXPECT_EQ
(path_data->
paths
, expected_file_paths);
54
56
wmDrag
drag;
57
drag.
type
=
WM_DRAG_PATH
;
58
drag.
poin
= path_data;
59
EXPECT_STREQ(
WM_drag_get_single_path
(&drag),
"blender.blend"
);
60
EXPECT_EQ
(
WM_drag_get_path_file_type
(&drag),
FILE_TYPE_BLENDER
);
61
EXPECT_EQ
(
WM_drag_get_paths
(&drag), expected_file_paths.
as_span
());
62
EXPECT_STREQ(
WM_drag_get_single_path
(&drag,
FILE_TYPE_BLENDER
),
"blender.blend"
);
63
EXPECT_STREQ(
WM_drag_get_single_path
(&drag,
FILE_TYPE_IMAGE
),
"image.png"
);
64
EXPECT_STREQ(
WM_drag_get_single_path
(&drag,
FILE_TYPE_TEXT
),
"text_file.txt"
);
65
EXPECT_STREQ(
66
WM_drag_get_single_path
(&drag,
FILE_TYPE_BLENDER
|
FILE_TYPE_TEXT
|
FILE_TYPE_IMAGE
),
67
"blender.blend"
);
68
EXPECT_STREQ(
WM_drag_get_single_path
(&drag,
FILE_TYPE_TEXT
|
FILE_TYPE_IMAGE
),
69
"text_file.txt"
);
70
EXPECT_EQ
(
WM_drag_get_single_path
(&drag,
FILE_TYPE_ASSET
),
nullptr
);
71
EXPECT_TRUE(
72
WM_drag_has_path_file_type
(&drag,
FILE_TYPE_BLENDER
|
FILE_TYPE_TEXT
|
FILE_TYPE_IMAGE
));
73
EXPECT_TRUE(
WM_drag_has_path_file_type
(&drag,
FILE_TYPE_BLENDER
|
FILE_TYPE_IMAGE
));
74
EXPECT_TRUE(
WM_drag_has_path_file_type
(&drag,
FILE_TYPE_IMAGE
));
75
EXPECT_FALSE(
WM_drag_has_path_file_type
(&drag,
FILE_TYPE_ASSET
));
76
MEM_delete(path_data);
77
}
78
{
80
wmDrag
drag;
81
drag.
type
=
WM_DRAG_COLOR
;
82
EXPECT_EQ
(
WM_drag_get_single_path
(&drag),
nullptr
);
83
EXPECT_EQ
(
WM_drag_get_path_file_type
(&drag), 0);
84
EXPECT_EQ
(
WM_drag_get_paths
(&drag).
size
(), 0);
85
EXPECT_EQ
(
WM_drag_get_single_path
(
86
&drag,
FILE_TYPE_BLENDER
|
FILE_TYPE_IMAGE
|
FILE_TYPE_TEXT
|
FILE_TYPE_ASSET
),
87
nullptr
);
88
EXPECT_FALSE(
WM_drag_has_path_file_type
(
89
&drag,
FILE_TYPE_BLENDER
|
FILE_TYPE_IMAGE
|
FILE_TYPE_TEXT
|
FILE_TYPE_ASSET
));
90
}
91
}
92
93
}
// namespace blender::tests
EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
FILE_TYPE_BLENDER
@ FILE_TYPE_BLENDER
Definition
DNA_space_enums.h:630
FILE_TYPE_ASSET
@ FILE_TYPE_ASSET
Definition
DNA_space_enums.h:652
FILE_TYPE_TEXT
@ FILE_TYPE_TEXT
Definition
DNA_space_enums.h:637
FILE_TYPE_IMAGE
@ FILE_TYPE_IMAGE
Definition
DNA_space_enums.h:632
DNA_space_types.h
WM_api.hh
WM_types.hh
WM_DRAG_PATH
@ WM_DRAG_PATH
Definition
WM_types.hh:1208
WM_DRAG_COLOR
@ WM_DRAG_COLOR
Definition
WM_types.hh:1218
size
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition
btDbvt.cpp:52
Vector::size
int64_t size() const
Definition
BLI_vector.hh:771
blender::Vector
Definition
BLI_vector.hh:76
blender::Vector::as_span
Span< T > as_span() const
Definition
BLI_vector.hh:381
blender::tests
Definition
BLF_tests.cc:9
blender::tests::TEST
TEST(blf_load, load)
Definition
BLF_tests.cc:34
wmDragPath
Definition
WM_types.hh:1270
wmDragPath::paths
blender::Vector< std::string > paths
Definition
WM_types.hh:1271
wmDragPath::tooltip
std::string tooltip
Definition
WM_types.hh:1276
wmDrag
Definition
WM_types.hh:1327
wmDrag::type
eWM_DragDataType type
Definition
WM_types.hh:1331
wmDrag::poin
void * poin
Definition
WM_types.hh:1332
WM_drag_create_path_data
wmDragPath * WM_drag_create_path_data(blender::Span< const char * > paths)
Definition
wm_dragdrop.cc:901
WM_drag_get_paths
blender::Span< std::string > WM_drag_get_paths(const wmDrag *drag)
Definition
wm_dragdrop.cc:968
WM_drag_get_path_file_type
int WM_drag_get_path_file_type(const wmDrag *drag)
Definition
wm_dragdrop.cc:978
WM_drag_get_single_path
const char * WM_drag_get_single_path(const wmDrag *drag)
Definition
wm_dragdrop.cc:929
WM_drag_has_path_file_type
bool WM_drag_has_path_file_type(const wmDrag *drag, int file_type)
Definition
wm_dragdrop.cc:959
Generated on
for Blender by
doxygen
1.16.1