| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 class TestStream final : public internal::MinidumpStreamWriter { | 45 class TestStream final : public internal::MinidumpStreamWriter { |
| 46 public: | 46 public: |
| 47 TestStream(MinidumpStreamType stream_type, | 47 TestStream(MinidumpStreamType stream_type, |
| 48 size_t stream_size, | 48 size_t stream_size, |
| 49 uint8_t stream_value) | 49 uint8_t stream_value) |
| 50 : stream_data_(stream_size, stream_value), stream_type_(stream_type) {} | 50 : stream_data_(stream_size, stream_value), stream_type_(stream_type) {} |
| 51 | 51 |
| 52 ~TestStream() {} | 52 ~TestStream() {} |
| 53 | 53 |
| 54 // MinidumpStreamWriter: | 54 // MinidumpStreamWriter: |
| 55 virtual MinidumpStreamType StreamType() const override { | 55 MinidumpStreamType StreamType() const override { |
| 56 return stream_type_; | 56 return stream_type_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 // MinidumpWritable: | 60 // MinidumpWritable: |
| 61 virtual size_t SizeOfObject() override { | 61 size_t SizeOfObject() override { |
| 62 EXPECT_GE(state(), kStateFrozen); | 62 EXPECT_GE(state(), kStateFrozen); |
| 63 return stream_data_.size(); | 63 return stream_data_.size(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual bool WriteObject(FileWriterInterface* file_writer) override { | 66 bool WriteObject(FileWriterInterface* file_writer) override { |
| 67 EXPECT_EQ(state(), kStateWritable); | 67 EXPECT_EQ(state(), kStateWritable); |
| 68 return file_writer->Write(&stream_data_[0], stream_data_.size()); | 68 return file_writer->Write(&stream_data_[0], stream_data_.size()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 std::string stream_data_; | 72 std::string stream_data_; |
| 73 MinidumpStreamType stream_type_; | 73 MinidumpStreamType stream_type_; |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(TestStream); | 75 DISALLOW_COPY_AND_ASSIGN(TestStream); |
| 76 }; | 76 }; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 const size_t kStream2Size = 3; | 244 const size_t kStream2Size = 3; |
| 245 const MinidumpStreamType kStream2Type = static_cast<MinidumpStreamType>(0x4d); | 245 const MinidumpStreamType kStream2Type = static_cast<MinidumpStreamType>(0x4d); |
| 246 const uint8_t kStream2Value = 0xa5; | 246 const uint8_t kStream2Value = 0xa5; |
| 247 TestStream stream2(kStream2Type, kStream2Size, kStream2Value); | 247 TestStream stream2(kStream2Type, kStream2Size, kStream2Value); |
| 248 ASSERT_DEATH(minidump_file.AddStream(&stream2), "already present"); | 248 ASSERT_DEATH(minidump_file.AddStream(&stream2), "already present"); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // namespace | 251 } // namespace |
| 252 } // namespace test | 252 } // namespace test |
| 253 } // namespace crashpad | 253 } // namespace crashpad |
| OLD | NEW |