Index: util/test/thread_win.cc |
diff --git a/util/win/time_test.cc b/util/test/thread_win.cc |
similarity index 52% |
copy from util/win/time_test.cc |
copy to util/test/thread_win.cc |
index ad0771e38b7889ab92154490845a0c3aafe13782..797d9c23ccdfa438b4b512373a16e059bf0c5d67 100644 |
--- a/util/win/time_test.cc |
+++ b/util/test/thread_win.cc |
@@ -12,23 +12,34 @@ |
// See the License for the specific language governing permissions and |
// limitations under the License. |
-#include "util/win/time.h" |
+#include "util/test/thread.h" |
#include "gtest/gtest.h" |
+#include "util/test/errors.h" |
namespace crashpad { |
namespace test { |
-namespace { |
-TEST(Time, Reasonable) { |
- timeval t; |
- GetTimeOfDay(&t); |
- // Assume that time's time_t return is seconds from 1970. |
- time_t approx_now = time(nullptr); |
- EXPECT_GE(approx_now, t.tv_sec); |
- EXPECT_LT(approx_now - 100, t.tv_sec); |
+void Thread::Start() { |
+ ASSERT_FALSE(platform_thread_); |
+ platform_thread_ = |
+ CreateThread(nullptr, 0, ThreadEntryThunk, this, 0, nullptr); |
+ ASSERT_TRUE(platform_thread_) << ErrorMessage("CreateThread"); |
+} |
+ |
+void Thread::Join() { |
+ ASSERT_FALSE(platform_thread_); |
+ DWORD result = WaitForSingleObject(platform_thread_, INFINITE); |
+ EXPECT_EQ(WAIT_OBJECT_0, result) << ErrorMessage("WaitForSingleObject"); |
+ platform_thread_ = 0; |
+} |
+ |
+// static |
+DWORD WINAPI Thread::ThreadEntryThunk(void* argument) { |
+ Thread* self = reinterpret_cast<Thread*>(argument); |
+ self->ThreadMain(); |
+ return 0; |
} |
-} // namespace |
} // namespace test |
} // namespace crashpad |