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

Unified Diff: util/misc/uuid_test.cc

Issue 1004913004: win: Add UUID::InitializeFromSystemUUID() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 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 | « util/misc/uuid.cc ('k') | util/util.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/misc/uuid_test.cc
diff --git a/util/misc/uuid_test.cc b/util/misc/uuid_test.cc
index 01f3b6a5f73718d4352f3ab62dc8e15d662cf291..c0132f30a5ea678563fa6274cb4814fb3cf84ee0 100644
--- a/util/misc/uuid_test.cc
+++ b/util/misc/uuid_test.cc
@@ -20,7 +20,9 @@
#include "base/basictypes.h"
#include "base/format_macros.h"
+#include "base/scoped_generic.h"
#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
#include "gtest/gtest.h"
namespace crashpad {
@@ -204,6 +206,36 @@ TEST(UUID, FromString) {
EXPECT_EQ("5762c15d-50b5-4171-a2e9-7429c9ec6cab", uuid.ToString());
}
+#if defined(OS_WIN)
+
+TEST(UUID, FromSystem) {
+ ::GUID system_uuid;
+ ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid));
+
+ UUID uuid;
+ uuid.InitializeFromSystemUUID(&system_uuid);
+
+ RPC_WSTR system_string;
+ ASSERT_EQ(RPC_S_OK, UuidToString(&system_uuid, &system_string));
+
+ struct ScopedRpcStringFreeTraits {
+ static RPC_WSTR* InvalidValue() { return nullptr; }
+ static void Free(RPC_WSTR* rpc_string) {
+ EXPECT_EQ(RPC_S_OK, RpcStringFree(rpc_string));
+ }
+ };
+ using ScopedRpcString =
+ base::ScopedGeneric<RPC_WSTR*, ScopedRpcStringFreeTraits>;
+ ScopedRpcString scoped_system_string(&system_string);
+
+ std::string system_string_utf8 =
+ base::UTF16ToUTF8(reinterpret_cast<wchar_t*>(system_string));
+
+ EXPECT_EQ(system_string_utf8, uuid.ToString());
scottmg 2015/03/13 16:52:32 maybe just system_string == uuid.ToString16()? Or
+}
+
+#endif // OS_WIN
+
} // namespace
} // namespace test
} // namespace crashpad
« no previous file with comments | « util/misc/uuid.cc ('k') | util/util.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698