Simplify test set-up

Use platform independent helpers to simplify initializing a
ProcessMemory object in this test.

Bug: crashpad:263
Change-Id: Id0f9e006f6dbaca31453803b8c790a6832e855e5
Reviewed-on: https://chromium-review.googlesource.com/c/1387264
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
This commit is contained in:
Vlad Tsyrklevich 2018-12-20 09:03:05 -08:00 committed by Commit Bot
parent bf6d2e0283
commit 7018a80b36

View File

@ -20,18 +20,8 @@
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "util/misc/from_pointer_cast.h"
#if defined(OS_FUCHSIA)
#include <lib/zx/process.h>
#include "util/process/process_memory_fuchsia.h"
#elif defined(OS_WIN)
#include "util/process/process_memory_win.h"
#else
#include <unistd.h>
#include "util/process/process_memory_linux.h"
#endif
#include "util/process/process_memory_native.h"
#include "test/process_type.h"
namespace crashpad {
namespace test {
@ -49,16 +39,8 @@ TEST(ProcessMemoryRange, Basic) {
constexpr bool is_64_bit = false;
#endif // ARCH_CPU_64_BITS
#if defined(OS_FUCHSIA)
ProcessMemoryFuchsia memory;
ASSERT_TRUE(memory.Initialize(*zx::process::self()));
#elif defined(OS_WIN)
ProcessMemoryWin memory;
ASSERT_TRUE(memory.Initialize(GetCurrentProcess()));
#elif defined(OS_LINUX) || defined(OS_ANDROID)
ProcessMemoryLinux memory;
ASSERT_TRUE(memory.Initialize(getpid()));
#endif // OS_FUCHSIA
ProcessMemoryNative memory;
ASSERT_TRUE(memory.Initialize(GetSelfProcess()));
ProcessMemoryRange range;
ASSERT_TRUE(range.Initialize(&memory, is_64_bit));