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

Unified Diff: snapshot/win/pe_image_annotations_reader_test.cc

Issue 1164453003: Refactor multiprocess test code to allow multiple child processes to be launched. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@multiprocess_test
Patch Set: Review comment. Created 5 years, 6 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 | « no previous file | snapshot/win/process_reader_win_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: snapshot/win/pe_image_annotations_reader_test.cc
diff --git a/snapshot/win/pe_image_annotations_reader_test.cc b/snapshot/win/pe_image_annotations_reader_test.cc
index d9365c2b83a5219abe45069a5ee8d45a77d20431..383ada99e01fddf69e54796f713492d01441d88f 100644
--- a/snapshot/win/pe_image_annotations_reader_test.cc
+++ b/snapshot/win/pe_image_annotations_reader_test.cc
@@ -36,19 +36,18 @@ namespace crashpad {
namespace test {
namespace {
-class TestPEImageAnnotationsReader final : public WinMultiprocess {
- public:
- enum TestType {
- // Don't crash, just test the CrashpadInfo interface.
- kDontCrash = 0,
+enum TestType {
+ // Don't crash, just test the CrashpadInfo interface.
+ kDontCrash = 0,
- // The child process should crash by __debugbreak().
- kCrashDebugBreak,
- };
-
- explicit TestPEImageAnnotationsReader(TestType test_type)
- : WinMultiprocess(), test_type_(test_type) {}
+ // The child process should crash by __debugbreak().
+ kCrashDebugBreak,
+};
+template <TestType Type>
+class TestPEImageAnnotationsReader final : public WinMultiprocess {
+ public:
+ TestPEImageAnnotationsReader() {}
~TestPEImageAnnotationsReader() {}
private:
@@ -87,7 +86,7 @@ class TestPEImageAnnotationsReader final : public WinMultiprocess {
EXPECT_EQ("shorter", all_annotations_simple_map["#TEST# longer"]);
EXPECT_EQ("", all_annotations_simple_map["#TEST# empty_value"]);
- if (test_type_ == kCrashDebugBreak)
+ if (Type == kCrashDebugBreak)
SetExpectedChildExitCode(STATUS_BREAKPOINT);
// Tell the child process to continue.
@@ -115,7 +114,7 @@ class TestPEImageAnnotationsReader final : public WinMultiprocess {
// Wait for the parent to indicate that it's safe to continue/crash.
CheckedReadFile(ReadPipeHandle(), &c, sizeof(c));
- switch (test_type_) {
+ switch (Type) {
case kDontCrash:
break;
@@ -125,21 +124,15 @@ class TestPEImageAnnotationsReader final : public WinMultiprocess {
}
}
- TestType test_type_;
-
DISALLOW_COPY_AND_ASSIGN(TestPEImageAnnotationsReader);
};
TEST(PEImageAnnotationsReader, DontCrash) {
- TestPEImageAnnotationsReader test_pe_image_annotations_reader(
- TestPEImageAnnotationsReader::kDontCrash);
- test_pe_image_annotations_reader.Run();
+ WinMultiprocess::Run<TestPEImageAnnotationsReader<kDontCrash>>();
}
TEST(PEImageAnnotationsReader, CrashDebugBreak) {
- TestPEImageAnnotationsReader test_pe_image_annotations_reader(
- TestPEImageAnnotationsReader::kCrashDebugBreak);
- test_pe_image_annotations_reader.Run();
+ WinMultiprocess::Run<TestPEImageAnnotationsReader<kCrashDebugBreak>>();
}
} // namespace
« no previous file with comments | « no previous file | snapshot/win/process_reader_win_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698