Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: installer/src/installer-lib/test/test-installer-lib-sandbox.cpp

Issue 5219280069066752: Issue #1186 - Change names that appear in the custom action (Closed)
Left Patch Set: Created Oct. 15, 2014, 3:29 p.m.
Right Patch Set: Created Jan. 4, 2015, 7 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « installer/src/installer-lib/test/test-installer-lib-ca.def ('k') | installer/src/msi/adblockplusie.wxs » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 18 matching lines...) Expand all
29 public: 29 public:
30 log_single_window_handle( ImmediateSession & session ) 30 log_single_window_handle( ImmediateSession & session )
31 : session( session ) 31 : session( session )
32 { 32 {
33 } 33 }
34 34
35 bool operator()( HWND window ) 35 bool operator()( HWND window )
36 { 36 {
37 std::stringstream s ; 37 std::stringstream s ;
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 enumerate_windows( 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 = creator_process( 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 enumerate_windows( 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.iterate_our_windows( 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
109 * Windows installer session handle 109 * Windows installer session handle
110 * 110 *
111 * \return 111 * \return
112 * An integer interpreted as a custom action return value. 112 * An integer interpreted as a custom action return value.
113 * 113 *
114 * \sa 114 * \sa
115 * - MSDN [Custom Action Return Values](http://msdn.microsoft.com/en-us/librar y/aa368072%28v=vs.85%29.aspx) 115 * - MSDN [Custom Action Return Values](http://msdn.microsoft.com/en-us/librar y/aa368072%28v=vs.85%29.aspx)
116 */ 116 */
117 extern "C" UINT __stdcall 117 extern "C" UINT __stdcall
118 sandbox( MSIHANDLE session_handle ) 118 sandbox( MSIHANDLE session_handle )
119 { 119 {
120 ImmediateSession session( session_handle, "sandbox" ) ; 120 ImmediateSession session( session_handle, "sandbox" ) ;
121 121
122 try 122 try
123 { 123 {
124 session.log( "Sandbox timestamp " __TIMESTAMP__ ) ; 124 session.Log( "Sandbox timestamp " __TIMESTAMP__ ) ;
125 log_only_window_handle_in_closer( session ) ; 125 log_only_window_handle_in_closer( session ) ;
126 } 126 }
127 catch( std::exception & e ) 127 catch( std::exception & e )
128 { 128 {
129 session.LogNoexcept( "terminated by exception: " + std::string( e.what() ) ) ; 129 session.LogNoexcept( "terminated by exception: " + std::string( e.what() ) ) ;
130 return ERROR_INSTALL_FAILURE ; 130 return ERROR_INSTALL_FAILURE ;
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
LEFTRIGHT

Powered by Google App Engine
This is Rietveld