Stack sampler: extract some test utilities to a common place
This creates a common TestModule class from several similar ones
scattered around the code base. It also extracts operator== for
base::Frame
Bug: 1101399
Change-Id: Ibaf6ecc5c30d877837297b474c314a2613a68dc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3430263
Reviewed-by: Mike Wittman <wittman@chromium.org>
Reviewed-by: Siddhartha S <ssid@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/main@{#967388}
diff --git a/base/profiler/chrome_unwinder_android_v2_unittest.cc b/base/profiler/chrome_unwinder_android_v2_unittest.cc
index 8f14225..b76d5d9 100644
--- a/base/profiler/chrome_unwinder_android_v2_unittest.cc
+++ b/base/profiler/chrome_unwinder_android_v2_unittest.cc
@@ -5,6 +5,7 @@
#include "base/profiler/chrome_unwinder_android_v2.h"
#include "base/profiler/chrome_unwind_info_android.h"
+#include "base/profiler/stack_sampling_profiler_test_util.h"
#include "base/test/gtest_util.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -949,25 +950,6 @@
}
}
-class TestModule : public ModuleCache::Module {
- public:
- TestModule(uintptr_t base_address,
- size_t size,
- const std::string& build_id = "TestModule")
- : base_address_(base_address), size_(size), build_id_(build_id) {}
-
- uintptr_t GetBaseAddress() const override { return base_address_; }
- std::string GetId() const override { return build_id_; }
- FilePath GetDebugBasename() const override { return FilePath(); }
- size_t GetSize() const override { return size_; }
- bool IsNative() const override { return true; }
-
- private:
- const uintptr_t base_address_;
- const size_t size_;
- const std::string build_id_;
-};
-
// Utility function to add a single native module during test setup. Returns
// a pointer to the provided module.
const ModuleCache::Module* AddNativeModule(
@@ -990,10 +972,8 @@
make_span(page_table, 1ul),
};
- auto chrome_module =
- std::make_unique<TestModule>(0x1000, 0x500, "ChromeModule");
- auto non_chrome_module =
- std::make_unique<TestModule>(0x2000, 0x500, "OtherModule");
+ auto chrome_module = std::make_unique<TestModule>(0x1000, 0x500);
+ auto non_chrome_module = std::make_unique<TestModule>(0x2000, 0x500);
ModuleCache module_cache;
ChromeUnwinderAndroidV2 unwinder(dummy_unwind_info,