| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 void LogAllWindowHandles(ImmediateSession& session) | 44 void LogAllWindowHandles(ImmediateSession& session) |
| 45 { | 45 { |
| 46 session.Log("LogAllWindowHandles"); | 46 session.Log("LogAllWindowHandles"); |
| 47 LogSingleWindowHandle lp(session); | 47 LogSingleWindowHandle lp(session); |
| 48 EnumerateWindows(lp); | 48 EnumerateWindows(lp); |
| 49 } | 49 } |
| 50 | 50 |
| 51 //------------------------------------------------------- | 51 //------------------------------------------------------- |
| 52 // LogIEWindowHandles | 52 // LogIeWindowHandles |
| 53 //------------------------------------------------------- | 53 //------------------------------------------------------- |
| 54 class LogSingleWindowHandleOnlyIfIE | 54 class LogSingleWindowHandleOnlyIfIe |
|
Oleksandr
2015/10/29 23:26:22
Nit: LogSingleWindowHandleOnlyIfIe
Eric
2015/11/14 18:01:07
Done.
| |
| 55 { | 55 { |
| 56 ImmediateSession& session; | 56 ImmediateSession& session; |
| 57 | 57 |
| 58 ProcessCloser& pc; | 58 ProcessCloser& pc; |
| 59 | 59 |
| 60 public: | 60 public: |
| 61 LogSingleWindowHandleOnlyIfIE(ImmediateSession& session, ProcessCloser& pc) | 61 LogSingleWindowHandleOnlyIfIe(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 = CreatorProcess(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 LogIEWindowHandles(ImmediateSession& session) | 79 void LogIeWindowHandles(ImmediateSession& session) |
| 80 { | 80 { |
| 81 session.Log("LogIEWindowHandles"); | 81 session.Log("LogIeWindowHandles"); |
| 82 const wchar_t* IENames[] = {L"IExplore.exe", L"AdblockPlusEngine.exe"}; | 82 const wchar_t* IeNames[] = {L"IExplore.exe", L"AdblockPlusEngine.exe"}; |
|
Oleksandr
2015/10/29 23:26:22
Nit: IeNames?
Eric
2015/11/14 18:01:07
Done.
| |
| 83 ProcessSnapshot snapshot; | 83 ProcessSnapshot snapshot; |
| 84 ProcessCloser iec(snapshot, IENames); | 84 ProcessCloser iec(snapshot, IeNames); |
| 85 LogSingleWindowHandleOnlyIfIE lp(session, iec); | 85 LogSingleWindowHandleOnlyIfIe lp(session, iec); |
| 86 EnumerateWindows(lp); | 86 EnumerateWindows(lp); |
| 87 } | 87 } |
| 88 | 88 |
| 89 //------------------------------------------------------- | 89 //------------------------------------------------------- |
| 90 // LogOnlyWindowHandleInCloser | 90 // LogOnlyWindowHandleInCloser |
| 91 //------------------------------------------------------- | 91 //------------------------------------------------------- |
| 92 void LogOnlyWindowHandleInCloser(ImmediateSession& session) | 92 void LogOnlyWindowHandleInCloser(ImmediateSession& session) |
| 93 { | 93 { |
| 94 session.Log("LogOnlyWindowHandleInCloser"); | 94 session.Log("LogOnlyWindowHandleInCloser"); |
| 95 const wchar_t* IENames[] = {L"IExplore.exe", L"AdblockPlusEngine.exe"}; | 95 const wchar_t* IeNames[] = {L"IExplore.exe", L"AdblockPlusEngine.exe"}; |
| 96 ProcessSnapshot snapshot; | 96 ProcessSnapshot snapshot; |
| 97 ProcessCloser iec(snapshot, IENames); | 97 ProcessCloser iec(snapshot, IeNames); |
| 98 iec.IterateOurWindows(LogSingleWindowHandle(session)); | 98 iec.IterateOurWindows(LogSingleWindowHandle(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 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 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 } |
| LEFT | RIGHT |