OLD | NEW |
1 #include <gtest/gtest.h> | 1 #include <gtest/gtest.h> |
2 #include "../process.h" | 2 #include "../process.h" |
3 #include <functional> | 3 #include <functional> |
4 | 4 |
5 // Turn off warnings for string copies | 5 // Turn off warnings for string copies |
6 #pragma warning( disable : 4996 ) | 6 #pragma warning( disable : 4996 ) |
7 | 7 |
8 //------------------------------------------------------- | 8 //------------------------------------------------------- |
9 // Comparison objects | 9 // Comparison objects |
10 //------------------------------------------------------- | 10 //------------------------------------------------------- |
(...skipping 29 matching lines...) Expand all Loading... |
40 struct our_process_by_name_CI | 40 struct our_process_by_name_CI |
41 : std::unary_function< PROCESSENTRY32W, bool > | 41 : std::unary_function< PROCESSENTRY32W, bool > |
42 { | 42 { |
43 bool operator()( const PROCESSENTRY32W & process ) | 43 bool operator()( const PROCESSENTRY32W & process ) |
44 { | 44 { |
45 return wstring_ci( process.szExeFile ) == mixedcase_exe_string_ci ; | 45 return wstring_ci( process.szExeFile ) == mixedcase_exe_string_ci ; |
46 } ; | 46 } ; |
47 } ; | 47 } ; |
48 | 48 |
49 | 49 |
50 struct our_process_by_name_subclassed | 50 struct our_process_by_name_subclassed |
51 : public process_by_any_exe_with_any_module | 51 : public process_by_any_exe_not_immersive |
52 { | 52 { |
53 our_process_by_name_subclassed() | 53 our_process_by_name_subclassed() |
54 : process_by_any_exe_with_any_module( file_name_set( multiple_exe_names ), f
ile_name_set() ) | 54 : process_by_any_exe_not_immersive( file_name_set( multiple_exe_names )) |
55 {} | 55 {} |
56 } ; | 56 } ; |
57 | 57 |
58 | 58 |
59 //------------------------------------------------------- | 59 //------------------------------------------------------- |
60 //------------------------------------------------------- | 60 //------------------------------------------------------- |
61 /** | 61 /** |
62 * Filter by process name. Comparison is case-insensitive. | 62 * Filter by process name. Comparison is case-insensitive. |
63 */ | 63 */ |
64 class process_by_any_file_name_CI | 64 class process_by_any_file_name_CI |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 PROCESSENTRY32 process_empty = process_with_name( L"" ) ; | 106 PROCESSENTRY32 process_empty = process_with_name( L"" ) ; |
107 PROCESSENTRY32 process_exact = process_with_name( exact_exe_name ) ; | 107 PROCESSENTRY32 process_exact = process_with_name( exact_exe_name ) ; |
108 PROCESSENTRY32 process_mixedcase = process_with_name( mixedcase_exe_name ) ; | 108 PROCESSENTRY32 process_mixedcase = process_with_name( mixedcase_exe_name ) ; |
109 PROCESSENTRY32 process_explorer = process_with_name( L"explorer.exe" ) ; | 109 PROCESSENTRY32 process_explorer = process_with_name( L"explorer.exe" ) ; |
110 PROCESSENTRY32 process_absent = process_with_name( L"no_such_name" ) ; | 110 PROCESSENTRY32 process_absent = process_with_name( L"no_such_name" ) ; |
111 | 111 |
112 file_name_set multiple_name_set( multiple_exe_names ) ; | 112 file_name_set multiple_name_set( multiple_exe_names ) ; |
113 file_name_set multiple_name_set_modules( multiple_module_names ) ; | 113 file_name_set multiple_name_set_modules( multiple_module_names ) ; |
114 file_name_set non_existent_name_set_modules( non_existent_module_names ) ; | 114 file_name_set non_existent_name_set_modules( non_existent_module_names ) ; |
115 process_by_any_file_name_CI find_in_set( multiple_name_set ) ; | 115 process_by_any_file_name_CI find_in_set( multiple_name_set ) ; |
116 process_by_any_exe_with_any_module find_in_set_w_kernel32( multiple_name_set, mu
ltiple_name_set_modules ) ; | |
117 process_by_any_exe_with_any_module find_in_set_w_non_existent( multiple_name_set
, non_existent_name_set_modules ) ; | |
118 | 116 |
119 TEST( file_name_set, validate_setup ) | 117 TEST( file_name_set, validate_setup ) |
120 { | 118 { |
121 ASSERT_EQ( 2u, multiple_name_set.size() ) ; | 119 ASSERT_EQ( 2u, multiple_name_set.size() ) ; |
122 ASSERT_TRUE( multiple_name_set.find( exact_exe_string_ci ) != multiple_name_se
t.end() ) ; | 120 ASSERT_TRUE( multiple_name_set.find( exact_exe_string_ci ) != multiple_name_se
t.end() ) ; |
123 ASSERT_TRUE( multiple_name_set.find( mixedcase_exe_string_ci ) != multiple_nam
e_set.end() ) ; | 121 ASSERT_TRUE( multiple_name_set.find( mixedcase_exe_string_ci ) != multiple_nam
e_set.end() ) ; |
124 ASSERT_TRUE( multiple_name_set.find( L"" ) == multiple_name_set.end() ) ; | 122 ASSERT_TRUE( multiple_name_set.find( L"" ) == multiple_name_set.end() ) ; |
125 ASSERT_TRUE( multiple_name_set.find( L"not-in-list" ) == multiple_name_set.end
() ) ; | 123 ASSERT_TRUE( multiple_name_set.find( L"not-in-list" ) == multiple_name_set.end
() ) ; |
126 } | 124 } |
127 | 125 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 ASSERT_GE( s.size(), 1u ); | 287 ASSERT_GE( s.size(), 1u ); |
290 } | 288 } |
291 | 289 |
292 TEST( pid_set, find_our_process_in_set ) | 290 TEST( pid_set, find_our_process_in_set ) |
293 { | 291 { |
294 std::set< DWORD > s ; | 292 std::set< DWORD > s ; |
295 initialize_process_set( s, find_in_set, copy_PID() ) ; | 293 initialize_process_set( s, find_in_set, copy_PID() ) ; |
296 size_t size( s.size() ) ; | 294 size_t size( s.size() ) ; |
297 EXPECT_EQ( size, 1u ); | 295 EXPECT_EQ( size, 1u ); |
298 ASSERT_GE( size, 1u ); | 296 ASSERT_GE( size, 1u ); |
299 } | 297 } |
300 | |
301 TEST( pid_set, find_our_process_in_set_w_kernel32 ) | |
302 { | |
303 std::set< DWORD > s ; | |
304 initialize_process_set( s, find_in_set_w_kernel32, copy_PID() ) ; | |
305 size_t size( s.size() ) ; | |
306 EXPECT_EQ( size, 1u ); | |
307 ASSERT_GE( size, 1u ); | |
308 } | |
309 TEST( pid_set, find_our_process_in_set_w_non_existant ) | |
310 { | |
311 std::set< DWORD > s ; | |
312 initialize_process_set( s, find_in_set_w_non_existent, copy_PID() ) ; | |
313 size_t size( s.size() ) ; | |
314 EXPECT_EQ( size, 0u ); | |
315 ASSERT_GE( size, 0u ); | |
316 } | |
OLD | NEW |