OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "util/test/scoped_temp_dir.h" | 21 #include "util/test/scoped_temp_dir.h" |
22 | 22 |
23 namespace crashpad { | 23 namespace crashpad { |
24 namespace test { | 24 namespace test { |
25 namespace { | 25 namespace { |
26 | 26 |
27 bool FileExistsAtPath(const base::FilePath& path) { | 27 bool FileExistsAtPath(const base::FilePath& path) { |
28 #if defined(OS_POSIX) | 28 #if defined(OS_POSIX) |
29 struct stat st; | 29 struct stat st; |
30 return lstat(path.value().c_str(), &st) == 0; | 30 return lstat(path.value().c_str(), &st) == 0; |
| 31 #elif defined(OS_WIN) |
| 32 struct _stat st; |
| 33 return _wstat(path.value().c_str(), &st); |
31 #else | 34 #else |
32 #error "Not implemented" | 35 #error "Not implemented" |
33 #endif | 36 #endif |
34 } | 37 } |
35 | 38 |
36 void CreateFile(const base::FilePath& path) { | 39 void CreateFile(const base::FilePath& path) { |
37 FileHandle handle = LoggingOpenFileForWrite(path, | 40 FileHandle handle = LoggingOpenFileForWrite(path, |
38 FileWriteMode::kCreateOrFail, | 41 FileWriteMode::kCreateOrFail, |
39 FilePermissions::kWorldReadable); | 42 FilePermissions::kWorldReadable); |
| 43 #if defined(OS_POSIX) |
40 ASSERT_GE(handle, 0); | 44 ASSERT_GE(handle, 0); |
| 45 #elif defined(OS_WIN) |
| 46 ASSERT_NE(handle, nullptr); |
| 47 #endif |
41 ASSERT_TRUE( | 48 ASSERT_TRUE( |
42 LoggingWriteFile(handle, path.value().c_str(), path.value().length())); | 49 LoggingWriteFile(handle, path.value().c_str(), path.value().length())); |
43 ASSERT_TRUE(LoggingCloseFile(handle)); | 50 ASSERT_TRUE(LoggingCloseFile(handle)); |
44 } | 51 } |
45 | 52 |
46 class CrashReportDatabaseTest : public testing::Test { | 53 class CrashReportDatabaseTest : public testing::Test { |
47 protected: | 54 protected: |
48 // testing::Test: | 55 // testing::Test: |
49 void SetUp() override { | 56 void SetUp() override { |
50 db_ = CrashReportDatabase::Initialize(path()); | 57 db_ = CrashReportDatabase::Initialize(path()); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 db()->GetReportForUploading(report.uuid, &upload_report_2)); | 418 db()->GetReportForUploading(report.uuid, &upload_report_2)); |
412 EXPECT_FALSE(upload_report_2); | 419 EXPECT_FALSE(upload_report_2); |
413 | 420 |
414 EXPECT_EQ(CrashReportDatabase::kNoError, | 421 EXPECT_EQ(CrashReportDatabase::kNoError, |
415 db()->RecordUploadAttempt(upload_report, true, "")); | 422 db()->RecordUploadAttempt(upload_report, true, "")); |
416 } | 423 } |
417 | 424 |
418 } // namespace | 425 } // namespace |
419 } // namespace test | 426 } // namespace test |
420 } // namespace crashpad | 427 } // namespace crashpad |
OLD | NEW |