Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Unified Diff: base/process_util_unittest.cc

Issue 9121046: Cleanup in ProcessSingleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process_util.h ('k') | base/process_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_unittest.cc
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index c37de366426cded12d7419a7ba8b1bdbf3c1b68c..23f994065e58d7020090e1e6ef81f80585fcd919 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -184,6 +184,25 @@ TEST_F(ProcessUtilTest, GetProcId) {
EXPECT_NE(id1, id2);
base::CloseProcessHandle(handle);
}
+
+TEST_F(ProcessUtilTest, GetModuleFromAddress) {
+ // Since the unit tests are their own EXE, this should be
+ // equivalent to the EXE's HINSTANCE.
+ //
+ // kExpectedKilledExitCode is a constant in this file and
+ // therefore within the unit test EXE.
+ EXPECT_EQ(::GetModuleHandle(NULL),
+ base::GetModuleFromAddress(
+ const_cast<int*>(&kExpectedKilledExitCode)));
+
+ // Any address within the kernel32 module should return
+ // kernel32's HMODULE. Our only assumption here is that
+ // kernel32 is larger than 4 bytes.
+ HMODULE kernel32 = ::GetModuleHandle(L"kernel32.dll");
+ HMODULE kernel32_from_address =
+ base::GetModuleFromAddress(reinterpret_cast<DWORD*>(kernel32) + 1);
+ EXPECT_EQ(kernel32, kernel32_from_address);
+}
#endif
#if !defined(OS_MACOSX)
« no previous file with comments | « base/process_util.h ('k') | base/process_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698