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

Unified Diff: util/win/process_info_test.cc

Issue 1422503015: win: Add HandleToInt() and IntToHandle() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 1 month 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
Index: util/win/process_info_test.cc
diff --git a/util/win/process_info_test.cc b/util/win/process_info_test.cc
index 0fc52a581fb0385161cd456af2ece47d2adfc364..a6f9dc1cebdc8b6068d5397576946212eae3d8de 100644
--- a/util/win/process_info_test.cc
+++ b/util/win/process_info_test.cc
@@ -33,6 +33,7 @@
#include "util/misc/uuid.h"
#include "util/win/command_line.h"
#include "util/win/get_function.h"
+#include "util/win/handle.h"
#include "util/win/scoped_handle.h"
namespace crashpad {
@@ -573,7 +574,8 @@ TEST(ProcessInfo, Handles) {
bool found_key_handle = false;
bool found_mapping_handle = false;
for (auto handle : info.Handles()) {
- if (reinterpret_cast<uint32_t>(file.get()) == handle.handle) {
+ const int handle_int = implicit_cast<int>(handle.handle);
+ if (handle_int == HandleToInt(file.get())) {
EXPECT_FALSE(found_file_handle);
found_file_handle = true;
EXPECT_EQ(L"File", handle.type_name);
@@ -583,7 +585,7 @@ TEST(ProcessInfo, Handles) {
handle.granted_access & STANDARD_RIGHTS_ALL);
EXPECT_EQ(0, handle.attributes);
}
- if (reinterpret_cast<uint32_t>(inherited_file.get()) == handle.handle) {
+ if (handle_int == HandleToInt(inherited_file.get())) {
EXPECT_FALSE(found_inherited_file_handle);
found_inherited_file_handle = true;
EXPECT_EQ(L"File", handle.type_name);
@@ -597,7 +599,7 @@ TEST(ProcessInfo, Handles) {
const int kObjInherit = 0x2;
EXPECT_EQ(kObjInherit, handle.attributes);
}
- if (reinterpret_cast<uint32_t>(scoped_key.get()) == handle.handle) {
+ if (handle_int == HandleToInt(scoped_key.get())) {
EXPECT_FALSE(found_key_handle);
found_key_handle = true;
EXPECT_EQ(L"Key", handle.type_name);
@@ -607,7 +609,7 @@ TEST(ProcessInfo, Handles) {
handle.granted_access & STANDARD_RIGHTS_ALL);
EXPECT_EQ(0, handle.attributes);
}
- if (reinterpret_cast<uint32_t>(mapping.get()) == handle.handle) {
+ if (handle_int == HandleToInt(mapping.get())) {
EXPECT_FALSE(found_mapping_handle);
found_mapping_handle = true;
EXPECT_EQ(L"Section", handle.type_name);
@@ -620,6 +622,7 @@ TEST(ProcessInfo, Handles) {
}
}
EXPECT_TRUE(found_file_handle);
+ EXPECT_TRUE(found_inherited_file_handle);
EXPECT_TRUE(found_key_handle);
EXPECT_TRUE(found_mapping_handle);
}

Powered by Google App Engine
This is Rietveld 408576698