aboutsummaryrefslogtreecommitdiff
path: root/tests/CMakeLists.txt
blob: 1556fc7c0ef2be8eae23b7e04fb29eb9e077069e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

###########################
# Google Test
###########################

include_directories(${GTEST_INCLUDE_DIR})

add_library (gtest STATIC
             ${GTEST_SOURCE_DIR}/gtest-all.cc
             ${GTEST_SOURCE_DIR}/gtest_main.cc)
target_link_libraries(gtest ${GTEST_LIBS})

###########################
# Vala Mocks
###########################

set(VALA_MOCKS_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/vala-mocks.h")
set(VALA_MOCKS_SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/vala-mocks.def")

vala_init(vala-mocks
	DEPENDS
		indicator-sound-service-lib
	PACKAGES
		config
		gio-2.0
		gio-unix-2.0
		libxml-2.0
		libpulse
		libpulse-mainloop-glib
		libnotify
		accounts-service
		indicator-sound-service
	OPTIONS
		--ccode
		--thread
		--vapidir=${CMAKE_BINARY_DIR}/src/
		--vapidir=${CMAKE_SOURCE_DIR}/vapi/
		--vapidir=.
)

vala_add(vala-mocks
	media-player-mock.vala
)

vala_finish(vala-mocks
	SOURCES
		vala_mocks_VALA_SOURCES
	OUTPUTS
		vala_mocks_VALA_C
	GENERATE_HEADER
		${VALA_MOCKS_HEADER_PATH}
	GENERATE_SYMBOLS
		${VALA_MOCKS_SYMBOLS_PATH}
)

set_source_files_properties(
	${vala_mocks_VALA_SOURCES}
	PROPERTIES
	HEADER_FILE_ONLY TRUE
)

set(
	VALA_MOCKS_SOURCES
	${vala_mocks_VALA_SOURCES}
	${vala_mocks_VALA_C}
	${VALA_MOCKS_SYMBOLS_PATH}
)

add_definitions(
	-Wno-unused-but-set-variable
)

add_library(
	vala-mocks-lib STATIC
	${VALA_MOCKS_SOURCES}
)

target_link_libraries(
	vala-mocks-lib
	indicator-sound-service-lib
)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

###########################
# Name Watch Test
###########################

include_directories(${CMAKE_SOURCE_DIR}/src)
add_executable (name-watch-test name-watch-test.cc ${CMAKE_SOURCE_DIR}/src/bus-watch-namespace.c)
target_link_libraries (name-watch-test gtest ${SOUNDSERVICE_LIBRARIES})
add_test(name-watch-test name-watch-test)

###########################
# Accounts Service User
###########################

include_directories(${CMAKE_SOURCE_DIR}/src)
add_executable (accounts-service-user-test accounts-service-user.cc)
target_link_libraries (
	accounts-service-user-test
	indicator-sound-service-lib
	vala-mocks-lib
	gtest
	${SOUNDSERVICE_LIBRARIES}
	${TEST_LIBRARIES}
)

# Split tests to work around libaccountservice sucking
add_test(accounts-service-user-test-basic
	accounts-service-user-test  --gtest_filter=AccountsServiceUserTest.BasicObject
)

add_test(accounts-service-user-test-player
	accounts-service-user-test  --gtest_filter=AccountsServiceUserTest.SetMediaPlayer
)