1 // Copyright 2019 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "util/stream/test_output_stream.h"
16 #include "base/check.h"
17
18 namespace crashpad {
19 namespace test {
20
TestOutputStream()21 TestOutputStream::TestOutputStream()
22 : last_written_data_(),
23 all_data_(),
24 write_count_(0),
25 flush_count_(0),
26 flush_needed_(false) {}
27
~TestOutputStream()28 TestOutputStream::~TestOutputStream() {
29 DCHECK(!flush_needed_);
30 }
31
Write(const uint8_t * data,size_t size)32 bool TestOutputStream::Write(const uint8_t* data, size_t size) {
33 last_written_data_.assign(data, data + size);
34 all_data_.insert(all_data_.end(), data, data + size);
35
36 flush_needed_ = true;
37 write_count_++;
38 return true;
39 }
40
Flush()41 bool TestOutputStream::Flush() {
42 flush_needed_ = false;
43 flush_count_++;
44 return true;
45 }
46
47 } // namespace test
48 } // namespace crashpad
49