Blender V4.3
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
13namespace blender::tests {
14
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");
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");
40 EXPECT_TRUE(
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");
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(
67 "blender.blend");
69 "text_file.txt");
71 EXPECT_TRUE(
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);
84 EXPECT_EQ(WM_drag_get_paths(&drag).size(), 0);
87 nullptr);
88 EXPECT_FALSE(WM_drag_has_path_file_type(
90 }
91}
92
93} // namespace blender::tests
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
@ FILE_TYPE_BLENDER
@ FILE_TYPE_ASSET
@ FILE_TYPE_TEXT
@ FILE_TYPE_IMAGE
@ WM_DRAG_PATH
Definition WM_types.hh:1160
@ WM_DRAG_COLOR
Definition WM_types.hh:1170
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
int64_t size() const
Span< T > as_span() const
TEST(any, DefaultConstructor)
blender::Vector< std::string > paths
Definition WM_types.hh:1222
std::string tooltip
Definition WM_types.hh:1227
eWM_DragDataType type
Definition WM_types.hh:1282
void * poin
Definition WM_types.hh:1283
wmDragPath * WM_drag_create_path_data(blender::Span< const char * > paths)
blender::Span< std::string > WM_drag_get_paths(const wmDrag *drag)
int WM_drag_get_path_file_type(const wmDrag *drag)
const char * WM_drag_get_single_path(const wmDrag *drag)
bool WM_drag_has_path_file_type(const wmDrag *drag, int file_type)