OLD | NEW |
1 /** | 1 /** |
2 * \file test-installer-lib-sandbox.cpp | 2 * \file test-installer-lib-sandbox.cpp |
3 * | 3 * |
4 * Automatic testing of many of the units within the custom action is infeasible
. | 4 * Automatic testing of many of the units within the custom action is infeasible
. |
5 * In one case, they rely on the execution environment within an installation se
ssion. | 5 * In one case, they rely on the execution environment within an installation se
ssion. |
6 * In another, they rely on the operation system environment as a whole. | 6 * In another, they rely on the operation system environment as a whole. |
7 * In these cases, it's easier to verify behavior manually. | 7 * In these cases, it's easier to verify behavior manually. |
8 * | 8 * |
9 * This file contains a custom action function sandbox() as well as a number of
test functions. | 9 * This file contains a custom action function sandbox() as well as a number of
test functions. |
10 * At any given time, not all of the test functions need to be referenced within
the body of custom action. | 10 * At any given time, not all of the test functions need to be referenced within
the body of custom action. |
(...skipping 27 matching lines...) Expand all Loading... |
38 s << "Window handle 0x" << std::hex << window ; | 38 s << "Window handle 0x" << std::hex << window ; |
39 session.Log( s.str() ) ; | 39 session.Log( s.str() ) ; |
40 return true ; | 40 return true ; |
41 } | 41 } |
42 } ; | 42 } ; |
43 | 43 |
44 void log_all_window_handles( ImmediateSession & session ) | 44 void log_all_window_handles( ImmediateSession & session ) |
45 { | 45 { |
46 session.Log( "log_all_window_handles" ) ; | 46 session.Log( "log_all_window_handles" ) ; |
47 log_single_window_handle lp( session ) ; | 47 log_single_window_handle lp( session ) ; |
48 enumerate_windows( lp ) ; | 48 EnumerateWindows( lp ) ; |
49 } | 49 } |
50 | 50 |
51 //------------------------------------------------------- | 51 //------------------------------------------------------- |
52 // log_IE_window_handles | 52 // log_IE_window_handles |
53 //------------------------------------------------------- | 53 //------------------------------------------------------- |
54 class log_single_window_handle_only_if_IE | 54 class log_single_window_handle_only_if_IE |
55 { | 55 { |
56 ImmediateSession & session ; | 56 ImmediateSession & session ; |
57 | 57 |
58 ProcessCloser & pc ; | 58 ProcessCloser & pc ; |
59 | 59 |
60 public: | 60 public: |
61 log_single_window_handle_only_if_IE( ImmediateSession & session, ProcessCloser
& pc ) | 61 log_single_window_handle_only_if_IE( ImmediateSession & session, ProcessCloser
& pc ) |
62 : session( session ), pc( pc ) | 62 : session( session ), pc( pc ) |
63 { | 63 { |
64 } | 64 } |
65 | 65 |
66 bool operator()( HWND window ) | 66 bool operator()( HWND window ) |
67 { | 67 { |
68 DWORD pid = creator_process( window ) ; | 68 DWORD pid = CreatorProcess( window ) ; |
69 if ( pc.contains( pid ) ) | 69 if ( pc.Contains( pid ) ) |
70 { | 70 { |
71 std::stringstream s ; | 71 std::stringstream s ; |
72 s << "Window handle 0x" << std::hex << window ; | 72 s << "Window handle 0x" << std::hex << window ; |
73 session.Log( s.str() ) ; | 73 session.Log( s.str() ) ; |
74 } | 74 } |
75 return true ; | 75 return true ; |
76 } | 76 } |
77 } ; | 77 } ; |
78 | 78 |
79 void log_IE_window_handles( ImmediateSession & session ) | 79 void log_IE_window_handles( ImmediateSession & session ) |
80 { | 80 { |
81 session.Log( "log_IE_window_handles" ) ; | 81 session.Log( "log_IE_window_handles" ) ; |
82 const wchar_t * IE_names[] = { L"IExplore.exe", L"AdblockPlusEngine.exe" } ; | 82 const wchar_t * IE_names[] = { L"IExplore.exe", L"AdblockPlusEngine.exe" } ; |
83 ProcessSnapshot snapshot ; | 83 ProcessSnapshot snapshot ; |
84 ProcessCloser iec(snapshot, IE_names) ; | 84 ProcessCloser iec(snapshot, IE_names) ; |
85 log_single_window_handle_only_if_IE lp( session, iec ) ; | 85 log_single_window_handle_only_if_IE lp( session, iec ) ; |
86 enumerate_windows( lp ) ; | 86 EnumerateWindows( lp ) ; |
87 } | 87 } |
88 | 88 |
89 //------------------------------------------------------- | 89 //------------------------------------------------------- |
90 // log_only_window_handle_in_closer | 90 // log_only_window_handle_in_closer |
91 //------------------------------------------------------- | 91 //------------------------------------------------------- |
92 void log_only_window_handle_in_closer( ImmediateSession & session ) | 92 void log_only_window_handle_in_closer( ImmediateSession & session ) |
93 { | 93 { |
94 session.Log( "log_only_window_handle_in_closer" ) ; | 94 session.Log( "log_only_window_handle_in_closer" ) ; |
95 const wchar_t * IE_names[] = { L"IExplore.exe", L"AdblockPlusEngine.exe" } ; | 95 const wchar_t * IE_names[] = { L"IExplore.exe", L"AdblockPlusEngine.exe" } ; |
96 ProcessSnapshot snapshot ; | 96 ProcessSnapshot snapshot ; |
97 ProcessCloser iec( snapshot, IE_names) ; | 97 ProcessCloser iec( snapshot, IE_names) ; |
98 iec.iterate_our_windows( log_single_window_handle( session ) ) ; | 98 iec.IterateOurWindows( log_single_window_handle( session ) ) ; |
99 } | 99 } |
100 | 100 |
101 //------------------------------------------------------- | 101 //------------------------------------------------------- |
102 // sandbox | 102 // sandbox |
103 //------------------------------------------------------- | 103 //------------------------------------------------------- |
104 /** | 104 /** |
105 * Exposed DLL entry point for custom action. | 105 * Exposed DLL entry point for custom action. |
106 * The function signature matches the calling convention used by Windows Install
er. | 106 * The function signature matches the calling convention used by Windows Install
er. |
107 | 107 |
108 * \param[in] session_handle | 108 * \param[in] session_handle |
(...skipping 22 matching lines...) Expand all Loading... |
131 } | 131 } |
132 catch( ... ) | 132 catch( ... ) |
133 { | 133 { |
134 session.LogNoexcept( "Caught an exception" ) ; | 134 session.LogNoexcept( "Caught an exception" ) ; |
135 return ERROR_INSTALL_FAILURE ; | 135 return ERROR_INSTALL_FAILURE ; |
136 } | 136 } |
137 | 137 |
138 return ERROR_SUCCESS ; | 138 return ERROR_SUCCESS ; |
139 } | 139 } |
140 | 140 |
OLD | NEW |